diff --git a/pc4mobx/hrmSalary/apis/attendance.js b/pc4mobx/hrmSalary/apis/attendance.js index b749338c..8636296d 100644 --- a/pc4mobx/hrmSalary/apis/attendance.js +++ b/pc4mobx/hrmSalary/apis/attendance.js @@ -169,4 +169,45 @@ export const saveAttendanceFieldSettingAsDefault = params => { }, body: JSON.stringify(params) }).then(res => res.json()) -} \ No newline at end of file +} + + +// 考勤导入模板下载 +export const downloadTemplate = (salaryYearMonth, salarySobId) => { + // /api/bs/hrmsalary/attendQuote/downloadTemplate + fetch('/api/bs/hrmsalary/attendQuote/downloadTemplate?salaryYearMonth=' + salaryYearMonth + "&salarySobId=" + salarySobId).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 previewAttendQuote = (params) => { + return fetch('/api/bs/hrmsalary/attendQuote/preview', { + method: 'POST', + mode: 'cors', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(params) + }).then(res => res.json()) +} + +// 考勤数据导入 +export const importAttendQuoteData = (params) => { + return fetch('/api/bs/hrmsalary/attendQuote/importAttendQuoteData', { + method: 'POST', + mode: 'cors', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(params) + }).then(res => res.json()) +} + + diff --git a/pc4mobx/hrmSalary/components/importModal/modalStep1.js b/pc4mobx/hrmSalary/components/importModal/modalStep1.js index 16bf8b7b..47652105 100644 --- a/pc4mobx/hrmSalary/components/importModal/modalStep1.js +++ b/pc4mobx/hrmSalary/components/importModal/modalStep1.js @@ -80,7 +80,14 @@ export default class ModalStep1 extends React.Component {
-

1. 第一步,请选择导出的Excel文件或 点击这里下载模板; +

1. 第一步,请选择导出的Excel文件或 + { + (typeof this.props.templateLink) == "string" ? + 点击这里下载模板 + : + {this.props.templateLink()}}>点击这里下载模板 + } + {this.props.headerSetCompoent && this.props.headerSetCompoent }

2. 第二步,请一定要确定Excel文档中的格式是模板中的格式,没有被修改掉;

