import * as React from 'react';
import AIService from './AIService';
import Service from './Service';
import {useNavigate, useLocation} from "react-router";
import ArrowRightIcon from '@rsuite/icons/ArrowRight';
import ArrowDownIcon from '@rsuite/icons/ArrowDown';
import TextField from '@mui/material/TextField';
import SearchIcon from '@rsuite/icons/Search';
//registerAllModules();
import { DataGrid, GridActionsCellItem, zhCN as zh_CN} from '@mui/x-data-grid';
import Box from '@mui/material/Box';
import MuiAppBar from '@mui/material/AppBar';
import { styled, useTheme } from '@mui/material/styles';
import Toolbar from '@mui/material/Toolbar';
import Typography from '@mui/material/Typography';
import CssBaseline from '@mui/material/CssBaseline';
import AccountCircle from '@mui/icons-material/AccountCircle';
import Fab from '@mui/material/Fab';
import Tooltip from '@mui/material/Tooltip';
import DeleteIcon from '@mui/icons-material/Delete';
import Button from '@mui/material/Button';
import Dialog from '@mui/material/Dialog';
import Drawer from '@mui/material/Drawer';
import Divider from '@mui/material/Divider';
import IconButton from '@mui/material/IconButton';
import ChevronLeftIcon from '@mui/icons-material/ChevronLeft';
import ChevronRightIcon from '@mui/icons-material/ChevronRight';
import MenuIcon from '@mui/icons-material/Menu';
import AddIcon from '@mui/icons-material/Add';
import DialogTitle from '@mui/material/DialogTitle';
import DialogActions from '@mui/material/DialogActions';
import CircularProgress from '@mui/material/CircularProgress';
import Backdrop from '@mui/material/Backdrop';
import List from '@mui/material/List';
import ListItem from '@mui/material/ListItem';
import ListItemButton from '@mui/material/ListItemButton';
import ListItemIcon from '@mui/material/ListItemIcon';
import ListItemText from '@mui/material/ListItemText';
import HomeIcon from '@mui/icons-material/Home';
import TipsAndUpdatesIcon from '@mui/icons-material/TipsAndUpdates';
import Stack from '@mui/material/Stack';
import Title from './Title';
import {Tree as Tree_2} from 'react-arborist';
import { CustomProvider } from 'rsuite';
import './Tree.css';
import zhCN from 'rsuite/locales/zh_CN';
import FormControl from '@mui/material/FormControl';
import InputLabel from '@mui/material/InputLabel';
import Input from 'rsuite/Input';
import 'rsuite/Input/styles/index.css';
import InputGroup from 'rsuite/InputGroup';
import 'rsuite/InputGroup/styles/index.css';
import Grid from '@mui/material/Grid';
import Container from '@mui/material/Container';
import Paper from '@mui/material/Paper';
import LinearProgress from '@mui/material/LinearProgress';
import Chart from './Chart';
import Chart2 from './Chart2';
import Chart3 from './Chart3';
import Select from '@mui/material/Select';
import MenuItem from '@mui/material/MenuItem';
export default function AI() {
const drawerWidth = 240;
const theme = useTheme();
function RenderDate(props) {
const { hasFocus, value } = props;
const buttonElement = React.useRef(null);
const rippleRef = React.useRef(null);
React.useLayoutEffect(() => {
if (hasFocus) {
const input = buttonElement.current.querySelector('input');
input?.focus();
} else if (rippleRef.current) {
// Only available in @mui/material v5.4.1 or later
rippleRef.current.stop({});
}
}, [hasFocus]);
return (
);
}
function RenderDe(props) {
const { hasFocus, value } = props;
const buttonElement = React.useRef(null);
const rippleRef = React.useRef(null);
return (
{value.split('@').map(x=>)}
);
}
function RenderDemc(props) {
const { hasFocus, value } = props;
const buttonElement = React.useRef(null);
const rippleRef = React.useRef(null);
return (
{value.split('@@').map(x=>)}
);
}
const columns = React.useMemo(
() => [
{ field: '清单编码', headerName: '清单编码', width: 250 },
{ field: '名称', headerName: '名称', width: 400 },
{ field: '数量', headerName: '数量', width: 200 },
{ field: '操作', headerName: '操作', width: 100 , sortable: false, renderCell: RenderDate},
],
);
const qdcolumns = React.useMemo(
() => [
{ field: '清单编码', headerName: '清单编码', },
{ field: '项目名称', headerName: '项目名称', },
{ field: '项目特征', headerName: '项目特征', width : 150 },
{ field: '计量单位', headerName: '计量单位', },
{ field: '工程量计算规则', headerName: '工程量计算规则', width: 300 },
{ field: '工作内容', headerName: '工作内容', width: 150 },
],
);
const zjcolumns = React.useMemo(
() => [
{ field: '单位', headerName: '单位', },
{ field: '组价定额', headerName: '组价定额', width : 250 , sortable: false, renderCell: RenderDe},
{ field: '定额名称', headerName: '定额名称', width : 250, sortable: false, renderCell: RenderDemc },
{ field: '数量', headerName: '数量', },
{ field: '综合单价', headerName: '综合单价', },
],
);
const tjcolumns = React.useMemo(
() => [
{ field: '组价定额', headerName: '组价定额', width : 250 , sortable: false, renderCell: RenderDe},
{ field: '定额名称', headerName: '定额名称', width : 350, sortable: false, renderCell: RenderDemc },
],
);
const Style = {
position: "absolute",
bottom: 128,
right: 64,
};
const VisuallyHiddenInput = styled('input')({
display: 'none',
accept: ".13jz, .13jt, .jszf"
});
const itemRef = React.useRef(null);
const navigate = useNavigate();
const [detail, setDetail] = React.useState( [
{label: "", value : 0}
]);
const [detail2, setDetail2] = React.useState( [
["工程类别", "清单数"],
["", 0],
]);
const [expanded, setExpanded] = React.useState([]);
const [frequency, setFrequency] = React.useState([]);
const [qddetail, setQddetail] = React.useState([]);
const [zjdetail, setZjdetail] = React.useState([]);
const [tjdetail, setTjdetail] = React.useState([]);
const [open, setOpen] = React.useState(false);
const [dopen, setDopen] = React.useState(false);
const [bopen, setBopen] = React.useState(false);
const [type, setType] = React.useState();
const [zjloading, setZjloading] = React.useState(false);
const [tjloading, setTjloading] = React.useState(false);
const [cjloading, setCjloading] = React.useState(false);
const [gploading, setGploading] = React.useState(false);
const [zhuanye, setZhuanye] = React.useState(10);
const [tab, setTab] = React.useState(false);
const [qingdanshu, setQingdanshu] = React.useState([]);
const [selected, setSelected] = React.useState();
const [keyword, setKeyword] = React.useState();
React.useEffect(
() => {
AIService.statistics("").then(x=>{
let t = [];
for (let i = 1; i < x.length; i++) {
t.push({label: x[i][0], value: x[i][1]});
}
setDetail(t);
});
AIService.qingdanshu(10).then(x=>{
setQingdanshu(x);
});
}, []
);
const handleRowClick = (params) => {
//setMessage(`Movie "${params.row.title}" clicked`);
navigate('/editor/qingdan/'.concat(params.row.id));
};
const AppBar = styled(MuiAppBar, {
shouldForwardProp: (prop) => prop !== 'open',
})(({ theme }) => ({
transition: theme.transitions.create(['margin', 'width'], {
easing: theme.transitions.easing.sharp,
duration: theme.transitions.duration.leavingScreen,
}),
variants: [
{
props: ({ open }) => open,
style: {
width: `calc(100% - ${drawerWidth}px)`,
marginLeft: `${drawerWidth}px`,
transition: theme.transitions.create(['margin', 'width'], {
easing: theme.transitions.easing.easeOut,
duration: theme.transitions.duration.enteringScreen,
}),
},
},
],
}));
const Main = styled('main', { shouldForwardProp: (prop) => prop !== 'open' })(
({ theme }) => ({
flexGrow: 1,
padding: theme.spacing(3),
transition: theme.transitions.create('margin', {
easing: theme.transitions.easing.sharp,
duration: theme.transitions.duration.leavingScreen,
}),
marginLeft: `-${drawerWidth}px`,
variants: [
{
props: ({ open }) => open,
style: {
transition: theme.transitions.create('margin', {
easing: theme.transitions.easing.easeOut,
duration: theme.transitions.duration.enteringScreen,
}),
marginLeft: 0,
},
},
],
}),
);
const DrawerHeader = styled('div')(({ theme }) => ({
display: 'flex',
alignItems: 'center',
padding: theme.spacing(0, 1),
// necessary for content to be below app bar
...theme.mixins.toolbar,
justifyContent: 'flex-end',
}));
const handleDrawerClose = () => {
setOpen(false);
};
const handleTongji = () => {
setOpen(false);
setTab(false);
};
const handleZujia = () => {
setOpen(false);
setTab(true);
};
const handleDrawerOpen = () => {
setOpen(true);
};
const handleClose = () => {
setDopen(false);
};
const handleDelete = () => {
Service.deleteFiles(itemRef.current).then(x=> {
Service.generateFiles2().then(x=>{
setDetail(x.map(y=>{return {'id': y[0], 'ID': y[0], '名称': y[1], '创建时间': y[2], '操作': y[0]};}));
});
});
setDopen(false);
};
const onSelect = (selectedKeys) => {
setSelected(selectedKeys['id']);
setZjloading(true);
console.log(selectedKeys);
AIService.qingdan(selectedKeys['title']).then(x=>{
setQddetail(x);
AIService.zujia(x[0]['清单编码']).then(y=>{
setZjdetail(y);
setZjloading(false);
});
setTjloading(true);
AIService.tuijian(x[0]['清单编码']).then(y=>{
setTjdetail(y);
setTjloading(false);
});
});
};
const onExpand = (expandItemValues, node) => {
//console.log(expandItemValues);
//console.log(node);
setExpanded(expandItemValues);
};
const clickLB = (lb) => {
console.log(lb);
setType(lb);
if (lb == null) {
} else if (lb == '建筑与装饰工程') {
//console.log('建筑与装饰工程');
setCjloading(true);
AIService.statistics("建筑与装饰工程").then(x=>{
let t = [];
for (let i = 1; i < x.length; i++) {
t.push({label: x[i][0], value: x[i][1]});
}
setDetail2(t);
setCjloading(false);
});
} else if (lb == '仿古建筑') {
setCjloading(true);
AIService.statistics("仿古建筑").then(x=>{
let t = [];
for (let i = 1; i < x.length; i++) {
t.push({label: x[i][0], value: x[i][1]});
}
setDetail2(t);
setCjloading(false);
});
} else if (lb == '安装工程') {
setCjloading(true);
AIService.statistics("安装工程").then(x=>{
let t = [];
for (let i = 1; i < x.length; i++) {
t.push({label: x[i][0], value: x[i][1]});
}
setDetail2(t);
setCjloading(false);
});
} else if (lb == '市政工程') {
setCjloading(true);
AIService.statistics("市政工程").then(x=>{
let t = [];
for (let i = 1; i < x.length; i++) {
t.push({label: x[i][0], value: x[i][1]});
}
setDetail2(t);
setCjloading(false);
});
} else if (lb == '园林绿化工程') {
setCjloading(true);
AIService.statistics("园林绿化工程").then(x=>{
let t = [];
for (let i = 1; i < x.length; i++) {
t.push({label: x[i][0], value: x[i][1]});
}
setDetail2(t);
setCjloading(false);
});
}
};
const clickLB2 = (type, lb) => {
console.log(type);
console.log(lb);
setGploading(true);
AIService.frequency(type, lb).then(x=>{
console.log(x);
setFrequency(x.map(y=>{y['操作'] = y['清单编码'];return y;}));
setGploading(false);
});
};
const handleChangeZhuanye = (event) => {
//console.log(event.target.value);
AIService.qingdanshu(event.target.value).then(x=>{
setQingdanshu(x);
});
setZhuanye(event.target.value);
};
const minHeight = 100;
const maxHeight = 400;
const CustomInputGroup = ({ placeholder, ...props }) => (
{setKeyword(value);}}
/>
);
function Node({ node, style }) {
let style_ = {'paddingLeft': style['paddingLeft']};
style_['fontSize'] = "0.875rem";
if (node.state.isSelected) {
style_['backgroundColor'] = "#f2faff";
style_['color'] = "#1675e0";
style_['fontWeight'] = "bold";
console.log(node);
}
return (
{
if (node.children.length > 0) {node.toggle();}
else {
setSelected(node['id']);
setZjloading(true);
}
}
}
>
{node.data.name}
);
}
function FolderArrow({ node }) {
return (
{node.isInternal ? (
node.isOpen ? (
) : (
)
) : null}
);
}
return (
清单AI
{theme.direction === 'ltr' ? : }
{['工作台', '清单AI'].map((text, index) => (
{
if (index == 0) {
navigate('/editor/index.html');
}
}}>
{index % 2 === 0 ? : }
))}
{ !tab &&
{/* Chart */}
清单分类
{/* Recent Deposits */}
次级清单分类
{ cjloading && }
{ !cjloading && }
{/* Recent Orders */}
高频清单
}
{ tab &&
{/* Chart */}
清单树
专业
{
onSelect(value);
}}
>
{/* Recent Deposits */}
'auto'}
rows={qddetail} columns={qdcolumns}
disableColumnMenu={true}
localeText={zh_CN.components.MuiDataGrid.defaultProps.localeText}
/>
历史组价
'auto'}
rows={zjdetail} columns={zjcolumns}
disableColumnMenu={true}
loading={zjloading}
localeText={zh_CN.components.MuiDataGrid.defaultProps.localeText}
/>
AI推荐
'auto'}
rows={tjdetail} columns={tjcolumns}
disableColumnMenu={true}
loading={tjloading}
localeText={zh_CN.components.MuiDataGrid.defaultProps.localeText}
/>
}
({ color: '#fff', zIndex: theme.zIndex.drawer + 1 })}
open={bopen}
>
);
}