From 0f79daefced8980fa571dd3d2c781a0e3646614f Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 24 十一月 2020 16:57:19 +0800 Subject: [PATCH] 2020-11-24 --- src/templates/zshare/editTable/cusSwitch/index.jsx | 54 ++ src/templates/zshare/editTable/index.jsx | 88 +++ src/templates/comtableconfig/menuform/index.jsx | 11 src/templates/sharecomponent/actioncomponent/verifyexcelin/columnform/index.jsx | 75 -- src/templates/sharecomponent/actioncomponent/verifyexcelin/uniqueform/index.jsx | 47 - src/templates/zshare/verifycard/index.jsx | 313 ++++++-------- src/templates/sharecomponent/actioncomponent/verifyexcelout/columnform/index.jsx | 25 - src/templates/zshare/verifycard/uniqueform/index.jsx | 56 -- src/templates/comtableconfig/index.jsx | 1 src/templates/zshare/verifycard/contrastform/index.jsx | 30 - src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx | 341 ++++++++------- src/templates/zshare/editTable/cusSwitch/index.scss | 40 + src/templates/zshare/editTable/index.scss | 7 src/menu/datasource/verifycard/index.jsx | 11 src/templates/sharecomponent/actioncomponent/verifyexcelin/index.scss | 5 src/utils/utils.js | 29 src/templates/sharecomponent/actioncomponent/verifyexcelout/index.jsx | 95 +--- 17 files changed, 610 insertions(+), 618 deletions(-) diff --git a/src/menu/datasource/verifycard/index.jsx b/src/menu/datasource/verifycard/index.jsx index ebaa9c9..e5de13b 100644 --- a/src/menu/datasource/verifycard/index.jsx +++ b/src/menu/datasource/verifycard/index.jsx @@ -51,6 +51,7 @@ dataIndex: 'field', inputType: 'input', editable: true, + unique: true, width: '28%' }, { @@ -259,6 +260,16 @@ columnChange = (values) => { const { columns } = this.state + let fields = columns.map(item => item.field) + if (fields.includes(values.field)) { + notification.warning({ + top: 92, + message: '瀛楁宸插瓨鍦紒', + duration: 5 + }) + return + } + values.uuid = Utils.getuuid() this.setState({ columns: [...columns, values] }) diff --git a/src/templates/comtableconfig/index.jsx b/src/templates/comtableconfig/index.jsx index b26feb3..0dee3c7 100644 --- a/src/templates/comtableconfig/index.jsx +++ b/src/templates/comtableconfig/index.jsx @@ -1158,7 +1158,6 @@ * @description 鏇存柊鎼滅储鏉′欢閰嶇疆淇℃伅 */ updatesearch = (config) => { - this.setState({ config: config }) diff --git a/src/templates/comtableconfig/menuform/index.jsx b/src/templates/comtableconfig/menuform/index.jsx index 617e4c2..c428598 100644 --- a/src/templates/comtableconfig/menuform/index.jsx +++ b/src/templates/comtableconfig/menuform/index.jsx @@ -21,9 +21,17 @@ UNSAFE_componentWillMount () { const { menu } = this.props + let supList = [] + if (menu.supMenuList && menu.supMenuList.length > 0) { + supList = menu.supMenuList + } else if (menu.fstMenuList && menu.FstId) { + let _menu = menu.fstMenuList.filter(cell => cell.MenuID === menu.FstId)[0] + supList = _menu ? _menu.children : [] + } + this.setState({ menulist: menu.fstMenuList, - submenulist: menu.supMenuList + submenulist: supList }) } @@ -94,6 +102,7 @@ sm: { span: 24 } } } + return ( <Form {...formItemLayout} className="ant-advanced-search-form" id="subqazxcvbn"> <Row gutter={24}> diff --git a/src/templates/sharecomponent/actioncomponent/verifyexcelin/columnform/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyexcelin/columnform/index.jsx index 2cf05f4..4ae7e6a 100644 --- a/src/templates/sharecomponent/actioncomponent/verifyexcelin/columnform/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/verifyexcelin/columnform/index.jsx @@ -6,45 +6,12 @@ class ExcelInColumn extends Component { static propTpyes = { dict: PropTypes.object, // 瀛楀吀椤� - columns: PropTypes.array, // 鍒楀悕闆嗗悎 columnChange: PropTypes.func // 淇敼鍑芥暟 } state = { - editItem: null, // 缂栬緫鍏冪礌 type: 'Nvarchar(50)', locked: false - } - - edit = (record) => { - this.setState({ - editItem: record, - type: record.type || 'Nvarchar(50)' - }, () => { - if (!/^Nvarchar/.test(record.type)) { - this.props.form.setFieldsValue({ - min: record.min, - max: record.max - }) - } - }) - - this.props.form.setFieldsValue({ - Column: record.Column, - Text: record.Text, - required: record.required || 'true', - import: record.import || 'true', - type: record.type - }) - if (record.type === 'Int' || /^Decimal/ig.test(record.type)) { - this.setState({ - locked: true - }) - } else { - this.setState({ - locked: false - }) - } } typeChange = (val) => { @@ -68,12 +35,9 @@ handleConfirm = () => { - // const { columns } = this.props // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� this.props.form.validateFieldsAndScroll((err, values) => { if (!err) { - values.uuid = this.state.editItem ? this.state.editItem.uuid : '' - if (/^Nvarchar/ig.test(values.type)) { values.limit = values.type.match(/\d+/) ? values.type.match(/\d+/)[0] : '20000' } else if (/^Decimal/ig.test(values.type)) { @@ -84,7 +48,6 @@ this.props.columnChange(values) this.setState({ - editItem: null, locked: false, type: 'Nvarchar(50)' }) @@ -113,12 +76,10 @@ } } - let haslimit = !/^Nvarchar/.test(this.state.type) - return ( <Form {...formItemLayout} className="verify-form"> <Row gutter={24}> - <Col span={7}> + <Col span={6}> <Form.Item label={dict['model.form.field']}> {getFieldDecorator('Column', { initialValue: '', @@ -131,7 +92,7 @@ })(<Input placeholder="" autoComplete="off" />)} </Form.Item> </Col> - <Col span={7}> + <Col span={6}> <Form.Item label={dict['model.name']}> {getFieldDecorator('Text', { initialValue: '', @@ -144,7 +105,7 @@ })(<Input placeholder="" autoComplete="off" />)} </Form.Item> </Col> - <Col span={7}> + <Col span={6}> <Form.Item label={dict['model.form.type']}> {getFieldDecorator('type', { initialValue: 'Nvarchar(50)' @@ -169,12 +130,7 @@ )} </Form.Item> </Col> - <Col span={3} className="add"> - <Button onClick={this.handleConfirm} type="primary" className="mk-green"> - {dict['model.save']} - </Button> - </Col> - <Col span={7}> + <Col span={6}> <Form.Item label={dict['model.required']}> {getFieldDecorator('required', { initialValue: 'true' @@ -186,8 +142,8 @@ )} </Form.Item> </Col> - <Col span={7}> - <Form.Item label={dict['model.import']}> + <Col span={6}> + <Form.Item style={{marginBottom: 0}} label={dict['model.import']}> {getFieldDecorator('import', { initialValue: 'true' })( @@ -198,20 +154,27 @@ )} </Form.Item> </Col> - {haslimit ? <Col span={7}> - <Form.Item label={'鏈�灏忓��'}> + <Col span={6}> + <Form.Item style={{marginBottom: 0}} label={'鏈�灏忓��'}> {getFieldDecorator('min', { initialValue: '' })(<InputNumber />)} </Form.Item> - </Col> : null} - {haslimit ? <Col span={7}> - <Form.Item label={'鏈�澶у��'}> + </Col> + <Col span={6}> + <Form.Item style={{marginBottom: 0}} label={'鏈�澶у��'}> {getFieldDecorator('max', { initialValue: '' })(<InputNumber />)} </Form.Item> - </Col> : null} + </Col> + <Col span={6}> + <Form.Item style={{marginBottom: 0}} label={' '} colon={false}> + <Button onClick={this.handleConfirm} type="primary" className="mk-green"> + {dict['model.add']} + </Button> + </Form.Item> + </Col> </Row> </Form> ) diff --git a/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx index 78f15d7..ea18718 100644 --- a/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx @@ -10,11 +10,13 @@ import UniqueForm from './uniqueform' import ColumnForm from './columnform' import CustomScript from './customscript' +import asyncComponent from '@/utils/asyncComponent' import './index.scss' const { TabPane } = Tabs const { confirm } = Modal const { Paragraph } = Typography +const EditTable = asyncComponent(() => import('@/templates/zshare/editTable')) class VerifyCard extends Component { static propTpyes = { @@ -31,26 +33,48 @@ { title: this.props.dict['model.form.field'], dataIndex: 'Column', - width: '16%', + width: '14%', + inputType: 'input', + unique: true, editable: true }, { title: this.props.dict['model.name'], dataIndex: 'Text', - width: '15%', + width: '14%', + inputType: 'input', editable: true }, { title: this.props.dict['model.form.type'], dataIndex: 'type', - width: '12%', - editable: true + width: '15%', + editable: true, + inputType: 'select', + options: [ + { value: 'Nvarchar(10)', text: 'Nvarchar(10)' }, + { value: 'Nvarchar(20)', text: 'Nvarchar(20)' }, + { value: 'Nvarchar(50)', text: 'Nvarchar(50)' }, + { value: 'Nvarchar(100)', text: 'Nvarchar(100)' }, + { value: 'Nvarchar(256)', text: 'Nvarchar(256)' }, + { value: 'Nvarchar(512)', text: 'Nvarchar(512)' }, + { value: 'Nvarchar(1024)', text: 'Nvarchar(1024)' }, + { value: 'Nvarchar(2048)', text: 'Nvarchar(2048)' }, + { 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' } + ] }, { title: this.props.dict['model.required'], dataIndex: 'required', width: '10%', editable: true, + inputType: 'switch', render: (text, record) => record.required === 'true' ? this.props.dict['model.true'] : this.props.dict['model.false'] }, { @@ -58,62 +82,74 @@ dataIndex: 'import', width: '10%', editable: true, + inputType: 'switch', render: (text, record) => record.import !== 'false' ? this.props.dict['model.true'] : this.props.dict['model.false'] }, { title: '鏈�灏忓��', dataIndex: 'min', width: '10%', + required: false, + inputType: 'number', + unlimit: true, editable: true }, { title: '鏈�澶у��', dataIndex: 'max', width: '10%', + required: false, + inputType: 'number', + unlimit: true, editable: true - }, - { - title: '鎿嶄綔', - align: 'center', - dataIndex: 'operation', - render: (text, record) => - ( - <div> - <span className="operation-btn" title={this.props.dict['model.edit']} onClick={() => this.handleEdit(record, 'columns')} style={{color: '#1890ff'}}><Icon type="edit" /></span> - <span className="operation-btn" title={this.props.dict['header.form.up']} onClick={() => this.handleUpDown(record, 'columns', 'up')} style={{color: '#1890ff'}}><Icon type="arrow-up" /></span> - <span className="operation-btn" title={this.props.dict['header.form.down']} onClick={() => this.handleUpDown(record, 'columns', 'down')} style={{color: '#ff4d4f'}}><Icon type="arrow-down" /></span> - <Popconfirm - overlayClassName="popover-confirm" - title={this.props.dict['model.query.delete']} - onConfirm={() => this.handleDelete(record, 'columns') - }> - <span className="operation-btn" style={{color: '#ff4d4f'}}><Icon type="delete" /></span> - </Popconfirm> - </div> - ) } ], uniqueColumns: [ { - title: '瀛楁鍚�', + title: '鍒楀悕', + dataIndex: 'fieldlabel', + width: '20%' + }, + { + title: '瀛楁', dataIndex: 'field', - width: '35%' + width: '25%', + editable: true, + inputType: 'multiStr', + options: [] }, { title: '鎶ラ敊缂栫爜', dataIndex: 'errorCode', - width: '12%' + width: '12%', + editable: true, + inputType: 'select', + options: [ + { value: 'E', text: 'E' }, + { value: 'N', text: 'N' }, + { value: 'F', text: 'F' }, + { value: 'NM', text: 'NM' } + ] }, { title: '楠岃瘉绫诲瀷', dataIndex: 'verifyType', - width: '13%', - render: (text, record) => record.verifyType === 'logic' ? '閫昏緫楠岃瘉' : '鐗╃悊楠岃瘉' + width: '12%', + render: (text, record) => record.verifyType === 'logic' ? '閫昏緫楠岃瘉' : '鐗╃悊楠岃瘉', + inputType: 'select', + editable: true, + options: [ + { value: 'physical', text: '鐗╃悊楠岃瘉' }, + { value: 'logic', text: '閫昏緫楠岃瘉' } + ] }, { - title: '鐘舵��', + title: '鏄惁鍚敤', dataIndex: 'status', - width: '15%', + width: '12%', + editable: true, + required: false, + inputType: 'switch', render: (text, record) => record.status === 'false' ? ( <div> @@ -128,26 +164,6 @@ </div> ) }, - { - title: '鎿嶄綔', - align: 'center', - width: '25%', - dataIndex: 'operation', - render: (text, record) => - (<div> - <span className="operation-btn" title={this.props.dict['model.edit']} onClick={() => this.handleEdit(record, 'unique')} style={{color: '#1890ff'}}><Icon type="edit" /></span> - <span className="operation-btn" title={this.props.dict['header.form.up']} onClick={() => this.handleUpDown(record, 'unique', 'up')} style={{color: '#1890ff'}}><Icon type="arrow-up" /></span> - <span className="operation-btn" title={this.props.dict['header.form.down']} onClick={() => this.handleUpDown(record, 'unique', 'down')} style={{color: '#ff4d4f'}}><Icon type="arrow-down" /></span> - <span className="operation-btn" title={this.props.dict['header.form.status.change']} onClick={() => this.handleStatus(record, 'unique')} style={{color: '#8E44AD'}}><Icon type="swap" /></span> - <Popconfirm - overlayClassName="popover-confirm" - title={this.props.dict['model.query.delete']} - onConfirm={() => this.handleDelete(record, 'unique') - }> - <span className="operation-btn" style={{color: '#ff4d4f'}}><Icon type="delete" /></span> - </Popconfirm> - </div>) - } ], scriptsColumns: [ { @@ -216,58 +232,25 @@ } UNSAFE_componentWillMount() { - const { columns, card } = this.props + const { card } = this.props let _verify = fromJS(card.verify || {range: 1}).toJS() let _columns = _verify.columns || [] - // 鍚屾鏄剧ず鍒� - if (_columns.length === 0) { - columns.forEach(col => { - if (!col.field) 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 - } + // 鏃ф暟鎹吋瀹� + _columns = _columns.map(col => { + col.required = col.required || 'true' + col.type = col.type || 'Nvarchar(50)' + + if (/^Nvarchar/ig.test(col.type)) { + col.limit = col.type.match(/\d+/)[0] + } else if (/^Decimal/ig.test(col.type)) { + col.limit = col.type.match(/\d+/ig)[1] + } else { + col.limit = '' + } - 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) - }) - } else { - // 鏃ф暟鎹吋瀹� - _columns = _columns.map(col => { - col.required = col.required || 'true' - col.type = col.type || 'Nvarchar(50)' - - if (/^Nvarchar/ig.test(col.type)) { - col.limit = col.type.match(/\d+/)[0] - } else if (/^Decimal/ig.test(col.type)) { - col.limit = col.type.match(/\d+/ig)[1] - } else { - col.limit = '' - } - - return col - }) - } + return col + }) this.setState({ verify: { @@ -279,6 +262,8 @@ scripts: _verify.scripts || [], uniques: _verify.uniques || [] } + }, () => { + this.resetUniqueColumns() }) } @@ -317,6 +302,27 @@ }) } }) + } + + resetUniqueColumns = () => { + const { uniqueColumns, verify } = this.state + + this.setState({uniqueColumns: uniqueColumns.map(col => { + if (col.dataIndex === 'field') { + col.options = verify.columns.map(c => { + return { + field: c.Column, + label: c.Text + } + }) + col.options.unshift({ + field: 'BID', + label: 'BID' + }) + } + + return col + })}) } columnFieldInput = () => { @@ -363,6 +369,8 @@ ...verify, columns: _columns } + }, () => { + this.resetUniqueColumns() }) } @@ -378,6 +386,8 @@ ...verify, columns: [] } + }, () => { + _this.resetUniqueColumns() }) }, onCancel() {} @@ -387,43 +397,85 @@ columnChange = (values) => { let verify = JSON.parse(JSON.stringify(this.state.verify)) - if (values.uuid) { - verify.columns = verify.columns.map(item => { - if (item.uuid === values.uuid) { - return values - } else { - return item - } + let fields = verify.columns.map(item => item.Column) + if (fields.includes(values.Column)) { + notification.warning({ + top: 92, + message: values.Column + '瀛楁宸插瓨鍦紒', + duration: 5 }) - } else { - values.uuid = Utils.getuuid() - verify.columns.push(values) + return } + + values.uuid = Utils.getuuid() + verify.columns.push(values) this.setState({ verify: verify + }, () => { + this.resetUniqueColumns() + }) + } + + changeColumns = (columns) => { + const { verify } = this.state + + columns = columns.map(col => { + 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] + col.required = 'true' + } else if (/^int/ig.test(col.type)) { + col.required = 'true' + } else { + col.limit = '' + } + + return col + }) + + this.setState({verify: {...verify, columns}}, () => { + this.resetUniqueColumns() }) } uniqueChange = (values) => { let verify = JSON.parse(JSON.stringify(this.state.verify)) - if (values.uuid) { - verify.uniques = verify.uniques.map(item => { - if (item.uuid === values.uuid) { - return values - } else { - return item - } - }) - } else { - values.uuid = Utils.getuuid() - verify.uniques.push(values) - } + values.status = 'true' + values.uuid = Utils.getuuid() + verify.uniques.push(values) this.setState({ verify: verify }) + } + + changeUniques = (uniques) => { + const { verify } = this.state + + let change = {} + verify.columns.forEach(col => { + change[col.Column] = col.Text + }) + + uniques = uniques.map(item => { + item.status = item.status || 'true' + + if (Array.isArray(item.field)) { + item.fieldlabel = item.field.map(field => { + return change[field] || '' + }) + + item.fieldlabel = item.fieldlabel.join(',') + item.field = item.field.join(',') + } + + return item + }) + + this.setState({verify: {...verify, uniques}}) } scriptsChange = (values) => { @@ -462,12 +514,8 @@ } handleEdit = (record, type) => { - if (type === 'columns') { - this.columnForm.edit(record) - } else if (type === 'scripts') { + if (type === 'scripts') { this.scriptsForm.edit(record) - } else if (type === 'unique') { - this.uniqueForm.edit(record) } let node = document.getElementById('verify-excel-box-tab').parentNode @@ -613,15 +661,9 @@ } let _loading = false - if (this.columnForm && this.columnForm.state.editItem) { - _loading = true - this.setState({activeKey: 'excelcolumn'}) - } else if (this.scriptsForm && this.scriptsForm.state.editItem) { + if (this.scriptsForm && this.scriptsForm.state.editItem) { _loading = true this.setState({activeKey: 'scripts'}) - } else if (this.uniqueForm && this.uniqueForm.state.editItem) { - _loading = true - this.setState({activeKey: 'unique'}) } if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql')) { @@ -778,26 +820,15 @@ {verify.columns.length ? <span className="count-tip">{verify.columns.length}</span> : null} </span> } key="excelcolumn"> - <ColumnForm - dict={this.props.dict} - columns={verify.columns} - columnChange={this.columnChange} - wrappedComponentRef={(inst) => this.columnForm = inst} - /> + <ColumnForm dict={this.props.dict} 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> - <Table - bordered - rowKey="uuid" - className="custom-table excel-custom-table" - dataSource={verify.columns} - columns={excelColumns} - pagination={false} - /> + <Col style={{fontSize: '12px', color: '#757575', paddingLeft: '10px'}} span={24}>娉細鏁板�肩被鍨嬶紙int 鎴� decimal锛夛紝鍐呭涓哄繀濉紱鏈�澶у�煎拰鏈�灏忓�煎湪绫诲瀷涓烘暟鍊兼椂鏈夋晥銆�</Col> + <EditTable data={verify.columns} columns={excelColumns} onChange={this.changeColumns}/> </TabPane> {card.intertype === 'system' ? <TabPane tab={ <span> @@ -805,20 +836,8 @@ {verify.uniques.length ? <span className="count-tip">{verify.uniques.length}</span> : null} </span> } key="unique"> - <UniqueForm - fields={verify.columns} - dict={this.props.dict} - uniqueChange={this.uniqueChange} - wrappedComponentRef={(inst) => this.uniqueForm = inst} - /> - <Table - bordered - rowKey="uuid" - className="custom-table" - dataSource={verify.uniques} - columns={uniqueColumns} - pagination={false} - /> + <UniqueForm fields={verify.columns} dict={this.props.dict} uniqueChange={this.uniqueChange}/> + <EditTable data={verify.uniques} columns={uniqueColumns} onChange={this.changeUniques}/> </TabPane> : null} {card.intertype === 'system' ? <TabPane tab={ <span> diff --git a/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.scss b/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.scss index 00808ca..6394765 100644 --- a/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.scss +++ b/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.scss @@ -51,9 +51,6 @@ width: 89.5%; } } - .add { - padding-top: 4px; - } } .custom-table .ant-empty { margin: 20px 8px!important; @@ -79,7 +76,7 @@ float: right; right: -9px; margin-right: 10px; - top: -40px; + top: 10px; z-index: 1; } } diff --git a/src/templates/sharecomponent/actioncomponent/verifyexcelin/uniqueform/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyexcelin/uniqueform/index.jsx index 221bf91..bba6819 100644 --- a/src/templates/sharecomponent/actioncomponent/verifyexcelin/uniqueform/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/verifyexcelin/uniqueform/index.jsx @@ -11,46 +11,25 @@ uniqueChange: PropTypes.func // 淇敼鍑芥暟 } - state = { - editItem: null // 缂栬緫鍏冪礌 - } - - edit = (record) => { - this.setState({ - editItem: record - }) - - this.props.form.setFieldsValue({ - field: record.field.split(','), - errorCode: record.errorCode, - verifyType: record.verifyType || 'physical' - }) - } - - handleConfirm = () => { const { fields } = this.props + let change = {} + + fields.forEach(col => { + change[col.Column] = col.Text + }) + // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� this.props.form.validateFieldsAndScroll((err, values) => { if (!err) { - values.uuid = this.state.editItem ? this.state.editItem.uuid : '' values.fieldlabel = values.field.map(field => { - let item = fields.filter(cell => cell.Column === field)[0] - let label = '' - if (item) { - label = item.Text - } - return label + return change[field] || '' }) values.fieldlabel = values.fieldlabel.join(',') values.field = values.field.join(',') - this.setState({ - editItem: null - }, () => { - this.props.uniqueChange(values) - }) + this.props.uniqueChange(values) this.props.form.setFieldsValue({ field: [], }) @@ -76,7 +55,7 @@ return ( <Form {...formItemLayout} className="verify-form" id="verifycard1"> <Row gutter={24}> - <Col span={8}> + <Col span={7}> <Form.Item label={'鍒楀悕'}> {getFieldDecorator('field', { initialValue: [], @@ -98,7 +77,7 @@ )} </Form.Item> </Col> - <Col span={6}> + <Col span={7}> <Form.Item label={'鎶ラ敊缂栫爜'}> {getFieldDecorator('errorCode', { initialValue: 'E', @@ -118,7 +97,7 @@ )} </Form.Item> </Col> - <Col span={6}> + <Col span={7}> <Form.Item label={'楠岃瘉绫诲瀷'}> {getFieldDecorator('verifyType', { initialValue: 'physical', @@ -136,9 +115,9 @@ )} </Form.Item> </Col> - <Col span={4} className="add"> + <Col span={3} className="add"> <Button onClick={this.handleConfirm} className="mk-green"> - 淇濆瓨 + 娣诲姞 </Button> </Col> </Row> diff --git a/src/templates/sharecomponent/actioncomponent/verifyexcelout/columnform/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyexcelout/columnform/index.jsx index 56f31eb..01ec3e6 100644 --- a/src/templates/sharecomponent/actioncomponent/verifyexcelout/columnform/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/verifyexcelout/columnform/index.jsx @@ -6,37 +6,14 @@ class ExcelOutColumn extends Component { static propTpyes = { dict: PropTypes.object, // 瀛楀吀椤� - columns: PropTypes.array, // 鍒楀悕闆嗗悎 columnChange: PropTypes.func // 淇敼鍑芥暟 } - - state = { - editItem: null // 缂栬緫鍏冪礌 - } - - edit = (record) => { - this.setState({ - editItem: record - }) - - this.props.form.setFieldsValue({ - Column: record.Column, - Text: record.Text, - Width: record.Width - }) - } - handleConfirm = () => { // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� this.props.form.validateFieldsAndScroll((err, values) => { if (!err) { - values.uuid = this.state.editItem ? this.state.editItem.uuid : '' - this.props.columnChange(values) - this.setState({ - editItem: null - }) this.props.form.setFieldsValue({ Column: '', Text: '', @@ -104,7 +81,7 @@ </Col> <Col span={3} className="add"> <Button onClick={this.handleConfirm} type="primary" className="mk-green"> - 淇濆瓨 + 娣诲姞 </Button> </Col> </Row> diff --git a/src/templates/sharecomponent/actioncomponent/verifyexcelout/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyexcelout/index.jsx index 32fe504..c2d4c20 100644 --- a/src/templates/sharecomponent/actioncomponent/verifyexcelout/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/verifyexcelout/index.jsx @@ -1,7 +1,7 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { fromJS } from 'immutable' -import { Form, Tabs, Row, Col, Button, Table, Popconfirm, Icon, notification, Modal, message, InputNumber, Radio } from 'antd' +import { Form, Tabs, Row, Col, Button, notification, Modal, message, InputNumber, Radio } from 'antd' import moment from 'moment' import Api from '@/api' @@ -9,10 +9,12 @@ import ColumnForm from './columnform' import CodeMirror from '@/templates/zshare/codemirror' +import asyncComponent from '@/utils/asyncComponent' import './index.scss' const { TabPane } = Tabs const { confirm } = Modal +const EditTable = asyncComponent(() => import('@/templates/zshare/editTable')) class VerifyCard extends Component { static propTpyes = { @@ -28,37 +30,26 @@ { title: this.props.dict['model.form.field'], dataIndex: 'Column', + inputType: 'input', + editable: true, + unique: true, width: '25%' }, { title: this.props.dict['model.name'], dataIndex: 'Text', + inputType: 'input', + editable: true, width: '25%' }, { title: this.props.dict['model.form.columnWidth'], dataIndex: 'Width', + inputType: 'number', + min: 5, + max: 200, + editable: true, width: '25%' - }, - { - title: '鎿嶄綔', - align: 'center', - dataIndex: 'operation', - render: (text, record) => - ( - <div> - <span className="operation-btn" title={this.props.dict['model.edit']} onClick={() => this.handleEdit(record, 'columns')} style={{color: '#1890ff'}}><Icon type="edit" /></span> - <span className="operation-btn" title={this.props.dict['header.form.up']} onClick={() => this.handleUpDown(record, 'columns', 'up')} style={{color: '#1890ff'}}><Icon type="arrow-up" /></span> - <span className="operation-btn" title={this.props.dict['header.form.down']} onClick={() => this.handleUpDown(record, 'columns', 'down')} style={{color: '#ff4d4f'}}><Icon type="arrow-down" /></span> - <Popconfirm - overlayClassName="popover-confirm" - title={this.props.dict['model.query.delete']} - onConfirm={() => this.handleDelete(record, 'columns') - }> - <span style={{color: '#ff4d4f', cursor: 'pointer'}}><Icon type="delete" /></span> - </Popconfirm> - </div> - ) } ] } @@ -158,27 +149,17 @@ columnChange = (values) => { let verify = JSON.parse(JSON.stringify(this.state.verify)) - if (values.uuid) { - verify.columns = verify.columns.map(item => { - if (item.uuid === values.uuid) { - return values - } else { - return item - } + let fields = verify.columns.map(item => item.Column) + if (fields.includes(values.Column)) { + notification.warning({ + top: 92, + message: values.Column + '瀛楁宸插瓨鍦紒', + duration: 5 }) - } else { - let fields = verify.columns.map(item => item.Column) - if (fields.includes(values.Column)) { - notification.warning({ - top: 92, - message: values.Column + '瀛楁宸插瓨鍦紒', - duration: 5 - }) - return - } - values.uuid = Utils.getuuid() - verify.columns.push(values) + return } + values.uuid = Utils.getuuid() + verify.columns.push(values) this.setState({ verify: verify @@ -191,25 +172,6 @@ verify.columns = verify.columns.filter(item => item.uuid !== record.uuid) this.setState({ verify: verify }) - } - - handleEdit = (record, type) => { - this.columnForm.edit(record) - - let node = document.getElementById('verify-excelout-box-tab').parentNode - - if (node && node.scrollTop) { - let inter = Math.ceil(node.scrollTop / 10) - - let timer = setInterval(() => { - if (node.scrollTop - inter > 0) { - node.scrollTop = node.scrollTop - inter - } else { - node.scrollTop = 0 - clearInterval(timer) - } - }, 10) - } } handleUpDown = (record, type, direction) => { @@ -452,25 +414,14 @@ {verify.columns.length ? <span className="count-tip">{verify.columns.length}</span> : null} </span> } key="1"> - <ColumnForm - dict={this.props.dict} - columnChange={this.columnChange} - wrappedComponentRef={(inst) => this.columnForm = inst} - /> + <ColumnForm dict={this.props.dict} 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> - <Table - bordered - rowKey="uuid" - className="custom-table" - dataSource={verify.columns} - columns={excelColumns} - pagination={false} - /> + <EditTable data={verify.columns} columns={excelColumns} onChange={(columns) => this.setState({verify: {...verify, columns}})}/> </TabPane> {card.intertype === 'system' ? <TabPane tab={ <span> diff --git a/src/templates/zshare/editTable/cusSwitch/index.jsx b/src/templates/zshare/editTable/cusSwitch/index.jsx new file mode 100644 index 0000000..82cd954 --- /dev/null +++ b/src/templates/zshare/editTable/cusSwitch/index.jsx @@ -0,0 +1,54 @@ +import React, {Component} from 'react' +import PropTypes from 'prop-types' +// import { is, fromJS } from 'immutable' +import { Switch } from 'antd' + +import './index.scss' + +class ColorSketch extends Component { + static propTpyes = { + defaultValue: PropTypes.any, + value: PropTypes.any, + onChange: PropTypes.func + } + state = { + status: true, + } + + UNSAFE_componentWillMount () { + const { defaultValue, value } = this.props + let initVal = 'true' + + if (this.props['data-__meta']) { + initVal = this.props['data-__meta'].initialValue + } else if (defaultValue) { + initVal = defaultValue + } else if (value) { + initVal = value + } + + if (initVal === 'false') { + initVal = false + } else { + initVal = true + } + + this.setState({status: initVal}) + } + + changeStatus = (val) => { + this.setState({ status: val }, () => { + let _val = val ? 'true' : 'false' + this.props.onChange && this.props.onChange(_val) + }) + } + + render() { + const { status } = this.state + return ( + <Switch checkedChildren="鏄�" unCheckedChildren="鍚�" checked={status} onChange={this.changeStatus} /> + ) + } +} + +export default ColorSketch \ No newline at end of file diff --git a/src/templates/zshare/editTable/cusSwitch/index.scss b/src/templates/zshare/editTable/cusSwitch/index.scss new file mode 100644 index 0000000..96900ce --- /dev/null +++ b/src/templates/zshare/editTable/cusSwitch/index.scss @@ -0,0 +1,40 @@ +.color-sketch-block { + height: 25px; + width: 100%; + + .color-sketch-block-box { + display: inline-block; + width: calc(100% - 160px); + height: 100%; + border-radius: 2px; + background: #ffffff url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAMUlEQVQ4T2NkYGAQYcAP3uCTZhw1gGGYhAGBZIA/nYDCgBDAm9BGDWAAJyRCgLaBCAAgXwixzAS0pgAAAABJRU5ErkJggg==') left center; + } + .color-sketch-block-inner { + display: inline-block; + cursor: pointer; + border-radius: 2px; + box-shadow: 0 0 0 1px rgba(0, 0, 0, .1); + width: 100%; + height: 100%; + } + .color-sketch-value { + display: inline-block; + width: 160px; + padding-left: 10px; + height: 25px; + line-height: 25px; + vertical-align: top; + white-space: nowrap; + overflow: visible; + } +} + +.color-sketch-popover { + z-index: 1090!important; + .ant-popover-inner-content { + padding: 0; + .sketch-picker { + width: 250px!important; + } + } +} \ No newline at end of file diff --git a/src/templates/zshare/editTable/index.jsx b/src/templates/zshare/editTable/index.jsx index 7597a13..bfeffd6 100644 --- a/src/templates/zshare/editTable/index.jsx +++ b/src/templates/zshare/editTable/index.jsx @@ -1,9 +1,10 @@ import React, { Component } from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import { Table, Input, InputNumber, Popconfirm, Form, Icon, Select, Radio, Cascader } from 'antd' +import { Table, Input, InputNumber, Popconfirm, Form, Icon, Select, Radio, Cascader, notification } from 'antd' import ColorSketch from '@/mob/colorsketch' +import CusSwitch from './cusSwitch' import zhCN from '@/locales/zh-CN/model.js' import enUS from '@/locales/en-US/model.js' import './index.scss' @@ -13,15 +14,25 @@ class EditableCell extends Component { getInput = (form) => { - const { inputType, options } = this.props + const { inputType, options, min, max, unlimit } = this.props - if (inputType === 'number') { - return <InputNumber min={12} max={50} precision={0} onPressEnter={() => this.getValue(form)} /> + 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 /> + } else if (inputType === 'switch') { + return <CusSwitch /> } else if (inputType === 'select') { return ( <Select> + {options.map((item, i) => (<Select.Option key={i} value={item.field || item.value}> {item.label || item.text} </Select.Option>))} + </Select> + ) + } else if (inputType === 'multiStr') { + return ( + <Select mode="multiple"> {options.map((item, i) => (<Select.Option key={i} value={item.field || item.value}> {item.label || item.text} </Select.Option>))} </Select> ) @@ -65,7 +76,7 @@ message: ['number', 'text', 'input'].includes(inputType) ? `${eTDict['form.required.input']} ${title}!` : `${eTDict['form.required.select']} ${title}!`, } ], - initialValue: record[dataIndex], + initialValue: inputType === 'multiStr' ? (record[dataIndex] ? record[dataIndex].split(',') : []) : record[dataIndex], })(this.getInput(form))} </Form.Item> ) : ( @@ -117,7 +128,7 @@ <span style={{ color: '#1890ff', cursor: 'pointer'}} onClick={() => this.cancel(record.uuid)}>{eTDict['model.cancel']}</span> </span> ) : ( - <div className={'operation-btn' + (editingKey !== '' ? ' disabled' : '')}> + <div className={'edit-operation-btn' + (editingKey !== '' ? ' disabled' : '')}> {!actions || actions.includes('edit') ? <span className="primary" onClick={() => {editingKey === '' && this.edit(record.uuid)}}><Icon type="edit" /></span> : null} {!actions || actions.includes('up') ? <span className="primary" onClick={() => {editingKey === '' && this.handleUpDown(record.uuid, 'up')}}><Icon type="arrow-up" /></span> : null} {!actions || actions.includes('down') ? <span className="danger" onClick={() => {editingKey === '' && this.handleUpDown(record.uuid, 'down')}}><Icon type="arrow-down" /></span> : null} @@ -136,6 +147,7 @@ this.setState({ data: data || [], + oricolumns: fromJS(this.props.columns).toJS(), columns }) } @@ -143,6 +155,19 @@ UNSAFE_componentWillReceiveProps (nextProps) { if (!is(fromJS(this.state.data), fromJS(nextProps.data))) { this.setState({data: nextProps.data, editingKey: ''}) + } else if (!is(fromJS(this.state.oricolumns), fromJS(nextProps.columns))) { + let cols = {} + nextProps.columns.forEach(col => {cols[col.dataIndex] = col}) + + this.setState({ + oricolumns: fromJS(nextProps.columns).toJS(), + columns: this.state.columns.map(col => { + if (cols[col.dataIndex]) { + return cols[col.dataIndex] + } + return col + }) + }) } } @@ -153,10 +178,36 @@ } onSave = (record) => { + const { columns } = this.state const newData = [...this.state.data] const index = newData.findIndex(item => record.uuid === item.uuid) - if (index === -1) return + if (index === -1) { + notification.warning({ + top: 92, + message: '鏁版嵁閿欒锛屾棤娉曟壘鍒拌ID锛�', + duration: 5 + }) + return + } + + let unique = true + columns.forEach(col => { + if (col.unique !== true || !unique) return + + let _index = newData.findIndex(item => record.uuid !== item.uuid && record[col.dataIndex] === item[col.dataIndex]) + + if (_index > -1) { + notification.warning({ + top: 92, + message: col.title + '涓嶅彲閲嶅锛�', + duration: 5 + }) + unique = false + } + }) + + if (!unique) return newData.splice(index, 1, record) this.setState({ data: newData, editingKey: '' }, () => { @@ -197,12 +248,32 @@ } save(form, uuid) { + const { columns } = this.state form.validateFields((error, row) => { if (error) { return; } const newData = [...this.state.data] const index = newData.findIndex(item => uuid === item.uuid) + + let unique = true + columns.forEach(col => { + if (col.unique !== true || !unique) return + + let _index = newData.findIndex(item => uuid !== item.uuid && row[col.dataIndex] === item[col.dataIndex]) + + if (_index > -1) { + notification.warning({ + top: 92, + message: col.title + '涓嶅彲閲嶅锛�', + duration: 5 + }) + unique = false + } + }) + + if (!unique) return + if (index > -1) { const item = newData[index] newData.splice(index, 1, { @@ -241,6 +312,9 @@ inputType: col.inputType, dataIndex: col.dataIndex, options: col.options || [], + min: col.min || 0, + max: col.max || 500, + unlimit: col.unlimit, required: col.required !== false ? true : false, title: col.title, editing: this.isEditing(record), diff --git a/src/templates/zshare/editTable/index.scss b/src/templates/zshare/editTable/index.scss index a84f0a7..f51b1ff 100644 --- a/src/templates/zshare/editTable/index.scss +++ b/src/templates/zshare/editTable/index.scss @@ -21,7 +21,7 @@ thead tr th:last-child { text-align: center; } - .operation-btn { + .edit-operation-btn { display: block; text-align: center; span { @@ -34,8 +34,11 @@ .danger { color: #ff4d4f; } + span:last-child { + margin-right: 0px; + } } - .operation-btn.disabled { + .edit-operation-btn.disabled { cursor: default; span { cursor: default; diff --git a/src/templates/zshare/verifycard/contrastform/index.jsx b/src/templates/zshare/verifycard/contrastform/index.jsx index 9393dc5..50cdead 100644 --- a/src/templates/zshare/verifycard/contrastform/index.jsx +++ b/src/templates/zshare/verifycard/contrastform/index.jsx @@ -3,43 +3,17 @@ import { Form, Row, Col, Select, Button, Input } from 'antd' import './index.scss' - class UniqueForm extends Component { static propTpyes = { dict: PropTypes.object, // 瀛楀吀椤� contrastChange: PropTypes.func // 淇敼鍑芥暟 } - state = { - editItem: null // 缂栬緫鍏冪礌 - } - - edit = (record) => { - this.setState({ - editItem: record - }) - - this.props.form.setFieldsValue({ - frontfield: record.frontfield, - operator: record.operator, - backfield: record.backfield, - errmsg: record.errmsg, - errorCode: record.errorCode - }) - } - - handleConfirm = () => { // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� this.props.form.validateFieldsAndScroll((err, values) => { if (!err) { - values.uuid = this.state.editItem ? this.state.editItem.uuid : '' - - this.setState({ - editItem: null - }, () => { - this.props.contrastChange(values) - }) + this.props.contrastChange(values) this.props.form.setFieldsValue({ frontfield: '', backfield: '', @@ -117,7 +91,7 @@ </Col> <Col span={3} className="add"> <Button onClick={this.handleConfirm} type="primary" className="mk-green"> - 淇濆瓨 + {this.props.dict['model.add']} </Button> </Col> <Col span={7}> diff --git a/src/templates/zshare/verifycard/index.jsx b/src/templates/zshare/verifycard/index.jsx index a1c1109..b067018 100644 --- a/src/templates/zshare/verifycard/index.jsx +++ b/src/templates/zshare/verifycard/index.jsx @@ -13,11 +13,13 @@ import CustomScript from './customscript' import BillcodeForm from './billcodeform' import VoucherForm from './voucherform' +import asyncComponent from '@/utils/asyncComponent' import './index.scss' const { TabPane } = Tabs const { confirm } = Modal const { Paragraph } = Typography +const EditTable = asyncComponent(() => import('@/templates/zshare/editTable')) class VerifyCard extends Component { static propTpyes = { @@ -43,25 +45,50 @@ columnsFields: [], uniqueColumns: [ { - title: '瀛楁鍚�', + title: '鍚嶇О', + dataIndex: 'fieldlabel', + width: '20%' + }, + { + title: '瀛楁', dataIndex: 'field', - width: '35%' + width: '20%', + editable: true, + inputType: 'multiStr', + options: [] }, { title: '鎶ラ敊缂栫爜', dataIndex: 'errorCode', - width: '12%' + width: '12%', + editable: true, + inputType: 'select', + options: [ + { value: 'E', text: 'E' }, + { value: 'N', text: 'N' }, + { value: 'F', text: 'F' }, + { value: 'NM', text: 'NM' } + ] }, { title: '楠岃瘉绫诲瀷', dataIndex: 'verifyType', width: '13%', - render: (text, record) => record.verifyType === 'logic' ? '閫昏緫楠岃瘉' : '鐗╃悊楠岃瘉' + render: (text, record) => record.verifyType === 'logic' ? '閫昏緫楠岃瘉' : '鐗╃悊楠岃瘉', + inputType: 'select', + editable: true, + options: [ + { value: 'physical', text: '鐗╃悊楠岃瘉' }, + { value: 'logic', text: '閫昏緫楠岃瘉' } + ] }, { - title: '鐘舵��', + title: '鏄惁鍚敤', dataIndex: 'status', - width: '15%', + width: '13%', + editable: true, + required: false, + inputType: 'switch', render: (text, record) => record.status === 'false' ? ( <div> @@ -75,38 +102,29 @@ <Icon style={{marginLeft: '5px'}} type="check-circle" theme="twoTone" twoToneColor="#52c41a" /> </div> ) - }, - { - title: '鎿嶄綔', - align: 'center', - width: '25%', - dataIndex: 'operation', - render: (text, record) => - (<div> - <span className="operation-btn" title={this.props.dict['model.edit']} onClick={() => this.handleEdit(record, 'unique')} style={{color: '#1890ff'}}><Icon type="edit" /></span> - <span className="operation-btn" title={this.props.dict['header.form.up']} onClick={() => this.handleUpDown(record, 'unique', 'up')} style={{color: '#1890ff'}}><Icon type="arrow-up" /></span> - <span className="operation-btn" title={this.props.dict['header.form.down']} onClick={() => this.handleUpDown(record, 'unique', 'down')} style={{color: '#ff4d4f'}}><Icon type="arrow-down" /></span> - <span className="operation-btn" title={this.props.dict['header.form.status.change']} onClick={() => this.handleStatus(record, 'unique')} style={{color: '#8E44AD'}}><Icon type="swap" /></span> - <Popconfirm - overlayClassName="popover-confirm" - title={this.props.dict['model.query.delete']} - onConfirm={() => this.handleDelete(record, 'unique') - }> - <span className="operation-btn" style={{color: '#ff4d4f'}}><Icon type="delete" /></span> - </Popconfirm> - </div>) } ], onceUniqueColumns: [ { - title: '瀛楁鍚�', - dataIndex: 'field', - width: '45%' + title: '鍚嶇О', + dataIndex: 'fieldlabel', + width: '30%' }, { - title: '鐘舵��', - dataIndex: 'status', + title: '瀛楁', + dataIndex: 'field', width: '30%', + editable: true, + inputType: 'multiStr', + options: [] + }, + { + title: '鏄惁鍚敤', + dataIndex: 'status', + width: '20%', + editable: true, + required: false, + inputType: 'switch', render: (text, record) => record.status === 'false' ? ( <div> @@ -121,57 +139,66 @@ </div> ) }, - { - title: '鎿嶄綔', - align: 'center', - width: '25%', - dataIndex: 'operation', - render: (text, record) => - (<div> - <span className="operation-btn" title={this.props.dict['model.edit']} onClick={() => this.handleEdit(record, 'unique')} style={{color: '#1890ff'}}><Icon type="edit" /></span> - <span className="operation-btn" title={this.props.dict['header.form.up']} onClick={() => this.handleUpDown(record, 'unique', 'up')} style={{color: '#1890ff'}}><Icon type="arrow-up" /></span> - <span className="operation-btn" title={this.props.dict['header.form.down']} onClick={() => this.handleUpDown(record, 'unique', 'down')} style={{color: '#ff4d4f'}}><Icon type="arrow-down" /></span> - <span className="operation-btn" title={this.props.dict['header.form.status.change']} onClick={() => this.handleStatus(record, 'unique')} style={{color: '#8E44AD'}}><Icon type="swap" /></span> - <Popconfirm - overlayClassName="popover-confirm" - title={this.props.dict['model.query.delete']} - onConfirm={() => this.handleDelete(record, 'unique') - }> - <span className="operation-btn" style={{color: '#ff4d4f'}}><Icon type="delete" /></span> - </Popconfirm> - </div>) - } ], contrastColumns: [ { title: '鍐呭1', dataIndex: 'frontfield', - width: '13%' + width: '14%', + inputType: 'input', + editable: true }, { title: '杩愮畻绗�', dataIndex: 'operator', - width: '13%' + width: '14%', + editable: true, + inputType: 'select', + options: [ + { value: '=', text: '=' }, + { value: '!=', text: '!=' }, + { value: '>', text: '>' }, + { value: '<', text: '<' }, + { value: '>=', text: '>=' }, + { value: '<=', text: '<=' }, + { value: 'in', text: 'in' }, + { value: 'like', text: 'like' } + ] }, { title: '鍐呭2', dataIndex: 'backfield', - width: '13%', + width: '14%', + inputType: 'input', + editable: true }, { title: '鎻愮ず淇℃伅', dataIndex: 'errmsg', - width: '13%' + width: '14%', + inputType: 'input', + editable: true }, { title: '鎶ラ敊缂栫爜', dataIndex: 'errorCode', - width: '13%' + width: '14%', + editable: true, + inputType: 'select', + options: [ + { value: 'E', text: 'E' }, + { value: 'N', text: 'N' }, + { value: 'F', text: 'F' }, + { value: 'NM', text: 'NM' } + ] }, { - title: '鐘舵��', + title: '鏄惁鍚敤', dataIndex: 'status', - width: '15%', + width: '13%', + editable: true, + required: false, + inputType: 'switch', render: (text, record) => record.status === 'false' ? ( <div> @@ -185,26 +212,6 @@ <Icon style={{marginLeft: '5px'}} type="check-circle" theme="twoTone" twoToneColor="#52c41a" /> </div> ) - }, - { - title: '鎿嶄綔', - align: 'center', - width: '20%', - dataIndex: 'operation', - render: (text, record) => - (<div> - <span className="operation-btn" title={this.props.dict['model.edit']} onClick={() => this.handleEdit(record, 'contrast')} style={{color: '#1890ff'}}><Icon type="edit" /></span> - <span className="operation-btn" title={this.props.dict['header.form.up']} onClick={() => this.handleUpDown(record, 'contrast', 'up')} style={{color: '#1890ff'}}><Icon type="arrow-up" /></span> - <span className="operation-btn" title={this.props.dict['header.form.down']} onClick={() => this.handleUpDown(record, 'contrast', 'down')} style={{color: '#ff4d4f'}}><Icon type="arrow-down" /></span> - <span className="operation-btn" title={this.props.dict['header.form.status.change']} onClick={() => this.handleStatus(record, 'contrast')} style={{color: '#8E44AD'}}><Icon type="swap" /></span> - <Popconfirm - overlayClassName="popover-confirm" - title={this.props.dict['model.query.delete']} - onConfirm={() => this.handleDelete(record, 'contrast') - }> - <span className="operation-btn" style={{color: '#ff4d4f'}}><Icon type="delete" /></span> - </Popconfirm> - </div>) } ], customColumns: [ @@ -779,7 +786,19 @@ columnsFields: _columns, initsql: _sql, defaultsql: _defaultsql, - usefulfields: _usefulfields.join(', ') + usefulfields: _usefulfields.join(', '), + uniqueColumns: this.state.uniqueColumns.map(col => { + if (col.dataIndex === 'field') { + col.options = _fields + } + return col + }), + onceUniqueColumns: this.state.onceUniqueColumns.map(col => { + if (col.dataIndex === 'field') { + col.options = _columns + } + return col + }) }) }) } @@ -885,18 +904,9 @@ contrastChange = (values) => { let verify = fromJS(this.state.verify).toJS() - if (values.uuid) { - verify.contrasts = verify.contrasts.map(item => { - if (item.uuid === values.uuid) { - return values - } else { - return item - } - }) - } else { - values.uuid = Utils.getuuid() - verify.contrasts.push(values) - } + values.status = 'true' + values.uuid = Utils.getuuid() + verify.contrasts.push(values) this.setState({ verify }) } @@ -980,14 +990,10 @@ if (type === 'customverify') { verify.customverifys = verify.customverifys.filter(item => item.uuid !== record.uuid) - } else if (type === 'unique') { - verify.uniques = verify.uniques.filter(item => item.uuid !== record.uuid) } else if (type === 'ordercode') { verify.billcodes = verify.billcodes.filter(item => item.uuid !== record.uuid) } else if (type === 'scripts') { verify.scripts = verify.scripts.filter(item => item.uuid !== record.uuid) - } else if (type === 'contrast') { - verify.contrasts = verify.contrasts.filter(item => item.uuid !== record.uuid) } this.setState({ verify }) @@ -996,14 +1002,10 @@ handleEdit = (record, type) => { if (type === 'customverify') { this.customForm.edit(record) - } else if (type === 'unique') { - this.uniqueForm.edit(record) } else if (type === 'ordercode') { this.orderForm.edit(record) } else if (type === 'scripts') { this.scriptsForm.edit(record) - } else if (type === 'contrast') { - this.contrastForm.edit(record) } let node = document.getElementById('verify-card-box-tab').parentNode @@ -1028,22 +1030,6 @@ if (type === 'customverify') { verify.customverifys = verify.customverifys.map(item => { - if (item.uuid === record.uuid) { - return record - } else { - return item - } - }) - } else if (type === 'unique') { - verify.uniques = verify.uniques.map(item => { - if (item.uuid === record.uuid) { - return record - } else { - return item - } - }) - } else if (type === 'contrast') { - verify.contrasts = verify.contrasts.map(item => { if (item.uuid === record.uuid) { return record } else { @@ -1091,40 +1077,6 @@ verify.customverifys.splice(index - 1, 0, record) } else { verify.customverifys.splice(index + 1, 0, record) - } - } else if (type === 'unique') { - verify.uniques = verify.uniques.filter((item, i) => { - if (item.uuid === record.uuid) { - index = i - } - - return item.uuid !== record.uuid - }) - if ((index === 0 && direction === 'up') || (index === verify.uniques.length && direction === 'down')) { - return - } - - if (direction === 'up') { - verify.uniques.splice(index - 1, 0, record) - } else { - verify.uniques.splice(index + 1, 0, record) - } - } else if (type === 'contrast') { - verify.contrasts = verify.contrasts.filter((item, i) => { - if (item.uuid === record.uuid) { - index = i - } - - return item.uuid !== record.uuid - }) - if ((index === 0 && direction === 'up') || (index === verify.contrasts.length && direction === 'down')) { - return - } - - if (direction === 'up') { - verify.contrasts.splice(index - 1, 0, record) - } else { - verify.contrasts.splice(index + 1, 0, record) } } else if (type === 'ordercode') { verify.billcodes = verify.billcodes.filter((item, i) => { @@ -1217,6 +1169,40 @@ }) } + changeUniques = (uniques) => { + const { card } = this.props + const { verify, fields, columnsFields } = this.state + + let _fields = [] + let change = {} + if (card.Ot !== 'requiredOnce') { + _fields = fields + } else { + _fields = columnsFields + } + + _fields.forEach(col => { + change[col.field] = col.label + }) + + uniques = uniques.map(item => { + item.status = item.status || 'true' + + if (Array.isArray(item.field)) { + item.fieldlabel = item.field.map(field => { + return change[field] || '' + }) + + item.fieldlabel = item.fieldlabel.join(',') + item.field = item.field.join(',') + } + + return item + }) + + this.setState({verify: {...verify, uniques}}) + } + handleConfirm = () => { const { card } = this.props let verify = fromJS(this.state.verify).toJS() @@ -1235,13 +1221,9 @@ let _loading = false if (this.customForm && this.customForm.state.editItem) { _loading = true - } else if (this.uniqueForm && this.uniqueForm.state.editItem) { - _loading = true } else if (this.orderForm && this.orderForm.state.editItem) { _loading = true } else if (this.scriptsForm && this.scriptsForm.state.editItem) { - _loading = true - } else if (this.contrastForm && this.contrastForm.state.editItem) { _loading = true } @@ -1383,19 +1365,8 @@ {verify.contrasts.length ? <span className="count-tip">{verify.contrasts.length}</span> : null} </span> } key="2x"> - <ContrastForm - dict={this.props.dict} - contrastChange={this.contrastChange} - wrappedComponentRef={(inst) => this.contrastForm = inst} - /> - <Table - bordered - rowKey="uuid" - className="custom-table" - dataSource={verify.contrasts} - columns={contrastColumns} - pagination={false} - /> + <ContrastForm dict={this.props.dict} contrastChange={this.contrastChange}/> + <EditTable data={verify.contrasts} columns={contrastColumns} onChange={(contrasts) => this.setState({verify: {...verify, contrasts}})}/> </TabPane> <TabPane tab={ <span> @@ -1457,16 +1428,8 @@ fields={card.Ot !== 'requiredOnce' ? fields : columnsFields} dict={this.props.dict} uniqueChange={this.uniqueChange} - wrappedComponentRef={(inst) => this.uniqueForm = inst} /> - <Table - bordered - rowKey="uuid" - className="custom-table" - dataSource={verify.uniques} - columns={card.Ot !== 'requiredOnce' ? uniqueColumns : onceUniqueColumns} - pagination={false} - /> + <EditTable data={verify.uniques} columns={card.Ot !== 'requiredOnce' ? uniqueColumns : onceUniqueColumns} onChange={this.changeUniques}/> </TabPane> <TabPane tab={ <span> diff --git a/src/templates/zshare/verifycard/uniqueform/index.jsx b/src/templates/zshare/verifycard/uniqueform/index.jsx index 5468de8..8566289 100644 --- a/src/templates/zshare/verifycard/uniqueform/index.jsx +++ b/src/templates/zshare/verifycard/uniqueform/index.jsx @@ -3,7 +3,6 @@ import { Form, Row, Col, Select, Button } from 'antd' import './index.scss' - class UniqueForm extends Component { static propTpyes = { btn: PropTypes.object, // 瀛楀吀椤� @@ -12,53 +11,24 @@ uniqueChange: PropTypes.func // 淇敼鍑芥暟 } - state = { - editItem: null // 缂栬緫鍏冪礌 - } - - edit = (record) => { - const { btn } = this.props - - this.setState({ - editItem: record - }) - - let _value = { - field: record.field.split(',') - } - - if (btn.Ot !== 'requiredOnce') { - _value.errorCode = record.errorCode - _value.verifyType = record.verifyType || 'physical' - } - - this.props.form.setFieldsValue(_value) - } - - handleConfirm = () => { const { fields } = this.props + let change = {} + + fields.forEach(col => { + change[col.field] = col.label + }) // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� this.props.form.validateFieldsAndScroll((err, values) => { if (!err) { - values.uuid = this.state.editItem ? this.state.editItem.uuid : '' values.fieldlabel = values.field.map(field => { - let item = fields.filter(cell => cell.field === field)[0] - let label = '' - if (item) { - label = item.label - } - return label + return change[field] || '' }) values.fieldlabel = values.fieldlabel.join(',') values.field = values.field.join(',') - this.setState({ - editItem: null - }, () => { - this.props.uniqueChange(values) - }) + this.props.uniqueChange(values) this.props.form.setFieldsValue({ field: [], }) @@ -84,7 +54,7 @@ return ( <Form {...formItemLayout} className="verify-form" id="verifycard1"> <Row gutter={24}> - <Col span={8}> + <Col span={7}> <Form.Item label={'瀛楁鍚�'}> {getFieldDecorator('field', { initialValue: [], @@ -99,13 +69,13 @@ mode="multiple" > {fields.map(item => ( - <Select.Option key={item.uuid} value={item.field}>{item.field}</Select.Option> + <Select.Option key={item.uuid} value={item.field}>{item.label}</Select.Option> ))} </Select> )} </Form.Item> </Col> - {btn.Ot !== 'requiredOnce' ? <Col span={6}> + {btn.Ot !== 'requiredOnce' ? <Col span={7}> <Form.Item label={'鎶ラ敊缂栫爜'}> {getFieldDecorator('errorCode', { initialValue: 'E', @@ -125,7 +95,7 @@ )} </Form.Item> </Col> : null} - {btn.Ot !== 'requiredOnce' ? <Col span={6}> + {btn.Ot !== 'requiredOnce' ? <Col span={7}> <Form.Item label={'楠岃瘉绫诲瀷'}> {getFieldDecorator('verifyType', { initialValue: 'physical', @@ -143,9 +113,9 @@ )} </Form.Item> </Col> : null} - <Col span={4} className="add"> + <Col span={3} className="add"> <Button onClick={this.handleConfirm} className="mk-green"> - 淇濆瓨 + {this.props.dict['model.add']} </Button> </Col> </Row> diff --git a/src/utils/utils.js b/src/utils/utils.js index 4deb649..987a514 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -1044,7 +1044,8 @@ let _sql = '' let _initvars = [] // 宸茶祴鍊煎瓧娈甸泦 - let _initfields = [] + let _initFormfields = [] + let _initColfields = [] let _declarefields = [] // 鑾峰彇瀛楁閿�煎 @@ -1069,9 +1070,9 @@ val = 0 } } - _initfields.push(`@${_key}=${val}`) + _initFormfields.push(`@${_key}=${val}`) } else { - _initfields.push(`@${_key}='${form.value}'`) + _initFormfields.push(`@${_key}='${form.value}'`) } } @@ -1114,9 +1115,9 @@ _val = 0 } } - _initfields.push(`@${_key}=${_val}`) + _initColfields.push(`@${_key}=${_val}`) } else { - _initfields.push(`@${_key}='${_val}'`) + _initColfields.push(`@${_key}='${_val}'`) } } @@ -1151,12 +1152,20 @@ Declare @tbid nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@BillCode nvarchar(50),@BVoucher nvarchar(50),@FIBVoucherDate nvarchar(50), @FiYear nvarchar(50), @UserName nvarchar(50),@FullName nvarchar(50),@ModularDetailCode nvarchar(50)${_declarefields} ` - // 鍙橀噺璧嬪�� - _initfields = _initfields.join(',') - if (_initfields) { + // 琛ㄥ崟鍙橀噺璧嬪�� + _initFormfields = _initFormfields.join(',') + if (_initFormfields) { _sql += ` - - select ${_initfields} + /* 琛ㄥ崟鍙橀噺璧嬪�� */ + select ${_initFormfields} + ` + } + // 鏄剧ず鍒楀彉閲忚祴鍊� + _initColfields = _initColfields.join(',') + if (_initColfields) { + _sql += ` + /* 鏄剧ず鍒楀彉閲忚祴鍊� */ + select ${_initColfields} ` } -- Gitblit v1.8.0