You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
285 lines
11 KiB
285 lines
11 KiB
function All() {}
|
|
All.prototype = {
|
|
timer: "",
|
|
debounce(fn:any, delay = 500) {
|
|
var _this = this;
|
|
return (arg: any) => {
|
|
//获取函数的作用域和变量
|
|
let that = this;
|
|
let args = arg;
|
|
clearTimeout(_this.timer) // 清除定时器
|
|
_this.timer = setTimeout(function() {
|
|
fn.call(that, args)
|
|
}, delay)
|
|
}
|
|
},
|
|
setCookie(val:any) { //cookie设置[{key:value}]、获取key、清除['key1','key2']
|
|
for (var i = 0, len = val.length; i < len; i++) {
|
|
for (var key in val[i]) {
|
|
document.cookie = key + '=' + encodeURIComponent(val[i][key]) + "; path=/";
|
|
}
|
|
}
|
|
},
|
|
getCookie(name:any) {
|
|
var strCookie = document.cookie;
|
|
var arrCookie = strCookie.split("; ");
|
|
for (var i = 0, len = arrCookie.length; i < len; i++) {
|
|
var arr = arrCookie[i].split("=");
|
|
if (name == arr[0]) {
|
|
return decodeURIComponent(arr[1]);
|
|
}
|
|
}
|
|
},
|
|
clearCookie(name:any) {
|
|
var myDate = new Date();
|
|
myDate.setTime(-1000); //设置时间
|
|
for (var i = 0, len = name.length; i < len; i++) {
|
|
document.cookie = "" + name[i] + "=''; path=/; expires=" + myDate.toUTCString();
|
|
}
|
|
},
|
|
arrToStr(arr:any) {
|
|
if (arr) {
|
|
return arr.map((item: { name: any; }) => { return item.name }).toString()
|
|
}
|
|
},
|
|
toggleClass(arr:any, elem:any, key = 'id') {
|
|
return arr.some((item: { [x: string]: any; }) => { return item[key] == elem[key] });
|
|
},
|
|
toChecked(arr:any, elem:any, key = 'id') {
|
|
var isIncludes = this.toggleClass(arr, elem, key);
|
|
!isIncludes ? arr.push(elem) : this.removeEle(arr, elem, key);
|
|
},
|
|
removeEle(arr:any, elem:any, key = 'id') {
|
|
var includesIndex;
|
|
arr.map((item:any, index:any) => {
|
|
if (item[key] == elem[key]) {
|
|
includesIndex = index
|
|
}
|
|
});
|
|
arr.splice(includesIndex, 1);
|
|
},
|
|
setApproverStr(nodeConfig:any) {
|
|
// console.log("setApproverStr",nodeConfig);
|
|
if (nodeConfig.settype == 1) {
|
|
if (nodeConfig.nodeUserList.length == 1) {
|
|
return nodeConfig.nodeUserList[0].name
|
|
} else if (nodeConfig.nodeUserList.length > 1) {
|
|
if (nodeConfig.examineMode == 1) {
|
|
return this.arrToStr(nodeConfig.nodeUserList)
|
|
} else if (nodeConfig.examineMode == 2) {
|
|
return nodeConfig.nodeUserList.length + "人会签"
|
|
}else if (nodeConfig.examineMode == 3) {
|
|
return nodeConfig.nodeUserList.length + "人或签"
|
|
}
|
|
}else{
|
|
// return "指定成员"
|
|
}
|
|
} else if (nodeConfig.settype == 2) {
|
|
|
|
let level = nodeConfig.directorLevel == 1 ? '直接主管' : '第' + nodeConfig.directorLevel + '级主管'
|
|
if (nodeConfig.examineMode == 1) {
|
|
return level
|
|
} else if (nodeConfig.examineMode == 2) {
|
|
return level + "会签"
|
|
}else if (nodeConfig.examineMode == 3) {
|
|
return level + + "或签"
|
|
}
|
|
} else if (nodeConfig.settype == 3) {
|
|
// console.log("nodeConfig==会签==>",nodeConfig)
|
|
if (nodeConfig.nodeUserList.length == 1) {
|
|
return nodeConfig.nodeUserList[0].name
|
|
}else{
|
|
return "指定行政岗位"
|
|
}
|
|
} else if (nodeConfig.settype == 4) {
|
|
// console.log("nodeConfig.selectRange",nodeConfig.selectRange,nodeConfig.nodeUserList);
|
|
if (nodeConfig.selectRange == 1) {
|
|
return "发起人自选"
|
|
} else {
|
|
if (nodeConfig.nodeUserList.length > 0) {
|
|
if (nodeConfig.selectRange == 2) {
|
|
return "发起人从指定成员中自选"
|
|
} else {
|
|
return '发起人从' + nodeConfig.nodeUserList[0].name + '中自选'
|
|
}
|
|
} else {
|
|
return "";
|
|
}
|
|
}
|
|
} else if (nodeConfig.settype == 5) {
|
|
return "发起人自己"
|
|
} else if (nodeConfig.settype == 6) {
|
|
// console.log("nodeConfig==直接主管==>",nodeConfig)
|
|
return '从直接主管到通讯录中级别最高的第' + nodeConfig.examineEndDirectorLevel + '个层级主管'
|
|
}else if (nodeConfig.settype == 7){
|
|
return "指定前置审批为本节点设置审批人"
|
|
}else if (nodeConfig.settype == 8){
|
|
// console.log("checkedFormList--1111->",nodeConfig)
|
|
if(nodeConfig.nodeUserList.length > 0){
|
|
if (nodeConfig.examineMode == 1) {
|
|
return nodeConfig.nodeUserList[0].name + "依次审批"
|
|
} else if (nodeConfig.examineMode == 2) {
|
|
return nodeConfig.nodeUserList[0].name + "会签"
|
|
}else if (nodeConfig.examineMode == 3) {
|
|
return nodeConfig.nodeUserList[0].name + "或签"
|
|
}
|
|
}
|
|
|
|
}else if (nodeConfig.settype == 9){
|
|
if(nodeConfig.matrix && nodeConfig.matrix.outcomeName){
|
|
let strVal = nodeConfig.matrix.outcomeName
|
|
if (nodeConfig.examineMode == 1) {
|
|
return strVal + "依次审批"
|
|
} else if (nodeConfig.examineMode == 2) {
|
|
return strVal + "会签"
|
|
}else if (nodeConfig.examineMode == 3) {
|
|
return strVal + "或签"
|
|
}
|
|
}
|
|
|
|
}
|
|
},
|
|
dealStr(str:any, obj:any) {
|
|
let arr: any[] = [];
|
|
let list = str.split(",");
|
|
for (var elem in obj) {
|
|
list.map((item: string) => {
|
|
if (item == elem) {
|
|
arr.push(obj[elem].value)
|
|
}
|
|
})
|
|
}
|
|
return arr.join("或")
|
|
},
|
|
conditionStr(nodeConfig:any, index:any) {
|
|
var { conditionList, nodeUserList } = nodeConfig.conditionNodes[index];
|
|
|
|
// console.log("判断调教--1->",nodeConfig)
|
|
// console.log("判断调教--2->",index)
|
|
// console.log("判断调教--3->",conditionList)
|
|
// console.log("判断调教--4->",nodeUserList)
|
|
// console.log("判断调教--5->",nodeConfig.conditionNodes[index])
|
|
// if(conditionList[0].nodeUserList){
|
|
// console.log("判断调教--6->",conditionList[0].nodeUserList)
|
|
// }
|
|
// conditionList.forEach((ites:any)=>{
|
|
// console.log("判断调教--6->",nodeConfig.conditionNodes.length - 1)
|
|
// })
|
|
// console.log("判断调教--7->",nodeConfig.conditionNodes[0].conditionList)
|
|
// console.log("判断调教--8->",(index == nodeConfig.conditionNodes.length - 1) && nodeConfig.conditionNodes[0].conditionList.length != 0)
|
|
|
|
if (conditionList.length == 0) {
|
|
return (index == nodeConfig.conditionNodes.length - 1) && nodeConfig.conditionNodes[0].conditionList.length != 0 ? '未满足其他条件分支的情况,将使用此流程!' : '请设置条件'
|
|
} else {
|
|
let str = ""
|
|
|
|
for (var i = 0; i < conditionList.length; i++) {
|
|
// console.log("判断调教分支形同--6->",conditionList[i])
|
|
var {name,type,options,nodeUserList,answers,isCheckbox,customFields,oneanswer} = conditionList[i]
|
|
switch(type){
|
|
case 1:
|
|
if(nodeUserList.length > 0){
|
|
str += '发起人属于:'
|
|
str += nodeUserList.map((item: { name: any; }) => { return item.name }).join("或") + " 并且 "
|
|
}
|
|
break;
|
|
case 2:
|
|
|
|
if(customFields.length > 0){
|
|
customFields.forEach((item:any) =>{
|
|
if (item.optType != 6 && item.leftval) {
|
|
var optTypeStr = ["", "<", ">", "≤", "=", "≥"][item.optType]
|
|
str += `${item.wordfield} ${optTypeStr} ${item.leftval} 并且 `
|
|
}else if (item.optType == 6 && item.leftval && item.rightval) {
|
|
let opt1 = ["", "<", ">", "≤", "=", "≥"][item.leftoptType]
|
|
let opt2 = ["", "<", ">", "≤", "=", "≥"][item.rightoptType]
|
|
str += `${item.leftval} ${opt1} ${item.wordfield} ${opt2} ${item.rightval} 并且 `
|
|
}
|
|
})
|
|
}
|
|
break;
|
|
case 3:
|
|
|
|
if(isCheckbox){
|
|
if(answers.length > 0){
|
|
str += name + "为"
|
|
if(Array.isArray(answers)){
|
|
let valStr = ""
|
|
options.forEach((item:any)=>{
|
|
if(answers.includes(item.value)){
|
|
valStr += `${item.label} 或 `
|
|
}
|
|
// console.log("answers.includes(item.value)",answers.includes(item.value),answers,item.value,valStr)
|
|
})
|
|
// str += valStr+` 并且 `
|
|
|
|
str += valStr ? valStr.substring(0, valStr.length - 2)+` 并且 `:"";
|
|
}else{
|
|
|
|
options.forEach((item:any)=>{
|
|
if(item.value == answers){
|
|
str += item.label+` 并且 `
|
|
}
|
|
})
|
|
|
|
}
|
|
}
|
|
}else{
|
|
|
|
str += name + "为"
|
|
options.forEach((item:any)=>{
|
|
// console.log("判断调教分支形同--6--1--->",oneanswer,item.value == oneanswer,item.value)
|
|
if(item.value == oneanswer){
|
|
str += item.label+` 并且 `
|
|
}
|
|
})
|
|
}
|
|
// console.log("判断调教分支形同--6--1-2-->",oneanswer,str,str.substring(0, str.length - 4))
|
|
break;
|
|
default:
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// for (var i = 0; i < conditionList.length; i++) {
|
|
// var { columnId, columnType, showType, showName, optType, zdy1, opt1, zdy2, opt2, fixedDownBoxValue } = conditionList[i];
|
|
// if (columnId == 0) {
|
|
// if (nodeUserList.length != 0) {
|
|
// str += '发起人属于:'
|
|
// str += nodeUserList.map((item: { name: any; }) => { return item.name }).join("或") + " 并且 "
|
|
// }
|
|
// }
|
|
// if (columnType == "String" && showType == "3") {
|
|
// if (zdy1) {
|
|
// str += showName + '属于:' + this.dealStr(zdy1, JSON.parse(fixedDownBoxValue)) + " 并且 "
|
|
// }
|
|
// }
|
|
// if (columnType == "Double") {
|
|
// if (optType != 6 && zdy1) {
|
|
// var optTypeStr = ["", "<", ">", "≤", "=", "≥"][optType]
|
|
// str += `${showName} ${optTypeStr} ${zdy1} 并且 `
|
|
// } else if (optType == 6 && zdy1 && zdy2) {
|
|
// str += `${zdy1} ${opt1} ${showName} ${opt2} ${zdy2} 并且 `
|
|
// }
|
|
// }
|
|
// }
|
|
return str ? str.substring(0, str.length - 4) : '请设置条件'
|
|
}
|
|
},
|
|
copyerStr(nodeConfig:any) {
|
|
if (nodeConfig.nodeUserList.length != 0) {
|
|
return this.arrToStr(nodeConfig.nodeUserList)
|
|
} else {
|
|
if (nodeConfig.ccSelfSelectFlag == 1) {
|
|
return "发起人自选"
|
|
}
|
|
}
|
|
},
|
|
toggleStrClass(item: { zdy1: string; }, key: any) {
|
|
let a = item.zdy1 ? item.zdy1.split(",") : []
|
|
return a.some((item: any) => { return item == key });
|
|
},
|
|
}
|
|
|
|
export default new (All as any)();
|
|
|