import React from "react";
import $ from "jquery/src/ajax";
import moment from "moment";
import {
Button,
Form,
Input,
Spin,
Table,
Select,
message,
Tabs,
DatePicker,
Modal,
} from "antd";
import { ChooseList } from "../../order/orderNew/chooseList";
import { ShowModal, getAccountName, getSecondaryAccountName } from "../../../tools"
import ShowModalDiv from "@/showModal.jsx";
const FormItem = Form.Item;
const { RangePicker } = DatePicker;
const { TabPane } = Tabs;
const AccountTotal = React.createClass({
getInitialState() {
return {
searchValues: {
targetType: 1
}, // 列表筛选条件
loading: false, //加载动画
changeList: undefined, // 更改后的表格显示数据
dataSource: [], // 列表数据
departmentArr: [],
pagination: {
defaultCurrent: 1,
defaultPageSize: 10,
showQuickJumper: true,
pageSize: 10,
onChange: function (page) {
this.loadData(page);
}.bind(this),
showTotal: function (total) {
return "共" + total + "条数据";
},
},
columns: [
{
title: "合同/客户",
dataIndex: "contractNo",
key: "contractNo",
render: (text, record) => {
return (
this.state.searchValues["targetType"] == 1 ?
{text + " / " + record.buyerName}
: {record.depName}
);
},
},
{
title: "合同总额/已收款",
dataIndex: "totalAmount",
key: "totalAmount",
render: (text, record) => {
return (
{text + " / " + record.settlementAmount}
);
},
},
{
title: "报销总额",
dataIndex: "expenseAmount",
key: "expenseAmount",
},
{
title: "已付成本",
dataIndex: "paymentAmount",
key: "paymentAmount",
},
{
title: "报销人数/天数/报销次数",
dataIndex: "peopleCount",
key: "peopleCount",
render: (text, record) => {
return (
{text + " / " + record.days + " / " + record.expenseCount}
);
},
},
{
title: "报销未审核/驳回次数",
dataIndex: "notExamine",
key: "notExamine",
render: (text, record) => {
return (
{text + " / " + record.rejectCount}
);
},
},
],
};
},
componentWillMount() {
this.departmentList();
this.loadData();
},
// 列表接口
loadData(pageNo) {
const { searchValues, pagination } = this.state;
this.setState({
loading: true,
});
let datas = Object.assign(searchValues, {
// pageNo: pageNo || 1,
// pageSize: pagination.pageSize,
});
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/expenseCounts/getCounts",
data: datas,
success: function (data) {
ShowModal(this);
this.setState({
loading: false,
});
if (data.error && data.error.length === 0) {
if (data.data) {
pagination.current = data.data.pageNo;
pagination.total = data.data.totalCount;
if (data.data && data.data && !data.data.length) {
pagination.current = 0;
pagination.total = 0;
}
this.setState({
dataSource: data.data,
pagination: this.state.pagination,
pageNo: data.data.pageNo,
totalAmount: data.data.totalAmount,
});
}
} else {
message.warning(data.error[0].message);
}
}.bind(this),
}).always(
function () {
this.setState({
loading: false,
});
}.bind(this)
);
},
departmentList() {
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/organization/selectSuperId",
data: {},
success: function (data) {
let thedata = data.data;
let theArr = [];
if (!thedata) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
}
} else {
thedata.map(function (item, index) {
theArr.push({
key: index,
name: item.name,
id: item.id
});
});
}
this.setState({
departmentArr: theArr
});
}.bind(this)
}).always(
function () {
}.bind(this)
);
},
// 搜索
search() {
this.loadData();
},
// 重置
reset() {
this.setState({
searchValues: {
targetType: 1
},
}, () => {
this.loadData();
})
},
changeList(arr) {
const newArr = [];
this.state.columns.forEach((item) => {
arr.forEach((val) => {
if (val === item.title) {
newArr.push(item);
}
});
});
this.setState({
changeList: newArr,
});
},
export() {
this.setState({
exportExecLoading: true
})
let loading = message.loading('加载中...');
let data = this.state.searchValues;
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/expenseCounts/getCounts/Export",
data,
success: function (data) {
if (data.error.length === 0) {
this.download(data.data);
} else {
message.warning(data.error[0].message);
}
}.bind(this),
}).always(function () {
loading();
this.setState({
exportExecLoading: false
})
}.bind(this));
},
// 下载
download(fileName) {
window.location.href = globalConfig.context + "/open/download?fileName=" + fileName
},
getCountsClear() {
this.setState({
loading: true,
});
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/expenseCounts/getCountsClear",
data: {},
success: function (data) {
ShowModal(this);
this.setState({
loading: false,
});
if (data.error && data.error.length === 0) {
message.success("清除成功!")
} else {
message.warning(data.error[0].message);
}
}.bind(this),
}).always(
function () {
this.setState({
loading: false,
});
}.bind(this)
);
},
render() {
const { searchValues, } = this.state
return (
);
},
});
export default AccountTotal;