InRequestForm.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  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. @change="changeBusinessType"
  23. placeholder="请选择业务类型"
  24. >
  25. <el-option
  26. v-for="dict in getDictDatas('inout_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-option>
  103. </el-select>
  104. </el-form-item>
  105. </el-col>
  106. <el-col :span="12">
  107. <el-form-item label="预计出入库时间" prop="expectedTime">
  108. <el-date-picker
  109. v-model="formData.expectedTime"
  110. :disabled="formData.businessType ? false : true"
  111. clearable
  112. type="date"
  113. value-format="timestamp"
  114. placeholder="选择预计出入库时间"
  115. /> </el-form-item
  116. ></el-col>
  117. <el-col :span="12">
  118. <el-form-item label="实际出入库时间" prop="actualTime">
  119. <el-date-picker
  120. v-model="formData.actualTime"
  121. clearable
  122. :disabled="formData.businessType ? false : true"
  123. type="date"
  124. value-format="timestamp"
  125. placeholder="选择实际出入库时间"
  126. /> </el-form-item
  127. ></el-col>
  128. <el-col :span="12">
  129. <el-form-item label="备注" prop="remark">
  130. <el-input
  131. v-model="formData.remark"
  132. :disabled="formData.businessType ? false : true"
  133. placeholder="请输入备注"
  134. /> </el-form-item
  135. ></el-col>
  136. </el-form>
  137. <el-table :data="formData.list" border size="mini">
  138. <el-table-column
  139. label="源单编号"
  140. align="center"
  141. prop="sourceRequestId"
  142. width="160"
  143. show-overflow-tooltip
  144. />
  145. <el-table-column
  146. label="物料编码"
  147. align="center"
  148. prop="materialNo"
  149. width="160"
  150. show-overflow-tooltip
  151. />
  152. <el-table-column
  153. label="物料名称"
  154. align="center"
  155. prop="materialName"
  156. width="150"
  157. show-overflow-tooltip
  158. />
  159. <el-table-column
  160. label="客户编码"
  161. align="center"
  162. prop="customerCode"
  163. width="150"
  164. show-overflow-tooltip
  165. />
  166. <el-table-column
  167. label="客户名称"
  168. align="center"
  169. prop="customerName"
  170. width="160"
  171. show-overflow-tooltip
  172. />
  173. <el-table-column
  174. label="本次出货数量"
  175. align="center"
  176. prop="nowDeliveredQty"
  177. >
  178. <template slot-scope="scope">
  179. <el-input
  180. v-model="scope.row.nowDeliveredQty"
  181. @change="deliverChange"
  182. />
  183. </template>
  184. </el-table-column>
  185. <el-table-column
  186. label="已出货数量"
  187. align="center"
  188. prop="deliveredQty"
  189. width="120"
  190. />
  191. <el-table-column
  192. label="应出货数量"
  193. align="center"
  194. prop="shouldDeliveredQty"
  195. width="120"
  196. />
  197. <el-table-column
  198. label="申请数量"
  199. align="center"
  200. prop="requireQty"
  201. width="120"
  202. />
  203. <el-table-column
  204. label="单位"
  205. align="center"
  206. prop="unitName"
  207. width="150"
  208. show-overflow-tooltip
  209. />
  210. <el-table-column label="行备注" align="center" prop="remark">
  211. <template slot-scope="scope">
  212. <el-input v-model="scope.row.remark" />
  213. </template>
  214. </el-table-column>
  215. </el-table>
  216. <div slot="footer" class="dialog-footer">
  217. <el-button type="primary" :disabled="formLoading" @click="submitForm"
  218. >确 定</el-button
  219. >
  220. <el-button @click="dialogVisible = false">取 消</el-button>
  221. </div>
  222. </el-dialog>
  223. </div>
  224. </template>
  225. <script>
  226. import * as InRequestApi from "@/api/wms/output/inrequest";
  227. // import ShipmentNotification from "./ShipmentNotification.vue";
  228. export default {
  229. name: "InRequestForm",
  230. components: {
  231. // ShipmentNotification,
  232. },
  233. data() {
  234. return {
  235. sourceOrderNoList: [],
  236. businessDescribeList: [],
  237. loading: false,
  238. // 弹出层标题
  239. dialogTitle: "",
  240. // 是否显示弹出层
  241. dialogVisible: false,
  242. // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
  243. formLoading: false,
  244. // 表单参数
  245. formData: {
  246. id: undefined,
  247. requestNo: undefined,
  248. requestType: undefined,
  249. businessType: undefined,
  250. businessCategory: undefined,
  251. businessDescribe: undefined,
  252. businessSubType: undefined,
  253. status: undefined,
  254. priority: undefined,
  255. warehouseId: undefined,
  256. relatedWarehouseId: undefined,
  257. supplierCode: undefined,
  258. customerCode: undefined,
  259. sourceOrderNo: undefined,
  260. expectedTime: undefined,
  261. actualTime: undefined,
  262. totalQty: undefined,
  263. totalSku: undefined,
  264. totalLine: undefined,
  265. remark: undefined,
  266. extendInfo: undefined,
  267. submitter: undefined,
  268. submitTime: undefined,
  269. auditor: undefined,
  270. auditTime: undefined,
  271. erpWriteFlag: undefined,
  272. erpErrMsg: undefined,
  273. erpBackId: undefined,
  274. list: [],
  275. },
  276. // 表单校验
  277. formRules: {
  278. requestNo: [
  279. { required: true, message: "申请单号不能为空", trigger: "blur" },
  280. ],
  281. requestType: [
  282. {
  283. required: true,
  284. message: "申请类型(0入库 1出库)不能为空",
  285. trigger: "change",
  286. },
  287. ],
  288. businessType: [
  289. {
  290. required: true,
  291. message:
  292. "业务类型(0采购入库 3生产退料 4成品入库 6销售退货 8委外退料 9委外入库 11其他入库 13转移调拨 14仓库盘点)不能为空",
  293. trigger: "change",
  294. },
  295. ],
  296. businessSubType: [
  297. {
  298. required: true,
  299. message: "业务子类型(0正常 1补料)不能为空",
  300. trigger: "change",
  301. },
  302. ],
  303. status: [
  304. {
  305. required: true,
  306. message:
  307. "状态(0草稿 1已提交 2已审核 3执行中 4已完成 5已取消)不能为空",
  308. trigger: "blur",
  309. },
  310. ],
  311. priority: [
  312. {
  313. required: true,
  314. message: "优先级(0普通 1紧急 2加急)不能为空",
  315. trigger: "blur",
  316. },
  317. ],
  318. },
  319. };
  320. },
  321. methods: {
  322. remoteMethod(query) {
  323. if (query !== "") {
  324. let that = this;
  325. this.loading = true;
  326. setTimeout(async () => {
  327. this.loading = false;
  328. let { data } = await InRequestApi.getSourceOrder({
  329. businessType: that.formData.businessType,
  330. sourceOrderNo: query,
  331. });
  332. this.sourceOrderNoList = data || [];
  333. }, 200);
  334. } else {
  335. this.sourceOrderNoList = [];
  336. }
  337. },
  338. changeSourceOrderNo(value) {
  339. this.sourceOrderNoList.map((v) => {
  340. if (v.sourceOrderNo == value) {
  341. this.formData.list = v.list;
  342. }
  343. });
  344. },
  345. changeBusinessDescribe(e) {
  346. this.businessDescribeList.map((v) => {
  347. if (v.label == e) {
  348. this.formData.businessCategory = v.value;
  349. }
  350. });
  351. },
  352. async changeBusinessType(value) {
  353. this.formData = {
  354. id: this.formData.id,
  355. businessType: this.formData.businessType,
  356. };
  357. this.formData = { ...this.formData };
  358. let { data } = await InRequestApi.getDictByOrderType({
  359. orderType: this.formData.businessType,
  360. });
  361. this.businessDescribeList = data;
  362. },
  363. /** 打开弹窗 */
  364. async open(id) {
  365. this.dialogVisible = true;
  366. this.reset();
  367. // 修改时,设置数据
  368. if (id) {
  369. this.formLoading = true;
  370. try {
  371. const res = await InRequestApi.getInRequest(id);
  372. res.data.businessType = res.data.businessType
  373. ? res.data.businessType.toString()
  374. : "0";
  375. res.data.businessDescribe = res.data.businessDescribe
  376. ? res.data.businessDescribe.toString()
  377. : "";
  378. res.data.priority = res.data.priority
  379. ? res.data.priority.toString()
  380. : "0";
  381. this.formData = res.data;
  382. this.dialogTitle = "修改";
  383. } finally {
  384. this.formLoading = false;
  385. }
  386. }
  387. this.dialogTitle = "新增";
  388. },
  389. /** 提交按钮 */
  390. async submitForm() {
  391. // 校验主表
  392. await this.$refs["formRef"].validate();
  393. this.formLoading = true;
  394. try {
  395. // this.$refs.shipmentNotification.open = true;
  396. const data = this.formData;
  397. let arr = [];
  398. data.list.filter((v) => {
  399. if (v.nowDeliveredQty) {
  400. arr.push(v);
  401. }
  402. });
  403. data.list = arr;
  404. // 修改的提交;
  405. if (data.id) {
  406. await InRequestApi.updateInRequest(data);
  407. this.$modal.msgSuccess("修改成功");
  408. this.dialogVisible = false;
  409. this.$emit("success");
  410. return;
  411. }
  412. // 添加的提交
  413. await InRequestApi.createInRequest(data);
  414. this.$modal.msgSuccess("新增成功");
  415. this.dialogVisible = false;
  416. this.$emit("success");
  417. } finally {
  418. this.formLoading = false;
  419. }
  420. },
  421. /** 表单重置 */
  422. reset() {
  423. this.formData = {
  424. id: undefined,
  425. requestNo: undefined,
  426. requestType: undefined,
  427. businessType: undefined,
  428. businessCategory: undefined,
  429. businessDescribe: undefined,
  430. businessSubType: undefined,
  431. status: undefined,
  432. priority: undefined,
  433. warehouseId: undefined,
  434. relatedWarehouseId: undefined,
  435. supplierCode: undefined,
  436. customerCode: undefined,
  437. sourceOrderNo: undefined,
  438. expectedTime: undefined,
  439. actualTime: undefined,
  440. totalQty: undefined,
  441. totalSku: undefined,
  442. totalLine: undefined,
  443. remark: undefined,
  444. extendInfo: undefined,
  445. submitter: undefined,
  446. submitTime: undefined,
  447. auditor: undefined,
  448. auditTime: undefined,
  449. erpWriteFlag: undefined,
  450. erpErrMsg: undefined,
  451. erpBackId: undefined,
  452. };
  453. this.resetForm("formRef");
  454. },
  455. },
  456. };
  457. </script>