diff --git a/pc4mobx/hrmSalary/pages/dataAcquisition/attendance/index.js b/pc4mobx/hrmSalary/pages/dataAcquisition/attendance/index.js index 1509cf23..8e973f84 100644 --- a/pc4mobx/hrmSalary/pages/dataAcquisition/attendance/index.js +++ b/pc4mobx/hrmSalary/pages/dataAcquisition/attendance/index.js @@ -3,7 +3,7 @@ import { inject, observer } from 'mobx-react'; import { toJS } from 'mobx'; import { WeaTableNew } from "comsMobx" -import { Button, Table, DatePicker, Row, Col, Menu, Dropdown, Switch } from 'antd'; +import { Button, Table, DatePicker, Row, Col, Menu, Dropdown, Switch, Select, message } from 'antd'; import { WeaInputSearch, WeaSlideModal, WeaHelpfulTip, WeaCheckbox, WeaDatePicker, WeaTop, WeaTab, WeaRightMenu, WeaRangePicker, WeaSelect, WeaTable } from 'ecCom'; import moment from 'moment' @@ -25,6 +25,7 @@ import TipLabel from '../../../components/TipLabel' import ItemMangeFormModal from './itemMangeFormModal' const { RangePicker } = DatePicker; +const { Option } = Select @inject('attendanceStore') @@ -45,7 +46,10 @@ export default class Attendance extends React.Component { this.state = { value: "", selectedKey: "0", - modalParam: {}, + modalParam: { + salarySobId: "", + salaryYearMonth: moment(new Date()).format("YYYY-MM"), // 薪资所属月 + }, modalVisiable: false, selectItemVisible: false, refereAttendFormVisible: false, @@ -54,15 +58,21 @@ export default class Attendance extends React.Component { itemMangeValue: {}, fieldName: "", fieldSettingSearchValue: "", - fieldCurrent: 1 + fieldCurrent: 1, + inited: false } this.fieldSearch = {} this.listSearch = {} } componentWillMount() { - const { attendanceStore: { doInit }} = this.props; + const { attendanceStore: { doInit, getLedgerList }} = this.props; doInit() + getLedgerList().then(() => { + this.setState({ + inited: true + }) + }) } onShowSlide() { @@ -102,11 +112,46 @@ export default class Attendance extends React.Component { getAttendanceList(this.listSearch) } + // 下载导入模板链接点击 + handleTemplateLinkClick() { + const { attendanceStore: { downloadTemplate }} = this.props; + const { modalParam: {salarySobId, salaryYearMonth}} = this.state; + if(!salaryYearMonth || salaryYearMonth == "") { + message.warning("薪资所属月不能为空") + return + } + + if(!salarySobId || salarySobId == "") { + message.warning("薪资账套不能为空") + return + } + downloadTemplate(salaryYearMonth, salarySobId) + } + + // 导入预览 + handlePreviewImport(params) { + const { attendanceStore: {previewAttendQuote}} = this.props; + previewAttendQuote(params) + } + + // 考勤导入 + handleImport(params) { + const { attendanceStore: { importAttendQuoteData }} = this.props; + importAttendQuoteData(params) + } + + // 导入完成 + handleFinish() { + this.setState({modalVisiable: false}) + } + render() { const { attendanceStore } = this.props; + const { modalParam } = this.state; const { loading, hasRight, form, condition, tableStore, showSearchAd, getTableDatas, doSearch, setShowSearchAd } = attendanceStore; const { step, setStep, setSlideVisiable, slideVisiable, doBatchDelete, attendTableStore, fieldSettingAttendList, fieldSettingCustomList, setFieldSettingAttendList, setFieldSettingCustomList, searchFieldSettingList } = attendanceStore; - const { getAttendanceFieldSettingList, saveAttendanceFieldSetting, fieldDataSource, fieldTableStore, fieldPageInfo, attendanceDataSource, attendanceColumns, attendancePageInfo} = attendanceStore + const { getAttendanceFieldSettingList, saveAttendanceFieldSetting, fieldDataSource, fieldTableStore, fieldPageInfo, attendanceDataSource, attendanceColumns, attendancePageInfo, importLedgerList, + previewAttendQuoteColumns, previewAttendQuoteDataSource} = attendanceStore const selectedRowKeys = toJS(tableStore.selectedRowKeys) || []; // tableStore 右侧选中数组 if (!hasRight && !loading) { // 无权限处理 @@ -159,7 +204,7 @@ export default class Attendance extends React.Component { const renderSearchOperationItem = () => { return
- +
} @@ -193,22 +238,45 @@ export default class Attendance extends React.Component { 薪资所属月: { + this.setState({modalParam: {...modalParam, salaryYearMonth: value}}) + }} /> 薪资账套: - + { + this.state.inited && + + } 薪资周期: - 2022-03-01 ~ 2022-03-31 + { + moment(this.state.modalParam.salaryYearMonth + "-01").startOf("month").format("YYYY-MM-DD") + } + ~ + { + moment(this.state.modalParam.salaryYearMonth + "-01").endOf("month").format("YYYY-MM-DD") + } 考勤周期: - 2022-03-01 ~ 2022-03-31 + { + moment(this.state.modalParam.salaryYearMonth + "-01").startOf("month").format("YYYY-MM-DD") + } + ~ + { + moment(this.state.modalParam.salaryYearMonth + "-01").endOf("month").format("YYYY-MM-DD") + } @@ -467,16 +535,16 @@ export default class Attendance extends React.Component { {}} - previewImport={(params) => {}} - importFile={(params) => {}} + onFinish={() => {this.handleFinish()}} + previewImport={(params) => {this.handlePreviewImport(params)}} + importFile={(params) => {this.handleImport(params)}} headerSetCompoent={renderHeaderSetCompoent()} - templateLink={"/api/bs/hrmsalary/addUpDeduction/downloadTemplate"} + templateLink={() => {this.handleTemplateLinkClick()}} renderFormComponent={() => renderFormComponent()} visiable={this.state.modalVisiable} onCancel={() => { this.setState({modalVisiable: false})}} diff --git a/pc4mobx/hrmSalary/pages/salaryFile/index.js b/pc4mobx/hrmSalary/pages/salaryFile/index.js index 49d5d7ee..e5aeabe3 100644 --- a/pc4mobx/hrmSalary/pages/salaryFile/index.js +++ b/pc4mobx/hrmSalary/pages/salaryFile/index.js @@ -163,6 +163,7 @@ export default class SalaryFile extends React.Component { const { salaryFileStore } = this.props; const { loading, hasRight, form, condition, tableStore, showSearchAd, getTableDatas, doSearch, setShowSearchAd } = salaryFileStore; const { importType, previewColumns, previewDataSource, dataSource, currentId, editAgentVisible, setEditAgentVisible, pageInfo } = salaryFileStore; + const { selectedTab, step, selectedRowKeys } = this.state; if (!hasRight && !loading) { // 无权限处理 return renderNoright(); diff --git a/pc4mobx/hrmSalary/stores/attendanceStore.js b/pc4mobx/hrmSalary/stores/attendanceStore.js index ce0073f8..3cf6d2eb 100644 --- a/pc4mobx/hrmSalary/stores/attendanceStore.js +++ b/pc4mobx/hrmSalary/stores/attendanceStore.js @@ -35,6 +35,12 @@ export class AttendanceStore { @observable attendancePageInfo = {}; @observable attendanceColumns = []; + // 导入 + @observable importLedgerList = []; // 表单-账套列表 + @observable previewAttendQuoteList = []; // 导入-预览列表 + @observable previewAttendQuoteColumns = []; // 导入预览-列表对应列 + @observable previewAttendQuoteDataSource = []; // 导入预览-列表 + @action searchFieldSettingList = (value) => { if(value != "") { @@ -311,6 +317,69 @@ export class AttendanceStore { } }) } + + // 导入表单-账套列表 + @action + getLedgerList = () => { + return new Promise((resolve, reject) => { + API.getLedgerList({}).then(res => { + if(res.status) { + this.importLedgerList = res.data + resolve(this.importLedgerList) + } else { + message.error(res.errormsg || "获取失败") + reject() + } + }) + }) + + } + + // 下载导入模板 + @action + downloadTemplate = (salaryYearMonth, salarySobId) => { + API.downloadTemplate(salaryYearMonth, salarySobId) + } + + // 导入预览 + @action + previewAttendQuote = (params) => { + API.previewAttendQuote(params).then(res => { + if(res.status) { + this.previewAttendQuoteList = res.data + this.previewAttendQuoteColumns = res.data.headers.map((item, index) => { + let column = {} + column.title = item; + column.dataIndex = "" + index; + column.key = index + "" + return column + }) + + this.previewAttendQuoteDataSource = res.data.list.map((item) => { + let data = {} + item.map((i, index) => { + data[index + ''] = i + }) + return data + }) + + } else { + message.error(res.errormsg || "获取失败"); + } + }) + } + + // 考勤导入 + @action + importAttendQuoteData = (params) => { + API.importAttendQuoteData(params).then(res => { + if(res.status) { + + } else { + message.error(res.errormsg || "导入失败") + } + }) + } } \ No newline at end of file