| | |
| | | import PropTypes from 'prop-types' |
| | | import {connect} from 'react-redux' |
| | | import { is, fromJS } from 'immutable' |
| | | import { notification, Spin, Switch, Row, Col, Icon, Tabs} from 'antd' |
| | | import { notification, Spin, Switch, Row, Col, Tabs} from 'antd' |
| | | |
| | | import Api from '@/api' |
| | | import zhCN from '@/locales/zh-CN/main.js' |
| | |
| | | import { updateSubTable } from '@/utils/utils-update.js' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import asyncSpinComponent from '@/utils/asyncSpinComponent' |
| | | import MkIcon from '@/components/mk-icon' |
| | | import NotFount from '@/components/404' |
| | | import MKEmitter from '@/utils/events.js' |
| | | |
| | |
| | | searchlist: null, // 搜索条件 |
| | | actions: null, // 按钮集 |
| | | columns: null, // 显示列 |
| | | arr_field: '', // 使用 sPC_Get_TableData 时的查询字段集 |
| | | arr_field: '', // 查询字段集 |
| | | setting: null, // 页面全局设置:数据源、按钮及显示列固定、主键等 |
| | | data: [], // 列表数据集 |
| | | selectedData: [], // 已选表格数据 |
| | |
| | | * @description 获取页面配置信息 |
| | | */ |
| | | async loadconfig () { |
| | | const { permAction, permMenus, Tab, BID, BData } = this.props |
| | | const { permAction, permMenus, Tab } = this.props |
| | | |
| | | let param = { |
| | | func: 'sPC_Get_LongParam', |
| | |
| | | config = updateSubTable(config) |
| | | |
| | | // 权限过滤 |
| | | 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 = '' |
| | | if (config.charts) { |
| | | // 视图权限 |
| | | 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 |
| | | } |
| | | |
| | | chartId = config.charts[0] ? config.charts[0].uuid : '' |
| | | } |
| | | |
| | | let chartId = config.charts[0] ? config.charts[0].uuid : '' |
| | | |
| | | // 1、筛选字段集,2、过滤隐藏列及合并列中的字段uuid |
| | | config.columns.forEach(col => { |
| | |
| | | col.linkThdMenu = permMenus.filter(m => m.MenuID === menu_id)[0] || '' |
| | | } else { |
| | | col.linkThdMenu = '' |
| | | } |
| | | |
| | | 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 (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 => { |
| | |
| | | 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({ |
| | | BID: BID || '', |
| | | BData: BData || '', |
| | | pageSize: config.setting.pageSize || 10, |
| | | BID: this.props.BID || '', |
| | | BData: this.props.BData || '', |
| | | loadingview: false, |
| | | chartId, |
| | | config, |
| | |
| | | search: Utils.initMainSearch(config.search), |
| | | hasReqFields |
| | | }, () => { |
| | | if (config.setting.onload !== 'false' && (!Tab.supMenu || BID || Tab.isTreeNode)) { // 初始化可加载 |
| | | if (config.setting.onload !== 'false' && (!Tab.supMenu || this.props.BID || Tab.isTreeNode)) { // 初始化可加载 |
| | | this.loadData() |
| | | } |
| | | }) |
| | |
| | | } |
| | | } |
| | | |
| | | loadData = () => { |
| | | loadData = (id) => { |
| | | const { mainSearch } = this.props |
| | | const { setting, BID, search, loadCustomApi, hasReqFields } = this.state |
| | | |
| | |
| | | |
| | | this.loadOutResource(searches) |
| | | if (setting.execType === 'async') { |
| | | this.loadmaindata() |
| | | this.loadmaindata(id) |
| | | } |
| | | } else { |
| | | this.loadmaindata() |
| | | this.loadmaindata(id) |
| | | } |
| | | } |
| | | |
| | | loadOutResource = (searches) => { |
| | | const { setting, BID } = this.state |
| | | |
| | | let param = UtilsDM.getPrevQueryParams(setting, searches, BID, this.props.menuType) |
| | | let param = UtilsDM.getPrevQueryParams(setting, searches, BID) |
| | | |
| | | if (setting.execType === 'sync') { |
| | | this.setState({ |
| | |
| | | `)) |
| | | sql = sql.join('') |
| | | |
| | | param = UtilsDM.getCallBackQueryParams(setting, sql, errSql) |
| | | |
| | | if (BID) { |
| | | param.BID = BID |
| | | } |
| | | |
| | | if (this.props.menuType === 'HS') { // 函数 sPC_TableData_InUpDe 云端验证 |
| | | param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) |
| | | } |
| | | param = UtilsDM.getCallBackQueryParams(setting, sql, errSql, BID) |
| | | } else { |
| | | param.func = 's_ex_result_back' |
| | | param.s_ex_result = lines.map((item, index) => ({ |
| | |
| | | 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 () { |
| | | async loadmaindata (id) { |
| | | const { mainSearch } = this.props |
| | | const { setting, BID, arr_field, search, orderBy, pageIndex, pageSize, absFields } = this.state |
| | | |
| | |
| | | }) |
| | | |
| | | let _orderBy = orderBy || setting.order |
| | | let param = UtilsDM.getQueryDataParams(setting, arr_field, searches, _orderBy, pageIndex, pageSize, BID, this.props.menuType) |
| | | let param = UtilsDM.getQueryDataParams(setting, arr_field, searches, _orderBy, pageIndex, pageSize, BID) |
| | | |
| | | let result = await Api.genericInterface(param) |
| | | |
| | |
| | | start = pageSize * (pageIndex - 1) + 1 |
| | | } |
| | | |
| | | if (setting.selected !== 'false') { |
| | | if (setting.selected !== 'false' || (setting.orisel && id)) { |
| | | setTimeout(() => { |
| | | MKEmitter.emit('mkTableCheckTopLine', this.props.MenuID) |
| | | MKEmitter.emit('mkTableCheckTopLine', this.props.MenuID, id) |
| | | }, 200) |
| | | if (setting.selected === 'init') { |
| | | this.setState({setting: {...setting, selected: 'false'}}) |
| | |
| | | } |
| | | 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 |
| | | }), |
| | |
| | | }) |
| | | |
| | | let _orderBy = orderBy || setting.order |
| | | let param = UtilsDM.getQueryDataParams(setting, arr_field, searches, _orderBy, pageIndex, pageSize, BID, this.props.menuType, id) |
| | | let param = UtilsDM.getQueryDataParams(setting, arr_field, searches, _orderBy, pageIndex, pageSize, BID, id) |
| | | |
| | | let result = await Api.genericInterface(param) |
| | | if (result.status) { |
| | |
| | | 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 { |
| | |
| | | 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) |
| | | |
| | | Api.genericInterface(param).then(res => { |
| | | if (res.status) { |
| | |
| | | /** |
| | | * @description 表格刷新 |
| | | */ |
| | | reloadtable = (btn) => { |
| | | reloadtable = (btn, id = '') => { |
| | | if (!btn || btn.resetPageIndex !== 'false') { |
| | | MKEmitter.emit('resetTable', this.props.Tab.uuid) // 列表重置 |
| | | this.setState({ |
| | | pageIndex: 1 |
| | | }, () => { |
| | | this.loadData() |
| | | this.loadData(id) |
| | | }) |
| | | } else { |
| | | MKEmitter.emit('resetTable', this.props.Tab.uuid, 'false') // 列表重置 |
| | | this.loadData() |
| | | this.loadData(id) |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @description 导出Excel时,获取页面搜索排序等参数 |
| | | */ |
| | | queryModuleParam = (menuId, btnId) => { |
| | | queryModuleParam = (menuId, callback) => { |
| | | const { Tab, mainSearch, MenuID } = this.props |
| | | const { arr_field, orderBy, search, setting} = this.state |
| | | |
| | |
| | | searches = [...mainSearch, ...search] |
| | | } |
| | | |
| | | MKEmitter.emit('returnModuleParam', MenuID, btnId, { |
| | | callback({ |
| | | arr_field: arr_field, |
| | | orderBy: orderBy || setting.order, |
| | | search: searches, |
| | |
| | | const { MenuID } = this.props |
| | | |
| | | if (menuId.indexOf(MenuID) === -1) return |
| | | if (id === 'empty') return |
| | | |
| | | if (!id) { |
| | | this.reloadtable() |
| | |
| | | * @param {*} position // 刷新位置 |
| | | * @param {*} btn // 执行的按钮 |
| | | */ |
| | | refreshByButtonResult = (menuId, position, btn) => { |
| | | refreshByButtonResult = (menuId, position, btn, id, lines) => { |
| | | const { MenuID } = this.props |
| | | |
| | | if (MenuID !== menuId) return |
| | |
| | | const { Tab, SupMenuID } = this.props |
| | | const { BID } = this.state |
| | | |
| | | if (position === 'grid' || position === 'view') { |
| | | this.reloadtable(btn) |
| | | if (position === 'line') { |
| | | if (lines && lines.length === 1) { |
| | | this.loadmainLinedata(lines[0].$$uuid) |
| | | } else { |
| | | this.reloadtable(btn, id) |
| | | } |
| | | } else if (position === 'grid' || position === 'view') { |
| | | this.reloadtable(btn, id) |
| | | } else if (position === 'maingrid' || position === 'mainline') { |
| | | this.reloadtable(btn) |
| | | if (Tab.supMenu) { |
| | | MKEmitter.emit('reloadData', Tab.supMenu, (BID || 'empty')) // 主表重置 |
| | | } else if (!Tab.supMenu && Tab.level === 0) { |
| | | MKEmitter.emit('reloadData', SupMenuID, (BID || 'empty')) // 树形结构,0级标签 |
| | | this.reloadtable(btn, id) |
| | | if (Tab.supMenu && BID) { |
| | | MKEmitter.emit('reloadData', Tab.supMenu, BID) // 主表重置 |
| | | } else if (!Tab.supMenu && Tab.level === 0 && BID) { |
| | | MKEmitter.emit('reloadData', SupMenuID, BID) // 树形结构,0级标签 |
| | | } |
| | | } else if (position === 'equaltab') { |
| | | this.reloadtable(btn) |
| | | this.reloadtable(btn, id) |
| | | if (Tab.equalTab && Tab.equalTab.length > 0) { |
| | | MKEmitter.emit('reloadData', Tab.equalTab.join(',')) // 同级标签重置 |
| | | } |
| | |
| | | |
| | | changeTableLine = (ContainerId, tableId, id, data) => { |
| | | const { Tab } = this.props |
| | | const { setting } = this.state |
| | | |
| | | if (!Tab.supMenu || tableId !== Tab.supMenu) return |
| | | |
| | | this.setState({BData: data, BID: id}) |
| | | |
| | | if (!setting) return |
| | | |
| | | if (id !== this.state.BID || id !== '') { |
| | | MKEmitter.emit('resetTable', this.props.Tab.uuid) // 列表重置 |
| | |
| | | <div className="subtable" id={'subtable' + this.props.MenuID}> |
| | | {loadingview && <Spin />} |
| | | {searchlist && searchlist.length ? |
| | | <SubSearch BID={BID} setting={setting} searchlist={searchlist} menuType={this.props.menuType} refreshdata={this.refreshbysearch}/> : null |
| | | <SubSearch BID={BID} setting={setting} searchlist={searchlist} refreshdata={this.refreshbysearch}/> : null |
| | | } |
| | | {config ? <Row className="chart-view" gutter={16}> |
| | | {config && config.charts ? <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> |
| | | <TabPane tab={<MkIcon type={item.icon} />} key={item.uuid}></TabPane> |
| | | ))} |
| | | </Tabs> : null} |
| | | {config.charts.map(item => { |
| | |
| | | } |
| | | })} |
| | | </Row> : null } |
| | | {config && !config.charts ? <> |
| | | <div className="sub-action"> |
| | | <SubAction |
| | | BID={BID} |
| | | BData={BData} |
| | | setting={setting} |
| | | actions={actions} |
| | | columns={columns} |
| | | Tab={this.props.Tab} |
| | | MenuID={this.props.MenuID} |
| | | selectedData={selectedData} |
| | | ContainerId={this.props.ContainerId} |
| | | /> |
| | | </div> |
| | | <div className="subtable-box"> |
| | | {(setting.tableType === 'radio' || setting.tableType === 'checkbox') && this.state.data && this.state.data.length > 0 ? |
| | | <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} |
| | | columns={columns} |
| | | pageSize={pageSize} |
| | | dict={this.state.dict} |
| | | data={this.state.data} |
| | | total={this.state.total} |
| | | MenuID={this.props.MenuID} |
| | | loading={this.state.loading} |
| | | statFValue={this.state.statFValue} |
| | | ContainerId={this.props.ContainerId} |
| | | refreshdata={this.refreshbytable} |
| | | chgSelectData={this.changeSelectedData} |
| | | /> |
| | | </div> |
| | | </> : null } |
| | | {viewlost ? <NotFount msg={this.state.lostmsg} /> : null} |
| | | </div> |
| | | ) |
| | |
| | | |
| | | const mapStateToProps = (state) => { |
| | | return { |
| | | menuType: state.editLevel, |
| | | permAction: state.permAction, |
| | | permMenus: state.permMenus, |
| | | } |