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 && 
}
							
{this.state.transferState ? 
 { this.transterSelect(record) }} okText="确认" cancelText="取消">
								
							 :
								
 { this.confirmSelect(record) }} okText="确认" cancelText="取消">
									
								}