From 0ee5e3ed9f0c60e453956972d29f6eaa1da8f282 Mon Sep 17 00:00:00 2001
From: haoxuan <haoxuan>
Date: 星期日, 28 四月 2024 14:44:34 +0800
Subject: [PATCH] 修改纤度检验表的样式

---
 src/views/employeeSalary/salaryPlan/components/addDialog.vue |  226 +++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 165 insertions(+), 61 deletions(-)

diff --git a/src/views/employeeSalary/salaryPlan/components/addDialog.vue b/src/views/employeeSalary/salaryPlan/components/addDialog.vue
index 17dd835..5ed0a6c 100644
--- a/src/views/employeeSalary/salaryPlan/components/addDialog.vue
+++ b/src/views/employeeSalary/salaryPlan/components/addDialog.vue
@@ -65,9 +65,22 @@
           >
           </el-input> -->
           <div class="formula-input" v-html="form.salaryFormulaHtml"></div>
-          <el-button class="formula-btn" type="text" @click="checkFormula()"
-            >妫�鏌ュ叕寮�</el-button
-          >
+          <div class="formula-btn-right">
+            <el-button
+              class="formula-btn-t"
+              type="text"
+              :disabled="form.salaryFormulaHtml.length > 0 ? false : true"
+              @click="deleteFormula()"
+              >娓呴櫎</el-button
+            >
+            <el-button
+              class="formula-btn"
+              :disabled="form.salaryFormulaHtml.length > 0 ? false : true"
+              type="text"
+              @click="checkFormula()"
+              >妫�鏌ュ叕寮�</el-button
+            >
+          </div>
         </el-form-item>
         <div class="formula-error">
           <span v-if="form.error == 1" class="color_blue">
@@ -129,7 +142,7 @@
                     v-if="item.type == 2"
                     class="el-icon-setting margin_left_5px cursor_pointer"
                     style="font-size: 18px; color: gray"
-                    @click="handleConstSetShow(2)"
+                    @click="handleConstSetShow(10)"
                   ></i>
                 </div>
               </div>
@@ -168,15 +181,15 @@
     <SilkSetDialog
       ref="silkSetDialog"
       @confirmValueSave="confirmValueSave"
-      :editRow="form"
+      :editRow="{wildSilkList:wildSilkList}"
       title="閰嶇疆"
     ></SilkSetDialog>
     <ConstantSetDialog
       ref="constantSetDialog"
       @confirmValueSave="confirmValueSave"
       :constType="constType"
-      :editRow="form"
-      :title="constType == 2 ? '閰嶇疆' : '杈撳叆'"
+      :editRow="constType == 10?{absenteeism:absenteeism}:form"
+      :title="constType == 10 ? '閰嶇疆' : '杈撳叆'"
     ></ConstantSetDialog>
   </div>
 </template>
@@ -212,9 +225,11 @@
         salaryFormula: "",
         salaryFormulaHtml: "",
         error: "",
-        purchaseTypeList: [1],
-        cycle: '1',
       },
