const {
  getAllDictionarySelect,
  IMG_BASE_URL,
  WU_TU_PIAN_URL,
  getAllConditionList,
  findAllPlan
} = require('../../../api/api')
Component({
  properties: {
    entryId: String,
    childObj:Object,
  },
  data: {
    photo: {
      flyImgs: [], //无人机航拍图
      roofPhotoOne:[],//安装区域整体照片
      roofPhotoTwo:[],//安装区域东南角照片
      roofPhotoThree:[],//安装区域西南角照片
      roofPhotoFour:[],//安装区域正南照片
      roofPhotoFive:[],//安装区域细节照片
      roofPhotoFacade:[],//房屋内部结构照片
      roofPhotoInterior:[],//房屋内部环境照片
      detailSupplementOne:[],//逆变器、配电箱预安装位置照片
      houseSupplementOne:[],//房屋其他障碍物照片
      surveyVideo:[],//踏勘补充证明视频
      surveyFiles:[],//踏勘记录表
      vrRoofOne: [], //房屋整体图
      vrRoofTwo: [], //房屋整体俯视图
      vrRoofThree: [], //房屋内部结构图
      vrRoofFour: [], //入户全景照片
      houseOutlinePhoto:[], //房屋轮廓照片
      designDrawings: [], //设计图纸
      dzImgs: [], //组合图
    },
    photoTips:[ 
      {
      showKey: 'fly_imgs',
      key:'flyImgs',
      num:9,
      minNum:3,
      title: '无人机航拍图',
    },{
      showKey: 'roof_photo_one',
      key:'roofPhotoOne',
      num:9,
      minNum:2,
      title: '安装区域整体照片',
    },{
      showKey: 'roof_photo_two',
      key:'roofPhotoTwo',
      num:9,
      minNum:1,
      title: '安装区域东南角照片',
    },{
      showKey: 'roof_photo_four',
      key:'roofPhotoFour',
      num:9,
      minNum:1,
      title: '安装区域正南照片',
    },{
      showKey: 'roof_photo_three',
      key:'roofPhotoThree',
      num:9,
      minNum:1,
      title: '安装区域西南角照片',
    },{
      showKey: 'roof_photo_five',
      key:'roofPhotoFive',
      num:9,
      minNum:1,
      title: '安装区域细节照片',
    },{
      showKey: 'roof_photo_interior',
      key:'roofPhotoInterior',
      num:9,
      minNum:2,
      title: '房屋内部环境照片',
    },{
      showKey: 'roof_photo_facade',
      key:'roofPhotoFacade',
      num:9,
      minNum:2,
      title: '房屋内部结构照片',
    },{
      showKey: 'detail_supplement_one',
      key:'detailSupplementOne',
      num:9,
      minNum:1,
      title: '逆变器、配电箱预安装位置照片',
    },{
      showKey: 'house_outline_photo',
      key: 'houseOutlinePhoto',
      num: 9,
      minNum: 1,
      title: '房屋轮廓照片',
    },{
      showKey: 'house_supplement_one',
      key:'houseSupplementOne',
      num:9,
      minNum:1,
      title: '房屋其他障碍物照片',
    },{
      showKey: 'survey_files',
      key:'surveyFiles',
      num:4,
      title: '踏勘记录表',
    },{
      showKey: 'roof_photo_one_03',
      key: 'roofPhotoOne',
      num: 9,
      minNum: 2,
      title: '房屋屋顶照片',
    },{
      showKey: 'roof_photo_two_03',
      key: 'roofPhotoTwo',
      num: 9,
      minNum: 1,
      title: '房屋屋顶东侧图片',
    },{
      showKey: 'roof_photo_three_03',
      key: 'roofPhotoThree',
      num: 9,
      minNum: 1,
      title: '房屋屋顶西侧图片',
    },{
      showKey: 'roof_photo_four_03',
      key: 'roofPhotoFour',
      num: 9,
      minNum: 1,
      title: '房屋屋顶南侧图片',
    },{
      showKey: 'fw_img3',
      key: 'fwImg3',
      num: 9,
      minNum: 1,
      title: '房屋屋顶东南侧图片',
    },{
      showKey: 'fw_img4',
      key: 'fwImg4',
      num: 9,
      minNum: 1,
      title: '房屋屋顶西南侧图片',
    },{
      showKey: 'fw_img5',
      key: 'fwImg5',
      num: 9,
      minNum: 1,
      title: '遮阴物与房屋距离、高度',
    },{
      showKey: 'survey_video',
      key: 'surveyVideo',
      num: 8,
      minNum: 1,
      title: '踏勘补充证明视频',
    },{
      showKey: 'house_ownership',
      key: 'houseOwnership',
      num: 8,
      minNum: 1,
      title: '房产证明',
    },{
      showKey: 'survey_files_03',
      key: 'surveyFiles',
      num: 9,
      minNum: 1,
      title: '户用勘察记录表（附平面草图）',
    },{
      showKey: 'fw_img1',
      key: 'fwImg1',
      num: 9,
      minNum: 1,
      title: '房屋整体图',
    },{
      showKey: 'vr_roof_one',
      key: 'vrRoofOne',
      num: 9,
      minNum: 1,
      title: '房屋整体图（VR全景）',
    },{
      showKey: 'vr_roof_two',
      key: 'vrRoofTwo',
      num: 9,
      minNum: 1,
      title: '房屋整体俯视图（无人机）',
    },{
      showKey: 'vr_roof_three',
      key: 'vrRoofThree',
      num: 9,
      minNum: 1,
      title: '房屋内部结构图（VR）',
    },{
      showKey: 'fw_img2',
      key: 'fwImg2',
      num: 9,
      minNum: 1,
      title: '房屋内部结构图',
    },{
      showKey: 'vr_roof_four',
      key: 'vrRoofFour',
      num: 9,
      minNum: 1,
      title: '入户全景照片(VR)',
    },{
      showKey: 'fly_imgs_04',
      key: 'flyImgs',
      num: 9,
      minNum: 3,
      title: '屋顶高空俯视照片',
    },{
      showKey: 'roof_photo_two_04',
      key: 'roofPhotoTwo',
      num: 9,
      minNum: 1,
      title: '屋顶东南照片',
    },{
      showKey: 'roof_photo_four_04',
      key: 'roofPhotoFour',
      num: 9,
      minNum: 1,
      title: '屋顶正南照片',
    },{
      showKey: 'roof_photo_three_04',
      key: 'roofPhotoThree',
      num: 9,
      minNum: 1,
      title: '屋顶西南照片',
    },{
      showKey: 'vr_roof_four_04',
      key: 'vrRoofFour',
      num: 9,
      minNum: 1,
      title: '入户全景照片',
    },{
      showKey: 'survey_files_04',
      key: 'surveyFiles',
      num: 4,
      title: '现场勘测表',
    }],
    formSetObj: {}, //自定义字段
    standardSolutionsList:[],//标准方案初始数量
    combinedSolutionsList:[],//组合方案初始数量
    planList:[],//方案
    gridType: '0',
    tabIndex: '0',
    productList: [],
    multiPhoto: [], //多产品图片
    // multiPhotoTips: [],//多产品图片
    multiScheme:[],//多产品方案
    multiComponentList:[],//多产品组件
  },
  ready(){
    this.findAllPlan();
    this.entryDetail();
  },
  methods:{
    /** 获取自定义字段 */
    getFormSet(partner) {
      getAllConditionList({
        partner: partner,
      }).then((res) => {
        this.setData({
          formSetObj: res.data
        })
      })
    },
    /*** 获取字典 */
  getDictionaryList(partner, callback) {
    getAllDictionarySelect({
      capitalId: partner,
    }).then((res) => {
      if(res.data){
        this.setData({
          angleAzimuthSel: res.data.angle_azimuth.map(item=>item.columns), //方位角
        })
      }
      if(callback) callback(res.data)
    })
  },
    /** 获取电站详情 **/
    entryDetail(e) {
      let that = this      
      let res = JSON.parse(JSON.stringify(this.data.childObj));      
      //华融资方--多产品分开显示
      let productList = res.projectDetailList //产品集合
      let multiPhoto = []
      let multiScheme = []
      //拆分成多产品 
      productList.forEach((item,index)=>{
        //多产品图片处理
        multiPhoto.push(this.data.photo)
        multiScheme.push({
          standardSolutionsListIndex: 0,
          standardSolutionsList: [{
            projectId: item.projectId, //产品ID
            type: "", //方案类型
            name: "", //方案名称
            id: "", //方案ID
            code: "", //方案编号
            drawing: "", //参考图纸
          }]
        })
        // 添加图片
        this.setData({
          multiComponentList: this.data.multiComponentList,
          multiScheme: this.data.multiScheme,
          // multiScheme, //方案信息默认值
          [`multiPhoto[${index}].dipAngle`]:item.dipAngle,//组件倾角
          [`multiPhoto[${index}].zjpbImg`]: item.zjpbImg ? item.zjpbImg.split(",").map(itm => {return {name: itm,url: IMG_BASE_URL + itm}}) : [], //组件排布图
          [`multiPhoto[${index}].zjzxImg`]: item.zjzxImg ? item.zjzxImg.split(",").map(itm => {return {name: itm,url: IMG_BASE_URL + itm}}) : [], //组件接线图
          [`multiPhoto[${index}].zjcsImg`]: item.zjcsImg ? item.zjcsImg.split(",").map(itm => {return {name: itm,url: IMG_BASE_URL + itm}}) : [], //组件支架图
          [`multiPhoto[${index}].zjhsImg`]: item.zjhsImg ? item.zjhsImg.split(",").map(itm => {return {name: itm,url: IMG_BASE_URL + itm}}) : [], //电气图              
          [`multiPhoto[${index}].dzImgs`]: item.dzImgs ? item.dzImgs.split(",").map(itm=>{return {name:itm, url:IMG_BASE_URL + itm}}) : [{url:WU_TU_PIAN_URL}],//组合图
          //房屋信息
          [`multiPhoto[${index}].flyImgs`]:item.flyImgs ? item.flyImgs.split(",").map(itm=>{return {name:itm, url:IMG_BASE_URL + itm}}) : [{url:WU_TU_PIAN_URL}],//无人机航拍图
          [`multiPhoto[${index}].roofPhotoOne`]:item.roofPhotoOne ? item.roofPhotoOne.split(",").map(itm=>{return {name:itm, url:IMG_BASE_URL + itm}}) : [{url:WU_TU_PIAN_URL}],//安装区域整体照片
          [`multiPhoto[${index}].roofPhotoTwo`]:item.roofPhotoTwo ? item.roofPhotoTwo.split(",").map(itm=>{return {name:itm, url:IMG_BASE_URL + itm}}) : [{url:WU_TU_PIAN_URL}],//安装区域东南角照片
          [`multiPhoto[${index}].roofPhotoThree`]:item.roofPhotoThree ? item.roofPhotoThree.split(",").map(itm=>{return {name:itm, url:IMG_BASE_URL + itm}}) : [{url:WU_TU_PIAN_URL}],//安装区域西南角照片
          [`multiPhoto[${index}].roofPhotoFour`]:item.roofPhotoFour ? item.roofPhotoFour.split(",").map(itm=>{return {name:itm, url:IMG_BASE_URL + itm}}) : [{url:WU_TU_PIAN_URL}],//安装区域正南照片
          [`multiPhoto[${index}].roofPhotoFive`]:item.roofPhotoFive ? item.roofPhotoFive.split(",").map(itm=>{return {name:itm, url:IMG_BASE_URL + itm}}) : [{url:WU_TU_PIAN_URL}],//安装区域细节照片
          [`multiPhoto[${index}].roofPhotoInterior`]:item.roofPhotoInterior ? item.roofPhotoInterior.split(",").map(itm=>{return {name:itm, url:IMG_BASE_URL + itm}}) : [{url:WU_TU_PIAN_URL}],//房屋内部环境照片
          [`multiPhoto[${index}].roofPhotoFacade`]:item.roofPhotoFacade ? item.roofPhotoFacade.split(",").map(itm=>{return {name:itm, url:IMG_BASE_URL + itm}}) : [{url:WU_TU_PIAN_URL}],//房屋内部结构照片
          [`multiPhoto[${index}].detailSupplementOne`]:item.detailSupplementOne ? item.detailSupplementOne.split(",").map(itm=>{return {name:itm, url:IMG_BASE_URL + itm}}) : [{url:WU_TU_PIAN_URL}],//逆变器、配电箱预安装位置照片
          [`multiPhoto[${index}].houseSupplementOne`]:item.houseSupplementOne ? item.houseSupplementOne.split(",").map(itm=>{return {name:itm, url:IMG_BASE_URL + itm}}) : [{url:WU_TU_PIAN_URL}],//房屋其他障碍物照片
          [`multiPhoto[${index}].surveyVideo`]:item.surveyVideo ? item.surveyVideo.split(",").map(itm=>{return {name:itm, url:IMG_BASE_URL + itm}}) : [{url:WU_TU_PIAN_URL}],//踏勘补充证明视频
          [`multiPhoto[${index}].surveyFiles`]:item.surveyFiles ? item.surveyFiles.split(",").map(itm=>{return {name:itm, url:IMG_BASE_URL + itm}}) : [],//踏勘记录表
          [`multiPhoto[${index}].vrRoofOne`]: item.vrRoofOne ? item.vrRoofOne.split(",").map(itm => { return { name: itm, url: IMG_BASE_URL + itm}}) : [], //房屋整体图（VR全景）
          [`multiPhoto[${index}].vrRoofTwo`]: item.vrRoofTwo ? item.vrRoofTwo.split(",").map(itm => { return { name: itm, url: IMG_BASE_URL + itm}}) : [], //房屋整体俯视图（VR）
          [`multiPhoto[${index}].vrRoofThree`]: item.vrRoofThree ? item.vrRoofThree.split(",").map(itm => { return { name: itm, url: IMG_BASE_URL + itm}}) : [], //房屋内部结构图（VR）
          [`multiPhoto[${index}].vrRoofFour`]: item.vrRoofFour ? item.vrRoofFour.split(",").map(itm => { return { name: itm, url: IMG_BASE_URL + itm}}) : [], //入户全景照片(VR)
          [`multiPhoto[${index}].houseOutlinePhoto`]: item.houseOutlinePhoto ? item.houseOutlinePhoto.split(",").map(itm => { return { name: itm, url: IMG_BASE_URL + itm}}) : [], //房屋轮廓照片
          [`multiPhoto[${index}].fwImg1`]: item.fwImg1 ? item.fwImg1.split(",").map(itm => {return {name: itm,url: IMG_BASE_URL + itm}}) : [], //房屋整体图 
          [`multiPhoto[${index}].fwImg2`]: item.fwImg2 ? item.fwImg2.split(",").map(itm => {return {name: itm,url: IMG_BASE_URL + itm}}) : [], //房屋内部结构图  
          [`multiPhoto[${index}].fwImg3`]: item.fwImg3 ? item.fwImg3.split(",").map(itm => {return {name: itm,url: IMG_BASE_URL + itm}}) : [], //房屋屋顶东南侧图片 
          [`multiPhoto[${index}].fwImg4`]: item.fwImg4 ? item.fwImg4.split(",").map(itm => {return {name: itm,url: IMG_BASE_URL + itm}}) : [], //房屋屋顶西南侧图片 
          [`multiPhoto[${index}].fwImg5`]: item.fwImg5 ? item.fwImg5.split(",").map(itm => {return {name: itm,url: IMG_BASE_URL + itm}}) : [], //遮阴物与房屋距离、高度 
        });  

        if(item.addEntryReqDesignDetails.length>0){
          this.setData({
            [`multiPhoto[${index}].designDrawings`]: item.addEntryReqDesignDetails[0].designDrawings ? item.addEntryReqDesignDetails[0].designDrawings.split(",").map(itm => {return {name: itm, url: IMG_BASE_URL + itm} }) : [], //设计图纸
          })
        }else{
          this.setData({
            [`multiPhoto[${index}].designDrawings`]: [], //设计图纸
          })
        }
      
        // 组件,逆变器,并网箱,支架
        if (item.componentList.length > 0) {
          var componentList = [];
          var converterList = [];
          var cagesList = [];
          var zhijList = [];
          var componentNum = 0;
          for (let i = 0; i < item.componentList.length; i++) {
            const element = item.componentList[i];
            var OB = {
              projectId: "", //产品ID
              id: "",
              num: "", //数量
              model: "", //名称
              addType: 0,
            }
            if (element.item_type == 3) {
              OB.projectId = item.projectId;
              OB.id = element.item_id;
              OB.num = element.num;
              OB.model = element.model;
              OB.material_model = element.material_model;
              componentNum = element.num * element.model + componentNum
              componentList.push(OB)
            } else if (element.item_type == 1) {
              OB.projectId = item.projectId;
              OB.id = element.item_id;
              OB.num = element.num;
              OB.model = element.model;
              OB.material_model = element.material_model;
              converterList.push(OB)
            } else if (element.item_type == 2) {
              OB.projectId = item.projectId;
              OB.id = element.item_id;
              OB.num = element.num;
              OB.model = element.model;
              cagesList.push(OB)
            } else if (element.item_type == 4) {
              OB.projectId = item.projectId;
              OB.id = element.item_id;
              OB.num = element.num;
              OB.model = element.model;
              zhijList.push(OB)
            }
          }
          this.setData({
            [`multiComponentList[${index}].componentList`]: componentList,
            [`multiComponentList[${index}].converterList`]: converterList,
            [`multiComponentList[${index}].cagesList`]: cagesList,
            [`multiComponentList[${index}].zhijList`]: zhijList,
            [`multiComponentList[${index}].productZj`]:item.assemblySpecs ? Number(item.assemblySpecs) : 0,//产品默认的组件值
            [`multiComponentList[${index}].componentNum`]: (componentNum/1000).toFixed(3),
          })
          // console.log(126666, this.data.multiComponentList)
        }else{
          this.setData({
            [`multiComponentList[${index}].componentList`]: [{
              projectId: item.projectId, //产品ID
              id: res.modeId ? res.modeId : '',//默认产品信息中的组件规格id
              num: '', //数量
              model: res.modeId ? item.assemblySpecs : '', //名称,默认产品信息中的组件规格
              addType: 1,
            }], //组件初始数量
            [`multiComponentList[${index}].converterList`]: [{
              projectId: item.projectId, //产品ID
              id: "",
              num: "", //数量
              model: "", //名称
              addType: 1,
            }], //逆变器初始数量
            [`multiComponentList[${index}].cagesList`]: [{
              projectId: item.projectId, //产品ID
              id: "",
              num: "", //数量
              model: "", //名称
              addType: 1,
            }], //并网箱初始数量
            [`multiComponentList[${index}].zhijList`]: [{
              projectId: item.projectId, //产品ID
              id: "",
              num: "", //数量
              model: "", //名称
              addType: 1,
            }], //支架初始数量
            [`multiComponentList[${index}].productZj`]: item.assemblySpecs ? Number(item.assemblySpecs) : 0,//产品默认的组件值
            [`multiComponentList[${index}].componentNum`]: 0,
          })
        }
        //方案信息-方案类型
        if (res.scheme_type == 1) {//标准方案
          // this.setData({
          //   [`standardSolutionsList[0].id`]: res.scheme_id ? res.scheme_id : '',
          //   [`standardSolutionsList[0].type`]: res.scheme_type_name ? res.scheme_type_name : '',
          //   [`standardSolutionsList[0].typeId`]: res.scheme_type_id ? res.scheme_type_id : '',
          //   [`standardSolutionsList[0].name`]: res.scheme_name ? res.scheme_name : "",
          // })
          if(productList[index].addEntryReqDesignDetails.length){
            for (let i = 0; i < that.data.planList.length; i++) {
              const element = that.data.planList[i];
              if (productList[index].addEntryReqDesignDetails[0].schemeTypeId && (productList[index].addEntryReqDesignDetails[0].schemeTypeId == element.id)) {
                this.setData({
                  [`multiScheme[${index}].standardSolutionsListIndex`]: i,
                })
              }
            }
            this.setData({
              [`multiScheme[${index}].standardSolutionsList[0].projectId`]: productList[index].projectId,
              [`multiScheme[${index}].standardSolutionsList[0].id`]: productList[index].addEntryReqDesignDetails[0].schemeId ? productList[index].addEntryReqDesignDetails[0].schemeId : '',
              [`multiScheme[${index}].standardSolutionsList[0].type`]: productList[index].addEntryReqDesignDetails[0].schemeTypeName ? productList[index].addEntryReqDesignDetails[0].schemeTypeName : '',
              [`multiScheme[${index}].standardSolutionsList[0].typeId`]: productList[index].addEntryReqDesignDetails[0].schemeTypeId ? productList[index].addEntryReqDesignDetails[0].schemeTypeId : '',
              [`multiScheme[${index}].standardSolutionsList[0].name`]: productList[index].addEntryReqDesignDetails[0].schemeName ? productList[index].addEntryReqDesignDetails[0].schemeName : "",            
            })
          }
        } else if (res.scheme_type == 2) {//组合方案
          if (res.composePlanList.length > 0) {
            var combinedSolutionsList = []
            for (let i = 0; i < res.composePlanList.length; i++) {
              var combinedSolutionsListOB = {}
              const element = res.composePlanList[i];
              if (i == 0) {
                combinedSolutionsListOB.addType = 1;
              }
              combinedSolutionsListOB.code = element.code;
              combinedSolutionsListOB.id = element.planId;
              combinedSolutionsListOB.name = element.name;
              combinedSolutionsListOB.type = element.planType;
              combinedSolutionsListOB.planTypeId = element.planTypeId;
              for (let i = 0; i < that.data.planList.length; i++) {
                const planTypeObj = that.data.planList[i];

                if (planTypeObj.allPlan.length > 0) {
                  for (let j = 0; j < planTypeObj.allPlan.length; j++) {
                    const plan = planTypeObj.allPlan[j];
                    if (plan.id == element.planId) {
                      combinedSolutionsListOB.pickerIndex = i
                    }
                  }
                }
              }
              combinedSolutionsList.push(combinedSolutionsListOB)
            }
            this.setData({
              combinedSolutionsList: combinedSolutionsList
            })
          }
        }
       }) 
        //保险购买情况
        if (res.insurance_flag == 1) {
          this.setData({
            insuranceName: "控制投放及续保"
          })
        } else if (res.insurance_flag == 2) {
          this.setData({
            insuranceName: "控制投放"
          })
        } else if (res.insurance_flag == 3) {
          this.setData({
            insuranceName: "其他"
          })
        }        
        this.setData({
          productList,
          projectList: res.projectList,
          multiComponentList: this.data.multiComponentList,
          multiScheme: this.data.multiScheme,
          id: res.id, //修改数据的时候传此ID
          detail: res,
          projectId: res.project_id,
          tenant_type: res.tenant_type=='1' ? '个人' : '单位',//1.个人，2单位
          //业主信息参数
          name: res.tenant_name,
          phone: res.mobile,
          provinceName: res.province,
          cityName: res.city,
          areaName: res.area,
          address: res.address,
          //项目信息
          capitalName: res.zfName, //资方
          projectName: res.projectName,//产品名称
          companyName: res.project_company_name,//项目公司
          filingName: res.filing_type=='1' ? '农户备案' : '项目公司备案',//备案类型
          leaseDate: res.leaseDate ? res.leaseDate : '',//预计投放日
          repaymentMethod: res.repayment_method,//划转方式
          //如果租金划转方式是二类卡，那么二类卡的信息 显示这个
          secCardName:res.secCardName ? res.secCardName : '',//二类卡账户名    
          secCardNo:res.secCardNo ? res.secCardNo : '',//二类卡账号
          secBankNumber:res.secBankNumber ? res.secBankNumber : '',//二类卡联行号
          bankName: res.bank_name ? res.bank_name : '', //卡账号名称
          bankCode: res.bank_code ? res.bank_code : '', //卡账号
          tssBankNum: res.tss_bank_num ? res.tss_bank_num : '', //卡开户行
          longitude: res.longitude, //经度
          latitude: res.latitude, //纬度
          //房屋信息
          roofType: res.roof_type,
          sealRoof:res.seal_roof,//是否封屋顶，1是，2.否
          completionYear:res.completion_year ? res.completion_year : '',//房屋建成年份
          slopeGradient:res.slope_gradient ? res.slope_gradient : '',//屋面坡度
          purlineInterval:res.purline_interval ? res.purline_interval : '',//檀条间距
          waterproof:res.waterproof ? res.waterproof : '',//屋顶防水情况
          sourcePollution:res.source_pollution ? res.source_pollution : '',//是否有污染源
          opsCondition:res.ops_condition ? res.ops_condition : '',//是否具备运维空间
          voltageClasses:res.voltage_classes ? res.voltage_classes : '',//并网电压等级
          transformerCapacity:res.transformer_capacity ? res.transformer_capacity : '',//变压器容量
          restrictFlag:res.restrict_flag ? res.restrict_flag : '',//是否符合变压器容量限制要求
          dipAngle:res.dip_angle ? res.dip_angle : '',//组件倾角
          roofArea: res.roof_area, //屋顶面积
          deg: res.distance,//配电箱至并网点距离
          height: res.building_height,//建筑高度
          azimuth: res.azimuth ? res.azimuth : 1,//方位角
          directionDeg: res.angle,//方位角
          //房屋信息-图片
          // [`photo.flyImgs`]:res.fly_imgs ? res.fly_imgs.split(",").map(itm=>{return {name:itm, url:IMG_BASE_URL + itm}}) : [{url:WU_TU_PIAN_URL}],//无人机航拍图
          // [`photo.roofPhotoOne`]:res.roof_photo_one ? res.roof_photo_one.split(",").map(itm=>{return {name:itm, url:IMG_BASE_URL + itm}}) : [{url:WU_TU_PIAN_URL}],//安装区域整体照片
          // [`photo.roofPhotoTwo`]:res.roof_photo_two ? res.roof_photo_two.split(",").map(itm=>{return {name:itm, url:IMG_BASE_URL + itm}}) : [{url:WU_TU_PIAN_URL}],//安装区域东南角照片
          // [`photo.roofPhotoThree`]:res.roof_photo_three ? res.roof_photo_three.split(",").map(itm=>{return {name:itm, url:IMG_BASE_URL + itm}}) : [{url:WU_TU_PIAN_URL}],//安装区域西南角照片
          // [`photo.roofPhotoFour`]:res.roof_photo_four ? res.roof_photo_four.split(",").map(itm=>{return {name:itm, url:IMG_BASE_URL + itm}}) : [{url:WU_TU_PIAN_URL}],//安装区域正南照片
          // [`photo.roofPhotoFive`]:res.roof_photo_five ? res.roof_photo_five.split(",").map(itm=>{return {name:itm, url:IMG_BASE_URL + itm}}) : [{url:WU_TU_PIAN_URL}],//安装区域细节照片
          // [`photo.roofPhotoInterior`]:res.roof_photo_interior ? res.roof_photo_interior.split(",").map(itm=>{return {name:itm, url:IMG_BASE_URL + itm}}) : [{url:WU_TU_PIAN_URL}],//房屋内部环境照片
          // [`photo.roofPhotoFacade`]:res.roof_photo_facade ? res.roof_photo_facade.split(",").map(itm=>{return {name:itm, url:IMG_BASE_URL + itm}}) : [{url:WU_TU_PIAN_URL}],//房屋内部结构照片
          // [`photo.detailSupplementOne`]:res.detail_supplement_one ? res.detail_supplement_one.split(",").map(itm=>{return {name:itm, url:IMG_BASE_URL + itm}}) : [{url:WU_TU_PIAN_URL}],//逆变器、配电箱预安装位置照片
          // [`photo.houseSupplementOne`]:res.house_supplement_one ? res.house_supplement_one.split(",").map(itm=>{return {name:itm, url:IMG_BASE_URL + itm}}) : [{url:WU_TU_PIAN_URL}],//房屋其他障碍物照片
          // [`photo.surveyVideo`]:res.survey_video ? res.survey_video.split(",").map(itm=>{return {name:itm, url:IMG_BASE_URL + itm}}) : [{url:WU_TU_PIAN_URL}],//踏勘补充证明视频
          // [`photo.houseOwnership`]:res.house_ownership ? res.house_ownership.split(",").map(itm=>{return {name:itm, url:IMG_BASE_URL + itm}}) : [],//房产证
          // [`photo.surveyFiles`]:res.survey_files ? res.survey_files.split(",").map(itm=>{return {name:itm, url:IMG_BASE_URL + itm}}) : [],//踏勘记录表
          // [`photo.vrRoofOne`]: res.vr_roof_one ? res.vr_roof_one.split(",").map(itm => { return { name: itm, url: IMG_BASE_URL + itm}}) : [], //房屋整体图（VR全景）
          // [`photo.vrRoofTwo`]: res.vr_roof_two ? res.vr_roof_two.split(",").map(itm => { return { name: itm, url: IMG_BASE_URL + itm}}) : [], //房屋整体俯视图（VR）
          // [`photo.vrRoofThree`]: res.vr_roof_three ? res.vr_roof_three.split(",").map(itm => { return { name: itm, url: IMG_BASE_URL + itm}}) : [], //房屋内部结构图（VR）
          // [`photo.vrRoofFour`]: res.vr_roof_four ? res.vr_roof_four.split(",").map(itm => { return { name: itm, url: IMG_BASE_URL + itm}}) : [], //入户全景照片(VR)
          // [`photo.houseOutlinePhoto`]: res.house_outline_photo ? res.house_outline_photo.split(",").map(itm => { return { name: itm, url: IMG_BASE_URL + itm}}) : [], //房屋轮廓照片
          //方案信息
          // componentNum: (componentNum/1000).toFixed(2),//设计安装容量
          // componentList: componentList,//组件
          // converterList: converterList,//逆变器
          // cagesList: cagesList,//并网箱
          // zhijList: zhijList,//支架
          schemeType: res.scheme_type ? res.scheme_type : 1,//设计方案
          solutionRemark: res.scheme_remarks ? res.scheme_remarks : '',//方案备注
          // [`photo.designDrawings`]: res.design_drawings ? res.design_drawings.split(",").map(itm => {
          //   return {
          //     name: itm,
          //     url: IMG_BASE_URL + itm
          //   }
          // }) : [], //设计图纸
          // 'photo.zjpbImg': res.zjpb_img ? res.zjpb_img.split(",").map(itm => {return {name: itm,url: IMG_BASE_URL + itm}}) : [], //组件排布图
          // 'photo.zjzxImg': res.zjzx_img ? res.zjzx_img.split(",").map(itm => {return {name: itm,url: IMG_BASE_URL + itm}}) : [], //组件接线图
          // 'photo.zjcsImg': res.zjcs_img ? res.zjcs_img.split(",").map(itm => {return {name: itm,url: IMG_BASE_URL + itm}}) : [], //组件支架图
          // 'photo.zjhsImg': res.zjhs_img ? res.zjhs_img.split(",").map(itm => {return {name: itm,url: IMG_BASE_URL + itm}}) : [], //电气图
          // // [`photo.nbqwzImg[0].url`]: res.nbqwz_img ? IMG_BASE_URL + res.nbqwz_img : WU_TU_PIAN_URL,
          // // [`photo.pdxwzImg[0].url`]: res.pdxwz_img ? IMG_BASE_URL + res.pdxwz_img : WU_TU_PIAN_URL,
          // [`photo.dzImgs`]: res.dz_imgs ? res.dz_imgs.split(",").map(itm=>{return {name:itm, url:IMG_BASE_URL + itm}}) : [{url:WU_TU_PIAN_URL}],//组合图
          // //2024-9-4 广发
          // 'photo.fwImg1': res.fw_img1 ? res.fw_img1.split(",").map(itm => {return {name: itm,url: IMG_BASE_URL + itm}}) : [], //房屋整体图 
          // 'photo.fwImg2': res.fw_img2 ? res.fw_img2.split(",").map(itm => {return {name: itm,url: IMG_BASE_URL + itm}}) : [], //房屋内部结构图  
          // 'photo.fwImg3': res.fw_img3 ? res.fw_img3.split(",").map(itm => {return {name: itm,url: IMG_BASE_URL + itm}}) : [], //房屋屋顶东南侧图片 
          // 'photo.fwImg4': res.fw_img4 ? res.fw_img4.split(",").map(itm => {return {name: itm,url: IMG_BASE_URL + itm}}) : [], //房屋屋顶西南侧图片 
          // 'photo.fwImg5': res.fw_img5 ? res.fw_img5.split(",").map(itm => {return {name: itm,url: IMG_BASE_URL + itm}}) : [], //遮阴物与房屋距离、高度 
        });
        //并网方式处理
        if(res.recordBoxHistory){
          if(res.recordBoxHistory ==''){//并网方式没选择过，默认‘单户并网’          
            this.setData({
              // gridType: '0',//并网方式
              boxTotalCount: '', //总数
              boxGroupNum: '', //编号
              boxGroupName: '', //名称
            })
          }else{
            this.setData({
              gridType: res.recordBoxHistory.type,//并网方式
              gridStatus: res.recordBoxHistory.status,//状态为1不能编辑
              boxTotalCount: res.recordBoxHistory.total_count,
              boxGroupNum: res.recordBoxHistory.group_number,
              boxGroupName: res.recordBoxHistory.group_name,
              boxGroupId: res.recordBoxHistory.box_group_id,
            })                
          }
        }
        // console.log("photo",this.data.photo);
        this.getFormSet(res.management)
        //下拉字典
        this.getDictionaryList(res.management, (res2)=>{
          let angleList = res2.angle_azimuth.map(item=>item.columns)       
          if(res.azimuth){
            let azimuthName = angleList.find(itm => itm.dict_key === res.azimuth).dict_value;
            this.setData({
              azimuthName
            })
          }        
        }); 
    },
    /** 获取方案类型和方案名称 **/
    findAllPlan(e) {
      let that = this
      findAllPlan({

      }).then((res) => {
        for (let i = 0; i < res.length; i++) {
          res[i].allPlan = JSON.parse(res[i].allPlan)
          for (let j = 0; j < res[i].allPlan.length; j++) {
            var element = res[i].allPlan[j].columns;
            res[i].allPlan[j] = element
          }
        }
        that.setData({
          planList: res,
        })
      })
    },   
    //打开pdf文件或者大图查看图片
    openDocument(res) {
      let path = res.currentTarget.dataset.path
      if (path) {
        let suffix = path.substring(path.lastIndexOf('.') + 1) //获取文件后缀
        if(suffix=='mp4'){// 开始预览多媒体内容
          wx.previewMedia({ 
            sources: [{
              url :IMG_BASE_URL + path,
              type: 'video'
            }], // 需要预览的资源列表
          });     
        }else if(suffix != 'jpg' && suffix != 'png' && suffix != 'gif' && suffix != 'jpeg') {
          wx.showLoading({
            title: '加载中',
          })
          wx.downloadFile({
            url: IMG_BASE_URL + path,
            complete: function (res) {
              wx.hideLoading()
              const filePath = res.tempFilePath
              wx.openDocument({
                filePath: filePath,
                fileType: suffix,
                showMenu: true,
                success: function (res) {}
              })
            }
          })
        }else{
          wx.previewImage({
            urls: [IMG_BASE_URL + path] // 需要预览的图片http链接列表
          })
        }
      }
    },
    //tab切换
    changeTab(e){
      let index = e.currentTarget.dataset.index
      this.setData({
        tabIndex: index
      })
    }
  }
})