| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | // import { is, fromJS } from 'immutable' |
| | | import moment from 'moment' |
| | | import { Button, Affix, Modal, notification } from 'antd' |
| | | import MutilForm from '../mutilform' |
| | | import Utils from '@/utils/utils.js' |
| | | import Api from '@/api' |
| | | import './index.scss' |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | execSubmit = (btn, data, _resolve) => { |
| | | execSubmit = (btn, data, _resolve, formdata) => { |
| | | const { setting } = this.props |
| | | if (btn.intertype === 'inner') { |
| | | // 使用内部接口时,内部函数和数据源不可同时为空 |
| | | if (!btn.innerFunc && !btn.sql) { |
| | | // 使用内部接口时,内部函数和数据源不可同时为空, 使用系统函数时,类型不可为空 |
| | | if (!btn.innerFunc && (!btn.sql || (btn.sql && !btn.sqlType))) { |
| | | this.actionSettingError() |
| | | _resolve() |
| | | return |
| | | } |
| | | |
| | | if (btn.Ot === 'notRequired' || btn.Ot === 'requiredSgl' || btn.Ot === 'requiredOnce') { |
| | | // 获取id |
| | | let param = { |
| | | if ( |
| | | btn.Ot === 'notRequired' || |
| | | btn.Ot === 'requiredSgl' || |
| | | (btn.Ot === 'requiredOnce' && btn.OpenType !== 'pop') || |
| | | (btn.OpenType === 'pop' && !btn.innerFunc && btn.sql && btn.sqlType === 'insert') |
| | | ) { |
| | | let param = { // 系统存储过程 |
| | | func: 'sPC_TableData_InUpDe' |
| | | } |
| | | let ID = '' |
| | | if (btn.Ot === 'notRequired') { |
| | | |
| | | } else if (btn.Ot === 'requiredSgl') { |
| | | ID = data[0][setting.primaryKey] |
| | | } else if (btn.Ot === 'requiredOnce') { |
| | | let ids = data.map(d => { return d[setting.primaryKey]}) |
| | | ID = ids.join(',') |
| | | } |
| | | |
| | | if (btn.innerFunc) { |
| | | param.func = btn.innerFunc |
| | | if (btn.OpenType === 'prompt' || btn.OpenType === 'exec') { // 是否弹框或直接执行 |
| | | let ID = '' |
| | | if (btn.Ot === 'notRequired') { |
| | | |
| | | } else if (btn.Ot === 'requiredSgl') { |
| | | ID = data[0][setting.primaryKey] |
| | | } else if (btn.Ot === 'requiredOnce') { |
| | | let ids = data.map(d => { return d[setting.primaryKey]}) |
| | | ID = ids.join(',') |
| | | } |
| | | |
| | | param.ID = ID |
| | | param.BID = '' |
| | | } else if (btn.sql) { |
| | | param.LText = btn.sql // 数据源 |
| | | |
| | | if (btn.innerFunc) { |
| | | param.func = btn.innerFunc |
| | | } else if (btn.sql) { |
| | | param.LText = Utils.formatOptions(Utils.getSysDefaultSql(btn, setting)) // 数据源 |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | param.secretkey = Utils.encrypt(param.LText, param.timestamp) |
| | | } |
| | | } else if (btn.OpenType === 'pop') { // 表单 |
| | | if (btn.innerFunc) { |
| | | param.func = btn.innerFunc |
| | | |
| | | formdata.forEach(_data => { |
| | | param[_data.key] = _data.value |
| | | }) |
| | | if (setting.primaryKey) { |
| | | if (!param.hasOwnProperty(setting.primaryKey) && data[0] && data[0][setting.primaryKey]) { |
| | | param[setting.primaryKey] = data[0][setting.primaryKey] |
| | | } |
| | | } |
| | | if (!param.hasOwnProperty('ID') && setting.primaryKey && data[0] && data[0][setting.primaryKey]) { |
| | | param.ID = data[0][setting.primaryKey] |
| | | } |
| | | if (!param.hasOwnProperty('BID')) { |
| | | param.BID = '' |
| | | } |
| | | } else if (btn.sql && btn.sqlType === 'insert') { |
| | | param.ID = Utils.getguid() |
| | | param.BID = '' |
| | | param.LText = Utils.formatOptions(Utils.getSysDefaultSql(btn, setting, formdata)) // 数据源 |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | param.secretkey = Utils.encrypt(param.LText, param.timestamp) |
| | | } else if (btn.sql) { |
| | | param.ID = data[0][setting.primaryKey] |
| | | param.BID = '' |
| | | param.LText = Utils.formatOptions(Utils.getSysDefaultSql(btn, setting, formdata)) // 数据源 |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | param.secretkey = Utils.encrypt(param.LText, param.timestamp) |
| | | } |
| | | } |
| | | |
| | | |
| | | Api.genericInterface(param).then((res) => { |
| | | if (res.status) { |
| | |
| | | } |
| | | _resolve() |
| | | }) |
| | | } else if (btn.Ot === 'required') { |
| | | } else if (btn.Ot === 'required' || (btn.Ot === 'requiredOnce' && btn.OpenType === 'pop')) { |
| | | let deffers = data.map(cell => { |
| | | let param = { |
| | | func: 'sPC_TableData_InUpDe' |
| | | } |
| | | let ID = cell[setting.primaryKey] |
| | | |
| | | if (btn.innerFunc) { |
| | | param.func = btn.innerFunc |
| | | param.ID = ID |
| | | if (btn.OpenType === 'prompt' || btn.OpenType === 'exec') { // 是否弹框或直接执行 |
| | | param.ID = cell[setting.primaryKey] |
| | | param.BID = '' |
| | | } else if (btn.sql) { |
| | | param.LText = btn.sql // 数据源 |
| | | |
| | | if (btn.innerFunc) { |
| | | param.func = btn.innerFunc |
| | | } else if (btn.sql) { |
| | | param.LText = Utils.formatOptions(Utils.getSysDefaultSql(btn, setting)) // 数据源 |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | param.secretkey = Utils.encrypt(param.LText, param.timestamp) |
| | | } |
| | | } else if (btn.OpenType === 'pop') { // 表单 |
| | | if (btn.innerFunc) { |
| | | param.func = btn.innerFunc |
| | | |
| | | formdata.forEach(_data => { |
| | | param[_data.key] = _data.value |
| | | }) |
| | | if (!param.hasOwnProperty(setting.primaryKey) && cell[setting.primaryKey]) { |
| | | param[setting.primaryKey] = cell[setting.primaryKey] |
| | | } |
| | | if (!param.hasOwnProperty('ID') && cell[setting.primaryKey]) { |
| | | param.ID = cell[setting.primaryKey] |
| | | } |
| | | } else if (btn.sql) { |
| | | param.ID = cell[setting.primaryKey] |
| | | param.BID = '' |
| | | param.LText = Utils.formatOptions(Utils.getSysDefaultSql(btn, setting, formdata)) // 数据源 |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | param.secretkey = Utils.encrypt(param.LText, param.timestamp) |
| | | } |
| | | } |
| | | |
| | | return new Promise(resolve => { |
| | |
| | | message: this.props.dict['main.action.confirm.success'], |
| | | duration: 5 |
| | | }) |
| | | if (btn.OpenType === 'pop') { |
| | | this.setState({ |
| | | visible: false |
| | | }) |
| | | } |
| | | this.refreshdata(btn, 'success') |
| | | } |
| | | |
| | |
| | | this.setState({ |
| | | confirmLoading: true |
| | | }) |
| | | this.execSubmit(this.state.execAction, this.state.tabledata, () => { |
| | | this.setState({ |
| | | confirmLoading: false |
| | | }) |
| | | }, res) |
| | | console.log(res) |
| | | // Api.setActionSubmit({ |
| | | // func: 'SetActionSubmitSuccess' |
| | | // }).then((res) => { |
| | | // if (res.status) { |
| | | // notification.success({ |
| | | // top: 92, |
| | | // message: this.props.dict['main.action.confirm.success'] |
| | | // }) |
| | | // this.setState({ |
| | | // confirmLoading: false, |
| | | // visible: false |
| | | // }) |
| | | // } else { |
| | | // notification.error({ |
| | | // top: 92, |
| | | // message: res.message |
| | | // }) |
| | | // } |
| | | // }) |
| | | }, () => {}) |
| | | } |
| | | |
| | |
| | | <MutilForm |
| | | dict={this.props.dict} |
| | | action={execAction} |
| | | data={this.state.tabledata} |
| | | configMap={this.props.configMap} |
| | | data={this.state.tabledata[0]} |
| | | wrappedComponentRef={(inst) => this.formRef = inst} |
| | | /> |
| | | </Modal> |