zhaoke 2 роки тому
батько
коміт
cbdf67dcf3

+ 113 - 0
src/layout/mixin/publicFunc.js

@@ -0,0 +1,113 @@
+import { Query, newData, modifyData, moveData } from "@/api/webApi"
+
+export default {
+  methods: {
+    formatQuery (arrs, key) {
+      const flag = Array.isArray(arrs)
+      const params = []
+      if (flag) {
+        for (let i = 0; i < arrs.length; i++) {
+          const obj = {
+            "left": "(",
+            "column": `${key}`,
+            "comparator": "=",
+            "value": `${arrs[i][key]}`,
+            "right": ")",
+            "connector": "and"
+          }
+          params.push(obj)
+        }
+      } else {
+        params.push({
+          "left": "(",
+          "column": `${key}`,
+          "comparator": "=",
+          "value": `${arrs[key]}`,
+          "right": ")",
+          "connector": "and"
+        })
+      }
+      return params
+    },
+    formatChange (data, event, key) {
+      const datas = []
+      const flag = Array.isArray(data)
+      if (flag) {
+        for (let i = 0; i < data.length; i++) {
+          const obj = {}
+          if (event == 1) {
+            obj.Value = data[i]
+          } else if (event == 2) {
+            obj.Value = data[i]
+            obj.filter = {}
+            obj.filter[key] = data[i][key]
+            if (obj.Value[key]) {
+              delete obj.Value[key]
+            }
+          } else {
+            obj.filter = data[i]
+          }
+          datas.push(obj)
+        }
+      } else {
+        const obj = {}
+        if (event == 1) {
+          obj.Value = data
+        } else if (event == 2) {
+          obj.Value = data
+          obj.filter = {}
+          obj.filter[key] = data[key]
+          if (obj.Value[key]) {
+            delete obj.Value[key]
+          }
+        } else {
+          obj.filter = data
+        }
+        datas.push(obj)
+      }
+      return datas
+    },
+    //查询
+    async getQueryList (id, dataContent = {}, key, pageSize) {
+      try {
+        const { code, columnset, returnData } = await Query({
+          serviceId: id,
+          page: this.pageIndex,
+          pageSize: pageSize ?? this.pageSize,
+          dataContent: this.formatQuery(dataContent, key)
+        })
+        if (code == 0) {
+          return returnData
+        } else {
+          return []
+        }
+      } catch (error) {
+        return []
+      }
+    },
+    //增/删/改
+    async getChangeList (id, data, event, key) {
+      try {
+        const params = {
+          serviceId: id,
+          dataContent: this.formatChange(data, event, key),
+          event: `${event}`,
+        };
+        const { code } =
+          event == 1
+            ? await newData(params)
+            : event == 2
+              ? await modifyData(params)
+              : await moveData(params);
+        if (code == 0) {
+          return 1
+        } else {
+          return 0
+        }
+      } catch (error) {
+        console.log(error)
+        return 0
+      }
+    },
+  }
+}

+ 50 - 26
src/views/newTable/index.vue

@@ -2,7 +2,7 @@
   <div class="data-table" :style="{ marginTop: marginTop }">
     <div :style="dataTableContentStyle" v-loading="loading" element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading" element-loading-background="rgba(0, 0, 0, 0.8)" class="data-table-content">
       <div class="flex">
-        <div :class="dataId ? 'bcTitle': 'manageTitle'">{{ pageTitle }}</div>
+        <div :class="dataId ? 'bcTitle': 'manageTitle'">{{ dataTitle }}</div>
         <el-button size="small" :class="dataId ? 'bcButton':''" :disabled="!dataContent.service_id" @click="handleAdd" plain type="primary">新增</el-button>
       </div>
       <template v-if="tableData.length">
@@ -131,8 +131,10 @@ import Dialog from "@/layout/components/Dialog/index.vue";
 import NoData from "@/components/nodata";
 import { translateDataToTreeAllTreeMsg } from "@/utils/validate";
 import { Query, newData, modifyData, moveData } from "@/api/webApi";
