diff --git a/pc4mobx/hrmSalary/apis/item.js b/pc4mobx/hrmSalary/apis/item.js index 2c8697a6..43ce39d2 100644 --- a/pc4mobx/hrmSalary/apis/item.js +++ b/pc4mobx/hrmSalary/apis/item.js @@ -24,7 +24,14 @@ export const getSaCondition = params => { //薪资项目-系统薪资项目列表 export const getSysItemList = params => { - return WeaTools.callApi('/api/bs/hrmsalary/salaryitem/sysList', 'POST', params); + return fetch('/api/bs/hrmsalary/salaryitem/sysList', { + method: 'POST', + mode: 'cors', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(params) + }).then(res => res.json()) }; //系统薪资项目的高级搜索 @@ -54,7 +61,14 @@ export const getItemForm = params => { //薪资项目-添加系统薪资项目 export const saveSysItem = params => { - return WeaTools.callApi('/api/bs/hrmsalary/salaryitem/saveSys', 'POST', params); + return fetch('/api/bs/hrmsalary/salaryitem/saveSys', { + method: 'POST', + mode: 'cors', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(params) + }).then(res => res.json()) } //获取薪资项目可选的类型(与属性有联动) diff --git a/pc4mobx/hrmSalary/apis/ledger.js b/pc4mobx/hrmSalary/apis/ledger.js index 1a24ff6c..6e293bc3 100644 --- a/pc4mobx/hrmSalary/apis/ledger.js +++ b/pc4mobx/hrmSalary/apis/ledger.js @@ -14,7 +14,14 @@ export const getLedgerList = params => { //启用/禁用薪资帐套 export const changeLedgerStatus = params => { - return WeaTools.callApi('/api/bs/hrmsalary/salarysob/disable', 'POST', params); + return fetch('/api/bs/hrmsalary/salarysob/disable', { + method: 'POST', + mode: 'cors', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(params) + }).then(res => res.json()) } //复制薪资帐套 diff --git a/pc4mobx/hrmSalary/pages/salaryItem/index.js b/pc4mobx/hrmSalary/pages/salaryItem/index.js index 5fdf4bf1..c3d8bd22 100644 --- a/pc4mobx/hrmSalary/pages/salaryItem/index.js +++ b/pc4mobx/hrmSalary/pages/salaryItem/index.js @@ -27,7 +27,6 @@ export default class SalaryItem extends React.Component { this.state = { value: "", selectedKey: "0", - systemItemVisible: false, editSlideVisible: false } columns.map(item => { @@ -56,10 +55,31 @@ export default class SalaryItem extends React.Component { doInit(); } + // 增加编辑功能,重写columns绑定事件 + getColumns = (columns) => { + let newColumns = ''; + newColumns = columns.map(column => { + let newColumn = column; + newColumn.render = (text, record, index) => { //前端元素转义 + let valueSpan = record[newColumn.dataIndex + "span"] !== undefined ? record[newColumn.dataIndex + "span"] : record[newColumn.dataIndex]; + switch(newColumn.dataIndex) { + case "useInEmployeeSalary": + return + case "useDefault": + return + default: + return
+ } + } + return newColumn; + }); + return newColumns; + } + render() { const { salaryItemStore } = this.props; const { loading, hasRight, form, condition, tableStore, showSearchAd, getTableDatas, doSearch, setShowSearchAd } = salaryItemStore; - + const { systemItemVisible, setSystemItemVisible } = salaryItemStore if (!hasRight && !loading) { // 无权限处理 return renderNoright(); } @@ -89,8 +109,10 @@ export default class SalaryItem extends React.Component { ]; const handleMenuClick = (e) => { + const { salaryItemStore: {getSysItemList}} = this.props; if(e.key == "1") { - this.setState({systemItemVisible: true}) + getSysItemList({}) + setSystemItemVisible(true) } else if(e.key == "2") { this.setState({editSlideVisible: true}) } @@ -145,13 +167,16 @@ export default class SalaryItem extends React.Component { hasOrder={true} // 是否启用排序 needScroll={true} // 是否启用table内部列表滚动,将自适应到父级高度 - // getColumns={this.getColumns} + getColumns={this.getColumns} // onOperatesClick={this.onOperatesClick.bind(this)} /> - {this.setState({systemItemVisible: false})}}/> + { + systemItemVisible && {setSystemItemVisible(false)}}/> + + } { this.state.editSlideVisible && diff --git a/pc4mobx/hrmSalary/pages/salaryItem/systemSalaryItemModal.js b/pc4mobx/hrmSalary/pages/salaryItem/systemSalaryItemModal.js index 77378871..6f4dddca 100644 --- a/pc4mobx/hrmSalary/pages/salaryItem/systemSalaryItemModal.js +++ b/pc4mobx/hrmSalary/pages/salaryItem/systemSalaryItemModal.js @@ -2,20 +2,40 @@ import React from 'react' import { systemItemColumns, dataSource } from './columns' import { WeaInputSearch } from 'ecCom' import { Modal, Button, Table } from 'antd' +import { inject, observer } from 'mobx-react'; +import { WeaTableNew } from "comsMobx" +const WeaTable = WeaTableNew.WeaTable; +@inject('salaryItemStore') +@observer export default class SystemSalaryItemModal extends React.Component { + render() { + const { salaryItemStore } = this.props; + const { sysListTableStore } = salaryItemStore + + const handleAdd = () => { + const { salaryItemStore: { saveSysItem } } = this.props; + saveSysItem(); + } return ( {this.props.onCancel()}} width={800}>
添加系统薪资项目
- +
- + ) diff --git a/pc4mobx/hrmSalary/stores/cumDeduct.js b/pc4mobx/hrmSalary/stores/cumDeduct.js index 197fe913..906235f2 100644 --- a/pc4mobx/hrmSalary/stores/cumDeduct.js +++ b/pc4mobx/hrmSalary/stores/cumDeduct.js @@ -53,7 +53,7 @@ export class CumDeductStore { this.condition = res.data.condition; this.form.initFormFields(res.data.condition); // 渲染高级搜索form表单 } else { - message.error(res.msg || '接口调用失败!') + message.error(res.errormsg || '接口调用失败!') } })); } @@ -69,7 +69,7 @@ export class CumDeductStore { if (res.status) { // 接口请求成功/失败处理 this.tableStore.getDatas(res.data.datas); // table 请求数据 } else { - message.error(res.msg || '接口调用失败!') + message.error(res.errormsg || '接口调用失败!') } this.loading = false; })); @@ -116,7 +116,7 @@ export class CumDeductStore { if (res.status) { // 接口请求成功/失败处理 this.slideTableStore.getDatas(res.data.datas); // table 请求数据 } else { - message.error(res.msg || '接口调用失败!') + message.error(res.errormsg || '接口调用失败!') } } }) @@ -126,6 +126,7 @@ export class CumDeductStore { @action exportCumDeductDetailList = (id, ids = "") => { API.exportCumDeductDetailList(id, ids) } + } \ No newline at end of file diff --git a/pc4mobx/hrmSalary/stores/cumSituation.js b/pc4mobx/hrmSalary/stores/cumSituation.js index 9f707151..541f97a3 100644 --- a/pc4mobx/hrmSalary/stores/cumSituation.js +++ b/pc4mobx/hrmSalary/stores/cumSituation.js @@ -53,7 +53,7 @@ export class CumSituationStore { this.condition = res.data.condition; this.form.initFormFields(res.data.condition); // 渲染高级搜索form表单 } else { - message.error(res.msg || '接口调用失败!') + message.error(res.errormsg || '接口调用失败!') } })); } @@ -69,7 +69,7 @@ export class CumSituationStore { if (res.status) { // 接口请求成功/失败处理 this.tableStore.getDatas(res.data.datas); // table 请求数据 } else { - message.error(res.msg || '接口调用失败!') + message.error(res.errormsg || '接口调用失败!') } this.loading = false; })); @@ -116,7 +116,7 @@ export class CumSituationStore { if (res.status) { // 接口请求成功/失败处理 this.slideTableStore.getDatas(res.data.datas); // table 请求数据 } else { - message.error(res.msg || '接口调用失败!') + message.error(res.errormsg || '接口调用失败!') } } }) diff --git a/pc4mobx/hrmSalary/stores/ledger.js b/pc4mobx/hrmSalary/stores/ledger.js index 5ac7305e..7ce5a070 100644 --- a/pc4mobx/hrmSalary/stores/ledger.js +++ b/pc4mobx/hrmSalary/stores/ledger.js @@ -29,7 +29,7 @@ export class LedgerStore { this.condition = res.condition; this.form.initFormFields(res.condition); // 渲染高级搜索form表单 } else { - message.error(res.msg || '接口调用失败!') + message.error(res.errormsg || '接口调用失败!') } })); } @@ -42,7 +42,7 @@ export class LedgerStore { if (res.status) { // 接口请求成功/失败处理 this.tableStore.getDatas(res.data.datas); // table 请求数据 } else { - message.error(res.msg || '接口调用失败!') + message.error(res.errormsg || '接口调用失败!') } this.loading = false; })); @@ -64,9 +64,23 @@ export class LedgerStore { message.success("复制成功") this.getTableDatas({}); } else { - message.error("复制失败") + message.error(res.errormsg || "复制失败") } }) } + + //启用/禁用薪资帐套 + @action + changeLedgerStatus = (id, disable) => { + API.changeLedgerStatus({id, disable}).then(res => { + if(res.status) { + message.success("修改成功") + } else { + message.error(res.errormsg || "修改失败") + } + }) + } + + } \ No newline at end of file diff --git a/pc4mobx/hrmSalary/stores/mySalary.js b/pc4mobx/hrmSalary/stores/mySalary.js index 15ba00bf..f91a7010 100644 --- a/pc4mobx/hrmSalary/stores/mySalary.js +++ b/pc4mobx/hrmSalary/stores/mySalary.js @@ -48,7 +48,7 @@ export class MySalaryStore { this.condition = res.condition; this.form.initFormFields(res.condition); // 渲染高级搜索form表单 } else { - message.error(res.msg || '接口调用失败!') + message.error(res.errormsg || '接口调用失败!') } })); } @@ -74,7 +74,7 @@ export class MySalaryStore { this.tableStore.getDatas(res.datas); // table 请求数据 this.hasRight = res.hasRight; } else { - message.error(res.msg || '接口调用失败!') + message.error(res.errormsg || '接口调用失败!') } this.loading = false; })); diff --git a/pc4mobx/hrmSalary/stores/otherDeduct.js b/pc4mobx/hrmSalary/stores/otherDeduct.js index 5f96bf5f..af63ad88 100644 --- a/pc4mobx/hrmSalary/stores/otherDeduct.js +++ b/pc4mobx/hrmSalary/stores/otherDeduct.js @@ -53,7 +53,7 @@ export class OtherDeductStore { this.condition = res.data.condition; this.form.initFormFields(res.data.condition); // 渲染高级搜索form表单 } else { - message.error(res.msg || '接口调用失败!') + message.error(res.errormsg || '接口调用失败!') } })); } @@ -69,7 +69,7 @@ export class OtherDeductStore { if (res.status) { // 接口请求成功/失败处理 this.tableStore.getDatas(res.data.datas); // table 请求数据 } else { - message.error(res.msg || '接口调用失败!') + message.error(res.errormsg || '接口调用失败!') } this.loading = false; })); @@ -116,7 +116,7 @@ export class OtherDeductStore { if (res.status) { // 接口请求成功/失败处理 this.slideTableStore.getDatas(res.data.datas); // table 请求数据 } else { - message.error(res.msg || '接口调用失败!') + message.error(res.errormsg || '接口调用失败!') } } }) diff --git a/pc4mobx/hrmSalary/stores/salaryItem.js b/pc4mobx/hrmSalary/stores/salaryItem.js index 2589983e..e29356ee 100644 --- a/pc4mobx/hrmSalary/stores/salaryItem.js +++ b/pc4mobx/hrmSalary/stores/salaryItem.js @@ -8,11 +8,16 @@ const { TableStore } = WeaTableNew; export class SalaryItemStore { @observable tableStore = new TableStore(); // new table + @observable sysListTableStore = new TableStore(); @observable form = new WeaForm(); // nrew 一个form @observable condition = []; // 存储后台得到的form数据 @observable hasRight = true; // 判断用户是有权限查看当前页面: 没有权限渲染无权限页面,有权限渲染数据 @observable showSearchAd = false; // 高级搜索面板显示 @observable loading = true; // 数据加载状态 + @observable systemItemVisible = false; + + @action + setSystemItemVisible = systemItemVisible => this.systemItemVisible = systemItemVisible; // 初始化操作 @action @@ -29,7 +34,7 @@ export class SalaryItemStore { this.condition = res.condition; this.form.initFormFields(res.condition); // 渲染高级搜索form表单 } else { - message.error(res.msg || '接口调用失败!') + message.error(res.errormsg || '接口调用失败!') } })); } @@ -42,7 +47,7 @@ export class SalaryItemStore { if (res.status) { // 接口请求成功/失败处理 this.tableStore.getDatas(res.data.datas); // table 请求数据 } else { - message.error(res.msg || '接口调用失败!') + message.error(res.errormsg || '接口调用失败!') } this.loading = false; })); @@ -56,5 +61,39 @@ export class SalaryItemStore { this.getTableDatas(); this.showSearchAd = false; } + + // 薪资项目-系统薪资项目列表 + @action + getSysItemList = (params) => { + API.getSysItemList(params).then(res => { + if (res.status) { // 接口请求成功/失败处理 + this.sysListTableStore.getDatas(res.data.datas); // table 请求数据 + } else { + message.error(res.errormsg || '接口调用失败!') + } + }) + } + + //薪资项目-添加系统薪资项目 + @action + saveSysItem = () => { + let ids = toJS(this.sysListTableStore.selectedRowKeys) + if(ids.length == 0) { + message.warning("未选择任何条目"); + return + } + API.saveSysItem(ids).then(res => { + if(res.status) { + this.setSystemItemVisible(false) + this.getTableDatas({}); + message.success("添加成功") + } else { + message.error(res.errormsg || '添加失败') + } + }) + } + + + } \ No newline at end of file