From 8943eb56b38bdac72fd45f63aa177e9dd7d46187 Mon Sep 17 00:00:00 2001 From: g7hoo Date: Wed, 17 Aug 2022 09:12:23 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E8=B4=A8=E9=87=8F=E6=A3=80=E6=B5=8B?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base-dialog/addOrUpdate/index.vue | 16 +++ .../monitoring/qualityInspectionRecord.vue | 133 ++++++++++++++---- 2 files changed, 119 insertions(+), 30 deletions(-) diff --git a/src/components/base-dialog/addOrUpdate/index.vue b/src/components/base-dialog/addOrUpdate/index.vue index a7f40a8..2411e11 100644 --- a/src/components/base-dialog/addOrUpdate/index.vue +++ b/src/components/base-dialog/addOrUpdate/index.vue @@ -27,6 +27,7 @@ :placeholder="getPlaceholder(n, c)" v-model="dataForm[configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)].name]" clearable + @change="emitSelectChange(configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)].name, $event)" > @@ -41,6 +42,7 @@ @@ -207,6 +209,16 @@ export default { /** 动态设置dataForm字段 */ this.configs.fields.forEach(item => { this.$set(this.dataForm, [item.name], '') + + /** select 的默认值设置 */ + if (item.type === 'select') { + const opts = item.options || [] + const dft = opts.find(item => item.default || false) + if (dft) { + this.$set(this.dataForm, [item.name], dft.value) + } + } + if (item.api) { /** 自动请求并填充 */ // or this.shouldWaitPool = [] @@ -395,6 +407,10 @@ export default { }) }, + emitSelectChange(name, id) { + this.$emit('select-change', { name, id }) + }, + handleEditorReady(val) { console.log('editor rready..', val) }, diff --git a/src/views/modules/monitoring/qualityInspectionRecord.vue b/src/views/modules/monitoring/qualityInspectionRecord.vue index 38ebed2..948428b 100644 --- a/src/views/modules/monitoring/qualityInspectionRecord.vue +++ b/src/views/modules/monitoring/qualityInspectionRecord.vue @@ -9,34 +9,9 @@ 新增 - + + + - + @@ -71,7 +54,7 @@ const tableConfigs = [ { prop: 'sectionId', name: '工段id' }, { prop: 'checkPerson', name: '检测人员' }, // { prop: 'checkPerson', name: '检测人员,可以多个' }, - { prop: 'source', name: '来源' }, + { prop: 'source', name: '来源', filter: val => ({ 1: '手动', 2: '自动' }[val]) }, // { prop: 'source', name: '来源 1,手动(默认) 2,自动' }, { prop: 'explainText', name: '描述' }, { prop: 'remark', name: '备注' }, @@ -82,7 +65,27 @@ const addOrUpdateConfigs = { type: 'dialog', infoUrl: '/monitoring/qualityInspectionRecord', fields: [ - {name: '', label: '检测类型', type: 'select', options: []} + { name: 'checkTime', label: '检测时间', type: 'date', props: { style: 'width: 100%', type: 'datetime' }, placeholder: '请选择检测时间' }, + { name: 'productionId', label: '产线', type: 'select', options: [] }, + { name: 'sectionId', label: '工段', type: 'select', options: [] }, + { + name: 'source', + label: '来源', + type: 'select', + options: [ + { value: 1, label: '手动', default: true }, + { value: 2, label: '自动' } + ] + }, + { name: 'inspectionDetId', label: '检测内容', type: 'select', options: [] }, + { name: 'checkPerson', label: '检测人员' }, + { name: 'explainText', label: '描述' }, + 'remark' + ], + operations: [ + { name: 'cancel', showAlways: true }, + { name: 'save', url: '/monitoring/qualityInspectionRecord', permission: '', showOnEdit: false }, + { name: 'update', url: '/monitoring/qualityInspectionRecord', permission: '', showOnEdit: true } ] } @@ -109,8 +112,78 @@ export default { }, activated() { this.getDataList() + this.getInspectionDet() + this.getWorkSections() + this.getProductLines() }, methods: { + // handle + async handleSelectChange({ name, id }) { + if (name === 'productionId') { + // 如果选择了产线,就依据此更新工单的选项 + await this.getWorkSections(id) + } + }, + // 获取检测内容 + getInspectionDet() { + this.$http({ + url: this.$http.adornUrl('/monitoring/qualityInspectionDet/page'), + method: 'get', + params: this.$http.adornParams({ + page: this.pageIndex, + limit: this.pageSize, + key: this.dataForm.key + }) + }).then(({ data: res }) => { + console.log('insdet:', res) + const insDetOpt = this.addOrUpdateConfigs.fields.find(item => item.name === 'inspectionDetId') + if (insDetOpt) { + insDetOpt.options = res.data.list.map(item => ({ value: item.id, label: item.content })) || [] + } + }) + }, + // 获取产线 + getProductLines() { + this.$http({ + url: this.$http.adornUrl('/monitoring/productionLine/page'), + method: 'get', + params: this.$http.adornParams({ + // page: this.pageIndex, + // limit: this.pageSize, + // key: this.dataForm.key + }) + }).then(({ data: res }) => { + const plOpt = this.addOrUpdateConfigs.fields.find(item => item.name === 'productionId') + if (plOpt) { + plOpt.options = res.data.list.map(item => ({ value: item.id, label: item.name })) || [] + } + }) + }, + // 获取工段 + getWorkSections(lineId) { + this.$http({ + url: this.$http.adornUrl('/monitoring/workshopSection/page'), + method: 'get', + params: lineId + ? this.$http.adornParams({ + // page: this.pageIndex, + // limit: this.pageSize, + // key: this.dataForm.key + lineId + }) + : {} + }).then(({ data: res }) => { + if (res.data.total === 0) { + this.$message.error('该产线没有工段') + } else { + this.$message.success(`该产线有 ${res.data.total} 条工段`) + } + const wsOpt = this.addOrUpdateConfigs.fields.find(item => item.name === 'sectionId') + if (wsOpt) { + wsOpt.options = res.data.list.map(item => ({ value: item.id, label: item.name })) || [] + } + }) + }, // 获取数据列表 getDataList() { this.addOrUpdateVisible = false