diff --git a/src/api/monitoring/qualityInspectionRecord.js b/src/api/monitoring/qualityInspectionRecord.js new file mode 100644 index 00000000..81454cc5 --- /dev/null +++ b/src/api/monitoring/qualityInspectionRecord.js @@ -0,0 +1,54 @@ +import request from '@/utils/request' + +// 创建质量检查信息记录表 +export function createQualityInspectionRecord(data) { + return request({ + url: '/monitoring/quality-inspection-record/create', + method: 'post', + data: data + }) +} + +// 更新质量检查信息记录表 +export function updateQualityInspectionRecord(data) { + return request({ + url: '/monitoring/quality-inspection-record/update', + method: 'put', + data: data + }) +} + +// 删除质量检查信息记录表 +export function deleteQualityInspectionRecord(id) { + return request({ + url: '/monitoring/quality-inspection-record/delete?id=' + id, + method: 'delete' + }) +} + +// 获得质量检查信息记录表 +export function getQualityInspectionRecord(id) { + return request({ + url: '/monitoring/quality-inspection-record/get?id=' + id, + method: 'get' + }) +} + +// 获得质量检查信息记录表分页 +export function getQualityInspectionRecordPage(query) { + return request({ + url: '/monitoring/quality-inspection-record/page', + method: 'get', + params: query + }) +} + +// 导出质量检查信息记录表 Excel +export function exportQualityInspectionRecordExcel(query) { + return request({ + url: '/monitoring/quality-inspection-record/export-excel', + method: 'get', + params: query, + responseType: 'blob' + }) +} diff --git a/src/views/quality/base/qualityInspectionBoxBtn/index.vue b/src/views/quality/base/qualityInspectionBoxBtn/index.vue index 8c777b7c..6c6bee19 100644 --- a/src/views/quality/base/qualityInspectionBoxBtn/index.vue +++ b/src/views/quality/base/qualityInspectionBoxBtn/index.vue @@ -38,80 +38,7 @@ @close="cancel" @cancel="cancel" @confirm="submitForm"> - + @@ -134,6 +61,69 @@ export default { components: {}, data() { return { + rows: [ + [ + { + select: true, + label: '产线', + url: '/base/production-line/listAll', + prop: 'productionId', + rules: [{ required: true, message: '不能为空', trigger: 'blur' }], + bind: { + filterable: true, + }, + }, + ], + [ + { + select: true, + label: '工段', + url: '/base/workshop-section/listAll', + prop: 'sectionId', + rules: [{ required: true, message: '不能为空', trigger: 'blur' }], + }, + ], + [ + { + input: true, + label: '按钮盒识别码', + prop: 'buttonId', + rules: [ + { + type: 'number', + message: '请输入数字', + trigger: 'blur', + transform: (val) => Number(val), + }, + ], + }, + ], + [{ input: true, label: '按钮盒模式', prop: 'model' }], + [ + { + input: true, + label: '按钮值', + prop: 'keyValue', + rules: [ + { + type: 'number', + message: '请输入100以内的数字', + trigger: 'blur', + transform: (val) => Number(val) <= 100 && Number(val), + }, + ], + bind: { type: 'number', min: 0, max: 100 }, + }, + ], + [ + { + textarea: true, + label: '检测内容', + prop: 'inspectionDetContent', + rules: [{ required: true, message: '不能为空', trigger: 'blur' }], + }, + ], + ], searchBarFormConfig: [ { type: 'input', diff --git a/src/views/quality/components/dialogForm.vue b/src/views/quality/components/dialogForm.vue index 000e1cf9..2db7ffd9 100644 --- a/src/views/quality/components/dialogForm.vue +++ b/src/views/quality/components/dialogForm.vue @@ -39,6 +39,12 @@ :label="opt.label" :value="opt.value" /> + @@ -102,6 +108,18 @@ export default { }, }, }, + watch: { + rows: { + handler() { + console.log('watch triggered!'); + this.$nextTick(() => { + this.handleOptions('watch'); + }); + }, + deep: true, + immediate: false, + }, + }, mounted() { // 处理 options this.handleOptions(); @@ -119,13 +137,18 @@ export default { const response = await this.$axios(url); return response.data; }, - handleOptions() { + async handleOptions(trigger = 'monuted') { // console.log("[dialogForm:handleOptions]") const promiseList = []; this.rows.forEach((cols) => { - cols.forEach(async (opt) => { + cols.forEach((opt) => { + if (opt.value && !this.form[opt.prop]) { + // 默认值 + this.form[opt.prop] = opt.value; + } + if (opt.options) { - this.optionListOf[opt.prop] = opt.options; + this.$set(this.optionListOf, opt.prop, opt.options); } else if (opt.url) { // 如果是下拉框,或者新增模式下的输入框,才去请求 if (opt.select || (opt.input && !this.form?.id)) { @@ -154,19 +177,23 @@ export default { } }); } - try { - // this.formLoading = true; - // console.log("[dialogForm:handleOptions:promiseList]", promiseList) - await Promise.all(promiseList.map((fn) => fn())); - this.formLoading = false; - // console.log("[dialogForm:handleOptions:optionListOf]", this.optionListOf) - } catch (error) { - console.log('[dialogForm:handleOptions:error]', error); - this.formLoading = false; - } } }); }); + + // 如果是 watch 触发的,不需要执行进一步的请求 + if (trigger == 'watch') { + this.formLoading = false; + return; + } + try { + await Promise.all(promiseList.map((fn) => fn())); + this.formLoading = false; + // console.log("[dialogForm:handleOptions:optionListOf]", this.optionListOf) + } catch (error) { + console.log('[dialogForm:handleOptions:error]', error); + this.formLoading = false; + } if (!promiseList.length) this.formLoading = false; }, }, @@ -174,6 +201,7 @@ export default {