Browse Source

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

695593266@qq.com 6 tháng trước cách đây
mục cha
commit
89c429a80f

+ 14 - 0
src/views/rulesManagement/releaseRules/components/editTypeModal.vue

@@ -23,6 +23,7 @@
           dictName="业务类型"
           placeholder="请选择业务分类"
           @itemChange="(data) => (form.businessName = data.dictValue)"
+          :isProhibit="!!businessType"
         />
       </el-form-item>
 
@@ -30,6 +31,7 @@
         <dict-selection
           v-model="form.reportWorkType"
           dictName="记录规则报工类型"
+          :listFormatte="listFormatte"
           placeholder="请选择模块划分"
           @itemChange="(data) => (form.reportWorkName = data.dictValue)"
         />
@@ -74,6 +76,9 @@
   export default {
     components: { DictSelection },
     mixins: [dictMixins],
+    props: {
+      businessType: ''
+    },
     data() {
       const formBaseData = {
         id: null,
@@ -125,11 +130,20 @@
       };
     },
     methods: {
+      listFormatte(list, valueName) {
+        console.log('list', list);
+        console.log('valueName', valueName);
+       
+      },
       // 外部调用,打开弹窗
       open(type, data) {
         console.log('type', type);
         console.log('data', data);
         if (type == 'add') {
+          if (this.businessType) {
+            this.form.businessType = this.businessType + '';
+            this.form.businessName = this.businessType == '1' ? '生产' : '质检';
+          }
           this.title = '新增类型';
           if (data) {
             // 根据data.type赋值

+ 58 - 10
src/views/rulesManagement/releaseRules/components/experimentationProcess.vue

@@ -69,7 +69,10 @@
       <el-card class="box-card" v-show="editShow" style="width: 320px">
         <div slot="header" class="clearfix">
           <span>配置</span>
-          <el-button style="float: right; padding: 3px 0" type="text" @click="editShow = false"
+          <el-button
+            style="float: right; padding: 3px 0"
+            type="text"
+            @click="editShow = false"
             >关闭</el-button
           >
         </div>
@@ -180,6 +183,22 @@
           <el-option key="append" label="追加" value="append" />
           <el-option key="replace" label="替换" value="replace" />
         </el-select>
+        <el-input
+          v-model.number="domObj.units.decimalPlace"
+          placeholder="小数位"
+          size="mini"
+          style="width: 120px; margin-left: 8px; flex-shrink: 0"
+        >
+        </el-input>
+        <el-select
+          v-model="domObj.units.takeValueMethod"
+          placeholder="取值方法"
+          size="mini"
+          style="width: 100px; margin-left: 8px; flex-shrink: 0"
+        >
+          <el-option key="1" label="四舍五入" value="1" />
+          <el-option key="2" label="去尾" value="2" />
+        </el-select>
       </div>
 
       <!-- 已组装公式标签展示 -->
@@ -247,7 +266,7 @@
         editShow: false,
         visible: false,
         templateDivRef: '',
-        domObj: {},
+        domObj: { units: {} },
         idList: [],
         opSelectOptions: ['+', '-', '*', '/', '%', '(', ')'],
         equationUnit: {
@@ -267,6 +286,7 @@
       calculation() {
         this.getValue();
         let equation = [];
+
         this.list.forEach((item) => {
           equation.push({
             id: item.id,
@@ -275,32 +295,58 @@
         });
         equation.forEach((item) => {
           for (const key in item.equation) {
-            let data = this.getObjValue(); //每次计算都获取最新的值
+            let { data, units } = this.getObjValue(); //每次计算都获取最新的值
             let value = '';
             if (item.equation[key].length) {
               item.equation[key].forEach((equationItem) => {
-                if (equationItem.type == 'symbol') {
+                if (
+                  equationItem.type == 'symbol' ||
+                  equationItem.type == 'value'
+                ) {
                   value += equationItem.value;
                 } else if (equationItem.type == 'id') {
                   value += Number(data[equationItem.value]) || 0;
-                } else {
-                  value += equationItem.value;
                 }
               });
+              if (units[key]?.decimalPlace) {
+                if (units[key]?.takeValueMethod) {
+                  value =
+                    units[key]?.takeValueMethod == 1
+                      ? parseFloat(eval(value).toFixed(units[key].decimalPlace))
+                      : this.truncateToFixedManual(
+                          eval(value),
+                          units[key].decimalPlace
+                        );
+                } else {
+                  value = parseFloat(
+                    eval(value).toFixed(units[key].decimalPlace)
+                  );
+                }
+              } else {
+                value = parseFloat(eval(value).toFixed(2));
+              }
               if (this.$refs['customTextRef' + item.id][0]) {
                 this.$refs['customTextRef' + item.id][0].equationValue({
                   domId: key,
-                  value: eval(value)
+                  value
                 });
               }
             }
           }
         });
       },
+
+      truncateToFixedManual(num, decimalPlaces) {
+        let factor = Math.pow(10, decimalPlaces);
+        return Math.floor(num * factor) / factor;
+      },
       getObjValue() {
         this.getValue();
         let data = {};
+        let units = {};
         this.list.forEach((item) => {
+          units = { ...item.units, ...units };
+
           if (item.type == 'customText') {
             data = { ...item.valueObj, ...data };
           } else {
@@ -311,7 +357,7 @@
             });
           }
         });
-        return data || {};
+        return { data: data || {}, units: units || {} };
       },
 
       setEquation() {
@@ -414,7 +460,8 @@
               this.$refs['customTextRef' + item.id][0].init({
                 form: item.value,
                 valueObj: item.valueObj,
-                equation: item.equation
+                equation: item.equation,
+                units: item.units
               });
             });
           });
@@ -449,11 +496,12 @@
       },
       getValue() {
         this.list.forEach((item, index) => {
-          let { form, valueObj, equation } =
+          let { form, valueObj, equation, units } =
             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);
+          this.$set(this.list[index], 'units', units);
         });
         return this.list;
       }

+ 1 - 1
src/views/rulesManagement/releaseRules/components/permitAdd.vue

@@ -700,7 +700,7 @@
       typeInfo: {
         type: Object,
         default: () => null
-      }
+      },
     },
     computed: {
       bankColumns() {

+ 19 - 10
src/views/rulesManagement/releaseRules/components/templateDiv/customTable.vue

@@ -93,7 +93,7 @@
         domId: '',
         rightClickShow: false,
         columns: [],
-        // rows: [],
+        units: {},
         equation: {}
       };
     },
