import { Component, OnInit, ViewChild } from '@angular/core';
import { FormBuilder, FormGroup,Validators,FormControl } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import {
  SFComponent,
  SFNumberWidgetSchema,
  SFSchema,
  SFSelectWidgetSchema,
  SFTextareaWidgetSchema,
  SFUISchema
} from '@delon/form';
import { _HttpClient } from '@delon/theme';
import { AmapPoiPickerComponent,AmapService } from '@shared';
import { NzModalService } from 'ng-zorro-antd/modal';
import { PublishGoodsChooseFamifiarComponent } from '../choose-famifiar/choose-famifiar.component';
import { SupplyManagementService } from '../../services/supply-management.service';
import { debug } from 'console';
import { PublishAddressListComponent } from './address-list/address-list.component';
import { PublishSuccessComponent } from './publish-success/publish-success.component';
@Component({
  selector: 'app-publish-goods-onecar-publish',
  templateUrl: './onecar-publish.component.html',
  styleUrls: ['./onecar-publish.component.less']
})
export class  SupplyManagementOnecarPublishComponent implements OnInit {
  validateForm1: FormGroup;
  newTempchecked = false; //是否存入新模板
  sf1data: any; // 货源单设置回显
  sf3data: any; // 货源单设置回显
  sf4data: any; // 货源单设置回显
  sf5data: any; // 货源单设置回显
  sf6data: any; // 货源单设置回显
  sf7data: any; // 货源单设置回显
  creatTime: any; // 货源单设置回显
  loadingTime: any; // 货源单设置回显
  unloadingTime: any; // 货源单设置回显
  totalFees: any; // 总数信息
  totalDistance = 0.0; //总里程
  totalTime = 0.0; //路程总时间
  npp =false
  id = this.route.snapshot.params.id;
  // // 单位
  unit1 = '吨';
  unit2 = '方';
  unit3 = '保价费金额';
  startInfo: any = [];
  endInfo: any = [];
  PageStatus = '';
  dataList: any;
  constructor(
    private http: _HttpClient, 
    fb: FormBuilder, 
    private router: Router, 
    private route: ActivatedRoute, 
    private modalService: NzModalService, 
    public service: SupplyManagementService,  
    private amapService: AmapService
    ) {
    this.validateForm1 = fb.group({
      loadingTime: [null, []],
      unloadingTime: [null, []],
    });
  }
  @ViewChild('sf1', { static: false }) sf1!: SFComponent;
  schema1: SFSchema = {};
  ui1!: SFUISchema;

  @ViewChild('sf2', { static: false }) sf2!: SFComponent;
  schema2: SFSchema = {};
  ui2!: SFUISchema;

  @ViewChild('sf3', { static: false }) sf3!: SFComponent;
  schema3: SFSchema = {};
  ui3!: SFUISchema;

  @ViewChild('sf4', { static: false }) sf4!: SFComponent;
  schema4: SFSchema = {};
  ui4!: SFUISchema;

  @ViewChild('sf5', { static: false }) sf5!: SFComponent;
  schema5: SFSchema = {};
  ui5!: SFUISchema;

  @ViewChild('sf6', { static: false }) sf6!: SFComponent;
  schema6: SFSchema = {};
  ui6!: SFUISchema;

  @ViewChild('sf7', { static: false }) sf7!: SFComponent;
  schema7: SFSchema = {};
  ui7!: SFUISchema;
  ngOnInit(): void {
    if(this.route.snapshot?.queryParams?.sta === '1') {
      console.log('修改')
      this.PageStatus = '整车修改';
    } else if(this.route.snapshot?.queryParams?.sta === '2')  {
      this.PageStatus = '整车下一单';
    } else if(this.route.snapshot?.queryParams?.sta === '3')  {
      this.PageStatus = '大宗修改';
    } else if(this.route.snapshot?.queryParams?.sta === '4')  {
      this.PageStatus = '大宗下一单';
    } 
    this.initSF1();
    // this.initSF2();
    this.initSF3();
    this.initSF4();
    this.initSF5();
    this.initSF6();
    this.initSF7();
    this.initdata();
  }

