index.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. <template>
  2. <div>
  3. <el-card class="box-card">
  4. <el-tabs v-model="activeName" type="card" @tab-change="changeActiveName">
  5. <el-tab-pane label="入库单" name="first">
  6. <byTable
  7. :source="sourceList.data"
  8. :pagination="sourceList.pagination"
  9. :config="config"
  10. :loading="loading"
  11. :searchConfig="searchConfig"
  12. highlight-current-row
  13. :action-list="[
  14. {
  15. text: '入库登记',
  16. action: () => clickModal(),
  17. },
  18. ]"
  19. @get-list="getList"
  20. @clickReset="clickReset">
  21. <template #code="{ item }">
  22. <div>
  23. <a style="color: #409eff; cursor: pointer; word-break: break-all" @click="clickCode(item)">{{ item.code }}</a>
  24. </div>
  25. </template>
  26. </byTable>
  27. </el-tab-pane>
  28. <el-tab-pane label="入库明细" name="second">
  29. <byTable
  30. :source="sourceListTwo.data"
  31. :pagination="sourceListTwo.pagination"
  32. :config="configTwo"
  33. :loading="loading"
  34. :searchConfig="searchConfigTwo"
  35. highlight-current-row
  36. :action-list="[
  37. {
  38. text: '入库登记',
  39. action: () => clickModal(),
  40. },
  41. {
  42. text: '导出Excel',
  43. action: () => deriveExcel(),
  44. },
  45. ]"
  46. @get-list="getListTwo"
  47. @clickReset="clickResetTwo">
  48. </byTable>
  49. </el-tab-pane>
  50. </el-tabs>
  51. </el-card>
  52. </div>
  53. </template>
  54. <script setup>
  55. import byTable from "/src/components/byTable/index";
  56. import { ElMessageBox } from "element-plus";
  57. const { proxy } = getCurrentInstance();
  58. const activeName = ref("first");
  59. const departmentList = ref([{ dictKey: "0", dictValue: "胜德体育" }]);
  60. const warehouseList = ref([]);
  61. const sourceList = ref({
  62. data: [],
  63. pagination: {
  64. total: 0,
  65. pageNum: 1,
  66. pageSize: 10,
  67. type: "1",
  68. code: "",
  69. departmentId: "",
  70. warehouseName: "",
  71. detailType: "",
  72. beginTime: "",
  73. endTime: "",
  74. },
  75. });
  76. const sourceListTwo = ref({
  77. data: [],
  78. pagination: {
  79. total: 0,
  80. pageNum: 1,
  81. pageSize: 10,
  82. type: "1",
  83. code: "",
  84. purchaseCode: "",
  85. bomSpecCode: "",
  86. bomSpecName: "",
  87. departmentId: "",
  88. warehouseName: "",
  89. detailType: "",
  90. beginTime: "",
  91. endTime: "",
  92. },
  93. });
  94. const loading = ref(false);
  95. const searchConfig = computed(() => {
  96. return [
  97. {
  98. type: "input",
  99. prop: "code",
  100. label: "入库单号",
  101. },
  102. {
  103. type: "select",
  104. prop: "departmentId",
  105. data: departmentList.value,
  106. label: "事业部",
  107. },
  108. {
  109. type: "select",
  110. prop: "warehouseId",
  111. data: warehouseList.value,
  112. label: "仓库",
  113. },
  114. {
  115. type: "select",
  116. prop: "detailType",
  117. dictKey: "put_stock_type",
  118. label: "入库类型",
  119. },
  120. {
  121. type: "date",
  122. propList: ["beginTime", "endTime"],
  123. label: "日期",
  124. },
  125. ];
  126. });
  127. const searchConfigTwo = computed(() => {
  128. return [
  129. {
  130. type: "input",
  131. prop: "purchaseCode",
  132. label: "采购单号",
  133. },
  134. {
  135. type: "input",
  136. prop: "code",
  137. label: "入库单号",
  138. },
  139. {
  140. type: "input",
  141. prop: "bomSpecCode",
  142. label: "品号",
  143. },
  144. {
  145. type: "input",
  146. prop: "bomSpecName",
  147. label: "品名",
  148. },
  149. {
  150. type: "select",
  151. prop: "departmentId",
  152. data: departmentList.value,
  153. label: "事业部",
  154. },
  155. {
  156. type: "select",
  157. prop: "warehouseId",
  158. data: warehouseList.value,
  159. label: "仓库",
  160. },
  161. {
  162. type: "select",
  163. prop: "detailType",
  164. dictKey: "put_stock_type",
  165. label: "入库类型",
  166. },
  167. {
  168. type: "date",
  169. propList: ["beginTime", "endTime"],
  170. label: "日期",
  171. },
  172. ];
  173. });
  174. const config = computed(() => {
  175. return [
  176. {
  177. attrs: {
  178. label: "入库单号",
  179. slot: "code",
  180. "min-width": 160,
  181. },
  182. },
  183. {
  184. attrs: {
  185. label: "采购单号",
  186. prop: "purchaseCode",
  187. "min-width": 160,
  188. },
  189. },
  190. {
  191. attrs: {
  192. label: "归属事业部",
  193. prop: "departmentName",
  194. "min-width": 160,
  195. },
  196. },
  197. {
  198. attrs: {
  199. label: "仓库类型",
  200. prop: "warehouseType",
  201. width: 140,
  202. },
  203. render(val) {
  204. return proxy.dictKeyValue(val, proxy.useUserStore().allDict["warehouse_type"]);
  205. },
  206. },
  207. {
  208. attrs: {
  209. label: "仓库名称",
  210. prop: "warehouseName",
  211. "min-width": 160,
  212. },
  213. },
  214. {
  215. attrs: {
  216. label: "入库类型",
  217. prop: "detailType",
  218. width: 140,
  219. },
  220. render(val) {
  221. return proxy.dictKeyValue(val, proxy.useUserStore().allDict["put_stock_type"]);
  222. },
  223. },
  224. {
  225. attrs: {
  226. label: "入库时间",
  227. prop: "createTime",
  228. width: 160,
  229. align: "center",
  230. },
  231. },
  232. {
  233. attrs: {
  234. label: "入库申请人",
  235. prop: "applicant",
  236. width: 160,
  237. align: "center",
  238. },
  239. },
  240. ];
  241. });
  242. const configTwo = computed(() => {
  243. return [
  244. {
  245. attrs: {
  246. label: "入库单号",
  247. prop: "code",
  248. width: 160,
  249. },
  250. },
  251. {
  252. attrs: {
  253. label: "采购单号",
  254. prop: "purchaseCode",
  255. width: 160,
  256. },
  257. },
  258. {
  259. attrs: {
  260. label: "归属事业部",
  261. prop: "departmentName",
  262. width: 100,
  263. },
  264. },
  265. {
  266. attrs: {
  267. label: "仓库类型",
  268. prop: "warehouseType",
  269. width: 100,
  270. },
  271. render(val) {
  272. return proxy.dictKeyValue(val, proxy.useUserStore().allDict["warehouse_type"]);
  273. },
  274. },
  275. {
  276. attrs: {
  277. label: "仓库名称",
  278. prop: "warehouseName",
  279. width: 120,
  280. },
  281. },
  282. {
  283. attrs: {
  284. label: "入库类型",
  285. prop: "detailType",
  286. width: 100,
  287. },
  288. render(val) {
  289. return proxy.dictKeyValue(val, proxy.useUserStore().allDict["put_stock_type"]);
  290. },
  291. },
  292. {
  293. attrs: {
  294. label: "品号",
  295. prop: "bomSpecCode",
  296. width: 140,
  297. },
  298. },
  299. {
  300. attrs: {
  301. label: "品名",
  302. prop: "bomSpecName",
  303. "min-width": 240,
  304. },
  305. },
  306. {
  307. attrs: {
  308. label: "数量",
  309. prop: "quantity",
  310. width: 80,
  311. },
  312. },
  313. {
  314. attrs: {
  315. label: "备注",
  316. prop: "remark",
  317. width: 180,
  318. },
  319. },
  320. {
  321. attrs: {
  322. label: "入库时间",
  323. prop: "createTime",
  324. width: 160,
  325. align: "center",
  326. },
  327. },
  328. {
  329. attrs: {
  330. label: "入库申请人",
  331. prop: "applicant",
  332. width: 150,
  333. align: "center",
  334. },
  335. },
  336. ];
  337. });
  338. const getList = async (req, status) => {
  339. if (status) {
  340. sourceList.value.pagination = {
  341. pageNum: sourceList.value.pagination.pageNum,
  342. pageSize: sourceList.value.pagination.pageSize,
  343. };
  344. } else {
  345. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  346. }
  347. loading.value = true;
  348. proxy.post("/inOutStorage/page", sourceList.value.pagination).then((res) => {
  349. sourceList.value.data = res.rows;
  350. sourceList.value.pagination.total = res.total;
  351. setTimeout(() => {
  352. loading.value = false;
  353. }, 200);
  354. });
  355. };
  356. getList();
  357. const clickReset = () => {
  358. getList("", true);
  359. };
  360. const getListTwo = async (req, status) => {
  361. if (status) {
  362. sourceListTwo.value.pagination = {
  363. pageNum: sourceListTwo.value.pagination.pageNum,
  364. pageSize: sourceListTwo.value.pagination.pageSize,
  365. };
  366. } else {
  367. sourceListTwo.value.pagination = { ...sourceListTwo.value.pagination, ...req };
  368. }
  369. loading.value = true;
  370. proxy.post("/inOutStorageBom/page", sourceListTwo.value.pagination).then((res) => {
  371. sourceListTwo.value.data = res.rows;
  372. sourceListTwo.value.pagination.total = res.total;
  373. setTimeout(() => {
  374. loading.value = false;
  375. }, 200);
  376. });
  377. };
  378. const clickResetTwo = () => {
  379. getListTwo("", true);
  380. };
  381. const changeActiveName = (val) => {
  382. if (val === "first") {
  383. getList();
  384. } else {
  385. getListTwo();
  386. }
  387. };
  388. const getDemandData = () => {
  389. proxy.post("/department/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  390. if (res.rows && res.rows.length > 0) {
  391. departmentList.value = departmentList.value.concat(
  392. res.rows.map((item) => {
  393. return {
  394. dictKey: item.id,
  395. dictValue: item.name,
  396. };
  397. })
  398. );
  399. }
  400. });
  401. proxy.post("/warehouse/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  402. if (res.rows && res.rows.length > 0) {
  403. warehouseList.value = res.rows.map((item) => {
  404. return {
  405. dictKey: item.id,
  406. dictValue: item.name,
  407. };
  408. });
  409. }
  410. });
  411. };
  412. getDemandData();
  413. const clickCode = (row) => {
  414. sourceListTwo.value.pagination.code = row.code;
  415. activeName.value = "second";
  416. };
  417. const clickModal = () => {
  418. proxy.$router.replace({
  419. path: "/putInStorage/add",
  420. query: {
  421. random: proxy.random(),
  422. },
  423. });
  424. };
  425. const deriveExcel = () => {
  426. ElMessageBox.confirm("你是否确认此操作", "提示", {
  427. confirmButtonText: "确定",
  428. cancelButtonText: "取消",
  429. type: "warning",
  430. })
  431. .then(() => {
  432. proxy.postFile("/inOutStorageBom/exportExcel", sourceListTwo.value.pagination).then((res) => {
  433. proxy.downloadFile(res, "入库明细.xlsx");
  434. });
  435. })
  436. .catch(() => {});
  437. };
  438. </script>
  439. <style lang="scss" scoped>
  440. ::v-deep(.el-input-number .el-input__inner) {
  441. text-align: left;
  442. }
  443. </style>