import React from "react";
import $ from "jquery/src/ajax";
import moment from "moment";
import {
Button,
Form,
Input,
Spin,
Table,
Select,
message,
Tabs,
AutoComplete,
DatePicker,
Modal,
} from "antd";
import { ChooseList } from "../../order/orderNew/chooseList";
import { ShowModal,getVehicleName, getTypeName, commonAdd, dealBigMoney } from "../../../tools"
import ShowModalDiv from "@/showModal.jsx";
import AccountDetails from "./accountDetails";
import { accountType, accountStatus } from "@/dataDic";
const FormItem = Form.Item;
const { RangePicker } = DatePicker;
const { TabPane } = Tabs;
const AccountReview = React.createClass({
getInitialState() {
return {
showDetails: false,
data: {},
logvisible: false,
logdataSour: [],
visible: "",
reason: "",
checkData: {},
aname: "",
searchValues: {}, // 列表筛选条件
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: "type",
key: "type",
render: (text, record) => {
return (
{text == 0 ? record.typeOther : accountType.find(item => item.value === text).label}
);
},
},
{
title: "报销金额(元)",
dataIndex: "totalAmount",
key: "totalAmount",
},
{
title: "报销至订单",
dataIndex: "buyerName",
key: "buyerName",
render: (text, record) => {
return (
record.targetType == 0
?
固定费用
:
{text || ""}
{record.contractNo || ""}
);
},
},
{
title: "报销至部门",
dataIndex: "appDepName",
key: "appDepName",
render: (text, record) => {
return (
{record.targetType == 0 && text}
);
},
},
{
title: "报销人",
dataIndex: "aname",
key: "aname",
},
{
title: "财务负责人",
dataIndex: "financeName",
key: "financeName",
},
{
title: "状态",
dataIndex: "status",
key: "status",
render: (text, record) => {
return (
{accountStatus[text].label}
);
},
},
{
title: "报销公司/支付公司",
dataIndex: "payDepName",
key: "payDepName",
render: (text, record) => {
return (
{record.appDepName || ""}
{text || ""}
);
},
},
{
title: "报销时间",
dataIndex: "createTimeStr",
key: "createTimeStr",
},
{
title: "操作",
dataIndex: "operate",
key: "operate",
render: (text, record) => {
return (
{this.props.isOperate &&
}
{this.props.isOperate && record.examine == 1 &&
}
{this.props.isOperate && record.examine == 1 &&
}
{record.status != 0 && }
)
}
},
],
logcolumns: [
{
title: "审核人",
dataIndex: "auditorName",
key: "auditorName"
},
{
title: "操作",
dataIndex: "status",
key: "status",
width: 120,
render: (text, record) => {
return (
{["【发起】", "【通过】", "【完成】", "【驳回】", "【重新发起】"][text]}
{this.state.processStatus == record.processStatus && !record.id &&
审核中...}
);
},
},
{
title: "操作时间",
dataIndex: "createTimeStr",
key: "createTimeStr",
width: 88,
},
{
title: "备注",
dataIndex: "remarks",
key: "remarks",
render: (text, record) => {
return (
{text}
)
}
}
],
};
},
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,
processStatus: this.props.isOperate ? 1 : 2,
});
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/expenseAccount/pageList",
data: datas,
success: function (data) {
ShowModal(this);
this.setState({
loading: false,
});
if (data.error && data.error.length === 0) {
if (data.data.list) {
pagination.current = data.data.pageNo;
pagination.total = data.data.totalCount;
if (data.data && data.data.list && !data.data.list.length) {
pagination.current = 0;
pagination.total = 0;
}
this.setState({
dataSource: data.data.list,
pagination: this.state.pagination,
pageNo: data.data.pageNo,
totalAmount: data.data.totalAmount,
});
} else {
this.setState({
dataSource: data.data,
pagination: false,
});
}
} else {
message.warning(data.error[0].message);
}
}.bind(this),
}).always(
function () {
this.setState({
loading: false,
});
}.bind(this)
);
},
// 日志
getLogData(eaid) {
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/expenseAccount/log/list",
data: { eaid },
success: function (data) {
if (data.error.length === 0) {
this.setState({
logdataSour: data.data || []
});
this.isHere(data.data || [])
} else {
message.warning(data.error[0].message);
}
}.bind(this)
}).always(
function () {
}.bind(this)
);
},
//
isHere(list = []) {
for (var i = 0; i < list.length; i++) {
if (!list[i].id) {
this.setState({
processStatus: list[i].processStatus
})
return
}
}
},
download(urls) {
if (!urls) {
message.error("暂无可下载的附件!");
} else {
let list = urls.split(',') || []
list.forEach(e => {
var aLink = document.createElement('a');
aLink.download = e;
aLink.href = globalConfig.context + `/open/download?fileName=${e}&delete=false`;
document.body.appendChild(aLink);
aLink.click();
document.body.removeChild(aLink);
});
}
},
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)
);
},
// 审核
toExamine(num) {
const { checkData, reason } = this.state
if (!reason) {
message.warning("请填写审核说明~");
return;
}
this.setState({
loading: true,
});
$.ajax({
method: "POST",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/expenseAccount/examine",
data: {
id: checkData.id,
reason,
status: num,//1同意 3驳回
},
}).done(
function (data) {
if (!data.error.length) {
message.success("审核成功!");
this.setState({
visible: "",
reason: "",
showDetails: false,
checkData: {},
});
this.loadData()
} else {
message.warning(data.error[0].message);
}
}.bind(this)
);
},
tableRowClick(e) {
this.setState({
showDetails: true,
id: e.id,
})
// this.getDetails(e.id)
},
// 查询负责人
followUp(e) {
this.setState({
aname: e
});
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/customer/listAdminByName",
data: {
adminName: e,
},
success: function (data) {
let thedata = data.data || [];
if (!thedata) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
}
thedata = {};
}
this.setState({
fjlist: thedata,
});
}.bind(this),
}).always(
function () {
this.setState({
loading: false,
});
}.bind(this)
);
},
// 选中负责人
selectF(value) {
const { searchValues, fjlist } = this.state;
const newdataSources = JSON.stringify(fjlist) == "{}" ? [] : fjlist;
this.setState({
searchValues: Object.assign(searchValues, {
aid: newdataSources.find((item) => item.name == value).id,
}),
});
},
// 搜索
search() {
this.loadData();
},
// 重置
reset() {
this.setState({
aname: "",
searchValues: JSON.parse(JSON.stringify({})),
}, () => {
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,
});
},
render() {
const { TextArea } = Input
const { searchValues, data, visible, list = [], newList, total, logdataSour, } = this.state
const formItemLayout = {
labelCol: { span: 5 },
wrapperCol: { span: 18 },
};
const dataSources = this.state.fjlist || [];
const options = dataSources.map((group) => (
{group.name}
));
const logArray = logdataSour.filter((item, index, arr) => {
return arr.findLastIndex((t) => t.auditorName === item.auditorName) === index;
});
const reimbursement = [
{
title: !!data.contractNo ? `报销至订单:${data.contractNo}` : `报销至部门`,
dataIndex: "head",
key: "head",
width: 275,
render: (text, row, index) => {
if (index < newList.length - 2) {
return {text};
} else if (index == newList.length - 2) {
return {
children:
金额合计(大写):{data.type == 5 ? dealBigMoney(total) : (dealBigMoney((total > data.debitTotalAmount) ? commonAdd(total, -data.debitTotalAmount) : 0))}
¥ {data.type == 5 ? total : (total > data.debitTotalAmount) ? commonAdd(total, -data.debitTotalAmount) : 0}
,
props: {
colSpan: 3,
},
};
} else if (index == newList.length - 1) {
return {
children:
{data.type == 3 && newList.map((item, index) => !!item.invoiceNo &&
付款方式:{"公对公转账"} 发票类型:{["普票", "专票"][item.invoiceType]} 发票号:{item.invoiceNo}
)}
{data.type == 3
? newList.map((item, index) => !!item.payerName &&
收款方式:{item.payerName} {item.openBank} {item.bankAccounts} {item.openBankAddress}
)
: data.type != 5 &&
收款方式:{data.bank} {data.accounts} {data.name}
}
,
props: {
colSpan: 3,
},
};
}
},
},
{
title: '报销数',
children: [
{
title: '付款项目',
dataIndex: "type",
key: "type",
width: 120,
render: (value, row, index) => {
if (index == newList.length - 2) {
return {
props: {
rowSpan: 0,
},
};
} else if (index == newList.length - 1) {
return {
props: {
rowSpan: 0,
},
};
} else {
return
{data.type == 1 &&
// 差旅费显示
{!!row.other
? row.other
: value == 1
? {`交通费(${getVehicleName(row.vehicle, row.vehicleOther)})`}
: {getTypeName(row.type)}}
}
{(data.type == 0 || data.type == 2 || data.type == 4 || data.type == 5) &&
{value == 4 ? "预借支金额" : value == 5 ? "抵扣金额" : !!row.other ? row.other : "申请金额"}
}
{data.type == 3 &&
{!!row.other ? row.other : "申请金额"}
}
;
}
},
},
{
title: '金额(元)',
dataIndex: "amount",
key: "amount",
width: 80,
render: (value, row, index) => {
if (index == newList.length - 2) {
return {
props: {
rowSpan: 0,
},
};
} else if (index == newList.length - 1) {
return {
props: {
rowSpan: 0,
},
};
} else {
return {value};
}
},
}
],
},
{
title: '审核意见',
dataIndex: "shyj",
key: "shyj",
width: 270,
render: (value, row, index) => {
if (index == 0) {
return {
children:
{logArray.map((item, index) => {
return (
// 要求只显示通过的审核
(item.status == 1 || item.status == 2) &&
-
{item.auditorName}:
{["【发起】,", "【通过】,", "【完成】,", "【驳回】,", "【重新发起】,"][item.status]}
{this.state.processStatus == item.processStatus && !item.id && data.status != 0 &&
审核中...}
{item.remarks}
{/* {item.createTimeStr} */}
)
})}
,
props: {
rowSpan: newList.length - 2,
},
};
} else if (index == newList.length - 2) {
return data.type != 0 && 要求付款时间:{data.type == 1 ? moment(data.agreeTimeStr).format('YYYY-MM-DD') : moment(newList[0].agreeTimeStr).format('YYYY-MM-DD')};
} else if (index < newList.length - 1) {
return {
props: {
rowSpan: 0,
},
};
}
},
},
]
return (
{this.props.isOperate ? "报销审核" : "报销列表"}
{
searchValues["contractNo"] = e.target.value;
this.setState({
searchValues: searchValues,
});
}}
/>
{
searchValues["username"] = e.target.value;
this.setState({
searchValues: searchValues,
});
}}
/>
报销时间:
{
this.setState({
searchValues: Object.assign(searchValues, {
startTime: dataString[0],
endTime: dataString[1],
}),
});
}}
/>
{
{`金额总计(元):${this.state.totalAmount}`}
}
{
//审核弹窗
this.state.visible != "" &&
{ this.toExamine(visible == "adopt" ? 1 : visible == "reject" && 3) }}
okText={this.state.visible == "adopt" ? "通过" : this.state.visible == "reject" && "驳回"}
onCancel={() => {
this.setState({
visible: '',
reason: "",
checkData: {},
})
}}
>
}
{
this.state.showDetails &&
{ this.setState({ showDetails: false }) }}
/>
}
{
// 审核日志
this.state.logvisible &&
{
this.setState({
logvisible: false,
})
}}
>
}
);
},
});
export default AccountReview;