Преглед на файлове

feat: 安全巡检详情页功能完善。

lanjianrong преди 4 години
родител
ревизия
44050fad89

+ 33 - 21
src/components/AuditContent/index.tsx

@@ -59,7 +59,7 @@ interface iAuditContentProps {
 }
 
 const Index: React.FC<iAuditContentProps> = props => {
-  const { onSelect, auditors, onDelete, status, auditHistory, latest } = props
+  const { onSelect, auditors, onDelete, status, auditHistory } = props
   const [ visible, setVisible ] = useState({
     check: false,
     reCheck: false
@@ -265,9 +265,11 @@ 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>
+          {status !== auditConsts.uncheck ? (
+            <td>
+              <span className={renderLeftStatus(auditors.length > 1 ? 2 : 0).textClass}>{renderLeftStatus(auditors.length > 1 ? 2 : 0).text}</span>
+            </td>
+          ) : null}
         </tr>
         {auditors
           .filter(item => item.progress === '0')
@@ -282,9 +284,11 @@ 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>
+                {status !== auditConsts.uncheck ? (
+                  <td>
+                    <span className={renderLeftStatus(item.status).textClass}>{renderLeftStatus(item.status).text}</span>
+                  </td>
+                ) : null}
               </tr>
             ) : (
               <tr key={item.audit_id}>
@@ -293,9 +297,11 @@ 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>
+                {status !== auditConsts.uncheck ? (
+                  <td>
+                    <span className={renderLeftStatus(item.status).textClass}>{renderLeftStatus(item.status).text}</span>
+                  </td>
+                ) : null}
               </tr>
             )
           })}
@@ -322,11 +328,13 @@ const Index: React.FC<iAuditContentProps> = props => {
               </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>
+          {status !== auditConsts.uncheck ? (
+            <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>
+          ) : null}
         </tr>
         {auditors
           .filter(item => item.progress === '2')
@@ -341,9 +349,11 @@ 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>
+                {status !== auditConsts.uncheck ? (
+                  <td>
+                    <span className={renderLeftStatus(item.status).textClass}>{renderLeftStatus(item.status).text}</span>
+                  </td>
+                ) : null}
               </tr>
             ) : (
               <tr key={item.audit_id}>
@@ -352,9 +362,11 @@ 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>
+                {status !== auditConsts.uncheck ? (
+                  <td>
+                    <span className={renderLeftStatus(item.status).textClass}>{renderLeftStatus(item.status).text}</span>
+                  </td>
+                ) : null}
               </tr>
             )
           })}

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

@@ -170,7 +170,7 @@ export default function Income() {
           </div>
         </Slot>
         <Slot position="right">
-          <Button type="ghost" size="small" icon={<SettingOutlined />} className="pi-mg-right-3" style={{ color: '#007bff' }} onClick={() => setRuleModal({ ...ruleModal, visible: true })}>设置</Button>
+          <Button type="ghost" size="small" icon={<SvgIcon type="xxh-cog" />} className="pi-mg-right-3" style={{ color: '#007bff' }} onClick={() => setRuleModal({ ...ruleModal, visible: true })}>设置</Button>
           {
             showCBtn ? <Button type="primary" size="small" onClick={() => setModalObj({ ...modalObj, type: 'create', visible: true })}>新建收入合同</Button>
             : ""

+ 1 - 1
src/pages/Login/index.tsx

@@ -51,7 +51,7 @@ class NormalLoginForm extends Component<iLoginProps, iState> {
       <Form
         name="normal_login"
         className={styles.loginForm}
-        initialValues={{ remember: true, password: '123456' }}
+        initialValues={{ password: '123456', code : '234' }}
         onFinish={this.onFinish}
       >
         <h4>纵横工程建设项目管理系统</h4>

+ 1 - 1
src/pages/Safe/Content/Info/Detail/api.ts

@@ -11,7 +11,7 @@ export async function apiGetSafeDetail(id: string) {
   for (const key in data?.data?.auditHistory) {
     if (Object.prototype.hasOwnProperty.call(data?.data?.auditHistory, key)) {
       const history = data?.data?.auditHistory[key]
-      auditHistory.push(history)
+      auditHistory.unshift(history)
     }
   }
   data.data.auditHistory = auditHistory

+ 6 - 7
src/pages/Safe/Content/Info/Detail/components/Modal/index.tsx

@@ -85,10 +85,6 @@ const AuditModal: React.FC<iAuditModalProps> = props => {
       if (type === 'pass' && isLastAuditor && curAuditor.progress === '0' && !user.id) {
         return message.error('请指定整改人!')
       }
-
-      if (type === 'back') {
-        values.progress = modal.auditType
-      }
       onCreate(values)
     })
   }
@@ -101,7 +97,7 @@ const AuditModal: React.FC<iAuditModalProps> = props => {
       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 })
+        setUser({ ...user, id: lastChecker.id, name: lastChecker.name })
       } else {
         const newGroup = initAuditBackGroup()
         setGroups(newGroup)
@@ -115,13 +111,15 @@ const AuditModal: React.FC<iAuditModalProps> = props => {
 
   // 初始化审批退回下拉选择框
   const initAuditBackGroup = () => {
+    console.log(auditors)
+
     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)
+            return mapUser(item.name, '', item.position, item.company, item.mobile)
           })
         newGroup.push({  value: '检查人', children: newAuditors })
       }
