提交 45ee4180 authored 作者: 钟是志's avatar 钟是志

28017 北电]宿舍抽查统计,查询输入会自动刷新实际无作用

上级 8870c7b6
...@@ -132,6 +132,7 @@ export default class TableCom extends Component { ...@@ -132,6 +132,7 @@ export default class TableCom extends Component {
modalTitle: '', modalTitle: '',
modalInit: {}, modalInit: {},
modalCode: null, modalCode: null,
getSqlOptionsCache: '', // fetchData3 函数参数做缓存 防止重复请求接口 禅道28017
dataSource: { dataSource: {
list: [], list: [],
pagination: false, pagination: false,
...@@ -1246,17 +1247,26 @@ export default class TableCom extends Component { ...@@ -1246,17 +1247,26 @@ export default class TableCom extends Component {
isMeta, isMeta,
filterSql, filterSql,
} = json; } = json;
if(isMeta){ // 2022年7月5日 2022 姚鑫国说的 如果是元数据 不需要传这个allValues
// 解决禅道bug 28017
allValues = {};
}
const { dispatch } = this.props; const { dispatch } = this.props;
if (init != null && Object.keys(init).length > 0) { if (init != null && Object.keys(init).length > 0) {
const params = {
sqlKey,
allValues,
isMeta,
filterSql: isMeta ? filterSql || '' : undefined,
}
let getSqlOptionsCache = JSON.stringify(params);
if(isMeta && getSqlOptionsCache === this.state.getSqlOptionsCache){ // 当上次的请求参数和这次的相同时 不再发起请求
return false;
}
dispatch({ dispatch({
type: 'DataColumn/getSqlOptions', type: 'DataColumn/getSqlOptions',
payload: { payload: params,
sqlKey,
allValues,
isMeta,
filterSql: isMeta ? filterSql || '' : undefined,
},
callback: (options) => { callback: (options) => {
const optionsx = []; const optionsx = [];
let base52 = dataColumn.base52; let base52 = dataColumn.base52;
...@@ -1277,6 +1287,7 @@ export default class TableCom extends Component { ...@@ -1277,6 +1287,7 @@ export default class TableCom extends Component {
this.props.form.setFieldsValue({ [base52]: null }); this.props.form.setFieldsValue({ [base52]: null });
} }
this.setState({ this.setState({
getSqlOptionsCache,
options: optionsx, options: optionsx,
selectDis: false, selectDis: false,
}); });
...@@ -1288,19 +1299,28 @@ export default class TableCom extends Component { ...@@ -1288,19 +1299,28 @@ export default class TableCom extends Component {
const x = base52.split('.'); const x = base52.split('.');
base52 = x[x.length - 1]; base52 = x[x.length - 1];
} }
const params = {
sqlKey,
values: obj[base52],
labelName,
valueName,
allValues,
isMeta,
}
let getSqlOptionsCache = JSON.stringify(params);
if(isMeta && getSqlOptionsCache === this.state.getSqlOptionsCache){ // 当上次的请求参数和这次的相同时 不再发起请求
return false;
}
if (obj[base52]) { if (obj[base52]) {
dispatch({ dispatch({
type: 'DataColumn/getSqlLabels', type: 'DataColumn/getSqlLabels',
payload: { payload: params,
sqlKey,
values: obj[base52],
labelName,
valueName,
allValues,
isMeta,
},
callback: (labels) => { callback: (labels) => {
this.setState({ this.setState({
getSqlOptionsCache,
labels, labels,
selectDis: false, selectDis: false,
}); });
...@@ -1308,15 +1328,22 @@ export default class TableCom extends Component { ...@@ -1308,15 +1328,22 @@ export default class TableCom extends Component {
}); });
} }
} else { } else {
const params = {
sqlKey,
allValues,
isMeta,
filterSql: isMeta ? filterSql || '' : undefined,
};
// console.log('1332', this.state.getSqlOptionsCache, JSON.stringify(params));
let getSqlOptionsCache = JSON.stringify(params);
if(isMeta && getSqlOptionsCache === this.state.getSqlOptionsCache){ // 当上次的请求参数和这次的相同时 不再发起请求
return false;
}
dispatch({ dispatch({
type: 'DataColumn/getSqlOptions', type: 'DataColumn/getSqlOptions',
payload: { payload: params,
sqlKey,
allValues,
isMeta,
filterSql: isMeta ? filterSql || '' : undefined,
},
callback: (options) => { callback: (options) => {
// console.log(options); // console.log(options);
let base52 = dataColumn.base52; let base52 = dataColumn.base52;
let vl = this.props.form.getFieldsValue()[base52]; let vl = this.props.form.getFieldsValue()[base52];
...@@ -1343,6 +1370,7 @@ export default class TableCom extends Component { ...@@ -1343,6 +1370,7 @@ export default class TableCom extends Component {
} }
this.setState({ this.setState({
getSqlOptionsCache,
options: optionsx, options: optionsx,
selectDis: false, selectDis: false,
}); });
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论