| | |
| | | import options from '@/store/options.js' |
| | | import UtilsDM from '@/utils/utils-datamanage.js' |
| | | import { updateSubTable } from '@/utils/utils-update.js' |
| | | import { modifyTabview } from '@/store/action' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import asyncSpinComponent from '@/utils/asyncSpinComponent' |
| | | import NotFount from '@/components/404' |
| | |
| | | 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 = '' |
| | |
| | | config.action = config.action.filter(item => permAction[item.uuid]) |
| | | } |
| | | |
| | | let roleId = sessionStorage.getItem('role_id') || '' // 角色ID |
| | | // 字段权限黑名单 |
| | | config.search = config.search.map(item => { |
| | | item.oriInitval = item.initval |
| | | if (!item.blacklist || item.blacklist.length === 0) return item |
| | | if (item.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) { |
| | | item.Hide = 'true' |
| | | config.search = Utils.initSearchVal(config.search) |
| | | |
| | | let hasReqFields = false |
| | | config.search.forEach(field => { |
| | | if (field.required) { |
| | | hasReqFields = true |
| | | } |
| | | return item |
| | | }) |
| | | |
| | | // 字段权限黑名单 |
| | | let roleId = sessionStorage.getItem('role_id') || '' // 角色ID |
| | | |
| | | config.columns = config.columns.map(col => { |
| | | if (!col.blacklist || col.blacklist.length === 0) return col |
| | |
| | | if (col.field) { |
| | | _arrField.push(col.field) |
| | | |
| | | if (col.linkmenu && col.linkmenu.length > 0) { |
| | | let menu_id = col.linkmenu.slice(-1)[0] |
| | | col.linkThdMenu = permMenus.filter(m => m.MenuID === menu_id)[0] || '' |
| | | } else { |
| | | col.linkThdMenu = '' |
| | | } |
| | | |
| | | col.nameField && _arrField.push(col.nameField) // 链接名字段 |
| | | if (col.Hide !== 'true' && col.type === 'number' && col.sum === 'true') { |
| | | statFields.push(col) |
| | |
| | | // 生成显示列,处理合并列中的字段 |
| | | config.columns.forEach((col, index) => { |
| | | if (_hideCol.includes(col.uuid)) return |
| | | |
| | | if (col.linkmenu && col.linkmenu.length > 0) { |
| | | let menu_id = col.linkmenu.slice(-1)[0] |
| | | col.linkThdMenu = permMenus.filter(m => m.MenuID === menu_id)[0] || '' |
| | | } else { |
| | | col.linkThdMenu = '' |
| | | } |
| | | |
| | | col.sort = index |
| | | |
| | |
| | | _columns.push(config.gridBtn) |
| | | } |
| | | |
| | | let valid = true // 搜索条件必填验证 |
| | | let hasReqFields = false |
| | | config.search.forEach(field => { |
| | | if (field.required !== 'true') return |
| | | hasReqFields = true |
| | | if (!field.initval) { |
| | | valid = false |
| | | } |
| | | }) |
| | | |
| | | config.setting.tabType = 'sub' |
| | | // 数据源信息预处理 |
| | | config.setting.laypage = config.setting.laypage !== 'false' // 是否分页,转为boolean 统一格式 |
| | |
| | | config.setting.dataresource = config.setting.dataresource.replace(/@\$|\$@/ig, '') |
| | | config.setting.customScript = config.setting.customScript.replace(/@\$|\$@/ig, '') |
| | | } |
| | | |
| | | 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') || '' |
| | | fullName = sessionStorage.getItem('CloudFullName') || '' |
| | | } |
| | | |
| | | let regs = [ |
| | | { reg: /@userName@/ig, value: `'${userName}'` }, |
| | | { reg: /@fullName@/ig, value: `'${fullName}'` }, |
| | | { reg: /@login_city@/ig, value: `'${city}'` } |
| | | ] |
| | | |
| | | regs.forEach(cell => { |
| | | config.setting.dataresource = config.setting.dataresource.replace(cell.reg, cell.value) |
| | | config.setting.customScript = config.setting.customScript.replace(cell.reg, cell.value) |
| | | }) |
| | | } |
| | | |
| | | this.setState({ |
| | |
| | | actions: _actions, |
| | | columns: _columns, |
| | | arr_field: _arrField.join(','), |
| | | search: Utils.initMainSearch(config.search), // 搜索条件初始化(含有时间格式,需要转化) |
| | | search: Utils.initMainSearch(config.search), |
| | | hasReqFields |
| | | }, () => { |
| | | if (config.setting.onload !== 'false' && (!Tab.supMenu || BID || Tab.isTreeNode) && valid) { // 初始化可加载 |
| | | if (config.setting.onload !== 'false' && (!Tab.supMenu || BID || Tab.isTreeNode)) { // 初始化可加载 |
| | | this.loadData() |
| | | } |
| | | }) |
| | |
| | | searches = [...mainSearch, ...searches] |
| | | } |
| | | |
| | | let requireFields = [] |
| | | if (hasReqFields) { |
| | | requireFields = searches.filter(item => item.required && (!item.value || item.value.length === 0)) |
| | | let requireFields = searches.filter(item => item.required && item.value === '') |
| | | if (requireFields.length > 0) { |
| | | this.setState({ |
| | | loading: false |
| | | }) |
| | | return |
| | | } |
| | | } |
| | | |
| | | if (requireFields.length > 0) { |
| | | let prex = this.props.Tab && this.props.Tab.label ? this.props.Tab.label + '-' : '' |
| | | let labels = requireFields.map(item => item.label) |
| | | labels = Array.from(new Set(labels)) |
| | | |
| | | notification.warning({ |
| | | top: 92, |
| | | message: prex + this.state.dict['form.required.input'] + labels.join('、') + ' !', |
| | | duration: 3 |
| | | }) |
| | | return |
| | | } else if (this.props.Tab.supMenu && !BID) { // 主表ID不存在时,不查询子表 |
| | | if (this.props.Tab.supMenu && !BID) { // 主表ID不存在时,不查询子表 |
| | | this.setState({ |
| | | data: [], |
| | | selectedData: [], |
| | |
| | | }) |
| | | |
| | | Api.directRequest(url, setting.method, param, setting.cross).then(res => { |
| | | if (typeof(res) !== 'object' || Array.isArray(res)) { |
| | | if (typeof(res) !== 'object') { |
| | | let error = '未知的返回结果!' |
| | | |
| | | if (typeof(res) === 'string') { |
| | |
| | | |
| | | this.customCallbackRequest(_result) |
| | | } else { |
| | | if (Array.isArray(res)) { |
| | | res = { data: res } |
| | | } |
| | | res.mk_api_key = mkey |
| | | this.customCallbackRequest(res) |
| | | } |
| | |
| | | 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 result = await Api.genericInterface(param) |
| | | |
| | | this.getStatFieldsValue(searches) |
| | | |
| | | if (result.status) { |
| | | let start = 1 |
| | | if (setting.laypage) { |
| | | start = pageSize * (pageIndex - 1) + 1 |
| | | } |
| | | |
| | | this.setState({ |
| | | data: result.data.map((item, index) => { |
| | | if (absFields.length) { |
| | |
| | | item.key = index |
| | | item.$$uuid = item[setting.primaryKey] || '' |
| | | item.$$BID = BID || '' |
| | | item.$Index = start + index + '' |
| | | |
| | | return item |
| | | }), |
| | |
| | | let _orderBy = orderBy || setting.order |
| | | let param = UtilsDM.getQueryDataParams(setting, arr_field, searches, _orderBy, pageIndex, pageSize, BID, this.props.menuType, id) |
| | | |
| | | if (param.func === 'sPC_Get_TableData') { |
| | | param.menuname = this.props.Tab.label || '' |
| | | } |
| | | |
| | | 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] |
| | | let _data = result.data[0] || {} |
| | | |
| | | if (absFields.length) { |
| | | absFields.forEach(field => { |
| | |
| | | }) |
| | | } |
| | | |
| | | _data.$$uuid = _data[setting.primaryKey] || '' |
| | | _data.$$BID = BID || '' |
| | | |
| | | try { |
| | | data = data.map(item => { |
| | | if (item[setting.primaryKey] === _data[setting.primaryKey]) { |
| | | if (item.$$uuid === _data.$$uuid) { |
| | | _data.key = item.key |
| | | _data.$$uuid = _data[setting.primaryKey] || '' |
| | | _data.$$BID = BID || '' |
| | | |
| | | _data.$Index = item.$Index |
| | | return _data |
| | | } else { |
| | | return item |
| | | } |
| | | }) |
| | | } catch { |
| | | selectedData = selectedData.map(item => { |
| | | if (_data.$$uuid === item.$$uuid) { |
| | | return _data |
| | | } |
| | | return item |
| | | }) |
| | | } catch (e) { |
| | | console.warn('数据查询错误') |
| | | } |
| | | } |
| | | |
| | | this.setState({ |
| | | data: data, |
| | | data, |
| | | selectedData, |
| | | loading: false |
| | | }) |
| | | } else { |
| | |
| | | let _orderBy = orderBy || setting.order |
| | | let param = UtilsDM.getStatQueryDataParams(setting, statFields, searches, _orderBy, BID, this.props.menuType) |
| | | |
| | | 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 导出Excel时,获取页面搜索排序等参数 |
| | | */ |
| | | getexceloutparam = (menuId, btnId) => { |
| | | queryModuleParam = (menuId, btnId) => { |
| | | const { Tab, mainSearch, MenuID } = this.props |
| | | const { arr_field, orderBy, search, setting} = this.state |
| | | |
| | |
| | | searches = [...mainSearch, ...search] |
| | | } |
| | | |
| | | MKEmitter.emit('execExcelout', MenuID, btnId, { |
| | | MKEmitter.emit('returnModuleParam', MenuID, btnId, { |
| | | arr_field: arr_field, |
| | | orderBy: orderBy || setting.order, |
| | | search: searches, |
| | |
| | | |
| | | componentDidMount () { |
| | | MKEmitter.addListener('reloadData', this.reloadData) |
| | | MKEmitter.addListener('getexceloutparam', this.getexceloutparam) |
| | | MKEmitter.addListener('queryModuleParam', this.queryModuleParam) |
| | | MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult) |
| | | } |
| | | |
| | |
| | | return |
| | | } |
| | | MKEmitter.removeListener('reloadData', this.reloadData) |
| | | MKEmitter.removeListener('getexceloutparam', this.getexceloutparam) |
| | | MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) |
| | | MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) |
| | | } |
| | | |
| | |
| | | <div className="subtable" id={'subtable' + this.props.MenuID}> |
| | | {loadingview && <Spin />} |
| | | {searchlist && searchlist.length ? |
| | | <SubSearch BID={this.props.BID} searchlist={searchlist} menuType={this.props.menuType} refreshdata={this.refreshbysearch}/> : null |
| | | <SubSearch BID={this.props.BID} setting={setting} searchlist={searchlist} menuType={this.props.menuType} refreshdata={this.refreshbysearch}/> : null |
| | | } |
| | | {config ? <Row className="chart-view" gutter={16}> |
| | | {/* 视图组 */} |
| | |
| | | </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="关" defaultChecked={pickup} onChange={this.pickupChange} /> : null |
| | | <Switch title="收起" className="subtable-pickup" checkedChildren="开" unCheckedChildren="关" checked={pickup} onChange={this.pickupChange} /> : null |
| | | } |
| | | <SubTable |
| | | tableId={this.props.Tab.uuid} |
| | |
| | | |
| | | const mapStateToProps = (state) => { |
| | | return { |
| | | tabviews: state.tabviews, |
| | | menuType: state.editLevel, |
| | | permAction: state.permAction, |
| | | permMenus: state.permMenus, |
| | | } |
| | | } |
| | | |
| | | const mapDispatchToProps = (dispatch) => { |
| | | return { |
| | | modifyTabview: (tabviews) => dispatch(modifyTabview(tabviews)) |
| | | } |
| | | const mapDispatchToProps = () => { |
| | | return {} |
| | | } |
| | | |
| | | export default connect(mapStateToProps, mapDispatchToProps)(SubTabViewTable) |