Browse Source

服务编辑页面修改

zhongxiaoyu 3 years ago
parent
commit
e0131271b7

+ 23 - 9
src/views/systemSettings/views/serviceManagement/mixins/operate.js

@@ -1,7 +1,7 @@
 /*
 /*
  * @Author: Badguy
  * @Author: Badguy
  * @Date: 2022-04-29 09:17:55
  * @Date: 2022-04-29 09:17:55
- * @LastEditTime: 2022-04-29 14:21:27
+ * @LastEditTime: 2022-04-29 16:00:18
  * @LastEditors: your name
  * @LastEditors: your name
  * @Description: 服务相关操作
  * @Description: 服务相关操作
  * have a nice day!
  * have a nice day!
@@ -40,8 +40,15 @@ export default {
     async updateServiceNode(operate, deployNodeID) {
     async updateServiceNode(operate, deployNodeID) {
       const params = {
       const params = {
         operate: operateMap[operate],
         operate: operateMap[operate],
-        serviceID: this.serviceID,
-        deployNodeID
+        serviceID: this.serviceID
+      }
+      if (['update', 'delete'].includes(operate)) {
+        const { DeployID } = this.serviceAndNodeList.find(
+          element => element.serviceID === this.serviceID && element.deployNodeID === deployNodeID
+        )
+        params.DeployID = DeployID
+      } else {
+        params.deployNodeID = deployNodeID
       }
       }
       try {
       try {
         const result = await GeneralDataReception({
         const result = await GeneralDataReception({
@@ -49,7 +56,7 @@ export default {
           dataContent: JSON.stringify(params)
           dataContent: JSON.stringify(params)
         })
         })
         if (Number(result.code) === 0) {
         if (Number(result.code) === 0) {
-          return result.returnData
+          return result.message
         } else {
         } else {
           return Promise.reject(result.message)
           return Promise.reject(result.message)
         }
         }
@@ -60,8 +67,15 @@ export default {
     async updateServiceSource(operate, sourceDataID) {
     async updateServiceSource(operate, sourceDataID) {
       const params = {
       const params = {
         operate: operateMap[operate],
         operate: operateMap[operate],
-        serviceID: this.serviceID,
-        sourceDataID
+        serviceID: this.serviceID
+      }
+      if (['update', 'delete'].includes(operate)) {
+        const { serviceInputSourceDataID } = this.serviceAndSourceList.find(
+          element => element.serviceID === this.serviceID && element.sourceDataID === sourceDataID
+        )
+        params.serviceInputSourceDataID = serviceInputSourceDataID
+      } else {
+        params.sourceDataID = sourceDataID
       }
       }
       try {
       try {
         const result = await GeneralDataReception({
         const result = await GeneralDataReception({
@@ -69,7 +83,7 @@ export default {
           dataContent: JSON.stringify(params)
           dataContent: JSON.stringify(params)
         })
         })
         if (Number(result.code) === 0) {
         if (Number(result.code) === 0) {
-          return result.returnData
+          return result.message
         } else {
         } else {
           return Promise.reject(result.message)
           return Promise.reject(result.message)
         }
         }
@@ -77,11 +91,11 @@ export default {
         console.log('错误', error)
         console.log('错误', error)
       }
       }
     },
     },
-    async updateServiceOutput(operate, outputTarget) {
+    async updateServiceOutput(operate, serviceOutputID) {
       const params = {
       const params = {
         operate: operateMap[operate],
         operate: operateMap[operate],
         serviceID: this.serviceID,
         serviceID: this.serviceID,
-        ...outputTarget
+        serviceOutputID
       }
       }
       try {
       try {
         const result = await GeneralDataReception({
         const result = await GeneralDataReception({

+ 16 - 3
src/views/systemSettings/views/serviceManagement/mixins/query.js

@@ -1,7 +1,7 @@
 /*
 /*
  * @Author: Badguy
  * @Author: Badguy
  * @Date: 2022-04-27 15:54:38
  * @Date: 2022-04-27 15:54:38
- * @LastEditTime: 2022-04-29 13:56:03
+ * @LastEditTime: 2022-04-29 15:57:40
  * @LastEditors: your name
  * @LastEditors: your name
  * @Description: 服务相关数据查询
  * @Description: 服务相关数据查询
  * have a nice day!
  * have a nice day!
@@ -37,7 +37,11 @@ export default {
     return {}
     return {}
   },
   },
   mounted() {
   mounted() {
-    this.serviceID && this.queryAll(this.serviceID)
+    if (this.serviceID) {
+      this.queryAll()
+    } else {
+      this.$router.push('/systemSettings')
+    }
   },
   },
   methods: {
   methods: {
     async myQuery(type, queryID) {
     async myQuery(type, queryID) {
@@ -137,35 +141,44 @@ export default {
     queryOutputListByServiceId(serviceID) {
     queryOutputListByServiceId(serviceID) {
       return this.myQuery(queryMap.outputListByServiceID, serviceID)
       return this.myQuery(queryMap.outputListByServiceID, serviceID)
     },
     },
-    async queryAll(serviceID) {
+    async queryAll(serviceID = this.serviceID) {
       try {
       try {
         const [
         const [
           [serviceInfo],
           [serviceInfo],
           nodeList,
           nodeList,
           checkedNodeList,
           checkedNodeList,
+          serviceAndNodeList,
           protocolList,
           protocolList,
           sourceList,
           sourceList,
           checkedSourceList,
           checkedSourceList,
+          serviceAndSourceList,
           outputList,
           outputList,
           targetList
           targetList
         ] = await Promise.all([
         ] = await Promise.all([
           this.queryServiceByID(serviceID),
           this.queryServiceByID(serviceID),
           this.queryNodeList(),
           this.queryNodeList(),
           this.queryNodeListByServiceId(serviceID),
           this.queryNodeListByServiceId(serviceID),
+          this.queryServiceAndNodeList(),
           this.queryProtocolList(),
           this.queryProtocolList(),
           this.querySourceList(),
           this.querySourceList(),
           this.querySourceListByServiceId(serviceID),
           this.querySourceListByServiceId(serviceID),
+          this.queryServiceAndSourceList(),
           this.queryOutputListByServiceId(serviceID),
           this.queryOutputListByServiceId(serviceID),
           this.queryTargetList()
           this.queryTargetList()
         ])
         ])
         Object.keys(this.serviceForm).forEach(key => {
         Object.keys(this.serviceForm).forEach(key => {
           this.serviceForm[key] = serviceInfo[key]
           this.serviceForm[key] = serviceInfo[key]
         })
         })
+        Object.keys(this.inputForm).forEach(key => {
+          this.inputForm[key] = serviceInfo[key]
+        })
         this.nodeList = nodeList
         this.nodeList = nodeList
         this.checkedNodeKeys = checkedNodeList.map(node => node.deployNodeID)
         this.checkedNodeKeys = checkedNodeList.map(node => node.deployNodeID)
+        this.serviceAndNodeList = serviceAndNodeList
         this.protocolList = protocolList
         this.protocolList = protocolList
         this.sourceList = sourceList
         this.sourceList = sourceList
         this.checkedSourceKeys = checkedSourceList.map(source => source.sourceDataID)
         this.checkedSourceKeys = checkedSourceList.map(source => source.sourceDataID)
+        this.serviceAndSourceList = serviceAndSourceList
         this.outputList = outputList
         this.outputList = outputList
         this.targetList = targetList
         this.targetList = targetList
       } catch (error) {
       } catch (error) {

+ 15 - 15
src/views/systemSettings/views/serviceManagement/serviceEdit.vue

@@ -1,6 +1,6 @@
 <!--
 <!--
  * @Date: 2022-03-24 09:55:13
  * @Date: 2022-03-24 09:55:13
- * @LastEditTime: 2022-04-29 14:21:16
+ * @LastEditTime: 2022-04-29 15:49:40
  * @LastEditors: your name
  * @LastEditors: your name
  * @Description: 服务管理-编辑服务
  * @Description: 服务管理-编辑服务
  * have a nice day!
  * have a nice day!
@@ -461,15 +461,7 @@ const keyMap = {
     checked: 'checkedSourceKeys',
     checked: 'checkedSourceKeys',
     operate: 'updateServiceSource'
     operate: 'updateServiceSource'
   },
   },
-  process: {
-    title: '数据处理',
-    deleteTitle: '数据处理流程',
-    key: 'processID',
-    label: 'processName',
-    list: 'processList',
-    checked: 'checkedProcessKeys',
-    operate: 'updateServiceProcess'
-  },
+  process: {},
   output: {
   output: {
     deleteTitle: '输出目标',
     deleteTitle: '输出目标',
     key: 'serviceOutputID',
     key: 'serviceOutputID',
@@ -483,7 +475,7 @@ export default {
   mixins: [query, operate],
   mixins: [query, operate],
   data() {
   data() {
     return {
     return {
-      serviceID: this.$route.query.serviceID,
+      serviceID: Number(this.$route.query.serviceID),
       operateDialogType: null,
       operateDialogType: null,
       delObj: {},
       delObj: {},
       deleteDialogType: null,
       deleteDialogType: null,
@@ -508,8 +500,10 @@ export default {
       protocolList: [],
       protocolList: [],
       nodeList: [],
       nodeList: [],
       checkedNodeKeys: [],
       checkedNodeKeys: [],
+      serviceAndNodeList: [],
       sourceList: [],
       sourceList: [],
       checkedSourceKeys: [],
       checkedSourceKeys: [],
+      serviceAndSourceList: [],
       processList: [],
       processList: [],
       checkedProcessKeys: [],
       checkedProcessKeys: [],
       outputList: []
       outputList: []
@@ -590,7 +584,7 @@ export default {
       try {
       try {
         await Promise.all([...createArr, ...deleteArr])
         await Promise.all([...createArr, ...deleteArr])
         this.$message.success('成功')
         this.$message.success('成功')
-        this.queryAll()
+        await this.queryAll()
         this.hideOperateDialog()
         this.hideOperateDialog()
       } catch (error) {
       } catch (error) {
         this.$message.error(error)
         this.$message.error(error)
@@ -605,18 +599,24 @@ export default {
       } else {
       } else {
         await this.updateServiceOutput('create', outputTarget)
         await this.updateServiceOutput('create', outputTarget)
       }
       }
-      this.queryAll()
+      await this.queryAll()
       this.hideOperateDialog()
       this.hideOperateDialog()
     },
     },
     hideOperateDialog() {
     hideOperateDialog() {
+      if (this.operateDialogType === 'output') {
+        this.$refs['outputForm'].resetFields()
+      }
       this.operateDialogType = null
       this.operateDialogType = null
     },
     },
     showDeleteDialog(obj, type) {
     showDeleteDialog(obj, type) {
       this.delObj = obj
       this.delObj = obj
       this.deleteDialogType = type
       this.deleteDialogType = type
     },
     },
-    deleteSubmitHandler() {
-      this.dataInMap(this.deleteDialogType, 'operate')('delete', this.delObj)
+    async deleteSubmitHandler() {
+      const message = await this.dataInMap(this.deleteDialogType, 'operate')('delete', this.delObj[this.dataInMap(this.deleteDialogType, 'key')])
+      this.$message.success(message ?? '成功')
+      await this.queryAll()
+      this.deleteDialogType = null
     },
     },
     hideDeleteDialog() {
     hideDeleteDialog() {
       this.deleteDialogType = null
       this.deleteDialogType = null