Browse Source

诊断任务解绑和绑定

humingshi-7@163.com 11 months ago
parent
commit
d2b34948ca

+ 20 - 0
src/api/iot/diagnoseMission.js

@@ -17,3 +17,23 @@ export function missionTypeList() {
     method: 'get',
   })
 }
+
+
+//绑定任务
+export function bindMission(query) {
+  return request({
+    url: '/iot/diagnoseMission/bindMission',
+    method: 'post',
+    data: query
+  })
+}
+
+
+//解绑任务
+export function unbindMission(query) {
+  return request({
+    url: '/iot/diagnoseMission/unbindMission',
+    method: 'post',
+    data: query
+  })
+}

+ 141 - 0
src/views/iot/diagnoseMission/dialog.dealAlarm.vue

@@ -0,0 +1,141 @@
+<template>
+  <div class="rule-type">
+    <DialogCom
+      title="设置任务关联摄像机"
+      :visible.sync="isShow"
+      @close="onHide"
+      width="800px"
+    >
+      <div class="page-body">
+        <el-form
+          :model="formData"
+          :rules="formDataRules"
+          size="small"
+          ref="form"
+          label-position="right"
+          label-width="150px"
+          label-prefix=":"
+        >
+          <el-form-item label="任务名称" prop="bindMissionId">
+            <el-select
+              label="任务名称"
+              v-model="formData.bindMissionId"
+              placeholder="请选择任务名称"
+              clearable
+              style="width: 80%;"
+            >
+            <el-option
+                    v-for="dict in deviceTypes"
+                    :key="dict.value"
+                    :label="dict.label"
+                    :value="dict.value"
+                  ></el-option>
+            </el-select>
+          </el-form-item>
+        </el-form>
+      </div>
+
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="onSubmit">确定</el-button>
+        <el-button @click="isShow = false">取消</el-button>
+      </div>
+    </DialogCom>
+  </div>
+</template>
+
+<script>
+import { mapState, mapMutations, mapGetters } from "vuex";
+import {missionTypeList,bindMission} from "@/api/iot/diagnoseMission";
+import { listIdName } from "@/api/system/device";
+export default {
+  dicts: ["alarm_deal_type"],
+  data() {
+    return {
+      id: null,
+      isShow: false,
+      formData: this.reset(),
+      formDataRules: {
+        bindMissionId: [{ required: true, message: "请选择任务名称" }]
+      },
+      // 查询参数
+      queryParams: {
+        checkSub: true,
+        missionCode: null,
+        state: null,
+        bindMissionId: null,
+      },
+      deviceTypes: [],
+      labelStyle: {
+        color: "#000",
+        "text-align": "center",
+        height: "40px",
+        "min-width": "150px",
+        "word-break": "keep-all",
+      },
+    };
+  },
+  props: {},
+  computed: {
+    ...mapGetters(["orgId"]),
+  },
+  methods: {
+    ...mapMutations([]),
+    initDeviceTypeList(){
+          missionTypeList()
+            .then((r) => {
+              // 使用 map 而不是 filter 进行数据转换
+              const transformedList = r.map((item) => ({
+                value: item.value,
+                label: item.label,
+                type: item.type,
+              }));
+
+              // 将转换后的数据推送到 this.deviceTypeList
+              this.deviceTypes.push(...transformedList);
+            })
+            .catch((error) => {
+              // 处理错误
+              console.error('Error fetching device type list:', error);
+            });
+    },
+    reset() {
+      return {
+        bindMissionId:null,
+      };
+    },
+    async show(queryParams, deviceTypes) {
+      this.queryParams = queryParams;
+      this.deviceTypes.push(deviceTypes);
+      this.isShow = true;
+    },
+    // 事件
+    onHide() {
+      this.$refs.form.resetFields();
+      this.formData = this.reset();
+    },
+    onSubmit() {
+      this.$refs.form.validate(async (isValidate) => {
+        if (!isValidate) return;
+        this.queryParams.bindMissionId = this.formData.bindMissionId;
+        await bindMission(this.queryParams);
+        this.$emit("success");
+        this.isShow = false;
+      });
+    },
+  },
+  created() {
+      this.initDeviceTypeList();
+  },
+  mounted() {},
+  components: { },
+};
+</script>
+
+<style lang="scss" scoped>
+.brand_info {
+  .el-form {
+    width: 600px;
+    padding-top: 40px;
+  }
+}
+</style>

+ 36 - 7
src/views/iot/diagnoseMission/index.vue

@@ -76,7 +76,24 @@
                   >重置
                 </el-button>
               </el-col>
-
+              <el-col :span="1.5">
+                <el-button
+                  type="primary"
+                  icon="el-icon-refresh"
+                  size="mini"
+                  @click="unbindMission()"
+                  >解绑任务
+                </el-button>
+              </el-col>
+              <el-col :span="1.5">
+                <el-button
+                  type="primary"
+                  icon="el-icon-refresh"
+                  size="mini"
+                  @click="bindMission()"
+                  >绑定任务
+                </el-button>
+              </el-col>
 
               <el-col :span="1.5">
                 <el-button
@@ -118,7 +135,6 @@
             <el-table-column label="所属主机" align="center" prop="hostName" width="280"/>
             <el-table-column label="任务" align="center" prop="missionName" width="380"/>
           </el-table>
-          <DetailDialog ref="detailDialog" @success="refresh(true)"></DetailDialog>
           <pagination
             v-show="total > 0"
             :total="total"
@@ -129,18 +145,19 @@
         </div>
       </el-col>
     </el-row>
+    <dialog-deal-alarm ref="dealAlarmDialog" @success="getList()"></dialog-deal-alarm>
   </div>
 </template>
 
 <script>
-import { list,missionTypeList} from "@/api/iot/diagnoseMission";
-import  DetailDialog  from "./dialog.detail.vue";
+import { list,missionTypeList,unbindMission} from "@/api/iot/diagnoseMission";
+import DetailDialog  from "./dialog.detail.vue";
+import DialogDealAlarm from "./dialog.dealAlarm.vue";
 import OrgTree from "@/components/orgTree/orgQuerySelector.vue";
-import DataRangePicker from "@/components/dateTime/daterange.picker.vue";
 import { mapGetters } from "vuex";
 import dayjs from "dayjs";
 export default {
-  components: { OrgTree, DataRangePicker,DetailDialog },
+  components: { OrgTree,DialogDealAlarm },
   name: "Task",
   dicts: ["sys_org_type",'sensor_alarm_status','sensor_device_type'],
   data() {
@@ -273,6 +290,7 @@ export default {
       this.queryParams.pageNum = 1;
       this.getList();
     },
+
     /** 重置按钮操作 */
     resetQuery() {
       this.resetForm("queryForm");
@@ -283,7 +301,18 @@ export default {
       this.$refs["orgTree"].setCheckSub(this.queryParams.checkSub);
       this.handleQuery();
     },
-
+    /** 绑定任务 */
+    bindMission() {
+      this.$refs["dealAlarmDialog"].show(this.queryParams, this.deviceTypes);
+    },
+    /** 解绑任务 */
+    unbindMission() {
+      this.loading = true;
+      unbindMission(this.queryParams).then((response) => {
+           this.loading = false;
+           this.getList();
+      });
+    },
     /** 修改按钮操作 */
     lookView(row) {
       this.$refs["detailDialog"].show(row);