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-sale-statistics',
  templateUrl: './sale-statistics.component.html',
})
export class PartnerSaleStatisticsComponent implements OnInit {
  url = `/user`;
  schema!: SFSchema;
  @ViewChild('st') private readonly st!: STComponent;
  @ViewChild('sf') private readonly sf!: SFComponent;
  columns: STColumn[] = [];
  ui!: SFUISchema;
  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',
          ui: {
            placeholder: '请输入'
          },
        },
      }
    };
    this.ui = { '*': { spanLabelFixed: 120, grid: { span: 8, gutter: 8 } } };
  }
  /**
 * 初始化数据列表
 */
  initST() {
    this.columns = [
      { title: '联系人', index: 'carNo', className: 'text-center' },
      { title: '手机号', render: 'carModelLabel', className: 'text-center' },
      { title: '添加时间', index: 'carNo', className: 'text-center' },
      { title: '本月新增客户', render: 'approvalStatus', className: 'text-center', sort: true },
      { title: '客户总数', render: 'approvalStatus', className: 'text-center', sort: true },
      { title: '本月新增合伙人', render: 'approvalStatus1', className: 'text-center', sort: true },
      { title: '合伙人总数', render: 'approvalStatus1', className: 'text-center', sort: true },
      { title: '本月已结算金额（元）', render: 'approvalStatus2', className: 'text-right', sort: true },
      { title: '累计已结算金额（元）', render: 'approvalStatus3', className: 'text-right', sort: true },
    ];
  }
  export() {

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