Commit 4fe036c9b215ca516ab411eec0c4f730506b4503

Authored by chenxt
1 parent 1d3f0f77

功能模块页面排序

src/components/Common/AffixMenu.js
@@ -11,7 +11,46 @@ import SvgIcon from '../SvgIcon'; @@ -11,7 +11,46 @@ import SvgIcon from '../SvgIcon';
11 11
12 const { Option } = Select; 12 const { Option } = Select;
13 const { TabPane } = Tabs; 13 const { TabPane } = Tabs;
  14 +const type = 'DraggableBodyRow';
  15 +// 自定义可拖拽的表格行
  16 +const DraggableBodyRow = ({ index, moveRow, className, style, ...restProps }) => {
  17 + const ref = React.useRef();
  18 + const [{ isOver, dropClassName }, drop] = useDrop({
  19 + accept: type,
  20 + collect: (monitor) => {
  21 + const { index: dragIndex } = monitor.getItem() || {};
  22 + if (dragIndex === index) {
  23 + return {};
  24 + }
  25 + return {
  26 + isOver: monitor.isOver(),
  27 + dropClassName: dragIndex < index ? 'drop-over-downward' : 'drop-over-upward',
  28 + };
  29 + },
  30 + drop: (item) => {
  31 + moveRow(item.index, index);
  32 + },
  33 + });
  34 +
  35 + const [, drag] = useDrag({
  36 + type,
  37 + item: { index },
  38 + collect: (monitor) => ({
  39 + isDragging: monitor.isDragging(),
  40 + }),
  41 + });
  42 +
  43 + drop(drag(ref));
14 44
  45 + return (
  46 + <tr
  47 + ref={ref}
  48 + className={`${className}${isOver ? dropClassName : ''}`}
  49 + style={{ cursor: 'move', ...style }}
  50 + {...restProps}
  51 + />
  52 + );
  53 +};
