import React from 'react'; import { Icon, Table, Modal, message, Spin, Input, Select, Button, Form ,Upload,Popconfirm,AutoComplete} 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 ,getApprovedState} from '../../../../tools.js'; 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, taskStatus:thisdata.taskStatus, deleteSign:thisdata.deleteSign, taskComment:thisdata.taskComment, }); }; } 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, orgCodeUrl:[], customerArr:[], checkedKeys: [], //派单 columns: [ { title: '任务名称', dataIndex: 'commodityName', key: 'commodityName' },{ title: '任务数量', dataIndex: 'commodityQuantity', key: 'commodityQuantity' }, { title: '任务负责人', dataIndex: 'technicianName', key: 'technicianName' }, { title: '任务状态', dataIndex: 'taskStatus', key: 'taskStatus', render:(text)=>{return getTaskStatus(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.confirmSelect(record)}} okText="确认" cancelText="取消"> ) } } ], contractList:[ { title: '姓名', dataIndex: 'name', key: 'name' }, { title: '部门', dataIndex: 'depatrment', key: 'depatrment' },{ title: '联系方式', dataIndex: 'mobile', key: 'mobile' }, { title: '职务', dataIndex: 'position', key: 'position' },{ title: '微信', dataIndex: 'wechat', key: 'wechat' },{ title: 'QQ', dataIndex: 'qq', key: 'qq' }, ], }; }, seeOrder(){ this.seeOrderAjax(); this.setState({ seeState:true, orderVisible:true }) }, 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(){ $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + '/api/admin/order/getServiceOrderDetail', data: { orderNo: this.state.orderNok }, 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)); }, //查看详情 loaduser(record){ if(record){ $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + '/api/admin/techproject/getProjectDetail', data: { contractId: record.id }, success: function (data) { let thisData = data.data; if (!thisData) { if (data.error && data.error.length) { message.warning(data.error[0].message); }; thisData = {}; }; this.setState({ buyerId:thisData.uid, id:record.id, orderNok:thisData.orderNo, orderList:thisData, technicianName:thisData.technicianName, //项目负责人 }); }.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(); } 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.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, } }).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 }); }, distributionCancel(){ this.setState({ distributionVisible:false }) }, distributionOk(){ this.setState({ distributionVisible:false }) }, //分配对象列表 contactList(){ $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + '/api/admin/superviser/adminList', 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 { 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, }); }; }; 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(); } else { message.warning(data.error[0].message); }; }.bind(this)); }, searchOrder(){ this.contactList(); }, resetOrder(){ this.state.departmenttList=undefined; this.state.financeNameSearch=''; this.setState({ distributionList:[] }) }, //添加任务 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(); } 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)); }, 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); } }else{ this.setState({ customerArr:[], customerName:'', autoId:'', signComment:'', projectName:'', aid:'' }) } }, 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:[] }) }, }; // 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(
{orderDetaiel.orderNo} {orderDetaiel.orderNo&&} {orderDetaiel.serialNumber} {orderDetaiel.buyerName} {orderDetaiel.buyerName&&} {getOrderType(orderDetaiel.projectType)} {orderDetaiel.principalName} {getProjectState(orderDetaiel.projectStatus)} {orderDetaiel.deleteSign==2?'锁定':'未锁定'} {orderDetaiel.signDate}
{orderDetaiel.signComment}
{orderDetaiel.completeDate}
{orderDetaiel.completeComment}
{orderDetaiel.deleteSign==1?'作废':'未作废'}
项目任务 {orderDetaiel.projectStatus<3?:''}
{!this.props.projectState?
:
}
{this.state.addTaskState?
* {this.setState({commodityQuantity:e.target.value})}}/> *
{this.setState({taskComment:e.target.value})}}/>
:
{this.state.projectNo} {this.state.taskNo} {this.state.taskStatus<1? * : {this.state.commodityName} } {getTaskStatus(this.state.taskStatus)} {this.state.deletedSign==2?'锁定':'未锁定'}
{this.state.taskStatus<1? {this.setState({taskComment:e.target.value})}}/> : {this.state.taskComment} }
{this.state.taskAllocatorName} {this.state.taskDistributionTime} {this.state.taskReceiverName}
} {this.state.taskStatus<1||this.state.addTaskState?
:''}
*
{this.state.projectName}
{this.setState({signComment:e.target.value})}}/>
{ this.setState({ financeNameSearch: e.target.value }); }} />
{this.state.seeState?
{orderArr.orderNo} {orderArr.createTime} {orderArr.buyerName} {getOrderType(orderArr.orderType)} {getOrderChannel(orderArr.orderChannel)} {getOrderState(orderArr.orderStatus)} {orderArr.actuallyTotalAmount+'万元'} {getPaymentState(orderArr.liquidationStatus)} {orderArr.orderAmount+'万元'} {orderArr.firstPayment+'万元'}
{orderArr.signTotalAmount+'万元'} {orderArr.signFirstPayment+'万元'} {getApprovedState(orderArr.approval)}
{ this.setState({ previewImage: file.url || file.thumbUrl, previewVisible: true, }); }} > { this.setState({ previewVisible: false }) }}>
{orderArr.orderRemarks}
:
} ) } })); export default MySettlementDetaile;