  initSF1() {
    this.schema1 = {
      properties: {
        shipperAppUserName: {
          type: 'string',
          title: '货主',
          maxLength: 30,
          ui: {
            placeholder: '请输入'
          }
        },
        enterpriseProjectId: {
          type: 'string',
          title: '项目',
          enum: [
            { label: '项目1', value: '1' },
            { label: '项目2', value: '2' }
          ],
          ui: {
            widget: 'select',
            placeholder: '请选择',
            allowClear: true
            // asyncData: () =>
            //   this.service.loadChildData2('0', '2').pipe(
            //     map((data: any) => {
            //       return data.map((m: any) => {
            //         return { label: m.name, value: m.id };
            //       });
            //     }),
            //   ),
            // change: (i) => this.updateCategory(i, '/categoryId2'),
          } as SFSelectWidgetSchema
        },
        enterpriseInfoName: {
          type: 'string',
          title: '网络货运人',
          ui: {
            widget: 'text'
          },
        },
        externalResourceCode: {
          type: 'string',
          title: '外部货源号',
          maxLength: 30,
          ui: {
            placeholder: '请输入'
          }
        },
        dispatchId: {
          type: 'string',
          title: '调度员',
          enum: [
            { label: '调度员1', value: '1' },
            { label: '调度员2', value: '2' }
          ],
          ui: {
            widget: 'select',
            placeholder: '请选择',
            allowClear: true
            // asyncData: () =>
            //   this.service.loadChildData2('0', '2').pipe(
            //     map((data: any) => {
            //       return data.map((m: any) => {
            //         return { label: m.name, value: m.id };
            //       });
            //     }),
            //   ),
            // change: (i) => this.updateCategory(i, '/categoryId2'),
          } as SFSelectWidgetSchema
        }
      }
    };
    this.ui1 = {
      '*': {
        spanLabelFixed: 120,
        grid: { span: 8 }
      }
    };
  }

  // initSF2() {
  //   this.schema2 = {
  //     properties: {
  //       name1: {
  //         type: 'string',
  //         title: '发货模板',
  //         ui: {
  //           widget: 'custom',
  //           placeholder: '请输入'
  //         }
  //       }
  //     }
  //   };
  //   this.ui2 = {
  //     '*': {
  //       spanLabelFixed: 90,
  //       grid: { span: 12 }
  //     }
  //   };
  // }
  initSF3() {
    this.schema3 = {
      properties: {
        goodsName: {
          type: 'string',
          title: '货物名称',
          ui: {
            widget: 'dict-select',
            params: { dictKey: 'GoodsName' },
            placeholder: '请选择'
          }
        },
        qita: {
          type: 'string',
          title: '',
          ui: {
            visibleIf: {
              goodsName: value => value === '3'
            }
          }
        }
      },
      required: ['goodsName', ]
    };
    this.ui3 = {
      '*': {
        spanLabelFixed: 90,
        grid: { span: 12 }
      },
      $goodsName: {
        grid: { span: 12 }
      },
      $qita: {
        grid: { span: 12 }
      }
    };
  }
  initSF4() {
    this.schema4 = {
      properties: {
        weight: {
          type: 'string',
          title: '货物数量',
          ui: {
            widget: 'custom',
            placeholder: '请输入',
            errors: { required: '必填项' }
          }
        },
        volume: {
          type: 'string',
          title: '',
          ui: {
            widget: 'custom',
            placeholder: '请输入'
          }
        },
        number: {
          type: 'string',
          title: '',
          ui: {
            widget: 'custom',
            placeholder: '请输入'
          }
        },
        maxWeight: {
          type: 'string',
          title: '车型/车长',

          enum: [
            { label: '1', value: '1' },
            { label: '2', value: '2' }
          ],
          ui: {
            widget: 'select',
            placeholder: '请选择车型',
            mode: 'multiple',
            errors: { required: '请选择车型' }
            // asyncData: () =>
            //   this.categoryService.loadChildData2('0', '2').pipe(
            //     map((data: any) => {
            //       return data.map((m: any) => {
            //         return { label: m.name, value: m.id };
            //       });
            //     }),
            //   ),
            // change: (i) => this.updateCategory(i, '/categoryId2'),
          } as SFSelectWidgetSchema
        },
        maxCube: {
          type: 'string',
          title: '',
          enum: [
            { label: '1', value: '1' },
            { label: '2', value: '2' }
          ],
          ui: {
            widget: 'select',
            placeholder: '请选择车长',
            mode: 'multiple',
            errors: { required: '请选择车长' }
            // asyncData: () =>
            //   this.categoryService.loadChildData2('0', '2').pipe(
            //     map((data: any) => {
            //       return data.map((m: any) => {
            //         return { label: m.name, value: m.id };
            //       });
            //     }),
            //   ),
            // change: (i) => this.updateCategory(i, '/categoryId2'),
          } as SFSelectWidgetSchema
        }
      },
      required: ['weight', 'maxWeight', 'maxCube']
    };
    this.ui4 = {
      '*': {
        spanLabelFixed: 90,
        grid: { span: 24 }
      },
      $weight: {
        grid: { span: 8 }
      },
      $volume: {
        grid: { span: 8 }
      },
      $number: {
        grid: { span: 8 }
      },
      $maxWeight: {
        grid: { span: 12 }
      },
      $maxCube: {
        grid: { span: 12 }
      }
    };
  }

