薪资项目保存
This commit is contained in:
parent
d5588c19f7
commit
829bda2c1f
|
|
@ -135,4 +135,16 @@ export const getCheckResultDetailList = params => {
|
|||
//薪资核算-获取导入组件前置参数
|
||||
export const getImportParams = params => {
|
||||
return WeaTools.callApi('/api/bs/hrmsalary/salaryAcct/checkResultRecord/list', 'POST', params);
|
||||
}
|
||||
|
||||
// 薪资记录--薪资核算列表
|
||||
export const getSalaryAcctList = params => {
|
||||
return fetch('/api/bs/hrmsalary/salaryacct/list', {
|
||||
method: 'POST',
|
||||
mode: 'cors',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(params)
|
||||
}).then(res => res.json())
|
||||
}
|
||||
|
|
@ -15,7 +15,7 @@ import moment from 'moment';
|
|||
|
||||
const { MonthPicker } = DatePicker;
|
||||
|
||||
@inject('baseTableStore')
|
||||
@inject('calculateStore')
|
||||
@observer
|
||||
export default class Calculate extends React.Component {
|
||||
constructor(props) {
|
||||
|
|
@ -23,10 +23,9 @@ export default class Calculate extends React.Component {
|
|||
this.state = {
|
||||
value: "",
|
||||
selectedKey: "0",
|
||||
modalParam:{
|
||||
startDate: moment(new Date()).format("YYYY-MM"),
|
||||
endDate: moment(new Date()).format("YYYY-MM")
|
||||
},
|
||||
startDate: moment(new Date()).format("YYYY-MM"),
|
||||
endDate: moment(new Date()).format("YYYY-MM"),
|
||||
searchValue: "",
|
||||
columns: columns.map(item => {
|
||||
if(item.dataIndex == 'cz') {
|
||||
item.render = () => (
|
||||
|
|
@ -41,9 +40,58 @@ export default class Calculate extends React.Component {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
const { calculateStore } = this.props;
|
||||
const { getSalaryAcctList } = calculateStore
|
||||
getSalaryAcctList({
|
||||
name:'',
|
||||
startMonthStr: moment(new Date()).format("YYYY-MM"),
|
||||
endMonthStr: moment(new Date()).format("YYYY-MM")
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 搜索
|
||||
handleSearch(value) {
|
||||
const { calculateStore } = this.props;
|
||||
const { getSalaryAcctList } = calculateStore
|
||||
getSalaryAcctList({
|
||||
name: value,
|
||||
startMonthStr: this.state.startDate,
|
||||
endMonthStr: this.state.endDate
|
||||
})
|
||||
}
|
||||
|
||||
// 开始日期变化监听
|
||||
handleStartDateChange(value) {
|
||||
const { calculateStore } = this.props;
|
||||
const { getSalaryAcctList } = calculateStore
|
||||
this.setState({startDate: value})
|
||||
getSalaryAcctList({
|
||||
name: this.state.searchValue,
|
||||
startMonthStr: value,
|
||||
endMonthStr: this.state.endDate
|
||||
})
|
||||
}
|
||||
|
||||
// 结束日期变化监听
|
||||
handleEndDataChange(value) {
|
||||
const { calculateStore } = this.props;
|
||||
const { getSalaryAcctList } = calculateStore
|
||||
this.setState({
|
||||
endDate: value
|
||||
})
|
||||
getSalaryAcctList({
|
||||
name: this.state.searchValue,
|
||||
startMonthStr: this.state.startDate,
|
||||
endMonthStr: value
|
||||
})
|
||||
}
|
||||
|
||||
render() {
|
||||
const { baseTableStore } = this.props;
|
||||
const { loading, hasRight, form, condition, tableStore, showSearchAd, getTableDatas, doSearch, setShowSearchAd } = baseTableStore;
|
||||
const { calculateStore } = this.props;
|
||||
const { salaryListDataSource, salaryListColumns, loading, hasRight, form, condition, tableStore, showSearchAd, getTableDatas, doSearch, setShowSearchAd } = calculateStore;
|
||||
const { modalParam } = this.state
|
||||
if (!hasRight && !loading) { // 无权限处理
|
||||
return renderNoright();
|
||||
|
|
@ -71,22 +119,24 @@ export default class Calculate extends React.Component {
|
|||
];
|
||||
|
||||
const topTab = [
|
||||
];
|
||||
];
|
||||
|
||||
const renderSearchOperationItem = () => {
|
||||
return <div></div>
|
||||
|
||||
}
|
||||
|
||||
const renderRightOperation = () => {
|
||||
const { startDate, endDate } = this.state;
|
||||
return (
|
||||
<div style={{display: "inline-block"}}>
|
||||
<Button type="primary" style={{marginRight: "10px"}} onClick={() => window.open("/spa/hrmSalary/static/index.html#/main/hrmSalary/calculateDetail")}>核算</Button>
|
||||
<div style={{display: "inline-block"}}>
|
||||
<WeaDatePicker
|
||||
format="yyyy-MM"
|
||||
value={modalParam.startDate}
|
||||
onChange={value => this.setState({ modalParam: {...modalParam, declareMonth: value} })}
|
||||
value={startDate}
|
||||
onChange={value =>
|
||||
this.handleStartDateChange(value)
|
||||
}
|
||||
/>
|
||||
{' '}
|
||||
至
|
||||
|
|
@ -94,16 +144,17 @@ export default class Calculate extends React.Component {
|
|||
<WeaDatePicker
|
||||
style={{marginLeft:"10px"}}
|
||||
format="yyyy-MM"
|
||||
value={modalParam.endDate}
|
||||
onChange={value => this.setState({ modalParam: {...modalParam, declareMonth: value} })}
|
||||
value={endDate}
|
||||
onChange={value => this.handleEndDataChange(value)}
|
||||
/>
|
||||
</div>
|
||||
<WeaInputSearch style={{marginLeft: "10px"}}/>
|
||||
<WeaInputSearch style={{marginLeft: "10px"}} value={this.state.searchValue} onChange={(value) => {this.setState({ searchValue:value })}} onSearch={(value) => {this.handleSearch(value)}}/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
<div className="mySalaryBenefitsWrapper">
|
||||
<WeaRightMenu
|
||||
datas={rightMenu} // 右键菜单
|
||||
|
|
@ -122,10 +173,9 @@ export default class Calculate extends React.Component {
|
|||
renderRightOperation()
|
||||
}
|
||||
onChange={(v) => {
|
||||
|
||||
}}
|
||||
/>
|
||||
<WeaTable columns={columns} dataSource={dataSource}/>
|
||||
<WeaTable columns={salaryListColumns} dataSource={salaryListDataSource}/>
|
||||
</WeaTop>
|
||||
</WeaRightMenu>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@ export default class CustomSalaryItemSlide extends React.Component {
|
|||
super(props)
|
||||
this.state = {
|
||||
showForm: false,
|
||||
formalModalVisible: false
|
||||
formalModalVisible: false,
|
||||
formula: ""
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -26,6 +27,15 @@ export default class CustomSalaryItemSlide extends React.Component {
|
|||
})
|
||||
}
|
||||
|
||||
// 保存公式成功回调
|
||||
handleSaveFormal(data) {
|
||||
this.handleChange({formulaId: data.id})
|
||||
this.setState({
|
||||
formula: data.formula
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
render() {
|
||||
const { editable, request } = this.props;
|
||||
const { name, useDefault, useInEmployeeSalary, roundingMode, pattern, valueType, description, dataType } = request;
|
||||
|
|
@ -56,7 +66,7 @@ export default class CustomSalaryItemSlide extends React.Component {
|
|||
<Row className="formItem">
|
||||
<Col span={4}>薪资档案引用</Col>
|
||||
<Col span={20}>
|
||||
<Switch disabled={editable ? false: true} checked={useInEmployeeSalary == 1} onChange={(value) => {this.handleChange({useInEmployeeSalary: value})}}/>
|
||||
<Switch disabled={editable ? false: true} checked={useInEmployeeSalary == 1} onChange={(value) => {this.handleChange({useInEmployeeSalary: value? 1: 0})}}/>
|
||||
<WeaHelpfulTip
|
||||
style={{marginLeft: "10px"}}
|
||||
width={200}
|
||||
|
|
@ -113,7 +123,9 @@ export default class CustomSalaryItemSlide extends React.Component {
|
|||
<Col span={20}>
|
||||
<div style={{width: "100%", height: "30px", border: "1px solid rgb(217, 217, 217)"}}
|
||||
onClick={() => this.handleShowFormal()}
|
||||
></div>
|
||||
>
|
||||
{this.state.formula}
|
||||
</div>
|
||||
</Col>
|
||||
</Row>
|
||||
}
|
||||
|
|
@ -130,6 +142,9 @@ export default class CustomSalaryItemSlide extends React.Component {
|
|||
formalModalVisible &&
|
||||
<FormalFormModal
|
||||
visible={formalModalVisible}
|
||||
onSaveFormal={(data) => {
|
||||
this.handleSaveFormal(data)
|
||||
}}
|
||||
onCancel={() => this.setState({
|
||||
formalModalVisible: false
|
||||
})}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,11 @@ export default class FormalFormModal extends React.Component {
|
|||
formula: this.state.value,
|
||||
parameters: this.parameters
|
||||
}
|
||||
saveFormual(params)
|
||||
|
||||
saveFormual(params).then(data => {
|
||||
this.props.onSaveFormal(data)
|
||||
this.props.onCancel()
|
||||
})
|
||||
}
|
||||
|
||||
// 字段点击回调
|
||||
|
|
@ -118,7 +122,6 @@ export default class FormalFormModal extends React.Component {
|
|||
return (
|
||||
<div style={{height: "25px", lineHeight: "25px", cursor: "pointer"}} key={item.fieldId} onClick={() => {this.handleFieldClick(item)}}>
|
||||
{item.name}
|
||||
|
||||
</div>
|
||||
)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -0,0 +1,78 @@
|
|||
import { observable, action, toJS } from 'mobx';
|
||||
import { message } from 'antd';
|
||||
import { WeaForm, WeaTableNew } from 'comsMobx';
|
||||
|
||||
import * as API from '../apis/calculate'; // 引入API接口文件
|
||||
|
||||
const { TableStore } = WeaTableNew;
|
||||
|
||||
export class calculateStore {
|
||||
@observable tableStore = new TableStore(); // new table
|
||||
@observable form = new WeaForm(); // nrew 一个form
|
||||
@observable condition = []; // 存储后台得到的form数据
|
||||
@observable hasRight = true; // 判断用户是有权限查看当前页面: 没有权限渲染无权限页面,有权限渲染数据
|
||||
@observable showSearchAd = false; // 高级搜索面板显示
|
||||
@observable loading = true; // 数据加载状态
|
||||
|
||||
// ** 薪资核算列表 **
|
||||
@observable salaryListDataSource = [];
|
||||
@observable salaryListColumns = [];
|
||||
|
||||
// 初始化操作
|
||||
@action
|
||||
doInit = () => {
|
||||
this.getCondition();
|
||||
this.getTableDatas();
|
||||
}
|
||||
|
||||
// 获得高级搜索表单数据
|
||||
@action
|
||||
getCondition = () => {
|
||||
API.getCondition().then(action(res => {
|
||||
if (res.api_status) { // 接口请求成功/失败处理
|
||||
this.condition = res.condition;
|
||||
this.form.initFormFields(res.condition); // 渲染高级搜索form表单
|
||||
} else {
|
||||
message.error(res.msg || '接口调用失败!')
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
// 渲染table数据
|
||||
@action
|
||||
getTableDatas = (params) => {
|
||||
this.loading = true;
|
||||
const formParams = this.form.getFormParams() || {};
|
||||
params = params || formParams;
|
||||
API.getTableDatas(params).then(action(res => {
|
||||
if (res.api_status) { // 接口请求成功/失败处理
|
||||
this.tableStore.getDatas(res.datas); // table 请求数据
|
||||
this.hasRight = res.hasRight;
|
||||
} else {
|
||||
message.error(res.msg || '接口调用失败!')
|
||||
}
|
||||
this.loading = false;
|
||||
}));
|
||||
}
|
||||
|
||||
@action
|
||||
setShowSearchAd = bool => this.showSearchAd = bool;
|
||||
|
||||
// 高级搜索 - 搜索
|
||||
@action doSearch = () => {
|
||||
this.getTableDatas();
|
||||
this.showSearchAd = false;
|
||||
}
|
||||
|
||||
@action
|
||||
getSalaryAcctList = (params = {}) => {
|
||||
API.getSalaryAcctList(params).then(res => {
|
||||
if(res.status) {
|
||||
this.salaryListDataSource = res.data.list;
|
||||
this.salaryListColumns = res.data.columns
|
||||
} else {
|
||||
message.error(res.errormsg || '获取失败');
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -14,6 +14,7 @@ import { LedgerStore } from './ledger'
|
|||
import { ArchivesStore } from './archives'
|
||||
import { salaryFileStore } from './salaryFile';
|
||||
import { payrollStore } from './payroll';
|
||||
import { calculateStore } from './calculate';
|
||||
|
||||
module.exports = {
|
||||
baseFormStore: new BaseFormStore(),
|
||||
|
|
@ -30,6 +31,7 @@ module.exports = {
|
|||
ledgerStore: new LedgerStore(),
|
||||
archivesStore: new ArchivesStore(),
|
||||
salaryFileStore: new salaryFileStore(),
|
||||
payrollStore: new payrollStore()
|
||||
payrollStore: new payrollStore(),
|
||||
calculateStore: new calculateStore()
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -40,8 +40,6 @@ export class SalaryItemStore {
|
|||
// 字段列表
|
||||
@observable searchFields = [];
|
||||
|
||||
|
||||
|
||||
// 设置字段列表
|
||||
@action
|
||||
setSearchFields = (searchFields) => {
|
||||
|
|
@ -277,12 +275,17 @@ export class SalaryItemStore {
|
|||
// 保存公式
|
||||
@action
|
||||
saveFormual = (params) => {
|
||||
API.saveFormual(params).then(res => {
|
||||
if(res.status) {
|
||||
message.success("保存成功");
|
||||
} else {
|
||||
message.error(res.errormsg || "保存失败");
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
API.saveFormual(params).then(res => {
|
||||
if(res.status) {
|
||||
message.success("保存成功");
|
||||
resolve(res.data)
|
||||
} else {
|
||||
message.error(res.errormsg || "保存失败");
|
||||
reject()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue