<template>
  <a-modal
    :open="visible"
    title="查看详情"
    cancelText="取消"
    okText="确定"
    @ok="submit"
    @cancel="cancel"
  >
    <a-form
       ref="formRef"
      :model="formState"
      :rules="formRules"
      :label-col="labelCol"
      :wrapper-col="wrapperCol"
    >
      <a-form-item ref="simId" label="物料编号" name="simId">
        <a-input v-model:value="formState.simId" />
      </a-form-item>
      <a-form-item ref="simName" label="物料名称" name="simName" >
        <a-input v-model:value="formState.simName" />
      </a-form-item>
      <a-form-item ref="simCategoryId" label="物料种类编号" name="simCategoryId">
        <a-input v-model:value="formState.simCategoryId" />
      </a-form-item>
      <a-form-item ref="simCategory" label="物料种类" name="simCategory">
        <a-input v-model:value="formState.simCategory" />
      </a-form-item>
    </a-form>
  </a-modal>
</template>
<script>
import { defineComponent, reactive, ref, watch } from "vue";
export default defineComponent({
  props: {
    visible: {
      type: Boolean,
    },
    record: {
      type: Object,
    }
  },
  emit: ["close"],
  setup(props, context) {

    const formRef = ref();

    const formState = reactive({});

    watch(props, (props) => {
        formState.simId = props.record.simId;
        formState.simName = props.record.simName;
        formState.simCategoryId = props.record.simCategoryId;
        formState.simCategory = props.record.simCategory;
    })

    const formRules = {};

    const submit = (e) => {
      formRef.value.resetFields();
      context.emit("close", false);
    };

    const cancel = (e) => {
      formRef.value.resetFields();
      context.emit("close", false);
    };

    return {

      submit,
      cancel,
      formRef,
      formState,
      formRules,

      labelCol: { span: 6 },
      wrapperCol: { span: 18 },
    };
  },
});
</script>
