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 | 166 +++++++++++++++++++++++++++++++++++++------------------ 1 files changed, 112 insertions(+), 54 deletions(-) diff --git a/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx index f22ea28..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: '瀛楁', @@ -39,6 +41,8 @@ inputType: 'input', unique: true, strict: true, + searchable: true, + copy: true, editable: true }, { @@ -46,6 +50,7 @@ dataIndex: 'Text', width: '14%', inputType: 'input', + searchable: true, editable: true }, { @@ -70,7 +75,8 @@ { 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' } ] }, { @@ -296,6 +302,7 @@ } this.setState({ + searchKey: '', verify: { ..._verify, default: _verify.default || 'true', @@ -387,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 = () => { @@ -477,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') { @@ -486,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 = '' } @@ -508,10 +565,6 @@ return col }) - - if (reset) { - message.warning('鏁板�肩被鍨嬪潎涓哄繀濉��') - } this.setState({verify: {...verify, columns}}, () => { this.resetUniqueColumns() @@ -786,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 }, @@ -854,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锛夛紝鍐呭涓哄繀濉紱鏈�澶у�煎拰鏈�灏忓�煎湪绫诲瀷涓烘暟鍊兼椂鏈夋晥銆傚鍏�-鍒濆鍖栵細鐢ㄤ簬excel涓笉瀛樺湪锛屽鍏ユ椂闇�瑕佸垵濮嬪寲鐨勫瓧娈�</Col> - <EditTable actions={['edit', 'move', 'copy', 'del', 'extra:required:鏄惁蹇呭~']} type="excelcolumn" data={verify.columns} columns={excelColumns} onChange={this.changeColumns}/> + <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> @@ -878,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} @@ -904,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