From 753361f589444455fe1b20476c658201ccd92c38 Mon Sep 17 00:00:00 2001 From: helongyang <647556386@qq.com> Date: 星期三, 30 七月 2025 09:53:19 +0800 Subject: [PATCH] 更新优化 --- 代码管理/WMS/WIDESEA_WMSClient/src/extension/outbound/extend/AddErpProScrapSheet.vue | 139 ++++++++++++++++++++++++++------------------- 1 files changed, 80 insertions(+), 59 deletions(-) diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSClient/src/extension/outbound/extend/AddErpProScrapSheet.vue" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSClient/src/extension/outbound/extend/AddErpProScrapSheet.vue" index b379641..99be825 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSClient/src/extension/outbound/extend/AddErpProScrapSheet.vue" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSClient/src/extension/outbound/extend/AddErpProScrapSheet.vue" @@ -61,8 +61,7 @@ <el-col :span="6"> <el-form-item required - :prop="'detailList.' + index + '.scrapProCode'" - :rules="{ required: true, message: '璇烽�夋嫨浜у搧缂栫爜', trigger: 'blur' }" + label="浜у搧缂栫爜锛�" > <el-select v-model="detail.scrapProCode" @@ -73,8 +72,8 @@ style="width: 100%;" > <el-option - v-for="(code, index) in proCodeOptions" - :key="index" + v-for="(code, idx) in proCodeOptions" + :key="idx" :label="code" :value="code" ></el-option> @@ -85,8 +84,7 @@ <el-col :span="5"> <el-form-item required - :prop="'detailList.' + index + '.scrapProVersion'" - :rules="{ required: true, message: '璇烽�夋嫨鐗堟湰', trigger: 'blur' }" + label="鐗堟湰锛�" > <el-select v-model="detail.scrapProVersion" @@ -108,8 +106,7 @@ <el-col :span="5"> <el-form-item required - :prop="'detailList.' + index + '.scrapProLotNo'" - :rules="{ required: true, message: '璇烽�夋嫨鎵规鍙�', trigger: 'blur' }" + label="鎵规鍙凤細" > <el-select v-model="detail.scrapProLotNo" @@ -131,13 +128,7 @@ <el-col :span="4"> <el-form-item required - :prop="'detailList.' + index + '.scrapPcsQty'" - :rules="{ - required: true, - message: '璇疯緭鍏CS鏁伴噺', - trigger: 'blur', - validator: validateNumber // 鑷畾涔夋暟瀛楁牎楠� - }" + label="PCS鏁伴噺锛�" > <el-input v-model="detail.scrapPcsQty" @@ -193,20 +184,6 @@ export default { components: { VolBox }, data() { - const validateNumber = (rule, value, callback) => { - if (!value) { - return callback(new Error('璇疯緭鍏ユ暟閲�')); - } - const numberRegex = /^\d+(\.\d+)?$/; - if (!numberRegex.test(value)) { - return callback(new Error('璇疯緭鍏ユ湁鏁堢殑鏁板瓧')); - } - if (parseFloat(value) <= 0) { - return callback(new Error('鏁伴噺蹇呴』澶т簬0')); - } - callback(); - }; - return { showDetialBox: false, warehouses: [], @@ -215,7 +192,6 @@ warehouseId: "", proScrapSheetOrderNo: "" }, - detailList: [ { scrapProCode: "", @@ -226,8 +202,7 @@ versionOptions: [], lotNoOptions: [] } - ], - validateNumber + ] }; }, methods: { @@ -243,6 +218,7 @@ warehouseId: "", proScrapSheetOrderNo: "" }; + this.proCodeOptions = []; // 娓呯┖浜у搧缂栫爜鍒楄〃 this.detailList = [this.createEmptyDetail()]; // 鍔犺浇浠撳簱鍒楄〃 @@ -281,10 +257,13 @@ // 浠撳簱鍙樻洿浜嬩欢 handleWarehouseChange(warehouseId) { - if (!warehouseId) return; + if (!warehouseId) { + this.proCodeOptions = []; // 浠撳簱涓虹┖鏃舵竻绌轰骇鍝佺紪鐮佸垪琛� + return; + } // 鏍规嵁浠撳簱ID鍔犺浇浜у搧缂栫爜鍒楄〃 this.http - .post(`api/ProStockInfo/GetProCodeByWarehouse?warehouseId=${this.form.warehouseId}`,null, "鍔犺浇浜у搧鏁版嵁涓�") + .post(`api/ProStockInfo/GetProCodeByWarehouse?warehouseId=${warehouseId}`,null, "鍔犺浇浜у搧鏁版嵁涓�") .then((res) => { if (res.status) { this.proCodeOptions = [...new Set(res.data)]; @@ -296,9 +275,13 @@ // 浜у搧缂栫爜鍙樻洿浜嬩欢 handleProCodeChange(detail, index) { + // 娓呯┖鐗堟湰鍜屾壒娆″彿 + detail.versionOptions = []; + detail.lotNoOptions = []; + detail.scrapProVersion = ""; + detail.scrapProLotNo = ""; + if (!detail.scrapProCode) { - detail.versionOptions = []; - detail.lotNoOptions = []; return; } @@ -353,34 +336,57 @@ // 鎻愪氦琛ㄥ崟 submitForm() { - if (!this.form.warehouseId) { - return this.$message.error("璇烽�夋嫨鎵�灞炰粨搴�"); - } + // 鑷畾涔夐獙璇侀�昏緫 + let isValid = true; + let errorMessage = ''; - const invalidDetail = this.detailList.find(item => - !item.scrapProCode || !item.scrapProVersion || !item.scrapProLotNo || !item.scrapPcsQty || isNaN(parseFloat(item.scrapPcsQty))|| parseFloat(item.scrapPcsQty) <= 0 - ); - - if (invalidDetail) { - return this.$message.error("璇蜂负鎵�鏈夋槑缁嗚緭鍏ユ湁鏁堢殑鏁伴噺鍊硷紙澶т簬0鐨勬暟瀛楋級"); - } + // 楠岃瘉浠撳簱 + if (!this.form.warehouseId) { + isValid = false; + errorMessage = '璇烽�夋嫨鎵�灞炰粨搴�'; + } - const submitData = { - warehouseId: this.form.warehouseId, - details: this.detailList.map(item => ({ - scrapProCode: item.scrapProCode, - scrapProVersion: item.scrapProVersion, - scrapProLotNo: item.scrapProLotNo, - scrapPcsQty: parseFloat(item.scrapPcsQty), - remark: item.remark - })) - }; + // 楠岃瘉鏄庣粏 + if (isValid) { + const invalidDetail = this.detailList.find(item => + !item.scrapProCode || + !item.scrapProVersion || + !item.scrapProLotNo || + !item.scrapPcsQty || + isNaN(parseFloat(item.scrapPcsQty)) || + parseFloat(item.scrapPcsQty) <= 0 + ); + + if (invalidDetail) { + isValid = false; + errorMessage = '鎻愪氦鏁版嵁瀛樺湪绌哄�兼垨杈撳叆鏁伴噺涓嶅悎娉曪紝璇锋鏌ワ紒'; + } + } - this.http - .post("api/ErpProScrapSheet/Save", submitData, "鎻愪氦涓�") - .then((res) => { + // 鏍规嵁楠岃瘉缁撴灉澶勭悊 + if (!isValid) { + this.$message.error(errorMessage); + return; + } + + // 楠岃瘉閫氳繃锛屽噯澶囨彁浜ゆ暟鎹� + const submitData = { + warehouseId: this.form.warehouseId, + details: this.detailList.map(item => ({ + scrapProCode: item.scrapProCode, + scrapProVersion: item.scrapProVersion, + scrapProLotNo: item.scrapProLotNo, + scrapPcsQty: parseFloat(item.scrapPcsQty), + remark: item.remark + })) + }; + + this.http + .post("api/ErpProScrapSheet/Save", submitData, "鎻愪氦涓�") + .then((res) => { if (!res.status) return this.$message.error(res.message); this.$message.success("鎿嶄綔鎴愬姛"); + this.proCodeOptions = []; this.close(); this.$emit("parentCall", ($vue) => { $vue.refresh(); @@ -391,6 +397,8 @@ // 鍏抽棴寮圭獥 close() { this.showDetialBox = false; + // 娓呯┖浜у搧缂栫爜鍒楄〃 + this.proCodeOptions = []; } }, created() { @@ -441,4 +449,17 @@ ::-webkit-scrollbar-track { background-color: #f5f5f5; } + +/* 澧炲姞閫夋嫨妗嗙殑闀垮害 */ +.el-select { + width: 100% !important; + min-width: 150px !important; + padding-right:10px; +} +.el-input { +width: 100% !important; + min-width: 150px !important; + padding-right:10px; +} + </style> \ No newline at end of file -- Gitblit v1.9.3