<template>
  <el-form ref="formRef" :model="modelValue" :rules="rules" label-width="100px">
    <el-form-item label="检验项名称" prop="checkName">
      <el-input v-model="modelValue.checkName" />
    </el-form-item>
    <el-form-item label="检验内容" prop="checkContent">
      <el-input v-model="modelValue.checkContent" type="textarea" />
    </el-form-item>
    <el-form-item label="结果" prop="result">
      <el-select v-model="modelValue.result">
        <el-option label="合格" value="1" />
        <el-option label="不合格" value="2" />
      </el-select>
    </el-form-item>
    <el-form-item label="流转卡号" prop="seqNoList">
      <el-select v-model="modelValue.seqNoList" multiple :disabled="true">
        <el-option
          v-for="(item, index) in SeqArray"
          :key="index"
          :label="item"
          :value="item"
        />
      </el-select>
    </el-form-item>
    <el-form-item label="备注" prop="remark">
      <el-input v-model="modelValue.remark" type="textarea" />
    </el-form-item>
    <!--    <el-form-item label="上传附件">-->
    <!--      <FilesUpload v-model:src="modelValue.filePath" ref="uploadRef" />-->
    <!--    </el-form-item>-->
  </el-form>
</template>

<script setup>
import { useProcessStore } from "@/store/modules/processView";

const rules = reactive({
  checkContent: [{ required: true, trigger: "blur" }],
  checkName: [{ required: true, trigger: "blur" }],
  result: [{ required: true, trigger: "blur" }],
  seqNoList: [{ required: true, trigger: "blur" }],
});
const processStore = useProcessStore();
const uploadRef = ref(null);
const setFileList = (value) => {
  uploadRef.value.resetFileList(value);
};

const formRef = ref(null);
const props = defineProps({
  modelValue: {
    type: [Object],
  },
});
const SeqArray = ref([]);
const emits = defineEmits(["update:modelValue", "submit"]);
const getSeq = async () => {
  // const { data } = await getSeqData(processStore.scanInfo.id);
  SeqArray.value = [processStore.useSeqNo];
  emits("update:modelValue", {
    ...props.modelValue.value,
    seqNoList: SeqArray.value,
  });
};
onMounted(() => {
  getSeq();
});
const fileName = inject("fileName");
watch(
  () => props.modelValue.filePath,
  (value) => {
    if (value) {
      fileName.value = uploadRef.value.fileList[0].name;
    } else {
      fileName.value = "";
    }
  },
  { deep: true }
);
defineExpose({
  setFileList,
  formRef,
  fileName,
});
</script>

<style lang="scss" scoped>
.body {
  display: flex;
  width: 100%;
  height: 100%;
}

.btns {
  width: 100%;
  height: 60px;
  display: flex;
  align-items: center;
  padding: 0 20%;
  justify-content: space-evenly;
}
</style>
