<!--
 * @Author: zhp
 * @Date: 2023-02-14 15:02:26
 * @LastEditTime: 2023-07-14 15:34:18
 * @LastEditors: DY
 * @Description: 
-->
<template>
  <el-form :model="dataForm" ref="dataForm" @keyup.enter.native="dataFormSubmitHandle()" label-width="150px">
    <el-form-item prop="evaluationType" label="评估类型">
      <!-- <el-input v-model="dataForm.evaluationType" :placeholder="$t('laboratory.title')">
      </el-input> -->
      <el-tag :type="dataForm.evaluationType === 0 ? 'info' : dataForm.evaluationType === 1 ? 'success' : ''" effect="dark">{{ dataForm.evaluationType === 0 ? '年度' : dataForm.evaluationType === 1 ? '季度' : '月度' }}</el-tag>
    </el-form-item>
    <el-form-item prop="estimatedNextStartTime" label="评估时间">
      <el-date-picker v-model="dataForm.estimatedNextStartTime" type="datetime" placeholder="评估时间"
        format='yyyy-MM-dd HH:mm:ss' valueFormat='yyyy-MM-ddTHH:mm:ss'>
      </el-date-picker>
    </el-form-item>
  </el-form>
</template>

<script>
import debounce from "lodash/debounce";
// import basicAdd from "@/mixins/basic-add";
export default {
  // mixins: [basicAdd],
  data() {
    return {
      urlOptions: {
        submitURL: "/supplier/qmsEvaluationPlan"
        // infoURL: "/laboratory/qmsLaboratoryTrainExperience/{ id }",
      },
      gageList: [],
      userList: [],
      customerList:[],
      gageTypeList:[],
      departmentList: [],
      visible: false,
      dataForm: {
        id: null,
        estimatedNextStartTime: '',
        evaluationType: ''
      },
    };
  },
  computed: {
    dataRule() {
      return {
      };
    },
  },
  // mounted () {
  //   this.getData();
  // },
  methods: {
    init(data) {
      this.visible = true
      console.log('jpuz cjuu', data)
      this.dataForm.id = data.id
      this.dataForm.evaluationType = data.evaluationType
      // this.dataForm.id = data.id ? data.id : ''
      // this.dataForm.laboratoryTesterId = data.laboratoryTesterId ? data.laboratoryTesterId : ''
      // // console.log(11111)
      // // this.dataForm.dictTypeId = dictTypeId || "";
      // this.visible = true
      // this.$nextTick(() => {
      //   this.$refs["dataForm"].resetFields();
      //   if (this.dataForm.id) {
      //     this.getInfo()
      //   } else {
      //     // this.getCode()
      //   }
      // });
    },
    // 获取信息
    // getInfo() {
    //   this.$http
    //     .get(`/laboratory/qmsLaboratoryTrainExperience/${this.dataForm.id}`)
    //     .then(({ data: res }) => {
    //       if (res.code !== 0) {
    //         return this.$message.error(res.msg);
    //       }
    //       this.dataForm = {
    //         ...this.dataForm,
    //         ...res.data,
    //       };
    //     })
    //     .catch(() => { })
    // },
    // 表单提交
    dataFormSubmit: debounce(
      function () {
        console.log('nihc ', this.dataForm)
        this.$refs["dataForm"].validate((valid) => {
          if (!valid) {
            return false;
          }
          this.$http['put'](this.urlOptions.submitURL, this.dataForm)
            .then(({ data: res }) => {
              if (res.code !== 0) {
                return this.$message.error(res.msg);
              }
              this.$message({
                message: this.$t("prompt.success"),
                type: "success",
                duration: 500,
                onClose: () => {
                  console.log(1111);
                  this.visible = false;
                  this.$emit("refreshDataList");
                },
              });
            })
            .catch(() => {});
        });
      },
      1000,
      { leading: true, trailing: false }
    ),
  },
};
</script>