  initSF5() {
    this.schema5 = {
      properties: {
        goodsValue: {
          type: 'string',
          title: '货物价值',
          ui: {
            widget: 'custom',
            placeholder: '请输入'
          }
        }
      }
    };
    this.ui5 = {
      '*': {
        spanLabelFixed: 90,
        grid: { span: 24 }
      }
    };
  }

  initSF6() {
    this.schema6 = {
      properties: {
        stateReceipt: {
          type: 'string',
          title: '是否回单',
          enum: [
            { label: '需要', value: true },
            { label: '不需要', value: false }
          ],
          ui: {
            widget: 'select',
            errors: { required: '请选择' },
            placeholder: '请选择'
          }
        },
        receiptType: {
          type: 'string',
          title: '回单类型',
          enum: [
            { label: '电子回单', value: 1 },
            { label: '纸质回单', value: 2 }
          ],
          ui: {
            widget: 'select',
            placeholder: '请选择',
            errors: { required: '请选择' },
            visibleIf: {
              stateReceipt: value => value === true
            }
          }
        },
        receiptUserId: {
          type: 'string',
          title: '选择地址',
          ui: {
            widget: 'custom',
            placeholder: '请点击选择收回单地址',
            validator: val => (this.sf6?.value?.receiptType === '2' ? [{ keyword: 'required', message: '请点击选择收回单地址' }] : []),
            visibleIf: {
              receiptType: value => value === 2
            }
          },
          default: '1212'
        },
        name4: {
          type: 'string',
          title: '联系人',
          ui: {
            visibleIf: {
              receiptType: value => value === 2
            }
          },
          readOnly: true
        },
        name5: {
          type: 'string',
          title: '联系电话',
          ui: {
            visibleIf: {
              receiptType: value => value === 2
            }
          },
          readOnly: true
        },
        name6: {
          type: 'string',
          title: '所在地区',
          ui: {
            visibleIf: {
              receiptType: value => value === 2
            }
          },
          readOnly: true
        },
        receiptAddress: {
          type: 'string',
          title: '详细地址',
          maxLength: 20,
          ui: {
            visibleIf: {
              receiptType: value => value === 2
            }
          },
          readOnly: true
        },
        remarks: {
          type: 'string',
          title: '备注',
          maxLength: 200,
          ui: {
            widget: 'textarea',
            placeholder: '请输入',
            autosize: { minRows: 3, maxRows: 3 }
          } as SFTextareaWidgetSchema
        }
      },
      required: ['stateReceipt', 'receiptType']
    };
    this.ui6 = {
      '*': {
        spanLabelFixed: 90,
        grid: { span: 24 }
      }
    };
  }
  changeValue() {
    this.totalFees = Number(this.sf7?.value?.appendFee) + Number(this.sf7?.value?.oilCardPay) + Number(this.sf7?.value?.prePay) + Number(this.sf7?.value?.receiptPay) + Number(this.sf7?.value?.toPay)
    console.log(this.totalFees)
  }
  initSF7() {
    this.schema7 = {
      properties: {
        prePay: { type: 'number', title: '预付', default: 0, ui: { prefix: '￥', change: ()=> {
          this.changeValue();
        },
       } as SFNumberWidgetSchema },
        toPay: { type: 'number', title: '到付', default: 0, ui: { prefix: '￥',change: ()=> {
          this.changeValue();
        },
       } as SFNumberWidgetSchema },
        oilCardPay: { type: 'number', title: '油卡', default: 0, ui: { prefix: '￥',change: ()=> {this.changeValue();} ,
      } as SFNumberWidgetSchema },
        receiptPay: { type: 'number', title: '回单付', default: 0, ui: { prefix: '￥',change: ()=> {
          this.changeValue();},
         } as SFNumberWidgetSchema },
        subtotal: {
          type: 'string',
          title: '小计',
          ui: {
            widget: 'custom',
            placeholder: '请输入',
          },
        },
        appendFee: {
          type: 'string',
          title: '附加费',
          ui: {
            widget: 'custom',
            placeholder: '请输入',
          },
    
        },
        totalFee: {
          type: 'string',
          title: '总费用',
          ui: {
            widget: 'custom',
            placeholder: '请输入'
          }
        },
        paymentDays: {
          type: 'string',
          title: '到货后',
          ui: {
            widget: 'custom',
            placeholder: '请输入',
          }
        }
      },
      required: ['paymentDays']
    };
    this.ui7 = {
      '*': {
        spanLabelFixed: 90,
        grid: { span: 24 }
      }
    };
  }

