From f0bf8c399c354c22227f8f1a76ed806098db59c0 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 21 五月 2024 16:51:02 +0800
Subject: [PATCH] 2024-05-21

---
 src/templates/sharecomponent/actioncomponent/verifyexcelout/index.jsx |  300 ++++++++++++++++++++++++++++++++++++------------------------
 1 files changed, 180 insertions(+), 120 deletions(-)

diff --git a/src/templates/sharecomponent/actioncomponent/verifyexcelout/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyexcelout/index.jsx
index 21d53fe..7b23dda 100644
--- a/src/templates/sharecomponent/actioncomponent/verifyexcelout/index.jsx
+++ b/src/templates/sharecomponent/actioncomponent/verifyexcelout/index.jsx
@@ -9,6 +9,7 @@
 import Utils from '@/utils/utils.js'
 import SettingUtils from './utils.jsx'
 import ColumnForm from './columnform'
+import OtherForm from './otherform'
 import DataSource from './datasource'
 import CustomScript from './customscript'
 import asyncComponent from '@/utils/asyncComponent'
@@ -30,6 +31,8 @@
     verify: {},
     debugId: '',
     activeKey: 'setting',
+    visible: false,
+    line: null,
     searchKey: '',
     excelColumns: [
       {
@@ -68,7 +71,7 @@
         editable: true,
         required: false,
         keyCol: true,
-        width: '8%',
+        width: '10%',
         render: (text) => {
           if (text === 'image') {
             return '鍥剧墖'
@@ -115,50 +118,50 @@
           {value: 'false', text: '鍚�'}
         ]
       },
-      {
-        title: '鍙栫粷瀵瑰��',
-        dataIndex: 'abs',
-        inputType: 'radio',
-        editable: true,
-        required: false,
-        keyVals: ['number'],
-        width: '10%',
-        render: (text, record) => {
-          if (record.type !== 'number') return ''
+      // {
+      //   title: '鍙栫粷瀵瑰��',
+      //   dataIndex: 'abs',
+      //   inputType: 'radio',
+      //   editable: true,
+      //   required: false,
+      //   keyVals: ['number'],
+      //   width: '10%',
+      //   render: (text, record) => {
+      //     if (record.type !== 'number') return ''
 
-          if (text === 'true') {
-            return '鏄�'
-          } else {
-            return '鍚�'
-          }
-        },
-        options: [
-          {value: 'true', text: '鏄�'},
-          {value: 'false', text: '鍚�'}
-        ]
-      },
-      {
-        title: '0鍊煎鍑�',
-        dataIndex: 'noValue',
-        inputType: 'radio',
-        editable: true,
-        required: false,
-        keyVals: ['number'],
-        width: '10%',
-        render: (text, record) => {
-          if (record.type !== 'number') return ''
+      //     if (text === 'true') {
+      //       return '鏄�'
+      //     } else {
+      //       return '鍚�'
+      //     }
+      //   },
+      //   options: [
+      //     {value: 'true', text: '鏄�'},
+      //     {value: 'false', text: '鍚�'}
+      //   ]
+      // },
+      // {
+      //   title: '0鍊煎鍑�',
+      //   dataIndex: 'noValue',
+      //   inputType: 'radio',
+      //   editable: true,
+      //   required: false,
+      //   keyVals: ['number'],
+      //   width: '10%',
+      //   render: (text, record) => {
+      //     if (record.type !== 'number') return ''
 
-          if (text !== 'false') {
-            return '鏄�'
-          } else {
-            return '鍚�'
-          }
-        },
-        options: [
-          {value: 'true', text: '鏄�'},
-          {value: 'false', text: '鍚�'}
-        ]
-      },
+      //     if (text !== 'false') {
+      //       return '鏄�'
+      //     } else {
+      //       return '鍚�'
+      //     }
+      //   },
+      //   options: [
+      //     {value: 'true', text: '鏄�'},
+      //     {value: 'false', text: '鍚�'}
+      //   ]
+      // },
       {
         title: '灏忔暟浣�',
         dataIndex: 'decimal',
@@ -170,7 +173,68 @@
         keyVals: ['number'],
         width: '12%',
         render: (text, record) => record.type === 'number' ? text : ''
-      }
+      },
+      {
+        title: '鍏朵粬',
+        dataIndex: 'other',
+        required: false,
+        width: '18%',
+        render: (_, record) => {
+          if (record.type === 'number') {
+            let val = ''
+
+            if (record.abs === 'true') {
+              val += '鍙栫粷瀵瑰�硷紱'
+            }
+            if (record.noValue === 'false') {
+              val += '0鍊间笉瀵煎嚭锛�'
+            }
+            if (record.format) {
+              if (record.format === 'thdSeparator') {
+                val += '鏍煎紡鍖栵細鍗冨垎浣嶏紱'
+              } else if (record.format === 'thdSepPm') {
+                val += '鏍煎紡鍖栵細鍗冨垎浣嶏紙璐熷�肩孩鑹诧級锛�'
+              } else if (record.format === 'percent') {
+                val += '鏍煎紡鍖栵細鐧惧垎姣旓紱'
+              }
+            }
+            if (record.prefix) {
+              val += `鍓嶇紑锛�${record.prefix}锛沗
+            }
+            if (record.postfix) {
+              val += `鍚庣紑锛�${record.postfix}锛沗
+            }
+
+            return <div>{val}<EditOutlined className="edit-other" onClick={() => {this.setState({visible: true, line: fromJS(record).toJS()})}} /></div>
+          } else if (record.type === 'text') {
+            let val = ''
+
+            if (record.wrapText === 'true') {
+              val += '鑷姩鎹㈣锛�'
+            }
+            if (record.noValue === 'false') {
+              val += '绌哄�间笉瀵煎嚭锛�'
+            }
+            if (record.textFormat) {
+              if (record.textFormat === 'YYYY-MM-DD') {
+                val += '鏍煎紡鍖栵細YYYY-MM-DD锛�'
+              } else if (record.textFormat === 'YYYY-MM-DD HH:mm:ss') {
+                val += '鏍煎紡鍖栵細YYYY-MM-DD HH:mm:ss锛�'
+              }
+            }
+            if (record.prefix) {
+              val += `鍓嶇紑锛�${record.prefix}锛沗
+            }
+            if (record.postfix) {
+              val += `鍚庣紑锛�${record.postfix}锛沗
+            }
+
+            return <div>{val}<EditOutlined className="edit-other" onClick={() => {this.setState({visible: true, line: fromJS(record).toJS()})}} /></div>
+          }
+
+          return ''
+        }
+      },
     ],
     scriptsColumns: [
       {
@@ -227,12 +291,12 @@
         dataIndex: 'operation',
         render: (text, record) =>
           (<div style={{textAlign: 'center'}}>
-            <span className="operation-btn" title="缂栬緫" onClick={() => this.handleEdit(record, 'scripts')} style={{color: '#1890ff'}}><EditOutlined /></span>
-            <span className="operation-btn" title="鐘舵�佸垏鎹�" onClick={() => this.handleStatus(record, 'scripts')} style={{color: '#8E44AD'}}><SwapOutlined /></span>
+            <span className="operation-btn" title="缂栬緫" onClick={() => this.handleEdit(record)} style={{color: '#1890ff'}}><EditOutlined /></span>
+            <span className="operation-btn" title="鐘舵�佸垏鎹�" onClick={() => this.handleStatus(record)} style={{color: '#8E44AD'}}><SwapOutlined /></span>
             <Popconfirm
               overlayClassName="popover-confirm"
               title="纭畾鍒犻櫎鍚�?"
-              onConfirm={() => this.handleDelete(record, 'scripts')
+              onConfirm={() => this.handleDelete(record)
             }>
               <span className="operation-btn" style={{color: '#ff4d4f'}}><DeleteOutlined /></span>
             </Popconfirm>
@@ -392,14 +456,9 @@
     })
   }
 
-  handleEdit = (record, type) => {
-    let node = null
-
-    if (type === 'scripts') {
-      this.scriptsForm.edit(record)
-      node = document.getElementById('mk-exout-script')
-    }
-
+  handleEdit = (record) => {
+    this.scriptsForm.edit(record)
+    let node = document.getElementById('mk-exout-script')
 
     if (node && node.scrollTop) {
       let inter = Math.ceil(node.scrollTop / 10)
@@ -415,19 +474,17 @@
     }
   }
 
-  handleStatus = (record, type) => {
+  handleStatus = (record) => {
     let verify = JSON.parse(JSON.stringify(this.state.verify))
     record.status = record.status === 'false' ? 'true' : 'false'
 
-    if (type === 'scripts') {
-      verify.scripts = verify.scripts.map(item => {
-        if (item.uuid === record.uuid) {
-          return record
-        } else {
-          return item
-        }
-      })
-    }
+    verify.scripts = verify.scripts.map(item => {
+      if (item.uuid === record.uuid) {
+        return record
+      } else {
+        return item
+      }
+    })
 
     this.setState({
       verify: verify
@@ -459,38 +516,12 @@
     })
   }
 
-  handleDelete = (record, type) => {
-    const { verify } = this.state
+  handleDelete = (record) => {
+    let verify = JSON.parse(JSON.stringify(this.state.verify))
 
-    verify.columns = verify.columns.filter(item => item.uuid !== record.uuid)
+    verify.scripts = verify.scripts.filter(item => item.uuid !== record.uuid)
 
     this.setState({ verify: verify })
-  }
-
-  handleUpDown = (record, type, direction) => {
-    let verify = JSON.parse(JSON.stringify(this.state.verify))
-    let index = 0
-
-    verify.columns = verify.columns.filter((item, i) => {
-      if (item.uuid === record.uuid) {
-        index = i
-      }
-
-      return item.uuid !== record.uuid
-    })
-    if ((index === 0 && direction === 'up') || (index === verify.columns.length && direction === 'down')) {
-      return
-    }
-
-    if (direction === 'up') {
-      verify.columns.splice(index - 1, 0, record)
-    } else {
-      verify.columns.splice(index + 1, 0, record)
-    }
-
-    this.setState({
-      verify: verify
-    })
   }
 
   showError = (errorType) => {
@@ -626,7 +657,7 @@
                 loading: false
               })
               reject()
-            }, verify.scripts)
+            }, verify.scripts, 'submit')
           })
         })
       } else if (activeKey === 'columns') {
@@ -645,7 +676,7 @@
               loading: false
             })
             reject()
