diff --git a/pc4mobx/organization/apis/resource.js b/pc4mobx/organization/apis/resource.js index dab4bce..577310a 100644 --- a/pc4mobx/organization/apis/resource.js +++ b/pc4mobx/organization/apis/resource.js @@ -67,6 +67,17 @@ export const saveSearchTemplate = (params) => { }) } +export const saveCustomTemplate = (params) => { + return fetch('/api/bs/hrmorganization/hrmresource/saveCustomTemplate', { + method: 'POST', + mode: 'cors', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(params) + }) +} + export const deleteSearchTemplate = (params) => { return fetch('/api/bs/hrmorganization/hrmresource/deleteSearchTemplate', { @@ -85,4 +96,13 @@ export const getSearchTemplate = (id) => { export const getTemplateSelectKeys = (id) => { return WeaTools.callApi(`/api/bs/hrmorganization/hrmresource/getTemplateSelectKeys?templateId=${id}`, 'GET'); -} \ No newline at end of file +} + + +export const getEditTable = () => { + return WeaTools.callApi('/api/bs/hrmorganization/cardAccess/getCardButtonTable', 'GET'); +} + +export const getCustomTransferData = (id) => { + return WeaTools.callApi(`/api/bs/hrmorganization/hrmresource/getCustomTransferData?templateId=${id}`, 'GET'); +} diff --git a/pc4mobx/organization/components/NewWeaTableEditDialog.js b/pc4mobx/organization/components/NewWeaTableEditDialog.js new file mode 100644 index 0000000..19a44f8 --- /dev/null +++ b/pc4mobx/organization/components/NewWeaTableEditDialog.js @@ -0,0 +1,59 @@ +import { + observer +} from 'mobx-react'; +import { + WeaDialog, + WeaTableEdit +} from 'ecCom'; +import { + Spin, + Button, Modal +} from 'antd' + +import * as mobx from "mobx"; +const toJS = mobx.toJS; + +@observer +export default class NewWeaTableEditDialog extends React.Component { + constructor(props) { + super(props); + } + + onRowSelect = (sRowKeys, rows, dataIndex, selectedDatas) => { + const { store } = this.props; + if (dataIndex === undefined || selectedDatas === undefined) { + return; + } + store.setEnableRows(selectedDatas.isused); + }; + + render() { + const { + store, + } = this.props, { + temlateManageDialog, + relatedData + } = store; + const { datas, columns, loading,selectedData } = relatedData; + + return ( + + store.setTableEditDatas(e)} + onRowSelect={(sRowKeys, rows, dataIndex, selectedDatas) => this.onRowSelect(sRowKeys, rows, dataIndex, selectedDatas)} + /> + + ); + } +} \ No newline at end of file diff --git a/pc4mobx/organization/components/resource/SearchCustomDialog.js b/pc4mobx/organization/components/resource/SearchCustomDialog.js index ed9e5d2..f82fb31 100644 --- a/pc4mobx/organization/components/resource/SearchCustomDialog.js +++ b/pc4mobx/organization/components/resource/SearchCustomDialog.js @@ -3,12 +3,18 @@ import { } from 'mobx-react'; import { WeaDialog, + WeaFormItem, + WeaInput } from 'ecCom'; import Customization from './Customization'; import { Spin, - Button, + Button,Modal } from 'antd' +import { + i18n +} from '../../public/i18n'; +const confirm = Modal.confirm; @observer export default class SearchCustomDialog extends React.Component { @@ -16,18 +22,47 @@ export default class SearchCustomDialog extends React.Component { super(props); } + + saveCustomTemplate() { + const { + store + } = this.props, { + customTemplateName + } = store; + + confirm({ + title: "存为模板", + content: + + store.customTemplateName = v} /> + , + okText: i18n.button.save(), + cancelText: i18n.button.cancel(), + onOk() { + store.saveCustomTemplate(); + }, + onCancel() { + return false; + }, + }); + } + render() { const { - store + store, } = this.props, { SEARCHDIALOG, searchDialog, - search + search, + searchTemplateName } = store; const buttons = [ , - , - + , + ] diff --git a/pc4mobx/organization/components/resource/resource.js b/pc4mobx/organization/components/resource/resource.js index 511d048..bf65163 100644 --- a/pc4mobx/organization/components/resource/resource.js +++ b/pc4mobx/organization/components/resource/resource.js @@ -41,6 +41,7 @@ import NewAndEditDialog from '../NewAndEditDialog'; import { renderNoright } from '../../util'; import DatasImport from '../import/datasImport'; import SearchCustomDialog from './SearchCustomDialog'; +import NewWeaTableEditDialog from '../NewWeaTableEditDialog'; @@ -569,7 +570,9 @@ export default class Resource extends React.Component { /> + store={store}/> + ) } diff --git a/pc4mobx/organization/stores/resource.js b/pc4mobx/organization/stores/resource.js index 929789c..5234f47 100644 --- a/pc4mobx/organization/stores/resource.js +++ b/pc4mobx/organization/stores/resource.js @@ -1,7 +1,8 @@ import { observable, action, - computed + computed, + extendObservable } from 'mobx'; import * as mobx from 'mobx'; import * as Api from '../apis/resource'; // 引入API接口文件 @@ -136,11 +137,14 @@ export class ResourceStore { } - @action("高级搜索表单") getSearchCondition() { + @action("高级搜索表单") getSearchCondition(key = true) { this.setScLoadingStatus(true); - const params = { + this.form2 = new WeaForm(); + let params = {}; + key ? params = { + templateId: this.searchTemplateId + } : params = { selectKeys: this.transfer.transferKeys, - templateId:this.searchTemplateId } Api.getAdvanceSearchCondition(params).then(res => { if (res.code === 200) { @@ -200,7 +204,8 @@ export class ResourceStore { @observable templates = []; @observable searchTemplateName = ''; @observable searchTemplateId = '-1'; - + @observable customTemplateName = ''; + @observable customTemplateId = '-1'; @observable search = false; SEARCHDIALOG = { @@ -215,7 +220,6 @@ export class ResourceStore { moreBtn: { datas: [] }, - } @@ -238,10 +242,10 @@ export class ResourceStore { @action("常用条件定制保存") saveHrmSearchUserDefine = () => { this.closeSearchDialog(); - this.getSearchCondition(); + this.getSearchCondition(false); } - @action("高级搜索模板切换") changeSearchTemplate(v){ + @action("高级搜索模板切换") changeSearchTemplate(v) { this.searchTemplateId = v; this.getSearchCondition(); } @@ -295,7 +299,7 @@ export class ResourceStore { message.warning(error.msg); }) } - + @action("搜索模板保存") saveTemplate = () => { if (this.searchTemplateName == '') { @@ -328,18 +332,42 @@ export class ResourceStore { } + @action("常用定制列模板保存") saveCustomTemplate = () => { + if (this.customTemplateName == '') { + message.error("列定制模板名称不能为空"); + } 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.customization(); + } else { + message.warning(data.msg); + } + }).catch(error => { + message.warning(error.msg); + }) + } + + } + @action("搜索模板删除") deleteSearchTemplate = () => { - - if(this.searchTemplateId == -1) { + + if (this.searchTemplateId == -1) { return message.error("默认模板不可删除"); } - Api.deleteSearchTemplate({id:this.searchTemplateId}).then(response => { + 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); + message.success(data.msg); + this.searchTemplateId = '-1'; + this.setPanelStatus(true); } else { message.warning(data.msg); } @@ -348,6 +376,8 @@ export class ResourceStore { }) } + + inputSearchStyle = { width: "105px", float: "right", @@ -456,6 +486,54 @@ export class ResourceStore { }) } + @observable relatedData = { + datas: [], + columns: [], + loading: true, + selectedData: {} + }; + + @observable temlateManageDialog = { + title: '模板管理', + visible: false, + hasScroll: true, + icon: 'icon-coms-hrm', + iconBgcolor: '#217346', + onCancel: () => this.closeTemlateManageDialog(), + style: { + width: 500, + height: 650 + }, + buttons: [] + } + + @action("列定制模板管理") getEditTable() { + this.temlateManageDialog.visible = true; + this.relatedData.loading = true; + Api.getEditTable().then(result => { + if (result.code === 200) { + const { columns, datas, selectedData } = result.data; + extendObservable(this.relatedData, { + datas: datas, + columns: columns + }); + selectedData && extendObservable(this.relatedData, { + selectedData: selectedData + }); + extendObservable(this.relatedData, { + loading: false + }); + } else { + message.warning(result.msg); + } + + }, error => { + message.warning(error.msg); + }) + + } + + @action updateTransferleftIptVal = (v) => { @@ -488,6 +566,33 @@ export class ResourceStore { 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"] = ""; + } + } + }); + extendObservable(this.relatedData, { + datas: e + }); + } + + setEnableRows(e) { + extendObservable(this.relatedData, { + selectedData: { + isused: e + } + }); + }