فهرست منبع

预警规则取消必填

yusheng 10 ماه پیش
والد
کامیت
348b6b7d0d

+ 1 - 1
src/views/rulesManagement/earlyWarningRules/components/matter-add.vue

@@ -641,7 +641,7 @@
         let form = deepClone(this.formData);
         console.log(form, 'form');
         if (form.actionList.length < 1) {
-          this.$message.error('请添加事项内容!');
+          this.$message.error('请添加预警内容!');
         }
         let actionListLen = form.actionList.filter((item) => item.matterRuleId);
         if (actionListLen?.length != form.actionList.length) {

+ 153 - 147
src/views/rulesManagement/earlyWarningRules/index.vue

@@ -39,6 +39,10 @@
             </span>
           </template>
         </template>
+        <template v-slot:ruleObjCode="{ row }">
+          {{ rulesObj[row.ruleObjCode] }}
+        </template>
+
         <!-- 操作列 -->
         <template v-slot:action="{ row }">
           <el-link
@@ -47,7 +51,6 @@
             icon="el-icon-finished"
             @click="openEdit('clone', row)"
             v-if="$hasPermission('main:warnrule:update')"
-
           >
             克隆
           </el-link>
@@ -57,7 +60,6 @@
             icon="el-icon-edit"
             @click="openEdit('edit', row)"
             v-if="$hasPermission('main:warnrule:update')"
-
           >
             修改
           </el-link>
@@ -66,7 +68,6 @@
             title="确定要删除此角色吗?"
             @confirm="remove(row)"
             v-if="$hasPermission('main:warnrule:delete')"
-
           >
             <template v-slot:reference>
               <el-link type="danger" :underline="false" icon="el-icon-delete">
@@ -89,161 +90,166 @@
 </template>
 
 <script>
-import tabMixins from '@/mixins/tableColumnsMixin';
-import MatterSearch from './components/matter-search.vue';
-import MatterAdd from './components/matter-add.vue';
-import {
-  getList,
-  getDetail,
-  removeRule,
-  listAllDateUnit
-} from '@/api/ruleManagement/earlyWarning';
-import dictMixins from '@/mixins/dictMixins';
-export default {
-  mixins: [dictMixins, tabMixins],
-  components: {
-    MatterSearch,
-    MatterAdd
-  },
-  data() {
-    return {
-      // 表格列配置
-      columns: [
-        {
-          columnKey: 'index',
-          label: '序号',
-          type: 'index',
-          width: 55,
-          align: 'center',
-          showOverflowTooltip: true,
-          fixed: 'left'
-        },
-        {
-          prop: 'ruleCode',
-          label: '规则编码',
-          align: 'center',
-          showOverflowTooltip: true,
-          minWidth: 110,
-          slot: 'ruleCode'
-        },
-        {
-          prop: 'ruleName',
-          label: '规则名称',
-          align: 'center',
-          showOverflowTooltip: true,
-          minWidth: 110
-        },
-        {//修改此prop名称时,请同步修改columnKey属性和下方selectType方法
-          prop: 'enabled',
-          label: '状态',
-          align: 'center',
-          showOverflowTooltip: true,
-          minWidth: 110,
-          formatter: (_row, _column, cellValue) => {
-            return this.getDictValue('规则状态', _row.enabled);
+  import tabMixins from '@/mixins/tableColumnsMixin';
+  import MatterSearch from './components/matter-search.vue';
+  import MatterAdd from './components/matter-add.vue';
+  import {
+    getList,
+    getDetail,
+    removeRule,
+    listAllRulesObj,
+    listAllDateUnit
+  } from '@/api/ruleManagement/earlyWarning';
+  import dictMixins from '@/mixins/dictMixins';
+
+  export default {
+    mixins: [dictMixins, tabMixins],
+    components: {
+      MatterSearch,
+      MatterAdd
+    },
+    data() {
+      return {
+        rulesObj: [],
+        // 表格列配置
+        columns: [
+          {
+            columnKey: 'index',
+            label: '序号',
+            type: 'index',
+            width: 55,
+            align: 'center',
+            showOverflowTooltip: true,
+            fixed: 'left'
+          },
+          {
+            prop: 'ruleCode',
+            label: '规则编码',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110,
+            slot: 'ruleCode'
+          },
+          {
+            prop: 'ruleName',
+            label: '规则名称',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110
           },
-          filters: [
+          {
+            //修改此prop名称时,请同步修改columnKey属性和下方selectType方法
+            prop: 'enabled',
+            label: '状态',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110,
+            formatter: (_row, _column, cellValue) => {
+              return this.getDictValue('规则状态', _row.enabled);
+            },
+            filters: [
               { value: 1, text: '生效' },
-              { value: 0, text: '失效' },
+              { value: 0, text: '失效' }
             ],
-          filterMultiple: false,
-          columnKey: 'enabled'
-        },
-        {
-          prop: 'alertCycleValue',
-          label: '周期',
-          align: 'center',
-          showOverflowTooltip: true,
-          minWidth: 110,
-          slot: 'alertCycleValue'
-        },
-        {
-          prop: 'createUserName',
-          label: '创建人',
-          align: 'center',
-          showOverflowTooltip: true,
-          minWidth: 110
-        },
-        {
-          prop: 'createTime',
-          label: '创建时间',
-          align: 'center',
-          showOverflowTooltip: true,
-          minWidth: 110,
-          formatter: (_row, _column, cellValue) => {
-            return this.$util.toDateString(cellValue);
+            filterMultiple: false,
+            columnKey: 'enabled'
+          },
+          {
+            prop: 'ruleObjCode',
+            label: '预警对象',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110,
+            slot: 'ruleObjCode'
+          },
+          {
+            prop: 'createUserName',
+            label: '创建人',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+          {
+            prop: 'createTime',
+            label: '创建时间',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110,
+            formatter: (_row, _column, cellValue) => {
+              return this.$util.toDateString(cellValue);
+            }
+          },
+          {
+            columnKey: 'action',
+            label: '操作',
+            width: 230,
+            align: 'center',
+            resizable: false,
+            slot: 'action',
+            showOverflowTooltip: true
           }
-        },
-        {
-          columnKey: 'action',
-          label: '操作',
-          width: 230,
-          align: 'center',
-          resizable: false,
-          slot: 'action',
-          showOverflowTooltip: true
-        }
-      ],
-      // 加载状态
-      loading: false,
-      pageType: 'add',
-      dialogTitle: '',
+        ],
+        // 加载状态
+        loading: false,
+        pageType: 'add',
+        dialogTitle: '',
 
-      cycleUnitOpt: {},
-      pageSize: this.$store.state.tablePageSize,
-      cacheKeyUrl: 'dfb89646-rulesManagement-earlyWarningRules'
-    };
-  },
-  computed: {},
-  created() {
-    // this.requestDict('规则周期');
-    this.requestDict('预警类型');
-    this.requestDict('规则状态');
-    this.getData();
-  },
-  methods: {
-    selectType(value) {
-      let where = {}
-      if (value.enabled.length > 0) {
-        where['enabled'] = value.enabled[0]
-      }
-      this.reload(where)
-    },
-    /* 表格数据源 */
-    datasource({ page, limit, where, order }) {
-      return getList({ pageNum: page, size: limit, ...where });
+        cycleUnitOpt: {},
+        pageSize: this.$store.state.tablePageSize,
+        cacheKeyUrl: 'dfb89646-rulesManagement-earlyWarningRules'
+      };
     },
-    /* 刷新表格 */
-    reload(where) {
-      this.$refs.table.reload({ page: 1, where });
-    },
-    async getData() {
-      const res2 = await listAllDateUnit();
-      this.cycleUnitOpt = res2;
+    computed: {},
+    async created() {
+      // this.requestDict('规则周期');
+      this.requestDict('预警类型');
+      this.requestDict('规则状态');
+      this.getData();
+      this.rulesObj = await listAllRulesObj();
     },
+    methods: {
+      selectType(value) {
+        let where = {};
+        if (value.enabled.length > 0) {
+          where['enabled'] = value.enabled[0];
+        }
+        this.reload(where);
+      },
+      /* 表格数据源 */
+      datasource({ page, limit, where, order }) {
+        return getList({ pageNum: page, size: limit, ...where });
+      },
+      /* 刷新表格 */
+      reload(where) {
+        this.$refs.table.reload({ page: 1, where });
+      },
+      async getData() {
+        const res2 = await listAllDateUnit();
+        this.cycleUnitOpt = res2;
+      },
 
-    remove(row) {
-      removeRule([row.id]).then((res) => {
-        this.$message.success('删除成功!');
-        this.reload();
-      });
-    },
+      remove(row) {
+        removeRule([row.id]).then((res) => {
+          this.$message.success('删除成功!');
+          this.reload();
+        });
+      },
 
-    openEdit(type, row) {
-      this.pageType = type;
-      this.dialogTitle =
-        type == 'add' ? '新建规则' : type == 'edit' ? '编辑规则' : '克隆规则';
-      this.$refs.addMatterRulesRef.openDialog(row, type);
-    },
+      openEdit(type, row) {
+        this.pageType = type;
+        this.dialogTitle =
+          type == 'add' ? '新建规则' : type == 'edit' ? '编辑规则' : '克隆规则';
+        this.$refs.addMatterRulesRef.openDialog(row, type);
+      },
 
-    goDetail({ id }) {
-      this.$router.push({
-        path: '/rulesManagement/earlyWarningRules/details',
-        query: { id }
-      });
+      goDetail({ id }) {
+        this.$router.push({
+          path: '/rulesManagement/earlyWarningRules/details',
+          query: { id }
+        });
+      }
     }
-  }
-};
+  };
 </script>
 
 <style lang="scss" scoped></style>

+ 25 - 23
src/views/rulesManagement/matterRules/components/matter-add.vue

@@ -82,7 +82,7 @@
 
         <el-table
           ref="multipleTable"
-          v-if="formData.ruleType !== 4"
+          v-if="formData.ruleType !== 4 && formData.ruleType != 8"
           :data="formData.ruleItems"
           tooltip-effect="dark"
           border
@@ -562,29 +562,31 @@
             }
             break;
         }
-        if (form.ruleItems && form.ruleItems.length > 0) {
-          this.$refs.contentConfigForm.validate(async (valid) => {
-            if (valid) {
-              // let form = deepClone(this.formData)
-              // form.ruleCycleList = this.$refs.cycleMultipleRef.ruleCycleList
-              // form.ruleItems.forEach(item => {
-              //   if (item.ruleType) {
-              //     item.ruleType = this.ruleTypeObj[item.ruleType.code]
-              //   }
-              // })
-              let res = await saveOrUpdate(form);
-              if (res) {
-                this.$message.success('操作成功!');
-                this.handleClose();
-                this.$emit('done');
-              }
-            } else {
-              this.$message.warning('请将信息补充完整!');
-            }
-          });
-        } else {
-          this.$message.error('请添加事项内容!');
+        if (!form.ruleItems?.length && form.ruleType != 8) {
+          return this.$message.error('请添加事项内容!');
         }
+        if (form.ruleType == 8) {
+          form.ruleItems = [];
+        }
+        this.$refs.contentConfigForm.validate(async (valid) => {
+          if (valid) {
+            // let form = deepClone(this.formData)
+            // form.ruleCycleList = this.$refs.cycleMultipleRef.ruleCycleList
+            // form.ruleItems.forEach(item => {
+            //   if (item.ruleType) {
+            //     item.ruleType = this.ruleTypeObj[item.ruleType.code]
+            //   }
+            // })
+            let res = await saveOrUpdate(form);
+            if (res) {
+              this.$message.success('操作成功!');
+              this.handleClose();
+              this.$emit('done');
+            }
+          } else {
+            this.$message.warning('请将信息补充完整!');
+          }
+        });
       },
 
       chooseModal(clickBomData, index) {