import React from "react";
import {
  Table,
  Modal,
  message,
  Spin,
  Input,
  Select,
  Button,
  Form,
  Upload,
  Popconfirm,
  AutoComplete,
  DatePicker,
  Col,
  Tag
} from "antd";
import $ from "jquery/src/ajax";
import "../userMangagement.less";
import moment from "moment";
import { cuiJieDian } from "@/dataDic.js";
import Picture from "@/manageCenter/publicComponent/picture";
import { jiedian, tepi, boutique } from "../../../dataDic.js";
import {
  splitUrl,
  getProcessStatus,
  getLiquidationStatus,
  getboutique,
  getApprovedState,
  getjiedian,
  getCuikuan,
  getProjectStatus, getProjectName
} from "../../../tools.js";
import PicturesWall from "./changeComponent/picturesWall.js";
import ResolutionDetail from "@/resolutionDetail";
const Addorders = Form.create()(
  React.createClass({
    //查看项目列表
    loadData(orderNo) {
      this.state.data = [];
      this.setState({
        loading: true,
      });
      $.ajax({
        method: "get",
        dataType: "json",
        crossDomain: false,
        url: globalConfig.context + "/api/admin/newOrder/getOrderTask",
        data: {
          orderNo: 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];
              thisdata.key = i;
              thisdata.sort = thisdata.cSort;
              theArr.push(thisdata);
            }
          }
          this.departmentList();
          this.setState({
            dataSource: theArr,
            pagination: false,
          });
        }.bind(this),
      }).always(
        function () {
          this.setState({
            loading: false,
          });
        }.bind(this)
      );
    },
    //收款节点
    loadDatas(orderNo) {
      this.state.data = [];
      this.setState({
        loading: true,
      });
      $.ajax({
        method: "get",
        dataType: "json",
        crossDomain: false,
        url: globalConfig.context + "/api/admin/newOrder/selectOrderDun",
        data: {
          orderNo: 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 {
        rotateDeg: 0,
        loading: false,
        visible: false,
        resVisible: false,
        orgCodeUrl: [],
        replenishUrl: [],
        voucherUrl: [],
        customerArr: [],
        mark: false,
        activeKey: "1",
        buttonStatus: true,
        typeChange: 0,
        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",
            render: (text, record) => {
              if (record.splitStatus == 1) {
                return (
                  
                    {text}{" "}
                     {
                        e.stopPropagation();
                        this.showRes(record);
                      }}
                    >
                      已拆
                    
                  
                );
              } else {
                return text;
              }
            },
          },
          {
            title: "金额(万元)",
            dataIndex: "commodityPrice",
            key: "commodityPrice",
          },
          {
            title: "负责人",
            dataIndex: "contacts",
            key: "contacts",
          },
          {
            title: "负责人电话",
            dataIndex: "contactsMobile",
            key: "contactsMobile",
          },
          {
            title: "项目状态",
            dataIndex: "projectStatus",
            key: "projectStatus",
            render: (text) => {
              return getProjectName(text);
            },
          },
          {
            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) => {
              return (
                
                  {this.state.processStatus == 0 ? (
                    
 {
                        this.delectRow(record);
                      }}
                      okText="是"
                      cancelText="否"
                    >
                      
                    
                  ) : (
                    ""
                  )}
                
                  {
                    
 {
                        this.confirmDelet(record.key);
                      }}
                      okText="删除"
                      cancelText="不删除"
                    >
                      
                    
                  }
                  {record.id ? (
                    ""
                  ) : (
                    
                  )}
                
                    
                    {record.dunType == 0 ? (
                       {
                          record.customizeName = e.target.value;
                          this.setState({
                            contactList: this.state.contactList,
                          });
                        }}
                        style={{ width: "120px" }}
                      />
                    ) : (
                      ""
                    )}
                  
                );
              } else {
                return (
                  
                );
              }
            },
          },
          {
            title: "收款时间(特批需选择时间)",
            dataIndex: "waitDay",
            key: "waitDay",
            render: (text, record) => {
              if (record.dunTypeName) {
                if (record.customizeTimes) {
                  return record.customizeTimes;
                }
                if (text == 0) {
                  var str = "当天";
                } else if (!text) {
                  var str = "";
                } else {
                  var str = text + "天";
                }
                return {str};
              }
              return (
                
                  {record.dunType == 0 ? (
                     {
                        let time = moment(e).valueOf();
                        let today = Date.parse(new Date());
                        if (time <= today) {
                          return true;
                        }
                      }}
                      onChange={(e, t) => {
                        record.customizeTimes = t;
                      }}
                    />
                  ) : (
                    
                  )}
                
              );
            },
          },
          {
            title: "金额(万元)",
            dataIndex: "money",
            key: "money",
            render: (text, record) => {
              if (record.dunTypeName) {
                if (record.appropriationRatio && !record.money) {
                  return {record.appropriationRatio}(拨款比例);
                } else if (record.appropriationRatio && record.money) {
                  return (
                    
                      {text}(比例:{record.appropriationRatio})
                    
                  );
                } else {
                  return {text};
                }
              }
              if (this.state.boFlag) {
                return (
                  
                );
              } else {
                return (
                  
                     {
                        record.money = e.target.value;
                        this.setState({ contactList: this.state.contactList });
                      }}
                      style={{ width: "120px" }}
                    />
                  
                );
              }
            },
          },
          {
            title: "服务年限",
            dataIndex: "startDate",
            key: "startDate",
            render: (text, record) => {
              if (record.dunTypeName) {
                return {text};
              }
              return (
                
              );
            },
          },
          {
            title: "催款状态",
            dataIndex: "status",
            key: "status",
            render: (text) => {
              return {text == 1 ? "已启动" : "未启动"};
            },
          },
          {
            title: "操作",
            dataIndex: "dels",
            key: "dels",
            render: (text, record, index) => {
              return (
                
                  {this.state.processStatus == 0 ? (
                    
 {
                        this.confirmDeletNew(record);
                      }}
                      okText="删除"
                      cancelText="不删除"
                    >
                      
                    
                  ) : (
                    ""
                  )}
                  {record.isSave ? (
                    
                  ) : (
                    ""
                  )}
                
          {this.state.resVisible ? (
            
          ) : (
            ""
          )}
          
            
              
                {{this.state.contractNo}}
              
              
                {this.state.orderNo}
              
              
                {getProcessStatus(this.state.processStatus)}
              
              
                
                  {getLiquidationStatus(this.state.liquidationStatus)}
                
              
              {this.props.deleteSign === 3 || this.state.processStatus === 0 ? (
                
                  
                    
                  
                  
                     {}}
                      value={
                        this.state.signDate ? moment(this.state.signDate) : null
                      }
                      onChange={(_data, dataString) => {
                        this.setState({ signDate: dataString });
                      }}
                    />
                    *
                  
                  
                    
                  
                
              ) : (
                
                  
                    {getApprovedState(this.state.approval)}
                  
                  
                    {this.state.signDate}
                  
                  
                    {this.state.depName}
                  
                
              )}
            
 
            
              收款项目
            
            {this.props.deleteSign === 3 || this.state.processStatus === 0 ? (
              
                
                   {
                      this.setState({ totalAmount: e.target.value });
                    }}
                    style={{ width: "240px" }}
                  />
                  *
                
                
                   {
                      this.setState({ firstAmount: e.target.value });
                    }}
                    style={{ width: "240px" }}
                  />
                  *
                
                
                  {this.state.settlementAmount + "万元"}
                  {/* {this.state.settlementAmount ? (
                      
                    ) : (
                      ""
                    )} */}
                
              
            ) : (
              
                
                  {this.state.totalAmount}
                
                
                  {this.state.firstAmount}
                
                
                  {this.state.settlementAmount + "万元"}
                  {/* {this.state.settlementAmount ? (
                      
                    ) : (
                      ""
                    )} */}
                
              
            )}
            
              联系信息
            
            {this.props.deleteSign === 3 || this.state.processStatus == 0 ? (
              
            ) : (
              
                {formItemList.map((data, index) => {
                  return (
                    
                      {data.content}
                    
                  );
                })}
              
            )}
            
              {this.props.deleteSign === 3 || this.state.processStatus == 0 ? (
                
                  
                        *合同扫描件
                      
                    }
                  >
                    
                    图片建议:要清晰。
                    
                  
                  
                        补充协议
                      
                    }
                  >
                    
                    图片建议:要清晰。
                  
                 
              ) : (
                
                  
                     {
                        this.setState({
                          previewImage: file.url || file.thumbUrl,
                          previewVisible: true,
                        });
                      }}
                    >
                     {
                        this.setState({ previewVisible: false, rotateDeg: 0 });
                      }}
                    >
                       {
                        this.setState({
                          previewImage: file.url || file.thumbUrl,
                          previewVisibles: true,
                        });
                      }}
                    >
                     {
                        this.setState({ previewVisibles: false, rotateDeg: 0 });
                      }}
                    >
                      
                      
                      
                    
                    
                  
                  
                     {
                        this.setState({
                          previewImage: file.url || file.thumbUrl,
                          previewVisibles: true,
                        });
                      }}
                    >
                     {
                        this.setState({ previewVisibles: false, rotateDeg: 0 });
                      }}
                    >
                       
                      
                      
                      
                    
                  
                 
              )}
            
              {this.props.deleteSign === 3 || this.state.processStatus == 0 ? (
                
                  
                     {
                        this.setState({ orderRemarks: e.target.value });
                      }}
                      style={{ width: "95%" }}
                    />
                    *
                  
                
              ) : (
                
                  
                    {this.state.orderRemarks}
                  
                
              )}
            
              
                {this.state.salesmanName}
              
              
                {this.state.salesmanMobile}
              
            
            
              
                {this.state.nowFinance}
              
              
                {this.state.nowFinanceMobile}
              
            
            
              
                {this.state.oldSalesmanName}
              
              
                {this.state.oldSalesmanMobile}
              
            
            
              
                {this.state.financeName}
              
              
                {this.state.financeMobile}
              
            
            
              
                项目业务
              
              {this.props.deleteSign === 3 || this.state.processStatus == 0 ? (
                
              ) : (
                ""
              )}
            
            {" "}
            
              
                旧催款节点
              
              
            
            
            
              
                新催款节点
              
              
                金额总计(万元): {this.state.totalCui}
              
              
            
            
            {this.props.deleteSign === 3 || this.state.processStatus == 0 ? (
              
                {!this.state.buttonStatus ? (
                  
                ) : (
                  ""
                )}
                
              
            ) : (
              ""
            )}
          
          
            
          
          {this.state.lookVisible ? 
            
           : 
}