diff --git a/pc4mobx/hrmSalary/apis/calculate.js b/pc4mobx/hrmSalary/apis/calculate.js index 0a16ec46..98c463b2 100644 --- a/pc4mobx/hrmSalary/apis/calculate.js +++ b/pc4mobx/hrmSalary/apis/calculate.js @@ -422,4 +422,54 @@ export const comparisonResultList = (params) => { }).then(res => res.json()) } +// 线下对比--结果导入模板 +export const exportImportTemplate = (salaryAcctRecordId) => { + fetch('/api/bs/hrmsalary/salaryacct/comparisonresult/importtemplate/export?salaryAcctRecordId=' + salaryAcctRecordId).then(res => res.blob().then(blob => { + var filename=`线下对比导入模板.xlsx` + var a = document.createElement('a'); + var url = window.URL.createObjectURL(blob); + a.href = url; + a.download = filename; + a.click(); + window.URL.revokeObjectURL(url); + })) +} + +// 线下对比--导入预览 +export const previewComparisonResult = (params) => { + return fetch('/api/bs/hrmsalary/salaryacct/comparisonresult/preview', { + method: 'POST', + mode: 'cors', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(params) + }).then(res => res.json()) +} + +// 线下对比--导入 +export const importComparisonExcelAcctResult = (params) => { + return fetch('/api/bs/hrmsalary/salaryacct/comparisonresult/importExcelAcctResult', { + method: 'POST', + mode: 'cors', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(params) + }).then(res => res.json()) +} + +// 线下对比-导出 +export const exportComparisonResult = (salaryAcctRecordId) => { + fetch('/api/bs/hrmsalary/salaryacct/comparisonresult/export?salaryAcctRecordId=' + salaryAcctRecordId).then(res => res.blob().then(blob => { + var filename=`线下对比结果.xlsx` + var a = document.createElement('a'); + var url = window.URL.createObjectURL(blob); + a.href = url; + a.download = filename; + a.click(); + window.URL.revokeObjectURL(url); + })) +} + diff --git a/pc4mobx/hrmSalary/components/importModal/index.js b/pc4mobx/hrmSalary/components/importModal/index.js index fae64c62..dfa301c9 100644 --- a/pc4mobx/hrmSalary/components/importModal/index.js +++ b/pc4mobx/hrmSalary/components/importModal/index.js @@ -79,7 +79,7 @@ export default class ImportModal extends React.Component { this.props.step == 0 && ( {this.setState({fileId})}} onStep1Next={() => { this.handleStep1Next(); diff --git a/pc4mobx/hrmSalary/components/importModal/modalStep2.js b/pc4mobx/hrmSalary/components/importModal/modalStep2.js index 31ac0678..dc3589f9 100644 --- a/pc4mobx/hrmSalary/components/importModal/modalStep2.js +++ b/pc4mobx/hrmSalary/components/importModal/modalStep2.js @@ -1,5 +1,6 @@ import React from 'react' import { Table, Button } from 'antd' +import { WeaTable } from "ecCom" export default class ModalStep2 extends React.Component { @@ -11,7 +12,7 @@ export default class ModalStep2 extends React.Component { return (
- +
diff --git a/pc4mobx/hrmSalary/pages/calculateDetail/compareDetail.js b/pc4mobx/hrmSalary/pages/calculateDetail/compareDetail.js index f4b03f42..70ca863b 100644 --- a/pc4mobx/hrmSalary/pages/calculateDetail/compareDetail.js +++ b/pc4mobx/hrmSalary/pages/calculateDetail/compareDetail.js @@ -5,6 +5,8 @@ import { mergeDetailColumns, dataSource } from './columns' import { getQueryString } from '../../util/url' import CustomTab from '../../components/customTab' import { inject, observer } from 'mobx-react'; +import CompareDetailImportModal from './compareDetailImportModal' +import CustomTable from '../../components/customTable' @inject('calculateStore') @observer @@ -15,6 +17,8 @@ export default class CompareDetail extends React.Component { this.state = { onlyDiffEmployee: true, onlyDiffSalaryItem: true, + importModalVisible: false, + searchValue: "" } } @@ -24,16 +28,134 @@ export default class CompareDetail extends React.Component { const { calculateStore: {fetchComparisonResultList}} = this.props; const { onlyDiffEmployee, onlyDiffSalaryItem} = this.state; - fetchComparisonResultList(onlyDiffEmployee, onlyDiffSalaryItem, this.id) + let params = { + onlyDiffEmployee, + onlyDiffSalaryItem, + salaryAcctRecordId: this.id, + current: 1 + } + fetchComparisonResultList(params) + } + + // 计算差值 + calculateCompares(systemValue, excelValue) { + if(systemValue == null || excelValue == null) { + return "" + } + let systemNum = Number(systemValue) + let excelNum = Number(excelValue) + if (!isNaN(systemNum) || !isNaN(excelNum)) { // 数字 + return systemNum - excelNum + } + return "" + } + + getColumns(columns) { + let newColumns = [...columns] + newColumns = newColumns.filter(item => item.hide == "false") + newColumns.map(item => { + let n = Number(item.dataIndex) + if (!isNaN(n)) { // 数字 + item.render = (text, record) => { + return ( +
+
系统值:{record[item.dataIndex].acctResultValue}
+
线下值:{record[item.dataIndex].excelResultValue}
+
差值:{this.calculateCompares(record[item.dataIndex].acctResultValue, record[item.dataIndex].excelResultValue)}
+
+ ) + } + } + }) + return newColumns + } + + // 导入 + handleImportClick() { + this.setState({ + importModalVisible: true + }) } + // 分页变化 + handleDataPageChange(value) { + const { calculateStore: {fetchComparisonResultList}} = this.props; + const { onlyDiffEmployee, onlyDiffSalaryItem} = this.state; + let params = { + onlyDiffEmployee, + onlyDiffSalaryItem, + salaryAcctRecordId: this.id, + current: value + } + fetchComparisonResultList(params) + } + + // 只显示有差异的人员 变化 + onlyDiffEmployeeChange(value) { + let onlyDiffEmployee = value == 1 ? true : false + this.setState({onlyDiffEmployee}) + + const { calculateStore: {fetchComparisonResultList}} = this.props; + const { onlyDiffSalaryItem} = this.state; + + let params = { + onlyDiffEmployee, + onlyDiffSalaryItem, + salaryAcctRecordId: this.id, + employeeName: this.state.searchValue, + current: 1 + } + + fetchComparisonResultList(params) + } + + // 只显示有差异的薪资项目 变化 + onlyDiffSalaryItemChange(value) { + let onlyDiffSalaryItem = value == 1 ? true : false + this.setState({onlyDiffSalaryItem}) + const { calculateStore: {fetchComparisonResultList}} = this.props; + const { onlyDiffEmployee} = this.state; + let params = { + onlyDiffEmployee, + onlyDiffSalaryItem, + salaryAcctRecordId: this.id, + employeeName: this.state.searchValue, + current: 1 + } + fetchComparisonResultList(params) + } + + // 搜索 + handleSearch(value) { + const { calculateStore: {fetchComparisonResultList}} = this.props; + const { onlyDiffEmployee, onlyDiffSalaryItem } = this.state + let params = { + onlyDiffEmployee, + onlyDiffSalaryItem, + salaryAcctRecordId: this.id, + employeeName: value, + current: 1 + } + fetchComparisonResultList(params) + } + + // 导出 + handleExportClick() { + const { calculateStore: {exportComparisonResult}} = this.props; + exportComparisonResult(this.id) + } + render() { + const { calculateStore: {comparisonResultPageInfo, comparisonResultTableStore, loading}} = this.props; + const { importModalVisible, searchValue } = this.state; const renderRightOperation = () => { return (
- - - + + + {this.setState({ + searchValue: value + })}} onSearch={(value) => {this.handleSearch(value)}}/>
) } @@ -43,16 +165,14 @@ export default class CompareDetail extends React.Component {
{ - this.setState({ - onlyDiffEmployee: value == 1 - }) + this.onlyDiffEmployeeChange(value) + }} + /> + { + this.onlyDiffSalaryItemChange(value) }} /> - { - this.setState({ - onlyDiffSalaryItem: value == 1 - }) - }}/>
) } @@ -74,9 +194,31 @@ export default class CompareDetail extends React.Component {
- + {this.handleDataPageChange(value)}, + total: comparisonResultPageInfo.total, + current: comparisonResultPageInfo.pageNum + }} + />
+ { + importModalVisible && { + this.setState({ + importModalVisible: false + }) + }} + /> + } + + ) diff --git a/pc4mobx/hrmSalary/pages/calculateDetail/compareDetailImportModal.js b/pc4mobx/hrmSalary/pages/calculateDetail/compareDetailImportModal.js new file mode 100644 index 00000000..1fd7c451 --- /dev/null +++ b/pc4mobx/hrmSalary/pages/calculateDetail/compareDetailImportModal.js @@ -0,0 +1,65 @@ +import React from 'react' +import ImportModal from '../../components/importModal' +import { inject, observer } from 'mobx-react'; + +@inject('calculateStore') +@observer +export default class CompareDetailImportModal extends React.Component { + constructor(props) { + super(props) + this.state = { + step: 0, + modalParam: { + salaryAcctRecordId: "" + } + } + } + + componentWillMount() { + const { id } = this.props; + let modalParam = { ...this.state.modalParam } + modalParam.salaryAcctRecordId = id + this.setState({ + modalParam + }) + } + + // 设置步骤 + setStep(step) { + this.setState({step}) + } + + handleTemplateLink() { + const { calculateStore: { exportImportTemplate }} = this.props; + exportImportTemplate(this.props.id) + } + + render() { + const { visiable } = this.props; + const { step, modalParam } = this.state; + const { calculateStore } = this.props + const { previewComparisonResult, comparisonPreviewColumns, comparisonPreviewDataSource, importComparisonExcelAcctResult, comparisonImportAcctResult } = calculateStore + return ( +
+ { + visiable && { + this.handleFinish() + }} + previewImport={(params) => {previewComparisonResult(params)}} + importFile={(params) => {importComparisonExcelAcctResult(params)}} + templateLink={ () => { this.handleTemplateLink()}} + visiable={visiable} + onCancel={() => { this.props.onCancel() }} + /> + } +
+ ) + } +} \ No newline at end of file diff --git a/pc4mobx/hrmSalary/pages/calculateDetail/index.js b/pc4mobx/hrmSalary/pages/calculateDetail/index.js index d519cfa0..a050f3dd 100644 --- a/pc4mobx/hrmSalary/pages/calculateDetail/index.js +++ b/pc4mobx/hrmSalary/pages/calculateDetail/index.js @@ -68,6 +68,12 @@ export default class CalculateDetail extends React.Component { }) } + // 核算结果搜索 + handleSearch(value) { + const { calculateStore: { acctResultList }} = this.props; + acctResultList(this.id, value) + } + render() { const { selectedKey, modalParam, acctResultImportVisiable } = this.state; @@ -86,7 +92,11 @@ export default class CalculateDetail extends React.Component { {/* */} 更多 - + { + this.setState({searchValue: value}) + }} + onSearch={(value) => {this.handleSearch(value)}} + /> ) } @@ -116,7 +126,7 @@ export default class CalculateDetail extends React.Component { selectedKey == 0 && } { - selectedKey == 1 && + selectedKey == 1 && } { acctResultImportVisiable &&
@@ -114,7 +121,15 @@ export default class SalaryDetail extends React.Component { {/* {this.setState({visible: true})}}>校验异常:0 */}
- + {this.handleDataPageChange(value)}, + total: acctResultListPageInfo.total, + current: acctResultListPageInfo.pageNum + }} + />
{this.setState({visible: false})}}/> { diff --git a/pc4mobx/hrmSalary/pages/calculateDetail/userSure.js b/pc4mobx/hrmSalary/pages/calculateDetail/userSure.js index 52a57328..62d9e5d3 100644 --- a/pc4mobx/hrmSalary/pages/calculateDetail/userSure.js +++ b/pc4mobx/hrmSalary/pages/calculateDetail/userSure.js @@ -5,6 +5,7 @@ import { inject, observer } from 'mobx-react'; import { dataSource , monthOnMonthColumns, userSureColumns} from './columns' import "./index.less" import { getQueryString } from '../../util/url' +import CustomTable from '../../components/customTable' @inject('calculateStore') @observer @@ -14,6 +15,7 @@ export default class UserSure extends React.Component { this.state = { selectedKey: "0", selectedRowKeys: [], // table 选中项 + userListSearchValue: '', } this.id = "" } @@ -24,8 +26,8 @@ export default class UserSure extends React.Component { const { calculateStore } = this.props; const { salaryacctGetForm, acctemployeeList, reducedemployeeList, getSalarySobCycle } = calculateStore salaryacctGetForm(id) - acctemployeeList(id) - reducedemployeeList(id) + acctemployeeList({salaryAcctRecordId: id, employeeName: this.state.userListSearchValue, current: 1}) + reducedemployeeList({salaryAcctRecordId: id, employeeName: this.state.userListSearchValue, current: 1}) getSalarySobCycle(id) } @@ -35,8 +37,8 @@ export default class UserSure extends React.Component { let idList = ids.split(","); const { calculateStore: { saveAcctemployee, reducedemployeeList, acctemployeeList, checkTaxAgent }} = this.props; saveAcctemployee(this.id, idList).then(() => { - reducedemployeeList(this.id) - acctemployeeList(this.id) + reducedemployeeList({salaryAcctRecordId: this.id, employeeName: this.state.userListSearchValue, current: 1}) + acctemployeeList({salaryAcctRecordId: this.id, employeeName: this.state.userListSearchValue, current: 1}) checkTaxAgent(this.id) }) } @@ -64,8 +66,8 @@ export default class UserSure extends React.Component { content: '确认删除', onOk:() => { deleteAcctemployee(this.id, selectedRowKeys).then(() => { - reducedemployeeList(this.id) - acctemployeeList(this.id) + reducedemployeeList({salaryAcctRecordId: this.id, employeeName: this.state.userListSearchValue, current: 1}) + acctemployeeList({salaryAcctRecordId: this.id, employeeName: this.state.userListSearchValue, current: 1}) }) }, onCancel: () => { @@ -105,8 +107,8 @@ export default class UserSure extends React.Component { content: '确认删除', onOk:() => { deleteAcctemployee(this.id, [record.id]).then(() => { - reducedemployeeList(this.id) - acctemployeeList(this.id) + reducedemployeeList({salaryAcctRecordId: this.id, employeeName: this.state.userListSearchValue, current: 1}) + acctemployeeList({salaryAcctRecordId: this.id, employeeName: this.state.userListSearchValue,current: 1}) }) }, onCancel: () => { @@ -119,13 +121,35 @@ export default class UserSure extends React.Component { handleRefresh = () => { const { calculateStore: {refreshTaxAgent, reducedemployeeList, acctemployeeList } } = this.props; refreshTaxAgent(this.id).then(() => { - reducedemployeeList(this.id) - acctemployeeList(this.id) + reducedemployeeList({salaryAcctRecordId: this.id, employeeName: this.state.userListSearchValue, current: 1}) + acctemployeeList({salaryAcctRecordId: this.id , employeeName: this.state.userListSearchValue, current: 1}) }) } onSelectChange = selectedRowKeys => { - this.setState({ selectedRowKeys }); + this.setState({ selectedRowKeys, userListSearchValue: "" }); + } + + // 核算人员范围分页 + handleUserListPageChange(value) { + const { calculateStore: {acctemployeeList}} = this.props; + acctemployeeList({acctemployeeList: this.id, employeeName: this.state.userListSearchValue, current: value}) + } + + // 环比减少人员分页 + handleReducedemployeeListPageChange(value) { + const { calculateStore: { reducedemployeeList }} = this.props; + reducedemployeeList({salaryAcctRecordId: this.id, employeeName: this.state.userListSearchValue, current: value}) + } + + // 搜索 + handleUserListSearch(value) { + const { calculateStore: {acctemployeeList, reducedemployeeList}} = this.props; + if(this.state.selectedKey == 0) { + acctemployeeList({acctemployeeList: this.id, employeeName: value, current: 1}) + } else { + reducedemployeeList({salaryAcctRecordId: this.id, employeeName: value, current: 1}) + } } render() { @@ -136,7 +160,10 @@ export default class UserSure extends React.Component { acctemployeeListColumns, reducedemployeeListDataSource, reducedemployeeListColumns, - baseSalarySobCycle + baseSalarySobCycle, + acctemployeeListPageInfo, + loading, + reducedemployeeListPageInfo } = calculateStore @@ -219,7 +246,9 @@ export default class UserSure extends React.Component { {this.handleRefresh()}}/> } - + { + this.setState({userListSearchValue: value}) + }} onSearch={(value) => {this.handleUserListSearch(value)}}/> @@ -227,10 +256,28 @@ export default class UserSure extends React.Component {
{ - this.state.selectedKey == 0 && + this.state.selectedKey == 0 && {this.handleUserListPageChange(value)}, + total: acctemployeeListPageInfo.total, + current: acctemployeeListPageInfo.pageNum + }} + /> } { - this.state.selectedKey == 1 && + this.state.selectedKey == 1 && {this.handleReducedemployeeListPageChange(value)}, + total: reducedemployeeListPageInfo.total, + current: reducedemployeeListPageInfo.pageNum + }} + /> }
diff --git a/pc4mobx/hrmSalary/stores/calculate.js b/pc4mobx/hrmSalary/stores/calculate.js index 6fd6a6be..aa2f5e2f 100644 --- a/pc4mobx/hrmSalary/stores/calculate.js +++ b/pc4mobx/hrmSalary/stores/calculate.js @@ -24,9 +24,11 @@ export class calculateStore { // 核算人员 @observable acctemployeeListDataSource = []; // dataSource @observable acctemployeeListColumns = []; // 列 + @observable acctemployeeListPageInfo = {}; // 分页信息 // 环比上期减少人员 @observable reducedemployeeListDataSource = []; // dataSource @observable reducedemployeeListColumns = []; // 列 + @observable reducedemployeeListPageInfo = {}; // 分页信息 // 薪资周期、考勤周期 @observable baseSalarySobCycle = {} @@ -36,6 +38,7 @@ export class calculateStore { @observable acctResultListColumns = []; // 列 @observable acctresultDetailForm = {}; // 编辑薪资表单数据 @observable acctResultListTableStore = new TableStore() + @observable acctResultListPageInfo = {}; // 分页信息 // 导入 @observable importFieldData = {}; // 表头选择列表 @observable acctResultImportPreview = {}; // 核算结果预览 @@ -45,8 +48,11 @@ export class calculateStore { @observable importAcctResult = {}; // 导入结果 //*** 线下比对 *** - @observable comparisonresultListDataSource = [];// dataSource - @observable comparisonresultListColumns = [];//列 + @observable comparisonResultPageInfo = [];// 线下对比列表pageInfo + @observable comparisonResultTableStore = new TableStore(); // tableStore + @observable comparisonPreviewColumns = []; // 线下对比预览列表 + @observable comparisonPreviewDataSource = []; // 线下对比列表数据 + @observable comparisonImportAcctResult = {}; // 导入结果 // 编辑薪资表单数据 @@ -148,11 +154,12 @@ export class calculateStore { // 核算人员--薪资核算人员确认列表 @action - acctemployeeList = (id = "") => { - API.acctemployeeList({salaryAcctRecordId: id}).then((res) => { + acctemployeeList = (params) => { + API.acctemployeeList(params).then((res) => { if(res.status) { this.acctemployeeListDataSource = res.data.list ? res.data.list : [] this.acctemployeeListColumns = res.data.columns; + this.acctemployeeListPageInfo = res.data } else { message.error(res.errormsg || "获取失败") } @@ -173,14 +180,17 @@ export class calculateStore { // 核算人员--薪资核算环比上期减少人员列表 @action - reducedemployeeList = (id = "") => { - API.reducedemployeeList({salaryAcctRecordId: id}).then(res => { + reducedemployeeList = (params) => { + this.loading = true + API.reducedemployeeList(params).then(res => { if(res.status) { this.reducedemployeeListDataSource = res.data.list ? res.data.list: []; this.reducedemployeeListColumns = res.data.columns; + this.reducedemployeeListPageInfo = res.data } else { message.error(res.errormsg || "获取失败") } + this.loading = false }) } @@ -243,11 +253,12 @@ export class calculateStore { // 核算结果--列表 @action - acctResultList = (salaryAcctRecordId, employeeName = "") => { - API.acctResultList({salaryAcctRecordId, employeeName}).then(res => { + acctResultList = (salaryAcctRecordId, employeeName = "", current = 1) => { + API.acctResultList({salaryAcctRecordId, employeeName, current}).then(res => { if(res.status) { this.acctResultListTableStore.getDatas(res.data.dataKey.datas) this.acctResultListDateSource = res.data.pageInfo.list ? res.data.pageInfo.list: []; + this.acctResultListPageInfo = res.data.pageInfo this.acctResultListColumns = res.data.columns; } else { message.error(res.errormsg || "") @@ -468,18 +479,66 @@ export class calculateStore { // 线下对比-列表 @action - fetchComparisonResultList = (onlyDiffEmployee, onlyDiffSalaryItem, salaryAcctRecordId) => { - let params = { - onlyDiffEmployee, - onlyDiffSalaryItem, - salaryAcctRecordId - } + fetchComparisonResultList = (params) => { + this.loading = true API.comparisonResultList(params).then(res => { if(res.status) { - this.comparisonResultList = res.data + this.comparisonResultPageInfo = res.data.pageInfo + this.comparisonResultTableStore.getDatas(res.data.dataKey.datas) + } else { + message.error(res.errormsg || "获取失败") + } + this.loading = false + }) + } + + // 线下对比-导入模板 + @action + exportImportTemplate = (salaryAcctRecordId) => { + API.exportImportTemplate(salaryAcctRecordId) + } + + // 线下对比--导入预览 + @action + previewComparisonResult = (params) => { + API.previewComparisonResult(params).then(res => { + if(res.status) { + this.comparisonPreviewColumns = res.data.headers.map((item, index) => { + let column = {} + column.title = item; + column.dataIndex = "" + index; + column.key = index + "" + return column + }) + + this.comparisonPreviewDataSource = res.data.list.map((item) => { + let data = {} + item.map((i, index) => { + data[index + ''] = i + }) + return data + }) } else { message.error(res.errormsg || "获取失败") } }) } + + // 线下对比-导入 + @action + importComparisonExcelAcctResult = (params) => { + API.importComparisonExcelAcctResult(params).then(res => { + if(res.status) { + this.comparisonImportAcctResult = res.data + } else { + message.error(res.errormsg || "获取失败") + } + }) + } + + // 线下对比-导出 + @action + exportComparisonResult = (salaryAcctRecordId) => { + API.exportComparisonResult(salaryAcctRecordId) + } } \ No newline at end of file