浏览代码

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

695593266@qq.com 9 月之前
父节点
当前提交
e07f0832c4

+ 1 - 1
src/api/system/file/index.js

@@ -84,7 +84,7 @@ export async function downLoadTemplateNew(url, fileName) {
       responseType: 'blob'
     }
   );
-  console.log(res.data, '***********');
+  console.log(res, '***********');
   download(res.data, fileName);
 }
 

+ 7 - 2
src/utils/util.js

@@ -50,11 +50,16 @@ export function copyObj(obj) {
 //随机id
 export function generateRandomString(num = 5) {
   let result = '';
-  const characters =
-    'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; // 包含字母和数字
+  const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; // 包含字母和数字
+  const charactersNum = '0123456789'; // 包含字母和数字
   const charactersLength = characters.length;
   for (let i = 0; i < num; i++) {
     result += characters.charAt(Math.floor(Math.random() * charactersLength));
   }
+  for (let j = 0; j < 3; j++) {
+    result += charactersNum.charAt(
+      Math.floor(Math.random() * charactersLength)
+    );
+  }
   return result;
 }

+ 6 - 1
src/views/documentManagement/certificateManagement/components/staffSelection.vue

@@ -161,6 +161,7 @@
     methods: {
       open(selectedList) {
         this.dialogVisible = true;
+        this.pageNum = 1;
         this.selectStafflist = selectedList;
         this.getInfo();
       },
@@ -172,6 +173,10 @@
           idField: 'id',
           parentIdField: 'parentId'
         });
+        this.$nextTick(()=>{
+          this.handleNodeClick(this.treeList[0])
+          this.$refs.tree.setCurrentKey(this.treeList[0].id)
+        })
         //this.treeList = res.data;
       },
       //选择分类
