Commit cd9ab746 authored by 满振华's avatar 满振华

修改子空间

parent 0880a177
......@@ -24,6 +24,10 @@ import { getOptionName, replacePageNum } from '@/utils/utils';
import { SIFT_TYPE } from '@/utils/enum';
import storage from '@/utils/storage'; /* eslint-disable react/sort-comp */ // 关闭下划线变量检测 // 关闭方法排序检测 // 多维数组降维成一维数组
/**
*
* @param {initView} fun 用于数据初始化之后的数据处理,每个自控可单独处理回调
*/
/* eslint-disable no-underscore-dangle */
function reduceDimension(arr) {
return Array.prototype.concat.apply([], arr);
......@@ -118,7 +122,7 @@ function formarRange(data) {
// 日期区间格式化(时间部分为00:00:00-23:59:59)
function changeDateRange(props, changedValues, allValues) {
const key = Object.keys(changedValues)[0];
const cols = reduceDimension([...props.searchCols, ...props.advancedSearchCols]);
const cols = reduceDimension([...(props.searchCols || []), ...(props.advancedSearchCols || [])]);
const col = cols.find((item) => {
return item.key === key;
});
......@@ -149,12 +153,10 @@ export function formatSelect(val, options) {
if (Array.isArray(val) && val.length === 0) {
return [];
}
return {
id: val,
name: options.find((item) => {
return item.id === val;
}).name,
};
const selectObj = options.find((item) => {
return item.id === val;
}) || {}
return selectObj;
}
function formatForm(formData, searchCols) {
......@@ -295,8 +297,9 @@ export default class DataView extends React.Component {
// this.getDefaultSift();
}
componentDidMount() {
this.getSiftData();
async componentDidMount() {
await this.getSiftData();
await this.initView();
replacePageNum('pageNum', this.state.current, this.fetchPage); // 当url里面有pageNum参数时,获取url里面的参数进行请求
}
......@@ -381,6 +384,14 @@ export default class DataView extends React.Component {
message.error(res && res.message);
}
}
initView = () => { // 该方法用于回调子空间的initView方法,只会执行一次
const { initView } = this.props;
const { searchForm } = this.state;
if (initView) {
initView({ searchForm, instance: this, form: this.props.form });
}
}
// eslint-disable-next-line react/sort-comp
_beforeFetch() {
......@@ -651,7 +662,7 @@ export default class DataView extends React.Component {
// 渲染查询条件按钮组件
_renderFilterBtn = () => {
let { searchCols, advancedSearchCols } = this.props;
searchCols = [...searchCols, ...advancedSearchCols];
searchCols = [...(searchCols || []), ...(advancedSearchCols || [])];
const { searchForm, siftDataArr, currentSiftNum } = this.state;
if (searchCols === null || searchCols.length <= 0) return null;
const chooseItems = formatForm(searchForm, searchCols);
......
......@@ -23,6 +23,9 @@ import styles from './index.less';
/* eslint-disable no-underscore-dangle */
// 基础搜索组件
// mode分为page 为页面模式下的搜索框, modal 弹框模式下搜索组件
/**
* select 拓展参数,将options 设置成function,用于基于业务处理options回调
*/
const formItemLayout = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment