From f6626b05f1275cc2f8ca77f773d4f6a6af1b0a89 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 21 十一月 2022 16:11:55 +0800
Subject: [PATCH] 2022-11-21

---
 src/menu/components/table/normal-table/columns/index.jsx |   52 ++++++++++++++++++++++++++++++----------------------
 1 files changed, 30 insertions(+), 22 deletions(-)

diff --git a/src/menu/components/table/normal-table/columns/index.jsx b/src/menu/components/table/normal-table/columns/index.jsx
index d6097f3..e976c72 100644
--- a/src/menu/components/table/normal-table/columns/index.jsx
+++ b/src/menu/components/table/normal-table/columns/index.jsx
@@ -13,7 +13,7 @@
 
 const { confirm } = Modal
 const { Paragraph } = Typography 
-const EditColumn = asyncIconComponent(() => import('./editColumn'))
+const EditColumn = asyncComponent(() => import('./editColumn'))
 const MarkColumn = asyncIconComponent(() => import('@/menu/components/share/markcomponent'))
 const CardCellComponent = asyncComponent(() => import('@/menu/components/card/cardcellcomponent'))
 const MobPagination = asyncIconComponent(() => import('@/menu/components/share/mobPagination'))
@@ -54,8 +54,14 @@
     const { connectDragSource, connectDropTarget, moveCol, dropCol, addElement, updateCol, editColumn, pasteCell, changeStyle, deleteCol, index, column, align, fields, children, ...restProps } = this.props
 
     if (index !== undefined) {
+      let style = {cursor: 'move', textAlign: align}
+      if (column.Width) {
+        style.width = column.Width
+        style.minWidth = column.Width
+      }
+
       return connectDragSource(
-        connectDropTarget(<th {...restProps} index={index} style={{ cursor: 'move', textAlign: align }} onDoubleClick={() => column && this.props.editColumn(column)}>
+        connectDropTarget(<th {...restProps} index={index} style={style} onDoubleClick={() => column && this.props.editColumn(column)}>
           <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={
             <div className="mk-popover-control" onDoubleClick={(e) => e.stopPropagation()}>
               {column && ['custom', 'colspan', 'action'].includes(column.type) ?
@@ -74,8 +80,14 @@
         </th>),
       )
     } else if (column) {
+      let style = {textAlign: align}
+      if (column.Width) {
+        style.width = column.Width
+        style.minWidth = column.Width
+      }
+
       return (
-        <th {...restProps} key={column.uuid} onDoubleClick={() => this.props.editColumn(column)}>
+        <th {...restProps} style={style} key={column.uuid} onDoubleClick={() => this.props.editColumn(column)}>
           <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={
             <div className="mk-popover-control" onDoubleClick={(e) => e.stopPropagation()}>
               {column && ['custom', 'colspan'].includes(column.type) ?
@@ -152,13 +164,13 @@
 
     if (column && column.type === 'custom') {
       return (
-        <td style={{padding: 0, minWidth: column.Width || 100, ...(column.style || {})}} className={className}>
+        <td style={{padding: 0, ...(column.style || {})}} className={className}>
           <CardCellComponent cards={config} cardCell={column} elements={column.elements} updateElement={this.updateCard}/>
         </td>
       )
     } else if (column && column.type === 'action') {
       return (
-        <td style={{padding: '0 5px', textAlign: column.Align, minWidth: column.Width || 100}} className={'action-column ' + className}>
+        <td style={{padding: '0 5px', textAlign: column.Align}} className={'action-column ' + className}>
           <CardCellComponent cards={config} cardCell={column} elements={column.elements} updateElement={this.updateCard}/>
         </td>
       )
@@ -174,7 +186,7 @@
         }
       }
       return (
-        <td style={{...style, minWidth: column.Width || 100}} className={className}>
+        <td style={{...style}} className={className}>
           {column.field ? <Paragraph className="col-copy" copyable={{ text: column.field }}>{val}</Paragraph> : val}
           {column.marks && column.marks.length ? <AntDesignOutlined className="profile"/> : null}
           {column.Hide === 'true' ? <CloseCircleOutlined className="close-col"/> : null}
@@ -277,6 +289,13 @@
     let _columns = fromJS(this.state.columns).toJS()
 
     let col = { focus: true, uuid: Utils.getuuid(), label: 'label', field: '', type: item.subType, elements: [] }
+    if (col.type === 'colspan') {
+      col.subcols = []
+    } else if (col.type === 'action') {
+      col.label = '鎿嶄綔'
+    } else if (col.type === 'index') {
+      col.label = '搴忓彿'
+    }
 
     _columns.splice(hoverIndex, 0, col)
 
@@ -290,7 +309,7 @@
   loopCol = (columns, col) => {
     return columns.map(column => {
       if (column.type === 'colspan') {
-        column.subcols = this.loopCol(column.subcols, col)
+        column.subcols = this.loopCol(column.subcols || [], col)
       }
       if (column.uuid === col.uuid) {
         return col
@@ -309,6 +328,10 @@
       let config = {...this.props.config, cols: _columns}
       if (btn) {
         config.action = config.action.filter(item => item.uuid !== btn.uuid)
+
+        setTimeout(() => {
+          MKEmitter.emit('revert', config.uuid)
+        }, 200)
       }
 
       this.props.updatecolumn(config)
@@ -422,7 +445,6 @@
   }
 
   deleteCol = (col) => {
-    const { appType } = this.state
     let _columns = fromJS(this.state.columns).toJS()
 
     _columns = this.loopDelCol(_columns, col)
@@ -432,19 +454,6 @@
     }, () => {
       this.props.updatecolumn({...this.props.config, cols: _columns})
     })
-
-    if (col.type !== 'action' || appType === 'mob') return
-
-    let uuids = []
-    col.elements && col.elements.forEach(c => {
-      if (appType === 'pc' && c.OpenType !== 'popview') return
-
-      uuids.push(c.uuid)
-    })
-
-    if (uuids.length === 0) return
-    
-    MKEmitter.emit('delButtons', uuids)
   }
 
   updateLineMarks = (vals) => {
@@ -607,7 +616,6 @@
           <Table
             rowKey="uuid"
             size={config.wrap.size || 'middle'}
-            rowClassName="editable-row"
             bordered={config.wrap.bordered !== 'false'}
             components={components}
             dataSource={this.state.data}

--
Gitblit v1.8.0