<!--
 * @Author: zwq
 * @Date: 2021-11-18 14:16:25
 * @LastEditors: zwq
 * @LastEditTime: 2023-03-03 10:40:35
 * @Description:
-->
<template>
  <el-form
    :model="dataForm"
    :rules="dataRule"
    ref="dataForm"
    @keyup.enter.native="dataFormSubmit()"
    label-width="80px"
  >
    <el-form-item label="产品全名" prop="productAllName">
      <el-input v-model="dataForm.productAllName"clearable placeholder="产品全名"></el-input>
    </el-form-item>
    <el-form-item label="产品名称" prop="productName">
      <el-input v-model="dataForm.productName"clearable placeholder="产品名称"></el-input>
    </el-form-item>
    <el-form-item label="产品编码" prop="productCode">
      <el-input v-model="dataForm.productCode"clearable placeholder="产品编码"></el-input>
    </el-form-item>
    <el-form-item label="产品类别" prop="productType">
      <el-select v-model="dataForm.productType"clearable placeholder="请选择产品类别">
        <el-option
          v-for="item in options"
          :key="item.value"
          :label="item.label"
          :value="item.value"
        >
        </el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="规格型号" prop="specModel">
      <el-input v-model="dataForm.specModel"clearable placeholder="规格型号"></el-input>
    </el-form-item>
    <el-form-item label="单位名称" prop="unitName">
      <el-input v-model="dataForm.unitName"clearable placeholder="单位名称"></el-input>
    </el-form-item>
    <el-form-item label="备注" prop="remark">
      <el-input v-model="dataForm.remark"clearable placeholder="备注"></el-input>
    </el-form-item>
  </el-form>
</template>

<script>
import basicAdd from "@/mixins/basic-add";
export default {
  mixins: [basicAdd],
  data() {
    return {
      urlOptions: {
        submitURL: "/code/mtProduct/",
        infoURL: "/code/mtProduct",
      },
      isGetCode: true,
      dataForm: {
        id: "",
        productAllName: "",
        productCode: "",
        productName: "",
        productType: "",
        specModel: "",
        unitName: "",
        remark: "",
      },
      options: [
        {
          value: "1",
          label: "成品",
        },
        {
          value: "2",
          label: "半成品",
        },
        {
          value: "3",
          label: "原材料",
        },
      ],
      dataRule: {
        productAllName: [{ required: true, message: "产品全名不能为空", trigger: "blur" }],
      },
    };
  },
  methods: {
    getCode() {
      this.$http
        .get("/code/mtProduct/getCode")
        .then(({ data: res }) => {
          console.log(res)
          this.dataForm.productCode = res;
        })
        .catch(() => {});
    },
  },
};
</script>
