import React from 'react';
import { Icon, Table, Modal, message, Spin, Input, Select, Button, Form ,Upload,Popconfirm,AutoComplete,DatePicker,Radio,Col} from 'antd';
import ajax from 'jquery/src/ajax/xhr.js';
import $ from 'jquery/src/ajax';
import '../userMangagement.less';
import moment from 'moment';
import Picture from '@/manageCenter/publicComponent/picture';
import {orderTypes,customerType,jiedian,tepi,boutique} from '../../../dataDic.js';  
import {splitUrl,getTransactionProject,getChangeState,getTransactionChannel,beforeUploadFile,getProcessStatus,getLiquidationStatus,getboutique} from '../../../tools.js';
const Option = AutoComplete.Option;
//图片组件
const PicturesWall = React.createClass({
    getInitialState() {
        return {
            previewVisible: false,
            previewImage: '',
            fileList: [],
        }
    },
    getDefaultProps(){
    	return{
    		changeClick:this.modifyChange
    	}
    },
    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 >= 18 ? null : uploadButton}
                
                
                     
                
             
        );
    }
});
const NewService = Form.create()(React.createClass({
	//查看项目列表
	loadData(record) {
        this.state.data = [];
        this.setState({
            loading: true
        });
        $.ajax({
            method: "get",
            dataType: "json",
            crossDomain: false,
            url: globalConfig.context + '/api/admin/newOrder/getOrderTask',
            data: {
            	orderNo:record?record.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++) {
                        let thisdata = data.data[i];
                        theArr.push({
                             key: i,
                             id:thisdata.id,
                             orderNo:thisdata.orderNo,//订单编号
                              commodityId:thisdata.commodityId,//项目ID
                             commodityName:thisdata.commodityName,//项目名称
                             cname:thisdata.cname,//项目类别
                             commodityPrice:thisdata.commodityPrice,//项目价格
                             commodityQuantity:thisdata.commodityQuantity,//项目数量
                             main:thisdata.main,//是否为主要任务
                             taskComment:thisdata.taskComment,//任务说明
                             contacts:thisdata.contacts,//联系人
                             contactsMobile:thisdata.contactsMobile,//联系人电话
                        });
                    };
                   }
                this.setState({
                    dataSource: theArr,
                    pagination: false,
                });
            }.bind(this),
        }).always(function () {
            this.setState({
                loading: false
            });
        }.bind(this));
    },
    //收款节点
    loadDatas(record) {
        this.state.data = [];
        this.setState({
            loading: true
        });
        $.ajax({
            method: "get",
            dataType: "json",
            crossDomain: false,
            url: globalConfig.context + '/api/admin/newOrder/selectOrderDun',
            data: {
            	orderNo:record?record.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++) {
                        let thisdata = data.data[i];
                        theArr.push({
                             key: i,
                             id:thisdata.id,
                            
                        });
                    };
                   }
                this.setState({
                    dataSource: theArr,
                    pagination: false,
                });
            }.bind(this),
        }).always(function () {
            this.setState({
                loading: false
            });
        }.bind(this));
    },
	getInitialState() {
		return {
			loading: false,
			visible: false,
			orgCodeUrl:[],
			customerArr:[],
			bussStats:false,
			checkedKeys: [],
			lookflowList:[],
			contractUrl:[],
			applicationUrl:[],
			active:{
				applySign:false
			},
			lookState:false,
			signBillVisible:false,
			commod:'',
			columns: [
				{
                    title: '业务项目名称',
                    dataIndex: 'commodityName',
                    key: 'commodityName'
                }, {
                    title: '项目类别',
                    dataIndex: 'cname',
                    key: 'cname',
                    
                },{
                    title: '项目数量',
                    dataIndex: 'commodityQuantity',
                    key: 'commodityQuantity'
                }, {
                    title: '金额(万元)',
                    dataIndex: 'commodityPrice',
                    key: 'commodityPrice'
                }, {
                    title: '负责人',
                    dataIndex: 'contacts',
                    key: 'contacts'
                }, {
                    title: '负责人电话',
                    dataIndex: 'contactsMobile',
                    key: 'contactsMobile'
                }, {
                    title: '主要项目',
                    dataIndex: 'main',
                    key: 'main',
                    render:(text)=>{
                    	return (text?'是':'否')
                    }
                }, {
                    title: '项目说明',
                    dataIndex: 'taskComment',
                    key: 'taskComment',
					render:(text)=>{
						return (text&&text.length>8?text.substr(0,8)+'…':text)
					}
                }, {
                    title: '操作',
                    dataIndex: 'ABC',
                    key: 'ABC',
                    render: (text, record, index) => {
						return 
									{this.state.processStatus==0?
{this.delectRow(record)}} okText="是" cancelText="否">
										                     
										:""}
								
		                        {this.state.processStatus==0?
{this.confirmDelet(record.key)}} okText="删除" cancelText="不删除">
									    
									
									:''}
								{record.id?'': 
}