Browse Source

feat: 新增巡检按钮的权限控制

lanjianrong 4 years ago
parent
commit
9eb83aa89e

+ 0 - 1
.prettierrc.json

@@ -1,5 +1,4 @@
 {
-  "prettier.eslintIntegration": true,
   "printWidth": 180,
   "tabWidth": 2,
   "eslintIntegration": true,

+ 14 - 4
src/pages/Quality/Content/Info/Detail/components/Modal/index.tsx

@@ -1,4 +1,5 @@
 import { GroupItem } from '@/components/AuditContent'
+import Authorization from '@/components/Authorization'
 import { ZhAuditBackButton, ZhButton, ZhCloseButton, ZhSubmitButton } from '@/components/Button'
 import { userStore } from '@/store/mobx'
 import { iAuditor, iLatestAuditorState } from '@/types/safe'
@@ -7,6 +8,7 @@ import { getUserGroup } from '@/utils/common/user'
 import { Button, Form, Input, message, Modal, Popover } from 'antd'
 import React, { ChangeEvent, useEffect, useMemo, useState, memo } from 'react'
 interface iAuditModalProps {
+  type: 'safe' | 'quality'
   onCancel: () => void
   modalObj: {
     visible: boolean
@@ -49,7 +51,7 @@ const textObj = {
 
 const AuditModal: React.FC<iAuditModalProps> = props => {
   const [ form ] = Form.useForm()
-  const { modalObj: { visible, type, loading }, onCancel, onCreate, auditors, curAuditor } = props
+  const { modalObj: { visible, type, loading }, onCancel, onCreate, auditors, curAuditor, type } = props
   console.log(loading)
 
 
@@ -127,7 +129,7 @@ const AuditModal: React.FC<iAuditModalProps> = props => {
           .map(item => {
             return mapUser(item.name, '', item.position, item.company, item.mobile)
           })
-        newGroup.push({  value: '检查人', children: newAuditors })
+        newGroup.push({ value: '检查人', children: newAuditors })
       }
       if (index === 1) {
         const newAuditors = auditors
@@ -135,7 +137,7 @@ const AuditModal: React.FC<iAuditModalProps> = props => {
           .map(item => {
             return mapUser(item.name, item.id, item.position, item.company, item.mobile)
           })
-        newGroup.push({  value: '审批', children: newAuditors })
+        newGroup.push({ value: '审批', children: newAuditors })
       }
       if (index === 2) {
         const newAuditors = auditors
@@ -175,7 +177,15 @@ const AuditModal: React.FC<iAuditModalProps> = props => {
           {textObj[type]?.okText}
         </ZhSubmitButton>
       )
-    } else if (type === 'delete' || type === 'close') {
+    } else if (type === 'delete') {
+      return (
+        <Authorization type={type} auth="delete">
+          <Button danger size="small" onClick={comfirmBtnClick} loading={loading}>
+            {textObj[type]?.okText}
+          </Button>
+        </Authorization>
+      )
+    } else if (type === 'close') {
       return (
         <Button danger size="small" onClick={comfirmBtnClick} loading={loading}>
           {textObj[type]?.okText}

+ 1 - 1
src/pages/Quality/Content/Info/Detail/index.tsx

@@ -469,7 +469,7 @@ const Detail: React.FC<RouteComponentProps> = props => {
         </div>
       </div>
       <OssUploadModal visible={modalObj.ossModal} onCancel={() => setModalObj({ ...modalObj, ossModal: false })} onCreate={onCreate} onShow={onOssModalShow}></OssUploadModal>
-      <AuditModal modalObj={modalProps} onCancel={hideAuditModal} onCreate={onModalConfirm} auditors={detail.auditors} curAuditor={detail.latestAuditor}></AuditModal>
+      <AuditModal type="quality" modalObj={modalProps} onCancel={hideAuditModal} onCreate={onModalConfirm} auditors={detail.auditors} curAuditor={detail.latestAuditor}></AuditModal>
     </div>
   )
 }

+ 53 - 65
src/pages/Quality/Content/List/index.tsx

@@ -1,3 +1,4 @@
+import Authorization from '@/components/Authorization'
 import FileModal from '@/components/FileModal'
 import Header from '@/components/Header'
 import Slot from '@/components/Header/slot'
@@ -16,24 +17,23 @@ import { Link } from 'react-router-dom'
 import { apiCreateQuality, apiQualityList, apiSaveRule } from './api'
 import AddModel from './modal'
 interface iQualityList {
-  id: string;
-  code: string;
-  createTime: string;
-  position: string;
-  inspection: string;
-  inspectionDetail: string;
-  demand: string;
-  status: number;
-  auditName: string;
-  fileCounts: number;
+  id: string
+  code: string
+  createTime: string
+  position: string
+  inspection: string
+  inspectionDetail: string
+  demand: string
+  status: number
+  auditName: string
+  fileCounts: number
 }
 interface iModal {
   visible: boolean
   loading: boolean
 }
 
-
-const QualityList:React.FC<{}> =() => {
+const QualityList: React.FC<{}> = () => {
   const [ ruleModal, setRuleModal ] = useState<iModal>({
     visible: false,
     loading: false
@@ -50,7 +50,7 @@ const QualityList:React.FC<{}> =() => {
   useEffect(() => {
     initData()
   }, [])
-  const columns:ColumnsType<iQualityList> = [
+  const columns: ColumnsType<iQualityList> = [
     {
       title: '序号',
       // eslint-disable-next-line react/display-name
@@ -63,7 +63,7 @@ const QualityList:React.FC<{}> =() => {
       dataIndex: 'code',
       // eslint-disable-next-line react/display-name
       render: (text: string, record) => {
-        return <Link to={{ pathname: "/console/quality/content/detail/info", state: { saveId: record.id } }}>{text}</Link>
+        return <Link to={{ pathname: '/console/quality/content/detail/info', state: { saveId: record.id } }}>{text}</Link>
       }
     },
     {
@@ -95,7 +95,11 @@ const QualityList:React.FC<{}> =() => {
       dataIndex: 'fileCounts',
       // eslint-disable-next-line react/display-name
       render: (text: string, record) => {
-      return <span className="pi-pointer" onClick={() => setFileModal({ ...fileModal, dataId: record.id, visible: true })}><SvgIcon type="xxh-paperclip1"></SvgIcon> {text}</span>
+        return (
+          <span className="pi-pointer" onClick={() => setFileModal({ ...fileModal, dataId: record.id, visible: true })}>
+            <SvgIcon type="xxh-paperclip1"></SvgIcon> {text}
+          </span>
+        )
       }
     },
     {
@@ -103,41 +107,30 @@ const QualityList:React.FC<{}> =() => {
       dataIndex: 'status',
       // eslint-disable-next-line react/display-name
       render: (statu: number) => {
-      return <span className={safeStatus[statu].className}>{safeStatus[statu].text}</span>
+        return <span className={safeStatus[statu].className}>{safeStatus[statu].text}</span>
       }
     }
   ]
-  const [ list, setList ] = useState<iQualityList[]>([
-    {
-      id: '',
-      code: '',
-      createTime: '',
-      position: '',
-      inspection: '',
-      inspectionDetail: '',
-      demand: '',
-      status: 0,
-      auditName: '',
-      fileCounts: 0
-    }
-  ])
+  const [ qualityList, setQualityList ] = useState<iQualityList[]>([])
   const [ total, setTotal ] = useState<number>(0)
   const initData = (pageNo: number = 1, pageSize: number = consts.PAGE_SIZE) => {
-    apiQualityList(tenderStore.bid, pageNo, pageSize).then(({ code = -1, data = [], total = 0 }) => {
-      if (code === consts.RET_CODE.SUCCESS) {
-        setList(data)
-        setTotal(total)
-      }
-    }).catch(err => {
-      console.log(err)
-    })
+    apiQualityList(tenderStore.bid, pageNo, pageSize)
+      .then(({ code = -1, data = [], total = 0 }) => {
+        if (code === consts.RET_CODE.SUCCESS) {
+          setQualityList(data)
+          setTotal(total)
+        }
+      })
+      .catch(err => {
+        console.log(err)
+      })
   }
 
   const onRuleCreate = async (ruleValue: any) => {
     setRuleModal({ ...ruleModal, loading: true })
     const { code = -1 } = await apiSaveRule({ bidsectionId: tenderStore.bid, type: 'quality_rule', rule: ruleValue })
     if (code === consts.RET_CODE.SUCCESS) {
-      message.success("规则更改成功!")
+      message.success('规则更改成功!')
       initData()
     }
     setRuleModal({ ...ruleModal, loading: false, visible: false })
@@ -156,13 +149,23 @@ const QualityList:React.FC<{}> =() => {
     <div className="wrap-contaniner">
       <Header title="质量巡检">
         <Slot position="right">
-          {
-            !list.length ?
-            <Button type="ghost" size="small" icon={<SvgIcon type="xxh-cog" />} className="pi-mg-right-3" style={{ color: '#007bff' }} onClick={() => setRuleModal({ ...ruleModal, visible: true })}>设置</Button>
-            : ""
-          }
+          {!qualityList.length ? (
+            <Button
+              type="ghost"
+              size="small"
+              icon={<SvgIcon type="xxh-cog" />}
+              className="pi-mg-right-3"
+              style={{ color: '#007bff' }}
+              onClick={() => setRuleModal({ ...ruleModal, visible: true })}>
+              设置
+            </Button>
+          ) : null}
 
-          <Button type="primary" size="small" onClick={() => setAddModal({ ...addModal, visible: true })}>新建巡检</Button>
+          <Authorization type="quality" auth="add">
+            <Button type="primary" size="small" onClick={() => setAddModal({ ...addModal, visible: true })}>
+              新建巡检
+            </Button>
+          </Authorization>
         </Slot>
       </Header>
       <Table
@@ -170,37 +173,22 @@ const QualityList:React.FC<{}> =() => {
         columns={columns}
         pagination={{
           hideOnSinglePage: true,
-          size: "small",
+          size: 'small',
           pageSize: consts.PAGE_SIZE,
           onChange: (page, pageSize) => initData(page, pageSize),
           total
         }}
         rowKey={record => record.id}
-        bordered
-        >
-      </Table>
+        bordered></Table>
       <RuleModal
         type={consts.RULE.QUALITY}
         title="质量巡检编号设置"
         visible={ruleModal.visible}
         onCreate={onRuleCreate}
         loading={ruleModal.loading}
-        onCancel={() => setRuleModal({ ...ruleModal, visible: false })}
-        >
-      </RuleModal>
-      <AddModel
-        visible={addModal.visible}
-        onCreate={onAddCreate}
-        loading={addModal.loading}
-        onCancel={() => setAddModal({ ...addModal, visible: false })}
-        >
-      </AddModel>
-      <FileModal
-        visible={fileModal.visible}
-        dataType={fileModal.dataType}
-        dataId={fileModal.dataId}
-        onCancel={() => setFileModal({ ...fileModal, visible: false })}
-      ></FileModal>
+        onCancel={() => setRuleModal({ ...ruleModal, visible: false })}></RuleModal>
+      <AddModel visible={addModal.visible} onCreate={onAddCreate} loading={addModal.loading} onCancel={() => setAddModal({ ...addModal, visible: false })}></AddModel>
+      <FileModal visible={fileModal.visible} dataType={fileModal.dataType} dataId={fileModal.dataId} onCancel={() => setFileModal({ ...fileModal, visible: false })}></FileModal>
     </div>
   )
 }

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

@@ -17,7 +17,7 @@ import { dayjsFormat } 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, useMemo, useCallback } from 'react'
+import React, { useEffect, useState, useMemo } from 'react'
 import { RouteComponentProps } from 'react-router'
 import { apiGetSafeDetail, apiResfulSafeAudit } from './api'
 import AuditModal from '@/pages/Quality/Content/Info/Detail/components/Modal'
@@ -230,7 +230,7 @@ const Detail: React.FC<RouteComponentProps> = props => {
           <ZhSubmitButton size="small" className="pi-mg-left-5" onClick={() => btnClick('start')}>提交审批</ZhSubmitButton>
         </div>
       )
-    } else if(status === auditProgress.checking || status === auditProgress.checkNo) {
+    } else if (status === auditProgress.checking || status === auditProgress.checkNo) {
       return (
         <div className="pi-flex-row pi-align-center">
           <Button type="primary" danger size="small" onClick={() => btnClick('close')}>关闭</Button>
@@ -275,7 +275,7 @@ const Detail: React.FC<RouteComponentProps> = props => {
                 <th style={{ width: '150px' }}>检查项目</th>
                 <td>
                   {
-                    isEdited ? <span>{detail.inspection}</span> : <TextArea value={detail.inspection} onChange={(e) => {setDetail({ ...detail, inspection: e.currentTarget.value })}}></TextArea>
+                    isEdited ? <span>{detail.inspection}</span> : <TextArea value={detail.inspection} onChange={(e) => { setDetail({ ...detail, inspection: e.currentTarget.value }) }}></TextArea>
                   }
                 </td>
               </tr>
@@ -283,7 +283,7 @@ const Detail: React.FC<RouteComponentProps> = props => {
                 <th style={{ width: '150px' }}>现场检查情况</th>
                 <td>
                   {
-                    isEdited ? <span>{detail.inspectionDetail}</span> : <TextArea value={detail.inspectionDetail} onChange={(e) => {setDetail({ ...detail, inspectionDetail: e.currentTarget.value })}}></TextArea>
+                    isEdited ? <span>{detail.inspectionDetail}</span> : <TextArea value={detail.inspectionDetail} onChange={(e) => { setDetail({ ...detail, inspectionDetail: e.currentTarget.value }) }}></TextArea>
                   }
                 </td>
               </tr>
@@ -291,7 +291,7 @@ const Detail: React.FC<RouteComponentProps> = props => {
                 <th style={{ width: '150px' }}>处理要求及措施</th>
                 <td>
                   {
-                    isEdited ? <span>{detail.demand}</span> : <TextArea value={detail.demand} onChange={(e) => {setDetail({ ...detail, demand: e.currentTarget.value })}}></TextArea>
+                    isEdited ? <span>{detail.demand}</span> : <TextArea value={detail.demand} onChange={(e) => { setDetail({ ...detail, demand: e.currentTarget.value }) }}></TextArea>
                   }
                 </td>
               </tr>
@@ -300,12 +300,12 @@ const Detail: React.FC<RouteComponentProps> = props => {
                 <td>
                   {
                     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>
+                      <DatePicker
+                        size="small"
+                        locale={locale}
+                        allowClear={false}
+                        value={dayjs(detail.createTime)}
+                        onChange={value => setDetail({ ...detail, createTime: value?.format() })}></DatePicker>
                   }
 
                 </td>
@@ -317,64 +317,64 @@ const Detail: React.FC<RouteComponentProps> = props => {
             </tbody>
           </table>
           {
-            detail.status === auditProgress.checked && detail.latestAuditor.audit_id === userStore.userInfo.id?
-            <table className="pi-table pi-bordered">
-            <thead>
-              <tr>
-                <th colSpan={2} className="pi-text-center">
-                  整改单
+            detail.status === auditProgress.checked && detail.latestAuditor.audit_id === userStore.userInfo.id ?
+              <table className="pi-table pi-bordered">
+                <thead>
+                  <tr>
+                    <th colSpan={2} className="pi-text-center">
+                      整改单
                 </th>
-              </tr>
-            </thead>
-            <tbody>
-              <tr>
-                <th style={{ width: '150px' }}>整改情况</th>
-                <td>
-                  <TextArea value={detail.checkOrder.opinion} onChange={(e) => setDetail({ ...detail, checkOrder: { ...detail.checkOrder, opinion: e.currentTarget.value } })}></TextArea>
-                </td>
-              </tr>
-              <tr>
-                <th style={{ width: '150px' }}>整改日期</th>
-                <td>
-                  <DatePicker
-                    size="small"
-                    locale={locale}
-                    allowClear={false}
-                    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>{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">
-                  整改单
+                  </tr>
+                </thead>
+                <tbody>
+                  <tr>
+                    <th style={{ width: '150px' }}>整改情况</th>
+                    <td>
+                      <TextArea value={detail.checkOrder.opinion} onChange={(e) => setDetail({ ...detail, checkOrder: { ...detail.checkOrder, opinion: e.currentTarget.value } })}></TextArea>
+                    </td>
+                  </tr>
+                  <tr>
+                    <th style={{ width: '150px' }}>整改日期</th>
+                    <td>
+                      <DatePicker
+                        size="small"
+                        locale={locale}
+                        allowClear={false}
+                        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>{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>
-          ))
+                    </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>
+              ))
 
           }
           <table className="pi-table pi-bordered mt-3">
@@ -400,20 +400,20 @@ const Detail: React.FC<RouteComponentProps> = props => {
 
               {detail.file.fileList?.map((file, idx) => (
                 <tr key={idx}>
-                <td className="pi-width-70">{idx + 1}</td>
-                <td style={{ width: 383, maxWidth: 383, overflow: 'hidden', whiteSpace: 'nowrap', textOverflow: 'ellipsis' }}>
-                  <a href={consts.OSS_PATH.REVIEW + file.filepath} target="_blank" rel="noopener noreferrer">
-                    {file.filename}
-                  </a>
-                </td>
-                <td className="pi-text-center pi-width-100">{file.accountName}</td>
-                <td className="pi-text-center">{dayjsFormat(file.createTime)}</td>
-                <td className="pi-text-center pi-width-90">
-                  <Tooltip title="移除">
-                    <Button size="small" type="text" icon={<SvgIcon type="xxh-times-circle1" />} style={{ color: '#df3f45' }} onClick={() => delFile(file.id, !idx)}></Button>
-                  </Tooltip>
-                </td>
-              </tr>
+                  <td className="pi-width-70">{idx + 1}</td>
+                  <td style={{ width: 383, maxWidth: 383, overflow: 'hidden', whiteSpace: 'nowrap', textOverflow: 'ellipsis' }}>
+                    <a href={consts.OSS_PATH.REVIEW + file.filepath} target="_blank" rel="noopener noreferrer">
+                      {file.filename}
+                    </a>
+                  </td>
+                  <td className="pi-text-center pi-width-100">{file.accountName}</td>
+                  <td className="pi-text-center">{dayjsFormat(file.createTime)}</td>
+                  <td className="pi-text-center pi-width-90">
+                    <Tooltip title="移除">
+                      <Button size="small" type="text" icon={<SvgIcon type="xxh-times-circle1" />} style={{ color: '#df3f45' }} onClick={() => delFile(file.id, !idx)}></Button>
+                    </Tooltip>
+                  </td>
+                </tr>
               ))}
               {detail.file.total > consts.PAGE_SIZE ? (
                 <tr>
@@ -440,6 +440,7 @@ const Detail: React.FC<RouteComponentProps> = props => {
         onShow={onOssModalShow}>
       </OssUploadModal>
       <AuditModal
+        type="safe"
         modalObj={modalProps}
         onCancel={() => setModalObj({ ...modalObj, auditModal: false })}
         onCreate={onModalConfirm}

+ 57 - 67
src/pages/Safe/Content/List/index.tsx

@@ -1,3 +1,4 @@
+import Authorization from '@/components/Authorization'
 import FileModal from '@/components/FileModal'
 import Header from '@/components/Header'
 import Slot from '@/components/Header/slot'
@@ -9,7 +10,6 @@ import { iCreateSafe } from '@/types/safe'
 import { safeStatus } from '@/utils/common/constStatus'
 import consts from '@/utils/consts'
 import { dayjsFormat } from '@/utils/util'
-import { SettingOutlined } from '@ant-design/icons'
 import { Button, message, Table } from 'antd'
 import { ColumnsType } from 'antd/lib/table'
 import React, { useEffect, useState } from 'react'
@@ -17,24 +17,23 @@ import { Link } from 'react-router-dom'
 import { apiCreateSafe, apiSafeList, apiSaveRule } from './api'
 import AddModel from './modal'
 interface iSafeList {
-  id: string;
-  code: string;
-  createTime: string;
-  position: string;
-  inspection: string;
-  inspectionDetail: string;
-  demand: string;
-  status: number;
-  auditName: string;
-  fileCounts: number;
+  id: string
+  code: string
+  createTime: string
+  position: string
+  inspection: string
+  inspectionDetail: string
+  demand: string
+  status: number
+  auditName: string
+  fileCounts: number
 }
 interface iModal {
   visible: boolean
   loading: boolean
 }
 
-
-const SafeList:React.FC<{}> =() => {
+const SafeList: React.FC<{}> = () => {
   const [ ruleModal, setRuleModal ] = useState<iModal>({
     visible: false,
     loading: false
@@ -48,10 +47,12 @@ const SafeList:React.FC<{}> =() => {
     dataType: consts.DATA_TYPE.SAFE,
     dataId: ''
   })
+  const [ safeList, setSafeList ] = useState<iSafeList[]>([])
+  const [ total, setTotal ] = useState<number>(0)
   useEffect(() => {
     initData()
   }, [])
-  const columns:ColumnsType<iSafeList> = [
+  const columns: ColumnsType<iSafeList> = [
     {
       title: '序号',
       // eslint-disable-next-line react/display-name
@@ -64,7 +65,7 @@ const SafeList:React.FC<{}> =() => {
       dataIndex: 'code',
       // eslint-disable-next-line react/display-name
       render: (text: string, record) => {
-        return <Link to={{ pathname: "/console/safe/content/detail/info", state: { saveId: record.id } }}>{text}</Link>
+        return <Link to={{ pathname: '/console/safe/content/detail/info', state: { saveId: record.id } }}>{text}</Link>
       }
     },
     {
@@ -96,7 +97,11 @@ const SafeList:React.FC<{}> =() => {
       dataIndex: 'fileCounts',
       // eslint-disable-next-line react/display-name
       render: (text: string, record) => {
-      return <span className="pi-pointer" onClick={() => setFileModal({ ...fileModal, dataId: record.id, visible: true })}><SvgIcon type="xxh-paperclip1"></SvgIcon> {text}</span>
+        return (
+          <span className="pi-pointer" onClick={() => setFileModal({ ...fileModal, dataId: record.id, visible: true })}>
+            <SvgIcon type="xxh-paperclip1"></SvgIcon> {text}
+          </span>
+        )
       }
     },
     {
@@ -104,41 +109,29 @@ const SafeList:React.FC<{}> =() => {
       dataIndex: 'status',
       // eslint-disable-next-line react/display-name
       render: (statu: number) => {
-      return <span className={safeStatus[statu].className}>{safeStatus[statu].text}</span>
+        return <span className={safeStatus[statu].className}>{safeStatus[statu].text}</span>
       }
     }
   ]
-  const [ list, setList ] = useState<iSafeList[]>([
-    {
-      id: '',
-      code: '',
-      createTime: '',
-      position: '',
-      inspection: '',
-      inspectionDetail: '',
-      demand: '',
-      status: 0,
-      auditName: '',
-      fileCounts: 0
-    }
-  ])
-  const [ total, setTotal ] = useState<number>(0)
+
   const initData = (pageNo: number = 1, pageSize: number = consts.PAGE_SIZE) => {
-    apiSafeList(tenderStore.bid, pageNo, pageSize).then(({ code = -1, data = [], total = 0 }) => {
-      if (code === consts.RET_CODE.SUCCESS) {
-        setList(data)
-        setTotal(total)
-      }
-    }).catch(err => {
-      console.log(err)
-    })
+    apiSafeList(tenderStore.bid, pageNo, pageSize)
+      .then(({ code = -1, data = [], total = 0 }) => {
+        if (code === consts.RET_CODE.SUCCESS) {
+          setSafeList(data)
+          setTotal(total)
+        }
+      })
+      .catch(err => {
+        console.log(err)
+      })
   }
 
   const onRuleCreate = async (ruleValue: any) => {
     setRuleModal({ ...ruleModal, loading: true })
     const { code = -1 } = await apiSaveRule({ bidsectionId: tenderStore.bid, type: 'safe_rule', rule: ruleValue })
     if (code === consts.RET_CODE.SUCCESS) {
-      message.success("规则更改成功!")
+      message.success('规则更改成功!')
       initData()
     }
     setRuleModal({ ...ruleModal, loading: false, visible: false })
@@ -157,13 +150,25 @@ const SafeList:React.FC<{}> =() => {
     <div className="wrap-contaniner">
       <Header title="安全巡检">
         <Slot position="right">
-          {
-            !list.length ?
-            <Button type="ghost" size="small" icon={<SvgIcon type="xxh-cog" />} className="pi-mg-right-3" style={{ color: '#007bff' }} onClick={() => setRuleModal({ ...ruleModal, visible: true })}>设置</Button>
-            : ""
-          }
+          {!safeList.length ? (
+            <Button
+              type="ghost"
+              size="small"
+              icon={<SvgIcon type="xxh-cog" />}
+              className="pi-mg-right-3"
+              style={{ color: '#007bff' }}
+              onClick={() => setRuleModal({ ...ruleModal, visible: true })}>
+              设置
+            </Button>
+          ) : (
+            ''
+          )}
 
-          <Button type="primary" size="small" onClick={() => setAddModal({ ...addModal, visible: true })}>新建巡检</Button>
+          <Authorization type="safe" auth="add">
+            <Button type="primary" size="small" onClick={() => setAddModal({ ...addModal, visible: true })}>
+              新建巡检
+            </Button>
+          </Authorization>
         </Slot>
       </Header>
       <Table
@@ -171,37 +176,22 @@ const SafeList:React.FC<{}> =() => {
         columns={columns}
         pagination={{
           hideOnSinglePage: true,
-          size: "small",
+          size: 'small',
           pageSize: consts.PAGE_SIZE,
           onChange: (page, pageSize) => initData(page, pageSize),
           total
         }}
         rowKey={record => record.id}
-        bordered
-        >
-      </Table>
+        bordered></Table>
       <RuleModal
         type={consts.RULE.SAFE}
         title="安全巡检编号设置"
         visible={ruleModal.visible}
         onCreate={onRuleCreate}
         loading={ruleModal.loading}
-        onCancel={() => setRuleModal({ ...ruleModal, visible: false })}
-        >
-      </RuleModal>
-      <AddModel
-        visible={addModal.visible}
-        onCreate={onAddCreate}
-        loading={addModal.loading}
-        onCancel={() => setAddModal({ ...addModal, visible: false })}
-        >
-      </AddModel>
-      <FileModal
-        visible={fileModal.visible}
-        dataType={fileModal.dataType}
-        dataId={fileModal.dataId}
-        onCancel={() => setFileModal({ ...fileModal, visible: false })}
-      ></FileModal>
+        onCancel={() => setRuleModal({ ...ruleModal, visible: false })}></RuleModal>
+      <AddModel visible={addModal.visible} onCreate={onAddCreate} loading={addModal.loading} onCancel={() => setAddModal({ ...addModal, visible: false })}></AddModel>
+      <FileModal visible={fileModal.visible} dataType={fileModal.dataType} dataId={fileModal.dataId} onCancel={() => setFileModal({ ...fileModal, visible: false })}></FileModal>
     </div>
   )
 }