+      // 婊″嫟濂栬缃�
+      absenteeism:1,
+      // 璁剧疆閲庣氦鐨勭敓涓濇爣鍑�
+      wildSilkList: ['閲庣氦'],
       activeName: 1,
       formulaName: [
         {
@@ -324,6 +339,8 @@
   computed: {},
   created() {
     this.handleGetBomKindDictList();
+    this.handleGetBomKindDictList(9);
+    this.handleGetBomKindDictList(10);
     this.getSelectDataList();
   },
   mounted() {},
@@ -341,6 +358,52 @@
     tabClickBottom(activeName) {
       this.activeName = activeName;
     },
+    formInfo() {
+      if (this.islook) {
+        this.form = {
+          name: "",
+          workTypes: [],
+          salaryType: "",
+          salaryFormula: "",
+          salaryFormulaHtml: "",
+          error: "",
+        };
+        this.$nextTick(() => {
+          this.$refs["form"].resetFields();
+          if (this.editRow.id) {
+            this.form = JSON.parse(JSON.stringify(this.editRow));
+            let salaryFormula = this.form.salaryFormula
+              ? this.form.salaryFormula
+              : "";
+            this.form.salaryFormulaHtml = "";
+            this.form.salaryFormula = "";
+            let arr = salaryFormula ? salaryFormula.split(",") : [];
+            this.getSalaryFormulaHtml(arr);
+          }
+        });
+      }
+    },
+    getSalaryFormulaHtml(arr) {
+      let formulaNameArr = this.formulaName
+        .concat(this.formulaNameTwo)
+        .concat(this.formulaSymbol);
+      if (arr.length > 0) {
+        for (let i in arr) {
+          for (let j in formulaNameArr) {
+            let reg2 =
+              /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;
+            if (reg2.test(arr[i])) {
+              this.formulaClick(
+                { name: "甯搁噺鏁板瓧", type: 3, width: 2 },
+                arr[i]
+              );
+            } else if (formulaNameArr[j].name == arr[i]) {
+              this.formulaClick(formulaNameArr[j]);
+            }
+          }
+        }
+      }
+    },
     // 鐐瑰嚮鐢熶骇鏁版嵁鍜岃�冨嫟鍙婅ˉ璐存暟鎹� 璧嬪�艰璐瑰叕寮忓畾涔�
     formulaClick(item, value) {
       let string = "";
@@ -356,17 +419,28 @@
           name +
           "</span>";
       }
-      this.form.salaryFormula = this.form.salaryFormula + name + "锛�";
+      this.form.salaryFormula = this.form.salaryFormula + name + ",";
       this.form.salaryFormulaHtml = this.form.salaryFormulaHtml + string;
       this.$forceUpdate();
+    },
+    deleteFormula() {
+      let salaryFormula = this.form.salaryFormula
+              ? this.form.salaryFormula
+              : "";
+      let arr = salaryFormula.split(",");
+      arr = arr.splice(0, arr.length - 1);
+      arr = arr.splice(0, arr.length - 1);
+      this.form.salaryFormulaHtml = "";
+      this.form.salaryFormula = "";
+      this.getSalaryFormulaHtml(arr);
     },
     checkFormula() {
       if (this.form.salaryFormula) {
         let string = true;
-        let isString = '+-*/';
-        let arr = this.form.salaryFormula.split("锛�");
-        arr=arr.splice(0,arr.length-1)
-        for (let i=0;i<arr.length;i++) {
+        let isString = "+-*/";
+        let arr = this.form.salaryFormula.split(",");
+        arr = arr.splice(0, arr.length - 1);
+        for (let i = 0; i < arr.length; i++) {
           if (arr[i] != "") {
             // 闄ゆ暟涓嶈兘涓�0, 绗﹀彿閭h竟闇�瑕佹湁鍊�
             if (isString.indexOf(arr[i]) != -1 || arr[i] == "(") {
@@ -391,7 +465,7 @@
               }
             } else if (arr[i] == ")") {
               if (i < arr.length - 1) {
-                if (isString.indexOf(arr[i+1]) == -1) {
+                if (isString.indexOf(arr[i + 1]) == -1) {
                   string = false;
                   break;
                 }
@@ -414,17 +488,23 @@
         }
 
         if (!string) {
-          this.form.error = 2;
+          this.$set(this.form, "error", 2);
         } else {
-          this.form.error = 1;
+          this.$set(this.form, "error", 1);
         }
       }
     },
     confirmValueSave(form, type) {
-      if (type == 1) {
-        this.form.purchaseTypeList = form.purchaseTypeList;
-      } else if (type == 2) {
-        this.form.cycle = form.cycle+'';
+      if (type == 9) {
+        this.wildSilkList = form.wildSilkList;
+        this.handleConfirmSave([
+          {name:this.wildSilkList.join(',')}
+        ],type)
+      } else if (type == 10) {
+        this.absenteeism = form.absenteeism + "";
+        this.handleConfirmSave([
+          {name:this.absenteeism}
+        ],type)
       } else if (type == 3) {
         this.formulaClick(
           {
@@ -438,11 +518,15 @@
     },
     // 閲庣氦鏁伴噺
     handleSlikSetShow() {
+      this.handleGetBomKindDictList(9);
       this.$refs.silkSetDialog.islook = true;
     },
     // 婊″嫟濂�
     handleConstSetShow(val) {
       this.constType = val;
+      if(val==10){
+        this.handleGetBomKindDictList(10);
+      }
       this.$refs.constantSetDialog.islook = true;
     },
     // 鍗曚綅
@@ -450,45 +534,47 @@
       this.handleGetBomKindDictList();
       this.$refs.editDialog.editDialogVisible = true;
     },
-    handleConfirmSave(dataList) {
-      saveSalaryType({
-        type: 8,
-        values: dataList,
-      }).then((res) => {
+    handleConfirmSave(dataList,val) {
+      let params={}
+      if(val==9||val==10){
+        params={
+          type: val,
+          values: dataList,
+        }
+      }else{
+        params={
+          type: 8,
+          values: dataList,
+        }
+      }
+      saveSalaryType(params).then((res) => {
         if (res.code == 200) {
           this.$message({
             message: "鎿嶄綔鎴愬姛锛�",
             type: "success",
           });
-          this.$refs.editDialog.editDialogVisible = false;
-          this.handleGetBomKindDictList();
+          if(val==9){
+            this.$refs.silkSetDialog.islook = false;
+          }else  if(val==10){
+            this.$refs.constantSetDialog.islook = false;
+          }else{
+            this.$refs.editDialog.editDialogVisible = false;
+          }
+          this.handleGetBomKindDictList(val?val:'');
         }
       });
     },
-    handleGetBomKindDictList() {
-      getSalaryTypeList({ type: 8 }).then((res) => {
-        this.unitList = res.data;
+    handleGetBomKindDictList(val) {
+      getSalaryTypeList({ type: val?val:8 }).then((res) => {
+        if(val==9){
+          this.wildSilkList=(res.data&&res.data.length>0)?res.data[0].name.split(','):['閲庣氦']
+        }else if(val==10){
+          this.absenteeism=(res.data&&res.data.length>0)?res.data[0].name:1
+        }else{
+          this.unitList = res.data;
+        }
+       
       });
-    },
-    formInfo() {
-      if (this.islook) {
-        this.form = {
-          name: "",
-          workTypes: [],
-          salaryType: "",
-          salaryFormula: "",
-          salaryFormulaHtml: "",
-          error: "",
-          purchaseTypeList: [1],
-          cycle: '1',
-        };
-        this.$nextTick(() => {
-          this.$refs["form"].resetFields();
-          if (this.editRow.id) {
-            this.form = JSON.parse(JSON.stringify(this.editRow));
-          }
-        });
-      }
     },
     getSelectDataList() {
       getWorkTypeList({
@@ -511,14 +597,25 @@
     submitForm(formName) {
       this.$refs[formName].validate((valid) => {
         if (valid) {
-          let form = JSON.parse(JSON.stringify(this.form));
-          let arr = form.salaryFormula.split("锛�");
-           arr=arr.splice(0,arr.length-1)
-           form.salaryFormula=arr.join("锛�")
-          if (form.purchaseTypeList.length == 0) {
-            this.$message.error("璇风偣鍑婚噹绾ゆ暟閲忛厤缃敓涓濇爣鍑嗭紒");
+          this.checkFormula();
+          if (this.form.error == 2) {
+            this.$message.error("璇锋鏌ヨ璐瑰叕寮忓畾涔夛紒");
             return true;
           }
+          let form = JSON.parse(JSON.stringify(this.form));
+          let arr = form.salaryFormula.split(",");
+          arr = arr.splice(0, arr.length - 1);
+          form.salaryFormula = arr.join(",");
+          let workTypes = [];
+          if (form.workTypes && form.workTypes.length > 0) {
+            for (let i in form.workTypes) {
+              workTypes.push({
+                workName: form.workTypes[i].label,
+                id: form.workTypes[i].value,
+              });
+            }
+          }
+          form.workTypes = workTypes;
           saveSalaryPlan(form).then((res) => {
             if (res.code == 200) {
               this.$message({
@@ -596,7 +693,7 @@
     }
   }
   .formula-input {
-    width: calc(100% - 100px);
+    width: calc(100% - 90px);
     height: 100px;
     padding: 10px 10px;
     overflow-y: auto;
@@ -604,12 +701,19 @@
     border: 1px solid #e4e7ed;
     cursor: not-allowed;
     float: left;
-    margin-right: 20px;
   }
-  .formula-btn {
+  .formula-btn-right {
+    width: 60px;
     float: left;
-    margin-top: 80px;
+    position: relative;
+    .formula-btn-t {
+      margin-left: 10px;
+    }
+    .formula-btn {
+      margin-top: 40px;
+    }
   }
+
   .formula-error {
     width: calc(100% - 110px);
     line-height: 28px;

--
Gitblit v1.8.0