import React, { Component } from "react";
import { connect } from "dva";
import "../financialWallet.less";
import { withRouter } from "dva/router";
import * as ajax from "../../../services/api";
import $modal from "../modal";
import { gup } from "../../../utils/utils";
import { SMS_OP_TRANSFER } from "../../../common/shortMessage";
import moment from 'moment';
import {
Alert,
Input,
Button,
Table,
Form,
Select,
Modal,
Upload,
Icon,
message,
Spin,
DatePicker
} from "antd";
const { Option } = Select;
const { MonthPicker } = DatePicker;
import dff from "../../../assets/images/wallet/dff2.png";
import ffsb from "../../../assets/images/wallet/ffsb1.png";
import ffcg from "../../../assets/images/wallet/ffcg1.png";
import ffze from "../../../assets/images/wallet/ffze1.png";
import Download from "./Download";
import UploadFile from "./UploadFile";
@connect(state => ({
global: state.global
}))
@withRouter
@Form.create()
export default class Messages extends Component {
constructor(props, context) {
super(props, context);
this.state = {
totalInfo: null,
grantInfo: null, //title等数据
// 搜索部分
searchData: {
// 表格数据请求参数
comGrantId: gup("comGrantId"),
keyword: "", //关键字
isCanGrant: "",
pageNumber: "1", // 页
pageSize: "10" //条目
},
isCanGrant: "",
keyword: "", //关键字
// 表格部分
tableList: [], // 表格数据
pagination: {
//分页数据
total: 1,
current: 1,
pageSize: 10,
showSizeChanger: true,
showQuickJumper: true
},
canAddData: false, //添加发放数据按钮是否显示
// 操作记录
operationVisibale: false,
operationPagination: {
total: 1,
current: 1,
pageSize: 10,
showSizeChanger: true,
showQuickJumper: true
},
operationList: [],
// 添加发放数据
addDataVisibale: false,
onlineSalaryDataSource: [],
grantDataSource: "1",
payrollList: [], //工资单列表
grantYearsDown:'',//选择导入线下数据的时候存储下选择的年月
};
}
componentDidMount() {
this.selectGrantDetailTotalMap();
//【薪资代发】根据id获取薪资代发记录
ajax.getComGrantInfoById({ comGrantId: gup("comGrantId") }).then(res => {
this.setState({
grantInfo: res.data
});
});
// 获取列表
this.getTable(this.state.searchData, list => {
/*
allGrantStatus
0 待发放
1 正在发放
2 部分完成
3 全部完成 */
// if(list.length == 0) {
// this.setState({
// canAddData: true
// });
// }
// this.state.grantInfo && this.state.grantInfo.allGrantStatus != 3
// 添加发放数据的判断 列表为空并且带发放数据大于零的时候
// list.length == 0 && this.state.totalInfo && this.state.totalInfo.toTotalSize > 0 && this.setState({
// canAddData: true
// });
});
// 获取在线薪酬数据来源列表,年月
ajax.getOnlineSalaryDataSource().then(res => {
// const arr = res.data || [];
this.setState({
onlineSalaryDataSource: res.data
// onlineSalaryDataSource: arr.reverse()
});
});
}
selectGrantDetailTotalMap() {
//获取薪资代发记录汇总
ajax
.selectGrantDetailTotalMap({ comGrantId: gup("comGrantId") })
.then(res => {
if (res.data) {
this.setState({
totalInfo: res.data
});
} else {
// this.setState({
// totalInfo: {
// failTotalAmount: "0.00",
// failTotalSize: "0",
// successTotalAmount: "0.00",
// successTotalSize: "0",
// toTotalAmount: "0",
// toTotalSize: "0",
// totalAmount: "0.00",
// totalSize: "0"
// }
// });
}
});
}
// 获取表格信息
getTable = (data, cb) => {
ajax.pageComToGrantDetailList(data).then(res => {
this.setState(
{
tableList: res.data.data,
pagination: {
...this.state.pagination,
total: res.data.total,
current: res.data.pageNumber,
pageSize: res.data.pageSize
}
},
() => {
cb && cb(res.data.data);
}
);
});
};
//添加代发放记录
createOnlineToGrantDataHandle = e => {
e.preventDefault();
this.props.form.validateFields((err, values) => {
if (!err) {
//薪酬服务调用另外接口去保存
if (this.state.grantDataSource === "3") {
if(!values.grantYears){
return message.error('先选择工资单')
}
const value = {
comGrantId: gup("comGrantId"),
grantYears: JSON.parse(values.grantYears).PayYear,
thirdPaySlipId: JSON.parse(values.grantYears).ID
};
ajax.createThirdToGrantData(value).then(res => {
this.selectGrantDetailTotalMap();
this.getTable(this.state.searchData, () => {
this.setState({
canAddData: false,
addDataVisibale: false
});
});
});
} else {
if(!values.grantYears1){
return message.error('先选择月份')
}
values.comGrantId = gup("comGrantId");
values.grantYears = values.grantYears1
ajax.createOnlineToGrantData(values).then(res => {
this.selectGrantDetailTotalMap();
this.getTable(this.state.searchData, () => {
this.setState({
canAddData: false,
addDataVisibale: false
});
});
});
}
}
});
// this.setState({
// addDataVisibale: false
// });
};
// 代发薪资时发送验证码的动作
// 获取操作记录
getOperationTable = (data, cb) => {
ajax.getComOperRecordList(data).then(res => {
this.setState(
{
operationList: res.data,
operationPagination: {
...this.state.operationPagination,
total: res.data.total,
current: res.data.pageNumber,
pageSize: res.data.pageSize
}
},
() => {
cb && cb(res.data.data);
}
);
});
};
// 表格渲染
renderList = () => {
const columns = [
{
title: "收款人姓名",
dataIndex: "name",
key: "name"
},
{
title: "身份证号码",
dataIndex: "idCardNo",
key: "idCardNo"
},
{
title: "手机号码",
dataIndex: "mobilePhone",
key: "mobilePhone"
},
{
title: "收款账户",
dataIndex: "walletAccountNo",
key: "walletAccountNo",
render: text => {
if (text == "该人员未开通钱包") {
return {text};
} else {
return {text};
}
}
},
{
title: "应发工资(元)",
dataIndex: "amount",
key: "amount"
},
{
title: "状态",
dataIndex: "isCanGrant",
key: "isCanGrant",
render: (text, record) => {
const { isCanGrant } = record;
switch (isCanGrant) {
case "不可发放":
return {isCanGrant};
case "可发放":
return {isCanGrant};
default:
{isCanGrant};
}
}
}
];
return (
{
const searchData = {
// 搜索数据
...this.state.searchData,
pageNumber: pagination.current, // 页
pageSize: pagination.pageSize
};
this.setState(
{
searchData
},
() => {
this.getTable(searchData);
}
);
}}
// rowSelection={{
// onChange: (selectedRowKeys, selectedRows) => {
// this.setState({
// selectedRows,
// selectedRowKeys
// });
// },
// selectedRowKeys: this.state.selectedRowKeys
// }}
/>
);
};
// 操作记录表格渲染
renderOperationList = () => {
const columns = [
{
title: "时间",
dataIndex: "createTime",
key: "createTime"
},
{
title: "操作人",
dataIndex: "createUserName",
key: "createUserName"
},
{
title: "操作功能",
dataIndex: "operGrantFuncType",
key: "operGrantFuncType"
},
{
title: "操作结果",
dataIndex: "operResult",
key: "operResult"
}
];
return (
{
pagination.comGrantId = gup("comGrantId");
this.setState(
{
operationSearchData: {
pageNumber: pagination.current, // 页
pageSize: pagination.pageSize
}
},
() => {
this.getOperationTable(pagination);
}
);
}}
/>
);
};
render() {
return (
{this.state.grantInfo && (
{this.state.grantInfo.title} ({gup("comGrantId")})
)}
1、发放工资:发放前请确认发放人数、发放总额、企业钱包余额是否充足,若不足,请
{
this.props.history.push("/finance/business-wallet");
}}
>
充值
;
2、未开通钱包服务的员工,请提醒其在APP端进行开通,否则无法向其发放工资。
}
type="warning"
showIcon
style={{ marginBottom: "15px" }}
/>
{this.state.totalInfo && (
{/*
*/}
待发放总额
{this.state.totalInfo.toTotalAmount}
待发放总笔数:{this.state.totalInfo.toTotalSize}
+
{
this.props.history.push(
`/finance/salary-proxy-fail?comGrantId=${gup("comGrantId")}`
);
}}
>
{/*
*/}
发放失败总额
{this.state.totalInfo.failTotalAmount}
发放总笔数:{this.state.totalInfo.failTotalSize}
+
{
this.props.history.push(
`/finance/salary-proxy-complete?comGrantId=${gup(
"comGrantId"
)}`
);
}}
>
发放成功总额
{this.state.totalInfo.successTotalAmount}
发放总笔数:{this.state.totalInfo.successTotalSize}
=
{
// if (this.state.listStatus == 3) {
// return 'active_uint statistics_uint';
// }
// return 'statistics_uint';
// })()
// }
// onClick={() => {
// this.setState({
// listStatus: 3
// });
// }}
>
{/*
*/}
发放总额
{this.state.totalInfo.totalAmount}
发放总笔数:{this.state.totalInfo.totalSize}
)}
{/*
allGrantStatus
0 待发放
1 正在发放
2 部分完成
3 全部完成 */}
{this.state.tableList.length == 0 && (
)}
{this.state.tableList.length > 0 && (
)}
{this.state.tableList.length > 0 && (
)}
{this.renderList()}
{/* 操作记录 */}
{
this.setState({
operationVisibale: false
});
}}
visible={this.state.operationVisibale}
>
{this.renderOperationList()}
{/* 添加发放数据 */}
{
this.setState({
addDataVisibale: false
});
}}
// onOk={this.createOnlineToGrantDataHandle}
visible={this.state.addDataVisibale}
footer={this.state.grantDataSource==='2'?null:[
,
]}
>
{(() => {
const { getFieldDecorator } = this.props.form;
const formItemLayout = {
labelCol: {
xs: { span: 5 },
sm: { span: 5 }
},
wrapperCol: {
xs: { span: 18 },
sm: { span: 18 }
}
};
return (
{getFieldDecorator("grantDataSource", {
initialValue: "1",
rules: [{}]
})(
)}
{this.state.grantDataSource === "1" ? (
{getFieldDecorator("grantYears1", {
initialValue: this.state.onlineSalaryDataSource[0],
rules: [{}]
})(
)}
注:请选择薪酬核算中的薪酬数据,系统会自动将薪酬数据中的人员及其应发工资数据带入到代发列表中。
) : this.state.grantDataSource === "2" ? (
{getFieldDecorator("grantYears2", {
// initialValue: [],
// rules: [{}]
})(
{
this.setState({
grantYearsDown:value?value.format('YYYY-MM'):''
})
}}
disabledDate={(current)=>{
return current && current > moment(parseInt(sessionStorage.getItem('requestDate'))).endOf('day')
}}
/>
)}
{getFieldDecorator("policyUrl", {
rules: [{ required: false, message: "请上传" }]
})(
{
//上传文件成功之后,刷新代发列表,以及关闭弹窗
this.selectGrantDetailTotalMap();
this.getTable(this.state.searchData, () => {
this.setState({
canAddData: false,
addDataVisibale: false
});
});
}}/>
)}
) : this.state.grantDataSource === "3" ? (
{getFieldDecorator("grantYears", {
initialValue: JSON.stringify(this.state.payrollList[0]),
rules: [{}]
})(
)}
只有锁定的工资单才可以发放,请到薪酬服务模块中先锁定。
) : (
""
)}
);
})()}
);
}
}