dialog.unbindThreshold.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <template>
  2. <div class="rule-type">
  3. <DialogCom
  4. title="解绑阈值关联摄像机"
  5. :visible.sync="isShow"
  6. @close="onHide"
  7. width="800px"
  8. >
  9. <div class="page-body">
  10. <el-form
  11. :model="formData"
  12. :rules="formDataRules"
  13. size="small"
  14. ref="form"
  15. label-position="right"
  16. label-width="150px"
  17. label-prefix=":"
  18. >
  19. <el-form-item label="阈值名称" prop="bindThresholdCodes">
  20. <el-select
  21. label="阈值名称"
  22. v-model="formData.bindThresholdCodes"
  23. placeholder="请选择阈值名称"
  24. clearable
  25. multiple
  26. style="width: 80%;"
  27. >
  28. <el-option
  29. v-for="dict in deviceTypes"
  30. :key="dict.value"
  31. :label="dict.label"
  32. :value="dict.value"
  33. ></el-option>
  34. </el-select>
  35. </el-form-item>
  36. </el-form>
  37. </div>
  38. <div slot="footer" class="dialog-footer">
  39. <el-button type="primary" @click="onSubmit">确定</el-button>
  40. <el-button @click="isShow = false">取消</el-button>
  41. </div>
  42. </DialogCom>
  43. </div>
  44. </template>
  45. <script>
  46. import { mapState, mapMutations, mapGetters } from "vuex";
  47. import {thresholdTypeList,unbindThreshold} from "@/api/iot/diagnoseThreshold";
  48. import { listIdName } from "@/api/system/device";
  49. export default {
  50. dicts: ["alarm_deal_type"],
  51. data() {
  52. return {
  53. id: null,
  54. isShow: false,
  55. formData: this.reset(),
  56. formDataRules: {
  57. bindThresholdCodes: [{ required: true, message: "请选择阈值名称" }]
  58. },
  59. // 查询参数
  60. queryParams: {
  61. checkSub: true,
  62. missionCode: null,
  63. state: null,
  64. bindThresholdCodes: [],
  65. },
  66. deviceTypes: [],
  67. labelStyle: {
  68. color: "#000",
  69. "text-align": "center",
  70. height: "40px",
  71. "min-width": "150px",
  72. "word-break": "keep-all",
  73. },
  74. };
  75. },
  76. props: {},
  77. computed: {
  78. ...mapGetters(["orgId"]),
  79. },
  80. methods: {
  81. ...mapMutations([]),
  82. initDeviceTypeList(){
  83. thresholdTypeList()
  84. .then((r) => {
  85. // 使用 map 而不是 filter 进行数据转换
  86. const transformedList = r.map((item) => ({
  87. value: item.value,
  88. label: item.label,
  89. type: item.type,
  90. }));
  91. // 将转换后的数据推送到 this.deviceTypeList
  92. this.deviceTypes.push(...transformedList);
  93. })
  94. .catch((error) => {
  95. // 处理错误
  96. console.error('Error fetching device type list:', error);
  97. });
  98. },
  99. reset() {
  100. return {
  101. bindThresholdCodes:null,
  102. };
  103. },
  104. async show(queryParams, deviceTypes) {
  105. this.queryParams = queryParams;
  106. this.deviceTypes.push(deviceTypes);
  107. this.isShow = true;
  108. },
  109. // 事件
  110. onHide() {
  111. this.$refs.form.resetFields();
  112. this.formData = this.reset();
  113. },
  114. onSubmit() {
  115. this.$refs.form.validate(async (isValidate) => {
  116. if (!isValidate) return;
  117. this.queryParams.bindThresholdCodes = this.formData.bindThresholdCodes;
  118. const param = this.queryParams;
  119. this.$modal
  120. .confirm("解绑符合当前筛选条件的设备选定的诊断阈值,不可恢复,确定执行?")
  121. .then(function () {
  122. return unbindThreshold(param);
  123. })
  124. .then(() => {
  125. this.$modal.msgSuccess("解绑成功");
  126. this.$emit("success");
  127. this.isShow = false;
  128. })
  129. .catch(() => {
  130. });
  131. });
  132. },
  133. },
  134. created() {
  135. this.initDeviceTypeList();
  136. },
  137. mounted() {},
  138. components: { },
  139. };
  140. </script>
  141. <style lang="scss" scoped>
  142. .brand_info {
  143. .el-form {
  144. width: 600px;
  145. padding-top: 40px;
  146. }
  147. }
  148. </style>