| | |
| | | _actions.forEach(item => { |
| | | if (item.uuid === config.autoMatic.action && (['pop', 'prompt', 'exec'].includes(item.OpenType) || (item.OpenType === 'funcbutton' && item.funcType === 'print'))) { |
| | | autoMatic = config.autoMatic |
| | | autoMatic.OpenType = item.execMode || item.OpenType |
| | | config.setting.selected = 'false' |
| | | item.autoMatic = true |
| | | } |
| | | }) |
| | | } |
| | |
| | | } |
| | | |
| | | loadData = () => { |
| | | const { MenuID } = this.props |
| | | const { setting, search, BIDs, loadCustomApi, hasReqFields } = this.state |
| | | |
| | | this.setState({ |
| | | selectedData: [], |
| | | BIDs: { |
| | | ...BIDs, |
| | | mainTable: '', |
| | | mainTabledata: '' |
| | | } |
| | | BIDs: { ...BIDs, [MenuID]: '', [MenuID + 'data']: '' } |
| | | }) |
| | | |
| | | if (hasReqFields) { |
| | |
| | | * @description 主表数据加载 |
| | | */ |
| | | async loadmaindata () { |
| | | const { setting, arr_field, search, orderBy, BID, pageIndex, pageSize, absFields } = this.state |
| | | const { setting, arr_field, search, orderBy, BID, pageIndex, pageSize, absFields, autoMatic } = this.state |
| | | |
| | | this.setState({ |
| | | loading: true |
| | |
| | | loading: false, |
| | | pickup: false |
| | | }) |
| | | |
| | | if (autoMatic) { |
| | | if (result.data && result.data.length > 0) { |
| | | MKEmitter.emit('autoGetData', this.props.MenuID) |
| | | } else { |
| | | MKEmitter.emit('autoMaticOver', this.props.MenuID) |
| | | } |
| | | } |
| | | } else { |
| | | this.setState({ |
| | | loading: false |
| | | }) |
| | | if (autoMatic) { |
| | | MKEmitter.emit('autoMaticError', this.props.MenuID) |
| | | } |
| | | notification.error({ |
| | | top: 92, |
| | | message: result.message, |
| | |
| | | this.loadData() |
| | | }) |
| | | } else { |
| | | MKEmitter.emit('resetTable', this.props.MenuID + 'mainTable') // 列表重置 |
| | | MKEmitter.emit('resetTable', this.props.MenuID) // 列表重置 |
| | | this.setState({ |
| | | pageIndex: 1, |
| | | search: searches |
| | |
| | | * @description 表格条件改变时重置数据(分页或排序) |
| | | */ |
| | | refreshbytable = (pagination, filters, sorter) => { |
| | | if (!sorter) { |
| | | this.setState({ |
| | | pageIndex: pagination.pageIndex |
| | | }, () => { |
| | | this.loadData() |
| | | }) |
| | | return |
| | | } |
| | | |
| | | if (sorter.order) { |
| | | let _chg = { |
| | | ascend: 'asc', |
| | |
| | | */ |
| | | reloadtable = (btn) => { |
| | | if (!btn || btn.resetPageIndex !== 'false') { |
| | | MKEmitter.emit('resetTable', this.props.MenuID + 'mainTable') // 列表重置 |
| | | MKEmitter.emit('resetTable', this.props.MenuID) // 列表重置 |
| | | this.setState({ |
| | | pageIndex: 1 |
| | | }, () => { |
| | | this.loadData() |
| | | }) |
| | | } else { |
| | | MKEmitter.emit('resetTable', this.props.MenuID + 'mainTable', 'false') // 列表重置 |
| | | MKEmitter.emit('resetTable', this.props.MenuID, 'false') // 列表重置 |
| | | this.loadData() |
| | | } |
| | | } |
| | |
| | | */ |
| | | changeSelectedData = (selectedData) => { |
| | | this.setState({selectedData}) |
| | | } |
| | | |
| | | /** |
| | | * @description 表格Id变化 |
| | | */ |
| | | handleTableId = (type, id, data) => { |
| | | const { BIDs } = this.state |
| | | |
| | | this.setState({ |
| | | BIDs: { |
| | | ...BIDs, |
| | | [type]: id, |
| | | [type + 'data']: data |
| | | } |
| | | }) |
| | | } |
| | | |
| | | /** |
| | |
| | | this.setShortcut() |
| | | } |
| | | |
| | | changeTableLine = (ContainerId, tableId, id, data) => { |
| | | if (this.state.ContainerId !== ContainerId) return |
| | | |
| | | this.setState({ |
| | | BIDs: {...this.state.BIDs, [tableId]: id, [tableId + 'data']: data} |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 按钮执行完成后页面刷新 |
| | | * @param {*} menuId // 菜单Id |
| | |
| | | componentDidMount () { |
| | | MKEmitter.addListener('reloadData', this.reloadData) |
| | | MKEmitter.addListener('reloadMenuView', this.reloadMenuView) |
| | | MKEmitter.addListener('changeTableLine', this.changeTableLine) |
| | | MKEmitter.addListener('resetActiveMenu', this.resetActiveMenu) |
| | | MKEmitter.addListener('queryModuleParam', this.queryModuleParam) |
| | | MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult) |
| | |
| | | document.onkeydown = () => {} |
| | | MKEmitter.removeListener('reloadData', this.reloadData) |
| | | MKEmitter.removeListener('reloadMenuView', this.reloadMenuView) |
| | | MKEmitter.removeListener('changeTableLine', this.changeTableLine) |
| | | MKEmitter.removeListener('resetActiveMenu', this.resetActiveMenu) |
| | | MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) |
| | | MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) |
| | |
| | | statFValue={this.state.statFValue} |
| | | ContainerId={this.state.ContainerId} |
| | | refreshdata={this.refreshbytable} |
| | | handleTableId={this.handleTableId} |
| | | chgSelectData={this.changeSelectedData} |
| | | /> |
| | | </div> |
| | |
| | | data={this.state.data} |
| | | loading={this.state.loading} |
| | | ContainerId={this.state.ContainerId} |
| | | handleTableId={this.handleTableId} |
| | | /> |
| | | </Col> |
| | | ) |
| | |
| | | ContainerId={this.state.ContainerId} |
| | | BID={this.state.BIDs[_tab.supMenu] || ''} |
| | | BData={this.state.BIDs[_tab.supMenu + 'data'] || ''} |
| | | handleTableId={this.handleTableId} |
| | | /> |
| | | </TabPane> |
| | | ) |
| | |
| | | * @description 获取页面配置信息 |
| | | */ |
| | | async loadconfig () { |
| | | const { permAction } = this.props |
| | | const { permAction, MenuID } = this.props |
| | | |
| | | let param = { |
| | | func: 'sPC_Get_LongParam', |
| | | MenuID: this.props.MenuID |
| | | MenuID: MenuID |
| | | } |
| | | let result = await Api.getCacheConfig(param) |
| | | if (result.status) { |
| | |
| | | config.tabgroups = _tabgroups |
| | | } |
| | | |
| | | // 权限过滤 |
| | | if (this.props.menuType !== 'HS') { |
| | | config.action = config.action.filter(item => permAction[item.uuid]) |
| | | config.tabgroups.forEach(group => { |
| | | group.sublist = group.sublist.filter(tab => permAction[tab.linkTab]) |
| | | }) |
| | | group.sublist = group.sublist.filter(tab => { |
| | | if (tab.supMenu === 'mainTable') { |
| | | tab.supMenu = MenuID |
| | | } |
| | | return permAction[tab.linkTab] |
| | | }) |
| | | }) |
| | | |
| | | // 按钮类型兼容 |
| | | config.action = config.action.map(item => { |
| | |
| | | primaryId: this.props.param.primaryId || '', |
| | | data: this.props.param.data || null, |
| | | BIDs: { |
| | | mainTable: config.setting.onload !== 'false' ? (this.props.param.primaryId || '') : '', |
| | | mainTabledata: config.setting.onload !== 'false' ? (config.setting.datatype === 'query' ? '' : this.props.param.data) : '' |
| | | [MenuID]: config.setting.onload !== 'false' ? (this.props.param.primaryId || '') : '', |
| | | [MenuID + 'data']: config.setting.onload !== 'false' ? (config.setting.datatype === 'query' ? '' : this.props.param.data) : '' |
| | | } |
| | | }, () => { |
| | | this.improveSelectOption(config.groups) |
| | |
| | | this.setState({ |
| | | data: _data, |
| | | primaryId: _primaryId, |
| | | BIDs: { |
| | | ...BIDs, |
| | | mainTable: _primaryId, |
| | | mainTabledata: _data |
| | | } |
| | | BIDs: { ...BIDs, [this.props.MenuID]: _primaryId, [this.props.MenuID + 'data']: _data } |
| | | }) |
| | | |
| | | if (_data && (setting.interType !== 'inner' || (setting.interType === 'inner' && setting.innerFunc))) { |
| | |
| | | } |
| | | |
| | | this.setState({ |
| | | BIDs: { |
| | | ...BIDs, |
| | | mainTable: primaryId, |
| | | mainTabledata: data |
| | | } |
| | | BIDs: { ...BIDs, [this.props.MenuID]: primaryId, [this.props.MenuID + 'data']: data } |
| | | }) |
| | | } |
| | | }) |
| | |
| | | } |
| | | MKEmitter.emit('closeTabView', this.props.MenuID) |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @description 表格Id变化 |
| | | */ |
| | | handleTableId = (type, id, data) => { |
| | | const { BIDs } = this.state |
| | | |
| | | this.setState({ |
| | | BIDs: { |
| | | ...BIDs, |
| | | [type]: id, |
| | | [type + 'data']: data |
| | | } |
| | | }) |
| | | } |
| | | |
| | | /** |
| | |
| | | this.loadmaindata() |
| | | } |
| | | |
| | | changeTableLine = (ContainerId, tableId, id, data) => { |
| | | if (this.state.ContainerId !== ContainerId) return |
| | | |
| | | this.setState({ |
| | | BIDs: {...this.state.BIDs, [tableId]: id, [tableId + 'data']: data} |
| | | }) |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | // 组件加载时,获取菜单数据 |
| | | this.loadconfig() |
| | |
| | | } |
| | | |
| | | componentDidMount () { |
| | | MKEmitter.addListener('reloadMenuView', this.reloadMenuView) |
| | | MKEmitter.addListener('reloadData', this.reloadData) |
| | | MKEmitter.addListener('reloadMenuView', this.reloadMenuView) |
| | | MKEmitter.addListener('changeTableLine', this.changeTableLine) |
| | | } |
| | | |
| | | /** |
| | |
| | | return |
| | | } |
| | | |
| | | MKEmitter.removeListener('reloadMenuView', this.reloadMenuView) |
| | | MKEmitter.removeListener('reloadData', this.reloadData) |
| | | MKEmitter.removeListener('reloadMenuView', this.reloadMenuView) |
| | | MKEmitter.removeListener('changeTableLine', this.changeTableLine) |
| | | } |
| | | |
| | | render() { |
| | |
| | | ContainerId={this.state.ContainerId} |
| | | BID={this.state.BIDs[_tab.supMenu] || ''} |
| | | BData={this.state.BIDs[_tab.supMenu + 'data'] || ''} |
| | | handleTableId={this.handleTableId} |
| | | /> |
| | | </TabPane> |
| | | ) |
| | |
| | | * 含有初始不加载的页面,修改设置 |
| | | */ |
| | | refreshbysearch = (searches) => { |
| | | MKEmitter.emit('resetTable', this.props.MenuID + 'mainTable') // 列表重置 |
| | | MKEmitter.emit('resetTable', this.props.MenuID) // 列表重置 |
| | | this.setState({ |
| | | loading: true, |
| | | pageIndex: 1, |
| | |
| | | * @description 表格刷新 |
| | | */ |
| | | reloadtable = () => { |
| | | MKEmitter.emit('resetTable', this.props.MenuID + 'mainTable') // 列表重置 |
| | | MKEmitter.emit('resetTable', this.props.MenuID) // 列表重置 |
| | | this.setState({ |
| | | loading: true, |
| | | pageIndex: 1, |
| | |
| | | </div> : null |
| | | } |
| | | <MainTable |
| | | tableId="mainTable" |
| | | tableId={this.props.MenuID} |
| | | pickup={pickup} |
| | | setting={setting} |
| | | columns={columns} |
| | |
| | | loading={this.state.loading} |
| | | refreshdata={this.refreshbytable} |
| | | buttonTrigger={() => {}} |
| | | handleTableId={() => {}} |
| | | chgSelectData={this.changeSelectedData} |
| | | /> |
| | | </div> |
| | |
| | | SupMenuID: PropTypes.string, // 上级菜单Id |
| | | mainSearch: PropTypes.any, // 主表搜索条件 |
| | | ContainerId: PropTypes.any, // 三级菜单Container(html) ID |
| | | handleTableId: PropTypes.func, // 控制表格数据切换时,更新在主表中的id |
| | | } |
| | | |
| | | state = { |
| | |
| | | statFValue: [], // 合计值 |
| | | absFields: [], // 绝对值字段 |
| | | loadCustomApi: true, // 加载外部资源 |
| | | hasReqFields: false |
| | | hasReqFields: false, |
| | | BID: '', |
| | | BData: '' |
| | | } |
| | | |
| | | /** |
| | | * @description 上级菜单id变化时,刷新数据 |
| | | */ |
| | | UNSAFE_componentWillReceiveProps(nextProps) { |
| | | const { config, setting } = this.state |
| | | const { setting } = this.state |
| | | |
| | | if (config && setting && this.props.Tab.supMenu && !is(fromJS(this.props.BID), fromJS(nextProps.BID))) { |
| | | MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid) // 列表重置 |
| | | this.setState({ |
| | | pageIndex: 1 |
| | | }, () => { |
| | | this.loadData() |
| | | }) |
| | | } else if (setting && !this.props.Tab.supMenu && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { |
| | | if (setting && !this.props.Tab.supMenu && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | | }) |
| | |
| | | * @description 获取页面配置信息 |
| | | */ |
| | | async loadconfig () { |
| | | const { permAction, permMenus, Tab, BID } = this.props |
| | | const { permAction, permMenus, Tab, BID, BData } = this.props |
| | | |
| | | let param = { |
| | | func: 'sPC_Get_LongParam', |
| | |
| | | } |
| | | |
| | | this.setState({ |
| | | BID: BID || '', |
| | | BData: BData || '', |
| | | loadingview: false, |
| | | chartId, |
| | | config, |
| | |
| | | } |
| | | |
| | | loadData = () => { |
| | | const { mainSearch, BID } = this.props |
| | | const { setting, search, loadCustomApi, hasReqFields } = this.state |
| | | const { mainSearch } = this.props |
| | | const { setting, BID, search, loadCustomApi, hasReqFields } = this.state |
| | | |
| | | let searches = fromJS(search).toJS() |
| | | if (mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | |
| | | statFValue: [], |
| | | total: 0 |
| | | }) |
| | | this.handleTableId() |
| | | MKEmitter.emit('changeTableLine', this.props.ContainerId, this.props.Tab.uuid, '', '') |
| | | return |
| | | } else if (window.GLOB.systemType === 'production' && setting.interType === 'custom' && !setting.proInterface) { |
| | | notification.warning({ |
| | |
| | | this.setState({ |
| | | selectedData: [] |
| | | }) |
| | | this.handleTableId() |
| | | MKEmitter.emit('changeTableLine', this.props.ContainerId, this.props.Tab.uuid, '', '') |
| | | |
| | | if (setting.interType === 'custom' && loadCustomApi) { |
| | | if (setting.execTime === 'once') { |
| | |
| | | } |
| | | |
| | | loadOutResource = (searches) => { |
| | | const { BID } = this.props |
| | | const { setting } = this.state |
| | | const { setting, BID } = this.state |
| | | |
| | | let param = UtilsDM.getPrevQueryParams(setting, searches, BID, this.props.menuType) |
| | | |
| | |
| | | } |
| | | |
| | | customCallbackRequest = (result) => { |
| | | const { setting } = this.state |
| | | const { setting, BID } = this.state |
| | | let errSql = '' |
| | | if (result.$ErrCode === 'E') { |
| | | errSql = ` |
| | |
| | | |
| | | param = UtilsDM.getCallBackQueryParams(setting, sql, errSql) |
| | | |
| | | if (this.props.BID) { |
| | | param.BID = this.props.BID |
| | | if (BID) { |
| | | param.BID = BID |
| | | } |
| | | |
| | | if (this.props.menuType === 'HS') { // 函数 sPC_TableData_InUpDe 云端验证 |
| | |
| | | * @description 子表数据加载 |
| | | */ |
| | | async loadmaindata () { |
| | | const { mainSearch, BID } = this.props |
| | | const { setting, arr_field, search, orderBy, pageIndex, pageSize, absFields } = this.state |
| | | const { mainSearch } = this.props |
| | | const { setting, BID, arr_field, search, orderBy, pageIndex, pageSize, absFields } = this.state |
| | | |
| | | let searches = fromJS(search).toJS() |
| | | if (mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | |
| | | * @description 获取单行数据 |
| | | */ |
| | | async loadmainLinedata (id) { |
| | | const { mainSearch, BID } = this.props |
| | | const { setting, arr_field, search, orderBy, pageIndex, pageSize, absFields } = this.state |
| | | const { mainSearch } = this.props |
| | | const { setting, BID, arr_field, search, orderBy, pageIndex, pageSize, absFields } = this.state |
| | | |
| | | let searches = fromJS(search).toJS() |
| | | if (mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | |
| | | * @description 获取合计字段值 |
| | | */ |
| | | getStatFieldsValue = (searches) => { |
| | | const { BID } = this.props |
| | | const { setting, orderBy, statFields } = this.state |
| | | const { setting, BID, orderBy, statFields } = this.state |
| | | |
| | | if (statFields.length === 0 || !(setting.interType === 'system' || (setting.interType === 'custom' && setting.requestMode === 'system')) || !setting.dataresource) return |
| | | |
| | |
| | | * 含有初始不加载的页面,修改设置 |
| | | */ |
| | | refreshbysearch = (searches) => { |
| | | MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid) // 列表重置 |
| | | MKEmitter.emit('resetTable', this.props.Tab.uuid) // 列表重置 |
| | | this.setState({ |
| | | pageIndex: 1, |
| | | search: searches, |
| | |
| | | */ |
| | | reloadtable = (btn) => { |
| | | if (!btn || btn.resetPageIndex !== 'false') { |
| | | MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid) // 列表重置 |
| | | MKEmitter.emit('resetTable', this.props.Tab.uuid) // 列表重置 |
| | | this.setState({ |
| | | pageIndex: 1 |
| | | }, () => { |
| | | this.loadData() |
| | | }) |
| | | } else { |
| | | MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid, 'false') // 列表重置 |
| | | MKEmitter.emit('resetTable', this.props.Tab.uuid, 'false') // 列表重置 |
| | | this.loadData() |
| | | } |
| | | } |
| | |
| | | */ |
| | | changeSelectedData = (selectedData) => { |
| | | this.setState({selectedData}) |
| | | } |
| | | |
| | | /** |
| | | * @description 表格Id变化 |
| | | */ |
| | | handleTableId = (type = this.props.Tab.uuid, id = '', data = '') => { |
| | | this.props.handleTableId(type, id, data) |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | if (MenuID !== menuId) return |
| | | |
| | | const { Tab, SupMenuID, BID } = this.props |
| | | const { Tab, SupMenuID } = this.props |
| | | const { BID } = this.state |
| | | |
| | | if (position === 'grid' || position === 'view') { |
| | | this.reloadtable(btn) |
| | | } else if (position === 'maingrid' || position === 'mainline') { |
| | | this.reloadtable(btn) |
| | | if (Tab.supMenu === 'mainTable') { |
| | | MKEmitter.emit('reloadData', SupMenuID, (BID || 'empty')) // 主表重置 |
| | | } else if (Tab.supMenu) { |
| | | if (Tab.supMenu) { |
| | | MKEmitter.emit('reloadData', Tab.supMenu, (BID || 'empty')) // 主表重置 |
| | | } else if (!Tab.supMenu && Tab.level === 0) { |
| | | MKEmitter.emit('reloadData', SupMenuID, (BID || 'empty')) // 树形结构,0级标签 |
| | |
| | | } |
| | | } |
| | | |
| | | changeTableLine = (ContainerId, tableId, id, data) => { |
| | | const { Tab } = this.props |
| | | |
| | | if (!Tab.supMenu || tableId !== Tab.supMenu) return |
| | | |
| | | this.setState({BData: data, BID: id}) |
| | | |
| | | if (id !== this.state.BID) { |
| | | MKEmitter.emit('resetTable', this.props.Tab.uuid) // 列表重置 |
| | | this.setState({ |
| | | pageIndex: 1 |
| | | }, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | } |
| | | |
| | | UNSAFE_componentWillMount() { |
| | | // 组件加载时,获取菜单数据 |
| | | this.loadconfig() |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { // handleTableId 函数判断时不相等 |
| | | return !is(fromJS({...this.props, handleTableId: ''}), fromJS({...nextProps, handleTableId: ''})) || !is(fromJS(this.state), fromJS(nextState)) |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | | return !is(fromJS(this.state), fromJS(nextState)) |
| | | } |
| | | |
| | | componentDidMount () { |
| | | MKEmitter.addListener('reloadData', this.reloadData) |
| | | MKEmitter.addListener('changeTableLine', this.changeTableLine) |
| | | MKEmitter.addListener('queryModuleParam', this.queryModuleParam) |
| | | MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult) |
| | | } |
| | |
| | | return |
| | | } |
| | | MKEmitter.removeListener('reloadData', this.reloadData) |
| | | MKEmitter.removeListener('changeTableLine', this.changeTableLine) |
| | | MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) |
| | | MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) |
| | | } |
| | | |
| | | render() { |
| | | const { config, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, pickup, chartId, selectedData } = this.state |
| | | const { config, BID, BData, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, pickup, chartId, selectedData } = this.state |
| | | |
| | | return ( |
| | | <div className="subtable" id={'subtable' + this.props.MenuID}> |
| | | {loadingview && <Spin />} |
| | | {searchlist && searchlist.length ? |
| | | <SubSearch BID={this.props.BID} setting={setting} searchlist={searchlist} menuType={this.props.menuType} refreshdata={this.refreshbysearch}/> : null |
| | | <SubSearch BID={BID} setting={setting} searchlist={searchlist} menuType={this.props.menuType} refreshdata={this.refreshbysearch}/> : null |
| | | } |
| | | {config ? <Row className="chart-view" gutter={16}> |
| | | {/* 视图组 */} |
| | |
| | | {config.charts.length > 1 ? <p className="chart-table chart-title">{item.title}</p> : null} |
| | | <div className="sub-action"> |
| | | <SubAction |
| | | BID={BID} |
| | | BData={BData} |
| | | setting={setting} |
| | | actions={actions} |
| | | columns={columns} |
| | | Tab={this.props.Tab} |
| | | BID={this.props.BID} |
| | | BData={this.props.BData} |
| | | MenuID={this.props.MenuID} |
| | | selectedData={selectedData} |
| | | ContainerId={this.props.ContainerId} |
| | |
| | | <Switch title="收起" className="subtable-pickup" checkedChildren="开" unCheckedChildren="关" checked={pickup} onChange={this.pickupChange} /> : null |
| | | } |
| | | <SubTable |
| | | BData={BData} |
| | | tableId={this.props.Tab.uuid} |
| | | pickup={pickup} |
| | | setting={setting} |
| | |
| | | pageSize={pageSize} |
| | | dict={this.state.dict} |
| | | data={this.state.data} |
| | | BData={this.props.BData} |
| | | total={this.state.total} |
| | | MenuID={this.props.MenuID} |
| | | loading={this.state.loading} |
| | | statFValue={this.state.statFValue} |
| | | ContainerId={this.props.ContainerId} |
| | | refreshdata={this.refreshbytable} |
| | | handleTableId={this.handleTableId} |
| | | chgSelectData={this.changeSelectedData} |
| | | /> |
| | | </div> |
| | |
| | | return ( |
| | | <Col className="card-view" span={item.width} key={item.uuid}> |
| | | <CardComponent |
| | | BID={BID} |
| | | plot={item} |
| | | BData={BData} |
| | | config={config} |
| | | columns={columns} |
| | | Tab={this.props.Tab} |
| | | BID={this.props.BID} |
| | | BData={this.props.BData} |
| | | data={this.state.data} |
| | | MenuID={this.props.MenuID} |
| | | loading={this.state.loading} |
| | | tableId={this.props.Tab.uuid} |
| | | handleTableId={this.handleTableId} |
| | | ContainerId={this.props.ContainerId} |
| | | /> |
| | | </Col> |
| | | ) |
| | |
| | | return ( |
| | | <Col span={item.width} key={item.uuid}> |
| | | <ChartComponent |
| | | BID={BID} |
| | | plot={item} |
| | | config={config} |
| | | BID={this.props.BID} |
| | | Tab={this.props.Tab} |
| | | data={this.state.data} |
| | | loading={this.state.loading} |
| | |
| | | import PropTypes from 'prop-types' |
| | | import {connect} from 'react-redux' |
| | | import { is, fromJS } from 'immutable' |
| | | import { notification, Spin, Col, Row, Icon, Tabs} from 'antd' |
| | | import { notification, Spin} from 'antd' |
| | | |
| | | import Api from '@/api' |
| | | import zhCN from '@/locales/zh-CN/main.js' |
| | |
| | | import Utils from '@/utils/utils.js' |
| | | import options from '@/store/options.js' |
| | | import UtilsDM from '@/utils/utils-datamanage.js' |
| | | import { updateSubTable } from '@/utils/utils-update.js' |
| | | import { updateSubTabTable } from '@/utils/utils-update.js' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import asyncSpinComponent from '@/utils/asyncSpinComponent' |
| | | import NotFount from '@/components/404' |
| | |
| | | |
| | | import './index.scss' |
| | | |
| | | const { TabPane } = Tabs |
| | | const SubSearch = asyncComponent(() => import('@/tabviews/zshare/topSearch')) |
| | | const SubAction = asyncComponent(() => import('@/tabviews/zshare/actionList')) |
| | | const SubTable = asyncSpinComponent(() => import('@/tabviews/zshare/normalTable')) |
| | | const CardComponent = asyncSpinComponent(() => import('@/tabviews/zshare/cardcomponent')) |
| | | const ChartComponent = asyncSpinComponent(() => import('@/tabviews/zshare/chartcomponent')) |
| | | |
| | | class SubTabModalTable extends Component { |
| | | static propTpyes = { |
| | |
| | | pageSize: 10, // 每页数据条数 |
| | | orderBy: '', // 排序 |
| | | search: '', // 搜索条件数组,使用时需分场景处理 |
| | | chartId: '', // 展开图表ID |
| | | statFields: [], // 合计字段 |
| | | statFValue: [], // 合计值 |
| | | absFields: [], // 绝对值字段 |
| | |
| | | let absFields = [] // 绝对值字段 |
| | | |
| | | // 版本兼容 |
| | | config = updateSubTable(config) |
| | | config = updateSubTabTable(config) |
| | | |
| | | // 不支持funcbutton、popview 类型按钮 |
| | | let labels = [] |
| | |
| | | |
| | | return col |
| | | }) |
| | | |
| | | // 视图权限 |
| | | config.charts = config.charts.filter(item => { |
| | | if (item.Hide === 'true') return false |
| | | if (!item.blacklist || item.blacklist.length === 0) return true |
| | | return item.blacklist.filter(v => roleId.indexOf(v) > -1).length === 0 |
| | | }) |
| | | |
| | | if (config.charts.length <= 1) { |
| | | config.expand = true |
| | | } |
| | | |
| | | let chartId = config.charts[0] ? config.charts[0].uuid : '' |
| | | |
| | | // 1、筛选字段集,2、过滤隐藏列及合并列中的字段uuid |
| | | config.columns.forEach(col => { |
| | |
| | | |
| | | this.setState({ |
| | | loadingview: false, |
| | | chartId, |
| | | config, |
| | | absFields, |
| | | statFields, |
| | |
| | | |
| | | param = UtilsDM.getCallBackQueryParams(setting, sql, errSql) |
| | | |
| | | if (this.state.BID) { |
| | | param.BID = this.state.BID |
| | | if (this.props.BID) { |
| | | param.BID = this.props.BID |
| | | } |
| | | |
| | | if (this.props.menuType === 'HS') { // 函数 sPC_TableData_InUpDe 云端验证 |
| | |
| | | * 含有初始不加载的页面,修改设置 |
| | | */ |
| | | refreshbysearch = (searches) => { |
| | | MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid) // 列表重置 |
| | | MKEmitter.emit('resetTable', this.props.Tab.uuid) // 列表重置 |
| | | this.setState({ |
| | | pageIndex: 1, |
| | | search: searches |
| | |
| | | */ |
| | | reloadtable = (btn) => { |
| | | if (!btn || btn.resetPageIndex !== 'false') { |
| | | MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid) // 列表重置 |
| | | MKEmitter.emit('resetTable', this.props.Tab.uuid) // 列表重置 |
| | | this.setState({ |
| | | pageIndex: 1 |
| | | }, () => { |
| | | this.loadData() |
| | | }) |
| | | } else { |
| | | MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid, 'false') // 列表重置 |
| | | MKEmitter.emit('resetTable', this.props.Tab.uuid, 'false') // 列表重置 |
| | | this.loadData() |
| | | } |
| | | |
| | |
| | | MKEmitter.emit('refreshPopButton', this.props.Tab.uuid) |
| | | } |
| | | |
| | | /** |
| | | * @description 图表视图切换 |
| | | */ |
| | | changeChart = (uuid) => { |
| | | this.setState({chartId: uuid}) |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | // 组件加载时,获取菜单数据 |
| | | this.loadconfig() |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { config, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, chartId, selectedData } = this.state |
| | | const { config, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, selectedData } = this.state |
| | | |
| | | return ( |
| | | <div className="subtabtable" id={'subtabtable' + this.props.MenuID}> |
| | |
| | | {searchlist && searchlist.length ? |
| | | <SubSearch BID={this.props.BID} setting={setting} searchlist={searchlist} menuType={this.props.menuType} refreshdata={this.refreshbysearch}/> : null |
| | | } |
| | | {config ? <Row className="chart-view" gutter={16}> |
| | | {/* 视图组 */} |
| | | {!config.expand ? <Tabs activeKey={chartId} onChange={this.changeChart}> |
| | | {config.charts.map(item => ( |
| | | <TabPane tab={<Icon type={item.icon} />} key={item.uuid}></TabPane> |
| | | ))} |
| | | </Tabs> : null} |
| | | {config.charts.map(item => { |
| | | if (!config.expand && chartId !== item.uuid) return null |
| | | |
| | | if (item.chartType === 'table') { |
| | | return ( |
| | | <Col span={item.width || 24} key={item.uuid}> |
| | | {config.charts.length > 1 ? <p className="chart-table chart-title">{item.title}</p> : null} |
| | | <div style={{minHeight: '25px'}}> |
| | | {config ? <div style={{minHeight: '25px'}}> |
| | | <SubAction |
| | | setting={setting} |
| | | actions={actions} |
| | |
| | | selectedData={selectedData} |
| | | MenuID={this.props.SupMenuID} |
| | | /> |
| | | </div> |
| | | <SubTable |
| | | </div> : null} |
| | | {config ? <SubTable |
| | | tableId={this.props.Tab.uuid} |
| | | setting={setting} |
| | | columns={columns} |
| | |
| | | refreshdata={this.refreshbytable} |
| | | statFValue={this.state.statFValue} |
| | | chgSelectData={this.changeSelectedData} |
| | | handleTableId={() => {}} |
| | | /> |
| | | </Col> |
| | | ) |
| | | } else if (item.chartType === 'card') { |
| | | return ( |
| | | <Col className="card-view" span={item.width} key={item.uuid}> |
| | | <CardComponent |
| | | tableId="" |
| | | plot={item} |
| | | config={config} |
| | | columns={columns} |
| | | BID={this.props.BID} |
| | | data={this.state.data} |
| | | BData={this.props.BData} |
| | | loading={this.state.loading} |
| | | handleTableId={() => {}} |
| | | /> |
| | | </Col> |
| | | ) |
| | | } else { |
| | | return ( |
| | | <Col span={item.width} key={item.uuid}> |
| | | <ChartComponent |
| | | plot={item} |
| | | config={config} |
| | | data={this.state.data} |
| | | loading={this.state.loading} |
| | | /> |
| | | </Col> |
| | | ) |
| | | } |
| | | })} |
| | | </Row> : null } |
| | | /> : null} |
| | | {viewlost ? <NotFount msg={this.state.lostmsg} /> : null} |
| | | </div> |
| | | ) |
| | |
| | | * @description 获取页面配置信息 |
| | | */ |
| | | async loadconfig () { |
| | | const { permAction, param, MenuName } = this.props |
| | | const { permAction, param, MenuName, MenuID } = this.props |
| | | |
| | | let _param = { |
| | | func: 'sPC_Get_LongParam', |
| | | MenuID: this.props.MenuID |
| | | MenuID: MenuID |
| | | } |
| | | let result = await Api.getCacheConfig(_param) |
| | | |
| | |
| | | |
| | | try { // 配置信息解析 |
| | | config = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) |
| | | config.MenuID = this.props.MenuID |
| | | config.MenuID = MenuID |
| | | config.MenuName = MenuName |
| | | config.setting.$name = MenuName |
| | | } catch (e) { |
| | |
| | | group.sublist = group.sublist.filter(tab => { |
| | | if (tab.supMenu === 'mainTable' || (!tab.supMenu && tab.level === 0)) { |
| | | tab.isTreeNode = true |
| | | } |
| | | if (tab.supMenu === 'mainTable') { |
| | | tab.supMenu = MenuID |
| | | } |
| | | return permAction[tab.linkTab]} |
| | | ) |
| | |
| | | } |
| | | |
| | | selectTreeNode = (selectedKeys, {selected, node}) => { |
| | | const { config } = this.state |
| | | const { config, ContainerId } = this.state |
| | | let _expandedKeys = fromJS(this.state.expandedKeys).toJS() |
| | | let _data = fromJS(node.props.dataRef).toJS() |
| | | |
| | |
| | | }) |
| | | |
| | | delete _data.children |
| | | this.handleTableId('mainTable', _data.key, _data) |
| | | |
| | | MKEmitter.emit('changeTableLine', ContainerId, this.props.MenuID, _data.key, _data) |
| | | |
| | | this.setState({ |
| | | tabgroups: _tabgroups, |
| | | expandedKeys: _expandedKeys, |
| | |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 表格Id变化 |
| | | */ |
| | | handleTableId = (type, id, data) => { |
| | | const { BIDs } = this.state |
| | | |
| | | this.setState({ |
| | | BIDs: { |
| | | ...BIDs, |
| | | [type]: id, |
| | | [type + 'data']: data |
| | | } |
| | | }) |
| | | } |
| | | |
| | | reloadData = (menuId) => { |
| | | const { MenuID } = this.props |
| | | |
| | |
| | | this.setShortcut() |
| | | } |
| | | |
| | | changeTableLine = (ContainerId, tableId, id, data) => { |
| | | if (this.state.ContainerId !== ContainerId) return |
| | | |
| | | this.setState({ |
| | | BIDs: {...this.state.BIDs, [tableId]: id, [tableId + 'data']: data} |
| | | }) |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | // 组件加载时,获取菜单数据 |
| | | this.loadconfig() |
| | |
| | | MKEmitter.addListener('reloadData', this.reloadData) |
| | | MKEmitter.addListener('reloadMenuView', this.reloadMenuView) |
| | | MKEmitter.addListener('resetActiveMenu', this.resetActiveMenu) |
| | | MKEmitter.addListener('changeTableLine', this.changeTableLine) |
| | | } |
| | | |
| | | /** |
| | |
| | | MKEmitter.removeListener('reloadData', this.reloadData) |
| | | MKEmitter.removeListener('reloadMenuView', this.reloadMenuView) |
| | | MKEmitter.removeListener('resetActiveMenu', this.resetActiveMenu) |
| | | MKEmitter.removeListener('changeTableLine', this.changeTableLine) |
| | | } |
| | | |
| | | changeExpandedKeys = (expandedKeys) => { |
| | |
| | | ContainerId={this.state.ContainerId} |
| | | BID={this.state.BIDs[_tab.supMenu] || ''} |
| | | BData={this.state.BIDs[_tab.supMenu + 'data'] || ''} |
| | | handleTableId={this.handleTableId} |
| | | /> : null} |
| | | </TabPane> |
| | | ) |
| | |
| | | ], |
| | | gridBtn: {display: false}, |
| | | tabs:[ |
| | | {label:'脚本',type:'SubTable',linkTab:'15839835082267ac69e4gm0ig6ac00ob',icon:'',supMenu:'mainTable',equalTab:[],uuid:'1583979660949hguu6ildhut1ig5mco1'}, |
| | | {label:'已执行',type:'SubTable',linkTab:'1583984646423lo60vt7snppb55lslbt',icon:'',supMenu:'mainTable',equalTab:[],uuid:'1583984632864kedhlvu7l31us7pkmbq'} |
| | | {label:'脚本',type:'SubTable',linkTab:'15839835082267ac69e4gm0ig6ac00ob',icon:'',supMenu:'1583979633842550imkchl4qt4qppsiv'/* mainTable */,equalTab:[],uuid:'1583979660949hguu6ildhut1ig5mco1'}, |
| | | {label:'已执行',type:'SubTable',linkTab:'1583984646423lo60vt7snppb55lslbt',icon:'',supMenu:'1583979633842550imkchl4qt4qppsiv'/* mainTable */,equalTab:[],uuid:'1583984632864kedhlvu7l31us7pkmbq'} |
| | | ] |
| | | } |
| | | |
| | |
| | | * @description 主表数据加载 |
| | | */ |
| | | async loadmaindata () { |
| | | const { setting, BIDs } = this.state |
| | | const { setting, ContainerId } = this.state |
| | | let param = '' |
| | | |
| | | if (setting.interType !== 'inner' || (setting.interType === 'inner' && setting.innerFunc)) { |
| | |
| | | pickup: false |
| | | }) |
| | | |
| | | this.handleTableId('mainTable', '', '') |
| | | MKEmitter.emit('changeTableLine', ContainerId, this.props.MenuID, '', '') |
| | | |
| | | if (!param) { // 未获取参数时,不发请求 |
| | | return |
| | |
| | | }), |
| | | total: result.total, |
| | | loading: false, |
| | | BIDs: { |
| | | ...BIDs, |
| | | mainTable: '' |
| | | } |
| | | BIDs: {[this.props.MenuID] : ''} |
| | | }) |
| | | } else { |
| | | this.setState({ |
| | |
| | | * 含有初始不加载的页面,修改设置 |
| | | */ |
| | | refreshbysearch = (searches) => { |
| | | MKEmitter.emit('resetTable', this.props.MenuID + 'mainTable') // 列表重置 |
| | | MKEmitter.emit('resetTable', this.props.MenuID) // 列表重置 |
| | | this.setState({ |
| | | loading: true, |
| | | pageIndex: 1, |
| | |
| | | * @description 表格刷新 |
| | | */ |
| | | reloadtable = () => { |
| | | MKEmitter.emit('resetTable', this.props.MenuID + 'mainTable') // 列表重置 |
| | | MKEmitter.emit('resetTable', this.props.MenuID) // 列表重置 |
| | | this.setState({ |
| | | pageIndex: 1, |
| | | loading: true |
| | |
| | | * @description 页面刷新,重新获取配置 |
| | | */ |
| | | reloadview = () => { |
| | | MKEmitter.emit('resetTable', this.props.MenuID + 'mainTable') // 列表重置 |
| | | MKEmitter.emit('resetTable', this.props.MenuID) // 列表重置 |
| | | this.setState({ |
| | | config: {}, |
| | | searchlist: [], |
| | |
| | | } |
| | | |
| | | /** |
| | | * @description 表格Id变化 |
| | | */ |
| | | handleTableId = (type, id, data) => { |
| | | const { BIDs } = this.state |
| | | |
| | | this.setState({ |
| | | BIDs: { |
| | | ...BIDs, |
| | | [type]: id, |
| | | [type + 'data']: data |
| | | } |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 数据展开合并切换 |
| | | */ |
| | | pickupChange = () => { |
| | |
| | | this.reloadview() |
| | | } |
| | | |
| | | changeTableLine = (ContainerId, tableId, id, data) => { |
| | | if (this.state.ContainerId !== ContainerId) return |
| | | |
| | | this.setState({ |
| | | BIDs: {...this.state.BIDs, [tableId]: id, [tableId + 'data']: data} |
| | | }) |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | // 组件加载时,获取菜单数据 |
| | | this.loadconfig() |
| | |
| | | |
| | | componentDidMount () { |
| | | MKEmitter.addListener('reloadMenuView', this.reloadMenuView) |
| | | MKEmitter.addListener('changeTableLine', this.changeTableLine) |
| | | } |
| | | |
| | | /** |
| | |
| | | return |
| | | } |
| | | MKEmitter.removeListener('reloadMenuView', this.reloadMenuView) |
| | | MKEmitter.removeListener('changeTableLine', this.changeTableLine) |
| | | } |
| | | |
| | | render() { |
| | |
| | | </div> : null |
| | | } |
| | | <MainTable |
| | | tableId="mainTable" |
| | | tableId={this.props.MenuID} |
| | | pickup={pickup} |
| | | setting={setting} |
| | | columns={columns} |
| | |
| | | loading={this.state.loading} |
| | | refreshdata={this.refreshbytable} |
| | | buttonTrigger={() => {}} |
| | | handleTableId={this.handleTableId} |
| | | ContainerId={this.state.ContainerId} |
| | | chgSelectData={this.changeSelectedData} |
| | | /> |
| | | </div> |
| | |
| | | ContainerId={this.state.ContainerId} |
| | | BID={this.state.BIDs[_tab.supMenu] || ''} |
| | | BData={this.state.BIDs[_tab.supMenu + 'data'] || ''} |
| | | handleTableId={this.handleTableId} |
| | | handleMainTable={(type) => this.handleMainTable(type, _tab)} |
| | | /> |
| | | </TabPane> |
| | |
| | | MenuID: PropTypes.string, // 菜单Id |
| | | SupMenuID: PropTypes.string, // 上级菜单Id |
| | | ContainerId: PropTypes.any, // 三级菜单Container(html) ID |
| | | handleTableId: PropTypes.func, // 控制表格数据切换时,更新在主表中的id |
| | | handleMainTable: PropTypes.func, // 刷新主表 |
| | | refreshtabs:PropTypes.any |
| | | } |
| | |
| | | popData: false, // 弹框页面,所选的表格数据 |
| | | visible: false, // 弹框显示隐藏控制 |
| | | pickup: false, // 子表数据隐藏显示切换 |
| | | BID: '', |
| | | BData: '' |
| | | } |
| | | |
| | | /** |
| | | * @description 上级菜单id变化时,刷新数据 |
| | | */ |
| | | UNSAFE_componentWillReceiveProps(nextProps) { |
| | | if (this.state.config && this.props.Tab.supMenu && !is(fromJS(this.props.BID), fromJS(nextProps.BID))) { |
| | | this.setState({ |
| | | pageIndex: 1, |
| | | selectedData: [] |
| | | }, () => { |
| | | MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid) // 列表重置 |
| | | this.loadmaindata(nextProps.BID, 'refresh') |
| | | }) |
| | | } else if (this.state.config && nextProps.refreshtabs && nextProps.refreshtabs.includes(this.props.Tab.uuid)) { |
| | | |
| | | if (this.state.config && nextProps.refreshtabs && nextProps.refreshtabs.includes(this.props.Tab.uuid)) { |
| | | this.reloadtable() |
| | | } |
| | | } |
| | |
| | | * @description 获取页面配置信息 |
| | | */ |
| | | async loadconfig () { |
| | | const { Tab, BID } = this.props |
| | | const { Tab, BID, BData } = this.props |
| | | |
| | | let config = tabConfig[this.props.MenuID] |
| | | |
| | |
| | | } |
| | | |
| | | this.setState({ |
| | | BID: BID || '', |
| | | BData: BData || '', |
| | | config: config, |
| | | setting: config.setting, |
| | | searchlist: config.search, |
| | |
| | | /** |
| | | * @description 子表数据加载 |
| | | */ |
| | | async loadmaindata (bid, type) { |
| | | const { setting } = this.state |
| | | async loadmaindata (type) { |
| | | const { setting, BID } = this.state |
| | | let param = '' |
| | | let _BID = this.props.BID |
| | | |
| | | if (type === 'refresh') { |
| | | _BID = bid |
| | | if (!bid) { // 主表ID不存在时,不查询子表 |
| | | if (!BID) { // 主表ID不存在时,不查询子表 |
| | | this.setState({ |
| | | data: [], |
| | | total: 0, |
| | |
| | | } |
| | | |
| | | if (setting.interType === 'system') { |
| | | param = this.getDefaultParam(_BID) |
| | | param = this.getDefaultParam(BID) |
| | | } else { |
| | | param = this.getCustomParam(_BID) |
| | | param = this.getCustomParam(BID) |
| | | } |
| | | |
| | | this.handleTableId() |
| | | |
| | | let result = await Api.genericInterface(param) |
| | | if (result.status) { |
| | |
| | | data: result.data.map((item, index) => { |
| | | item.key = index |
| | | item.$$uuid = item[setting.primaryKey] || '' |
| | | item.$$BID = _BID || '' |
| | | item.$$BID = BID || '' |
| | | return item |
| | | }), |
| | | total: result.total, |
| | |
| | | * 含有初始不加载的页面,修改设置 |
| | | */ |
| | | refreshbysearch = (searches) => { |
| | | MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid) // 列表重置 |
| | | MKEmitter.emit('resetTable', this.props.Tab.uuid) // 列表重置 |
| | | this.setState({ |
| | | loading: true, |
| | | pageIndex: 1, |
| | |
| | | * @description 表格刷新 |
| | | */ |
| | | reloadtable = () => { |
| | | MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid) // 列表重置 |
| | | MKEmitter.emit('resetTable', this.props.Tab.uuid) // 列表重置 |
| | | this.setState({ |
| | | loading: true, |
| | | pageIndex: 1, |
| | |
| | | } |
| | | |
| | | /** |
| | | * @description 表格Id变化 |
| | | */ |
| | | handleTableId = (type = this.props.Tab.uuid, id = '', data = '') => { |
| | | this.props.handleTableId(type, id, data) |
| | | } |
| | | |
| | | /** |
| | | * @description 数据展开合并切换 |
| | | */ |
| | | pickupChange = () => { |
| | |
| | | }) |
| | | } |
| | | |
| | | changeTableLine = (ContainerId, tableId, id, data) => { |
| | | const { Tab } = this.props |
| | | |
| | | if (tableId !== Tab.supMenu) return |
| | | |
| | | this.setState({BData: data, BID: id}) |
| | | |
| | | if (id !== this.state.BID) { |
| | | MKEmitter.emit('resetTable', this.props.Tab.uuid) // 列表重置 |
| | | this.setState({ |
| | | pageIndex: 1, |
| | | selectedData: [] |
| | | }, () => { |
| | | this.loadmaindata('refresh') |
| | | }) |
| | | } |
| | | } |
| | | |
| | | UNSAFE_componentWillMount() { |
| | | // 组件加载时,获取菜单数据 |
| | | this.loadconfig() |
| | | } |
| | | |
| | | componentDidMount () { |
| | | MKEmitter.addListener('changeTableLine', this.changeTableLine) |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { // handleMainTable 函数判断时不相等 |
| | | return !is(fromJS({...this.props, handleMainTable: '', handleTableId: ''}), fromJS({...nextProps, handleMainTable: '', handleTableId: ''})) || !is(fromJS(this.state), fromJS(nextState)) |
| | | return !is(fromJS(this.state), fromJS(nextState)) |
| | | } |
| | | |
| | | /** |
| | |
| | | this.setState = () => { |
| | | return |
| | | } |
| | | MKEmitter.removeListener('changeTableLine', this.changeTableLine) |
| | | } |
| | | |
| | | render() { |
| | | const { setting, searchlist, actions, columns, pickup, selectedData } = this.state |
| | | const { BID, BData, setting, searchlist, actions, columns, pickup, selectedData } = this.state |
| | | |
| | | return ( |
| | | <div className="verup-subtable" id={'subtable' + this.props.MenuID}> |
| | |
| | | <div className="sub-action"> |
| | | <SubAction |
| | | type="sub" |
| | | BID={BID} |
| | | BData={BData} |
| | | setting={setting} |
| | | actions={actions} |
| | | columns={columns} |
| | | Tab={this.props.Tab} |
| | | BID={this.props.BID} |
| | | BData={this.props.BData} |
| | | dict={this.state.dict} |
| | | selectedData={selectedData} |
| | | MenuID={this.props.SupMenuID} |
| | |
| | | loading={this.state.loading} |
| | | refreshdata={this.refreshbytable} |
| | | buttonTrigger={() => {}} |
| | | handleTableId={this.handleTableId} |
| | | chgSelectData={this.changeSelectedData} |
| | | /> |
| | | </div> : null |
| | |
| | | loading: false, |
| | | loadingNumber: '', |
| | | disabled: false, |
| | | checkParam: null |
| | | checkParam: null, |
| | | autoMatic: false |
| | | } |
| | | |
| | | moduleParams = null |
| | |
| | | } |
| | | |
| | | componentDidMount () { |
| | | const { position } = this.props |
| | | const { position, btn } = this.props |
| | | |
| | | MKEmitter.addListener('triggerBtnId', this.actionTrigger) |
| | | if (position === 'form') { |
| | | MKEmitter.addListener('triggerFormSubmit', this.actionSubmit) |
| | | } |
| | | MKEmitter.addListener('returnModuleParam', this.resetModuleParam) |
| | | |
| | | if (btn.autoMatic) { |
| | | MKEmitter.addListener('triggerBtnPopSubmit', this.triggerBtnPopSubmit) |
| | | } |
| | | } |
| | | |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | |
| | | MKEmitter.removeListener('triggerBtnId', this.actionTrigger) |
| | | MKEmitter.removeListener('triggerFormSubmit', this.actionSubmit) |
| | | MKEmitter.removeListener('returnModuleParam', this.resetModuleParam) |
| | | MKEmitter.removeListener('triggerBtnPopSubmit', this.triggerBtnPopSubmit) |
| | | } |
| | | |
| | | triggerBtnPopSubmit = (id) => { |
| | | const { btn } = this.props |
| | | |
| | | if (btn.uuid !== id) return |
| | | |
| | | this.handleOk() |
| | | } |
| | | |
| | | actionSubmit = (res) => { |
| | |
| | | return |
| | | } |
| | | } |
| | | |
| | | this.setState({autoMatic: type === 'autoMatic'}) |
| | | |
| | | let _this = this |
| | | let data = record || selectedData || [] |
| | |
| | | */ |
| | | execSuccess = (res) => { |
| | | const { btn } = this.props |
| | | const { btnconfig } = this.state |
| | | const { btnconfig, autoMatic } = this.state |
| | | |
| | | if (res && res.ErrCode === 'S') { // 执行成功 |
| | | if ((res && res.ErrCode === 'S') || autoMatic) { // 执行成功 |
| | | notification.success({ |
| | | top: 92, |
| | | message: res.ErrMesg || this.state.dict['main.action.confirm.success'], |
| | |
| | | |
| | | } |
| | | |
| | | if (btn.OpenType !== 'pop' || !btnconfig || btnconfig.setting.finish !== 'unclose') { |
| | | if (autoMatic) { |
| | | this.setState({ |
| | | loading: false, |
| | | visible: false |
| | | }) |
| | | MKEmitter.emit('autoExecOver', btn.uuid, 'success') |
| | | return |
| | | } else if (btn.OpenType !== 'pop' || !btnconfig || btnconfig.setting.finish !== 'unclose') { |
| | | this.setState({ |
| | | loading: false, |
| | | visible: false |
| | |
| | | */ |
| | | execError = (res) => { |
| | | const { btn } = this.props |
| | | const { btnconfig } = this.state |
| | | const { btnconfig, autoMatic } = this.state |
| | | |
| | | if (res.ErrCode === 'E') { |
| | | if (res.ErrCode === 'E' && !autoMatic) { |
| | | Modal.error({ |
| | | title: res.message || res.ErrMesg, |
| | | }) |
| | | } else if (res.ErrCode === 'N') { |
| | | } else if (res.ErrCode === 'N' || autoMatic) { |
| | | notification.error({ |
| | | top: 92, |
| | | message: res.message || res.ErrMesg, |
| | |
| | | }) |
| | | } else if (res.ErrCode === 'NM') { |
| | | message.error(res.message || res.ErrMesg) |
| | | } |
| | | |
| | | if (autoMatic) { |
| | | this.setState({ |
| | | loading: false, |
| | | loadingNumber: '', |
| | | visible: false |
| | | }) |
| | | MKEmitter.emit('autoExecOver', btn.uuid, 'error') |
| | | return |
| | | } |
| | | |
| | | this.setState({ |
| | |
| | | */ |
| | | improveAction = () => { |
| | | const { btn } = this.props |
| | | const { btnconfig } = this.state |
| | | const { btnconfig, autoMatic } = this.state |
| | | |
| | | if (btnconfig) { |
| | | if (btnconfig.setting.display === 'prompt') { // 如果表单以是否框展示 |
| | | if (!autoMatic && btnconfig.setting.display === 'prompt') { // 如果表单以是否框展示 |
| | | this.modelconfirm() |
| | | } else { |
| | | this.setState({ |
| | |
| | | this.setState({ |
| | | btnconfig: _LongParam |
| | | }, () => { |
| | | if (_LongParam.setting.display === 'prompt') { // 如果表单以是否框展示 |
| | | if (!autoMatic && _LongParam.setting.display === 'prompt') { // 如果表单以是否框展示 |
| | | this.modelconfirm() |
| | | } else { |
| | | this.setState({ |
| | |
| | | * @description 模态框(表单),确认 |
| | | */ |
| | | handleOk = () => { |
| | | if (!this.formRef) return |
| | | this.formRef.handleConfirm().then(res => { |
| | | this.setState({ confirmLoading: true }) |
| | | |
| | |
| | | btnconfig: null, |
| | | loading: false, |
| | | disabled: false, |
| | | loadingNumber: '' |
| | | loadingNumber: '', |
| | | autoMatic: false |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | |
| | | } |
| | | |
| | | componentDidMount () { |
| | | const { btn } = this.props |
| | | |
| | | MKEmitter.addListener('triggerBtnId', this.actionTrigger) |
| | | |
| | | if (btn.autoMatic) { |
| | | MKEmitter.addListener('triggerBtnPopSubmit', this.triggerBtnPopSubmit) |
| | | } |
| | | } |
| | | |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | |
| | | return |
| | | } |
| | | MKEmitter.removeListener('triggerBtnId', this.actionTrigger) |
| | | MKEmitter.removeListener('triggerBtnPopSubmit', this.triggerBtnPopSubmit) |
| | | } |
| | | |
| | | triggerBtnPopSubmit = (id) => { |
| | | const { btn } = this.props |
| | | |
| | | if (btn.uuid !== id) return |
| | | |
| | | this.handleOk() |
| | | } |
| | | |
| | | /** |
| | |
| | | return |
| | | } |
| | | } |
| | | |
| | | this.setState({autoMatic: type === 'autoMatic'}) |
| | | |
| | | let _this = this |
| | | let data = record || selectedData || [] |
| | |
| | | */ |
| | | execSuccess = (res) => { |
| | | const { btn } = this.props |
| | | const { autoMatic } = this.state |
| | | |
| | | if (res && res.ErrCode === 'S') { // 执行成功 |
| | | if ((res && res.ErrCode === 'S') || autoMatic) { // 执行成功 |
| | | notification.success({ |
| | | top: 92, |
| | | message: res.ErrMesg || this.state.dict['main.action.confirm.success'], |
| | |
| | | loading: false |
| | | }) |
| | | |
| | | if (autoMatic) { |
| | | MKEmitter.emit('autoExecOver', btn.uuid, 'success') |
| | | return |
| | | } |
| | | |
| | | if (btn.execSuccess !== 'never') { |
| | | MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execSuccess, btn) |
| | | } |
| | |
| | | */ |
| | | execError = (res) => { |
| | | const { btn } = this.props |
| | | const { btnconfig } = this.state |
| | | const { btnconfig, autoMatic } = this.state |
| | | |
| | | if (res.ErrCode === 'E') { |
| | | if (res.ErrCode === 'E' && !autoMatic) { |
| | | Modal.error({ |
| | | title: res.message || res.ErrMesg, |
| | | }) |
| | | } else if (res.ErrCode === 'N') { |
| | | } else if (res.ErrCode === 'N' || autoMatic) { |
| | | notification.error({ |
| | | top: 92, |
| | | message: res.message || res.ErrMesg, |
| | |
| | | this.setState({ |
| | | loading: false |
| | | }) |
| | | |
| | | if (autoMatic) { |
| | | MKEmitter.emit('autoExecOver', btn.uuid, 'error') |
| | | return |
| | | } |
| | | |
| | | if (btnconfig && btnconfig.setting && btnconfig.setting.errFocus) { |
| | | MKEmitter.emit('mkFC', 'focus', btnconfig.setting.errFocus) |
| | |
| | | */ |
| | | improveAction = () => { |
| | | const { btn } = this.props |
| | | const { btnconfig } = this.state |
| | | const { btnconfig, autoMatic } = this.state |
| | | |
| | | if (btnconfig) { |
| | | if (btnconfig.setting.display === 'prompt') { // 如果表单以是否框展示 |
| | | if (!autoMatic && btnconfig.setting.display === 'prompt') { // 如果表单以是否框展示 |
| | | this.modelconfirm() |
| | | } else { |
| | | this.setState({ |
| | |
| | | this.setState({ |
| | | btnconfig: _LongParam |
| | | }, () => { |
| | | if (_LongParam.setting.display === 'prompt') { // 如果表单以是否框展示 |
| | | if (!autoMatic && _LongParam.setting.display === 'prompt') { // 如果表单以是否框展示 |
| | | this.modelconfirm() |
| | | } else { |
| | | this.setState({ |
| | |
| | | * @description 模态框(表单),确认 |
| | | */ |
| | | handleOk = () => { |
| | | const { btnconfig } = this.state |
| | | const { btnconfig, autoMatic } = this.state |
| | | |
| | | if (!this.formRef) return |
| | | |
| | | this.formRef.handleConfirm().then(res => { |
| | | if (btnconfig.setting.finish !== 'unclose') { |
| | | if (btnconfig.setting.finish !== 'unclose' || autoMatic) { |
| | | this.setState({ |
| | | visible: false |
| | | }) |
| | |
| | | import { is, fromJS } from 'immutable' |
| | | import { Button } from 'antd' |
| | | |
| | | // import MKEmitter from '@/utils/events.js' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import './index.scss' |
| | | |
| | | class AutoMatic extends Component { |
| | |
| | | |
| | | state = { |
| | | running: false, |
| | | line: 0 |
| | | line: 1, |
| | | init: true |
| | | } |
| | | |
| | | timer = null |
| | | |
| | | componentDidMount () { |
| | | MKEmitter.addListener('autoGetData', this.autoGetData) |
| | | MKEmitter.addListener('autoExecOver', this.autoExecOver) |
| | | MKEmitter.addListener('autoMaticOver', this.autoMaticOver) |
| | | MKEmitter.addListener('autoMaticError', this.autoMaticError) |
| | | MKEmitter.addListener('autoTransSelectData', this.autoTransSelectData) |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | |
| | | this.setState = () => { |
| | | return |
| | | } |
| | | MKEmitter.removeListener('autoGetData', this.autoGetData) |
| | | MKEmitter.removeListener('autoExecOver', this.autoExecOver) |
| | | MKEmitter.removeListener('autoMaticOver', this.autoMaticOver) |
| | | MKEmitter.removeListener('autoMaticError', this.autoMaticError) |
| | | MKEmitter.removeListener('autoTransSelectData', this.autoTransSelectData) |
| | | } |
| | | |
| | | autoExecOver = (btnId, type) => { |
| | | const { autoMatic, config } = this.props |
| | | |
| | | if (!this.state.running || btnId !== autoMatic.action) return |
| | | |
| | | if (type === 'error') { |
| | | if (autoMatic.onFail === 'next') { |
| | | this.setState({line: this.state.line + 1}, () => { |
| | | setTimeout(() => { |
| | | MKEmitter.emit('autoQueryData', config.MenuID, this.state.line) |
| | | }, 1000) |
| | | }) |
| | | } else if (autoMatic.onFail === 'stay') { |
| | | setTimeout(() => { |
| | | MKEmitter.emit('autoQueryData', config.MenuID, this.state.line) |
| | | }, 1000) |
| | | } else { |
| | | this.setState({running: false}) |
| | | } |
| | | } else { |
| | | if (autoMatic.onSuccess === 'next') { |
| | | this.setState({line: this.state.line + 1}, () => { |
| | | setTimeout(() => { |
| | | MKEmitter.emit('autoQueryData', config.MenuID, this.state.line) |
| | | }, 1000) |
| | | }) |
| | | } else if (autoMatic.onSuccess === 'stay') { |
| | | setTimeout(() => { |
| | | MKEmitter.emit('autoQueryData', config.MenuID, this.state.line) |
| | | }, 1000) |
| | | } else { |
| | | this.setState({running: false}) |
| | | } |
| | | } |
| | | } |
| | | |
| | | autoTransSelectData = (MenuID, data) => { |
| | | const { config, autoMatic } = this.props |
| | | |
| | | if (!this.state.running || MenuID !== config.MenuID) return |
| | | |
| | | setTimeout(() => { |
| | | MKEmitter.emit('triggerBtnId', autoMatic.action, [data], 'autoMatic') |
| | | if (['prompt', 'pop'].includes(autoMatic.OpenType)) { |
| | | let delay = this.state.init && autoMatic.OpenType === 'pop' ? 2000 : 200 |
| | | |
| | | setTimeout(() => { |
| | | if (autoMatic.OpenType === 'prompt') { |
| | | let node = document.querySelector('.ant-modal-confirm-btns >.ant-btn-primary') |
| | | node && node.click() |
| | | } else if (autoMatic.OpenType === 'pop') { |
| | | MKEmitter.emit('triggerBtnPopSubmit', autoMatic.action) |
| | | } |
| | | }, delay) |
| | | } |
| | | }, 100) |
| | | } |
| | | |
| | | autoMaticError = (MenuID) => { |
| | | const { config } = this.props |
| | | |
| | | if (!this.state.running || MenuID !== config.MenuID) return |
| | | |
| | | this.setState({running: false}) |
| | | } |
| | | |
| | | autoGetData = (MenuID) => { |
| | | const { config } = this.props |
| | | |
| | | if (!this.state.running || MenuID !== config.MenuID) return |
| | | setTimeout(() => { |
| | | MKEmitter.emit('autoSelectData', config.MenuID, this.state.line) |
| | | }, 100) |
| | | } |
| | | |
| | | trigger = () => { |
| | | // const { config } = this.props |
| | | const { config } = this.props |
| | | let running = !this.state.running |
| | | |
| | | // MKEmitter.emit('autoQueryData', config.MenuID, 0) |
| | | MKEmitter.emit('autoQueryData', config.MenuID, 1) |
| | | |
| | | this.setState({running: running}) |
| | | this.setState({running: running, line: 1}) |
| | | clearTimeout(this.timer) |
| | | } |
| | | |
| | | autoMaticOver = (MenuID) => { |
| | | const { config, autoMatic } = this.props |
| | | |
| | | if (!this.state.running || MenuID !== config.MenuID) return |
| | | |
| | | this.setState({running: false}) |
| | | |
| | | if (autoMatic.onFinish !== 'over') { |
| | | let interval = autoMatic.interval * 1000 || 10 |
| | | |
| | | if (autoMatic.restart === 'first') { |
| | | this.setState({line: 1}) |
| | | } else { |
| | | this.setState({line: this.state.line + 1}) |
| | | } |
| | | |
| | | this.timer = setTimeout(() => { |
| | | this.setState({running: true}) |
| | | MKEmitter.emit('autoQueryData', config.MenuID, this.state.line) |
| | | }, interval) |
| | | } |
| | | } |
| | | |
| | | render() { |
| | |
| | | |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import asyncExcelComponent from './asyncButtonComponent' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import '@/assets/css/table.scss' |
| | | import './index.scss' |
| | | |
| | |
| | | tableId: PropTypes.string, |
| | | loading: PropTypes.bool, |
| | | data: PropTypes.array, |
| | | handleTableId: PropTypes.func |
| | | } |
| | | |
| | | state = { |
| | |
| | | |
| | | this.setState({selectKey: data.key}) |
| | | |
| | | this.props.handleTableId(this.props.tableId, _id, data) |
| | | MKEmitter.emit('changeTableLine', this.props.ContainerId, this.props.tableId, _id, data) |
| | | } |
| | | |
| | | render() { |
| | |
| | | total: PropTypes.any, // 总数 |
| | | loading: PropTypes.bool, // 表格加载中 |
| | | refreshdata: PropTypes.func, // 表格中排序列、页码的变化时刷新 |
| | | handleTableId: PropTypes.func, // 数据切换 |
| | | chgSelectData: PropTypes.func, // 数据切换 |
| | | } |
| | | |
| | |
| | | |
| | | componentDidMount () { |
| | | MKEmitter.addListener('resetTable', this.resetTable) |
| | | MKEmitter.addListener('autoQueryData', this.autoQueryData) |
| | | MKEmitter.addListener('autoSelectData', this.autoSelectData) |
| | | MKEmitter.addListener('mkTableCheckTopLine', this.mkTableCheckTopLine) |
| | | } |
| | | |
| | |
| | | return |
| | | } |
| | | MKEmitter.removeListener('resetTable', this.resetTable) |
| | | MKEmitter.removeListener('autoQueryData', this.autoQueryData) |
| | | MKEmitter.removeListener('autoSelectData', this.autoSelectData) |
| | | MKEmitter.removeListener('mkTableCheckTopLine', this.mkTableCheckTopLine) |
| | | } |
| | | |
| | |
| | | if (this.props.data.length > 0) { |
| | | this.changeRow(null, 0) |
| | | } |
| | | } |
| | | |
| | | autoSelectData = (id, index) => { |
| | | if (id !== this.props.MenuID) return |
| | | |
| | | const { pageSize, pageIndex } = this.state |
| | | |
| | | let i = index - (pageIndex - 1) * pageSize - 1 |
| | | |
| | | if (this.props.data[i]) { |
| | | this.changeRow(null, i) |
| | | MKEmitter.emit('autoTransSelectData', this.props.MenuID, this.props.data[i]) |
| | | } else { |
| | | MKEmitter.emit('autoMaticOver', this.props.MenuID) |
| | | } |
| | | } |
| | | |
| | | autoQueryData = (id, index) => { |
| | | if (id !== this.props.MenuID) return |
| | | |
| | | const { total } = this.props |
| | | const { pageSize } = this.state |
| | | |
| | | if (index !== 1 && (!total || index > total)) { |
| | | MKEmitter.emit('autoMaticOver', this.props.MenuID) |
| | | return |
| | | } |
| | | |
| | | let pageIndex = Math.ceil(index / pageSize) |
| | | |
| | | this.setState({ |
| | | pageIndex: pageIndex, |
| | | selectedRowKeys: [], |
| | | activeIndex: null |
| | | }) |
| | | |
| | | this.props.refreshdata({pageIndex}) |
| | | } |
| | | |
| | | // 字段透视 |
| | |
| | | } |
| | | |
| | | changedata = (index) => { |
| | | const { data, setting } = this.props |
| | | const { data, setting, tableId, ContainerId } = this.props |
| | | |
| | | if (!tableId || !ContainerId) return |
| | | |
| | | let _id = '' |
| | | let _data = '' |
| | |
| | | _data = data[index] || '' |
| | | } |
| | | |
| | | this.props.handleTableId(this.props.tableId, _id, _data) |
| | | MKEmitter.emit('changeTableLine', ContainerId, tableId, _id, _data) |
| | | } |
| | | |
| | | resetTable = (id, repage) => { |
| | | const { MenuID, tableId } = this.props |
| | | const { tableId } = this.props |
| | | |
| | | if (id !== (MenuID + tableId)) return |
| | | if (id !== tableId) return |
| | | |
| | | if (repage === 'false') { |
| | | this.setState({ |
| | |
| | | |
| | | return config |
| | | } |
| | | |
| | | /** |
| | | * @description 升级弹窗子表信息 |
| | | * @param {Object} config 页面配置信息 |
| | | * @return {Object} config |
| | | */ |
| | | export function updateSubTabTable (config) { |
| | | if (!config.version || config.version < '1.1') { |
| | | config.version = '1.1' |
| | | if (config.setting.interType === 'inner' && !config.setting.innerFunc) { |
| | | config.setting.interType = 'system' |
| | | } |
| | | // 兼容接口类型 |
| | | config.action = config.action.map(item => { |
| | | if (item.intertype === 'inner' && !item.innerFunc) { |
| | | item.intertype = 'system' |
| | | } |
| | | return item |
| | | }) |
| | | } |
| | | |
| | | if (config.version < '1.2') { |
| | | config.version = '1.2' |
| | | // 兼容功能按钮 |
| | | config.action = config.action.map(item => { |
| | | if (item.execMode) { |
| | | item.OpenType = 'funcbutton' |
| | | } else if (item.OpenType === 'blank') { |
| | | item.OpenType = 'tab' |
| | | } |
| | | return item |
| | | }) |
| | | } |
| | | |
| | | config.Template = 'SubTable' |
| | | |
| | | return config |
| | | } |