|
@@ -8,15 +8,14 @@ import {
|
|
|
} from '@/services/device';
|
|
|
import { RightOutlined } from '@ant-design/icons';
|
|
|
import { useNavigate, useParams, useRequest } from '@umijs/max';
|
|
|
-import { Button, Collapse, List, Space, Table } from 'antd';
|
|
|
+import { Collapse, List, Space, Table } from 'antd';
|
|
|
import dayjs from 'dayjs';
|
|
|
import { useMemo, useState } from 'react';
|
|
|
import styles from './index.less';
|
|
|
-const img = require('@/assets/deviceManager/device01.png');
|
|
|
+const img = require('@/assets/air-conditioner.png');
|
|
|
const chartIcon = require('@/assets/deviceManager/chartIcon.png');
|
|
|
const DeviceManager = () => {
|
|
|
const { projectId } = useParams();
|
|
|
- const [type, setType] = useState(0); //0 全部 1维修 2保养
|
|
|
const year = dayjs().format('YYYY');
|
|
|
const params = {
|
|
|
project_id: Number(projectId),
|
|
@@ -35,7 +34,7 @@ const DeviceManager = () => {
|
|
|
}
|
|
|
};
|
|
|
return (
|
|
|
- <PageContent style={{ backgroundColor: 'gray' }}>
|
|
|
+ <PageContent>
|
|
|
<TabsContent
|
|
|
defaultActiveKey="1"
|
|
|
onChange={onChange}
|
|
@@ -59,6 +58,7 @@ const DeviceManager = () => {
|
|
|
};
|
|
|
const Device = ({ projectId }) => {
|
|
|
const [type, setType] = useState(0); //0 全部 1维修 2保养
|
|
|
+ const [activeCode, setActiveCode] = useState();
|
|
|
|
|
|
const columnsRepair = [
|
|
|
{
|
|
@@ -136,45 +136,51 @@ const Device = ({ projectId }) => {
|
|
|
|
|
|
//请求 全部设备列表
|
|
|
const {
|
|
|
- data: allData,
|
|
|
+ data,
|
|
|
run: runDevice,
|
|
|
loading: loadingDevice,
|
|
|
} = useRequest(queryDeviceList, {
|
|
|
defaultParams: [projectId],
|
|
|
- formatResult: (res) => {
|
|
|
- const data = res.data;
|
|
|
- const total = data?.reduce((total, item) => item.Count, 0);
|
|
|
- const items = data?.map((item, idx) => {
|
|
|
- const itemLen = item?.List?.length;
|
|
|
- return {
|
|
|
- key: idx,
|
|
|
- label: (
|
|
|
- <div style={{ display: 'flex', justifyContent: 'space-between' }}>
|
|
|
- <span>{item.Type}</span>
|
|
|
- <span>{itemLen}个</span>
|
|
|
- </div>
|
|
|
- ),
|
|
|
- children: (
|
|
|
- <div style={{ position: 'relative' }}>
|
|
|
- <List
|
|
|
- header={null}
|
|
|
- footer={null}
|
|
|
- dataSource={item.List}
|
|
|
- renderItem={(cur) => (
|
|
|
- <List.Item style={{ justifyContent: 'left' }}>
|
|
|
- <span style={{ width: '30%' }}> {cur.Code} </span>
|
|
|
- <span> {cur.Name} </span>
|
|
|
- </List.Item>
|
|
|
- )}
|
|
|
- />
|
|
|
- </div>
|
|
|
- ),
|
|
|
- };
|
|
|
- });
|
|
|
- return { total, items };
|
|
|
- },
|
|
|
});
|
|
|
|
|
|
+ const allData = useMemo(() => {
|
|
|
+ console.log(activeCode);
|
|
|
+ const total = data?.reduce((total, item) => item.Count, 0);
|
|
|
+ const items = data?.map((item, idx) => {
|
|
|
+ const itemLen = item?.List?.length;
|
|
|
+ return {
|
|
|
+ key: `${idx + 1}`,
|
|
|
+ label: (
|
|
|
+ <div className={styles.lineContent}>
|
|
|
+ <span>{item.Type}</span>
|
|
|
+ <span>{itemLen}个</span>
|
|
|
+ </div>
|
|
|
+ ),
|
|
|
+ children: (
|
|
|
+ <div style={{ position: 'relative' }}>
|
|
|
+ <List
|
|
|
+ header={null}
|
|
|
+ footer={null}
|
|
|
+ dataSource={item.List}
|
|
|
+ renderItem={(cur) => (
|
|
|
+ <List.Item
|
|
|
+ className={`${styles.itemText} ${
|
|
|
+ activeCode == cur.Code ? styles.itemTextActive : ''
|
|
|
+ }`}
|
|
|
+ onClick={() => handleItemClick(cur.Code)}
|
|
|
+ >
|
|
|
+ <span style={{ marginRight: '166px' }}> {cur.Code} </span>
|
|
|
+ <span> {cur.Name} </span>
|
|
|
+ </List.Item>
|
|
|
+ )}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ ),
|
|
|
+ };
|
|
|
+ });
|
|
|
+ return { total, items };
|
|
|
+ }, [data, activeCode]);
|
|
|
+
|
|
|
//请求维修中设备列表queryRepairRecord
|
|
|
const {
|
|
|
data: repairData,
|
|
@@ -208,6 +214,35 @@ const Device = ({ projectId }) => {
|
|
|
},
|
|
|
);
|
|
|
|
|
|
+ const handleItemClick = (code) => {
|
|
|
+ console.log(code);
|
|
|
+ setActiveCode(code);
|
|
|
+ };
|
|
|
+
|
|
|
+ const renderChildlen = (item) => {
|
|
|
+ console.log(activeCode);
|
|
|
+ return (
|
|
|
+ <div style={{ position: 'relative' }}>
|
|
|
+ <List
|
|
|
+ header={null}
|
|
|
+ footer={null}
|
|
|
+ dataSource={item.List}
|
|
|
+ renderItem={(cur) => (
|
|
|
+ <List.Item
|
|
|
+ className={`${styles.listText} ${
|
|
|
+ activeCode == cur.Code ? styles.lineTextActive : ''
|
|
|
+ }`}
|
|
|
+ onClick={() => handleItemClick(cur.Code)}
|
|
|
+ >
|
|
|
+ <span style={{ marginRight: '166px' }}> {cur.Code} </span>
|
|
|
+ <span> {cur.Name} </span>
|
|
|
+ </List.Item>
|
|
|
+ )}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ );
|
|
|
+ };
|
|
|
+
|
|
|
const handleBtnClick = (type) => {
|
|
|
setType(type);
|
|
|
switch (type) {
|
|
@@ -225,32 +260,36 @@ const Device = ({ projectId }) => {
|
|
|
|
|
|
const onChange = () => {};
|
|
|
return (
|
|
|
- <Space direction="vertical" className={styles.sparePart}>
|
|
|
+ <div className={styles.sparePart}>
|
|
|
<div className={`card-box ${styles.titleContent}`}>
|
|
|
<img className={styles.img} src={img} />
|
|
|
<div>
|
|
|
<div className={styles.num}>{allData?.total}</div>
|
|
|
- <div>设备总数</div>
|
|
|
+ <div className={styles.text}>设备总数</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <Space>
|
|
|
- <Button shape="round" onClick={() => handleBtnClick(0)}>
|
|
|
+ <Space className={styles.btns} size={28}>
|
|
|
+ <div
|
|
|
+ className={`${styles.btn} ${type == 0 ? styles.active : ''}`}
|
|
|
+ onClick={() => handleBtnClick(0)}
|
|
|
+ >
|
|
|
全部
|
|
|
- </Button>
|
|
|
- <Button shape="round" onClick={() => handleBtnClick(1)}>
|
|
|
+ </div>
|
|
|
+ <div
|
|
|
+ className={`${styles.btn} ${type == 1 ? styles.active : ''}`}
|
|
|
+ onClick={() => handleBtnClick(1)}
|
|
|
+ >
|
|
|
维修
|
|
|
- </Button>
|
|
|
- <Button shape="round" onClick={() => handleBtnClick(2)}>
|
|
|
- 计划保养
|
|
|
- </Button>
|
|
|
+ </div>
|
|
|
+ <div
|
|
|
+ className={`${styles.btn} ${type == 2 ? styles.active : ''}`}
|
|
|
+ onClick={() => handleBtnClick(2)}
|
|
|
+ >
|
|
|
+ 保养
|
|
|
+ </div>
|
|
|
</Space>
|
|
|
{type == 0 && (
|
|
|
- <Collapse
|
|
|
- defaultActiveKey={['1']}
|
|
|
- bordered={false}
|
|
|
- onChange={onChange}
|
|
|
- items={allData?.items}
|
|
|
- />
|
|
|
+ <Collapse bordered={false} onChange={onChange} items={allData?.items} />
|
|
|
)}
|
|
|
{type == 1 && (
|
|
|
<Table
|
|
@@ -263,14 +302,14 @@ const Device = ({ projectId }) => {
|
|
|
)}
|
|
|
{type == 2 && (
|
|
|
<Table
|
|
|
- loading={repairLoading}
|
|
|
+ loading={maintaiLoading}
|
|
|
style={{ marginTop: '10px' }}
|
|
|
- dataSource={repairData?.filter((item) => item.DeviceCode)}
|
|
|
+ dataSource={maintainData?.filter((item) => item.DeviceCode)}
|
|
|
columns={columns}
|
|
|
pagination={false}
|
|
|
/>
|
|
|
)}
|
|
|
- </Space>
|
|
|
+ </div>
|
|
|
);
|
|
|
};
|
|
|
const SparePart = ({ data, loading, projectId }) => {
|
|
@@ -312,7 +351,7 @@ const SparePart = ({ data, loading, projectId }) => {
|
|
|
return result;
|
|
|
}, [data]);
|
|
|
return (
|
|
|
- <Space direction="vertical" className={styles.sparePart}>
|
|
|
+ <Space direction="vertical" size={16} className={styles.sparePart}>
|
|
|
<div className={`card-box ${styles.titleContent}`}>
|
|
|
<img className={styles.img} src={img} />
|
|
|
<div>
|