| | |
| | | this.refreshdata(item, 'excelOut') |
| | | } else if (item.OpenType === 'excelIn') { |
| | | if (item.verify && item.verify.sheet && item.verify.columns && item.verify.columns.length > 0) { |
| | | this.refs.excelIn.exceltrigger(item) |
| | | let primaryId = '' // 导入时行Id |
| | | if (item.Ot === 'requiredSgl') { |
| | | primaryId = data[0][setting.primaryKey] || '' |
| | | } |
| | | |
| | | this.refs.excelIn.exceltrigger(item, primaryId) |
| | | } else { |
| | | notification.warning({ |
| | | top: 92, |
| | |
| | | }) |
| | | } |
| | | |
| | | getexceldata = (data, btn, errors) => { |
| | | if (errors && errors.length > 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: errors.join(',') + '表头设置错误!', |
| | | duration: 10 |
| | | }) |
| | | getexceldata = (data, btn, errors, primaryId) => { |
| | | if (errors) { |
| | | if (errors === 'notexit') { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '工作表《' + btn.verify.sheet + '》不存在!', |
| | | duration: 10 |
| | | }) |
| | | } else if (errors === 'empty') { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '工作表《' + btn.verify.sheet + '》为空!', |
| | | duration: 10 |
| | | }) |
| | | } else if (errors === 'headerError') { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '工作表《' + btn.verify.sheet + '》表头设置错误!', |
| | | duration: 10 |
| | | }) |
| | | } |
| | | |
| | | return |
| | | } |
| | | |
| | | if (!data || data.length === 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '未获取到excel数据!', |
| | | message: '未获取到工作表《' + btn.verify.sheet + '》数据!', |
| | | duration: 10 |
| | | }) |
| | | return |
| | |
| | | } |
| | | |
| | | let param = { |
| | | BID: this.props.BID |
| | | BID: this.props.BID, |
| | | ID: primaryId |
| | | } |
| | | |
| | | param.LText = Utils.formatOptions(result.sql) |
| | |
| | | |
| | | state = { |
| | | excelbtn: null, |
| | | primaryId: '', // 行Id |
| | | excelId: Utils.getuuid() |
| | | } |
| | | |
| | | exceltrigger = (item) => { |
| | | exceltrigger = (item, primaryId) => { |
| | | const { excelId } = this.state |
| | | this.setState({ |
| | | excelbtn: item |
| | | excelbtn: item, |
| | | primaryId: primaryId |
| | | }) |
| | | |
| | | let _excelInput = document.getElementById(excelId + this.props.MenuID) |
| | |
| | | } |
| | | } |
| | | onImportExcel = file => { |
| | | const { excelbtn } = this.state |
| | | const { excelbtn, primaryId } = this.state |
| | | |
| | | let columns = excelbtn.verify.columns.map(option => option.Column) |
| | | let range = excelbtn.verify.range || 0 |
| | |
| | | // 以二进制流方式读取得到整份excel表格对象 |
| | | const workbook = XLSX.read(result, { type: 'binary' }) |
| | | |
| | | let errors = [] |
| | | if (range === 1) { |
| | | workbook.SheetNames.forEach(sheetname => { |
| | | if (workbook.Sheets.hasOwnProperty(sheetname)) { |
| | | let header = XLSX.utils.sheet_to_json(workbook.Sheets[sheetname], {header: columns})[0] |
| | | |
| | | if (!header) { |
| | | errors.push(sheetname) |
| | | } else { |
| | | let iserror = false |
| | | excelbtn.verify.columns.forEach(op => { |
| | | if (header[op.Column] !== op.Text) { |
| | | iserror = true |
| | | } |
| | | }) |
| | | let errors = null |
| | | |
| | | if (iserror) { |
| | | errors.push(sheetname) |
| | | } |
| | | if (!workbook.Sheets.hasOwnProperty(excelbtn.verify.sheet)) { |
| | | errors = 'notexit' |
| | | } else if (range === 1) { |
| | | let header = XLSX.utils.sheet_to_json(workbook.Sheets[excelbtn.verify.sheet], {header: columns})[0] |
| | | |
| | | if (!header) { |
| | | errors = 'empty' |
| | | } else { |
| | | let iserror = false |
| | | excelbtn.verify.columns.forEach(op => { |
| | | if (header[op.Column] !== op.Text) { |
| | | iserror = true |
| | | } |
| | | }) |
| | | |
| | | if (iserror) { |
| | | errors = 'headerError' |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | |
| | | let data = [] |
| | | |
| | | workbook.SheetNames.forEach(sheetname => { |
| | | if (workbook.Sheets.hasOwnProperty(sheetname)) { |
| | | data = data.concat(XLSX.utils.sheet_to_json(workbook.Sheets[sheetname], {header: columns, range: (range)})) |
| | | } |
| | | }) |
| | | if (!errors) { |
| | | data = XLSX.utils.sheet_to_json(workbook.Sheets[excelbtn.verify.sheet], {header: columns, range: (range)}) |
| | | } |
| | | |
| | | // 最终获取到并且格式化后的 json 数据 |
| | | this.props.returndata(data, excelbtn, errors) |
| | | this.props.returndata(data, excelbtn, errors, primaryId) |
| | | this.setState({ |
| | | excelId: '' |
| | | excelId: '', |
| | | primaryId: '' |
| | | }, () => { |
| | | this.setState({ |
| | | excelId: Utils.getuuid() |
| | |
| | | } |
| | | } else if (_opentype === 'excelIn') { // 导入导出 |
| | | if (_intertype === 'outer') { |
| | | _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'icon', 'class', 'execSuccess', 'execError'] |
| | | _options = ['label', 'Ot', 'OpenType', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'icon', 'class', 'sheet', 'execSuccess', 'execError'] |
| | | } else { |
| | | _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'execSuccess', 'execError'] |
| | | _options = ['label', 'Ot', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'sheet', 'execSuccess', 'execError'] |
| | | } |
| | | } else { |
| | | if (_intertype === 'outer') { |
| | |
| | | } else if (item.key === 'Ot') { |
| | | if (_opentype === 'innerpage' || _position === 'grid') { |
| | | item.options = this.state.reqOptionSgl |
| | | } else if (['outerpage', 'blank', 'tab', 'popview'].includes(_opentype)) { |
| | | } else if (['outerpage', 'blank', 'tab', 'popview', 'excelIn'].includes(_opentype)) { |
| | | item.options = this.state.reqOptions |
| | | } else { |
| | | item.options = this.state.reqOptionsMutil |
| | |
| | | } |
| | | } else if (value === 'excelIn') { |
| | | if (this.state.interType === 'outer') { |
| | | _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'icon', 'class', 'execSuccess', 'execError'] |
| | | _options = ['label', 'Ot', 'OpenType', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'icon', 'class', 'sheet', 'execSuccess', 'execError'] |
| | | } else { |
| | | _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'execSuccess', 'execError'] |
| | | _options = ['label', 'Ot', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'sheet', 'execSuccess', 'execError'] |
| | | } |
| | | } else { |
| | | if (this.state.interType === 'inner') { |
| | |
| | | } else if (['outerpage', 'blank', 'tab', 'popview'].includes(value)) { |
| | | item.options = this.state.reqOptions |
| | | _fieldval.Ot = 'requiredSgl' |
| | | } else if (value === 'excelIn') { |
| | | item.options = this.state.reqOptions |
| | | _fieldval.Ot = 'notRequired' |
| | | } else { |
| | | item.options = this.state.reqOptionsMutil |
| | | } |
| | |
| | | } |
| | | } else if (openType === 'excelIn') { |
| | | if (value === 'outer') { |
| | | _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'icon', 'class', 'execSuccess', 'execError'] |
| | | _options = ['label', 'Ot', 'OpenType', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'icon', 'class', 'sheet', 'execSuccess', 'execError'] |
| | | } else { |
| | | _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'execSuccess', 'execError'] |
| | | _options = ['label', 'Ot', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'sheet', 'execSuccess', 'execError'] |
| | | } |
| | | } else { |
| | | if (value === 'inner') { |
| | |
| | | |
| | | if (values.OpenType === 'excelIn') { |
| | | values.position = 'toolbar' |
| | | values.Ot = 'notRequired' |
| | | } else if (values.OpenType === 'excelOut') { |
| | | values.position = 'toolbar' |
| | | values.Ot = 'notRequired' |
| | |
| | | verifySubmit = () => { |
| | | const { card } = this.state |
| | | let config = JSON.parse(JSON.stringify(this.state.config)) |
| | | let _verify = this.verifyRef.state.verify |
| | | |
| | | |
| | | if (card.OpenType !== 'excelIn') { |
| | | let _verify = this.verifyRef.state.verify |
| | | |
| | | if (_verify.default === 'false' && _verify.scripts.length === 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | |
| | | }) |
| | | return |
| | | } |
| | | } else if (card.OpenType === 'excelIn') { |
| | | let cols = _verify.columns.map(col => col.Column) |
| | | cols = Array.from(new Set(cols)) |
| | | |
| | | if (!_verify.sheet) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请设置导入表名!', |
| | | duration: 10 |
| | | }) |
| | | return |
| | | } else if (_verify.columns.length === 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请设置Excel列字段!', |
| | | duration: 10 |
| | | }) |
| | | return |
| | | } else if (_verify.columns.length > cols.length) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: 'Excel列字段名,不可重复!', |
| | | duration: 10 |
| | | }) |
| | | return |
| | | } else if (_verify.range === 1) { |
| | | let tEmptys = _verify.columns.filter(op => !op.Text) |
| | | if (tEmptys.length > 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '忽略首行时,会使用Text值校验Excel首行内容,Text值与Excel表首行内容相同,且均不可为空!', |
| | | duration: 10 |
| | | }) |
| | | return |
| | | config.action = config.action.map(item => { |
| | | if (item.uuid === card.uuid) { |
| | | item.verify = _verify |
| | | } |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | |
| | | this.setState({ |
| | | profileVisible: false, |
| | | config: config, |
| | | card: '', |
| | | }) |
| | | } else if (card.OpenType === 'excelIn') { |
| | | this.verifyRef.handleConfirm().then(res => { |
| | | |
| | | config.action = config.action.map(item => { |
| | | if (item.uuid === card.uuid) { |
| | | item.verify = res |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | |
| | | this.setState({ |
| | | profileVisible: false, |
| | | config: config, |
| | | card: '', |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | config.action = config.action.map(item => { |
| | | if (item.uuid === card.uuid) { |
| | | item.verify = _verify |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | |
| | | this.setState({ |
| | | profileVisible: false, |
| | | config: config, |
| | | card: '', |
| | | }) |
| | | } |
| | | |
| | | /** |
| | |
| | | value: 'requiredSgl', |
| | | text: this.props.dict['header.form.requiredSgl'] |
| | | }], |
| | | reqOptions: [{ |
| | | value: 'notRequired', |
| | | text: this.props.dict['header.form.notRequired'] |
| | | }, { |
| | | value: 'requiredSgl', |
| | | text: this.props.dict['header.form.requiredSgl'] |
| | | }], |
| | | reqOptionsMutil: [{ |
| | | value: 'notRequired', |
| | | text: this.props.dict['header.form.notRequired'] |
| | |
| | | } |
| | | } else if (_opentype === 'excelIn') { |
| | | if (_intertype === 'outer') { |
| | | _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'icon', 'class', 'execSuccess', 'execError'] |
| | | _options = ['label', 'Ot', 'OpenType', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'icon', 'class', 'sheet', 'execSuccess', 'execError'] |
| | | } else { |
| | | _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'execSuccess', 'execError'] |
| | | _options = ['label', 'Ot', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'sheet', 'execSuccess', 'execError'] |
| | | } |
| | | } else { |
| | | if (_intertype === 'outer') { |
| | |
| | | } else if (item.key === 'icon') { |
| | | item.options = btnIcons |
| | | } else if (item.key === 'Ot') { |
| | | item.options = this.state.reqOptionsMutil |
| | | if (_opentype === 'excelIn') { |
| | | item.options = this.state.reqOptions |
| | | } else { |
| | | item.options = this.state.reqOptionsMutil |
| | | } |
| | | } else if (item.key === 'sqlType') { |
| | | if (['prompt', 'exec'].includes(_opentype)) { |
| | | item.options = this.state.deleteOptions |
| | |
| | | } |
| | | } else if (value === 'excelIn') { |
| | | if (this.state.interType === 'outer') { |
| | | _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'icon', 'class', 'execSuccess', 'execError'] |
| | | _options = ['label', 'Ot', 'OpenType', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'icon', 'class', 'sheet', 'execSuccess', 'execError'] |
| | | } else { |
| | | _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'execSuccess', 'execError'] |
| | | _options = ['label', 'Ot', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'sheet', 'execSuccess', 'execError'] |
| | | } |
| | | } else { |
| | | if (this.state.interType === 'inner') { |
| | |
| | | if (this.state.position === 'grid') { |
| | | item.options = this.state.reqOptionSgl |
| | | item.initVal = 'requiredSgl' |
| | | } else if (value === 'excelIn') { |
| | | item.options = this.state.reqOptions |
| | | item.initVal = 'notRequired' |
| | | } else { |
| | | item.options = this.state.reqOptionsMutil |
| | | } |
| | |
| | | return item |
| | | }) |
| | | }, () => { |
| | | if (['excelIn', 'excelOut'].includes(value)) return |
| | | if (['excelOut'].includes(value)) return |
| | | |
| | | this.setState({ |
| | | formlist: this.state.formlist.map(item => { |
| | |
| | | } |
| | | } else if (openType === 'excelIn') { |
| | | if (value === 'outer') { |
| | | _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'icon', 'class', 'execSuccess', 'execError'] |
| | | _options = ['label', 'Ot', 'OpenType', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'icon', 'class', 'sheet', 'execSuccess', 'execError'] |
| | | } else { |
| | | _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'execSuccess', 'execError'] |
| | | _options = ['label', 'Ot', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'sheet', 'execSuccess', 'execError'] |
| | | } |
| | | } else { |
| | | if (value === 'inner') { |
| | |
| | | values.uuid = this.props.card.uuid |
| | | values.verify = this.props.card.verify || null |
| | | |
| | | if (values.OpenType === 'excelIn' || values.OpenType === 'excelOut') { |
| | | if (values.OpenType === 'excelIn') { |
| | | values.position = 'toolbar' |
| | | } else if (values.OpenType === 'excelOut') { |
| | | values.position = 'toolbar' |
| | | values.Ot = 'notRequired' |
| | | } else if (values.OpenType === 'popview' && !values.linkTab) { // 没有关联标签(新建时),创建新标签Id |
| | |
| | | verifySubmit = () => { |
| | | const { card } = this.state |
| | | let config = JSON.parse(JSON.stringify(this.state.config)) |
| | | let _verify = this.verifyRef.state.verify |
| | | |
| | | |
| | | if (card.OpenType !== 'excelIn') { |
| | | let _verify = this.verifyRef.state.verify |
| | | |
| | | if (_verify.default === 'false' && _verify.scripts.length === 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | |
| | | }) |
| | | return |
| | | } |
| | | } else if (card.OpenType === 'excelIn') { |
| | | let cols = _verify.columns.map(col => col.Column) |
| | | cols = Array.from(new Set(cols)) |
| | | |
| | | if (!_verify.sheet) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请设置导入表名!', |
| | | duration: 10 |
| | | }) |
| | | return |
| | | } else if (_verify.columns.length === 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请设置Excel列字段!', |
| | | duration: 10 |
| | | }) |
| | | return |
| | | } else if (_verify.columns.length > cols.length) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: 'Excel列字段名,不可重复!', |
| | | duration: 10 |
| | | }) |
| | | return |
| | | } else if (_verify.range === 1) { |
| | | let tEmptys = _verify.columns.filter(op => !op.Text) |
| | | if (tEmptys.length > 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '忽略首行时,会使用Text值校验Excel首行内容,Text值与Excel表首行内容相同,且均不可为空!', |
| | | duration: 10 |
| | | }) |
| | | return |
| | | config.action = config.action.map(item => { |
| | | if (item.uuid === card.uuid) { |
| | | item.verify = _verify |
| | | } |
| | | } |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | |
| | | this.setState({ |
| | | profileVisible: false, |
| | | config: config, |
| | | card: '' |
| | | }) |
| | | } else if (card.OpenType === 'excelIn') { |
| | | this.verifyRef.handleConfirm().then(res => { |
| | | |
| | | config.action = config.action.map(item => { |
| | | if (item.uuid === card.uuid) { |
| | | item.verify = res |
| | | } |
| | | |
| | | config.action = config.action.map(item => { |
| | | if (item.uuid === card.uuid) { |
| | | item.verify = _verify |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | |
| | | this.setState({ |
| | | profileVisible: false, |
| | | config: config, |
| | | card: '' |
| | | }) |
| | | return item |
| | | }) |
| | | |
| | | this.setState({ |
| | | profileVisible: false, |
| | | config: config, |
| | | card: '' |
| | | }) |
| | | }) |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | } |
| | | |
| | | let hasProfile = false |
| | | if (type === 'action') { |
| | | if (['pop', 'prompt', 'exec'].includes(card.OpenType) && card.intertype === 'inner' && !card.innerFunc) { |
| | | hasProfile = true |
| | | } else if (card.OpenType === 'excelIn') { |
| | | hasProfile = true |
| | | } |
| | | } |
| | | |
| | | return ( |
| | | <div className="page-card" style={type === 'columns' ? { flex: card.Width, opacity: opacity} : { opacity: opacity}}> |
| | | <div ref={node => drag(drop(node))}> |
| | |
| | | {showfield ? |
| | | <div className="ant-table-column-fields"> |
| | | <span className="ant-table-column-title">{card.type === 'colspan' ? card.subfield : card.field}</span> |
| | | {/* <span className="ant-table-column-title"> |
| | | {card.type === 'colspan' ? |
| | | <Paragraph copyable>{card.subfield}</Paragraph> : |
| | | <Paragraph copyable>{card.field}</Paragraph> |
| | | } |
| | | </span> */} |
| | | </div> : null |
| | | } |
| | | </span> : null |
| | |
| | | <Icon className="edit" title="编辑" type="edit" onClick={edit} /> |
| | | <Icon className="edit close" title="删除" type="close" onClick={del} /> |
| | | {type === 'action' ? <Icon className="edit copy" title="复制" type="copy" onClick={copy} /> : null} |
| | | {type === 'action' && ['pop', 'prompt', 'exec', 'excelIn'].includes(card.OpenType) && card.intertype === 'inner' && !card.innerFunc ? |
| | | <Icon className="edit profile" title="校验规则" type="profile" onClick={profile} /> : null |
| | | } |
| | | {hasProfile ? <Icon className="edit profile" title="校验规则" type="profile" onClick={profile} /> : null} |
| | | </div> |
| | | ) |
| | | } |
| | |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'sheet', |
| | | label: Formdict['header.form.tablename'], |
| | | initVal: card.sheet || config.setting.tableName || '', |
| | | required: true |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'sql', |
| | | label: Formdict['header.form.tablename'], |
| | | initVal: card.sql || config.setting.tableName || '', |
| | |
| | | </Col> |
| | | <Col span={8}> |
| | | <Form.Item label={'停留时间'}> |
| | | <InputNumber defaultValue={2} min={1} max={10000} precision={0} onChange={(val) => {this.timeChange(val, 'stime')}} /> |
| | | <InputNumber defaultValue={verify.stime || 2} min={1} max={10000} precision={0} onChange={(val) => {this.timeChange(val, 'stime')}} /> |
| | | </Form.Item> |
| | | </Col> |
| | | </Row> |
| | |
| | | </Col> |
| | | <Col span={8}> |
| | | <Form.Item label={'停留时间'}> |
| | | <InputNumber defaultValue={15} min={1} max={10000} precision={0} onChange={(val) => {this.timeChange(val, 'ntime')}} /> |
| | | <InputNumber defaultValue={verify.ntime || 15} min={1} max={10000} precision={0} onChange={(val) => {this.timeChange(val, 'ntime')}} /> |
| | | </Form.Item> |
| | | </Col> |
| | | </Row> |
| | |
| | | </Col> |
| | | <Col span={8}> |
| | | <Form.Item label={'停留时间'}> |
| | | <InputNumber defaultValue={15} min={1} max={10000} precision={0} onChange={(val) => {this.timeChange(val, 'ftime')}} /> |
| | | <InputNumber defaultValue={verify.ftime || 15} min={1} max={10000} precision={0} onChange={(val) => {this.timeChange(val, 'ftime')}} /> |
| | | </Form.Item> |
| | | </Col> |
| | | </Row> |
| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { Form, Tabs, Row, Col, Input, Button, Table, Popconfirm, Icon, notification, Modal, message, InputNumber } from 'antd' |
| | | import { formRule } from '@/utils/option.js' |
| | | |
| | | import Utils from '@/utils/utils.js' |
| | | |
| | |
| | | this.setState({ |
| | | verify: { |
| | | ..._verify, |
| | | sheet: _verify.sheet || '', |
| | | sheet: _verify.sheet || 'Sheet1', |
| | | range: _verify.range || 0, |
| | | columns: _verify.columns || [], |
| | | scripts: _verify.scripts || [] |
| | |
| | | }) |
| | | } |
| | | |
| | | sheetChange = (e) => { |
| | | handleConfirm = () => { |
| | | const { verify } = this.state |
| | | // 表单提交时检查输入值是否正确 |
| | | return new Promise((resolve, reject) => { |
| | | this.props.form.validateFieldsAndScroll((err, values) => { |
| | | if (!err) { |
| | | let _verify = {...verify, ...values} |
| | | |
| | | this.setState({}, () => { |
| | | this.props.form.validateFields(['sheet'], (errors, values) => { |
| | | if (!errors) { |
| | | this.setState({ |
| | | verify: { |
| | | ...verify, |
| | | ...values |
| | | let cols = _verify.columns.map(col => col.Column) |
| | | cols = Array.from(new Set(cols)) |
| | | |
| | | if (_verify.columns.length === 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请设置Excel列字段!', |
| | | duration: 10 |
| | | }) |
| | | return |
| | | } else if (_verify.columns.length > cols.length) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: 'Excel列字段名,不可重复!', |
| | | duration: 10 |
| | | }) |
| | | return |
| | | } else if (_verify.range === 1) { |
| | | let tEmptys = _verify.columns.filter(op => !op.Text) |
| | | if (tEmptys.length > 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '忽略首行时,会使用Text值校验Excel首行内容,Text值与Excel表首行内容相同,且均不可为空!', |
| | | duration: 10 |
| | | }) |
| | | return |
| | | } |
| | | }) |
| | | } |
| | | console.log(_verify) |
| | | |
| | | resolve(_verify) |
| | | } else { |
| | | this.setState({ |
| | | verify: { |
| | | ...verify, |
| | | sheet: '' |
| | | } |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请设置Excel表名!', |
| | | duration: 10 |
| | | }) |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | rangeChange = (value) => { |
| | | const { verify } = this.state |
| | | |
| | | this.setState({ |
| | | verify: { |
| | | ...verify, |
| | | range: value || 0 |
| | | } |
| | | }) |
| | | } |
| | | |
| | |
| | | <Form {...formItemLayout}> |
| | | <Row gutter={24}> |
| | | <Col span={8}> |
| | | <Form.Item label={this.props.dict['header.form.tablename']}> |
| | | <Form.Item label={'Excel表名'}> |
| | | {getFieldDecorator('sheet', { |
| | | initialValue: verify.sheet || '', |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: this.props.dict['form.required.input'] + this.props.dict['header.form.tablename'] + '!' |
| | | }, |
| | | { |
| | | pattern: formRule.table.pattern, |
| | | message: formRule.table.message |
| | | }, { |
| | | max: formRule.table.max, |
| | | message: formRule.table.maxMessage |
| | | } |
| | | ] |
| | | })(<Input placeholder="" autoComplete="off" onChange={this.sheetChange} />)} |
| | | })(<Input placeholder="" autoComplete="off" />)} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={8}> |
| | | <Form.Item label={'忽略行'}> |
| | | <InputNumber min={0} max={100} precision={0} defaultValue={0} onChange={this.rangeChange} /> |
| | | {getFieldDecorator('range', { |
| | | initialValue: verify.range || 0 |
| | | })(<InputNumber min={0} max={100} precision={0} />)} |
| | | </Form.Item> |
| | | </Col> |
| | | </Row> |
| | |
| | | </Col> |
| | | <Col span={8}> |
| | | <Form.Item label={'停留时间'}> |
| | | <InputNumber defaultValue={2} min={1} max={10000} precision={0} onChange={(val) => {this.timeChange(val, 'stime')}} /> |
| | | <InputNumber defaultValue={verify.stime || 2} min={1} max={10000} precision={0} onChange={(val) => {this.timeChange(val, 'stime')}} /> |
| | | </Form.Item> |
| | | </Col> |
| | | </Row> |
| | |
| | | </Col> |
| | | <Col span={8}> |
| | | <Form.Item label={'停留时间'}> |
| | | <InputNumber defaultValue={15} min={1} max={10000} precision={0} onChange={(val) => {this.timeChange(val, 'ntime')}} /> |
| | | <InputNumber defaultValue={verify.ntime || 15} min={1} max={10000} precision={0} onChange={(val) => {this.timeChange(val, 'ntime')}} /> |
| | | </Form.Item> |
| | | </Col> |
| | | </Row> |
| | |
| | | </Col> |
| | | <Col span={8}> |
| | | <Form.Item label={'停留时间'}> |
| | | <InputNumber defaultValue={15} min={1} max={10000} precision={0} onChange={(val) => {this.timeChange(val, 'ftime')}} /> |
| | | <InputNumber defaultValue={verify.ftime || 15} min={1} max={10000} precision={0} onChange={(val) => {this.timeChange(val, 'ftime')}} /> |
| | | </Form.Item> |
| | | </Col> |
| | | </Row> |
| | |
| | | |
| | | let errors = [] |
| | | let _topline = btn.range || 0 |
| | | let upId = this.getuuid() |
| | | let _Ltext = data.map((item, lindex) => { |
| | | let vals = btn.columns.map((col, cindex) => { |
| | | let val = item[col.Column] !== undefined ? item[col.Column] : '' |
| | |
| | | let _lineIndex = '0000' + (lindex + 1) + '0' |
| | | _lineIndex = _lineIndex.substring(_lineIndex.length - 6) |
| | | |
| | | vals.push(`@upid+'${_lineIndex}' as jskey`) |
| | | vals.push(`'${upId + _lineIndex}' as jskey`) |
| | | |
| | | return `Select ${vals.join(',')}` |
| | | }) |
| | |
| | | |
| | | fields = fields.join(',') |
| | | |
| | | _sql = `declare @${btn.sheet} table (${declarefields.join(',')},jskey nvarchar(50) ) |
| | | Declare @UserName nvarchar(50),@FullName nvarchar(50) ,@upid nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000) |
| | | _sql = `declare @${item.sheet} table (${declarefields.join(',')},jskey nvarchar(50) ) |
| | | Declare @UserName nvarchar(50),@FullName nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000) |
| | | |
| | | Select @ErrorCode='', @retmsg='' |
| | | |
| | | select @UserName=UserName,@FullName=FullName from SUsers where UID=@UserID@ |
| | | |
| | | set @upid='${this.getuuid()}' |
| | | |
| | | Insert into @${btn.sheet} (${fields},jskey) |
| | | Insert into @${item.sheet} (${fields},jskey) |
| | | ${_Ltext} |
| | | |
| | | Insert into ${btn.sheet} (${fields},createuserid,createuser,createstaff,bid,upid) |
| | | Select ${fields},@userid@,@username,@fullname,@BID@,@upid From @${btn.sheet} |
| | | Insert into ${item.sheet} (${fields},createuserid,createuser,createstaff,bid) |
| | | Select ${fields},@userid@,@username,@fullname,@BID@ From @${item.sheet} |
| | | |
| | | Delete @${btn.sheet} |
| | | Delete @${item.sheet} |
| | | |
| | | aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg` |
| | | |
| | |
| | | |
| | | fields = fields.join(',') |
| | | |
| | | let _sql = `declare @${_verify.sheet} table (${declarefields.join(',')},jskey nvarchar(50) ) |
| | | Declare @UserName nvarchar(50),@FullName nvarchar(50),@upid nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000) |
| | | let _sql = `declare @${btn.sheet} table (${declarefields.join(',')},jskey nvarchar(50) ) |
| | | Declare @UserName nvarchar(50),@FullName nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000) |
| | | |
| | | Select @ErrorCode='',@retmsg='' |
| | | |
| | | select @UserName=UserName,@FullName=FullName from SUsers where UID=@UserID@ |
| | | |
| | | set @upid='时间戳' |
| | | |
| | | Insert into @${_verify.sheet} (${fields},jskey) |
| | | Insert into @${btn.sheet} (${fields},jskey) |
| | | |
| | | exec s_KeyWords_Replace |
| | | @LText=@LText, @BID=@BID,@LoginUID=@LoginUID,@SessionUid=@SessionUid,@UserID=@UserID,@ID=@ID |
| | | |
| | | Insert into ${_verify.sheet} (${fields},createuserid,createuser,createstaff,bid,upid) |
| | | Select ${fields},@userid@,@username,@fullname,@BID@,@upid From @${_verify.sheet} |
| | | Insert into ${btn.sheet} (${fields},createuserid,createuser,createstaff,bid) |
| | | Select ${fields},@userid@,@username,@fullname,@BID@ From @${btn.sheet} |
| | | |
| | | Delete @${_verify.sheet} |
| | | Delete @${btn.sheet} |
| | | |
| | | aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg` |
| | | |