Ver Fonte

iot 服务接入页面代码提交

jingyuanchao há 1 ano atrás
pai
commit
8832790103
2 ficheiros alterados com 55 adições e 22 exclusões
  1. 18 0
      src/api/iot/server.js
  2. 37 22
      src/views/iot/server/index.vue

+ 18 - 0
src/api/iot/server.js

@@ -18,3 +18,21 @@ export function add(query) {
     data: query
   })
 }
+
+// 编辑iot服务
+export function edit(query) {
+  return request({
+    url: '/iot/server/edit',
+    method: 'post',
+    data: query
+  })
+}
+
+
+// iot详情
+export function getIot(id) {
+  return request({
+    url: `/iot/server/${id}`,
+    method: 'get',
+  })
+}

+ 37 - 22
src/views/iot/server/index.vue

@@ -162,9 +162,16 @@
                   type="text"
                   icon="el-icon-view"
                   @click="lookView(scope.row)"
-                  >历史数据</el-button
-                >
+                  >历史数据</el-button>
+                <el-button
+                  size="mini"
+                  type="text"
+                  icon="el-icon-edit-outline"
+                  @click="handleUpdate(scope.row)"
+                >编辑
+                </el-button>
               </template>
+
             </el-table-column>
           </el-table>
           <DetailDialog ref="detailDialog" @success="refresh(true)"></DetailDialog>
@@ -205,6 +212,7 @@
           <el-col :span="24">
             <el-form-item label="所属机构" prop="orgId">
               <tree-select
+                :disabled="disable"
                 v-model="form.orgId"
                 :options="deptOptions"
                 :show-count="true"
@@ -222,7 +230,7 @@
 
       </el-form>
       <div slot="footer" class="dialog-footer">
-        <el-button type="primary" @click="addIot">确 定</el-button>
+        <el-button type="primary" @click="editIot">确 定</el-button>
         <el-button @click="cancel">取 消</el-button>
       </div>
     </DialogCom>
@@ -230,7 +238,7 @@
 </template>
 
 <script>
-import { list,add } from "@/api/iot/server";
+import {list, add, getIot, edit} from "@/api/iot/server";
 import { getLabel } from "./../../commonOption";
 import  DetailDialog  from "./dialog.detail.vue";
 import OrgTree from "@/components/orgTree/orgQuerySelector.vue";
@@ -260,6 +268,7 @@ export default {
       title: "",
       // 是否显示弹出层
       open: false,
+      disable: false,
       // 查询参数
       queryParams: {
         pageNum: 1,
@@ -329,6 +338,7 @@ export default {
     // 取消按钮
     cancel() {
       this.open = false;
+      this.disable = false;
       this.reset();
     },
     // 表单重置
@@ -353,28 +363,37 @@ export default {
       this.getDeptTree();
       this.reset();
       this.open = true;
-      this.title = "新增演练任务";
+      this.title = "新增Iot服务";
     },
-    addIot(){
-
-      add(this.form).then(() => {
-        this.closeDialog();
-        this.getList();
-        this.$modal.msgSuccess("新增成功,等待Iot服务接入!");
+    editIot(){
+      this.$refs["form"].validate((valid) => {
+        if (this.form.id==null){
+          add(this.form).then(() => {
+            this.closeDialog();
+            this.getList();
+            this.$modal.msgSuccess("新增成功,等待Iot服务接入!");
+          })
+        }else {
+          edit(this.form).then(() => {
+            this.closeDialog();
+            this.getList();
+            this.$modal.msgSuccess("编辑成功!");
+          })
+        }
       })
 
+
     },
     /** 修改按钮操作 */
     handleUpdate(row) {
-      // this.initRoleList();
       this.getDeptTree();
       this.reset();
+      this.disable=true;
       const id = row.id || this.ids;
-      getPlan(id).then((response) => {
+      getIot(id).then((response) => {
         this.form = response.data;
-        this.formFileListDefualtValue = this.form.fileList;
         this.open = true;
-        this.title = "编辑演练任务";
+        this.title = "编辑Iot服务";
       });
     },
     /** 重置按钮操作 */
@@ -413,13 +432,9 @@ export default {
     /** 导出按钮操作 */
     handleExport() {
       this.download(
-        "iot/sensor/export",
-        {
-          ...this.queryParams,
-        },
-        `${
-          this.selectedOrgName
-        }-${this.$tab.getCurrentTabName()}-${dayjs().format("YYYYMMDD")}.xlsx`
+        "iot/server/export",
+        {...this.queryParams},
+        `${this.selectedOrgName}-${this.$tab.getCurrentTabName()}-${dayjs().format("YYYYMMDD")}.xlsx`
       );
     },
   },