king
2024-05-21 a4466960bfd628036aa2b6f9aa706f75215482bc
src/utils/utils.js
@@ -854,24 +854,6 @@
  }
  /**
   * @description 获取云端图片真实路径
   * @return {String}    url 图片路径
   */
  static getcloudurl (url) {
    if (!url) return ''
    let baseurl = ''
    if (window.GLOB.cloudServiceApi) {
      baseurl = window.GLOB.cloudServiceApi.replace(/webapi(.*)$/, '')
    } else {
      baseurl = window.GLOB.baseurl
    }
    return url.match(/^http/) || url.match(/^\/\//) ? url : baseurl + url
  }
  /**
   * @description 获取下拉搜索查询条件
   * @return {String} item   搜索条件信息
   */
@@ -2149,8 +2131,13 @@
    let status = 0
    let statusName = ''
    let detailId = ''
    let sign = ''
    let error = ''
    let userid = sessionStorage.getItem('UserID') || ''
    let checkIds = []
    let checkUsers = []
    let noticeIds = []
    let work_grade = sessionStorage.getItem('work_grade') || 0
    if (verify.flowType === 'start') {
      target = flow.cells.filter(cell => cell.mknode === 'start')[0]
@@ -2193,14 +2180,31 @@
                }
              })
              if (!error) {
                line = lines[0]
                lines = lines.filter(cell => {
                  if (cell.mkdata.seniorCondition === 'open' && !line) {
                    cell.mkdata.seniorbers && cell.mkdata.seniorbers.forEach(per => {
                      if (per.worker_id === userid) {
                        line = cell
                      }
                    })
                    return false
                  }
                  return true
                })
                if (!line) {
                  line = lines[0]
                }
              }
            } else if (!_data.hasOwnProperty(branchKey)) {
              error = '信息中无流程控制字段。'
            } else {
              let equalLine = null
              let gtOrLtLine = []
              let unEqualLine = null
              let _def_lines = []
              let _equ_lines = []
              let _unequ_lines = []
              let _or_lines = []
              let branchVal = _data[branchKey]
              if (branchVal && typeof(branchVal) === 'string' && !isNaN(branchVal)) {
@@ -2209,45 +2213,58 @@
              lines.forEach(item => {
                if (item.mkdata.execCondition !== 'open') {
                  line = item
                  _def_lines.push(item)
                } else {
                  if (item.mkdata.match === '=') {
                    if (item.mkdata.matchVal === branchVal + '') {
                      equalLine = item
                      _equ_lines.push(item)
                    }
                  } else if (item.mkdata.match === '!=') {
                    if (item.mkdata.matchVal !== branchVal + '') {
                      unEqualLine = item
                      _unequ_lines.push(item)
                    }
                  } else {
                    if (item.mkdata.match === '<') {
                      if (item.mkdata.matchVal < branchVal) {
                        gtOrLtLine.push({...item, dist: Math.abs(item.mkdata.matchVal - branchVal)})
                        _or_lines.push({...item, dist: Math.abs(item.mkdata.matchVal - branchVal)})
                      }
                    } else if (item.mkdata.match === '>') {
                      if (item.mkdata.matchVal > branchVal) {
                        gtOrLtLine.push({...item, dist: Math.abs(item.mkdata.matchVal - branchVal)})
                        _or_lines.push({...item, dist: Math.abs(item.mkdata.matchVal - branchVal)})
                      }
                    } else if (item.mkdata.match === '<=') {
                      if (item.mkdata.matchVal <= branchVal) {
                        gtOrLtLine.push({...item, dist: Math.abs(item.mkdata.matchVal - branchVal)})
                        _or_lines.push({...item, dist: Math.abs(item.mkdata.matchVal - branchVal)})
                      }
                    } else if (item.mkdata.match === '>=') {
                      if (item.mkdata.matchVal >= branchVal) {
                        gtOrLtLine.push({...item, dist: Math.abs(item.mkdata.matchVal - branchVal)})
                        _or_lines.push({...item, dist: Math.abs(item.mkdata.matchVal - branchVal)})
                      }
                    }
                  }
                }
              })
              if (equalLine) {
                line = equalLine
              } else if (gtOrLtLine.length > 0) {
                gtOrLtLine.sort((a, b) => a.dist - b.dist)
                line = gtOrLtLine[0]
              } else if (unEqualLine) {
                line = unEqualLine
              _or_lines.sort((a, b) => a.dist - b.dist)
              let _lines = [..._equ_lines, ..._or_lines, ..._unequ_lines, ..._def_lines]
              _lines = _lines.filter(cell => {
                if (cell.mkdata.seniorCondition === 'open' && !line) {
                  cell.mkdata.seniorbers && cell.mkdata.seniorbers.forEach(per => {
                    if (per.worker_id === userid) {
                      line = cell
                    }
                  })
                  return false
                }
                return true
              })
              if (!line) {
                line = _lines[0]
              }
            }
          }
@@ -2260,7 +2277,36 @@
        detailId = line.id
        status = line.mkdata.status
        statusName = line.mkdata.statusName
        sign = line.mkdata.seniorSign || ''
        target = flow.cells.filter(cell => cell.id === line.target.cell)[0]
        line.mkdata.members && line.mkdata.members.forEach(item => {
          if (line.mkdata.approver === 'departmentManager') {
            if (item.job_type === 'manage' && departmentcode === item.parentIds[1]) {
              checkIds.push(item.worker_id)
              checkUsers.push(item)
            }
          } else if (line.mkdata.approver === 'directManager') {
            if (departmentcode === item.parentIds[1] && item.work_grade > work_grade) {
              checkIds.push(item.worker_id)
              checkUsers.push(item)
            }
          } else {
            checkIds.push(item.worker_id)
            checkUsers.push(item)
          }
        })
        line.mkdata.copys && line.mkdata.copys.forEach(item => {
          noticeIds.push(item.worker_id)
        })
        if (!target) {
          error = '未查询到工作流目标节点'
        } else if (checkIds.length === 0 && !['startEdge', 'endEdge', 'throughEdge'].includes(line.mknode)) {
          error = '未获取到下一步审批人'
        } else if (line.approvalMethod === 'countersign' && (!node.checkIds || !node.checkIds.includes(userid))) {
          error = '当前用户不在审批人列表中'
        }
      } else if (!error) {
        error = '工作流中无对应流程'
      }