-          }, verify.scripts)
+          }, verify.scripts, 'submit')
         }
       } else if (activeKey === 'scripts') {
         this.setState({loading: true})
@@ -659,7 +690,7 @@
             loading: false
           })
           reject()
-        }, verify.scripts)
+        }, verify.scripts, 'submit')
       } else {
         resolve(verify)
       }
@@ -812,27 +843,30 @@
           col.type = 'text'
         }
       }
+      if (col.type === 'text' && col.format) {
+        delete col.format
+      } else if (col.type === 'number' && col.textFormat) {
+        delete col.textFormat
+      }
 
       return col
     })
-    // if (columns[0] && !['image', 'text', 'number'].includes(columns[0].type)) {
-    //   columns = columns.map(col => {
-    //     let _cell = {
-    //       uuid: Utils.getuuid(),
-    //       Column: col.Column,
-    //       Text: col.Text,
-    //       Width: 20,
-    //       abs: 'false',
-    //       output: col.output || 'true',
-    //       required: col.required || 'false',
-    //       type: 'text',
-    //     }
-
-    //     return _cell
-    //   })
-    // }
 
     this.setState({verify: {...verify, columns}})
+  }
+
+  lineSubmit = () => {
+    const { line, verify } = this.state
+
+    let columns = verify.columns.map(col => {
+      if (col.uuid === line.uuid) {
+        return line
+      }
+
+      return col
+    })
+
+    this.setState({verify: {...verify, columns}, line: null, visible: false})
   }
 
   // 鏍囩鍒囨崲
