From e461400624e975821edf4684727eeaa7bf8c29c1 Mon Sep 17 00:00:00 2001 From: lixiangyu <lixiangyu@xalxzn.com> Date: 星期一, 15 九月 2025 18:07:08 +0800 Subject: [PATCH] feat(cms): 废料单列表增加提交功能并优化相关逻辑 --- src/views/cms/modules/CuttingScrapModal.vue | 159 ++++++++++++++++++++++++++++++---------------------- 1 files changed, 92 insertions(+), 67 deletions(-) diff --git a/src/views/cms/modules/CuttingScrapModal.vue b/src/views/cms/modules/CuttingScrapModal.vue index 027d35c..82ff665 100644 --- a/src/views/cms/modules/CuttingScrapModal.vue +++ b/src/views/cms/modules/CuttingScrapModal.vue @@ -3,7 +3,7 @@ <a-spin :spinning="confirmLoading"> <a-form :form="form"> <a-row style="width: 100%"> - <a-col :span="24 / 2"> + <a-col :span="24 / 2"> <a-form-item label="鐢宠浜�" :labelCol="labelCol" :wrapperCol="wrapperCol"> <j-search-select-tag :disabled="disableSubmit" @@ -26,12 +26,13 @@ <a-row style="width: 100%"> <a-col :span="24"> <a-form-item label="鐢宠璇存槑" :labelCol="{span:3}" :wrapperCol="{span:21}"> - <a-textarea :disabled="disableSubmit" placeholder="璇疯緭鍏ョ敵璇疯鏄�" v-decorator="['applicationComment', validatorRules.applicationComment]" /> + <a-textarea :disabled="disableSubmit" placeholder="璇疯緭鍏ョ敵璇疯鏄�" + v-decorator="['applicationComment', validatorRules.applicationComment]" /> </a-form-item> </a-col> </a-row> <a-row style="width: 100%"> - <a-col :span="24 / 2"> + <a-col :span="24 / 2"> <a-form-item label="纭浜�" :labelCol="labelCol" :wrapperCol="wrapperCol"> <j-search-select-tag :disabled="disableSubmit" @@ -54,14 +55,16 @@ <a-row style="width: 100%"> <a-col :span="24"> <a-form-item label="纭鎰忚" :labelCol="{span:3}" :wrapperCol="{span:21}"> - <a-textarea :disabled="disableSubmit" placeholder="璇疯緭鍏ョ‘璁ゆ剰瑙�" v-decorator="['confirmComment', validatorRules.confirmComment]" /> + <a-textarea :disabled="disableSubmit" placeholder="璇疯緭鍏ョ‘璁ゆ剰瑙�" + v-decorator="['confirmComment', validatorRules.confirmComment]" /> </a-form-item> </a-col> </a-row> </a-form> </a-spin> <a-button type="primary" :style="{ marginBottom: '8px' }" @click="selectTooling()" - >閫夋嫨鍒�鍏�</a-button + >閫夋嫨鎶ュ簾鍒�鍏� + </a-button > <a-table ref="table" @@ -75,13 +78,13 @@ > <template v-for="col in columns" :slot="col.dataIndex" slot-scope="text, record, index"> <div :key="col.dataIndex"> - <a-input - :value="text" - :disabled="disableSubmit" - v-if="col.dataIndex == 'newCuttingId'" - @change="(e)=>handleChange(e.target.value, record.key, col, index)" - /> - + <a-input + :value="text" + :disabled="disableSubmit" + v-if="col.dataIndex == 'newCuttingId'" + @change="(e)=>handleChange(e.target.value, record.key, col, index)" + /> + </div> </template> <span slot="action" slot-scope="text, record, index"> @@ -98,33 +101,35 @@ <template slot="footer" v-if="disableSubmit == true"> <a-button :style="{ marginRight: '8px' }" @click="handleCancel">鍏抽棴</a-button> </template> - <j-select-tooling-modal ref="toolingModalForm" @ok="modalFormOk"></j-select-tooling-modal> + <j-select-scrap-modal ref="scrapModalForm" @ok="modalFormOk"></j-select-scrap-modal> </a-modal> </template> <script> - import pick from 'lodash.pick' - import JSelectToolingModal from './JSelectToolingModal' - import moment from 'moment' - import { getAction, postAction, requestPut } from '@/api/manage' - import JDictSelectTag from '@/components/dict/JDictSelectTag' - import JSearchSelectTag from '@/components/dict/JSearchSelectTag' - import JMultiSelectTag from '@/components/dict/JMultiSelectTag' - import { filterObj } from '@/utils/util' - import store from '@/store/' - export default { - name: 'CuttingInboundModal', - components: { - JSelectToolingModal, +import pick from 'lodash.pick' +import JSelectToolingModal from './JSelectToolingModal' +import moment from 'moment' +import { getAction, postAction, requestPut } from '@/api/manage' +import JDictSelectTag from '@/components/dict/JDictSelectTag' +import JSearchSelectTag from '@/components/dict/JSearchSelectTag' +import JMultiSelectTag from '@/components/dict/JMultiSelectTag' +import { filterObj } from '@/utils/util' +import store from '@/store/' +import JSelectScrapModal from '@views/cms/modules/JSelectScrapModal.vue' + +export default { + name: 'CuttingInboundModal', + components: { + JSelectScrapModal, JMultiSelectTag, JDictSelectTag, store, - moment, + moment }, - data () { - return { - /* 鍒嗛〉鍙傛暟 */ + data() { + return { + /* 鍒嗛〉鍙傛暟 */ ipagination: { current: 1, pageSize: 10, @@ -134,27 +139,26 @@ }, showQuickJumper: true, showSizeChanger: true, - total: 0, + total: 0 }, - title:'鏂板', - visible: false, - selectedRowKeys: {}, + title: '鏂板', + visible: false, + selectedRowKeys: {}, model: {}, labelCol: { xs: { span: 24 }, - sm: { span: 6 }, + sm: { span: 6 } }, wrapperCol: { xs: { span: 24 }, - sm: { span: 18 }, + sm: { span: 18 } }, confirmLoading: false, loading: false, form: this.$form.createForm(this), dataSource: [], param: {}, - validatorRules: { - }, + validatorRules: {}, columns: [ { title: '#', @@ -162,47 +166,47 @@ key: 'rowIndex', width: 50, align: 'center', - customRender: function (t, r, index) { + customRender: function(t, r, index) { return parseInt(index) + 1 - }, + } }, { title: '鍒�鍏风紪鐮�', align: 'center', dataIndex: 'cuttingCode', - width: 150, + width: 150 }, { title: '鍒�鍏峰悕绉�', align: 'center', - dataIndex: 'cuttingName', + dataIndex: 'cuttingName' }, - + { title: '鎿嶄綔', dataIndex: 'action', align: 'center', - scopedSlots: { customRender: 'action' }, - }, + scopedSlots: { customRender: 'action' } + } ], url: { add: '/cms/cuttingScrap/add', - detailList: '/cms/cuttingScrap/detailList', + detailList: '/cms/cuttingScrap/detailList' }, - orderId:'', - disableSubmit:false - } - }, - methods: { - modalFormOk(){ + orderId: '', + disableSubmit: false + } + }, + methods: { + modalFormOk() { - }, - getQueryParams() { + }, + getQueryParams() { this.param.pageNo = this.ipagination.current this.param.pageSize = this.ipagination.pageSize return filterObj(this.param) }, - add() { + add() { let applicant = store.getters.userInfo.id let applicationTime = moment(new Date()).format('YYYY-MM-DD HH:mm:ss') this.edit({ applicant: applicant, applicationTime: applicationTime }) @@ -224,7 +228,7 @@ ) }) }, - handleDelete(record, index) { + handleDelete(record, index) { this.dataSource.splice(index, 1) }, handleChange(value, key, column, index) { @@ -236,14 +240,15 @@ this.dataSource = temp } }, - selectTooling: function () { + selectTooling: function() { let ids = [] for (let i = 0; i < this.dataSource.length; i++) { ids.push(this.dataSource[i].cuttingId) + ids.push(this.dataSource[i].inventoryId) } - this.$refs.toolingModalForm.showModal(ids) - this.$refs.toolingModalForm.title = '閫夋嫨鍒�鍏�' - this.$refs.toolingModalForm.disableSubmit = false + this.$refs.scrapModalForm.showModal(ids) + this.$refs.scrapModalForm.title = '閫夋嫨鎶ュ簾鍒�鍏�' + this.$refs.scrapModalForm.disableSubmit = false }, detailList(orderId) { this.param.orderId = orderId @@ -262,17 +267,32 @@ return } const that = this + // 瑙﹀彂琛ㄥ崟楠岃瘉 this.form.validateFields((err, values) => { if (!err) { that.confirmLoading = true let formData = Object.assign(this.model, values) formData.detailData = this.dataSource + + // 纭繚浼犻�掔粰鍚庣鐨勬暟鎹寘鍚墍鏈夊繀瑕佸瓧娈� + formData.detailData = this.dataSource.map(item => { + return { + // 鏄庣‘鎸囧畾姣忎釜瀛楁锛岀‘淇� inventoryId 琚纭紶閫� + inventoryId: item.inventoryId, + cuttingId: item.cuttingId, + cuttingCode: item.cuttingCode, + cuttingName: item.cuttingName, + // 濡傛灉杩樻湁鍏朵粬瀛楁涔熼渶瑕佸寘鍚� + ...item // 鍖呭惈鍏朵粬鍙兘瀛樺湪鐨勫瓧娈� + } + }) + postAction(that.url.add, formData) .then((res) => { if (res.success) { - that.$message.success('鎶ュ簾鎴愬姛') that.$emit('ok', new Date()) + that.$message.success('鎶ュ簾鎴愬姛') } else { that.$message.warning(res.message) } @@ -292,19 +312,24 @@ this.dataSource = [] this.visible = false this.disableSubmit = false - }, - }, - mounted() { + } + }, + mounted() { this.$bus.$on('selectionRows', (data) => { //getCurrSelected 浜嬩欢 鎺ユ敹缁勪欢浼犻�掔殑鍙傛暟 for (let i = 0; i < data.length; i++) { this.dataSource.push({ - cuttingId: data[i].id, + // cuttingId: data[i].id, + // cuttingCode: data[i].cuttingCode, + // cuttingName: data[i].cuttingName + inventoryId: data[i].id, cuttingCode: data[i].cuttingCode, - cuttingName: data[i].cuttingName + cuttingName: data[i].cuttingName, + cuttingId: data[i].cuttingId, }) } }) - }, + console.log('鏇存柊鍚庣殑鏁版嵁婧�:', this.dataSource) } +} </script> \ No newline at end of file -- Gitblit v1.9.3