1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057 |
- import ModuleTitle from '@/components/ManagementPage/moduleTitle';
- import TabsContent from '@/components/TabsContent';
- import ThresholdDetail from '@/components/ThresholdDetail';
- import ThresholdModal from '@/components/ThresholdDetail/ThresholdModal';
- import { changeRecordStatus, getDumuDetail } from '@/services/eqSelfInspection';
- import { UnityAction } from '@/utils/utils';
- import { connect, useRequest } from '@umijs/max';
- import {
- Col,
- DatePicker,
- Form,
- Input,
- Modal,
- Row,
- Select,
- Spin,
- Table,
- message,
- } from 'antd';
- import dayjs from 'dayjs';
- import { useEffect, useMemo, useState } from 'react';
- import ReactZmage from 'react-zmage';
- import styles from './PatrolReportDetail.less';
- function Detail(props) {
- const { data, userList, projectId, dispatch, loading = false } = props;
- const [select, setSelect] = useState();
- const [dumuList, setDumuList] = useState([]);
- const sendMessageToUnity = (select, data) => {
- setSelect(select);
- if (window.HightlightEquipment) {
- window.HightlightEquipment(data);
- }
- };
- const getTextColor = (status) => {
- switch (status) {
- case '警告':
- return '#FFE26D';
- case '异常':
- return '#FE5850';
- case '正常':
- return '#12CEB3';
- default:
- return '#12CEB3';
- }
- };
- const { run: detailRun } = useRequest(getDumuDetail, {
- manual: true,
- fetchKey: (id) => id,
- onSuccess: (data) => {
- var item = dumuList?.find((child) => child.id === data.id);
- if (item) {
- item.url = base64ToImageUrl(data.event_bg);
- }
- setDumuList([...dumuList]);
- },
- });
- const result = useMemo(() => {
- var resultArr = [];
- var tempResult = data?.PatrolResult;
- var tempArr = tempResult?.split(';');
- if (tempArr?.length > 0) {
- tempArr?.forEach((item, index) => {
- var tempItem = item;
- var itemSplit = tempItem.split(':');
- if (itemSplit?.length > 1) {
- var label = '';
- var value = itemSplit[1];
- if (index === 0) label = '设备自检';
- else if (index === 1) label = '工艺自检';
- else {
- label = '安全隐患';
- value = data?.secureStatus === 0 ? '正常' : '异常';
- }
- resultArr.push({
- label,
- value,
- color: getTextColor(value),
- });
- }
- });
- }
- return resultArr;
- }, [data]);
- useEffect(() => {
- dispatch({
- type: 'eqSelfInspection/fetchUserList',
- payload: {
- projectId,
- },
- });
- }, []);
- useEffect(() => {
- setDumuList(data?.dumuList);
- data?.dumuList?.map((item) => {
- detailRun(item.id);
- });
- }, [data?.dumuList]);
- return (
- <Spin spinning={loading} wrapperClassName="card-box">
- <div className={styles.card}>
- {data.Status == 0 ? (
- <div className={`${styles.orderIcon}`}>正常</div>
- ) : (
- <div className={`${styles.orderIcon} ${styles.error}`}>异常</div>
- )}
- <Row>
- <Col span={24} className={styles.cardText}>
- 自检时间:{data?.CreatedTime}
- </Col>
- </Row>
- <Row>
- <Col span={16} className={styles.cardText}>
- 自检路线:{data?.RouteInfo?.Name}
- </Col>
- <Col span={8} className={styles.cardText}>
- 工艺段:{data?.RouteInfo?.GroupID}
- </Col>
- </Row>
- <Row>
- {result?.map((item) => {
- return (
- <Col span={8} className={styles.cardText}>
- {item?.label}:
- <span style={{ color: item.color, fontWeight: 'bold' }}>
- {item?.value}
- </span>
- </Col>
- );
- })}
- </Row>
- </div>
- <div style={{ padding: 20, background: '#fff' }}>
- {/* 设备自检报告 */}
- <ReportCom
- sendMessageToUnity={sendMessageToUnity}
- select={select}
- waringData={data?.extendWarningData}
- allData={data?.extendWarningAllData}
- key="extend"
- type={'extend'}
- userList={userList}
- title={<ModuleTitle title="设备自检报告" />}
- ></ReportCom>
- {/* 工艺自检报告"> */}
- <div className={styles.content}>
- <div className={styles.tableStatus}>
- 异常({data?.FaultAnalysis?.length || 0})
- </div>
- <ModuleTitle title="工艺自检报告" />
- <AalysisTable
- onClickItem={sendMessageToUnity}
- select={select}
- data={data}
- />
- </div>
- {/* 安全隐患自检报告"> */}
- <div className={styles.content}>
- {/* 环境异常 */}
- <ReportCom
- sendMessageToUnity={sendMessageToUnity}
- select={select}
- waringData={data?.sensorWaringData}
- allData={data?.sensor}
- data={data?.sensorWaringData}
- key="sensor"
- type={'sensor'}
- userList={userList}
- title={<ModuleTitle title="环境异常" />}
- ></ReportCom>
- {/* 液位异常 */}
- {/* <LiquidLevelCom
- sendMessageToUnity={sendMessageToUnity}
- select={select}
- allData={data?.FluidLevelList}
- key="liquid"
- type={'liquid'}
- userList={userList}
- title={<ModuleTitle title="液位异常" />}
- /> */}
- {/* 安防检测异常 */}
- <ReportDumCom
- data={dumuList}
- title={<ModuleTitle title="安防检测异常" />}
- />
- {/* 电器检测异常 */}
- <ReportCom
- sendMessageToUnity={sendMessageToUnity}
- select={select}
- waringData={[]}
- allData={[]}
- key="extend"
- type={'extend'}
- userList={userList}
- title={<ModuleTitle title="电气检测异常" />}
- ></ReportCom>
- {/* 密闭空间检测异常 */}
- <ReportCom
- sendMessageToUnity={sendMessageToUnity}
- select={select}
- waringData={[]}
- allData={[]}
- key="extend"
- type={'extend'}
- userList={userList}
- title={<ModuleTitle title="密闭空间检测异常" />}
- ></ReportCom>
- </div>
- </div>
- {/* </Card> */}
- </Spin>
- );
- }
- export function DeviceTable(props) {
- const {
- onClickItem,
- data = {},
- items,
- onErrorHandle,
- select,
- userList,
- type,
- } = props;
- const { ProjectId, Id } = data;
- const [loading, setLoading] = useState(false);
- const [visible, setVisible] = useState(false);
- const [errVisible, setErrVisible] = useState(false);
- const [currentItem, setCurrentItem] = useState({});
- const isSensor = type == 'sensor';
- const onClickThreshold = (record) => {
- setCurrentItem(record);
- setVisible(true);
- };
- const onClickError = (record) => {
- setCurrentItem(record);
- setErrVisible(true);
- };
- const handleError = async (values) => {
- setLoading(true);
- var res = await changeRecordStatus({
- ...values,
- Id: currentItem.Id,
- DeviceCode: currentItem.DeviceCode,
- DeviceName: currentItem.DeviceName,
- RecordId: data.Id,
- RepairMan: values.RepairMan * 1,
- });
- setLoading(false);
- if (res) {
- message.success('操作成功');
- setErrVisible(false);
- }
- };
- const columns = [
- {
- title: '设备名称',
- dataIndex: 'DeviceName',
- },
- {
- title: '巡检项',
- width: '20%',
- dataIndex: 'TemplateItem.Name',
- },
- // {
- // title: '设备位号',
- // width: '16%',
- // dataIndex: 'DeviceCode',
- // },
- {
- title: '设定值范围',
- width: '30%',
- render: (record) => (
- <ThresholdDetail
- current={record.Value || 0}
- data={record || {}}
- // onClick={() => onClickThreshold(record)}
- />
- ),
- },
- {
- title: '状态',
- width: '13%',
- dataIndex: 'Status',
- render: (Status) => {
- switch (Status) {
- case -1:
- case 0:
- return (
- <div>
- <i
- className={styles.iconStatus}
- style={{ background: '#12CEB3' }}
- ></i>
- 正常
- </div>
- );
- case 1:
- return (
- <div>
- <i
- className={styles.iconStatus}
- style={{ background: '#FE5850' }}
- ></i>
- 异常
- </div>
- );
- case 2:
- return (
- <div>
- <i
- className={styles.iconStatus}
- style={{ background: '#FFE26D' }}
- ></i>
- 警告
- </div>
- );
- }
- },
- },
- ];
- const handleClickItem = (data) => {
- if (!isSensor) {
- onClickItem(`DeviceTable-${data.Id}`, {
- type: data.Status,
- deviceCode: data.DeviceCode,
- });
- } else {
- onClickItem(`DeviceTable-${data.Id}`, {
- // type: data.Status,
- deviceCode: data.DeviceCode,
- value: Number(data.Value || 0),
- threshold: data.JsonNumThreshold,
- });
- UnityAction.sendMsg('SinglePowerEnvironFromWeb', JSON.stringify(data));
- }
- };
- useEffect(() => {
- console.log('温控', items);
- if (isSensor)
- UnityAction.sendMsg('PowerEnvironsFromWeb', JSON.stringify(items));
- }, [items]);
- if (!isSensor) {
- columns.push({
- title: '操作',
- width: 120,
- render: (record) =>
- record.Status == 1 && (
- <a style={{ color: '#FE5850' }} onClick={() => onClickError(record)}>
- 异常处理
- </a>
- ),
- });
- }
- return (
- <div>
- <Table
- columns={columns}
- dataSource={items}
- rowKey="Id"
- locale={{
- emptyText: <Empty />,
- }}
- pagination={false}
- />
- <ThresholdModal
- open={visible}
- data={currentItem.JsonNumThreshold}
- onClose={() => setVisible(false)}
- />
- <ErrorHandleModal
- open={errVisible}
- userList={userList}
- onCancel={() => setErrVisible(false)}
- onOk={handleError}
- />
- </div>
- );
- }
- function AalysisTable(props) {
- const { onClickItem, data = {}, select } = props;
- const { FaultAnalysis } = data;
- const columns = [
- {
- title: '异常名称',
- width: '18%',
- dataIndex: 'device_name',
- },
- // {
- // title: '位号',
- // width: '15%',
- // dataIndex: 'device_code',
- // },
- {
- title: '可能原因',
- width: '30%',
- render: (record) => record.reason,
- },
- {
- title: '解决方案',
- width: '52%',
- render: (record) => {
- if (record.fix_plan instanceof Array) {
- return (
- <div>
- {record.fix_plan.map((item) => (
- <div>
- {item.content}
- <br />
- </div>
- ))}
- </div>
- );
- } else {
- return record.fix_plan;
- }
- },
- },
- ];
- return (
- <div>
- <Table
- columns={columns}
- dataSource={FaultAnalysis}
- rowKey="device_code"
- locale={{
- emptyText: <Empty />,
- }}
- pagination={false}
- />
- </div>
- );
- }
- function ErrorHandleModal(props) {
- const { visible, onCancel, onOk, userList } = props;
- const [form] = Form.useForm();
- const status = form.getFieldValue('Status');
- const handleOk = () => {
- form.validateFields((error, values) => {
- if (error) return;
- onOk({
- ...values,
- PlanTime: values?.PlanTime?.format('YYYY-MM-DD HH:mm:ss'),
- });
- });
- };
- return (
- <Modal
- title="异常处理"
- open={visible}
- onCancel={onCancel}
- onOk={handleOk}
- destroyOnClose
- >
- <Form labelCol={{ span: 7 }} wrapperCol={{ span: 16 }}>
- <Form.Item label="异常处理备注" name="ExceptionHandling">
- <Input.TextArea />
- </Form.Item>
- <Form.Item
- label="审核状态"
- name="Status"
- rules={[{ required: true, message: '请选择验收状态' }]}
- >
- <Select style={{ width: '100%' }} placeholder="请选择验收状态">
- <Select.Option value={1}>已派遣</Select.Option>
- <Select.Option value={2}>已通过</Select.Option>
- </Select>
- </Form.Item>
- <Form.Item
- label="维修人"
- name="RepairMan"
- rules={[{ required: true, message: '请选择维修人' }]}
- >
- <Select
- showSearch
- placeholder="请选择维修人"
- filterOption={(input, option) =>
- option.props.children.indexOf(input) >= 0
- }
- style={{ width: '100%' }}
- >
- {userList?.map((item) => (
- <Select.Option key={item.ID}>{item.CName}</Select.Option>
- ))}
- </Select>
- </Form.Item>
- {status == 1 && (
- <>
- <Form.Item
- label="难度级别"
- name="DifficultyLevel"
- rules={[{ required: true, message: '请选择难度级别' }]}
- >
- <Select placeholder="请选择难度级别" style={{ width: '100%' }}>
- <Select.Option value={0}>大修</Select.Option>
- <Select.Option value={1}>项目维修</Select.Option>
- <Select.Option value={2}>小修</Select.Option>
- </Select>
- </Form.Item>
- <Form.Item
- label="维修方式"
- name="RepairType"
- rules={[{ required: true, message: '请选择维修方式' }]}
- >
- <Select placeholder="请选择维修方式" style={{ width: '100%' }}>
- <Select.Option value={0}>自维</Select.Option>
- <Select.Option value={1}>外委</Select.Option>
- </Select>
- </Form.Item>
- <Form.Item
- label="计划完成日期"
- name="PlanTime"
- rules={[{ required: true, message: '请选择计划完成日期' }]}
- >
- <DatePicker inputReadOnly />
- </Form.Item>
- </>
- )}
- </Form>
- </Modal>
- );
- }
- export function WarningTable(props) {
- const {
- onClickItem,
- data = {},
- onErrorHandle,
- select,
- userList,
- type,
- items,
- } = props;
- const { ProjectId, Id } = data;
- const [loading, setLoading] = useState(false);
- const [visible, setVisible] = useState(false);
- const [errVisible, setErrVisible] = useState(false);
- const [currentItem, setCurrentItem] = useState({});
- const isSensor = type == 'sensor';
- const onClickThreshold = (record) => {
- setCurrentItem(record);
- setVisible(true);
- };
- const onClickError = (record) => {
- setCurrentItem(record);
- setErrVisible(true);
- };
- const handleError = async (values) => {
- setLoading(true);
- var res = await changeRecordStatus({
- ...values,
- Id: currentItem.Id,
- DeviceCode: currentItem.DeviceCode,
- DeviceName: currentItem.DeviceName,
- RecordId: data.Id,
- RepairMan: values.RepairMan * 1,
- });
- setLoading(false);
- if (res) {
- message.success('操作成功');
- setErrVisible(false);
- }
- };
- const columns = [
- {
- title: '设备名称',
- dataIndex: 'DeviceName',
- },
- {
- title: '巡检项',
- width: '20%',
- dataIndex: 'TemplateItem.Name',
- },
- // {
- // title: '设备位号',
- // width: '16%',
- // dataIndex: 'DeviceCode',
- // },
- {
- title: '设定值范围',
- width: '30%',
- render: (record) => (
- <ThresholdDetail
- current={record.Value || 0}
- data={record || {}}
- // onClick={() => onClickThreshold(record)}
- />
- ),
- },
- {
- title: '状态',
- width: '13%',
- dataIndex: 'Status',
- render: (Status) => {
- switch (Status) {
- case -1:
- case 0:
- return (
- <div>
- <i
- className={styles.iconStatus}
- style={{ background: '#12CEB3' }}
- ></i>
- 正常
- </div>
- );
- case 1:
- return (
- <div>
- <i
- className={styles.iconStatus}
- style={{ background: '#FE5850' }}
- ></i>
- 异常
- </div>
- );
- case 2:
- return (
- <div>
- <i
- className={styles.iconStatus}
- style={{ background: '#FFE26D' }}
- ></i>
- 警告
- </div>
- );
- }
- },
- },
- ];
- const handleClickItem = (data) => {
- if (!isSensor) {
- onClickItem(`DeviceTable-${data.Id}`, {
- type: data.Status,
- deviceCode: data.DeviceCode,
- });
- } else {
- onClickItem(`DeviceTable-${data.Id}`, {
- // type: data.Status,
- deviceCode: data.DeviceCode,
- value: Number(data.Value || 0),
- threshold: data.JsonNumThreshold,
- });
- UnityAction.sendMsg('SinglePowerEnvironFromWeb', JSON.stringify(data));
- }
- };
- if (!isSensor) {
- columns.push({
- title: '操作',
- width: 120,
- render: (record) =>
- record.Status == 1 && (
- <a style={{ color: '#FE5850' }} onClick={() => onClickError(record)}>
- 异常处理
- </a>
- ),
- });
- }
- useEffect(() => {
- if (isSensor)
- UnityAction.sendMsg('PowerEnvironsFromWeb', JSON.stringify(items));
- }, [items]);
- return (
- <div>
- <Table
- columns={columns}
- dataSource={items}
- rowKey="Id"
- locale={{
- emptyText: <Empty />,
- }}
- pagination={false}
- />
- <ThresholdModal
- open={visible}
- data={currentItem.JsonNumThreshold}
- onClose={() => setVisible(false)}
- />
- <ErrorHandleModal
- open={errVisible}
- userList={userList}
- onCancel={() => setErrVisible(false)}
- onOk={handleError}
- />
- </div>
- );
- }
- function ReportCom(props) {
- const {
- sendMessageToUnity,
- select,
- waringData = [],
- allData = [],
- userList,
- type,
- title,
- data,
- } = props;
- const [activeKey, setActiveKey] = useState('1');
- const handleTabsChange = (activeKey) => {
- setActiveKey(activeKey);
- };
- return (
- <div className={styles.detailCard}>
- <div className={styles.tableTop}>
- {title}
- <TabsContent
- defaultActiveKey="1"
- onChange={handleTabsChange}
- small={true}
- items={[
- {
- key: '1',
- label: `异常/警告(${waringData.length || 0})`,
- children: <div></div>,
- },
- {
- key: '2',
- label: `全部(${allData.length || 0})`,
- children: <div></div>,
- },
- ]}
- ></TabsContent>
- </div>
- {activeKey == '1' && (
- <WarningTable
- onClickItem={sendMessageToUnity}
- select={select}
- items={waringData}
- key={type}
- data={data}
- type={type}
- userList={userList}
- />
- )}
- {activeKey == '2' && (
- <DeviceTable
- onClickItem={sendMessageToUnity}
- select={select}
- items={allData}
- data={data}
- key={type}
- type={type}
- userList={userList}
- />
- )}
- </div>
- );
- }
- export function LiquidTable(props) {
- const { onClickItem, data = {}, items, select, type } = props;
- const { ProjectId, Id } = data;
- const [loading, setLoading] = useState(false);
- const [currentItem, setCurrentItem] = useState({});
- const columns = [
- {
- title: '设备名称',
- width: '25%',
- dataIndex: 'device_name',
- },
- {
- title: '液位数',
- width: '20%',
- dataIndex: 'origin_value',
- },
- {
- title: '差值',
- width: '16%',
- dataIndex: 'value',
- },
- {
- title: '设定值范围',
- width: '30%',
- render: (record) => (
- <ThresholdDetail
- current={record.value || 0}
- data={{
- JsonNumThreshold: record?.json_num_threshold,
- Type: record.type || 2,
- }}
- />
- ),
- },
- {
- title: '状态',
- width: '13%',
- dataIndex: 'status',
- render: (status) => {
- switch (status) {
- case -1:
- case 0:
- return (
- <div>
- <i
- className={styles.iconStatus}
- style={{ background: '#12CEB3' }}
- ></i>
- 正常
- </div>
- );
- case 1:
- return (
- <div>
- <i
- className={styles.iconStatus}
- style={{ background: '#FFE26D' }}
- ></i>
- 异常
- </div>
- );
- case 2:
- return (
- <div>
- <i
- className={styles.iconStatus}
- style={{ background: '#FFE26D' }}
- ></i>
- 警告
- </div>
- );
- }
- },
- },
- ];
- const handleClickItem = (data) => {
- onClickItem(`DeviceTable-${data.device_code}`, {
- type: data.status,
- deviceCode: data.device_code,
- });
- };
- return (
- <Table
- columns={columns}
- dataSource={items}
- rowKey="device_code"
- locale={{
- emptyText: <Empty />,
- }}
- pagination={false}
- />
- );
- }
- function LiquidLevelCom(props) {
- const { sendMessageToUnity, select, allData = [], type, title } = props;
- const [activeKey, setActiveKey] = useState('1');
- const errorData = useMemo(() => {
- const errorData = allData?.filter((item) => item.status);
- return errorData;
- }, [allData]);
- const handleTabsChange = (activeKey) => {
- setActiveKey(activeKey);
- };
- return (
- <div className={styles.detailCard}>
- <div className={styles.tableTop}>
- {title}
- <TabsContent
- defaultActiveKey="1"
- onChange={handleTabsChange}
- small={true}
- items={[
- {
- key: '1',
- label: `异常/警告(${errorData?.length || 0})`,
- children: <div></div>,
- },
- {
- key: '2',
- label: `全部(${allData?.length || 0})`,
- children: <div></div>,
- },
- ]}
- ></TabsContent>
- </div>
- {activeKey == '1' && (
- <LiquidTable
- onClickItem={sendMessageToUnity}
- select={select}
- items={errorData}
- key={type}
- type={type}
- />
- )}
- {activeKey == '2' && (
- <LiquidTable
- onClickItem={sendMessageToUnity}
- select={select}
- items={allData}
- key={type}
- type={type}
- />
- )}
- </div>
- // <div className={styles.detailCard}>
- // <Tabs
- // defaultActiveKey="1"
- // tabBarExtraContent={<div className={styles.tabBarExtraContent}>{title} </div>}
- // onChange={handleTabsChange}
- // >
- // <Tabs.TabPane tab={`异常/警告(${errorData.length || 0})`} key="1">
- // {activeKey == '1' && (
- // <LiquidTable
- // onClickItem={sendMessageToUnity}
- // select={select}
- // items={errorData}
- // key={type}
- // // data={data}
- // type={type}
- // />
- // )}
- // </Tabs.TabPane>
- // <Tabs.TabPane tab={`全部(${allData.length || 0})`} key="2">
- // {activeKey == '2' && (
- // <LiquidTable
- // onClickItem={sendMessageToUnity}
- // select={select}
- // items={allData}
- // // data={data}
- // key={type}
- // type={type}
- // />
- // )}
- // </Tabs.TabPane>
- // </Tabs>
- // </div>
- );
- }
- function ReportDumCom(props) {
- const { data = [], title } = props;
- const columns = [
- {
- title: '报警时间',
- dataIndex: 'event_time',
- render: (time) => dayjs(time).format('YYYY-MM-DD HH:mm:ss'),
- },
- {
- title: '设备名称',
- dataIndex: 'device_name',
- },
- {
- title: '报警类型',
- dataIndex: 'event_type',
- // render: type => alarmType[type],
- },
- {
- title: '报警图片',
- render: (item) => (
- <ReactZmage
- controller={{
- // 关闭按钮
- close: true,
- // 旋转按钮
- rotate: true,
- // 缩放按钮
- zoom: false,
- // 下载按钮
- download: false,
- // 翻页按钮
- flip: false,
- // 多页指示
- pagination: false,
- }}
- backdrop="rgba(255,255,255,0.5)"
- style={{ height: '90px' }}
- src={item.url}
- />
- ),
- },
- ];
- return (
- <div>
- <div className={styles.tabBarExtraContent}>
- <div className={styles.text} style={{ width: '60%' }}>
- {title}
- </div>
- <div className={styles.abnormal}>
- <div className={styles.text} style={{ float: 'right' }}>
- 异常({data?.length || 0})
- </div>
- </div>
- </div>
- <Table
- bordered
- rowKey="event_time"
- columns={columns}
- dataSource={data}
- locale={{
- emptyText: <Empty />,
- }}
- pagination={false}
- />
- </div>
- );
- }
- function base64ToImageUrl(base64String) {
- const byteCharacters = atob(base64String);
- const byteArrays = [];
- for (let i = 0; i < byteCharacters.length; i++) {
- byteArrays.push(byteCharacters.charCodeAt(i));
- }
- const byteArray = new Uint8Array(byteArrays);
- const blob = new Blob([byteArray], { type: 'image/png' });
- const imageUrl = URL.createObjectURL(blob);
- return imageUrl;
- }
- function Empty() {
- return (
- <div>
- <img
- src={require('@/assets/self-empty.png')}
- style={{ margin: '20px 0' }}
- />
- <p style={{ textAlign: 'center', color: '#555' }}>自检正常</p>
- </div>
- );
- }
- export default connect(({ eqSelfInspection }) => ({
- userList: eqSelfInspection.userList,
- mandateInfo: eqSelfInspection.mandateInfo,
- }))(Detail);
|