From e9aabffcbe34650677a7ffd6d4686bb2237d9cf4 Mon Sep 17 00:00:00 2001 From: h7ml Date: Fri, 1 Jul 2022 22:16:41 +0800 Subject: [PATCH] =?UTF-8?q?fix(multitenant):=20=E4=BF=AE=E5=A4=8D=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E5=88=97=E8=A1=A8=E7=BF=BB=E9=A1=B5=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/DgiotAmisEditor/index.vue | 6 +- src/views/CloudFunction/doc/index.vue | 4 +- src/views/CloudFunction/engine/channel.vue | 4 +- .../engine/components/DynamicForms.vue | 12 +- .../lowcode/components/ViewEdit.vue | 2 +- src/views/CloudFunction/lowcode/index.vue | 2 +- src/views/CloudOT/maintenance/alert.vue | 19 +- src/views/CloudOT/maintenance/index.vue | 2 +- src/views/DeviceCloud/manage/product.vue | 614 +++++++++--------- 9 files changed, 342 insertions(+), 323 deletions(-) diff --git a/src/dgiot/components/DgiotAmisEditor/index.vue b/src/dgiot/components/DgiotAmisEditor/index.vue index 5a31c31b0d..7ceaf3e934 100644 --- a/src/dgiot/components/DgiotAmisEditor/index.vue +++ b/src/dgiot/components/DgiotAmisEditor/index.vue @@ -75,16 +75,16 @@ diff --git a/src/views/CloudFunction/doc/index.vue b/src/views/CloudFunction/doc/index.vue index e21107bdb8..2a1b75aa29 100644 --- a/src/views/CloudFunction/doc/index.vue +++ b/src/views/CloudFunction/doc/index.vue @@ -275,11 +275,11 @@ diff --git a/src/views/CloudFunction/engine/channel.vue b/src/views/CloudFunction/engine/channel.vue index 1cbba42452..bc07cd4fb0 100644 --- a/src/views/CloudFunction/engine/channel.vue +++ b/src/views/CloudFunction/engine/channel.vue @@ -246,7 +246,7 @@
{{ item.name }} - + {{ item.objectId }} @@ -176,7 +176,7 @@ :value="deviceName.objectId" > {{ deviceName.name }} - + {{ deviceName.objectId }} @@ -255,7 +255,7 @@ :value="item.objectId" > {{ item.name }} - + {{ item.objectId }} @@ -292,7 +292,7 @@ :value="deviceName.objectId" > {{ deviceName.name }} - + {{ deviceName.objectId }} @@ -556,7 +556,7 @@ :value="item.objectId" > {{ item.name }} - + {{ item.objectId }} @@ -594,7 +594,7 @@ :value="deviceName.objectId" > {{ deviceName.name }} - + {{ deviceName.objectId }} diff --git a/src/views/CloudFunction/lowcode/components/ViewEdit.vue b/src/views/CloudFunction/lowcode/components/ViewEdit.vue index 08672771fd..a2629f30f7 100644 --- a/src/views/CloudFunction/lowcode/components/ViewEdit.vue +++ b/src/views/CloudFunction/lowcode/components/ViewEdit.vue @@ -41,7 +41,7 @@ :value="item.value" > {{ item.label }} - + {{ item.value }} diff --git a/src/views/CloudFunction/lowcode/index.vue b/src/views/CloudFunction/lowcode/index.vue index 181f7d55a7..59f12930c0 100644 --- a/src/views/CloudFunction/lowcode/index.vue +++ b/src/views/CloudFunction/lowcode/index.vue @@ -48,7 +48,7 @@ :value="item.value" > {{ item.label }} - + {{ item.value }} diff --git a/src/views/CloudOT/maintenance/alert.vue b/src/views/CloudOT/maintenance/alert.vue index 986251181e..8d0f5d51b7 100644 --- a/src/views/CloudOT/maintenance/alert.vue +++ b/src/views/CloudOT/maintenance/alert.vue @@ -245,7 +245,7 @@ --> - +
-
+
{{ o.objectId }} @@ -417,6 +417,7 @@ { - if ( - items.category != '' && - items.category && - items.devType != 'report' - ) { - category.push(items.category) - } - }) - this.listLoading = false - this.proTableData = results - this.total = count - } - } catch (error) { - this.listLoading = false - dgiotlog.log(error) - this.$baseMessage( - this.$translateTitle('alert.Data request error') + `${error}`, - 'error', - 'dgiot-hey-message-error' - ) - } - }, - handleClose() { - this.dialogFormVisible = false - }, - // 选择产品模板 - async chooseTemplate(row) { - this.selectedRow = row - console.log(row) - // const res = await this.getcategoryname(row.category) - this.$set( - this.form, - 'categoryid', - row?.category?.objectId ? row.category.objectId : '0' - ) - this.$set( - this.form, - 'categoryname', - row?.category?.name ? row.category.name + '/' + row.name : row.name - ) - this.$set(this.form, 'producttempid', row.objectId) - this.form.thing = row.thing ? row.thing : {} - // try { - // const res = await this.getcategoryname(row.category) - // }catch (e) { - // console.log(e) - // this.$message({ - // type:'error', - // message:e, - // duration:true, - // }) - // } - this.cascaderDrawer = !this.cascaderDrawer - console.log('select', row) - }, - async getcategoryname(category) { - const { name } = await getCategory(category.parent.objectId) - const returnName = - name == '所有领域' ? category.name : name + '/' + category.name - return returnName - }, - // 关闭dialog 事件 - handleCloseDialogForm() { - this.dialogFormVisible = false - // 重置表单 - this.$nextTick(() => { - this.$refs['form'].resetFields() - }) - }, - properties(things, type = 'things') { - this.descriptions.tableLoading = true - dgiotlog.log(things) - this.descriptions.things = things - this.descriptions.tableType = type - setTimeout(() => (this.descriptions.tableLoading = false), 1200) - }, - // 添加产品弹窗 - addproduct() { - this.Get_Re_Channel() - this.queryprodut({}) - this.custom_status = 'add' - // return false - this.moduleTitle = this.$translateTitle('product.createproduct') - this.imageUrl = '' - this.form = { - dynamicReg: true, - name: '', - type: 1, - category: '', - nodeType: 3, - desc: '', - netType: ' ', - devType: '', - productSecret: '', - relationApp: this.currentDepartment.name, - roles: [], - categoryname: '', - config: { checkList: ['konva', 'amis'], address: '余杭区良渚平高创业城c1座', location: { latitude: '120.161324', longitude: '30.262441' , __type: 'GeoPoint'} }, + if (this.formInline.productname) { + this.queryForm.limit = 8 + this.queryForm.skip = 0 } - this.productid = moment(new Date()).valueOf().toString() - this.dialogFormVisible = true - }, - getParent(id, origin, returnarr) { - origin.map((item) => { - if (id == item.id) { - returnarr.unshift(item.value) - this.getParent(item.parentid, origin, returnarr) - } else if (item.parentid == 0 && item.id == id) { - returnarr.unshift(item.value) - } - }) - this.form.category = returnarr[0] - return returnarr - }, - // 查找Industry父级 - getIndustryParent(type, originarr) { - originarr.map((item) => { - if (item.value == type) { - this.getParent(item.id, originarr, []) - } - }) - }, - async editorParser(ObjectId) { - this.parserFromId = ObjectId - try { - const { - config = { - parser: [], - }, - thing = {}, - } = await getProduct(ObjectId) - this.parserTableList = config - dgiotlog.log(this.parserTableList) - this.parserDict = _.merge(thing, config) - } catch (e) { - this.parserTableList = { parser: [] } - dgiotlog.log('eeeeeeeeeeeee', e) - } - this.parserTable = true - }, - editParse(index, row) { - this.formConfig = row - this.editIndex = index - this.dialogVisible = true - }, - async saveParse(list, type = -1) { - if (type + 2 > 0) { - this.parserTableList.parser[type] = _.merge({}, list) + // 优化下查询条件,新增忽略字段 + let params = { + count: 'objectId', + order: '-updatedAt', + skip: this.queryForm.skip, + limit: this.queryForm.limit, + where: {}, + excludeKeys: + 'children,thing,decoder,topics,productSecret,view,category,producttemplet', } - try { - const res = await putProduct(this.parserFromId, { - config: type + 2 > 0 ? this.parserTableList : list, - }) - this.$message({ - showClose: true, - message: this.$translateTitle( - 'user.Save the template successfully' - ), - duration: 2000, - type: 'success', + this.formInline.productname + ? (params.where.name = {$regex: this.formInline.productname}) + : '' + const {results = [], count = 0} = await this.$query_object( + 'Product', + params + ) + // dgiotlog.log("results", results) + if (results) { + results.map((items) => { + if ( + items.category != '' && + items.category && + items.devType != 'report' + ) { + category.push(items.category) + } }) - this.dialogVisible = false - this.parserTable = false - } catch (e) { - this.$baseMessage( - this.$translateTitle('user.Save the template error') + `${e}`, - 'error', - 'dgiot-hey-message-error' - ) - dgiotlog.log(e, 'eeee') - } - dgiotlog.log(list) - }, - previewParse(row) { - this.parserView = true - this.formConfig = row - dgiotlog.log('previewParse', row) - }, - addParse(row) { - row['parser'].push({ - name: uuid(6), - enname: uuid(6), - config: {}, - }) - }, - deleteParse(index, rows) { - rows.splice(index, 1) - }, - async editorDict(ObjectId) { - // const loading = this.$baseColorfullLoading() - this.getAllunit() - const row = await getProduct(ObjectId) - // loading.close() - const { config = { basedate: {} } } = row - this.productInfo = row - dgiotlog.log(' this.parserDict', this.parserDict) - this.editDictTempId = ObjectId - this.dictTempForm = { - name: '', - cType: '', - enable: '1', - description: '', - params: [], + this.listLoading = false + this.proTableData = results + this.total = count } - this.title_temp_dialog = '创建字典模板' - dgiotlog.log(config) - if (config.basedate && config.basedate.name) { - this.title_temp_dialog = '修改字典模板' - this.dictTempForm = config.basedate + } catch (error) { + this.listLoading = false + dgiotlog.log(error) + this.$baseMessage( + this.$translateTitle('alert.Data request error') + `${error}`, + 'error', + 'dgiot-hey-message-error' + ) + } + }, + handleClose() { + this.dialogFormVisible = false + }, + // 选择产品模板 + async chooseTemplate(row) { + this.selectedRow = row + console.log(row) + // const res = await this.getcategoryname(row.category) + this.$set( + this.form, + 'categoryid', + row?.category?.objectId ? row.category.objectId : '0' + ) + this.$set( + this.form, + 'categoryname', + row?.category?.name ? row.category.name + '/' + row.name : row.name + ) + this.$set(this.form, 'producttempid', row.objectId) + this.form.thing = row.thing ? row.thing : {} + // try { + // const res = await this.getcategoryname(row.category) + // }catch (e) { + // console.log(e) + // this.$message({ + // type:'error', + // message:e, + // duration:true, + // }) + // } + this.cascaderDrawer = !this.cascaderDrawer + console.log('select', row) + }, + async getcategoryname(category) { + const {name} = await getCategory(category.parent.objectId) + const returnName = + name == '所有领域' ? category.name : name + '/' + category.name + return returnName + }, + // 关闭dialog 事件 + handleCloseDialogForm() { + this.dialogFormVisible = false + // 重置表单 + this.$nextTick(() => { + this.$refs['form'].resetFields() + }) + }, + properties(things, type = 'things') { + this.descriptions.tableLoading = true + dgiotlog.log(things) + this.descriptions.things = things + this.descriptions.tableType = type + setTimeout(() => (this.descriptions.tableLoading = false), 1200) + }, + // 添加产品弹窗 + addproduct() { + this.Get_Re_Channel() + this.queryprodut({}) + this.custom_status = 'add' + // return false + this.moduleTitle = this.$translateTitle('product.createproduct') + this.imageUrl = '' + this.form = { + dynamicReg: true, + name: '', + type: 1, + category: '', + nodeType: 3, + desc: '', + netType: ' ', + devType: '', + productSecret: '', + relationApp: this.currentDepartment.name, + roles: [], + categoryname: '', + config: { + checkList: ['konva', 'amis'], + address: '余杭区良渚平高创业城c1座', + location: {latitude: '120.161324', longitude: '30.262441', __type: 'GeoPoint'} + }, + } + this.productid = moment(new Date()).valueOf().toString() + this.dialogFormVisible = true + }, + getParent(id, origin, returnarr) { + origin.map((item) => { + if (id == item.id) { + returnarr.unshift(item.value) + this.getParent(item.parentid, origin, returnarr) + } else if (item.parentid == 0 && item.id == id) { + returnarr.unshift(item.value) } - this.rule = { - name: [ - { - required: true, - message: '请输入字典模板名称', - trigger: 'blur', - }, - ], - cType: [ - { - required: true, - message: '请输入字典模板类型', - trigger: 'blur', - }, - ], - enable: [ - { - required: true, - message: '请选择状态', - trigger: 'change', - }, - ], + }) + this.form.category = returnarr[0] + return returnarr + }, + // 查找Industry父级 + getIndustryParent(type, originarr) { + originarr.map((item) => { + if (item.value == type) { + this.getParent(item.id, originarr, []) } - dgiotlog.log(this.dictTempForm, 'config') - this.dictVisible = true - }, - async editorProduct(editorProductid) { - this.Get_Re_Channel() - const loading = this.$baseColorfullLoading() - const row = await getProduct(editorProductid) - this.form = row - loading.close() - this.product = row - this.imageUrl = '' - this.moduleTitle = this.$translateTitle('product.editproduct') - this.custom_status = 'edit' - this.custom_row = row - this.dialogFormVisible = true - this.productid = row.objectId - this.form.desc = row.desc - this.form.category = row.category - this.form.producttemplet = row.producttemplet - this.form.config = _.merge(row.config, { checkList: [] }) - this.form.name = row.name - this.form.nodeType = row.nodeType - this.form.dynamicReg = row.dynamicReg - this.$set(this.form, 'type', row.channel ? row.channel.type : '') - this.$set( - this.form, - 'tdchannel', - row.channel ? row.channel.tdchannel : '' - ) - this.$set( - this.form, - 'taskchannel', - row.channel ? row.channel.taskchannel : '' - ) - this.$set( - this.form, - 'otherchannel', - row.channel ? row.channel.otherchannel : '' - ) - this.$set( - this.form, - 'storageStrategy', - row.channel ? row.channel.storageStrategy : '' + }) + }, + async editorParser(ObjectId) { + this.parserFromId = ObjectId + try { + const { + config = { + parser: [], + }, + thing = {}, + } = await getProduct(ObjectId) + this.parserTableList = config + dgiotlog.log(this.parserTableList) + this.parserDict = _.merge(thing, config) + } catch (e) { + this.parserTableList = {parser: []} + dgiotlog.log('eeeeeeeeeeeee', e) + } + this.parserTable = true + }, + editParse(index, row) { + this.formConfig = row + this.editIndex = index + this.dialogVisible = true + }, + async saveParse(list, type = -1) { + if (type + 2 > 0) { + this.parserTableList.parser[type] = _.merge({}, list) + } + try { + const res = await putProduct(this.parserFromId, { + config: type + 2 > 0 ? this.parserTableList : list, + }) + this.$message({ + showClose: true, + message: this.$translateTitle( + 'user.Save the template successfully' + ), + duration: 2000, + type: 'success', + }) + this.dialogVisible = false + this.parserTable = false + } catch (e) { + this.$baseMessage( + this.$translateTitle('user.Save the template error') + `${e}`, + 'error', + 'dgiot-hey-message-error' ) - this.form.netType = row.netType - this.form.devType = row.devType - this.form.categoryname = row.category ? row.category.name : '' - this.form.productSecret = row.productSecret - this.form.nodeType = row.nodeType - if (row.icon) { - this.imageUrl = row.icon - } + dgiotlog.log(e, 'eeee') + } + dgiotlog.log(list) + }, + previewParse(row) { + this.parserView = true + this.formConfig = row + dgiotlog.log('previewParse', row) + }, + addParse(row) { + row['parser'].push({ + name: uuid(6), + enname: uuid(6), + config: {}, + }) + }, + deleteParse(index, rows) { + rows.splice(index, 1) + }, + async editorDict(ObjectId) { + // const loading = this.$baseColorfullLoading() + this.getAllunit() + const row = await getProduct(ObjectId) + // loading.close() + const {config = {basedate: {}}} = row + this.productInfo = row + dgiotlog.log(' this.parserDict', this.parserDict) + this.editDictTempId = ObjectId + this.dictTempForm = { + name: '', + cType: '', + enable: '1', + description: '', + params: [], + } + this.title_temp_dialog = '创建字典模板' + dgiotlog.log(config) + if (config.basedate && config.basedate.name) { + this.title_temp_dialog = '修改字典模板' + this.dictTempForm = config.basedate + } + this.rule = { + name: [ + { + required: true, + message: '请输入字典模板名称', + trigger: 'blur', + }, + ], + cType: [ + { + required: true, + message: '请输入字典模板类型', + trigger: 'blur', + }, + ], + enable: [ + { + required: true, + message: '请选择状态', + trigger: 'change', + }, + ], + } + dgiotlog.log(this.dictTempForm, 'config') + this.dictVisible = true + }, + async editorProduct(editorProductid) { + this.Get_Re_Channel() + const loading = this.$baseColorfullLoading() + const row = await getProduct(editorProductid) + this.form = row + loading.close() + this.product = row + this.imageUrl = '' + this.moduleTitle = this.$translateTitle('product.editproduct') + this.custom_status = 'edit' + this.custom_row = row + this.dialogFormVisible = true + this.productid = row.objectId + this.form.desc = row.desc + this.form.category = row.category + this.form.producttemplet = row.producttemplet + this.form.config = _.merge(row.config, {checkList: []}) + this.form.name = row.name + this.form.nodeType = row.nodeType + this.form.dynamicReg = row.dynamicReg + this.$set(this.form, 'type', row.channel ? row.channel.type : '') + this.$set( + this.form, + 'tdchannel', + row.channel ? row.channel.tdchannel : '' + ) + this.$set( + this.form, + 'taskchannel', + row.channel ? row.channel.taskchannel : '' + ) + this.$set( + this.form, + 'otherchannel', + row.channel ? row.channel.otherchannel : '' + ) + this.$set( + this.form, + 'storageStrategy', + row.channel ? row.channel.storageStrategy : '' + ) + this.form.netType = row.netType + this.form.devType = row.devType + this.form.categoryname = row.category ? row.category.name : '' + this.form.productSecret = row.productSecret + this.form.nodeType = row.nodeType + if (row.icon) { + this.imageUrl = row.icon + } // this.form.relationApp = this.currentDepartment.name console.log('row', row) @@ -2820,6 +2831,7 @@ this.resetProductForm() this.$refs['form'].resetFields() this.searchProduct() + this.paginationKey = moment(new Date()).valueOf() + '' }, resetProductForm() { this.form = { @@ -2882,6 +2894,7 @@ // row._self.$refs[`popover-${index}`].doClose() setTimeout(() => { this.searchProduct() + this.paginationKey = moment(new Date()).valueOf() + '' }, 1000) } }) @@ -2889,6 +2902,7 @@ }) setTimeout(() => { this.searchProduct() + this.paginationKey = moment(new Date()).valueOf() + '' }, 1000) // this.$baseMessage( // this.$translateTitle('Maintenance.successfully deleted'),