import React from "react";
import $ from "jquery/src/ajax";
import moment from "moment";
import "./public.less";
import {
Button,
Form,
Input,
Spin,
Table,
Select,
message,
DatePicker,
Modal,
Tabs
} from "antd";
import OrderDesc from "../orderDetail/orderDesc";
import Receivable from "./receivable";
import Assign from "@/manageCenter/publicComponent/assign";
import {
getLiquidationStatus,
getProcessStatus,
getApproval,
getInvoiceStatus,
getTransactionProject
} from "@/tools";
import { ChooseList } from "../../order/orderNew/chooseList"
const FormItem = Form.Item;
const { TabPane } = Tabs;
const ShouKuang = React.createClass({
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)
);
},
loadData(pageNo) {
this.state.data = [];
this.setState({
selectedRowKeys: [],
selectedRowKey: [],
page: pageNo,
loading: true
});
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/financial/financeList",
data: {
pageNo: pageNo || 1,
pageSize: this.state.pagination.pageSize,
buyerName: this.state.nameSearch, //客户名称
orderNo: this.state.orderNoSearch,
startTime: this.state.releaseDate[0],
endTime: this.state.releaseDate[1],
departmentId: this.state.departmenttList,
processStatus: this.state.processStatusSearch,
contractNo: this.state.contractNoSearch
},
success: function(data) {
let theArr = [];
if (!data.data || !data.data.list) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
}
} else {
for (let i = 0; i < data.data.list.length; i++) {
let thisdata = data.data.list[i];
theArr.push({
key: thisdata.orderNo,
orderNo: thisdata.orderNo,
orderType: thisdata.orderType,
orderStatus: thisdata.orderStatus,
sellerName: thisdata.sellerName,
processStatus: thisdata.processStatus,
liquidationStatus: thisdata.liquidationStatus,
approval: thisdata.approval,
buyerName: thisdata.buyerName,
actuallyTotalAmount: thisdata.actuallyTotalAmount,
signTime: thisdata.signTime,
companyId: thisdata.companyId,
companyName: thisdata.companyName,
buyerId: thisdata.buyerId,
buyerName: thisdata.buyerName,
contractNo: thisdata.contractNo,
createTime: thisdata.createTime,
departmentName: thisdata.departmentName
});
}
}
this.state.pagination.current = data.data.pageNo;
this.state.pagination.total = data.data.totalCount;
if (data.data && data.data.list && !data.data.list.length) {
this.state.pagination.current = 0;
this.state.pagination.total = 0;
}
this.setState({
totalPage: data.data.totalPage,
dataSource: theArr,
pagination: this.state.pagination
});
}.bind(this)
}).always(
function() {
this.setState({
loading: false
});
}.bind(this)
);
},
getInitialState() {
return {
searchMore: true,
assignVisibleX: false,
assignVisibleY: false,
releaseDate: [],
assignDataX: [],
assignDataY: [],
totalPage: 0,
processStatusSearch: "3",
boHuivisible: false,
selectedRowKeys: [],
selectedRows: [],
loading: false,
pagination: {
defaultCurrent: 1,
defaultPageSize: 10,
showQuickJumper: true,
pageSize: 10,
onChange: function(page) {
this.loadData(page);
}.bind(this),
showTotal: function(total) {
return "共" + total + "条数据";
}
},
// 子组件改变的表格title数组
changeList: undefined,
columns: [
{
title: "订单编号",
dataIndex: "orderNo",
key: "orderNo"
// fixed: "left"
},
{
title: "签单日期",
dataIndex: "signTime",
key: "signTime"
},
{
title: "下单日期",
dataIndex: "createTime",
key: "createTime"
},
{
title: "已收款(万元)",
dataIndex: "actuallyTotalAmount",
key: "actuallyTotalAmount"
},
{
title: "客户名称",
dataIndex: "buyerName",
key: "buyerName"
},
{
title: "流程状态",
dataIndex: "processStatus",
key: "processStatus",
render: text => {
return getProcessStatus(text);
}
},
{
title: "订单部门",
dataIndex: "departmentName",
key: "departmentName"
},
{
title: "特批状态",
dataIndex: "approval",
key: "approval",
render: text => {
return getApproval(text);
}
},
{
title: "合同编号",
dataIndex: "contractNo",
key: "contractNo"
},
// {
// title: '订单状态',
// dataIndex: 'orderStatus',
// key: 'orderStatus',
// render: text => { return getNewOrderStatus(text)}
// },
{
title: "订单负责人",
dataIndex: "sellerName",
key: "sellerName"
},
{
title: "结算状态",
dataIndex: "liquidationStatus",
key: "liquidationStatus",
render: text => {
return getLiquidationStatus(text);
}
},
{
title: "操作",
dataIndex: "caozuo",
key: "caouzo",
render: (text, recard) => {
return (
{recard.liquidationStatus < 2 &&
(recard.approval === 1 || recard.approval === 2) ? (
) : (
)}
{recard.approval === 2 && recard.processStatus < 4 ? (
) : (
""
)}
{!(
recard.actuallyTotalAmount &&
Number(recard.actuallyTotalAmount) > 0
) && (
)}
{
}
);
}
}
],
dataSource: [],
searchTime: [],
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 => {
return getInvoiceStatus(text);
}
}
],
waterlistDate: [
{
title: "平台流水号",
dataIndex: "billNo",
key: "billNo"
// fixed: "left"
},
{
title: "金额(万元)",
dataIndex: "transactionAmount",
key: "transactionAmount"
},
{
title: "收款方",
dataIndex: "payeeName",
key: "payeeName"
},
{
title: "付款方",
dataIndex: "payerName",
key: "payerName"
},
{
title: "流水科目",
dataIndex: "transactionSubject",
key: "transactionSubject",
render: text => {
return getTransactionProject(text);
}
},
{
title: "收款类型",
dataIndex: "type",
key: "type"
},
{
title: "财务流水时间",
dataIndex: "financialPayTimes",
key: "financialPayTimes"
},
{
title: "财务流水号",
dataIndex: "financialPayNo",
key: "financialPayNo"
},
{
title: "订单编号",
dataIndex: "orderNo",
key: "orderNo"
},
{
title: "订单负责人",
dataIndex: "saleName",
key: "saleName"
},
{
title: "创建时间",
dataIndex: "createTimes",
key: "createTimes"
}
],
waterData: []
};
},
// 特批通过
evaluateZ(record) {
$.ajax({
method: "POST",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/financial/financeApproval",
data: {
orderNo: record.orderNo
}
}).done(
function(data) {
if (!data.error.length) {
message.success("通过成功!");
this.setState({
loading: false
});
this.loadData();
} else {
message.warning(data.error[0].message);
}
}.bind(this)
);
},
/* 收款 */
evaluateX(recard) {
this.state.assignDataX = recard;
this.setState({
assignVisibleX: true
});
},
/* 转交 */
evaluateY(recard, nub) {
this.state.assignDataY = recard;
this.setState({
nub,
assignVisibleY: true
});
},
/* 驳回 */
reject(recard) {
this.setState({
bohuiData: recard,
boHuiVisible: true,
content: ""
});
},
boHuiOk() {
this.setState({
boHuiVisible: false
});
if (
this.state.pagination.current == this.state.totalPage &&
this.state.pagination.total % 10 == 1
) {
this.loadData(this.state.page - 1);
} else {
this.loadData(this.state.page);
}
},
boHuiCancel() {
this.setState({
boHuiVisible: false
});
},
componentWillMount() {
this.loadData();
this.departmentList();
},
tableRowClick(record) {
this.state.RowData = record;
this.setState({
showDesc: true
});
},
closeDesc(e, s) {
this.state.showDesc = e;
if (s) {
this.loadData(this.state.page);
}
},
closeAssignX(e, s) {
this.state.assignDataX = {};
this.state.assignVisibleX = e;
if (s) {
this.loadData(this.state.page);
}
},
closeAssignY(e, s) {
this.state.assignDataY = {};
this.state.assignVisibleY = e;
if (s) {
this.loadData(this.state.page);
}
},
search() {
this.loadData();
},
reset() {
this.state.nameSearch = "";
this.state.releaseDate = [];
this.state.orderNoSearch = "";
this.state.departmenttList = undefined;
this.state.processStatus = [];
this.state.contractNoSearch = "";
this.loadData();
},
//驳回
boHuiSubmit(e) {
e.preventDefault();
if (!this.state.content) {
message.warning("请填写驳回原因");
return false;
}
this.setState({
loading: true
});
$.ajax({
method: "POST",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/financial/reject",
data: {
orderNo: this.state.bohuiData.orderNo,
reason: this.state.content
}
}).done(
function(data) {
if (!data.error.length) {
message.success("驳回成功!");
this.setState({
loading: false
});
this.boHuiOk();
} else {
message.warning(data.error[0].message);
}
}.bind(this)
);
},
searchSwitch() {
this.setState({
searchMore: !this.state.searchMore
});
},
changeList(arr) {
const newArr = [];
this.state.columns.forEach(item => {
arr.forEach(val => {
if (val === item.title) {
newArr.push(item);
}
});
});
this.setState({
changeList: newArr
});
},
callback(key) {
console.log(key);
},
onSelectChange(selectedRowKeys) {
console.log("selectedRowKeys changed: ", selectedRowKeys);
this.setState({ selectedRowKeys });
},
inRecordCanl() {
this.setState({
bvisible: false
});
},
inRecordData() {
this.setState({
loading: true
});
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url:
globalConfig.context +
"/api/admin/orderInvoice/salesmanOrderInvoiceList",
data: {
orderNo: this.state.selectedRowKeys[0]
},
success: function(data) {
let theArr = [];
let sum = 0;
if (!data.data) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
}
} else {
for (let i = 0; i < data.data.list.length; i++) {
let thisdata = data.data.list[i];
sum += parseFloat(thisdata.amount);
theArr.push({
id: thisdata.id,
orderno: thisdata.orderno, //订单编号
amount: thisdata.amount, //签单金额
createTime: thisdata.createTime, //流程状态
status: thisdata.status, //结算状态
rejectReason: thisdata.rejectReason
});
}
}
this.setState({
recordData: theArr,
sum: sum.toFixed(4)
});
}.bind(this)
}).done(
function() {
this.setState({
loading: false
});
}.bind(this)
);
},
waterData() {
this.state.data = [];
this.setState({
loading: true
});
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/financial/myBillList",
data: {
orderNo: this.state.selectedRowKeys[0],
},
success: function(data) {
let theArr = [];
let waterSum = 0;
if (!data.data || !data.data.list) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
}
} else {
for (let i = 0; i < data.data.list.length; i++) {
let thisdata = data.data.list[i];
waterSum += parseFloat(thisdata.transactionAmount);
theArr.push({
key: i,
orderNo: thisdata.orderNo,
billNo: thisdata.billNo,
transactionAmount: thisdata.transactionAmount,
payeeName: thisdata.payeeName,
payerName: thisdata.payerName,
transactionSubject: thisdata.transactionSubject,
transactionChannel: thisdata.transactionChannel,
financialPayTimes: thisdata.financialPayTimes,
financialPayNo: thisdata.financialPayNo,
createrName: thisdata.createrName,
saleName: thisdata.saleName,
createTimes: thisdata.createTimes,
type: thisdata.type == 0 ? "手工" : "批量"
});
}
}
this.setState({
waterData: theArr,
waterSum: waterSum.toFixed(4)
});
}.bind(this)
}).always(
function() {
this.setState({
loading: false
});
}.bind(this)
);
},
waterCanl() {
this.setState({
cvisible: false
});
},
render() {
const formItemLayout = {
labelCol: { span: 8 },
wrapperCol: { span: 14 }
};
const { RangePicker } = DatePicker;
var departmentArr = this.state.departmentArr || [];
const { loading, selectedRowKeys, visible } = this.state;
const rowSelection = {
selectedRowKeys,
onChange: this.onSelectChange,
hideDefaultSelections: true
};
return (
);
}
});
export default ShouKuang;