Qingdan3.js 65 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471
  1. import * as React from 'react';
  2. import Box from "@mui/material/Box";
  3. import Table from 'rsuite/Table';
  4. import 'rsuite/Table/styles/index.css';
  5. import Checkbox from 'rsuite/Checkbox';
  6. import 'rsuite/Checkbox/styles/index.css';
  7. import { CustomProvider } from 'rsuite';
  8. import zhCN from 'rsuite/locales/zh_CN';
  9. import { Grid } from '@mui/material';
  10. import Tooltip from '@mui/material/Tooltip';
  11. import AddIcon from '@mui/icons-material/Add';
  12. import Typography from '@mui/material/Typography';
  13. import DeleteIcon from '@mui/icons-material/DeleteOutlined';
  14. import Radio from '@mui/material/Radio';
  15. import RadioGroup from '@mui/material/RadioGroup';
  16. import FormControlLabel from '@mui/material/FormControlLabel';
  17. import FormControl from '@mui/material/FormControl';
  18. import FormLabel from '@mui/material/FormLabel';
  19. import Tab from "@mui/material/Tab";
  20. import TabContext from "@mui/lab/TabContext";
  21. import TabList from "@mui/lab/TabList";
  22. import TabPanel from "@mui/lab/TabPanel";
  23. import Stack from "@mui/material/Stack";
  24. import Service from './Service';
  25. import Button from '@mui/material/Button';
  26. import ButtonGroup from '@mui/material/ButtonGroup';
  27. import {extractFuzhu} from './utils';
  28. import {shanchu, undo, redo, danxiangdinge, updateDercj, changguidinge, handleBeizhu, huan, updateShuliang, handleYuban, updateDeMingcheng, handleRcjbc} from './editor';
  29. import { DataGrid, GridActionsCellItem, zhCN as zhCN_MUI, GridToolbarContainer } from '@mui/x-data-grid';
  30. import { v4 as uuidv4 } from 'uuid';
  31. import {copy} from './utils';
  32. import {TabulatorFull as Tabulator} from "tabulator-tables"; //import Tabulator library
  33. import './Tabulator.css';
  34. const {Column, HeaderCell, Cell} = Table;
  35. /**
  36. *
  37. 本条规定了工程量清单编码的表示方式:十二位阿拉伯数字及其设置规定。
  38. 各位数字的含义是:一、二位为专业工程代码(01—房屋建筑与装饰工程;02—仿古建筑工程;
  39. 03—通用安装工程;04—市政工程;05—园林绿化工程;06—矿山工程;07—构筑物工程;08—城市
  40. 轨道交通工程;09—爆破工程。以后进入国标的专业工程代码以此类推);三、四位为附录分类顺序码;
  41. 五、六位为分部工程顺序码;七、八、九位为分项工程项目名称顺序码;十至十二位为清单项目名称
  42. 顺序码。
  43. */
  44. export default function Qingdan3({name, bh, bt, rgde, jxde, clde, beizhu/*后台传回来的附注信息,要整理后才能成为展示用的行*/ , beizhuFK, clickCallback, loadingCallback, dingeclick, tihuanCallback, tihuanClick, suanshiCallback}) {
  45. const myTable = React.useRef(null);
  46. const myRef = React.useRef(null);
  47. const [valueTab, setValueTab] = React.useState("1");
  48. const handleChange = (event, newValue) => {
  49. setValueTab(newValue);
  50. };
  51. const [rcjhl, setRcjhl] = React.useState([]);
  52. const [rcjhl2, setRcjhl2] = React.useState([]);
  53. const [fuzhu, setFuzhu] = React.useState([]);//展示用的附注行
  54. const [tuijian, setTuijian] = React.useState([]);
  55. const [fuzhuEnable, setFuzhuEnable] = React.useState(false);
  56. const [yubanEnable, setYubanEnable] = React.useState(false);
  57. const highlight = React.useRef([]);
  58. const debmRef = React.useRef(null);
  59. const tuijianRef = React.useRef(null);
  60. const tuijianTable = React.useRef(null);
  61. const rcj2Ref = React.useRef(null);
  62. const rcj2Table = React.useRef(null);
  63. const rcjRef = React.useRef(null);
  64. const rcjTable = React.useRef(null);
  65. const [detail, setDetail] = React.useState([
  66. ]);
  67. const selectedRowKeysTable = React.useRef([]);
  68. const selectedRowKeysTableParent = React.useRef(null);
  69. const beizhuFKRef = React.useRef(null);
  70. const rgdeRef = React.useRef(null);
  71. const jxdeRef = React.useRef(null);
  72. const cldeRef = React.useRef(null);
  73. const isQdrcj = React.useRef(false);
  74. ///备注
  75. const onSelectChange = (newSelectedRowKeys) => {
  76. const [newData, newHl] = handleBeizhu(beizhuFKRef.current, selectedRowKeysTable.current[0], newSelectedRowKeys, fuzhu);
  77. if (newData) {
  78. myTable.current.updateData(newData.filter(x=>x['key'] == selectedRowKeysTableParent.current));
  79. let y =[];
  80. for (let i = 1; i < newHl.length; i++) {
  81. y.push({
  82. 'ID' : newHl[i][0],
  83. '人材机编码' : newHl[i][1],
  84. '名称' : newHl[i][2],
  85. '规格型号': newHl[i][3],
  86. '单位' : newHl[i][4],
  87. '单价' : newHl[i][5],
  88. '产地' : newHl[i][6],
  89. '供应厂商' : newHl[i][7],
  90. '人材机类别' : newHl[i][8],
  91. '甲供标志': newHl[i][9],
  92. '含量' : newHl[i][10],
  93. '合价' : newHl[i][11],
  94. '暂估价标志' : newHl[i][12],
  95. '主要材料标志' : newHl[i][13],
  96. '主材标志' : newHl[i][14],
  97. '设备标志' : newHl[i][15]
  98. });
  99. }
  100. setRcjhl(y);
  101. if (rcjTable.current) {
  102. rcjTable.current.replaceData(y);
  103. }
  104. }
  105. };
  106. //预拌砂浆
  107. const onSelectChange2 = (event) => {
  108. setValueYuban(event.target.value);
  109. const [newData, newHl] = handleYuban(selectedRowKeysTable.current[0], [event.target.value]);
  110. if (newData) {
  111. myTable.current.updateData(newData.filter(x=>x['key'] == selectedRowKeysTableParent.current));
  112. let y =[];
  113. for (let i = 1; i < newHl.length; i++) {
  114. y.push({
  115. 'ID' : newHl[i][0],
  116. '人材机编码' : newHl[i][1],
  117. '名称' : newHl[i][2],
  118. '规格型号': newHl[i][3],
  119. '单位' : newHl[i][4],
  120. '单价' : newHl[i][5],
  121. '产地' : newHl[i][6],
  122. '供应厂商' : newHl[i][7],
  123. '人材机类别' : newHl[i][8],
  124. '甲供标志': newHl[i][9],
  125. '含量' : newHl[i][10],
  126. '合价' : newHl[i][11],
  127. '暂估价标志' : newHl[i][12],
  128. '主要材料标志' : newHl[i][13],
  129. '主材标志' : newHl[i][14],
  130. '设备标志' : newHl[i][15]
  131. });
  132. }
  133. setRcjhl(y);
  134. if (rcjTable.current) {
  135. rcjTable.current.replaceData(y);
  136. }
  137. }
  138. };
  139. /**fuzhu select */
  140. const [checked, setChecked] = React.useState(false);
  141. const [indeterminate, setIndeterminate] = React.useState(false);
  142. const [checkedKeys, setCheckedKeys] = React.useState([]);
  143. const setCheckedKeys_ = (keys) => {
  144. setCheckedKeys(keys);
  145. if (keys.length == fuzhu.length) {
  146. setChecked(true);
  147. setIndeterminate(false);
  148. } else if (keys.length == 0) {
  149. setChecked(false);
  150. setIndeterminate(false);
  151. } else {
  152. setIndeterminate(true);
  153. setChecked(false);
  154. }
  155. onSelectChange(keys);
  156. };
  157. const setCheckedKeys_2 = (keys) => {
  158. setCheckedKeys(keys);
  159. if (keys.length == fuzhu.length) {
  160. setChecked(true);
  161. setIndeterminate(false);
  162. } else if (keys.length == 0) {
  163. setChecked(false);
  164. setIndeterminate(false);
  165. } else {
  166. setIndeterminate(true);
  167. setChecked(false);
  168. }
  169. //onSelectChange(keys);
  170. };
  171. const handleCheckAll = (value, checked) => {
  172. const keys = checked? fuzhu.map(item => item.id) : [];
  173. setCheckedKeys_(keys);
  174. }
  175. const handleCheck = (value, checked) => {
  176. const keys = checked? [...checkedKeys, value] : checkedKeys.filter(item => item != value);
  177. setCheckedKeys_(keys);
  178. }
  179. const CheckCell = ({rowData, onChange, checkedKeys, dataKey, disabled, ...props}) => {
  180. return <Cell {...props} style={{ padding: 0}}>
  181. <div style={{lineHeight: '40px'}}>
  182. <Checkbox value = {rowData[dataKey]}
  183. inline
  184. disabled={disabled}
  185. onChange={onChange}
  186. checked={checkedKeys.some(item =>
  187. {
  188. let hit = item === rowData[dataKey];
  189. return hit;
  190. })}
  191. ></Checkbox>
  192. </div>
  193. </Cell>
  194. };
  195. const [valueYuban, setValueYuban] = React.useState("");
  196. var editCheck = function(cell){
  197. //cell - the cell component for the editable cell
  198. //get row data
  199. //console.log(cell);
  200. if(cell._cell.row.data['序号']) return false;
  201. return true;
  202. }
  203. var editCheckJg = function(cell){
  204. //cell - the cell component for the editable cell
  205. //get row data
  206. //console.log(cell);
  207. if(isQdrcj.current) return false;
  208. if (cell._cell.row.getData()['人材机编码'] == '410000F') {
  209. return false;
  210. }
  211. if (cell._cell.row.getData()['人材机编码'].includes('000FE')) {
  212. return false;
  213. }
  214. if (cell._cell.row.getData()['甲供标志'] == 'true') {
  215. return false;
  216. }
  217. return true;
  218. }
  219. var editCheckRcj = function(cell){
  220. //cell - the cell component for the editable cell
  221. //get row data
  222. //console.log(cell);
  223. if(isQdrcj.current) return false;
  224. if (cell._cell.row.getData()['人材机编码'] == '410000F') {
  225. return false;
  226. }
  227. if (cell._cell.row.getData()['人材机编码'].includes('000FE')) {
  228. return false;
  229. }
  230. return true;
  231. }
  232. var sparklineFormatter = function(cell, formatterParams, onRendered){
  233. for (let i = 0; i < highlight.current.length; i++) {
  234. let entry = highlight.current[i];
  235. if (entry.row + 1 == cell._cell.row.position && entry.col + 1 == cell._cell.column.getPosition()) {
  236. cell.getElement().style.fontWeight = 'bold';
  237. cell.getElement().style.color = 'green';
  238. cell.getElement().style.background = '#d7f1e1';
  239. }
  240. }
  241. return Number(cell.getValue()).toFixed(2).toString();
  242. };
  243. var sparklineFormatter2 = function(cell, formatterParams, onRendered){
  244. for (let i = 0; i < highlight.current.length; i++) {
  245. let entry = highlight.current[i];
  246. if (entry.row + 1 == cell._cell.row.position && entry.col + 1 == cell._cell.column.getPosition()) {
  247. cell.getElement().style.fontWeight = 'bold';
  248. cell.getElement().style.color = 'green';
  249. cell.getElement().style.background = '#d7f1e1';
  250. }
  251. }
  252. return cell.getValue();
  253. };
  254. const resetUI = () => {
  255. selectedRowKeysTable.current = [];
  256. selectedRowKeysTableParent.current = null;
  257. setRcjhl([]);
  258. if (rcjTable.current) {
  259. rcjTable.current.replaceData([]);
  260. }
  261. setFuzhu([]);
  262. setRcjrows([]);
  263. setShowToolbar(false);
  264. setValueYuban("");
  265. setYubanEnable(false);
  266. isQdrcj.current = true;
  267. highlight.current = [];
  268. setTuijian([]);
  269. if (tuijianTable.current) tuijianTable.current.replaceData([]);
  270. };
  271. function handleSelect(row){
  272. selectedRowKeysTable.current = [row._row['data']['key']];
  273. if (row._row.data['序号'] != null && row._row.data['序号'].length >0) {
  274. selectedRowKeysTableParent.current = row._row['data']['key'];
  275. setFuzhu([]);
  276. setRcjrows([]);//补充人材机
  277. setYubanEnable(false);
  278. setValueYuban("");
  279. setShowToolbar(false);
  280. Service.generateQingdanrcj(name, bh,bt,row._row.data['清单编码']).then(x=>{
  281. let y =[];
  282. for (let i = 1; i < x.length; i++) {
  283. y.push({
  284. 'ID' : x[i][0],
  285. '人材机编码' : x[i][1],
  286. '名称' : x[i][2],
  287. '规格型号': x[i][3],
  288. '单位' : x[i][4],
  289. '单价' : x[i][5],
  290. '产地' : x[i][6],
  291. '供应厂商' : x[i][7],
  292. '人材机类别' : x[i][8],
  293. '甲供标志': x[i][9],
  294. '含量' : x[i][10],
  295. '合价' : x[i][11],
  296. '暂估价标志' : x[i][12],
  297. '主要材料标志' : x[i][13],
  298. '主材标志' : x[i][14],
  299. '设备标志' : x[i][15]
  300. });
  301. }
  302. setRcjhl(y);
  303. if (rcjTable.current) {
  304. rcjTable.current.replaceData(y);
  305. }
  306. isQdrcj.current = true;
  307. highlight.current = [];
  308. });
  309. Service.generateQingdanTuijian(name, bh,bt,row._row.data['清单编码']).then(x=>{
  310. setTuijian(x);
  311. if (tuijianTable.current) tuijianTable.current.replaceData(x);
  312. });
  313. }else{
  314. setTuijian([]);
  315. if (tuijianTable.current) tuijianTable.current.replaceData([]);
  316. let row_parent = row._row;
  317. while(row_parent.modules.dataTree.parent) {
  318. row_parent = row_parent.modules.dataTree.parent;
  319. }
  320. //console.log(name, bh,bt,qdbm, selected[1]);
  321. debmRef.current = row._row['data']['清单编码'];
  322. selectedRowKeysTableParent.current = row_parent['data']['key'];
  323. let qdbm = row_parent['data']['清单编码'];
  324. let debm = row._row['data']['清单编码'];
  325. console.log('debm=');
  326. console.log(debm);
  327. let danwei = row._row['data']['单位'];
  328. clickCallback(qdbm, debm);/**dingercj need row key */
  329. Service.generateDingercj(name, bh,bt,qdbm, debm, danwei, row._row['data']['key']).then(x=>{
  330. console.log(x);
  331. let y =[];
  332. for (let i = 1; i < x[0].length; i++) {
  333. y.push({
  334. 'ID' : x[0][i][0],
  335. '人材机编码' : x[0][i][1],
  336. '名称' : x[0][i][2],
  337. '规格型号': x[0][i][3],
  338. '单位' : x[0][i][4],
  339. '单价' : x[0][i][5],
  340. '产地' : x[0][i][6],
  341. '供应厂商' : x[0][i][7],
  342. '人材机类别' : x[0][i][8],
  343. '甲供标志': x[0][i][9],
  344. '含量' : x[0][i][10],
  345. '合价' : x[0][i][11],
  346. '暂估价标志' : x[0][i][12],
  347. '主要材料标志' : x[0][i][13],
  348. '主材标志' : x[0][i][14],
  349. '设备标志' : x[0][i][15]
  350. });
  351. }
  352. setRcjhl(y);
  353. if (rcjTable.current) {
  354. rcjTable.current.replaceData(y);
  355. }
  356. setShowToolbar(true);
  357. setFuzhuEnable(x[1]);
  358. setYubanEnable(x[1]);
  359. if (x[2]== null || x[2].length == 0) {
  360. setValueYuban("");
  361. } else {
  362. setValueYuban(x[2][0]);
  363. }
  364. setRcjrows(x[3]);
  365. //hotRcjRef.current?.hotInstance?.loadData(x);
  366. isQdrcj.current = false;
  367. let toHighlight = [];
  368. for(let i = 0; i < y.length; i++) {
  369. let entry = y[i];
  370. let bianhao = entry['人材机编码'];
  371. let rcjlb = entry['人材机类别'];
  372. let hit = false;
  373. if (Number(rcjlb) == 1 && rgdeRef.current ) {
  374. for (let j = 0;j < rgdeRef.current.length; j++) {
  375. if (rgdeRef.current[j]["CLBH"] == bianhao) {
  376. if(rgdeRef.current[j]["CLMC"] == entry['名称'])hit = true;
  377. let danjia = Number(entry['单价']);
  378. if (danjia != rgdeRef.current[j]["YSJG"]) {
  379. //console.log(`[${i},5]danjia bu yizhi`);
  380. toHighlight.push({row: i, col: 5, renderer: "customStylesRenderer"});
  381. }
  382. let hanliang = Number(entry['含量']);
  383. if (hanliang != rgdeRef.current[j]["gr"]) {
  384. //console.log(`[${i}, 10]hanliang bu yizhi`);
  385. toHighlight.push({row: i, col: 10, renderer: "customStylesRenderer"});
  386. }
  387. }
  388. }
  389. }
  390. if (Number(rcjlb) == 3 && jxdeRef.current ) {
  391. for (let j = 0; j < jxdeRef.current.length; j++) {
  392. if (jxdeRef.current[j]["jxbh"] == bianhao) {
  393. if(jxdeRef.current[j]["jxmc"] == entry['名称'])hit = true;
  394. let danjia = Number(entry['单价']);
  395. if (danjia != jxdeRef.current[j]["tbdj"]) {
  396. //console.log(`[${i},5]danjia bu yizhi`);
  397. toHighlight.push({row: i, col: 5, renderer: "customStylesRenderer"});
  398. }
  399. let hanliang = Number(entry['含量']);
  400. if (hanliang != jxdeRef.current[j]["sl"]) {
  401. //console.log(`[${i}, 10]hanliang bu yizhi`);
  402. toHighlight.push({row: i, col: 10, renderer: "customStylesRenderer"});
  403. }
  404. }
  405. }
  406. }
  407. if (Number(rcjlb) == 2 && cldeRef.current ) {
  408. for (let j = 0; j < cldeRef.current.length; j++) {
  409. if (cldeRef.current[j]["CLBH"] == bianhao) {
  410. if(cldeRef.current[j]["CLMC"] == entry['名称'])hit = true;
  411. let danjia = Number(entry['单价']);
  412. if (danjia != cldeRef.current[j]["YSJG"]) {
  413. //console.log(`[${i},5]danjia bu yizhi`);
  414. toHighlight.push({row: i, col: 5, renderer: "customStylesRenderer"});
  415. }
  416. let hanliang = Number(entry['含量']);
  417. if (hanliang != cldeRef.current[j]["SL"]) {
  418. //console.log(`[${i}, 10]hanliang bu yizhi`);
  419. toHighlight.push({row: i, col: 10, renderer: "customStylesRenderer"});
  420. }
  421. }
  422. }
  423. }
  424. if (!hit) {
  425. toHighlight.push({row: i, col: 1, renderer: "customStylesRenderer"});
  426. }
  427. }
  428. highlight.current = toHighlight;
  429. });
  430. }
  431. }
  432. /**补充人材机 */
  433. const [rcjrows, setRcjrows] = React.useState([]);
  434. //const [rowModesModel, setRowModesModel] = React.useState({});
  435. const [showToolbar, setShowToolbar] = React.useState(false);
  436. const rcjcolumns = [
  437. {
  438. field: 'actions',
  439. type: 'actions',
  440. headerName: '操作',
  441. width: 100,
  442. cellClassName: 'actions',
  443. getActions: ({ id }) => {
  444. return [
  445. <GridActionsCellItem
  446. icon={<DeleteIcon />}
  447. label="Delete"
  448. onClick={handleDeleteClick(id)}
  449. color="inherit"
  450. />,
  451. ];
  452. },
  453. },
  454. { field: '人材机编码', headerName: '人材机编码', width: 120, editable: false },
  455. {
  456. field: '名称',
  457. headerName: '名称',
  458. width: 120,
  459. align: 'left',
  460. headerAlign: 'left',
  461. editable: true,
  462. },
  463. {
  464. field: '规格型号',
  465. headerName: '规格型号',
  466. width: 100,
  467. editable: true,
  468. },
  469. {
  470. field: '单位',
  471. headerName: '单位',
  472. width: 80,
  473. editable: true,
  474. },
  475. {
  476. field: '单价',
  477. headerName: '单价',
  478. width: 80,
  479. editable: true,
  480. },
  481. {
  482. field: '产地',
  483. headerName: '产地',
  484. width: 80,
  485. editable: true,
  486. },
  487. {
  488. field: '供应厂商',
  489. headerName: '供应厂商',
  490. width: 80,
  491. editable: true,
  492. },
  493. {
  494. field: '人材机类别',
  495. headerName: '人材机类别',
  496. width: 120,
  497. editable: true,
  498. },
  499. {
  500. field: '甲供标志',
  501. headerName: '甲供标志',
  502. width: 80,
  503. editable: true,
  504. },
  505. {
  506. field: '含量',
  507. headerName: '含量',
  508. width: 80,
  509. editable: true,
  510. },
  511. /* {
  512. field: '合价',
  513. headerName: '合价',
  514. width: 80,
  515. editable: true,
  516. },*/
  517. {
  518. field: '暂估价标志',
  519. headerName: '暂估价标志',
  520. width: 100,
  521. editable: true,
  522. },
  523. {
  524. field: '主要材料标志',
  525. headerName: '主要材料标志',
  526. width: 120,
  527. editable: true,
  528. },
  529. {
  530. field: '主材标志',
  531. headerName: '主材标志',
  532. width: 80,
  533. editable: true,
  534. },
  535. {
  536. field: '设备标志',
  537. headerName: '设备标志',
  538. width: 80,
  539. editable: true,
  540. },
  541. ];
  542. const handleDeleteClick = (id) => () => {
  543. setRcjrows(rcjrows.filter((row) => row.id !== id));
  544. const [newData, newHl] = handleRcjbc(selectedRowKeysTable.current[0], rcjrows.filter((row) => row.id !== id));
  545. if (newData) {
  546. myTable.current.updateData(newData.filter(x=>x['key'] == selectedRowKeysTableParent.current));
  547. let y =[];
  548. for (let i = 1; i < newHl.length; i++) {
  549. y.push({
  550. 'ID' : newHl[i][0],
  551. '人材机编码' : newHl[i][1],
  552. '名称' : newHl[i][2],
  553. '规格型号': newHl[i][3],
  554. '单位' : newHl[i][4],
  555. '单价' : newHl[i][5],
  556. '产地' : newHl[i][6],
  557. '供应厂商' : newHl[i][7],
  558. '人材机类别' : newHl[i][8],
  559. '甲供标志': newHl[i][9],
  560. '含量' : newHl[i][10],
  561. '合价' : newHl[i][11],
  562. '暂估价标志' : newHl[i][12],
  563. '主要材料标志' : newHl[i][13],
  564. '主材标志' : newHl[i][14],
  565. '设备标志' : newHl[i][15]
  566. });
  567. }
  568. setRcjhl(y);
  569. if (rcjTable.current) {
  570. rcjTable.current.replaceData(y);
  571. }
  572. }
  573. };
  574. const processRowUpdate = (newRow) => {
  575. const updatedRow = { ...newRow, isNew: false };
  576. setRcjrows(rcjrows.map((row) => (row.id === newRow.id ? updatedRow : row)));
  577. const [newData, newHl] = handleRcjbc(selectedRowKeysTable.current[0], rcjrows.map((row) => (row.id === newRow.id ? updatedRow : row)));
  578. if (newData) {
  579. myTable.current.updateData(newData.filter(x=>x['key'] == selectedRowKeysTableParent.current));
  580. let y =[];
  581. for (let i = 1; i < newHl.length; i++) {
  582. y.push({
  583. 'ID' : newHl[i][0],
  584. '人材机编码' : newHl[i][1],
  585. '名称' : newHl[i][2],
  586. '规格型号': newHl[i][3],
  587. '单位' : newHl[i][4],
  588. '单价' : newHl[i][5],
  589. '产地' : newHl[i][6],
  590. '供应厂商' : newHl[i][7],
  591. '人材机类别' : newHl[i][8],
  592. '甲供标志': newHl[i][9],
  593. '含量' : newHl[i][10],
  594. '合价' : newHl[i][11],
  595. '暂估价标志' : newHl[i][12],
  596. '主要材料标志' : newHl[i][13],
  597. '主材标志' : newHl[i][14],
  598. '设备标志' : newHl[i][15]
  599. });
  600. }
  601. setRcjhl(y);
  602. if (rcjTable.current) {
  603. rcjTable.current.replaceData(y);
  604. }
  605. }
  606. return updatedRow;
  607. };
  608. function EditToolbar(props) {
  609. const { setRcjrows } = props;
  610. const handleClick = () => {
  611. const id = uuidv4();
  612. let a = [];
  613. setRcjrows((oldRows) => {
  614. a = [
  615. ...oldRows,
  616. { id, '人材机编码': '410000F', '名称': '', '规格型号': '', '单位': '', '单价':'0','产地': '', '供应厂商': '', '人材机类别':'2',
  617. '甲供标志':'', '含量':'1', '暂估价标志':'', '主要材料标志':'true', '主材标志':'true', '设备标志':'' },
  618. ];
  619. return a;
  620. });
  621. const [newData, newHl] = handleRcjbc(selectedRowKeysTable.current[0], a);
  622. if (newData) {
  623. myTable.current.updateData(newData.filter(x=>x['key'] == selectedRowKeysTableParent.current));
  624. let y =[];
  625. for (let i = 1; i < newHl.length; i++) {
  626. y.push({
  627. 'ID' : newHl[i][0],
  628. '人材机编码' : newHl[i][1],
  629. '名称' : newHl[i][2],
  630. '规格型号': newHl[i][3],
  631. '单位' : newHl[i][4],
  632. '单价' : newHl[i][5],
  633. '产地' : newHl[i][6],
  634. '供应厂商' : newHl[i][7],
  635. '人材机类别' : newHl[i][8],
  636. '甲供标志': newHl[i][9],
  637. '含量' : newHl[i][10],
  638. '合价' : newHl[i][11],
  639. '暂估价标志' : newHl[i][12],
  640. '主要材料标志' : newHl[i][13],
  641. '主材标志' : newHl[i][14],
  642. '设备标志' : newHl[i][15]
  643. });
  644. }
  645. setRcjhl(y);
  646. if (rcjTable.current) {
  647. rcjTable.current.replaceData(y);
  648. }
  649. }
  650. };
  651. return (
  652. <GridToolbarContainer>
  653. <Button disabled={!showToolbar}
  654. color="primary" startIcon={<AddIcon />} onClick={handleClick}>
  655. 补充
  656. </Button>
  657. </GridToolbarContainer>
  658. );
  659. }
  660. React.useEffect(() => {
  661. myTable.current = new Tabulator(myRef.current, {
  662. index: "key",
  663. height: 380,
  664. //rowHeight: 40,
  665. //renderVerticalBuffer: 760,
  666. renderVertical: "basic",
  667. data: detail, //link data to table
  668. reactiveData: false, //enable data reactivity
  669. dataTreeStartExpanded:true,
  670. dataTree: true,
  671. selectableRows:1, //make rows selectable
  672. editTriggerEvent:"dblclick", //trigger edit on double click
  673. dataTreeStartExpanded:function(row, level){
  674. //console.log(row);
  675. //console.log(level);
  676. return true; //expand rows where the "driver" data field is true;
  677. },
  678. columns: [ //Define Table Columns
  679. {title:"序号", field:"序号", width:80, headerSort:false, frozen: true}, //never hide this column
  680. {title:"清单编码", field:"清单编码", width:120,headerSort:false, frozen: true ,formatter:"textarea" },
  681. {title:"名称", field:"名称", width:150, headerSort:false, formatter:"textarea", editor: "input", editable: editCheck}, //hide this column first
  682. {title:"项目特征", field:"项目特征", width:200 , headerSort:false, formatter:"textarea"},
  683. {title:"计算规则", field:"计算规则", width:300, headerSort:false, formatter:"textarea"},
  684. {title:"单位", field:"单位", width:100, headerSort:false},
  685. {title:"数量", field:"数量", width:100, headerSort:false, editor: "input", editable: editCheck },
  686. {title:"综合单价", field:"综合单价", width:100, headerSort:false, formatter:"money"},
  687. {title:"合价", field:"合价", width:100, headerSort:false, formatter:"money"},
  688. {title:"人工费", field:"人工费", width:100, headerSort:false, formatter:"money"},
  689. {title:"主材费", field:"主材费", width:100, headerSort:false, formatter:"money"},
  690. {title:"设备费", field:"设备费", width:100, headerSort:false, formatter:"money"},
  691. {title:"辅材费", field:"辅材费", width:100, headerSort:false, formatter:"money"},
  692. {title:"材料费", field:"材料费", width:100, headerSort:false, formatter:"money"},
  693. {title:"机械费", field:"机械费", width:100, headerSort:false, formatter:"money"},
  694. {title:"管理费", field:"管理费", width:100, headerSort:false, formatter:"money"},
  695. {title:"利润", field:"利润", width:100, headerSort:false, formatter:"money"},
  696. {title:"暂估价", field:"暂估价", width:100, headerSort:false, formatter:"money"},
  697. {title:"综合人工工日", field:"综合人工工日", width:100, headerSort:false},
  698. ]
  699. });
  700. myTable.current.on("cellDblClick", function(e, cell){
  701. //e - the click event object
  702. //cell - cell component
  703. console.log(cell);
  704. });
  705. myTable.current.on("rowSelected", handleSelect);
  706. myTable.current.on("cellEdited", function(cell){
  707. //console.log("edited");
  708. //console.log();
  709. let key = cell._cell.row.data['key'];
  710. myTable.current.deselectRow();
  711. if(cell._cell.column.field == '名称') {
  712. let newData = updateDeMingcheng(cell._cell.row.data['名称'], selectedRowKeysTable.current[0]);
  713. myTable.current.updateData(newData.filter(x=>x['key'] == selectedRowKeysTableParent.current)).then(function() {
  714. let getRow = myTable.current.getRows(); //get array of currently selected row components.
  715. let component = null;
  716. for(let i = 0; i < getRow.length; i++) {
  717. let entry = getRow[i]._row.modules.dataTree.children;
  718. for(let j = 0; j < entry.length; j++) {
  719. let child = entry[j];
  720. if(child.data['key'] == key) {
  721. //console.log(child);
  722. component = child.component;
  723. break;
  724. }
  725. }
  726. }
  727. component.select();
  728. handleSelect(component);
  729. //handleSelect(getRow[0]);
  730. });
  731. }
  732. else{
  733. let [success, data] = updateShuliang(cell._cell.row.data['数量'], selectedRowKeysTable.current[0]);
  734. if (success) {
  735. myTable.current.updateData(data.filter(x=>x['key'] == selectedRowKeysTableParent.current)).then(function() {
  736. let getRow = myTable.current.getRows(); //get array of currently selected row components.
  737. let component = null;
  738. for(let i = 0; i < getRow.length; i++) {
  739. let entry = getRow[i]._row.modules.dataTree.children;
  740. for(let j = 0; j < entry.length; j++) {
  741. let child = entry[j];
  742. if(child.data['key'] == key) {
  743. //console.log(child);
  744. component = child.component;
  745. break;
  746. }
  747. }
  748. }
  749. component.select();
  750. handleSelect(component);
  751. //handleSelect(getRow[0]);
  752. });
  753. }
  754. }
  755. });
  756. myTable.current.on("tableBuilt", () => {
  757. Service.generateQingdanmingxi(name, bh, bt).then(x=>{
  758. myTable.current.replaceData(x);
  759. });
  760. });
  761. }, [bh, bt]);
  762. React.useEffect(
  763. () => {
  764. //console.log("rgde changed");
  765. //console.log(rgde);
  766. rgdeRef.current = rgde;
  767. jxdeRef.current = jxde;
  768. cldeRef.current = clde;
  769. if (isQdrcj.current) {
  770. highlight.current = [];
  771. } else {
  772. let toHighlight = [];
  773. for(let i = 0; i < rcjhl.length; i++) {
  774. let entry = rcjhl[i];
  775. let bianhao = entry['人材机编码'];
  776. let rcjlb = entry['人材机类别'];
  777. let hit = false;
  778. if (Number(rcjlb) == Number(1) && rgde) {
  779. for (let j = 0; j < rgde.length; j++) {
  780. if (rgde[j]["CLBH"] == bianhao) {
  781. if(rgde[j]["CLMC"] == entry['名称'])hit = true;
  782. let danjia = Number(entry['单价']);
  783. if (danjia != rgde[j]["YSJG"]) {
  784. //console.log(`[${i},5]danjia bu yizhi`);
  785. toHighlight.push({row: i, col: 5, renderer: "customStylesRenderer"});
  786. }
  787. let hanliang = Number(entry['含量']);
  788. if (hanliang != rgde[j]["gr"]) {
  789. //console.log(`[${i}, 10]hanliang bu yizhi`);
  790. toHighlight.push({row: i, col: 10, renderer: "customStylesRenderer"});
  791. }
  792. }
  793. }
  794. }
  795. if (Number(rcjlb) == Number(3) && jxde ) {
  796. for (let j = 0; j < jxde.length; j++) {
  797. if (jxde[j]["jxbh"] == bianhao) {
  798. if(jxde[j]["jxmc"] == entry['名称'])hit = true;
  799. let danjia = Number(entry['单价']);
  800. if (danjia != jxde[j]["tbdj"]) {
  801. //console.log(`[${i},5]danjia bu yizhi`);
  802. toHighlight.push({row: i, col: 5, renderer: "customStylesRenderer"});
  803. }
  804. let hanliang = Number(entry['含量']);
  805. if (hanliang != jxde[j]["sl"]) {
  806. //console.log(`[${i}, 10]hanliang bu yizhi`);
  807. toHighlight.push({row: i, col: 10, renderer: "customStylesRenderer"});
  808. }
  809. }
  810. }
  811. }
  812. if (Number(rcjlb) == Number(2) && clde ) {
  813. for (let j = 0; j < clde.length; j++) {
  814. if (clde[j]["CLBH"] == bianhao) {
  815. if(clde[j]["CLMC"] == entry['名称'])hit = true;
  816. let danjia = Number(entry['单价']);
  817. if (danjia != clde[j]["YSJG"]) {
  818. //console.log(`[${i},5]danjia bu yizhi`);
  819. toHighlight.push({row: i, col: 5, renderer: "customStylesRenderer"});
  820. }
  821. let hanliang = Number(entry['含量']);
  822. if (hanliang != clde[j]["SL"]) {
  823. //console.log(`[${i}, 10]hanliang bu yizhi`);
  824. toHighlight.push({row: i, col: 10, renderer: "customStylesRenderer"});
  825. }
  826. }
  827. }
  828. }
  829. if (!hit) {
  830. toHighlight.push({row: i, col: 1, renderer: "customStylesRenderer"});
  831. }
  832. }
  833. //console.log(toHighlight);
  834. highlight.current = toHighlight;
  835. }
  836. let bzrcjhl = [/*["人材机编码", "名称", "单位", "单价", "合价", "含量"]*/]
  837. if (rgde)
  838. for (let i = 0; i < rgde.length; i++) {
  839. bzrcjhl.push({'人材机编码': rgde[i]["CLBH"], '名称': rgde[i]["CLMC"], '单位': rgde[i]["JLDW"], '单价': rgde[i]["YSJG"], '合价': rgde[i]["gf"], '含量': rgde[i]["gr"]});
  840. }
  841. if (clde)
  842. for (let i = 0; i < clde.length; i++) {
  843. bzrcjhl.push({'人材机编码': clde[i]["CLBH"], '名称': clde[i]["CLMC"], '单位': clde[i]["JLDW"], '单价': clde[i]["YSJG"], '合价': clde[i]["HJ"], '含量': clde[i]["SL"]});
  844. }
  845. if (jxde)
  846. for (let i = 0; i < jxde.length; i++) {
  847. bzrcjhl.push({'人材机编码': jxde[i]["jxbh"], '名称': jxde[i]["jxmc"], '单位': jxde[i]["DW"], '单价': jxde[i]["tbdj"], '合价': jxde[i]["hj"], '含量': jxde[i]["sl"]});
  848. }
  849. setRcjhl2(bzrcjhl);
  850. }, [rgde, jxde, clde]
  851. );
  852. React.useEffect(
  853. () => {
  854. console.log(beizhu);
  855. let result = [];
  856. if (beizhu != null) {
  857. let keys = Object.keys(beizhu["BZBH"]);
  858. for(let i = 0; i < keys.length; i++) {
  859. let key = keys[i];
  860. result.push({'id': i+1, 'key': i+1, '序号': i+1, '编号': beizhu["BZBH"][key], '说明': beizhu["SM"][key]});//序号很重要
  861. }
  862. setFuzhu(result);
  863. let newSelect = extractFuzhu(debmRef.current);
  864. setCheckedKeys_2(newSelect);
  865. //setSelectedRowKeys([1]);
  866. }
  867. }, [beizhu]
  868. );
  869. React.useEffect(
  870. () => {
  871. beizhuFKRef.current = beizhuFK;
  872. }, [beizhuFK]
  873. );
  874. React.useEffect(
  875. () => {
  876. myTable.current.deselectRow();
  877. //console.log(dingeclick);
  878. if (selectedRowKeysTable.current.length > 0 ) {
  879. const [success, data, key] = changguidinge(JSON.parse(dingeclick), selectedRowKeysTable.current[0]);
  880. if (success) {
  881. myTable.current.updateData(data.filter(x=>x['key'] == selectedRowKeysTableParent.current)).then(function(){
  882. let getRow = myTable.current.getRows(); //get array of currently selected row components.
  883. let component = null;
  884. for(let i = 0; i < getRow.length; i++) {
  885. let entry = getRow[i]._row.modules.dataTree.children;
  886. for(let j = 0; j < entry.length; j++) {
  887. let child = entry[j];
  888. if(child.data['key'] == key) {
  889. //console.log(child);
  890. component = child.component;
  891. break;
  892. }
  893. }
  894. }
  895. component.select();
  896. handleSelect(component);
  897. });
  898. }
  899. }
  900. }, [dingeclick]//常规添加定额
  901. );
  902. React.useEffect(
  903. () => {
  904. //console.log(dingeclick);
  905. if (selectedRowKeysTable.current.length > 0 ) {
  906. const data = huan(JSON.parse(tihuanClick), selectedRowKeysTable.current[0]);
  907. myTable.current.updateData(data.filter(x=>x['key'] == selectedRowKeysTableParent.current)).then(function(){
  908. let getRow = myTable.current.getRows(); //get array of currently selected row components.
  909. let component = null;
  910. for(let i = 0; i < getRow.length; i++) {
  911. let entry = getRow[i]._row.modules.dataTree.children;
  912. for(let j = 0; j < entry.length; j++) {
  913. let child = entry[j];
  914. if(child.data['key'] == selectedRowKeysTable.current[0]) {
  915. //console.log(child);
  916. component = child.component;
  917. break;
  918. }
  919. }
  920. }
  921. handleSelect(component);
  922. });
  923. }
  924. }, [tihuanClick]//替换定额人材机
  925. );
  926. React.useEffect(
  927. () => {
  928. if (tuijianRef.current != null ) {
  929. tuijianTable.current = new Tabulator(tuijianRef.current, {
  930. index: "key",
  931. height: 200,
  932. data: tuijian, //link data to table
  933. reactiveData: false, //enable data reactivity
  934. dataTreeStartExpanded:false,
  935. dataTree: false,
  936. selectableRows:1, //make rows selectable
  937. columns: [ //Define Table Columns
  938. {title:"ID", field:"ID", width:80, headerSort:false, }, //never hide this column
  939. {title:"定额编号", field:"定额编号", width:120,headerSort:false, formatter:"textarea" },
  940. {title:"工程量名称", field:"工程量名称", width:150, headerSort:false, formatter:"textarea"}, //hide this column first
  941. {title:"工作内容", field:"工作内容", width:150 , headerSort:false, formatter:"textarea"},
  942. ]
  943. });
  944. tuijianTable.current.on("tableBuilt", () => {
  945. tuijianTable.current.replaceData(tuijian);
  946. });
  947. }
  948. if (rcj2Ref.current != null ) {
  949. rcj2Table.current = new Tabulator(rcj2Ref.current, {
  950. index: "key",
  951. height: 200,
  952. data: rcjhl2, //link data to table
  953. reactiveData: false, //enable data reactivity
  954. dataTreeStartExpanded:false,
  955. dataTree: false,
  956. selectableRows:1, //make rows selectable
  957. columns: [ //Define Table Columns
  958. {title:"人材机编码", field:"人材机编码", width:100, headerSort:false, }, //never hide this column
  959. {title:"名称", field:"名称", width:120,headerSort:false, formatter:"textarea" },
  960. {title:"单位", field:"单位", width:150, headerSort:false, formatter:"textarea"}, //hide this column first
  961. {title:"单价", field:"单价", width:150 , headerSort:false, formatter:"money"},
  962. {title:"合价", field:"合价", width:150 , headerSort:false, formatter:"money"},
  963. {title:"含量", field:"含量", width:150 , headerSort:false, formatter:"textarea"},
  964. ]
  965. });
  966. rcj2Table.current.on("tableBuilt", () => {
  967. rcj2Table.current.replaceData(rcjhl2);
  968. });
  969. }
  970. if (rcjRef.current != null ) {
  971. rcjTable.current = new Tabulator(rcjRef.current, {
  972. index: "key",
  973. height: 250,
  974. data: rcjhl, //link data to table
  975. reactiveData: false, //enable data reactivity
  976. dataTreeStartExpanded:false,
  977. dataTree: false,
  978. selectableRows:1, //make rows selectable
  979. editTriggerEvent:"dblclick",
  980. rowFormatter:function(row){
  981. //row - row component
  982. var data = row.getData();
  983. if (data['人材机编码'] == '410000F') {
  984. row.getElement().style.backgroundColor = "#ffff00";
  985. }
  986. },
  987. columns: [ //Define Table Columns
  988. {title:"ID", field:"ID", width:80, headerSort:false, },
  989. {title:"人材机编码", field:"人材机编码", width:100, headerSort:false, formatter: sparklineFormatter2}, //never hide this column
  990. {title:"名称", field:"名称", width:120,headerSort:false, formatter:"textarea", editor: "input", editable: editCheckRcj },
  991. {title:"规格型号", field:"规格型号", width:80, headerSort:false, editor: "input", editable: editCheckRcj },
  992. {title:"单位", field:"单位", width:80, headerSort:false, formatter:"textarea"}, //hide this column first
  993. {title:"单价", field:"单价", width:80 , headerSort:false, formatter: sparklineFormatter, editor: "input", editable: editCheckJg },
  994. {title:"产地", field:"产地", width:80, headerSort:false, },
  995. {title:"供应厂商", field:"供应厂商", width:80, headerSort:false, },
  996. {title:"人材机类别", field:"人材机类别", width:80, headerSort:false, },
  997. {title:"甲供标志", field:"甲供标志", width:80 , headerSort:false, formatter:"textarea"},
  998. {title:"含量", field:"含量", width:80 , headerSort:false, formatter:"money", formatterParams:{precision:4}, editor: "input", editable: editCheckRcj },
  999. {title:"合价", field:"合价", width:80 , headerSort:false, formatter:"money"},
  1000. {title:"暂估价标志", field:"暂估价标志", width:80 , headerSort:false, formatter:"textarea"},
  1001. {title:"主要材料标志", field:"主要材料标志", width:100 , headerSort:false, formatter:"textarea"},
  1002. {title:"主材标志", field:"主材标志", width:80 , headerSort:false, formatter:"textarea"},
  1003. {title:"设备标志", field:"设备标志", width:80 , headerSort:false, formatter:"textarea"},
  1004. ]
  1005. });
  1006. rcjTable.current.on("tableBuilt", () => {
  1007. rcjTable.current.replaceData(rcjhl);
  1008. });
  1009. rcjTable.current.on("cellDblClick", function(e, cell){
  1010. //e - the click event object
  1011. //cell - cell component
  1012. let determine = cell._cell.row.getData()['人材机编码'] != '410000F';
  1013. let determine2 = !cell._cell.row.getData()['人材机编码'].includes('000FE');
  1014. let determine3 = !cell._cell.row.getData()['人材机编码'].startsWith('D');
  1015. if(cell._cell.column.getPosition() == 2 && !isQdrcj.current && determine && determine2 && determine3) {
  1016. tihuanCallback(cell._cell.row.position, cell._cell.column.getPosition());
  1017. }
  1018. });
  1019. rcjTable.current.on("cellEdited", function(cell){
  1020. let data = copy(cell._cell.table.getData());
  1021. for(let i = 0; i < data.length; i++) {
  1022. data[i]['合价'] = Number(data[i]['单价']) * Number(data[i]['含量']);
  1023. }
  1024. setRcjhl(data);
  1025. if (rcjTable.current) {
  1026. rcjTable.current.replaceData(data);
  1027. }
  1028. let data2 = [['ID', '人材机编码', '名称', '规格型号', '单位', '单价', '产地', '供应厂商', '人材机类别', '甲供标志', '含量', '合价', '暂估价标志', '主要材料标志', '主材标志', '设备标志']]
  1029. for (let i = 0; i < data.length; i++) {
  1030. data2.push([data[i]['ID'], data[i]['人材机编码'], data[i]['名称'], data[i]['规格型号'], data[i]['单位'],
  1031. data[i]['单价'], data[i]['产地'], data[i]['供应厂商'], data[i]['人材机类别'],
  1032. data[i]['甲供标志'], data[i]['含量'], data[i]['合价'], data[i]['暂估价标志'], data[i]['主要材料标志'], data[i]['主材标志'], data[i]['设备标志']]);
  1033. }
  1034. let newData = updateDercj(selectedRowKeysTable.current[0], data2);
  1035. myTable.current.updateData(newData.filter(x=>x['key'] == selectedRowKeysTableParent.current)).then(function() {
  1036. let getRow = myTable.current.getRows(); //get array of currently selected row components.
  1037. let component = null;
  1038. for(let i = 0; i < getRow.length; i++) {
  1039. let entry = getRow[i]._row.modules.dataTree.children;
  1040. for(let j = 0; j < entry.length; j++) {
  1041. let child = entry[j];
  1042. if(child.data['key'] == selectedRowKeysTable.current[0]) {
  1043. //console.log(child);
  1044. component = child.component;
  1045. break;
  1046. }
  1047. }
  1048. }
  1049. handleSelect(component);
  1050. });
  1051. });
  1052. }
  1053. }, [valueTab]
  1054. );
  1055. return (
  1056. <Stack spacing={2}>
  1057. <Box>
  1058. <Stack direction='row' spacing={2}>
  1059. <Button variant="outlined" size="small" onClick={() => {
  1060. if (selectedRowKeysTable.current.length > 0) {
  1061. let getRow = myTable.current.getRows(); //get array of currently selected row components.
  1062. let hit = false;
  1063. for(let i = 0; i < getRow.length; i++) {
  1064. if (getRow[i]._row.data['key'] == selectedRowKeysTable.current[0]) {
  1065. hit = true;
  1066. }
  1067. }
  1068. if (hit) {
  1069. suanshiCallback();
  1070. }
  1071. }
  1072. }}
  1073. >定额(算式)</Button>
  1074. <Button variant="outlined" size="small" onClick={() => {
  1075. if (selectedRowKeysTable.current.length > 0) {
  1076. const [success, data] = danxiangdinge(selectedRowKeysTable.current[0]);
  1077. if(success) {
  1078. myTable.current.updateData(data.filter(x=>x['key'] == selectedRowKeysTableParent.current)).then(function(){
  1079. resetUI();
  1080. });
  1081. }
  1082. }
  1083. }}
  1084. >单项定额</Button>
  1085. <Button variant="outlined" size="small" onClick={() => {
  1086. if (selectedRowKeysTable.current.length > 0) {
  1087. let newData = shanchu(selectedRowKeysTable.current[0]);
  1088. myTable.current.updateData(newData.filter(x=>x['key'] == selectedRowKeysTableParent.current)).then(function(){
  1089. if (newData.filter(x=>x['key'] == selectedRowKeysTable.current[0]).length == 0) {
  1090. resetUI();
  1091. }
  1092. });
  1093. }
  1094. }}
  1095. >删除</Button>
  1096. <Button variant="outlined" size="small" onClick={() => {
  1097. let newData = undo();
  1098. myTable.current.updateData(newData).then(function(){
  1099. resetUI();
  1100. });
  1101. }}
  1102. >撤销</Button>
  1103. <Button variant="outlined" size="small" onClick={() => {
  1104. let newData = redo();
  1105. myTable.current.updateData(newData).then(function(){
  1106. resetUI();
  1107. });
  1108. }}
  1109. >重做</Button>
  1110. <Button variant="outlined" size="small" onClick={() => {
  1111. console.log("save to cloud");
  1112. loadingCallback();
  1113. }}
  1114. >保存</Button>
  1115. </Stack>
  1116. <div style={{width: "70vw"}}>
  1117. <div ref={myRef}>
  1118. </div>
  1119. </div>
  1120. </Box>
  1121. <Box >
  1122. <TabContext value={valueTab}>
  1123. <Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
  1124. <TabList sx={{minHeight: '24px'}} onChange={handleChange} aria-label="lab API tabs example">
  1125. <Tab sx={{p: 0, minHeight: '24px'}} label="人材机含量" value="1" />
  1126. <Tab sx={{p: 0, minHeight: '24px'}} label="标准定额人材机含量" value="2" />
  1127. <Tab sx={{p: 0, minHeight: '24px'}} label="人材机补充" value="3" />
  1128. <Tab sx={{p: 0, minHeight: '24px'}} label="定额附注" value="4" />
  1129. <Tab sx={{p: 0, minHeight: '24px'}} label="预拌砂浆" value="5" />
  1130. <Tab sx={{p: 0, minHeight: '24px'}} label="组价推荐" value="6" />
  1131. </TabList>
  1132. </Box>
  1133. <TabPanel sx={{p: 1}} value="1">
  1134. <div style={{width:"70vw"}}>
  1135. <div ref={rcjRef}></div>
  1136. </div>
  1137. </TabPanel>
  1138. <TabPanel sx={{p: 1}} value="2">
  1139. <div ref={rcj2Ref}></div>
  1140. </TabPanel>
  1141. <TabPanel sx={{p: 1}} value="3">
  1142. <Box
  1143. sx={{
  1144. height: 200,
  1145. width: '100%',
  1146. '& .actions': {
  1147. color: 'text.secondary',
  1148. },
  1149. '& .textPrimary': {
  1150. color: 'text.primary',
  1151. },
  1152. }}
  1153. >
  1154. <DataGrid disableColumnMenu disableColumnSorting
  1155. hideFooter={true}
  1156. rows={rcjrows}
  1157. columns={rcjcolumns}
  1158. processRowUpdate={processRowUpdate}
  1159. slotProps={{
  1160. toolbar: { setRcjrows },
  1161. }}
  1162. slots={{
  1163. toolbar: EditToolbar,
  1164. }}
  1165. localeText={zhCN_MUI.components.MuiDataGrid.defaultProps.localeText}
  1166. />
  1167. </Box>
  1168. </TabPanel>
  1169. <TabPanel sx={{p: 1}} value="4">
  1170. <Box sx={{maxHeight: `190px`}}>
  1171. <CustomProvider locale={zhCN}>
  1172. <Table rowHeight={rowData=>{
  1173. return 40;
  1174. }}
  1175. height={200} data = {fuzhu} id="fuzhu">
  1176. <Column width={80} align="center">
  1177. <HeaderCell style={{padding: 0}}>
  1178. <div style={{lineHeight: '40px'}}>
  1179. <Checkbox inline checked={checked} indeterminate={indeterminate} onChange={handleCheckAll} disabled={!fuzhuEnable}
  1180. ></Checkbox>
  1181. </div>
  1182. </HeaderCell>
  1183. <CheckCell dataKey="id" checkedKeys={checkedKeys} onChange={handleCheck} disabled={!fuzhuEnable}></CheckCell>
  1184. </Column>
  1185. <Column width={80} align="center">
  1186. <HeaderCell style={{ "font-size": "0.875rem" }}>序号</HeaderCell>
  1187. <Cell dataKey="序号" style={{ "font-size": "0.875rem" }}></Cell>
  1188. </Column>
  1189. <Column width={120} align="center">
  1190. <HeaderCell style={{ "font-size": "0.875rem" }}>编号</HeaderCell>
  1191. <Cell dataKey="编号" style={{ "font-size": "0.875rem" }}></Cell>
  1192. </Column>
  1193. <Column fullText width={650} align="center">
  1194. <HeaderCell style={{ "font-size": "0.875rem" }}>说明</HeaderCell>
  1195. <Cell dataKey="说明" style={{ "font-size": "0.875rem" }}></Cell>
  1196. </Column>
  1197. </Table>
  1198. </CustomProvider>
  1199. </Box>
  1200. </TabPanel>
  1201. <TabPanel sx={{p: 1}} value="5">
  1202. <Box sx={{maxHeight: `190px`}}>
  1203. <FormControl>
  1204. <FormLabel id="demo-controlled-radio-buttons-group">说明</FormLabel>
  1205. <RadioGroup
  1206. aria-labelledby="demo-controlled-radio-buttons-group"
  1207. name="controlled-radio-buttons-group"
  1208. value={valueYuban}
  1209. onChange={onSelectChange2}
  1210. >
  1211. <FormControlLabel disabled = {!yubanEnable} value="0" control={<Radio />} label={
  1212. <Typography sx={{fontSize: "0.875rem"}} >无</Typography>
  1213. } />
  1214. <FormControlLabel disabled = {!yubanEnable} value="1" control={<Radio />} label={
  1215. <Typography sx={{fontSize: "0.875rem"}} >湿拌砂浆</Typography>
  1216. } />
  1217. <FormControlLabel disabled = {!yubanEnable} value="2" control={<Radio />} label={
  1218. <Typography sx={{fontSize: "0.875rem"}} >散装干拌(混)砂浆</Typography>
  1219. } />
  1220. <FormControlLabel disabled = {!yubanEnable} value="3" control={<Radio />} label={
  1221. <Typography sx={{fontSize: "0.875rem"}} >袋装干拌(混)砂浆</Typography>
  1222. } />
  1223. </RadioGroup>
  1224. </FormControl>
  1225. </Box>
  1226. </TabPanel>
  1227. <TabPanel sx={{p: 1}} value="6">
  1228. <div ref={tuijianRef}></div>
  1229. </TabPanel>
  1230. </TabContext>
  1231. </Box>
  1232. </Stack>
  1233. );
  1234. }