@@ -956,7 +990,7 @@
     }
   }
 
-  sqlverify = (_resolve, _reject, scripts) => {
+  sqlverify = (_resolve, _reject, scripts, type) => {
     const { searches, verify, debugId } = this.state
 
     if (verify.dataType !== 'custom') {
@@ -978,10 +1012,24 @@
         this.setState({debugId: _debugId})
         _resolve()
       } else {
-        _reject()
-        Modal.error({
-          title: result.message
-        })
+        if (type === 'submit') {
+          Modal.confirm({
+            title: result.message,
+            okText: '鐭ラ亾浜�',
+            cancelText: '寮哄埗淇濆瓨',
+            onOk: () => {
+              _reject()
+            },
+            onCancel() {
+              _resolve()
+            }
+          })
+        } else {
+          _reject()
+          Modal.error({
+            title: result.message
+          })
+        }
       }
     })
   }
@@ -1007,7 +1055,7 @@
 
   render() {
     const { card } = this.props
-    const { verify, excelColumns, scriptsColumns, activeKey, loading, searches, searchKey } = this.state
+    const { verify, excelColumns, scriptsColumns, activeKey, loading, searches, searchKey, visible, line } = this.state
     const formItemLayout = {
       labelCol: {
         xs: { span: 24 },
@@ -1040,7 +1088,7 @@
             <Button className="excel-col-add mk-red" title="娓呯┖Excel鍒�" onClick={this.clearField}>
               娓呯┖Excel鍒�
             </Button>
-            <div style={{color: '#959595', fontSize: '13px', paddingLeft: '10px'}}>濡傞渶瀵煎嚭搴忓彿锛岃浣跨敤瀛楁 $Index锛涙暟鍊肩被鍨嬪鍑烘椂鍙彇缁濆鍊间互鍙婅缃皬鏁颁綅锛涘鍑轰负鍚︽椂锛屼笉浣跨敤琛屼俊鎭紱绾㈣壊鏍囬瀵煎嚭鏃跺垪澶存枃瀛椾负绾㈣壊銆�</div>
+            <div style={{color: '#959595', fontSize: '13px', paddingLeft: '10px'}}>濡傞渶瀵煎嚭搴忓彿锛岃浣跨敤瀛楁 $Index锛涘鍑轰负鍚︽椂锛屼笉浣跨敤琛屼俊鎭紙鏂囨湰涓虹┖锛屾暟鍊间负0锛夛紱绾㈣壊鏍囬瀵煎嚭鏃跺垪澶存枃瀛椾负绾㈣壊銆�</div>
             <EditTable actions={['edit', 'move', 'copy', 'del']} type="excelcolumn" searchKey={searchKey} wrappedComponentRef={(inst) => this.columnRef = inst} data={verify.columns} columns={excelColumns} onChange={this.changeColumns}/>
           </TabPane>
           {card.intertype === 'system' ? <TabPane tab={
@@ -1159,6 +1207,18 @@
             </Form>
           </TabPane>
         </Tabs>
+        <Modal
+          title=""
+          visible={visible}
+          width={1000}
+          maskClosable={false}
+          closable={false}
+          onOk={this.lineSubmit}
+          onCancel={() => {this.setState({visible: false, line: null})}}
+          destroyOnClose
+        >
+          <OtherForm line={line} submit={this.lineSubmit} onChange={(values) => this.setState({line: values})}/>
+        </Modal>
       </div>
     )
   }

--
Gitblit v1.8.0