index.vue 10 KB

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