From 04c7115ce5d2d376bbd27c24b5e92b1007807a03 Mon Sep 17 00:00:00 2001 From: Chengliang <1546584672@qq.com> Date: Thu, 25 Jul 2024 18:50:53 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8A=B1=E5=90=8D=E5=86=8C=E6=95=B4=E4=BD=93?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pc4mobx/organization/apis/resource.js | 4 + .../components/NewWeaTableEditDialog.js | 5 +- .../components/resource/SearchCustomDialog.js | 6 +- .../components/resource/resource.js | 43 +- pc4mobx/organization/stores/fieldDefined.js | 1 + pc4mobx/organization/stores/resource.js | 490 ++++++++++-------- pc4mobx/organization/style/common.less | 4 + 7 files changed, 307 insertions(+), 246 deletions(-) diff --git a/pc4mobx/organization/apis/resource.js b/pc4mobx/organization/apis/resource.js index 7e05037..81a2e76 100644 --- a/pc4mobx/organization/apis/resource.js +++ b/pc4mobx/organization/apis/resource.js @@ -115,6 +115,10 @@ export const saveColumnsCustomTemplate = (params) => { return WeaTools.callApi(`/api/bs/hrmorganization/hrmresource/saveColumnsCustomTemplate`, 'POST',params); } +export const setOverAll = (params) => { + return WeaTools.callApi(`/api/bs/hrmorganization/hrmresource/customOverall`, 'POST',params); +} + export const getEditTable = () => { return WeaTools.callApi('/api/bs/hrmorganization/hrmresource/getCustomTemplate', 'GET'); } diff --git a/pc4mobx/organization/components/NewWeaTableEditDialog.js b/pc4mobx/organization/components/NewWeaTableEditDialog.js index 0cbdb50..144ffce 100644 --- a/pc4mobx/organization/components/NewWeaTableEditDialog.js +++ b/pc4mobx/organization/components/NewWeaTableEditDialog.js @@ -3,7 +3,8 @@ import { } from 'mobx-react'; import { WeaDialog, - WeaTableEdit + WeaTableEdit, + WeaTableEditable } from 'ecCom'; import { Spin, @@ -44,7 +45,7 @@ export default class NewWeaTableEditDialog extends React.Component { search ? store.saveHrmSearchUserDefine() : store.saveCustomDefine()}>{getLabel(547360,'保存')}, , - + , + loginId == 1 ? : '' ] diff --git a/pc4mobx/organization/components/resource/resource.js b/pc4mobx/organization/components/resource/resource.js index 387f10c..e10bb12 100644 --- a/pc4mobx/organization/components/resource/resource.js +++ b/pc4mobx/organization/components/resource/resource.js @@ -79,7 +79,9 @@ export default class Resource extends React.Component { const { resource } = this.props; + resource.getHasRight(); + //1.获取快捷搜索内容 resource.getQuickSearchCondition(); let { hash } = window.location; hash = hash.split("?")[1].split("&"); @@ -143,7 +145,7 @@ export default class Resource extends React.Component { const type = event.node.props.type || '0'; const id = event.node.props.id || ''; let params = {}; - form2.resetConditionValue(); + form2.resetForm(); resource.setPanelStatus(false) // resource.tabkey = 'default_3'; resource.nodeType = type; @@ -290,7 +292,7 @@ export default class Resource extends React.Component { resource } = this.props; - resource.customization(); + resource.openCustomDialog(); } //存为模板 @@ -331,10 +333,10 @@ export default class Resource extends React.Component { const btn = [ (), (), - (), + (), (), (), ]; @@ -441,7 +443,21 @@ export default class Resource extends React.Component { isFormInit } = form2; - + arr.push( + {getLabel(547655,'模板选择')} + + { + resource.changeSearchTemplate(v) + }} + /> + + + ) + isFormInit && templates.length > 0 && defaultCondition.map((c, i) => { let _arr = []; c.items.map((field, index) => { @@ -456,22 +472,9 @@ export default class Resource extends React.Component { ), }) }) - arr.push( - {getLabel(547655,'模板选择')} - - { - resource.changeSearchTemplate(v) - }} - /> - - - ) + - arr.push() + arr.push() }) diff --git a/pc4mobx/organization/stores/fieldDefined.js b/pc4mobx/organization/stores/fieldDefined.js index ebe72a2..66a2959 100644 --- a/pc4mobx/organization/stores/fieldDefined.js +++ b/pc4mobx/organization/stores/fieldDefined.js @@ -824,6 +824,7 @@ this.spinning = false; } @action("分组维护") doGroupSetting = () => { + debugger this.tableEditConfig.groupSetting.datas.length = 0; let arr = []; this.tabRecord.map(tabInfo => { diff --git a/pc4mobx/organization/stores/resource.js b/pc4mobx/organization/stores/resource.js index 880c63d..e942ff5 100644 --- a/pc4mobx/organization/stores/resource.js +++ b/pc4mobx/organization/stores/resource.js @@ -24,6 +24,8 @@ import { } from '../public/i18n'; import { getSecondPath } from '../util/index' import { cloneDeep, isEmpty, trim } from 'lodash'; +import HrmBaseStore from './baseStore'; + const getLabel = WeaLocaleProvider.getLabel; const toJS = mobx.toJS; @@ -32,7 +34,7 @@ const { } = WeaTableNew; -export class ResourceStore { +export class ResourceStore extends HrmBaseStore{ @observable tableStore = new TableStore(); @observable topMenu = [] @observable rightMenu = []; @@ -58,6 +60,7 @@ export class ResourceStore { @observable defaultShowLeft = true; @observable companysId = 1 @observable hasRight = ''; + @observable loginId = ''; @observable selectTreeNodeInfo; @@ -110,6 +113,7 @@ export class ResourceStore { @action onRadioGroupChangeHandle = params => { this.radioParams = params; + this.form2.reset(); this.getTableInfo(); } @@ -119,9 +123,10 @@ export class ResourceStore { let params = {}; if(this.isEmptyObject(this.radioParams)) { params = { + isQuickSearch:false, ...this.selectTreeNodeInfo, - isQuickSearch:false } + //高级搜索内容为空 if (this.isEmptyObject(this.form2.getFormParams())) { params = { ...params, @@ -140,7 +145,7 @@ export class ResourceStore { isQuickSearch:true } } - this.form2.resetForm(); + //this.form2.resetForm(); Api.getSearchList(params).then(res => { if (res.code === 200) { res.data.datas && this.tableStore.getDatas(res.data.datas, 1); @@ -204,28 +209,7 @@ export class ResourceStore { } - @action("高级搜索表单") getSearchCondition(key = true) { - this.setScLoadingStatus(true); - this.form2 = new WeaForm(); - let params = {}; - key ? params = { - templateId: this.searchTemplateId - } : params = { - selectKeys: this.transfer.transferKeys, - } - Api.getAdvanceSearchCondition(params).then(res => { - if (res.code === 200) { - this.setScLoadingStatus(false); - res.data.conditions && this.setSearchCondition(res.data.conditions); - res.data.defaultcondition && this.setDefaultCondition(res.data.defaultcondition); - res.data.defaultcondition && this.form2.initFormFields(res.data.defaultcondition); - } else { - message.warning(res.msg); - } - }, error => { - message.warning(error.msg); - }) - } + @action("快捷搜索") getQuickSearchCondition() { Api.getQuickSearchCondition().then(res => { @@ -244,8 +228,15 @@ export class ResourceStore { Api.getHasRight().then(res => { if (res.code === 200) { this.setHasRight(res.data.hasRight); + this.loginId = res.data.loginId; + this.customTemplateId = res.data.customTemplateId; + this.searchTemplateId = res.data.searchTemplateId; res.data.rightMenu && this.setRightMenu(res.data.rightMenu); res.data.topMenu && this.setTopMenu(res.data.topMenu); + //1.获取高级搜索内容 + this.getHSearchTemplate(res.data.searchTemplateId); + //2.获取列定制内容 + this.getSearchTemplate(res.data.customTemplateId); } else { message.warning(res.msg); } @@ -279,12 +270,10 @@ export class ResourceStore { /** ============================================================================================= */ - @observable search = true; - @observable searchDialog = { visible: false, - loading: true + loading: false } @observable templates = []; @@ -345,155 +334,33 @@ export class ResourceStore { if (res.code === 200) { this.searchDialog.visible = false; this.getTableInfo(); + }else{ + message.error(getLabel(547857,'该模板字段内容仅管理员可操作,即将返回默认设置值')); + this.searchDialog.visible = false; + this.getTableInfo(); } }, error => { message.warning(error.msg); }) } - @action("高级搜索模板切换") changeSearchTemplate(v) { - this.searchTemplateId = v; - this.getSearchCondition(); - } - - @action("常用条件定制") formatTransfer = () => { - const transferDatas = [] - const transferKeys = [] - const transferOptions = [{ - key: "", - showname: "" - }] - this.transfer.transferSelectedKey = '0'; - this.transfer.transferleftIptVal = ''; - this.transfer.transferRightIptVal = ''; - this.searchCondition.forEach((c, idx) => { - transferOptions.push({ - key: `${idx}`, - showname: c.title, - }) - c.items.forEach((i) => { - transferDatas.push({ - id: i.domkey[0], - label: i.label, - title: c.title, - idx: `${idx}` - }) - }) - }) - this.defaultCondition.forEach((c, idx) => { - c.items.forEach((i) => { - transferKeys.push(i.domkey[0]); - }) - }) - this.transfer.transferDatas = transferDatas; - this.transfer.transferKeys = transferKeys; - this.transfer.transferOptions = transferOptions; - this.searchDialog.visible = true; - } - - @action("列定制") customization = (v = false) => { - this.openCustomDialog(v); - } - - @action("常用条件定制模板切换") getTemplateSelectKeys = v => { - if (!this.search) { - this.customTemplateId = v; - } - + @action("将当前模板应用到所有人") setOverAll = () => { + if (this.customTemplateId == '-1') { + return message.error(getLabel(547854,'默认模板不可应用,请选择其它模板')); + } const params = { - templateId: v, - type: this.search ? 'search' : 'custom' + templateId: this.customTemplateId } - Api.getTemplateSelectKeys(params).then(res => { + Api.setOverAll(params).then(res => { if (res.code === 200) { - this.transfer.transferKeys = res.data.split(","); - } else { - message.warning(res.msg); + message.success(res.msg); } }, error => { message.warning(error.msg); }) } - - @action("搜索模板保存") saveTemplate = () => { - if (this.searchTemplateName == '') { - message.error(getLabel(547651,'搜索模板的名称不能为空')); - } else { - const fields = []; - this.defaultCondition.forEach((c, idx) => { - c.items.forEach((i) => { - fields.push(i.domkey[0]); - }) - }) - const params = { - showname: this.searchTemplateName, - fields: fields.toString() - } - - Api.saveSearchTemplate(params).then(response => { - return response.json() - }).then(data => { - if (data.code === 200) { - this.searchTemplateId = data.data; - this.templates = []; - this.setPanelStatus(true); - } else { - message.warning(data.msg); - } - }).catch(error => { - message.warning(error.msg); - }) - } - - } - - @action("常用定制列模板保存") saveCustomTemplate = () => { - if (this.customTemplateName == '') { - message.error(getLabel(547652,'列定制模板的名称不能为空')); - } else { - const params = { - showname: this.customTemplateName, - fields: this.transfer.transferKeys.toString() - } - Api.saveCustomTemplate(params).then(response => { - return response.json() - }).then(data => { - if (data.code === 200) { - this.customTemplateId = data.data; - // this.getSearchTemplate(false); - this.customization(); - message.success(data.msg); - } else { - message.warning(data.msg); - } - }).catch(error => { - message.warning(error.msg); - }) - } - - } - - @action("搜索模板删除") deleteSearchTemplate = () => { - - if (this.searchTemplateId == -1) { - return message.error(getLabel(547653,'默认模板不可删除')); - } - Api.deleteSearchTemplate({ id: this.searchTemplateId }).then(response => { - return response.json() - }).then(data => { - if (data.code === 200) { - message.success(data.msg); - this.searchTemplateId = '-1'; - this.templates = []; - this.setPanelStatus(true); - } else { - message.warning(data.msg); - } - }).catch(error => { - message.warning(error.msg); - }) - } + @@ -595,12 +462,17 @@ export class ResourceStore { this.transfer.transferKeys = v; } - @action("模板") getSearchTemplate = (bool) => { + /******显示列定制功能 *************/ + @action("tab显示列定制点击") openCustomDialog = () => { + this.search = false; + this.searchDialog.visible = true; + } - Api.getSearchTemplate({ type: bool ? 'search' : 'custom',id: bool ? this.searchTemplateId : this.customTemplateId}).then(res => { + @action("列定制模板") getSearchTemplate = (customTemplateId) => { + Api.getSearchTemplate({ type: 'custom',id:customTemplateId}).then(res => { if (res.code === 200) { - bool ? this.setTemplates(res.data.templates) : this.setCustomTemplates(res.data.templates); - + this.setCustomTemplates(res.data.templates); + this.getCustomTransferData(); } else { message.warning(res.msg); } @@ -609,38 +481,52 @@ export class ResourceStore { }) } - @observable relatedData = { - datas: [], - columns: [], - loading: true, - selectedData: {} - }; - - @observable temlateManageDialog = { - title: getLabel(547582,'模板管理'), - visible: false, - hasScroll: true, - icon: 'icon-coms-hrm', - iconBgcolor: '#217346', - onCancel: () => this.closeTemlateManageDialog(), - style: { - width: 500, - height: 650 - }, - buttons: [] + @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; + + } else { + message.warning(result.msg); + } + }, error => { + message.warning(error.msg); + }) } - @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("列定制存为模板保存") saveCustomTemplate = () => { + if (this.customTemplateName == '') { + message.error(getLabel(547652,'列定制模板的名称不能为空')); + } else { + const params = { + showname: this.customTemplateName, + fields: this.transfer.transferKeys.toString() + }; + Api.saveCustomTemplate(params).then(response => { + return response.json() + }).then(res => { + if (res.code === 200) { + debugger + this.setCustomTemplates(res.data.result.templates); + this.setCustomTemplateId(res.data.result.id); + message.success(res.msg); + } else { + message.warning(res.msg); + } + }).catch(error => { + message.warning(error.msg); + }) + } } @action("列定制模板管理") getEditTable() { + this.searchDialog.visible = false; this.temlateManageDialog.visible = true; this.relatedData.loading = true; + this.relatedData.datas = []; Api.getEditTable().then(result => { if (result.code === 200) { const { columns, datas, selectedData } = result.data; @@ -663,16 +549,14 @@ export class ResourceStore { }) } - @action("保存") updateCustomTemplate() { + @action("列定制模板管理保存") updateCustomTemplate() { let params = this.editTableParams; Api.updateCustomTemplate(params).then(res => { let { code, msg } = res; if (code === 200) { message.success(msg || getLabel(30700,'操作成功')); - //返回默认模板 - this.customTemplateId = '-1'; - this.getEditTable(); - this.customization(); + this.getSearchTemplate(this.customTemplateId); + } else { message.error(msg); } @@ -681,17 +565,101 @@ export class ResourceStore { }); } - @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; + + /******************************************* 高级搜索内容******************************************/ + @action("高级搜索模板内容") getHSearchTemplate = (searchTemplateId) => { + Api.getSearchTemplate({ type: 'search',id: searchTemplateId }).then(res => { + if (res.code === 200) { + this.setTemplates(res.data.templates); + this.getSearchCondition(); } else { - message.warning(result.msg); + message.warning(res.msg); + } + }, error => { + message.warning(error.msg); + }) + + } + + //key为true时根据模板id查找模板内容 + @action("高级搜索表单") getSearchCondition(key = true) { + this.setScLoadingStatus(true); + this.form2 = new WeaForm(); + let params = {}; + key ? params = { + templateId: this.searchTemplateId + } : params = { + selectKeys: this.transfer.transferKeys, + } + Api.getAdvanceSearchCondition(params).then(res => { + if (res.code === 200) { + this.setScLoadingStatus(false); + res.data.conditions && this.setSearchCondition(res.data.conditions); + res.data.defaultcondition && this.setDefaultCondition(res.data.defaultcondition); + res.data.defaultcondition && this.form2.initFormFields(res.data.defaultcondition); + } else { + message.warning(res.msg); + } + }, error => { + message.warning(error.msg); + }) + } + + @action("高级搜索模板切换") changeSearchTemplate(v) { + this.searchTemplateId = v; + this.getSearchCondition(); + } + + @action("常用条件定制") formatTransfer = () => { + const transferDatas = [] + const transferKeys = [] + const transferOptions = [{ + key: "", + showname: "" + }] + this.transfer.transferSelectedKey = '0'; + this.transfer.transferleftIptVal = ''; + this.transfer.transferRightIptVal = ''; + this.searchCondition.forEach((c, idx) => { + transferOptions.push({ + key: `${idx}`, + showname: c.title, + }) + c.items.forEach((i) => { + transferDatas.push({ + id: i.domkey[0], + label: i.label, + title: c.title, + idx: `${idx}` + }) + }) + }) + this.defaultCondition.forEach((c, idx) => { + c.items.forEach((i) => { + transferKeys.push(i.domkey[0]); + }) + }) + this.transfer.transferDatas = transferDatas; + this.transfer.transferKeys = transferKeys; + this.transfer.transferOptions = transferOptions; + this.searchDialog.visible = true; + } + + + @action("高级搜索常用条件定制模板切换") getTemplateSelectKeys = v => { + 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 { + message.warning(res.msg); } }, error => { message.warning(error.msg); @@ -699,6 +667,88 @@ export class ResourceStore { } + @action("高级搜索模板保存") saveTemplate = () => { + if (this.searchTemplateName == '') { + message.error(getLabel(547651,'搜索模板的名称不能为空')); + } else { + const fields = []; + this.defaultCondition.forEach((c, idx) => { + c.items.forEach((i) => { + fields.push(i.domkey[0]); + }) + }) + const params = { + showname: this.searchTemplateName, + fields: fields.toString() + } + + Api.saveSearchTemplate(params).then(response => { + return response.json() + }).then(data => { + if (data.code === 200) { + this.setSearchTemplateId(data.data); + this.getHSearchTemplate(data.data); + } else { + message.warning(data.msg); + } + }).catch(error => { + message.warning(error.msg); + }) + } + + } + + + @action("高级搜索模板删除") deleteSearchTemplate = () => { + + if (this.searchTemplateId == -1) { + return message.error(getLabel(547653,'默认模板不可删除')); + } + Api.deleteSearchTemplate({ id: this.searchTemplateId }).then(response => { + return response.json() + }).then(data => { + if (data.code === 200) { + message.success(data.msg); + this.setSearchTemplateId('-1'); + this.getHSearchTemplate('-1'); + } else { + message.warning(data.msg); + } + }).catch(error => { + message.warning(error.msg); + }) + } + + @observable relatedData = { + datas: [], + columns: [], + loading: true, + selectedData: {} + }; + + @observable temlateManageDialog = { + title: getLabel(547582,'模板管理'), + visible: false, + hasScroll: true, + icon: 'icon-coms-hrm', + iconBgcolor: '#217346', + onCancel: () => this.closeTemlateManageDialog(), + style: { + width: 600, + height: 450 + }, + 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 updateTransferleftIptVal = (v) => { @@ -720,18 +770,11 @@ export class ResourceStore { - @action openSearchDialog = (bool) => { - this.search = bool; - this.searchDialog.loading = false; + @action("高级搜索显示列定制") openSearchDialog = () => { this.formatTransfer(); } - @action openCustomDialog = (bool) => { - this.search = bool; - this.searchDialog.loading = true; - this.getSearchTemplate(bool); - this.getCustomTransferData(); - } + @action closeSearchDialog = () => { this.searchDialog.visible = false; @@ -790,23 +833,26 @@ export class ResourceStore { this.templates = datas; } + @action setSearchTemplateId(id) { + this.searchTemplateId = id; + } + + @action setCustomTemplates(datas) { this.customTemplates = datas; } + @action setCustomTemplateId(id) { + this.customTemplateId = id; + } + setScLoadingStatus(bool) { this.searchConditionLoading = bool; } setPanelStatus(bool) { - this.isPanelShow = bool; this.search = true; - this.searchDialog.loading = true; - this.getSearchTemplate(bool); - bool && this.getSearchCondition(); - if (!bool) { - this.scLoadingReset(); - } + this.isPanelShow = bool; } arrToJson(arr, rows, rowKey = "isused") { diff --git a/pc4mobx/organization/style/common.less b/pc4mobx/organization/style/common.less index 45d2642..1562dec 100644 --- a/pc4mobx/organization/style/common.less +++ b/pc4mobx/organization/style/common.less @@ -38,6 +38,10 @@ width: 70px !important; } +//高级搜索表单内日期样式特殊处理 +.organization-search .wea-date-picker { + height:30px !important +} //集团管理