dialog.bindMission.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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="bindMissionId">
  20. <el-select
  21. label="任务名称"
  22. v-model="formData.bindMissionId"
  23. placeholder="请选择任务名称"
  24. clearable
  25. style="width: 80%;"
  26. >
  27. <el-option
  28. v-for="dict in deviceTypes"
  29. :key="dict.value"
  30. :label="dict.label"
  31. :value="dict.value"
  32. ></el-option>
  33. </el-select>
  34. </el-form-item>
  35. </el-form>
  36. </div>
  37. <div slot="footer" class="dialog-footer">
  38. <el-button type="primary" @click="onSubmit">确定</el-button>
  39. <el-button @click="isShow = false">取消</el-button>
  40. </div>
  41. </DialogCom>
  42. </div>
  43. </template>
  44. <script>
  45. import { mapState, mapMutations, mapGetters } from "vuex";
  46. import {missionTypeList,bindMission} from "@/api/iot/diagnoseMission";
  47. import { listIdName } from "@/api/system/device";
  48. export default {
  49. dicts: ["alarm_deal_type"],
  50. data() {
  51. return {
  52. id: null,
  53. isShow: false,
  54. formData: this.reset(),
  55. formDataRules: {
  56. bindMissionId: [{ required: true, message: "请选择任务名称",trigger:'blur' }]
  57. },
  58. // 查询参数
  59. queryParams: {
  60. checkSub: true,
  61. missionCode: null,
  62. state: null,
  63. bindMissionId: null,
  64. },
  65. deviceTypes: [],
  66. labelStyle: {
  67. color: "#000",
  68. "text-align": "center",
  69. height: "40px",
  70. "min-width": "150px",
  71. "word-break": "keep-all",
  72. },
  73. };
  74. },
  75. props: {},
  76. computed: {
  77. ...mapGetters(["orgId"]),
  78. },
  79. methods: {
  80. ...mapMutations([]),
  81. reset() {
  82. return {
  83. bindMissionId:null,
  84. };
  85. },
  86. async show(queryParams, deviceTypes) {
  87. this.queryParams = queryParams;
  88. // 使用 map 而不是 filter 进行数据转换
  89. this.deviceTypes = [];
  90. const transformedList = deviceTypes.map((item) => ({
  91. value: item.value,
  92. label: item.label,
  93. type: item.type,
  94. }));
  95. this.deviceTypes.push(...transformedList);
  96. this.isShow = true;
  97. },
  98. // 事件
  99. onHide() {
  100. this.$refs.form.resetFields();
  101. this.formData = this.reset();
  102. },
  103. onSubmit() {
  104. this.$refs.form.validate(async (isValidate) => {
  105. if (!isValidate) return;
  106. this.queryParams.bindMissionId = this.formData.bindMissionId;
  107. const param = this.queryParams;
  108. this.$modal
  109. .confirm("添加符合当前筛选条件的设备到选定的诊断任务,取消和其他任务的关联,确定?")
  110. .then(function () {
  111. return bindMission(param);
  112. })
  113. .then(() => {
  114. this.$modal.msgSuccess("绑定成功");
  115. this.$emit("success");
  116. this.isShow = false;
  117. })
  118. .catch(() => {
  119. });
  120. });
  121. },
  122. },
  123. created() {
  124. },
  125. mounted() {},
  126. components: { },
  127. };
  128. </script>
  129. <style lang="scss" scoped>
  130. .brand_info {
  131. .el-form {
  132. width: 600px;
  133. padding-top: 40px;
  134. }
  135. }
  136. </style>