import React from "react";
import $ from "jquery/src/ajax";
import moment from "moment";
import "./public.less";
import {
Form,
Button,
Input,
Select,
Spin,
Table,
message,
Modal,
Upload,
DatePicker,
Icon,
Tabs,
Popconfirm,
Tag,
Tooltip,
} from "antd";
import {
getProvinceA,
getInvoiceStatus,
getprovince,
getStatus,
getPeople,
splitUrl,
moneyVerify
} from "@/tools";
import { ChooseList } from "../../../../component/manageCenter/order/orderNew/chooseList";
import "./huiKuan.less"
import LogPopup from "../../../common/logPopup";
import Cascaders from "../../../common/cascaders";
const { RangePicker } = DatePicker;
const FormItem = Form.Item;
const { TextArea } = Input;
const { TabPane } = Tabs;
const formItemLayout = {
labelCol: { span: 5 },
wrapperCol: { span: 19 }
};
const HuiKuan = React.createClass({
loadData(pageNo, pageSize) {
this.state.data = [];
this.setState({
loading: true
});
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/receivables/listReceivables",
data: {
pageNo: pageNo || 1,
pageSize: pageSize || this.state.pagination.pageSize,
// 0 正常 1 待合并库
mergeStatus: this.state.mergeStatus,
// 订单状态 判断是否重复
status: this.state.statusSearch,
// 订单编号
orderNo: this.state.orderNoSearch,
// 合同编号
contractNo: this.state.nameSearch,
// 付款方
corporateName: this.state.payFrom,
// 营销员名字
adminName: this.state.adminName,
// 客户名称
nickname: this.state.nickname,
// 订单所属部门id
orderDeps: this.state.orderDeps,
// 管理员部门id
adminDeps: this.state.adminDeps
},
success: function (data) {
let theArr = [];
if (!data.data || !data.data.pagination.list) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
}
} else {
for (let i = 0; i < data.data.pagination.list.length; i++) {
let thisdata = data.data.pagination.list[i];
theArr.push({
key: thisdata.id,
status: {
first: thisdata.status,
second: thisdata.inptStatus
},
orderNo: thisdata.orderNo,
contractNo: thisdata.contractNo,
corporateName: thisdata.corporateName,
nickname: thisdata.nickname,
totalAmount: thisdata.totalAmount,
depName: thisdata.depName,
amount: thisdata.amount,
receivablesTimes: thisdata.receivablesTimes,
createTimes: thisdata.createTimes,
remarks: thisdata.remarks,
financialPayNo: thisdata.financialPayNo,
settlementAmount: thisdata.settlementAmount
});
}
}
this.state.pagination.current = data.data.pagination.pageNo;
this.state.pagination.total = data.data.pagination.totalCount;
if (
data.data &&
data.data.pagination.list &&
!data.data.pagination.list.length
) {
this.state.pagination.current = 0;
this.state.pagination.total = 0;
}
this.setState({
totalPage: data.data.pagination.totalPage,
dataSource: theArr,
pagination: this.state.pagination,
totalHui: data.data.count ? data.data.count.totalAmount : 0,
hui: data.data.count ? data.data.count.amount : 0
});
// console.log(this.state.dataSource);
}.bind(this)
}).always(
function () {
this.setState({
loading: false
});
}.bind(this)
);
},
departmentList() {
this.setState({
loading: true
});
$.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 () {
this.setState({
loading: false
});
}.bind(this)
);
},
getInitialState() {
return {
matching: "",
matchList: [],
mergeStatus: 0,
mergeModal: false,
visible: false,
selectedRowKeys: [], // Check here to configure the default column
loading: false,
searchMore: true,
assignVisible: false,
releaseDate: [],
totalPage: 0,
boHuivisible: false,
selectedRows: [],
// 弹出层数据
modalData: {},
// userName: "",
contractNo: "",
reason: "",
foo: 0,
// 子组件改变的表格title数组
changeList: undefined,
pagination: {
defaultCurrent: 1,
defaultPageSize: 10,
showQuickJumper: true,
pageSize: 10,
onChange: function (page) {
this.loadData(page);
}.bind(this),
showTotal: function (total) {
return "共" + total + "条数据";
}
},
paginationModal: {
pageSize: 100,
showTotal: function (total) {
return "共" + total + "条数据";
}
},
columns: [
{
title: "合同编号",
dataIndex: "contractNo",
key: "contractNo",
// fixed: "left"
className: "title-table"
},
{
title: "订单编号",
dataIndex: "orderNo",
key: "orderNo",
className: "title-table"
},
{
title: "流水编号",
dataIndex: "financialPayNo",
key: "financialPayNo",
className: "title-table"
},
{
title: "客户名称",
dataIndex: "nickname",
key: "nickname",
className: "title-table",
width: 150,
render: (text) => {
return (
{text}
)
},
},
{
title: "付款方",
dataIndex: "corporateName",
key: "corporateName",
className: "title-table"
},
{
title: "合同额(万元)",
dataIndex: "totalAmount",
key: "totalAmount",
className: "title-table"
},
{
title: "已收款(万元)",
dataIndex: "settlementAmount",
key: "settlementAmount",
className: "title-table"
},
{
title: "本次回款(万元)",
dataIndex: "amount",
key: "amount",
className: "title-table"
},
{
title: "回款时间",
dataIndex: "receivablesTimes",
key: "receivablesTimes",
className: "title-table"
},
{
title: "状态",
dataIndex: "status",
key: "status",
className: "title-table",
render: status => {
let str = "";
let color = "";
let str2 = "";
let color2 = "";
if (status.first == 0) {
color = "#87d068";
str = "正常"
if (status.second == 1) {
str = "内容缺失"
color = "#000";
} else if (status.second == 2) {
str = "订单异常"
color = "#000";
} else if (status.second == 3) {
str = "名称不一致"
color = "#000";
}
} else if (status.first == 1) {
str = "重复";
color = "#f50";
if (status.second == 1) {
str2 = "内容缺失";
color2 = "#000";
} else if (status.second == 2) {
str2 = "订单异常";
color2 = "#000";
} else if (status.second == 3) {
str2 = "名称不一致";
color2 = "#000";
}
} else {
color = "#000";
if (status.first == 2) {
str = "订单异常";
} else if (status.first == 3) {
str = "金额异常";
} else if (status.first == 4) {
str = "名称异常";
} else if (status.first == 5) {
str = "已收款";
} else if (status.first == 6) {
str = "变更锁定";
}
}
return (
{str}
{str2}
);
}
},
{
title: "批量导入时间",
dataIndex: "createTimes",
key: "createTimes",
className: "title-table"
},
{
title: "备注",
dataIndex: "remarks",
key: "remarks",
className: "title-table"
}
],
columnsDate: [
{
title: "编号",
dataIndex: "id",
key: "id"
},
{
title: "订单编号",
dataIndex: "orderno",
key: "orderno"
},
{
title: "开票金额(万元)",
dataIndex: "amount",
key: "amount"
},
{
title: "申请时间",
dataIndex: "createTime",
key: "createTime"
},
{
title: "开票状态",
dataIndex: "status",
key: "status",
render: (text, record) => {
return {getInvoiceStatus(text, record)}
;
},
}
],
dataSource: [],
upLoadFlag: false,
upLoad: {
name: "file",
action: globalConfig.context + "/api/admin/receivables/import",
headers: {
authorization: "authorization-text"
},
onChange: info => {
if (info.file.status == "done") {
if (info.file.response.data == 1) {
message.success("导入成功!");
this.loadData();
} else {
message.warning(info.file.response.error[0].message);
}
}
}
}
};
},
search() {
this.setState({
selectedRowKeys: []
})
this.loadData();
},
componentWillMount() {
this.loadData();
this.departmentList();
// $("#rcDialogTitle0").on("click", function() {
// alert(123);
// console.log(123);
// });
},
reset() {
this.state.nameSearch = "";
this.state.releaseDate = [];
this.state.orderNoSearch = "";
this.state.adminName = "";
this.state.departmenttList = [];
this.state.nickname = "";
this.state.payFrom = "";
this.state.statusSearch = [];
this.state.adminDeps = undefined;
this.state.orderDeps = undefined;
this.state.statusSearch = [];
this.Cascaders1.empty();
this.Cascaders2.empty();
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
});
},
onSelectChange(selectedRowKeys) {
// console.log("selectedRowKeys changed: ", selectedRowKeys);
this.setState({ selectedRowKeys });
},
showModal() {
this.setState({
visible: true,
choose: true
});
this.state.dataSource.forEach((item) => {
if (item.key == this.state.selectedRowKeys[0]) {
this.setState({
modalData: JSON.parse(JSON.stringify(item))
})
// console.log(this.state.modalData);
}
})
},
tableRowClick(record) {
this.setState({
visible: true,
choose: true
});
this.setState({
modalData: JSON.parse(JSON.stringify(record))
});
},
handleOk() {
if (moneyVerify(this.state.modalData.amount)) return
this.setState({ loading: true });
if (!this.state.choose) {
$.ajax({
method: "POST",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/receivables/addReceivables",
data: {
orderNo: this.state.modalData.orderNo,
amount: this.state.modalData.amount,
receivablesTimes: this.state.modalData.receivablesTimes,
// totalAmount: this.state.modalData.totalAmount,
// contractNo: this.state.modalData.contractNo,
// nickname: this.state.modalData.nickname,
remarks: this.state.modalData.remarks,
corporateName: this.state.modalData.corporateName,
financialPayNo: this.state.modalData.financialPayNo
},
success: function (data) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
} else {
// console.log("成功", data);
message.success("添加成功!")
this.loadData();
this.state.selectedRowKeys = [];
this.setState({
selectedRowKeys: this.state.selectedRowKeys
});
this.setState({ loading: false, visible: false });
}
}.bind(this)
}).always(
function () {
this.setState({
loading: false
});
}.bind(this)
);
} else {
$.ajax({
method: "POST",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/receivables/updateReceivables",
data: {
orderNo: this.state.modalData.orderNo,
amount: this.state.modalData.amount,
receivablesTimes: this.state.modalData.receivablesTimes,
// totalAmount: this.state.modalData.totalAmount,
// contractNo: this.state.modalData.contractNo,
// nickname: this.state.modalData.nickname,
corporateName: this.state.modalData.corporateName,
financialPayNo: this.state.modalData.financialPayNo,
remarks: this.state.modalData.remarks,
id: this.state.modalData.key
},
success: function (data) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
} else {
// console.log("成功",data);
message.success("修改成功!")
this.loadData()
this.state.selectedRowKeys = [];
this.setState({
selectedRowKeys: this.state.selectedRowKeys
});
this.setState({ loading: false, visible: false });
}
}.bind(this)
}).always(
function () {
this.setState({
loading: false
});
}.bind(this)
);
}
// this.setState({ loading: false, visible: false });
},
handleCancel() {
// this.loadData()
this.setState({ visible: false });
},
callback(key) {
// console.log(key);
},
delChecked() {
// console.log("被删除列表",this.state.selectedRowKeys);
let ids = this.state.selectedRowKeys.join(",")
$.ajax({
method: "POST",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/receivables/deleteReceivables",
data: {
ids,
type: 0
},
success: function (data) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
}
message.success("删除成功!")
}.bind(this)
}).always(
function () {
this.loadData()
this.state.selectedRowKeys = [];
this.setState({
selectedRowKeys: this.state.selectedRowKeys
});
}.bind(this)
);
// this.loadData()
},
delAllChecked() {
// console.log("删除全部");
$.ajax({
method: "POST",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/receivables/deleteReceivables",
data: {
type: 1
},
success: function (data) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
}
message.success("删除全部成功!")
}.bind(this)
}).always(
function () {
this.loadData();
this.state.selectedRowKeys = [];
this.setState({
selectedRowKeys: this.state.selectedRowKeys
});
}.bind(this)
);
// this.loadData()
// console.log("aaa", $(".ant-modal-content"));
},
mergeAll() {
// console.log("合并全部");
this.setState({
confirmLoading: true
})
$.ajax({
method: "POST",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/receivables/batchImport",
data: {
mergeStatus: this.state.mergeStatus,
},
success: function (data) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
} else {
message.success("合并成功!请在收款列表中,查看已收款情况。");
this.setState({
mergeModal: false
});
}
}.bind(this)
}).always(
function () {
this.loadData();
this.state.pagination.pageSize = 10
this.state.selectedRowKeys = []
this.setState({
selectedRowKeys: this.state.selectedRowKeys,
pagination: this.state.pagination,
mergeModal: false,
confirmLoading: false,
})
// window.location.reload();
}.bind(this)
);
// message.success("合并成功!请在收款列表中,查看已收款情况。");
},
addModal() {
this.state.modalData = {}
this.setState({
modalData: this.state.modalData,
visible: true,
choose: false
})
},
download() {
window.location.href =
globalConfig.context +
"/api/admin/receivables/downloadTemplate?" +
"sign=receivbles_template";
},
// daoHui() {
// window.location.href =
// globalConfig.context +
// "/api/admin/receivables/exportReceivables"
// },
// 添加至待合并库
waitingMerge() {
this.setState({
confirmLoading: true
})
let ids = this.state.selectedRowKeys.join(",")
$.ajax({
method: "POST",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/receivables/waitingMerge",
data: {
ids,
},
success: function (data) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
} else {
message.success("添加成功!");
this.setState({
mergeModal: false
});
}
}.bind(this)
}).always(
function () {
this.loadData();
this.state.selectedRowKeys = []
this.setState({
selectedRowKeys: this.state.selectedRowKeys,
confirmLoading: false,
})
}.bind(this)
);
},
// 匹配客户
matchingUser(user) {
this.setState({
loading: true
});
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/receivables/matchingUser",
data: {
value: user
},
success: function (data) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
} else {
this.setState({
matching: "orderno",
matchList: data.data,
})
}
}.bind(this)
}).always(
function () {
this.setState({
loading: false
});
}.bind(this)
);
},
// 匹配订单
matchingOrderNo(orderno) {
this.setState({
loading: true
});
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/receivables/matchingOrderNo",
data: {
value: orderno
},
success: function (data) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
} else {
this.setState({
matching: "name",
matchList: data.data,
})
}
}.bind(this)
}).always(
function () {
this.setState({
loading: false
});
}.bind(this)
);
},
selCancel() {
this.setState({
matching: "",
})
},
render() {
var departmentArr = this.state.departmentArr || [];
const { loading, selectedRowKeys, visible } = this.state;
const rowSelection = {
selectedRowKeys,
onChange: this.onSelectChange,
hideDefaultSelections: true
};
const radioStyle = {
display: "flex",
flexDirection: "row",
alignItems: "center",
justifyContent: "space-between",
padding: "5px",
height: '30px',
lineHeight: '30px',
fontSize: "14px",
borderBottom: "1px solid #e9e9e9",
};
var departmentArr = this.state.departmentArr || [];
return (
);
}
});
export default HuiKuan;