接口测试

This commit is contained in:
Chengliang 2023-08-11 09:39:58 +08:00
parent 7c6e62c28f
commit de6a309f42
1 changed files with 55 additions and 27 deletions

View File

@ -18,10 +18,11 @@ import { WeaLocaleProvider } from 'ecCom';
const toJS = mobx.toJS;
const getLabel = WeaLocaleProvider.getLabel;
const formatMultiLang = WeaLocaleProvider.formatMultiLang;
export class QuickSearchStore {
@observable quickSearchForm = new WeaForm();
@observable qcSelectedRowKeys = [];
@observable quickSearchData = {
@ -36,8 +37,8 @@ export class QuickSearchStore {
@observable qcDetailRowKeys = [];
quickSearchRefObj = {};
/**** ==============quickSearchForm ===============*/
@observable quickSearchFields = [
/**** ==============quickSearchForm ===============*/
@observable quickSearchFields = [
{
domkey: ['isquicksearch'],
conditionType: 'SWITCH',
@ -100,7 +101,7 @@ export class QuickSearchStore {
id: id,
data: JSON.stringify(datas), ...formparm
}).then(({ code, data, msg }) => {
if (data == 200) {
if (code == 200) {
message.success(getLabel(83551, '保存成功!'));
this.qcSelectedRowKeys = [];
this.getQuickSearchInfo();
@ -128,7 +129,7 @@ export class QuickSearchStore {
this.quickSearchData.datas = datas;
}
@action setQuickSearchData = (datas) => {
@action setQuickSearchData = (datas) => {
this.quickSearchData.datas = datas;
}
@ -142,38 +143,65 @@ export class QuickSearchStore {
}
@action getQuickSearchDetailInfo = (cid) => {
API.getQuickSearchDetailInfo({ cid: cid }).then(({ status, errorCode, error, setting, datas, precision }) => {
if (status == '1') {
this.quickSearchDetailData = datas;
this.precision = precision;
API.getQuickSearchDetailInfo({ cid: cid }).then(({ code, data, msg }) => {
if (code == 200) {
this.quickSearchDetailData = data.datas;
this.precision = data.precision;
} else {
message.error(`[${getLabel(127353, "错误") + errorCode}]:${error}`);
message.error(`[${getLabel(127353, "错误") + code}]:${msg}`);
}
});
}
@action("明细保存") saveQuickSearchDetailInfo = () => {
// let datas = this.quickSearchDetailData;
// if (!this.checkQuickSearchDetailData()) {
// return;
// }
// API.saveQuickSearchDetailInfo({
// cid: this.qcData.cid,
// data: JSON.stringify(datas)
// }).then(({ status, errorCode, error, setting, datas, options }: any) => {
// if (status == '1') {
// message.success(getLabel(83551, '保存成功!'));
// this.qcDetailRowKeys = [];
// this.getQuickSearchDetailInfo(this.qcData.cid);
// } else {
// message.error(`[${getLabel(127353, "错误") + errorCode}]:${error}`);
// }
// });
let datas = this.quickSearchDetailData;
if (!this.checkQuickSearchDetailData()) {
return;
}
API.saveQuickSearchDetailInfo({
cid: this.qcData.cid,
data: JSON.stringify(datas)
}).then(({ code, data, msg }) => {
if (code == 200) {
message.success(getLabel(83551, '保存成功!'));
this.qcDetailRowKeys = [];
this.getQuickSearchDetailInfo(this.qcData.cid);
} else {
message.error(`[${getLabel(127353, "错误") + code}]:${msg}`);
}
});
}
@action setQuickSearchDetailData = (datas) => {
this.quickSearchDetailData = datas;
}
checkQuickSearchDetailData = () => {
let result = true;
for (let i = 0; i < this.quickSearchDetailData.length; i++) {
let data = this.quickSearchDetailData[i];
if (_.trim(formatMultiLang(data.customname)) == '') {
this.quickSearchRefObj[`error_customname_${i}`].showError();
result = false;
break;
}
let minnum = data.minnum + '';
let maxnum = data.maxnum + '';
if ((_.trim(formatMultiLang(minnum)) == '' || minnum == undefined) && (_.trim(formatMultiLang(maxnum)) == '' || maxnum == undefined)) {
this.quickSearchRefObj[`error_condition_${i}`].showError();
result = false;
return;
}
if ((minnum != '' && minnum != undefined)
&& (maxnum != '' && maxnum != undefined)
&& (parseFloat(minnum) > parseFloat(maxnum))) {
message.error(getLabel('382783', "请填写正确的区间"));
result = false;
return;
}
}
return result;
}
/**===========================buttons=========================== */
rightMenu = [
@ -204,5 +232,5 @@ export class QuickSearchStore {
"type": "BTN_save"
}
]
}