From 5e1ff4dc1c6d384af39cac1d3fbe6bf4b58566f2 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 19 十月 2023 17:59:22 +0800
Subject: [PATCH] 2023-10-19

---
 src/menu/components/table/edit-table/columns/editColumn/index.jsx |   96 +++++++++++++++++++++++++++++++++++++----------
 1 files changed, 75 insertions(+), 21 deletions(-)

diff --git a/src/menu/components/table/edit-table/columns/editColumn/index.jsx b/src/menu/components/table/edit-table/columns/editColumn/index.jsx
index 06b4348..9a107bb 100644
--- a/src/menu/components/table/edit-table/columns/editColumn/index.jsx
+++ b/src/menu/components/table/edit-table/columns/editColumn/index.jsx
@@ -3,7 +3,6 @@
 import { is, fromJS } from 'immutable'
 import { Form, Row, Col, Input, Select, InputNumber, Radio, Tooltip, Modal, notification, Popover } from 'antd'
 import { QuestionCircleOutlined } from '@ant-design/icons'
-import moment from 'moment'
 
 import Api from '@/api'
 import Utils from '@/utils/utils.js'
@@ -72,6 +71,8 @@
 
         if (this.record.editType === 'switch') {
           _options.push('enter', 'openVal', 'closeVal', 'openText', 'closeText', 'editField')
+        } else if (this.record.editType === 'date') {
+          _options.push('required', 'precision', 'enter', 'declareType')
         } else if (this.record.editType === 'select') {
           _options.push('required', 'enter', 'resourceType', 'linkSubField', 'editField', 'dropdown')
 
@@ -383,8 +384,19 @@
         className = 'text-area'
 
         let linkSubFields = this.record.linkSubField || []
+
+        let columns = []
+
+        columns.push({ title: 'Value', key: 'Value', strict: true })
+        columns.push({ title: 'Text', key: 'Text' })
+
+        linkSubFields.forEach(field => {
+          if (field === 'Value' || field === 'Text') return
+
+          columns.push({ title: transfield[field] || field, key: field })
+        })
       
-        content = <EditTable type={'select'} module="form" transfield={transfield} linkSubFields={linkSubFields} onChange={this.changeOptions}/>
+        content = <EditTable columns={columns} module="form" onChange={this.changeOptions}/>
       }
 
       fields.push(
@@ -406,6 +418,29 @@
     return fields
   }
 
+  transfer = (options) => {
+    if (options.length === 0) return options
+
+    let isNumber = true
+    options.forEach(item => {
+      if (!item.Value || isNaN(item.Value)) {
+        isNumber = false
+      }
+    })
+
+    if (isNumber) {
+      return options.map(item => {
+        item.Value = +item.Value
+        return item
+      })
+    } else {
+      return options.map(item => {
+        item.Value = item.Value + ''
+        return item
+      })
+    }
+  }
+
   handleSubmit = () => {
     const { fields } = this.props
     // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭�
@@ -421,7 +456,7 @@
             return
           }
           // eslint-disable-next-line
-        } else if (values.type === 'formula' && values.eval !== 'false' && /^[\u4E00-\u9FA50-9a-zA-Z_\s@\+\-\*\/]*$/ig.test(values.formula) && /[\+\-\*\/]/ig.test(values.formula)) {
+        } else if (values.type === 'formula' && values.eval === 'true' && /^[\u4E00-\u9FA50-9a-zA-Z_\s@\+\-\*\/]*$/ig.test(values.formula) && /[\+\-\*\/]/ig.test(values.formula)) {
           let cols = []
           fields.forEach(col => {
             if (/^(Int|Decimal)/ig.test(col.datatype)) {
@@ -432,6 +467,32 @@
           cols.forEach(col => {
             values.formula = values.formula.replace(col.reg, col.value)
           })
+        } else if (values.type === 'text' && values.editable === 'true' && values.editType === 'select') {
+          if (values.resourceType === '0') {
+            values.options = values.options || []
+            
+            values.options = this.transfer(values.options)
+
+            if (values.options.filter(op => op.Text === '').length > 0) {
+              notification.warning({
+                top: 92,
+                message: '鎻愮ず鏂囨湰锛圱ext锛変笉鍙负绌猴紒',
+                duration: 5
+              })
+              return
+            } else {
+              let arr = values.options.map(m => m.Value)
+              let _arr = Array.from(new Set(arr))
+              if (arr.length > _arr.length) {
+                notification.warning({
+                  top: 92,
+                  message: 'Value鍊间笉鍙噸澶嶏紒',
+                  duration: 5
+                })
+                return
+              }
+            }
+          }
         }
 
         if (values.dataSource && /\s/.test(values.dataSource)) {
@@ -449,27 +510,19 @@
           this.setState({
             loading: true
           })
-    
-          let param = {
-            func: 's_debug_sql',
-            exec_type: 'y',
-            LText: `declare @mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20)
-              ${values.dataSource}`
-          }
-    
-          param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
-          param.LText = param.LText.replace(/@\$|\$@/ig, '').replace(/@(BID|ID|LoginUID|SessionUid|UserID|Appkey|time_id)@/ig, `'${param.timestamp}'`)
-          param.LText = param.LText.replace(/\n/g, ' ')
-          
-          param.LText = Utils.formatOptions(param.LText)
-          param.secretkey = Utils.encrypt('', param.timestamp)
-    
+
+          let sql = `declare @mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20)
+          ${values.dataSource}`
+
+          sql = sql.replace(/@\$|\$@/ig, '').replace(/@(BID|ID|LoginUID|SessionUid|UserID|Appkey|time_id)@/ig, `'1949-10-01 15:00:00'`)
+
+          let rduri = ''
           if (window.GLOB.mainSystemApi && values.database === 'sso') {
-            param.rduri = window.GLOB.mainSystemApi
+            rduri = window.GLOB.mainSystemApi
           }
           
-          Api.genericInterface(param).then(result => {
-            if (result.status) {
+          Api.sDebug(sql, rduri).then(result => {
+            if (result.status || result.ErrCode === '-2') {
               this.setState({visible: false, loading: false, formlist: null})
               this.props.submitCol(values)
               this.record = null
@@ -512,6 +565,7 @@
       <div style={{display: 'inline-block'}}>
         <Modal
           title="鏄剧ず鍒楃紪杈�"
+          wrapClassName="mk-scroll-modal"
           visible={visible}
           width={900}
           maskClosable={false}

--
Gitblit v1.8.0