Эх сурвалжийг харах

服务编辑-输出项编辑修改

zhongxiaoyu 2 жил өмнө
parent
commit
e29b621464

+ 18 - 8
src/views/systemSettings/views/serviceManagement/mixins/operate.js

@@ -1,7 +1,7 @@
 /*
  * @Author: Badguy
  * @Date: 2022-04-29 09:17:55
- * @LastEditTime: 2022-05-11 17:28:40
+ * @LastEditTime: 2022-05-12 16:46:54
  * @LastEditors: your name
  * @Description: 服务相关操作
  * have a nice day!
@@ -93,13 +93,23 @@ export default {
       }
     },
     async updateServiceOutput(operate, outputTarget) {
+      const { dataOutputConfig, outputCondition, protocolID, serviceOutputID, targetdataID } = outputTarget
       const params = {
-        operate: operateMap[operate],
-        serviceID: this.serviceID,
-        ...outputTarget
+        operate: operateMap[operate]
       }
-      if (operate === 'update') {
-        params.serviceOutputID = outputTarget.serviceOutputID
+      if (operate !== 'create') {
+        Object.assign(params, {
+          serviceOutputID
+        })
+      }
+      if (operate !== 'delete') {
+        Object.assign(params, {
+          protocolID,
+          dataOutputConfig,
+          targetdataID,
+          outputCondition,
+          serviceID: this.serviceID
+        })
       }
       try {
         const result = await GeneralDataReception({
@@ -107,9 +117,9 @@ export default {
           dataContent: JSON.stringify(params)
         })
         if (Number(result.code) === 0) {
-          this.$message.success(result.message ?? '成功')
+          return result.message
         } else {
-          this.$message.error(result.message ?? '失败')
+          return Promise.reject(result.message)
         }
       } catch (error) {
         console.log('错误', error)

+ 24 - 14
src/views/systemSettings/views/serviceManagement/serviceEdit.vue

@@ -1,6 +1,6 @@
 <!--
  * @Date: 2022-03-24 09:55:13
- * @LastEditTime: 2022-05-12 13:53:55
+ * @LastEditTime: 2022-05-12 16:46:25
  * @LastEditors: your name
  * @Description: 服务管理-编辑服务
  * have a nice day!
@@ -582,9 +582,10 @@ export default {
       this.operateDialogType = type
     },
     btnEditClickHandler(obj, type) {
-      Object.keys(this.outputForm).forEach(key => {
-        this.outputForm[key] = obj[key]
-      })
+      // Object.keys(this.outputForm).forEach(key => {
+      //   this.outputForm[key] = obj[key]
+      // })
+      this.outputForm = obj
       this.showOperateDialog(type)
     },
     // 关联编辑-提交
@@ -611,13 +612,19 @@ export default {
       const outputTarget = {
         ...this.outputForm
       }
-      if (typeof outputTarget.serviceOutputID !== 'undefined') {
-        await this.updateServiceOutput('update', outputTarget)
-      } else {
-        await this.updateServiceOutput('create', outputTarget)
+      try {
+        let message
+        if (outputTarget.serviceOutputID ?? true) {
+          message = await this.updateServiceOutput('update', outputTarget)
+        } else {
+          message = await this.updateServiceOutput('create', outputTarget)
+        }
+        this.$message.success(message ?? '成功')
+        await this.queryAll()
+        this.hideOperateDialog()
+      } catch (error) {
+        this.$message.error(error)
       }
-      await this.queryAll()
-      this.hideOperateDialog()
     },
     // 关联编辑-隐藏弹框
     hideOperateDialog() {
@@ -633,10 +640,13 @@ export default {
     },
     // 关联删除-提交
     async deleteSubmitHandler() {
-      const message = await this.dataInMap(this.deleteDialogType, 'operate')(
-        'delete',
-        this.delObj[this.dataInMap(this.deleteDialogType, 'key')]
-      )
+      const operate = this.dataInMap(this.deleteDialogType, 'operate')
+      let message
+      if (this.deleteDialogType === 'output') {
+        message = await operate('delete', this.delObj)
+      } else {
+        message = await operate('delete', this.delObj[this.dataInMap(this.deleteDialogType, 'key')])
+      }
       this.$message.success(message ?? '成功')
       await this.queryAll()
       this.hideDeleteDialog()