<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="tLang('product', '产品编码')" prop="code">
        <el-input v-model="form.code" :disabled="Boolean(props.form.id)" :placeholder="tLang('common', '请输入') + tLang('product', '产品编码')" />
      </el-form-item>
      <el-form-item :label="tLang('product', '针号')" prop="needleNum">
        <el-input v-model="form.needleNum" :placeholder="tLang('common', '请输入') + tLang('product', '针号')" />
      </el-form-item>
      <el-form-item :label="tLang('product', '面线信息')" prop="surfacelineCode">
        <el-input v-model="form.surfacelineCode" :placeholder="tLang('common', '请输入') + tLang('product', '面线信息')" />
      </el-form-item>
      <el-form-item :label="tLang('product', '底线信息')" prop="bottomlineCode">
        <el-input v-model="form.bottomlineCode" :placeholder="tLang('common', '请输入') + tLang('product', '底线信息')" />
      </el-form-item>
      <!-- <el-form-item :label="tLang('product', '梭芯信息')" prop="shuttlecoreId">
        <el-input v-model="form.shuttlecoreId" :placeholder="tLang('common', '请输入') + tLang('product', '梭芯信息')" />
      </el-form-item> -->
      <el-form-item :label="tLang('product', '排序')" prop="sort">
        <el-input v-model.number="form.sort" :placeholder="tLang('common', '请输入') + tLang('product', '排序')" />
      </el-form-item>
      <el-form-item :label="tLang('product', '最小张力')" prop="min">
        <el-input-number v-model="form.min" :min="1" @change="handleChange" />
      </el-form-item>
      <el-form-item :label="tLang('product', '最大张力')" prop="max">
        <el-input-number v-model="form.max" :min="1" @change="handleChange" />
      </el-form-item>
      <el-form-item :label="tLang('product', '备注')" prop="remark">
        <el-input :rows="3" type="textarea" v-model="form.remark" style="width: 520px"
          :placeholder="tLang('common', '请输入') + tLang('product', '备注')" />
      </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button type="primary" @click="submitForm">{{ tLang('common', '确 定') }}</el-button>
        <el-button @click="cancel">{{ tLang('common', '取 消') }}</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: `${proxy.tLang('common', '请输入') + proxy.tLang('product', '产品编码')}`, trigger: "blur" }],
};
const formRef = ref()
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() {
  formRef.value.validate(valid => {
    if (valid) {
      emit("submitForm", props.form);
    }
  }
  );

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

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