@@ -190,7 +195,7 @@
       async getStaffList(params) {
         let res = await getUserPage(params);
         let list = res.list;
-        if (list.length < res.count) {
+        if (this.staffList.length < res.count) {
           this.isMore = true;
         } else {
           this.isMore = false;

+ 6 - 1
src/views/enterpriseModel/dept/components/staffSelection.vue

@@ -161,6 +161,7 @@
     methods: {
       open(selectedList) {
         this.dialogVisible = true;
+        this.pageNum = 1;
         // this.selectStafflist = selectedList;
         this.selectStafflist = selectedList.map((item) => {
           item.name = item.name ? item.name : item.recipientName;
@@ -180,6 +181,10 @@
           idField: 'id',
           parentIdField: 'parentId'
         });
+        this.$nextTick(()=>{
+          this.handleNodeClick(this.treeList[0])
+          this.$refs.tree.setCurrentKey(this.treeList[0].id)
+        })
         //this.treeList = res.data;
       },
       //选择分类
@@ -198,7 +203,7 @@
       async getStaffList(params) {
         let res = await getUserPage(params);
         let list = res.list;
-        if (list.length < res.count) {
+        if (this.staffList.length < res.count) {
           this.isMore = true;
         } else {
           this.isMore = false;

+ 2 - 0
src/views/rulesManagement/matterRules/components/ProductModal.vue

@@ -223,8 +223,10 @@
               // 默认高亮第一级树节点
               if (this.treeList[0]) {
                 this.rootTreeId = this.treeList[0].id;
+                this.categoryLevelId = this.treeList[0].id;
                 this.$nextTick(() => {
                   this.$refs.treeRef.setCurrentKey(this.treeList[0].id);
+                  this.$refs.table.reload({ pageNum: 1 });
                 });
               }
             });

+ 289 - 20
src/views/rulesManagement/releaseRules/components/experimentationProcess.vue

@@ -48,6 +48,7 @@
               :form="item.value"
               :valueObj="item.valueObj"
               @editShow="editShowFn"
+              @calculation="calculation"
               :edit="edit"
             ></customText>
             <customTable
@@ -57,6 +58,7 @@
               :id="item.id"
               :form="item.value"
               :valueObj="item.valueObj"
+              @calculation="calculation"
               @editShow="editShowFn"
               :edit="edit"
             ></customTable>
@@ -68,7 +70,7 @@
         <div slot="header" class="clearfix">
           <span>配置</span>
         </div>
-        <el-form label-width="100px">
+        <el-form label-width="80px">
           <el-form-item label="字段标识:" prop="id">
             <el-input
               v-model="domObj.id"
@@ -94,9 +96,125 @@
               <el-option :key="2" label="是" :value="2"> </el-option>
             </el-select>
           </el-form-item>
+          <el-form-item label="计算公式:" prop="readonly">
+            <el-input
+              :value="domObj.equation?.map((item) => item.value).join('')"
+              type="textarea"
+              placeholder=""
+              disabled
+            ></el-input>
+            <el-button type="primary" @click="setEquation">配置公式</el-button>
+            <el-button type="primary" @click="delEquation">重置</el-button>
+          </el-form-item>
         </el-form>
       </el-card>
     </div>
+    <ele-modal
+      title="配置公式"
+      :visible.sync="visible"
+      :close-on-click-modal="false"
+      append-to-body
+      width="800px"
+      resizable
+      maxable
+    >
+      <div class="formula-builder__selects">
+        <!-- 选择参数:从已填的非计算参数内容里取 -->
+        <el-select
+          v-model="equationUnit.paramSelect"
+          placeholder="选择参数"
+          size="mini"
+          style="width: 100px; margin-right: 8px; flex-shrink: 0"
+          @change="paramSelectChange($event, 'id')"
+        >
+          <el-option
+            v-for="item in idList"
+            :key="item"
+            :label="item"
+            :value="item"
+          />
+        </el-select>
+
+        <!-- 选择运算符 -->
+        <el-select
+          v-model="equationUnit.opSelect"
+          placeholder="选择符号"
+          size="mini"
+          style="width: 100px; flex-shrink: 0; margin-right: 8px"
+          @change="paramSelectChange($event, 'symbol')"
+        >
+          <el-option
+            v-for="op in opSelectOptions"
+            :key="op"
+            :label="op"
+            :value="op"
+          />
+        </el-select>
+        <!-- 选择值 -->
+        <el-input
+          v-model="equationUnit.currentValue"
+          placeholder="输入值"
+          size="mini"
+          style="width: 150px; flex-shrink: 0"
+        >
+          <template slot="append">
+            <span
+              style="cursor: pointer"
+              @click="paramSelectChange(equationUnit.currentValue, 'value')"
+              >确认</span
+            >
+          </template>
+        </el-input>
+        <!-- 替换或者追加 -->
+        <el-select
+          v-if="equationUnit.activeIndex != undefined"
+          v-model="equationUnit.replaceOrAppend"
+          placeholder="选择"
+          size="mini"
+          style="width: 80px; margin-left: 8px; flex-shrink: 0"
+        >
+          <el-option key="append" label="追加" value="append" />
+          <el-option key="replace" label="替换" value="replace" />
+        </el-select>
+      </div>
+
+      <!-- 已组装公式标签展示 -->
+      <div
+        v-if="equationUnit.equation.length"
+        style="
+          display: inline-flex;
+          flex-wrap: wrap;
+          max-width: 100%;
+          margin-top: 5px;
+        "
+      >
+        <el-tag
+          v-for="(p, index) in equationUnit.equation"
+          :key="index"
+          size="mini"
+          closable
+          :type="equationUnit.activeIndex === index ? 'primary' : 'info'"
+          @click="formulaPartsTagClick(index)"
+          @close="tagItemDelete(index)"
+        >
+          {{ p.value }}
+        </el-tag>
+      </div>
+
+      <el-input
+        style="margin-top: 5px"
+        :value="equationUnit.equation?.map((item) => item.value).join('')"
+        type="textarea"
+        placeholder=""
+        disabled
+      ></el-input>
+      <div slot="footer" class="footer">
+        <el-button type="primary" @click="editInputChange('equation')"
+          >确认</el-button
+        >
+        <el-button @click="visible = false">返回</el-button>
+      </div>
+    </ele-modal>
   </div>
 </template>
 
@@ -114,8 +232,8 @@
     },
     props: {
       edit: {
-        default:true,
-        type:Boolean
+        default: true,
+        type: Boolean
       }
     },
     computed: {},
@@ -123,29 +241,177 @@
       return {
         list: [],
         editShow: false,
+        visible: false,
         templateDivRef: '',
-        domObj: {}
+        domObj: {},
+        idList: [],
+        opSelectOptions: ['+', '-', '*', '/', '%', '(', ')'],
+        equationUnit: {
+          equation: [],
+          activeIndex: '',
+          paramSelect: '',
+          opSelect: '',
+          currentValue: '',
+          replaceOrAppend: 'append'
+        }
       };
     },
     mounted() {},
-    created() {
-      // if (sessionStorage['valueJSON']) {
-      //   this.list = JSON.parse(sessionStorage['valueJSON']);
-      // }
-      //  if (localStorage['valueJSON']) {
-      //   this.list = JSON.parse(localStorage['valueJSON']);
-      // }
-    },
+    created() {},
     methods: {
+      // 计算
+      calculation() {
+        this.getValue();
+        let equation = [];
+        this.list.forEach((item) => {
+          equation.push({
+            id: item.id,
+            equation: item.equation
+          });
+        });
+        equation.forEach((item) => {
+          for (const key in item.equation) {
+            let data=this.getObjValue() //每次计算都获取最新的值
+            let value = '';
+            if (item.equation[key].length) {
+              item.equation[key].forEach((equationItem) => {
+                if (equationItem.type == 'symbol') {
+                  value += equationItem.value;
+                } else if (equationItem.type == 'id') {
+                  value += Number(data[equationItem.value]) || 0;
+                } else {
+                  value += equationItem.value;
+                }
+              });
+              if (this.$refs['customTextRef' + item.id][0]) {
+                this.$refs['customTextRef' + item.id][0].equationValue({
+                  domId: key,
+                  value: eval(value)
+                });
+              }
+            }
+          }
+        });
+      },
+      getObjValue() {
+        this.getValue();
+        let data = {};
+        this.list.forEach((item) => {
+          if (item.type == 'customText') {
+            data = { ...item.valueObj, ...data };
+          } else {
+            item.valueObj.rows.forEach((row) => {
+              row.cells.forEach((cell) => {
+                data[cell.id] = cell.value;
+              });
+            });
+          }
+        });
+        return data || {};
+      },
+
+      setEquation() {
+        this.getValue();
+        this.idList = [];
+        if (this.domObj.equation) {
+          this.equationUnit.equation = JSON.parse(
+            JSON.stringify(this.domObj.equation)
+          );
+          this.equationUnit.activeIndex = this.domObj.equation.length;
+        } else {
+          this.equationUnit.equation = [];
+        }
+        this.list.forEach((item) => {
+          if (item.type == 'customText') {
+            for (let key in item.valueObj) {
+              this.idList.push(key);
+            }
+          } else {
+            item.valueObj.rows.forEach((row) => {
+              row.cells.forEach((cell) => {
+                this.idList.push(cell.id);
+              });
+            });
+          }
+        });
+        this.visible = true;
+      },
+      delEquation() {
+        this.equationUnit.equation = [];
+        this.editInputChange('equation');
+      },
+      tagItemDelete(index) {
+        this.equationUnit.equation.splice(index, 1);
+      },
+      formulaPartsTagClick(index, row) {
+        if (!this.equationUnit.replaceOrAppend) {
+          // 默认追加
+          this.equationUnit_replaceOrAppend = 'append';
+        }
+
+        if (
+          this.equationUnit.activeIndex &&
+          this.equationUnit.activeIndex === index
+        ) {
+          this.$set(this.equationUnit, 'activeIndex', undefined);
+        } else {
+          this.$set(this.equationUnit, 'activeIndex', index);
+        }
+      },
+      paramSelectChange(val, type) {
+        if (!val) {
+          return;
+        }
+        if (type == 'id') {
+          this.setValue({ type: 'id', value: val });
+          this.equationUnit.paramSelect = null;
+        } else if (type == 'symbol') {
+          this.setValue({ type: 'symbol', value: val });
+
+          this.equationUnit.opSelect = null;
+        } else if (type == 'value') {
+          this.setValue({ type: 'value', value: val });
+        }
+      },
+      setValue(val) {
+        if (this.equationUnit.activeIndex != undefined) {
+          if (
+            !this.equationUnit.replaceOrAppend ||
+            this.equationUnit.replaceOrAppend === 'replace'
+          ) {
+            this.equationUnit.equation.splice(
+              this.equationUnit.activeIndex,
+              1,
+              val
+            );
+          } else if (this.equationUnit.replaceOrAppend === 'append') {
+            this.equationUnit.equation.splice(
+              this.equationUnit.activeIndex + 1,
+              0,
+              val
+            );
+            // 追加后activeIndex后移一位
+            this.$set(
+              this.equationUnit,
+              'activeIndex',
+              this.equationUnit.activeIndex + 1
+            );
+          }
+        } else {
+          this.equationUnit.equation.push(val);
+        }
+      },
+
       init(list) {
         this.list = JSON.parse(list);
-        console.log(this.list, ' this.list');
         if (this.list.length) {
+          // this.list[0].id="ozFSPs"
           this.$nextTick(() => {
             this.list.forEach((item) => {
               this.$refs['customTextRef' + item.id][0].init({
                 form: item.value,
-                valueObj: item.valueObj
+                valueObj: item.valueObj,
+                equation: item.equation
               });
             });
           });
@@ -156,7 +422,13 @@
         this.$set(this, 'domObj', domObj);
         this.editShow = true;
       },
-      editInputChange() {
+      editInputChange(type) {
+        if (type == 'equation') {
+          this.visible = false;
+          this.domObj.equation = JSON.parse(
+            JSON.stringify(this.equationUnit.equation)
+          );
+        }
         this.$nextTick(() => {
           this.$refs[this.templateDivRef][0].editInputChange(this.domObj);
         });
@@ -173,15 +445,12 @@
         });
       },
       getValue() {
-        // this.$nextTick(() => {
-        //   // sessionStorage['valueJSON'] = JSON.stringify(this.list);
-        //   // localStorage['valueJSON'] = JSON.stringify(this.list);
-        // });
         this.list.forEach((item, index) => {
-          let { form, valueObj } =
+          let { form, valueObj, equation } =
             this.$refs['customTextRef' + item.id][0].getValue();
           this.$set(this.list[index], 'value', form);
           this.$set(this.list[index], 'valueObj', valueObj);
+          this.$set(this.list[index], 'equation', equation);
         });
         return this.list;
       }

+ 44 - 18
src/views/rulesManagement/releaseRules/components/templateDiv/customTable.vue

@@ -7,7 +7,11 @@
     <table style="margin-top: 10px" :id="id">
       <thead>
         <tr>
-          <th v-for="(item, index) in columns" class="tableTh">
+          <th
+            v-for="(item, index) in columns"
+            class="tableTh"
+            :style="{ width: item.width + 'px' }"
+          >
             <i
               class="el-icon-delete delete"
               style="display: none"
@@ -19,8 +23,8 @@
               type="text"
               class="templateInput"
               :id="item.id"
-              :readonly="item.readonly == 2||!edit"
-              @click="inputClick(item)"
+              :readonly="item.readonly == 2 || !edit"
+              @click="inputClick(item, 'columns')"
             />
           </th>
           <th v-if="edit"></th>
@@ -34,8 +38,9 @@
               type="text"
               class="templateInput"
               :id="item.id"
-               :readonly="item.readonly == 2||!edit"
+              :readonly="item.readonly == 2 || !edit"
               @click="inputClick(item)"
+              @input="calculation"
           /></td>
           <td v-if="edit">
             <i
@@ -62,8 +67,7 @@
       edit: {
         default: true,
         type: Boolean
-      },
-    
+      }
     },
     data() {
       return {
@@ -72,9 +76,11 @@
         domId: '',
         rightClickShow: false,
         columns: [],
-        rows: []
+        rows: [],
+        equation: {}
       };
     },
+    created() {},
     methods: {
       // 方法:添加新列
       addColumn() {
@@ -128,22 +134,38 @@
           }
         }
       },
+      calculation() {
+        this.$emit('calculation');
 
+      },
+      equationValue({ domId, value }) {
+        this.rows.forEach((item, index) => {
+          let cellIndex = item.cells.findIndex((cell) => cell.id == domId);
+          if (cellIndex != '-1') {
+            this.$set(this.rows[index].cells[cellIndex], 'value', value);
+          }
+        });
+      },
       getValue() {
         return {
           form: null,
+          equation: this.equation,
           valueObj: {
             columns: this.columns,
             rows: this.rows
           }
         };
       },
-      init({ form, valueObj }) {
+      init({ form, valueObj, equation }) {
         this.form = form;
         this.columns = valueObj.columns;
         this.rows = valueObj.rows;
+        this.equation = equation || {};
       },
       editInputChange(domObj) {
+        if (domObj.equation) {
+          this.equation[this.domId] = domObj.equation;
+        }
         let columnsIndex = this.columns.findIndex(
           (item) => item.id == this.domId
         );
@@ -155,25 +177,29 @@
           let rowsIndex = item.cells.findIndex(
             (cells) => cells.id == this.domId
           );
-          // console.log(rowsIndex,'rowsIndex')
+
           if (rowsIndex >= 0) {
             this.$set(this.rows[index].cells, rowsIndex, domObj);
           }
         });
       },
 
