|
@@ -2,225 +2,66 @@ import PageContent from '@/components/PageContent';
|
|
|
import PageTitle from '@/components/PageTitle';
|
|
|
import { GetTokenFromUrl, UnityAction } from '@/utils/utils';
|
|
|
import { connect, history, useParams } from '@umijs/max';
|
|
|
-import { Button, Col, DatePicker, Form, Row, Select, Table } from 'antd';
|
|
|
import dayjs from 'dayjs';
|
|
|
-import { Fragment, useEffect, useState } from 'react';
|
|
|
-
|
|
|
-const FormItem = Form.Item;
|
|
|
-const { Option } = Select;
|
|
|
-const statusList = [
|
|
|
- { key: 1, value: '0', label: '正常' },
|
|
|
- { key: 2, value: '1', label: '异常' },
|
|
|
-];
|
|
|
+import { Fragment, useEffect } from 'react';
|
|
|
+import styles from './index.less';
|
|
|
|
|
|
function List(props) {
|
|
|
const { loading, list, processList = [], dispatch } = props;
|
|
|
|
|
|
const { projectId } = useParams();
|
|
|
- const [form] = Form.useForm();
|
|
|
- const [pagination, setPagination] = useState({ pageSize: 10, current: 1 });
|
|
|
- const [groupId, setGroupId] = useState('');
|
|
|
-
|
|
|
- const getColumns = () => {
|
|
|
- return [
|
|
|
- {
|
|
|
- title: '自检时间',
|
|
|
- dataIndex: 'CreatedTime',
|
|
|
- width: '26%',
|
|
|
- render: (text) => {
|
|
|
- return text ? dayjs(text).format('YYYY-MM-DD HH:mm') : null;
|
|
|
- },
|
|
|
- },
|
|
|
- {
|
|
|
- title: '工艺段',
|
|
|
- width: '24%',
|
|
|
- render: (record) => {
|
|
|
- const name = processList?.find(
|
|
|
- (item) => item.group_id == record?.RouteInfo?.GroupID,
|
|
|
- )?.name;
|
|
|
- return name || '-';
|
|
|
- },
|
|
|
- },
|
|
|
- {
|
|
|
- title: '状态',
|
|
|
- width: '10%',
|
|
|
- dataIndex: 'Status',
|
|
|
- render: (text) => {
|
|
|
- return text == 0 ? (
|
|
|
- '正常'
|
|
|
- ) : (
|
|
|
- <div style={{ color: '#FF8600' }}>异常</div>
|
|
|
- );
|
|
|
- },
|
|
|
- },
|
|
|
- {
|
|
|
- title: '操作',
|
|
|
- width: '16%',
|
|
|
- render: (text, record) => {
|
|
|
- return (
|
|
|
- <Fragment>
|
|
|
- {
|
|
|
- <>
|
|
|
- <a
|
|
|
- onClick={(e) => {
|
|
|
- goToDetail(record, e);
|
|
|
- }}
|
|
|
- >
|
|
|
- 详情
|
|
|
- </a>
|
|
|
- </>
|
|
|
- }
|
|
|
- </Fragment>
|
|
|
- );
|
|
|
- },
|
|
|
- },
|
|
|
- ];
|
|
|
- };
|
|
|
-
|
|
|
- const getRecord = async (pagination) => {
|
|
|
- form.validateFields().then((fieldsValue) => {
|
|
|
- fieldsValue.projectId = projectId;
|
|
|
- fieldsValue.auto = 1;
|
|
|
- fieldsValue.startDate = dayjs(fieldsValue.startDate).format('YYYY-MM-DD');
|
|
|
- fieldsValue.endDate = dayjs(fieldsValue.endDate).format('YYYY-MM-DD');
|
|
|
- fieldsValue.pageSize = pagination.pageSize;
|
|
|
- fieldsValue.currentPage = pagination.current;
|
|
|
- dispatch({
|
|
|
- type: 'patrolArtificialRecord/queryPatrol',
|
|
|
- payload: { ...fieldsValue },
|
|
|
- callback: (data) => {
|
|
|
- setPagination(data.pagination);
|
|
|
- },
|
|
|
- });
|
|
|
- });
|
|
|
- };
|
|
|
|
|
|
- const handleSearch = (e) => {
|
|
|
- e?.preventDefault();
|
|
|
- getRecord(pagination);
|
|
|
- };
|
|
|
- const TableOnChange = (tempPagination) => {
|
|
|
- getRecord(tempPagination);
|
|
|
- };
|
|
|
- const goToDetail = (record, e) => {
|
|
|
- e.stopPropagation();
|
|
|
+ const goToDetail = (record) => {
|
|
|
UnityAction.sendMsg('reportDetail', '');
|
|
|
history.push(
|
|
|
- `/self-inspection/detail/${projectId}/${record.Id}?JWT-TOKEN=${GetTokenFromUrl()}`,
|
|
|
+ `/self-inspection/detail/${projectId}/${
|
|
|
+ record.Id
|
|
|
+ }?JWT-TOKEN=${GetTokenFromUrl()}`,
|
|
|
);
|
|
|
};
|
|
|
|
|
|
useEffect(() => {
|
|
|
- UnityAction.sendMsg('type', 2);
|
|
|
- handleSearch();
|
|
|
-
|
|
|
- dispatch({
|
|
|
- type: 'patrolArtificialRecord/queryRouteInfoList',
|
|
|
- payload: { ProjectId: projectId },
|
|
|
- });
|
|
|
+ let params = {};
|
|
|
+ params.projectId = projectId;
|
|
|
+ params.auto = 1;
|
|
|
+ params.startDate = dayjs().subtract(1).format('YYYY-MM-DD');
|
|
|
+ params.endDate = dayjs().format('YYYY-MM-DD');
|
|
|
+ params.pageSize = 100;
|
|
|
+ params.currentPage = 1;
|
|
|
dispatch({
|
|
|
- type: 'patrolArtificialRecord/queryProcessSection',
|
|
|
- payload: projectId,
|
|
|
+ type: 'patrolArtificialRecord/queryPatrol',
|
|
|
+ payload: params,
|
|
|
});
|
|
|
-
|
|
|
- UnityAction.addEventListener('group_id', (e) => {
|
|
|
- setGroupId(e);
|
|
|
- });
|
|
|
-
|
|
|
- return () => {
|
|
|
- UnityAction.off('group_id');
|
|
|
- };
|
|
|
}, []);
|
|
|
return (
|
|
|
<PageContent closeable={false}>
|
|
|
<PageTitle returnable>自检记录</PageTitle>
|
|
|
- <Form
|
|
|
- layout="vertical"
|
|
|
- labelAlign="left"
|
|
|
- labelCol={{ span: 8 }}
|
|
|
- wrapperCol={{ span: 16 }}
|
|
|
- onSubmit={handleSearch}
|
|
|
- form={form}
|
|
|
- >
|
|
|
- <Row gutter={16}>
|
|
|
- <Col span={12}>
|
|
|
- <FormItem
|
|
|
- label="开始时间"
|
|
|
- name="startDate"
|
|
|
- initialValue={dayjs().subtract(1, 'M')}
|
|
|
- >
|
|
|
- <div style={{ width: '95%' }}>
|
|
|
- <DatePicker allowClear={false} placeholder="选择开始日期" />
|
|
|
+
|
|
|
+ <div className={styles.list}>
|
|
|
+ {list.map((item) => (
|
|
|
+ <div className={styles.item} onClick={() => goToDetail(item)}>
|
|
|
+ {item.Status == 0 ? (
|
|
|
+ <div className={`${styles.status}`}>正常</div>
|
|
|
+ ) : (
|
|
|
+ <div className={`${styles.status} ${styles.statusError}`}>
|
|
|
+ 异常
|
|
|
</div>
|
|
|
- </FormItem>
|
|
|
- </Col>
|
|
|
- <Col span={12}>
|
|
|
- <FormItem label="结束时间" name="endDate" initialValue={dayjs()}>
|
|
|
- <div style={{ width: '95%' }}>
|
|
|
- <DatePicker allowClear={false} placeholder="选择结束日期" />
|
|
|
+ )}
|
|
|
+ <div className={styles.info}>
|
|
|
+ <div className={styles.time}>
|
|
|
+ <i></i>自检时间:{dayjs(item.CreatedTime).format('MM-DD HH:mm')}
|
|
|
</div>
|
|
|
- </FormItem>
|
|
|
- </Col>
|
|
|
- </Row>
|
|
|
- <Row gutter={16}>
|
|
|
- <Col span={12}>
|
|
|
- <FormItem label="状态" name="status">
|
|
|
- <Select
|
|
|
- placeholder="选择状态"
|
|
|
- allowClear
|
|
|
- style={{ width: '95%' }}
|
|
|
- >
|
|
|
- {statusList.map((item) => {
|
|
|
- return (
|
|
|
- <Option key={item.key} value={item.value}>
|
|
|
- {item.label}
|
|
|
- </Option>
|
|
|
- );
|
|
|
- })}
|
|
|
- </Select>
|
|
|
- </FormItem>
|
|
|
- </Col>
|
|
|
- <Col span={12}>
|
|
|
- <FormItem label="工艺段" name="groupId">
|
|
|
- <Select
|
|
|
- placeholder="选择工艺段"
|
|
|
- allowClear
|
|
|
- style={{ width: '95%' }}
|
|
|
- >
|
|
|
- {processList?.map((item) => {
|
|
|
- return (
|
|
|
- <Option key={item.id} value={item.group_id}>
|
|
|
- {item.name}
|
|
|
- </Option>
|
|
|
- );
|
|
|
- })}
|
|
|
- </Select>
|
|
|
- </FormItem>
|
|
|
- </Col>
|
|
|
- </Row>
|
|
|
- <div style={{ overflow: 'hidden' }}>
|
|
|
- <Button
|
|
|
- type="primary"
|
|
|
- htmlType="submit"
|
|
|
- style={{ float: 'right', marginBottom: 10 }}
|
|
|
- >
|
|
|
- 查询
|
|
|
- </Button>
|
|
|
- </div>
|
|
|
- </Form>
|
|
|
- <div className="table-total">当前列表总数 {pagination?.total || 0}</div>
|
|
|
- <Table
|
|
|
- bordered
|
|
|
- loading={loading}
|
|
|
- columns={getColumns()}
|
|
|
- dataSource={list.filter((item) => {
|
|
|
- if (!groupId) return true;
|
|
|
- if (groupId == item.RouteInfo.GroupID) return true;
|
|
|
- return false;
|
|
|
- })}
|
|
|
- pagination={pagination}
|
|
|
- onChange={TableOnChange}
|
|
|
- />
|
|
|
+ {/* <div className={styles.desc}>
|
|
|
+ <i></i>
|
|
|
+ 发现异常
|
|
|
+ <span className={styles.number}>4</span>
|
|
|
+ <span>项</span>
|
|
|
+ </div> */}
|
|
|
+ </div>
|
|
|
+ <div className={styles.btn}></div>
|
|
|
+ </div>
|
|
|
+ ))}
|
|
|
+ </div>
|
|
|
</PageContent>
|
|
|
);
|
|
|
}
|