From 3f43f0c979f9ae7a6d9eba25cb88f1cd7bc53495 Mon Sep 17 00:00:00 2001 From: g7hoo Date: Fri, 30 Sep 2022 17:01:47 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E8=AE=BE=E5=A4=87=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base-dialog/addOrUpdate/index.vue | 31 +++++++++-- src/utils/request.js | 2 +- src/views/modules/monitoring/equipment.vue | 52 ++++++++++++++++--- .../monitoring/workshopSectionDialog.vue | 22 ++++---- vue.config.js | 2 +- 5 files changed, 85 insertions(+), 24 deletions(-) diff --git a/src/components/base-dialog/addOrUpdate/index.vue b/src/components/base-dialog/addOrUpdate/index.vue index c6639bd..3c71bd9 100644 --- a/src/components/base-dialog/addOrUpdate/index.vue +++ b/src/components/base-dialog/addOrUpdate/index.vue @@ -38,7 +38,7 @@ :disabled="isDetail" @change="emitSelectChange(configs.fields[(n - 1) * COLUMN_PER_ROW + (c - 1)].name, $event)" > - + { - if (Object.hasOwn(this.dataForm, [item.name])) { + // if (Object.hasOwn(this.dataForm, [item.name])) { + if (this.dataForm.hasOwnProperty(item.name)) { return } else { this.$set(this.dataForm, [item.name], calDefault(item.fieldType)) @@ -394,7 +410,8 @@ export default { this.dataForm.files.forEach(file => { // const fileName = file.fileUrl.split('/').pop() /** [1] 处理 fileList */ - if (Object.hasOwn(this.fileList, file.typeCode)) { + // if (Object.hasOwn(this.fileList, file.typeCode)) { + if (this.fileList.hasOwnProperty(file.typeCode)) { /** 已存在 */ // this.fileList[file.typeCode].push({ id: file.id, name: fileName, typeCode: file.typeCode }) this.fileList[file.typeCode].push(file) @@ -404,7 +421,8 @@ export default { } /** [2] 处理 fileForm */ - if (Object.hasOwn(this.fileForm, file.typeCode)) { + // if (Object.hasOwn(this.fileForm, file.typeCode)) { + if (this.fileForm.hasOwnProperty(file.typeCode)) { this.fileForm[file.typeCode].push(file.id) } else { this.fileForm[file.typeCode] = [file.id] @@ -425,12 +443,17 @@ export default { }) // console.log('create new, dataform', JSON.stringify(this.dataForm)) } + this.shouldWait = null }) } }) }, emitSelectChange(name, id) { + const currentField = this.configs.fields.find(item => item.name === name) + if (currentField.relatedField) { + this.dataForm[currentField.relatedField] = null + } this.$emit('select-change', { name, id }) }, diff --git a/src/utils/request.js b/src/utils/request.js index d06a328..0700744 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -8,7 +8,7 @@ import merge from 'lodash/merge' const http = axios.create({ // baseURL: window.SITE_CONFIG['apiURL'], - baseURL: '/api', + baseURL: '/yd-monitor', // baseURL: process.env.NODE_ENV === 'production' ? '/api' : '/yd-monitor', timeout: 1000 * 180, withCredentials: true diff --git a/src/views/modules/monitoring/equipment.vue b/src/views/modules/monitoring/equipment.vue index 88e109c..9007ccd 100644 --- a/src/views/modules/monitoring/equipment.vue +++ b/src/views/modules/monitoring/equipment.vue @@ -30,7 +30,7 @@ layout="total, sizes, prev, pager, next, jumper" > - + @@ -62,6 +62,7 @@ const tableConfigs = [ { prop: 'groupName', name: i18n.t('eq.group') }, { prop: 'enName', name: i18n.t('enname') }, { prop: 'abbr', name: i18n.t('abbr') }, + { prop: 'lineName', name: i18n.t('pl.title') }, { prop: 'sectionName', name: i18n.t('ws.title') }, { prop: 'details', @@ -94,6 +95,14 @@ const addOrUpdateConfigs = { type: 'select', options: [] }, + { + name: 'lineId', + label: i18n.t('pl.title'), + required: true, + type: 'select', + options: [], + relatedField: 'sectionId', // 关联下面的id,在更换lineId时,会清空相应的sectionId选择结果 + }, { name: 'sectionId', label: i18n.t('ws.title'), @@ -283,19 +292,41 @@ export default { console.log('activated') this.getDataList() this.getGroupList() - this.getWsList() + this.getPlList() this.getTypeList() }, methods: { - // 获取工段列表 - getWsList() { + // 获取产线列表,用于刷新工段列表 + getPlList() { this.$http({ - url: this.$http.adornUrl('/monitoring/workshopSection/list'), + url: this.$http.adornUrl('/monitoring/productionLine/list'), method: 'get' - }).then(({ data : res }) => { + }).then(({ data: res }) => { + const plConfig = this.addOrUpdateConfigs.fields.find(item => item.name === 'lineId') + plConfig.options = + res.data?.map(item => ({ + value: item.id, + label: item.name + })) || [] + }) + }, + // 获取工段列表 + getWsList(id) { + let params = { + page: 1, + limit: 999 + } + if (id) { + params.lineId = id + } + this.$http({ + url: this.$http.adornUrl('/monitoring/workshopSection/page'), + method: 'get', + params: this.$http.adornParams(params) + }).then(({ data: res }) => { const wsConfig = this.addOrUpdateConfigs.fields.find(item => item.name === 'sectionId') wsConfig.options = - res.data?.map(item => ({ + res.data?.list?.map(item => ({ value: item.id, label: item.name })) || [] @@ -378,6 +409,13 @@ export default { selectionChangeHandle(val) { this.dataListSelections = val }, + // 对话框里的某个选择改变了 + handleDialogSelectChange({ name, id }) { + switch (name) { + case 'lineId': + this.getWsList(id) + } + }, handleOperations({ type, data: id }) { switch (type) { case 'view-detail': diff --git a/src/views/modules/monitoring/workshopSectionDialog.vue b/src/views/modules/monitoring/workshopSectionDialog.vue index 71189aa..16b7ca5 100644 --- a/src/views/modules/monitoring/workshopSectionDialog.vue +++ b/src/views/modules/monitoring/workshopSectionDialog.vue @@ -39,7 +39,7 @@

{{ $t('ws.eqbind') }} - {{ $t('add') }} +

@@ -68,8 +68,8 @@ import i18n from '@/i18n' import BaseTable from '@/components/base-table' import SmallTitle from '@/components/small-title' -import { pick } from 'lodash/object' -import TableOperateComponent from '@/components/base-table/components/operationComponent' +// import { pick } from 'lodash/object' +// import TableOperateComponent from '@/components/base-table/components/operationComponent' import AttrForm from './workshopSectionDialogAttrForm.vue' import { calcMaxHeight } from '@/utils' const tableProps = [ @@ -79,14 +79,14 @@ const tableProps = [ }, { name: i18n.t('eq.name'), prop: 'equipmentName' }, { name: i18n.t('dept.sort'), prop: 'sort' }, - { - name: i18n.t('handle'), - prop: 'operations', - fixed: 'right', - width: 180, - subcomponent: TableOperateComponent, - options: ['edit', 'delete'] - } + // { + // name: i18n.t('handle'), + // prop: 'operations', + // fixed: 'right', + // width: 180, + // subcomponent: TableOperateComponent, + // options: ['edit', 'delete'] + // } ] export default { diff --git a/vue.config.js b/vue.config.js index ddeec80..5ed4110 100644 --- a/vue.config.js +++ b/vue.config.js @@ -32,7 +32,7 @@ module.exports = { target: 'http://india.mes.picaiba.com/' }, '/yd-monitor': { - target: 'http://192.168.1.20:8080/' // 开发地址 + target: 'http://192.168.1.18:8080/' // 开发地址 }, '/ureport': { target: 'http://india.mes.picaiba.com/' // ureporter