lanjianrong 4 年之前
父節點
當前提交
0a33bf25d4

+ 2 - 1
src/components/AuditContent/index.tsx

@@ -15,6 +15,7 @@ interface iGroupItem extends iAccountGroupItem {
 }
 export const GroupItem: React.FC<iGroupItem> = props => {
   const { onSelect } = props
+
   const [ visible, setVisible ] = useState<boolean>(true)
 
   const changeVisible = () => {
@@ -164,7 +165,7 @@ const Index: React.FC<iAuditContentProps> = props => {
         break
       case 3:
         bgColor = 'pi-bg-yellow'
-        iconType = 'xxh-level-up'
+        iconType = 'xxh-reply'
         break
       case 4:
         bgColor = 'pi-bg-red'

+ 1 - 1
src/components/SvgIcon/index.tsx

@@ -1,5 +1,5 @@
 import { createFromIconfontCN } from '@ant-design/icons'
 const IconFont = createFromIconfontCN({
-  scriptUrl: '//at.alicdn.com/t/font_2224180_hl1573b0nw6.js'
+  scriptUrl: '//at.alicdn.com/t/font_2224180_1n7qk7cijqy.js'
 })
 export default IconFont

+ 1 - 1
src/pages/Contract/Content/Income/index.tsx

@@ -21,7 +21,7 @@ interface iModal {
 
 export default function Income() {
   const [ modalObj, setModalObj ] = useState<iModalBooleanProps>({
-    type: '',
+    type: 'create',
     visible: false,
     confirmLoading: false
   })

+ 106 - 8
src/pages/Safe/Content/Info/Detail/components/Modal/index.tsx

@@ -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}

+ 3 - 3
src/pages/Safe/Content/Info/Detail/index.tsx

@@ -141,12 +141,12 @@ const Detail: React.FC<RouteComponentProps> = props => {
     if (type === "check") {
       const newAuditors = detail.auditors
       const len = detail.auditors.filter((item: iAuditor) => item.progress === "0").length
-      newAuditors.push({ audit_id: user.id, audit_order: len + 1,position: user.position, progress: "0", name: user.name,accountGroup: user.accountGroup, company: user.company, status: 0 })
+      newAuditors.push({ id: '', mobile:'', audit_id: user.id, audit_order: len + 1,position: user.position, progress: "0", name: user.name,accountGroup: user.accountGroup, company: user.company, status: 0 })
       setDetail({ ...detail, auditors: newAuditors })
     } else {
       const newAuditors = detail.auditors
       const len = detail.auditors.filter((item: iAuditor) => item.progress === "2").length
-      newAuditors.push({ audit_id: user.id, audit_order: len + 1,position: user.position, progress: "2",  name: user.name, accountGroup: user.accountGroup, company: user.company, status: 0 })
+      newAuditors.push({ id: '', audit_id: user.id, mobile:'', audit_order: len + 1,position: user.position, progress: "2",  name: user.name, accountGroup: user.accountGroup, company: user.company, status: 0 })
       setDetail({ ...detail, auditors: newAuditors })
     }
   }
@@ -395,7 +395,7 @@ const Detail: React.FC<RouteComponentProps> = props => {
         visible={visible.auditModal}
         onCancel={() => setVisible({ ...visible, auditModal: false })}
         onCreate={onModalConfirm}
-        auditors={detail.auditors.filter(item => item.progress === '0')}
+        auditors={detail.auditors}
         curAuditor={detail.latestAuditor}
         ></AuditModal>
     </div>

+ 2 - 1
src/types/safe.d.ts

@@ -37,7 +37,8 @@ export interface iLatestAuditorState {
 
 export interface iAuditor {
   audit_id: string
-  auditor_id?: string
+  mobile: string
+  id: string
   name: string
   position: string
   progress: string

+ 0 - 3
src/utils/common/user.ts

@@ -41,9 +41,6 @@ export const getUserGroupName = (key: number): iGroup | undefined =>{
 
 // 根据group对用户列表进行分组
 export const getUserGroup = async (name?: string) => {
-  // if (!userStore.groupList.length) {
-  //   userStore.getGroupList()
-  // }
   const { code = -1, data = [] } = await apiGetAccountWithSearch(name)
   const accountGroup: iAccountGroupItem[] = []
   if (code === consts.RET_CODE.SUCCESS) {