<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="productionCode">
        <el-input v-model="props.form.productionCode" :placeholder="tLang('common','请输入') + tLang('produce','产品编码')" />
      </el-form-item>
      <el-form-item label="设备编码" prop="deviceCode">
        <el-input v-model="props.form.deviceCode" :placeholder="tLang('common','请输入') + tLang('produce','设备编码')" />
      </el-form-item>
      <el-form-item label="员工编号" prop="persionCode">
        <el-input v-model="props.form.persionCode" :placeholder="tLang('common','请输入') + tLang('produce','员工编号')" />
      </el-form-item>
      <el-form-item label="目标产量" prop="planOutput">
        <el-input v-model="props.form.planOutput" :placeholder="tLang('common','请输入') + tLang('produce','目标产量')" />
      </el-form-item>
      <el-form-item label="当前产量" prop="output">
        <el-input v-model="props.form.output" :placeholder="tLang('common','请输入') + tLang('produce','当前产量')" />
      </el-form-item>
      <el-form-item label="开始时间" prop="starttime">
        <el-date-picker clearable v-model="props.form.starttime" type="date" format="YYYY-MM-DD hh:mm:ss"
        value-format="YYYY-MM-DD hh:mm:ss" :placeholder="tLang('common','请选择') + tLang('produce','开始时间')">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="结束时间" prop="endtime">
        <el-date-picker clearable v-model="props.form.endtime" type="date" format="YYYY-MM-DD hh:mm:ss"
        value-format="YYYY-MM-DD hh:mm:ss" :placeholder="tLang('common','请选择') + tLang('produce','结束时间')">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="批次" prop="batch">
        <el-input v-model="props.form.batch" :placeholder="tLang('common','请输入') + tLang('produce','批次')" />
      </el-form-item>
      <el-form-item label="备注" prop="remark">
        <el-input v-model="props.form.remark" :placeholder="tLang('common','请输入') + tLang('produce','备注')" />
      </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 { proxy } = getCurrentInstance();
const emit = defineEmits();
const props = defineProps({
  modelValue: [String, Object, Array],
  title: String,
  form: {
    type: Object,
    default: () => ({}),
  },
});
const formRef = ref(null);
const baseUrl = import.meta.env.VITE_APP_BASE_API;
const rules = {
  productionCode: [
    { required: true, message: `${proxy.tLang('produce','产品编码')} ` + proxy.tLang('validate','不能为空'), trigger: "blur" }
  ],
  deviceCode: [
    { required: true, message: `${proxy.tLang('produce','设备编码')} ` + proxy.tLang('validate','不能为空'), trigger: "blur" }
  ],
  persionCode: [
    { required: true, message: `${proxy.tLang('produce','员工编号')} ` + proxy.tLang('validate','不能为空'), trigger: "blur" }
  ],
}
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>