@@ -141,6 +139,7 @@ const AuditModal: React.FC<iAuditModalProps> = props => {
           })
         newGroup.push({ value: '整改', children: newAuditors })
       }
+
     }
     function mapUser(name: string, id: string, position: string, company: string, mobile: string) {
       return {
@@ -250,7 +249,7 @@ const AuditModal: React.FC<iAuditModalProps> = props => {
               </Popover>
             ) : null}
 
-            {user.id ? (
+            {user.name ? (
               <div className="pi-bordered pi-warning">
                 <span>已选择退回流程: </span>
                 <span>{user.name}</span>

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

@@ -10,13 +10,13 @@ import { iFile } from '@/types/file'
 import { iAuditHistoryState, iAuditor, iLatestAuditorState, iRectifiedState } from '@/types/safe'
 import { iUserInfo } from '@/types/setting'
 import { apiDelFile, apiGetFileList, apiSaveFileInfo } from '@/utils/common/api'
-import { auditProgress } from '@/utils/common/constStatus'
+import { auditConsts, auditProgress } from '@/utils/common/constStatus'
 import consts from '@/utils/consts'
-import { dayjsFormat } from '@/utils/util'
+import { dayjsFormat, formatDate } from '@/utils/util'
 import { Button, Input, message, Pagination, Tooltip } from 'antd'
 import locale from 'antd/es/date-picker/locale/zh_CN'
 import dayjs from 'dayjs'
-import React, { useEffect, useState } from 'react'
+import React, { useEffect, useState, useMemo } from 'react'
 import { RouteComponentProps } from 'react-router'
 import { apiGetSafeDetail, apiResfulSafeAudit } from './api'
 import AuditModal from './components/Modal'
@@ -27,6 +27,7 @@ interface iDetailState {
   auditName: string
   auditors: iAuditor[]
   bidsectionId: string
+  uid: string
   code: string
   createTime: string | undefined
   demand: string
@@ -44,7 +45,7 @@ interface iDetailState {
 
 interface iModifiedOrder {
   name: string
-  end_time: string | undefined
+  create_time: string | undefined
   opinion: string
   status: number
 }
@@ -67,6 +68,7 @@ const Detail: React.FC<RouteComponentProps> = props => {
   })
   const [ detail, setDetail ] = useState<iDetailState>({
     auditName: '',
+    uid: '',
     auditors: [],
     bidsectionId: '',
     code: '',
@@ -82,7 +84,7 @@ const Detail: React.FC<RouteComponentProps> = props => {
       name: '',
       status: 0,
       opinion: '',
-      end_time: ''
+      create_time: new Date().toDateString()
     },
     auditHistory: [],
     rectifiedInfo: [],
@@ -99,6 +101,9 @@ const Detail: React.FC<RouteComponentProps> = props => {
     },
     times: 0
   })
+  const isEdited = useMemo(() => {
+    return !!detail.status
+  }, [ detail.status ])
   useEffect(() => {
     initData()
   }, [ saveId ])
@@ -184,9 +189,15 @@ const Detail: React.FC<RouteComponentProps> = props => {
       payload = { id: detail.id }
     }
 
-    if (visible.auditType === 'pass') {
+    if (visible.auditType === 'pass' || visible.auditType === 'back') {
       payload.id = detail.latestAuditor.id
-      detail.latestAuditor.progress === '1' && (payload.rectifiedInfo = detail.checkOrder.opinion)
+      if (detail.latestAuditor.progress === '1') {
+        if (!detail.checkOrder.opinion) {
+          return message.error("请填写整改单!")
+        } else {
+          payload.rectifiedInfo = detail.checkOrder.opinion
+        }
+      }
     }
 
     if (visible.auditType === 'close') {
@@ -206,6 +217,8 @@ const Detail: React.FC<RouteComponentProps> = props => {
     }
   }
   const renderHeaderBtn = (status: number) => {
+
+    if (!detail.latestAuditor.audit_id && userStore.userInfo.id !== detail.uid) return null
     if (detail.latestAuditor.audit_id && userStore.userInfo.id !== detail.latestAuditor.audit_id) return null
     if (!status) {
       return (
@@ -254,30 +267,40 @@ const Detail: React.FC<RouteComponentProps> = props => {
               <tr>
                 <th style={{ width: '150px' }}>检查项目</th>
                 <td>
-                  <TextArea value={detail.inspection}></TextArea>
+                  {
+                    isEdited ? <span>{detail.inspection}</span> : <TextArea value={detail.inspection} ></TextArea>
+                  }
                 </td>
               </tr>
               <tr>
                 <th style={{ width: '150px' }}>现场检查情况</th>
                 <td>
-                  <TextArea value={detail.inspectionDetail}></TextArea>
+                  {
+                    isEdited ? <span>{detail.inspectionDetail}</span> : <TextArea value={detail.inspectionDetail} ></TextArea>
+                  }
                 </td>
               </tr>
               <tr>
                 <th style={{ width: '150px' }}>处理要求及措施</th>
                 <td>
-                  <TextArea value={detail.demand}></TextArea>
+                  {
+                    isEdited ? <span>{detail.demand}</span> : <TextArea value={detail.demand}></TextArea>
+                  }
                 </td>
               </tr>
               <tr>
                 <th style={{ width: '150px' }}>检查日期</th>
                 <td>
-                  <DatePicker
+                  {
+                    isEdited ? <span>{detail.createTime && dayjsFormat(detail.createTime, 'YYYY-MM-DD')}</span> :
+                    <DatePicker
                     size="small"
                     locale={locale}
                     allowClear={false}
                     value={dayjs(detail.createTime)}
                     onChange={value => setDetail({ ...detail, createTime: value?.format() })}></DatePicker>
+                  }
+
                 </td>
               </tr>
               <tr>
@@ -287,7 +310,7 @@ const Detail: React.FC<RouteComponentProps> = props => {
             </tbody>
           </table>
           {
-            detail.latestAuditor.progress === '1' && detail.rectifiedInfo.length ?
+            detail.status === auditProgress.checked && detail.latestAuditor.progress === '1'?
             <table className="pi-table pi-bordered">
             <thead>
               <tr>
@@ -310,17 +333,42 @@ const Detail: React.FC<RouteComponentProps> = props => {
                     size="small"
                     locale={locale}
                     allowClear={false}
-                    value={dayjs(detail.checkOrder.end_time)}
-                    onChange={value => setDetail({ ...detail, checkOrder: { ...detail.checkOrder, end_time: value?.format() } })}></DatePicker>
+                    value={dayjs(detail.checkOrder.create_time)}
+                    onChange={value => setDetail({ ...detail, checkOrder: { ...detail.checkOrder, create_time: value?.format() } })}></DatePicker>
                 </td>
               </tr>
               <tr>
                 <th style={{ width: '150px' }}>整改人</th>
-                <td>王五</td>
+                <td>{detail.auditors.find(item => item.progress === '1')?.name}</td>
+              </tr>
+            </tbody>
+          </table>
+          : detail.rectifiedInfo.map(item => (
+            <table className="pi-table pi-bordered" key={item.create_time}>
+            <thead>
+              <tr>
+                <th colSpan={2} className="pi-text-center">
+                  整改单
+                </th>
+              </tr>
+            </thead>
+            <tbody>
+              <tr>
+                <th style={{ width: '150px' }}>整改情况</th>
+                <td>{item.opinion}</td>
+              </tr>
+              <tr>
+                <th style={{ width: '150px' }}>整改日期</th>
+                <td>{dayjsFormat(item.create_time, 'YYYY-MM-DD')}</td>
+              </tr>
+              <tr>
+                <th style={{ width: '150px' }}>整改人</th>
+                <td>{item.name}</td>
               </tr>
             </tbody>
           </table>
-          : null
+          ))
+
           }
           <table className="pi-table pi-bordered mt-3">
             <thead>

+ 1 - 1
src/pages/Safe/Content/List/index.tsx

@@ -159,7 +159,7 @@ const SafeList:React.FC<{}> =() => {
         <Slot position="right">
           {
             !list.length ?
-            <Button type="ghost" size="small" icon={<SettingOutlined />} className="pi-mg-right-3" style={{ color: '#007bff' }} onClick={() => setRuleModal({ ...ruleModal, visible: true })}>设置</Button>
+            <Button type="ghost" size="small" icon={<SvgIcon type="xxh-cog" />} className="pi-mg-right-3" style={{ color: '#007bff' }} onClick={() => setRuleModal({ ...ruleModal, visible: true })}>设置</Button>
             : ""
           }
 

+ 4 - 1
src/router/routes.ts

@@ -129,7 +129,10 @@ export const routeConfig: RouteModel[] = [
                     path: 'list',
                     component: AsyncModuleLoader(() => import('@/pages/Safe/Content/List')),
                     auth: [ 'USER', 'ADMIN' ],
-                    defaultChildRoute: true
+                    defaultChildRoute: true,
+                    meta: {
+                      noCache: true
+                    }
                   },
                   {
                     path: 'info',

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

@@ -23,9 +23,8 @@ export interface iAuditHistory {
 
 export interface iRectifiedState {
   name: string;
-  end_time: string;
+  create_time: string;
   opinion: string;
-  status: number;
 }
 
 export interface iLatestAuditorState {