import React from 'react';
import { Icon, Button, AutoComplete,Input, Select, Spin, Popconfirm, Table, message,DatePicker, Upload, Form ,Modal,Col} from 'antd';
import $ from 'jquery/src/ajax';
import moment from 'moment';
import {boutique ,tepi,jiedian} from '@/dataDic.js';
import {
getLiquidationStatus,
getProcessStatus,
splitUrl,
getCuikuan,
moneyVerify,
ShowModal
} from "@/tools.js";
import './customer.less';
import ShowModalDiv from "@/showModal.jsx"
import OrderRiZi from "@/orderRiZi.jsx";
import { cuiJieDian } from "@/dataDic.js";
//图片组件
const PicturesWall = React.createClass({
getInitialState() {
return {
previewVisible: false,
previewImage: '',
fileList: [],
}
},
handleCancel() {
this.setState({
previewVisible: false
})
},
handlePreview(file) {
this.setState({
previewImage: file.url || file.thumbUrl,
previewVisible: true,
});
},
handleChange(info) {
let fileList = info.fileList;
this.setState({
fileList
});
this.props.fileList(fileList);
},
componentWillReceiveProps(nextProps) {
this.state.fileList = nextProps.pictureUrl;
this.state.pojectApplicationUrl = undefined;
},
render() {
const {
previewVisible,
previewImage,
fileList
} = this.state;
const uploadButton = (
);
return(
{fileList.length >= 18 ? null : uploadButton}
);
}
});
const IntentionCustomer = Form.create()(
React.createClass({
loadData(pageNo) {
this.setState({
visitModul: false,
loading: true,
ispage: pageNo,
modalVisible: false
});
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/newOrder/orderNewList",
data: {
pageNo: pageNo || 1,
pageSize: this.state.pagination.pageSize,
specially: 2, //审核列表
name: this.state.customerName, //名称
orderNo: this.state.orderNoSearch, //订单编号
starTime: this.state.releaseDate[0], //开始时间
endTime: this.state.releaseDate[1] //结束时间
},
success: function(data) {
ShowModal(this);
let theArr = [];
if (data.error.length || 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: i,
id: thisdata.id, //用户ID
orderNo: thisdata.orderNo, //订单编号
totalAmount: thisdata.totalAmount + "", //签单金额
processStatus: thisdata.processStatus, //流程状态
liquidationStatus: thisdata.liquidationStatus, //结算状态
approval: thisdata.approval, //特批状态
signDate: thisdata.signDate, //签单时间
userName: thisdata.userName, //客户名称
salesmanName: thisdata.salesmanName, //营销员名称
financeName: thisdata.financeName, //财务名称
createDate: thisdata.createDate, //下单时间
initiateName: thisdata.initiateName, //驳回人
reason: thisdata.reason, //驳回信息
backDate: thisdata.backDate, //驳回日期
backId: thisdata.backId //驳回编号
});
}
this.state.pagination.total = data.data.totalCount;
this.state.pagination.current = data.data.pageNo;
}
if (data.data && data.data.list && !data.data.list.length) {
this.state.pagination.total = 0;
}
this.setState({
dataSource: theArr,
pageNo: pageNo,
pagination: this.state.pagination,
selectedRowKeys: []
});
}.bind(this)
}).always(
function() {
this.setState({
loading: false
});
}.bind(this)
);
},
getInitialState() {
return {
page: 1,
releaseDate: [],
selectedRowKeys: [],
orgCodeUrl: [],
customerArr: [],
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: "backId",
key: "backId"
},
{
title: "驳回日期",
dataIndex: "backDate",
key: "backDate"
},
{
title: "下单时间",
dataIndex: "createDate",
key: "createDate"
},
{
title: "订单编号",
dataIndex: "orderNo",
key: "orderNo"
},
{
title: "客户名称",
dataIndex: "userName",
key: "userName",
render: text => {
return text && text.length > 9 ? text.substr(0, 9) + "..." : text;
}
},
{
title: "驳回人",
dataIndex: "initiateName",
key: "initiateName"
},
{
title: "驳回原因",
dataIndex: "reason",
key: "reason",
render: text => {
return text && text.length > 24
? text.substr(0, 24) + "..."
: text;
}
}
],
columnsrizhi: [
{
title: "流程",
dataIndex: "processName",
key: "processName"
},
{
title: "操作人",
dataIndex: "adminName",
key: "adminName"
},
{
title: "时间",
dataIndex: "createDate",
key: "createDate"
}
],
data: [],
dataSource: [],
columnsX: [
{
title: "业务项目名称",
dataIndex: "commodityName",
key: "commodityName"
},
{
title: "项目类别",
dataIndex: "cname",
key: "cname"
},
{
title: "项目数量",
dataIndex: "commodityQuantity",
key: "commodityQuantity"
},
{
title: "金额(万元)",
dataIndex: "commodityPrice",
key: "commodityPrice"
},
{
title: "负责人",
dataIndex: "contacts",
key: "contacts"
},
{
title: "负责人电话",
dataIndex: "contactsMobile",
key: "contactsMobile"
},
{
title: "主要项目",
dataIndex: "main",
key: "main",
render: text => {
return text ? "是" : "否";
}
},
{
title: "项目说明",
dataIndex: "taskComment",
key: "taskComment",
render: text => {
return text && text.length > 8 ? text.substr(0, 8) + "…" : text;
}
},
{
title: "操作",
dataIndex: "ABC",
key: "ABC",
render: (text, record) => {
return (
{this.state.processStatus == 0 ? (
{
this.delectRow(record);
}}
okText="是"
cancelText="否"
>
) : (
""
)}
);
}
}
],
dataSourceX: [],
ContactsListsNew: [
{
title: "项目名称",
dataIndex: "commodityName",
key: "commodityName",
render: (text, record, index) => {
let dataArr = this.state.dataSourceX || [];
if (text) {
return {text};
}
return (
);
}
},
{
title: "项目分类",
dataIndex: "projectType",
key: "projectType",
render: (text, record) => {
if (text) {
let arr = this.state.dataSourceX || [];
let str = "";
for (let i = 0; i < arr.length; i++) {
if (this.state.dataSourceX[i].sort == text) {
str = this.state.dataSourceX[i].cname;
return {str};
}
}
}
if (this.state.getLoad) {
return (
);
} else {
return (
);
}
}
},
{
title: "催款科目",
dataIndex: "dunTypeName",
key: "dunTypeName",
render: (text, record) => {
if (text) {
return {text};
}
if (this.state.getLoad) {
let arr = record.arr || [];
console.log("arrrr", arr);
return (
);
} else {
return (
);
}
}
},
{
title: "首付时间(特批需选择时间)",
dataIndex: "waitDay",
key: "waitDay",
render: (text, record) => {
if (record.dunTypeName) {
if (text == 0) {
var str = "当天";
} else if (!text) {
var str = "";
} else {
var str = text + "天";
}
return {str};
}
return (
);
}
},
{
title: "金额(万元)",
dataIndex: "money",
key: "money",
render: (text, record) => {
if (record.dunTypeName) {
if (record.appropriationRatio && !record.money) {
return {record.appropriationRatio}(拨款比例);
} else if (record.appropriationRatio && record.money) {
return (
{text}(比例:{record.appropriationRatio})
);
} else {
return {text};
}
}
if (this.state.boFlag) {
return (
);
} else {
return (
{
record.money = e.target.value;
this.setState({ contactList: this.state.contactList });
}}
style={{ width: "120px" }}
/>
);
}
}
},
{
title: "服务年限",
dataIndex: "startDate",
key: "startDate",
render: (text, record) => {
if (record.dunTypeName) {
return {text};
}
return (
);
}
},
{
title: "催款状态",
dataIndex: "status",
key: "status",
render: text => {
return {text == 1 ? "已启动" : "未启动"};
}
},
{
title: "操作",
dataIndex: "dels",
key: "dels",
render: (text, record, index) => {
return (
{this.state.processStatus == 0 ? (
{
this.confirmDeletNew(record);
}}
okText="删除"
cancelText="不删除"
>
) : (
""
)}
{record.isSave ? (
) : (
""
)}
);
}
}
],
ContactsLists: [
{
title: "催款科目",
dataIndex: "dunSubject",
key: "dunSubject",
render: (text, record) => {
return (
);
}
},
{
title: "金额(万元)",
dataIndex: "money",
key: "money",
render: (text, record) => {
return (
{
record.money = e.target.value;
this.setState({ contactList: this.state.contactList });
}}
style={{ width: "120px" }}
/>
);
}
},
{
title: "催款状态",
dataIndex: "dunStatus",
key: "dunStatus",
render: text => {
return getCuikuan(text);
}
},
{
title: "操作",
dataIndex: "dels",
key: "dels",
render: (text, record) => {
return (
{
{
this.confirmDelet(record.key);
}}
okText="删除"
cancelText="不删除"
>
}
{record.id ? (
""
) : (
)}
);
}
}
]
};
},
//删除
delectRow(record) {
this.setState({
loading: true
});
$.ajax({
method: "post",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/newOrder/deleteOrderTask",
data: {
id: record.id
}
}).done(
function(data) {
if (!data.error.length) {
message.success("删除成功!");
this.setState({
loading: false
});
this.xiangmu(this.state.orderNo);
this.loadData();
} else {
message.warning(data.error[0].message);
}
}.bind(this)
);
},
//页面加载函数
componentWillMount() {
this.loadData();
},
//整行点击
tableRowClick(record) {
this.setState({
visible: true
});
this.xiangqing(record.orderNo);
this.xiangmu(record.orderNo);
this.jiedian(record.orderNo);
this.jiedianNew(record.orderNo);
this.departmentList();
},
//点击打卡项目详情
tableRowClickX(record) {
this.setState({
jid: record.id, //项目ID
kid: record.commodityId, //商品ID
commodityName: record.commodityName, //金额
commodityPrice: record.commodityPrice, //金额
commodityQuantity: record.commodityQuantity, //数量
taskComment: record.taskComment, //备注
main: record.main.toString(), //是否为主要
addnextVisible: true,
addState: 0
});
},
//项目详情关闭
nextCancel() {
this.setState({
addnextVisible: false
});
},
//订单详情
xiangqing(orderNos) {
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/newOrder/getOrderNewDetail",
data: {
orderNo: orderNos
},
success: function(data) {
if (data.error.length || data.data.list == "") {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
}
} else {
let thisdata = data.data;
if (thisdata.approval == 2) {
thisdata.approval = "特批通过";
} else if (thisdata.approval == 3) {
thisdata.approval = "特批驳回";
}
this.setState({
id: thisdata.id,
kehuId: thisdata.buyerId,
orderNo: thisdata.orderNo, //订单编号
contractNo: thisdata.contractNo, //合同编号
userName: thisdata.userName, //客户名称
signDate: thisdata.signDate, //签单时间
processStatus: thisdata.processStatus, //流程状态
liquidationStatus: thisdata.liquidationStatus, //结算状态
contacts: thisdata.contacts, //企业联系人
contactMobile: thisdata.contactMobile, //联系人电话
legalPerson: thisdata.legalPerson, //法人
legalPersonTel: thisdata.legalPersonTel, //法人电话
firstAmount: thisdata.firstAmount + "", //签单金额
totalAmount: thisdata.totalAmount + "", //首付金额
settlementAmount: thisdata.settlementAmount, //已收款项
orderRemarks: thisdata.orderRemarks, //订单留言
orgCodeUrl: thisdata.contractPictureUrl
? splitUrl(
thisdata.contractPictureUrl,
",",
globalConfig.avatarHost + "/upload"
)
: [], //图片地址
salesmanName: thisdata.salesmanName, //营销员名称
salesmanMobile: thisdata.salesmanMobile, //营销员电话
oldSalesmanName: thisdata.oldSalesmanName, //营销员名称
oldSalesmanMobile: thisdata.oldSalesmanMobile, //营销员电话
financeName: thisdata.financeName, //财务名称
financeMobile: thisdata.financeMobile, //财务电话
nowFinance: thisdata.nowFinance, //财务名称
nowFinanceMobile: thisdata.nowFinanceMobile, //财务电话
initiateName: thisdata.initiateName, //驳回人
backDate: thisdata.backDate, //驳回时间
reason: thisdata.reason, //驳回原因
approval: thisdata.approval.toString(), //特批状态
organizationSearch: thisdata.orderDep,
//approval:thisdata.approval==0?thisdata.approval.toString():thisdata.approval,//特批状态
outsource: thisdata.outsource == 0 ? "否" : "是"
});
}
}.bind(this)
}).always(
function() {
this.setState({
loading: false
});
}.bind(this)
);
},
//项目列表
xiangmu(orderNos) {
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/newOrder/getOrderTask",
data: {
orderNo: orderNos
},
success: function(data) {
let theArr = [];
if (data.error.length || data.data.list == "") {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
}
} else {
for (let i = 0; i < data.data.length; i++) {
let thisdata = data.data[i];
theArr.push({
key: i,
id: thisdata.id,
orderNo: thisdata.orderNo, //订单编号
commodityId: thisdata.commodityId, //项目ID
commodityName: thisdata.commodityName, //项目名称
cname: thisdata.cname, //项目类别
commodityPrice: thisdata.commodityPrice, //项目价格
commodityQuantity: thisdata.commodityQuantity, //项目数量
main: thisdata.main, //是否为主要任务
taskComment: thisdata.taskComment, //任务说明
contacts: thisdata.contacts, //联系人
contactsMobile: thisdata.contactsMobile, //联系人电话
sort: thisdata.cSort
});
}
}
this.setState({
dataSourceX: theArr,
paginations: false
});
}.bind(this)
}).always(
function() {
this.setState({
loading: false
});
}.bind(this)
);
},
//节点列表
jiedian(orderNos) {
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/newOrder/selectOrderDun",
data: {
orderNo: orderNos
},
success: function(data) {
let theArr = [];
let thisData = [];
if (data.error.length || data.data.list == "") {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
}
} else {
for (let i = 0; i < data.data.length; i++) {
thisData = data.data[i];
theArr.push({
key: i,
dunSubject: thisData.dunSubject
? thisData.dunSubject.toString()
: "", //催款科目
id: thisData.id, //节点Id
money: thisData.money, //催款金额
dunStatus: thisData.dunStatus, //催款状态
orderNo: thisData.orderNo
});
}
this.setState({
contactList: theArr
});
}
}.bind(this)
}).always(
function() {
this.setState({
loading: false
});
}.bind(this)
);
},
//查看催款节点
jiedianNew(orderNos) {
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url:
globalConfig.context + "/api/admin/newOrderDun/selectListNewOrderDun",
data: {
orderNo: orderNos
},
success: function(data) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
} else {
let theArr = [];
let thisData = [];
let arr = data.data || [];
let totalCui = 0;
for (let i = 0; i < arr.length; i++) {
thisData = arr[i];
totalCui += +thisData.money;
theArr.push({
key: i,
dunSubject: thisData.dunSubject
? thisData.dunSubject.toString()
: "", //催款科目
id: thisData.id, //节点Id
money: thisData.money, //催款金额
// orderNo: record ? record.orderNo : this.props.datauser.orderNo,
commodityName: thisData.commodityName,
projectType: thisData.projectType,
dunTypeName: thisData.dunTypeName,
status: thisData.status,
waitDay: thisData.waitDay,
effectiveCount: thisData.effectiveCount,
startDate: thisData.startDate,
dunType: thisData.dunType,
appropriationRatio: thisData.appropriationRatio
});
}
if (!totalCui) {
totalCui = 0;
}
totalCui = (Math.round(totalCui * 10000) / 10000).toFixed(4);
this.setState({
contactListNew: theArr,
totalCui
});
}
}.bind(this)
}).always(
function() {
this.setState({
loading: false
});
}.bind(this)
);
},
//催款节点保存
contactSave() {
for (let i = 0; i < this.state.contactList.length; i++) {
if (moneyVerify(this.state.contactList[i].money)) {
return;
}
}
this.setState({
loading: true
});
$.ajax({
url: globalConfig.context + "/api/admin/newOrder/createOrderDun",
method: "post",
data: {
orderNo: this.state.orderNo,
orderDun: JSON.stringify(this.state.contactList)
}
}).done(
function(data) {
this.setState({
loading: false
});
if (!data.error.length) {
message.success("保存成功!");
this.jiedian(this.state.orderNo);
} else {
message.warning(data.error[0].message);
}
}.bind(this)
);
},
//催款节点保存
contactSaveNew(record) {
if (record.boStatus == "false") {
record.boStatus = false;
} else if (record.boStatus == "true") {
record.boStatus = true;
}
if (!this.state.yearFlag) {
if (!record.effectiveCount) {
message.warning("请选择服务年限");
return;
}
} else {
record.effectiveCount = "";
}
if (record.money == "") {
message.warning("请填写金额");
return;
}
if (record.boStatus) {
if (
typeof +record.money == "number" &&
+record.money >= 0 &&
+record.money <= 1
) {
record.appropriationRatio = record.money;
} else {
message.warning("金额比例填写错误,比例范围0~1");
return;
}
}
if (!record.dunType) {
message.warning("请选择对应科目");
return;
}
if (record.dunType != 1) {
record.waitDay = "";
}
this.setState({
loading: true
});
if (record.boStatus) {
$.ajax({
url: globalConfig.context + "/api/admin/newOrderDun/createDun",
method: "post",
data: {
orderNo: record.orderNo,
tid: record.tid,
projectType: record.sort,
dunType: record.dunType,
appropriationRatio: record.appropriationRatio,
waitDay: record.waitDay,
effectiveCount: record.effectiveCount
}
}).done(
function(data) {
this.setState({
loading: false
});
if (!data.error.length) {
message.success("保存成功!");
this.setState({
cuiFlag: false,
boFlag: false
});
this.jiedianNew(record.orderNo);
} else {
message.warning(data.error[0].message);
}
}.bind(this)
);
} else {
$.ajax({
url: globalConfig.context + "/api/admin/newOrderDun/createDun",
method: "post",
data: {
orderNo: record.orderNo,
tid: record.tid,
projectType: record.sort,
dunType: record.dunType,
money: record.money,
waitDay: record.waitDay,
effectiveCount: record.effectiveCount
}
}).done(
function(data) {
this.setState({
loading: false
});
if (!data.error.length) {
message.success("保存成功!");
this.setState({
cuiFlag: false,
boFlag: false
});
this.jiedianNew(record.orderNo);
} else {
message.warning(data.error[0].message);
}
}.bind(this)
);
}
},
//点击新增催款节点
addcontact() {
this.state.contactList.push({
key: this.state.contactList.length,
money: "",
dunSubject: undefined,
orderNo: this.state.orderNo,
dunTarget: this.state.kehuId
});
this.setState({
contactList: this.state.contactList
});
},
//点击新增催款节点
addcontactNew() {
this.state.contactListNew.push({
key: this.state.contactListNew.length,
money: "",
dunSubject: undefined,
orderNo: this.state.orderNo,
dunTarget: this.state.kehuId
});
this.setState({
contactListNew: this.state.contactListNew,
cuiFlag: true
});
},
//删除收款节点
confirmDelet(index) {
this.state.contactList.splice(index, 1);
this.setState({
contactList: this.state.contactList
});
this.contactSave();
},
//删除收款节点
confirmDeletNew(index) {
if (index.id) {
this.state.contactListNew.splice(index.key, 1);
this.setState({
contactListNew: this.state.contactListNew,
cuiFlag: false,
addFlag: false,
boFlag: false
});
$.ajax({
url: globalConfig.context + "/api/admin/newOrderDun/deleteDun",
method: "post",
data: {
id: index.id
}
}).done(
function(data) {
this.setState({
loading: false
});
if (!data.error.length) {
message.success("删除成功!");
this.setState({
cuiFlag: false
});
this.jiedianNew(this.state.orderNo);
} else {
message.warning(data.error[0].message);
}
}.bind(this)
);
} else {
this.state.contactListNew.splice(index.key, 1);
this.setState({
contactListNew: this.state.contactListNew,
cuiFlag: false,
addFlag: false,
boFlag: false
});
}
},
//重新提交
examOk() {
if (this.state.flag) return;
this.setState({
flag: true
});
let theorgCodeUrl = [];
if (this.state.orgCodeUrl.length) {
let picArr = [];
this.state.orgCodeUrl.map(function(item) {
if (
item.response &&
item.response.data &&
item.response.data.length
) {
picArr.push(item.response.data);
}
});
theorgCodeUrl = picArr.join(",");
}
if (moneyVerify(this.state.totalAmount)) {
this.setState({
flag: false
});
return;
}
if (moneyVerify(this.state.firstAmount)) {
this.setState({
flag: false
});
return;
}
if (!this.state.totalAmount) {
message.warning("签单金额不能为空");
this.refs.signFirstPayment.focus();
this.setState({
flag: false
});
return false;
}
if (!this.state.firstAmount) {
message.warning("首付金额不能为空");
this.refs.signFirstPayment.focus();
this.setState({
flag: false
});
return false;
}
if (!theorgCodeUrl) {
message.warning("企业负责人不能为空");
this.refs.signFirstPayment.focus();
this.setState({
flag: false
});
return false;
}
if (
this.state.approval == "特批通过" ||
this.state.approval == "特批驳回"
) {
message.warning("特批状态不正确,请重新填写");
this.setState({
flag: false
});
return false;
}
const arr = this.state.contactListNew || [];
for (let i = 0; i < arr.length; i++) {
if (
arr[i].dunType == 1 &&
arr[i].waitDay != null &&
this.state.approval == 0
) {
message.warning(
"非特批存在填写催款节点首付时间的情况,请删除后重新填写保存"
);
this.setState({
flag: false
});
return false;
} else if (
arr[i].dunType == 1 &&
arr[i].waitDay == null &&
this.state.approval == 1
) {
message.warning(
"特批存在首付催款节点未填写时间的情况,请删除后重新填写保存"
);
this.setState({
flag: false
});
return false;
}
if (!this.state.contactListNew[i].id) {
message.warning("请保存催款节点");
this.setState({
flag: false
});
return false;
}
}
$.ajax({
method: "post",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/newOrder/updateServiceOrderNew",
data: {
orderNo: this.state.orderNo, //订单编号
totalAmount: this.state.totalAmount, //总金额
firstAmount: this.state.firstAmount, //首付
isSubmit: 1, //保存草稿还是提交
signDate: this.state.signDate, //签单日期
contacts: this.state.contacts, //企业负责人
contactMobile: this.state.contactMobile, //负责人联系方式
legalPerson: this.state.legalPerson, //企业法人
legalPersonTel: this.state.legalPersonTel, //企业法人联系电话
approval: this.state.approval, //特批状态
contractNo: this.state.contractNo, //合同编号
orderRemarks: this.state.orderRemarks, //订单备注
contractPictureUrl: theorgCodeUrl.length ? theorgCodeUrl : "",
orderDep: this.state.organizationSearch
},
success: function(data) {
if (data.error.length || data.data.list == "") {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
this.setState({
flag: false
});
}
} else {
message.success("该订单已重新提交~");
this.setState({
visible: false,
flag: false
});
this.resets();
this.loadData();
}
}.bind(this)
}).always(
function() {
this.setState({
loading: false
});
}.bind(this)
);
},
//重新提交
examOks() {
if (this.state.flag) return;
this.setState({
flag: true
});
$.ajax({
method: "post",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/newOrder/deleteOrderNew",
data: {
orderNo: this.state.orderNo //订单编号
},
success: function(data) {
if (data.error.length || data.data.list == "") {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
}
} else {
message.success("该订单已作废~");
this.setState({
visible: false,
flag: false
});
this.resets();
this.loadData();
}
}.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);
}
thedata = {};
} else {
thedata.map(function(item, index) {
theArr.push({
key: index,
name: item.name,
id: item.id,
depNo: item.depNo
});
});
}
this.setState({
departmentArr: theArr
});
console.log(this.state.departmentArr);
}.bind(this)
}).always(
function() {
this.setState({
loading: false
});
}.bind(this)
);
},
//新建项目明细保存
nextSubmit(e) {
e.preventDefault();
if (this.state.gid == undefined || !this.state.gid) {
message.warning("服务名称不匹配!");
return false;
}
if (moneyVerify(this.state.commodityPrice)) {
return;
}
if (!this.state.commodityPrice) {
message.warning("请输入金额!");
this.refs.commodityPrice.focus();
return false;
}
if (!this.state.commodityQuantity) {
message.warning("请输入商品数量!");
this.refs.commodityQuantity.focus();
return false;
}
if (!this.state.main) {
message.warning("请选择是否为主要项目!");
this.refs.commodityQuantity.focus();
return false;
}
this.setState({
loading: true
});
let api = this.state.addState
? "/api/admin/newOrder/addOrderTask"
: "/api/bianji";
$.ajax({
method: "POST",
dataType: "json",
crossDomain: false,
url: globalConfig.context + api,
data: {
commodityId: this.state.gid, //商品ID
orderNo: this.state.orderNo, //订单编号
commodityName: this.state.commodityName, //商品名称
commodityQuantity: this.state.commodityQuantity, //商品数量
commodityPrice: this.state.commodityPrice, //签单总价
taskComment: this.state.taskComment, //服务说明
main: this.state.main //是否为主要项目
}
}).done(
function(data) {
this.setState({
loading: false
});
if (!data.error.length) {
message.success("保存成功!");
this.nextCancel();
this.xiangmu(this.state.orderNo);
} else {
message.warning(data.error[0].message);
}
}.bind(this)
);
},
rizhi() {
console.log(this.state.orderNo);
this.setState({
loading: true
});
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: "/api/admin/newOrder/selectOrderLog",
data: {
orderNo: this.state.orderNo
},
success: function(data) {
let theArr = [];
let thisData = data.data;
if (!thisData.length) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
}
thisData = {};
} else {
for (let i = 0; i < data.data.length; i++) {
let thisdata = data.data[i];
theArr.push({
processName: thisdata.processName,
adminName: thisdata.adminName,
createDate: thisdata.createDate
});
}
}
this.setState({
dataSourcerizhi: theArr
});
}.bind(this)
}).always(
function() {
this.setState({
loading: false
});
}.bind(this)
);
},
//查看订单日志
getOrderLog() {
this.setState({
rizhivisible: true
});
this.rizhi();
},
closeOrderLog() {
this.setState({
rizhivisible: false
});
},
//点击签单
handleCancels() {
this.setState({
isSubmit: 1
});
},
//点击签单
handleCancelq() {
this.setState({
isSubmit: 0
});
},
resets() {
this.state.orderNo = "";
this.state.customerName = "";
this.state.releaseDate[0] = undefined;
this.state.releaseDate[1] = undefined;
this.loadData();
},
//点击添加项目明细
addDetailed() {
this.setState({
gid: "",
customerArr: [],
commodityName: "",
commodityQuantity: "",
commodityId: "",
taskComment: "",
main: undefined,
commodityPrice: "",
addState: 1,
addnextVisible: true
});
},
//修改项目详情
tabRowSave(e) {
e.preventDefault();
if (!this.state.commodityPrice) {
message.warning("金额不能为空!");
return false;
}
if (!this.state.commodityQuantity) {
message.warning("数量不能为空!");
return false;
}
if (!this.state.main) {
message.warning("请选择是否为主要项目!");
this.refs.commodityQuantity.focus();
return false;
}
$.ajax({
method: "POST",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/newOrder/updateOrderTask",
data: {
id: this.state.jid, //项目ID
commodityId: this.state.kid, //商品ID
orderNo: this.state.orderNo, //订单编号
main: this.state.main, //是否为主要
commodityPrice: this.state.commodityPrice, //金额
commodityQuantity: this.state.commodityQuantity, //数量
taskComment: this.state.taskComment //备注
}
}).done(
function(data) {
this.setState({
loading: false
});
if (!data.error.length) {
message.success("保存成功!");
this.nextCancel();
this.xiangmu(this.state.orderNo);
//this.loaduser(this.props.datauser);
this.loadData();
} else {
message.warning(data.error[0].message);
}
}.bind(this)
);
},
//搜索
search() {
this.setState({
//signBillVisible:false
});
this.loadData();
},
getOrgCodeUrl(e) {
this.setState({ orgCodeUrl: e });
},
//关闭详情
visitCancel() {
this.setState({
visible: false,
cuiFlag: false,
addFlag: false,
boFlag: false
});
this.resets();
},
visitOk() {
this.setState({
visible: false
});
this.resets();
},
//客户
selectAutoCUT(value) {
let autoIds;
let fwList = this.state.customerArr;
fwList.map(function(item) {
if (value == item.name) {
autoIds = item.id;
}
});
this.setState({
customerName: value,
autoId: autoIds
});
},
//加载(自动补全)
supervisor(e, state) {
//客户名称与服务名称自动补全
let api = state
? "/api/admin/customer/getCustomerByName"
: "/api/admin/order/getBusinessProjectByName";
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + api,
data: state
? {
name: e,
type: this.state.customType
}
: {
businessName: 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({
states: state,
customerArr: thedata
});
}.bind(this)
}).always(
function() {
this.setState({
loading: false
});
}.bind(this)
);
},
//上级主管输入框失去焦点是判断客户是否存在
selectAuto(value) {
let kid = [];
let fwList = this.state.customerArr;
fwList.map(function(item) {
if (value == item.bname) {
kid = item;
}
});
this.setState({
commodityName: value,
gid: kid.id,
//commodityPrice:kid.price==0?kid.price.toString():kid.price,
commodityFirstPayment:
kid.firstPayment == 0 ? kid.firstPayment.toString() : kid.firstPayment
});
},
//服务值改变时请求客户名称
httpChange(e) {
this.state.gid = "";
if (e.length >= 1) {
this.supervisor(e, false);
}
this.setState({
commodityName: e
});
},
render() {
const formItemLayout = {
labelCol: { span: 8 },
wrapperCol: { span: 14 }
};
const FormItem = Form.Item;
const { RangePicker } = DatePicker;
const rowSelection = {
selectedRowKeys: this.state.selectedRowKeys,
onChange: (selectedRowKeys, selectedRows) => {
this.setState({
modalVisible: false,
selectedRows: selectedRows.slice(-1),
selectedRowKeys: selectedRowKeys.slice(-1)
});
},
onSelect: recordt => {
this.setState({
modalVisible: false,
recordt: recordt.id
});
}
};
const cuiDataList = this.state.contactList || [];
const dataSources = this.state.customerArr || [];
let departmentArr = this.state.departmentArr || [];
const options = this.state.states
? dataSources.map(group => (
{group.name}
))
: dataSources.map((group, index) => (
{group.bname}
));
return (
);
}
})
);
export default IntentionCustomer;