From ba1a2f73f9ce33d175bea4060d217b9f7a08eeed Mon Sep 17 00:00:00 2001 From: hyingbo <1363390067@qq.com> Date: 星期四, 31 七月 2025 16:55:42 +0800 Subject: [PATCH] 工具报损-添加报损数量校验规则 --- src/views/tms/lossBound/modules/LossboundModal.vue | 134 ++++++++++++++++++++++++++++---------------- 1 files changed, 84 insertions(+), 50 deletions(-) diff --git a/src/views/tms/lossBound/modules/LossboundModal.vue b/src/views/tms/lossBound/modules/LossboundModal.vue index 62782be..7db180f 100644 --- a/src/views/tms/lossBound/modules/LossboundModal.vue +++ b/src/views/tms/lossBound/modules/LossboundModal.vue @@ -13,7 +13,7 @@ <a-row> <a-col :span="12"> <a-form-model-item label="鎶ユ崯鍗曞崟鍙�" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="orderCode"> - <a-input v-model="model.orderCode" placeholder="绯荤粺鑷姩鐢熸垚" :disabled="true"></a-input> + <j-input v-model="model.orderCode" placeholder="绯荤粺鑷姩鐢熸垚" :disabled="true"></j-input> </a-form-model-item> </a-col> <a-col :span="12"> @@ -28,7 +28,7 @@ <a-col :span="12"> <a-form-model-item label="鎶ユ崯鏃堕棿" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="lossTime"> - <j-date placeholder="璇烽�夋嫨鎶ユ崯鏃堕棿" date-format="YYYY-MM-DD HH:mm:ss" v-model="model.lossTime" + <j-date placeholder="璇烽�夋嫨鎶ユ崯鏃堕棿" :disabled="disableSubmit" date-format="YYYY-MM-DD HH:mm:ss" v-model="model.lossTime" style="width: 100%" /> </a-form-model-item> </a-col> @@ -66,7 +66,7 @@ <a-form-model-item v-if="addShow" label="瀹℃牳鏃堕棿" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="approvalDate"> - <j-date placeholder="璇烽�夋嫨瀹℃牳鏃堕棿" date-format="YYYY-MM-DD HH:mm:ss" v-model="model.approvalDate" + <j-date placeholder="璇烽�夋嫨瀹℃牳鏃堕棿" :disabled="disableSubmit" date-format="YYYY-MM-DD HH:mm:ss" v-model="model.approvalDate" style="width: 100%" /> </a-form-model-item> </a-col> @@ -89,14 +89,14 @@ <a-row> <a-col :span="12"> <a-form-model-item label="鎶ユ崯鍘熷洜" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="lossReason"> - <a-textarea :disabled="disableSubmit" v-model="model.lossReason" rows="4" placeholder="璇疯緭鍏ュ娉�" /> + <a-textarea :disabled="disableSubmit" v-model="model.lossReason" rows="4" placeholder="璇疯緭鍏ユ姤鎹熷師鍥�" /> </a-form-model-item> </a-col> </a-row> </a-form-model> </a-spin> - <a-button type="primary" :style="{ marginBottom: '8px' }" @click="selectTools"> + <a-button type="primary" :style="{ marginBottom: '8px' }" :disabled="disableSubmit" @click="selectTools"> 閫夋嫨宸ュ叿 </a-button> <a-table @@ -113,9 +113,20 @@ @change="handleTableChange"> <template v-for="col in columns" :slot="col.dataIndex" slot-scope="text, record, index"> - <a-input-number :disabled="disableSubmit" :value="text" v-if="col.dataIndex == 'lossNumber'" :min="0" - :max="99999" - @change="(e) => handleChange(e, record.key, col, index)" style="width: 100%;" /> + <div v-if="col.dataIndex == 'lossNumber'"> + <a-input-number + :disabled="disableSubmit" + :value="text" + :min="0" + :max="99999" + @change="(e) => handleChange(e, record.key, col, index)" + style="width: 100%;" + /> + <div v-if="record.lossNumberError" style="color: #f5222d; font-size: 12px; margin-top: 4px;"> + {{ record.lossNumberMsg }} + </div> + </div> + <a-textarea v-if="col.dataIndex == 'lossReason'" :disabled="disableSubmit" @@ -193,10 +204,10 @@ width: 50 }, { - title: '鍒�鍏风紪鍙�', - dataIndex: 'toolCode', + title: '鍒�鍏风紪鐮�', + dataIndex: 'toolId', align: 'center', - width: 150 + width: 200 }, { @@ -205,7 +216,22 @@ align: 'center', width: 150 }, + { + title: '鎶ユ崯鍘熷洜', + width: 150, + dataIndex: 'lossReason', + align: 'center', + scopedSlots: { customRender: 'lossReason' } + }, + { + title: '鎶ユ崯鏁伴噺', + dataIndex: 'lossNumber', + align: 'center', + width: 150, + scopedSlots: { customRender: 'lossNumber' }, + key: 'lossNumber' + }, { title: '涓枃鍚嶇О', dataIndex: 'chineseName', @@ -245,21 +271,7 @@ dataIndex: 'goodsShelvesId', align: 'center' }, - { - title: '鎶ユ崯鍘熷洜', - width: 150, - dataIndex: 'lossReason', - align: 'center', - scopedSlots: { customRender: 'lossReason' } - }, - { - title: '鎶ユ崯鏁伴噺', - dataIndex: 'lossNumber', - align: 'center', - width: 150, - scopedSlots: { customRender: 'lossNumber' } - }, { title: '澶囨敞', @@ -304,8 +316,8 @@ this.$bus.$on('selectionRows', (data) => { for (let i = 0; i < data.length; i++) { this.dataSource.push({ - toolId: data[i].id, - toolCode: data[i].toolCode, + toolCode:data[i].toolCode, + toolId:data[i].toolId, classifyId: data[i].classifyId, applicationType: data[i].applicationType_dictText, chineseName: data[i].chineseName, @@ -314,8 +326,10 @@ supplierId: data[i].supplierId, goodsShelvesId: data[i].positionCode, toolMaterial: data[i].toolMaterial, - partMaterial: data[i].partMaterial - + partMaterial: data[i].partMaterial, + lossNumber: null, // 鍒濆鍖栨姤鎹熸暟閲� + lossNumberError: false, // 鏍¢獙鐘舵�� + lossNumberMsg: '' // 閿欒淇℃伅 }) } this.ipagination.total = this.dataSource.length @@ -332,13 +346,15 @@ const target = temp.filter(item => key === item.key)[index] if (target) { target[column.dataIndex] = value - this.dataSource = temp - if (column.dataIndex === 'lossNumber') { - target[column.dataIndex] = value - } - if (column.dataIndex === 'lossReason') { - target[column.dataIndex] = value + if (column.dataIndex === 'lossNumber') { + if (value === null || value === undefined || value <= 0) { + target.lossNumberError = true + target.lossNumberMsg = '鎶ユ崯鏁伴噺涓嶈兘涓虹┖涓斿繀椤诲ぇ浜�0' + } else { + target.lossNumberError = false + target.lossNumberMsg = '' + } } this.dataSource = temp } @@ -355,26 +371,33 @@ }, add() { this.addShow = false - this.edit() + this.edit({}) // 浼犲叆绌哄璞′綔涓洪粯璁ゅ�� this.dataSource = [] }, edit(record) { console.log(record) - this.model = Object.assign({}, record) - this.visible = true - getAction(this.url.list, { - lossBoundId: record.id, - pageNo: 1, - pageSize: 99999 - }).then((res) => { - if (res.success) { - console.log(res.result.records) - this.dataSource = res.result.records - } else { - this.dataSource = null - } - }) + if (record && record.id) { + this.model = Object.assign({}, record) + this.visible = true + getAction(this.url.list, { + lossBoundId: record.id, + pageNo: 1, + pageSize: 99999 + }).then((res) => { + if (res.success) { + console.log(res.result.records) + this.dataSource = res.result.records + } else { + this.dataSource = null + } + }) + } else { + this.model = {} // 濡傛灉鏄柊澧炴ā寮忥紝鍒欏垵濮嬪寲 model + this.visible = true + this.dataSource = [] // 娓呯┖鏁版嵁婧� + } }, + close() { this.$emit('close') @@ -391,6 +414,17 @@ // 瑙﹀彂琛ㄥ崟楠岃瘉 this.$refs.form.validate(valid => { if (valid) { + let isTableValid = true + this.dataSource.forEach((row, index) => { + this.handleChange(row.lossNumber, row.key, { dataIndex: 'lossNumber' }, index) + if (row.lossNumberError) { + isTableValid = false + } + }) + + if (!isTableValid) { + return false + } this.model.toolsLossBoundDetailList = this.dataSource that.confirmLoading = true let httpurl = '' -- Gitblit v1.9.3