import React from 'react';
import { Icon, Table, Modal, message, Spin, Input, Select, Button, Form, Upload, Popconfirm, AutoComplete, Radio, DatePicker } from 'antd';
import ajax from 'jquery/src/ajax/xhr.js';
import $ from 'jquery/src/ajax';
import '../userMangagement.less';
import { orderType } from '../../../../dataDic.js';
import { getOrderType, getProjectState, getTaskStatus, getOrderChannel, getOrderState, getPaymentState, getChangeState, getApprovedState, getPublishStatus } from '../../../../tools.js';
import moment from 'moment';
const MySettlementDetaile = Form.create()(React.createClass({
loadData(record) {
this.setState({
loading: true
});
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + '/api/admin/techproject/getProjectTask',
data: {
contractId: record ? record.id : this.props.datauser.id
},
success: function (data) {
let theArr = [];
if (!data.data) {
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,
taskId: thisdata.taskId,
commodityName: thisdata.commodityName,
commodityQuantity: thisdata.commodityQuantity,
technicianName: thisdata.technicianName,
technicianMobile: thisdata.technicianMobile,
taskStatus: thisdata.taskStatus,
deleteSign: thisdata.deleteSign,
taskComment: thisdata.taskComment,
publishStatus: thisdata.publishStatus,
});
};
}
this.setState({
dataSource: theArr,
});
}.bind(this),
}).always(function () {
this.setState({
loading: false
});
}.bind(this));
},
getInitialState() {
return {
loading: false,
visible: false,
contractState: false,
projectVisible: false,
selectedRowKey: [],
orderSelect: false,
transferState: false,
orgCodeUrl: [],
lvState: true,
lvRadio: 0,
customerArr: [],
checkedKeys: [],
//派单
columns: [
{
title: '任务名称',
dataIndex: 'commodityName',
key: 'commodityName'
}, {
title: '任务负责人',
dataIndex: 'technicianName',
key: 'technicianName'
}, {
title: '负责人联系方式',
dataIndex: 'technicianMobile',
key: 'technicianMobile'
}, {
title: '任务状态',
dataIndex: 'taskStatus',
key: 'taskStatus',
render: (text) => { return getTaskStatus(text) }
}, {
title: '公示状态',
dataIndex: 'publishStatus',
key: 'publishStatus',
render: (text) => {
{ return getPublishStatus(text) }
}
}, {
title: '是否锁定',
dataIndex: 'deleteSign',
key: 'deleteSign',
render: (text) => { return text == 2 ? '锁定' : '未锁定' }
}, {
title: '任务说明',
dataIndex: 'taskComment',
key: 'taskComment',
render: (text) => {
return (
text && text.length > 6 ? text.substr(0, 8) + '...' : text
)
}
}, {
title: '操作',
dataIndex: 'rrtk',
key: 'rrtk',
render: (text, record, index) => {
return (
{record.taskStatus <= 1 &&
{ this.voidOperation(record) }} okText="确认" cancelText="取消">
}
{record.taskStatus < 1 &&
}
)
}
}
],
userList: [
{
title: '用户编号',
dataIndex: 'userNo',
key: 'userNo'
}, {
title: '用户姓名',
dataIndex: 'name',
key: 'name'
}, {
title: '部门机构',
dataIndex: 'departmentName',
key: 'departmentName'
}, {
title: '职务',
dataIndex: 'position',
key: 'position'
}, {
title: '联系手机',
dataIndex: 'mobile',
key: 'mobile'
}, {
title: '操作',
dataIndex: 'abc',
key: 'abc',
render: (text, record, index) => {
return (
{this.state.transferState ?
{ this.transterSelect(record) }} okText="确认" cancelText="取消">
:
{ this.confirmSelect(record) }} okText="确认" cancelText="取消">
}
)
}
}
],
contractList: [
{
title: '姓名',
dataIndex: 'name',
key: 'name'
}, {
title: '部门',
dataIndex: 'depatrment',
key: 'depatrment'
}, {
title: '联系方式',
dataIndex: 'mobile',
key: 'mobile'
}, {
title: '是否为主要联系人',
dataIndex: 'major',
key: 'major',
render: (text) => {
return text ? '是' : "否"
}
}, {
title: '职务',
dataIndex: 'position',
key: 'position'
}, {
title: '微信',
dataIndex: 'wechat',
key: 'wechat'
}, {
title: 'QQ',
dataIndex: 'qq',
key: 'qq'
},
],
};
},
seeContract() {
this.contract();
this.setState({
seeState: false,
orderVisible: true
})
},
orderCancel() {
this.setState({
orderVisible: false
})
},
//查看联系人
contract() {
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + '/api/admin/customer/findAllContacts',
data: {
uid: this.state.buyerId
},
success: function (data) {
let thisData = data.data;
if (!thisData) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
};
thisData = {};
};
this.setState({
contractArr: thisData,
});
}.bind(this),
}).always(function () {
this.setState({
loading: false
});
}.bind(this));
},
//查看订单
seeOrderAjax(data) {
if (!data.orderNo) {
return false;
};
this.setState({
loading: true
});
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + '/api/admin/order/getServiceOrderDetail',
data: {
orderNo: data.orderNo
},
success: function (data) {
let thisData = data.data;
if (!thisData) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
};
thisData = {};
};
this.setState({
orderArr: thisData,
});
}.bind(this),
}).always(function () {
this.setState({
loading: false
});
}.bind(this));
},
//时间选择
selTime(e, index) {
this.setState({
completeDate: e,
selTime: index
})
},
setTime(e, index) {
this.setState({
signDate: e,
setTime: index
})
},
//查看详情
loaduser(record) {
if (record) {
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + '/api/admin/techproject/getProjectDetail',
data: {
contractId: record.id,
buyerType: record.buyerType
},
success: function (data) {
let thisData = data.data;
if (!thisData) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
};
thisData = {};
};
this.setState({
signTime: thisData.signDate,
completeTime: thisData.completeDate,
signComment: thisData.signComment,
contractNo: thisData.signComment,
completeComment: thisData.completeComment,
completeDate: thisData.completeDate ? moment(thisData.completeDate, 'YYYY-MM-DD HH:mm:ss') : undefined,
signDate: thisData.signDate ? moment(thisData.signDate, 'YYYY-MM-DD HH:mm:ss') : undefined,
buyerId: thisData.uid,
id: record.id,
orderNok: thisData.orderNo,
orderList: thisData,
technicianName: thisData.technicianName, //任务负责人
selTime: '',
setTime: ''
});
}.bind(this),
}).always(function () {
this.setState({
loading: false
});
}.bind(this));
}
},
//删除
voidOperation(record) {
this.setState({
loading: true
});
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + '/api/admin/techproject/deleteProjectTask',
data: {
taskId: record.taskId
}
}).done(function (data) {
if (!data.error.length) {
message.success('操作成功');
this.setState({
loading: false,
});
this.loadData();
this.props.closeDesc(true, true);
} else {
message.warning(data.error[0].message);
};
}.bind(this));
},
//订单编辑保存
handleOk(e) {
this.setState({
visible: false,
});
this.props.closeDesc(false, true);
},
handleCancel(e) {
this.setState({
visible: false,
});
this.props.closeDesc(false);
},
//新建项目
projectOk(e) {
this.setState({
projectVisible: false,
});
this.props.closeDesc(false, true);
},
projectCancel(e) {
this.setState({
projectVisible: false,
});
this.props.closeDesc(false);
},
//选定订单
orderOk() {
this.setState({
orderSelect: false,
});
},
componentWillMount() {
},
nextCancel() {
this.setState({
addnextVisible: false
})
},
//查看订单明细
orderDetails(record) {
if (record) {
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + '/api/admin/techproject/getProjectTaskDetail',
data: {
taskId: record.taskId
},
success: function (data) {
let thisData = data.data;
if (!thisData) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
};
thisData = {};
};
this.setState({
taskId: thisData.taskId,
taskNo: thisData.taskNo,
projectNo: thisData.projectNo,
categoryId: thisData.categoryId,
commodityName: thisData.commodityName,
taskStatus: thisData.taskStatus,
taskComment: thisData.taskComment,
deletedSign: thisData.deletedSign,
taskAllocatorName: thisData.taskAllocatorName,
taskReceiverName: thisData.taskReceiverName,
taskDistributionTime: thisData.taskDistributionTime,
});
}.bind(this),
}).always(function () {
this.setState({
loading: false
});
}.bind(this));
}
},
//创建项目保存
admissibleOrder() {
if (!this.state.autoId || !this.state.customerName) {
message.warning('客户名称不匹配');
return false;
};
if (!this.state.projectName) {
message.warning('请选择项目负责人');
return false;
};
if (!this.state.contractType) {
message.warning('请选择业务品类');
return false;
};
if (this.state.signComment && this.state.signComment.length > 45) {
message.warning('项目说明字数不能超过45字');
return false;
};
this.setState({
loading: true
});
$.ajax({
method: "POST",
dataType: "json",
crossDomain: false,
url: globalConfig.context + '/api/admin/techproject/createProject',
data: {
uid: this.state.autoId,
signComment: this.state.signComment,
aid: this.state.aid,
projectType: 0,
contractType: this.state.contractType
}
}).done(function (data) {
this.setState({
loading: false
});
if (!data.error.length) {
message.success('创建成功!');
this.projectOk()
} else {
message.warning(data.error[0].message);
}
}.bind(this));
},
//派单
//操作分配
confirmDelet(index) {
this.setState({
taskIds: index.taskId,
userDetaile: false,
distributionVisible: true,
transferState: false,
lvState: false,
distributionList: []
});
this.state.departmenttList = undefined;
this.state.financeNameSearch = '';
this.state.lvRadio = 0;
//this.contactLists();
},
distributionCancel() {
this.setState({
distributionVisible: false
})
},
distributionOk() {
this.setState({
distributionVisible: false
})
},
//分配对象列表
contactList() {
this.setState({
loading: true
});
let api = this.state.lvRadio == 2 ? '/api/admin/superviser/adminList' : '/api/admin/superviser/selectAdminByOrg'
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + api,
data: this.state.lvRadio == 2 ? {
pageNo: 1,
pageSize: 99,
departmentId: this.state.departmenttList,
name: this.state.financeNameSearch,
} : {
//subOrSame:!this.state.lvRadio?"SUB":"SAME"
},
success: function (data) {
let theArr = [];
if (!data.data) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
};
} else {
if (data.data.list) {
for (let i = 0; i < data.data.list.length; i++) {
let thisdata = data.data.list[i];
theArr.push({
key: i,
id: thisdata.id,
userNo: thisdata.userNo,
name: thisdata.name,
departmentName: thisdata.departmentName,
departmentId: thisdata.departmentId,
position: thisdata.position,
mobile: thisdata.mobile,
});
};
} else {
for (let i = 0; i < data.data.length; i++) {
let thisdata = data.data[i];
theArr.push({
key: i,
id: thisdata.id,
userNo: thisdata.userNo,
name: thisdata.name,
departmentName: thisdata.departmentName,
departmentId: thisdata.departmentId,
position: thisdata.position,
mobile: thisdata.mobile,
});
};
}
};
this.setState({
distributionList: theArr,
});
}.bind(this),
}).always(function () {
this.setState({
loading: false
});
}.bind(this));
},
//分配对象列表
contactLists() {
this.setState({
loading: true
});
let api = '/api/admin/superviser/adminList';
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + api,
data: {
pageNo: 1,
pageSize: 99,
departmentId: this.state.departmenttList,
name: this.state.financeNameSearch,
},
success: function (data) {
let theArr = [];
if (!data.data) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
};
} else {
if (data.data.list) {
for (let i = 0; i < data.data.list.length; i++) {
let thisdata = data.data.list[i];
theArr.push({
key: i,
id: thisdata.id,
userNo: thisdata.userNo,
name: thisdata.name,
departmentName: thisdata.departmentName,
departmentId: thisdata.departmentId,
position: thisdata.position,
mobile: thisdata.mobile,
});
};
} else {
for (let i = 0; i < data.data.length; i++) {
let thisdata = data.data[i];
theArr.push({
key: i,
id: thisdata.id,
userNo: thisdata.userNo,
name: thisdata.name,
departmentName: thisdata.departmentName,
departmentId: thisdata.departmentId,
position: thisdata.position,
mobile: thisdata.mobile,
});
};
}
};
this.setState({
distributionList: theArr,
});
}.bind(this),
}).always(function () {
this.setState({
loading: false
});
}.bind(this));
},
//选定对象
confirmSelect(record) {
if (this.state.projectVisible) {
this.setState({
aid: record.id,
projectName: record.name
})
this.distributionOk();
return false
}
this.setState({
loading: true
});
$.ajax({
method: "POST",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/techproject/distributionTask",
data: {
taskId: this.state.taskIds,
taskReceiverId: record.id
}
}).done(function (data) {
if (!data.error.length) {
message.success('分派成功!');
this.setState({
loading: false,
});
this.distributionOk();
this.loadData();
this.props.closeDesc(true, true);
} else {
message.warning(data.error[0].message);
};
}.bind(this));
},
//指派
//选定对象
transterSelect(record) {
this.setState({
loading: true
});
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/techproject/transferProject",
data: {
contractId: this.state.id,
projectReceiveId: record.id,
orderNo: this.state.orderNok || ''
}
}).done(function (data) {
if (!data.error.length) {
message.success('转交成功!');
this.setState({
loading: false,
});
this.distributionOk();
this.loaduser(this.props.datauser);
} else {
message.warning(data.error[0].message);
};
}.bind(this));
},
searchOrder() {
this.contactLists();
},
resetOrder() {
this.state.departmenttList = undefined;
this.state.financeNameSearch = '';
this.state.lvRadio = 0;
this.setState({
lvState: false,
distributionList: []
})
this.contactLists();
},
//添加任务
addTask() {
this.setState({
commodityQuantity: '',
commodityName: '',
taskComment: '',
kid: '',
commodityId: undefined,
addTaskState: true,
addnextVisible: true,
customerArr: []
});
},
//客户名称自动补全
//加载(自动补全)
supervisor(e, state) { //客户名称与服务名称自动补全
let api = state ? '/api/admin/customer/findCustomerByName' : '/api/admin/order/getBusinessProjectByName';
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + api,
data: state ? {
name: e
} : {
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));
},
//服务值改变时请求客户名称
httpChange(e) {
if (e.length >= 2) {
this.supervisor(e, false);
}
this.setState({
commodityName: e
})
},
//上级主管输入框失去焦点是判断客户是否存在
selectAuto(value) {
let kid = [];
let fwList = this.state.customerArr;
fwList.map(function (item) {
if (value == item.bname) {
kid = item.id
}
})
this.setState({
kid: kid,
commodityName: value,
})
},
customerChange(e) {
if (e.length >= 2) {
this.supervisor(e, true);
}
this.setState({
customerName: e
})
},
//客户
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
})
},
//任务新建、编辑保存
taskSumbit(e) {
e.preventDefault();
if (this.state.addTaskState) {
if (!this.state.kid) {
message.warning('请输入服务项目名称');
return false;
};
if (!this.state.commodityQuantity) {
message.warning('请输入数量');
return false;
};
}
this.props.form.validateFields((err, values) => {
if (!err) {
this.setState({
loading: true
});
let api = this.state.addTaskState ? '/api/admin/techproject/addProjectTask' : '/api/admin/techproject/updateProjectTask';
$.ajax({
method: "POST",
dataType: "json",
crossDomain: false,
url: globalConfig.context + api,
data: this.state.addTaskState ? {
contractId: this.props.datauser.id,
commodityId: this.state.kid,
commodityName: this.state.commodityName,
commodityQuantity: this.state.commodityQuantity,
taskComment: this.state.taskComment,
} : {
taskId: this.state.taskId,
commodityId: this.state.kid ? this.state.kid : this.state.commodityId,
taskComment: this.state.taskComment
}
}).done(function (data) {
this.setState({
loading: false
});
if (!data.error.length) {
message.success('保存成功!');
this.nextCancel();
this.loadData();
this.props.closeDesc(true, true);
} else {
message.warning(data.error[0].message);
}
}.bind(this));
}
});
},
//任务项目各种骚操作
removeItem() { //撤项
this.removeList(0)
},
Knot() { //结项
this.removeList(1)
},
removeList(e) {
this.setState({
loading: true
});
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + '/api/admin/techproject/revokeOrComplete',
data: {
contractId: this.props.datauser.id,
operatorType: e
}
}).done(function (data) {
this.setState({
loading: false
});
if (!data.error.length) {
message.success('操作成功!');
this.handleOk()
} else {
message.warning(data.error[0].message);
}
}.bind(this));
},
//保存详情
knotSave() {
this.setState({
loading: true
});
$.ajax({
method: "post",
dataType: "json",
crossDomain: false,
url: globalConfig.context + '/api/admin/techproject/updateProject',
data: {
contractId: this.props.datauser.id,
completeComment: this.state.completeComment,
signComment: this.state.signComment,
signDate: this.state.setTime ? this.state.setTime : this.state.signTime,
completeDate: this.state.selTime ? this.state.selTime : this.state.completeTime
}
}).done(function (data) {
this.setState({
loading: false
});
if (!data.error.length) {
message.success('保存成功!');
this.handleOk()
} else {
message.warning(data.error[0].message);
}
}.bind(this));
},
//负责人转交
transfer() {
this.setState({
distributionVisible: true,
transferState: true,
lvState: false,
distributionList: []
});
this.state.departmenttList = undefined;
this.state.financeNameSearch = '';
this.state.lvRadio = 0;
//this.contactLists();
},
/* -----变更操作开始----- */
//新建变更
addChange() {
this.setState({
addChangeState: true,
stateAdd: 1,
changeRemarks: ''
})
},
//产看变更记录
lookChange() {
this.setState({
addChangeState: true,
stateAdd: 0
})
this.lookChangeData()
},
//查看变更列表修改变更
modifyChangeCancel() {
this.setState({
modifyChangeState: false
})
},
//获取变更记录
lookChangeData() {
this.setState({
loading: true
});
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + '/api/admin/order/viewOrderChange',
data: {
orderNo: this.props.datauser.orderNo,
},
success: function (data) {
let theArr = [];
if (!data.data) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
};
} else {
for (let i = 0; i < data.data.length; i++) {
theArr = data.data;
};
};
this.setState({
changeHtml: theArr,
});
}.bind(this),
}).always(function () {
this.setState({
loading: false
});
}.bind(this));
},
//添加变更状态
addChangeCancel() {
this.setState({
addChangeState: false
})
},
//新建变更
subChangeState(e) {
e.preventDefault();
this.setState({
loading: true
});
$.ajax({
method: "POST",
dataType: "json",
crossDomain: false,
url: globalConfig.context + '/api/admin/order/addOrderChange',
data: {
orderNo: this.props.datauser.orderNo,
changeComment: this.state.changeRemarks
}
}).done(function (data) {
this.setState({
loading: false
});
if (!data.error.length) {
message.success('保存成功!');
this.addChangeCancel();
this.seeOrderAjax(this.props.datauser);
} else {
message.warning(data.error[0].message);
}
}.bind(this));
},
//查看修改变更
modifyChange(item) {
this.setState({
modifyChangeState: true,
changePromoter: item.creater,
changeTime: item.createTime,
changeState: item.changeStatus,
changeRemarks: item.changeComment,
idt: item.changeId,
orderNot: item.orderNo
})
},
//删除变更
modifyDelete(item) {
this.setState({
loading: true
});
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + '/api/admin/order/deleteOrderChange',
data: {
changeId: item.changeId,
}
}).done(function (data) {
this.setState({
loading: false
});
if (!data.error.length) {
message.success('删除成功!');
this.lookChangeData();
this.seeOrderAjax(this.props.datauser)
} else {
message.warning(data.error[0].message);
}
}.bind(this));
},
//修改变更保存
changeModify(e) {
e.preventDefault();
this.setState({
loading: true
});
$.ajax({
method: "POST",
dataType: "json",
crossDomain: false,
url: globalConfig.context + '/api/admin/order/updateOrderChange',
data: {
changeId: this.state.idt,
changeStatus: this.state.changeState,
changeComment: this.state.changeRemarks
}
}).done(function (data) {
this.setState({
loading: false
});
if (!data.error.length) {
message.success('保存成功!');
this.modifyChangeCancel();
this.lookChangeData();
this.seeOrderAjax(this.props.datauser)
} else {
message.warning(data.error[0].message);
}
}.bind(this));
},
/*-----变更操作结束----*/
//切换其他下级
lvRadioFn(e) {
if (e.target.value == 0) {
this.setState({
lvRadio: e.target.value,
lvState: false
})
this.setState({
distributionList: [],
})
} else {
this.setState({
lvRadio: e.target.value,
lvState: true
})
this.contactList();
}
},
tableRowClick(record, index) {
this.setState({
addTaskState: false,
addnextVisible: true,
});
this.orderDetails(record)
},
componentWillReceiveProps(nextProps) { //props改变时触发
this.state.projectVisible = nextProps.newProject;
this.state.visible = nextProps.showDesc;
if (nextProps.userDetaile && nextProps.showDesc) {
if (nextProps.datauser && nextProps.datauser.id) {
this.loaduser(nextProps.datauser);
this.loadData(nextProps.datauser);
this.seeOrderAjax(nextProps.datauser);
}
} else {
this.setState({
customerArr: [],
customerName: '',
autoId: '',
signComment: '',
projectName: '',
aid: '',
contractType: undefined
})
}
},
render() {
const FormItem = Form.Item
const formItemLayout = {
labelCol: { span: 8 },
wrapperCol: { span: 14 },
};
const rowSelection = {
selectedRowKey: this.state.selectedRowKey,
onChange: (selectedRowKey, selectedRows) => {
this.setState({
selectedRows: selectedRows.slice(-1),
selectedRowKey: selectedRowKey.slice(-1)
});
},
onSelectAll: (selected, selectedRows, changeRows) => {
this.setState({
selectedRowKey: []
})
},
};
const changeHtml = this.state.changeHtml || [];
const categoryList = this.props.categoryArr || [];
let departmentArr = this.props.departmentArr || [];
const hasSelected = this.state.selectedRowKey.length > 0;
const orderDetaiel = this.state.orderList || [];
const dataSources = this.state.customerArr || [];
const orderArr = this.state.orderArr || [];
const options = this.state.states ? dataSources.map((group, index) =>
{group.name}
) : dataSources.map((group, index) =>
{group.bname}
)
return (
)
}
}));
export default MySettlementDetaile;