|
@@ -1,3 +1,4 @@
|
|
|
|
|
+import Authorization from '@/components/Authorization'
|
|
|
import FileModal from '@/components/FileModal'
|
|
import FileModal from '@/components/FileModal'
|
|
|
import Header from '@/components/Header'
|
|
import Header from '@/components/Header'
|
|
|
import Slot from '@/components/Header/slot'
|
|
import Slot from '@/components/Header/slot'
|
|
@@ -9,7 +10,6 @@ import { iCreateSafe } from '@/types/safe'
|
|
|
import { safeStatus } from '@/utils/common/constStatus'
|
|
import { safeStatus } from '@/utils/common/constStatus'
|
|
|
import consts from '@/utils/consts'
|
|
import consts from '@/utils/consts'
|
|
|
import { dayjsFormat } from '@/utils/util'
|
|
import { dayjsFormat } from '@/utils/util'
|
|
|
-import { SettingOutlined } from '@ant-design/icons'
|
|
|
|
|
import { Button, message, Table } from 'antd'
|
|
import { Button, message, Table } from 'antd'
|
|
|
import { ColumnsType } from 'antd/lib/table'
|
|
import { ColumnsType } from 'antd/lib/table'
|
|
|
import React, { useEffect, useState } from 'react'
|
|
import React, { useEffect, useState } from 'react'
|
|
@@ -17,24 +17,23 @@ import { Link } from 'react-router-dom'
|
|
|
import { apiCreateSafe, apiSafeList, apiSaveRule } from './api'
|
|
import { apiCreateSafe, apiSafeList, apiSaveRule } from './api'
|
|
|
import AddModel from './modal'
|
|
import AddModel from './modal'
|
|
|
interface iSafeList {
|
|
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 {
|
|
interface iModal {
|
|
|
visible: boolean
|
|
visible: boolean
|
|
|
loading: boolean
|
|
loading: boolean
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-const SafeList:React.FC<{}> =() => {
|
|
|
|
|
|
|
+const SafeList: React.FC<{}> = () => {
|
|
|
const [ ruleModal, setRuleModal ] = useState<iModal>({
|
|
const [ ruleModal, setRuleModal ] = useState<iModal>({
|
|
|
visible: false,
|
|
visible: false,
|
|
|
loading: false
|
|
loading: false
|
|
@@ -48,10 +47,12 @@ const SafeList:React.FC<{}> =() => {
|
|
|
dataType: consts.DATA_TYPE.SAFE,
|
|
dataType: consts.DATA_TYPE.SAFE,
|
|
|
dataId: ''
|
|
dataId: ''
|
|
|
})
|
|
})
|
|
|
|
|
+ const [ safeList, setSafeList ] = useState<iSafeList[]>([])
|
|
|
|
|
+ const [ total, setTotal ] = useState<number>(0)
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
initData()
|
|
initData()
|
|
|
}, [])
|
|
}, [])
|
|
|
- const columns:ColumnsType<iSafeList> = [
|
|
|
|
|
|
|
+ const columns: ColumnsType<iSafeList> = [
|
|
|
{
|
|
{
|
|
|
title: '序号',
|
|
title: '序号',
|
|
|
// eslint-disable-next-line react/display-name
|
|
// eslint-disable-next-line react/display-name
|
|
@@ -64,7 +65,7 @@ const SafeList:React.FC<{}> =() => {
|
|
|
dataIndex: 'code',
|
|
dataIndex: 'code',
|
|
|
// eslint-disable-next-line react/display-name
|
|
// eslint-disable-next-line react/display-name
|
|
|
render: (text: string, record) => {
|
|
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',
|
|
dataIndex: 'fileCounts',
|
|
|
// eslint-disable-next-line react/display-name
|
|
// eslint-disable-next-line react/display-name
|
|
|
render: (text: string, record) => {
|
|
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',
|
|
dataIndex: 'status',
|
|
|
// eslint-disable-next-line react/display-name
|
|
// eslint-disable-next-line react/display-name
|
|
|
render: (statu: number) => {
|
|
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) => {
|
|
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) => {
|
|
const onRuleCreate = async (ruleValue: any) => {
|
|
|
setRuleModal({ ...ruleModal, loading: true })
|
|
setRuleModal({ ...ruleModal, loading: true })
|
|
|
const { code = -1 } = await apiSaveRule({ bidsectionId: tenderStore.bid, type: 'safe_rule', rule: ruleValue })
|
|
const { code = -1 } = await apiSaveRule({ bidsectionId: tenderStore.bid, type: 'safe_rule', rule: ruleValue })
|
|
|
if (code === consts.RET_CODE.SUCCESS) {
|
|
if (code === consts.RET_CODE.SUCCESS) {
|
|
|
- message.success("规则更改成功!")
|
|
|
|
|
|
|
+ message.success('规则更改成功!')
|
|
|
initData()
|
|
initData()
|
|
|
}
|
|
}
|
|
|
setRuleModal({ ...ruleModal, loading: false, visible: false })
|
|
setRuleModal({ ...ruleModal, loading: false, visible: false })
|
|
@@ -157,13 +150,25 @@ const SafeList:React.FC<{}> =() => {
|
|
|
<div className="wrap-contaniner">
|
|
<div className="wrap-contaniner">
|
|
|
<Header title="安全巡检">
|
|
<Header title="安全巡检">
|
|
|
<Slot position="right">
|
|
<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>
|
|
</Slot>
|
|
|
</Header>
|
|
</Header>
|
|
|
<Table
|
|
<Table
|
|
@@ -171,37 +176,22 @@ const SafeList:React.FC<{}> =() => {
|
|
|
columns={columns}
|
|
columns={columns}
|
|
|
pagination={{
|
|
pagination={{
|
|
|
hideOnSinglePage: true,
|
|
hideOnSinglePage: true,
|
|
|
- size: "small",
|
|
|
|
|
|
|
+ size: 'small',
|
|
|
pageSize: consts.PAGE_SIZE,
|
|
pageSize: consts.PAGE_SIZE,
|
|
|
onChange: (page, pageSize) => initData(page, pageSize),
|
|
onChange: (page, pageSize) => initData(page, pageSize),
|
|
|
total
|
|
total
|
|
|
}}
|
|
}}
|
|
|
rowKey={record => record.id}
|
|
rowKey={record => record.id}
|
|
|
- bordered
|
|
|
|
|
- >
|
|
|
|
|
- </Table>
|
|
|
|
|
|
|
+ bordered></Table>
|
|
|
<RuleModal
|
|
<RuleModal
|
|
|
type={consts.RULE.SAFE}
|
|
type={consts.RULE.SAFE}
|
|
|
title="安全巡检编号设置"
|
|
title="安全巡检编号设置"
|
|
|
visible={ruleModal.visible}
|
|
visible={ruleModal.visible}
|
|
|
onCreate={onRuleCreate}
|
|
onCreate={onRuleCreate}
|
|
|
loading={ruleModal.loading}
|
|
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>
|
|
</div>
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|