  addStartInfo(event: any) {
    if (this.startInfo.length < 5) {
      const controlId = this.startInfo.length;
      this.startInfo.push({
        detailedAddress: '',
        appUserName: '',
        contractTelephone: '',
        latitude: '',
        longitude: '',
        province: '',
        city: '',
        area: '',
        type: 1
      });
      this.validateForm1.addControl(`loadAddress${controlId}`, new FormControl(null, Validators.required));
      this.validateForm1.addControl(`loadName${controlId}`, new FormControl(null, Validators.required));
      this.validateForm1.addControl(`loadPhone${controlId}`, new FormControl(null, Validators.required));
    }
  }
  subStartInfo(event: any, index: number, id?:any) {
    console.log(event, index, id)
    if(id) {
      this.service.request(this.service.$api_delete_Wholedeletebatch,  [id]).subscribe((res) => {
        console.log(res)
      })
    }
    this.startInfo.splice(index, 1);
    this.validateForm1.removeControl(`loadAddress${index}`);
    this.validateForm1.removeControl(`loadName${index}`);
    this.validateForm1.removeControl(`loadPhone${index}`);
  }

  addEndInfo(event: any) {
    if (this.addEndInfo.length < 5) {
      const controlId = this.endInfo.length;
      this.endInfo.push({
        detailedAddress: '',
        appUserName: '',
        contractTelephone: '',
        latitude: '',
        longitude: '',
        province: '',
        city: '',
        area: '',
        type: 2
      });
      this.validateForm1.addControl(`unloadAddress${controlId}`, new FormControl(null, Validators.required));
      this.validateForm1.addControl(`unloadName${controlId}`, new FormControl(null, Validators.required));
      this.validateForm1.addControl(`unloadPhone${controlId}`, new FormControl(null, Validators.required));
    }
  }
  subEndInfo(event: any, index: number, id?:any) {
    if(id) {
      this.service.request(this.service.$api_delete_Wholedeletebatch,  [id]).subscribe((res) => {
        console.log(res)
      })
    }
    console.log(event, index, id)
    this.endInfo.splice(index, 1);
        this.validateForm1.removeControl(`unloadAddress${index}`);
    this.validateForm1.removeControl(`unloadName${index}`);
    this.validateForm1.removeControl(`unloadPhone${index}`);
  }

