启动与授权-初步优化
This commit is contained in:
@@ -10,6 +10,12 @@
|
||||
|
||||
<el-card>
|
||||
<el-form :model="form" label-width="120px">
|
||||
<el-form-item :label="TEXT.common.fields.site">
|
||||
<el-input v-model="siteInfo.name" disabled />
|
||||
</el-form-item>
|
||||
<el-form-item :label="TEXT.modules.startupMeetingAuth.ownerLabel">
|
||||
<el-input :model-value="ownerLabel" disabled />
|
||||
</el-form-item>
|
||||
<el-form-item :label="TEXT.common.fields.kickoffDate">
|
||||
<el-date-picker v-model="form.kickoff_date" type="date" value-format="YYYY-MM-DD" :placeholder="TEXT.common.placeholders.select" />
|
||||
</el-form-item>
|
||||
@@ -28,12 +34,16 @@
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<AttachmentList
|
||||
v-if="isEdit && meetingId"
|
||||
:study-id="studyId"
|
||||
entity-type="startup_kickoff"
|
||||
:entity-id="meetingId"
|
||||
/>
|
||||
<div v-if="isEdit && meetingId" class="attachment-grid">
|
||||
<AttachmentList
|
||||
v-for="group in kickoffAttachmentGroups"
|
||||
:key="group.entityType"
|
||||
:study-id="studyId"
|
||||
:entity-type="group.entityType"
|
||||
:entity-id="meetingId"
|
||||
:title="group.title"
|
||||
/>
|
||||
</div>
|
||||
<el-card v-else class="hint-card">
|
||||
<StateEmpty :description="TEXT.modules.startupMeetingAuth.kickoffUploadHint" />
|
||||
</el-card>
|
||||
@@ -46,6 +56,9 @@ import { useRoute, useRouter } from "vue-router";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { useStudyStore } from "../../store/study";
|
||||
import { createKickoff, getKickoff, updateKickoff } from "../../api/startup";
|
||||
import { fetchSites } from "../../api/sites";
|
||||
import { listMembers } from "../../api/members";
|
||||
import { fetchUsers } from "../../api/users";
|
||||
import AttachmentList from "../../components/attachments/AttachmentList.vue";
|
||||
import StateEmpty from "../../components/StateEmpty.vue";
|
||||
import { TEXT } from "../../locales";
|
||||
@@ -58,6 +71,37 @@ const saving = ref(false);
|
||||
const meetingId = computed(() => route.params.meetingId as string | undefined);
|
||||
const isEdit = computed(() => !!meetingId.value);
|
||||
const studyId = computed(() => study.currentStudy?.id || "");
|
||||
const siteInfo = reactive<{ name: string; contact?: string | null }>({ name: "" });
|
||||
const siteId = ref("");
|
||||
const users = ref<any[]>([]);
|
||||
const members = ref<any[]>([]);
|
||||
|
||||
const memberNameMap = computed(() => {
|
||||
const map: Record<string, string> = {};
|
||||
users.value.forEach((u: any) => {
|
||||
if (u?.id) map[u.id] = u.full_name || u.username || u.id;
|
||||
});
|
||||
members.value.forEach((m: any) => {
|
||||
if (m?.user_id && !map[m.user_id]) map[m.user_id] = m.full_name || m.username || m.user_id;
|
||||
});
|
||||
return map;
|
||||
});
|
||||
|
||||
const ownerLabel = computed(() => {
|
||||
if (!siteInfo.contact) return TEXT.common.fallback;
|
||||
return String(siteInfo.contact)
|
||||
.split(",")
|
||||
.map((c) => c.trim())
|
||||
.filter(Boolean)
|
||||
.map((c) => memberNameMap.value[c] || c)
|
||||
.join("、") || TEXT.common.fallback;
|
||||
});
|
||||
const kickoffAttachmentGroups = [
|
||||
{ entityType: "startup_kickoff_minutes", title: TEXT.modules.startupMeetingAuth.kickoffMinutesLabel },
|
||||
{ entityType: "startup_kickoff_signin", title: TEXT.modules.startupMeetingAuth.kickoffSignInLabel },
|
||||
{ entityType: "startup_kickoff_ppt", title: TEXT.modules.startupMeetingAuth.kickoffPptLabel },
|
||||
{ entityType: "startup_kickoff", title: TEXT.modules.startupMeetingAuth.kickoffOtherLabel },
|
||||
];
|
||||
|
||||
const form = reactive({
|
||||
kickoff_date: "",
|
||||
@@ -72,13 +116,24 @@ const parseAttendees = (value: string) => {
|
||||
};
|
||||
|
||||
const load = async () => {
|
||||
if (!isEdit.value || !studyId.value || !meetingId.value) return;
|
||||
if (!studyId.value) return;
|
||||
try {
|
||||
const { data } = await getKickoff(studyId.value, meetingId.value);
|
||||
Object.assign(form, {
|
||||
kickoff_date: data.kickoff_date || "",
|
||||
attendees: Array.isArray(data.attendees) ? data.attendees.join("\n") : "",
|
||||
});
|
||||
if (isEdit.value && meetingId.value) {
|
||||
const { data } = await getKickoff(studyId.value, meetingId.value);
|
||||
Object.assign(form, {
|
||||
kickoff_date: data.kickoff_date || "",
|
||||
attendees: Array.isArray(data.attendees) ? data.attendees.join("\n") : "",
|
||||
});
|
||||
siteId.value = data.site_id || "";
|
||||
} else {
|
||||
siteId.value = (route.query.siteId as string) || "";
|
||||
}
|
||||
if (siteId.value) {
|
||||
const { data: sitesData } = await fetchSites(studyId.value, { limit: 500 });
|
||||
const list = Array.isArray(sitesData) ? sitesData : sitesData.items || [];
|
||||
const matched = list.find((site: any) => site.id === siteId.value);
|
||||
Object.assign(siteInfo, matched || { name: "", contact: "" });
|
||||
}
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.response?.data?.message || TEXT.common.messages.loadFailed);
|
||||
}
|
||||
@@ -97,7 +152,7 @@ const submit = async () => {
|
||||
ElMessage.success(TEXT.common.messages.saveSuccess);
|
||||
router.push(`/startup/kickoff/${meetingId.value}`);
|
||||
} else {
|
||||
const { data } = await createKickoff(studyId.value, payload);
|
||||
const { data } = await createKickoff(studyId.value, { ...payload, site_id: siteId.value });
|
||||
ElMessage.success(TEXT.common.messages.createSuccess);
|
||||
router.push(`/startup/kickoff/${data.id}`);
|
||||
}
|
||||
@@ -110,7 +165,21 @@ const submit = async () => {
|
||||
|
||||
const goBack = () => router.push("/startup/meeting-auth");
|
||||
|
||||
onMounted(load);
|
||||
onMounted(async () => {
|
||||
if (studyId.value) {
|
||||
const [membersResp, usersResp] = await Promise.all([
|
||||
listMembers(studyId.value, { limit: 500 }),
|
||||
fetchUsers({ limit: 500 }),
|
||||
]).catch(() => [null, null]);
|
||||
if (membersResp?.data) {
|
||||
members.value = Array.isArray(membersResp.data) ? membersResp.data : membersResp.data.items || [];
|
||||
}
|
||||
if (usersResp?.data) {
|
||||
users.value = usersResp.data.items || [];
|
||||
}
|
||||
}
|
||||
load();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
@@ -141,4 +210,10 @@ onMounted(load);
|
||||
.hint-card {
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.attachment-grid {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user