App2.js 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088
  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 Qingdan2 from './Qingdan2';
  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 loadingCallback_djcs = () => {
  275. setOpen(true);
  276. Service.save_djcs().then(x=>{
  277. setOpen(false);
  278. });
  279. };
  280. const qufeiCallback = (id, data) => {
  281. setOpen(true);
  282. Service.applyFL(id, data).then(x=>{
  283. Service.clearCache();
  284. Service.setQufei(data);
  285. setOpen(false);
  286. });
  287. };
  288. const tihuanCallback = (row, col) => {
  289. setDopen(true);
  290. tihuanRowRef.current = row;
  291. };
  292. const handleClose = () => {
  293. setDopen(false);
  294. };
  295. const clickCallback = (qdbm, debh) => {
  296. console.log('####################################zylb#####################'.concat(zylb.toString()));
  297. //console.log(debh);
  298. setExpandedQd(false);
  299. setExpandedDe(true);//1 jianzhu 2 zhuangshi 3 anzhuang 4 shizheng 5 yuanlin 6 guidao 7 xiushantujian 8 xiushananzhuang 9 xiushanjiagu
  300. if (qdbm.startsWith("01")) {
  301. let suggestion = 10;
  302. if (zylb == "7") {
  303. suggestion = 50;
  304. }
  305. setZhuanye(suggestion);
  306. Service.generateSingleDingeXilie(suggestion, debh).then(x=>{
  307. //console.log(x);
  308. let res = JSON.parse(x);
  309. console.log(res);
  310. setZhuanye(res["actual_zhuanye"]);
  311. let id = res['reverse'];
  312. if (id && id != "None") {
  313. setRgde(res["rgde"]);
  314. setJxde(res["jxde"]);
  315. setClde(res["clde"]);
  316. console.log(res["rgde"]);
  317. console.log(res["jxde"]);
  318. console.log(res["clde"]);
  319. setBeizhu(res["bz_selected"]);
  320. setBeizhuFK(res["bz_selected2"]);
  321. Service.generateDingeshu(res["actual_zhuanye"]).then(x=>{
  322. setOutlineDes_(x);
  323. setSelectedItems(id);
  324. setExpandedItems(findparent(id));
  325. Service.generateDingeXilie(res["actual_zhuanye"], id).then(x=>{
  326. let y = JSON.parse(x);
  327. //console.log(y);
  328. let result = [];
  329. let keys = Object.keys(y["DW"])
  330. for(let i = 0; i < keys.length; i++) {
  331. let key = keys[i];
  332. let entry = {
  333. "id": y["DEBH"][key],
  334. "定额编号": y["DEBH"][key],
  335. "名称": y["GCLMC"][key],
  336. "单位": y["DW"][key],
  337. "单价": y["GCLSJDJ"][key]
  338. };
  339. result.push(entry);
  340. }
  341. setDeXilie(result);
  342. });
  343. });
  344. } else {
  345. setRgde(null);
  346. setJxde(null);
  347. setClde(null);
  348. setBeizhu(res["bz_selected"]);
  349. }
  350. });
  351. } else if (qdbm.startsWith("03")) {//安装
  352. let suggestion = 30;
  353. if (zylb == "8") {
  354. suggestion = 60;
  355. }
  356. setZhuanye(suggestion);
  357. Service.generateSingleDingeXilie(suggestion, debh).then(x=>{
  358. //console.log(x);
  359. let res = JSON.parse(x);
  360. console.log(res);
  361. setZhuanye(res["actual_zhuanye"]);
  362. let id = res['reverse'];
  363. if (id && id != "None") {
  364. setRgde(res["rgde"]);
  365. setJxde(res["jxde"]);
  366. setClde(res["clde"]);
  367. console.log(res["rgde"]);
  368. console.log(res["jxde"]);
  369. console.log(res["clde"]);
  370. setBeizhu(res["bz_selected"]);
  371. Service.generateDingeshu(res["actual_zhuanye"]).then(x=>{
  372. setOutlineDes_(x);
  373. setSelectedItems(id);
  374. setExpandedItems(findparent(id));
  375. Service.generateDingeXilie(res["actual_zhuanye"], id).then(x=>{
  376. let y = JSON.parse(x);
  377. //console.log(y);
  378. let result = [];
  379. let keys = Object.keys(y["DW"])
  380. for(let i = 0; i < keys.length; i++) {
  381. let key = keys[i];
  382. let entry = {
  383. "id": y["DEBH"][key],
  384. "定额编号": y["DEBH"][key],
  385. "名称": y["GCLMC"][key],
  386. "单位": y["DW"][key],
  387. "单价": y["GCLSJDJ"][key]
  388. };
  389. result.push(entry);
  390. }
  391. setDeXilie(result);
  392. });
  393. });
  394. } else {
  395. setRgde(null);
  396. setJxde(null);
  397. setClde(null);
  398. setBeizhu(res["bz_selected"]);
  399. }
  400. });
  401. } else if (qdbm.startsWith("04")) {////市政
  402. setZhuanye(20);
  403. Service.generateSingleDingeXilie(20, debh).then(x=>{
  404. //console.log(x);
  405. let res = JSON.parse(x);
  406. console.log(res);
  407. setZhuanye(res["actual_zhuanye"]);
  408. let id = res['reverse'];
  409. if (id && id != "None") {
  410. setRgde(res["rgde"]);
  411. setJxde(res["jxde"]);
  412. setClde(res["clde"]);
  413. console.log(res["rgde"]);
  414. console.log(res["jxde"]);
  415. console.log(res["clde"]);
  416. setBeizhu(res["bz_selected"]);
  417. Service.generateDingeshu(res["actual_zhuanye"]).then(x=>{
  418. setOutlineDes_(x);
  419. setSelectedItems(id);
  420. setExpandedItems(findparent(id));
  421. Service.generateDingeXilie(res["actual_zhuanye"], id).then(x=>{
  422. let y = JSON.parse(x);
  423. //console.log(y);
  424. let result = [];
  425. let keys = Object.keys(y["DW"])
  426. for(let i = 0; i < keys.length; i++) {
  427. let key = keys[i];
  428. let entry = {
  429. "id": y["DEBH"][key],
  430. "定额编号": y["DEBH"][key],
  431. "名称": y["GCLMC"][key],
  432. "单位": y["DW"][key],
  433. "单价": y["GCLSJDJ"][key]
  434. };
  435. result.push(entry);
  436. }
  437. setDeXilie(result);
  438. });
  439. });
  440. } else {
  441. setRgde(null);
  442. setJxde(null);
  443. setClde(null);
  444. setBeizhu(res["bz_selected"]);
  445. }
  446. });
  447. }
  448. else if (qdbm.startsWith("05")) {//园林
  449. setZhuanye(40);
  450. Service.generateSingleDingeXilie(40, debh).then(x=>{
  451. //console.log(x);
  452. let res = JSON.parse(x);
  453. console.log(res);
  454. setZhuanye(res["actual_zhuanye"]);
  455. let id = res['reverse'];
  456. if (id && id != "None") {
  457. setRgde(res["rgde"]);
  458. setJxde(res["jxde"]);
  459. setClde(res["clde"]);
  460. console.log(res["rgde"]);
  461. console.log(res["jxde"]);
  462. console.log(res["clde"]);
  463. setBeizhu(res["bz_selected"]);
  464. Service.generateDingeshu(res["actual_zhuanye"]).then(x=>{
  465. setOutlineDes_(x);
  466. setSelectedItems(id);
  467. setExpandedItems(findparent(id));
  468. Service.generateDingeXilie(res["actual_zhuanye"], id).then(x=>{
  469. let y = JSON.parse(x);
  470. //console.log(y);
  471. let result = [];
  472. let keys = Object.keys(y["DW"])
  473. for(let i = 0; i < keys.length; i++) {
  474. let key = keys[i];
  475. let entry = {
  476. "id": y["DEBH"][key],
  477. "定额编号": y["DEBH"][key],
  478. "名称": y["GCLMC"][key],
  479. "单位": y["DW"][key],
  480. "单价": y["GCLSJDJ"][key]
  481. };
  482. result.push(entry);
  483. }
  484. setDeXilie(result);
  485. });
  486. });
  487. } else {
  488. setRgde(null);
  489. setJxde(null);
  490. setClde(null);
  491. setBeizhu(res["bz_selected"]);
  492. }
  493. });
  494. } else {
  495. console.log('####################################zylb#####################'.concat(zylb.toString()));
  496. }
  497. };
  498. const handleEvent = (A) => {
  499. let state = {
  500. 'time': Date.now(),
  501. 'newBianhao': A.row['编号'],
  502. 'newName': A.row['名称'],
  503. 'newJia': A.row['单价'],
  504. 'old' : tihuanRowRef.current
  505. };
  506. setTihuanClick(JSON.stringify(state));
  507. setDopen(false);
  508. };
  509. const handleChangeAccord = (panel) => (event, newExpanded) => {
  510. if (panel == 'qingdan') {
  511. setExpandedQd(newExpanded);
  512. }
  513. else if (panel == 'peibi'){
  514. setExpandedPb(newExpanded);
  515. } else {
  516. setExpandedDe(newExpanded);
  517. }
  518. };
  519. const handleItemSelectionTogglePbs = (event, itemId, isSelected) => {
  520. if (isSelected) {
  521. console.log(itemId);
  522. if (["0", "3", "4", "6", "7", "8", "9", "11", "12", "13", "15", "16", "18", "19", "20", "21"].includes(itemId)) {
  523. Service.generatePeibiXilie(itemId).then(x=>{
  524. let y = JSON.parse(x);
  525. console.log(y);
  526. let result = [];
  527. let keys = Object.keys(y["PBBH"])
  528. for(let i = 0; i < keys.length; i++) {
  529. let key = keys[i];
  530. let entry = {
  531. "id": y["id"][key],
  532. "编号": y["PBBH"][key],
  533. "名称": y["PBMC"][key],
  534. "单位": y["DW"][key],
  535. "单价": y["PBDJ"][key]
  536. };
  537. result.push(entry);
  538. setPbXilie(result);
  539. }
  540. });
  541. }
  542. }
  543. }
  544. const handleDingEEvent = (row) => {
  545. Service.generateSingleDingeXilie(zhuanye, row.id).then(x=>{
  546. let res = JSON.parse(x);
  547. console.log(res);
  548. res["date"] = Date.now().toString();
  549. setDingeclick(JSON.stringify(res));
  550. });
  551. //
  552. };
  553. const handleItemSelectionToggleDes = (event, itemId, isSelected) => {
  554. if (isSelected) {
  555. //console.log(itemId);
  556. setSelectedItems(itemId);
  557. setExpandedItems(findparent(itemId));
  558. Service.generateDingeXilie(zhuanye, itemId).then(x=>{
  559. let y = JSON.parse(x);
  560. //console.log(y);
  561. let result = [];
  562. let keys = Object.keys(y["DW"])
  563. for(let i = 0; i < keys.length; i++) {
  564. let key = keys[i];
  565. let entry = {
  566. "id": y["DEBH"][key],
  567. "定额编号": y["DEBH"][key],
  568. "名称": y["GCLMC"][key],
  569. "单位": y["DW"][key],
  570. "单价": y["GCLSJDJ"][key]
  571. };
  572. result.push(entry);
  573. }
  574. setDeXilie(result);
  575. });
  576. }
  577. }
  578. const handleItemSelectionToggle = (event, itemId, isSelected) => {
  579. if (isSelected) {
  580. //console.log(itemId);
  581. let pos = itemId.indexOf("Zylb");
  582. let Zylb = itemId.substring(pos+4, pos+5);
  583. setZylb(Zylb);
  584. //console.log("Zylb=".concat(Zylb));
  585. if (itemId.includes("bao jia hui zong")) {
  586. let regex = /[0-9]*/;
  587. let id = itemId.match(regex)[0];
  588. Service.generateBaojiahuizong2(location["id"], id).then(x=>{
  589. setNestDetail(x);
  590. setNest(true);
  591. setQingdan(false);
  592. setCuoshi(false);
  593. setQufei(false);
  594. setColumnHeaders(["序号", "名称", "金额", "暂估价", "类别"]);
  595. });
  596. }
  597. else if (itemId.includes("gui fei shui jin")) {
  598. let regex = /[0-9]*/;
  599. let id = itemId.match(regex)[0];
  600. Service.generateGuifeishuijin2(location["id"], id).then(x=>{
  601. setNestDetail(x);
  602. setNest(true);
  603. setQingdan(false);
  604. setCuoshi(false);
  605. setQufei(false);
  606. setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
  607. });
  608. }
  609. else if (itemId.includes("qing dan xiang mu")) {
  610. let regex = /[0-9]*/;
  611. let id = itemId.match(regex)[0];
  612. Service.generateQingdanxiangmu2(location["id"], id).then(x=>{
  613. setValue("1");
  614. setNest(false);
  615. setQingdan(true);
  616. setCuoshi(false);
  617. setQdbt(x);
  618. setQdbh(id);
  619. setQufei(false);
  620. //setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
  621. });
  622. }
  623. else if (itemId.includes("cuo shi xiang mu")) {
  624. let regex = /[0-9]*/;
  625. let id = itemId.match(regex)[0];
  626. setValue("1");
  627. setNest(false);
  628. setQingdan(false);
  629. setCuoshi(true);
  630. setDwgc(id);
  631. setQufei(false);
  632. //setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
  633. }
  634. else if (itemId.includes("qi ta xiang mu")) {
  635. let regex = /[0-9]*/;
  636. let id = itemId.match(regex)[0];
  637. setValue("1");
  638. //setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
  639. Service.generateQitaxiangmu2(location["id"], id).then(x=>{
  640. setNestDetail(x);
  641. setNest(true);
  642. setQingdan(false);
  643. setCuoshi(false);
  644. setQufei(false);
  645. setColumnHeaders(["序号", "名称", "金额", "项目类别", "备注"]);
  646. });
  647. }
  648. else if (itemId.includes("zan lie jin e")) {
  649. let regex = /[0-9]*/;
  650. let id = itemId.match(regex)[0];
  651. setValue("1");
  652. //setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
  653. Service.generateZanliejine2(location["id"], id).then(x=>{
  654. setDetail(x);
  655. setNest(false);
  656. setQingdan(false);
  657. setCuoshi(false);
  658. setQufei(false);
  659. });
  660. }
  661. else if (itemId.includes("ji ri gong")) {
  662. let regex = /[0-9]*/;
  663. let id = itemId.match(regex)[0];
  664. setValue("1");
  665. //setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
  666. Service.generateJirigong2(location["id"], id).then(x=>{
  667. setDetail(x);
  668. setNest(false);
  669. setQingdan(false);
  670. setCuoshi(false);
  671. setQufei(false);
  672. });
  673. }
  674. else if (itemId.includes("zong cheng bao fu wu fei")) {
  675. let regex = /[0-9]*/;
  676. let id = itemId.match(regex)[0];
  677. setValue("1");
  678. //setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
  679. Service.generateZongchengbaofuwufei2(location["id"], id).then(x=>{
  680. setDetail(x);
  681. setNest(false);
  682. setQingdan(false);
  683. setCuoshi(false);
  684. setQufei(false);
  685. });
  686. }
  687. else if (itemId.includes("fa bao ren gong ying cai liao")) {
  688. let regex = /[0-9]*/;
  689. let id = itemId.match(regex)[0];
  690. setValue("1");
  691. //setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
  692. Service.generateFabaorengongyingcailiao2(location["id"], id).then(x=>{
  693. setDetail(x);
  694. setNest(false);
  695. setQingdan(false);
  696. setCuoshi(false);
  697. setQufei(false);
  698. });
  699. }
  700. else if (itemId.includes("ren cai ji hui zong")) {
  701. let regex = /[0-9]*/;
  702. let id = itemId.match(regex)[0];
  703. setValue("1");
  704. //setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
  705. Service.generateRencaijihuizong2(location["id"], id).then(x=>{
  706. setDetail(x);
  707. setNest(false);
  708. setQingdan(false);
  709. setCuoshi(false);
  710. setQufei(false);
  711. });
  712. }
  713. else if (itemId.includes("TouBiaoXx")) {
  714. Service.generateDetail2(location["id"]).then(x=>{
  715. setQingdan(false);
  716. setCuoshi(false);
  717. setDetail(x);
  718. setNest(false);
  719. setQufei(false);
  720. });
  721. }
  722. }
  723. };
  724. React.useEffect(
  725. () => {
  726. console.log(location);
  727. Service.generateQufei(location["id"]).then(x=>{
  728. Service.setQufei(x);
  729. });
  730. Service.generateOutline2(location["id"]).then(x=>{
  731. setOutline(x);
  732. });
  733. Service.generateDetail2(location['id']).then(x=>{
  734. setDetail(x);
  735. });
  736. Service.generateDingeshu(10).then(x=>{
  737. setOutlineDes_(x);
  738. });
  739. }, [location]
  740. );
  741. React.useEffect(
  742. () => {
  743. Service.generatePeibishu(zhuanye).then(x=>{
  744. setPeibishu(x);
  745. });
  746. }, [zhuanye]
  747. );
  748. return (
  749. <Box sx={{ flexGrow: 1 }}>
  750. <Grid container spacing={2}>
  751. <Grid size={3}>
  752. <Accordion expanded={expandedQd} disableGutters
  753. onChange={handleChangeAccord('qingdan')}>
  754. <AccordionSummary
  755. expandIcon={<ExpandMoreIcon />}
  756. aria-controls="panel1-content"
  757. id="panel1-header"
  758. >
  759. <Typography component="span">清单</Typography>
  760. </AccordionSummary>
  761. <AccordionDetails>
  762. <RichTreeView sx={{overflow: "scroll", maxHeight: "90vh"}}
  763. onItemSelectionToggle={handleItemSelectionToggle}
  764. slots={{ item: CustomTreeItem }}
  765. items={outline}/>
  766. </AccordionDetails>
  767. </Accordion>
  768. <Accordion expanded={expandedDe} disableGutters
  769. onChange={handleChangeAccord('dinge')}>
  770. <AccordionSummary
  771. expandIcon={<ExpandMoreIcon />}
  772. aria-controls="panel1-content"
  773. id="panel1-header"
  774. >
  775. <Typography component="span">定额</Typography>
  776. </AccordionSummary>
  777. <AccordionDetails>
  778. <FormControl size="small">
  779. <InputLabel id="demo-multiple-name-label">专业</InputLabel>
  780. <Select
  781. labelId="demo-multiple-name-label"
  782. id="demo-multiple-name"
  783. value={zhuanye}
  784. onChange={handleChangeZhuanye}
  785. label="专业"
  786. >
  787. <MenuItem value={10}>土建</MenuItem>
  788. <MenuItem value={20}>市政</MenuItem>
  789. <MenuItem value={30}>安装</MenuItem>
  790. <MenuItem value={40}>园林</MenuItem>
  791. <MenuItem value={50}>修缮(土建)</MenuItem>
  792. <MenuItem value={60}>修缮(安装)</MenuItem>
  793. </Select>
  794. </FormControl>
  795. <Stack spacing={1}>
  796. <RichTreeView sx={{overflow: "scroll", maxHeight: `calc(100vh - 540px)`}}
  797. onItemSelectionToggle={handleItemSelectionToggleDes}
  798. slots={{ item: CustomTreeItem }}
  799. selectedItems={selectedItems}
  800. expandedItems={expandedItems}
  801. items={outlineDes}/>
  802. <div style={{ height: 350 }}>
  803. <DataGrid
  804. sx={{
  805. '& .MuiDataGrid-cell': {
  806. fontSize: '0.8rem', // Adjust font size for cells
  807. },
  808. /* '& .MuiDataGrid-columnHeaders': {
  809. fontSize: '1rem', // Adjust font size for column headers
  810. },*/
  811. }}
  812. getRowHeight={() => 'auto'}
  813. rows={deXilie}
  814. columns={columns}
  815. hideFooter={true}
  816. onRowDoubleClick={handleDingEEvent}
  817. />
  818. </div>
  819. </Stack>
  820. </AccordionDetails>
  821. </Accordion>
  822. <Button variant="outlined" fullWidth onClick={()=> {
  823. setQufei(true);
  824. setQingdan(false);
  825. setCuoshi(false);
  826. }}>费率</Button>
  827. </Grid>
  828. <Grid size={9}>
  829. {!nest && !qingdan && !cuoshi && !qufei && <HotTable nestedRows={false}
  830. data={detail
  831. }
  832. rowHeaders={true}
  833. colHeaders={true}
  834. fixedRowsTop={1}
  835. height="800"
  836. readOnly={true}
  837. autoWrapRow={false}
  838. autoWrapCol={false}
  839. licenseKey="non-commercial-and-evaluation" // for non-commercial use only
  840. />}
  841. {nest && !qingdan && !cuoshi && !qufei && <HotTable nestedRows={true}
  842. data={nestDetail
  843. }
  844. readOnly={true}
  845. fixedRowsTop={1}
  846. rowHeaders={true}
  847. colHeaders={columnHeaders}
  848. height="auto"
  849. contextMenu={true}
  850. bindRowsWithHeaders={true}
  851. autoWrapRow={false}
  852. autoWrapCol={false}
  853. licenseKey="non-commercial-and-evaluation" // for non-commercial use only
  854. />}
  855. {!qingdan && !cuoshi && qufei && <Qufei id={location['id']} qufeiCallback={qufeiCallback}
  856. />}
  857. {!nest && qingdan && !cuoshi && !qufei && <TabContext value={value}>
  858. <Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
  859. <TabList scrollButtons='auto'
  860. variant="scrollable"
  861. sx={{minHeight: '24px'}}
  862. onChange={handleChange} aria-label="lab API tabs example">
  863. {qdbt.map((x, index)=> <Tab sx={{p: 0, minHeight: '24px'}} label={x} value={(index+1).toString()} />)}
  864. </TabList>
  865. </Box>
  866. {qdbt.map((x, index)=><TabPanel sx={{p: 1}} value={(index+1).toString()}>
  867. <Qingdan2
  868. name={location["id"]}
  869. bh={qdbh}
  870. bt={x}
  871. rgde={rgde}
  872. jxde={jxde}
  873. clde={clde}
  874. beizhu={beizhu}
  875. beizhuFK={beizhuFK}
  876. clickCallback={clickCallback}
  877. loadingCallback={loadingCallback}
  878. dingeclick={dingeclick}
  879. tihuanCallback={tihuanCallback}
  880. tihuanClick={tihuanClick}
  881. />
  882. </TabPanel>
  883. )}
  884. </TabContext>}
  885. {!nest && !qingdan && cuoshi && !qufei && <TabContext value={value}>
  886. <Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
  887. <TabList scrollButtons='auto'
  888. variant="scrollable"
  889. sx={{minHeight: '24px'}}
  890. onChange={handleChange} aria-label="lab API tabs example">
  891. <Tab sx={{p: 0, minHeight: '24px'}} label="总价措施" value="1" />
  892. <Tab sx={{p: 0, minHeight: '24px'}} label="单价措施" value="2" />
  893. </TabList>
  894. </Box>
  895. <TabPanel sx={{p: 1}} value="1">
  896. <Zjcs name={location["id"]} bh={dwgc}/>
  897. </TabPanel>
  898. <TabPanel sx={{p: 1}} value="2">
  899. <Djcs2
  900. name={location["id"]}
  901. bh={dwgc}
  902. rgde={rgde}
  903. jxde={jxde}
  904. clde={clde}
  905. beizhu={beizhu}
  906. clickCallback={clickCallback}
  907. loadingCallback={loadingCallback_djcs}
  908. dingeclick={dingeclick}
  909. beizhuFK={beizhuFK}
  910. />
  911. </TabPanel>
  912. </TabContext>}
  913. </Grid>
  914. </Grid>
  915. <Backdrop
  916. sx={(theme) => ({ color: '#fff', zIndex: theme.zIndex.drawer + 1 })}
  917. open={open}
  918. >
  919. <CircularProgress color="inherit" />
  920. </Backdrop>
  921. <Dialog
  922. onClose={handleClose}
  923. aria-labelledby="customized-dialog-title"
  924. open={dopen}
  925. fullWidth={true}
  926. maxWidth="md"
  927. >
  928. <DialogTitle sx={{ m: 0, p: 2 }} id="customized-dialog-title">
  929. 替换
  930. </DialogTitle>
  931. <IconButton
  932. aria-label="close"
  933. onClick={handleClose}
  934. sx={(theme) => ({
  935. position: 'absolute',
  936. right: 8,
  937. top: 8,
  938. color: theme.palette.grey[500],
  939. })}
  940. >
  941. <CloseIcon />
  942. </IconButton>
  943. <DialogContent dividers>
  944. <Stack direction="row" spacing={2}>
  945. <RichTreeView sx={{
  946. overflow: "scroll",
  947. maxHeight: "350px",
  948. minWidth: "250px"
  949. }}
  950. slots={{ item: CustomTreeItem }}
  951. onItemSelectionToggle={handleItemSelectionTogglePbs}
  952. items={peibishu}/>
  953. <div style={{ height: 350 }}>
  954. <DataGrid disableColumnMenu
  955. sx={{
  956. '& .MuiDataGrid-cell': {
  957. fontSize: '0.8rem', // Adjust font size for cells
  958. }}}
  959. getRowHeight={() => 'auto'}
  960. rows={pbXilie}
  961. onRowDoubleClick={handleEvent}
  962. columns={columns2}
  963. hideFooter={false}
  964. disableColumnFilter
  965. disableColumnSelector
  966. disableDensitySelector
  967. showToolbar
  968. slots={{ toolbar: CustomToolbar }}
  969. localeText={{
  970. noRowsLabel: '无数据',
  971. paginationRowsPerPage: '每页行数',
  972. footerRowSelected: (count) => `共选中了${count.toLocaleString()}行`,
  973. }}
  974. />
  975. </div>
  976. </Stack>
  977. </DialogContent>
  978. </Dialog>
  979. </Box>
  980. );
  981. }