import {getConfigs} from "@/api/system/sysCustomConfig"; import {Message} from "element-ui"; function getColer(item,value){ const colorRule = item.colorRule; if(colorRule && colorRule.indexOf(",") != -1){ var arr = colorRule.split("|"); var reColor = ""; arr.some(s => { var arrTemp = s.split(","); const type = arrTemp[0] const valueT = arrTemp[1] const color = arrTemp[2] if(type == "=" && value == valueT){ reColor = color; }else if(type == ">=" && value >= valueT){ reColor = color; }else if(type == ">" && value > valueT){ reColor = color; }else if(type == "<" && value < valueT){ reColor = color; }else if(type == "<=" && value <= valueT){ reColor = color; } else if(type == "0"){ reColor = color; } }) return reColor; }else{ return colorRule; } } export async function getHead(businessType,type){ try { var subData = {}; subData.businessType = businessType; subData.type = type; const re = await getConfigs(subData); if(re.code != 20000){ Message.error("获取配置失败"); } return re; } catch (error) { console.error(error); } } export function executeFuc(_this,row,number,type,clickFuc,value){ if("1" == type){ //按钮事件 return callModelFun(_this,clickFuc,row); }else if("3" == type){ //按钮是否禁用事件 if(clickFuc){ return callModelFun(_this,clickFuc,row); }else{ return false; } }else if("4" == type){ //颜色方法 return getColer(clickFuc,value); }else if("5" == type){ //查询input方法 if(clickFuc){ return callModelFun(_this,clickFuc,row); }else{ return false; } }else if("6" == type){ //查询input方法 if(clickFuc){ return callModelFun(_this,clickFuc,row); }else{ return false; } }else if("2" == type){ if(number.clickFuc){ //表单事件 return callModelFun(_this,number.clickFuc,row); }else{ return true; } }else if(number != null && number >= 0){ //复选框事件 var checkSelectableFuc = "" _this.tableObj.tableList.forEach(obj => { if(obj.columnType == "selection"){ checkSelectableFuc = obj.clickFuc; } }) // if(checkSelectableFuc){ return callModelFun(_this,checkSelectableFuc,row); }else{ return true; } }else{ console.log(row); //表单点击事件 if(_this.tableObj.handleChangeFuc){ return callModelFun(_this,_this.tableObj.handleChangeFuc,row); } return true; } } /** * 根据方法名称调用方法 */ function callModelFun(_this,funcName,row) { let methods = _this.$options.methods; // 解释说明一下, this需要传入目标方法, 否则,在目标方法中修改data中的值, 将不会重新渲染dom, 跟v-if结合使用的过程中需要注意 return methods[funcName](_this,row); }