import { Component, OnInit, ViewChild } from '@angular/core';
import { STColumn, STComponent } from '@delon/abc/st';
import { SFComponent, SFSchema, SFUISchema } from '@delon/form';
import { ModalHelper, _HttpClient } from '@delon/theme';
import { BussinessStatisticsService } from '../../services/bussiness-statistics.service';

@Component({
  selector: 'app-partner-partner-statistics',
  templateUrl: './partner-statistics.component.html',
})
export class PartnerPartnerStatisticsComponent implements OnInit {
  url = `/user`;
  schema!: SFSchema;
  ui!: SFUISchema;
  @ViewChild('st') private readonly st!: STComponent;
  @ViewChild('sf') private readonly sf!: SFComponent;
  columns: STColumn[] = [];
  isLoading: boolean = false;

  constructor(public service: BussinessStatisticsService) { }
  /**
   * 查询参数
   */
  get reqParams() {
    const params = { ...this.sf?.value };
    return params
  }

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

  initSF() {
    this.schema = {
      properties: {
        abnormalCause: {
          title: '合伙人名称',
          type: 'string',
          ui: {
            placeholder: '请输入',
          },
        },
        abnormalCause1: {
          title: '类型',
          type: 'string',
          default: '',
          enum: [
            {
              label: '全部',
              value: ''
            },
            {
              label: '个人',
              value: '1'
            },
            {
              label: '企业',
              value: '2'
            }
          ],
          ui: {
            widget: 'select'
          },
        },
      }
    }
    this.ui = { '*': { spanLabelFixed: 120, grid: { span: 8, gutter: 4 } } };
  }
  /**
 * 初始化数据列表
 */
  initST() {
    this.columns = [
      { title: '合伙人名称', index: 'carNo', className: 'text-center', width: 150 },
      { title: '类型', render: 'carModelLabel', className: 'text-center', width: 150 },
      { title: '注册时间', index: 'carNo', className: 'text-center', width: 150 },
      { title: '本月新增客户', render: 'approvalStatus0', className: 'text-center', sort: true, width: 150 },
      { title: '客户总数', render: 'approvalStatus', className: 'text-center', sort: true, width: 150 },
      { title: '本月已结算金额（元）', render: 'approvalStatus1', className: 'text-right', sort: true, width: 180 },
      { title: '累计已结算金额（元）', render: 'approvalStatus2', className: 'text-right', sort: true, width: 180 },
      { title: '本月预估收益（元）', render: 'approvalStatus3', className: 'text-right', sort: true, width: 180 },
      { title: '累计收益（元）', render: 'approvalStatus4', className: 'text-right', sort: true, width: 180 },
    ];
  }

  resetSF() {
    this.sf.reset();
    this.isLoading = true
  }

  export() {

  }



}
