Bjhz.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import * as React from 'react';
  2. import Box from "@mui/material/Box";
  3. import { Grid } from '@mui/material';
  4. import Tab from "@mui/material/Tab";
  5. import TabContext from "@mui/lab/TabContext";
  6. import TabList from "@mui/lab/TabList";
  7. import TabPanel from "@mui/lab/TabPanel";
  8. import Stack from "@mui/material/Stack";
  9. //registerPlugin(NestedRows);
  10. import Service from './Service';
  11. import Button from '@mui/material/Button';
  12. import {copy} from './utils';
  13. import {TabulatorFull as Tabulator} from "tabulator-tables"; //import Tabulator library
  14. import "tabulator-tables/dist/css/tabulator.min.css"; //import Tabulator stylesheet
  15. import './Tabulator.css';
  16. export default function Bjhz({data}) {
  17. const myRef = React.useRef();
  18. const myTable = React.useRef(null);
  19. React.useEffect(() => {
  20. myTable.current = new Tabulator(myRef.current, {
  21. index: "key",
  22. height: 600,
  23. data: data, //link data to table
  24. reactiveData: false, //enable data reactivity
  25. dataTreeStartExpanded:true,
  26. dataTree: true,
  27. selectableRows:1, //make rows selectable
  28. editTriggerEvent:"dblclick", //trigger edit on double click
  29. dataTreeStartExpanded:function(row, level){
  30. //console.log(row);
  31. //console.log(level);
  32. return true; //expand rows where the "driver" data field is true;
  33. },
  34. columns: [ //Define Table Columns 序号", "名称", "取费基数", "计算基础","费率", "金额", "类别
  35. {title:"序号", field:"序号", width:80, headerSort:false,}, //never hide this column
  36. {title:"名称", field:"名称", width:150, headerSort:false, formatter:"textarea"}, //hide this column first
  37. {title:"金额", field:"金额", width:100, formatter:"money", },
  38. {title:"暂估价", field:"暂估价", width:100, formatter:"textarea"},
  39. {title:"类别", field:"类别", width:100, formatter:"textarea"},
  40. ]
  41. });
  42. myTable.current.on("cellDblClick", function(e, cell){
  43. //e - the click event object
  44. //cell - cell component
  45. console.log(cell);
  46. });
  47. //myTable.current.on("rowSelected", handleSelect);
  48. }, [data]);
  49. return (
  50. <div ref={myRef}>
  51. </div>
  52. );
  53. }