| | |
| | | * @description 上级菜单id变化时,刷新数据 |
| | | */ |
| | | UNSAFE_componentWillReceiveProps(nextProps) { |
| | | if (this.state.config && this.props.Tab.supMenu && !is(fromJS(this.props.BID), fromJS(nextProps.BID))) { |
| | | const { config, 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 |
| | | }, () => { |
| | | if (this.state.setting) { |
| | | this.loadmaindata() |
| | | } |
| | | this.loadData() |
| | | }) |
| | | } else if (!this.props.Tab.supMenu && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { |
| | | if (this.state.setting) { |
| | | this.setState({}, () => { |
| | | this.loadmaindata() |
| | | }) |
| | | } |
| | | } else if (setting && !this.props.Tab.supMenu && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { |
| | | this.setState({}, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | } |
| | | |
| | |
| | | let valid = true // 搜索条件必填验证 |
| | | let hasReqFields = false |
| | | config.search.forEach(field => { |
| | | if (field.required === 'true' && !field.initval) { |
| | | if (field.required !== 'true') return |
| | | hasReqFields = true |
| | | if (!field.initval) { |
| | | valid = false |
| | | } |
| | | if (field.required === 'true') { |
| | | hasReqFields = true |
| | | } |
| | | }) |
| | | |
| | |
| | | hasReqFields |
| | | }, () => { |
| | | if (config.setting.onload !== 'false' && (!Tab.supMenu || BID || Tab.isTreeNode) && valid) { // 初始化可加载 |
| | | this.loadmaindata() |
| | | this.loadData() |
| | | } |
| | | }) |
| | | } else { |
| | |
| | | |
| | | loadData = () => { |
| | | const { mainSearch, BID } = this.props |
| | | const { setting, search, loadCustomApi } = this.state |
| | | const { setting, search, loadCustomApi, hasReqFields } = this.state |
| | | |
| | | let searches = fromJS(search).toJS() |
| | | if (mainSearch && mainSearch.length > 0) { // 主表搜索条件 |
| | | searches = [...mainSearch, ...searches] |
| | | } |
| | | |
| | | let requireFields = searches.filter(item => item.required && (!item.value || item.value.length === 0)) |
| | | let prex = this.props.Tab && this.props.Tab.label ? this.props.Tab.label + '-' : '' |
| | | |
| | | let requireFields = [] |
| | | if (hasReqFields) { |
| | | requireFields = searches.filter(item => item.required && (!item.value || item.value.length === 0)) |
| | | } |
| | | |
| | | 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)) |
| | | |
| | |
| | | statFValue: [], |
| | | total: 0 |
| | | }) |
| | | this.handleTableId() |
| | | return |
| | | } else if (window.GLOB.systemType === 'production' && setting.interType === 'custom' && !setting.proInterface) { |
| | | notification.warning({ |
| | |
| | | return |
| | | } |
| | | |
| | | this.setState({ |
| | | selectedData: [] |
| | | }) |
| | | this.handleTableId() |
| | | |
| | | if (setting.interType === 'custom' && loadCustomApi) { |
| | | if (setting.execTime === 'once') { |
| | | this.setState({loadCustomApi: false}) |
| | | } |
| | | |
| | | this.loadOutResource() |
| | | this.loadOutResource(searches) |
| | | if (setting.execType === 'async') { |
| | | this.loadmaindata() |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | loadOutResource = () => { |
| | | const { setting, search, BID } = this.state |
| | | loadOutResource = (searches) => { |
| | | const { BID } = this.props |
| | | const { setting } = this.state |
| | | |
| | | let param = UtilsDM.getPrevQueryParams(setting, search, BID, this.props.menuType) |
| | | let param = UtilsDM.getPrevQueryParams(setting, searches, BID, this.props.menuType) |
| | | |
| | | if (setting.execType === 'sync') { |
| | | this.setState({ |
| | |
| | | let error = '未知的返回结果!' |
| | | |
| | | if (typeof(res) === 'string') { |
| | | error = res |
| | | error = res.replace(/'/ig, '"') |
| | | } |
| | | |
| | | let _result = { |
| | |
| | | |
| | | 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 云端验证 |
| | |
| | | } else { |
| | | param.func = 's_ex_result_back' |
| | | param.s_ex_result = [...lineMap.values()].map((item, index) => ({ |
| | | MenuID: this.state.config.MenuID, |
| | | MenuName: this.state.config.MenuName, |
| | | MenuID: this.props.MenuID, |
| | | MenuName: this.props.Tab.label, |
| | | TableName: item.table, |
| | | LongText: window.btoa(window.encodeURIComponent(`${item.insert} ${item.selects.join(` union all `)}`)), |
| | | Sort: index + 1 |
| | |
| | | searches = [...mainSearch, ...searches] |
| | | } |
| | | |
| | | let requireFields = search.filter(item => item.required && (!item.value || item.value.length === 0)) |
| | | let prex = this.props.Tab && this.props.Tab.label ? this.props.Tab.label + '-' : '' |
| | | |
| | | if (requireFields.length > 0) { |
| | | 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 |
| | | } |
| | | |
| | | if (this.props.Tab.supMenu && !BID) { // 主表ID不存在时,不查询子表 |
| | | this.setState({ |
| | | data: [], |
| | | selectedData: [], |
| | | statFValue: [], |
| | | total: 0 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | this.setState({ |
| | | loading: true |
| | | }) |
| | | |
| | | let _orderBy = orderBy || setting.order |
| | | let param = UtilsDM.getQueryDataParams(setting, arr_field, searches, _orderBy, pageIndex, pageSize, BID, this.props.menuType) |
| | | |
| | | this.handleTableId() |
| | | |
| | | if (param.func === 'sPC_Get_TableData') { |
| | | param.menuname = this.props.Tab.label || '' |
| | |
| | | pageIndex: 1, |
| | | search: searches, |
| | | }, () => { |
| | | this.loadmaindata() |
| | | this.loadData() |
| | | }) |
| | | } |
| | | |
| | |
| | | pageSize: pagination.pageSize, |
| | | orderBy: (sorter.field && sorter.order) ? `${sorter.field} ${sorter.order}` : '' |
| | | }, () => { |
| | | this.loadmaindata() |
| | | this.loadData() |
| | | }) |
| | | } |
| | | |
| | |
| | | this.setState({ |
| | | pageIndex: 1 |
| | | }, () => { |
| | | this.loadmaindata() |
| | | this.loadData() |
| | | }) |
| | | } else { |
| | | MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid, 'false') // 列表重置 |
| | | this.loadmaindata() |
| | | this.loadData() |
| | | } |
| | | } |
| | | |