From 01a88094eaa183714ed7490ca7b85fee1e7bb064 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期六, 20 五月 2023 23:03:41 +0800
Subject: [PATCH] 2023-05-20

---
 src/menu/components/table/edit-table/columns/tableIn/index.jsx |  237 +++++++++++++++++++++++++++++++++++++---------------------
 1 files changed, 151 insertions(+), 86 deletions(-)

diff --git a/src/menu/components/table/edit-table/columns/tableIn/index.jsx b/src/menu/components/table/edit-table/columns/tableIn/index.jsx
index 61698fb..b452acf 100644
--- a/src/menu/components/table/edit-table/columns/tableIn/index.jsx
+++ b/src/menu/components/table/edit-table/columns/tableIn/index.jsx
@@ -1,15 +1,16 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { fromJS } from 'immutable'
-import { Form, Tabs, Row, Col, Input, Button, Table, Popconfirm, notification, Modal, message, InputNumber, Radio, Typography } from 'antd'
-import { StopTwoTone, CheckCircleTwoTone, EditOutlined, ArrowUpOutlined, ArrowDownOutlined, SwapOutlined, DeleteOutlined } from '@ant-design/icons'
+import { Form, Tabs, Row, Col, Input, Button, Popconfirm, notification, Modal, message, InputNumber, Radio, Typography } from 'antd'
+import { StopTwoTone, CheckCircleTwoTone, EditOutlined, SwapOutlined, DeleteOutlined, BorderOutlined, CheckCircleOutlined, StopOutlined } from '@ant-design/icons'
 import moment from 'moment'
 
 import Api from '@/api'
 import Utils from '@/utils/utils.js'
-
+import MKEmitter from '@/utils/events.js'
 import UniqueForm from './uniqueform'
 import CustomScript from './customscript'
+import MinView from '@/assets/img/minview.png'
 import asyncComponent from '@/utils/asyncComponent'
 import './index.scss'
 
