From 76c2f50bf332ac8e7ea158a0970a25a251a17c77 Mon Sep 17 00:00:00 2001 From: lb Date: Mon, 27 Nov 2023 11:31:21 +0800 Subject: [PATCH 1/4] fix bugs --- src/components/DialogForm/index.vue | 53 +- src/layout/components/DialogWithMenu.vue | 978 ------------------ .../coreEquipment/components/AssetsUpload.vue | 79 +- .../components/EquipmentDrawer.vue | 22 +- src/views/base/coreEquipment/index.vue | 194 ++-- .../analysis/quality/components/lineChart.vue | 26 +- .../equipment/analysis/quality/index.vue | 39 +- .../BindGroup/components/BasicDrawer.vue | 11 +- .../equipmentProcessAmount/graph.vue | 2 +- .../equipmentProcessAmount/index.vue | 24 +- 10 files changed, 304 insertions(+), 1124 deletions(-) delete mode 100644 src/layout/components/DialogWithMenu.vue diff --git a/src/components/DialogForm/index.vue b/src/components/DialogForm/index.vue index 3c92a2f4..0c4fcff1 100644 --- a/src/components/DialogForm/index.vue +++ b/src/components/DialogForm/index.vue @@ -76,6 +76,7 @@ class="upload-area" :class="uploadOpen ? '' : 'height-48'" ref="uploadArea" + :key="col.prop" v-if="col.upload"> + @delete="!disabled && handleDeleteFile(file, col.prop)" /> @@ -152,12 +158,30 @@ const uploadedFile = { handleDelete() { this.$emit('delete', this.file); }, + async handleDownload() { + const data = await this.$axios({ + url: this.file.fileUrl, + method: 'get', + responseType: 'blob', + }); + + await this.$message.success('开始下载'); + // create download link + const url = window.URL.createObjectURL(data); + const link = document.createElement('a'); + link.href = url; + link.download = this.file.fileName; + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); + }, }, mounted() {}, render: function (h) { return (
{ + this.form[prop] = this.form[prop] ?? []; + }); + } } }, deep: true, @@ -348,7 +378,7 @@ export default { // 处理输入框数据 this.form[opt.prop] = response.data; // 更新下外部的 dataForm,防止code字段有数据也报空的bug - this.$emit('update', this.form) + this.$emit('update', this.form); } }); } @@ -377,11 +407,12 @@ export default { // 上传成功的特殊处理 beforeUpload() {}, // 上传前的验证规则可通过 bind 属性传入 - handleUploadSuccess(response, file, fileList) { - this.form.files.push({ + handleUploadSuccess(response, file, prop) { + console.log('[handleUploadSuccess]', response, file, prop); + this.form[prop].push({ fileName: file.name, fileUrl: response.data, - fileType: 2, + fileType: prop == 'files' ? 2 : 1, }); this.$modal.msgSuccess('上传成功'); this.$emit('update', this.form); @@ -395,8 +426,8 @@ export default { this.uploadOpen = !this.uploadOpen; }, - handleDeleteFile(file) { - this.form.files = this.form.files.filter( + handleDeleteFile(file, prop) { + this.form[prop] = this.form[prop].filter( (item) => item.fileUrl != file.fileUrl ); this.$emit('update', this.form); diff --git a/src/layout/components/DialogWithMenu.vue b/src/layout/components/DialogWithMenu.vue deleted file mode 100644 index efd6428e..00000000 --- a/src/layout/components/DialogWithMenu.vue +++ /dev/null @@ -1,978 +0,0 @@ - - - - - diff --git a/src/views/base/coreEquipment/components/AssetsUpload.vue b/src/views/base/coreEquipment/components/AssetsUpload.vue index bd19723d..a5a3319d 100644 --- a/src/views/base/coreEquipment/components/AssetsUpload.vue +++ b/src/views/base/coreEquipment/components/AssetsUpload.vue @@ -46,35 +46,36 @@ }}文件大小不超过2MB
-
- + style="width: 100%"> +
+ +
+ +
@@ -189,6 +190,32 @@ export default { }, 500); }, + async handleDownload(file) { + if (this.isPicMode) { + // this.$emit('preview', file); + const link = document.createElement('a'); + link.href = file.fileUrl; + link.target = '_blank'; + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); + } else { + // this.$emit('download', file); + const data = await this.$axios({ + url: file.fileUrl, + method: 'get', + responseType: 'blob', + }); + const link = document.createElement('a'); + link.href = window.URL.createObjectURL(new Blob([data])); + link.download = file.fileName; + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); + window.URL.revokeObjectURL(link.href); + } + }, + emitFilelist() { this.$emit('update', this.files); }, diff --git a/src/views/base/coreEquipment/components/EquipmentDrawer.vue b/src/views/base/coreEquipment/components/EquipmentDrawer.vue index 4fd9551b..3c58a5c9 100644 --- a/src/views/base/coreEquipment/components/EquipmentDrawer.vue +++ b/src/views/base/coreEquipment/components/EquipmentDrawer.vue @@ -42,16 +42,26 @@ v-model="form" /> -
+
+
+ + + 添加属性 + +
+ 编辑 - 确定 + 保存 - + - - - - - - + ]" + @refreshDataList="getList" + @cancel="cancelEdit" + @destroy="cancelEdit" />
@@ -96,21 +132,21 @@ export default { tableBtn: [ this.$auth.hasPermi(`base:core-equipment:update`) ? { - type: 'detail', - btnName: '详情', - } + type: 'detail', + btnName: '详情', + } : undefined, this.$auth.hasPermi('base:core-equipment:update') ? { - type: 'edit', - btnName: '修改', - } + type: 'edit', + btnName: '修改', + } : undefined, this.$auth.hasPermi('base:core-equipment:delete') ? { - type: 'delete', - btnName: '删除', - } + type: 'delete', + btnName: '删除', + } : undefined, ].filter((v) => v), tableProps: [ @@ -176,14 +212,18 @@ export default { type: 'separate', }, { - type: this.$auth.hasPermi('base:core-equipment:export') ? 'button' : '', + type: this.$auth.hasPermi('base:core-equipment:export') + ? 'button' + : '', btnName: '导出', name: 'export', plain: true, color: 'primary', }, { - type: this.$auth.hasPermi('base:core-equipment:create') ? 'button' : '', + type: this.$auth.hasPermi('base:core-equipment:create') + ? 'button' + : '', btnName: '新增', name: 'add', plain: true, @@ -196,7 +236,9 @@ export default { input: true, label: '设备名称', prop: 'name', - rules: [{ required: true, message: '设备名称不能为空', trigger: 'blur' }], + rules: [ + { required: true, message: '设备名称不能为空', trigger: 'blur' }, + ], // bind: { // disabled: this.editMode == 'detail', // some condition, like detail mode... // } @@ -225,7 +267,9 @@ export default { label: '设备类型', prop: 'equipmentTypeId', url: '/base/core-equipment-type/page?pageNo=1&pageSize=100', - rules: [{ required: true, message: '设备类型不能为空', trigger: 'blur' }], + rules: [ + { required: true, message: '设备类型不能为空', trigger: 'blur' }, + ], bind: { filterable: true, }, @@ -235,7 +279,11 @@ export default { label: '预计生产时间(min/天)', prop: 'workTime', rules: [ - { required: true, message: '预计生产时间不能为空', trigger: 'blur' }, + { + required: true, + message: '预计生产时间不能为空', + trigger: 'blur', + }, { type: 'number', message: '请输入正确的数字值', @@ -291,7 +339,11 @@ export default { label: '单件产品加工时间(s)', prop: 'processingTime', rules: [ - { required: true, message: '单件产品加工时间不能为空', trigger: 'blur' }, + { + required: true, + message: '单件产品加工时间不能为空', + trigger: 'blur', + }, { type: 'number', message: '请输入正确的数字值', @@ -322,13 +374,19 @@ export default { [ { upload: true, - label: '上传资料', + label: '设备资料', prop: 'files', }, ], [ - { input: true, label: '备注', prop: 'remark' } + { + upload: true, + label: '设备图片', + prop: 'files2', + fileType: 1, + }, ], + [{ input: true, label: '备注', prop: 'remark' }], // [ // { // assetUpload: true, @@ -429,7 +487,7 @@ export default { // 表单参数 form: { id: null, - files: [] + files: [], }, showUploadComponents: false, // 是否显示上传组件 }; @@ -441,36 +499,36 @@ export default { computedRows() { return this.showUploadComponents ? [ - ...this.rows, - [ - { - assetUpload: true, - key: 'eq-assets', // 用于区分不同的上传组件 - label: '上传资料', - fieldName: 'assets', - subcomponent: AssetsUpload, - prop: 'uploadedAssets', - default: [], - bind: { - 'is-pic-mode': false, + ...this.rows, + [ + { + assetUpload: true, + key: 'eq-assets', // 用于区分不同的上传组件 + label: '上传资料', + fieldName: 'assets', + subcomponent: AssetsUpload, + prop: 'uploadedAssets', + default: [], + bind: { + 'is-pic-mode': false, + }, }, - }, - ], - [ - { - assetUpload: true, - key: 'eq-pics', // 用于区分不同的上传组件 - label: '上传图片', - fieldName: 'images', - subcomponent: AssetsUpload, - // prop: '', - // default: [], - bind: { - 'is-pic-mode': true, + ], + [ + { + assetUpload: true, + key: 'eq-pics', // 用于区分不同的上传组件 + label: '上传图片', + fieldName: 'images', + subcomponent: AssetsUpload, + // prop: '', + // default: [], + bind: { + 'is-pic-mode': true, + }, }, - }, - ], - ] + ], + ] : this.rows; }, }, @@ -512,7 +570,8 @@ export default { spec: undefined, description: undefined, remark: undefined, - files: [] + files: [], + files2: [], }; this.resetForm('form'); }, @@ -540,9 +599,12 @@ export default { if (!valid) { return; } + const payload = Object.assign({}, this.form); + payload.files = [...payload.files, ...payload.files2]; + delete payload.files2; // 修改的提交 if (this.form.id != null) { - updateEquipment(this.form).then((response) => { + updateEquipment(payload).then((response) => { this.$modal.msgSuccess('修改成功'); this.open = false; this.getList(); @@ -550,7 +612,7 @@ export default { return; } // 添加的提交 - createEquipment(this.form).then((response) => { + createEquipment(payload).then((response) => { this.$modal.msgSuccess('新增成功'); this.open = false; this.getList(); @@ -569,7 +631,7 @@ export default { this.getList(); this.$modal.msgSuccess('删除成功'); }) - .catch(() => { }); + .catch(() => {}); }, /** 导出按钮操作 */ handleExport() { @@ -587,7 +649,7 @@ export default { this.$download.excel(response, '设备.xls'); this.exportLoading = false; }) - .catch(() => { }); + .catch(() => {}); }, // 查看详情 viewDetail(id) { diff --git a/src/views/equipment/analysis/quality/components/lineChart.vue b/src/views/equipment/analysis/quality/components/lineChart.vue index 04f25dc2..44af2402 100644 --- a/src/views/equipment/analysis/quality/components/lineChart.vue +++ b/src/views/equipment/analysis/quality/components/lineChart.vue @@ -21,18 +21,15 @@ export default { chart: null, }; }, - // watch: { - // list: { - // handler(listdata) { - // if (listdata && listdata.length) { - // console.log('[linechart] list changed', listdata); - // const option = this.handleList(listdata); - // this.setOption(option); - // } - // }, - // immediate: true, - // }, - // }, + watch: { + list: { + handler(listdata) { + this.setOption(); + }, + immediate: true, + deep: true, + }, + }, computed: { option() { const opt = []; @@ -55,7 +52,7 @@ export default { }, formatter: (params) => { const name = params[0].name; - const goodRate = opt.find((item) => item[0] == name)[4]; + const goodRate = opt.find((item) => item[0] == name)[4] || '0'; return `

${ params[0].axisValue @@ -109,6 +106,9 @@ export default { xAxis: { type: 'category', axisTick: { show: false }, + axisLabel: { + rotate: 45, + }, data: opt.map((item) => item[0]), }, yAxis: { diff --git a/src/views/equipment/analysis/quality/index.vue b/src/views/equipment/analysis/quality/index.vue index 785f7dc1..0b3512f9 100644 --- a/src/views/equipment/analysis/quality/index.vue +++ b/src/views/equipment/analysis/quality/index.vue @@ -6,15 +6,15 @@ -->