Ver Fonte

Merge branch 'dev' of http://110.41.163.243:9980/kd-aiot/kd-aiot-frontend into dev

chencc há 1 ano atrás
pai
commit
c84cd799ee

+ 32 - 4
src/api/ruleManagement/earlyWarning.js

@@ -1,8 +1,34 @@
 import request from '@/utils/request';
 
+// 操作类型 
+export async function listAllActionType(params) {
+  const res = await request.get(`/main/alertrules/listAllActionType/`, params);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+export async function listAllDateUnit(params) {
+  const res = await request.get(`/main/alertrules/listAllDateUnit/`, params);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+// 预警对象
+export async function listAllRulesObj(params) {
+  const res = await request.get(`/main/alertrules/listAllRulesObj/`, params);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
 // 更新或保存
 export async function saveOrUpdate(data) {
-  const res = await request.post('/main/warnrule/save', data);
+  const res = await request.post('/main/alertrules/save', data);
   if (res.data.code == 0) {
     return res.data;
   }
@@ -21,7 +47,7 @@ export async function getCode(code) {
 // 获取规则列表页
 export async function getList(data) {
   let par = new URLSearchParams(data);
-  const res = await request.get(`/main/warnrule/page?` + par, {});
+  const res = await request.get(`/main/alertrules/page?` + par, {});
   if (res.data.code == 0) {
     return res.data.data;
   }
@@ -30,7 +56,7 @@ export async function getList(data) {
 
 // 获取规则详情
 export async function getDetail(id) {
-  const res = await request.get(`/main/warnrule/getById/` + id, {});
+  const res = await request.get(`/main/alertrules/getById/` + id, {});
   if (res.data.code == 0) {
     return res.data.data;
   }
@@ -41,7 +67,9 @@ export async function getDetail(id) {
  * 删除事项
  */
 export async function removeRule(data) {
-  const res = await request.delete('/main/warnrule/delete', { data });
+  const res = await request.delete('/main/alertrules/delete', {
+    data
+  });
   if (res.data.code == 0) {
     return res.data.data;
   }

+ 54 - 26
src/views/material/BOMmanage/components/detailedList.vue

@@ -1,7 +1,7 @@
 <template>
   <div class="ele-body">
     <BOMSearch @search="reload" :statusOpt="statusOpt" />
-   
+
     <ele-pro-table
       ref="table"
       :columns="columns"
@@ -25,11 +25,13 @@
               placeholder="请输入"
               v-model.number="attributeData.baseCount"
             >
-              <template #append> {{ attributeData.category &&  attributeData.category.measuringUnit }}</template>
+              <template #append>
+                {{
+                  attributeData.category && attributeData.category.measuringUnit
+                }}</template
+              >
             </el-input>
-        
-           
-         </div>
+          </div>
         </div>
       </template>
 
@@ -62,8 +64,6 @@
         </el-select>
       </template>
 
-
-      
       <template v-slot:attributeType="{ row }">
         <el-select
           v-model="row.attributeType"
@@ -81,7 +81,6 @@
         </el-select>
       </template>
 
-
       <template v-slot:materielDesignation="{ row }">
         <el-input
           v-model="row.materielDesignation"
@@ -135,6 +134,11 @@
     </ele-pro-table>
 
     <bomTreeDialog ref="bomTreeDialogRef" @reload="bomClose" />
+
+    <standardOutput
+      ref="standardOutputRefs"
+      @selection="chooseStandardList"
+    ></standardOutput>
   </div>
 </template>
 
@@ -149,9 +153,11 @@
   import { getByCode } from '@/api/system/dictionary-data';
 
   import bomTreeDialog from './bomTreeDialog.vue';
+
+  import standardOutput from './standardOutput.vue';
   export default {
     name: 'SystemDictionary',
-    components: { BOMSearch, bomTreeDialog },
+    components: { BOMSearch, bomTreeDialog, standardOutput },
 
     data() {
       return {
@@ -227,7 +233,6 @@
             width: 260
           },
 
-
           {
             prop: 'materielDesignation',
             slot: 'materielDesignation',
@@ -288,7 +293,7 @@
         },
 
         attributeList: [
-        {
+          {
             label: '总装',
             value: 1
           },
@@ -299,7 +304,8 @@
           {
             label: '零',
             value: 3
-          },{
+          },
+          {
             label: '原材料',
             value: 4
           }
@@ -359,7 +365,7 @@
     methods: {
       /* 表格数据源 */
       datasource({ where, page, limit }) {
-        console.log('yyyyyy', this.attributeData)
+        console.log('yyyyyy', this.attributeData);
         return getBomPageCategoryId({
           ...where,
           pageNum: page,
@@ -398,14 +404,30 @@
       },
 
       handleAdd() {
-        // 打开树形对话框
-        this.$refs.bomTreeDialogRef.open(
-          this.attributeData.bomType,
-          this.attributeData.versions,
-          this.attributeData.categoryId,
-          this.newTreeId,
-          this.isTemp
+        // // 打开树形对话框
+        // this.$refs.bomTreeDialogRef.open(
+        //   this.attributeData.bomType,
+        //   this.attributeData.versions,
+        //   this.attributeData.categoryId,
+        //   this.newTreeId,
+        //   this.isTemp
+        // );
+
+        let _list = this.$refs.table.getData() ?? [];
+
+        this.$refs.standardOutputRefs.open(_list);
+      },
+
+      chooseStandardList(data) {
+        data.map((m) => {
+          m.parentId = this.newTreeId;
+        });
+        console.log(
+          data,
+          555555555555555555555555555555555555555555555555555555555555555555555555555555
         );
+
+        this.$refs.table.setData([...data, ...this.$refs.table.getData()]);
       },
 
       bomClose() {
@@ -423,12 +445,17 @@
           type: 'warning'
         })
           .then(() => {
-            deleteBomTreeList([row.id]).then((msg) => {
-              this.$message.success('删除' + msg);
-              this.$refs.table.reload({
-                pageNum: 1
-              });
-            });
+            // deleteBomTreeList([row.id]).then((msg) => {
+            //   this.$message.success('删除' + msg);
+            //   this.$refs.table.reload({
+            //     pageNum: 1
+            //   });
+            // });
+
+            let _list = this.$refs.table.getData() ?? [];
+
+            _list = _list.filter((item) => item.id !== row.id);
+            this.$refs.table.setData(_list);
           })
           .finally(() => {});
       },
@@ -439,6 +466,7 @@
           return this.$message.info('明细表最少有一条数据');
         }
         let list = JSON.parse(JSON.stringify(_list));
+        console.log(list, 'list');
         updateBatchBOM(list).then((res) => {
           this.$message.success('保存成功');
           this.$refs.table.reload({

+ 8 - 4
src/views/material/BOMmanage/components/standardOutput.vue

@@ -68,7 +68,11 @@
             columnKey: 'selection',
             type: 'selection',
             width: 45,
-            align: 'center'
+            align: 'center',
+            selectable: (row, index) => {
+              return !this.selectList.some((it) => row.id == it.id);
+            },
+            reserveSelection: true,
           },
           {
             columnKey: 'index',
@@ -192,8 +196,8 @@
         this.isCategory = false;
         this.$refs.table.reload({ pageNum: 1, where: where });
       },
-      open(type) {
-        this.type = type;
+      open(list) {
+        this.selectList = list;
         this.getTreeData();
         this.visible = true;
       },
@@ -230,7 +234,7 @@
         if (this.selection.length <= 0) {
           return this.$message.warning('请至少选择一条数据');
         }
-        this.$emit('selection', this.type,this.selection);
+        this.$emit('selection',this.selection);
         this.handleClose();
       }
     }

+ 31 - 32
src/views/material/BOMmanage/qualityTesting/term.vue

@@ -30,6 +30,8 @@
             ? '时间'
             : row.textType == 6
             ? '范围'
+            : row.textType == 7
+            ? '文本'
             : ''
         }}
       </template>
@@ -39,35 +41,36 @@
       </template>
 
       <template v-slot:defaultValue="{ row }">
-        <div style="display: flex">
+        <div style="width: 100%; display: flex; justify-content: space-between">
+          <div style="width: 8%">
+            <el-input v-model="row.symbol" disabled> </el-input>
+          </div>
+          <!-- 上下限 -->
           <div
             v-if="row.textType == 3"
-            style="display: flex; align-items: center"
+            style="
+              display: flex;
+              align-items: center;
+              justify-content: space-between;
+              width: 75%;
+            "
           >
-            <el-input
-              style="width: 132px"
-              v-model="row.minValue"
-            ></el-input>
+            <el-input style="width: 45%" v-model="row.minValue"></el-input>
             <span>&nbsp;&nbsp;-</span>
             <el-input
-              style="width: 132px; margin-left: 10px"
+              style="width: 45%; margin-left: 10px"
               v-model="row.maxValue"
             ></el-input>
           </div>
 
-          <div v-else style="width: 290px">
-            <el-input
-              v-model="row.defaultValue"
-              placeholder="请输入"
-            ></el-input>
+          <div v-else style="width: 75%">
+            <el-input v-model="row.defaultValue" placeholder="请输入">
+            </el-input>
           </div>
 
-          <el-input
-            style="margin-left: 10px; width: 80px"
-            v-model="row.unit"
-            disabled
-          >
-          </el-input>
+          <div style="width: 15%">
+            <el-input v-model="row.unit" disabled> </el-input>
+          </div>
         </div>
       </template>
 
@@ -143,19 +146,17 @@
             slot: 'defaultValue',
             label: '工艺参数',
             align: 'center',
-            minWidth: 260
+            width: 700
           },
 
-          {
-            label: '工艺要求',
-            prop: 'inspectionStandard',
-            formatter: (row, column, cellValue) => {
-              return (
-                row.symbol + ' ' + cellValue + ' ' + row.unit
-              );
-            },
-            minWidth: 350
-          },
+          // {
+          //   label: '工艺要求',
+          //   prop: 'inspectionStandard',
+          //   formatter: (row, column, cellValue) => {
+          //     return row.symbol + ' ' + cellValue + ' ' + row.unit;
+          //   },
+          //   minWidth: 350
+          // },
 
           {
             columnKey: 'action',
@@ -212,6 +213,4 @@
   };
 </script>
 
-<style lang="scss" scoped>
-
-</style>
+<style lang="scss" scoped></style>

+ 103 - 7
src/views/material/product/components/PurchasingInfo.vue

@@ -11,19 +11,77 @@
       <el-row :gutter="24">
         <el-col :span="8">
           <el-form-item label="周期" prop="purchasingCycle">
-            <el-input v-model="form.purchasingCycle" placeholder="请输入" />
+            <el-input-number
+              v-model="form.purchasingCycle"
+              placeholder="请输入"
+              :min="0"
+              :precision="1"
+              :controls="false"
+              style="width: calc(100% - 100px)"
+            />
+            <el-select
+              v-model="form.purchasingCycleUnit"
+              placeholder="请选择"
+              style="width: 100px"
+            >
+              <el-option
+                v-for="item in CycleUnitoptions"
+                :key="item.value"
+                :label="item.label"
+                :value="item.value"
+              >
+              </el-option>
+            </el-select>
           </el-form-item>
         </el-col>
         <el-col :span="8">
           <el-form-item label="倍数" prop="purchaseMultiplier">
-            <el-input v-model="form.purchaseMultiplier" placeholder="请输入" />
+            <el-input-number
+              style="width: 100%"
+              v-model="form.purchaseMultiplier"
+              placeholder="请输入"
+              :min="0"
+              :precision="2"
+              :controls="false"
+            />
           </el-form-item>
         </el-col>
         <el-col :span="8">
           <el-form-item label="最低订购量" prop="minimumOrderQuantity">
-            <el-input
+            <el-input-number
+              style="width: 100%"
               v-model="form.minimumOrderQuantity"
               placeholder="请输入"
+              :min="0"
+              :precision="2"
+              :controls="false"
+            />
+          </el-form-item>
+        </el-col>
+        <el-col :span="8">
+          <el-form-item label="计量单位" prop="purchasingCycle">
+            <DictSelection
+              dictName="计量单位"
+              clearable
+              v-model="form.measuringUnit"
+            >
+            </DictSelection>
+          </el-form-item>
+        </el-col>
+        <el-col :span="8">
+          <el-form-item label="采购组织" prop="checkDepart">
+            <deptSelect
+              v-model="form.checkDepart"
+              @changeGroup="searchDeptNodeClick"
+            />
+          </el-form-item>
+        </el-col>
+        <el-col :span="8">
+          <el-form-item label="采购员" prop="checkPerson">
+            <personSelect
+              ref="directorRef"
+              v-model="form.checkPerson"
+              :init="false"
             />
           </el-form-item>
         </el-col>
@@ -33,6 +91,8 @@
 </template>
 
 <script>
+  import deptSelect from '@/components/CommomSelect/dept-select.vue';
+  import personSelect from '@/components/CommomSelect/person-select.vue';
   export default {
     props: {
       form: {
@@ -40,12 +100,45 @@
         default: {}
       }
     },
-    components: {},
+    components: { deptSelect, personSelect },
     data() {
-      return {};
+      return {
+        CycleUnitoptions: [
+          {
+            value: '年',
+            label: '年'
+          },
+          {
+            value: '月',
+            label: '月'
+          },
+          {
+            value: '日',
+            label: '日'
+          }
+        ]
+      };
     },
-
-    methods: {}
+    watch: {
+      form(data) {
+        if (data.checkDepart) {
+          const params = { executeGroupId: data.checkDepart };
+          this.$nextTick(() => {
+            this.$refs.directorRef.getList(params);
+          });
+        }
+      }
+    },
+    methods: {
+      // 选择所属部门
+      searchDeptNodeClick(id, info) {
+        // 根据部门获取人员
+        const params = { executeGroupId: id };
+        this.$nextTick(() => {
+          this.$refs.directorRef.getList(params);
+        });
+      }
+    }
   };
 </script>
 
@@ -82,4 +175,7 @@
       margin-left: 15px;
     }
   }
+  ::v-deep .el-input-number .el-input__inner {
+    text-align: left !important;
+  }
 </style>

+ 41 - 73
src/views/material/product/components/QualityInfo.vue

@@ -1,49 +1,41 @@
 <template>
   <div class="other">
-      <el-form label-width="120px"  ref="form" :model="form">
-         <div class="divider">
-           <div class="title">
-             <div class="ele-bg-primary"></div>
-             <span>质量配置</span>
-           </div>
-           <div class="ele-bg-primary ele-width"></div>
-         </div>
-         <el-row :gutter="24">
-           <el-col :span="8">
-             <el-form-item label="是否来料检验" prop="isComeCheck">
-                 <el-radio v-model="form.isComeCheck" :label="1">是</el-radio>
-                 <el-radio v-model="form.isComeCheck" :label="0">否</el-radio>
-             </el-form-item>
-           </el-col>
-           <el-col :span="8">
-             <el-form-item label="检验方案" prop="checkFormula">
-                <DictSelection dictName="检验方案" clearable v-model="form.checkFormula">
-                </DictSelection>
-             </el-form-item>
-           </el-col>
-           <el-col :span="8">
-             <el-form-item label="采购组织" prop="checkDepart">
-               <deptSelect v-model="form.checkDepart" @changeGroup="searchDeptNodeClick"/>
-             </el-form-item>
-           </el-col>
-           <el-col :span="8">
-             <el-form-item label="采购员" prop="checkPerson">
-               <personSelect
-                 ref="directorRef"
-                 v-model="form.checkPerson"
-                 @selfChange="handleDirectorChange"
-                 :init="false"
-               />
-             </el-form-item>
-           </el-col>
-         </el-row>
-      </el-form>
+    <el-form label-width="120px" ref="form" :model="form">
+      <div class="divider">
+        <div class="title">
+          <div class="ele-bg-primary"></div>
+          <span>质量配置</span>
+        </div>
+        <div class="ele-bg-primary ele-width"></div>
+      </div>
+      <el-row :gutter="24">
+        <el-col :span="8">
+          <el-form-item label="是否来料检验" prop="isComeCheck">
+            <el-radio v-model="form.isComeCheck" :label="1">是</el-radio>
+            <el-radio v-model="form.isComeCheck" :label="0">否</el-radio>
+          </el-form-item>
+        </el-col>
+        <el-col :span="8">
+          <el-form-item label="检验方式" prop="checkFormula">
+            <DictSelection
+              dictName="检验方案"
+              clearable
+              v-model="form.checkFormula"
+            >
+            </DictSelection>
+          </el-form-item>
+        </el-col>
+        <el-col :span="8">
+          <!-- <el-form-item label="检验方案" prop="">
+            <el-select placeholder="请选择" style="width: 100%"></el-select>
+          </el-form-item> -->
+        </el-col>
+      </el-row>
+    </el-form>
   </div>
 </template>
 
 <script>
-  import deptSelect from '@/components/CommomSelect/dept-select.vue'
-  import personSelect from '@/components/CommomSelect/person-select.vue';
   export default {
     props: {
       form: {
@@ -51,41 +43,17 @@
         default: {}
       }
     },
-    components: { deptSelect , personSelect },
+    components: {},
     data() {
-      return {
-      };
+      return {};
     },
-    watch: {
-      form(data) {
-        if (data.checkDepart) {
-           const params = { executeGroupId: data.checkDepart };
-            this.$nextTick(() => {
-              this.$refs.directorRef.getList(params);
-            });
-        }
-      }
-    },
-    methods: {
-      // 选择所属部门
-      searchDeptNodeClick (id, info) {
-        // 根据部门获取人员
-        const params = { executeGroupId: id };
-        this.$nextTick(() => {
-          this.$refs.directorRef.getList(params);
-        });
-      },
-      //选择负责人
-      handleDirectorChange (id, info) {
-      },
-
-
-    }
+    watch: {},
+    methods: {}
   };
 </script>
 
 <style lang="scss" scoped>
-  .other{
+  .other {
     background: #fff;
     padding: 1px 17px;
   }
@@ -104,17 +72,17 @@
         font-size: 20px;
       }
     }
-    .ele-width{
+    .ele-width {
       width: 100%;
       height: 2px;
     }
   }
-  .form-line{
+  .form-line {
     display: flex;
     align-items: center;
     justify-content: space-between;
-    .line-select{
-      margin-left:15px;
+    .line-select {
+      margin-left: 15px;
     }
   }
 </style>

+ 89 - 0
src/views/material/product/components/SalesInfos.vue

@@ -0,0 +1,89 @@
+<template>
+  <div class="other">
+    <el-form label-width="120px" ref="form" :model="form">
+      <div class="divider">
+        <div class="title">
+          <div class="ele-bg-primary"></div>
+          <span>销售配置</span>
+        </div>
+        <div class="ele-bg-primary ele-width"></div>
+      </div>
+      <el-row :gutter="24">
+        <el-col :span="8">
+          <el-form-item label="计价方式" prop="pricingWay">
+            <el-select
+              v-model="form.pricingWay"
+              placeholder="请选择计价方式"
+              style="width: 100%"
+            >
+              <el-option
+                v-for="item in pricingWayList"
+                :key="item.id"
+                :label="item.name"
+                :value="item.id"
+              ></el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+      </el-row>
+    </el-form>
+  </div>
+</template>
+
+<script>
+  export default {
+    props: {
+      form: {
+        type: Object,
+        default: {}
+      }
+    },
+    components: {},
+    data() {
+      return {
+        // 计价方式
+        pricingWayList: [
+          { id: 1, name: '按数量计价' },
+          { id: 2, name: '按重量计价' }
+        ]
+      };
+    },
+    watch: {},
+    methods: {}
+  };
+</script>
+
+<style lang="scss" scoped>
+  .other {
+    background: #fff;
+    padding: 1px 17px;
+  }
+  .divider {
+    margin: 0px 0 20px;
+    .title {
+      display: flex;
+      align-items: center;
+      margin-bottom: 10px;
+      div {
+        width: 8px;
+        height: 20px;
+        margin-right: 10px;
+      }
+      span {
+        font-size: 20px;
+      }
+    }
+    .ele-width {
+      width: 100%;
+      height: 2px;
+    }
+  }
+  .form-line {
+    display: flex;
+    align-items: center;
+    justify-content: space-between;
+    .line-select {
+      margin-left: 15px;
+    }
+  }
+</style>

+ 14 - 1
src/views/material/product/detail.vue

@@ -230,6 +230,8 @@
       :packageDispositionVOList="packageDispositionVOList"
       @change="changePackagingSpecification"
     />
+    <!-- 销售配置 -->
+    <SalesInfos ref="salesRefs" :form="categorySales" />
     <!-- 采购信息 -->
     <PurchasingInfo ref="PurchasingInfoRefs" :form="categoryPurchase" />
     <!-- 生产信息 -->
@@ -257,6 +259,7 @@
 </template>
 
 <script>
+  import SalesInfos from './components/SalesInfos.vue';
   import PurchasingInfo from './components/PurchasingInfo.vue';
   import GroupDialog from './components/GroupDialog.vue';
   import CodeDialog from './components/codeDialog.vue';
@@ -285,6 +288,7 @@
   export default {
     name: 'product',
     components: {
+      SalesInfos,
       PurchasingInfo,
       linkMsg,
       GroupDialog,
@@ -339,7 +343,8 @@
         remarkform: {
           remarkAttach: []
         },
-        categoryPurchase: {},
+        categorySales: {},
+        categoryPurchase: { purchaseMultiplier: 1 },
         categoryAps: {},
         categoryMes: {},
         categoryMold: {},
@@ -541,6 +546,12 @@
         } else {
           this.categoryPallet = info.categoryPallet;
         }
+        if (typeof info.categorySales == 'string') {
+          this.categorySales = {};
+        } else {
+          this.categorySales = info.categorySales;
+        }
+
         if (typeof info.categoryPurchase == 'string') {
           this.categoryPurchase = {};
         } else {
@@ -744,6 +755,7 @@
           //   : '';
 
           const data = {
+            categorySales: this.categorySales,
             categoryPurchase: this.categoryPurchase,
             categoryWms: this.categoryWms,
             categoryAps: this.categoryAps,
@@ -761,6 +773,7 @@
           };
 
           if (this.$route.query.status == 1) {
+            data.categorySales.id = null;
             data.categoryPurchase.id = null;
             data.category.id = null;
             data.categoryWms.id = null;

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

@@ -18,66 +18,91 @@
         :rules="contentConfigFormRules"
       >
         <el-row>
-          <el-col :span="7">
-            <el-form-item label="规则编码" prop="name">
+          <el-col :span="8">
+            <el-form-item label="规则编码" prop="ruleCode">
               <el-input
-                v-model="formData.code"
+                v-model="formData.ruleCode"
                 size="small"
                 :disabled="true"
               ></el-input>
             </el-form-item>
           </el-col>
-          <el-col :span="6">
-            <el-form-item label="规则名称" prop="name">
+          <el-col :span="8">
+            <el-form-item label="规则名称" prop="ruleName">
               <el-input
-                v-model="formData.name"
+                v-model="formData.ruleName"
                 placeholder="请输入"
                 size="small"
-                :disabled="isBindPlan"
               ></el-input>
             </el-form-item>
           </el-col>
-          <el-col :span="6">
-            <el-form-item label="预警类型" prop="ruleType">
-              <DictSelection
-                dictName="预警类型"
-                clearable
-                v-model="formData.ruleType"
+          <el-col :span="8">
+            <el-form-item label="预警对象" prop="ruleObjCode">
+              <el-select
+                v-model="formData.ruleObjCode"
+                size="small"
+                :disabled="isBindPlan == 'edit'"
+                style="width: 100%"
               >
-              </DictSelection>
+                <el-option
+                  v-for="(value, key) in allRulesData"
+                  :key="key"
+                  :label="value"
+                  :value="key"
+                />
+              </el-select>
+            </el-form-item>
+          </el-col>
+          <el-col :span="8">
+            <el-form-item label="周期" prop="alertCycleValue">
+              <el-col :span="16">
+                <el-input-number
+                  v-model="formData.alertCycleValue"
+                  placeholder="请输入"
+                  size="small"
+                  :min="0"
+                  :precision="1"
+                  :controls="false"
+                  style="width: 100%"
+                />
+              </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-col>
             </el-form-item>
           </el-col>
-          <el-col :span="5">
-            <el-form-item label="状态" prop="status" label-width="70px">
-              <el-switch
-                v-model="formData.status"
+          <el-col :span="8">
+            <el-form-item label="状态" prop="enabled">
+              <el-select
+                v-model="formData.enabled"
+                size="small"
+                style="width: 100%"
+              >
+                <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>
-
-        <el-row>
-          <el-col :span="24">
-            <el-form-item label="周期" prop="cycleValue">
-              <rule-cycle
-                ref="cycleMultipleRef"
-                :formData="formData"
-                :pageType="pageType"
-                :isBindPlan="isBindPlan"
-              />
+              </el-switch> -->
             </el-form-item>
           </el-col>
         </el-row>
 
         <el-table
           ref="multipleTable"
-          v-if="formData.ruleType !== 4"
-          :data="formData.ruleItems"
+          :data="formData.actionList"
           tooltip-effect="dark"
           style="width: 95%; margin: auto"
           border
@@ -85,81 +110,63 @@
         >
           <el-table-column type="index" width="100" align="center">
             <template slot="header">
-              <el-button
-                type="text"
-                @click="addItem"
-                icon="el-icon-plus"
-                :disabled="isBindPlan"
+              <el-button type="text" @click="addItem" icon="el-icon-plus"
                 >新增</el-button
               >
             </template>
           </el-table-column>
-
-          <el-table-column prop="minWarningValue" label="预警值" width="240">
-            <template
-              slot-scope="scope"
-              style="display: flex; flex-direction: row"
-            >
-              <el-form-item
-                style="width: 100px"
-                :prop="'ruleItems.' + scope.$index + '.minWarningValue'"
-                label-width="0"
-                :rules="contentConfigFormRules.minWarningValue"
-              >
-                <span v-if="scope.row.readonly">{{
-                  scope.row.minWarningValue
-                }}</span>
-                <el-input
-                  v-if="!scope.row.readonly"
-                  size="small"
-                  placeholder="最小"
-                  v-model="scope.row.minWarningValue"
-                  :disabled="isBindPlan"
-                ></el-input>
-              </el-form-item>
-              <span>&nbsp;&nbsp; - &nbsp;&nbsp;</span>
-
+          <el-table-column prop="targetAddressName" label="通知人" width="240">
+            <template slot-scope="scope">
               <el-form-item
-                style="width: 100px"
-                :prop="'ruleItems.' + scope.$index + '.maxWarningValue'"
+                :prop="'actionList.' + scope.$index + '.targetAddressName'"
                 label-width="0"
-                :rules="contentConfigFormRules.maxWarningValue"
+                :rules="contentConfigFormRules.targetAddressName"
               >
-                <span v-if="scope.row.readonly">{{
-                  scope.row.maxWarningValue
-                }}</span>
                 <el-input
-                  v-if="!scope.row.readonly"
-                  size="small"
-                  placeholder="最大"
-                  v-model="scope.row.maxWarningValue"
-                  :disabled="isBindPlan"
+                  v-model="scope.row.targetAddressName"
+                  @focus="handleAddInfo(scope.row, scope.$index)"
                 ></el-input>
+                <!-- <el-select
+                  v-model="scope.row.manager"
+                  placeholder="请选择"
+                  style="width: 100%"
+                  filterable
+                  multiple
+                >
+                  <el-option
+                    v-for="item in managerData"
+                    :key="item.id"
+                    :label="item.name"
+                    :value="item.id"
+                  >
+                  </el-option>
+                </el-select> -->
               </el-form-item>
             </template>
           </el-table-column>
-
-          <el-table-column prop="warningUnit" label="预警时间单位" width="120">
+          <el-table-column prop="actionType" label="操作类型" width="240">
             <template slot-scope="scope">
               <el-form-item
-                :prop="'ruleItems.' + scope.$index + '.warningUnit'"
+                :prop="'actionList.' + scope.$index + '.actionType'"
                 label-width="0"
-                :rules="contentConfigFormRules.warningUnit"
+                :rules="contentConfigFormRules.actionType"
               >
-                <DictSelection
-                  dictName="时间单位"
-                  v-model="scope.row.warningUnit"
-                  :disabled="isBindPlan"
-                >
-                </DictSelection>
+                <el-select size="small" v-model="scope.row.actionType">
+                  <el-option
+                    v-for="(value, key) in operationTypeData"
+                    :key="key"
+                    :label="value"
+                    :value="key"
+                  />
+                </el-select>
               </el-form-item>
             </template>
           </el-table-column>
 
-          <el-table-column prop="urgent" label="紧急程度" width="120">
+          <!-- <el-table-column prop="urgent" label="紧急程度" width="120">
             <template slot-scope="scope">
               <el-form-item
-                :prop="'ruleItems.' + scope.$index + '.urgent'"
+                :prop="'actionList.' + scope.$index + '.urgent'"
                 label-width="0"
                 :rules="contentConfigFormRules.urgent"
               >
@@ -171,71 +178,46 @@
                 </DictSelection>
               </el-form-item>
             </template>
-          </el-table-column>
-
-          <el-table-column prop="name" label="事项" width="300">
-            <template slot-scope="scope">
-              <el-form-item
-                :prop="'ruleItems.' + scope.$index + '.name'"
-                label-width="0"
-                :rules="contentConfigFormRules.name"
-              >
-                <span v-if="scope.row.readonly">{{ scope.row.name }}</span>
-                <el-input
-                  v-if="!scope.row.readonly"
-                  size="small"
-                  placeholder="请输入"
-                  v-model="scope.row.name"
-                  :disabled="isBindPlan"
-                ></el-input>
-              </el-form-item>
-            </template>
-          </el-table-column>
-          <el-table-column prop="content" label="内容" width="300">
+          </el-table-column> -->
+          <el-table-column
+            prop="alertMessageTempateCode"
+            label="模板编码"
+            width="240"
+          >
             <template slot-scope="scope">
-              <el-form-item
-                :prop="'ruleItems.' + scope.$index + '.content'"
-                label-width="0"
-                :rules="contentConfigFormRules.content"
+              <el-select
+                placeholder="请选择"
+                v-model="scope.row.alertMessageTempateCode"
+                @change="changeTemplate(scope.row, scope.$index)"
               >
-                <span v-if="scope.row.readonly">{{ scope.row.content }}</span>
-                <el-input
-                  v-if="!scope.row.readonly"
-                  size="small"
-                  placeholder="请输入"
-                  v-model="scope.row.content"
-                  :disabled="isBindPlan"
-                ></el-input>
-              </el-form-item>
+                <el-option
+                  v-for="item in templateData"
+                  :key="item.code"
+                  :label="item.name + '-' + item.code"
+                  :value="item.code"
+                >
+                </el-option>
+              </el-select>
             </template>
           </el-table-column>
-
-          <el-table-column prop="norm" label="标准">
+          <el-table-column prop="content" label="内容" width="240">
             <template slot-scope="scope">
-              <el-form-item
-                :prop="'ruleItems.' + scope.$index + '.norm'"
-                label-width="0"
-                :rules="contentConfigFormRules.norm"
-              >
-                <span v-if="scope.row.readonly">{{ scope.row.norm }}</span>
-                <el-input
-                  v-if="!scope.row.readonly"
-                  size="small"
-                  placeholder="请输入"
-                  v-model="scope.row.norm"
-                  :disabled="isBindPlan"
-                ></el-input>
-              </el-form-item>
+              <el-input
+                type="textarea"
+                size="small"
+                placeholder="请输入"
+                v-model="scope.row.content"
+                disabled
+              ></el-input>
             </template>
           </el-table-column>
-
           <el-table-column label="操作">
             <template slot-scope="scope">
               <el-button
                 type="text"
                 @click="delItem(scope.$index)"
                 size="small"
-                :disabled="isBindPlan"
+                :disabled="isBindPlan == 'clone'"
                 >删除</el-button
               >
             </template>
@@ -247,30 +229,29 @@
         <el-button type="primary" @click="dataKeep"> 保存 </el-button>
       </template>
     </ele-modal>
+    <select-person-dialog
+      ref="selectPersonDialogRef"
+      @changeParent="changeParent"
+    ></select-person-dialog>
   </div>
 </template>
 <script>
-  import RuleCycle from './rule-cycle';
   import { deepClone } from '@/utils/index';
   import {
     saveOrUpdate,
     getCode,
-    getDetail
+    getDetail,
+    listAllRulesObj,
+    listAllDateUnit,
+    listAllActionType
   } from '@/api/ruleManagement/earlyWarning';
+  import { notifyTemplatePageAPI } from '@/api/notifyManage';
+  import { getUserPage } from '@/api/system/organization';
+  import selectPersonDialog from './user-select/user-select.vue';
 
   export default {
-    components: { RuleCycle },
+    components: { selectPersonDialog },
     props: {
-      pageType: {
-        type: String,
-        default: ''
-      },
-      infoData: {
-        type: Object,
-        default: () => {
-          return {};
-        }
-      },
       dialogTitle: {
         type: String,
         default: '新建规则'
@@ -283,78 +264,122 @@
       }
     },
     data() {
-      // 默认表单数据
-      const defaultForm = {
-        code: '',
-        name: '',
-        ruleType: '1',
-        status: 1,
-        warningValue: null,
-        cycleValue: undefined,
-        cycleType: 1,
-        contentImage: {},
-        ruleCycleList: [], // 规则周期日期值
-        ruleItems: [
-          {
-            name: '', // 巡点检事项
-            content: '', // 巡点检内容
-            norm: '' // 巡点检标准
-          }
-        ]
-      };
       return {
         addMatterDialog: false,
-        cycleValue: '',
-        uploadList: [],
-        formData: {},
+        formData: {
+          ruleCode: '',
+          ruleName: '',
+          ruleObjCode: '',
+          alertCycleValue: '',
+          alertCycleUnit: '',
+          enabled: 1,
+          actionList: [
+            {
+              targetAddress: '',
+              targetAddressName: '',
+              actionType: '',
+              // urgent: '',
+              alertMessageTempateCode: '',
+              content: ''
+            }
+          ]
+        },
         contentConfigFormRules: {
-          maxWarningValue: [
-            { required: true, message: '请输入预警值', trigger: 'blur' }
-          ],
-          minWarningValue: [
-            { required: true, message: '请输入预警值', trigger: 'blur' }
-          ],
-          warningUnit: [
-            { required: true, message: '请输入预警时间单位', trigger: 'blur' }
-          ],
-          urgent: [
-            { required: true, message: '请选择紧急程度', trigger: 'blur' }
+          targetAddressName: [
+            { required: true, message: '请选择通知人', trigger: 'blur' }
           ],
-          name: [
-            { required: true, message: '请输入规则名称', trigger: 'blur' }
+          actionType: [
+            { required: true, message: '请选择操作类型', trigger: 'blur' }
           ],
-          ruleType: [
-            { required: true, message: '请选择预警类型', trigger: 'change' }
-          ],
-
-          // contentImage: [
-          //   { required: false, message: '请上传图片', trigger: 'blur' }
+          // urgent: [
+          //   { required: true, message: '请选择紧急程度', trigger: 'blur' }
           // ],
-          status: [{ required: true }],
-          name: [
-            { required: true, message: '请输入巡点检事项', trigger: 'blur' }
-          ],
-          content: [
-            { required: true, message: '请输入巡点检内容', trigger: 'blur' }
-          ],
-          norm: [
-            { required: true, message: '请输入巡点检标准', trigger: 'blur' }
+          alertMessageTempateCode: [
+            { required: true, message: '请选择模板编码', trigger: 'blur' }
           ]
         },
-        isBindPlan: false
+        isBindPlan: '',
+        managerData: [],
+        templateData: [],
+        allRulesData: {},
+        cycleUnitOpt: {},
+        operationTypeData: {}
       };
     },
     watch: {},
+    created() {
+      this.gettemplateList();
+      this.getInfo();
+    },
+
     methods: {
-      openDialog(row, type) {
+      async getAllRulesObj() {
+        const res = await listAllRulesObj();
+        this.allRulesData = res;
+      },
+      async getAllDateUnit() {
+        const res = await listAllDateUnit();
+        this.cycleUnitOpt = res;
+      },
+      async getAllActionType() {
+        const res = await listAllActionType();
+        this.operationTypeData = res;
+      },
+      handleAddInfo(row, index) {
+        this.formData.actionList[index].targetAddress = '';
+        this.formData.actionList[index].targetAddressName = '';
+        this.$refs.selectPersonDialogRef.open(row, index);
+      },
+      changeParent(list, index) {
+        console.log(list, 'list', this.isBindPlan);
+        let ids = list
+          .map((item) => {
+            return item.id;
+          })
+          .join(',');
+        let names = list
+          .map((item) => {
+            return item.name;
+          })
+          .join(',');
+        this.formData.actionList[index].targetAddress = ids;
+        this.formData.actionList[index].targetAddressName = names;
+      },
+      changeTemplate(row, index) {
+        console.log(row, index);
+        this.formData.actionList[index].alertMessageTempateCode =
+          row.alertMessageTempateCode;
+        this.templateData.filter((item) => {
+          if (item.code == row.alertMessageTempateCode) {
+            this.formData.actionList[index].content = item.content;
+          }
+        });
+      },
+      async gettemplateList() {
+        const res = await notifyTemplatePageAPI({
+          pageNum: 1,
+          size: 999
+        });
+        this.templateData = res?.list;
+      },
+      async getInfo() {
+        getUserPage({
+          size: 999
+        }).then((res) => {
+          this.managerData = res.list;
+        });
+      },
+      async openDialog(row, type) {
         this.addMatterDialog = true;
+        this.isBindPlan = type;
+
+        await this.getAllRulesObj();
+        await this.getAllDateUnit();
+        await this.getAllActionType();
         if (type != 'add') {
           this.getRuleInfo(row.id, type);
         } else {
-          this.formData = { ...this.defaultForm };
-          this.$set(this.formData, 'status', 1);
-          this.$set(this.formData, 'ruleType', '1');
-          console.log('this.formData---------', this.formData);
+          this.$set(this.formData, 'enabled', 1);
           this.$refs.contentConfigForm &&
             this.$refs.contentConfigForm.resetFields();
         }
@@ -365,17 +390,24 @@
 
       async getRuleInfo(id, type) {
         const data = await getDetail(id);
-        this.formData = data;
-        console.log(
-          '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!',
-          this.formData
-        );
-        this.formData.ruleType = JSON.stringify(this.formData.ruleType);
-        this.$set(
-          this.formData,
-          'urgent',
-          JSON.stringify(this.formData.urgent)
-        );
+        this.formData = deepClone(data);
+
+        if (data.actionList && data.actionList.length > 0) {
+          for (let i = 0; i < data.actionList.length; i++) {
+            const ele = data.actionList[i].alertMessageTempateCode;
+            const template = this.templateData.find(
+              (item) => item.code === ele
+            );
+            if (template) {
+              data.actionList[i].content = template.content + '';
+            }
+            data.actionList.map((item) => {
+              item.actionType = item.actionType + '';
+            });
+          }
+          this.formData.actionList = data.actionList;
+        }
+
         if (type == 'clone') {
           delete this.formData.id;
         }
@@ -383,155 +415,48 @@
 
       async getOrderCode() {
         const data = await getCode('warn_rule_code');
-        this.$set(this.formData, 'code', data);
+        this.$set(this.formData, 'ruleCode', data);
       },
 
       handleClose() {
+        this.formData = {};
+        this.formData.actionList = [];
         this.addMatterDialog = false;
         this.$emit('handleClose');
       },
       addItem() {
-        if (this.formData.ruleItems) {
-          this.formData.ruleItems.push({
-            name: '', // 巡点检事项
-            content: '', // 巡点检内容
-            norm: '', // 巡点检标准
-
-            readonly: false
+        if (this.formData.actionList) {
+          this.formData.actionList.push({
+            targetAddress: '',
+            actionType: '',
+            // urgent: '',
+            alertMessageTempateCode: '',
+            content: ''
           });
         } else {
           let arr = [
             {
-              name: '', // 巡点检事项
-              content: '', // 巡点检内容
-              norm: '' // 巡点检标准
+              targetAddress: '',
+              actionType: '',
+              // urgent: '',
+              alertMessageTempateCode: '',
+              content: ''
             }
           ];
-          this.$set(this.formData, 'ruleItems', arr);
-          // this.formData.ruleItems =
+          this.$set(this.formData, 'actionList', arr);
         }
       },
-      saveItem(index, row) {
-        this.$nextTick(() => {
-          let flag = false;
-          let name = row.name;
-          let content = row.content;
-          let norm = row.norm;
-          flag = name && content && norm;
-          this.$refs.contentConfigForm.validate((valid) => {
-            if (valid || flag) {
-              this.$set(this.formData.ruleItems[index], 'readonly', true);
-            }
-          });
-        });
-      },
-      upload(data) {
-        if (data && data[0]?.accessUrl) {
-          this.formData.contentImage = data;
-        } else {
-          this.formData.contentImage = {};
-        }
-        this.$nextTick(() => {
-          this.$refs.contentConfigForm.validateField('contentImage');
-        });
-        console.log(this.formData.contentImage);
-      },
-      editItem(index) {
-        this.$nextTick(() => {
-          this.$set(this.formData.ruleItems[index], 'readonly', false);
-        });
-      },
       delItem(index) {
-        this.formData.ruleItems.splice(index, 1);
+        this.formData.actionList.splice(index, 1);
       },
 
       // 保存
       dataKeep() {
         let form = deepClone(this.formData);
-        console.log(this.$refs.cycleMultipleRef);
-        form.cycle = this.$refs.cycleMultipleRef.ruleCycleList;
-        console.log(form);
-        switch (form.cycleType) {
-          case 1:
-            if (form.cycle[0].minute === '') {
-              this.$message.warning('周期信息需补充完整!');
-              return;
-            }
-            break;
-          case 2:
-            if (form.cycle[0].hour === '' || form.cycle[0].minute === '') {
-              this.$message.warning('周期信息需补充完整!');
-              return;
-            }
-            break;
-          case 4:
-            if (
-              form.cycle[0].day === '' ||
-              form.cycle[0].hour === '' ||
-              form.cycle[0].minute === ''
-            ) {
-              this.$message.warning('周期信息需补充完整!');
-              return;
-            }
-            break;
-          case 5:
-            if (
-              form.cycle[0].month === '' ||
-              form.cycle[0].day === '' ||
-              form.cycle[0].hour === '' ||
-              form.cycle[0].minute === ''
-            ) {
-              this.$message.warning('周期信息需补充完整!');
-              return;
-            }
-            break;
-          case 11:
-            let flg = false;
-            form.cycle.map((item, index) => {
-              if (item.hour === '' || item.minute === '') {
-                flg = true;
-              }
-            });
-            if (flg) {
-              this.$message.warning('周期信息需补充完整!');
-              return;
-            }
-            break;
-          case 13:
-            let flag = false;
-            form.cycle.map((item, index) => {
-              if (item.day === '' || item.hour === '') {
-                flag = true;
-              }
-            });
-            if (flag) {
-              this.$message.warning('周期信息需补充完整!');
-              return;
-            }
-            break;
-          case 14:
-            let fla = false;
-            form.cycle.map((item, index) => {
-              if (item.month === '' || item.day === '' || item.hour === '') {
-                fla = true;
-              }
-            });
-            if (fla) {
-              this.$message.warning('周期信息需补充完整!');
-              return;
-            }
-            break;
-        }
-        if (form.ruleItems && form.ruleItems.length > 0) {
+        console.log(form, 'form');
+        if (form.actionList && form.actionList.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('操作成功!');
@@ -628,4 +553,7 @@
   ::v-deep .el-table .cell {
     display: flex;
   }
+  ::v-deep .el-input-number .el-input__inner {
+    text-align: left !important;
+  }
 </style>

+ 146 - 0
src/views/rulesManagement/earlyWarningRules/components/user-select/departmentTree.vue

@@ -0,0 +1,146 @@
+<template>
+  <div class="tree-wrapper">
+    <el-tree
+      :data="treeList"
+      :props="defaultProps"
+      v-loading="treeLoading"
+      :node-key="nodeKey"
+      ref="tree"
+      :highlight-current="true"
+      :expand-on-click-node="false"
+      @node-click="handleNodeClick"
+      v-bind="$attrs"
+      :default-expand-all="defaultExpandAll"
+    >
+    </el-tree>
+  </div>
+</template>
+
+<script>
+  import { listOrganizations } from '@/api/system/organization';
+  // let originId = '';
+  // let originType = '';
+  export default {
+    props: {
+      // treeList私有化处理
+      treeFormate: {
+        type: Function,
+        default: null
+      },
+      defaultProps: {
+        type: Object,
+        default: function () {
+          return {
+            children: 'children',
+            value: 'id',
+            label: 'name'
+          };
+        }
+      },
+      defaultExpandAll: {
+        type: Boolean,
+        default: function () {
+          return true;
+        }
+      },
+      // 初始请求treeList
+      init: {
+        type: Boolean,
+        default: true
+      },
+
+      isFirstRefreshTable: {
+        type: Boolean,
+        default: true
+      },
+      id: {
+        type: String,
+        default: '0'
+      },
+      nodeKey: {
+        type: String,
+        default: 'id'
+      }
+      // appendRoot: {
+      //   type: Boolean,
+      //   default: false
+      // },
+    },
+    data() {
+      return {
+        treeList: [],
+        treeLoading: false,
+        parentName: '',
+        parentId: '',
+        currentKey: ''
+      };
+    },
+    mounted() {
+      if (this.init) {
+        this.getTreeData();
+      }
+    },
+    methods: {
+      getInstance() {
+        return this.$refs.tree;
+      },
+      // 获取树结构数据
+      async getTreeData(params = {}) {
+        try {
+          this.treeLoading = true;
+
+          const data = await listOrganizations(params);
+          this.treeLoading = false;
+          this.$emit('setRootId', data[0].id);
+          this.treeList = this.$util.toTreeData({
+            data: data || [],
+            idField: 'id',
+            parentIdField: 'parentId'
+          });
+          this.$nextTick(() => {
+            // 默认高亮第一级树节点
+            if (this.treeList[0] && this.isFirstRefreshTable) {
+              this.setCurrentKey(this.treeList[0].id);
+              this.handleNodeClick(
+                this.treeList[0],
+                this.$refs.tree.getCurrentNode()
+              );
+            }
+          });
+          return this.treeList;
+        } catch (error) {
+          console.error(error);
+        }
+        this.treeLoading = false;
+      },
+
+      handleNodeClick(data, node) {
+        this.$emit('handleNodeClick', data, node);
+      },
+      // 设置默认高亮行
+      setCurrentKey(id) {
+        this.currentKey = id;
+        this.$refs.tree.setCurrentKey(this.currentKey);
+      },
+
+      // 获取树的选中状态
+      getSelectList() {
+        const selectList = this.$refs.tree.getCurrentNode();
+        return selectList;
+      }
+    }
+  };
+</script>
+
+<style lang="scss" scoped>
+  .tree-wrapper {
+    width: 100%;
+    height: 100%;
+    overflow: auto;
+
+    :deep(.el-tree) {
+      display: inline-block;
+      min-width: 100%;
+    }
+  }
+</style>

+ 92 - 0
src/views/rulesManagement/earlyWarningRules/components/user-select/user-select-search.vue

@@ -0,0 +1,92 @@
+<!-- 搜索表单 -->
+<template>
+  <el-form
+    size="small"
+    class="ele-form-search"
+    @keyup.enter.native="search"
+    @submit.native.prevent
+  >
+    <el-row :gutter="24">
+      <el-col v-bind="styleResponsive ? { md: 6 } : { span: 6 }">
+        <el-form-item>
+          <el-input
+            clearable
+            size="small"
+            v-model.trim="where.jobNumber"
+            placeholder="请输入工号"
+          />
+        </el-form-item>
+      </el-col>
+
+      <el-col v-bind="styleResponsive ? { md: 6 } : { span: 6 }">
+        <el-form-item>
+          <el-input
+            clearable
+            size="small"
+            v-model.trim="where.loginName"
+            placeholder="请输入用户账号"
+          />
+        </el-form-item>
+      </el-col>
+      <el-col v-bind="styleResponsive ? { md: 6 } : { span: 6 }">
+        <el-form-item>
+          <el-input
+            clearable
+            size="small"
+            v-model.trim="where.name"
+            placeholder="请输入姓名"
+          />
+        </el-form-item>
+      </el-col>
+      <el-col v-bind="styleResponsive ? { md: 6 } : { span: 6 }">
+        <el-form-item>
+          <el-button
+            size="small"
+            type="primary"
+            icon="el-icon-search"
+            class="ele-btn-icon"
+            @click="search"
+          >
+            查询
+          </el-button>
+          <el-button @click="reset">重置</el-button>
+          <slot></slot>
+        </el-form-item>
+      </el-col>
+    </el-row>
+  </el-form>
+</template>
+
+<script>
+  export default {
+    data() {
+      // 默认表单数据
+      const defaultWhere = {
+        jobNumber: '',
+        loginName: '',
+        name: ''
+      };
+      return {
+        // 表单数据
+        where: { ...defaultWhere }
+      };
+    },
+    computed: {
+      // 是否开启响应式布局
+      styleResponsive() {
+        return this.$store.state.theme.styleResponsive;
+      }
+    },
+    methods: {
+      /* 搜索 */
+      search() {
+        this.$emit('search', this.where);
+      },
+      /*  重置 */
+      reset() {
+        this.where = { ...this.defaultWhere };
+        this.search();
+      }
+    }
+  };
+</script>

+ 176 - 0
src/views/rulesManagement/earlyWarningRules/components/user-select/user-select.vue

@@ -0,0 +1,176 @@
+<template>
+  <el-dialog
+    :title="title"
+    :visible.sync="visible"
+    :before-close="handleClose"
+    :close-on-click-modal="false"
+    top="5vh"
+    :close-on-press-escape="false"
+    append-to-body
+    width="70%"
+  >
+    <el-card shadow="never">
+      <ele-split-layout width="244px" allow-collapse>
+        <div class="ele-border-lighter split-layout-right-content">
+          <DepartmentTree
+            @handleNodeClick="handleNodeClick"
+            :isFirstRefreshTable="false"
+            ref="treeList"
+          />
+        </div>
+        <!-- 表格 -->
+        <template v-slot:content>
+          <user-select-search @search="reload"></user-select-search>
+          <ele-pro-table
+            class="table1"
+            ref="table222"
+            :columns="columns1"
+            :datasource="datasource"
+            :selection.sync="selection"
+            height="calc(100vh - 430px)"
+            cache-key="systemRoleTable3"
+            row-key="id"
+          ></ele-pro-table>
+        </template>
+      </ele-split-layout>
+    </el-card>
+
+    <div slot="footer" class="dialog-footer">
+      <el-button type="primary" size="small" @click="selected">选择</el-button>
+      <el-button size="small" @click="handleClose">关闭</el-button>
+    </div>
+  </el-dialog>
+</template>
+
+<script>
+  import { getUserPage } from '@/api/system/organization';
+  import DepartmentTree from './departmentTree.vue';
+  import userSelectSearch from './user-select-search.vue';
+  export default {
+    components: {
+      DepartmentTree,
+      userSelectSearch
+    },
+    props: {},
+    data() {
+      return {
+        visible: false,
+        currentIndex: 0,
+        title: '选择',
+        statusOptions: [
+          { value: 1, label: '全职' },
+          { value: 2, label: '兼职' },
+          { value: 3, label: '实习' },
+          { value: 4, label: '正式' },
+          { value: 5, label: '试用' },
+          { value: 6, label: '离职' }
+        ],
+        selection: [],
+        columns1: [
+          {
+            width: 45,
+            type: 'selection',
+            columnKey: 'selection',
+            reserveSelection: true
+          },
+          {
+            columnKey: 'index',
+            label: '序号',
+            type: 'index',
+            width: 55
+          },
+          {
+            prop: 'name',
+            label: '姓名',
+            sortable: 'custom',
+
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+          {
+            prop: 'jobNumber',
+            label: '工号',
+            sortable: 'custom',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+          {
+            prop: 'loginName',
+            label: '用户账号',
+            sortable: 'custom',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+          {
+            prop: 'sex',
+            label: '性别',
+            sortable: 'custom',
+            showOverflowTooltip: true,
+            minWidth: 80,
+            formatter: (_row, _column, cellValue) => {
+              return cellValue == 1 ? '男' : cellValue == 2 ? '女' : '';
+            }
+          },
+          {
+            prop: 'status',
+            label: '状态',
+
+            sortable: 'custom',
+            width: 80,
+            formatter: (_row, _column, cellValue) => {
+              const dom = this.statusOptions.find((item) => {
+                return item.value == cellValue;
+              });
+              return dom ? dom.label : '';
+            }
+          }
+        ]
+      };
+    },
+    computed: {},
+    watch: {},
+    methods: {
+      /* 表格数据源 */
+      datasource({ page, limit, where }) {
+        return getUserPage({
+          pageNum: page,
+          size: limit,
+          ...where
+        });
+      },
+
+      /* 刷新表格 */
+      reload(where) {
+        this.$refs.table222.reload({ pageNum: 1, where: where });
+      },
+
+      open(row, index) {
+        this.visible = true;
+        this.selection = [];
+        this.currentIndex = index;
+        this.$refs.table222.clearSelection();
+      },
+      handleNodeClick(data, node) {
+        this.curNodeData = data;
+        this.reload({ groupId: data.id });
+      },
+      handleClose() {
+        this.visible = false;
+      },
+
+      selected() {
+        if (!this.selection.length) return this.$message.warning('请选择');
+        this.$emit('changeParent', this.selection, this.currentIndex);
+        this.handleClose();
+      }
+    }
+  };
+</script>
+
+<style lang="scss" scoped>
+  ::v-deep .table1 .el-table .el-table__cell .cell {
+    display: flex;
+    width: 100%;
+    justify-content: center;
+  }
+</style>

+ 45 - 34
src/views/rulesManagement/earlyWarningRules/index.vue

@@ -22,14 +22,19 @@
           </el-button>
         </template>
         <!-- 编码列 -->
-        <template v-slot:code="{ row }">
+        <template v-slot:ruleCode="{ row }">
           <el-link type="primary" :underline="false" @click="goDetail(row)">
-            {{ row.code }}
+            {{ row.ruleCode }}
           </el-link>
         </template>
-
-      
-
+        <template v-slot:alertCycleValue="{ row }">
+          <span v-if="row.alertCycleValue">{{ row.alertCycleValue }}</span>
+          <template v-if="row.alertCycleUnit">
+            <span v-for="(value, key) in cycleUnitOpt">
+              <span v-if="key == row.alertCycleUnit">{{ value }}</span>
+            </span>
+          </template>
+        </template>
         <!-- 操作列 -->
         <template v-slot:action="{ row }">
           <el-link
@@ -79,7 +84,8 @@
   import {
     getList,
     getDetail,
-    removeRule
+    removeRule,
+    listAllDateUnit
   } from '@/api/ruleManagement/earlyWarning';
   import dictMixins from '@/mixins/dictMixins';
   export default {
@@ -102,52 +108,52 @@
             fixed: 'left'
           },
           {
-            prop: 'code',
+            prop: 'ruleCode',
             label: '规则编码',
             align: 'center',
             showOverflowTooltip: true,
             minWidth: 110,
-            slot: 'code'
+            slot: 'ruleCode'
           },
           {
-            prop: 'status',
-            label: '状态',
+            prop: 'ruleName',
+            label: '规则名称',
             align: 'center',
             showOverflowTooltip: true,
-            minWidth: 110,
-            formatter: (_row, _column, cellValue) => {
-              return this.getDictValue('规则状态', _row.status);
-            }
+            minWidth: 110
           },
           {
-            prop: 'ruleType',
-            label: '预警类型',
+            prop: 'enabled',
+            label: '状态',
             align: 'center',
             showOverflowTooltip: true,
-            slot: 'enable',
             minWidth: 110,
             formatter: (_row, _column, cellValue) => {
-              return this.getDictValue('预警类型', _row.ruleType);
+              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: 'name',
-            label: '规则名称',
-            align: 'center',
-            showOverflowTooltip: true,
-            minWidth: 110
-          },
-
-
-          {
-            prop: 'cycle',
+            prop: 'alertCycleValue',
             label: '周期',
             align: 'center',
             showOverflowTooltip: true,
             minWidth: 110,
-            formatter: (_row, _column, cellValue) => {
-              return this.getDictValue('规则周期', _row.cycleType);
-            }
+            slot: 'alertCycleValue'
+
+            // formatter: (_row, _column, cellValue) => {
+            //   return this.getDictValue('规则周期', _row.cycleType);
+            // }
           },
           {
             prop: 'createUserName',
@@ -179,14 +185,16 @@
         // 加载状态
         loading: false,
         pageType: 'add',
-        dialogTitle: ''
+        dialogTitle: '',
+        cycleUnitOpt: {}
       };
     },
     computed: {},
     created() {
-      this.requestDict('规则周期');
+      // this.requestDict('规则周期');
       this.requestDict('预警类型');
       this.requestDict('规则状态');
+      this.getAllDateUnit();
     },
     methods: {
       /* 表格数据源 */
@@ -197,7 +205,10 @@
       reload(where) {
         this.$refs.table.reload({ page: 1, where });
       },
-
+      async getAllDateUnit() {
+        const res = await listAllDateUnit();
+        this.cycleUnitOpt = res;
+      },
       remove(row) {
         removeRule([row.id]).then((res) => {
           this.$message.success('删除成功!');

+ 14 - 12
src/views/technology/parameter/components/user-edit.vue

@@ -43,6 +43,7 @@
               <el-option label="规格" :value="'4'" />
               <el-option label="时间" :value="'5'" />
               <el-option label="范围" :value="'6'" />
+              <el-option label="文本" :value="'7'" />
             </el-select>
           </el-form-item>
         </el-col>
@@ -65,8 +66,6 @@
           </el-form-item>
         </el-col>
 
-
-
         <el-col :span="10" v-if="form.textType == 2">
           <el-form-item label="默认值:" prop="defaultValue">
             <el-select
@@ -80,17 +79,12 @@
           </el-form-item>
         </el-col>
 
-        <el-col
-          :span="10"
-          v-if="
-            form.textType == 6
-          "
-        >
+        <el-col :span="10" v-if="form.textType == 6">
           <el-form-item label="默认值:">
             <!-- oninput="value=value.replace(/[^\d.]/g, '').replace(/\.{2,}/g, '.').replace('.', '$#$').replace(/\./g, '').replace('$#$', '.').replace(/^(\-)*(\d+)\.(\d\d\d\d\d\d\d\d).*$/, '$1$2.$3').replace(/^\./g, '').replace(/^0+(?!\.|$)/g, ''),value = Number(value) >= 999999.99 ? 999999.99 : value" -->
             <el-input
               v-model="form.defaultValue"
-                 placeholder="案例: 12.7≤IC<19.05 ;IC<12.7"
+              placeholder="案例: 12.7≤IC<19.05 ;IC<12.7"
             ></el-input>
           </el-form-item>
         </el-col>
@@ -131,7 +125,15 @@
         </el-col>
 
         <el-col :span="20">
-          <el-form-item label="文字描述:">
+          <el-form-item
+            label="文字描述:"
+            :rules="[
+              {
+                required: form.textType == 7 ? true : false,
+                message: '请输入'
+              }
+            ]"
+          >
             <el-input placeholder="请输入" v-model="form.description" />
           </el-form-item>
         </el-col>
@@ -426,9 +428,9 @@
         } else {
           this.$refs.form.clearValidate();
           this.$refs.form1.clearValidate();
-          
+
           this.form = { ...this.defaultForm };
-         this.$set(this.form, 'intervalList', [])
+          this.$set(this.form, 'intervalList', []);
         }
       }
     }

+ 209 - 172
src/views/technology/parameter/index.vue

@@ -4,10 +4,22 @@
       <!-- 搜索表单 -->
       <user-search @search="reload" />
       <!-- 数据表格 -->
-      <ele-pro-table ref="table" :columns="columns" :datasource="datasource" :selection.sync="selection" row-key="code">
+      <ele-pro-table
+        ref="table"
+        :columns="columns"
+        :datasource="datasource"
+        :selection.sync="selection"
+        row-key="code"
+      >
         <!-- 表头工具栏 -->
         <template v-slot:toolbar>
-          <el-button size="small" type="primary" icon="el-icon-plus" class="ele-btn-icon" @click="openEdit()">
+          <el-button
+            size="small"
+            type="primary"
+            icon="el-icon-plus"
+            class="ele-btn-icon"
+            @click="openEdit()"
+          >
             新建
           </el-button>
           <!-- <el-button
@@ -27,20 +39,41 @@
         <!-- 状态列 -->
 
         <template v-slot:textType="{ row }">
-          {{ row.textType == 1 ? '数值' : row.textType == 2 ? '选择' : row.textType == 3 ? '产品参数' : row.textType == 4 ? '规格' :
-             row.textType == 5 ? '时间' :   row.textType == 6 ? '范围' : '' }}
+          {{
+            row.textType == 1
+              ? '数值'
+              : row.textType == 2
+              ? '选择'
+              : row.textType == 3
+              ? '产品参数'
+              : row.textType == 4
+              ? '规格'
+              : row.textType == 5
+              ? '时间'
+              : row.textType == 6
+              ? '范围'
+              : row.textType == 7
+              ? '文本'
+              : ''
+          }}
         </template>
 
-
-
-
         <!-- 操作列 -->
         <template v-slot:action="{ row }">
-          <el-link type="primary" :underline="false" icon="el-icon-edit" @click="openEdit(row)">
+          <el-link
+            type="primary"
+            :underline="false"
+            icon="el-icon-edit"
+            @click="openEdit(row)"
+          >
             修改
           </el-link>
 
-          <el-popconfirm class="ele-action" title="确定要删除当前工序吗?" @confirm="remove(row)">
+          <el-popconfirm
+            class="ele-action"
+            title="确定要删除当前工序吗?"
+            @confirm="remove(row)"
+          >
             <template v-slot:reference>
               <el-link type="danger" :underline="false" icon="el-icon-delete">
                 删除
@@ -51,183 +84,187 @@
       </ele-pro-table>
     </el-card>
     <!-- 编辑弹窗 -->
-    <user-edit :visible.sync="showEdit" :data="current" @done="reload" ref="userEdit" />
+    <user-edit
+      :visible.sync="showEdit"
+      :data="current"
+      @done="reload"
+      ref="userEdit"
+    />
     <!-- 导入弹窗 -->
   </div>
 </template>
 
 <script>
-import UserSearch from './components/user-search.vue';
-import UserEdit from './components/user-edit.vue';
+  import UserSearch from './components/user-search.vue';
+  import UserEdit from './components/user-edit.vue';
 
-import parameter from '@/api/technology/parameter';
-
-export default {
-  name: 'technologyParameter',
-  components: {
-    UserSearch,
-    UserEdit
-  },
-  data() {
-    return {
-      // 表格列配置
-      columns: [
-        {
-          prop: 'code',
-          label: '参数编码',
-          // sortable: 'custom',
-          showOverflowTooltip: true,
-          align: 'center',
-          minWidth: 110
-        },
-        {
-          prop: 'name',
-          label: '参数名称',
-          showOverflowTooltip: true,
-          align: 'center',
-          minWidth: 110
-        },
+  import parameter from '@/api/technology/parameter';
 
+  export default {
+    name: 'technologyParameter',
+    components: {
+      UserSearch,
+      UserEdit
+    },
+    data() {
+      return {
+        // 表格列配置
+        columns: [
+          {
+            prop: 'code',
+            label: '参数编码',
+            // sortable: 'custom',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 110
+          },
+          {
+            prop: 'name',
+            label: '参数名称',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 110
+          },
 
-        {
-          prop: 'textType',
-          label: '参数类型',
-          showOverflowTooltip: true,
-          align: 'center',
-          slot: 'textType',
-          minWidth: 110
-        },
-        {
-          align: 'center',
-          prop: 'description',
-          label: '文本描述',
-          showOverflowTooltip: true,
-          minWidth: 110
-        },
-        {
-          prop: 'maxValue',
-          label: '参数上限',
-          align: 'center',
-          showOverflowTooltip: true
-        },
-        {
-          prop: 'minValue',
-          label: '参数下限',
-          align: 'center',
-          showOverflowTooltip: true
-        },
-        {
-          prop: 'defaultValue',
-          label: '默认值',
-          align: 'center',
-          showOverflowTooltip: true
-        },
-        {
-          prop: 'categoryType',
-          label: '参数分类',
-          align: 'center',
-          slot: 'status',
-          showOverflowTooltip: true
-        },
+          {
+            prop: 'textType',
+            label: '参数类型',
+            showOverflowTooltip: true,
+            align: 'center',
+            slot: 'textType',
+            minWidth: 110
+          },
+          {
+            align: 'center',
+            prop: 'description',
+            label: '文本描述',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+          {
+            prop: 'maxValue',
+            label: '参数上限',
+            align: 'center',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'minValue',
+            label: '参数下限',
+            align: 'center',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'defaultValue',
+            label: '默认值',
+            align: 'center',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'categoryType',
+            label: '参数分类',
+            align: 'center',
+            slot: 'status',
+            showOverflowTooltip: true
+          },
 
-        {
-          columnKey: 'action',
-          label: '操作',
-          width: 220,
-          align: 'center',
-          resizable: false,
-          slot: 'action',
-          showOverflowTooltip: true
-        }
-      ],
-      statusList: [
-        { label: '工艺', value: 0 },
-        { label: '工序', value: 1 },
-        { label: '产品', value: 2 },
-        { label: '原料', value: 3 },
-        { label: '设备', value: 4 },
-        { label: '其他', value: 5 }
-      ],
-      // 表格选中数据
-      selection: [],
-      // 当前编辑数据
-      current: null,
-      // 是否显示编辑弹窗
-      showEdit: false,
-      // 是否显示导入弹窗
-      showImport: false
-    };
-  },
-  methods: {
-    /*回显类型 */
-    checkType(id) {
-      const obj = this.statusList.find((item) => item.value == id);
-      return obj.label;
-    },
-    /* 表格数据源 */
-    async datasource({ page, limit, where, order }) {
-      const res = await parameter.list({
-        ...where,
-        ...order,
-        pageNum: page,
-        size: limit
-      });
-      return res;
+          {
+            columnKey: 'action',
+            label: '操作',
+            width: 220,
+            align: 'center',
+            resizable: false,
+            slot: 'action',
+            showOverflowTooltip: true
+          }
+        ],
+        statusList: [
+          { label: '工艺', value: 0 },
+          { label: '工序', value: 1 },
+          { label: '产品', value: 2 },
+          { label: '原料', value: 3 },
+          { label: '设备', value: 4 },
+          { label: '其他', value: 5 }
+        ],
+        // 表格选中数据
+        selection: [],
+        // 当前编辑数据
+        current: null,
+        // 是否显示编辑弹窗
+        showEdit: false,
+        // 是否显示导入弹窗
+        showImport: false
+      };
     },
+    methods: {
+      /*回显类型 */
+      checkType(id) {
+        const obj = this.statusList.find((item) => item.value == id);
+        return obj.label;
+      },
+      /* 表格数据源 */
+      async datasource({ page, limit, where, order }) {
+        const res = await parameter.list({
+          ...where,
+          ...order,
+          pageNum: page,
+          size: limit
+        });
+        return res;
+      },
 
-    /* 刷新表格 */
-    reload(where) {
-      this.$refs.table.reload({ page: 1, where: where });
-    },
-    /* 打开编辑弹窗 */
-    openEdit(row) {
-      this.current = row;
-      this.showEdit = true;
-      this.$refs.userEdit.$refs.form &&
-        this.$refs.userEdit.$refs.form.clearValidate();
-    },
+      /* 刷新表格 */
+      reload(where) {
+        this.$refs.table.reload({ page: 1, where: where });
+      },
+      /* 打开编辑弹窗 */
+      openEdit(row) {
+        this.current = row;
+        this.showEdit = true;
+        this.$refs.userEdit.$refs.form &&
+          this.$refs.userEdit.$refs.form.clearValidate();
+      },
 
-    /* 删除 */
-    remove(row) {
-      const loading = this.$loading({ lock: true });
+      /* 删除 */
+      remove(row) {
+        const loading = this.$loading({ lock: true });
 
-      parameter
-        .delete([row.id])
-        .then((msg) => {
-          loading.close();
-          this.$message.success('删除' + msg);
-          this.reload();
+        parameter
+          .delete([row.id])
+          .then((msg) => {
+            loading.close();
+            this.$message.success('删除' + msg);
+            this.reload();
+          })
+          .catch((e) => {
+            loading.close();
+            // this.$message.error(e.message);
+          });
+      },
+      /* 批量删除 */
+      removeBatch() {
+        if (!this.selection.length) {
+          this.$message.error('请至少选择一条数据');
+          return;
+        }
+        this.$confirm('确定要删除选中的工序吗?', '提示', {
+          type: 'warning'
         })
-        .catch((e) => {
-          loading.close();
-          // this.$message.error(e.message);
-        });
-    },
-    /* 批量删除 */
-    removeBatch() {
-      if (!this.selection.length) {
-        this.$message.error('请至少选择一条数据');
-        return;
+          .then(() => {
+            const loading = this.$loading({ lock: true });
+            parameter
+              .delete(this.selection.map((d) => d.id))
+              .then((msg) => {
+                loading.close();
+                this.$message.success('删除' + msg);
+                this.reload();
+              })
+              .catch((e) => {
+                loading.close();
+                // this.$message.error(e.message);
+              });
+          })
+          .catch(() => {});
       }
-      this.$confirm('确定要删除选中的工序吗?', '提示', {
-        type: 'warning'
-      })
-        .then(() => {
-          const loading = this.$loading({ lock: true });
-          parameter
-            .delete(this.selection.map((d) => d.id))
-            .then((msg) => {
-              loading.close();
-              this.$message.success('删除' + msg);
-              this.reload();
-            })
-            .catch((e) => {
-              loading.close();
-              // this.$message.error(e.message);
-            });
-        })
-        .catch(() => { });
     }
-  }
-};
+  };
 </script>