Kaynağa Gözat

预警修改

yijing 1 yıl önce
ebeveyn
işleme
278641b6c5

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

@@ -56,24 +56,24 @@
           <el-col :span="8">
             <el-form-item label="周期" prop="alertCycleValue">
               <el-col :span="16">
-                <el-input-number
+                <el-input
                   v-model="formData.alertCycleValue"
                   placeholder="请输入"
                   size="small"
-                  :min="0"
-                  :controls="false"
-                  style="width: 100%"
+                  @input="handleInput"
                 />
               </el-col>
               <el-col :span="8">
-                <el-select v-model="formData.alertCycleUnit" size="small">
-                  <el-option
-                    v-for="(value, key) in cycleUnitOpt"
-                    :key="key"
-                    :label="value"
-                    :value="key"
-                  />
-                </el-select>
+                <el-form-item prop="alertCycleUnit" label-width="0px">
+                  <el-select v-model="formData.alertCycleUnit" size="small">
+                    <el-option
+                      v-for="(value, key) in cycleUnitOpt"
+                      :key="key"
+                      :label="value"
+                      :value="key"
+                    />
+                  </el-select>
+                </el-form-item>
               </el-col>
             </el-form-item>
           </el-col>
@@ -88,14 +88,6 @@
                 <el-option label="生效" :value="1">生效</el-option>
                 <el-option label="失效" :value="0">失效</el-option>
               </el-select>
-              <!-- <el-switch
-                v-model="formData.enabled"
-                active-text="生效"
-                inactive-text="失效"
-                :active-value="1"
-                :inactive-value="0"
-              >
-              </el-switch> -->
             </el-form-item>
           </el-col>
         </el-row>
@@ -162,6 +154,9 @@
                 <el-input
                   v-model="scope.row.thresholdValue"
                   placeholder="请输入"
+                  @input="
+                    handleInputByTable(scope.row.thresholdValue, scope.$index)
+                  "
                 ></el-input>
               </el-form-item>
             </template>
@@ -255,11 +250,7 @@
   import {
     saveOrUpdate,
     getCode,
-    getDetail,
-    listAllRulesObj,
-    listAllDateUnit,
-    listAllActionType,
-    listAllAlertLevel
+    getDetail
   } from '@/api/ruleManagement/earlyWarning';
   import { notifyTemplatePageAPI } from '@/api/notifyManage';
   import { getUserPage } from '@/api/system/organization';
@@ -311,6 +302,9 @@
           ruleObjCode: [
             { required: true, message: '请选择预警对象', trigger: 'blur' }
           ],
+          alertCycleUnit: [
+            { required: true, message: '请输入周期单位', trigger: 'blur' }
+          ],
           alertCycleValue: [
             { required: true, message: '请输入周期', trigger: 'blur' }
           ],
@@ -333,10 +327,11 @@
         isBindPlan: '',
         managerData: [],
         templateData: [],
+        NumberOfPeople: '',
+
         allRulesData: {},
         cycleUnitOpt: {},
         operationTypeData: {},
-        NumberOfPeople: '',
         allAlertLevelData: {}
       };
     },
@@ -345,22 +340,52 @@
       this.gettemplateList();
       this.getInfo();
     },
