| | |
| | | import FormAction from './actionList' |
| | | import SubTable from '@/tabviews/subtable' |
| | | import NotFount from '@/components/404' |
| | | import {refreshTabView} from '@/store/action' |
| | | import {refreshTabView, modifyTabview} from '@/store/action' |
| | | import './index.scss' |
| | | |
| | | const { TabPane } = Tabs |
| | |
| | | static propTpyes = { |
| | | // MenuNo: PropTypes.string, // 菜单参数 |
| | | // MenuName: PropTypes.string, // 菜单参数 |
| | | MenuID: PropTypes.string, // 菜单Id |
| | | param: PropTypes.any // 主表传递参数 |
| | | MenuID: PropTypes.string, // 菜单Id |
| | | param: PropTypes.any, // 主表传递参数 |
| | | refresh: PropTypes.any // 刷新主表页面 |
| | | } |
| | | |
| | | state = { |
| | |
| | | pickup: false, // 主表数据隐藏显示切换 |
| | | isLinkMain: false, // 是否存在与主表关联的子表 |
| | | popData: false, // 弹框页面,所选的表格数据 |
| | | visible: false // 弹框显示隐藏控制 |
| | | visible: false, // 弹框显示隐藏控制 |
| | | primaryId: null |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | let _arrField = [] // 字段集 |
| | | |
| | | if (this.props.param && this.props.param.arr_field) { |
| | | _arrField = this.props.param.arr_field |
| | | } else { |
| | | config.groups.forEach(group => { |
| | | group.sublist.forEach(item => { |
| | | if (!item.field) return |
| | | // if (this.props.param && this.props.param.arr_field) { // 使用显示列字段查询 |
| | | // _arrField = this.props.param.arr_field |
| | | // } else { |
| | | config.groups.forEach(group => { |
| | | group.sublist.forEach(item => { |
| | | if (!item.field) return |
| | | |
| | | _arrField.push(item.field) |
| | | }) |
| | | _arrField.push(item.field) |
| | | }) |
| | | _arrField = _arrField.join(',') |
| | | } |
| | | }) |
| | | _arrField = _arrField.join(',') |
| | | // } |
| | | |
| | | // 权限过滤 |
| | | config.action = config.action.filter(item => permAction[item.uuid]) |
| | |
| | | actions: config.action, |
| | | isLinkMain: _isLinkMain, |
| | | arr_field: _arrField, |
| | | data: config.setting.datatype === 'query' ? null : (this.props.param.data[0] || null), |
| | | primaryId: this.props.param.primaryId || '', |
| | | data: config.setting.datatype === 'query' ? null : this.props.param.data, |
| | | BIDs: { |
| | | mainTable: this.props.param.primaryId || '', |
| | | mainTabledata: config.setting.datatype === 'query' ? '' : (this.props.param.data[0] || '') |
| | | mainTabledata: config.setting.datatype === 'query' ? '' : this.props.param.data |
| | | } |
| | | }, () => { |
| | | this.improveSelectOption(config.groups) |
| | | |
| | | if (config.setting.datatype === 'query') { |
| | | if (config.setting.datatype === 'query' && this.props.param.primaryId) { |
| | | this.loadmaindata() |
| | | } |
| | | }) |
| | |
| | | */ |
| | | async loadmaindata () { |
| | | const { setting } = this.state |
| | | let param = this.getCustomParam() |
| | | |
| | | if (setting.datatype !== 'query') return |
| | | |
| | | let param = null |
| | | |
| | | if (setting.interType !== 'inner' || (setting.interType === 'inner' && setting.innerFunc)) { |
| | | param = this.getCustomParam() |
| | | } else { |
| | | param = this.getDefaultParam() |
| | | } |
| | | |
| | | if (!param) return // 未获取参数时,不发请求 |
| | | |
| | | let result = await Api.genericInterface(param) |
| | | if (result.status) { |
| | | let _data = result.data[0] || '' |
| | | let _primaryId = '' |
| | | |
| | | if (_data) { |
| | | _primaryId = _data[setting.primaryKey] || '' |
| | | } |
| | | |
| | | this.setState({ |
| | | data: result.data, |
| | | data: _data, |
| | | primaryId: _primaryId, |
| | | BIDs: { |
| | | mainTable: (result.data[0] && result.data[0][setting.primaryKey]) || '', |
| | | mainTabledata: result.data[0] || '' |
| | | mainTable: _primaryId, |
| | | mainTabledata: _data |
| | | } |
| | | }) |
| | | } else { |
| | |
| | | } |
| | | |
| | | /** |
| | | * @description 获取系统存储过程 sPC_Get_TableData 的参数 |
| | | */ |
| | | getDefaultParam = () => { |
| | | const { arr_field, setting, primaryId } = this.state |
| | | |
| | | if (!arr_field) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '未设置表单字段!', |
| | | duration: 10 |
| | | }) |
| | | return null |
| | | } else if (!primaryId) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '未获取到主键值!', |
| | | duration: 10 |
| | | }) |
| | | return null |
| | | } |
| | | |
| | | |
| | | let param = { |
| | | func: 'sPC_Get_TableData', |
| | | obj_name: 'data', |
| | | arr_field: arr_field, |
| | | appkey: window.GLOB.appkey || '' |
| | | } |
| | | |
| | | let _dataresource = setting.dataresource |
| | | |
| | | if (/\s/.test(_dataresource)) { |
| | | _dataresource = '(' + _dataresource + ') tb' |
| | | } |
| | | |
| | | let LText = `select ${arr_field} from (select ${arr_field} ,ROW_NUMBER() from ${_dataresource}) tmptable where ${setting.primaryKey}=${primaryId}` |
| | | |
| | | param.LText = Utils.formatOptions(LText) |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | param.secretkey = Utils.encrypt(param.LText, param.timestamp) |
| | | param.DateCount = '' |
| | | |
| | | return param |
| | | } |
| | | |
| | | /** |
| | | * @description 获取用户自定义存储过程传参 |
| | | */ |
| | | getCustomParam = () => { |
| | | const { setting } = this.state |
| | | const { setting, primaryId } = this.state |
| | | |
| | | let param = {} |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | param[setting.primaryKey] = primaryId |
| | | |
| | | return param |
| | | } |
| | | |
| | | /** |
| | | * @description 按钮操作完成后(成功或失败),页面刷新,重置页码及选择项 |
| | | */ |
| | | refreshbyaction = (btn, type) => { |
| | | if (btn.execSuccess === 'grid' && type === 'success') { |
| | | refreshbyaction = (btn, type, primaryId) => { |
| | | if (type === 'success' && btn.afterExecSuccess === 'notclose') { |
| | | this.setState({ |
| | | primaryId: primaryId |
| | | }, () => { |
| | | if (btn.execSuccess === 'refresh') { |
| | | this.loadmaindata() |
| | | } |
| | | }) |
| | | } else if (type === 'success' && btn.afterExecSuccess === 'close') { |
| | | if (this.props.refresh) { |
| | | this.props.refresh(btn.execSuccess) |
| | | } else { |
| | | if (btn.execSuccess !== 'never') { |
| | | let PMenu = { |
| | | MenuID: this.props.param.parentId || '', |
| | | position: btn.execSuccess |
| | | } |
| | | this.props.refreshTabView(PMenu) |
| | | } |
| | | |
| | | } else if (btn.execError === 'grid' && type === 'error') { |
| | | let tabs = this.props.tabviews.filter(tab => { |
| | | tab.selected = false |
| | | if (tab.MenuID === this.props.param.parentId) { |
| | | tab.selected = true |
| | | } |
| | | |
| | | } else if (btn.execSuccess === 'view' && type === 'success') { |
| | | return tab.MenuID !== this.props.MenuID |
| | | }) |
| | | |
| | | } else if (btn.execError === 'view' && type === 'error') { |
| | | this.props.modifyTabview(tabs) |
| | | } |
| | | } else if (type === 'error' && btn.afterExecError === 'notclose') { |
| | | if (btn.execSuccess === 'refresh') { |
| | | this.loadmaindata() |
| | | } |
| | | } else if (type === 'error' && btn.afterExecError === 'close') { |
| | | if (this.props.refresh) { |
| | | this.props.refresh(btn.execError) |
| | | } else { |
| | | if (btn.execError !== 'never') { |
| | | let PMenu = { |
| | | MenuID: this.props.param.parentId || '', |
| | | position: btn.execError |
| | | } |
| | | this.props.refreshTabView(PMenu) |
| | | } |
| | | |
| | | let tabs = this.props.tabviews.filter(tab => { |
| | | tab.selected = false |
| | | if (tab.MenuID === this.props.param.parentId) { |
| | | tab.selected = true |
| | | } |
| | | |
| | | return tab.MenuID !== this.props.MenuID |
| | | }) |
| | | |
| | | this.props.modifyTabview(tabs) |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | [type + 'data']: data |
| | | } |
| | | }) |
| | | } |
| | | |
| | | getFormData = () => { |
| | | return this.formGroupRef.handleConfirm() |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | |
| | | |
| | | render() { |
| | | const { setting, actions, loadingview, viewlost, isLinkMain, config, groups, data } = this.state |
| | | let hasform = false |
| | | |
| | | if (groups && (groups.length > 1 || groups[0].sublist.length > 0)) { |
| | | hasform = true |
| | | } |
| | | |
| | | return ( |
| | | <div className={'formtab ' + (isLinkMain ? 'pick-control' : '')} id={this.state.ContainerId}> |
| | | {loadingview && <Spin size="large" />} |
| | | {groups && (groups.length > 1 || groups[0].sublist.length > 0) ? |
| | | {hasform ? |
| | | <FormGroup |
| | | dict={this.state.dict} |
| | | data={data} |
| | |
| | | wrappedComponentRef={(inst) => this.formGroupRef = inst} |
| | | /> : null |
| | | } |
| | | {actions ? |
| | | {hasform ? |
| | | <FormAction |
| | | logcolumns={[]} |
| | | setting={setting} |
| | | actions={actions} |
| | | dict={this.state.dict} |
| | | data={this.state.data} |
| | | MenuID={this.props.MenuID} |
| | | logcolumns={[]} |
| | | primaryId={this.state.primaryId} |
| | | getFormData={this.getFormData} |
| | | refreshdata={this.refreshbyaction} |
| | | /> : null |
| | | } |
| | |
| | | |
| | | const mapStateToProps = (state) => { |
| | | return { |
| | | tabviews: state.tabviews, |
| | | refreshTab: state.refreshTab, |
| | | permAction: state.permAction |
| | | } |
| | |
| | | |
| | | const mapDispatchToProps = (dispatch) => { |
| | | return { |
| | | refreshTabView: (refreshTab) => dispatch(refreshTabView(refreshTab)) |
| | | refreshTabView: (refreshTab) => dispatch(refreshTabView(refreshTab)), |
| | | modifyTabview: (tabviews) => dispatch(modifyTabview(tabviews)) |
| | | } |
| | | } |
| | | |