From 5baac661e288a514c355d79030543099154bc9fa Mon Sep 17 00:00:00 2001 From: Chengliang <1546584672@qq.com> Date: Fri, 13 Jan 2023 14:37:03 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8A=B1=E5=90=8D=E5=86=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pc4mobx/organization/apis/resource.js | 19 +- .../components/resource/Customization.js | 68 ++- .../components/resource/SearchCustomDialog.js | 2 +- .../components/resource/resource.js | 5 +- pc4mobx/organization/stores/resource.js | 415 +++++++++++------- 5 files changed, 335 insertions(+), 174 deletions(-) diff --git a/pc4mobx/organization/apis/resource.js b/pc4mobx/organization/apis/resource.js index 577310a..f4c16ee 100644 --- a/pc4mobx/organization/apis/resource.js +++ b/pc4mobx/organization/apis/resource.js @@ -90,19 +90,28 @@ export const deleteSearchTemplate = (params) => { }) } -export const getSearchTemplate = (id) => { - return WeaTools.callApi(`/api/bs/hrmorganization/hrmresource/getSearchTemplate?templateId=${id}`, 'GET'); +export const getSearchTemplate = (params) => { + return WeaTools.callApi(`/api/bs/hrmorganization/hrmresource/getSearchTemplate`, 'GET',params); } -export const getTemplateSelectKeys = (id) => { - return WeaTools.callApi(`/api/bs/hrmorganization/hrmresource/getTemplateSelectKeys?templateId=${id}`, 'GET'); +export const getTemplateSelectKeys = (params) => { + return WeaTools.callApi(`/api/bs/hrmorganization/hrmresource/getTemplateSelectKeys`, 'GET',params); } +export const updateCustomTemplate = (params) => { + return WeaTools.callApi(`/api/bs/hrmorganization/hrmresource/updateCustomTemplate`, 'POST',params); +} + +export const saveColumnsCustomTemplate = (params) => { + return WeaTools.callApi(`/api/bs/hrmorganization/hrmresource/saveColumnsCustomTemplate`, 'POST',params); +} export const getEditTable = () => { - return WeaTools.callApi('/api/bs/hrmorganization/cardAccess/getCardButtonTable', 'GET'); + return WeaTools.callApi('/api/bs/hrmorganization/hrmresource/getCustomTemplate', 'GET'); } export const getCustomTransferData = (id) => { return WeaTools.callApi(`/api/bs/hrmorganization/hrmresource/getCustomTransferData?templateId=${id}`, 'GET'); } + + diff --git a/pc4mobx/organization/components/resource/Customization.js b/pc4mobx/organization/components/resource/Customization.js index 51c3b21..b0f64ae 100644 --- a/pc4mobx/organization/components/resource/Customization.js +++ b/pc4mobx/organization/components/resource/Customization.js @@ -3,11 +3,16 @@ import { } from 'mobx-react'; import { WeaTransfer, + WeaInputSearch, + WeaSelect } from 'ecCom'; import { toJS } from 'mobx'; import isEmpty from 'lodash/isEmpty' +import { + Spin +} from 'antd' @observer export default class Customization extends React.Component { @@ -15,6 +20,41 @@ export default class Customization extends React.Component { super(props); } + rightHeader = () => { + + + const { + store + } = this.props, { + transfer, + inputSearchStyle, + search, + customTemplates, + templates, + searchTemplateId, + customTemplateId + } = store, { + transferRightIptVal, + } = transfer; + return ( +
+ 已选 + + store.getTemplateSelectKeys(v)} + /> +
+ ) + } + + render() { const { store @@ -23,21 +63,29 @@ export default class Customization extends React.Component { transfer, leftHeader, rightHeader, + searchDialog, + search } = store, { transferDatas, transferKeys } = transfer; - + + return ( -
- -
+
+ { + !searchDialog.loading ? :
+ +
+ } + +
); } } \ No newline at end of file diff --git a/pc4mobx/organization/components/resource/SearchCustomDialog.js b/pc4mobx/organization/components/resource/SearchCustomDialog.js index f82fb31..eead673 100644 --- a/pc4mobx/organization/components/resource/SearchCustomDialog.js +++ b/pc4mobx/organization/components/resource/SearchCustomDialog.js @@ -60,7 +60,7 @@ export default class SearchCustomDialog extends React.Component { searchTemplateName } = store; const buttons = [ - , + , , ] diff --git a/pc4mobx/organization/components/resource/resource.js b/pc4mobx/organization/components/resource/resource.js index bf65163..5fc987c 100644 --- a/pc4mobx/organization/components/resource/resource.js +++ b/pc4mobx/organization/components/resource/resource.js @@ -417,10 +417,6 @@ export default class Resource extends React.Component { !isNew && resource.edit(); } - //高级搜索模板修改 - handleTemplateChange() { - - } getPanelComponents() { const { @@ -536,6 +532,7 @@ export default class Resource extends React.Component { searchType={['base', 'advanced']} showSearchAd={isPanelShow} searchsBaseValue={this.isEmptyObject(form2.getFormParams()) ? lastName : form2.getFormParams().lastName} + searchsBasePlaceHolder='请输入姓名' setShowSearchAd={bool => resource.setPanelStatus(bool)} hideSearchAd={() => resource.setPanelStatus(false)} searchsAd={isPanelShow ? this.getPanelComponents() :
} diff --git a/pc4mobx/organization/stores/resource.js b/pc4mobx/organization/stores/resource.js index 5234f47..d75b09c 100644 --- a/pc4mobx/organization/stores/resource.js +++ b/pc4mobx/organization/stores/resource.js @@ -22,9 +22,8 @@ import { import { i18n } from '../public/i18n'; -import trim from 'lodash/trim'; import { getSecondPath } from '../util/index' -import cloneDeep from 'lodash/cloneDeep'; +import {cloneDeep,isEmpty,trim} from 'lodash'; const toJS = mobx.toJS; const { @@ -197,11 +196,16 @@ export class ResourceStore { /** ============================================================================================= */ + @observable search = true; + + @observable searchDialog = { visible: false, + loading: true } @observable templates = []; + @observable customTemplates = []; @observable searchTemplateName = ''; @observable searchTemplateId = '-1'; @observable customTemplateName = ''; @@ -245,6 +249,29 @@ export class ResourceStore { this.getSearchCondition(false); } + @action("列定制保存") saveCustomDefine = () => { + if(this.customTemplateId == '-1') { + message.error("默认模板不能修改"); + }else { + + const params = { + columns:this.transfer.transferKeys, + templateId:this.customTemplateId + } + Api.getTemplateSelectKeys(params).then(res => { + if (res.code === 200) { + this.transfer.transferKeys = res.data.split(","); + } else { + this.searchDialog.visible = false; + this.getTableInfo(); + } + }, error => { + message.warning(error.msg); + }) + } + + } + @action("高级搜索模板切换") changeSearchTemplate(v) { this.searchTemplateId = v; this.getSearchCondition(); @@ -282,14 +309,23 @@ export class ResourceStore { this.transfer.transferDatas = transferDatas; this.transfer.transferKeys = transferKeys; this.transfer.transferOptions = transferOptions; + this.searchDialog.visible = true; } - @action("列定制") customization = (v) => { - this.openSearchDialog(false); + @action("列定制") customization = (v = false) => { + this.openCustomDialog(v); } @action("常用条件定制模板切换") getTemplateSelectKeys = v => { - Api.getTemplateSelectKeys(v).then(res => { + if(!this.search){ + this.customTemplateId = v; + } + + const params = { + templateId: v, + type: this.search ? 'search' : 'custom' + } + Api.getTemplateSelectKeys(params).then(res => { if (res.code === 200) { this.transfer.transferKeys = res.data.split(","); } else { @@ -345,7 +381,7 @@ export class ResourceStore { }).then(data => { if (data.code === 200) { this.customTemplateId = data.data; - this.customization(); + } else { message.warning(data.msg); } @@ -427,12 +463,14 @@ export class ResourceStore { /> this.getTemplateSelectKeys(v)} /> ) } + renderItem = (item) => { const { label, @@ -474,10 +512,10 @@ export class ResourceStore { this.transfer.transferKeys = v; } - @action("高级搜索模板") getSearchTemplate = () => { - Api.getSearchTemplate(this.searchTemplateId).then(res => { + @action("模板") getSearchTemplate = (bool) => { + Api.getSearchTemplate({ type: bool ? 'search' : 'custom' }).then(res => { if (res.code === 200) { - res.data && this.setTemplates(res.data); + bool ? this.setTemplates(res.data) : this.setCustomTemplates(res.data); } else { message.warning(res.msg); } @@ -504,7 +542,15 @@ export class ResourceStore { width: 500, height: 650 }, - buttons: [] + buttons: [] + } + + @computed get editTableParams() { + let datas = this.relatedData.datas; + let selectedData = this.relatedData.selectedData.status; + let params = this.arrToJson(toJS(datas), toJS(selectedData), 'status'); + params.rownum = datas.length; + return params; } @action("列定制模板管理") getEditTable() { @@ -530,173 +576,234 @@ export class ResourceStore { }, error => { message.warning(error.msg); }) - } - - - - @action updateTransferleftIptVal = (v) => { - this.transfer.transferleftIptVal = v; - } - - @action updateTransferSelectedKey = (v) => { - this.transfer.transferSelectedKey = v; - } - - @action updateTransferKeys = (v) => { - this.transfer.transferKeys = v; - } - - - @action updateTransferRightptVal = (v) => { - this.transfer.transferRightIptVal = v; - } - - - - @action openSearchDialog = (bool) => { - this.search = bool; - this.searchDialog.visible = true; - this.formatTransfer(); - - } - - @action closeSearchDialog = () => { - this.searchDialog.visible = false; - } - - @action closeTemlateManageDialog = () => { - this.temlateManageDialog.visible = false; - } - - setTableEditDatas(e) { - e.map(item => { - for (let key in item) { - if (key == "undefined") { - delete item[key]; - } - if (!item["isused"]) { - item["isused"] = ""; - } + @action("保存") updateCustomTemplate() { + let params = this.editTableParams; + Api.updateCustomTemplate(params).then(res => { + let { code, msg } = res; + if (code === 200) { + message.success(msg || "操作成功"); + this.getEditTable(); + this.customization(); + } else { + message.error(msg); } + }).catch(error => { + message.error(error); }); - extendObservable(this.relatedData, { - datas: e - }); - } +} - setEnableRows(e) { - extendObservable(this.relatedData, { - selectedData: { - isused: e - } - }); - } - - - - updateFields(val) { - this.form2.updateFields({ - lastName: { - value: val - } - }); - } - - setSearchCondition(condition) { - this.searchCondition = condition; - } - - setDefaultCondition(defaultcondition) { - this.defaultCondition = defaultcondition; - } - - setTemplates(templates) { - this.templates = templates; - } - - setScLoadingStatus(bool) { - this.searchConditionLoading = bool; - } - - setPanelStatus(bool) { - this.isPanelShow = bool; - this.getSearchTemplate(); - bool && this.getSearchCondition(); - if (!bool) { - this.scLoadingReset(); +@action("列定制") getCustomTransferData() { + Api.getCustomTransferData(this.customTemplateId).then(result => { + if (result.code === 200) { + const { transferDatas, transferKeys, transferOptions } = result.data; + this.transfer.transferDatas = transferDatas; + this.transfer.transferKeys = transferKeys; + this.transfer.transferOptions = transferOptions; + this.searchDialog.visible = true; + this.searchDialog.loading = false; + } else { + message.warning(result.msg); } - } + }, error => { + message.warning(error.msg); + }) +} - setLastName(val) { - this.lastName = val; - } - isEmptyObject(obj) { - for (let key in obj) { - return false; + + +@action updateTransferleftIptVal = (v) => { + this.transfer.transferleftIptVal = v; +} + +@action updateTransferSelectedKey = (v) => { + this.transfer.transferSelectedKey = v; +} + +@action updateTransferKeys = (v) => { + this.transfer.transferKeys = v; +} + + +@action updateTransferRightptVal = (v) => { + this.transfer.transferRightIptVal = v; +} + + + +@action openSearchDialog = (bool) => { + this.search = bool; + this.searchDialog.loading = false; + this.formatTransfer(); +} + +@action openCustomDialog = (bool) => { + this.search = bool; + this.searchDialog.loading = true; + this.getSearchTemplate(bool); + this.getCustomTransferData(); + +} + +@action closeSearchDialog = () => { + this.searchDialog.visible = false; +} + +@action closeTemlateManageDialog = () => { + this.temlateManageDialog.visible = false; +} + +setTableEditDatas(e) { + e.map(item => { + for (let key in item) { + if (key == "undefined") { + delete item[key]; + } + if (!item["isused"]) { + item["isused"] = ""; + } } - return true; - } + }); + extendObservable(this.relatedData, { + datas: e + }); +} - setIds(ids) { - this.ids = ids; - } - - scLoadingReset() { - this.searchConditionLoading = true; - } +setEnableRows(e) { + extendObservable(this.relatedData, { + selectedData: { + isused: e + } + }); +} - formReset() { - this.form = new WeaForm(); - } - dialogLoadingReset() { - this.dialogLoading = true; - } +updateFields(val) { + this.form2.updateFields({ + lastname: { + value: val + } + }); +} - setVisible(bool) { - this.visible = bool; - this.formReset(); - !bool && this.dialogLoadingReset(); - } +setSearchCondition(condition) { + this.searchCondition = condition; +} - setDialogLoadingStatus(bool) { - this.dialogLoading = bool; - } +setDefaultCondition(defaultcondition) { + this.defaultCondition = defaultcondition; +} - setNeDialogTitle(title) { - this.nEdialogTitle = title; - } +setTemplates(datas) { + this.templates = datas; +} - setIsNew(bool) { - this.isNew = bool; - } +setCustomTemplates(datas) { + this.customTemplates = datas; +} - setCondition(condition) { - this.condition = condition; - } +setScLoadingStatus(bool) { + this.searchConditionLoading = bool; +} - setUserId(userId) { - this.userId = userId; +setPanelStatus(bool) { + this.isPanelShow = bool; + this.search = true; + this.searchDialog.loading = true; + this.getSearchTemplate(bool); + bool && this.getSearchCondition(); + if (!bool) { + this.scLoadingReset(); } +} - setDate(date) { - this.date = date; - } +arrToJson(arr, rows, rowKey = "isused") { + let json = {}; + const _rows = isEmpty(arr) ? [] : rows; + _rows && _rows.map(index => { + arr[index][rowKey] = "1"; + }); + arr.map((item, index) => { + if (!item[rowKey]) item[rowKey] = "0"; + for (let key in item) { + json[key + "_" + index] = item[key]; + } + }); - setTopMenu(topMenu) { - this.topMenu = topMenu; - } + return json; +} - setRightMenu(rightMenu) { - this.rightMenu = rightMenu; - } +setLastName(val) { + this.lastName = val; +} - setHasRight(bool) { - this.hasRight = bool; +isEmptyObject(obj) { + for (let key in obj) { + return false; } + return true; +} + +setIds(ids) { + this.ids = ids; +} + +scLoadingReset() { + this.searchConditionLoading = true; +} + + +formReset() { + this.form = new WeaForm(); +} + +dialogLoadingReset() { + this.dialogLoading = true; +} + +setVisible(bool) { + this.visible = bool; + this.formReset(); + !bool && this.dialogLoadingReset(); +} + +setDialogLoadingStatus(bool) { + this.dialogLoading = bool; +} + +setNeDialogTitle(title) { + this.nEdialogTitle = title; +} + +setIsNew(bool) { + this.isNew = bool; +} + +setCondition(condition) { + this.condition = condition; +} + +setUserId(userId) { + this.userId = userId; +} + +setDate(date) { + this.date = date; +} + +setTopMenu(topMenu) { + this.topMenu = topMenu; +} + +setRightMenu(rightMenu) { + this.rightMenu = rightMenu; +} + +setHasRight(bool) { + this.hasRight = bool; +} } \ No newline at end of file