From 7c6e62c28fdfb4f6cf96180fed87e5ce8499d3b4 Mon Sep 17 00:00:00 2001 From: Chengliang <1546584672@qq.com> Date: Thu, 10 Aug 2023 09:34:44 +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/apis/quickSearch.js | 4 + .../fieldDefinedSet/QuickSearchDetail.js | 83 +++++++++++-------- pc4mobx/organization/stores/quickSearch.js | 15 ++-- 3 files changed, 60 insertions(+), 42 deletions(-) diff --git a/pc4mobx/organization/apis/quickSearch.js b/pc4mobx/organization/apis/quickSearch.js index 10a9ae2..7c5e5fb 100644 --- a/pc4mobx/organization/apis/quickSearch.js +++ b/pc4mobx/organization/apis/quickSearch.js @@ -6,6 +6,10 @@ export const saveQuickSearchInfo = (params) => { return WeaTools.callApi(`/api/bs/hrmorganization/quicksearch/saveQuickSearchInfo`, 'POST', params); } +export const saveQuickSearchDetailInfo = (params) => { + return WeaTools.callApi(`/api/bs/hrmorganization/quicksearch/saveQuickSearchDetailInfo`, 'POST', params); +} + export const getQuickSearchInfo = (params) => WeaTools.callApi(`/api/bs/hrmorganization/quicksearch/getQuickSearchInfo`, 'GET', params); export const getQuickSearchDetailInfo = (params) => WeaTools.callApi(`/api/bs/hrmorganization/quicksearch/getQuickSearchDetailInfo`, 'GET', params); diff --git a/pc4mobx/organization/components/fieldDefinedSet/QuickSearchDetail.js b/pc4mobx/organization/components/fieldDefinedSet/QuickSearchDetail.js index 23dc8d1..94e43ef 100644 --- a/pc4mobx/organization/components/fieldDefinedSet/QuickSearchDetail.js +++ b/pc4mobx/organization/components/fieldDefinedSet/QuickSearchDetail.js @@ -48,44 +48,57 @@ export default class QuickSearchDetail extends React.Component { } addRow = () => { - // const { quickSearch } = this.props; - // let { quickSearchDetailData } = CubeListStore; - // let datas = quickSearchDetailData; - // let time = new Date().getTime(); - // let obj = { - // key: "new_" + time, - // customname: '', - // orderid: 0, - // minnum: '', - // maxnum: '', - // type: CubeListStore.qcData.qcType, - // fieldid: CubeListStore.qcData.fieldid, - // customid: CubeListStore.customid - // } - // datas = toJS(datas); - // datas.push(obj); - // CubeListStore.setQuickSearchDetailData(datas); + const { quickSearch } = this.props; + let { quickSearchDetailData } = quickSearch; + let datas = quickSearchDetailData; + let time = new Date().getTime(); + let obj = { + key: "new_" + time, + customname: '', + orderid: 0, + minnum: '', + maxnum: '', + type: quickSearch.qcData.qcType, + fieldid: quickSearch.qcData.fieldid, + customid: quickSearch.customid + } + datas = toJS(datas); + datas.push(obj); + quickSearch.setQuickSearchDetailData(datas); } delRow = () => { - // const { CubeListStore } = this.props; - // let { qcDetailRowKeys } = CubeListStore; - // if (qcDetailRowKeys.length <= 0) { - // message.error(getLabel(22346, '请选择要删除的信息', 'label')); - // return; - // } - // const that = this; - // Modal.confirm({ - // title: getLabel(83601, '您确认要删除选中的记录吗?'), - // onOk() { - // let datas = CubeListStore.quickSearchDetailData; - // datas = toJS(datas); - // datas = that.delFromArray(datas, qcDetailRowKeys); - // CubeListStore.qcDetailRowKeys = []; - // CubeListStore.setQuickSearchDetailData(datas); - // }, - // onCancel() { }, - // }); + const { quickSearch } = this.props; + let { qcDetailRowKeys } = quickSearch; + if (qcDetailRowKeys.length <= 0) { + message.error(getLabel(22346, '请选择要删除的信息', 'label')); + return; + } + const that = this; + Modal.confirm({ + title: getLabel(83601, '您确认要删除选中的记录吗?'), + onOk() { + let datas = quickSearch.quickSearchDetailData; + datas = toJS(datas); + datas = that.delFromArray(datas, qcDetailRowKeys); + quickSearch.qcDetailRowKeys = []; + quickSearch.setQuickSearchDetailData(datas); + }, + onCancel() { }, + }); + } + + delFromArray = (array, selectRowIds) => { + for (let i = 0; i < selectRowIds.length; i++) { + let key = selectRowIds[i]; + for (let j = 0; j < array.length; j++) { + if (array[j]["key"] == key) { + array.splice(j, 1); + break; + } + } + } + return array; } render() { diff --git a/pc4mobx/organization/stores/quickSearch.js b/pc4mobx/organization/stores/quickSearch.js index 9e7b12d..23979b6 100644 --- a/pc4mobx/organization/stores/quickSearch.js +++ b/pc4mobx/organization/stores/quickSearch.js @@ -62,10 +62,10 @@ export class QuickSearchStore { @action("数据获取") getQuickSearchInfo = () => { this.clearQuciSearchData(); - API.getQuickSearchInfo({ customid: 382 }).then(action(({ code, data, msg }) => { + API.getQuickSearchInfo().then(action(({ code, data, msg }) => { if (code == 200) { this.quickSearchData.setting = data.setting; - this.quickSearchData.datas = datas.map(d => { + this.quickSearchData.datas = data.datas.map(d => { return { ...d, visible: false } }); this.quickSearchData.groupidOptions = data.groupidOptions; @@ -98,15 +98,14 @@ export class QuickSearchStore { } API.saveQuickSearchInfo({ id: id, - customid: this.customid, data: JSON.stringify(datas), ...formparm - }).then(({ status, errorCode, error, setting, datas, options }) => { - if (status == '1') { + }).then(({ code, data, msg }) => { + if (data == 200) { message.success(getLabel(83551, '保存成功!')); this.qcSelectedRowKeys = []; this.getQuickSearchInfo(); } else { - message.error(`[${getLabel(127353, "错误") + errorCode}]:${error}`); + message.error(`[${getLabel(127353, "错误") + code}]:${msg}`); } }); this.quickSearchData.setting.id = null; @@ -171,7 +170,9 @@ export class QuickSearchStore { // }); } - + @action setQuickSearchDetailData = (datas) => { + this.quickSearchDetailData = datas; + } /**===========================buttons=========================== */