@@ -134,7 +134,8 @@
 
       // 方法:添加新行
       addRow(rowIndex, columnIndex) {
-        if (columnIndex > 0) { //不是第一列则需要合并单元格
+        if (columnIndex > 0) {
+          //不是第一列则需要合并单元格
           this.columns.forEach((item, newColumnIndex) => {
             let newRow = this.getInput();
             if (newColumnIndex < columnIndex) {
@@ -155,7 +156,7 @@
             }
             this.columns[newColumnIndex].splice(rowIndex + 1, 0, newRow);
           });
-        } else { 
+        } else {
           this.columns.forEach((item, index) => {
             let _rowIndex = rowIndex;
             if (item[rowIndex]?.rowspan > 1) {
@@ -169,7 +170,8 @@
       getPreventRowspan(columnIndex, rowIndex) {
         let preventRowspan = null;
         this.columns[columnIndex].forEach((item, newRowIndex) => {
-          if (newRowIndex < rowIndex && item.rowspan > 1) { //向上找到当前列合并过单元格的行
+          if (newRowIndex < rowIndex && item.rowspan > 1) {
+            //向上找到当前列合并过单元格的行
             preventRowspan = newRowIndex;
           }
         });
@@ -179,7 +181,8 @@
       // 方法:删除指定行
       removeRow(rowIndex) {
         this.columns.forEach((item, columnIndex) => {
-          if (item[rowIndex].rowspan == 0) { // 如果当前列,删除的这一行rowspan为0,则需要找到真正需要改变rowspan的行
+          if (item[rowIndex].rowspan == 0) {
+            // 如果当前列,删除的这一行rowspan为0,则需要找到真正需要改变rowspan的行
             let preventRowspanIndex = this.getPreventRowspan(
               columnIndex,
               rowIndex
@@ -191,17 +194,17 @@
                 this.columns[columnIndex][preventRowspanIndex].rowspan - 1
               );
             }
-          } else if (item[rowIndex].rowspan > 1) { //rowspan大于1,代表合并过单元格,需要吧值继承给下一行
+          } else if (item[rowIndex].rowspan > 1) {
+            //rowspan大于1,代表合并过单元格,需要吧值继承给下一行
             let data = item[rowIndex];
             data.rowspan--;
-            this.$set(this.columns[columnIndex], [rowIndex + 1], data); 
+            this.$set(this.columns[columnIndex], [rowIndex + 1], data);
           }
 
           item.splice(rowIndex, 1);
         });
       },
 
-
       calculation() {
         this.$emit('calculation');
       },
@@ -217,20 +220,25 @@
         return {
           form: null,
           equation: this.equation,
+          units: this.units,
           valueObj: {
             columns: this.columns
           }
         };
       },
-      init({ form, valueObj, equation }) {
+      init({ form, valueObj, equation, units }) {
         this.form = form;
         this.columns = valueObj.columns;
         this.equation = equation || {};
+        this.units = units || {};
       },
       editInputChange(domObj) {
         if (domObj.equation) {
           this.equation[this.domId] = domObj.equation;
         }
+        if (domObj.units) {
+          this.units[this.domId] = domObj.units;
+        }
         this.columns.forEach((item, index) => {
           let rowsIndex = item.findIndex((cells) => cells.id == this.domId);
           if (rowsIndex >= 0) {
@@ -255,7 +263,8 @@
             readonly: item.readonly,
             value: item.value,
             rowspan: item.rowspan,
-            equation: this.equation[item.id]
+            equation: this.equation[item.id],
+            units: this.units[item.id]||{}
           }
         });
       }

+ 10 - 3
src/views/rulesManagement/releaseRules/components/templateDiv/customText.vue

@@ -43,6 +43,7 @@
         form: null,
         valueObj: {},
         equation: {},
+        units: {},
         domId: '',
         rightClickShow: false
       };
@@ -113,7 +114,8 @@
         return {
           form: this.$refs[this.id].innerHTML,
           valueObj: data,
-          equation: this.equation
+          equation: this.equation,
+          units: this.units
         };
       },
       equationValue({ domId, value }) {
@@ -125,10 +127,11 @@
           }
         }
       },
-      init({ form, valueObj, equation }) {
+      init({ form, valueObj, equation, units }) {
         this.form = form;
         this.valueObj = valueObj;
         this.equation = equation || {};
+        this.units = units || {};
         this.$nextTick(() => {
           if (!this.edit) {
             let inputs = document.querySelectorAll('.templateInput');
@@ -152,6 +155,9 @@
         if (domObj.equation) {
           this.equation[domObj.id] = domObj.equation;
         }
+        if (domObj.units) {
+          this.units[domObj.id] = domObj.units;
+        }
         dom.id = domObj.id;
       },
       onRightClick(PointerEvent) {
@@ -185,7 +191,8 @@
               width: event.target.offsetWidth,
               id: event.target.id,
               readonly: event.target.readOnly ? 2 : 1,
-              equation: this.equation[this.domId]
+              equation: this.equation[this.domId],
+              units: this.units[this.domId]||{}
             }
           });
         }

+ 33 - 12
src/views/rulesManagement/releaseRules/index.vue

@@ -68,6 +68,7 @@
             :datasource="datasource"
             :cache-key="cacheKeyUrl"
             row-key="id"
+            :initLoad="false"
           >
             <template v-slot:toolbar>
               <el-button
@@ -188,7 +189,17 @@
       @reloadTypeList="getTypeList"
     />
     <historyModal ref="historyModalRef" />
-    <editTypeModal ref="editTypeModalRef" @reload="getTypeList"></editTypeModal>
+    <editTypeModal
+      ref="editTypeModalRef"
+      @reload="getTypeList"
+      :businessType="
+        $route.path == '/releaseRules/productionReleaseRules'
+          ? 1
+          : '/releaseRules/qualityReleaseRules'
+          ? 2
+          : ''
+      "
+    ></editTypeModal>
   </div>
 </template>
 
@@ -201,7 +212,7 @@
     recordrulesPublish,
     recordrulesRevokePublish,
     recordrulesTypePage,
-    recordrulesTypeDeletes,
+    recordrulesTypeDeletes
   } from '@/api/recordrules/index';
   import tabMixins from '@/mixins/tableColumnsMixin';
   import dictMixins from '@/mixins/dictMixins';
@@ -415,15 +426,20 @@
         cacheKeyUrl: 'maindata-25922-recordrules-index',
         typeTree: [],
         treeNode: null,
-        qmsReportWorkType: [5, 6, 7],
+        qmsReportWorkType: [5, 6, 7]
       };
     },
     created() {
       this.getTypeList();
     },
+    watch: {
+      $route() {
+        this.treeNode = null;
+        this.getTypeList();
+      }
+    },
     methods: {
       addPermit(row, type, title) {
-     
         if (type == 'add') {
           if (!this.treeNode) {
             return this.$message.warning('请先选择类型节点!');
@@ -477,7 +493,9 @@
           pageNum: page,
           size: limit,
           ...where,
-          ...typeWhere
+          ...typeWhere,
+          businessType:
+            this.$route.path == '/releaseRules/productionReleaseRules' ? 1 : 2
         });
       },
       /* 刷新表格 */
@@ -519,7 +537,7 @@
           return this.$message.warning('请先修改规则停用时间!');
         }
 
-        console.log('row~~~~~', row)
+        console.log('row~~~~~', row);
         if (!this.qmsReportWorkType.includes(row.reportWorkType)) {
           if (row.details.length == 0) {
             return this.$message.warning('至少选择一条规则项');
@@ -527,9 +545,7 @@
 
           if (row.reportWorkType == 4) {
             // 生产统计过滤掉非成品统计的明细
-            row.details = row.details.filter(
-              (i) => i.statisticsType
-            );
+            row.details = row.details.filter((i) => i.statisticsType);
           }
 
           // 判断参数类型是否选择
@@ -567,7 +583,9 @@
       async getTypeList() {
         const { list = [] } = await recordrulesTypePage({
           pageNum: 1,
-          size: 99999
+          size: 99999,
+          businessType:
+            this.$route.path == '/releaseRules/productionReleaseRules' ? 1 : 2
         });
 
         console.log('type list', list);
@@ -671,7 +689,7 @@
         this.typeTree = tree; // 结果树
 
         console.log('typeTree~~~~~', this.typeTree);
-        
+
         if (!this.treeNode) {
           // 默认选中第一个节点
           this.treeNode = this.typeTree.length > 0 ? this.typeTree[0] : null;
@@ -689,7 +707,10 @@
       },
       // 打开新增类型
       openEditType(type = 'add', data = null) {
-        this.$refs.editTypeModalRef.open(type, type == 'add' ? this.treeNode : data);
+        this.$refs.editTypeModalRef.open(
+          type,
+          type == 'add' ? this.treeNode : data
+        );
       },
       async deleteTypeNode(node) {
         console.log('delete node', node);

+ 2 - 0
src/views/system/dictionary/components/dict-edit.vue

@@ -127,6 +127,7 @@
         <template slot-scope="scope">
           <el-input
             @blur="checkedValue(scope.row.code)"
+            :disabled="isUpdate && scope.row.id"
             v-model="scope.row.code"
             placeholder=""
           ></el-input>
@@ -158,6 +159,7 @@
       <el-table-column align="center" label="操作">
         <template slot-scope="scope">
           <el-popconfirm
+            v-if="!isUpdate || (!scope.row.id && isUpdate)"
             class="ele-action"
             title="确定要删除此字典项吗?"
             @confirm="removeArr(scope)"

+ 2 - 2
src/views/system/unifiedPortal/index.vue

@@ -25,12 +25,12 @@
                     <i
                       class="el-icon-delete"
                       @click="deleted(item)"
-                      v-if="$hasPermission('mian:codeManage:delete')"
+                      v-if="$hasPermission('sys:system:delete')"
                     ></i>
                     <i
                       class="el-icon-edit"
                       @click="edit(item)"
-                      v-if="$hasPermission('mian:codeManage:update')"
+                      v-if="$hasPermission('sys:system:update')"
                     ></i>
                   </div>
                   <div class="card-content">