Step UX-1:通用选择器
This commit is contained in:
@@ -2,14 +2,7 @@
|
||||
<el-dialog :title="isEdit ? '编辑 AE' : '新增 AE'" v-model="visible" width="600px" @close="onClose">
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="120px">
|
||||
<el-form-item label="受试者" prop="subject_id">
|
||||
<el-select v-model="form.subject_id" placeholder="可留空" clearable filterable>
|
||||
<el-option
|
||||
v-for="s in subjects || []"
|
||||
:key="s.id"
|
||||
:label="s.subject_no || s.id"
|
||||
:value="s.id"
|
||||
/>
|
||||
</el-select>
|
||||
<SubjectSelect v-model="form.subject_id" :study-id="study.currentStudy?.id || null" placeholder="可留空" />
|
||||
</el-form-item>
|
||||
<el-form-item label="事件描述" prop="term">
|
||||
<el-input v-model="form.term" />
|
||||
@@ -45,14 +38,13 @@ import type { FormInstance, FormRules } from "element-plus";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { createAe, updateAe } from "../api/aes";
|
||||
import { useStudyStore } from "../store/study";
|
||||
import SubjectSelect from "./selectors/SubjectSelect.vue";
|
||||
|
||||
interface Props {
|
||||
const props = defineProps<{
|
||||
modelValue: boolean;
|
||||
ae?: Record<string, any>;
|
||||
subjects?: any[];
|
||||
}
|
||||
|
||||
const props = defineProps<Props>();
|
||||
}>();
|
||||
const emit = defineEmits(["update:modelValue", "success"]);
|
||||
|
||||
const visible = computed({
|
||||
@@ -125,16 +117,11 @@ const onSubmit = async () => {
|
||||
submitting.value = true;
|
||||
try {
|
||||
const payload: Record<string, any> = {};
|
||||
const uuidLike = /^[0-9a-fA-F-]{36}$/;
|
||||
Object.entries(form).forEach(([k, v]) => {
|
||||
if (v !== "" && v !== null && v !== undefined) {
|
||||
payload[k] = v;
|
||||
}
|
||||
});
|
||||
if (payload.subject_id && !uuidLike.test(String(payload.subject_id))) {
|
||||
ElMessage.warning("受试者ID格式不正确,已忽略");
|
||||
delete payload.subject_id;
|
||||
}
|
||||
if (isEdit.value && props.ae) {
|
||||
await updateAe(study.currentStudy.id, props.ae.id, payload);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user