|
|
@@ -1,6 +1,5 @@
|
|
|
import * as React from 'react';
|
|
|
import Box from "@mui/material/Box";
|
|
|
-import {RichTreeView } from "@mui/x-tree-view/RichTreeView";
|
|
|
import { Grid } from '@mui/material';
|
|
|
import Tab from "@mui/material/Tab";
|
|
|
import TabContext from "@mui/lab/TabContext";
|
|
|
@@ -9,46 +8,49 @@ import TabPanel from "@mui/lab/TabPanel";
|
|
|
import Stack from "@mui/material/Stack";
|
|
|
//registerPlugin(NestedRows);
|
|
|
import Service from './Service';
|
|
|
-import { Table, ConfigProvider, Button as AButton } from "antd";
|
|
|
+import { Table, ConfigProvider } from "antd";
|
|
|
import EditableSelect from './EditableSelect';
|
|
|
import EditableSelectGC from './EditableSelectGC';
|
|
|
import Editable from './Editable';
|
|
|
import Button from '@mui/material/Button';
|
|
|
-
|
|
|
+import {TabulatorFull as Tabulator} from "tabulator-tables"; //import Tabulator library
|
|
|
+import "tabulator-tables/dist/css/tabulator.min.css"; //import Tabulator stylesheet
|
|
|
+import './Tabulator.css';
|
|
|
import {copy} from './utils';
|
|
|
|
|
|
export default function Qufei({id, qufeiCallback}) {
|
|
|
|
|
|
- const [detail, setDetail] = React.useState([
|
|
|
- {"序号": null, "清单编码" : null, "名称" : null,"项目特征" : null,
|
|
|
- "计算规则" : null,
|
|
|
- "单位" : null,
|
|
|
- "数量": null,
|
|
|
- "综合单价" : null,
|
|
|
- "合价" : null,
|
|
|
- "人工费": null,
|
|
|
- "主材费" : null,
|
|
|
- "设备费": null,
|
|
|
- "辅材费": null,
|
|
|
- "材料费" : null,
|
|
|
- "机械费" : null,
|
|
|
- "管理费": null,
|
|
|
- "利润": null,
|
|
|
- "暂估价" : null,
|
|
|
- "综合人工工日" : null,
|
|
|
- "备注" : null}]
|
|
|
-);
|
|
|
+ const [detail, setDetail] = React.useState([]);
|
|
|
|
|
|
const hotRef = React.useRef(null);
|
|
|
+const myRef = React.useRef();
|
|
|
+const myTable = React.useRef(null);
|
|
|
const [expandedRowKeys, setExpandedRowKeys] = React.useState([]);
|
|
|
const [selectedRowKeys, setSelectedRowKeys] = React.useState([]);
|
|
|
|
|
|
|
|
|
|
|
|
const apply = () => {
|
|
|
- let checked = check(detail);
|
|
|
+ let checked = check(myTable.current.getData());
|
|
|
if (checked) {
|
|
|
- qufeiCallback(id, detail);
|
|
|
+ let origin = myTable.current.getData();
|
|
|
+ let y = origin.map(z=>{
|
|
|
+ z["children"] = z['_children'];
|
|
|
+ return z;
|
|
|
+ });
|
|
|
+ let t = y.map(z=>{
|
|
|
+ if (z.hasOwnProperty("children")) {
|
|
|
+ let children = z["children"];
|
|
|
+ for (let i = 0; i < children.length; i++) {
|
|
|
+ let child = children[i];
|
|
|
+ if (child.hasOwnProperty("_children")) {
|
|
|
+ child["children"] = child["_children"];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return z;
|
|
|
+ });
|
|
|
+ qufeiCallback(id, t);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
@@ -60,8 +62,8 @@ const check = (data) => {
|
|
|
if (data[i]['利润(%)'].length == 0) {
|
|
|
return false;
|
|
|
}
|
|
|
- if (data[i].hasOwnProperty('children')) {
|
|
|
- let checked = check(data[i]['children']);
|
|
|
+ if (data[i].hasOwnProperty('_children')) {
|
|
|
+ let checked = check(data[i]['_children']);
|
|
|
if (!checked) {
|
|
|
return false;
|
|
|
}
|
|
|
@@ -274,8 +276,8 @@ const traverse = (data) => {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- if (data[i].hasOwnProperty("children")) {
|
|
|
- traverse(data[i]['children']);
|
|
|
+ if (data[i].hasOwnProperty("_children")) {
|
|
|
+ traverse(data[i]['_children']);
|
|
|
}
|
|
|
}
|
|
|
return data;
|
|
|
@@ -284,231 +286,376 @@ const traverse = (data) => {
|
|
|
|
|
|
|
|
|
const handleChangeLR = (value) => {
|
|
|
- if (selectedRowKeys.length > 0 && detail.length > 0) {
|
|
|
- let selected = selectedRowKeys[0];
|
|
|
- if (detail[0]['key'] == selected) {
|
|
|
+
|
|
|
+ let selected = value.row.getData()['key'];
|
|
|
+ let all = value.row.table.getData();
|
|
|
+ if (all[0]['key'] == selected) {
|
|
|
//总选择
|
|
|
- let newData = copy(detail);
|
|
|
- newData[0]['利润(%)'] = value;
|
|
|
- for(let i = 0; i < newData[0]["children"].length; i++) {
|
|
|
- let child = newData[0]['children'][i];
|
|
|
- child['利润(%)'] = value;
|
|
|
- for(let j = 0; j < child['children'].length; j++) {
|
|
|
- child['children'][j]['利润(%)'] = value;
|
|
|
+ let newData = copy(all);
|
|
|
+ newData[0]['利润(%)'] = value.value;
|
|
|
+ for(let i = 0; i < newData[0]["_children"].length; i++) {
|
|
|
+ let child = newData[0]['_children'][i];
|
|
|
+ child['利润(%)'] = value.value;
|
|
|
+ for(let j = 0; j < child['_children'].length; j++) {
|
|
|
+ child['_children'][j]['利润(%)'] = value.value;
|
|
|
}
|
|
|
}
|
|
|
- setDetail(newData);
|
|
|
+ myTable.current.replaceData(newData);
|
|
|
|
|
|
}
|
|
|
- else if (detail[0]["children"].filter(x=>x['key'] == selected).length > 0) {
|
|
|
+ else if (all[0]["_children"].filter(x=>x['key'] == selected).length > 0) {
|
|
|
//某个单项工程
|
|
|
- let newData = copy(detail);
|
|
|
- for(let i = 0; i < newData[0]["children"].length; i++) {
|
|
|
- let child = newData[0]['children'][i];
|
|
|
+ let newData = copy(all);
|
|
|
+ for(let i = 0; i < newData[0]["_children"].length; i++) {
|
|
|
+ let child = newData[0]['_children'][i];
|
|
|
if (child['key'] == selected) {
|
|
|
- child['利润(%)'] = value;
|
|
|
- for(let j = 0; j < child['children'].length; j++) {
|
|
|
- child['children'][j]['利润(%)'] = value;
|
|
|
+ child['利润(%)'] = value.value;
|
|
|
+ for(let j = 0; j < child['_children'].length; j++) {
|
|
|
+ child['_children'][j]['利润(%)'] = value.value;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- setDetail(newData);
|
|
|
+ myTable.current.replaceData(newData);
|
|
|
} else {
|
|
|
//具体一行
|
|
|
- let newData = copy(detail);
|
|
|
- for(let i = 0; i < newData[0]["children"].length; i++) {
|
|
|
- let child = newData[0]['children'][i];
|
|
|
+ let newData = copy(all);
|
|
|
+ for(let i = 0; i < newData[0]["_children"].length; i++) {
|
|
|
+ let child = newData[0]['_children'][i];
|
|
|
|
|
|
- for(let j = 0; j < child['children'].length; j++) {
|
|
|
- if (child['children'][j]['key'] == selected) {
|
|
|
- child['children'][j]['利润(%)'] = value;
|
|
|
+ for(let j = 0; j < child['_children'].length; j++) {
|
|
|
+ if (child['_children'][j]['key'] == selected) {
|
|
|
+ child['_children'][j]['利润(%)'] = value.value;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
- setDetail(newData);
|
|
|
+ myTable.current.replaceData(newData);
|
|
|
}
|
|
|
|
|
|
|
|
|
- }
|
|
|
+
|
|
|
};
|
|
|
|
|
|
|
|
|
const handleChangeGLF = (value) => {
|
|
|
- if (selectedRowKeys.length > 0 && detail.length > 0) {
|
|
|
- let selected = selectedRowKeys[0];
|
|
|
- if (detail[0]['key'] == selected) {
|
|
|
+
|
|
|
+ let selected = value.row.getData()['key'];
|
|
|
+ let all = value.row.table.getData();
|
|
|
+ if (all[0]['key'] == selected) {
|
|
|
//总选择
|
|
|
- let newData = copy(detail);
|
|
|
- newData[0]['管理费(%)'] = value;
|
|
|
- for(let i = 0; i < newData[0]["children"].length; i++) {
|
|
|
- let child = newData[0]['children'][i];
|
|
|
- child['管理费(%)'] = value;
|
|
|
- for(let j = 0; j < child['children'].length; j++) {
|
|
|
- child['children'][j]['管理费(%)'] = value;
|
|
|
+ let newData = copy(all);
|
|
|
+ newData[0]['管理费(%)'] = value.value;
|
|
|
+ for(let i = 0; i < newData[0]["_children"].length; i++) {
|
|
|
+ let child = newData[0]['_children'][i];
|
|
|
+ child['管理费(%)'] = value.value;
|
|
|
+ for(let j = 0; j < child['_children'].length; j++) {
|
|
|
+ child['_children'][j]['管理费(%)'] = value.value;
|
|
|
}
|
|
|
}
|
|
|
- setDetail(newData);
|
|
|
+ myTable.current.replaceData(newData);
|
|
|
|
|
|
}
|
|
|
- else if (detail[0]["children"].filter(x=>x['key'] == selected).length > 0) {
|
|
|
+ else if (all[0]["_children"].filter(x=>x['key'] == selected).length > 0) {
|
|
|
//某个单项工程
|
|
|
- let newData = copy(detail);
|
|
|
- for(let i = 0; i < newData[0]["children"].length; i++) {
|
|
|
- let child = newData[0]['children'][i];
|
|
|
+ let newData = copy(all);
|
|
|
+ for(let i = 0; i < newData[0]["_children"].length; i++) {
|
|
|
+ let child = newData[0]['_children'][i];
|
|
|
if (child['key'] == selected) {
|
|
|
- child['管理费(%)'] = value;
|
|
|
- for(let j = 0; j < child['children'].length; j++) {
|
|
|
- child['children'][j]['管理费(%)'] = value;
|
|
|
+ child['管理费(%)'] = value.value;
|
|
|
+ for(let j = 0; j < child['_children'].length; j++) {
|
|
|
+ child['_children'][j]['管理费(%)'] = value.value;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- setDetail(newData);
|
|
|
+ myTable.current.replaceData(newData);
|
|
|
} else {
|
|
|
//具体一行
|
|
|
- let newData = copy(detail);
|
|
|
- for(let i = 0; i < newData[0]["children"].length; i++) {
|
|
|
- let child = newData[0]['children'][i];
|
|
|
+ let newData = copy(all);
|
|
|
+ for(let i = 0; i < newData[0]["_children"].length; i++) {
|
|
|
+ let child = newData[0]['_children'][i];
|
|
|
|
|
|
- for(let j = 0; j < child['children'].length; j++) {
|
|
|
- if (child['children'][j]['key'] == selected) {
|
|
|
- child['children'][j]['管理费(%)'] = value;
|
|
|
+ for(let j = 0; j < child['_children'].length; j++) {
|
|
|
+ if (child['_children'][j]['key'] == selected) {
|
|
|
+ child['_children'][j]['管理费(%)'] = value.value;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
- setDetail(newData);
|
|
|
+ myTable.current.replaceData(newData);
|
|
|
}
|
|
|
|
|
|
|
|
|
- }
|
|
|
+
|
|
|
};
|
|
|
|
|
|
|
|
|
const handleChange = (value) => {
|
|
|
- if (selectedRowKeys.length > 0 && detail.length > 0) {
|
|
|
- let selected = selectedRowKeys[0];
|
|
|
- if (detail[0]['key'] == selected) {
|
|
|
+
|
|
|
+ let selected = value.row.getData()['key'];
|
|
|
+ let all = value.row.table.getData();
|
|
|
+ if (all[0]['key'] == selected) {
|
|
|
//总选择
|
|
|
- let newData = copy(detail);
|
|
|
- newData[0]['工程类别'] = value;
|
|
|
- for(let i = 0; i < newData[0]["children"].length; i++) {
|
|
|
- let child = newData[0]['children'][i];
|
|
|
- child['工程类别'] = value;
|
|
|
- for(let j = 0; j < child['children'].length; j++) {
|
|
|
- child['children'][j]['工程类别'] = value;
|
|
|
+ let newData = copy(all);
|
|
|
+ newData[0]['工程类别'] = value.value;
|
|
|
+ for(let i = 0; i < newData[0]["_children"].length; i++) {
|
|
|
+ let child = newData[0]['_children'][i];
|
|
|
+ child['工程类别'] = value.value;
|
|
|
+ for(let j = 0; j < child['_children'].length; j++) {
|
|
|
+ child['_children'][j]['工程类别'] = value.value;
|
|
|
}
|
|
|
}
|
|
|
- setDetail(traverse(newData));
|
|
|
+ myTable.current.replaceData(traverse(newData));
|
|
|
|
|
|
}
|
|
|
- else if (detail[0]["children"].filter(x=>x['key'] == selected).length > 0) {
|
|
|
+ else if (all[0]["_children"].filter(x=>x['key'] == selected).length > 0) {
|
|
|
//某个单项工程
|
|
|
- let newData = copy(detail);
|
|
|
- for(let i = 0; i < newData[0]["children"].length; i++) {
|
|
|
- let child = newData[0]['children'][i];
|
|
|
+ let newData = copy(all);
|
|
|
+ for(let i = 0; i < newData[0]["_children"].length; i++) {
|
|
|
+ let child = newData[0]['_children'][i];
|
|
|
if (child['key'] == selected) {
|
|
|
- child['工程类别'] = value;
|
|
|
- for(let j = 0; j < child['children'].length; j++) {
|
|
|
- child['children'][j]['工程类别'] = value;
|
|
|
+ child['工程类别'] = value.value;
|
|
|
+ for(let j = 0; j < child['_children'].length; j++) {
|
|
|
+ child['_children'][j]['工程类别'] = value.value;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- setDetail(traverse(newData));
|
|
|
+ myTable.current.replaceData(traverse(newData));
|
|
|
} else {
|
|
|
//具体一行
|
|
|
- let newData = copy(detail);
|
|
|
- for(let i = 0; i < newData[0]["children"].length; i++) {
|
|
|
- let child = newData[0]['children'][i];
|
|
|
+ let newData = copy(all);
|
|
|
+ for(let i = 0; i < newData[0]["_children"].length; i++) {
|
|
|
+ let child = newData[0]['_children'][i];
|
|
|
|
|
|
- for(let j = 0; j < child['children'].length; j++) {
|
|
|
- if (child['children'][j]['key'] == selected) {
|
|
|
- child['children'][j]['工程类别'] = value;
|
|
|
+ for(let j = 0; j < child['_children'].length; j++) {
|
|
|
+ if (child['_children'][j]['key'] == selected) {
|
|
|
+ child['_children'][j]['工程类别'] = value.value;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
- setDetail(traverse(newData));
|
|
|
+ myTable.current.replaceData(traverse(newData));
|
|
|
}
|
|
|
|
|
|
|
|
|
- }
|
|
|
+
|
|
|
};
|
|
|
|
|
|
const handleChangeGC = (value) => {
|
|
|
- if (selectedRowKeys.length > 0 && detail.length > 0) {
|
|
|
- let selected = selectedRowKeys[0];
|
|
|
- if (detail[0]['key'] == selected) {
|
|
|
+
|
|
|
+ let selected = value.row.getData()['key'];
|
|
|
+ let all = value.row.table.getData();
|
|
|
+ if (all[0]['key'] == selected) {
|
|
|
//总选择
|
|
|
- let newData = copy(detail);
|
|
|
- newData[0]['工程类型'] = value;
|
|
|
- for(let i = 0; i < newData[0]["children"].length; i++) {
|
|
|
- let child = newData[0]['children'][i];
|
|
|
- child['工程类型'] = value;
|
|
|
- for(let j = 0; j < child['children'].length; j++) {
|
|
|
- child['children'][j]['工程类型'] = value;
|
|
|
+ let newData = copy(all);
|
|
|
+ newData[0]['工程类型'] = value.value;
|
|
|
+ for(let i = 0; i < newData[0]["_children"].length; i++) {
|
|
|
+ let child = newData[0]['_children'][i];
|
|
|
+ child['工程类型'] = value.value;
|
|
|
+ for(let j = 0; j < child['_children'].length; j++) {
|
|
|
+ child['_children'][j]['工程类型'] = value.value;
|
|
|
}
|
|
|
}
|
|
|
- setDetail(traverse(newData));
|
|
|
+ myTable.current.replaceData(traverse(newData));
|
|
|
|
|
|
}
|
|
|
- else if (detail[0]["children"].filter(x=>x['key'] == selected).length > 0) {
|
|
|
+ else if (all[0]["_children"].filter(x=>x['key'] == selected).length > 0) {
|
|
|
//某个单项工程
|
|
|
- let newData = copy(detail);
|
|
|
- for(let i = 0; i < newData[0]["children"].length; i++) {
|
|
|
- let child = newData[0]['children'][i];
|
|
|
+ let newData = copy(all);
|
|
|
+ for(let i = 0; i < newData[0]["_children"].length; i++) {
|
|
|
+ let child = newData[0]['_children'][i];
|
|
|
if (child['key'] == selected) {
|
|
|
- child['工程类型'] = value;
|
|
|
- for(let j = 0; j < child['children'].length; j++) {
|
|
|
- child['children'][j]['工程类型'] = value;
|
|
|
+ child['工程类型'] = value.value;
|
|
|
+ for(let j = 0; j < child['_children'].length; j++) {
|
|
|
+ child['_children'][j]['工程类型'] = value.value;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- setDetail(traverse(newData));
|
|
|
+ myTable.current.replaceData(traverse(newData));
|
|
|
} else {
|
|
|
//具体一行
|
|
|
- let newData = copy(detail);
|
|
|
- for(let i = 0; i < newData[0]["children"].length; i++) {
|
|
|
- let child = newData[0]['children'][i];
|
|
|
+ let newData = copy(all);
|
|
|
+ for(let i = 0; i < newData[0]["_children"].length; i++) {
|
|
|
+ let child = newData[0]['_children'][i];
|
|
|
|
|
|
- for(let j = 0; j < child['children'].length; j++) {
|
|
|
- if (child['children'][j]['key'] == selected) {
|
|
|
- child['children'][j]['工程类型'] = value;
|
|
|
+ for(let j = 0; j < child['_children'].length; j++) {
|
|
|
+ if (child['_children'][j]['key'] == selected) {
|
|
|
+ child['_children'][j]['工程类型'] = value.value;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
- setDetail(traverse(newData));
|
|
|
+ myTable.current.replaceData(traverse(newData));
|
|
|
}
|
|
|
|
|
|
|
|
|
- }
|
|
|
+
|
|
|
};
|
|
|
|
|
|
-function selectRow(record) {
|
|
|
- /*
|
|
|
- const selectedRowKeys_ = [...selectedRowKeys];
|
|
|
- if (selectedRowKeys_.indexOf(record.key) >= 0) {
|
|
|
- selectedRowKeys_.splice(selectedRowKeys_.indexOf(record.key), 1);
|
|
|
- } else {
|
|
|
- selectedRowKeys_.push(record.key);
|
|
|
- }*/
|
|
|
- setSelectedRowKeys([record.key]);
|
|
|
-}
|
|
|
+
|
|
|
React.useEffect(
|
|
|
() => {
|
|
|
-
|
|
|
+ myTable.current = new Tabulator(myRef.current, {
|
|
|
+
|
|
|
+ index: "key",
|
|
|
+ height: 600,
|
|
|
+ data: detail, //link data to table
|
|
|
+ reactiveData: false, //enable data reactivity
|
|
|
+ dataTreeStartExpanded:true,
|
|
|
+ dataTree: true,
|
|
|
+ selectableRows:1, //make rows selectable
|
|
|
+ editTriggerEvent:"dblclick", //trigger edit on double click
|
|
|
+ dataTreeStartExpanded:function(row, level){
|
|
|
+ //console.log(row);
|
|
|
+ //console.log(level);
|
|
|
+ return true; //expand rows where the "driver" data field is true;
|
|
|
+ },
|
|
|
+ columns: [ //Define Table Columns 序号", "名称", "取费基数", "计算基础","费率", "金额", "类别
|
|
|
+ {title:"名称", field:"名称", width:250, headerSort:false, formatter:"textarea"}, //hide this column first
|
|
|
+ {title:"工程类型", field:"工程类型", width:100 , headerSort:false, formatter:"textarea", editor: "list", editorParams: {
|
|
|
+ values: [
|
|
|
+ { //option group
|
|
|
+ label:"建筑工程",
|
|
|
+ options:[ //options in option group
|
|
|
+ {
|
|
|
+ label:"建筑工程",
|
|
|
+ value:"建筑工程",
|
|
|
+
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label:"单独预制构件制作",
|
|
|
+ value:"单独预制构件制作",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label:"打预制桩、单独构件吊装",
|
|
|
+ value:"打预制桩、单独构件吊装",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label:"制作兼打桩",
|
|
|
+ value:"制作兼打桩",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label:"大型土石方工程",
|
|
|
+ value:"大型土石方工程",
|
|
|
+ },
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ { //option group
|
|
|
+ label:"单独装饰工程",
|
|
|
+ options:[ //options in option group
|
|
|
+ {
|
|
|
+ label:"单独装饰工程",
|
|
|
+ value:"单独装饰工程",
|
|
|
+
|
|
|
+ },
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ { //option group
|
|
|
+ label:"安装工程",
|
|
|
+ options:[ //options in option group
|
|
|
+ {
|
|
|
+ label:"安装工程",
|
|
|
+ value:"安装工程",
|
|
|
+
|
|
|
+ },
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ { //option group
|
|
|
+ label:"市政工程",
|
|
|
+ options:[ //options in option group
|
|
|
+ {
|
|
|
+ label:"通用项目、道路、排水工程",
|
|
|
+ value:"通用项目、道路、排水工程",
|
|
|
+
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label:"桥梁、水工构筑物",
|
|
|
+ value:"桥梁、水工构筑物",
|
|
|
+
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label:"给水、燃气与集中供热",
|
|
|
+ value:"给水、燃气与集中供热",
|
|
|
+
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label:"路灯及交通设施工程",
|
|
|
+ value:"路灯及交通设施工程",
|
|
|
+
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label:"(市)大型土石方工程",
|
|
|
+ value:"(市)大型土石方工程",
|
|
|
+
|
|
|
+ },
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ ]
|
|
|
+ }},
|
|
|
+ {title:"工程类别", field:"工程类别", width:100, headerSort:false, formatter: "textarea" , editor: "list", editorParams: {
|
|
|
+ values: ["一类工程", "二类工程", "三类工程"]
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+ {title:"管理费(%)", field:"管理费(%)", width:100, headerSort:false, formatter:"textarea", editor: "input"},
|
|
|
+ {title:"利润(%)", field:"利润(%)", width:150, headerSort:false, formatter:"textarea", editor: "input" },
|
|
|
+ {title:"备注", field:"备注", width:200, headerSort:false, formatter:"textarea"},
|
|
|
+
|
|
|
+ ]
|
|
|
+
|
|
|
+ });//init table
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ myTable.current.on("tableBuilt", () => {
|
|
|
Service.generateQufei(id).then(x=>{
|
|
|
|
|
|
- setDetail(x);
|
|
|
+ console.log(x);
|
|
|
+ let y = x.map(z=>{
|
|
|
+ z["_children"] = z['children'];
|
|
|
+ return z;
|
|
|
+ });
|
|
|
+ let t = y.map(z=>{
|
|
|
+ if (z.hasOwnProperty("_children")) {
|
|
|
+ let children = z["_children"];
|
|
|
+ for (let i = 0; i < children.length; i++) {
|
|
|
+ let child = children[i];
|
|
|
+ if (child.hasOwnProperty("children")) {
|
|
|
+ child["_children"] = child["children"];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return z;
|
|
|
+ });
|
|
|
+ myTable.current.replaceData(t);
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ myTable.current.on("cellEdited", function(cell){
|
|
|
+ console.log(cell._cell);
|
|
|
+ if (cell._cell.column.field == '工程类型') {
|
|
|
+ handleChangeGC(cell._cell);
|
|
|
+ }
|
|
|
+ if (cell._cell.column.field == '工程类别') {
|
|
|
+ handleChange(cell._cell);
|
|
|
+ }
|
|
|
+ if (cell._cell.column.field == '管理费(%)') {
|
|
|
+ handleChangeGLF(cell._cell);
|
|
|
+ }
|
|
|
+ if (cell._cell.column.field == '利润(%)') {
|
|
|
+ handleChangeLR(cell._cell);
|
|
|
+ }
|
|
|
});
|
|
|
|
|
|
|
|
|
@@ -517,130 +664,11 @@ React.useEffect(
|
|
|
|
|
|
|
|
|
return (
|
|
|
- <Box>
|
|
|
+ <Box sx={{ width: '70vw'}}>
|
|
|
<Button variant="outlined" onClick={apply}>应用</Button>
|
|
|
- <ConfigProvider
|
|
|
- theme={{
|
|
|
- components: {
|
|
|
- Table: {
|
|
|
- /* here is your component tokens */
|
|
|
- cellPaddingBlock : 8
|
|
|
- },
|
|
|
- },
|
|
|
- }}
|
|
|
- >
|
|
|
- <Table
|
|
|
- dataSource={detail}
|
|
|
-
|
|
|
-
|
|
|
- //afterSelection={handleSelection}
|
|
|
- //afterSelection={handleSelection}
|
|
|
- ref = {hotRef}
|
|
|
- expandable = {
|
|
|
- {
|
|
|
- expandedRowKeys,
|
|
|
- onExpand: (expandable, record) => {
|
|
|
- if (expandable) {
|
|
|
- setExpandedRowKeys([...expandedRowKeys, record.key]);
|
|
|
- } else {
|
|
|
- setExpandedRowKeys(expandedRowKeys.filter((id) => record.key !== id));
|
|
|
- }
|
|
|
- },
|
|
|
- expandRowByClick: true
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- rowSelection= {rowSelection}
|
|
|
- onRow={(record)=>({
|
|
|
- onClick: () => {
|
|
|
- selectRow(record);
|
|
|
- }
|
|
|
- })}
|
|
|
- scroll={{ x: 'max-content' , y : 'calc(100vh - 200px)'}}
|
|
|
- //pagination={{ position: ['none', 'none'] }}
|
|
|
- pagination={false}
|
|
|
- columns = {[
|
|
|
-
|
|
|
- { dataIndex: '操作', title : '操作', key : '操作' , width : 30 , fixed: 'left' },
|
|
|
- { dataIndex: '名称' , title : '名称' , key : '名称' , width : 250 },
|
|
|
- { dataIndex: '工程类型' , title : '工程类型' ,
|
|
|
- key : '工程类型' , width : 150 ,
|
|
|
- render: (text, record) => {
|
|
|
- //console.log("column render");
|
|
|
- //console.log("text".concat(text));
|
|
|
- //console.log(record);
|
|
|
-
|
|
|
- return (
|
|
|
- <EditableSelectGC initialText={text} onChange={handleChangeGC}
|
|
|
- >
|
|
|
- </EditableSelectGC>
|
|
|
- );
|
|
|
-
|
|
|
- //console.log(text);
|
|
|
-
|
|
|
- }
|
|
|
- },
|
|
|
- { dataIndex: '工程类别' , title : '工程类别' ,
|
|
|
- key : '工程类别' , width : 100 ,
|
|
|
- render: (text, record) => {
|
|
|
- //console.log("column render");
|
|
|
- //console.log("text".concat(text));
|
|
|
- //console.log(record);
|
|
|
-
|
|
|
- return (
|
|
|
- <EditableSelect initialText={text} onChange={handleChange}
|
|
|
- >
|
|
|
- </EditableSelect>
|
|
|
- );
|
|
|
-
|
|
|
- //console.log(text);
|
|
|
-
|
|
|
- }
|
|
|
- },
|
|
|
- { dataIndex: '管理费(%)' , title : '管理费(%)' , key : '管理费(%)' , width : 50 ,
|
|
|
- render: (text, record) => {
|
|
|
- //console.log("column render");
|
|
|
- //console.log("text".concat(text));
|
|
|
- //console.log(record);
|
|
|
-
|
|
|
- return (
|
|
|
- <Editable initialText={text} onChange={handleChangeGLF}
|
|
|
- >
|
|
|
- </Editable>
|
|
|
- );
|
|
|
-
|
|
|
- //console.log(text);
|
|
|
-
|
|
|
- } },
|
|
|
- { dataIndex: '利润(%)' , title : '利润(%)' , key : '利润(%)' , width : 50 ,
|
|
|
- render: (text, record) => {
|
|
|
- //console.log("column render");
|
|
|
- //console.log("text".concat(text));
|
|
|
- //console.log(record);
|
|
|
-
|
|
|
- return (
|
|
|
- <Editable initialText={text} onChange={handleChangeLR}
|
|
|
- >
|
|
|
- </Editable>
|
|
|
- );
|
|
|
-
|
|
|
- //console.log(text);
|
|
|
-
|
|
|
- }
|
|
|
- },
|
|
|
- { dataIndex: '备注', title : '备注', key : '备注' , width : 100 },
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- ]}
|
|
|
-
|
|
|
- />
|
|
|
- </ConfigProvider>
|
|
|
-
|
|
|
+
|
|
|
+ <div ref={myRef}>
|
|
|
+ </div>
|
|
|
|
|
|
</Box>
|
|
|
|