访视选择添加校验判断

main
wangxiaoshuang 2024-04-17 17:16:38 +08:00
parent 82dfda0f05
commit a78a0e038c
5 changed files with 99 additions and 13 deletions

View File

@ -10,6 +10,7 @@
:key="item.id"
:label="item.label"
:value="item.value"
:disabled="Number(item.SubmitState) > 1"
/>
<p class="addVisit" @click.stop="add">
<i class="el-icon-plus" v-loading="loading"></i>
@ -17,6 +18,7 @@
</el-select>
</template>
<script>
import moment from "moment";
export default {
name: "visitSelect",
props: {
@ -26,6 +28,12 @@ export default {
return [];
},
},
studyData: {
required: true,
default: () => {
return {};
},
},
modelData: {
required: true,
},
@ -52,10 +60,80 @@ export default {
this.$emit("add");
},
selectChange(flag) {
this.$emit("selectChange", flag);
this.$emit("selectChange", flag, this.studyData.StudyId);
},
handleChange() {
this.$emit("update:modelData", this.visit);
async handleChange() {
try {
let res = await this.formatVisit();
if (!res) return;
this.$emit("update:modelData", this.visit);
} catch (err) {
console.log(err);
}
},
// 访
async formatVisit() {
try {
let StudyTime = this.studyData.StudyTime;
let visitIndex = this.list.findIndex((item) => item.Id === this.visit);
if (visitIndex >= 1) {
let time = this.list[visitIndex - 1].VisitMaxStudyTime;
if (time && moment(StudyTime).isBefore(time)) {
throw "Out of range";
}
}
if (visitIndex < this.list.length - 1 && visitIndex >= 0) {
let time = this.list[visitIndex + 1].VisitMinStudyTime;
if (time && moment(StudyTime).isAfter(time)) {
throw "Out of range";
}
}
let visit = this.list[visitIndex];
if (
(visit.VisitMinStudyTime &&
moment(StudyTime).isBefore(
moment(visit.VisitMinStudyTime)
.subtract(15, "day")
.format("YYYY-MM-DD HH:mm:ss")
)) ||
(visit.VisitMaxStudyTime &&
moment(StudyTime).isAfter(
moment(visit.VisitMaxStudyTime)
.add(15, "day")
.format("YYYY-MM-DD HH:mm:ss")
))
) {
let message = this.$t("trials:studyVisit:format:studyTime");
message = message.replace("minTime", visit.VisitMinStudyTime);
message = message.replace("maxTime", visit.VisitMaxStudyTime);
message = message.replace("studyTime", StudyTime);
this.$confirm(
message,
this.$t("trials:uploadDicomList:label:prompt"),
{
type: "warning",
showCancelButton: false,
}
).then(() => {
this.$emit("update:modelData", this.visit);
});
}
return true;
} catch (err) {
console.log(err);
if (err === "Out of range") {
this.$confirm(
this.$t("trials:studyVisit:format:studyTimeNo"),
this.$t("trials:uploadDicomList:label:prompt"),
{
type: "warning",
showCancelButton: false,
}
).then();
this.visit = this.modelData;
}
return false;
}
},
},
};

View File

@ -19,7 +19,7 @@
:model="submitMessage"
class="demo-form-inline"
:rules="rules"
label-width="100px"
label-width="150px"
>
<div>
<!--项目-->

View File

@ -132,7 +132,7 @@
<!--操作-->
<el-table-column
:label="$t('common:action:action')"
width="300"
width="330"
class-name="actionBox"
>
<template slot-scope="scope">
@ -140,6 +140,7 @@
<visitSelect
:modelData.sync="scope.row.SubjectVisitId"
:loading="addLoading"
:studyData="scope.row"
:list="visitList"
@add="addVisit"
@selectChange="selectChange"
@ -271,17 +272,18 @@ export default {
if (flag) this.visitStatus = "confirm";
},
// 访
selectChange(flag) {
selectChange(flag, StudyId) {
if (flag) {
this.getSubjectVisitSelectList();
this.getSubjectVisitSelectList(StudyId);
}
},
// 访
async getSubjectVisitSelectList() {
async getSubjectVisitSelectList(StudyId = null) {
let data = {
TrialId: this.submitMessage.TrialId,
SubjectId: this.submitMessage.SubjectId,
};
if (StudyId) data.ScpStudyId = StudyId;
try {
let res = await getSubjectVisitSelectList(data);
if (res.IsSuccess) {

View File

@ -55,6 +55,7 @@
<visitSelect
:modelData.sync="form.SubjectVisitId"
:loading="addLoading"
:studyData="data"
:list="visitList"
@add="addVisit"
@selectChange="selectChange"
@ -102,6 +103,7 @@ import {
addSubjectPatientStudyBinding,
addOrUpdateSubjectVisit,
} from "@/api/inspection.js";
import { getVisitStudyVerifyTime } from "@/api/trials/visit.js";
import visitSelect from "@/components/visitSelect";
export default {
name: "editVisitDialog",
@ -128,7 +130,7 @@ export default {
{
required: true,
message: this.$t("trials:study:formRlue:selectVisit"),
trigger: "change",
trigger: "blur",
},
],
},
@ -181,9 +183,9 @@ export default {
}
},
// 访
selectChange(flag) {
selectChange(flag, StudyId) {
if (flag) {
this.getSubjectVisitSelectList();
this.getSubjectVisitSelectList(StudyId);
}
},
// 访
@ -208,11 +210,12 @@ export default {
}
},
// 访
async getSubjectVisitSelectList() {
async getSubjectVisitSelectList(StudyId = null) {
let data = {
TrialId: this.data.TrialId,
SubjectId: this.data.SubjectId,
};
if (StudyId) data.ScpStudyId = StudyId;
try {
let res = await getSubjectVisitSelectList(data);
if (res.IsSuccess) {
@ -224,6 +227,9 @@ export default {
item.value = item.Id;
return item;
});
this.visitList.sort(
(a, b) => parseFloat(a.VisitNum) - parseFloat(b.VisitNum)
);
this.form.SubjectVisitId = this.data.SubjectVisitId;
}
} catch (err) {

View File

@ -19,7 +19,7 @@
class="demo-form-inline topForm"
:rules="rules"
ref="addSubjectForm"
label-width="100px"
label-width="150px"
>
<div class="selectAndBtn">
<!--受试者编号-->