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 {lvl} 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;
},
render() {
const { previewVisible, previewImage, fileList } = this.state;
const uploadButton = (
);
return (
{fileList.length >= 4 ? null : uploadButton}
);
}
});
const ApproveDetaile = 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[i];
theArr.push({
key: i,
});
};
}
this.setState({
dataSource: theArr,
pagination: false,
});
}.bind(this),
}).always(function () {
this.setState({
loading: false
});
}.bind(this));
},
getInitialState() {
return {
loading: false,
visible: false,
contractState:false,
orgCodeUrl:[],
checkedKeys: [],
columns: [
{
title: '业务项目名称',
dataIndex: 'roleName',
key: 'roleName'
}, {
title: '项目类别',
dataIndex: 'creater1',
key: 'creater1'
},{
title: '项目数量',
dataIndex: 'roleName2',
key: 'roleName2'
}, {
title: '服务市价',
dataIndex: 'creater2',
key: 'creater2'
}, {
title: '实签价格',
dataIndex: 'roleName3',
key: 'roleName3'
}, {
title: '下单时间',
dataIndex: 'creater4',
key: 'creater4'
}, {
title: '项目说明',
dataIndex: 'roleName5',
key: 'roleName5'
}
]
};
},
//主管初始加载(自动补全)
supervisor(e){
$.ajax({
method: "post",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/selectName",
data:{
name: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({
customerArr:thedata,
});
}.bind(this),
}).always(function () {
this.setState({
loading: false
});
}.bind(this));
},
//上级主管输入框失去焦点是判断客户是否存在
selectAuto(value,options){
this.setState({
auto:value
})
},
blurChange(e){
let theType;
let contactLists=this.state.customerArr||[];
if (e) {
contactLists.map(function (item) {
if (item.name == e.toString()) {
theType=item.id
}
});
}
this.setState({
theTypes:theType
})
},
//值改变时请求客户名称
httpChange(e){
if(e.length>=1){
this.supervisor(e);
}
this.setState({
auto:e
})
},
//查看基本详情基本信息
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 = {};
};
let idList=[];
thisData.map(function(item){
idList.push(
item.pid
)
})
this.setState({
ids:record.id,
roleName:thisData[0].rname,
checkedKeys:idList,
});
}.bind(this),
}).always(function () {
this.setState({
loading: false
});
}.bind(this));
}
},
handleOk(e) {
this.setState({
visible: false,
});
this.props.closeDesc(false, true);
},
handleCancel(e) {
this.setState({
visible: false,
});
this.props.closeDesc(false);
},
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));
}
},
tableRowClick(record, index) {
this.setState({
addnextVisible:true,
});
this.orderDetails(record)
},
componentWillMount() {
},
componentWillReceiveProps(nextProps) { //props改变时触发
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 orderDetaiel=this.state.orderList || [];
const dataSources=this.state.customerArr || [];
const options = dataSources.map((group,index) =>
)
return(
)
}
}));
export default ApproveDetaile;