| | |
| | | import moment from 'moment' |
| | | import { Button, Affix, Modal, notification, Spin, message } from 'antd' |
| | | import MutilForm from '@/tabviews/tableshare/mutilform' |
| | | import ExcelIn from '../excelin' |
| | | import Utils from '@/utils/utils.js' |
| | | import Api from '@/api' |
| | | import './index.scss' |
| | |
| | | |
| | | class MainAction extends Component { |
| | | static propTpyes = { |
| | | BID: PropTypes.string, // 主表ID |
| | | BData: PropTypes.any, // 主表数据 |
| | | Tab: PropTypes.any, // 如果当前元素为标签时,tab为标签信息 |
| | | type: PropTypes.string, // 判断当前为主表(main)、子表(sub)、子表标签(subtab) |
| | | MenuID: PropTypes.string, // 菜单ID |
| | | actions: PropTypes.array, // 按钮组 |
| | | logcolumns: PropTypes.array, // 日志中显示列 |
| | | dict: PropTypes.object, // 字典项 |
| | | setting: PropTypes.any, // 页面通用设置 |
| | | ContainerId: PropTypes.any, // tab页面ID,用于弹窗控制 |
| | | triggerPopview: PropTypes.func // 弹窗标签页触发 |
| | | BID: PropTypes.string, // 主表ID |
| | | BData: PropTypes.any, // 主表数据 |
| | | Tab: PropTypes.any, // 如果当前元素为标签时,tab为标签信息 |
| | | type: PropTypes.string, // 判断当前为主表(main)、子表(sub)、子表标签(subtab) |
| | | MenuID: PropTypes.string, // 菜单ID |
| | | actions: PropTypes.array, // 按钮组 |
| | | logcolumns: PropTypes.array, // 日志中显示列 |
| | | dict: PropTypes.object, // 字典项 |
| | | setting: PropTypes.any, // 页面通用设置 |
| | | ContainerId: PropTypes.any, // tab页面ID,用于弹窗控制 |
| | | refreshdata: PropTypes.func, // 执行完成后数据刷新 |
| | | triggerPopview: PropTypes.func, // 弹窗标签页触发 |
| | | gettableselected: PropTypes.func // 获取表格中数据 |
| | | } |
| | | |
| | | state = { |
| | |
| | | } else if (item.OpenType === 'excelOut') { |
| | | this.setState({loadingUuid: item.uuid}) |
| | | 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) |
| | | } else { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: 'excel导入验证信息未设置!', |
| | | duration: 10 |
| | | }) |
| | | } |
| | | } else if (item.OpenType === 'popview' && this.props.type !== 'subtab') { |
| | | this.props.triggerPopview(item, data) |
| | | } else if (item.OpenType === 'popview' && this.props.type === 'subtab') { |
| | |
| | | * 5、通知主列表刷新 |
| | | */ |
| | | execSuccess = (btn, res) => { |
| | | if (btn.OpenType === 'excelOut') { // 导出excel |
| | | if (btn.OpenType === 'excelOut' || btn.OpenType === 'excelIn') { // 导出excel |
| | | this.setState({ |
| | | loadingUuid: '' |
| | | }) |
| | |
| | | message.error(res.message || res.ErrMesg) |
| | | } |
| | | |
| | | if (btn.OpenType === 'excelOut') { |
| | | if (btn.OpenType === 'excelOut' || btn.OpenType === 'excelIn') { |
| | | this.setState({ |
| | | loadingUuid: '' |
| | | }) |
| | |
| | | }) |
| | | } |
| | | |
| | | getexceldata = (data, btn, errors) => { |
| | | if (errors && errors.length > 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: errors.join(',') + '表头设置错误!', |
| | | duration: 10 |
| | | }) |
| | | return |
| | | } |
| | | if (!data || data.length === 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '未获取到excel数据!', |
| | | duration: 10 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | let result = Utils.getExcelInSql(btn, data, this.props.dict) |
| | | if (result.errors) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: result.errors, |
| | | duration: 10 |
| | | }) |
| | | return |
| | | } |
| | | if (!btn.innerFunc) { |
| | | let param = { // 系统存储过程 |
| | | func: 'sPC_TableData_InUpDe', |
| | | BID: this.props.BID |
| | | } |
| | | |
| | | param.LText = Utils.formatOptions(result.sql) |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | param.secretkey = Utils.encrypt(param.LText, param.timestamp) |
| | | |
| | | this.setState({loadingUuid: btn.uuid}) |
| | | |
| | | Api.genericInterface(param).then((res) => { |
| | | if (res.status) { |
| | | this.execSuccess(btn, res) |
| | | } else { |
| | | this.execError(res, btn) |
| | | } |
| | | }) |
| | | } else { |
| | | let param = { // 自定义存储过程 |
| | | func: btn.innerFunc, |
| | | BID: this.props.BID |
| | | } |
| | | |
| | | param.LText = Utils.formatOptions(result.sql) |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | param.secretkey = Utils.encrypt(param.LText, param.timestamp) |
| | | |
| | | this.setState({loadingUuid: btn.uuid}) |
| | | |
| | | Api.genericInterface(param).then((res) => { |
| | | if (res.status) { |
| | | this.execSuccess(btn, res) |
| | | } else { |
| | | this.execError(res, btn) |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @description 模态框(表单),确认 |
| | | */ |
| | |
| | | })} |
| | | {this.getModels()} |
| | | {btnloading && <Spin size="large" />} |
| | | <ExcelIn MenuID={this.props.MenuID} returndata={this.getexceldata} ref="excelIn" /> |
| | | </div> |
| | | </Affix> |
| | | ) |
| | |
| | | })} |
| | | {this.getModels()} |
| | | {btnloading && <Spin size="large" />} |
| | | <ExcelIn MenuID={this.props.MenuID} returndata={this.getexceldata} ref="excelIn" /> |
| | | </div> |
| | | ) |
| | | } |