  //指派熟车
  chooseFamifiar() {
    this.modalService.create({
      nzTitle: '指派熟车',
      nzContent: PublishGoodsChooseFamifiarComponent,
      nzWidth: 1300
    });
  }
  submit(): void {
    console.log('进来了')
    console.log(this.startInfo)
    // Object.keys(this.validateForm1.controls).forEach(key => {
    //   this.validateForm1.controls[key].markAsDirty();
    //   this.validateForm1.controls[key].updateValueAndValidity();
    // });
    // this.sf1.validator({ emitError: true });
    // this.sf3.validator({ emitError: true });
    // this.sf4.validator({ emitError: true });
    // this.sf6.validator({ emitError: true });
    // if (this.validateForm1.invalid || !this.sf1.valid || !this.sf3.valid || !this.sf4.valid || !this.sf6.valid) {
    //   return;
    // }
    console.log(this.validateForm1.value)
    if(typeof(this.validateForm1.value.unloadingTime) !== 'string' ) {
      var c = new Date(this.validateForm1.value.unloadingTime);  
      this.validateForm1.value.unloadingTime = c.getFullYear() + '-' + this.addPreZero(c.getMonth() + 1) + '-' + this.addPreZero(c.getDate()) + ' ' + this.addPreZero(c.getHours()) + ':' + this.addPreZero(c.getMinutes()) + ':' + this.addPreZero(c.getSeconds())
    }
    if(typeof(this.validateForm1.value.loadingTime) !== 'string' ) {
      var c = new Date(this.validateForm1.value.loadingTime);  
      this.validateForm1.value.loadingTime = c.getFullYear() + '-' + this.addPreZero(c.getMonth() + 1) + '-' + this.addPreZero(c.getDate()) + ' ' + this.addPreZero(c.getHours()) + ':' + this.addPreZero(c.getMinutes()) + ':' + this.addPreZero(c.getSeconds())
    }
    // if (this.validateForm1.invalid) {
    //   return;
    // }
    const params: any = {
      ...this.sf1.value,
      ...this.sf5.value,
      ...this.sf6.value,
      paymentDays: this.sf7.value.paymentDays,
      loadingTime: this.validateForm1?.value?.loadingTime,
      unloadingTime: this.validateForm1?.value?.unloadingTime,
      unLoadingPlaceDTOList: [...this.startInfo, ...this.endInfo,], 
      goodsInfoDTOList: [
        {
          ...this.sf4.value,
          ...this.sf3.value,
          maxWeight: this.sf4.value.maxWeight.join(','),
          maxCube: this.sf4.value.maxCube.join(',')
        }
      ]
    }
      params.shippingInformationDTO = {
        ...this.sf7.value,
        totalFees: this.totalFees
      }
    console.log(params)
    if(this.PageStatus === '整车修改') {
      this.requests(this.service.$api_set_WholeModify, params);
    }  else if(this.PageStatus === '整车下一单') {
      this.requests(this.service.$api_set_saveAnotherWholeOrder, params);
    }
  }
   addPreZero(num: any){
    if(num<10){
     return '0'+num;
    } else {
     return num;
    }
   }
  requests(url: any, params: any) {
    this.service.request(url, params).subscribe((res: any) => {
      if (res) {
        this.modalService.create({
          nzTitle: '',
          nzContent: PublishSuccessComponent,
          nzWidth: 900,
          nzFooter: null,
          nzComponentParams: { type: 'onecar' }
        });
      } else {
        this.service.msgSrv.error(res.msg);
      }
    })
  }
 // 打开地图
 openMap(type: string, index: number) {
  const modalRef = this.modalService.create({
    nzTitle: '',
    nzContent: AmapPoiPickerComponent,
    nzWidth: 900,
    nzOnOk: item => {
      const poi = item.poi;
      const locList = poi.location.toString().split(',');
      switch (type) {
        case 'start':
          this.startInfo[index].detailedAddress = poi.district + poi.name;
          this.startInfo[index].longitude = locList[0];
          this.startInfo[index].latitude = locList[1];
          this.startInfo[index].province = poi.cityInfo.province;
          this.startInfo[index].city = poi.cityInfo.city;
          this.startInfo[index].area = poi.cityInfo.district;
          this.startInfo[index].address = poi.name;
          break;
        case 'end':
          this.endInfo[index].detailedAddress = poi.district + poi.name;
          this.endInfo[index].longitude = locList[0];
          this.endInfo[index].latitude = locList[1];
          this.endInfo[index].province = poi.cityInfo.province;
          this.endInfo[index].city = poi.cityInfo.city;
          this.endInfo[index].area = poi.cityInfo.district;
          this.endInfo[index].address = poi.name;
          break;
        default:
          break;
      }

      if (this.startInfo[0]?.area && this.endInfo[0]?.area) {
        this.amapService.drivingCompute([...this.startInfo], [...this.endInfo]).subscribe((res: any) => {
          this.totalDistance = res.distance;
          this.totalTime = res.time;
        });
      }
    }
  });
}
  goBack() {
    window.history.go(-1);
  }
  // 初始化信息
  initdata() {
    this.service.request(`${this.service.$api_get_getCompleteVehicleDetail}`, {id:this.id}).subscribe((res) => {
      this.dataR(res);
    })
  }
  asds(i: any) {
    console.log(i)
  }
  // 初始化信息
  dataR (res: any) {
    // this.dataList = res;
    this.sf1data = {
      // shipperAppUserName: res?.shipperAppUserName ,
      enterpriseProjectId: res?.enterpriseProjectId  ,
      enterpriseInfoName: res?.enterpriseInfoName  ,
      externalResourceCode: res?.externalResourceCode  ,
      dispatchId: res?.dispatchId  ,
    }
    if(this.PageStatus === '整车修改') {
      this.sf1data.id = res?.id;
    }
    res?.unLoadingPlaceVOList.forEach((element: any) => {
      if(element.type === 1) {
        const controlId = this.startInfo.length;
        if(this.PageStatus === '整车修改') {
          this.startInfo.push({
            detailedAddress: element.detailedAddress,
            appUserName: element.appUserName,
            contractTelephone: element.contractTelephone,
            latitude: element.latitude,
            longitude: element.longitude,
            province: element.province,
            city: element.city,
            area: element.area,
            type: element.type,
            id: element.id
          })
        } else {
          this.startInfo.push({
            detailedAddress: element.detailedAddress,
            appUserName: element.appUserName,
            contractTelephone: element.contractTelephone,
            latitude: element.latitude,
            longitude: element.longitude,
            province: element.province,
            city: element.city,
            area: element.area,
            type: element.type,
          })
        }
       
        this.validateForm1.addControl(`loadAddress${controlId}`, new FormControl(null, Validators.required));
        this.validateForm1.addControl(`loadName${controlId}`, new FormControl(null, Validators.required));
        this.validateForm1.addControl(`loadPhone${controlId}`, new FormControl(null, Validators.required));
      } else if(element.type === 2) {
        const controlId = this.endInfo.length;
        if(this.PageStatus === '整车修改') { 
          this.endInfo.push({
            detailedAddress: element?.detailedAddress,
            appUserName: element?.appUserName,
            contractTelephone: element?.contractTelephone,
            latitude: element.latitude,
            longitude: element.longitude,
            province: element.province,
            city: element.city,
            area: element.area,
            type: element.type,
            id: element.id
          })
        } else {
          this.endInfo.push({
            detailedAddress: element?.detailedAddress,
            appUserName: element?.appUserName,
            contractTelephone: element?.contractTelephone,
            latitude: element.latitude,
            longitude: element.longitude,
            province: element.province,
            city: element.city,
            area: element.area,
            type: element.type
          })
        }
        this.validateForm1.addControl(`unloadAddress${controlId}`, new FormControl(null, Validators.required));
        this.validateForm1.addControl(`unloadName${controlId}`, new FormControl(null, Validators.required));
        this.validateForm1.addControl(`unloadPhone${controlId}`, new FormControl(null, Validators.required));
      }
    });

    this.sf3data = {
      goodsName: res?.goodsInfoVOList[0]?.goodsName ,
    }
    this.sf4data = {
      weight:  res?.goodsInfoVOList[0]?.weight   ,
      volume:  res?.goodsInfoVOList[0]?.volume   ,
      vehicleDemand:  res?.goodsInfoVOList[0]?.vehicleDemand   ,
      maxCube: res?.goodsInfoVOList[0]?.maxCube?.split(',') ,
      maxWeight: res?.goodsInfoVOList[0]?.maxWeight?.split(',') ,
      number:  res?.goodsInfoVOList[0]?.number   ,
      goodsType:  res?.goodsInfoVOList[0]?.goodsType   ,
      modifyUserId:  res?.goodsInfoVOList[0]?.modifyUserId   ,
      resourceId:  res?.goodsInfoVOList[0]?.resourceId   ,
      rule:  res?.goodsInfoVOList[0]?.rule   ,
      settlementBasis:  res?.goodsInfoVOList[0]?.settlementBasis   ,
    }
    if(res?.loadingTime) {
      this.loadingTime = res?.loadingTime;
    }
    if(res?.unloadingTime) {
      this.unloadingTime = res?.unloadingTime;
    }
    if(this.PageStatus === '整车修改' ) { 
      this.sf4data.id = res?.goodsInfoVOList[0]?.id;
     }
    this.totalFees = res?.shippingInformationVO?.totalFee || '0';
    this.sf5data = {
      goodsValue: res?.goodsValue ,
    }
    console.log(res?.stateReceipt)
    this.sf6data = {
      stateReceipt: res?.stateReceipt,
      receiptType: res?.receiptType ,
      receiptUserId: res?.receiptUserId ,
      remarks: res?.remarks 
    }
    this.sf7data = {
      prePay: res?.shippingInformationVO?.prePay ,
      toPay: res?.shippingInformationVO?.toPay ,
      oilCardPay: res?.shippingInformationVO?.oilCardPay ,
      receiptPay: res?.shippingInformationVO?.receiptPay ,
      // subtotal: res?.shippingInformationVO?.oilCardPay ,
      appendFee: res?.shippingInformationVO?.appendFee ,
      paymentDays: res?.paymentDays ,
    }
  }
  backBillChange() {
    const modalRef = this.modalService.create({
      nzTitle: '选择收回单地址',
      nzContent: PublishAddressListComponent,
      nzWidth: 900,
      nzComponentParams: { spuStatus: '2' },
      nzOnOk: item => {
        const data = item.seleteData;
        if (JSON.stringify(data) === '{}') return;
        this.sf6.setValue('/name4', data.contactName);
        this.sf6.setValue('/name5', data.contactTelephone);
        this.sf6.setValue('/name6', `${data.province}-${data.city}-${data.area}`);
        this.sf6.setValue('/receiptAddress', data.detailedAddress);
      }
    });
  }
}
