From 5ef3d9f4fd1b7edc167cca043498cf494960b52f Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 25 八月 2023 17:16:23 +0800 Subject: [PATCH] 2023-08-25 --- src/tabviews/zshare/actionList/excelInbutton/excelin/index.jsx | 5 +- src/menu/components/share/actioncomponent/actionform/index.jsx | 22 ++++------- src/templates/sharecomponent/actioncomponent/verifyexcelin/columnform/index.jsx | 1 src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx | 32 +++++++++++++--- src/utils/utils.js | 10 ++++ 5 files changed, 47 insertions(+), 23 deletions(-) diff --git a/src/menu/components/share/actioncomponent/actionform/index.jsx b/src/menu/components/share/actioncomponent/actionform/index.jsx index e83ff55..c0ce3c6 100644 --- a/src/menu/components/share/actioncomponent/actionform/index.jsx +++ b/src/menu/components/share/actioncomponent/actionform/index.jsx @@ -980,11 +980,12 @@ values.$fixed = card.$fixed || false if (card.OpenType === 'excelOut' && values.OpenType === 'excelIn') { - if (values.verify && values.verify.columns && values.verify.columns.length > 0) { - values.verify.columns = values.verify.columns.map(col => { + values.verify = {columns: [], scripts: [], sheet: 'Sheet1', default: 'true', range: 1, uniques: []} + if (card.verify && card.verify.columns) { + values.verify.columns = card.verify.columns.map(col => { col.required = col.required || 'true' col.type = col.type || 'Nvarchar(50)' - col.import = col.import || 'true' + col.import = 'true' if (col.type === 'text' || col.type === 'image') { col.type = 'Nvarchar(50)' @@ -1007,15 +1008,12 @@ return col }) - values.verify.sheet = values.verify.sheet || 'Sheet1' - } - - if (values.verify) { - values.verify.scripts = [] + values.verify.sheet = card.verify.sheet || 'Sheet1' } } else if (card.OpenType === 'excelIn' && values.OpenType === 'excelOut') { - if (values.verify && values.verify.columns && values.verify.columns.length > 0) { - values.verify.columns = values.verify.columns.map(col => { + values.verify = {columns: [], scripts: [], dataType: 'default'} + if (card.verify && card.verify.columns) { + values.verify.columns = card.verify.columns.map(col => { col.type = col.type || 'text' col.output = col.output || 'true' col.required = col.required || 'false' @@ -1033,10 +1031,6 @@ return col }) - } - - if (values.verify) { - values.verify.scripts = [] } } diff --git a/src/tabviews/zshare/actionList/excelInbutton/excelin/index.jsx b/src/tabviews/zshare/actionList/excelInbutton/excelin/index.jsx index 7610cae..ee873ec 100644 --- a/src/tabviews/zshare/actionList/excelInbutton/excelin/index.jsx +++ b/src/tabviews/zshare/actionList/excelInbutton/excelin/index.jsx @@ -27,7 +27,8 @@ onImportExcel = file => { const { btn } = this.props - let columns = btn.verify.columns.map(option => option.Column) + let btnColumns = btn.verify.columns.filter(option => option.import !== 'init') + let columns = btnColumns.map(option => option.Column) let range = btn.verify.range || 0 // excel鏁版嵁澶勭悊 @@ -58,7 +59,7 @@ errors = 'empty' } else { let iserror = false - btn.verify.columns.forEach(op => { + btnColumns.forEach(op => { let _name = typeof(header[op.Column]) === 'string' ? header[op.Column].replace(/(^\s*|\s*$)/g, '') : header[op.Column] let _text = op.Text ? op.Text.replace(/(^\s*|\s*$)/g, '') : op.Text diff --git a/src/templates/sharecomponent/actioncomponent/verifyexcelin/columnform/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyexcelin/columnform/index.jsx index 7724f6c..83ebde0 100644 --- a/src/templates/sharecomponent/actioncomponent/verifyexcelin/columnform/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/verifyexcelin/columnform/index.jsx @@ -148,6 +148,7 @@ <Radio.Group> <Radio value="true">鏄�</Radio> <Radio value="false">鍚�</Radio> + <Radio value="init">鍒濆鍖�</Radio> </Radio.Group> )} </Form.Item> diff --git a/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx index 2ec586a..0bc167a 100644 --- a/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx @@ -38,6 +38,7 @@ width: '14%', inputType: 'input', unique: true, + strict: true, editable: true }, { @@ -84,8 +85,20 @@ dataIndex: 'import', width: '10%', editable: true, - inputType: 'switch', - render: (text, record) => record.import !== 'false' ? '鏄�' : '鍚�' + inputType: 'radio', + render: (text, record) => { + if (record.import === 'init') { + return '鍒濆鍖�' + } else if (record.import === 'false') { + return '鍚�' + } + return '鏄�' + }, + options: [ + { value: 'true', text: '鏄�' }, + { value: 'false', text: '鍚�' }, + { value: 'init', text: '鍒濆鍖�' } + ] }, { title: '鏈�灏忓��', @@ -253,8 +266,6 @@ const { card } = this.props let _verify = fromJS(card.verify || {}).toJS() let _columns = _verify.columns || [] - - delete _verify.dataresource // 鏃ф暟鎹吋瀹� _columns = _columns.map(col => { @@ -638,7 +649,7 @@ if (!err) { let _verify = {...verify, ...values} - let cols = _verify.columns.map(col => col.Column) + let cols = _verify.columns.map(col => col.Column.toLowerCase()) cols = Array.from(new Set(cols)) if (_verify.columns.length === 0) { @@ -666,6 +677,15 @@ return } } + + _verify.columns.sort((a, b) => { + if (a.import === 'init' && b.import !== 'init') { + return 1 + } else if (a.import !== 'init' && b.import === 'init') { + return -1 + } + return 0 + }) let _loading = false if (this.scriptsForm && this.scriptsForm.state.editItem) { @@ -838,7 +858,7 @@ <Button className="excel-col-add mk-red" title="娓呯┖Excel鍒�" onClick={this.clearField}> 娓呯┖Excel鍒� </Button> - <Col style={{fontSize: '12px', color: '#757575', paddingLeft: '10px'}} span={24}>娉細鏁板�肩被鍨嬶紙int 鎴� decimal锛夛紝鍐呭涓哄繀濉紱鏈�澶у�煎拰鏈�灏忓�煎湪绫诲瀷涓烘暟鍊兼椂鏈夋晥銆�</Col> + <Col style={{fontSize: '12px', color: '#757575', paddingLeft: '10px'}} span={24}>娉細鏁板�肩被鍨嬶紙int 鎴� decimal锛夛紝鍐呭涓哄繀濉紱鏈�澶у�煎拰鏈�灏忓�煎湪绫诲瀷涓烘暟鍊兼椂鏈夋晥銆傚鍏�-鍒濆鍖栵細鐢ㄤ簬excel涓笉瀛樺湪锛屽鍏ユ椂闇�瑕佸垵濮嬪寲鐨勫瓧娈�</Col> <EditTable actions={['edit', 'move', 'copy', 'del', 'extra:required:鏄惁蹇呭~']} type="excelcolumn" data={verify.columns} columns={excelColumns} onChange={this.changeColumns}/> </TabPane> {card.intertype === 'system' ? <TabPane tab={ diff --git a/src/utils/utils.js b/src/utils/utils.js index 566ced2..7f89611 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -967,7 +967,15 @@ let _colindex = cols[cindex] || (cindex + 1) let _position = (_topline + lindex + 1) + '琛� ' + _colindex + '鍒� ' - if (/^Nvarchar/ig.test(col.type)) { + if (col.import === 'init') { + if (/^Nvarchar/ig.test(col.type)) { + val = '' + } else if (/^Decimal/ig.test(col.type) || /^int/ig.test(col.type)) { + val = 0 + } else if (col.type === 'date') { + val = '1949-10-01' + } + } else if (/^Nvarchar/ig.test(col.type)) { val = val + '' if (/'/.test(val)) { -- Gitblit v1.8.0