index.vue 11 KB

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