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} from '../../../../tools.js'; const MySettlementDetaile = Form.create()(React.createClass({ loadData() { this.setState({ loading: true }); $.ajax({ method: "post", dataType: "json", crossDomain: false, url: globalConfig.context + '/api/admin/roles', data: { }, 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; theArr.push({ key:i, roleName5:thisdata[i].id }); }; } 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:[], checkedKeys: [], pagination: { defaultCurrent: 1, defaultPageSize: 10, showQuickJumper: true, pageSize: 10, onChange: function (page) { this.loadData(page); }.bind(this), showTotal: function (total) { return '共' + total + '条数据'; } }, //派单 distributionPagination: { defaultCurrent: 1, defaultPageSize: 10, showQuickJumper: true, pageSize: 10, onChange: function (page) { this.contactList(page); }.bind(this), showTotal: function (total) { return '共' + total + '条数据'; } }, columns: [ { title: '任务名称', dataIndex: 'roleName', key: 'roleName' }, { title: '业务类别', dataIndex: 'creater1', key: 'creater1' },{ title: '任务数量', dataIndex: 'roleName2', key: 'roleName2' }, { title: '任务负责人', dataIndex: 'creater4', key: 'creater4' }, { title: '任务状态', dataIndex: 'roleName22', key: 'roleName22' }, { title: '是否锁定', dataIndex: 'creater41', key: 'creater41' },{ title: '任务说明', dataIndex: 'roleName5', key: 'roleName5', render:(text) => { return( text?text.substr(0,6)+'...':'' ) } },{ title: '操作', dataIndex: 'rrtk', key: 'rrtk', render:(text,record,index)=>{ return (
{this.voidOperation(record)}} okText="确认" cancelText="取消"> {this.lockOperation(record)}} okText="确认" cancelText="取消">
) } } ], //选择订单 columnOrder: [ { title: '订单编号', dataIndex: 'roleName', key: 'roleName' }, { title: '项目类别', dataIndex: 'creater1', key: 'creater1' },{ title: '项目数量', dataIndex: 'roleName2', key: 'roleName2' }, { title: '下单时间', dataIndex: 'creater4', key: 'creater4' },{ title: '操作', dataIndex: 'rrt', key: 'rrt', render:(text,record,index)=>{ return (
{this.listSelect(record)}} okText="确认" cancelText="取消">
) } } ], userList:[ { title: '用户编号', dataIndex: 'roleName', key: 'roleName' }, { title: '用户姓名', dataIndex: 'creater', key: 'creater' },{ title: '部门机构', dataIndex: 'roleName1', key: 'roleName1' }, { title: '职务', dataIndex: 'creater1', key: 'creater1' },{ title: '联系手机', dataIndex: 'roleName2', key: 'roleName2' }, { title: '操作', dataIndex: 'abc', key: 'abc', render:(text,record,index)=>{ return ( {this.confirmSelect(record)}} okText="确认" cancelText="取消"> ) } } ], }; }, //选定订单 listSelect(record){ this.setState({ loading: true }); $.ajax({ method: "POST", dataType: "json", crossDomain: false, url: globalConfig.context +'/api/zuofei', data: { id:record.id, } }).done(function(data) { this.setState({ loading: false }); if(!data.error.length) { message.success('操作成功!'); this.orderOk(); this.addOrderDetaiel(record) } else { message.warning(data.error[0].message); } }.bind(this)); }, addOrderDetaiel(record){ this.setState({ loading: true }); $.ajax({ method: "post", dataType: "json", crossDomain: false, url: globalConfig.context + '/api/admin/xiangqing', data: { id:record.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.list.length; i++) { let thisdata = data.data.list; this.setState({ key: i, }); }; } }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); }, //查看基本详情基本信息 loaduser(record){ if(record){ $.ajax({ method: "post", dataType: "json", crossDomain: false, url: globalConfig.context + '/api/admin/role/rolePermission', data: { id: 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({ ids:record.id, roleName:thisData[0].rname, }); }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); } }, //作废 voidOperation(e){ this.unlock(e,true) }, //锁定 lockOperation(e){ this.unlock(e,false) }, unlock(record,state){ this.setState({ loading: true }); let api=state?'/api/zuofei':'/api/suoding' $.ajax({ method: "POST", dataType: "json", crossDomain: false, url: globalConfig.context + api, data: { id:this.props.datauser.id, uid:record.id } }).done(function (data) { if (!data.error.length) { message.success('操作成功'); this.setState({ loading: false, }); this.loadData(); } else { message.warning(data.error[0].message); }; this.loadData(); }.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, }); }, SelectOrder(){ this.setState({ orderSelect: true, }); }, componentWillMount() { }, nextCancel() { this.setState({ addnextVisible: false }) }, //查看订单明细 orderDetails(record){ if(record){ $.ajax({ method: "post", dataType: "json", crossDomain: false, url: globalConfig.context + '/api/admin/role/rolePermission', data: { id: record.id }, success: function (data) { let thisData = data.data; if (!thisData) { if (data.error && data.error.length) { message.warning(data.error[0].message); }; thisData = {}; }; let idList=[]; thisData.map(function(item){ idList.push( item.pid ) }) this.setState({ ids:record.id, }); }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); } }, //创建项目保存 admissibleOrder(){ if(this.state.Names==''||this.state.Names==null){ message.warning('请输入客户名称'); this.refs.Names.focus() return false; }; if(this.state.projectType==undefined){ message.warning('请选择项目类型'); return false; }; if(this.state.pName==''||this.state.pName==null){ message.warning('请输入项目负责人'); this.refs.pName.focus() return false; }; this.setState({ loading: true }); $.ajax({ method: "POST", dataType: "json", crossDomain: false, url: globalConfig.context + '/api/xinjianbaocun', data: { } }).done(function(data) { this.setState({ loading: false }); if(!data.error.length) { message.success('保存成功!'); this.projectOk() } else { message.warning(data.error[0].message); } }.bind(this)); }, //编辑订单保存 handleSubmit(e) { e.preventDefault(); this.props.form.validateFields((err, values) => { if(!err) { this.setState({ loading: true }); $.ajax({ method: "POST", dataType: "json", crossDomain: false, url: globalConfig.context + '/api/000', data: { id:this.props.datauser.id } }).done(function(data) { this.setState({ loading: false }); if(!data.error.length) { message.success('保存成功!'); this.handleOk() } else { message.warning(data.error[0].message); } }.bind(this)); } }); }, //派单 //操作分配 confirmDelet(index){ this.setState({ userDetaile:false, distributionVisible:true }); this.contactList(1,index.id) }, distributionCancel(){ this.setState({ distributionVisible:false }) }, distributionOk(){ this.setState({ distributionVisible:false }) }, //分配对象列表 contactList(pageNo,orderId){ $.ajax({ method: "post", dataType: "json", crossDomain: false, url: globalConfig.context + '/api/admin/roles', data: { pageNo: pageNo || 1, pageSize: this.state.distributionPagination.pageSize, }, 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, roleName: thisdata.roleName, creater:thisdata.creater, createTime:thisdata.createTimez, uid:orderId, }); }; this.state.distributionPagination.current = data.data.pageNo; this.state.distributionPagination.total = data.data.totalCount; }; if(!data.data.list.length){ this.state.distributionPagination.current=0 this.state.distributionPagination.total=0 } this.setState({ distributionList: theArr, pagination: this.state.distributionPagination, }); }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); }, //选定对象 confirmSelect(record){ this.setState({ loading: true }); $.ajax({ method: "POST", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/paidan", data: { id:this.props.datauser.id, uid:record.id } }).done(function (data) { if (!data.error.length) { message.success('分派成功'); this.setState({ loading: false, }); this.distributionOk(); } else { message.warning(data.error[0].message); }; this.loadData(); }.bind(this)); }, //添加任务 addTask(){ this.setState({ addTaskState:true, addnextVisible:true, }); }, //任务新建、编辑保存 taskSumbit(e) { e.preventDefault(); // if(!this.state.customerName&&!this.state.autoId){ // message.warning('请输入客户名称'); // return false; // }; this.props.form.validateFields((err, values) => { if(!err) { this.setState({ loading: true }); let api=this.state.addTaskState?'/api/tianjia':'/api/admin/order/bianji'; $.ajax({ method: "POST", dataType: "json", crossDomain: false, url: globalConfig.context + api, data: this.state.addTaskState?{ id:'tianjia' }:{ id:'bianji' } }).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)); } }); }, //任务项目各种骚操作 unlock(){ //解锁 this.removeList('1') }, lock(){ //锁定 this.removeList('2') }, removeItem(){ //撤项 this.removeList('3') }, Knot(){ //结项 this.removeList('4') }, removeList(e){ if(!e) return false; this.setState({ loading: true }); let api=''; switch (e){ case '1': //解锁 api='/api/jiesuo' break; case '2': //锁定 api='/api/suoding' break; case '3': //撤项 api='/api/chexiang' break; case '4': //结项 api='/api/jiexiang' break; }; $.ajax({ method: "POST", dataType: "json", crossDomain: false, url: globalConfig.context + api, data: { id:this.props.datauser.id } }).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(); } } }, 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 hasSelected = this.state.selectedRowKey.length > 0; const orderDetaiel=this.state.orderList || []; return(
{orderDetaiel.roleName} {orderDetaiel.createTimez} {orderDetaiel.roleName} {orderDetaiel.roleName} {!this.props.projectState? {this.setState({ordesss:e.target.value})}} style={{width:'240px'}}/> * : {orderDetaiel.roleName} } {orderDetaiel.roleName} {orderDetaiel.roleName} {orderDetaiel.roleName}
{orderDetaiel.roleName}
{orderDetaiel.roleName}
{orderDetaiel.roleName}
{orderDetaiel.createTimez}
项目任务 {!this.props.projectState&&}
{!this.props.projectState?
:
}
{this.state.addTaskState?
* {this.setState({leibie:e.target.value})}}/> * {this.setState({leibie:e.target.value})}}/> *
{this.setState({introduction:e.target.value})}}/>
:
{this.state.bianhao} {this.state.bianhao} * {this.setState({leibie:e.target.value})}}/> * {this.state.bianhao} {this.state.bianhao}
{this.setState({introduction:e.target.value})}}/>
{this.state.bianhao} {this.state.bianhao} {this.state.bianhao}
}
{this.state.roleName}
{this.state.roleName} {this.state.roleName} {this.state.roleName} {this.state.roleName} {this.state.roleName} {this.state.roleName}
{this.setState({Names:e.target.value})}} style={{width:'240px'}} ref='Names'/> * * {this.setState({pName:e.target.value})}} style={{width:'240px'}} ref='pName'/> *
{this.setState({introduction:e.target.value})}}/>
{this.admissibleOrder()}} okText="确认" cancelText="取消">
{ this.setState({ customerName: e.target.value }); }} /> { this.setState({ customerName: e.target.value }); }} />
) } })); export default MySettlementDetaile;