|  | @@ -40,17 +40,20 @@ const textObj = {
 | 
	
		
			
				|  |  |  interface iModalObjState {
 | 
	
		
			
				|  |  |    searchValue: string
 | 
	
		
			
				|  |  |    visible: boolean
 | 
	
		
			
				|  |  | +  auditType: string
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  const AuditModal: React.FC<iAuditModalProps> = props => {
 | 
	
		
			
				|  |  |    const [ form ] = Form.useForm()
 | 
	
		
			
				|  |  |    const { visible, type, onCancel, onCreate, auditors, curAuditor } = props
 | 
	
		
			
				|  |  |    const [ modal, setModal ] = useState<iModalObjState>({
 | 
	
		
			
				|  |  |      searchValue: '',
 | 
	
		
			
				|  |  | -    visible: false
 | 
	
		
			
				|  |  | +    visible: false,
 | 
	
		
			
				|  |  | +    auditType: ''
 | 
	
		
			
				|  |  |    })
 | 
	
		
			
				|  |  |    // 是否是审批组的最后一个审核人
 | 
	
		
			
				|  |  |    const isLastAuditor = useMemo(() => {
 | 
	
		
			
				|  |  | -    if (auditors.length && auditors[auditors.length - 1].auditor_id === userStore.userInfo.id) {
 | 
	
		
			
				|  |  | +    const len = auditors.filter(item => item.progress === '0').length
 | 
	
		
			
				|  |  | +    if (len && auditors.filter(item => item.progress === '0')[len - 1].audit_id === userStore.userInfo.id) {
 | 
	
		
			
				|  |  |        return true
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      return false
 | 
	
	
		
			
				|  | @@ -78,23 +81,88 @@ const AuditModal: React.FC<iAuditModalProps> = props => {
 | 
	
		
			
				|  |  |        if (user.id) {
 | 
	
		
			
				|  |  |          values.audit_id = user.id
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |        if (type === 'pass' && isLastAuditor && curAuditor.progress === '0' && !user.id) {
 | 
	
		
			
				|  |  |          return message.error('请指定整改人!')
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +      if (type === 'back') {
 | 
	
		
			
				|  |  | +        values.progress = modal.auditType
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  |        onCreate(values)
 | 
	
		
			
				|  |  |      })
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    useEffect(() => {
 | 
	
		
			
				|  |  | -    if ((visible && isLastAuditor && type === 'pass') || type === 'back') {
 | 
	
		
			
				|  |  | +    if (visible && isLastAuditor && type === 'pass') {
 | 
	
		
			
				|  |  |        initGroupList()
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +    if (visible && type === 'back') {
 | 
	
		
			
				|  |  | +      if (curAuditor.progress === '1') {
 | 
	
		
			
				|  |  | +        const len = auditors.filter(item => item.progress === '0').length
 | 
	
		
			
				|  |  | +        const lastChecker = auditors.filter(item => item.progress === '0')[len - 1]
 | 
	
		
			
				|  |  | +        setUser({ ...user, id: lastChecker.audit_id, name: lastChecker.name })
 | 
	
		
			
				|  |  | +      } else {
 | 
	
		
			
				|  |  | +        const newGroup = initAuditBackGroup()
 | 
	
		
			
				|  |  | +        setGroups(newGroup)
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |    }, [ visible ])
 | 
	
		
			
				|  |  |    const initGroupList = async (serach?: string) => {
 | 
	
		
			
				|  |  |      const data = await getUserGroup(serach)
 | 
	
		
			
				|  |  |      setGroups(data)
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +  // 初始化审批退回下拉选择框
 | 
	
		
			
				|  |  | +  const initAuditBackGroup = () => {
 | 
	
		
			
				|  |  | +    const newGroup: iAccountGroupItem[] = []
 | 
	
		
			
				|  |  | +    for (let index = 0; index < 3; index++) {
 | 
	
		
			
				|  |  | +      if (index === 0) {
 | 
	
		
			
				|  |  | +        const newAuditors = auditors
 | 
	
		
			
				|  |  | +          .filter(item => item.progress === '')
 | 
	
		
			
				|  |  | +          .map(item => {
 | 
	
		
			
				|  |  | +            return mapUser(item.name, item.id, item.position, item.company, item.mobile)
 | 
	
		
			
				|  |  | +          })
 | 
	
		
			
				|  |  | +        newGroup.push({  value: '检查人', children: newAuditors })
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +      if (index === 1) {
 | 
	
		
			
				|  |  | +        const newAuditors = auditors
 | 
	
		
			
				|  |  | +          .filter(item => item.progress === '0')
 | 
	
		
			
				|  |  | +          .map(item => {
 | 
	
		
			
				|  |  | +            return mapUser(item.name, item.id, item.position, item.company, item.mobile)
 | 
	
		
			
				|  |  | +          })
 | 
	
		
			
				|  |  | +        newGroup.push({  value: '审批', children: newAuditors })
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +      if (index === 2) {
 | 
	
		
			
				|  |  | +        const newAuditors = auditors
 | 
	
		
			
				|  |  | +          .filter(item => item.progress === '1')
 | 
	
		
			
				|  |  | +          .map(item => {
 | 
	
		
			
				|  |  | +            return mapUser(item.name, item.id, item.position, item.company, item.mobile)
 | 
	
		
			
				|  |  | +          })
 | 
	
		
			
				|  |  | +        newGroup.push({ value: '整改', children: newAuditors })
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    function mapUser(name: string, id: string, position: string, company: string, mobile: string) {
 | 
	
		
			
				|  |  | +      return {
 | 
	
		
			
				|  |  | +        account: '',
 | 
	
		
			
				|  |  | +        accountGroup: 0,
 | 
	
		
			
				|  |  | +        company,
 | 
	
		
			
				|  |  | +        csrf: '',
 | 
	
		
			
				|  |  | +        enable: 0,
 | 
	
		
			
				|  |  | +        id,
 | 
	
		
			
				|  |  | +        isAdmin: 0,
 | 
	
		
			
				|  |  | +        mobile,
 | 
	
		
			
				|  |  | +        name,
 | 
	
		
			
				|  |  | +        password: '',
 | 
	
		
			
				|  |  | +        position,
 | 
	
		
			
				|  |  | +        projectId: '',
 | 
	
		
			
				|  |  | +        role: '',
 | 
	
		
			
				|  |  | +        telephone: ''
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    return newGroup
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |    const renderOkBtn = (type: string) => {
 | 
	
		
			
				|  |  |      if (type === 'start' || type === 'pass') {
 | 
	
		
			
				|  |  |        return (
 | 
	
	
		
			
				|  | @@ -132,9 +200,10 @@ const AuditModal: React.FC<iAuditModalProps> = props => {
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -  const itemSelectHandler = (item: iUserInfo) => {
 | 
	
		
			
				|  |  | +  const itemSelectHandler = (item: iUserInfo, type: string = '') => {
 | 
	
		
			
				|  |  |      setUser({ ...user, ...item })
 | 
	
		
			
				|  |  | -    setModal({ ...modal, visible: false })
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    setModal({ ...modal, visible: false, auditType: type })
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    const handleVisibleChange = (visible: boolean) => {
 | 
	
	
		
			
				|  | @@ -160,6 +229,35 @@ const AuditModal: React.FC<iAuditModalProps> = props => {
 | 
	
		
			
				|  |  |          </div>
 | 
	
		
			
				|  |  |        }>
 | 
	
		
			
				|  |  |        <Form form={form} layout="vertical">
 | 
	
		
			
				|  |  | +        {type === 'back' ? (
 | 
	
		
			
				|  |  | +          <>
 | 
	
		
			
				|  |  | +            <Form.Item name="opinion" label="审批意见">
 | 
	
		
			
				|  |  | +              <Input.TextArea rows={5}></Input.TextArea>
 | 
	
		
			
				|  |  | +            </Form.Item>
 | 
	
		
			
				|  |  | +            {curAuditor.progress !== '1' ? (
 | 
	
		
			
				|  |  | +              <Popover
 | 
	
		
			
				|  |  | +                content={groups.map(item => (
 | 
	
		
			
				|  |  | +                  <GroupItem {...item} key={item.value} onSelect={(item: iUserInfo, type?: string) => itemSelectHandler(item, type)}></GroupItem>
 | 
	
		
			
				|  |  | +                ))}
 | 
	
		
			
				|  |  | +                overlayClassName="popover-card"
 | 
	
		
			
				|  |  | +                trigger="click"
 | 
	
		
			
				|  |  | +                visible={modal.visible}
 | 
	
		
			
				|  |  | +                onVisibleChange={visible => handleVisibleChange(visible)}
 | 
	
		
			
				|  |  | +                placement="bottomLeft">
 | 
	
		
			
				|  |  | +                <ZhButton size="small" onClick={showPopover}>
 | 
	
		
			
				|  |  | +                  选择退回流程
 | 
	
		
			
				|  |  | +                </ZhButton>
 | 
	
		
			
				|  |  | +              </Popover>
 | 
	
		
			
				|  |  | +            ) : null}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            {user.id ? (
 | 
	
		
			
				|  |  | +              <div className="pi-bordered pi-warning">
 | 
	
		
			
				|  |  | +                <span>已选择退回流程: </span>
 | 
	
		
			
				|  |  | +                <span>{user.name}</span>
 | 
	
		
			
				|  |  | +              </div>
 | 
	
		
			
				|  |  | +            ) : null}
 | 
	
		
			
				|  |  | +          </>
 | 
	
		
			
				|  |  | +        ) : null}
 | 
	
		
			
				|  |  |          {type === 'delete' ? (
 | 
	
		
			
				|  |  |            <>
 | 
	
		
			
				|  |  |              <p className="mb-2">删除后,数据无法恢复,请谨慎操作。</p>
 | 
	
	
		
			
				|  | @@ -196,11 +294,11 @@ const AuditModal: React.FC<iAuditModalProps> = props => {
 | 
	
		
			
				|  |  |              <Form.Item name="opinion" label="审批意见">
 | 
	
		
			
				|  |  |                <Input.TextArea rows={5}></Input.TextArea>
 | 
	
		
			
				|  |  |              </Form.Item>
 | 
	
		
			
				|  |  | -            {isLastAuditor &&  curAuditor.progress === '0'? (
 | 
	
		
			
				|  |  | +            {isLastAuditor && curAuditor.progress === '0' ? (
 | 
	
		
			
				|  |  |                <Popover
 | 
	
		
			
				|  |  |                  title={<Input.Search size="small" placeholder="姓名/手机 检索" onSearch={search} onChange={e => change(e)}></Input.Search>}
 | 
	
		
			
				|  |  |                  content={groups.map(item => (
 | 
	
		
			
				|  |  | -                  <GroupItem {...item} key={item.value} onSelect={(item: iUserInfo) => itemSelectHandler(item)}></GroupItem>
 | 
	
		
			
				|  |  | +                  <GroupItem {...item} key={item.value} onSelect={(item: iUserInfo, type?: string) => itemSelectHandler(item, type)}></GroupItem>
 | 
	
		
			
				|  |  |                  ))}
 | 
	
		
			
				|  |  |                  overlayClassName="popover-card"
 | 
	
		
			
				|  |  |                  trigger="click"
 | 
	
	
		
			
				|  | @@ -217,7 +315,7 @@ const AuditModal: React.FC<iAuditModalProps> = props => {
 | 
	
		
			
				|  |  |                <p className="pi-bordered pi-pd-8 pi-mg-top-5">
 | 
	
		
			
				|  |  |                  <span>已指派整改人: </span>
 | 
	
		
			
				|  |  |                  <span>
 | 
	
		
			
				|  |  | -                  {user.name}-{user.position}-{user.company}{' '}
 | 
	
		
			
				|  |  | +                  {user.name}-{user.position}-{user.company}
 | 
	
		
			
				|  |  |                  </span>
 | 
	
		
			
				|  |  |                </p>
 | 
	
		
			
				|  |  |              ) : null}
 |