From cb9ade2afd2a367ad767bc605ab7086c695dd010 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 09 十二月 2022 15:53:32 +0800
Subject: [PATCH] 2022-12-09

---
 src/templates/zshare/editTable/index.jsx |   63 +++++++++++++++++++++++++------
 1 files changed, 50 insertions(+), 13 deletions(-)

diff --git a/src/templates/zshare/editTable/index.jsx b/src/templates/zshare/editTable/index.jsx
index ef0ff17..ff2c97f 100644
--- a/src/templates/zshare/editTable/index.jsx
+++ b/src/templates/zshare/editTable/index.jsx
@@ -10,13 +10,10 @@
 import PasteForm from '@/templates/zshare/pasteform'
 import asyncComponent from '@/utils/asyncComponent'
 import CusSwitch from './cusSwitch'
-import zhCN from '@/locales/zh-CN/model.js'
-import enUS from '@/locales/en-US/model.js'
 import MKEmitter from '@/utils/events.js'
 import './index.scss'
 
 const MkEditIcon = asyncComponent(() => import('@/components/mkIcon'))
-let eTDict = sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS
 const EditableContext = React.createContext()
 const { confirm } = Modal
 let dragingIndex = -1
@@ -81,14 +78,14 @@
 
 class EditableCell extends Component {
   getInput = (form) => {
-    const { inputType, options, min, max, unlimit } = this.props
+    const { inputType, options, min, max, unlimit, allowClear } = this.props
 
     if (inputType === 'number' && unlimit) {
       return <InputNumber onPressEnter={() => this.getValue(form)} />
     } else if (inputType === 'number') {
       return <InputNumber min={min} max={max} precision={0} onPressEnter={() => this.getValue(form)} />
     } else if (inputType === 'color') {
-      return <ColorSketch />
+      return <ColorSketch allowClear={allowClear} />
     } else if (inputType === 'icon') {
       return <MkEditIcon allowClear/>
     } else if (inputType === 'switch') {
@@ -144,7 +141,7 @@
               rules: [
                 {
                   required: required,
-                  message: ['number', 'text', 'input'].includes(inputType) ? `${eTDict['form.required.input']} ${title}!` : `${eTDict['form.required.select']} ${title}!`,
+                  message: ['number', 'text', 'input'].includes(inputType) ? `璇疯緭鍏�${title}!` : `璇烽�夋嫨${title}!`,
                 },
                 ...rules
               ],
@@ -195,7 +192,7 @@
 
       operation = {
         title: (<div>
-          {eTDict['model.operation']}
+          鎿嶄綔
           <span className="copy-control">
             {actions.includes('copy') ? <CopyOutlined title="澶嶅埗" onClick={() => this.copy()} /> : null}
             {actions.includes('copy') ? <SnippetsOutlined title="绮樿创" onClick={this.paste} /> : null}
@@ -212,11 +209,11 @@
               <EditableContext.Consumer>
                 {form => (
                   <span onClick={() => this.save(form, record.uuid)} style={{ marginRight: 8 , color: '#1890ff', cursor: 'pointer'}}>
-                    {eTDict['model.save']}
+                    淇濆瓨
                   </span>
                 )}
               </EditableContext.Consumer>
-              <span style={{ color: '#1890ff', cursor: 'pointer'}} onClick={() => this.cancel(record.uuid)}>{eTDict['model.cancel']}</span>
+              <span style={{ color: '#1890ff', cursor: 'pointer'}} onClick={() => this.cancel(record.uuid)}>鍙栨秷</span>
             </div>
           ) : (
             <div className={'edit-operation-btn' + (editingKey !== '' ? ' disabled' : '')} style={{minWidth: '110px', whiteSpace: 'nowrap'}}>
@@ -225,7 +222,7 @@
               {actions.includes('status') ? <span className="status" onClick={() => {editingKey === '' && this.handleStatus(record)}}><SwapOutlined /></span> : null}
               {actions.includes('del') && editingKey === '' ? <Popconfirm
                 overlayClassName="popover-confirm"
-                title={eTDict['model.query.delete']}
+                title="纭畾鍒犻櫎鍚�?"
                 onConfirm={() => this.handleDelete(record.uuid)
               }>
                 <span className="danger"><DeleteOutlined /></span>
@@ -364,7 +361,46 @@
     let data = fromJS(this.state.data).toJS()
 
     this.pasteFormRef.handleConfirm().then(res => {
-      if (res.key !== type) {
+      if (res.copyType === 'columns' && type === 'datasourcefield') {
+        res.type = 'array'
+        res.data = []
+        res.columns.forEach(col => {
+          if (!col.field) return
+          if (col.type === 'number') {
+            let datatype = 'Int'
+            if (col.decimal) {
+              datatype = `Decimal(18,${col.decimal})`
+            }
+
+            res.data.push({
+              $index: res.data.length + 1,
+              datatype: datatype,
+              field: col.field,
+              decimal: col.decimal,
+              label: col.label,
+              type: 'number',
+              uuid: Utils.getuuid()
+            })
+          } else {
+            let datatype = 'Nvarchar(50)'
+            let fieldlength = 50
+            if (col.fieldlength && [10, 20, 50, 100, 256, 512, 1024, 2048].includes(col.fieldlength)) {
+              fieldlength = col.fieldlength
+              datatype = `Nvarchar(${fieldlength})`
+            }
+
+            res.data.push({
+              $index: res.data.length + 1,
+              datatype: datatype,
+              field: col.field,
+              fieldlength: fieldlength,
+              label: col.label,
+              type: 'text',
+              uuid: Utils.getuuid()
+            })
+          }
+        })
+      } else if (res.key !== type) {
         message.warning('閰嶇疆淇℃伅鏍煎紡閿欒锛�')
         return
       }
@@ -582,6 +618,7 @@
           max: col.max || 500,
           unlimit: col.unlimit,
           required: col.required !== false ? true : false,
+          allowClear: col.allowClear === true,
           title: col.title,
           editing: this.isEditing(record),
           onSave: this.onSave,
@@ -624,7 +661,7 @@
           </DndProvider>
           {/* 淇℃伅绮樿创 */}
           <Modal
-            title={eTDict['header.form.paste']}
+            title="绮樿创"
             visible={this.state.visible}
             width={600}
             maskClosable={false}
@@ -632,7 +669,7 @@
             onCancel={() => {this.setState({visible: false})}}
             destroyOnClose
           >
-            <PasteForm dict={eTDict} wrappedComponentRef={(inst) => this.pasteFormRef = inst}/>
+            <PasteForm wrappedComponentRef={(inst) => this.pasteFormRef = inst} inputSubmit={this.pasteSubmit}/>
           </Modal>
         </div>
       </EditableContext.Provider>

--
Gitblit v1.8.0