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

31435 勤工助学(新)/工作情况考核,20219001028 批次设置的时间没有受控制 看下

部分接口增加缓存。
上级 0d60ba29
......@@ -11,7 +11,8 @@ import { getUrlInfo } from '@/webPublic/one_stop_public/DetailForAudit/utils';
import { getTransformApi } from '@/webPublic/one_stop_public/2022beidianke/localstorageTransform';
import { strToBinary } from './strToBinary'; // 字符串转二进制 混淆代码
import { binaryToStr } from './binaryToStr';
import { getVisitorToken } from '@/webPublic/zyd_public/utils/getHeaders'; // 二进制字符串转JSON字符串 混淆代码
import { getVisitorToken } from '@/webPublic/zyd_public/utils/getHeaders';
import { saveCacheData } from '@/webPublic/one_stop_public/utils/apiServiceCache'; // 二进制字符串转JSON字符串 混淆代码
const test = !!getUrlInfo().test;
......@@ -151,7 +152,7 @@ export async function requestFileInfo(url, datas) {
res = binaryToStr(res.rbin);
if (isJSON(res)) {
res = JSON.parse(res);
}
}
}
if (res && res.errCode) {
qqCw({
......
......@@ -16,7 +16,6 @@ export default class ChildForm extends React.Component {
triggerChange = changedValue => {
// Should provide an event to pass value to Form.
const onChange = this.props.onChange;
console.log('ChildForm', changedValue);
if (onChange) {
if (changedValue && typeof changedValue === 'object' && !Object.keys(changedValue).length) {
......@@ -232,6 +231,7 @@ export default class ChildForm extends React.Component {
);
}
/***
* 子表单
* */
......
......@@ -158,7 +158,6 @@ export default class TableCom extends Component {
};
showModal = (fk, title, data, modalProps) => {
// console.log(fk, title, data, modalProps);
const { dispatch } = this.props;
const x = this.props.DataColumn.isShowModal;
......@@ -664,7 +663,6 @@ export default class TableCom extends Component {
setValues = (base52, json, values) => {
try {
// console.log(values);
this.props.form.setFieldsValue(values);
} catch (e) {
console.log(
......@@ -758,7 +756,7 @@ export default class TableCom extends Component {
if (base52) {
try {
const x = callback(data);
// console.log(x, '674');
if (x == null || x != 'NaN') this.props.form.setFieldsValue({ [base52]: x });
} catch (e) {
console.log(
......@@ -833,7 +831,7 @@ export default class TableCom extends Component {
if (base52) {
try {
const x = callback(data);
// console.log(x, '757');
if (x == null || x != 'NaN') this.props.form.setFieldsValue({ [base52]: x });
} catch (e) {
console.log(
......@@ -864,8 +862,6 @@ export default class TableCom extends Component {
}
//查缓存
// console.log(params && params.otherParams, JSON.stringify(params));
var isChange = false;
const { sqlKeys } = this.state;
......@@ -946,7 +942,7 @@ export default class TableCom extends Component {
if (base52) {
try {
const x = callback(data);
// console.log(x, 853);
if (x == null || x != 'NaN') this.props.form.setFieldsValue({ [base52]: x });
} catch (e) {
console.log(
......@@ -969,7 +965,6 @@ export default class TableCom extends Component {
...this.props.defaultValues[this.props.formKey],
...options,
});
// console.log(JSON.stringify(allValues));
let pp = {
sqlKey,
......@@ -1292,7 +1287,13 @@ export default class TableCom extends Component {
}
}
this.getData(json, dataColumn, obj);
const obj2 = {
...obj,
...this.props.form.getFieldsValue(),
...this.props.defaultValues[this.props.formKey],
};
this.getData(json, dataColumn, obj2);
if (json.formula != null && json.formula != '' && !this.props.safe) {
this.getFunctionValue(json.formula, dataColumn, json);
}
......@@ -1300,6 +1301,8 @@ export default class TableCom extends Component {
fetchData3 = (obj, dataColumn, init, json, allValues) => {
const { sqlKey, labelName, valueName, isMeta, filterSql } = json;
// console.log(sqlKey, allValues);
// debugger;
if (isMeta) {
// 2022年7月5日 2022 姚鑫国说的 如果是元数据 不需要传这个allValues
// 解决禅道bug 28017
......@@ -1319,6 +1322,7 @@ export default class TableCom extends Component {
return false;
}
dispatch({
type: 'DataColumn/getSqlOptions',
payload: params,
......@@ -2119,14 +2123,10 @@ export default class TableCom extends Component {
}
}
// console.log(json);
var title = json.label || (dataColumn && dataColumn.title);
var initValue;
const objinit = { ...init, ...obj };
if (dataColumn.base52 === 'KYAHGbFFyWo') {
// console.log(objinit);
}
if (objinit !== null && Object.keys(objinit).length > 0) {
if (this.props.fatherCode != null) {
......@@ -2156,7 +2156,6 @@ export default class TableCom extends Component {
}
}
// console.log(json.comName);
switch (json.comName) {
case 'RichText':
cm = (
......@@ -2269,7 +2268,6 @@ ${obj[dataColumn.base52]}
break;
case 'Select':
// console.log('Select组件的labels = ', labels);
let stringLabels = labels != null && labels.length > 0 ? labels.join(' ') : '';
if (Array.isArray(labels) && labels.length && typeof labels[0] === 'object') {
stringLabels = Object.values(labels[0]);
......@@ -2573,7 +2571,6 @@ ${obj[dataColumn.base52]}
console.log('签名组件没有获取到图片地址', dataColumn.base52);
cm = '';
} else {
// console.log(obj[dataColumn.base52], '签名组件获取的值');
const filePath = queryFileUrl(obj[dataColumn.base52]);
if (!filePath) {
cm = '';
......@@ -2605,7 +2602,6 @@ ${obj[dataColumn.base52]}
if (Object.keys(xxxxx).length > 0) {
delete xxxxx[''];
}
// console.log(datas);
cm = (
<ChildForm
taskId={this.props.taskId}
......@@ -2658,9 +2654,6 @@ ${obj[dataColumn.base52]}
break;
case 'LocationCom':
// cm = '';
// break;
// console.log(obj, obj[dataColumn.base52], json);
let v = obj[dataColumn.base52];
if (typeof v !== 'object') {
console.log('定位组件未获取到对象', '进行了数据转换', v, typeof v, isJSON(v));
......@@ -2846,7 +2839,6 @@ ${obj[dataColumn.base52]}
);
}
} else {
// console.log(JSON.stringify(this.props.form.getFieldsValue()), '----formValue----');
cm = getFieldDecorator(dataColumn.base52, {
initialValue: initValue,
......
/**
* 将接口数据进行缓存, 节流接口让页面没有那么卡顿
* 钟是志
* 2022年12月8日
* */
window.onestopApiServiceCacheData = {};
const cacheApiconfig = [
{
key: 'findParamsKey', // 接口唯一的键
url: '/SqlManageEntityApi/findParamsKey', // 接口地址
searchParams: 'sqlKey', // 缓存的参数
time: 600, // 缓存数据有效期. 单位秒
},
{
key: 'find', // 接口唯一的键
url: '/SqlManageEntityApi/find', // 接口地址
searchParams: 'sqlKey', // 缓存的参数
time: 600, // 缓存数据有效期. 单位秒
},
{
key: 'getSqlOptions', // 接口唯一的键
url: '/DataColumnApi/getSqlOptions', // 接口地址
searchParams: 'sqlKey', // 缓存的参数
time: 3, // 缓存数据有效期. 单位秒
},
];
function getConfig(apiUrl){
let findConfig = cacheApiconfig.find((g) => {
return apiUrl === g.url;
});
return findConfig || undefined;
}
// 获取缓存数据
export function getCacheData(apiUrl, params){
return new Promise((resolve, reject) => {
let findConfig = getConfig(apiUrl);
if(!findConfig){
resolve(false);
return;
}
// console.log(apiUrl, params);
let res = window.onestopApiServiceCacheData[findConfig.key + params[findConfig.searchParams]];
// console.log(res);
if(!res || new Date().getTime() > res?.expiresTime){
window.onestopApiServiceCacheData[findConfig.key + params[findConfig.searchParams]] = 'pending';
resolve(false);
return;
}
if(res === 'pending'){
let interval = setInterval(() => {
let newD = window.onestopApiServiceCacheData[findConfig.key + params[findConfig.searchParams]];
if(newD !== 'pending'){
clearInterval(interval);
resolve(newD.response);
return newD.response;
}
}, 200);
}else{
resolve(res.response);
return res.response;
}
});
}
// 保存缓存数据
export function saveCacheData(apiUrl = '', params,response = {}){
let findConfig = getConfig(apiUrl);
if(findConfig){
// console.log(params);
window.onestopApiServiceCacheData[findConfig.key + params[findConfig.searchParams]] = {
response,
expiresTime: new Date().getTime() + findConfig.time * 1000,
};
// console.log(window.onestopApiServiceCacheData);
return true;
}else{
return false;
}
}
......@@ -21,6 +21,7 @@ import { getHeaders, getIsBei_Dian } from '@/webPublic/zyd_public/utils/utils';
import { proxyChangeUrl } from '@/webPublic/zyd_public/request/proxyChangeUrl';
import { getTransformApi } from '@/webPublic/one_stop_public/2022beidianke/localstorageTransform';
import { getVisitorToken } from '@/webPublic/zyd_public/utils/getHeaders';
import { getCacheData, saveCacheData } from '@/webPublic/one_stop_public/utils/apiServiceCache';
const codeMessage = {
200: '服务器成功返回请求的数据。',
......@@ -133,7 +134,7 @@ const loginUmiRequest = extend({
// const getUrl = url => (url.startsWith('/') ? url : '/' + url);
// const test = getUrlInfo().test;
export const request = (url, data, options = {}) => {
const requestA = (url, data, options = {}) => {
return giveBase16EnCode(data, url)
.then((newData) => {
if (typeof newData === 'object' && newData.url && newData.datas) {
......@@ -143,6 +144,17 @@ export const request = (url, data, options = {}) => {
});
};
export async function request(url, data, options = {}) {
let cacheData = await getCacheData(url, data); // 读接口缓存
if(cacheData){
return cacheData;
}
const response = await requestA(url, data, options);
saveCacheData(url, data, response); // 写接口缓存
return response;
}
export async function requestOrigin(url, data, options = {}){
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论