添加系统项目

This commit is contained in:
MustangDeng 2022-03-24 10:32:14 +08:00
parent c84976ce58
commit 1768c5bc70
10 changed files with 146 additions and 26 deletions

View File

@ -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())
}
//获取薪资项目可选的类型(与属性有联动)

View File

@ -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())
}
//复制薪资帐套

View File

@ -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 <Switch checked={text == 1}/>
case "useDefault":
return <Switch checked={text == 1}/>
default:
return <div dangerouslySetInnerHTML={{ __html: valueSpan }} />
}
}
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)}
/>
</WeaTop>
</WeaRightMenu>
<SystemSalaryItemModal visible={this.state.systemItemVisible} onCancel={() => {this.setState({systemItemVisible: false})}}/>
{
systemItemVisible && <SystemSalaryItemModal visible={systemItemVisible} onCancel={() => {setSystemItemVisible(false)}}/>
}
{
this.state.editSlideVisible &&

View File

@ -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 (
<Modal visible={this.props.visible} onCancel={() => {this.props.onCancel()}} width={800}>
<div style={{height: "47px", lineHeight: '47px'}}>
<span style={{marginLeft: "10px", fontSize: '14px'}}>添加系统薪资项目</span>
<div style={{float: "right", marginRight: "40px"}}>
<Button type="primary" style={{marginRight: '10px'}}>添加</Button>
<Button type="primary" style={{marginRight: '10px'}} onClick={() => {handleAdd()}}>添加</Button>
<WeaInputSearch />
</div>
</div>
<div style={{margin: "10px"}}>
<Table dataSource={dataSource} columns={systemItemColumns}/>
<WeaTable // table内部做了loading加载处理页面就不需要再加了
comsWeaTableStore={sysListTableStore} // table store
hasOrder={true} // 是否启用排序
needScroll={true} // 是否启用table内部列表滚动将自适应到父级高度
// getColumns={this.getColumns}
// onOperatesClick={this.onOperatesClick.bind(this)}
/>
</div>
</Modal>
)

View File

@ -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)
}
}

View File

@ -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 || '接口调用失败!')
}
}
})

View File

@ -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 || "修改失败")
}
})
}
}

View File

@ -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;
}));

View File

@ -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 || '接口调用失败!')
}
}
})

View File

@ -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 || '添加失败')
}
})
}
}