<template>
  <el-dialog v-model="props.modelValue" :title="props.title" @close="close" width="800">
    <el-form ref="formRef" :inline="true" :model="props.form" :rules="rules" class="demo-form-inline"
      label-width="100px">
      <el-form-item label="产品条码" prop="code">
          <el-input v-model="form.code" placeholder="请输入产品条码" />
        </el-form-item>
        <el-form-item label="针号" prop="needleNum">
          <el-input v-model="form.needleNum" placeholder="请输入针号" />
        </el-form-item>
        <el-form-item label="面线信息" prop="surfacelineId">
          <el-input v-model="form.surfacelineId" placeholder="请输入面线信息" />
        </el-form-item>
        <el-form-item label="底线信息" prop="bottomlineId">
          <el-input v-model="form.bottomlineId" placeholder="请输入底线信息" />
        </el-form-item>
        <el-form-item label="梭芯信息" prop="shuttlecoreId">
          <el-input v-model="form.shuttlecoreId" placeholder="请输入梭芯信息" />
        </el-form-item>
        <el-form-item label="排序" prop="sort">
          <el-input v-model="form.sort" placeholder="请输入排序" />
        </el-form-item>
        <el-form-item label="最小值" prop="min">
          <el-input v-model="form.min" placeholder="请输入最小值" />
        </el-form-item>
        <el-form-item label="最大值" prop="max">
          <el-input v-model="form.max" placeholder="请输入最大值" />
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" placeholder="请输入备注" />
        </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script setup>
import { ref } from "vue";
const emit = defineEmits();
const proxy = getCurrentInstance();
const rules = {
  code: [{ required: true, message: "请输入产品编码", trigger: "blur" }],
};
const props = defineProps({
  modelValue: [String, Object, Array],
  title: String,
  form: {
    type: Object,
    default: () => ({}),
  },
});
const baseUrl = import.meta.env.VITE_APP_BASE_API;


function close() {
  emit("update:modelValue", false);
}
function submitForm() {
  proxy.refs["formRef"].validate(valid => {
    if (valid) {
      emit("submitForm", props.form);
    }
  }
  );

}
function cancel() {
  emit("update:form", {});
  close();
}
</script>

<style lang="scss" scoped></style>