15 class AffixMenuComponent extends Component { 54 class AffixMenuComponent extends Component {
16 constructor(props) { 55 constructor(props) {
17 super(props); 56 super(props);
@@ -367,6 +406,10 @@ class AffixMenuComponent extends Component { @@ -367,6 +406,10 @@ class AffixMenuComponent extends Component {
367 } else { 406 } else {
368 dataSource = this.state[`modalContentData${count}`]; 407 dataSource = this.state[`modalContentData${count}`];
369 } 408 }
  409 + dataSource.forEach((item, index) => {
  410 + // 根据索引来更新 iOrder,使用 index + 1 因为排序通常从1开始,而不是0
  411 + dataSource[index].iOrder = (index + 1) * 10;
  412 + });
370 const columns = [{ 413 const columns = [{
371 title: columniOrder, 414 title: columniOrder,
372 dataIndex: 'iOrder', 415 dataIndex: 'iOrder',
@@ -456,7 +499,11 @@ class AffixMenuComponent extends Component { @@ -456,7 +499,11 @@ class AffixMenuComponent extends Component {
456 } 499 }
457 } 500 }
458 } 501 }
459 - 502 + const components = {
  503 + body: {
  504 + row: DraggableBodyRow,
  505 + },
  506 + };
460 childTable = ( 507 childTable = (
461 <TabPane tab={configName} key={count}> 508 <TabPane tab={configName} key={count}>
462 <div key={count} className={styles.affixMenuTableAll}> 509 <div key={count} className={styles.affixMenuTableAll}>
@@ -466,6 +513,7 @@ class AffixMenuComponent extends Component { @@ -466,6 +513,7 @@ class AffixMenuComponent extends Component {
466 <Table 513 <Table
467 bordered 514 bordered
468 columns={columns} 515 columns={columns}
  516 + components={components}
469 dataSource={dataSource_dep} 517 dataSource={dataSource_dep}
470 pagination={false} 518 pagination={false}
471 scroll={{ y: 310 }} 519 scroll={{ y: 310 }}
src/components/Common/CommonNewBill.js
@@ -2046,6 +2046,18 @@ const BillComponent = Form.create({ @@ -2046,6 +2046,18 @@ const BillComponent = Form.create({
2046 onChange: props.onTitleChange.bind(this, "slave0"), 2046 onChange: props.onTitleChange.bind(this, "slave0"),
2047 }, 2047 },
2048 }; 2048 };
  2049 +
  2050 + if (sModelsId === '16411004790004762980820285096000') {
  2051 + slaveTableProps.tableProps.AutoTableHeight = 344
  2052 + slaveTableProps.isDragAndDrop = true
  2053 + slaveTableProps.onMoveRow = props.onMoveRow
  2054 + slaveTableProps.isSettingFunctions = true
  2055 + slave0TableProps.tableProps.AutoTableHeight = 344
  2056 + slave0TableProps.isDragAndDrop = true
  2057 + slave0TableProps.onMoveRow = props.onMove0Row
  2058 + slave0TableProps.isSettingFunctions = true
  2059 + slave0TableProps.noVlistTable = true
  2060 + }
2049 const bCheck1 = commonUtils.isNotEmptyObject(slave1Config) && slave1Config.sTbName === "sysbillcheckresult" ? true : false; 2061 const bCheck1 = commonUtils.isNotEmptyObject(slave1Config) && slave1Config.sTbName === "sysbillcheckresult" ? true : false;
2050 const slave1TableProps = { 2062 const slave1TableProps = {
2051 ...commonBusiness.getTableTypes("slave1", props), 2063 ...commonBusiness.getTableTypes("slave1", props),
src/components/Common/CommonNewBillEvent.js
@@ -6518,36 +6518,32 @@ export default ChildComponent =&gt; { @@ -6518,36 +6518,32 @@ export default ChildComponent =&gt; {
6518 /* 拖拽表格树形节点 */ 6518 /* 拖拽表格树形节点 */
6519 handleMoveRow = (dragIndex, hoverIndex, dragKey, hoverKey, props) => { 6519 handleMoveRow = (dragIndex, hoverIndex, dragKey, hoverKey, props) => {
6520 const { slaveData: data } = this.props; 6520 const { slaveData: data } = this.props;
6521 - // const dragRow = data[dragIndex]; 6521 + const newData = [...data];
  6522 + const [removed] = newData.splice(dragIndex, 1);
  6523 + newData.splice(hoverIndex, 0, removed);
6522 const dragObject = commonUtils.isNotEmptyArr(data.filter(ele => ele.sId === dragKey)) ? data.filter(ele => ele.sId === dragKey)[0] : {}; 6524 const dragObject = commonUtils.isNotEmptyArr(data.filter(ele => ele.sId === dragKey)) ? data.filter(ele => ele.sId === dragKey)[0] : {};
6523 - const hoverObject = commonUtils.isNotEmptyArr(data.filter(ele => ele.sId === hoverKey)) ? data.filter(ele => ele.sId === hoverKey)[0] : {};  
6524 - // 同级菜单的移动  
6525 - let newData = data.filter(ele => ele.sId !== dragKey);  
6526 - let insertIndex = 0;  
6527 - if (commonUtils.isNotEmptyArr(newData)) {  
6528 - newData.forEach((ele, index) => {  
6529 - if (ele.sId === hoverKey) {  
6530 - if (dragIndex > hoverIndex) {  
6531 - // 上移:dragKey表示的元素 放到 hoverKey表示的元素之前  
6532 - insertIndex = index;  
6533 - } else {  
6534 - // 下移 dragKey表示的元素 放到 hoverKey表示的元素之后  
6535 - insertIndex = index + 1;  
6536 - }  
6537 - }  
6538 - });  
6539 - newData.splice(insertIndex, 0, dragObject);  
6540 - if (commonUtils.isNotEmptyObject(dragObject)) {  
6541 - dragObject.handleType = dragObject.handleType ? dragObject.handleType : "update";  
6542 - dragObject.iOrder = hoverObject.iOrder + 1  
6543 - }  
6544 - // newData.forEach((item,index) =>{  
6545 - // item.handleType = 'update'  
6546 - // item.iOrder =  
6547 - // })  
6548 - this.props.onSaveState({ slaveData: newData });  
6549 - } 6525 + newData.forEach((item, index) => {
  6526 + // 根据索引来更新 iOrder,使用 index + 1 因为排序通常从1开始,而不是0
  6527 + newData[index].iOrder = (index + 1) * 10;
  6528 + newData[index].handleType = dragObject.handleType ? dragObject.handleType : "update";
  6529 + });
  6530 + this.props.onSaveState({ slaveData: newData });
6550 }; 6531 };
  6532 + handleMove0Row = (dragIndex, hoverIndex, dragKey, hoverKey, props) => {
  6533 + const { slave0Data: data } = this.props;
  6534 + const newData = [...data];
  6535 + const [removed] = newData.splice(dragIndex, 1);
  6536 + newData.splice(hoverIndex, 0, removed);
  6537 + const dragObject = commonUtils.isNotEmptyArr(data.filter(ele => ele.sId === dragKey)) ? data.filter(ele => ele.sId === dragKey)[0] : {};
  6538 + newData.forEach((item, index) => {
  6539 + // 根据索引来更新 iOrder,使用 index + 1 因为排序通常从1开始,而不是0
  6540 + newData[index].iOrder = (index + 1) * 10000;
  6541 + newData[index].handleType = dragObject.handleType ? dragObject.handleType : "update";
  6542 + });
  6543 + this.props.onSaveState({ slave0Data: newData });
  6544 + // }
  6545 + };
  6546 +
6551 render() { 6547 render() {
6552 const { masterData, sModelsType, app } = this.props; 6548 const { masterData, sModelsType, app } = this.props;
6553 const imgSrc = commonBusiness.handleAddIcon(masterData, sModelsType, app); 6549 const imgSrc = commonBusiness.handleAddIcon(masterData, sModelsType, app);
@@ -6610,6 +6606,7 @@ export default ChildComponent =&gt; { @@ -6610,6 +6606,7 @@ export default ChildComponent =&gt; {
6610 onGetParamsValue={this.handleGetParamsValue} 6606 onGetParamsValue={this.handleGetParamsValue}
6611 onSelectCommonPopup={this.handleSelectCommonPopup} 6607 onSelectCommonPopup={this.handleSelectCommonPopup}
6612 onMoveRow={this.handleMoveRow} 6608 onMoveRow={this.handleMoveRow}
  6609 + onMove0Row={this.handleMove0Row}
6613 /> 6610 />
6614 ); 6611 );
6615 } 6612 }
src/components/Common/CommonTable/index.js
@@ -7396,7 +7396,16 @@ class CommonTableRc extends React.Component { @@ -7396,7 +7396,16 @@ class CommonTableRc extends React.Component {
7396 7396
7397 const hasColorInfo = this.props?.masterConfig?.sTableColorTs; 7397 const hasColorInfo = this.props?.masterConfig?.sTableColorTs;
7398 const BtnUpload = commonFunc.showLocalMessage(this.props, "BtnUpload", "上传"); 7398 const BtnUpload = commonFunc.showLocalMessage(this.props, "BtnUpload", "上传");
7399 - 7399 + const { sModelsId } = this.props
  7400 + const columniOrder = commonFunc.showMessage(this.props.app.commonConst, 'columniOrder');/* 排序 */
  7401 + if (sModelsId === '16411004790004762980820285096000') {
  7402 + tableProps.onRow = (record, index) => ({
  7403 + index,
  7404 + moveRow: (dragIndex, hoverIndex, dragKey, hoverKey) => {
  7405 + this.moveRow(dragIndex, hoverIndex, dragKey, hoverKey);
  7406 + },
  7407 + });
  7408 + }
7400 return ( 7409 return (
7401 <FormItem className={styles.subForm} style={{ height: '100%' }}> 7410 <FormItem className={styles.subForm} style={{ height: '100%' }}>
7402 <div className={styles.extraAction} onselectstart="return false"> 7411 <div className={styles.extraAction} onselectstart="return false">