Commit 0880a177 authored by 满振华's avatar 满振华

修改searchView

parent 64395ea0
...@@ -135,7 +135,7 @@ function changeDateRange(props, changedValues, allValues) { ...@@ -135,7 +135,7 @@ function changeDateRange(props, changedValues, allValues) {
return allValues; return allValues;
} }
function formatSelect(val, options) { export function formatSelect(val, options) {
if (Array.isArray(val) && val.length > 0) { if (Array.isArray(val) && val.length > 0) {
return val.map((item) => { return val.map((item) => {
return { return {
...@@ -557,11 +557,37 @@ export default class DataView extends React.Component { ...@@ -557,11 +557,37 @@ export default class DataView extends React.Component {
} }
return data; return data;
}; };
filterSubComChangeParams = (key) => {
const { searchCols, advancedSearchCols } = this.props;
const sumSearchCols = [...(searchCols || []), ...(advancedSearchCols || [])];
let fn = null;
if (!Array.isArray(sumSearchCols)) return null;
const filterFun = (data) => {
if (data.key === key && Object.prototype.toString(data) === '[object Object]') {
const componentAttr = data.componentAttr || {};
const onChangeParams = componentAttr.onChangeParams;
if (onChangeParams && typeof onChangeParams === 'function') {
fn = onChangeParams;
return;
}
}
if (Array.isArray(data)) {
data.map(ls => filterFun(ls));
}
}
filterFun(sumSearchCols);
return fn;
}
// 更改查询条件 // 更改查询条件
_changeSearchForm = (props, changedValues, allValues) => { _changeSearchForm = async (props, changedValues, allValues) => {
const newData = changeDateRange(props, changedValues, allValues); let newData = changeDateRange(props, changedValues, allValues);
this.setState({ // 回调配置项里面changeParams方法
const onChangeParams = this.filterSubComChangeParams(Object.keys(changedValues)[0]);
if (onChangeParams) {
newData = await onChangeParams(changedValues, newData) || newData
}
await this.setState({
searchForm: newData, searchForm: newData,
currentSiftNum: 0, currentSiftNum: 0,
}); });
...@@ -596,9 +622,16 @@ export default class DataView extends React.Component { ...@@ -596,9 +622,16 @@ export default class DataView extends React.Component {
}; };
// 删除指定搜索条件 // 删除指定搜索条件
_onRemoveItem = (values) => { _onRemoveItem = async (values) => {
const { searchForm } = this.state; const { searchForm } = this.state;
const formData = removeItem(searchForm, values); let formData = removeItem(searchForm, values);
// 回调配置项里面changeParams方法
const onChangeParams = this.filterSubComChangeParams(values.key);
if (onChangeParams) {
const obj = {}
obj[values.key] = undefined;
formData = await onChangeParams(obj, formData) || formData
}
this.setState( this.setState(
{ {
searchForm: formData, searchForm: formData,
......
...@@ -346,7 +346,6 @@ class SearchView extends React.Component { ...@@ -346,7 +346,6 @@ class SearchView extends React.Component {
if (this.props.modal === 'modal') { if (this.props.modal === 'modal') {
return this._renderModalForm(col); return this._renderModalForm(col);
} }
return ( return (
<div className={styles.colInner}> <div className={styles.colInner}>
{!!label && <div className={styles.label}>{label}</div>} {!!label && <div className={styles.label}>{label}</div>}
......
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