-      inputClick(item) {
-        if(!this.edit){
-          return
+      inputClick(item, type) {
+        if (!this.edit) {
+          return;
         }
+        let dom = document.getElementById(item.id);
+
         this.domId = item.id;
         this.$emit('editShow', {
           templateDivRef: 'customTextRef' + this.id,
           domObj: {
-            isNoWidth: true,
+            width: dom.parentElement.offsetWidth,
+            isNoWidth: type == 'columns' ? false : true,
             id: item.id,
             readonly: item.readonly,
-            value: item.value
+            value: item.value,
+            equation: this.equation[item.id]
           }
         });
       }
@@ -183,10 +209,9 @@
 <style lang="scss" scoped>
   :deep(.templateInput) {
     width: 100%;
-    border: solid 1px #bfbfbf;
-    padding: 1px;
-    margin: 1px;
-    margin-left: 3px;
+    height: 100%;
+    border: none;
+
     text-align: center;
     background-color: #fff;
   }
@@ -199,6 +224,7 @@
     border: 1px solid #ddd;
     padding: 0;
     text-align: center;
+    height: 30px;
   }
   th {
     background-color: #f2f2f2;

+ 34 - 13
src/views/rulesManagement/releaseRules/components/templateDiv/customText.vue

@@ -16,7 +16,7 @@
       v-html="form"
       :contenteditable="edit"
       class="contenteditable"
-      :ref="'valueChange'"
+      :ref="id"
       :id="id"
       @contextmenu.prevent="onRightClick($event)"
     >
@@ -42,6 +42,7 @@
       return {
         form: null,
         valueObj: {},
+        equation: {},
         domId: '',
         rightClickShow: false
       };
@@ -49,8 +50,6 @@
     methods: {
       addHtml() {
         this.insertInput();
-
-        this.objInit();
       },
       objInit() {
         if (Object.keys(this.valueObj).length) {
@@ -66,7 +65,7 @@
         const selection = window.getSelection();
         if (selection.rangeCount > 0) {
           const range = selection.getRangeAt(0);
-          console.log(range, 'range');
+
           this.getParentID(range.commonAncestorContainer);
           if (this.getParentID(range.commonAncestorContainer)) {
             range.setStart(selection.anchorNode, selection.anchorOffset);
@@ -101,15 +100,34 @@
         return inputElement;
       },
       getValue() {
-        // this.form = this.$refs['valueChange'].innerHTML;
+        let inputs = document.querySelectorAll(
+          '#' + this.id + ' .templateInput'
+        );
+        let data = {};
+        if (inputs.length) {
+          inputs.forEach((item) => {
+            data[item.id] = item.value;
+          });
+        }
         return {
-          form: this.$refs['valueChange'].innerHTML,
-          valueObj: this.valueObj
+          form: this.$refs[this.id].innerHTML,
+          valueObj: data,
+          equation: this.equation
         };
       },
-      init({ form, valueObj }) {
+      equationValue({ domId, value }) {
+        if (domId) {
+          let dom = document.getElementById(domId);
+          if (dom) {
+            this.valueObj[domId] = value;
+            dom.value = value;
+          }
+        }
+      },
+      init({ form, valueObj, equation }) {
         this.form = form;
         this.valueObj = valueObj;
+        this.equation = equation || {};
         this.$nextTick(() => {
           if (!this.edit) {
             let inputs = document.querySelectorAll('.templateInput');
@@ -130,6 +148,9 @@
         }
         delete this.valueObj[dom.id];
         this.valueObj[domObj.id] = dom.value;
+        if (domObj.equation) {
+          this.equation[domObj.id] = domObj.equation;
+        }
         dom.id = domObj.id;
       },
       onRightClick(PointerEvent) {
@@ -147,6 +168,8 @@
       inputChange(event) {
         if (event.target && event.target.className == 'templateInput') {
           this.valueObj[event.target.id] = event.target.value;
+
+          this.$emit('calculation');
         }
       },
       inputClick(event) {
@@ -155,14 +178,13 @@
         }
         if (event.target && event.target.className == 'templateInput') {
           this.domId = event.target.id;
-          console.log(event, 'event');
-          // event.getAttribute('class', 'templateInput');
           this.$emit('editShow', {
             templateDivRef: 'customTextRef' + this.id,
             domObj: {
               width: event.target.offsetWidth,
               id: event.target.id,
-              readonly: event.target.readOnly ? 2 : 1
+              readonly: event.target.readOnly ? 2 : 1,
+              equation: this.equation[this.domId]
             }
           });
         }
@@ -171,10 +193,9 @@
 
     mounted() {
       this.$nextTick(() => {
-        console.log(document.getElementById(this.id), 'dsd');
         document
           .getElementById(this.id)
-          .addEventListener('change', this.inputChange);
+          .addEventListener('input', this.inputChange);
 
         document
           .getElementById(this.id)

+ 24 - 1
src/views/rulesManagement/releaseRules/index.vue

@@ -413,7 +413,8 @@
         loading: false,
         cacheKeyUrl: 'maindata-25922-recordrules-index',
         typeTree: [],
-        treeNode: null
+        treeNode: null,
+        qmsReportWorkType: ['5', '6', '7'],
       };
     },
     created() {
@@ -517,6 +518,28 @@
           return this.$message.warning('请先修改规则停用时间!');
         }
 
+        console.log('row~~~~~', row)
+        if (!this.qmsReportWorkType.includes(row.reportWorkType)) {
+          if (row.details.length == 0) {
+            return this.$message.warning('至少条件一条规则项');
+          }
+
+          if (row.reportWorkType == 4) {
+            // 生产统计过滤掉非成品统计的明细
+            row.details = row.details.filter(
+              (i) => i.statisticsType
+            );
+          }
+
+          // 判断参数类型是否选择
+          for (const detail of row.details) {
+            if (!detail.paramType) {
+              console.log('detail', detail);
+              return this.$message.warning('请选择规则明细中的参数类型!');
+            }
+          }
+        }
+
         try {
           await recordrulesPublish(row.id);
           this.$message.success('发布成功');

+ 2 - 1
src/views/workforceManagement/team/components/staffSelection.vue

@@ -201,6 +201,7 @@
     methods: {
       open(selectedList) {
         this.dialogVisible = true;
+        this.pageNum = 1;
         this.selectStafflist = selectedList;
         this.getInfo();
       },
@@ -254,7 +255,7 @@
         }
       let res = await getUserPage(params);
       let list = res.list;
-      if (list.length < res.count) {
+      if (this.staffList.length < res.count) {
         this.isMore = true;
       } else {
         this.isMore = false;