| | |
| | | import { is, fromJS } from 'immutable' |
| | | import { notification, Spin, Modal, Button, Switch} from 'antd' |
| | | import moment from 'moment' |
| | | |
| | | import Api from '@/api' |
| | | import SubTable from './subTable' |
| | | import SubAction from '@/tabviews/tableshare/actionList' |
| | | import SubSearch from '@/tabviews/tableshare/topSearch' |
| | | import asyncComponent from '@/utils/asyncLoadComponent' |
| | | import NotFount from '@/components/404' |
| | | import zhCN from '@/locales/zh-CN/main.js' |
| | | import enUS from '@/locales/en-US/main.js' |
| | | import Utils from '@/utils/utils.js' |
| | | import options from '@/store/options.js' |
| | | import { modifyTabview } from '@/store/action' |
| | | |
| | | import SubTable from '@/tabviews/zshare/normalTable' |
| | | import SubSearch from '@/tabviews/zshare/topSearch' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import asyncLoadComponent from '@/utils/asyncLoadComponent' |
| | | import NotFount from '@/components/404' |
| | | |
| | | import './index.scss' |
| | | |
| | | const SubTabTable = asyncComponent(() => import('@/tabviews/subtabtable')) |
| | | const SubAction = asyncComponent(() => import('@/tabviews/zshare/actionList')) |
| | | const SubTabTable = asyncLoadComponent(() => import('@/tabviews/subtabtable')) |
| | | |
| | | class SubTabViewTable extends Component { |
| | | static propTpyes = { |
| | |
| | | BData: PropTypes.any, // 上级数据 |
| | | MenuID: PropTypes.string, // 菜单Id |
| | | SupMenuID: PropTypes.string, // 上级菜单Id |
| | | mainSearch: PropTypes.any, // 主表搜索条件 |
| | | ContainerId: PropTypes.any, // 三级菜单Container(html) ID |
| | | handleTableId: PropTypes.func, // 控制表格数据切换时,更新在主表中的id |
| | | handleMainTable: PropTypes.func, // 刷新主表 |
| | | refreshtabs:PropTypes.any |
| | | refreshtabs: PropTypes.any, // 标签刷新控制 |
| | | userConfig: PropTypes.any, // 用户自定义设置 |
| | | triggerBtn: PropTypes.any // 快捷键或点击行按钮触发事件 |
| | | } |
| | | |
| | | state = { |
| | |
| | | pageSize: 10, // 每页数据条数 |
| | | orderBy: '', // 排序 |
| | | search: '', // 搜索条件数组,使用时需分场景处理 |
| | | configMap: {}, // 页面配置信息:下拉、按钮等 |
| | | popAction: false, // 弹框页面,按钮信息 |
| | | popData: false, // 弹框页面,所选的表格数据 |
| | | visible: false, // 弹框显示隐藏控制 |
| | | pickup: false, // 子表数据隐藏显示切换 |
| | | pickup: false, // 子表数据隐藏显示切换 |
| | | triggerBtn: null // 按钮触发 |
| | | } |
| | | |
| | | /** |
| | |
| | | this.loadmaindata(nextProps.BID, 'refresh') |
| | | } else if (this.state.config && nextProps.refreshtabs && nextProps.refreshtabs.includes(this.props.Tab.uuid)) { |
| | | this.reloadtable() |
| | | } else if (nextProps.triggerBtn && !is(fromJS(this.props.triggerBtn), fromJS(nextProps.triggerBtn)) && nextProps.triggerBtn.parentId === this.props.Tab.uuid) { |
| | | let trigger = nextProps.triggerBtn |
| | | |
| | | trigger.parentId = this.props.MenuID |
| | | |
| | | this.setState({ |
| | | triggerBtn: trigger |
| | | }) |
| | | } else if (!this.props.Tab.supMenu && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { |
| | | this.setState({}, () => { |
| | | this.loadmaindata() |
| | | }) |
| | | } |
| | | } |
| | | |
| | |
| | | * @description 获取页面配置信息 |
| | | */ |
| | | async loadconfig () { |
| | | const { permAction, Tab, BID } = this.props |
| | | const { permAction, permMenus, Tab, BID, userConfig } = this.props |
| | | |
| | | let param = { |
| | | func: 'sPC_Get_LongParam', |
| | |
| | | // 权限过滤 |
| | | if (this.props.menuType !== 'HS') { |
| | | config.action = config.action.filter(item => permAction[item.uuid]) |
| | | |
| | | // 字段权限黑名单 |
| | | config.search = config.search.filter(item => { |
| | | if (!item.blacklist || item.blacklist.length === 0) return true |
| | | |
| | | let _black = item.blacklist.filter(v => { |
| | | return this.props.permRoles.indexOf(v) !== -1 |
| | | }) |
| | | |
| | | if (_black.length > 0) { |
| | | return false |
| | | } else { |
| | | return true |
| | | } |
| | | }) |
| | | |
| | | config.columns = config.columns.filter(col => { |
| | | if (!col.field || !col.blacklist || col.blacklist.length === 0 || config.setting.primaryKey === col.field) return true |
| | | |
| | | let _black = col.blacklist.filter(v => { |
| | | return this.props.permRoles.indexOf(v) !== -1 |
| | | }) |
| | | |
| | | if (_black.length > 0) { |
| | | return false |
| | | } else { |
| | | return true |
| | | } |
| | | }) |
| | | } |
| | | |
| | | if (userConfig) { |
| | | config.setting.tableType = userConfig.setting.tableType |
| | | |
| | | config.action = config.action.map(item => { |
| | | if (userConfig.action[item.uuid]) { |
| | | delete userConfig.action[item.uuid].label |
| | | item = {...item, ...userConfig.action[item.uuid]} |
| | | } |
| | | |
| | | if (item.execMode) { |
| | | item.OpenType = 'funcbutton' |
| | | } |
| | | |
| | | if (item.OpenType === 'funcbutton' && item.funcType === 'print' && item.verify && item.printer) { |
| | | item.verify.defaultPrinter = item.printer.defaultPrinter || '' |
| | | if (item.verify.printerTypeList && item.printer.printerList) { |
| | | item.verify.printerTypeList = item.verify.printerTypeList.map(cell => { |
| | | cell.printer = item.printer.printerList[cell.Value] || '' |
| | | |
| | | return cell |
| | | }) |
| | | } |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | } |
| | | |
| | | // 1、筛选字段集,2、过滤隐藏列及合并列中的字段uuid |
| | |
| | | }) |
| | | |
| | | // 生成显示列,处理合并列中的字段 |
| | | config.columns.forEach(col => { |
| | | config.columns.forEach((col, index) => { |
| | | if (_hideCol.includes(col.uuid)) return |
| | | |
| | | if (col.linkThdMenu && !permMenus[col.linkThdMenu.MenuID]) { |
| | | col.linkThdMenu = '' |
| | | } |
| | | |
| | | col.sort = index |
| | | |
| | | if (col.type === 'colspan' && col.sublist) { |
| | | let _col = JSON.parse(JSON.stringify(col)) |
| | |
| | | }) |
| | | } |
| | | |
| | | let valid = true // 搜索条件必填验证 |
| | | config.search.forEach(field => { |
| | | if (field.required === 'true' && !field.initval) { |
| | | valid = false |
| | | } |
| | | }) |
| | | |
| | | // 添加用户显示列设置 |
| | | if (userConfig) { |
| | | _columns = _columns.map(item => { |
| | | if (userConfig.columns[item.uuid]) { |
| | | delete userConfig.columns[item.uuid].label |
| | | item = {...item, ...userConfig.columns[item.uuid]} |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | |
| | | _columns.sort((pre, next) => { |
| | | return pre.sort - next.sort |
| | | }) |
| | | } |
| | | |
| | | this.setState({ |
| | | loadingview: false, |
| | | config: config, |
| | |
| | | }, () => { |
| | | this.improveSearch() |
| | | |
| | | if (config.setting.onload !== 'false' && (!Tab.supMenu || BID)) { // 初始化可加载 |
| | | this.setState({ |
| | | loading: true |
| | | }) |
| | | if (config.setting.onload !== 'false' && (!Tab.supMenu || BID) && valid) { // 初始化可加载 |
| | | this.loadmaindata() |
| | | } |
| | | }) |
| | |
| | | loadingview: false, |
| | | viewlost: true |
| | | }) |
| | | let prex = Tab && Tab.label ? Tab.label + ': ' : '' |
| | | |
| | | notification.warning({ |
| | | top: 92, |
| | | message: result.message, |
| | | duration: 10 |
| | | message: prex + result.message, |
| | | duration: 5 |
| | | }) |
| | | } |
| | | } |
| | |
| | | }) |
| | | deffers.push(defer) |
| | | } else if (item.resourceType === '1' && !item.dataSource) { |
| | | let prex = this.props.Tab && this.props.Tab.label ? this.props.Tab.label + '-' : '' |
| | | |
| | | notification.warning({ |
| | | top: 92, |
| | | message: item.label + ': ' + this.state.dict['main.datasource.settingerror'], |
| | | duration: 10 |
| | | message: prex + item.label + ': ' + this.state.dict['main.datasource.settingerror'], |
| | | duration: 5 |
| | | }) |
| | | } |
| | | }) |
| | |
| | | return item |
| | | }) |
| | | } else { |
| | | let prex = this.props.Tab && this.props.Tab.label ? this.props.Tab.label + '-' : '' |
| | | |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.search.label + ':' + res.message, |
| | | duration: 10 |
| | | message: prex + res.search.label + ':' + res.message, |
| | | duration: 5 |
| | | }) |
| | | } |
| | | }) |
| | |
| | | * @description 子表数据加载 |
| | | */ |
| | | async loadmaindata (bid, type) { |
| | | const { setting } = this.state |
| | | const { setting, search } = this.state |
| | | let param = '' |
| | | let _BID = this.props.BID |
| | | |
| | | let requireFields = search.filter(item => item.required && !item.value) |
| | | |
| | | if (requireFields.length > 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: this.state.dict['form.required.input'] + requireFields.map(item => item.label).join('、') + ' !', |
| | | duration: 3 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | this.setState({ |
| | | loading: true |
| | | }) |
| | | |
| | | if (type === 'refresh') { |
| | | _BID = bid |
| | |
| | | this.setState({ |
| | | loading: false |
| | | }) |
| | | let prex = this.props.Tab && this.props.Tab.label ? this.props.Tab.label + ': ' : '' |
| | | |
| | | notification.error({ |
| | | top: 92, |
| | | message: result.message, |
| | | duration: 15 |
| | | message: prex + result.message, |
| | | duration: 10 |
| | | }) |
| | | } |
| | | } |
| | |
| | | * @description 获取用户自定义存储过程传参 |
| | | */ |
| | | getCustomParam = (BID) => { |
| | | const { mainSearch } = this.props |
| | | const { pageIndex, pageSize, orderBy, search, setting } = this.state |
| | | |
| | | let _search = Utils.formatCustomMainSearch(search) |
| | | let searches = search |
| | | if (mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | searches = [...mainSearch, ...search] |
| | | } |
| | | |
| | | let _search = Utils.formatCustomMainSearch(searches) |
| | | |
| | | let param = { |
| | | PageIndex: pageIndex, |
| | |
| | | param.rduri = setting.interface |
| | | } |
| | | } else { |
| | | if (setting.sysInterface === 'true') { |
| | | param.rduri = window.GLOB.mainSystemApi || window.GLOB.subSystemApi |
| | | } else { |
| | | if (setting.sysInterface === 'true' && window.GLOB.mainSystemApi) { |
| | | param.rduri = window.GLOB.mainSystemApi |
| | | } else if (setting.sysInterface !== 'true') { |
| | | param.rduri = setting.interface |
| | | } |
| | | } |
| | | |
| | | param.appkey = window.GLOB.appkey || '' // 调用外部接口增加appkey |
| | | |
| | | if (setting.outerFunc) { |
| | | param.func = setting.outerFunc |
| | |
| | | * @description 获取系统存储过程 sPC_Get_TableData 的参数 |
| | | */ |
| | | getDefaultParam = (BID) => { |
| | | const { mainSearch } = this.props |
| | | const { arr_field, pageIndex, pageSize, orderBy, search, setting } = this.state |
| | | |
| | | let _search = Utils.joinMainSearchkey(search) |
| | | let searches = search |
| | | if (mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | searches = [...mainSearch, ...search] |
| | | } |
| | | |
| | | let _search = Utils.joinMainSearchkey(searches) |
| | | _search = _search ? 'where ' + _search : '' |
| | | |
| | | let param = { |
| | | func: 'sPC_Get_TableData', |
| | | obj_name: 'data', |
| | | arr_field: arr_field, |
| | | BID: BID, |
| | | appkey: window.GLOB.appkey || '' |
| | | BID: BID |
| | | } |
| | | |
| | | let _orderBy = orderBy || setting.order |
| | |
| | | fieldmap.set(item.key, true) |
| | | |
| | | return { |
| | | reg: new RegExp('@' + _field, 'ig'), |
| | | reg: new RegExp('@' + _field + '@', 'ig'), |
| | | value: item.value |
| | | } |
| | | }) |
| | | |
| | | options.reverse() |
| | | // options.reverse() |
| | | |
| | | options.forEach(item => { |
| | | _dataresource = _dataresource.replace(item.reg, `'${item.value}'`) |
| | |
| | | this.refs.subTable.resetTable() |
| | | |
| | | this.setState({ |
| | | loading: true, |
| | | pageIndex: 1, |
| | | search: searches |
| | | }, () => { |
| | |
| | | } |
| | | |
| | | this.setState({ |
| | | loading: true, |
| | | pageIndex: pagination.current, |
| | | pageSize: pagination.pageSize, |
| | | orderBy: (sorter.field && sorter.order) ? `${sorter.field} ${sorter.order}` : '' |
| | |
| | | reloadtable = () => { |
| | | this.refs.subTable.resetTable() |
| | | this.setState({ |
| | | loading: true, |
| | | pageIndex: 1 |
| | | }, () => { |
| | | this.loadmaindata() |
| | |
| | | pageSize: 10, |
| | | orderBy: '', |
| | | search: '', |
| | | configMap: {} |
| | | triggerBtn: null |
| | | }, () => { |
| | | this.loadconfig() |
| | | }) |
| | |
| | | * @description 导出Excel时,获取页面搜索排序等参数 |
| | | */ |
| | | getexceloutparam = () => { |
| | | const { Tab } = this.props |
| | | const { Tab, mainSearch } = this.props |
| | | const { arr_field, orderBy, search, setting} = this.state |
| | | |
| | | let searches = search |
| | | if (mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | searches = [...mainSearch, ...search] |
| | | } |
| | | |
| | | return { |
| | | arr_field: arr_field, |
| | | orderBy: orderBy || setting.order, |
| | | search: search, |
| | | search: searches, |
| | | menuName: Tab.label |
| | | } |
| | | } |
| | |
| | | * @description 表格中,按钮触发事件传递 |
| | | */ |
| | | buttonTrigger = (btn, record) => { |
| | | this.refs.subButton.actionTrigger(btn, record) |
| | | this.setState({ |
| | | triggerBtn: { |
| | | uuid: new Date().getTime(), |
| | | parentId: this.props.MenuID, |
| | | button: btn, |
| | | data: record |
| | | } |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 表格Id变化 |
| | | */ |
| | | handleTableId = (id = '', data = '') => { |
| | | this.props.handleTableId(this.props.Tab.uuid, id, data) |
| | | handleTableId = (type = this.props.Tab.uuid, id = '', data = '') => { |
| | | this.props.handleTableId(type, id, data) |
| | | } |
| | | |
| | | /** |
| | |
| | | this.setState({ |
| | | pickup: !pickup |
| | | }) |
| | | } |
| | | |
| | | linkTrigger = (menu) => { |
| | | const { tabviews, SupMenuID } = this.props |
| | | |
| | | menu.selected = true |
| | | |
| | | let index = 0 |
| | | let isexit = false |
| | | let tabs = tabviews.map((tab, i) => { |
| | | tab.selected = false |
| | | |
| | | if (tab.MenuID === SupMenuID) { |
| | | index = i |
| | | } else if (tab.MenuID === menu.MenuID) { |
| | | tab.param = menu.param |
| | | tab.selected = true |
| | | isexit = true |
| | | } |
| | | |
| | | return tab |
| | | }) |
| | | |
| | | if (!isexit) { |
| | | tabs.splice(index + 1, 0, menu) |
| | | } |
| | | |
| | | this.props.modifyTabview(tabs) |
| | | } |
| | | |
| | | popclose = () => { |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { setting, searchlist, actions, columns, loadingview, viewlost, pickup } = this.state |
| | | const { setting, searchlist, actions, columns, loadingview, viewlost, pickup, triggerBtn } = this.state |
| | | |
| | | return ( |
| | | <div className="subtable" id={'subtable' + this.props.MenuID}> |
| | |
| | | dict={this.state.dict} |
| | | /> : null |
| | | } |
| | | {actions && |
| | | <SubAction |
| | | ref="subButton" |
| | | type="sub" |
| | | menuType={this.props.menuType} |
| | | setting={setting} |
| | | actions={actions} |
| | | Tab={this.props.Tab} |
| | | BID={this.props.BID} |
| | | BData={this.props.BData} |
| | | dict={this.state.dict} |
| | | MenuID={this.props.SupMenuID} |
| | | logcolumns={this.state.logcolumns} |
| | | ContainerId={this.props.ContainerId} |
| | | refreshdata={this.refreshbyaction} |
| | | triggerPopview={this.triggerPopview} |
| | | getexceloutparam={this.getexceloutparam} |
| | | gettableselected={this.gettableselected} |
| | | /> |
| | | {actions ? |
| | | <div className="sub-action"> |
| | | <SubAction |
| | | type="sub" |
| | | menuType={this.props.menuType} |
| | | triggerBtn={triggerBtn} |
| | | setting={setting} |
| | | actions={actions} |
| | | Tab={this.props.Tab} |
| | | BID={this.props.BID} |
| | | BData={this.props.BData} |
| | | dict={this.state.dict} |
| | | MenuID={this.props.MenuID} |
| | | permRoles={this.props.permRoles} |
| | | logcolumns={this.state.logcolumns} |
| | | refreshdata={this.refreshbyaction} |
| | | ContainerId={this.props.ContainerId} |
| | | triggerPopview={this.triggerPopview} |
| | | getexceloutparam={this.getexceloutparam} |
| | | gettableselected={this.gettableselected} |
| | | /> |
| | | </div> : null |
| | | } |
| | | {columns ? |
| | | <div className="subtable-box"> |
| | |
| | | } |
| | | <SubTable |
| | | ref="subTable" |
| | | menuType={this.props.menuType} |
| | | tableId={this.props.Tab.uuid} |
| | | pickup={pickup} |
| | | setting={setting} |
| | | columns={columns} |
| | |
| | | loading={this.state.loading} |
| | | refreshdata={this.refreshbytable} |
| | | buttonTrigger={this.buttonTrigger} |
| | | linkTrigger={this.linkTrigger} |
| | | handleTableId={this.handleTableId} |
| | | /> |
| | | </div> : null |
| | |
| | | |
| | | const mapStateToProps = (state) => { |
| | | return { |
| | | permAction: state.permAction |
| | | tabviews: state.tabviews, |
| | | permAction: state.permAction, |
| | | permRoles: state.permRoles, |
| | | permMenus: state.permMenus |
| | | } |
| | | } |
| | | |
| | | const mapDispatchToProps = () => { |
| | | return {} |
| | | const mapDispatchToProps = (dispatch) => { |
| | | return { |
| | | modifyTabview: (tabviews) => dispatch(modifyTabview(tabviews)) |
| | | } |
| | | } |
| | | |
| | | export default connect(mapStateToProps, mapDispatchToProps)(SubTabViewTable) |