From c357ab8005c51d69f431ad5ec52de3a36ee088ff Mon Sep 17 00:00:00 2001 From: lb Date: Thu, 3 Aug 2023 11:19:06 +0800 Subject: [PATCH 1/5] =?UTF-8?q?update=20=E8=B4=A8=E9=87=8F=E6=A3=80?= =?UTF-8?q?=E6=B5=8B=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/qualityInspectionDet/index.vue | 123 ++---------------- src/views/quality/mixin/basicPageMixin.js | 44 ++++--- 2 files changed, 37 insertions(+), 130 deletions(-) diff --git a/src/views/quality/base/qualityInspectionDet/index.vue b/src/views/quality/base/qualityInspectionDet/index.vue index eab63e01..e5c50335 100644 --- a/src/views/quality/base/qualityInspectionDet/index.vue +++ b/src/views/quality/base/qualityInspectionDet/index.vue @@ -49,9 +49,6 @@ prop: 'typeId', url: '/base/quality-inspection-type/listAll', rules: [{ required: true, message: '不能为空', trigger: 'blur' }], - // bind: { - // disabled: true, // some condition, like detail mode... - // } }, ], [ @@ -66,32 +63,6 @@ [{ input: true, label: '备注', prop: 'remark' }], ]" /> - @@ -108,9 +79,12 @@ import { import moment from 'moment'; import DialogForm from '../../components/dialogForm.vue'; +import basicPageMixin from '../../mixin/basicPageMixin'; + export default { name: 'QualityInspectionDet', components: { DialogForm }, + mixins: [basicPageMixin], data() { return { typeList: [], // 检测类型列表 @@ -125,8 +99,9 @@ export default { type: 'datePicker', label: '创建时间', dateType: 'daterange', // datetimerange - format: 'yyyy-MM-dd HH:mm:ss', - valueFormat: 'yyyy-MM-ddTHH:mm:ss', + // format: 'yyyy-MM-dd HH:mm:ss', + format: 'yyyy-MM-dd', + valueFormat: 'yyyy-MM-dd HH:mm:ss', rangeSeparator: '-', startPlaceholder: '开始日期', endPlaceholder: '结束日期', @@ -180,7 +155,6 @@ export default { } : undefined, ].filter((v) => v), - tableData: [], tableProps: [ { prop: 'createTime', @@ -194,20 +168,6 @@ export default { { prop: 'code', label: '检测编码', align: 'center' }, { prop: 'remark', label: '备注', align: 'center' }, ], - // 遮罩层 - loading: true, - // 导出遮罩层 - exportLoading: false, - // 显示搜索条件 - showSearch: true, - // 总条数 - total: 0, - // 质量检测信息基础列表 - list: [], - // 弹出层标题 - title: '', - // 是否显示弹出层 - open: false, // 查询参数 queryParams: { pageNo: 1, @@ -215,16 +175,14 @@ export default { content: null, createTime: [], }, - // 表单参数 - form: {}, - // 表单校验 - rules: { - typeId: [ - { required: true, message: '检测类型id不能为空', trigger: 'change' }, - ], - content: [ - { required: true, message: '检测内容不能为空', trigger: 'blur' }, - ], + // 搜索框需要的 keys + searchBarKeys: ['content', 'createTime'], + form: { + id: undefined, + typeId: undefined, + content: undefined, + code: undefined, + remark: undefined, }, }; }, @@ -233,49 +191,6 @@ export default { this.getTypeList(); }, methods: { - /** base table related */ - handleTableBtnClick({ data, type }) { - switch (type) { - case 'edit': - this.handleUpdate(data); - break; - case 'delete': - this.handleDelete(data); - break; - } - }, - /** search bar related */ - handleSearchBarBtnClick(btn) { - const keys = ['content', 'createTime']; // timeVal - switch (btn.btnName) { - case 'search': - keys.forEach((key) => { - if (key == 'timeVal') { - this.queryParams['startTime'] = btn.timeVal[0]; - this.queryParams['endTime'] = btn.timeVal[1]; - return; - } - console.log('key', key, btn[key]) - this.queryParams[key] = btn[key] || null; - }); - console.log('queryParams', this.queryParams) - this.handleQuery(); - break; - case 'add': - this.handleAdd(); - break; - case 'export': - this.handleExport(); - break; - case 'reset': - this.$refs['search-bar'].resetForm(); - this.resetQuery(); - break; - } - }, - handleEmitFun(val) { - console.log('emit unf', val); - }, /** 获取检测类型id */ getTypeList() { this.$axios('/base/quality-inspection-type/listAll').then((response) => { @@ -313,16 +228,6 @@ export default { }; this.resetForm('form'); }, - /** 搜索按钮操作 */ - handleQuery() { - this.queryParams.pageNo = 1; - this.getList(); - }, - /** 重置按钮操作 */ - resetQuery() { - this.resetForm('queryForm'); - this.handleQuery(); - }, /** 新增按钮操作 */ handleAdd() { this.reset(); diff --git a/src/views/quality/mixin/basicPageMixin.js b/src/views/quality/mixin/basicPageMixin.js index b4005a91..dbe0db1d 100644 --- a/src/views/quality/mixin/basicPageMixin.js +++ b/src/views/quality/mixin/basicPageMixin.js @@ -15,32 +15,24 @@ export default { title: '', // 是否显示弹出层 open: false, - // 查询参数 - queryParams: { - pageNo: 1, - pageSize: 10, - }, - // 列表数据 tableData: [], - tableProps: [], // 占位 - tableBtn: [], // 占位 - searchBarFormConfig: [], // 占位 - // 弹窗表单配置 - dialogFormConfig: [], // 占位 + // 弹窗的表单 + // form: {}, // 占位 + // 搜索框需要的 keys + // searchBarKeys: [], // 占位 + // tableProps: [], // 占位 + // tableBtn: [], // 占位 + // searchBarFormConfig: [], // 占位 + // // 弹窗表单配置 + // dialogFormConfig: [], // 占位 }; }, - mounted() { - if (this.prepareSelectOptions) { - // 准备列表的options - // TODO: 也许需要挪到 dialogForm.vue 里 - this.prepareSelectOptions(); - } - }, + mounted() {}, methods: { // 处理搜索条件 handleSearchBarBtnClick() {}, - // 处理表格按钮 + // 处理表格按钮 handleTableBtnClick({ data, type }) { switch (type) { case 'edit': @@ -53,10 +45,10 @@ export default { }, // 处理搜索栏按钮 handleSearchBarBtnClick(btn) { - const keys = ['name', 'createTime']; // timeVal + // const keys = ['name', 'createTime']; // timeVal // 已被 searchBarKeys 替代 switch (btn.btnName) { case 'search': - keys.forEach((key) => { + this.searchBarKeys.forEach((key) => { if (key == 'timeVal') { this.queryParams['startTime'] = btn.timeVal[0]; this.queryParams['endTime'] = btn.timeVal[1]; @@ -83,5 +75,15 @@ export default { }, // 获取列表数据 getList() {}, + /** 搜索按钮操作 */ + handleQuery() { + this.queryParams.pageNo = 1; + this.getList(); + }, + /** 重置按钮操作 */ + resetQuery() { + this.resetForm('queryForm'); + this.handleQuery(); + }, }, }; From 78777d5d24ed8f8bc7d62a74c5c595df5fee9bfc Mon Sep 17 00:00:00 2001 From: lb Date: Thu, 3 Aug 2023 13:37:24 +0800 Subject: [PATCH 2/5] update --- .../base/qualityInspectionDet/index.vue | 9 +---- .../base/qualityInspectionType/index.vue | 36 ++----------------- src/views/quality/components/dialogForm.vue | 4 --- src/views/quality/mixin/basicPageMixin.js | 8 +++++ 4 files changed, 11 insertions(+), 46 deletions(-) diff --git a/src/views/quality/base/qualityInspectionDet/index.vue b/src/views/quality/base/qualityInspectionDet/index.vue index e5c50335..da2a30d7 100644 --- a/src/views/quality/base/qualityInspectionDet/index.vue +++ b/src/views/quality/base/qualityInspectionDet/index.vue @@ -77,13 +77,11 @@ import { } from '@/api/base/qualityInspectionDet'; import moment from 'moment'; -import DialogForm from '../../components/dialogForm.vue'; import basicPageMixin from '../../mixin/basicPageMixin'; export default { name: 'QualityInspectionDet', - components: { DialogForm }, mixins: [basicPageMixin], data() { return { @@ -175,7 +173,7 @@ export default { content: null, createTime: [], }, - // 搜索框需要的 keys + // 搜索框需要的 keys, 与上面 queryParams 的除 pageNo, pageSize 之外的 key 一一对应 searchBarKeys: ['content', 'createTime'], form: { id: undefined, @@ -212,11 +210,6 @@ export default { this.loading = false; }); }, - /** 取消按钮 */ - cancel() { - this.open = false; - this.reset(); - }, /** 表单重置 */ reset() { this.form = { diff --git a/src/views/quality/base/qualityInspectionType/index.vue b/src/views/quality/base/qualityInspectionType/index.vue index ce6f2c23..c4097ee2 100644 --- a/src/views/quality/base/qualityInspectionType/index.vue +++ b/src/views/quality/base/qualityInspectionType/index.vue @@ -61,7 +61,6 @@ diff --git a/src/views/quality/components/dialogForm.vue b/src/views/quality/components/dialogForm.vue index 0a306bea..408c108c 100644 --- a/src/views/quality/components/dialogForm.vue +++ b/src/views/quality/components/dialogForm.vue @@ -20,6 +20,13 @@ @change="$emit('update', form)" :placeholder="`请输入${col.label}`" v-bind="col.bind" /> + - + From 7c665484a7b0f2949d6d269a827da71c1f8c3d43 Mon Sep 17 00:00:00 2001 From: lb Date: Thu, 3 Aug 2023 15:03:59 +0800 Subject: [PATCH 4/5] =?UTF-8?q?update=20getCode=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/qualityInspectionType/index.vue | 9 +++- src/views/quality/components/dialogForm.vue | 50 +++++++++++++------ 2 files changed, 42 insertions(+), 17 deletions(-) diff --git a/src/views/quality/base/qualityInspectionType/index.vue b/src/views/quality/base/qualityInspectionType/index.vue index c4097ee2..9bafb076 100644 --- a/src/views/quality/base/qualityInspectionType/index.vue +++ b/src/views/quality/base/qualityInspectionType/index.vue @@ -52,7 +52,14 @@ // } }, ], - [{ input: true, label: '检测类型编码', prop: 'code' }], + [ + { + input: true, + label: '检测类型编码', + prop: 'code', + url: '/base/quality-inspection-type/getCode', + }, + ], [{ input: true, label: '备注', prop: 'remark' }], ]" /> diff --git a/src/views/quality/components/dialogForm.vue b/src/views/quality/components/dialogForm.vue index 408c108c..000e1cf9 100644 --- a/src/views/quality/components/dialogForm.vue +++ b/src/views/quality/components/dialogForm.vue @@ -97,6 +97,9 @@ export default { get() { return this.dataForm; }, + set(val) { + console.log('set form', val); + }, }, }, mounted() { @@ -111,7 +114,11 @@ export default { resetFields(args) { return this.$refs.form.resetFields(args); }, - + // getCode + async getCode(url) { + const response = await this.$axios(url); + return response.data; + }, handleOptions() { // console.log("[dialogForm:handleOptions]") const promiseList = []; @@ -120,22 +127,33 @@ export default { if (opt.options) { this.optionListOf[opt.prop] = opt.options; } else if (opt.url) { - promiseList.push(async () => { - const response = await this.$axios(opt.url, { - method: opt.method ?? 'get', + // 如果是下拉框,或者新增模式下的输入框,才去请求 + if (opt.select || (opt.input && !this.form?.id)) { + promiseList.push(async () => { + const response = await this.$axios(opt.url, { + method: opt.method ?? 'get', + }); + console.log('[dialogForm:handleOptions:response]', response); + if (opt.select) { + // 处理下拉框选项 + const list = + 'list' in response.data + ? response.data.list + : response.data; + this.$set( + this.optionListOf, + opt.prop, + list.map((item) => ({ + label: item[opt.labelKey ?? 'name'], + value: item[opt.valueKey ?? 'id'], + })) + ); + } else if (opt.input) { + // 处理输入框数据 + this.form[opt.prop] = response.data; + } }); - console.log('[dialogForm:handleOptions:response]', response); - const list = - 'list' in response.data ? response.data.list : response.data; - this.$set( - this.optionListOf, - opt.prop, - list.map((item) => ({ - label: item[opt.labelKey ?? 'name'], - value: item[opt.valueKey ?? 'id'], - })) - ); - }); + } try { // this.formLoading = true; // console.log("[dialogForm:handleOptions:promiseList]", promiseList) From 4d0c0ae91adb2210cc085cb65d6fb9980ce4ec1f Mon Sep 17 00:00:00 2001 From: lb Date: Thu, 3 Aug 2023 15:09:15 +0800 Subject: [PATCH 5/5] =?UTF-8?q?update=20=E5=9F=BA=E6=9C=AC=E5=AE=8C?= =?UTF-8?q?=E6=88=90=E8=B4=A8=E9=87=8F=E5=9F=BA=E7=A1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/qualityInspectionDet/index.vue | 45 ++++++++++++------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/src/views/quality/base/qualityInspectionDet/index.vue b/src/views/quality/base/qualityInspectionDet/index.vue index da2a30d7..939568c5 100644 --- a/src/views/quality/base/qualityInspectionDet/index.vue +++ b/src/views/quality/base/qualityInspectionDet/index.vue @@ -17,6 +17,7 @@ v-if="tableBtn.length" slot="handleBtn" label="操作" + fixed="right" :method-list="tableBtn" @clickBtn="handleTableBtnClick" /> @@ -49,6 +50,9 @@ prop: 'typeId', url: '/base/quality-inspection-type/listAll', rules: [{ required: true, message: '不能为空', trigger: 'blur' }], + bind: { + filterable: true, + }, }, ], [ @@ -59,7 +63,14 @@ rules: [{ required: true, message: '不能为空', trigger: 'blur' }], }, ], - [{ input: true, label: '检测编码', prop: 'code' }], + [ + { + input: true, + label: '内容编码', + prop: 'code', + url: '/base/quality-inspection-det/getCode', + }, + ], [{ input: true, label: '备注', prop: 'remark' }], ]" /> @@ -93,20 +104,20 @@ export default { placeholder: '请输入检测内容', param: 'content', }, - { - type: 'datePicker', - label: '创建时间', - dateType: 'daterange', // datetimerange - // format: 'yyyy-MM-dd HH:mm:ss', - format: 'yyyy-MM-dd', - valueFormat: 'yyyy-MM-dd HH:mm:ss', - rangeSeparator: '-', - startPlaceholder: '开始日期', - endPlaceholder: '结束日期', - defaultTime: ['00:00:00', '23:59:59'], - param: 'createTime', - width: 350, - }, + // { + // type: 'datePicker', + // label: '创建时间', + // dateType: 'daterange', // datetimerange + // // format: 'yyyy-MM-dd HH:mm:ss', + // format: 'yyyy-MM-dd', + // valueFormat: 'yyyy-MM-dd HH:mm:ss', + // rangeSeparator: '-', + // startPlaceholder: '开始日期', + // endPlaceholder: '结束日期', + // defaultTime: ['00:00:00', '23:59:59'], + // param: 'createTime', + // width: 350, + // }, { type: 'button', btnName: '查询', @@ -161,8 +172,8 @@ export default { width: 180, filter: (val) => moment(val).format('yyyy-MM-DD HH:mm:ss'), }, - { prop: 'typeId', label: '检测类型ID', align: 'center' }, - { prop: 'content', label: '检测类型内容', align: 'center' }, + { prop: 'typeName', label: '类型名称', align: 'center' }, + { prop: 'content', label: '检测内容', align: 'center' }, { prop: 'code', label: '检测编码', align: 'center' }, { prop: 'remark', label: '备注', align: 'center' }, ],