<!--
 * @Author: zwq
 * @Date: 2023-01-04 10:29:40
 * @LastEditors: zhp
 * @LastEditTime: 2023-07-06 16:26:20
 * @Description: 
-->
<template>
  <el-form :model="dataForm" ref="dataForm" @keyup.enter.native="dataFormSubmitHandle()" label-width="120px">
    <el-form-item :label="$t('quality.transferTime')" 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-item prop="inspectionStage" :label="$t('quality.inspectionStage')">
      <el-select v-model="dataForm.inspectionStage" :placeholder="$t('quality.inspectionStage')">
        <el-option v-for="item in inspectionStageList" :key="item.id" :label="item.name" :value="item.id">
        </el-option>
      </el-select>
    </el-form-item>
    <el-form-item prop="inspectionType" :label="$t('quality.inspectionStage')">
      <el-select v-model="dataForm.inspectionType" :placeholder="$t('quality.inspectionStage')">
        <el-option v-for="item in inspectionTypeList" :key="item.id" :label="item.name" :value="item.id">
        </el-option>
      </el-select>
    </el-form-item>
    <el-form-item prop="supplierId" :label="$t('quality.supplierName')">
      <el-select v-model="dataForm.supplierId" :placeholder="$t('quality.supplierName')">
        <el-option v-for="item in supplierList" :key="item.id" :label="item.name" :value="item.id">
        </el-option>
      </el-select>
    </el-form-item>
    <el-form-item prop="productId" :label="$t('quality.productName')">
      <el-select v-model="dataForm.productId" :placeholder="$t('quality.productName')">
        <el-option v-for="item in productList" :key="item.id" :label="item.name" :value="item.id">
        </el-option>
      </el-select>
    </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",
      // },
      inspectionStageList: [
        {
          id: 0,
          name: '进货检验 ',
        },
        {
          id: 1,
          name: '成品检验',
        },
        {
          id: 2,
          name: '出货检验',
        }
      ],
      inspectionTypeList: [
        {
          id: 0,
          name: '监控',
        },
        {
          id: 1,
          name: '电芯来料检验',
        },
        {
          id: 2,
          name: 'IQC抽检',
        },
        {
          id: 3,
          name: 'IQC抽检2',
        },
        {
          id: 4,
          name: '原料抽检',
        },
        {
          id: 5,
          name: '进货外观检验',
        },
        {
          id: 6,
          name: '库内原料检验',
        },
        {
          id: 7,
          name: ' 来料检验',
        },
        {
          id: 8,
          name: '胶片',
        },
        {
          id: 9,
          name: ' 抽检',
        },
        {
          id: 10,
          name: '巡检 ',
        },
        {
          id: 11,
          name: '首检',
        },
        {
          id: 12,
          name: '末检',
        },
        {
          id: 13,
          name: '实时监测',
        },
        {
          id: 14,
          name: 'FQC抽检',
        },
        {
          id: 16,
          name: 'OQC抽检',
        }
      ],
      urlOptions: {
        getSupplierList: "/supplier/qmsSupplier/page",
        getProductList: "/basic/qmsProduct/page",
      },
      productList: [],
      supplierList:[],
      listQuery: {
        limit: 999,
        page:1
      },
      visible: false,
      customerTypeList:{},
      dataForm: {
        timeSlot:null,
        inspectionStage:null,
        inspectionTypeId: null,
        productId: null,
        supplierId: null,
      }
    };
  },
  mounted () {
    this.getData()
  },
  computed: {
    // dataRule() {
    //   return {
    //     paramCode: [
    //       {
    //         required: true,
    //         message: this.$t("validate.required"),
    //         trigger: "blur",
    //       },
    //     ],
    //     paramValue: [
    //       {
    //         required: true,
    //         message: this.$t("validate.required"),
    //         trigger: "blur",
    //       },
    //     ],
    //   };
    // },
  },
  methods: {
    getData() {
      this.$http.get(this.urlOptions.getSupplierList, {
        params:this.listQuery
      })
        .then(({ data: res }) => {
          if (res.code === 0) {
            console.log(res);
            this.supplierList = res.data.list
          }
        })
        .catch(() => {
        })
      this.$http.get(this.urlOptions.getProductList, {
        params: this.listQuery
      })
        .then(({ data: res }) => {
          if (res.code === 0) {
            console.log(res);
            this.productList = res.data.list
          }
        })
        .catch(() => {
        })
    },
    // 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.getCustomerPageListURL, {
    //       params: this.listQuery,
    //     })
    //     .then(({ data: res }) => {
    //       this.dataListLoading = false;
    //       if (res.code !== 0) {
    //         this.customerTypeList = res.data
    //       }
    //     })
    // },
    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>
