index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  1. <template>
  2. <div class="pageIndexClass">
  3. <div class="content">
  4. <byTable :source="sourceList.data" :pagination="sourceList.pagination" :config="config" :loading="loading" :selectConfig="selectConfig"
  5. highlight-current-row @get-list="getList">
  6. <template #businessType="{ item }">
  7. <div style="width: 100%">
  8. <span :class="item.businessType==4||item.businessType==5?'tag-active':''">
  9. {{ dictValueLabel(item.businessType, businessType) }}</span>
  10. </div>
  11. </template>
  12. <template #expand="{item}">
  13. <div style="width:100%;padding:0 50px">
  14. <el-table :data="item.stockWaitDetailsList" class="bom-table" border>
  15. <el-table-column label="物品图片" width="100" align="center">
  16. <template #default="{ row }">
  17. <div v-if="row.fileUrl">
  18. <img :src="row.fileUrl" class="pic" @click="openImg(row.fileUrl)" />
  19. </div>
  20. </template>
  21. </el-table-column>
  22. <el-table-column prop="productCode" label="物品编码" width="200" />
  23. <el-table-column prop="productName" label="物品名称" min-width="130" />
  24. <el-table-column label="尺寸 (cm)" width="140">
  25. <template #default="{ row, $index }">
  26. <div style="width: 100%">
  27. {{row.productLength}} * {{row.productWidth}} * {{row.productHeight}}
  28. </div>
  29. </template>
  30. </el-table-column>
  31. <el-table-column label="需出库数量" prop="quantity" width="100" />
  32. <el-table-column label="待出库数量" prop="waitQuantity" width="100" />
  33. <el-table-column label="已出库数量" prop="receiptQuantity" width="100" />
  34. </el-table>
  35. </div>
  36. </template>
  37. </byTable>
  38. </div>
  39. <el-dialog title="出库" v-if="dialogVisible" v-model="dialogVisible" width="1200">
  40. <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit" v-loading="loadingDialog">
  41. <template #detail>
  42. <div style="width:100%">
  43. <div style="width:100%;padding:0 15px">
  44. <el-table :data="formData.data.stockWaitDetailsList">
  45. <el-table-column label="物品图片" width="80">
  46. <template #default="{ row }">
  47. <div v-if="row.fileUrl">
  48. <img :src="row.fileUrl" class="pic" @click="openImg(row.fileUrl)" />
  49. </div>
  50. </template>
  51. </el-table-column>
  52. <el-table-column prop="productCode" label="物品编码" width="160" />
  53. <el-table-column prop="productName" label="物品名称" min-width="130" />
  54. <el-table-column label="尺寸 (cm)" width="140">
  55. <template #default="{ row, $index }">
  56. <div style="width: 100%">
  57. {{row.productLength}} * {{row.productWidth}} * {{row.productHeight}}
  58. </div>
  59. </template>
  60. </el-table-column>
  61. <el-table-column label="可用库存" prop="availableQuantity" width="100" />
  62. <el-table-column label="需出库数量" prop="needQuantity" width="100" />
  63. <el-table-column label="待出库数量" prop="waitQuantity" width="100" />
  64. <el-table-column label="已出库数量" prop="receiptQuantity" width="100" />
  65. <el-table-column prop="quantity" label="出库数量" width="130">
  66. <template #default="{ row, $index }">
  67. <el-form-item :prop="'stockWaitDetailsList.' + $index + '.quantity'" :rules="rules.quantity" :inline-message="true"
  68. class="margin-b-0">
  69. <el-input-number onmousewheel="return false;" v-model="row.quantity" placeholder="请输入" style="width: 100%" :precision="0"
  70. :controls="false" :min="0" />
  71. </el-form-item>
  72. </template>
  73. </el-table-column>
  74. </el-table>
  75. </div>
  76. </div>
  77. </template>
  78. </byForm>
  79. <template #footer>
  80. <el-button @click="dialogVisible = false" size="default">取 消</el-button>
  81. <el-button type="primary" @click="submitForm()" size="default">确 定</el-button>
  82. </template>
  83. </el-dialog>
  84. </div>
  85. </template>
  86. <script setup>
  87. import { computed, ref } from "vue";
  88. import byTable from "@/components/byTable/index";
  89. import byForm from "@/components/byForm/index";
  90. import { ElMessage } from "element-plus";
  91. const { proxy } = getCurrentInstance();
  92. const warehouseList = ref([]);
  93. const productType = ref([]);
  94. const materialUnitData = computed(
  95. () => proxy.useUserStore().allDict["material_unit"]
  96. );
  97. const status = ref([
  98. {
  99. label: "待出库",
  100. value: 0,
  101. },
  102. {
  103. label: "部分出库",
  104. value: 1,
  105. },
  106. {
  107. label: "出库完成",
  108. value: 2,
  109. },
  110. ]);
  111. const businessType = ref([
  112. {
  113. label: "生产打样",
  114. value: "0",
  115. },
  116. {
  117. label: "生产超领",
  118. value: "1",
  119. },
  120. {
  121. label: "销售出库",
  122. value: "2",
  123. },
  124. {
  125. label: "借用出库",
  126. value: "3",
  127. },
  128. {
  129. label: "报损超领",
  130. value: "4",
  131. },
  132. {
  133. label: "丢件超领",
  134. value: "5",
  135. },
  136. {
  137. label: "采购退货",
  138. value: "6",
  139. },
  140. {
  141. label: "调拨出库",
  142. value: "7",
  143. },
  144. {
  145. label: "盘亏出库",
  146. value: "8",
  147. },
  148. {
  149. label: "生产出库",
  150. value: "9",
  151. },
  152. ]);
  153. const sourceList = ref({
  154. data: [],
  155. pagination: {
  156. total: 0,
  157. pageNum: 1,
  158. pageSize: 10,
  159. keyword: "",
  160. status: "",
  161. type: 2,
  162. },
  163. });
  164. const loading = ref(false);
  165. const selectConfig = computed(() => {
  166. return [
  167. {
  168. label: "业务公司",
  169. prop: "companyId",
  170. data: proxy.useUserStore().allDict["list_company_data"],
  171. },
  172. {
  173. label: "出库状态",
  174. prop: "status",
  175. data: status.value,
  176. },
  177. {
  178. label: "数据来源",
  179. prop: "businessType",
  180. data: businessType.value,
  181. },
  182. ];
  183. });
  184. const config = computed(() => {
  185. return [
  186. {
  187. type: "expand",
  188. attrs: {
  189. slot: "expand",
  190. width: 50,
  191. align: "center",
  192. },
  193. },
  194. {
  195. attrs: {
  196. label: "业务公司",
  197. prop: "companyName",
  198. width: 110,
  199. },
  200. },
  201. {
  202. attrs: {
  203. label: "数据来源",
  204. prop: "businessType",
  205. slot: "businessType",
  206. // width: 120,
  207. },
  208. // render(type) {
  209. // return proxy.dictValueLabel(type, businessType.value);
  210. // },
  211. },
  212. {
  213. attrs: {
  214. label: "单号",
  215. prop: "businessCode",
  216. // width: 160,
  217. },
  218. },
  219. // {
  220. // attrs: {
  221. // label: "物品类型",
  222. // prop: "productType",
  223. // width: 120,
  224. // },
  225. // render(type) {
  226. // return proxy.dictValueLabel(type, productType.value);
  227. // },
  228. // },
  229. // {
  230. // attrs: {
  231. // label: "图片",
  232. // slot: "pic",
  233. // align: "center",
  234. // width: 80,
  235. // },
  236. // },
  237. // {
  238. // attrs: {
  239. // label: "物品编码",
  240. // prop: "productCustomCode",
  241. // width: 140,
  242. // },
  243. // },
  244. // {
  245. // attrs: {
  246. // label: "物品名称",
  247. // prop: "productName",
  248. // "min-width": 200,
  249. // },
  250. // },
  251. // {
  252. // attrs: {
  253. // label: "规格型号",
  254. // prop: "productSpec",
  255. // width: 140,
  256. // },
  257. // },
  258. // {
  259. // attrs: {
  260. // label: "单位",
  261. // prop: "productUnit",
  262. // width: 120,
  263. // },
  264. // render(unit) {
  265. // return proxy.dictKeyValue(unit, materialUnitData.value);
  266. // },
  267. // },
  268. // {
  269. // attrs: {
  270. // label: "待出库数量",
  271. // prop: "quantity",
  272. // width: 120,
  273. // },
  274. // },
  275. {
  276. attrs: {
  277. label: "出库状态",
  278. prop: "status",
  279. // width: 140,
  280. },
  281. render(type) {
  282. return proxy.dictValueLabel(type, status.value);
  283. },
  284. },
  285. {
  286. attrs: {
  287. label: "创建时间",
  288. prop: "createTime",
  289. // width: 160,
  290. },
  291. },
  292. {
  293. attrs: {
  294. label: "操作",
  295. width: "80",
  296. align: "center",
  297. },
  298. renderHTML(row) {
  299. return [
  300. row.status !== 2
  301. ? {
  302. attrs: {
  303. label: "出库",
  304. type: "primary",
  305. text: true,
  306. },
  307. el: "button",
  308. click() {
  309. clickOperation(row);
  310. },
  311. }
  312. : {},
  313. ];
  314. },
  315. },
  316. ];
  317. });
  318. const getDict = () => {
  319. proxy.post("/warehouse/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  320. if (res.rows && res.rows.length > 0) {
  321. warehouseList.value = res.rows.map((item) => {
  322. return {
  323. label: item.name,
  324. value: item.id,
  325. };
  326. });
  327. }
  328. });
  329. };
  330. const getList = async (req) => {
  331. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  332. loading.value = true;
  333. proxy.post("/stockWait/page", sourceList.value.pagination).then((res) => {
  334. sourceList.value.data = res.rows;
  335. let productIds = [];
  336. for (let i = 0; i < res.rows.length; i++) {
  337. for (let j = 0; j < res.rows[i].stockWaitDetailsList.length; j++) {
  338. let ele = res.rows[i].stockWaitDetailsList[j];
  339. ele.waitQuantity = Number(ele.quantity) - Number(ele.receiptQuantity);
  340. productIds.push(ele.productId);
  341. }
  342. }
  343. if (productIds && productIds.length > 0) {
  344. proxy
  345. .getFileData({
  346. businessIdList: Array.from(new Set(productIds)),
  347. getAll: true,
  348. })
  349. .then((res) => {
  350. for (let i = 0; i < sourceList.value.data.length; i++) {
  351. for (
  352. let j = 0;
  353. j < sourceList.value.data[i].stockWaitDetailsList.length;
  354. j++
  355. ) {
  356. let ele = sourceList.value.data[i].stockWaitDetailsList[j];
  357. for (const key in res) {
  358. if (ele.productId == key && res[key]) {
  359. let list = res[key].filter((x) => x.businessType == "0");
  360. ele.fileUrl = list && list.length > 0 ? list[0].fileUrl : "";
  361. break;
  362. }
  363. }
  364. }
  365. }
  366. });
  367. }
  368. sourceList.value.pagination.total = res.total;
  369. setTimeout(() => {
  370. loading.value = false;
  371. }, 200);
  372. });
  373. };
  374. getDict();
  375. getList();
  376. const dialogVisible = ref(false);
  377. const loadingDialog = ref(false);
  378. const submit = ref(null);
  379. const formOption = reactive({
  380. inline: true,
  381. labelWidth: 100,
  382. itemWidth: 100,
  383. rules: [],
  384. });
  385. const formData = reactive({
  386. data: {},
  387. });
  388. const formConfig = computed(() => {
  389. return [
  390. {
  391. type: "title1",
  392. title: "待出库信息",
  393. },
  394. {
  395. type: "select",
  396. prop: "businessType",
  397. label: "数据来源",
  398. disabled: true,
  399. data: businessType.value,
  400. itemWidth: 50,
  401. },
  402. {
  403. type: "input",
  404. prop: "businessCode",
  405. label: "单号",
  406. itemType: "text",
  407. disabled: true,
  408. itemWidth: 50,
  409. },
  410. {
  411. type: "treeSelect",
  412. prop: "companyId",
  413. label: "业务公司",
  414. data: proxy.useUserStore().allDict["tree_company_data"],
  415. propsTreeLabel: "deptName",
  416. propsTreeValue: "deptId",
  417. itemWidth: 50,
  418. disabled: true,
  419. },
  420. {
  421. type: "select",
  422. prop: "warehouseId",
  423. label: "仓库名称",
  424. required: true,
  425. data: warehouseList.value,
  426. itemWidth: 50,
  427. },
  428. {
  429. type: "upload",
  430. listType: "text",
  431. accept: "",
  432. prop: "fileList",
  433. label: "上传凭证",
  434. itemWidth: 100,
  435. required: true,
  436. },
  437. {
  438. type: "title1",
  439. title: "出库明细",
  440. },
  441. {
  442. type: "slot",
  443. slotName: "detail",
  444. label: "",
  445. },
  446. ];
  447. });
  448. const rules = ref({
  449. companyId: [{ required: true, message: "请选择业务公司", trigger: "change" }],
  450. warehouseId: [{ required: true, message: "请选择仓库", trigger: "change" }],
  451. quantity: [{ required: true, message: "请输入出库数量", trigger: "blur" }],
  452. fileList: [
  453. { required: true, message: "请上传凭证", trigger: ["blur", "change"] },
  454. ],
  455. });
  456. const submitForm = () => {
  457. submit.value.handleSubmit(() => {
  458. if (!(formData.data.fileList && formData.data.fileList.length > 0)) {
  459. return proxy.msgTip("请上传附件", 2);
  460. }
  461. for (let i = 0; i < formData.data.stockWaitDetailsList.length; i++) {
  462. const ele = formData.data.stockWaitDetailsList[i];
  463. if (Number(ele.quantity) > Number(ele.waitQuantity)) {
  464. return proxy.msgTip("出库数量不可大于待出库数量", 2);
  465. }
  466. }
  467. loadingDialog.value = true;
  468. proxy.post("/stockWait/add", formData.data).then(
  469. () => {
  470. proxy.msgTip("提交成功", 1);
  471. dialogVisible.value = false;
  472. getList();
  473. },
  474. (err) => {
  475. loadingDialog.value = false;
  476. }
  477. );
  478. });
  479. };
  480. const clickOperation = (row) => {
  481. formData.data = {
  482. id: row.id,
  483. companyId: row.companyId,
  484. businessType: row.businessType + "",
  485. businessCode: row.businessCode,
  486. warehouseId: "",
  487. stockWaitDetailsList: row.stockWaitDetailsList.map((x) => ({
  488. ...x,
  489. availableQuantity: x.availableQuantity || 0,
  490. needQuantity: x.quantity,
  491. quantity: null,
  492. })),
  493. fileList: [],
  494. };
  495. loadingDialog.value = false;
  496. dialogVisible.value = true;
  497. };
  498. </script>
  499. <style lang="scss" scoped>
  500. .tenant {
  501. padding: 20px;
  502. }
  503. ::v-deep(.el-input-number .el-input__inner) {
  504. text-align: left;
  505. }
  506. :deep(.bom-table .el-table__body-wrapper .el-table__body .el-table__row) {
  507. background: #f4f4f5 !important;
  508. }
  509. </style>