From de6a309f42be96982a8b622b1057ddd263194804 Mon Sep 17 00:00:00 2001 From: Chengliang <1546584672@qq.com> Date: Fri, 11 Aug 2023 09:39:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pc4mobx/organization/stores/quickSearch.js | 82 +++++++++++++++------- 1 file changed, 55 insertions(+), 27 deletions(-) diff --git a/pc4mobx/organization/stores/quickSearch.js b/pc4mobx/organization/stores/quickSearch.js index 23979b6..08c456a 100644 --- a/pc4mobx/organization/stores/quickSearch.js +++ b/pc4mobx/organization/stores/quickSearch.js @@ -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" } ] - + } \ No newline at end of file