InRequestForm.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. <template>
  2. <div class="app-container">
  3. <!-- 对话框(添加 / 修改) -->
  4. <el-dialog
  5. v-dialogDrag
  6. :title="dialogTitle"
  7. :visible.sync="dialogVisible"
  8. width="75%"
  9. append-to-body
  10. >
  11. <el-form
  12. ref="formRef"
  13. v-loading="formLoading"
  14. :model="formData"
  15. :rules="formRules"
  16. label-width="150px"
  17. >
  18. <el-col :span="12"
  19. ><el-form-item label="业务类型" prop="businessType">
  20. <el-select
  21. v-model="formData.businessType"
  22. placeholder="请选择业务类型"
  23. @change="changeBusinessType"
  24. >
  25. <el-option
  26. v-for="dict in getDictDatas('in_business_type')"
  27. :key="dict.value"
  28. :label="dict.label"
  29. :value="dict.value"
  30. />
  31. </el-select> </el-form-item
  32. ></el-col>
  33. <el-col :span="12"
  34. ><el-form-item label="业务分类名称" prop="businessDescribe">
  35. <el-select
  36. v-model="formData.businessDescribe"
  37. :disabled="formData.businessType ? false : true"
  38. placeholder="请选择业务类型"
  39. @change="changeBusinessDescribe"
  40. >
  41. <el-option
  42. v-for="dict in businessDescribeList"
  43. :key="dict.label"
  44. :label="dict.label"
  45. :value="dict.label"
  46. />
  47. </el-select> </el-form-item
  48. ></el-col>
  49. <el-col :span="12"
  50. ><el-form-item label="优先级" prop="priority">
  51. <el-select
  52. v-model="formData.priority"
  53. :disabled="formData.businessType ? false : true"
  54. placeholder="请选择优先级"
  55. >
  56. <el-option
  57. v-for="dict in getDictDatas('priority')"
  58. :key="dict.value"
  59. :label="dict.label"
  60. :value="dict.value"
  61. />
  62. </el-select>
  63. </el-form-item>
  64. </el-col>
  65. <el-col :span="12">
  66. <el-form-item label="供应商编码" prop="supplierCode">
  67. <el-input
  68. v-model="formData.supplierCode"
  69. :disabled="formData.businessType ? false : true"
  70. placeholder="请输入供应商编码"
  71. />
  72. </el-form-item>
  73. </el-col>
  74. <el-col :span="12">
  75. <el-form-item label="客户编码" prop="customerCode">
  76. <el-input
  77. v-model="formData.customerCode"
  78. :disabled="formData.businessType ? false : true"
  79. placeholder="请输入客户编码"
  80. />
  81. </el-form-item>
  82. </el-col>
  83. <el-col :span="12">
  84. <el-form-item label="源单编号" prop="sourceOrderNo">
  85. <el-select
  86. v-model="formData.sourceOrderNo"
  87. filterable
  88. remote
  89. :disabled="formData.businessType ? false : true"
  90. reserve-keyword
  91. placeholder="请输入源单编号"
  92. :remote-method="remoteMethod"
  93. :loading="loading"
  94. @change="changeSourceOrderNo"
  95. >
  96. <el-option
  97. v-for="item in sourceOrderNoList"
  98. :key="item.sourceOrderNo"
  99. :label="item.sourceOrderNo"
  100. :value="item.sourceOrderNo"
  101. />
  102. </el-select>
  103. </el-form-item>
  104. </el-col>
  105. <el-col :span="12">
  106. <el-form-item label="预计出入库时间" prop="expectedTime">
  107. <el-date-picker
  108. v-model="formData.expectedTime"
  109. :disabled="formData.businessType ? false : true"
  110. clearable
  111. type="date"
  112. value-format="timestamp"
  113. placeholder="选择预计出入库时间"
  114. /> </el-form-item
  115. ></el-col>
  116. <el-col :span="12">
  117. <el-form-item label="实际出入库时间" prop="actualTime">
  118. <el-date-picker
  119. v-model="formData.actualTime"
  120. clearable
  121. :disabled="formData.businessType ? false : true"
  122. type="date"
  123. value-format="timestamp"
  124. placeholder="选择实际出入库时间"
  125. /> </el-form-item
  126. ></el-col>
  127. <el-col :span="12">
  128. <el-form-item label="备注" prop="remark">
  129. <el-input
  130. v-model="formData.remark"
  131. :disabled="formData.businessType ? false : true"
  132. placeholder="请输入备注"
  133. /> </el-form-item
  134. ></el-col>
  135. <el-col :span="12">
  136. <el-form-item label="存储地点" prop="warehouseId">
  137. <el-select
  138. v-model="formData.warehouseId"
  139. filterable
  140. remote
  141. :disabled="formData.businessType ? false : true"
  142. reserve-keyword
  143. placeholder="请输入存储地点"
  144. :remote-method="remoteWarehouse"
  145. :loading="loading"
  146. >
  147. <el-option
  148. v-for="item in warehouseList"
  149. :key="item.erpId"
  150. :label="item.name"
  151. :value="item.erpId"
  152. />
  153. </el-select>
  154. </el-form-item>
  155. </el-col>
  156. </el-form>
  157. <el-button
  158. type="primary"
  159. size="mini"
  160. style="margin-bottom: 10px"
  161. @click="add()"
  162. >新增明细</el-button
  163. >
  164. <el-table :data="formData.list" border size="mini">
  165. <el-table-column
  166. label="源单编号"
  167. align="center"
  168. prop="sourceRequestId"
  169. width="160"
  170. show-overflow-tooltip
  171. />
  172. <el-table-column
  173. label="源单行号"
  174. align="center"
  175. prop="sourceLineNo"
  176. width="160"
  177. show-overflow-tooltip
  178. />
  179. <el-table-column
  180. label="物料编码"
  181. align="center"
  182. prop="materialNo"
  183. width="160"
  184. show-overflow-tooltip
  185. />
  186. <el-table-column
  187. label="物料名称"
  188. align="center"
  189. prop="materialName"
  190. width="150"
  191. show-overflow-tooltip
  192. >
  193. <template v-slot="scope">
  194. <el-select
  195. v-model="scope.row.materialName"
  196. filterable
  197. remote
  198. reserve-keyword
  199. placeholder="请选择物料名称"
  200. :remote-method="remoteMaterialName"
  201. :loading="loading"
  202. @change="changeMaterialName"
  203. >
  204. <el-option
  205. v-for="item in materialNameList"
  206. :key="item.code"
  207. :label="item.name"
  208. :value="item.code + '-' + scope.$index"
  209. />
  210. </el-select>
  211. </template>
  212. </el-table-column>
  213. <el-table-column
  214. label="客户编码"
  215. align="center"
  216. prop="customerCode"
  217. width="150"
  218. show-overflow-tooltip
  219. />
  220. <el-table-column
  221. label="客户名称"
  222. align="center"
  223. prop="customerName"
  224. width="160"
  225. show-overflow-tooltip
  226. />
  227. <el-table-column
  228. label="本次出货数量"
  229. align="center"
  230. prop="nowDeliveredQty"
  231. >
  232. <template slot-scope="scope">
  233. <el-input
  234. v-model="scope.row.nowDeliveredQty"
  235. @change="deliverChange"
  236. />
  237. </template>
  238. </el-table-column>
  239. <el-table-column
  240. label="已出货数量"
  241. align="center"
  242. prop="deliveredQty"
  243. width="120"
  244. />
  245. <el-table-column
  246. label="应出货数量"
  247. align="center"
  248. prop="shouldDeliveredQty"
  249. width="120"
  250. />
  251. <el-table-column
  252. label="申请数量"
  253. align="center"
  254. prop="requireQty"
  255. width="120"
  256. />
  257. <el-table-column
  258. label="单位"
  259. align="center"
  260. prop="unitName"
  261. width="150"
  262. show-overflow-tooltip
  263. />
  264. <el-table-column label="行备注" align="center" prop="remark">
  265. <template slot-scope="scope">
  266. <el-input v-model="scope.row.remark" />
  267. </template>
  268. </el-table-column>
  269. <el-table-column
  270. label="操作"
  271. align="center"
  272. fixed="right"
  273. width="150px"
  274. class-name="small-padding fixed-width"
  275. >
  276. <template v-slot="scope">
  277. <el-button
  278. size="mini"
  279. type="text"
  280. icon="el-icon-delete"
  281. @click="handleDelete(scope)"
  282. >删除</el-button
  283. >
  284. </template>
  285. </el-table-column>
  286. </el-table>
  287. <div slot="footer" class="dialog-footer">
  288. <el-button type="primary" :disabled="formLoading" @click="submitForm"
  289. >确 定</el-button
  290. >
  291. <el-button @click="dialogVisible = false">取 消</el-button>
  292. </div>
  293. </el-dialog>
  294. </div>
  295. </template>
  296. <script>
  297. import * as InRequestApi from "@/api/wms/output/inrequest";
  298. // import ShipmentNotification from "./ShipmentNotification.vue";
  299. export default {
  300. name: "InRequestForm",
  301. components: {
  302. // ShipmentNotification,
  303. },
  304. data() {
  305. return {
  306. materialNameList: [],
  307. sourceOrderNoList: [],
  308. businessDescribeList: [],
  309. warehouseList: [],
  310. loading: false,
  311. // 弹出层标题
  312. dialogTitle: "",
  313. // 是否显示弹出层
  314. dialogVisible: false,
  315. // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
  316. formLoading: false,
  317. // 表单参数
  318. formData: {
  319. id: undefined,
  320. requestNo: undefined,
  321. requestType: undefined,
  322. businessType: undefined,
  323. businessCategory: undefined,
  324. businessDescribe: undefined,
  325. businessSubType: undefined,
  326. status: undefined,
  327. priority: undefined,
  328. warehouseId: undefined,
  329. relatedWarehouseId: undefined,
  330. supplierCode: undefined,
  331. customerCode: undefined,
  332. sourceOrderNo: undefined,
  333. expectedTime: undefined,
  334. actualTime: undefined,
  335. totalQty: undefined,
  336. totalSku: undefined,
  337. totalLine: undefined,
  338. remark: undefined,
  339. extendInfo: undefined,
  340. submitter: undefined,
  341. submitTime: undefined,
  342. auditor: undefined,
  343. auditTime: undefined,
  344. erpWriteFlag: undefined,
  345. erpErrMsg: undefined,
  346. erpBackId: undefined,
  347. list: [],
  348. },
  349. // 表单校验
  350. formRules: {
  351. requestNo: [
  352. { required: true, message: "申请单号不能为空", trigger: "blur" },
  353. ],
  354. requestType: [
  355. {
  356. required: true,
  357. message: "申请类型(0入库 1出库)不能为空",
  358. trigger: "change",
  359. },
  360. ],
  361. businessType: [
  362. {
  363. required: true,
  364. message:
  365. "业务类型(0采购入库 3生产退料 4成品入库 6销售退货 8委外退料 9委外入库 11其他入库 13转移调拨 14仓库盘点)不能为空",
  366. trigger: "change",
  367. },
  368. ],
  369. businessSubType: [
  370. {
  371. required: true,
  372. message: "业务子类型(0正常 1补料)不能为空",
  373. trigger: "change",
  374. },
  375. ],
  376. status: [
  377. {
  378. required: true,
  379. message:
  380. "状态(0草稿 1已提交 2已审核 3执行中 4已完成 5已取消)不能为空",
  381. trigger: "blur",
  382. },
  383. ],
  384. priority: [
  385. {
  386. required: true,
  387. message: "优先级(0普通 1紧急 2加急)不能为空",
  388. trigger: "blur",
  389. },
  390. ],
  391. },
  392. };
  393. },
  394. methods: {
  395. handleDelete(row) {
  396. console.log(row);
  397. this.formData.list.splice(row.$index, 1);
  398. },
  399. remoteMaterialName(query) {
  400. if (query !== "") {
  401. const that = this;
  402. this.loading = true;
  403. setTimeout(async () => {
  404. this.loading = false;
  405. const {
  406. data: { list },
  407. } = await InRequestApi.getMaterialPage({
  408. name: query,
  409. pageSize: 999,
  410. });
  411. this.materialNameList = list || [];
  412. }, 200);
  413. } else {
  414. this.materialNameList = [];
  415. }
  416. },
  417. remoteMethod(query) {
  418. if (query !== "") {
  419. const that = this;
  420. this.loading = true;
  421. setTimeout(async () => {
  422. this.loading = false;
  423. const { data } = await InRequestApi.getSourceOrder({
  424. businessType: that.formData.businessType,
  425. sourceOrderNo: query,
  426. pageSize: 999,
  427. });
  428. this.sourceOrderNoList = data || [];
  429. }, 200);
  430. } else {
  431. this.sourceOrderNoList = [];
  432. }
  433. },
  434. add() {
  435. if (!this.formData.businessType) {
  436. return this.$message.error("请先选择业务类型");
  437. }
  438. this.formData.list = this.formData.list || [];
  439. this.formData.list.push({});
  440. this.formData = { ...this.formData };
  441. },
  442. remoteWarehouse(query) {
  443. if (query !== "") {
  444. const that = this;
  445. this.loading = true;
  446. setTimeout(async () => {
  447. this.loading = false;
  448. const {
  449. data: { list },
  450. } = await InRequestApi.getStockPage({
  451. name: query,
  452. pageSize: 999,
  453. });
  454. this.warehouseList = list || [];
  455. }, 200);
  456. } else {
  457. this.warehouseList = [];
  458. }
  459. },
  460. changeSourceOrderNo(value) {
  461. this.sourceOrderNoList.map((v) => {
  462. if (v.sourceOrderNo == value) {
  463. this.formData.list = v.list;
  464. }
  465. });
  466. },
  467. changeMaterialName(value) {
  468. const data = value.split("-");
  469. this.materialNameList.map((v) => {
  470. if (v.code == data[0]) {
  471. v.materialNo = v.code;
  472. v.materialName = v.name;
  473. this.formData.list[data[1]] = v;
  474. }
  475. });
  476. },
  477. changeBusinessDescribe(e) {
  478. this.businessDescribeList.map((v) => {
  479. if (v.label == e) {
  480. this.formData.businessCategory = v.value;
  481. }
  482. });
  483. },
  484. async changeBusinessType(value) {
  485. this.formData = {
  486. id: this.formData.id,
  487. businessType: this.formData.businessType,
  488. };
  489. this.formData = { ...this.formData };
  490. const { data } = await InRequestApi.getDictByOrderType({
  491. orderType: this.formData.businessType,
  492. });
  493. this.businessDescribeList = data;
  494. },
  495. /** 打开弹窗 */
  496. async open(id) {
  497. this.dialogVisible = true;
  498. this.reset();
  499. // 修改时,设置数据
  500. if (id) {
  501. this.formLoading = true;
  502. try {
  503. const res = await InRequestApi.getRequest(id);
  504. res.data.businessType = res.data.businessType
  505. ? res.data.businessType.toString()
  506. : "0";
  507. res.data.businessDescribe = res.data.businessDescribe
  508. ? res.data.businessDescribe.toString()
  509. : "";
  510. res.data.priority = res.data.priority
  511. ? res.data.priority.toString()
  512. : "0";
  513. this.formData = res.data;
  514. this.dialogTitle = "修改";
  515. } finally {
  516. this.formLoading = false;
  517. }
  518. }
  519. this.dialogTitle = "新增";
  520. },
  521. /** 提交按钮 */
  522. async submitForm() {
  523. // 校验主表
  524. await this.$refs["formRef"].validate();
  525. this.formLoading = true;
  526. try {
  527. // this.$refs.shipmentNotification.open = true;
  528. const data = this.formData;
  529. data.list = data.list
  530. .filter((v) => v.nowDeliveredQty)
  531. .map(
  532. ({
  533. completedQty,
  534. actualQty,
  535. stock_code,
  536. area_code,
  537. location_code,
  538. status,
  539. lineNo,
  540. inventory_status,
  541. ...rest
  542. }) => rest
  543. );
  544. // let arr = [];
  545. // data.list.filter((v) => {
  546. // if (v.nowDeliveredQty) {
  547. // arr.push(v);
  548. // }
  549. // });
  550. // data.list = arr;
  551. // 修改的提交;
  552. if (data.id) {
  553. await InRequestApi.updateRequest(data);
  554. this.$modal.msgSuccess("修改成功");
  555. this.dialogVisible = false;
  556. this.$emit("success");
  557. return;
  558. }
  559. // 添加的提交
  560. await InRequestApi.createRequest(data);
  561. this.$modal.msgSuccess("新增成功");
  562. this.dialogVisible = false;
  563. this.$emit("success");
  564. } finally {
  565. this.formLoading = false;
  566. }
  567. },
  568. /** 表单重置 */
  569. reset() {
  570. this.formData = {
  571. id: undefined,
  572. requestNo: undefined,
  573. requestType: undefined,
  574. businessType: undefined,
  575. businessCategory: undefined,
  576. businessDescribe: undefined,
  577. businessSubType: undefined,
  578. status: undefined,
  579. priority: undefined,
  580. warehouseId: undefined,
  581. relatedWarehouseId: undefined,
  582. supplierCode: undefined,
  583. customerCode: undefined,
  584. sourceOrderNo: undefined,
  585. expectedTime: undefined,
  586. actualTime: undefined,
  587. totalQty: undefined,
  588. totalSku: undefined,
  589. totalLine: undefined,
  590. remark: undefined,
  591. extendInfo: undefined,
  592. submitter: undefined,
  593. submitTime: undefined,
  594. auditor: undefined,
  595. auditTime: undefined,
  596. erpWriteFlag: undefined,
  597. erpErrMsg: undefined,
  598. erpBackId: undefined,
  599. };
  600. this.resetForm("formRef");
  601. },
  602. },
  603. };
  604. </script>