import { Component, OnInit, ViewChild } from '@angular/core';
import { Router } from '@angular/router';
import { STColumn, STComponent, STRequestOptions } from '@delon/abc/st';
import { SFSchema } from '@delon/form';
import { ModalHelper, _HttpClient } from '@delon/theme';
import { NzModalRef } from 'ng-zorro-antd/modal';
import { ReportingService } from '../../services/reporting.service';

@Component({
  selector: 'app-datatable-fund-info',
  templateUrl: './fund-info.component.html',
})
export class DatatableReportingFundInfoComponent implements OnInit {
  url = `/user`;
  searchSchema!: SFSchema;
  @ViewChild('st') private readonly st!: STComponent;
  columns: STColumn[] = [];
  record: any = {}


  get reqParams() {
    return { capitalCode: this?.record?.serialNumberCode };
  }

  beforeReq(requestOptions: STRequestOptions) {
    delete requestOptions?.body?.pageSize;
    delete requestOptions?.body?.pageIndex;
    return requestOptions;
  }
  constructor(public service: ReportingService, private modalRef: NzModalRef, public router: Router) {

  }

  ngOnInit(): void {
    this.initST();
  }

  /**
 * 初始化数据列表
 */
  initST() {
    this.columns = [
      { title: '序号', type: 'no', className: 'text-center', width: '10%', },
      { title: '监管平台字段', index: 'thirdPartyFieldName', className: 'text-center', width: '15%', },
      { title: '系统字段', index: 'checkFieldName', className: 'text-center', width: '15%', },
      { title: '归属模块', index: 'orderStatus', className: 'text-center', width: '15%', },
      {
        title: '是否必填',
        index: 'orderStatus',
        className: 'text-center',
        width: '10%',
        type: 'enum',
        enum: {
          0: '否',
          1: '是',
        },
      },
      { title: '上传值', index: 'fieldValue', className: 'text-center', width: '15%', },
      {
        title: '本地校验',
        render: 'checkStatus',
        className: 'text-center',
        // type: 'enum',
        // enum: {
        //   '0': '校验中',
        //   '1': '通过',
        //   '2': '不通过'
        // },
        width: '10%',
      },
      { title: '错误内容', index: 'remark', className: 'text-center', width: '20%', },
    ]
  }


  add(): void {
    // this.modal
    //   .createStatic(FormEditComponent, { i: { id: 0 } })
    //   .subscribe(() => this.st.reload());
  }

  selectTab(e: any) {

  }

  update() {
    if (this.record?.billType === '1') {
      window.open(location.origin + `/#/order-management/vehicle-detailChange/${this.record?.id}`)

    } else if (this.record.billType === '2') {
      window.open(location.origin + `/#/order-management/bulk-detailChange/${this.record?.id}`);
    }


  }
  close(): void {
    this.modalRef.destroy();
  }

  filterCheckStatus(status: number) {
    switch (status) {
      case 0:
        return '校验中';
      case 1:
        return '通过';
      case 2:
        return '不通过';
      default:
        return '';

    }
  }


}
