function All() {}
All.prototype = {
  // 将负责人的姓名挑出来做成字符串
  arrToStr(arr: any) {
    if (arr) {
      return arr.map((item: any) => { return item.name }).toString()
    }
  },
  toggleClass(arr: any, elem: any, key = 'id') {
    return arr.some((item: any) => { return item[key] == elem[key] })
  },
  toChecked(arr: any, elem: any, key = 'id') {
    console.log('toChecked')
    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) {
    // let tempValue = '会签'
    // let strPeople = ' '
    // if (nodeConfig.selectCustomApprovalType === 'huoqian') {
    //   tempValue = '或签'
    // }
    // if (nodeConfig.selectCustomApprovalMethod === 'normal') {
    //   if (nodeConfig.nodeUserList && nodeConfig.nodeUserList.length === 1) {
    //     strPeople = `由${nodeConfig.nodeUserList[0].name}负责`
    //   }
    //   else if (nodeConfig.nodeUserList && nodeConfig.nodeUserList.length > 1) {
    //     strPeople = `由${this.arrToStr(nodeConfig.nodeUserList)}负责（${tempValue}）`
    //   }
    //   return strPeople
    // }
    // else if (nodeConfig.selectCustomApprovalMethod === 'stepBYstep') {
    //   let strPeople = ' '
    //   if (nodeConfig.nodeUserList && nodeConfig.nodeUserList.length === 1) {
    //     strPeople = `由${nodeConfig.nodeUserList[0].name}负责(逐级审批)`
    //   }
    //   else if (nodeConfig.nodeUserList && nodeConfig.nodeUserList.length > 1) {
    //     strPeople = `由${this.arrToStr(nodeConfig.nodeUserList)}负责（逐级审批-${tempValue}）`
    //   }
    //   return strPeople
    // }

    if (nodeConfig.settype == 1 || nodeConfig.settype == 11) {
      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 `由${this.arrToStr(nodeConfig.nodeUserList)}负责（会签）`
        }
        else if (nodeConfig.examineMode == 3) {
          return `由${this.arrToStr(nodeConfig.nodeUserList)}负责（或签）`
        }
      }
    }
    else if (nodeConfig.settype == 2) {
      const level = nodeConfig.directorLevel == 1 ? '直接主管' : `第${nodeConfig.directorLevel}级主管`
      if (nodeConfig.examineMode == 1) {
        return level
      }
      else if (nodeConfig.examineMode == 2) {
        return `${level}会签`
      }
    }
    else if (nodeConfig.settype == 7) {
      return `从直接主管到通讯录中级别最高的第${nodeConfig.examineEndDirectorLevel}个层级主管`
    }
  },
  dealStr(str: any, obj: any) {
    const arr = []
    const list = str.split(',')
    for (var elem in obj) {
      list.map((item) => {
        if (item == elem) {
          arr.push(obj[elem].value)
        }
      })
    }
    return arr.join('或')
  },
  // 设置条件节点的文字
  conditionStr(nodeConfig: any, index: any) {
    var { conditionList, nodeUserList } = nodeConfig.conditionNodes[index]
    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++) {
        var { columnId } = conditionList[i]
        if (columnId == 0) {
          if (nodeUserList.length != 0) {
            str += '发起人属于：'
            str += `${nodeUserList.map((item: any) => { return item.name }).join('、')} `
          }
        }
      }
      // return str ? str.substring(0, str.length - 4) : '请设置条件'
      return str || '请设置条件'
    }
  },
  // 设置抄送人节点文字
  copyerStr(nodeConfig: any) {
    if (nodeConfig.nodeUserList && nodeConfig.nodeUserList.length != 0) {
      console.log(this.arrToStr(nodeConfig.nodeUserList))
      return this.arrToStr(nodeConfig.nodeUserList)
    }
    // else {
    //   if (nodeConfig.ccSelfSelectFlag == 1) {
    //     return '发起人自选'
    //   }
    // }
  },
  toggleStrClass(item: any, key: any) {
    const a = item.zdy1 ? item.zdy1.split(',') : []
    return a.some((item: any) => { return item == key })
  },
}

export default new All()
