App2.js 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864
  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 { HandsonTable } from 'handsontable/base';
  7. import {HotTable} from "@handsontable/react";
  8. import { registerAllModules } from 'handsontable/registry';
  9. import {RichTreeView } from "@mui/x-tree-view/RichTreeView";
  10. import { Grid } from '@mui/material';
  11. import Tab from "@mui/material/Tab";
  12. import TabContext from "@mui/lab/TabContext";
  13. import TabList from "@mui/lab/TabList";
  14. import TabPanel from "@mui/lab/TabPanel";
  15. //import { registerPlugin, NestedRows } from 'handsontable/plugins';
  16. //registerPlugin(NestedRows);
  17. import Qingdan from './Qingdan';
  18. import Zjcs from './Zjcs';
  19. import Djcs from './Djcs';
  20. import Service from './Service';
  21. import {useLocation, useParams} from "react-router";
  22. import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
  23. import Typography from '@mui/material/Typography';
  24. import InputLabel from '@mui/material/InputLabel';
  25. import MenuItem from '@mui/material/MenuItem';
  26. import FormControl from '@mui/material/FormControl';
  27. import Select from '@mui/material/Select';
  28. import Accordion from '@mui/material/Accordion';
  29. import AccordionActions from '@mui/material/AccordionActions';
  30. import AccordionSummary from '@mui/material/AccordionSummary';
  31. import AccordionDetails from '@mui/material/AccordionDetails';
  32. import Stack from '@mui/material/Stack';
  33. import { DataGrid } from '@mui/x-data-grid';
  34. import Backdrop from '@mui/material/Backdrop';
  35. import CircularProgress from '@mui/material/CircularProgress';
  36. import { TreeItem, treeItemClasses } from '@mui/x-tree-view/TreeItem';
  37. registerAllModules();
  38. const MUI_X_PRODUCTS = [
  39. {
  40. id: 'grid',
  41. label: 'Data Grid',
  42. children: [
  43. { id: 'grid-community', label: '@mui/x-data-grid' },
  44. { id: 'grid-pro', label: '@mui/x-data-grid-pro' },
  45. { id: 'grid-premium', label: '@mui/x-data-grid-premium' },
  46. ],
  47. },
  48. {
  49. id: 'pickers',
  50. label: 'Date and Time Pickers',
  51. children: [
  52. { id: 'pickers-community', label: '@mui/x-date-pickers' },
  53. { id: 'pickers-pro', label: '@mui/x-date-pickers-pro' },
  54. ],
  55. },
  56. {
  57. id: 'charts',
  58. label: 'Charts',
  59. children: [
  60. { id: 'charts-community', label: '@mui/x-charts' },
  61. { id: 'charts-pro', label: '@mui/charts-pro' },
  62. ],
  63. },
  64. {
  65. id: 'tree-view',
  66. label: 'Tree View',
  67. children: [
  68. { id: 'tree-view-community', label: '@mui/x-tree-view' },
  69. { id: 'tree-view-pro', label: '@mui/x-tree-view-pro' },
  70. ],
  71. },
  72. ];
  73. const INFO = [
  74. ['名称', '金额', '暂估价', '安全文明施工费', '规费'],
  75. ];
  76. const CustomTreeItem = styled(TreeItem)(({ theme }) => ({
  77. [`& .${treeItemClasses.content}`]: {
  78. padding: theme.spacing(0.5, 1),
  79. margin: theme.spacing(0.2, 0),
  80. [`& .${treeItemClasses.label}`]: {
  81. fontSize: '0.8rem',
  82. fontWeight: 500,
  83. },
  84. }
  85. }));
  86. export default function App2() {
  87. const [outline, setOutline] = React.useState([]);
  88. const [peibishu, setPeibishu] = React.useState([]);
  89. const [outlineDes, setOutlineDes] = React.useState([]);
  90. const [columnHeaders, setColumnHeaders] = React.useState([]);
  91. const [detail, setDetail] = React.useState(INFO);
  92. const [deXilie, setDeXilie] = React.useState([]);
  93. const [pbXilie, setPbXilie] = React.useState([]);
  94. const [nestDetail, setNestDetail] = React.useState(INFO);
  95. const [nest, setNest] = React.useState(false);
  96. const [qingdan, setQingdan] = React.useState(false);
  97. const [cuoshi, setCuoshi] = React.useState(false);
  98. const [qdbt, setQdbt] = React.useState([]);
  99. const [qdbh, setQdbh] = React.useState(null);
  100. const [value, setValue] = React.useState('1');
  101. const [dwgc, setDwgc] = React.useState(null);
  102. const [zhuanye, setZhuanye] = React.useState(10);
  103. const [expandedQd, setExpandedQd] = React.useState(true);
  104. const [expandedPb, setExpandedPb] = React.useState(false);
  105. const [expandedDe, setExpandedDe] = React.useState(false);
  106. const [zylb, setZylb] = React.useState('');
  107. const [selectedItems, setSelectedItems] = React.useState(null);
  108. const [expandedItems, setExpandedItems] = React.useState([]);
  109. const [rgde, setRgde] = React.useState(null);
  110. const [beizhu, setBeizhu] = React.useState(null);
  111. const [beizhuFK, setBeizhuFK] = React.useState(null);
  112. const [clde, setClde] = React.useState(null);
  113. const [jxde, setJxde] = React.useState(null);
  114. const [open, setOpen] = React.useState(false);
  115. const [dingeclick, setDingeclick] = React.useState(null);
  116. const relation = React.useRef({});
  117. const columns =[
  118. {field: '定额编号', headerName: '定额编号'},
  119. {field: '名称', headerName: '名称'},
  120. {field: '单位', headerName: '单位'},
  121. {field: '单价', headerName: '单价'}
  122. ];
  123. const columns2 =[
  124. {field: '编号', headerName: '定额编号'},
  125. {field: '名称', headerName: '名称'},
  126. {field: '单位', headerName: '单位'},
  127. {field: '单价', headerName: '单价'}
  128. ];
  129. let location = useParams();
  130. const traverse = (shu) => {
  131. for(let i = 0; i < shu.length; i++) {
  132. let id = shu[i]["id"];
  133. let children = shu[i]["children"];
  134. for (let j = 0; j < children.length; j++) {
  135. let id2 = children[j]["id"];
  136. relation.current[id2]=id;
  137. }
  138. traverse(children);
  139. }
  140. };
  141. const setOutlineDes_ = (x) => {
  142. setOutlineDes(x);
  143. relation.current = {};
  144. traverse(x);
  145. };
  146. const handleChangeZhuanye = (event) => {
  147. //console.log(event.target.value);
  148. Service.generateDingeshu(event.target.value).then(x=>{
  149. setOutlineDes_(x);
  150. });
  151. setZhuanye(event.target.value);
  152. };
  153. const handleChange = (event, newValue) => {
  154. setValue(newValue);
  155. };
  156. const findparent = (id) => {
  157. let result = [];
  158. while(id) {
  159. result.push(id);
  160. id = relation.current[id];
  161. }
  162. return result;
  163. };
  164. const loadingCallback = () => {
  165. setOpen(true);
  166. Service.save().then(x=>{
  167. setOpen(false);
  168. });
  169. };
  170. const clickCallback = (qdbm, debh) => {
  171. console.log('####################################zylb#####################'.concat(zylb.toString()));
  172. //console.log(debh);
  173. setExpandedQd(false);
  174. setExpandedDe(true);//1 jianzhu 2 zhuangshi 3 anzhuang 4 shizheng 5 yuanlin 6 guidao 7 xiushantujian 8 xiushananzhuang 9 xiushanjiagu
  175. if (qdbm.startsWith("01")) {
  176. let suggestion = 10;
  177. if (zylb == "7") {
  178. suggestion = 50;
  179. }
  180. setZhuanye(suggestion);
  181. Service.generateSingleDingeXilie(suggestion, debh).then(x=>{
  182. //console.log(x);
  183. let res = JSON.parse(x);
  184. console.log(res);
  185. setZhuanye(res["actual_zhuanye"]);
  186. let id = res['reverse'];
  187. if (id && id != "None") {
  188. setRgde(res["rgde"]);
  189. setJxde(res["jxde"]);
  190. setClde(res["clde"]);
  191. console.log(res["rgde"]);
  192. console.log(res["jxde"]);
  193. console.log(res["clde"]);
  194. setBeizhu(res["bz_selected"]);
  195. setBeizhuFK(res["bz_selected2"]);
  196. Service.generateDingeshu(res["actual_zhuanye"]).then(x=>{
  197. setOutlineDes_(x);
  198. setSelectedItems(id);
  199. setExpandedItems(findparent(id));
  200. Service.generateDingeXilie(res["actual_zhuanye"], id).then(x=>{
  201. let y = JSON.parse(x);
  202. //console.log(y);
  203. let result = [];
  204. let keys = Object.keys(y["DW"])
  205. for(let i = 0; i < keys.length; i++) {
  206. let key = keys[i];
  207. let entry = {
  208. "id": y["DEBH"][key],
  209. "定额编号": y["DEBH"][key],
  210. "名称": y["GCLMC"][key],
  211. "单位": y["DW"][key],
  212. "单价": y["GCLSJDJ"][key]
  213. };
  214. result.push(entry);
  215. }
  216. setDeXilie(result);
  217. });
  218. });
  219. } else {
  220. setRgde(null);
  221. setJxde(null);
  222. setClde(null);
  223. setBeizhu(res["bz_selected"]);
  224. }
  225. });
  226. } else if (qdbm.startsWith("03")) {//安装
  227. let suggestion = 30;
  228. if (zylb == "8") {
  229. suggestion = 60;
  230. }
  231. setZhuanye(suggestion);
  232. Service.generateSingleDingeXilie(suggestion, debh).then(x=>{
  233. //console.log(x);
  234. let res = JSON.parse(x);
  235. console.log(res);
  236. setZhuanye(res["actual_zhuanye"]);
  237. let id = res['reverse'];
  238. if (id && id != "None") {
  239. setRgde(res["rgde"]);
  240. setJxde(res["jxde"]);
  241. setClde(res["clde"]);
  242. console.log(res["rgde"]);
  243. console.log(res["jxde"]);
  244. console.log(res["clde"]);
  245. setBeizhu(res["bz_selected"]);
  246. Service.generateDingeshu(res["actual_zhuanye"]).then(x=>{
  247. setOutlineDes_(x);
  248. setSelectedItems(id);
  249. setExpandedItems(findparent(id));
  250. Service.generateDingeXilie(res["actual_zhuanye"], id).then(x=>{
  251. let y = JSON.parse(x);
  252. //console.log(y);
  253. let result = [];
  254. let keys = Object.keys(y["DW"])
  255. for(let i = 0; i < keys.length; i++) {
  256. let key = keys[i];
  257. let entry = {
  258. "id": y["DEBH"][key],
  259. "定额编号": y["DEBH"][key],
  260. "名称": y["GCLMC"][key],
  261. "单位": y["DW"][key],
  262. "单价": y["GCLSJDJ"][key]
  263. };
  264. result.push(entry);
  265. }
  266. setDeXilie(result);
  267. });
  268. });
  269. } else {
  270. setRgde(null);
  271. setJxde(null);
  272. setClde(null);
  273. setBeizhu(res["bz_selected"]);
  274. }
  275. });
  276. } else if (qdbm.startsWith("04")) {////市政
  277. setZhuanye(20);
  278. Service.generateSingleDingeXilie(20, debh).then(x=>{
  279. //console.log(x);
  280. let res = JSON.parse(x);
  281. console.log(res);
  282. setZhuanye(res["actual_zhuanye"]);
  283. let id = res['reverse'];
  284. if (id && id != "None") {
  285. setRgde(res["rgde"]);
  286. setJxde(res["jxde"]);
  287. setClde(res["clde"]);
  288. console.log(res["rgde"]);
  289. console.log(res["jxde"]);
  290. console.log(res["clde"]);
  291. setBeizhu(res["bz_selected"]);
  292. Service.generateDingeshu(res["actual_zhuanye"]).then(x=>{
  293. setOutlineDes_(x);
  294. setSelectedItems(id);
  295. setExpandedItems(findparent(id));
  296. Service.generateDingeXilie(res["actual_zhuanye"], id).then(x=>{
  297. let y = JSON.parse(x);
  298. //console.log(y);
  299. let result = [];
  300. let keys = Object.keys(y["DW"])
  301. for(let i = 0; i < keys.length; i++) {
  302. let key = keys[i];
  303. let entry = {
  304. "id": y["DEBH"][key],
  305. "定额编号": y["DEBH"][key],
  306. "名称": y["GCLMC"][key],
  307. "单位": y["DW"][key],
  308. "单价": y["GCLSJDJ"][key]
  309. };
  310. result.push(entry);
  311. }
  312. setDeXilie(result);
  313. });
  314. });
  315. } else {
  316. setRgde(null);
  317. setJxde(null);
  318. setClde(null);
  319. setBeizhu(res["bz_selected"]);
  320. }
  321. });
  322. }
  323. else if (qdbm.startsWith("05")) {//园林
  324. setZhuanye(40);
  325. Service.generateSingleDingeXilie(40, debh).then(x=>{
  326. //console.log(x);
  327. let res = JSON.parse(x);
  328. console.log(res);
  329. setZhuanye(res["actual_zhuanye"]);
  330. let id = res['reverse'];
  331. if (id && id != "None") {
  332. setRgde(res["rgde"]);
  333. setJxde(res["jxde"]);
  334. setClde(res["clde"]);
  335. console.log(res["rgde"]);
  336. console.log(res["jxde"]);
  337. console.log(res["clde"]);
  338. setBeizhu(res["bz_selected"]);
  339. Service.generateDingeshu(res["actual_zhuanye"]).then(x=>{
  340. setOutlineDes_(x);
  341. setSelectedItems(id);
  342. setExpandedItems(findparent(id));
  343. Service.generateDingeXilie(res["actual_zhuanye"], id).then(x=>{
  344. let y = JSON.parse(x);
  345. //console.log(y);
  346. let result = [];
  347. let keys = Object.keys(y["DW"])
  348. for(let i = 0; i < keys.length; i++) {
  349. let key = keys[i];
  350. let entry = {
  351. "id": y["DEBH"][key],
  352. "定额编号": y["DEBH"][key],
  353. "名称": y["GCLMC"][key],
  354. "单位": y["DW"][key],
  355. "单价": y["GCLSJDJ"][key]
  356. };
  357. result.push(entry);
  358. }
  359. setDeXilie(result);
  360. });
  361. });
  362. } else {
  363. setRgde(null);
  364. setJxde(null);
  365. setClde(null);
  366. setBeizhu(res["bz_selected"]);
  367. }
  368. });
  369. } else {
  370. console.log('####################################zylb#####################'.concat(zylb.toString()));
  371. }
  372. };
  373. const handleChangeAccord = (panel) => (event, newExpanded) => {
  374. if (panel == 'qingdan') {
  375. setExpandedQd(newExpanded);
  376. }
  377. else if (panel == 'peibi'){
  378. setExpandedPb(newExpanded);
  379. } else {
  380. setExpandedDe(newExpanded);
  381. }
  382. };
  383. const handleItemSelectionTogglePbs = (event, itemId, isSelected) => {
  384. if (isSelected) {
  385. console.log(itemId);
  386. if (["3", "4", "6", "7", "8", "9", "11", "12", "13", "15", "16", "18", "19", "20", "21"].includes(itemId)) {
  387. Service.generatePeibiXilie(itemId).then(x=>{
  388. let y = JSON.parse(x);
  389. console.log(y);
  390. let result = [];
  391. let keys = Object.keys(y["PBBH"])
  392. for(let i = 0; i < keys.length; i++) {
  393. let key = keys[i];
  394. let entry = {
  395. "id": y["id"][key],
  396. "编号": y["PBBH"][key],
  397. "名称": y["PBMC"][key],
  398. "单位": y["DW"][key],
  399. "单价": y["PBDJ"][key]
  400. };
  401. result.push(entry);
  402. setPbXilie(result);
  403. }
  404. });
  405. }
  406. }
  407. }
  408. const handleDingEEvent = (row) => {
  409. Service.generateSingleDingeXilie(zhuanye, row.id).then(x=>{
  410. let res = JSON.parse(x);
  411. console.log(res);
  412. res["date"] = Date.now().toString();
  413. setDingeclick(JSON.stringify(res));
  414. });
  415. //
  416. };
  417. const handleItemSelectionToggleDes = (event, itemId, isSelected) => {
  418. if (isSelected) {
  419. //console.log(itemId);
  420. setSelectedItems(itemId);
  421. setExpandedItems(findparent(itemId));
  422. Service.generateDingeXilie(zhuanye, itemId).then(x=>{
  423. let y = JSON.parse(x);
  424. //console.log(y);
  425. let result = [];
  426. let keys = Object.keys(y["DW"])
  427. for(let i = 0; i < keys.length; i++) {
  428. let key = keys[i];
  429. let entry = {
  430. "id": y["DEBH"][key],
  431. "定额编号": y["DEBH"][key],
  432. "名称": y["GCLMC"][key],
  433. "单位": y["DW"][key],
  434. "单价": y["GCLSJDJ"][key]
  435. };
  436. result.push(entry);
  437. }
  438. setDeXilie(result);
  439. });
  440. }
  441. }
  442. const handleItemSelectionToggle = (event, itemId, isSelected) => {
  443. if (isSelected) {
  444. //console.log(itemId);
  445. let pos = itemId.indexOf("Zylb");
  446. let Zylb = itemId.substring(pos+4, pos+5);
  447. setZylb(Zylb);
  448. //console.log("Zylb=".concat(Zylb));
  449. if (itemId.includes("bao jia hui zong")) {
  450. let regex = /[0-9]*/;
  451. let id = itemId.match(regex)[0];
  452. Service.generateBaojiahuizong2(location["id"], id).then(x=>{
  453. setNestDetail(x);
  454. setNest(true);
  455. setQingdan(false);
  456. setCuoshi(false);
  457. setColumnHeaders(["序号", "名称", "金额", "暂估价", "类别"]);
  458. });
  459. }
  460. else if (itemId.includes("gui fei shui jin")) {
  461. let regex = /[0-9]*/;
  462. let id = itemId.match(regex)[0];
  463. Service.generateGuifeishuijin2(location["id"], id).then(x=>{
  464. setNestDetail(x);
  465. setNest(true);
  466. setQingdan(false);
  467. setCuoshi(false);
  468. setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
  469. });
  470. }
  471. else if (itemId.includes("qing dan xiang mu")) {
  472. let regex = /[0-9]*/;
  473. let id = itemId.match(regex)[0];
  474. Service.generateQingdanxiangmu2(location["id"], id).then(x=>{
  475. setValue("1");
  476. setNest(false);
  477. setQingdan(true);
  478. setCuoshi(false);
  479. setQdbt(x);
  480. setQdbh(id);
  481. //setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
  482. });
  483. }
  484. else if (itemId.includes("cuo shi xiang mu")) {
  485. let regex = /[0-9]*/;
  486. let id = itemId.match(regex)[0];
  487. setValue("1");
  488. setNest(false);
  489. setQingdan(false);
  490. setCuoshi(true);
  491. setDwgc(id);
  492. //setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
  493. }
  494. else if (itemId.includes("qi ta xiang mu")) {
  495. let regex = /[0-9]*/;
  496. let id = itemId.match(regex)[0];
  497. setValue("1");
  498. //setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
  499. Service.generateQitaxiangmu2(location["id"], id).then(x=>{
  500. setNestDetail(x);
  501. setNest(true);
  502. setQingdan(false);
  503. setCuoshi(false);
  504. setColumnHeaders(["序号", "名称", "金额", "项目类别", "备注"]);
  505. });
  506. }
  507. else if (itemId.includes("zan lie jin e")) {
  508. let regex = /[0-9]*/;
  509. let id = itemId.match(regex)[0];
  510. setValue("1");
  511. //setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
  512. Service.generateZanliejine2(location["id"], id).then(x=>{
  513. setDetail(x);
  514. setNest(false);
  515. setQingdan(false);
  516. setCuoshi(false);
  517. });
  518. }
  519. else if (itemId.includes("ji ri gong")) {
  520. let regex = /[0-9]*/;
  521. let id = itemId.match(regex)[0];
  522. setValue("1");
  523. //setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
  524. Service.generateJirigong2(location["id"], id).then(x=>{
  525. setDetail(x);
  526. setNest(false);
  527. setQingdan(false);
  528. setCuoshi(false);
  529. });
  530. }
  531. else if (itemId.includes("zong cheng bao fu wu fei")) {
  532. let regex = /[0-9]*/;
  533. let id = itemId.match(regex)[0];
  534. setValue("1");
  535. //setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
  536. Service.generateZongchengbaofuwufei2(location["id"], id).then(x=>{
  537. setDetail(x);
  538. setNest(false);
  539. setQingdan(false);
  540. setCuoshi(false);
  541. });
  542. }
  543. else if (itemId.includes("fa bao ren gong ying cai liao")) {
  544. let regex = /[0-9]*/;
  545. let id = itemId.match(regex)[0];
  546. setValue("1");
  547. //setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
  548. Service.generateFabaorengongyingcailiao2(location["id"], id).then(x=>{
  549. setDetail(x);
  550. setNest(false);
  551. setQingdan(false);
  552. setCuoshi(false);
  553. });
  554. }
  555. else if (itemId.includes("ren cai ji hui zong")) {
  556. let regex = /[0-9]*/;
  557. let id = itemId.match(regex)[0];
  558. setValue("1");
  559. //setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
  560. Service.generateRencaijihuizong2(location["id"], id).then(x=>{
  561. setDetail(x);
  562. setNest(false);
  563. setQingdan(false);
  564. setCuoshi(false);
  565. });
  566. }
  567. else if (itemId.includes("TouBiaoXx")) {
  568. Service.generateDetail2(location["id"]).then(x=>{
  569. setQingdan(false);
  570. setCuoshi(false);
  571. setDetail(x);
  572. setNest(false);
  573. });
  574. }
  575. }
  576. };
  577. React.useEffect(
  578. () => {
  579. console.log(location);
  580. Service.generateOutline2(location["id"]).then(x=>{
  581. setOutline(x);
  582. });
  583. Service.generateDetail2(location['id']).then(x=>{
  584. setDetail(x);
  585. });
  586. Service.generateDingeshu(10).then(x=>{
  587. setOutlineDes_(x);
  588. });
  589. }, [location]
  590. );
  591. React.useEffect(
  592. () => {
  593. Service.generatePeibishu(zhuanye).then(x=>{
  594. setPeibishu(x);
  595. });
  596. }, [zhuanye]
  597. );
  598. return (
  599. <Box sx={{ flexGrow: 1 }}>
  600. <Grid container spacing={2}>
  601. <Grid size={3}>
  602. <Accordion expanded={expandedQd} disableGutters
  603. onChange={handleChangeAccord('qingdan')}>
  604. <AccordionSummary
  605. expandIcon={<ExpandMoreIcon />}
  606. aria-controls="panel1-content"
  607. id="panel1-header"
  608. >
  609. <Typography component="span">清单</Typography>
  610. </AccordionSummary>
  611. <AccordionDetails>
  612. <RichTreeView sx={{overflow: "scroll", maxHeight: "90vh"}}
  613. onItemSelectionToggle={handleItemSelectionToggle}
  614. slots={{ item: CustomTreeItem }}
  615. items={outline}/>
  616. </AccordionDetails>
  617. </Accordion>
  618. <Accordion expanded={expandedDe} disableGutters
  619. onChange={handleChangeAccord('dinge')}>
  620. <AccordionSummary
  621. expandIcon={<ExpandMoreIcon />}
  622. aria-controls="panel1-content"
  623. id="panel1-header"
  624. >
  625. <Typography component="span">定额</Typography>
  626. </AccordionSummary>
  627. <AccordionDetails>
  628. <FormControl size="small">
  629. <InputLabel id="demo-multiple-name-label">专业</InputLabel>
  630. <Select
  631. labelId="demo-multiple-name-label"
  632. id="demo-multiple-name"
  633. value={zhuanye}
  634. onChange={handleChangeZhuanye}
  635. label="专业"
  636. >
  637. <MenuItem value={10}>土建</MenuItem>
  638. <MenuItem value={20}>市政</MenuItem>
  639. <MenuItem value={30}>安装</MenuItem>
  640. <MenuItem value={40}>园林</MenuItem>
  641. <MenuItem value={50}>修缮(土建)</MenuItem>
  642. <MenuItem value={60}>修缮(安装)</MenuItem>
  643. </Select>
  644. </FormControl>
  645. <Stack spacing={1}>
  646. <RichTreeView sx={{overflow: "scroll", maxHeight: "48vh"}}
  647. onItemSelectionToggle={handleItemSelectionToggleDes}
  648. slots={{ item: CustomTreeItem }}
  649. selectedItems={selectedItems}
  650. expandedItems={expandedItems}
  651. items={outlineDes}/>
  652. <div style={{ height: 350 }}>
  653. <DataGrid
  654. sx={{
  655. '& .MuiDataGrid-cell': {
  656. fontSize: '0.8rem', // Adjust font size for cells
  657. },
  658. /* '& .MuiDataGrid-columnHeaders': {
  659. fontSize: '1rem', // Adjust font size for column headers
  660. },*/
  661. }}
  662. getRowHeight={() => 'auto'}
  663. rows={deXilie}
  664. columns={columns}
  665. hideFooter={true}
  666. onRowDoubleClick={handleDingEEvent}
  667. />
  668. </div>
  669. </Stack>
  670. </AccordionDetails>
  671. </Accordion>
  672. <Accordion expanded={expandedPb} disableGutters
  673. onChange={handleChangeAccord('peibi')}>
  674. <AccordionSummary
  675. expandIcon={<ExpandMoreIcon />}
  676. aria-controls="panel1-content"
  677. id="panel1-header"
  678. >
  679. <Typography component="span">配合比</Typography>
  680. </AccordionSummary>
  681. <AccordionDetails>
  682. <Stack spacing={1}>
  683. <RichTreeView sx={{overflow: "scroll", maxHeight: "38vh"}}
  684. slots={{ item: CustomTreeItem }}
  685. onItemSelectionToggle={handleItemSelectionTogglePbs}
  686. items={peibishu}/>
  687. <div style={{ height: 350 }}>
  688. <DataGrid
  689. getRowHeight={() => 'auto'}
  690. rows={pbXilie}
  691. columns={columns2}
  692. hideFooter={true}
  693. />
  694. </div>
  695. </Stack>
  696. </AccordionDetails>
  697. </Accordion>
  698. </Grid>
  699. <Grid size={9}>
  700. {!nest && !qingdan && !cuoshi && <HotTable nestedRows={false}
  701. data={detail
  702. }
  703. rowHeaders={true}
  704. colHeaders={true}
  705. fixedRowsTop={1}
  706. height="800"
  707. readOnly={true}
  708. autoWrapRow={false}
  709. autoWrapCol={false}
  710. licenseKey="non-commercial-and-evaluation" // for non-commercial use only
  711. />}
  712. {nest && !qingdan && !cuoshi && <HotTable nestedRows={true}
  713. data={nestDetail
  714. }
  715. readOnly={true}
  716. fixedRowsTop={1}
  717. rowHeaders={true}
  718. colHeaders={columnHeaders}
  719. height="auto"
  720. contextMenu={true}
  721. bindRowsWithHeaders={true}
  722. autoWrapRow={false}
  723. autoWrapCol={false}
  724. licenseKey="non-commercial-and-evaluation" // for non-commercial use only
  725. />}
  726. {!nest && qingdan && !cuoshi && <TabContext value={value}>
  727. <Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
  728. <TabList scrollButtons='auto'
  729. variant="scrollable"
  730. sx={{minHeight: '24px'}}
  731. onChange={handleChange} aria-label="lab API tabs example">
  732. {qdbt.map((x, index)=> <Tab sx={{p: 0, minHeight: '24px'}} label={x} value={(index+1).toString()} />)}
  733. </TabList>
  734. </Box>
  735. {qdbt.map((x, index)=><TabPanel sx={{p: 1}} value={(index+1).toString()}>
  736. <Qingdan
  737. name={location["id"]}
  738. bh={qdbh}
  739. bt={x}
  740. rgde={rgde}
  741. jxde={jxde}
  742. clde={clde}
  743. beizhu={beizhu}
  744. beizhuFK={beizhuFK}
  745. clickCallback={clickCallback}
  746. loadingCallback={loadingCallback}
  747. dingeclick={dingeclick}
  748. />
  749. </TabPanel>
  750. )}
  751. </TabContext>}
  752. {!nest && !qingdan && cuoshi && <TabContext value={value}>
  753. <Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
  754. <TabList scrollButtons='auto'
  755. variant="scrollable"
  756. onChange={handleChange} aria-label="lab API tabs example">
  757. <Tab label="总价措施" value="1" />
  758. <Tab label="单价措施" value="2" />
  759. </TabList>
  760. </Box>
  761. <TabPanel sx={{p: 1}} value="1">
  762. <Zjcs name={location["id"]} bh={dwgc}/>
  763. </TabPanel>
  764. <TabPanel sx={{p: 1}} value="2">
  765. <Djcs
  766. name={location["id"]}
  767. bh={dwgc}
  768. rgde={rgde}
  769. jxde={jxde}
  770. clde={clde}
  771. beizhu={beizhu}
  772. clickCallback={clickCallback}
  773. />
  774. </TabPanel>
  775. </TabContext>}
  776. </Grid>
  777. </Grid>
  778. <Backdrop
  779. sx={(theme) => ({ color: '#fff', zIndex: theme.zIndex.drawer + 1 })}
  780. open={open}
  781. >
  782. <CircularProgress color="inherit" />
  783. </Backdrop>
  784. </Box>
  785. );
  786. }