<!--
 * @Author: zwq
 * @Date: 2023-01-04 10:29:40
 * @LastEditors: zhp
 * @LastEditTime: 2023-05-10 16:18:12
 * @Description: 
-->
<template>
  <el-form :model="dataForm" ref="dataForm" @keyup.enter.native="dataFormSubmitHandle()" label-width="120px">
    <el-form-item prop="gageCode" :label="$t('gage.gageName')">
      <el-input v-model="dataForm.gageCode" :placeholder="$t('gage.gageName')"></el-input>
    </el-form-item>
    <el-form-item prop="gageName" :label="$t('gage.gageName')">
      <el-input v-model="dataForm.gageName" :placeholder="$t('gage.gageName')"></el-input>
    </el-form-item>
    <el-form-item prop="measurToolEvent" :label="$t('gage.measurToolEvent')">
      <el-select v-model="dataForm.measurToolEvent" :placeholder="$t('gage.measurToolEvent')">
        <el-option v-for="item in eventList" :key="item.id" :label="item.name" :value="item.id">
        </el-option>
      </el-select>
    </el-form-item>
    <el-form-item prop="gageTypeId" :label="$t('gage.gageTypeName')">
      <el-select v-model="dataForm.gageTypeId" :placeholder="$t('gage.gageTypeName')">
        <el-option v-for="item in gageTypeList" :key="item.id" :label="item.name" :value="item.id">
        </el-option>
      </el-select>
    </el-form-item>
    <el-form-item prop="process" :label="$t('gage.process')">
      <el-select v-model="dataForm.process" :placeholder="$t('gage.process')">
        <el-option v-for="item in processList" :key="item.id" :label="item.name" :value="item.id">
        </el-option>
      </el-select>
    </el-form-item>
    <el-form-item :label="$t('time')" prop="timeSlot">
      <el-date-picker v-model="dataForm.timeSlot" size="small" type="datetimerange" format='yyyy-MM-dd HH:mm:ss'
        valueFormat='yyyy-MM-ddTHH:mm:ss' :start-placeholder="$t('gage.startTime')"
        :end-placeholder="$t('gage.endTime')" :range-separator="$t('gage.to')" clearable />
    </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: "/sys/params/",
      //   infoURL: "/sys/params",
      // },
      urlOptions: {
        getCustomerPageListURL: "/quality/qmsTransferScheme/page",
        getGageTypeList: '/gage/qmsGageType/page'
      },
      visible: false,
      customerTypeList:{},
      dataForm: {
        gageName: null,
        gageCode: null,
        measurToolEvent: null,
        process: null,
        timeSlot:null,
      },
      gageTypeList:[],
      eventList: [
        {
          id: 0,
          name: '领用'
        },
        {
          id: 1,
          name: '归还'
        },
        {
          id: 2,
          name: '量具报废'
        },
        {
          id: 3,
          name: '量具维修'
        },
        {
          id: 4,
          name: '量具购买'
        },
      ],
      processList: [
        {
          id: 0,
          name: '未审核'
        },
        {
          id: 1,
          name: '不同意'
        },
        {
          id: 2,
          name: '同意'
        }
      ]
    };
  },
  computed: {
    // dataRule() {
    //   return {
    //     paramCode: [
    //       {
    //         required: true,
    //         message: this.$t("validate.required"),
    //         trigger: "blur",
    //       },
    //     ],
    //     paramValue: [
    //       {
    //         required: true,
    //         message: this.$t("validate.required"),
    //         trigger: "blur",
    //       },
    //     ],
    //   };
    // },
  },
  methods: {
    // init(id) {
    //   this.dataForm.id = id || "";
    //   this.visible = true;
    //   this.$nextTick(() => {
    //     this.$refs["dataForm"].resetFields();
    //     if (this.dataForm.id) {
    //       this.getInfo();
    //     }
    //   });
    // },
    // 获取信息
    // getInfo() {
    //   this.$http
    //     .get(`/sys/params/${this.dataForm.id}`)
    //     .then(({ data: res }) => {
    //       if (res.code !== 0) {
    //         return this.$message.error(res.msg);
    //       }
    //       this.dataForm = {
    //         ...this.dataForm,
    //         ...res.data,
    //       };
    //     })
    //     .catch(() => {});
    // },
    // 表单提交
    getDict() {
      this.$http
        .get(this.urlOptions.getGageTypeList, this.listQuery)
        .then(({ data: res }) => {
          if (res.code === 0) {
            console.log(res.data);
            this.gageTypeList = res.data.list
          }
        })
        .catch(() => {
        })
    },
    handleConditionSearch() {
      this.$emit("successSubmit", this.dataForm);
    },
    // dataFormSubmitHandle: debounce(
    //   function () {
    //     // console.log(1111);
    //     // this.visible = false;
    //     this.$emit("successSubmit", this.dataForm.key);
    //     // this.$refs["dataForm"].validate((valid) => {
    //     //   if (!valid) {
    //     //     return false;
    //     //   }
    //     //   this.$http[!this.dataForm.id ? "post" : "put"](
    //     //     "/sys/params",
    //     //     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: () => {

    //     //         },
    //     //       });
    //     //     })
    //     //     .catch(() => {});
    //     // });
    //   },
    //   1000,
    //   { leading: true, trailing: false }
    // ),
  },
};
</script>
