| | |
| | | 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 = { |
| | |
| | | BID: PropTypes.string, // 上级数据ID |
| | | BData: PropTypes.any, // 上级数据 |
| | | MenuID: PropTypes.string, // 菜单Id |
| | | mainSearch: PropTypes.any, // 主表搜索条件 |
| | | SupMenuID: PropTypes.string, // 上级菜单Id |
| | | } |
| | | |
| | |
| | | searchlist: null, // 搜索条件 |
| | | actions: null, // 按钮集 |
| | | columns: null, // 显示列 |
| | | arr_field: '', // 使用 sPC_Get_TableData 时的查询字段集 |
| | | arr_field: '', // 查询字段集 |
| | | setting: null, // 页面全局设置:数据源、按钮及显示列固定、主键等 |
| | | data: [], // 列表数据集 |
| | | selectedData: [], // 已选表格数据 |
| | |
| | | pageSize: 10, // 每页数据条数 |
| | | orderBy: '', // 排序 |
| | | search: '', // 搜索条件数组,使用时需分场景处理 |
| | | chartId: '', // 展开图表ID |
| | | statFields: [], // 合计字段 |
| | | statFValue: [], // 合计值 |
| | | absFields: [], // 绝对值字段 |
| | |
| | | try { // 配置信息解析 |
| | | config = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) |
| | | config.setting.MenuName = Tab.label |
| | | config.setting.$name = Tab.label |
| | | } catch (e) { |
| | | console.warn('Parse Failure') |
| | | config = '' |
| | |
| | | let absFields = [] // 绝对值字段 |
| | | |
| | | // 版本兼容 |
| | | config = updateSubTable(config) |
| | | config = updateSubTabTable(config) |
| | | |
| | | // 不支持funcbutton、popview 类型按钮 |
| | | let labels = [] |
| | |
| | | } |
| | | |
| | | // 权限过滤 |
| | | if (this.props.menuType !== 'HS') { |
| | | config.action = config.action.filter(item => permAction[item.uuid]) |
| | | if (!window.GLOB.mkHS) { |
| | | config.action = config.action.filter(item => item.hidden !== 'true' && permAction[item.uuid]) |
| | | } else { |
| | | config.action = config.action.filter(item => item.hidden !== 'true') |
| | | } |
| | | |
| | | config.search = Utils.initSearchVal(config.search) |
| | |
| | | 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 => { |
| | | if (col.field) { |
| | | _arrField.push(col.field) |
| | | |
| | | if (col.type === 'number') { |
| | | col.decimal = col.decimal || 0 |
| | | col.round = Math.pow(10, col.decimal) |
| | | |
| | | if (col.format === 'percent') { |
| | | col.decimal = col.decimal > 2 ? col.decimal - 2 : 0 |
| | | } |
| | | } |
| | | |
| | | col.nameField && _arrField.push(col.nameField) // 链接名字段 |
| | | if (col.Hide !== 'true' && col.type === 'number' && col.sum === 'true') { |
| | |
| | | item.$menuId = this.props.MenuID |
| | | |
| | | if (item.position === 'toolbar') { |
| | | item.$toolbtn = true |
| | | _actions.push(item) |
| | | } else if (item.position === 'grid') { |
| | | _operations.push(item) |
| | |
| | | |
| | | let userName = sessionStorage.getItem('User_Name') || '' |
| | | let fullName = sessionStorage.getItem('Full_Name') || '' |
| | | let city = sessionStorage.getItem('city') || '' |
| | | |
| | | if (sessionStorage.getItem('isEditState') === 'true') { |
| | | userName = sessionStorage.getItem('CloudUserName') || '' |
| | |
| | | |
| | | let regs = [ |
| | | { reg: /@userName@/ig, value: `'${userName}'` }, |
| | | { reg: /@fullName@/ig, value: `'${fullName}'` }, |
| | | { reg: /@login_city@/ig, value: `'${city}'` } |
| | | { reg: /@fullName@/ig, value: `'${fullName}'` } |
| | | ] |
| | | |
| | | regs.forEach(cell => { |
| | |
| | | }) |
| | | } |
| | | |
| | | if (config.setting.selected !== 'init' && config.setting.selected !== 'always') { |
| | | config.setting.selected = 'false' |
| | | } else if (config.setting.selected === 'init' && config.setting.onload === 'false') { |
| | | config.setting.selected = 'false' |
| | | } else { |
| | | config.setting.orisel = true |
| | | } |
| | | |
| | | if (config.setting.controlField) { |
| | | if (config.setting.controlVal) { |
| | | config.setting.controlVal = config.setting.controlVal.split(',') |
| | | } else { |
| | | config.setting.controlVal = [''] |
| | | } |
| | | } |
| | | |
| | | this.setState({ |
| | | pageSize: config.setting.pageSize || 10, |
| | | loadingview: false, |
| | | chartId, |
| | | config, |
| | | absFields, |
| | | statFields, |
| | |
| | | } |
| | | } |
| | | |
| | | loadData = () => { |
| | | const { mainSearch } = this.props |
| | | loadData = (id) => { |
| | | const { setting, search, hasReqFields, loadCustomApi } = this.state |
| | | |
| | | let searches = fromJS(search).toJS() |
| | | if (mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | searches = [...mainSearch, ...searches] |
| | | } |
| | | |
| | | if (hasReqFields) { |
| | | let requireFields = searches.filter(item => item.required && item.value === '') |
| | |
| | | |
| | | this.loadOutResource(searches) |
| | | if (setting.execType === 'async') { |
| | | this.loadmaindata() |
| | | this.loadmaindata(id) |
| | | } |
| | | } else { |
| | | this.loadmaindata() |
| | | this.loadmaindata(id) |
| | | } |
| | | } |
| | | |
| | | loadOutResource = (searches) => { |
| | | const { setting } = this.state |
| | | |
| | | let param = UtilsDM.getPrevQueryParams(setting, searches, this.props.BID, this.props.menuType) |
| | | let param = UtilsDM.getPrevQueryParams(setting, searches, this.props.BID) |
| | | |
| | | if (setting.execType === 'sync') { |
| | | this.setState({ |
| | |
| | | `)) |
| | | sql = sql.join('') |
| | | |
| | | param = UtilsDM.getCallBackQueryParams(setting, sql, errSql) |
| | | |
| | | if (this.state.BID) { |
| | | param.BID = this.state.BID |
| | | } |
| | | |
| | | if (this.props.menuType === 'HS') { // 函数 sPC_TableData_InUpDe 云端验证 |
| | | param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) |
| | | } |
| | | param = UtilsDM.getCallBackQueryParams(setting, sql, errSql, this.props.BID) |
| | | } else { |
| | | let name = this.props.Tab ? (this.props.Tab.label || '') : '' |
| | | param.func = 's_ex_result_back' |
| | |
| | | Sort: index + 1 |
| | | })) |
| | | |
| | | if ((window.GLOB.systemType !== 'production' && options.sysType !== 'cloud') || window.debugger === true) { |
| | | if (window.GLOB.debugger === true || (window.debugger === true && options.sysType !== 'cloud')) { |
| | | let sql = lines.map(item => (` |
| | | ${item.insert} |
| | | ${item.selects.join(` union all |
| | |
| | | /** |
| | | * @description 子表数据加载 |
| | | */ |
| | | async loadmaindata () { |
| | | const { mainSearch, BID } = this.props |
| | | async loadmaindata (id) { |
| | | const { BID } = this.props |
| | | const { setting, arr_field, search, orderBy, pageIndex, pageSize, absFields } = this.state |
| | | |
| | | let searches = fromJS(search).toJS() |
| | | if (mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | searches = [...mainSearch, ...searches] |
| | | } |
| | | |
| | | this.setState({ |
| | | loading: true |
| | | }) |
| | | |
| | | let _orderBy = orderBy || setting.order |
| | | let param = UtilsDM.getQueryDataParams(setting, arr_field, searches, _orderBy, pageIndex, pageSize, BID, this.props.menuType) |
| | | |
| | | if (param.func === 'sPC_Get_TableData') { |
| | | param.menuname = this.props.Tab.label || '' |
| | | } |
| | | let param = UtilsDM.getQueryDataParams(setting, arr_field, searches, _orderBy, pageIndex, pageSize, BID) |
| | | |
| | | let result = await Api.genericInterface(param) |
| | | |
| | |
| | | let start = 1 |
| | | if (setting.laypage) { |
| | | start = pageSize * (pageIndex - 1) + 1 |
| | | } |
| | | |
| | | if (setting.selected !== 'false' || (setting.orisel && id)) { |
| | | setTimeout(() => { |
| | | MKEmitter.emit('mkTableCheckTopLine', this.props.MenuID, id) |
| | | }, 200) |
| | | if (setting.selected === 'init') { |
| | | this.setState({setting: {...setting, selected: 'false'}}) |
| | | } |
| | | } |
| | | |
| | | this.setState({ |
| | |
| | | } |
| | | item.key = index |
| | | item.$$uuid = item[setting.primaryKey] || '' |
| | | item.$$key = '' + item.key + item.$$uuid |
| | | item.$$BID = BID || '' |
| | | item.$Index = start + index + '' |
| | | |
| | | if (setting.controlField) { |
| | | if (setting.controlVal.includes(item[setting.controlField])) { |
| | | item.$disabled = true |
| | | } |
| | | } |
| | | |
| | | return item |
| | | }), |
| | |
| | | if (statFields.length === 0 || !(setting.interType === 'system' || (setting.interType === 'custom' && setting.requestMode === 'system')) || !setting.dataresource) return |
| | | |
| | | let _orderBy = orderBy || setting.order |
| | | let param = UtilsDM.getStatQueryDataParams(setting, statFields, searches, _orderBy, BID, this.props.menuType) |
| | | let param = UtilsDM.getStatQueryDataParams(setting, statFields, searches, _orderBy, BID) |
| | | |
| | | if (param.func === 'sPC_Get_TableData') { |
| | | param.menuname = this.props.Tab.label || '' |
| | | } |
| | | |
| | | Api.genericInterface(param).then(res => { |
| | | if (res.status) { |
| | | let _data = res.data[0] |
| | |
| | | } |
| | | |
| | | /** |
| | | * @description 获取单行数据 |
| | | */ |
| | | async loadmainLinedata (id) { |
| | | const { BID } = this.props |
| | | const { setting, arr_field, search, orderBy, pageIndex, pageSize, absFields } = this.state |
| | | |
| | | let searches = fromJS(search).toJS() |
| | | |
| | | this.setState({ |
| | | loading: true |
| | | }) |
| | | |
| | | let _orderBy = orderBy || setting.order |
| | | let param = UtilsDM.getQueryDataParams(setting, arr_field, searches, _orderBy, pageIndex, pageSize, BID, id) |
| | | |
| | | let result = await Api.genericInterface(param) |
| | | if (result.status) { |
| | | let data = fromJS(this.state.data).toJS() |
| | | let selectedData = fromJS(this.state.selectedData).toJS() |
| | | if (result.data && result.data[0]) { |
| | | let _data = result.data[0] || {} |
| | | |
| | | if (absFields.length) { |
| | | absFields.forEach(field => { |
| | | if (!_data[field]) return |
| | | if (isNaN(Math.abs(_data[field]))) return |
| | | |
| | | _data[field] = Math.abs(_data[field]) |
| | | }) |
| | | } |
| | | |
| | | _data.$$uuid = _data[setting.primaryKey] || '' |
| | | _data.$$BID = BID || '' |
| | | |
| | | try { |
| | | data = data.map(item => { |
| | | if (item.$$uuid === _data.$$uuid) { |
| | | _data.key = item.key |
| | | _data.$$key = '' + item.key + item.$$uuid |
| | | _data.$Index = item.$Index |
| | | return _data |
| | | } else { |
| | | return item |
| | | } |
| | | }) |
| | | selectedData = selectedData.map(item => { |
| | | if (_data.$$uuid === item.$$uuid) { |
| | | return _data |
| | | } |
| | | return item |
| | | }) |
| | | } catch (e) { |
| | | console.warn('数据查询错误') |
| | | } |
| | | } |
| | | |
| | | this.setState({ |
| | | data, |
| | | selectedData, |
| | | loading: false |
| | | }) |
| | | } else { |
| | | this.setState({ |
| | | loading: false |
| | | }) |
| | | notification.error({ |
| | | top: 92, |
| | | message: result.message, |
| | | duration: 10 |
| | | }) |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @description 搜索条件改变时,重置表格数据 |
| | | * 含有初始不加载的页面,修改设置 |
| | | */ |
| | | 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 |
| | |
| | | /** |
| | | * @description 表格刷新 |
| | | */ |
| | | reloadtable = (btn) => { |
| | | reloadtable = (btn, id) => { |
| | | 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() |
| | | this.loadData(id) |
| | | }) |
| | | } else { |
| | | MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid, 'false') // 列表重置 |
| | | this.loadData() |
| | | MKEmitter.emit('resetTable', this.props.Tab.uuid, 'false') // 列表重置 |
| | | this.loadData(id) |
| | | } |
| | | |
| | | } |
| | |
| | | /** |
| | | * @description 导出Excel时,获取页面搜索排序等参数 |
| | | */ |
| | | queryModuleParam = (menuId, btnId) => { |
| | | const { Tab, mainSearch, MenuID } = this.props |
| | | queryModuleParam = (menuId, callback) => { |
| | | const { Tab, MenuID } = this.props |
| | | const { arr_field, orderBy, search, setting} = this.state |
| | | |
| | | if (MenuID !== menuId) return |
| | | |
| | | let searches = search |
| | | if (mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | searches = [...mainSearch, ...search] |
| | | } |
| | | |
| | | MKEmitter.emit('returnModuleParam', MenuID, btnId, { |
| | | callback({ |
| | | arr_field: arr_field, |
| | | orderBy: orderBy || setting.order, |
| | | search: searches, |
| | | search: search, |
| | | menuName: Tab.label |
| | | }) |
| | | } |
| | |
| | | * @param {*} position // 刷新位置 |
| | | * @param {*} btn // 执行的按钮 |
| | | */ |
| | | refreshByButtonResult = (menuId, position, btn) => { |
| | | refreshByButtonResult = (menuId, position, btn, id = '', lines) => { |
| | | const { MenuID } = this.props |
| | | |
| | | if (MenuID !== menuId) return |
| | | |
| | | this.reloadtable(btn) |
| | | if (position === 'line' && lines && lines.length === 1) { |
| | | this.loadmainLinedata(lines[0].$$uuid) |
| | | } else { |
| | | this.reloadtable(btn, id) |
| | | } |
| | | MKEmitter.emit('refreshPopButton', this.props.Tab.uuid) |
| | | } |
| | | |
| | | /** |
| | | * @description 图表视图切换 |
| | | */ |
| | | changeChart = (uuid) => { |
| | | this.setState({chartId: uuid}) |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | |
| | | } |
| | | |
| | | 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}> |
| | | {loadingview && <Spin />} |
| | | {searchlist && searchlist.length ? |
| | | <SubSearch BID={this.props.BID} setting={setting} searchlist={searchlist} menuType={this.props.menuType} refreshdata={this.refreshbysearch}/> : null |
| | | <SubSearch BID={this.props.BID} setting={setting} searchlist={searchlist} 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'}}> |
| | | <SubAction |
| | | setting={setting} |
| | | actions={actions} |
| | | columns={columns} |
| | | BID={this.props.BID} |
| | | dict={this.state.dict} |
| | | BData={this.props.BData} |
| | | selectedData={selectedData} |
| | | MenuID={this.props.SupMenuID} |
| | | /> |
| | | </div> |
| | | <SubTable |
| | | tableId={this.props.Tab.uuid} |
| | | setting={setting} |
| | | columns={columns} |
| | | pageSize={pageSize} |
| | | data={this.state.data} |
| | | dict={this.state.dict} |
| | | BData={this.props.BData} |
| | | total={this.state.total} |
| | | MenuID={this.props.MenuID} |
| | | loading={this.state.loading} |
| | | 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 } |
| | | {config ? <div style={{minHeight: '25px'}}> |
| | | <SubAction |
| | | setting={setting} |
| | | actions={actions} |
| | | columns={columns} |
| | | BID={this.props.BID} |
| | | dict={this.state.dict} |
| | | BData={this.props.BData} |
| | | selectedData={selectedData} |
| | | MenuID={this.props.SupMenuID} |
| | | /> |
| | | </div> : null} |
| | | {config ? <SubTable |
| | | tableId={this.props.Tab.uuid} |
| | | setting={setting} |
| | | columns={columns} |
| | | pageSize={pageSize} |
| | | data={this.state.data} |
| | | dict={this.state.dict} |
| | | BData={this.props.BData} |
| | | total={this.state.total} |
| | | MenuID={this.props.MenuID} |
| | | loading={this.state.loading} |
| | | refreshdata={this.refreshbytable} |
| | | statFValue={this.state.statFValue} |
| | | chgSelectData={this.changeSelectedData} |
| | | /> : null} |
| | | {viewlost ? <NotFount msg={this.state.lostmsg} /> : null} |
| | | </div> |
| | | ) |
| | |
| | | |
| | | const mapStateToProps = (state) => { |
| | | return { |
| | | menuType: state.editLevel, |
| | | permAction: state.permAction, |
| | | memberLevel: state.memberLevel |
| | | permAction: state.permAction |
| | | } |
| | | } |
| | | |