bug修复

This commit is contained in:
MustangDeng 2022-05-19 15:13:31 +08:00
parent 4701ada4dc
commit 45e72e723f
4 changed files with 63 additions and 10 deletions

View File

@ -93,4 +93,17 @@ export const importBatch = (params) => {
}).then(res => res.json())
}
// 导出档案
export const exportArchives = (ids) => {
fetch('/api/bs/hrmsalary/scheme/export?ids=' + ids).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);
}))
}

View File

@ -2,7 +2,7 @@ import React from 'react';
import { inject, observer } from 'mobx-react';
import { toJS } from 'mobx';
import { Button, Table, DatePicker, Dropdown, Menu } from 'antd';
import { Button, Table, DatePicker, Dropdown, Menu, message } from 'antd';
import { WeaTop, WeaTab, WeaRightMenu, WeaRangePicker, WeaTable, WeaSlideModal } from 'ecCom';
// import { WeaTableNew } from "comsMobx"
@ -36,6 +36,7 @@ export default class Archives extends React.Component {
importVisible: false,
modalParam: {},
step: 0,
selectedRowKeys: []
}
this.record = {}
@ -60,13 +61,13 @@ export default class Archives extends React.Component {
let columns = [...tableStore.columns]
columns = columns.filter(item => item.hide == "false")
columns.map(item => {
item.width = item.oldWidth
item.width = "150px"
})
columns.push({
title: "操作",
dataIndex: "operate",
fixed: "right",
width: "200px",
width: "100px",
height: "auto",
render: (text, record) => {
return (<a onClick={() => {this.handleEdit(record)}}>编辑</a>)
@ -131,9 +132,14 @@ export default class Archives extends React.Component {
setImportResult({})
}
// 选项设置
onSelectChange = selectedRowKeys => {
this.setState({ selectedRowKeys });
}
render() {
const { archivesStore } = this.props;
const { selectedTab } = this.state;
const { selectedTab, selectedRowKeys } = this.state;
const { loading, hasRight, form, condition, tableStore, showSearchAd, getTableDatas, doSearch, setShowSearchAd,
previewCurDataColumns, previewCurDataDataSource, importResult
} = archivesStore;
@ -166,8 +172,24 @@ export default class Archives extends React.Component {
const topTab = [
];
const handleButtonClick = () => {}
const handleMenuClick = () => {}
// 导出全部
const handleButtonClick = () => {
const { archivesStore:{exportArchives}} = this.props;
exportArchives()
}
// 导出选中
const handleMenuClick = () => {
const { selectedRowKeys } = this.state;
console.log("selectedRowKeys", selectedRowKeys);
if(selectedRowKeys.length == 0) {
message.warning("未选择任何条目");
return
}
let ids = selectedRowKeys.join(",")
const { archivesStore:{exportArchives}} = this.props;
exportArchives(ids)
}
const btns = [
<Button type="primary" onClick={() => { this.handleBtnImport() }}>导入</Button>,
@ -185,6 +207,11 @@ export default class Archives extends React.Component {
return <div></div>
}
const rowSelection = {
selectedRowKeys,
onChange: this.onSelectChange,
};
return (
<div className="mySalaryBenefitsWrapper">
<WeaRightMenu
@ -224,7 +251,8 @@ export default class Archives extends React.Component {
loading={loading}
columns={this.getColumns()}
dataSource={dataSource}
scroll={{ x: 2300 }}
rowSelection={rowSelection}
scroll={{ x: this.getColumns().length > 0 ? this.getColumns().length * 150: 1000 }}
pagination={{
onChange: (value) => {this.handlePageChnage(value)},
total: pageInfo.total,

View File

@ -59,6 +59,7 @@ export default class Programme extends React.Component {
// 增加编辑功能重写columns绑定事件
getColumns = (columns) => {
let newColumns = columns.filter(item => item.dataIndex !== "id" && item.dataIndex !== "paymentArea")
newColumns = newColumns.map(column => {
let newColumn = column;
newColumn.render = (text, record, index) => { //前端元素转义

View File

@ -82,14 +82,14 @@ export class ArchivesStore {
// 初始化操作
@action
doInit = () => {
// this.getCondition();
this.getCondition();
this.getTableDatas();
}
// 获得高级搜索表单数据
@action
getCondition = () => {
API.getSaCondition().then(action(res => {
API.getCondition().then(action(res => {
if (res.status) { // 接口请求成功/失败处理
this.condition = res.data.condition;
this.form.initFormFields(res.data.condition); // 渲染高级搜索form表单
@ -107,7 +107,12 @@ export class ArchivesStore {
params = {...formParams, ...params};
API.getTable(params).then(action(res => {
if (res.status) { // 接口请求成功/失败处理
this.dataSource = res.data.datas;
this.dataSource = res.data.datas.map(item => {
item = {...item}
item.key = item.employeeId
return item;
})
console.log("this.dataSource:", this.dataSource)
// this.columns = res.data.columns;
this.tableStore.getDatas(res.data.dataKey.datas)
this.pageInfo = res.data.pageInfo
@ -233,4 +238,10 @@ export class ArchivesStore {
}
})
}
// 导出档案
@action
exportArchives = (ids = "") => {
API.exportArchives(ids)
}
}