@@ -21,11 +22,12 @@
 class VerifyTableCard extends Component {
   static propTpyes = {
     columns: PropTypes.array,  // 鏄剧ず鍒�
-    dict: PropTypes.object,    // 瀛楀吀椤�
     card: PropTypes.object,
   }
 
   state = {
+    visible: false,
+    scriptId: '',
     verify: {},
     fields: [],
     fieldLabel: {},
@@ -48,7 +50,7 @@
       {
         title: '鎶ラ敊缂栫爜',
         dataIndex: 'errorCode',
-        width: '12%',
+        width: '10%',
         editable: true,
         inputType: 'select',
         options: [
@@ -61,13 +63,24 @@
       {
         title: '楠岃瘉绫诲瀷',
         dataIndex: 'verifyType',
-        width: '12%',
-        render: (text, record) => record.verifyType === 'logic' ? '閫昏緫楠岃瘉' : '鐗╃悊楠岃瘉',
+        width: '14%',
+        render: (text, record) => {
+          let names = {
+            physical: '鐗╃悊楠岃瘉锛堝叏閲忛獙璇侊級',
+            logic: '閫昏緫楠岃瘉锛堝叏閲忛獙璇侊級',
+            physical_temp: '鐗╃悊楠岃瘉锛堜粎涓存椂琛級',
+            logic_temp: '閫昏緫楠岃瘉锛堜粎涓存椂琛級',
+          }
+
+          return names[text] || '鐗╃悊楠岃瘉锛堝叏閲忛獙璇侊級'
+        },
         inputType: 'select',
         editable: true,
         options: [
-          { value: 'physical', text: '鐗╃悊楠岃瘉' },
-          { value: 'logic', text: '閫昏緫楠岃瘉' }
+          { value: 'physical', text: '鐗╃悊楠岃瘉锛堝叏閲忛獙璇侊級' },
+          { value: 'logic', text: '閫昏緫楠岃瘉锛堝叏閲忛獙璇侊級' },
+          { value: 'physical_temp', text: '鐗╃悊楠岃瘉锛堜粎涓存椂琛級' },
+          { value: 'logic_temp', text: '閫昏緫楠岃瘉锛堜粎涓存椂琛級' }
         ]
       },
       {
@@ -86,7 +99,7 @@
           ) :
           (
             <div>
-              {this.props.dict['model.status.open']}
+              鍚敤
               <CheckCircleTwoTone style={{marginLeft: '5px'}} twoToneColor="#52c41a" />
             </div>
           )
@@ -115,15 +128,13 @@
         dataIndex: 'position',
         width: '10%',
         render: (text, record) => {
-          let _text = ''
-          if (record.position === 'front') {
-            _text = 'sql鍓�'
-          } else if (record.position === 'init') {
-            _text = '鍒濆鍖�'
+          if (record.position === 'init') {
+            return <span style={{color: 'orange'}}>鍒濆鍖�</span>
+          } else if (record.position === 'front') {
+            return <span style={{color: '#26C281'}}>sql鍓�</span>
           } else {
-            _text = 'sql鍚�'
+            return <span style={{color: '#1890ff'}}>sql鍚�</span>
           }
-          return _text
         }
       },
       {
@@ -139,7 +150,7 @@
           ) :
           (
             <div>
-              {this.props.dict['model.status.open']}
+              鍚敤
               <CheckCircleTwoTone style={{marginLeft: '5px'}} twoToneColor="#52c41a" />
             </div>
           )
@@ -150,14 +161,12 @@
         width: '20%',
         dataIndex: 'operation',
         render: (text, record) =>
-          (<div>
+          (<div style={{textAlign: 'center'}}>
             <span className="operation-btn" onClick={() => this.handleEdit(record, 'scripts')} style={{color: '#1890ff'}}><EditOutlined /></span>
-            <span className="operation-btn" onClick={() => this.handleUpDown(record, 'scripts', 'up')} style={{color: '#1890ff'}}><ArrowUpOutlined /></span>
-            <span className="operation-btn" onClick={() => this.handleUpDown(record, 'scripts', 'down')} style={{color: '#ff4d4f'}}><ArrowDownOutlined /></span>
-            <span className="operation-btn" title={this.props.dict['header.form.status.change']} onClick={() => this.handleStatus(record, 'scripts')} style={{color: '#8E44AD'}}><SwapOutlined /></span>
+            <span className="operation-btn" title="鐘舵�佸垏鎹�" onClick={() => this.handleStatus(record, 'scripts')} style={{color: '#8E44AD'}}><SwapOutlined /></span>
             <Popconfirm
               overlayClassName="popover-confirm"
-              title={this.props.dict['model.query.delete']}
+              title="纭畾鍒犻櫎鍚�?"
               onConfirm={() => this.handleDelete(record, 'scripts')
             }>
               <span className="operation-btn" style={{color: '#ff4d4f'}}><DeleteOutlined /></span>
@@ -196,6 +205,17 @@
   }
 
   componentDidMount () {
+    this.getsysScript()
+  }
+
+  getsysScript = () => {
+    if (sessionStorage.getItem('mk_sys_scripts')) {
+      this.setState({
+        systemScripts: JSON.parse(sessionStorage.getItem('mk_sys_scripts'))
+      })
+      return
+    }
+    
     let _scriptSql = `Select distinct func+Remark as funcname,longparam, s.Sort from聽 s_custom_script s inner join (select OpenID from sapp where ID=@Appkey@) p on s.openid = case when s.appkey='' then s.openid else p.OpenID end order by s.Sort`
 
     _scriptSql = Utils.formatOptions(_scriptSql)
@@ -214,13 +234,17 @@
     
     Api.getSystemConfig(_sParam).then(res => {
       if (res.status) {
+        let _scripts = res.data.map(item => {
+          return {
+            name: item.funcname,
+            value: window.decodeURIComponent(window.atob(item.longparam))
+          }
+        })
+
+        sessionStorage.setItem('mk_sys_scripts', JSON.stringify(_scripts))
+
         this.setState({
-          systemScripts: res.data.map(item => {
-            return {
-              name: item.funcname,
-              value: window.decodeURIComponent(window.atob(item.longparam))
-            }
-          })
+          systemScripts: _scripts
         })
       } else {
         notification.warning({
@@ -299,6 +323,8 @@
       verify.scripts.push(values)
     }
 
+    MKEmitter.emit('editLineId', values.uuid)
+
     this.setState({
       verify: verify
     })
@@ -357,51 +383,6 @@
           return item
         }
       })
-    }
-
-    this.setState({
-      verify: verify
-    })
-  }
-
-  handleUpDown = (record, type, direction) => {
-    let verify = JSON.parse(JSON.stringify(this.state.verify))
-    let index = 0
-
-    if (type === 'unique') {
-      verify.uniques = verify.uniques.filter((item, i) => {
-        if (item.uuid === record.uuid) {
-          index = i
-        }
-
-        return item.uuid !== record.uuid
-      })
-      if ((index === 0 && direction === 'up') || (index === verify.uniques.length && direction === 'down')) {
-        return
-      }
-
-      if (direction === 'up') {
-        verify.uniques.splice(index - 1, 0, record)
-      } else {
-        verify.uniques.splice(index + 1, 0, record)
-      }
-    } else if (type === 'scripts') {
-      verify.scripts = verify.scripts.filter((item, i) => {
-        if (item.uuid === record.uuid) {
-          index = i
-        }
-
-        return item.uuid !== record.uuid
-      })
-      if ((index === 0 && direction === 'up') || (index === verify.scripts.length && direction === 'down')) {
-        return
-      }
-
-      if (direction === 'up') {
-        verify.scripts.splice(index - 1, 0, record)
-      } else {
-        verify.scripts.splice(index + 1, 0, record)
-      }
     }
 
     this.setState({
@@ -512,7 +493,7 @@
   }
 
   render() {
-    const { verify, scriptsColumns, uniqueColumns, activeKey, fields } = this.state
+    const { verify, scriptsColumns, uniqueColumns, activeKey, fields, visible } = this.state
     const formItemLayout = {
       labelCol: {
         xs: { span: 24 },
@@ -532,7 +513,7 @@
             <Form {...formItemLayout}>
               <Row gutter={24}>
                 <Col span={8}>
-                  <Form.Item required label={this.props.dict['model.form.tablename']}>
+                  <Form.Item required label="琛ㄥ悕">
                     <Input value={verify.sheet} placeholder="" autoComplete="off" onChange={(e) => this.onOptionChange(e.target.value, 'sheet')}/>
                   </Form.Item>
                 </Col>
@@ -592,7 +573,7 @@
               {verify.uniques.length ? <span className="count-tip">{verify.uniques.length}</span> : null}
             </span>
           } key="unique">
-            <UniqueForm fields={fields} dict={this.props.dict} uniqueChange={this.uniqueChange}/>
+            <UniqueForm fields={fields} uniqueChange={this.uniqueChange}/>
             <EditTable actions={['edit', 'move', 'del']} data={verify.uniques} columns={uniqueColumns} onChange={this.changeUniques}/>
           </TabPane>
           <TabPane disabled={verify.intertype !== 'system'} tab={
@@ -601,8 +582,18 @@
               {verify.scripts.length ? <span className="count-tip">{verify.scripts.length}</span> : null}
             </span>
           } key="scripts">
+            <BorderOutlined className="full-scripts" onClick={() => {
+              if (this.scriptsForm && (this.scriptsForm.state.editItem || (this.scriptsForm.props.form.getFieldValue('sql') && !/^\s+$/.test(this.scriptsForm.props.form.getFieldValue('sql'))))) {
+                notification.warning({
+                  top: 92,
+                  message: '璇蜂繚瀛樿嚜瀹氫箟鑴氭湰锛�',
+                  duration: 5
+                })
+                return
+              }
+              this.setState({visible: true, scriptId: ''})
+            }}/>
             <CustomScript
-              dict={this.props.dict}
               btn={verify}
               usefulfields={fields}
               scripts={verify.scripts}
@@ -610,14 +601,7 @@
               scriptsChange={this.scriptsChange}
               wrappedComponentRef={(inst) => this.scriptsForm = inst}
             />
-            <Table
-              bordered
-              rowKey="uuid"
-              className="custom-table"
-              dataSource={verify.scripts}
-              columns={scriptsColumns}
-              pagination={false}
-            />
+            <EditTable actions={['move']} data={verify.scripts} columns={scriptsColumns} onChange={(scripts) => {this.setState({verify: {...verify, scripts}})}}/>
           </TabPane>
           <TabPane tab="淇℃伅鎻愮ず" key="tip">
             <Form {...formItemLayout}>
@@ -707,6 +691,87 @@
             </Form>
           </TabPane>
         </Tabs>
+        <Modal
+          wrapClassName="model-custom-scripts-modal"
+          title="鑷畾涔夎剼鏈�"
+          visible={visible}
+          width={'95vw'}
+          maskClosable={false}
+          destroyOnClose
+        >
+          <img className="unfull-scripts" src={MinView} onClick={() => this.setState({visible: false, scriptId: ''})} alt=""/>
+          <div className="script-table-wrap">
+            {verify.scripts.map(item => {
+              let title = item.sql.match(/^\s*\/\*.+\*\//)
+              title = title && title[0] ? title[0] : ''
+              let _text = title ? item.sql.replace(title, '') : item.sql
+
+              let position = null
+              if (item.position === 'init') {
+                position = <span style={{color: 'orange'}}>鍒濆鍖�</span>
+              } else if (item.position === 'front') {
+                position = <span style={{color: '#26C281'}}>sql鍓�</span>
+              } else {
+                position = <span style={{color: '#1890ff'}}>sql鍚�</span>
+              }
+
+              if (item.status === 'false') {
+                return (
+                  <div className="script-item" key={item.uuid}>
+                    <div style={{cursor: 'not-allowed'}}>
+                      {title ? <div style={{color: '#a50', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis'}}>{title}</div> : null}
+                      <Paragraph copyable={{ text: item.sql }} ellipsis={{ rows: 4 }}>{_text}</Paragraph>
+                      <div>{position}
+                        <span style={{color: '#ff4d4f', marginLeft: '20px'}}>
+                          绂佺敤
+                          <StopOutlined style={{marginLeft: '5px'}} />
+                        </span>
+                      </div>
+                    </div>
+                    <div style={{height: '24px'}}></div>
+                  </div>
+                )
+              } else {
+                return (
+                  <div className={'script-item ' + (this.state.scriptId === item.uuid ? 'active' : '') } key={item.uuid}>
+                    <div style={{cursor: 'pointer'}} onClick={() => {
+                      this.scriptsFullForm.edit(item)
+                      this.setState({scriptId: item.uuid})
+                    }}>
+                      {title ? <div style={{color: '#a50', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis'}}>{title}</div> : null}
+                      <Paragraph copyable={{ text: item.sql }} ellipsis={{ rows: 4 }}>{_text}</Paragraph>
+                      <div>{position}
+                        <span style={{color: '#26C281', marginLeft: '20px'}}>
+                          鍚敤
+                          <CheckCircleOutlined style={{marginLeft: '5px'}}/>
+                        </span>
+                      </div>
+                    </div>
+                    <div style={{textAlign: 'right'}}>
+                      <span className="operation-btn" onClick={() => this.handleStatus(item, 'scripts')} style={{color: '#8E44AD'}}><SwapOutlined /></span>
+                      <Popconfirm
+                        overlayClassName="popover-confirm"
+                        title="纭畾鍒犻櫎鍚�?"
+                        onConfirm={() => this.handleDelete(item, 'scripts')
+                      }>
+                        <span className="operation-btn" style={{color: '#ff4d4f'}}><DeleteOutlined /></span>
+                      </Popconfirm>
+                    </div>
+                  </div>
+                )
+              }
+            })}
+          </div>
+          <CustomScript
+            type="fullscreen"
+            btn={verify}
+            usefulfields={fields}
+            scripts={verify.scripts}
+            systemScripts={this.state.systemScripts}
+            scriptsChange={this.scriptsChange}
+            wrappedComponentRef={(inst) => this.scriptsFullForm = inst}
+          />
+        </Modal>
       </div>
     )
   }

--
Gitblit v1.8.0