+import pf from '@/layout/mixin/publicFunc'
 export default {
   name: "DataTable",
+  mixins: [pf],
   props: {
     dataContent: {
       type: Object,
@@ -248,8 +250,9 @@ export default {
     dataContent: {
       handler (val) {
         if (val.service_id) {
+          this.queryId = val.service_id
           this.resetTable();
-          this.getColumnData(this.dataId)
+          this.getColumnData(val.service_id)
           // this.getQuery(this.dataId);
         } else {
           this.resetTable();
@@ -314,19 +317,7 @@ export default {
     },
   },
   mounted () {
-    if (this.dataId) {
-      this.queryId = this.dataId;
-      this.pageTitle = this.dataTitle;
-      // this.getQuery(this.dataId);
-      this.getDataSourceId(this.datasource_id)
-    } else {
-      const { qid, title, other } = this.$route.meta
-      this.pageTitle = title;
-      if (qid) {
-        this.queryId = qid;
-        this.getQuery(qid);
-      }
-    }
+    this.getDataSourceId(this.datasource_id)
   },
   updated () {
     this.$refs["table"]?.doLayout();
@@ -337,9 +328,15 @@ export default {
       try {
         const { code, returnData } = await Query({
           serviceId: SERVICE_ID.getTableColumnId,
-          dataContent: {
-            serviceOutPutId: id
-          },
+          dataContent: [{
+            "left": "(",
+            "column": "serviceOutPutId",
+            "comparator": "=",
+            "value": `${this.dataId}`,
+            "right": ")",
+            "connector": "and"
+          }],
+          event: '0'
         });
         if (code == 0) {
           if (returnData && returnData.length) {
@@ -350,7 +347,7 @@ export default {
               this.rowTitle = titleColumn.columnName;
             }
             this.tableCols = returnData;
-            this.getQuery(this.dataId);
+            this.getQuery(id);
           }
         } else {
           this.$message.error("获取表头数据失败");
@@ -448,10 +445,18 @@ export default {
       try {
         this.loading = true;
         const { code, returnData, columnset } = await Query({
-          serviceId: id,
+          serviceId: this.dataId,
           page: ++this.page,
           pageSize: this.pageSize,
-          dataContent: this.dataContent,
+          dataContent: [{
+            "left": "(",
+            "column": "service_id",
+            "comparator": "=",
+            "value": `${id}`,
+            "right": ")",
+            "connector": "and"
+          }],
+          event: '0'
         });
         if (code == 0) {
           if (returnData.length === 0) {
@@ -752,15 +757,31 @@ export default {
       this.form = JSON.parse(JSON.stringify(row));
     },
 
+    successData () {
+      this.$message.success("操作成功");
+      this.resetTable();
+      this.getQuery(this.queryId);
+      this.flag = false;
+      this.rmFlag = false;
+      this.tableObj = {};
+      this.form = {};
+    },
+
     // 新增/编辑-确认
     submitClickHandler () {
-      this.$refs["ruleForm"].validate((valid) => {
+      this.$refs["ruleForm"].validate(async (valid) => {
         if (valid) {
           this.form = Object.assign(this.form, this.dataContent)
           if (this.tableType == "add") {
-            this.generalDataReception(1, this.form);
+            const code = await this.getChangeList(this.dataId, this.form, 1)
+            if (code) {
+              this.successData()
+            }
           } else {
-            this.generalDataReception(2, this.form);
+            const code = await this.getChangeList(this.dataId, this.form, 2, 'library_id')
+            if (code) {
+              this.successData()
+            }
           }
         } else {
           return false;
@@ -775,8 +796,11 @@ export default {
       this.tableObj = row;
     },
     //表格-删除-确认
-    tableRemove () {
-      this.generalDataReception(3, this.tableObj);
+    async tableRemove () {
+      const code = await this.getChangeList(this.dataId, this.tableObj, 3)
+      if (code) {
+        this.successData()
+      }
     },
 
     // 表格-选中行

+ 48 - 51
src/views/systemSettings/views/newMachine/components/table.vue

@@ -2,7 +2,7 @@
   <div class="data-table" :style="{ marginTop: marginTop }">
     <div :style="dataTableContentStyle" v-loading="loading" element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading" element-loading-background="rgba(0, 0, 0, 0.8)" class="data-table-content">
       <div class="flex">
-        <div :class="dataId ? 'bcTitle': 'manageTitle'">{{ pageTitle }}</div>
+        <div :class="dataId ? 'bcTitle': 'manageTitle'">{{ dataTitle }}</div>
       </div>
       <template v-if="tableData.length">
         <div style="height:100%">
@@ -37,9 +37,13 @@
             <el-table-column fixed="right" label="操作" :width="fixedWidth">
               <template slot-scope="scope">
                 <div class="hd-td">
-                  <el-button type="text" size="small" class="rmScs">启用</el-button>
-                  <el-button type="text" @click="handleEdit(scope.row)" size="small" class="rmScs">停用</el-button>
-                  <el-button class="rmSc" type="text" @click="handleRemove(scope.row)" size="small">重置</el-button>
+                  <template v-if="scope.row.serviceType == 4">
+                    <el-button v-if="!scope.row.runState" @click="handleStart(scope.row)" type="text" size="small" class="rmScs">启用</el-button>
+                    <el-button v-else type="text" @click="handleEdit(scope.row)" size="small" class="rmScs">停用</el-button>
+                  </template>
+                  <template v-else>
+                    <el-button class="rmSc" type="text" @click="handleRemove(scope.row)" size="small">重置</el-button>
+                  </template>
                 </div>
               </template>
             </el-table-column>
@@ -58,7 +62,7 @@ import { setTableFilters } from "@/utils/table";
 import Dialog from "@/layout/components/Dialog/index.vue";
 import NoData from "@/components/nodata";
 import { translateDataToTreeAllTreeMsg } from "@/utils/validate";
-import { Query, newData, modifyData, moveData } from "@/api/webApi";
+import { Query, newData, modifyData, moveData, start, stop } from "@/api/webApi";
 export default {
   name: "DataTable",
   props: {
@@ -176,6 +180,7 @@ export default {
     dataContent: {
       handler (obj) {
         if (obj.deployNodeID) {
+          this.queryId = obj.deployNodeID
           this.resetTable();
           this.getColumnData(obj.deployNodeID)
         } else {
@@ -254,7 +259,7 @@ export default {
               "left": "(",
               "column": "serviceOutPutId",
               "comparator": "=",
-              "value": `${id}`,
+              "value": `185`,
               "right": ")",
               "connector": ""
             }
@@ -270,7 +275,7 @@ export default {
               this.rowTitle = titleColumn.columnName;
             }
             this.tableCols = returnData;
-            this.getQuery(this.queryId);
+            this.getQuery(id);
           }
         } else {
           this.$message.error("获取表头数据失败");
@@ -368,13 +373,13 @@ export default {
       try {
         this.loading = true;
         const { code, returnData, columnset } = await Query({
-          serviceId: id,
+          serviceId: 3,
           page: ++this.page,
           pageSize: this.pageSize,
           dataContent: [
             {
               "left": "(",
-              "column": "deployNodeID",
+              "column": "workId",
               "comparator": "=",
               "value": `${id}`,
               "right": ")",
@@ -406,11 +411,11 @@ export default {
         this.loading = false;
       }
     },
-    //表-增/删/改
+    //服务列表-增/删/改
     async generalDataReception (event, data) {
       try {
         const params = {
-          serviceId: this.dataId,
+          serviceId: this.queryId,
           dataContent: data,
           event: `${event}`,
         };
@@ -424,23 +429,34 @@ export default {
           this.$message.success("操作成功");
           this.resetTable();
           this.getQuery(this.queryId);
-          this.flag = false;
-          this.rmFlag = false;
-          this.tableObj = {};
-          this.form = {};
-          // this.$router.go(0);
         } else {
           this.$message.error("操作失败");
-          this.flag = false;
-          this.rmFlag = false;
-          this.tableObj = {};
-          this.form = {};
         }
       } catch (error) {
-        this.flag = false;
-        this.rmFlag = false;
-        this.tableObj = {};
-        this.form = {};
+        this.$message.error("操作失败");
+      }
+    },
+
+    //服务启停
+    async controlService (event, data) {
+      try {
+        const params = {
+          serviceId: data.serviceID
+        };
+        const { code } =
+          event == 1
+            ? await start(params)
+            : await stop(params);
+        if (code == 0) {
+          this.$message.success('操作成功')
+          this.resetTable();
+          this.getColumnData(this.queryId)
+        } else {
+          this.$message.error("操作失败");
+        }
+      } catch (error) {
+        console.log(error)
+        this.$message.error("操作失败");
       }
     },
     // 表格勾选
@@ -676,10 +692,13 @@ export default {
     },
     //表格-编辑
     handleEdit (row) {
-      this.flag = true;
-      this.tableType = "edit";
-      this.tableTitle = "编辑算法配置";
-      this.form = JSON.parse(JSON.stringify(row));
+      row.runState = 0
+      this.controlService(0, row)
+    },
+
+    handleStart (row) {
+      row.runState = 1
+      this.controlService(1, row)
     },
 
     // 新增/编辑-确认
@@ -699,10 +718,7 @@ export default {
     },
     //表格-删除
     handleRemove (row) {
-      this.rmFlag = true;
-      // this.rmTitle = row.className || row.username || row.serviceName || row.queryTemplateName;
-      this.rmTitle = row[this.rowTitle];
-      this.tableObj = row;
+      this.controlService(0, row)
     },
     //表格-删除-确认
     tableRemove () {
@@ -717,25 +733,6 @@ export default {
     handlePreview (row) {
       this.$emit("preview", row);
     },
-    //服务启停
-    async controlService (event, data) {
-      try {
-        const params = {
-          serviceId: data.deployNodeID
-        };
-        const { code } =
-          event == 1
-            ? await start(params)
-            : await stop(params);
-        if (code == 0) {
-          this.generalDataReception(2, data)
-        } else {
-          this.$message.error("操作失败");
-        }
-      } catch (error) {
-        this.$message.error("操作失败");
-      }
-    },
   },
 };
 </script>

+ 1 - 1
src/views/systemSettings/views/newMachine/css/index.scss

@@ -113,7 +113,7 @@
       }
     }
     &-right {
-      flex: 1;
+      width: calc(100% - 376px);
       height: 100%;
       &-top {
         

+ 4 - 2
src/views/systemSettings/views/newMachine/index.vue

@@ -62,7 +62,7 @@
       <div class="newService-content-right">
         <div class="newService-content-right-top">
           <div class="flex">
-            <div class="title">服务配置 {{ dataObj.deployNodeName }}</div>
+            <div class="title">机器配置 {{ dataObj.deployNodeName }}</div>
             <el-button type="primary" @click="handleSave" :disabled="flag" class="bcButton" size="small">保存</el-button>
           </div>
           <div class="demo-form">
@@ -80,7 +80,7 @@
           </div>
         </div>
         <div :style="formInline.serviceType != 4 ? 'height: calc(100% - 180px);':'height: calc(100% - 305px);'" class="newService-content-right-bottom">
-          <Table :dataId="dataId" :dataContent="msgContent" width="860px" tableHeight="calc(100% - 30px)" dataTitle="算法配置" />
+          <Table :dataId="dataId" :dataContent="msgContent" width="860px" tableHeight="calc(100% - 30px)" dataTitle="服务列表" />
         </div>
       </div>
     </div>
@@ -90,10 +90,12 @@
 <script>
 import Table from './components/table.vue'
 import { Query, newData, modifyData, moveData, start, stop } from "@/api/webApi"
+import pf from '@/layout/mixin/publicFunc'
 import * as _ from 'lodash'
 export default {
   name: 'NewService',
   components: { Table },
+  mixins: [pf],
   data () {
     return {
       title: '服务设置',

+ 2 - 5
src/views/systemSettings/views/newService/css/index.scss

@@ -113,13 +113,13 @@
       }
     }
     &-right {
-      flex: 1;
+      width: calc(100% - 376px);
       height: 100%;
       &-top {
         
         background: #ffffff;
         border-radius: 4px;
-        padding: 24px;
+        padding: 24px 24px 0 24px;
         margin-bottom: 16px;
         .title {
           font-size: 20px;
@@ -139,9 +139,6 @@
           .title{
             margin-bottom: 20px;
           }
-          .el-form-item{
-            margin-bottom: 0;
-          }
           margin-top: 0;
         }
       }

+ 38 - 9
src/views/systemSettings/views/newService/index.vue

@@ -82,8 +82,7 @@
               </el-form-item>
             </el-form>
           </div>
-          <div v-if="formInline.serviceType == 4" class="cj-form">
-            <div class="title">采集配置</div>
+          <div class="cj-form">
             <el-form class="flex" style="flex-wrap: wrap;justify-content: flex-start;" :inline="true" :model="formInline">
               <el-form-item label="采集类型">
                 <el-select clearable size="small" style="width: 175px;" v-model="formInline.taskType" placeholder="请选择采集类型">
@@ -121,7 +120,7 @@
             </el-form>
           </div>
         </div>
-        <div :style="formInline.serviceType != 4 ? 'height: calc(100% - 180px);':'height: calc(100% - 305px);'" class="newService-content-right-bottom">
+        <div style="height: calc(100% - 215px);" class="newService-content-right-bottom">
           <Table :dataId="dataId" :dataContent="msgContent" width="860px" tableHeight="calc(100% - 30px)" dataTitle="算法配置" />
         </div>
       </div>
@@ -319,12 +318,30 @@ export default {
     //服务列表-保存
     handleSave () {
       if (this.dataObj.serviceID && this.dataType == 'edit') {
-        this.generalDataReception(2, this.formInline)
+        const obj = {}
+        obj.Value = this.formInline
+        obj.filter = {
+          serviceID: this.dataObj.serviceID
+        }
+        if (obj.Value.serviceID) {
+          delete obj.Value.serviceID
+        }
+        this.generalDataReception(2, [obj])
       } else if (this.dataType == 'add' && this.arrs[this.arrs.length - 1].serviceID) {
         this.formInline.serviceID = this.arrs[this.arrs.length - 1].serviceID
-        this.generalDataReception(2, this.formInline)
+        const obj = {}
+        obj.Value = this.formInline
+        obj.filter = {
+          serviceID: this.formInline.serviceID
+        }
+        if (obj.Value.serviceID) {
+          delete obj.Value.serviceID
+        }
+        this.generalDataReception(2, [obj])
       } else if (this.dataType == 'add') {
-        this.generalDataReception(1, this.formInline)
+        const obj = {}
+        obj.Value = this.formInline
+        this.generalDataReception(1, [obj])
       }
       else {
         this.$message.error('请先选中服务后再操作')
@@ -338,7 +355,9 @@ export default {
           cancelButtonText: '取消',
           type: 'warning'
         }).then(() => {
-          this.generalDataReception(3, this.dataObj)
+          const obj = {}
+          obj.filter = this.dataObj
+          this.generalDataReception(3, [obj])
           this.msgContent = {
             service_id: ''
           }
@@ -362,7 +381,9 @@ export default {
           cancelButtonText: '取消',
           type: 'warning'
         }).then(() => {
-          this.generalDataReception(3, this.arrs[this.arrs.length - 1])
+          const obj = {}
+          obj.filter = this.arrs[this.arrs.length - 1]
+          this.generalDataReception(3, [obj])
           this.msgContent = {
             service_id: ''
           }
@@ -426,7 +447,15 @@ export default {
             ? await start(params)
             : await stop(params);
         if (code == 0) {
-          this.generalDataReception(2, data)
+          const obj = {}
+          obj.Value = data
+          obj.filter = {
+            serviceID: data.serviceID
+          }
+          if (obj.Value.serviceID) {
+            delete obj.Value.serviceID
+          }
+          this.generalDataReception(2, [obj])
         } else {
           this.$message.error("操作失败");
         }