-
+    mounted() {
+      const str1 = localStorage.getItem('allRulesData');
+      if (str1) {
+        this.allRulesData = JSON.parse(str1);
+      }
+      const str2 = localStorage.getItem('cycleUnitOpt');
+      if (str2) {
+        this.cycleUnitOpt = JSON.parse(str2);
+      }
+      const str3 = localStorage.getItem('operationTypeData');
+      if (str3) {
+        this.operationTypeData = JSON.parse(str3);
+      }
+      const str4 = localStorage.getItem('allAlertLevelData');
+      if (str4) {
+        this.allAlertLevelData = JSON.parse(str4);
+      }
+    },
     methods: {
-      async getAllRulesObj() {
-        const res = await listAllRulesObj();
-        this.allRulesData = res;
-      },
-      async getAllDateUnit() {
-        const res = await listAllDateUnit();
-        this.cycleUnitOpt = res;
+      handleInput(value) {
+        //表单输入框 只保留数字和小数点
+        // const filteredValue = value.replace(/[^0-9.]/g, '');
+        // let finalValue = '';
+        // const dotIndex = filteredValue.indexOf('.');
+        // if (dotIndex !== -1) {
+        //   finalValue = filteredValue.slice(0, dotIndex + 3);
+        // } else {
+        //   finalValue = filteredValue;
+        // }
+
+        // 只能输入数字
+        this.formData.alertCycleValue = value.replace(/[^0-9]/g, '');
       },
-      async getAllActionType() {
-        const res = await listAllActionType();
-        this.operationTypeData = res;
-        const res2 = await listAllAlertLevel();
-        this.allAlertLevelData = res2;
+      handleInputByTable(value, index) {
+        // 表内限制输入框 只保留数字和小数点
+        const filteredValue = value.replace(/[^0-9.]/g, '');
+        let finalValue = '';
+        const dotIndex = filteredValue.indexOf('.');
+        if (dotIndex !== -1) {
+          finalValue = filteredValue.slice(0, dotIndex + 3);
+        } else {
+          finalValue = filteredValue;
+        }
+        this.formData.actionList[index].thresholdValue = finalValue;
       },
+
       handleAddInfo(row, index) {
         this.formData.actionList[index].targetAddress = '';
         this.formData.actionList[index].targetAddressName = '';
@@ -397,7 +422,10 @@
           pageNum: 1,
           size: 999
         });
-        this.templateData = res?.list;
+        if (res?.list) {
+          this.templateData = res.list;
+          localStorage.setItem('templateData', JSON.stringify(res.list));
+        }
       },
       async getInfo() {
         getUserPage({
@@ -408,9 +436,7 @@
       },
       async openDialog(row, type) {
         this.isBindPlan = type;
-        await this.getAllRulesObj();
-        await this.getAllDateUnit();
-        await this.getAllActionType();
+        // await this.getAllData();
         if (type != 'add') {
           this.getRuleInfo(row.id, type);
         } else {

+ 115 - 42
src/views/rulesManagement/earlyWarningRules/details.vue

@@ -9,26 +9,45 @@
           <el-row>
             <el-col :span="6">
               <el-form-item label="规则编码">
-                <span> {{ infoData.code }} </span>
+                <span> {{ infoData.ruleCode || '' }} </span>
               </el-form-item>
             </el-col>
             <el-col :span="6">
               <el-form-item label="规则名称">
-                <span> {{ infoData.name }} </span>
+                <span> {{ infoData.ruleName || '' }} </span>
               </el-form-item>
             </el-col>
             <el-col :span="6">
-              <el-form-item label="规则类型">
-                <span>
-                  {{ getDictValue('规则类型', infoData.ruleType) }}
-                </span>
+              <el-form-item label="预警对象">
+                <template v-for="(value, key) in allRulesData">
+                  <span v-if="key == infoData.ruleObjCode">{{
+                    value + '-' + key
+                  }}</span>
+                </template>
+              </el-form-item>
+            </el-col>
+            <el-col :span="6">
+              <el-form-item label="周期">
+                <span> {{ infoData.alertCycleValue || '' }}</span>
+                <template v-if="infoData.alertCycleValue">
+                  <span v-for="(value, key) in cycleUnitOpt">
+                    <span v-if="key == infoData.alertCycleUnit">
+                      {{ value }}</span
+                    >
+                  </span>
+                </template>
               </el-form-item>
             </el-col>
             <el-col :span="6">
               <el-form-item label="状态">
-                <span class="primary-text" v-if="infoData.status">生效</span>
-                <span class="danger-text" v-else-if="!infoData.status"
-                  >失效</span
+                <span>
+                  {{
+                    infoData.enabled == 1
+                      ? '生效'
+                      : infoData.enabled == 0
+                      ? '失效'
+                      : ''
+                  }}</span
                 >
               </el-form-item>
             </el-col>
@@ -43,17 +62,8 @@
               </el-form-item>
             </el-col>
           </el-row>
-
-          <el-row>
-          <el-col :span="24">
-            <el-form-item label="巡点检周期">
-              <rule-cycle :formData="infoData" />
-            </el-form-item>
-          </el-col>
-          </el-row>
-          
         </div>
-        <template v-if="!(infoData.ruleType && infoData.ruleType.code == 4)">
+        <template>
           <div class="basic-details-title">
             <span class="border-span">内容配置</span>
           </div>
@@ -65,13 +75,42 @@
             border
             :header-cell-style="{ background: '#F0F3F3' }"
           >
-            <el-table-column type="index" label="序号" width="60" />
-            <el-table-column prop="minWarningValue" label="预警值" />
-            <el-table-column prop="warningUnit" label="预警时间单位" />
-            <el-table-column prop="urgent" label="紧急程度" />
-            <el-table-column prop="name" label="检测事项" />
-            <el-table-column prop="content" label="检测内容" />
-            <el-table-column prop="norm" label="检测标准" />
+            <el-table-column
+              type="index"
+              align="center"
+              label="序号"
+              width="60"
+            />
+            <el-table-column
+              prop="targetAddressName"
+              label="通知人"
+              width="120"
+            />
+            <el-table-column
+              align="center"
+              prop="alertLevel"
+              label="预警级别"
+              width="120"
+            />
+            <el-table-column
+              align="center"
+              prop="thresholdValue"
+              label="阈值"
+              width="120"
+            />
+            <el-table-column
+              align="center"
+              prop="actionTypeName"
+              label="操作类型"
+              width="120"
+            />
+            <el-table-column
+              align="center"
+              prop="alertMessageTempateCodeName"
+              label="模板编码"
+              width="320"
+            />
+            <el-table-column align="center" prop="content" label="内容" />
           </el-table>
         </template>
       </div>
@@ -83,7 +122,10 @@
 <script>
   import dictMixins from '@/mixins/dictMixins';
   import RuleCycle from './components/rule-cycle';
-  import { getDetail } from '@/api/ruleManagement/earlyWarning';
+  import {
+    getDetail,
+    listAllRulesObj
+  } from '@/api/ruleManagement/earlyWarning';
   export default {
     mixins: [dictMixins],
     components: { RuleCycle },
@@ -92,32 +134,63 @@
         num: 1,
         dialogVisible: false,
         infoData: {},
-        form: {},
-        type: [],
         tableData: [],
-        ruleTypeObj: {
-          1: '巡点检规则',
-          2: '保养规则',
-          4: '盘点规则'
-        }
+
+        allRulesData: {},
+        cycleUnitOpt: {},
+        operationTypeData: {},
+        allAlertLevelData: {},
+        templateData: []
       };
     },
     async created() {
-      this.getInfo();
-      this.requestDict('规则类型');
+      await this.getAll();
+      if (this.$route.query.id) this.getInfo();
     },
+    mounted() {},
     methods: {
-      delete() {},
-      // 点击切换事件
-      tab(index) {
-        this.num = index;
+      getAll() {
+        const str1 = localStorage.getItem('allRulesData');
+        if (str1) {
+          this.allRulesData = JSON.parse(str1);
+        }
+        const str2 = localStorage.getItem('cycleUnitOpt');
+        if (str2) {
+          this.cycleUnitOpt = JSON.parse(str2);
+        }
+        const str3 = localStorage.getItem('operationTypeData');
+        if (str3) {
+          this.operationTypeData = JSON.parse(str3);
+        }
+        const str4 = localStorage.getItem('allAlertLevelData');
+        if (str4) {
+          this.allAlertLevelData = JSON.parse(str4);
+        }
+        const str5 = localStorage.getItem('templateData');
+        if (str4) {
+          this.templateData = JSON.parse(str5);
+        }
+        console.log(this.templateData, 'this.templateData');
       },
-
       // 表格数据
       async getInfo() {
         const data = await getDetail(this.$route.query.id);
-        this.tableData = data.ruleItems;
         this.infoData = data;
+        data?.actionList.forEach((ele) => {
+          for (const key in this.operationTypeData) {
+            if (key == ele.actionType) {
+              ele.actionTypeName = this.operationTypeData[key];
+            }
+          }
+
+          this.templateData.forEach((item) => {
+            if (item.code == ele.alertMessageTempateCode) {
+              ele.alertMessageTempateCodeName = item.name + '-' + item.code;
+              ele.content = item.content;
+            }
+          });
+        });
+        this.tableData = data.actionList;
       }
     }
   };

+ 30 - 21
src/views/rulesManagement/earlyWarningRules/index.vue

@@ -85,7 +85,10 @@
     getList,
     getDetail,
     removeRule,
-    listAllDateUnit
+    listAllDateUnit,
+    listAllRulesObj,
+    listAllActionType,
+    listAllAlertLevel
   } from '@/api/ruleManagement/earlyWarning';
   import dictMixins from '@/mixins/dictMixins';
   export default {
@@ -132,17 +135,6 @@
               return this.getDictValue('规则状态', _row.enabled);
             }
           },
-          // {
-          //   prop: 'ruleType',
-          //   label: '预警类型',
-          //   align: 'center',
-          //   showOverflowTooltip: true,
-          //   slot: 'enable',
-          //   minWidth: 110,
-          //   formatter: (_row, _column, cellValue) => {
-          //     return this.getDictValue('预警类型', _row.ruleType);
-          //   }
-          // },
           {
             prop: 'alertCycleValue',
             label: '周期',
@@ -150,10 +142,6 @@
             showOverflowTooltip: true,
             minWidth: 110,
             slot: 'alertCycleValue'
-
-            // formatter: (_row, _column, cellValue) => {
-            //   return this.getDictValue('规则周期', _row.cycleType);
-            // }
           },
           {
             prop: 'createUserName',
@@ -186,7 +174,11 @@
         loading: false,
         pageType: 'add',
         dialogTitle: '',
-        cycleUnitOpt: {}
+
+        allRulesData: {},
+        cycleUnitOpt: {},
+        operationTypeData: {},
+        allAlertLevelData: {}
       };
     },
     computed: {},
@@ -194,7 +186,7 @@
       // this.requestDict('规则周期');
       this.requestDict('预警类型');
       this.requestDict('规则状态');
-      this.getAllDateUnit();
+      this.getAllData();
     },
     methods: {
       /* 表格数据源 */
@@ -205,10 +197,27 @@
       reload(where) {
         this.$refs.table.reload({ page: 1, where });
       },
-      async getAllDateUnit() {
-        const res = await listAllDateUnit();
-        this.cycleUnitOpt = res;
+
+      async getAllData() {
+        try {
+          const res1 = await listAllRulesObj();
+          this.allRulesData = res1;
+          localStorage.setItem('allRulesData', JSON.stringify(res1));
+          const res2 = await listAllDateUnit();
+          this.cycleUnitOpt = res2;
+          localStorage.setItem('cycleUnitOpt', JSON.stringify(res2));
+          const res3 = await listAllActionType();
+          this.operationTypeData = res3;
+          localStorage.setItem('operationTypeData', JSON.stringify(res3));
+          const res4 = await listAllAlertLevel();
+          this.allAlertLevelData = res4;
+          localStorage.setItem('allAlertLevelData', JSON.stringify(res4));
+        } catch (error) {
+          console.error('Failed to load data:', error);
+          throw error;
+        }
       },
+
       remove(row) {
         removeRule([row.id]).then((res) => {
           this.$message.success('删除成功!');