|
@@ -0,0 +1,163 @@
|
|
|
+import Header from '@/components/Header'
|
|
|
+import Slot from '@/components/Header/slot'
|
|
|
+import SvgIcon from '@/components/SvgIcon'
|
|
|
+import { tenderStore } from '@/store/mobx'
|
|
|
+import { iCreateSafe } from '@/types/safe'
|
|
|
+import { safeStatus } from '@/utils/common/constStatus'
|
|
|
+import consts from '@/utils/consts'
|
|
|
+import { dayjsFomrat } from '@/utils/util'
|
|
|
+import { SettingOutlined } from '@ant-design/icons'
|
|
|
+import { Button, Table } from 'antd'
|
|
|
+import { ColumnsType } from 'antd/lib/table'
|
|
|
+import React, { useEffect, useState } from 'react'
|
|
|
+import { useActivate } from 'react-activation'
|
|
|
+import { Link } from 'react-router-dom'
|
|
|
+import { apiCreateSafe, apiSafeList } from './api'
|
|
|
+import Modal from './modal'
|
|
|
+interface iSafeList {
|
|
|
+ id: string;
|
|
|
+ code: string;
|
|
|
+ createTime: string;
|
|
|
+ position: string;
|
|
|
+ inspection: string;
|
|
|
+ inspectionDetail: string;
|
|
|
+ demand: string;
|
|
|
+ status: number;
|
|
|
+ auditName: string;
|
|
|
+ fileCounts: number;
|
|
|
+}
|
|
|
+interface iModal {
|
|
|
+ type: string
|
|
|
+ visible: boolean
|
|
|
+ loading: boolean
|
|
|
+}
|
|
|
+
|
|
|
+const SafeList:React.FC<{}> =() => {
|
|
|
+ const columns:ColumnsType<iSafeList> = [
|
|
|
+ {
|
|
|
+ title: '序号',
|
|
|
+ // eslint-disable-next-line react/display-name
|
|
|
+ render: (_: string, record: any, i: number) => {
|
|
|
+ return <span>{i + 1}</span>
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '编号',
|
|
|
+ dataIndex: 'code',
|
|
|
+ // eslint-disable-next-line react/display-name
|
|
|
+ render: (text: string) => {
|
|
|
+ return <Link to={{ pathname: "/console/safe/content/detail", state: { id: tenderStore.bidsectionId } }}>{text}</Link>
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '检查项目',
|
|
|
+ dataIndex: 'inspection'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '现场检查情况',
|
|
|
+ dataIndex: 'inspection_detail'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '处理要求及措施',
|
|
|
+ dataIndex: 'demand'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '检查日期',
|
|
|
+ dataIndex: 'create_time',
|
|
|
+ // eslint-disable-next-line react/display-name
|
|
|
+ render: (text: string) => {
|
|
|
+ return <span>{dayjsFomrat(text, 'YYYY-MM-DD')}</span>
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '检查人',
|
|
|
+ dataIndex: 'auditName'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '附件',
|
|
|
+ dataIndex: 'fileCounts',
|
|
|
+ // eslint-disable-next-line react/display-name
|
|
|
+ render: (text: string) => {
|
|
|
+ return <span><SvgIcon type="xxh-paperclip1"></SvgIcon> {text}</span>
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '状态',
|
|
|
+ dataIndex: 'status',
|
|
|
+ // eslint-disable-next-line react/display-name
|
|
|
+ render: (statu: number) => {
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ ])
|
|
|
+ useEffect(() => {
|
|
|
+ initData()
|
|
|
+ }, [])
|
|
|
+ useActivate(() => {
|
|
|
+ initData()
|
|
|
+ })
|
|
|
+ const initData = async () => {
|
|
|
+ const { code = -1, data = [] } = await apiSafeList(tenderStore.bidsectionId)
|
|
|
+ if (code === consts.RET_CODE.SUCCESS) {
|
|
|
+ setList(data)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const [ modal, setModal ] = useState<iModal>({
|
|
|
+ type: '',
|
|
|
+ visible: false,
|
|
|
+ loading: false
|
|
|
+ })
|
|
|
+ const onCreate = async (payload: iCreateSafe) => {
|
|
|
+ setModal({ ...modal, loading: true })
|
|
|
+ const createTime = dayjsFomrat(payload.createTime)
|
|
|
+
|
|
|
+ const { code = -1 } = await apiCreateSafe({ ...payload, createTime })
|
|
|
+ if (code === consts.RET_CODE.SUCCESS) {
|
|
|
+ initData()
|
|
|
+ }
|
|
|
+ setModal({ ...modal, loading: false, visible: false })
|
|
|
+ }
|
|
|
+ return (
|
|
|
+ <div className="wrap-contaniner">
|
|
|
+ <Header title="巡检概况">
|
|
|
+ <Slot position="right">
|
|
|
+ <Button type="ghost" size="small" icon={<SettingOutlined />} className="pi-mg-right-3" style={{ color: '#007bff' }} onClick={() => setModal({ ...modal, visible: true,type: 'setting' })}>设置</Button>
|
|
|
+ <Button type="primary" size="small" onClick={() => setModal({ ...modal, visible: true,type: 'add' })}>新建巡检</Button>
|
|
|
+ </Slot>
|
|
|
+ </Header>
|
|
|
+ <Table
|
|
|
+ dataSource={list}
|
|
|
+ columns={columns}
|
|
|
+ pagination={false}
|
|
|
+ rowKey={record => record.id}
|
|
|
+ bordered
|
|
|
+ >
|
|
|
+ </Table>
|
|
|
+ <Modal
|
|
|
+ visible={modal.visible}
|
|
|
+ type={modal.type}
|
|
|
+ onCreate={onCreate}
|
|
|
+ loading={modal.loading}
|
|
|
+ onCancel={() => setModal({ ...modal, visible: false })}
|
|
|
+ >
|
|
|
+ </Modal>
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+}
|
|
|
+
|
|
|
+export default SafeList
|