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

change:
1. 更改通道名称

kindring 2 жил өмнө
parent
commit
eb54132281

+ 42 - 2
web_src/src/components/channelList.vue

@@ -48,6 +48,14 @@
         <el-table-column prop="deviceId" label="设备编号" min-width="200">
         </el-table-column>
         <el-table-column prop="name" label="通道名称" min-width="200">
+          <template slot-scope="scope">
+              <div v-if="scope.row.isEdit">
+                <el-input size="mini" v-model="editName" clearable></el-input>
+                <el-button size="mini" type="text" @click="saveEditName(scope.row)">保存</el-button>
+                <el-button size="mini" type="text" @click="exitEditName(scope.row)">取消</el-button>
+              </div>
+              <span v-else @click="toEditMode(scope.row)">{{ scope.row.name }}</span>
+          </template>
         </el-table-column>
         <el-table-column label="快照" min-width="120">
           <template v-slot:default="scope">
@@ -167,6 +175,7 @@ export default {
       showTree: false,
       loadSnap: {},
       isUsePs: true,
+      editName: '',
     };
   },
 
@@ -228,8 +237,13 @@ export default {
         }
       }).then(function (res) {
         if (res.data.code === 0) {
+          let list = res.data.data.list;
           that.total = res.data.data.total;
-          that.deviceChannelList = res.data.data.list;
+          list.forEach(item=>{
+            // 是否为编辑状态
+            item.isEdit = false;
+          });
+          that.deviceChannelList = list;
           // 防止出现表格错位
           that.$nextTick(() => {
             that.$refs.channelListTable.doLayout();
@@ -447,7 +461,33 @@ export default {
     closeHandle(){
       // 刷新页面
       this.refresh();
-    }
+    },
+    saveEditName(row){
+      if (this.editName === "") {
+        this.$message({
+          message: '名称不能为空',
+          type: 'warning'
+        });
+        return;
+      }
+      row.name = this.editName;
+      this.updateChannel(row);
+      row.isEdit = false;
+      this.editName = "";
+      this.$notify.info({
+        title: 'Tips',
+        message: '在编辑通道名称后,请前往设备编辑界面选择不跟随sip更新数据,用以持久化数据',
+      })
+    },
+    exitEditName(row){
+      row.isEdit = false;
+      this.editName = "";
+    },
+    toEditMode(row){
+      row.isEdit = true;
+      this.editName = row.name;
+    },
+
 
   }
 };