소스 검색

feat: 安全巡检审批功能优化

lanjianrong 4 년 전
부모
커밋
e381f7a7b6
5개의 변경된 파일118개의 추가작업 그리고 113개의 파일을 삭제
  1. 99 98
      src/components/AuditContent/index.tsx
  2. 1 1
      src/components/SvgIcon/index.tsx
  3. 2 9
      src/pages/Login/index.tsx
  4. 9 3
      src/pages/Safe/Content/Info/Detail/index.tsx
  5. 7 2
      src/types/safe.d.ts

+ 99 - 98
src/components/AuditContent/index.tsx

@@ -59,7 +59,7 @@ interface iAuditContentProps {
 }
 
 const Index: React.FC<iAuditContentProps> = props => {
-  const { onSelect, auditors, onDelete, status, auditHistory, uName } = props
+  const { onSelect, auditors, onDelete, status, auditHistory, latest } = props
   const [ visible, setVisible ] = useState({
     check: false,
     reCheck: false
@@ -147,35 +147,27 @@ const Index: React.FC<iAuditContentProps> = props => {
     )
   }
 
-  const renderStatusIcon = (status: number, isStart: boolean) => {
+  const renderStatusIcon = (status: number, isEnd: boolean) => {
     let bgColor: string = ''
     let iconType: string = ''
     switch (status) {
       case 0:
-        bgColor = 'pi-bg-gray'
-        iconType = ''
-        break
-      case 1:
-        bgColor = 'pi-bg-yellow'
-        iconType = 'xxh-ellipsis-h1'
-        break
-      case 2:
         bgColor = 'pi-bg-green'
         iconType = 'xxh-check'
         break
-      case 3:
+      case 1:
         bgColor = 'pi-bg-yellow'
         iconType = 'xxh-reply'
         break
-      case 4:
+      case 2:
         bgColor = 'pi-bg-red'
         iconType = 'xxh-minus'
         break
       default:
         break
     }
-    if (isStart) {
-      bgColor = 'pi-bg-green'
+
+    if (isEnd) {
       iconType = 'xxh-caret-down1'
     }
     return <div className={[ 'timeline-item-icon', 'pi-justify-center', 'pi-align-center', bgColor ].join(' ')}>{iconType ? <SvgIcon type={iconType}></SvgIcon> : null}</div>
@@ -186,56 +178,52 @@ const Index: React.FC<iAuditContentProps> = props => {
     let textClass = 'pi-green'
     if (progress === '0') {
       switch (status) {
-        case 1:
-          text = '审批中'
-          textClass = 'pi-yellow'
-          break
-        case 2:
-          text = '审批通过'
+        case 0:
+          text = '上报审批'
           textClass = 'pi-green'
           break
-        case 3:
+        case 1:
           text = '审批退回'
           textClass = 'pi-yellow'
           break
-        case 4:
-          text = '审批关闭'
+        case 2:
+          text = '关闭'
           textClass = 'pi-red'
           break
         default:
           break
       }
-    } else if (progress === '1') {
+    } else if (progress === '1' || progress === '3') {
       switch (status) {
-        case 1:
-          text = '整改中'
-          textClass = 'pi-yellow'
-          break
-        case 2:
-          text = '整改完成'
+        case 0:
+          text = '审批通过'
           textClass = 'pi-green'
           break
-        case 3:
+        case 1:
           text = '审批退回'
           textClass = 'pi-yellow'
           break
+        case 2:
+          text = '关闭'
+          textClass = 'pi-red'
+          break
         default:
           break
       }
     } else if (progress === '2') {
       switch (status) {
-        case 1:
-          text = '复查中'
-          textClass = 'pi-yellow'
-          break
-        case 2:
-          text = '复查完成'
+        case 0:
+          text = '整改完成'
           textClass = 'pi-green'
           break
-        case 3:
+        case 1:
           text = '审批退回'
           textClass = 'pi-yellow'
           break
+        case 2:
+          text = '关闭'
+          textClass = 'pi-red'
+          break
         default:
           break
       }
@@ -243,10 +231,31 @@ const Index: React.FC<iAuditContentProps> = props => {
     return { text, textClass }
   }
 
+  const renderLeftStatus = (status: number) => {
+    let text = ''
+    let textClass = ''
+    switch (status) {
+      case 1:
+        text = '进行中'
+        textClass = 'pi-yellow'
+        break
+      case 2:
+        text = '完成'
+        textClass = 'pi-green'
+        break
+      case 3:
+        text = '关闭'
+        textClass = 'pi-red'
+        break
+      default:
+        break
+    }
+    return { text, textClass }
+  }
+
   const renderLeftAuditors = (status: number) => {
     // 整改人所需信息
     const len = auditors.filter(item => item.progress === '0').length
-
     return (
       <tbody>
         <tr>
@@ -256,6 +265,9 @@ const Index: React.FC<iAuditContentProps> = props => {
             <span className="pi-mg-left-3">{auditors[0]?.name}</span>
             <small className="text-muted pi-mg-left-3">{auditors[0]?.position}</small>
           </td>
+          <td>
+            <span className={renderLeftStatus(latest.id ? 2 : 0).textClass}>{renderLeftStatus(latest.id ? 2 : 0).text}</span>
+          </td>
         </tr>
         {auditors
           .filter(item => item.progress === '0')
@@ -270,6 +282,9 @@ const Index: React.FC<iAuditContentProps> = props => {
                   <span className="pi-mg-left-3">{item.name}</span>
                   <small className="text-muted pi-mg-left-3">{item.position}</small>
                 </td>
+                <td>
+                  <span className={renderLeftStatus(item.status).textClass}>{renderLeftStatus(item.status).text}</span>
+                </td>
               </tr>
             ) : (
               <tr key={item.audit_id}>
@@ -278,6 +293,9 @@ const Index: React.FC<iAuditContentProps> = props => {
                   <span className="pi-mg-left-3">{item.name}</span>
                   <small className="text-muted pi-mg-left-3">{item.position}</small>
                 </td>
+                <td>
+                  <span className={renderLeftStatus(item.status).textClass}>{renderLeftStatus(item.status).text}</span>
+                </td>
               </tr>
             )
           })}
@@ -295,9 +313,20 @@ const Index: React.FC<iAuditContentProps> = props => {
                 <span className="pi-mg-left-3">由 {auditors.filter(item => item.progress === '0')[len - 1]?.name} 指派</span>
               )
             ) : (
-              <span className="pi-mg-left-3">由<span className="pi-mg-3">{auditors.filter(item => item.progress === '0').length ? auditors.filter(item => item.progress === '0')[len - 1]?.name : '最后一个审批人'}</span>指派</span>
+              <span className="pi-mg-left-3">
+                由
+                <span className="pi-mg-3">
+                  {auditors.filter(item => item.progress === '0').length ? auditors.filter(item => item.progress === '0')[len - 1]?.name : '最后一个审批人'}
+                </span>
+                指派
+              </span>
             )}
           </td>
+          <td>
+            <span className={renderLeftStatus(auditors.find(item => item.progress === '1')?.status || 0).textClass}>
+              {renderLeftStatus(auditors.find(item => item.progress === '1')?.status || 0).text}
+            </span>
+          </td>
         </tr>
         {auditors
           .filter(item => item.progress === '2')
@@ -312,6 +341,9 @@ const Index: React.FC<iAuditContentProps> = props => {
                   <span className="pi-mg-left-3">{item.name}</span>
                   <small className="text-muted pi-mg-left-3">{item.position}</small>
                 </td>
+                <td>
+                  <span className={renderLeftStatus(item.status).textClass}>{renderLeftStatus(item.status).text}</span>
+                </td>
               </tr>
             ) : (
               <tr key={item.audit_id}>
@@ -320,6 +352,9 @@ const Index: React.FC<iAuditContentProps> = props => {
                   <span className="pi-mg-left-3">{item.name}</span>
                   <small className="text-muted pi-mg-left-3">{item.position}</small>
                 </td>
+                <td>
+                  <span className={renderLeftStatus(item.status).textClass}>{renderLeftStatus(item.status).text}</span>
+                </td>
               </tr>
             )
           })}
@@ -330,73 +365,41 @@ const Index: React.FC<iAuditContentProps> = props => {
   const renderHistory = () => {
     return (
       <>
-      {auditHistory?.map((item, index) => {
-        return (
-          <ul className="timeline-list" key={index}>
-            {item?.map((auditor, idx) => (
-              <div key={idx}>
-                {index === 0 && idx === 0 ? (
+        {auditHistory?.map((item, index) => {
+          return (
+            <ul className="timeline-list" key={index}>
+              {item?.map((auditor, idx) => (
+                <div key={idx}>
                   <li className="timeline-list-item">
-                    <div className="timeline-item-date pi-flex-column" dangerouslySetInnerHTML={{ __html: formatDate(auditor.create_time) }}></div>
-                    <div className={item.length - 1 === idx ? '' : 'timeline-item-tail'}></div>
-                    {renderStatusIcon(auditor.status, true)}
-                    <div className="timeline-item-content">
-                      <div className="card-container">
-                        <div className="card-content">
-                          <div className="pi-justify-between label">
-                            <span>{uName}</span>
-                            <span className="pi-green">上报审批</span>
-                          </div>
-                        </div>
-                      </div>
-                    </div>
-                  </li>
-                ) : null}
-                <li className="timeline-list-item" >
-                  {auditor.status ? (
                     <div
                       className="timeline-item-date pi-flex-column"
-                      dangerouslySetInnerHTML={{ __html: formatDate(auditor.status === auditConsts.checked || auditor.status === auditConsts.close? auditor.end_time : auditor.create_time) }}></div>
-                  ) : null}
-                  <div className={item.length - 1 === idx ? '' : 'timeline-item-tail'}></div>
-                  {renderStatusIcon(auditor.status, false)}
-                  <div className="timeline-item-content">
-                    <div className="card-container">
-                      <div className="card-content">
-                        <div className="pi-justify-between label">
-                          <span>{auditor.name}</span>
-                          <span className={renderStatusEle(auditor.status, auditor.progress).textClass}>{renderStatusEle(auditor.status, auditor.progress).text}</span>
-                        </div>
-                        <div className="text-muted">{auditor.position}</div>
-                      </div>
-                      {auditor.opinion ? (
-                        <div className="textarea">
-                          <span>{auditor.opinion}</span>
-                        </div>
-                      ) : null}
-                    </div>
-                  </div>
-                </li>
-                {idx === item.filter(item => item.progress === '0').length - 1 && !auditors.find(item => item.progress === '1')? (
-                  <li className="timeline-list-item" >
-                    <div className="timeline-item-tail"></div>
-                    {renderStatusIcon(0, false)}
+                      dangerouslySetInnerHTML={{
+                        __html: formatDate(auditor.create_time)
+                      }}></div>
+                    <div className={item.length - 1 === idx ? '' : 'timeline-item-tail'}></div>
+                    {renderStatusIcon(auditor.status, idx === item.length - 1)}
                     <div className="timeline-item-content">
                       <div className="card-container">
                         <div className="card-content">
                           <div className="pi-justify-between label">
-                            <span>待指派</span>
+                            <span>{auditor.name}</span>
+                            <span className={renderStatusEle(auditor.status, auditor.progress).textClass}>{renderStatusEle(auditor.status, auditor.progress).text}</span>
                           </div>
+                          <div className="text-muted">{auditor.position}</div>
                         </div>
+                        {auditor.opinion ? (
+                          <div className="textarea">
+                            <span>{auditor.opinion}</span>
+                          </div>
+                        ) : null}
                       </div>
                     </div>
                   </li>
-                ) : null}
-              </div>
-            ))}
-          </ul>
-        )
-      })}
+                </div>
+              ))}
+            </ul>
+          )
+        })}
       </>
     )
   }
@@ -473,9 +476,7 @@ const Index: React.FC<iAuditContentProps> = props => {
                 <div className="pi-flex-sub pi-mg-right-15 pi-mg-top-5 pi-mg-left-5">
                   <table className="table table-bordered pi-width-100P">{renderLeftAuditors(status)}</table>
                 </div>
-                <div className="pi-flex-treble pi-mg-left-15">
-                  {renderHistory()}
-                </div>
+                <div className="pi-flex-twice pi-mg-left-15">{renderHistory()}</div>
               </div>
             </td>
           )}

+ 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_1n7qk7cijqy.js'
+  scriptUrl: '//at.alicdn.com/t/font_2224180_1k48wjqufrd.js'
 })
 export default IconFont

+ 2 - 9
src/pages/Login/index.tsx

@@ -24,15 +24,9 @@ class NormalLoginForm extends Component<iLoginProps, iState> {
     this.state = initLoginState
   }
   onFinish = (values: iFromValues) => {
-    // const { code = -1, data }  = await apiLogin(values)
-    // if (code === consts.RET_CODE.SUCCESS) {
-      // }
     userStore.login(values)
   }
 
-  componentWillUnmount() {
-    // this.props.saveUser!(this.state.user)
-  }
   handleProjectCode = async (e: any) => {
     const projectCode = e.target?.value
     const { code = -1, data = [] } = await apiProject(projectCode)
@@ -57,7 +51,7 @@ class NormalLoginForm extends Component<iLoginProps, iState> {
       <Form
         name="normal_login"
         className={styles.loginForm}
-        initialValues={{ remember: true }}
+        initialValues={{ remember: true, password: '123456' }}
         onFinish={this.onFinish}
       >
         <h4>纵横工程建设项目管理系统</h4>
@@ -78,8 +72,7 @@ class NormalLoginForm extends Component<iLoginProps, iState> {
           name="password"
           rules={[ { required: true, message: 'Please input your Password!' } ]}
         >
-          <Input.Password type="password" placeholder="密码"
-          />
+          <Input.Password type="password" placeholder="密码"/>
         </Form.Item>
 
         <Form.Item>

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

@@ -87,10 +87,15 @@ const Detail: React.FC<RouteComponentProps> = props => {
     auditHistory: [],
     rectifiedInfo: [],
     latestAuditor: {
-      id: '',
       audit_id: '',
-      status: 0,
-      progress: ''
+      audit_order: 0,
+      bidsection_id: '',
+      data_id: '',
+      data_type: 0,
+      id: '',
+      progress: '',
+      project_id: '',
+      status: 0
     },
     times: 0
   })
@@ -201,6 +206,7 @@ const Detail: React.FC<RouteComponentProps> = props => {
     }
   }
   const renderHeaderBtn = (status: number) => {
+    if (detail.latestAuditor.audit_id && userStore.userInfo.id !== detail.latestAuditor.audit_id) return null
     if (!status) {
       return (
         <div className="pi-flex-row pi-align-center">

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

@@ -30,9 +30,14 @@ export interface iRectifiedState {
 
 export interface iLatestAuditorState {
   audit_id: string;
-  status: number;
+  audit_order: number;
+  bidsection_id: string;
+  data_id: string;
+  data_type: number;
+  id: string;
   progress: string;
-  id: string
+  project_id: string;
+  status: number;
 }
 
 export interface iAuditor {