From 829bda2c1f24b099fff4c4001eede3b2e414582e Mon Sep 17 00:00:00 2001 From: MustangDeng <670124965@qq.com> Date: Mon, 18 Apr 2022 16:57:42 +0800 Subject: [PATCH] =?UTF-8?q?=E8=96=AA=E8=B5=84=E9=A1=B9=E7=9B=AE=E4=BF=9D?= =?UTF-8?q?=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pc4mobx/hrmSalary/apis/calculate.js | 12 +++ pc4mobx/hrmSalary/pages/calculate/index.js | 82 +++++++++++++++---- .../pages/salaryItem/customSalaryItemSlide.js | 21 ++++- .../pages/salaryItem/formalFormModal.js | 7 +- pc4mobx/hrmSalary/stores/calculate.js | 78 ++++++++++++++++++ pc4mobx/hrmSalary/stores/index.js | 4 +- pc4mobx/hrmSalary/stores/salaryItem.js | 19 +++-- 7 files changed, 193 insertions(+), 30 deletions(-) create mode 100644 pc4mobx/hrmSalary/stores/calculate.js diff --git a/pc4mobx/hrmSalary/apis/calculate.js b/pc4mobx/hrmSalary/apis/calculate.js index 2fccc9c8..bd1029aa 100644 --- a/pc4mobx/hrmSalary/apis/calculate.js +++ b/pc4mobx/hrmSalary/apis/calculate.js @@ -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()) } \ No newline at end of file diff --git a/pc4mobx/hrmSalary/pages/calculate/index.js b/pc4mobx/hrmSalary/pages/calculate/index.js index b4faf56e..afbe2140 100644 --- a/pc4mobx/hrmSalary/pages/calculate/index.js +++ b/pc4mobx/hrmSalary/pages/calculate/index.js @@ -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
- } const renderRightOperation = () => { + const { startDate, endDate } = this.state; return (
this.setState({ modalParam: {...modalParam, declareMonth: value} })} + value={startDate} + onChange={value => + this.handleStartDateChange(value) + } /> {' '} 至 @@ -94,16 +144,17 @@ export default class Calculate extends React.Component { this.setState({ modalParam: {...modalParam, declareMonth: value} })} + value={endDate} + onChange={value => this.handleEndDataChange(value)} />
- + {this.setState({ searchValue:value })}} onSearch={(value) => {this.handleSearch(value)}}/>
) } return ( +
{ - }} /> - +
diff --git a/pc4mobx/hrmSalary/pages/salaryItem/customSalaryItemSlide.js b/pc4mobx/hrmSalary/pages/salaryItem/customSalaryItemSlide.js index 234383ab..c3965a1d 100644 --- a/pc4mobx/hrmSalary/pages/salaryItem/customSalaryItemSlide.js +++ b/pc4mobx/hrmSalary/pages/salaryItem/customSalaryItemSlide.js @@ -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 { 薪资档案引用 - {this.handleChange({useInEmployeeSalary: value})}}/> + {this.handleChange({useInEmployeeSalary: value? 1: 0})}}/>
this.handleShowFormal()} - >
+ > + {this.state.formula} +
} @@ -130,6 +142,9 @@ export default class CustomSalaryItemSlide extends React.Component { formalModalVisible && { + this.handleSaveFormal(data) + }} onCancel={() => this.setState({ formalModalVisible: false })} diff --git a/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js b/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js index b8433689..871de439 100644 --- a/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js +++ b/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js @@ -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 (
{this.handleFieldClick(item)}}> {item.name} -
) }) diff --git a/pc4mobx/hrmSalary/stores/calculate.js b/pc4mobx/hrmSalary/stores/calculate.js new file mode 100644 index 00000000..87a21d55 --- /dev/null +++ b/pc4mobx/hrmSalary/stores/calculate.js @@ -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 || '获取失败'); + } + }) + } +} \ No newline at end of file diff --git a/pc4mobx/hrmSalary/stores/index.js b/pc4mobx/hrmSalary/stores/index.js index 594052fd..c07dd0f7 100644 --- a/pc4mobx/hrmSalary/stores/index.js +++ b/pc4mobx/hrmSalary/stores/index.js @@ -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() }; diff --git a/pc4mobx/hrmSalary/stores/salaryItem.js b/pc4mobx/hrmSalary/stores/salaryItem.js index 32d44c51..cfcd030e 100644 --- a/pc4mobx/hrmSalary/stores/salaryItem.js +++ b/pc4mobx/hrmSalary/stores/salaryItem.js @@ -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() + } + }) }) + } } \ No newline at end of file