App2.js 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076
  1. import * as React from 'react';
  2. import Box from "@mui/material/Box";
  3. import 'handsontable/dist/handsontable.full.min.css';
  4. //import 'handsontable/styles/ht-theme-main.min.css';
  5. import { styled, alpha } from '@mui/material/styles';
  6. import Paper from '@mui/material/Paper';
  7. import TextField from '@mui/material/TextField';
  8. import InputAdornment from '@mui/material/InputAdornment';
  9. import CancelIcon from '@mui/icons-material/Cancel';
  10. import { HandsonTable } from 'handsontable/base';
  11. import {HotTable} from "@handsontable/react";
  12. import { registerAllModules } from 'handsontable/registry';
  13. import {RichTreeView } from "@mui/x-tree-view/RichTreeView";
  14. import { Grid } from '@mui/material';
  15. import Tab from "@mui/material/Tab";
  16. import TabContext from "@mui/lab/TabContext";
  17. import TabList from "@mui/lab/TabList";
  18. import TabPanel from "@mui/lab/TabPanel";
  19. //import { registerPlugin, NestedRows } from 'handsontable/plugins';
  20. //registerPlugin(NestedRows);
  21. import Qingdan from './Qingdan';
  22. import Zjcs from './Zjcs';
  23. import Djcs2 from './Djcs2';
  24. import Service from './Service';
  25. import Qufei from './Qufei';
  26. import {useLocation, useParams} from "react-router";
  27. import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
  28. import Typography from '@mui/material/Typography';
  29. import InputLabel from '@mui/material/InputLabel';
  30. import MenuItem from '@mui/material/MenuItem';
  31. import FormControl from '@mui/material/FormControl';
  32. import Select from '@mui/material/Select';
  33. import Accordion from '@mui/material/Accordion';
  34. import AccordionActions from '@mui/material/AccordionActions';
  35. import AccordionSummary from '@mui/material/AccordionSummary';
  36. import AccordionDetails from '@mui/material/AccordionDetails';
  37. import Stack from '@mui/material/Stack';
  38. import { DataGrid } from '@mui/x-data-grid';
  39. import Backdrop from '@mui/material/Backdrop';
  40. import CircularProgress from '@mui/material/CircularProgress';
  41. import { TreeItem, treeItemClasses } from '@mui/x-tree-view/TreeItem';
  42. import Dialog from '@mui/material/Dialog';
  43. import DialogTitle from '@mui/material/DialogTitle';
  44. import DialogContent from '@mui/material/DialogContent';
  45. import DialogActions from '@mui/material/DialogActions';
  46. import IconButton from '@mui/material/IconButton';
  47. import CloseIcon from '@mui/icons-material/Close';
  48. import SearchIcon from '@mui/icons-material/Search';
  49. import Button from '@mui/material/Button';
  50. import {
  51. Toolbar,
  52. ToolbarButton,
  53. QuickFilter,
  54. QuickFilterControl,
  55. QuickFilterClear,
  56. QuickFilterTrigger,
  57. } from '@mui/x-data-grid';
  58. import Tooltip from '@mui/material/Tooltip';
  59. registerAllModules();
  60. const MUI_X_PRODUCTS = [
  61. {
  62. id: 'grid',
  63. label: 'Data Grid',
  64. children: [
  65. { id: 'grid-community', label: '@mui/x-data-grid' },
  66. { id: 'grid-pro', label: '@mui/x-data-grid-pro' },
  67. { id: 'grid-premium', label: '@mui/x-data-grid-premium' },
  68. ],
  69. },
  70. {
  71. id: 'pickers',
  72. label: 'Date and Time Pickers',
  73. children: [
  74. { id: 'pickers-community', label: '@mui/x-date-pickers' },
  75. { id: 'pickers-pro', label: '@mui/x-date-pickers-pro' },
  76. ],
  77. },
  78. {
  79. id: 'charts',
  80. label: 'Charts',
  81. children: [
  82. { id: 'charts-community', label: '@mui/x-charts' },
  83. { id: 'charts-pro', label: '@mui/charts-pro' },
  84. ],
  85. },
  86. {
  87. id: 'tree-view',
  88. label: 'Tree View',
  89. children: [
  90. { id: 'tree-view-community', label: '@mui/x-tree-view' },
  91. { id: 'tree-view-pro', label: '@mui/x-tree-view-pro' },
  92. ],
  93. },
  94. ];
  95. const INFO = [
  96. ['名称', '金额', '暂估价', '安全文明施工费', '规费'],
  97. ];
  98. const CustomTreeItem = styled(TreeItem)(({ theme }) => ({
  99. [`& .${treeItemClasses.content}`]: {
  100. padding: theme.spacing(0.5, 1),
  101. margin: theme.spacing(0.2, 0),
  102. [`& .${treeItemClasses.label}`]: {
  103. fontSize: '0.8rem',
  104. fontWeight: 500,
  105. },
  106. }
  107. }));
  108. const StyledToolbarButton = styled(ToolbarButton)(({ theme, ownerState }) => ({
  109. gridArea: '1 / 1',
  110. width: 'min-content',
  111. height: 'min-content',
  112. zIndex: 1,
  113. opacity: ownerState.expanded ? 0 : 1,
  114. pointerEvents: ownerState.expanded ? 'none' : 'auto',
  115. transition: theme.transitions.create(['opacity']),
  116. }));
  117. const StyledQuickFilter = styled(QuickFilter)({
  118. display: 'grid',
  119. alignItems: 'center',
  120. marginLeft: 'auto',
  121. });
  122. const StyledTextField = styled(TextField)(({ theme, ownerState }) => ({
  123. gridArea: '1 / 1',
  124. overflowX: 'clip',
  125. width: ownerState.expanded ? 260 : 'var(--trigger-width)',
  126. opacity: ownerState.expanded ? 1 : 0,
  127. transition: theme.transitions.create(['width', 'opacity']),
  128. }));
  129. function CustomToolbar() {
  130. return (
  131. <Toolbar>
  132. <StyledQuickFilter defaultExpanded>
  133. <QuickFilterTrigger
  134. render={(triggerProps, state) => (
  135. <Tooltip title="搜索" enterDelay={0}>
  136. <StyledToolbarButton
  137. {...triggerProps}
  138. ownerState={{ expanded: state.expanded }}
  139. color="default"
  140. aria-disabled={state.expanded}
  141. >
  142. <SearchIcon fontSize="small" />
  143. </StyledToolbarButton>
  144. </Tooltip>
  145. )}
  146. />
  147. <QuickFilterControl
  148. render={({ ref, ...controlProps }, state) => (
  149. <StyledTextField
  150. {...controlProps}
  151. ownerState={{ expanded: state.expanded }}
  152. inputRef={ref}
  153. aria-label="搜索"
  154. placeholder="搜索"
  155. size="small"
  156. slotProps={{
  157. input: {
  158. startAdornment: (
  159. <InputAdornment position="start">
  160. <SearchIcon fontSize="small" />
  161. </InputAdornment>
  162. ),
  163. endAdornment: state.value ? (
  164. <InputAdornment position="end">
  165. <QuickFilterClear
  166. edge="end"
  167. size="small"
  168. aria-label="清除"
  169. material={{ sx: { marginRight: -0.75 } }}
  170. >
  171. <CancelIcon fontSize="small" />
  172. </QuickFilterClear>
  173. </InputAdornment>
  174. ) : null,
  175. ...controlProps.slotProps?.input,
  176. },
  177. ...controlProps.slotProps,
  178. }}
  179. />
  180. )}
  181. />
  182. </StyledQuickFilter>
  183. </Toolbar>
  184. );
  185. }
  186. export default function App2() {
  187. const [outline, setOutline] = React.useState([]);
  188. const [peibishu, setPeibishu] = React.useState([]);
  189. const [outlineDes, setOutlineDes] = React.useState([]);
  190. const [columnHeaders, setColumnHeaders] = React.useState([]);
  191. const [detail, setDetail] = React.useState(INFO);
  192. const [deXilie, setDeXilie] = React.useState([]);
  193. const [pbXilie, setPbXilie] = React.useState([]);
  194. const [nestDetail, setNestDetail] = React.useState(INFO);
  195. const [nest, setNest] = React.useState(false);
  196. const [qingdan, setQingdan] = React.useState(false);
  197. const [cuoshi, setCuoshi] = React.useState(false);
  198. const [qufei, setQufei] = React.useState(false);
  199. const [qdbt, setQdbt] = React.useState([]);
  200. const [qdbh, setQdbh] = React.useState(null);
  201. const [value, setValue] = React.useState('1');
  202. const [dwgc, setDwgc] = React.useState(null);
  203. const [zhuanye, setZhuanye] = React.useState(10);
  204. const [expandedQd, setExpandedQd] = React.useState(true);
  205. const [expandedPb, setExpandedPb] = React.useState(false);
  206. const [expandedDe, setExpandedDe] = React.useState(false);
  207. const [zylb, setZylb] = React.useState('');
  208. const [selectedItems, setSelectedItems] = React.useState(null);
  209. const [expandedItems, setExpandedItems] = React.useState([]);
  210. const [rgde, setRgde] = React.useState(null);
  211. const [beizhu, setBeizhu] = React.useState(null);
  212. const [beizhuFK, setBeizhuFK] = React.useState(null);
  213. const [clde, setClde] = React.useState(null);
  214. const [jxde, setJxde] = React.useState(null);
  215. const [open, setOpen] = React.useState(false);
  216. const [dopen, setDopen] = React.useState(false);
  217. const [dingeclick, setDingeclick] = React.useState(null);
  218. const [tihuanClick, setTihuanClick] = React.useState(null);
  219. const tihuanRowRef = React.useRef(null);
  220. const relation = React.useRef({});
  221. const columns =[
  222. {field: '定额编号', headerName: '定额编号'},
  223. {field: '名称', headerName: '名称'},
  224. {field: '单位', headerName: '单位'},
  225. {field: '单价', headerName: '单价'}
  226. ];
  227. const columns2 =[
  228. {field: '编号', headerName: '定额编号'},
  229. {field: '名称', headerName: '名称', width: 200},
  230. {field: '单位', headerName: '单位'},
  231. {field: '单价', headerName: '单价'}
  232. ];
  233. let location = useParams();
  234. const traverse = (shu) => {
  235. for(let i = 0; i < shu.length; i++) {
  236. let id = shu[i]["id"];
  237. let children = shu[i]["children"];
  238. for (let j = 0; j < children.length; j++) {
  239. let id2 = children[j]["id"];
  240. relation.current[id2]=id;
  241. }
  242. traverse(children);
  243. }
  244. };
  245. const setOutlineDes_ = (x) => {
  246. setOutlineDes(x);
  247. relation.current = {};
  248. traverse(x);
  249. };
  250. const handleChangeZhuanye = (event) => {
  251. //console.log(event.target.value);
  252. Service.generateDingeshu(event.target.value).then(x=>{
  253. setOutlineDes_(x);
  254. });
  255. setZhuanye(event.target.value);
  256. };
  257. const handleChange = (event, newValue) => {
  258. setValue(newValue);
  259. };
  260. const findparent = (id) => {
  261. let result = [];
  262. while(id) {
  263. result.push(id);
  264. id = relation.current[id];
  265. }
  266. return result;
  267. };
  268. const loadingCallback = () => {
  269. setOpen(true);
  270. Service.save().then(x=>{
  271. setOpen(false);
  272. });
  273. };
  274. const qufeiCallback = (id, data) => {
  275. setOpen(true);
  276. Service.applyFL(id, data).then(x=>{
  277. Service.clearCache();
  278. Service.setQufei(data);
  279. setOpen(false);
  280. });
  281. };
  282. const tihuanCallback = (row, col) => {
  283. setDopen(true);
  284. tihuanRowRef.current = row;
  285. };
  286. const handleClose = () => {
  287. setDopen(false);
  288. };
  289. const clickCallback = (qdbm, debh) => {
  290. console.log('####################################zylb#####################'.concat(zylb.toString()));
  291. //console.log(debh);
  292. setExpandedQd(false);
  293. setExpandedDe(true);//1 jianzhu 2 zhuangshi 3 anzhuang 4 shizheng 5 yuanlin 6 guidao 7 xiushantujian 8 xiushananzhuang 9 xiushanjiagu
  294. if (qdbm.startsWith("01")) {
  295. let suggestion = 10;
  296. if (zylb == "7") {
  297. suggestion = 50;
  298. }
  299. setZhuanye(suggestion);
  300. Service.generateSingleDingeXilie(suggestion, debh).then(x=>{
  301. //console.log(x);
  302. let res = JSON.parse(x);
  303. console.log(res);
  304. setZhuanye(res["actual_zhuanye"]);
  305. let id = res['reverse'];
  306. if (id && id != "None") {
  307. setRgde(res["rgde"]);
  308. setJxde(res["jxde"]);
  309. setClde(res["clde"]);
  310. console.log(res["rgde"]);
  311. console.log(res["jxde"]);
  312. console.log(res["clde"]);
  313. setBeizhu(res["bz_selected"]);
  314. setBeizhuFK(res["bz_selected2"]);
  315. Service.generateDingeshu(res["actual_zhuanye"]).then(x=>{
  316. setOutlineDes_(x);
  317. setSelectedItems(id);
  318. setExpandedItems(findparent(id));
  319. Service.generateDingeXilie(res["actual_zhuanye"], id).then(x=>{
  320. let y = JSON.parse(x);
  321. //console.log(y);
  322. let result = [];
  323. let keys = Object.keys(y["DW"])
  324. for(let i = 0; i < keys.length; i++) {
  325. let key = keys[i];
  326. let entry = {
  327. "id": y["DEBH"][key],
  328. "定额编号": y["DEBH"][key],
  329. "名称": y["GCLMC"][key],
  330. "单位": y["DW"][key],
  331. "单价": y["GCLSJDJ"][key]
  332. };
  333. result.push(entry);
  334. }
  335. setDeXilie(result);
  336. });
  337. });
  338. } else {
  339. setRgde(null);
  340. setJxde(null);
  341. setClde(null);
  342. setBeizhu(res["bz_selected"]);
  343. }
  344. });
  345. } else if (qdbm.startsWith("03")) {//安装
  346. let suggestion = 30;
  347. if (zylb == "8") {
  348. suggestion = 60;
  349. }
  350. setZhuanye(suggestion);
  351. Service.generateSingleDingeXilie(suggestion, debh).then(x=>{
  352. //console.log(x);
  353. let res = JSON.parse(x);
  354. console.log(res);
  355. setZhuanye(res["actual_zhuanye"]);
  356. let id = res['reverse'];
  357. if (id && id != "None") {
  358. setRgde(res["rgde"]);
  359. setJxde(res["jxde"]);
  360. setClde(res["clde"]);
  361. console.log(res["rgde"]);
  362. console.log(res["jxde"]);
  363. console.log(res["clde"]);
  364. setBeizhu(res["bz_selected"]);
  365. Service.generateDingeshu(res["actual_zhuanye"]).then(x=>{
  366. setOutlineDes_(x);
  367. setSelectedItems(id);
  368. setExpandedItems(findparent(id));
  369. Service.generateDingeXilie(res["actual_zhuanye"], id).then(x=>{
  370. let y = JSON.parse(x);
  371. //console.log(y);
  372. let result = [];
  373. let keys = Object.keys(y["DW"])
  374. for(let i = 0; i < keys.length; i++) {
  375. let key = keys[i];
  376. let entry = {
  377. "id": y["DEBH"][key],
  378. "定额编号": y["DEBH"][key],
  379. "名称": y["GCLMC"][key],
  380. "单位": y["DW"][key],
  381. "单价": y["GCLSJDJ"][key]
  382. };
  383. result.push(entry);
  384. }
  385. setDeXilie(result);
  386. });
  387. });
  388. } else {
  389. setRgde(null);
  390. setJxde(null);
  391. setClde(null);
  392. setBeizhu(res["bz_selected"]);
  393. }
  394. });
  395. } else if (qdbm.startsWith("04")) {////市政
  396. setZhuanye(20);
  397. Service.generateSingleDingeXilie(20, debh).then(x=>{
  398. //console.log(x);
  399. let res = JSON.parse(x);
  400. console.log(res);
  401. setZhuanye(res["actual_zhuanye"]);
  402. let id = res['reverse'];
  403. if (id && id != "None") {
  404. setRgde(res["rgde"]);
  405. setJxde(res["jxde"]);
  406. setClde(res["clde"]);
  407. console.log(res["rgde"]);
  408. console.log(res["jxde"]);
  409. console.log(res["clde"]);
  410. setBeizhu(res["bz_selected"]);
  411. Service.generateDingeshu(res["actual_zhuanye"]).then(x=>{
  412. setOutlineDes_(x);
  413. setSelectedItems(id);
  414. setExpandedItems(findparent(id));
  415. Service.generateDingeXilie(res["actual_zhuanye"], id).then(x=>{
  416. let y = JSON.parse(x);
  417. //console.log(y);
  418. let result = [];
  419. let keys = Object.keys(y["DW"])
  420. for(let i = 0; i < keys.length; i++) {
  421. let key = keys[i];
  422. let entry = {
  423. "id": y["DEBH"][key],
  424. "定额编号": y["DEBH"][key],
  425. "名称": y["GCLMC"][key],
  426. "单位": y["DW"][key],
  427. "单价": y["GCLSJDJ"][key]
  428. };
  429. result.push(entry);
  430. }
  431. setDeXilie(result);
  432. });
  433. });
  434. } else {
  435. setRgde(null);
  436. setJxde(null);
  437. setClde(null);
  438. setBeizhu(res["bz_selected"]);
  439. }
  440. });
  441. }
  442. else if (qdbm.startsWith("05")) {//园林
  443. setZhuanye(40);
  444. Service.generateSingleDingeXilie(40, debh).then(x=>{
  445. //console.log(x);
  446. let res = JSON.parse(x);
  447. console.log(res);
  448. setZhuanye(res["actual_zhuanye"]);
  449. let id = res['reverse'];
  450. if (id && id != "None") {
  451. setRgde(res["rgde"]);
  452. setJxde(res["jxde"]);
  453. setClde(res["clde"]);
  454. console.log(res["rgde"]);
  455. console.log(res["jxde"]);
  456. console.log(res["clde"]);
  457. setBeizhu(res["bz_selected"]);
  458. Service.generateDingeshu(res["actual_zhuanye"]).then(x=>{
  459. setOutlineDes_(x);
  460. setSelectedItems(id);
  461. setExpandedItems(findparent(id));
  462. Service.generateDingeXilie(res["actual_zhuanye"], id).then(x=>{
  463. let y = JSON.parse(x);
  464. //console.log(y);
  465. let result = [];
  466. let keys = Object.keys(y["DW"])
  467. for(let i = 0; i < keys.length; i++) {
  468. let key = keys[i];
  469. let entry = {
  470. "id": y["DEBH"][key],
  471. "定额编号": y["DEBH"][key],
  472. "名称": y["GCLMC"][key],
  473. "单位": y["DW"][key],
  474. "单价": y["GCLSJDJ"][key]
  475. };
  476. result.push(entry);
  477. }
  478. setDeXilie(result);
  479. });
  480. });
  481. } else {
  482. setRgde(null);
  483. setJxde(null);
  484. setClde(null);
  485. setBeizhu(res["bz_selected"]);
  486. }
  487. });
  488. } else {
  489. console.log('####################################zylb#####################'.concat(zylb.toString()));
  490. }
  491. };
  492. const handleEvent = (A) => {
  493. let state = {
  494. 'time': Date.now(),
  495. 'newBianhao': A.row['编号'],
  496. 'newName': A.row['名称'],
  497. 'newJia': A.row['单价'],
  498. 'old' : tihuanRowRef.current
  499. };
  500. setTihuanClick(JSON.stringify(state));
  501. setDopen(false);
  502. };
  503. const handleChangeAccord = (panel) => (event, newExpanded) => {
  504. if (panel == 'qingdan') {
  505. setExpandedQd(newExpanded);
  506. }
  507. else if (panel == 'peibi'){
  508. setExpandedPb(newExpanded);
  509. } else {
  510. setExpandedDe(newExpanded);
  511. }
  512. };
  513. const handleItemSelectionTogglePbs = (event, itemId, isSelected) => {
  514. if (isSelected) {
  515. console.log(itemId);
  516. if (["0", "3", "4", "6", "7", "8", "9", "11", "12", "13", "15", "16", "18", "19", "20", "21"].includes(itemId)) {
  517. Service.generatePeibiXilie(itemId).then(x=>{
  518. let y = JSON.parse(x);
  519. console.log(y);
  520. let result = [];
  521. let keys = Object.keys(y["PBBH"])
  522. for(let i = 0; i < keys.length; i++) {
  523. let key = keys[i];
  524. let entry = {
  525. "id": y["id"][key],
  526. "编号": y["PBBH"][key],
  527. "名称": y["PBMC"][key],
  528. "单位": y["DW"][key],
  529. "单价": y["PBDJ"][key]
  530. };
  531. result.push(entry);
  532. setPbXilie(result);
  533. }
  534. });
  535. }
  536. }
  537. }
  538. const handleDingEEvent = (row) => {
  539. Service.generateSingleDingeXilie(zhuanye, row.id).then(x=>{
  540. let res = JSON.parse(x);
  541. console.log(res);
  542. res["date"] = Date.now().toString();
  543. setDingeclick(JSON.stringify(res));
  544. });
  545. //
  546. };
  547. const handleItemSelectionToggleDes = (event, itemId, isSelected) => {
  548. if (isSelected) {
  549. //console.log(itemId);
  550. setSelectedItems(itemId);
  551. setExpandedItems(findparent(itemId));
  552. Service.generateDingeXilie(zhuanye, itemId).then(x=>{
  553. let y = JSON.parse(x);
  554. //console.log(y);
  555. let result = [];
  556. let keys = Object.keys(y["DW"])
  557. for(let i = 0; i < keys.length; i++) {
  558. let key = keys[i];
  559. let entry = {
  560. "id": y["DEBH"][key],
  561. "定额编号": y["DEBH"][key],
  562. "名称": y["GCLMC"][key],
  563. "单位": y["DW"][key],
  564. "单价": y["GCLSJDJ"][key]
  565. };
  566. result.push(entry);
  567. }
  568. setDeXilie(result);
  569. });
  570. }
  571. }
  572. const handleItemSelectionToggle = (event, itemId, isSelected) => {
  573. if (isSelected) {
  574. //console.log(itemId);
  575. let pos = itemId.indexOf("Zylb");
  576. let Zylb = itemId.substring(pos+4, pos+5);
  577. setZylb(Zylb);
  578. //console.log("Zylb=".concat(Zylb));
  579. if (itemId.includes("bao jia hui zong")) {
  580. let regex = /[0-9]*/;
  581. let id = itemId.match(regex)[0];
  582. Service.generateBaojiahuizong2(location["id"], id).then(x=>{
  583. setNestDetail(x);
  584. setNest(true);
  585. setQingdan(false);
  586. setCuoshi(false);
  587. setQufei(false);
  588. setColumnHeaders(["序号", "名称", "金额", "暂估价", "类别"]);
  589. });
  590. }
  591. else if (itemId.includes("gui fei shui jin")) {
  592. let regex = /[0-9]*/;
  593. let id = itemId.match(regex)[0];
  594. Service.generateGuifeishuijin2(location["id"], id).then(x=>{
  595. setNestDetail(x);
  596. setNest(true);
  597. setQingdan(false);
  598. setCuoshi(false);
  599. setQufei(false);
  600. setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
  601. });
  602. }
  603. else if (itemId.includes("qing dan xiang mu")) {
  604. let regex = /[0-9]*/;
  605. let id = itemId.match(regex)[0];
  606. Service.generateQingdanxiangmu2(location["id"], id).then(x=>{
  607. setValue("1");
  608. setNest(false);
  609. setQingdan(true);
  610. setCuoshi(false);
  611. setQdbt(x);
  612. setQdbh(id);
  613. setQufei(false);
  614. //setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
  615. });
  616. }
  617. else if (itemId.includes("cuo shi xiang mu")) {
  618. let regex = /[0-9]*/;
  619. let id = itemId.match(regex)[0];
  620. setValue("1");
  621. setNest(false);
  622. setQingdan(false);
  623. setCuoshi(true);
  624. setDwgc(id);
  625. setQufei(false);
  626. //setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
  627. }
  628. else if (itemId.includes("qi ta xiang mu")) {
  629. let regex = /[0-9]*/;
  630. let id = itemId.match(regex)[0];
  631. setValue("1");
  632. //setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
  633. Service.generateQitaxiangmu2(location["id"], id).then(x=>{
  634. setNestDetail(x);
  635. setNest(true);
  636. setQingdan(false);
  637. setCuoshi(false);
  638. setQufei(false);
  639. setColumnHeaders(["序号", "名称", "金额", "项目类别", "备注"]);
  640. });
  641. }
  642. else if (itemId.includes("zan lie jin e")) {
  643. let regex = /[0-9]*/;
  644. let id = itemId.match(regex)[0];
  645. setValue("1");
  646. //setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
  647. Service.generateZanliejine2(location["id"], id).then(x=>{
  648. setDetail(x);
  649. setNest(false);
  650. setQingdan(false);
  651. setCuoshi(false);
  652. setQufei(false);
  653. });
  654. }
  655. else if (itemId.includes("ji ri gong")) {
  656. let regex = /[0-9]*/;
  657. let id = itemId.match(regex)[0];
  658. setValue("1");
  659. //setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
  660. Service.generateJirigong2(location["id"], id).then(x=>{
  661. setDetail(x);
  662. setNest(false);
  663. setQingdan(false);
  664. setCuoshi(false);
  665. setQufei(false);
  666. });
  667. }
  668. else if (itemId.includes("zong cheng bao fu wu fei")) {
  669. let regex = /[0-9]*/;
  670. let id = itemId.match(regex)[0];
  671. setValue("1");
  672. //setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
  673. Service.generateZongchengbaofuwufei2(location["id"], id).then(x=>{
  674. setDetail(x);
  675. setNest(false);
  676. setQingdan(false);
  677. setCuoshi(false);
  678. setQufei(false);
  679. });
  680. }
  681. else if (itemId.includes("fa bao ren gong ying cai liao")) {
  682. let regex = /[0-9]*/;
  683. let id = itemId.match(regex)[0];
  684. setValue("1");
  685. //setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
  686. Service.generateFabaorengongyingcailiao2(location["id"], id).then(x=>{
  687. setDetail(x);
  688. setNest(false);
  689. setQingdan(false);
  690. setCuoshi(false);
  691. setQufei(false);
  692. });
  693. }
  694. else if (itemId.includes("ren cai ji hui zong")) {
  695. let regex = /[0-9]*/;
  696. let id = itemId.match(regex)[0];
  697. setValue("1");
  698. //setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
  699. Service.generateRencaijihuizong2(location["id"], id).then(x=>{
  700. setDetail(x);
  701. setNest(false);
  702. setQingdan(false);
  703. setCuoshi(false);
  704. setQufei(false);
  705. });
  706. }
  707. else if (itemId.includes("TouBiaoXx")) {
  708. Service.generateDetail2(location["id"]).then(x=>{
  709. setQingdan(false);
  710. setCuoshi(false);
  711. setDetail(x);
  712. setNest(false);
  713. setQufei(false);
  714. });
  715. }
  716. }
  717. };
  718. React.useEffect(
  719. () => {
  720. console.log(location);
  721. Service.generateQufei(location["id"]).then(x=>{
  722. Service.setQufei(x);
  723. });
  724. Service.generateOutline2(location["id"]).then(x=>{
  725. setOutline(x);
  726. });
  727. Service.generateDetail2(location['id']).then(x=>{
  728. setDetail(x);
  729. });
  730. Service.generateDingeshu(10).then(x=>{
  731. setOutlineDes_(x);
  732. });
  733. }, [location]
  734. );
  735. React.useEffect(
  736. () => {
  737. Service.generatePeibishu(zhuanye).then(x=>{
  738. setPeibishu(x);
  739. });
  740. }, [zhuanye]
  741. );
  742. return (
  743. <Box sx={{ flexGrow: 1 }}>
  744. <Grid container spacing={2}>
  745. <Grid size={3}>
  746. <Accordion expanded={expandedQd} disableGutters
  747. onChange={handleChangeAccord('qingdan')}>
  748. <AccordionSummary
  749. expandIcon={<ExpandMoreIcon />}
  750. aria-controls="panel1-content"
  751. id="panel1-header"
  752. >
  753. <Typography component="span">清单</Typography>
  754. </AccordionSummary>
  755. <AccordionDetails>
  756. <RichTreeView sx={{overflow: "scroll", maxHeight: "90vh"}}
  757. onItemSelectionToggle={handleItemSelectionToggle}
  758. slots={{ item: CustomTreeItem }}
  759. items={outline}/>
  760. </AccordionDetails>
  761. </Accordion>
  762. <Accordion expanded={expandedDe} disableGutters
  763. onChange={handleChangeAccord('dinge')}>
  764. <AccordionSummary
  765. expandIcon={<ExpandMoreIcon />}
  766. aria-controls="panel1-content"
  767. id="panel1-header"
  768. >
  769. <Typography component="span">定额</Typography>
  770. </AccordionSummary>
  771. <AccordionDetails>
  772. <FormControl size="small">
  773. <InputLabel id="demo-multiple-name-label">专业</InputLabel>
  774. <Select
  775. labelId="demo-multiple-name-label"
  776. id="demo-multiple-name"
  777. value={zhuanye}
  778. onChange={handleChangeZhuanye}
  779. label="专业"
  780. >
  781. <MenuItem value={10}>土建</MenuItem>
  782. <MenuItem value={20}>市政</MenuItem>
  783. <MenuItem value={30}>安装</MenuItem>
  784. <MenuItem value={40}>园林</MenuItem>
  785. <MenuItem value={50}>修缮(土建)</MenuItem>
  786. <MenuItem value={60}>修缮(安装)</MenuItem>
  787. </Select>
  788. </FormControl>
  789. <Stack spacing={1}>
  790. <RichTreeView sx={{overflow: "scroll", maxHeight: `calc(100vh - 540px)`}}
  791. onItemSelectionToggle={handleItemSelectionToggleDes}
  792. slots={{ item: CustomTreeItem }}
  793. selectedItems={selectedItems}
  794. expandedItems={expandedItems}
  795. items={outlineDes}/>
  796. <div style={{ height: 350 }}>
  797. <DataGrid
  798. sx={{
  799. '& .MuiDataGrid-cell': {
  800. fontSize: '0.8rem', // Adjust font size for cells
  801. },
  802. /* '& .MuiDataGrid-columnHeaders': {
  803. fontSize: '1rem', // Adjust font size for column headers
  804. },*/
  805. }}
  806. getRowHeight={() => 'auto'}
  807. rows={deXilie}
  808. columns={columns}
  809. hideFooter={true}
  810. onRowDoubleClick={handleDingEEvent}
  811. />
  812. </div>
  813. </Stack>
  814. </AccordionDetails>
  815. </Accordion>
  816. <Button variant="outlined" fullWidth onClick={()=> {
  817. setQufei(true);
  818. setQingdan(false);
  819. setCuoshi(false);
  820. }}>费率</Button>
  821. </Grid>
  822. <Grid size={9}>
  823. {!nest && !qingdan && !cuoshi && !qufei && <HotTable nestedRows={false}
  824. data={detail
  825. }
  826. rowHeaders={true}
  827. colHeaders={true}
  828. fixedRowsTop={1}
  829. height="800"
  830. readOnly={true}
  831. autoWrapRow={false}
  832. autoWrapCol={false}
  833. licenseKey="non-commercial-and-evaluation" // for non-commercial use only
  834. />}
  835. {nest && !qingdan && !cuoshi && !qufei && <HotTable nestedRows={true}
  836. data={nestDetail
  837. }
  838. readOnly={true}
  839. fixedRowsTop={1}
  840. rowHeaders={true}
  841. colHeaders={columnHeaders}
  842. height="auto"
  843. contextMenu={true}
  844. bindRowsWithHeaders={true}
  845. autoWrapRow={false}
  846. autoWrapCol={false}
  847. licenseKey="non-commercial-and-evaluation" // for non-commercial use only
  848. />}
  849. {!qingdan && !cuoshi && qufei && <Qufei id={location['id']} qufeiCallback={qufeiCallback}
  850. />}
  851. {!nest && qingdan && !cuoshi && !qufei && <TabContext value={value}>
  852. <Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
  853. <TabList scrollButtons='auto'
  854. variant="scrollable"
  855. sx={{minHeight: '24px'}}
  856. onChange={handleChange} aria-label="lab API tabs example">
  857. {qdbt.map((x, index)=> <Tab sx={{p: 0, minHeight: '24px'}} label={x} value={(index+1).toString()} />)}
  858. </TabList>
  859. </Box>
  860. {qdbt.map((x, index)=><TabPanel sx={{p: 1}} value={(index+1).toString()}>
  861. <Qingdan
  862. name={location["id"]}
  863. bh={qdbh}
  864. bt={x}
  865. rgde={rgde}
  866. jxde={jxde}
  867. clde={clde}
  868. beizhu={beizhu}
  869. beizhuFK={beizhuFK}
  870. clickCallback={clickCallback}
  871. loadingCallback={loadingCallback}
  872. dingeclick={dingeclick}
  873. tihuanCallback={tihuanCallback}
  874. tihuanClick={tihuanClick}
  875. />
  876. </TabPanel>
  877. )}
  878. </TabContext>}
  879. {!nest && !qingdan && cuoshi && !qufei && <TabContext value={value}>
  880. <Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
  881. <TabList scrollButtons='auto'
  882. variant="scrollable"
  883. sx={{minHeight: '24px'}}
  884. onChange={handleChange} aria-label="lab API tabs example">
  885. <Tab sx={{p: 0, minHeight: '24px'}} label="总价措施" value="1" />
  886. <Tab sx={{p: 0, minHeight: '24px'}} label="单价措施" value="2" />
  887. </TabList>
  888. </Box>
  889. <TabPanel sx={{p: 1}} value="1">
  890. <Zjcs name={location["id"]} bh={dwgc}/>
  891. </TabPanel>
  892. <TabPanel sx={{p: 1}} value="2">
  893. <Djcs2
  894. name={location["id"]}
  895. bh={dwgc}
  896. rgde={rgde}
  897. jxde={jxde}
  898. clde={clde}
  899. beizhu={beizhu}
  900. clickCallback={clickCallback}
  901. />
  902. </TabPanel>
  903. </TabContext>}
  904. </Grid>
  905. </Grid>
  906. <Backdrop
  907. sx={(theme) => ({ color: '#fff', zIndex: theme.zIndex.drawer + 1 })}
  908. open={open}
  909. >
  910. <CircularProgress color="inherit" />
  911. </Backdrop>
  912. <Dialog
  913. onClose={handleClose}
  914. aria-labelledby="customized-dialog-title"
  915. open={dopen}
  916. fullWidth={true}
  917. maxWidth="md"
  918. >
  919. <DialogTitle sx={{ m: 0, p: 2 }} id="customized-dialog-title">
  920. 替换
  921. </DialogTitle>
  922. <IconButton
  923. aria-label="close"
  924. onClick={handleClose}
  925. sx={(theme) => ({
  926. position: 'absolute',
  927. right: 8,
  928. top: 8,
  929. color: theme.palette.grey[500],
  930. })}
  931. >
  932. <CloseIcon />
  933. </IconButton>
  934. <DialogContent dividers>
  935. <Stack direction="row" spacing={2}>
  936. <RichTreeView sx={{
  937. overflow: "scroll",
  938. maxHeight: "350px",
  939. minWidth: "250px"
  940. }}
  941. slots={{ item: CustomTreeItem }}
  942. onItemSelectionToggle={handleItemSelectionTogglePbs}
  943. items={peibishu}/>
  944. <div style={{ height: 350 }}>
  945. <DataGrid disableColumnMenu
  946. sx={{
  947. '& .MuiDataGrid-cell': {
  948. fontSize: '0.8rem', // Adjust font size for cells
  949. }}}
  950. getRowHeight={() => 'auto'}
  951. rows={pbXilie}
  952. onRowDoubleClick={handleEvent}
  953. columns={columns2}
  954. hideFooter={false}
  955. disableColumnFilter
  956. disableColumnSelector
  957. disableDensitySelector
  958. showToolbar
  959. slots={{ toolbar: CustomToolbar }}
  960. localeText={{
  961. noRowsLabel: '无数据',
  962. paginationRowsPerPage: '每页行数',
  963. footerRowSelected: (count) => `共选中了${count.toLocaleString()}行`,
  964. }}
  965. />
  966. </div>
  967. </Stack>
  968. </DialogContent>
  969. </Dialog>
  970. </Box>
  971. );
  972. }