import { Component, OnInit } from '@angular/core';
import { BsModalService } from 'ngx-bootstrap/modal';
import { FramePageComponent } from '../../../frame/core/page/frame.page';

@Component({
  selector: 'app-clean-data',
  templateUrl: './clean-data.component.html',
  styleUrls: ['./clean-data.component.scss']
})
export class CleanDataComponent extends FramePageComponent implements OnInit {

   clean_password: any;
   flagArray = [];
   flag:any;

  constructor(private modalService: BsModalService) {
    super(modalService);
   }

  ngOnInit(): void {
    this.flagArray.push({value: '', name: '请选择'});
    this.flagArray.push({value: '1', name: '报考之前'});
    this.flagArray.push({value: '2', name: '评分之前'});
  }

  cleanData() {
    if(!this.clean_password) {
      this.MsgService.errorAlert('请填写清理密码，如不知道，请联系研发人员！');
      return;
    }
    this.MsgService.confirmAlert('确定要清除考生数据和合分数据吗？一旦清除，不可还原，请谨慎操作！', () => {
      this.AjaxService.request('exam/ops/data/clean/all.htm', {clean_password : this.clean_password, flag: this.flag}, () => {
        this.MsgService.successAlert('数据清理成功！');
      });
    })
  }

}
