From 49f09cc6f8ff8c30a75ed1a9d6f510b69b73962a Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 12 十二月 2023 21:05:37 +0800 Subject: [PATCH] 2023-12-12 --- src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx | 213 ++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 146 insertions(+), 67 deletions(-) diff --git a/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx index 32de2fd..18de67e 100644 --- a/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx @@ -17,6 +17,7 @@ const { TabPane } = Tabs const { confirm } = Modal +const { Search } = Input const { Paragraph } = Typography const EditTable = asyncComponent(() => import('@/templates/zshare/editTable')) const FullScripts = asyncComponent(() => import('@/templates/zshare/verifycard/fullScripts')) @@ -31,6 +32,7 @@ verify: {}, systemScripts: [], activeKey: 'basemsg', + searchKey: '', excelColumns: [ { title: '瀛楁', @@ -38,6 +40,9 @@ width: '14%', inputType: 'input', unique: true, + strict: true, + searchable: true, + copy: true, editable: true }, { @@ -45,6 +50,7 @@ dataIndex: 'Text', width: '14%', inputType: 'input', + searchable: true, editable: true }, { @@ -62,13 +68,35 @@ { value: 'Nvarchar(512)', text: 'Nvarchar(512)' }, { value: 'Nvarchar(1024)', text: 'Nvarchar(1024)' }, { value: 'Nvarchar(2048)', text: 'Nvarchar(2048)' }, + { value: 'Nvarchar(4000)', text: 'Nvarchar(4000)' }, { value: 'Nvarchar(max)', text: 'Nvarchar(max)' }, { value: 'Int', text: 'Int' }, { value: 'Decimal(18,0)', text: 'Decimal(18,0)' }, { value: 'Decimal(18,2)', text: 'Decimal(18,2)' }, { value: 'Decimal(18,4)', text: 'Decimal(18,4)' }, { value: 'Decimal(18,6)', text: 'Decimal(18,6)' }, - { value: 'date', text: 'date' } + { value: 'date', text: 'date' }, + { value: 'datetime', text: 'datetime' } + ] + }, + { + title: '瀵煎叆', + dataIndex: 'import', + width: '10%', + editable: true, + 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: '鍒濆鍖�' } ] }, { @@ -78,14 +106,6 @@ editable: true, inputType: 'switch', render: (text, record) => record.required === 'true' ? '鏄�' : '鍚�' - }, - { - title: '瀵煎叆', - dataIndex: 'import', - width: '10%', - editable: true, - inputType: 'switch', - render: (text, record) => record.import !== 'false' ? '鏄�' : '鍚�' }, { title: '鏈�灏忓��', @@ -254,8 +274,6 @@ let _verify = fromJS(card.verify || {}).toJS() let _columns = _verify.columns || [] - delete _verify.dataresource - // 鏃ф暟鎹吋瀹� _columns = _columns.map(col => { col.required = col.required || 'true' @@ -284,6 +302,7 @@ } this.setState({ + searchKey: '', verify: { ..._verify, default: _verify.default || 'true', @@ -325,7 +344,7 @@ _sParam.secretkey = Utils.encrypt(_sParam.LText, _sParam.timestamp) _sParam.open_key = Utils.encryptOpenKey(_sParam.secretkey, _sParam.timestamp) // 浜戠鏁版嵁楠岃瘉 - Api.getSystemConfig(_sParam).then(res => { + Api.getCloudConfig(_sParam).then(res => { if (res.status) { let _scripts = res.data.map(item => { return { @@ -375,48 +394,100 @@ const { verify } = this.state let _columns = JSON.parse(JSON.stringify(verify.columns)) + let _names = {} + let _cols = _columns.map(item => { + let key = item.Column.toLowerCase() + _names[key] = item.Text - let _cols = _columns.map(col => col.Column) + return key + }) + let names = {$up: false} columns.forEach(col => { - if (col.field && !_cols.includes(col.field)) { - let _type = 'Nvarchar(50)' - let _limit = '50' - if (col.type === 'number' && !col.decimal) { - _type = 'Int' - _limit = '' - } else if (col.type === 'number') { - _type = 'Decimal(18,' + col.decimal + ')' - _limit = col.decimal + if (!col.field) return + let key = col.field.toLowerCase() + if (_cols.includes(key)) { + if (_names[key] !== col.label) { + names.$up = true + names[key] = col.label } - - let _cell = { - uuid: col.uuid, - Column: col.field, - Text: col.label, - type: _type, - limit: _limit, - import: 'true', - required: 'true' - } - - if (_type !== 'Nvarchar(50)') { - _cell.min = 0 - _cell.max = 999999 - } - - _columns.push(_cell) + return } + + let _type = 'Nvarchar(50)' + let _limit = '50' + if (col.type === 'number' && !col.decimal) { + _type = 'Int' + _limit = '' + } else if (col.type === 'number') { + _type = 'Decimal(18,' + col.decimal + ')' + _limit = col.decimal + } + + let _cell = { + uuid: col.uuid, + Column: col.field, + Text: col.label, + type: _type, + limit: _limit, + import: 'true', + required: 'true' + } + + if (_type !== 'Nvarchar(50)') { + _cell.min = 0 + _cell.max = 999999 + } + + _columns.push(_cell) }) - this.setState({ - verify: { - ...verify, - columns: _columns - } - }, () => { - this.resetUniqueColumns() - }) + if (names.$up) { + const that = this + + confirm({ + content: '閮ㄥ垎瀛楁鍚嶇О涓庢樉绀哄垪涓嶄竴鑷达紝鏄惁鏇存柊锛�', + onOk() { + _columns = _columns.map(item => { + let key = item.Column.toLowerCase() + + if (names[key]) { + item.Text = names[key] + } + + return item + }) + + that.setState({ + verify: { + ...verify, + columns: _columns + } + }, () => { + that.resetUniqueColumns() + }) + }, + onCancel() { + that.setState({ + verify: { + ...verify, + columns: _columns + } + }, () => { + that.resetUniqueColumns() + }) + } + }) + } else { + this.setState({ + verify: { + ...verify, + columns: _columns + } + }, () => { + this.resetUniqueColumns() + }) + } } clearField = () => { @@ -465,7 +536,6 @@ changeColumns = (columns) => { const { verify } = this.state - let reset = false columns = columns.map(col => { col.type = col.type || 'Nvarchar(50)' if (col.type === 'text' || col.type === 'image') { @@ -474,19 +544,18 @@ col.type = 'Decimal(18,2)' } + if (col.import === 'init') { + col.required = 'false' + col.min = '' + col.max = '' + } + if (/^Nvarchar/ig.test(col.type)) { col.limit = col.type.match(/\d+/) ? col.type.match(/\d+/)[0] : '20000' } else if (/^Decimal/ig.test(col.type)) { col.limit = col.type.match(/\d+/ig)[1] - if (col.required === 'false') { - reset = true - } - col.required = 'true' } else if (/^int/ig.test(col.type)) { - if (col.required === 'false') { - reset = true - } - col.required = 'true' + } else { col.limit = '' } @@ -496,10 +565,6 @@ return col }) - - if (reset) { - message.warning('鏁板�肩被鍨嬪潎涓哄繀濉��') - } this.setState({verify: {...verify, columns}}, () => { this.resetUniqueColumns() @@ -638,7 +703,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 +731,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) { @@ -765,7 +839,7 @@ render() { const { card } = this.props const { getFieldDecorator } = this.props.form - const { verify, excelColumns, scriptsColumns, uniqueColumns, activeKey } = this.state + const { verify, excelColumns, scriptsColumns, uniqueColumns, activeKey, searchKey } = this.state const formItemLayout = { labelCol: { xs: { span: 24 }, @@ -833,13 +907,13 @@ } key="excelcolumn"> <ColumnForm columnChange={this.columnChange}/> <Button className="excel-col-add mk-green" title="娣诲姞鏄剧ず鍒楀瓧娈�" onClick={this.columnFieldInput}> - 鍚屾鏄剧ず鍒� + 鍚屾瀛楁闆� </Button> <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> - <EditTable actions={['edit', 'move', 'copy', 'del', 'extra:required:鏄惁蹇呭~']} type="excelcolumn" data={verify.columns} columns={excelColumns} onChange={this.changeColumns}/> + <Col style={{fontSize: '12px', color: '#757575', paddingLeft: '10px'}} span={24}>娉細鏁板�肩被鍨嬶紙int 鎴� decimal锛夛紝鍐呭涓哄繀濉紱鏈�澶у�煎拰鏈�灏忓�煎湪绫诲瀷涓烘暟鍊兼椂鏈夋晥銆傚鍏�-鍒濆鍖栵細鐢ㄤ簬excel涓笉瀛樺湪锛屽鍏ユ椂闇�瑕佸垵濮嬪寲鐨勫瓧娈�</Col> + <EditTable actions={['edit', 'move', 'copy', 'del', 'extra:required:鏄惁蹇呭~']} searchKey={searchKey} type="excelcolumn" data={verify.columns} columns={excelColumns} onChange={this.changeColumns}/> </TabPane> {card.intertype === 'system' ? <TabPane tab={ <span> @@ -857,7 +931,7 @@ </span> } key="scripts" id="mk-exin-script"> <FullScripts - verify={verify} + scripts={verify.scripts} getScriptsFullForm={() => this.scriptsFullForm} getScriptsForm={() => this.scriptsForm} handleStatus={this.handleStatus} @@ -883,7 +957,12 @@ /> <EditTable actions={['move']} data={verify.scripts} columns={scriptsColumns} onChange={(scripts) => {this.setState({verify: {...verify, scripts}})}}/> </TabPane> : null} - <TabPane tab="淇℃伅鎻愮ず" key="tip"> + <TabPane tab={ + <span> + 淇℃伅鎻愮ず + {activeKey === 'excelcolumn' ? <span onClick={(e) => {e.stopPropagation()}}><Search className="mk-search-fields" defaultValue={searchKey} allowClear onSearch={(val, e) => {e.stopPropagation();this.setState({searchKey: val})}} /></span> : null} + </span> + } key="tip"> <Form {...formItemLayout}> <Row gutter={24}> <Col offset={6} span={6}> -- Gitblit v1.8.0