@@ -2276,7 +2322,7 @@
      /* 工作流异常sql */
      select @ErrorCode='E',@retmsg='${error}' goto aaa
      `
    } else if (verify.flowSql === 'true' && target) {
    } else if (verify.flowSql === 'true') {
      if (verify.flowType === 'start') {
        _sql += `
      /* 工作流默认sql */
@@ -2289,15 +2335,7 @@
      insert into s_my_works_flow_role (works_flow_id,works_flow_code,userid,works_flow_detail_id,createuserid,CreateUser,CreateStaff,upid,typecharone)
      select @ID@,@works_flow_code@,@userid@,@works_flow_detail_id@,@userid@,@UserName,@FullName,@time_id@,'begin'
      `
      } else if (line && line.approvalMethod === 'countersign' && (!node.checkIds || !node.checkIds.includes(userid))) {
        status = 0
        statusName = '异常'
        _sql += `
        /* 工作流异常sql */
        select @ErrorCode='E',@retmsg='当前用户不在审批人列表中' goto aaa
        `
      } else if (line && line.approvalMethod === 'countersign' && node.checkIds.length > 1) {
      } else if (line.approvalMethod === 'countersign' && node.checkIds.length > 1) {
        let label = ''
        let field = ''
        let mark = line.mark || '已审核'
@@ -2427,51 +2465,16 @@
      end
      `
      }
    } else if (verify.flowSql === 'true') {
      status = 0
      statusName = '异常'
      _sql += `
      /* 工作流异常sql */
      select @ErrorCode='E',@retmsg='${error || '工作流执行异常'}' goto aaa
      `
    }
    let checkIds = []
    let checkUsers = []
    let work_grade = sessionStorage.getItem('work_grade') || 0
    if (verify.flowType !== 'start') {
      if (line) {
        let noticeIds = []
        line.mkdata.members && line.mkdata.members.forEach(item => {
          if (line.mkdata.approver === 'departmentManager') {
            if (item.job_type === 'manage' && departmentcode === item.parentIds[1]) {
              checkIds.push(item.worker_id)
              checkUsers.push(item)
            }
          } else if (line.mkdata.approver === 'directManager') {
            if (departmentcode === item.parentIds[1] && item.work_grade > work_grade) {
              checkIds.push(item.worker_id)
              checkUsers.push(item)
            }
          } else {
            checkIds.push(item.worker_id)
            checkUsers.push(item)
          }
        })
        line.mkdata.copys && line.mkdata.copys.forEach(item => {
          noticeIds.push(item.worker_id)
        })
        _sql = _sql.replace(/@check_userids@/ig, `'${checkIds.join(',')}'`)
        _sql = _sql.replace(/@notice_userids@/ig, `'${noticeIds.join(',')}'`)
      } else {
        _sql = _sql.replace(/@check_userids@/ig, `''`)
        _sql = _sql.replace(/@notice_userids@/ig, `''`)
      }
    } else {
      _sql = _sql.replace(/@check_userids@/ig, `''`)
      _sql = _sql.replace(/@notice_userids@/ig, `''`)
    if (_backCustomScript) {
      _sql += _backCustomScript
    }
    _sql = _sql.replace(/@works_flow_sign@/ig, `'${sign}'`)
    _sql = _sql.replace(/@check_userids@/ig, `'${checkIds.join(',')}'`)
    _sql = _sql.replace(/@notice_userids@/ig, `'${noticeIds.join(',')}'`)
    _sql = _sql.replace(/@start_type@/ig, `'开始'`)
    _sql = _sql.replace(/@check_type@/ig, verify.flowType === 'reject' ? `'驳回'` : `'审核'`)
@@ -2492,9 +2495,7 @@
    _sql = _sql.replace(/@statusname@/ig, `'${statusName}'`)
    _sql = _sql.replace(/@work_group@/ig, `'${sessionStorage.getItem('work_group') || ''}'`)
    _sql = _sql.replace(/@work_grade@/ig, `'${work_grade}'`)
  }
  if (_backCustomScript) {
  } else if (_backCustomScript) {
    _sql += _backCustomScript
  }