/*
 * @Author: your name
 * @Date: 2021-12-03 11:10:14
 * @LastEditTime: 2021-12-13 15:24:41
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \tms-obc-web\src\app\routes\supply-management\components\bulk-detail\bulk-detail.component.ts
 */
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { STColumn } from '@delon/abc/st';
import { _HttpClient } from '@delon/theme';
import { NzMessageService } from 'ng-zorro-antd/message';
import { NzModalService } from 'ng-zorro-antd/modal';
import { SupplyManagementAddDriversComponent } from '../add-drivers/add-drivers.component';
import { SupplyManagementService } from '../../services/supply-management.service';

@Component({
  selector: 'app-supply-management-bulk-detail',
  templateUrl: './bulk-detail.component.html',
  styleUrls: ['./bulk-detail.component.less']
})
export class SupplyManagementBulkDetailComponent implements OnInit {
  isVisibleView = false
  id = this.route.snapshot.params.id;
  i: any;
  logColumns: STColumn[] = [
    { title: '内容', index: 'theme' },
    { title: '操作人', index: 'operationUserPhone' },
    { title: '操作时间', index: ' createTime' },
  ];
  columnsFloatView: STColumn[] = [
    { title: '司机姓名', index: 'theme' },
    { title: '手机号', index: 'operationUserPhone' },
    { title: '车队长', index: ' createTime' },
    { title: '车牌号', index: ' createTime' },
  ];
  driverColums: STColumn[] = [
    { title: '司机姓名', index: 'theme' },
    { title: '手机号', index: 'operationUserPhone' },
    { title: '车牌号', index: ' createTime' },
    { title: '承运次数', index: 'operationUserPhone' },
    { title: '承运数量', index: ' createTime' },
    {
      title: '操作',
      fixed: 'right',
      width: '200px',
      className: 'text-center',
      buttons: [
        {
          text: '移除',
          click: (_record) => this.delDiver(_record),
        },
      ],
    },
  ];
  dataList: any;
  constructor(
    private route: ActivatedRoute,
    private msgSrv: NzMessageService,
    private service: SupplyManagementService,
    private modal: NzModalService,
    private router: Router,private ar: ActivatedRoute
  ) {

  }

  ngOnInit(): void {
    this.getDetailList();
  }
  // 获取录单员 
  getDetailList() {
    const params = {
      id: this.id
    };
   this.service.request(`${this.service.$api_get_getBulkDetail}`, params).subscribe((res) => {
      console.log(res)
      this.dataList = res
    })
  }
  /**
   * 移除司机
   */
  delDiver(item: any) {
    const { id } = item;
    this.modal.confirm({
      nzTitle: '<i>删除确认</i>',
      nzContent: `请仔细核对,避免误操作！<br>是否删除？</br>`,
      nzOnOk: () => {
        // this.service.http.post(this.service.$api_del_driver, { id }).subscribe((res) => {
        //   if (res) {
        //     this.service.msgSrv.success('数据删除成功！');
        //     // this.st1.reload();
        //   } else {
        //     this.service.msgSrv.error('删除失败！');
        //   }
        // });
      },
    });
  }

  /**
 * 指派熟车
 */
  assignedCar() {
    const modalRef = this.modal.create({
      nzTitle: '指派熟车',
      nzWidth: '90%',
      nzContent: SupplyManagementAddDriversComponent,
      nzComponentParams: {
        i: this.i,
      },
      nzFooter: null,
    });
  }

  goBack() {
    window.history.go(-1);
  }
    // 修改货源 
    modification() {
      this.router.navigate(['/supply-management/bulk-amend', this.id], {
        queryParams: {
          sta: 3
        },
      })
    }
    //  再下一单
    nextOrder() {
      this.router.navigate(['/supply-management/bulk-amend', this.id], {
        queryParams: {
          sta: 4
        },
      })
    }

    handleCancel() {
      this.isVisibleView = false
    }
    handleOK() {

    }
    NowAssign() {
      this.isVisibleView = true
    }
}
