From 3ab51289d8364d7eb7093bffc4a0290f8cd91b06 Mon Sep 17 00:00:00 2001 From: MustangDeng <670124965@qq.com> Date: Mon, 25 Apr 2022 14:32:51 +0800 Subject: [PATCH] =?UTF-8?q?=E8=80=83=E5=8B=A4=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pc4mobx/hrmSalary/apis/attendance.js | 43 +++++++- .../components/importModal/modalStep1.js | 9 +- .../pages/dataAcquisition/attendance/index.js | 104 +++++++++++++++--- pc4mobx/hrmSalary/pages/salaryFile/index.js | 1 + pc4mobx/hrmSalary/stores/attendanceStore.js | 69 ++++++++++++ 5 files changed, 206 insertions(+), 20 deletions(-) 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