From caeb71b06d19a8ffd854c19e5e4b58f7180cdce8 Mon Sep 17 00:00:00 2001 From: haoxuan <haoxuan> Date: 星期一, 29 四月 2024 18:55:14 +0800 Subject: [PATCH] 纤度检验表的保存接口参数修改 --- src/views/employeeSalary/salaryPlan/components/addDialog.vue | 603 ++++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 468 insertions(+), 135 deletions(-) diff --git a/src/views/employeeSalary/salaryPlan/components/addDialog.vue b/src/views/employeeSalary/salaryPlan/components/addDialog.vue index 645e466..6fd49ea 100644 --- a/src/views/employeeSalary/salaryPlan/components/addDialog.vue +++ b/src/views/employeeSalary/salaryPlan/components/addDialog.vue @@ -30,14 +30,14 @@ v-for="item in workTypeList" :key="item.ID" :label="item.workName" - :value="item" + :value="{ value: item.ID, label: item.workName }" > </el-option> </el-select> </el-form-item> - <el-form-item prop="salaryType" label="钖祫绫诲瀷"> + <el-form-item prop="salaryTypeId" label="钖祫绫诲瀷"> <el-select - v-model="form.salaryType" + v-model="form.salaryTypeId" style="width: calc(100% - 40px)" placeholder="璇烽�夋嫨杞﹂棿" > @@ -45,7 +45,7 @@ v-for="item in unitList" :key="item.id" :label="item.name" - :value="item.name" + :value="item.id" > </el-option> </el-select> @@ -55,16 +55,41 @@ @click="handleUnitShow" ></i> </el-form-item> - <el-form-item prop="salaryFormula" label="璁¤垂鍏紡瀹氫箟"> - <el-input + <el-form-item prop="salaryFormulaHtml" label="璁¤垂鍏紡瀹氫箟"> + <!-- <el-input type="textarea" :autosize="{ minRows: 4, maxRows: 6}" disabled placeholder="璇疯緭鍏ュ唴瀹�" - v-model="form.salaryFormula" + v-model="form.salaryFormulaHtml" > - </el-input> + </el-input> --> + <div class="formula-input" v-html="form.salaryFormulaHtml"></div> + <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"> + 鏃犻敊璇紝鍙斁蹇冧娇鐢� ! + </span> + <span v-if="form.error == 2" class="color_red"> + 鍏紡鏈夐敊璇紝璇锋鏌� ! + </span> + </div> <div class="formula-box"> <div class="table-bottom-tabs"> <div @@ -91,22 +116,51 @@ <div class="formula-bottom-box"> <div class="formula-l"> <div class="formula-p">鍙�夋暟鎹�</div> - <div class="formula-bottom" v-if="activeName==1"> - <div :class="item.width==2?'formula-item-100':'formula-item'" v-for='item in formulaName' :key="item.name"> - <span @click="formulaClick(item)"> {{ item.name }}</span> + <div class="formula-bottom" v-if="activeName == 1"> + <div + :class="item.width == 2 ? 'formula-item-100' : 'formula-item'" + v-for="item in formulaName" + :key="item.name" + > + <span @click="formulaClick(item)"> {{ item.name }}</span> + <i + v-if="item.type == 1" + class="el-icon-setting margin_left_5px cursor_pointer" + style="font-size: 18px; color: gray" + @click="handleSlikSetShow" + ></i> </div> </div> - <div class="formula-bottom" v-if="activeName==2"> - <div :class="item.width==2?'formula-item-100':'formula-item'" v-for='item in formulaNameTwo' :key="item.name"> - <span @click="formulaClick(item)"> {{ item.name }}</span> + <div class="formula-bottom" v-if="activeName == 2"> + <div + :class="item.width == 2 ? 'formula-item-100' : 'formula-item'" + v-for="item in formulaNameTwo" + :key="item.name" + > + <span @click="formulaClick(item)"> {{ item.name }}</span> + <i + v-if="item.type == 2" + class="el-icon-setting margin_left_5px cursor_pointer" + style="font-size: 18px; color: gray" + @click="handleConstSetShow(10)" + ></i> </div> </div> </div> <div class="formula-r"> <div class="formula-p">甯哥敤绗﹀彿/浜ч噺</div> <div class="formula-bottom"> - <div :class="item.width==2?'formula-item-100':'formula-item'" v-for='item in formulaSymbol' :key="item.name"> - <span @click="formulaClick(item)"> {{ item.name }}</span> + <div + :class="item.width == 2 ? 'formula-item-100' : 'formula-item'" + v-for="item in formulaSymbol" + :key="item.name" + > + <span v-if="item.type == 3" @click="handleConstSetShow(3)"> + {{ item.name }}</span + > + <span v-else @click="formulaClick(item)"> + {{ item.name }}</span + > </div> </div> </div> @@ -115,7 +169,7 @@ </el-form> <span slot="footer" class="dialog-footer"> <el-button type="cancel" @click="cancelMethod()">鍙栨秷</el-button> - <el-button type="primary" @click="submitForm('form')">纭� 瀹�</el-button> + <el-button type="primary" :loading="isAddloading" @click="submitForm('form')">纭� 瀹�</el-button> </span> </el-dialog> <BomDialog @@ -124,6 +178,19 @@ :workList="unitList" title="璁¢噺鍗曚綅" ></BomDialog> + <SilkSetDialog + ref="silkSetDialog" + @confirmValueSave="confirmValueSave" + :editRow="{wildSilkList:wildSilkList}" + title="閰嶇疆" + ></SilkSetDialog> + <ConstantSetDialog + ref="constantSetDialog" + @confirmValueSave="confirmValueSave" + :constType="constType" + :editRow="constType == 10?{absenteeism:absenteeism}:form" + :title="constType == 10 ? '閰嶇疆' : '杈撳叆'" + ></ConstantSetDialog> </div> </template> @@ -135,8 +202,14 @@ } from "@/api/employeeSalary/salaryPlan.js"; import { getWorkTypeList } from "@/api/employeeManage/employeeInfo.js"; import BomDialog from "@/views/employeeSalary/salaryPlan/components/bomDialog.vue"; +import SilkSetDialog from "@/views/employeeSalary/salaryPlan/components/SilkSetDialog.vue"; +import ConstantSetDialog from "@/views/employeeSalary/salaryPlan/components/ConstantSetDialog.vue"; export default { - components: { BomDialog }, + components: { + BomDialog, + SilkSetDialog, + ConstantSetDialog, + }, props: { editRow: { type: Object, @@ -144,90 +217,100 @@ }, data() { return { - islook: true, + islook: false, form: { name: "", workTypes: [], - salaryType: "", + salaryTypeId: null, salaryFormula: "", + salaryFormulaHtml: "", + error: "", }, + // 婊″嫟濂栬缃� + absenteeism:{value:1,id:null}, + // 璁剧疆閲庣氦鐨勭敓涓濇爣鍑� + wildSilkList: {value:'閲庣氦',id:null}, activeName: 1, - formulaName:[ + formulaName: [ { - name:'鏃ヤ骇涓濋噺', + name: "鏃ヤ骇涓濋噺", }, { - name:'閲庣氦鏁伴噺', - type:1, + name: "閲庣氦鏁伴噺", + type: 1, }, { - name:'鐢熶笣鍗曚环', + name: "鐢熶笣鍗曚环", }, { - name:'閲庣氦鍗曚环', + name: "閲庣氦鍗曚环", }, { - name:'妗舵暟(鏃�)', + name: "妗舵暟(鏃�)", }, { - name:'鍑哄嫟澶╂暟', + name: "鍑哄嫟澶╂暟", }, { - name:'鍚岀粍鎸¤溅宸ユ湀骞冲潎宸ヨ祫', - width:2 + name: "鍚岀粍鎸¤溅宸ユ湀骞冲潎宸ヨ祫", + width: 2, }, { - name:'鍚岀粍杞﹀ご宸ュ伐璧�', - width:2 - } - ], - formulaNameTwo:[ - { - name:'宸ヤ綔鏃ュ姞鐝椂闀�', - }, - { - name:'婊″嫟濂�', - type:1, - }, - { - name:'浼戞伅鏃ュ姞鐝椂闀�', - }, - { - name:'璇峰亣澶╂暟', - }, - { - name:'甯﹀緬澶╂暟', - }, - { - name:'宸ラ緞', - }, - { - name:'鍑哄嫟澶╂暟', + name: "鍚岀粍杞﹀ご宸ュ伐璧�", + width: 2, }, ], - formulaSymbol:[ + formulaNameTwo: [ { - name:'+', + name: "宸ヤ綔鏃ュ姞鐝椂闀�", }, { - name:'-', + name: "婊″嫟濂�", + type: 2, }, { - name:'/', + name: "浼戞伅鏃ュ姞鐝椂闀�", }, { - name:'*', + name: "璇峰亣澶╂暟", }, { - name:'(', + name: "甯﹀緬澶╂暟", }, { - name:')', + name: "宸ラ緞", }, { - name:'甯搁噺鏁板瓧', - type:1, - width:2 + name: "鍑哄嫟澶╂暟", + }, + ], + formulaSymbol: [ + { + name: "+", + background: "background_red", + }, + { + name: "-", + background: "background_red", + }, + { + name: "/", + background: "background_red", + }, + { + name: "*", + background: "background_red", + }, + { + name: "(", + }, + { + name: ")", + }, + { + name: "甯搁噺鏁板瓧", + type: 3, + width: 2, }, ], workTypeList: [], //宸ョ @@ -242,19 +325,23 @@ trigger: ["blur", "change"], }, ], - salaryType: [ + salaryTypeId: [ { required: true, message: "璇烽�夋嫨", trigger: ["blur", "change"] }, ], - salaryFormula: [ + salaryFormulaHtml: [ { required: true, message: "璇烽�夋嫨", trigger: ["blur", "change"] }, ], }, unitList: [], + constType: "", + isAddloading: false, }; }, computed: {}, created() { this.handleGetBomKindDictList(); + this.handleGetBomKindDictList(9); + this.handleGetBomKindDictList(10); this.getSelectDataList(); }, mounted() {}, @@ -272,50 +359,249 @@ tabClickBottom(activeName) { this.activeName = activeName; }, - // 鍗曚綅 - handleUnitShow() { - this.handleGetBomKindDictList(); - this.$refs.editDialog.editDialogVisible = true; - }, - handleConfirmSave(dataList) { - saveSalaryType({ - type: 8, - values: dataList, - }).then((res) => { - if (res.code == 200) { - this.$message({ - message: "鎿嶄綔鎴愬姛锛�", - type: "success", - }); - this.$refs.editDialog.editDialogVisible = false; - this.handleGetBomKindDictList(); - } - }); - }, - handleGetBomKindDictList() { - getSalaryTypeList({ type: 8 }).then((res) => { - this.unitList = res.data; - }); - }, formInfo() { if (this.islook) { this.form = { name: "", workTypes: [], - salaryType: "", + salaryTypeId: null, salaryFormula: "", + salaryFormulaHtml: "", + error: "", }; this.$nextTick(() => { this.$refs["form"].resetFields(); if (this.editRow.id) { this.form = JSON.parse(JSON.stringify(this.editRow)); - this.form.groupNumber = this.form.groupNumber - ? this.form.groupNumber - : null; - this.getGroupNumber(true); + 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 = ""; + let name = item.type == 3 && item.name == "甯搁噺鏁板瓧" ? value : item.name; + if (item.background) { + string = + "<span class='formula-input-item background_red color_fff'>" + + name + + "</span>"; + } else { + string = + "<span class='formula-input-item background_e3e3e3'>" + + name + + "</span>"; + } + 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++) { + if (arr[i] != "") { + // 闄ゆ暟涓嶈兘涓�0, 绗﹀彿閭h竟闇�瑕佹湁鍊� + if (isString.indexOf(arr[i]) != -1 || arr[i] == "(") { + if (i != 0) { + if (isString.indexOf(arr[i - 1]) != -1) { + string = false; + break; + } + } + if (i == arr.length - 1) { + string = false; + break; + } + if (i < arr.length - 1) { + if (isString.indexOf(arr[i + 1]) != -1) { + string = false; + break; + } else if (arr[i] == "/" && arr[i + 1] == 0) { + string = false; + break; + } + } + } else if (arr[i] == ")") { + if (i < arr.length - 1) { + if (isString.indexOf(arr[i + 1]) == -1) { + string = false; + break; + } + } + } else { + if (i != 0) { + if (isString.indexOf(arr[i - 1]) == -1 && arr[i - 1] != "(") { + string = false; + break; + } + } + if (i < arr.length - 1) { + if (isString.indexOf(arr[i + 1]) == -1 && arr[i + 1] != ")") { + string = false; + break; + } + } + } + } + } + + if (!string) { + this.$set(this.form, "error", 2); + } else { + this.$set(this.form, "error", 1); + } + } + }, + confirmValueSave(form, type) { + if (type == 9) { + let wildSilkList = form.wildSilkList; + this.handleConfirmSave([ + { + name:wildSilkList.join(','), + id:this.wildSilkList.id + } + ],type) + } else if (type == 10) { + let absenteeism = form.absenteeism + ""; + this.handleConfirmSave([ + { + name:absenteeism, + id:this.absenteeism.id + } + ],type) + } else if (type == 3) { + this.formulaClick( + { + name: "甯搁噺鏁板瓧", + type: 3, + width: 2, + }, + form.number + ); + } + }, + // 閲庣氦鏁伴噺 + 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; + }, + // 鍗曚綅 + handleUnitShow() { + this.handleGetBomKindDictList(); + this.$refs.editDialog.editDialogVisible = true; + }, + handleConfirmSave(dataList,val) { + let params={} + if(val==9||val==10){ + params={ + type: val, + values: dataList, + } + }else{ + params={ + type: 8, + values: dataList, + } + } + this.isAddloading = true; + saveSalaryType(params).then((res) => { + if (res.code == 200) { + this.$message({ + message: "鎿嶄綔鎴愬姛锛�", + type: "success", + }); + 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:''); + } + this.isAddloading = false; + }).catch(() => { + setTimeout(() => { + this.isAddloading = false; + }, 3000); + }); + }, + handleGetBomKindDictList(val) { + getSalaryTypeList({ type: val?val:8 }).then((res) => { + if(val==9){ + // 閲庣氦鐨勭敓涓濇爣鍑嗛厤缃� + this.wildSilkList=(res.data&&res.data.length>0)?{ + ...res.data[0], + value:res.data[0].name.split(',')||[] + }:{ + id:null, + value:['閲庣氦'] + } + }else if(val==10){ + // 鑰冨嫟閰嶇疆 + this.absenteeism=(res.data&&res.data.length>0)?{ + ...res.data[0], + value:res.data[0].name||1 + }:{ + id:null, + value:1 + } + }else{ + this.unitList = res.data; + } + + }); }, getSelectDataList() { getWorkTypeList({ @@ -338,7 +624,25 @@ submitForm(formName) { this.$refs[formName].validate((valid) => { if (valid) { + 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({ @@ -349,7 +653,6 @@ } }); } else { - console.log("error submit!!"); return false; } }); @@ -363,57 +666,87 @@ width: 90%; margin-bottom: 40px; margin: 0 auto; - .formula-box{ - height:auto; - width:calc(100% - 110px); - font-size:14px; - line-height:25px; - padding-left:110px; - .formula-bottom-box{ - width:100%; - height:auto; - overflow:hidden; - .formula-p{ - line-height:40px; + .formula-box { + height: auto; + width: calc(100% - 110px); + font-size: 14px; + line-height: 25px; + padding-left: 110px; + .formula-bottom-box { + width: 100%; + height: auto; + overflow: hidden; + margin-bottom: 30px; + .formula-p { + line-height: 40px; } - .formula-l,.formula-r{ - height:auto; - float:left; + .formula-l, + .formula-r { + height: auto; + float: left; } - .formula-l{ - width:calc(75% - 10px); - margin-right:20px; + .formula-l { + width: calc(75% - 10px); + margin-right: 20px; } - .formula-r{ - width:calc(25% - 10px); + .formula-r { + width: calc(25% - 10px); } - .formula-item-100{ - width:100%; - margin-bottom:10px; - span{ + .formula-item-100 { + width: 100%; + margin-bottom: 10px; + span { cursor: pointer; - padding:5px 10px; + padding: 5px 10px; } } - .formula-item{ - width:calc(50% - 5px); - margin-bottom:10px; - float:left; + .formula-item { + width: calc(50% - 5px); + margin-bottom: 10px; + float: left; &:nth-of-type(odd) { margin-right: 10px; } - span{ + span { cursor: pointer; - padding:5px 10px; + padding: 5px 10px; } } - .formula-bottom{ - padding:15px 10px; - background:#f3f3f3; - overflow:hidden; + .formula-bottom { + padding: 15px 10px; + background: #f3f3f3; + overflow: hidden; } } - + } + .formula-input { + width: calc(100% - 90px); + height: 100px; + padding: 10px 10px; + overflow-y: auto; + background: #f5f7fa; + border: 1px solid #e4e7ed; + cursor: not-allowed; + float: left; + } + .formula-btn-right { + width: 60px; + float: left; + position: relative; + .formula-btn-t { + margin-left: 10px; + } + .formula-btn { + margin-top: 40px; + } + } + + .formula-error { + width: calc(100% - 110px); + line-height: 28px; + font-size: 14px; + margin-left: 110px; + margin-bottom: 10px; } } -- Gitblit v1.8.0