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