diff --git a/pc4mobx/organization/apis/resource.js b/pc4mobx/organization/apis/resource.js index d7d1e33..dab4bce 100644 --- a/pc4mobx/organization/apis/resource.js +++ b/pc4mobx/organization/apis/resource.js @@ -54,3 +54,35 @@ export const exportResource = (ids) => { window.URL.revokeObjectURL(url); })) } + + +export const saveSearchTemplate = (params) => { + return fetch('/api/bs/hrmorganization/hrmresource/saveSearchTemplate', { + method: 'POST', + mode: 'cors', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(params) + }) +} + + +export const deleteSearchTemplate = (params) => { + return fetch('/api/bs/hrmorganization/hrmresource/deleteSearchTemplate', { + method: 'POST', + mode: 'cors', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(params) + }) +} + +export const getSearchTemplate = (id) => { + return WeaTools.callApi(`/api/bs/hrmorganization/hrmresource/getSearchTemplate?templateId=${id}`, 'GET'); +} + +export const getTemplateSelectKeys = (id) => { + return WeaTools.callApi(`/api/bs/hrmorganization/hrmresource/getTemplateSelectKeys?templateId=${id}`, 'GET'); +} \ No newline at end of file diff --git a/pc4mobx/organization/components/resource/SearchCustomDialog.js b/pc4mobx/organization/components/resource/SearchCustomDialog.js index cd8b39b..ed9e5d2 100644 --- a/pc4mobx/organization/components/resource/SearchCustomDialog.js +++ b/pc4mobx/organization/components/resource/SearchCustomDialog.js @@ -5,6 +5,10 @@ import { WeaDialog, } from 'ecCom'; import Customization from './Customization'; +import { + Spin, + Button, +} from 'antd' @observer export default class SearchCustomDialog extends React.Component { @@ -17,14 +21,23 @@ export default class SearchCustomDialog extends React.Component { store } = this.props, { SEARCHDIALOG, - searchDialog + searchDialog, + search } = store; + const buttons = [ + , + , + + ] + return ( diff --git a/pc4mobx/organization/components/resource/resource.js b/pc4mobx/organization/components/resource/resource.js index aa7427d..511d048 100644 --- a/pc4mobx/organization/components/resource/resource.js +++ b/pc4mobx/organization/components/resource/resource.js @@ -7,6 +7,7 @@ import { import { WeaTop, WeaTab, + WeaInput, WeaFormItem, WeaRightMenu, WeaLeftRightLayout, @@ -280,6 +281,43 @@ export default class Resource extends React.Component { this[key] && this[key](); } + //列定制 + customization() { + const { + resource + } = this.props; + + resource.customization(); + } + + //存为模板 + saveTemplate() { + const { + resource + } = this.props, { + searchTemplateName + } = resource; + + confirm({ + title: "存为模板", + content: + + resource.searchTemplateName = v} /> + , + okText: i18n.button.save(), + cancelText: i18n.button.cancel(), + onOk() { + resource.saveTemplate(); + }, + onCancel() { + return false; + }, + }); + } + getTabBtn() { const { resource @@ -290,8 +328,8 @@ export default class Resource extends React.Component { const btn = [ (), - (), - (), + (), + (), (), (), ]; @@ -391,7 +429,8 @@ export default class Resource extends React.Component { defaultCondition, form2, searchConditionLoading, - templates + templates, + searchTemplateId } = resource; let arr = []; @@ -400,19 +439,20 @@ export default class Resource extends React.Component { isFormInit } = form2; - + arr.push( 选择过滤模板 { - + resource.changeSearchTemplate(v) }} /> - + ) isFormInit && defaultCondition.map((c, i) => { @@ -432,7 +472,7 @@ export default class Resource extends React.Component { arr.push() }) - + if (searchConditionLoading) { return (
@@ -440,7 +480,7 @@ export default class Resource extends React.Component {
) } else { - return
{ + return
{ if (e.keyCode == 13 && e.target.tagName === "INPUT") { rankScheme.getTableInfo(); rankScheme.setPanelStatus(false) diff --git a/pc4mobx/organization/stores/resource.js b/pc4mobx/organization/stores/resource.js index 8041274..929789c 100644 --- a/pc4mobx/organization/stores/resource.js +++ b/pc4mobx/organization/stores/resource.js @@ -6,7 +6,7 @@ import { import * as mobx from 'mobx'; import * as Api from '../apis/resource'; // 引入API接口文件 import { - WeaForm,WeaTableNew + WeaForm, WeaTableNew } from 'comsMobx'; import { Modal, @@ -14,32 +14,30 @@ import { Button } from 'antd' import { - WeaSelect, - WeaInputSearch, - WeaLocaleProvider, + WeaSelect, + WeaInputSearch, + WeaLocaleProvider, } from 'ecCom'; import { i18n } from '../public/i18n'; import trim from 'lodash/trim'; -import {getSecondPath} from '../util/index' +import { getSecondPath } from '../util/index' import cloneDeep from 'lodash/cloneDeep'; - const toJS = mobx.toJS; const { TableStore } = WeaTableNew; - - - export class ResourceStore { + + +export class ResourceStore { @observable tableStore = new TableStore(); @observable topMenu = [] @observable rightMenu = []; @observable condition = []; @observable searchCondition = []; @observable defaultCondition = []; - @observable templates=[]; @observable isEdit = true; @observable isNew = true; @observable isPanelShow = false; //高级搜索面板 @@ -48,7 +46,7 @@ const { @observable lastName = ''; @observable conditionNum = 8; @observable ids = ''; //选择行id - @observable searchConditionLoading = true; + @observable searchConditionLoading = false; @observable nEdialogTitle = ''; @observable visible = false; @observable dialogLoading = true; @@ -60,8 +58,8 @@ const { @observable hasRight = ''; @observable selectTreeNodeInfo; - - + + @action("列表") getTableInfo() { let params; this.tableStore = new TableStore(); @@ -88,8 +86,8 @@ const { } @action("nodetree事件") doSearch(params) { - this.selectTreeNodeInfo = params; - this.getTableInfo(); + this.selectTreeNodeInfo = params; + this.getTableInfo(); } @action("保存") save() { @@ -141,7 +139,8 @@ const { @action("高级搜索表单") getSearchCondition() { this.setScLoadingStatus(true); const params = { - selectKeys:this.transfer.transferKeys + selectKeys: this.transfer.transferKeys, + templateId:this.searchTemplateId } Api.getAdvanceSearchCondition(params).then(res => { if (res.code === 200) { @@ -149,7 +148,6 @@ const { 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); - res.data.templates && this.setTemplates(res.data.templates); } else { message.warning(res.msg); } @@ -173,7 +171,7 @@ const { }) } - @action("导出") export(){ + @action("导出") export() { const params = { ...this.form.getFormParams() } @@ -182,210 +180,313 @@ const { } @action("另存为版本") version(id) { - Api.version({id:id}).then(res => { - if (res.code === 200) { - message.success(res.msg); - } else { - message.warning(res.msg); - } + Api.version({ id: id }).then(res => { + if (res.code === 200) { + message.success(res.msg); + } else { + message.warning(res.msg); + } }, error => { - message.warning(error.msg); + message.warning(error.msg); }) } - /** ====================================================================================== */ + /** ============================================================================================= */ @observable searchDialog = { - visible: false, - title: '常用条件定制', - } + visible: false, + } + @observable templates = []; + @observable searchTemplateName = ''; + @observable searchTemplateId = '-1'; + + + @observable search = false; SEARCHDIALOG = { - hasScroll: false, - icon: 'icon-coms-hrm', - iconBgcolor: '#217346', - onCancel: () => this.closeSearchDialog(), - style: { - width: 700, - height: 450 - }, - moreBtn: { - datas: [] - }, - buttons: [], - } + hasScroll: false, + icon: 'icon-coms-hrm', + iconBgcolor: '#217346', + onCancel: () => this.closeSearchDialog(), + style: { + width: 700, + height: 450 + }, + moreBtn: { + datas: [] + }, + + } TRANSFER = { - height: 350, - renderItem: (items) => this.renderItem(items), - filterLeft: (items) => this.filterLeft(items), - filterRight: (items) => this.filterRight(items), - onChange: (v) => this.updateTransferKeys(v) - } + height: 350, + renderItem: (items) => this.renderItem(items), + filterLeft: (items) => this.filterLeft(items), + filterRight: (items) => this.filterRight(items), + onChange: (v) => this.updateTransferKeys(v) + } @observable transfer = { - transferDatas: [], - transferKeys: [], - transferOptions: [], - transferSelectedKey: '0', - transferleftIptVal: '', - transferRightIptVal: '' - } + transferDatas: [], + transferKeys: [], + transferOptions: [], + transferSelectedKey: '0', + transferleftIptVal: '', + transferRightIptVal: '' + } @action("常用条件定制保存") saveHrmSearchUserDefine = () => { this.closeSearchDialog(); this.getSearchCondition(); } + @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; - } + 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; + } + + @action("列定制") customization = (v) => { + this.openSearchDialog(false); + } + + @action("常用条件定制模板切换") getTemplateSelectKeys = v => { + Api.getTemplateSelectKeys(v).then(res => { + if (res.code === 200) { + this.transfer.transferKeys = res.data.split(","); + } else { + message.warning(res.msg); + } + }, error => { + message.warning(error.msg); + }) + } + + + @action("搜索模板保存") saveTemplate = () => { + if (this.searchTemplateName == '') { + message.error("搜索模板名称不能为空"); + } 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.setPanelStatus(true); + } else { + message.warning(data.msg); + } + }).catch(error => { + message.warning(error.msg); + }) + } + + } + + @action("搜索模板删除") deleteSearchTemplate = () => { + + if(this.searchTemplateId == -1) { + return message.error("默认模板不可删除"); + } + Api.deleteSearchTemplate({id:this.searchTemplateId}).then(response => { + return response.json() + }).then(data => { + if (data.code === 200) { + message.success(data.msg); + this.searchTemplateId = '-1'; + this.setPanelStatus(true); + } else { + message.warning(data.msg); + } + }).catch(error => { + message.warning(error.msg); + }) + } inputSearchStyle = { - width:"105px", - float:"right", - marginTop:"5px", - marginLeft:"10px" + width: "105px", + float: "right", + marginTop: "5px", + marginLeft: "10px" } - selectStyle={ - marginTop:"-1px", - width:"85px", - float:"right" + selectStyle = { + marginTop: "-1px", + width: "85px", + float: "right" } - @computed get leftHeader() { - const { - transferleftIptVal, - transferOptions, - transferSelectedKey - } = this.transfer; - return ( -
- 待选 - - -
- ) - } - - @computed get rightHeader() { - const { - transferRightIptVal - } = this.transfer; - return ( -
- 已选 - + @computed get leftHeader() { + const { + transferleftIptVal, + transferOptions, + transferSelectedKey + } = this.transfer; + return ( +
+ 待选 + +
- ) - } + ) + } + + @computed get rightHeader() { + const { + transferRightIptVal, + } = this.transfer; + return ( +
+ 已选 + + this.getTemplateSelectKeys(v)} + /> +
+ ) + } renderItem = (item) => { - const { - label, - title - } = item; - return (
-
{label}
-
{title}
-
) - }; + const { + label, + title + } = item; + return (
+
{label}
+
{title}
+
) + }; filterLeft = (items) => { - let leftItems = cloneDeep(items); - const { - transferleftIptVal, - transferSelectedKey - } = this.transfer; - if (transferSelectedKey) { - leftItems = leftItems.filter((item) => item.idx == transferSelectedKey) - } - if (trim(transferleftIptVal)) { - leftItems = leftItems.filter((item) => item.label.indexOf(trim(transferleftIptVal)) > -1) - } - return leftItems - } + let leftItems = cloneDeep(items); + const { + transferleftIptVal, + transferSelectedKey + } = this.transfer; + if (transferSelectedKey) { + leftItems = leftItems.filter((item) => item.idx == transferSelectedKey) + } + if (trim(transferleftIptVal)) { + leftItems = leftItems.filter((item) => item.label.indexOf(trim(transferleftIptVal)) > -1) + } + return leftItems + } - filterRight = (items) => { - let rightItems = cloneDeep(items); - const { - transferRightIptVal - } = this.transfer; - if (trim(transferRightIptVal)) { - rightItems = rightItems.filter((item) => item.label.indexOf(trim(transferRightIptVal)) > -1) - } - return rightItems - } + filterRight = (items) => { + let rightItems = cloneDeep(items); + const { + transferRightIptVal + } = this.transfer; + if (trim(transferRightIptVal)) { + rightItems = rightItems.filter((item) => item.label.indexOf(trim(transferRightIptVal)) > -1) + } + return rightItems + } @action("穿梭框变化回调") updateTransferKeys = (v) => { - this.transfer.transferKeys = v; - } + this.transfer.transferKeys = v; + } + + @action("高级搜索模板") getSearchTemplate = () => { + Api.getSearchTemplate(this.searchTemplateId).then(res => { + if (res.code === 200) { + res.data && this.setTemplates(res.data); + } else { + message.warning(res.msg); + } + }, error => { + message.warning(error.msg); + }) + } + + @action updateTransferleftIptVal = (v) => { - this.transfer.transferleftIptVal = v; - } + this.transfer.transferleftIptVal = v; + } - @action updateTransferSelectedKey = (v) => { - this.transfer.transferSelectedKey = v; - } + @action updateTransferSelectedKey = (v) => { + this.transfer.transferSelectedKey = v; + } - @action updateTransferRightptVal = (v) => { - this.transfer.transferRightIptVal = v; - } + @action updateTransferKeys = (v) => { + this.transfer.transferKeys = v; + } + + + @action updateTransferRightptVal = (v) => { + this.transfer.transferRightIptVal = v; + } - @action openSearchDialog = () => { - this.searchDialog.visible = true; + @action openSearchDialog = (bool) => { + this.search = bool; + this.searchDialog.visible = true; this.formatTransfer(); - } + } - @action closeSearchDialog = () => { - this.searchDialog.visible = false; - } + @action closeSearchDialog = () => { + this.searchDialog.visible = false; + } @@ -416,6 +517,7 @@ const { setPanelStatus(bool) { this.isPanelShow = bool; + this.getSearchTemplate(); bool && this.getSearchCondition(); if (!bool) { this.scLoadingReset(); @@ -491,5 +593,5 @@ const { setHasRight(bool) { this.hasRight = bool; } - - } \ No newline at end of file + +} \ No newline at end of file