import React, { Component } from 'react'; import axios from 'axios'; import store from 'store'; import style from "styled-components"; import { Tabs, Breadcrumb, Steps, Button, message, Upload, Spin, DatePicker } from 'antd'; import { Link } from "dva/router"; const { TabPane } = Tabs; const { Step } = Steps; const { MonthPicker } = DatePicker; import { host } from '../../services/api'; import moment from 'moment'; export default class ImportSalary extends Component { constructor(props, context) { super(props, context); this.state = { // grantYears: moment(Date.now()).format('YYYY-MM'), grantYears: this.getPreMouth(), faileDisabled: 'none', //上传文件失败显示下载失败文件 failData: '', //上传文件失败返回的数据(链接) loading: false }; } componentWillMount() { } getPreMouth() { // return moment().format('YYYY-DD'); // 获取上一个月 const date = new Date(); const year = date.getFullYear(); const mouth = date.getMonth() + 1; // return year + '-' + mouth; if(mouth > 1) { return year + '-' + ((mouth - 1) >= 10?(mouth - 1): '0' + (mouth - 1)); }else { return (year - 1) + '-' + 12; } } //下载 handleClickLink = () => { return ( ); }; //选择月份核算 onPickMonth = (date, dateString) => { console.log(date, dateString); this.setState( { grantYears: dateString } ); }; //上传 handleClickUpload = () => { const uploadExcel = { name: 'xfile', // action: `${host}/system/com-depart/get-import-depart-json`, action: `${host}/task/com/salary/import-per-month-salary`, headers: { authorization: 'Basic c2Fhc3dlYjp3ZWI=', access_token: store.get('saas')['access_token'], Accesstoken: store.get('saas')['access_token']|| sessionStorage.userV5Token, }, showUploadList: false, data: { month: this.state.grantYears } }; const beforeUpload = file => { this.setState({ loading:true }); let ifError = true; if (file.name.indexOf('xls') === -1 && file.name.indexOf('xlsx') === -1) { this.setState({ loading:false }); message.error('请上传xls或xlsx文件!'); ifError = false; } return ifError; }; //上传文件 const UploadChange = info => { this.setState({ faileDisabled: 'none', // loading: true }); if (info.file.status === 'uploading') { return; } if (info.file.status === 'done') { const { data, msg, retType } = info.file.response; //"retType":"-1"为错误,data会有相应的路径值 //"retType":"0"为正确,data为空 if (retType === '-1') { message.error(msg); this.setState({ faileDisabled: 'block', failData: data }); } else if (retType === '0') { message.success(msg); } else { message.error(msg); } this.setState({ loading: false }); } }; return (
{ // return current && current > moment(parseInt(sessionStorage.getItem('requestDate'))).subtract(1, 'month'); // }} placeholder='请选择月份' defaultValue={moment().subtract(1, 'month')} />
导入失败信息表: { this.setState({ faileDisabled: 'none' }); }} > 点击下载
); }; render() { return (
薪酬核算 导入工资数据
); } } const Box = style.div`{ .import_salary{ margin:16px 0 8px 24px; } }`;