feat: 优化驳回状态判断和显示逻辑

1. 添加 isRejectAdvise 方法判断驳回状态
2. 添加 getAdviseText 方法获取修改建议文本
3. 优化各步骤的状态显示逻辑
4. 修复状态流转问题
This commit is contained in:
huertian 2025-01-05 16:29:26 +08:00
parent 8452965556
commit 4406934444
2 changed files with 91 additions and 56 deletions

View File

@ -4,8 +4,8 @@ import { ref } from "vue";
export const useConfig = defineStore('config', () => { export const useConfig = defineStore('config', () => {
// const BASE_URL = ref<string>("https://ppmp.fenshenzhike.com/api"); // const BASE_URL = ref<string>("https://ppmp.fenshenzhike.com/api");
// const BASE_URL = ref<string>("http://localhost:1218/api"); // const BASE_URL = ref<string>("http://localhost:1218/api");
const BASE_URL = ref<string>("http://192.168.0.119:1218/api"); // const BASE_URL = ref<string>("http://192.168.0.119:1218/api");
// const BASE_URL = ref<string>("http://192.30.5.11:1218/api"); const BASE_URL = ref<string>("http://192.30.5.20:1218/api");
return { return {
BASE_URL BASE_URL

View File

@ -32,7 +32,7 @@ const pickerLessonColumns = computed(() => {
}) : [] }) : []
}) })
const pickerLessonValue = ref() const pickerLessonValue = ref()
const adviseText = ref<string>('') const adviseTextValue = ref<string>('')
const selectedLesson = computed(() => { const selectedLesson = computed(() => {
if (!pickerLessonValue.value) return null if (!pickerLessonValue.value) return null
@ -44,6 +44,43 @@ const selectedLessonStage = computed(() => {
return extractLessonStage(selectedLesson.value) return extractLessonStage(selectedLesson.value)
}) })
/**
* 判断advise是否为驳回状态
* @param advise 修改建议字符串
* @returns {boolean} 是否为驳回状态
*/
const isRejectAdvise = (advise: string | undefined): boolean => {
try {
if (!advise) return false
const adviseObj = JSON.parse(advise)
return 'reject' in adviseObj
} catch {
return false
}
}
const adviseText = computed(() => {
try {
if (!selectedLesson.value?.advise) return '暂无修改建议'
const adviseObj = JSON.parse(selectedLesson.value.advise)
return adviseObj.reject || '暂无修改建议'
} catch {
return selectedLesson?.value?.advise || '暂无修改建议'
}
})
const getAdviseText = (adviseString: string | undefined): string => {
try {
if (!adviseString) return ''
const adviseObj = JSON.parse(adviseString)
const rejectText = adviseObj.reject || ''
return rejectText
} catch (e) {
console.error('JSON解析失败:', e)
return ''
}
}
const onCoursePick = ({ value }: { value: string }) => { const onCoursePick = ({ value }: { value: string }) => {
pickerCourseValue.value = value pickerCourseValue.value = value
pickerLessonValue.value = undefined pickerLessonValue.value = undefined
@ -74,7 +111,7 @@ const onStep0 = () => {
msg: '正在提交...' msg: '正在提交...'
}) })
const params = { const params = {
advise: "", advise: JSON.stringify({ confirm: "" }),
courseName: selectedLesson.value.courseName, courseName: selectedLesson.value.courseName,
microLessonName: selectedLesson.value.microLessonName, microLessonName: selectedLesson.value.microLessonName,
userId: selectedLesson.value.userId, userId: selectedLesson.value.userId,
@ -114,13 +151,13 @@ const onStep1 = (rejected: boolean = false) => {
BussApi.updateLessonTask( BussApi.updateLessonTask(
selectedLesson.value.id, selectedLesson.value.id,
rejected ? { rejected ? {
advise: adviseText.value.toString(), advise: JSON.stringify({ reject: adviseTextValue.value.toString() }),
courseName: selectedLesson.value.courseName, courseName: selectedLesson.value.courseName,
microLessonName: selectedLesson.value.microLessonName, microLessonName: selectedLesson.value.microLessonName,
userId: selectedLesson.value.userId, userId: selectedLesson.value.userId,
progressStatus: ProgressStatus.NOT_STARTED//0 progressStatus: ProgressStatus.NOT_STARTED//0
} : { } : {
advise: "", advise: JSON.stringify({ confirm: "" }),
courseName: selectedLesson.value.courseName, courseName: selectedLesson.value.courseName,
microLessonName: selectedLesson.value.microLessonName, microLessonName: selectedLesson.value.microLessonName,
userId: selectedLesson.value.userId, userId: selectedLesson.value.userId,
@ -156,13 +193,13 @@ const onStep2 = (rejected: boolean = false) => {
BussApi.updateLessonTask( BussApi.updateLessonTask(
selectedLesson.value.id, selectedLesson.value.id,
rejected ? { rejected ? {
advise: adviseText.value.toString(), advise: JSON.stringify({ reject: adviseTextValue.value.toString() }),
courseName: selectedLesson.value.courseName, courseName: selectedLesson.value.courseName,
microLessonName: selectedLesson.value.microLessonName, microLessonName: selectedLesson.value.microLessonName,
userId: selectedLesson.value.userId, userId: selectedLesson.value.userId,
progressStatus: ProgressStatus.SCRIPT_CREATING//1 progressStatus: ProgressStatus.SCRIPT_CREATING//1
} : { } : {
advise: "", advise: JSON.stringify({ confirm: "" }),
courseName: selectedLesson.value.courseName, courseName: selectedLesson.value.courseName,
microLessonName: selectedLesson.value.microLessonName, microLessonName: selectedLesson.value.microLessonName,
userId: selectedLesson.value.userId, userId: selectedLesson.value.userId,
@ -198,13 +235,13 @@ const onStep3 = (rejected: boolean = false) => {
BussApi.updateLessonTask( BussApi.updateLessonTask(
selectedLesson.value.id, selectedLesson.value.id,
rejected ? { rejected ? {
advise: adviseText.value.toString(), advise: JSON.stringify({ reject: 'huertian' + adviseTextValue.value.toString() }),
courseName: selectedLesson.value.courseName, courseName: selectedLesson.value.courseName,
microLessonName: selectedLesson.value.microLessonName, microLessonName: selectedLesson.value.microLessonName,
userId: selectedLesson.value.userId, userId: selectedLesson.value.userId,
progressStatus: ProgressStatus.SCRIPT_CONFIRMED//3 progressStatus: ProgressStatus.SCRIPT_CONFIRMED//3
} : { } : {
advise: "", advise: JSON.stringify({ confirm: "" }),
courseName: selectedLesson.value.courseName, courseName: selectedLesson.value.courseName,
microLessonName: selectedLesson.value.microLessonName, microLessonName: selectedLesson.value.microLessonName,
userId: selectedLesson.value.userId, userId: selectedLesson.value.userId,
@ -239,13 +276,13 @@ const onStep4 = (rejected: boolean = false) => {
BussApi.updateLessonTask( BussApi.updateLessonTask(
selectedLesson.value.id, selectedLesson.value.id,
rejected ? { rejected ? {
advise: adviseText.value.toString(), advise: JSON.stringify({ reject: adviseTextValue.value.toString() }),
courseName: selectedLesson.value.courseName, courseName: selectedLesson.value.courseName,
microLessonName: selectedLesson.value.microLessonName, microLessonName: selectedLesson.value.microLessonName,
userId: selectedLesson.value.userId, userId: selectedLesson.value.userId,
progressStatus: ProgressStatus.VIDEO_CREATING//4 progressStatus: ProgressStatus.SCRIPT_CONFIRMED//3
} : { } : {
advise: "", advise: JSON.stringify({ confirm: "" }),
courseName: selectedLesson.value.courseName, courseName: selectedLesson.value.courseName,
microLessonName: selectedLesson.value.microLessonName, microLessonName: selectedLesson.value.microLessonName,
userId: selectedLesson.value.userId, userId: selectedLesson.value.userId,
@ -264,7 +301,7 @@ const onStep4 = (rejected: boolean = false) => {
} }
const updateLessons = async () => { const updateLessons = async () => {
adviseText.value = "" adviseTextValue.value = ""
if (!user.userinfo) { if (!user.userinfo) {
toast.error({ msg: '请先登录' }) toast.error({ msg: '请先登录' })
return return
@ -351,7 +388,7 @@ onPullDownRefresh(() => {
:columns-height="280" label-width="80px" safe-area-inset-bottom title="微课选择" :disabled="!pickerCourseValue" /> :columns-height="280" label-width="80px" safe-area-inset-bottom title="微课选择" :disabled="!pickerCourseValue" />
</div> </div>
<wd-message-box selector="wd-message-box-slot"> <wd-message-box selector="wd-message-box-slot">
<wd-textarea v-model="adviseText" type="text" clear-trigger="focus" clearable auto-height show-word-limit <wd-textarea v-model="adviseTextValue" type="text" clear-trigger="focus" clearable auto-height show-word-limit
:focus-when-clear="false" :maxlength="100" placeholder="请输入审核建议..." block /> :focus-when-clear="false" :maxlength="100" placeholder="请输入审核建议..." block />
</wd-message-box> </wd-message-box>
<div class="p-2 pt-4"> <div class="p-2 pt-4">
@ -366,9 +403,9 @@ onPullDownRefresh(() => {
<div v-if="selectedLessonStage?.step === 0" class="px-2"> <div v-if="selectedLessonStage?.step === 0" class="px-2">
<div v-if="user.hasRole('teacher')"> <div v-if="user.hasRole('teacher')">
<div v-if="selectedLesson?.advise && selectedLesson.advise.length > 0" class=" m-2 text-sm"> <div v-if="isRejectAdvise(selectedLesson?.advise)" class="m-2 text-sm">
<wd-card title="修改建议"> <wd-card title="修改建议">
{{ selectedLesson?.advise }} {{ adviseText }}
</wd-card> </wd-card>
</div> </div>
<wd-cell-group> <wd-cell-group>
@ -391,21 +428,21 @@ onPullDownRefresh(() => {
<div v-if="selectedLessonStage?.step === 1"> <div v-if="selectedLessonStage?.step === 1">
<div v-if="user.hasRole('teacher')"> <div v-if="user.hasRole('teacher')">
<StatusBlock title="脚本已提交" subtitle="请耐心等待审核"> <StatusBlock title="脚本制作已完成" subtitle="请核对并审核">
<template #icon> <template #icon>
<div class="i-tabler-progress-bolt text-7xl text-neutral-400 "></div> <div class="i-tabler-progress-check text-7xl text-neutral-400"></div>
</template> </template>
</StatusBlock> </StatusBlock>
</div> </div>
<div v-else> <div v-else>
<div v-if="selectedLesson?.advise && selectedLesson.advise.length > 0" class=" m-2 text-sm"> <div v-if="isRejectAdvise(selectedLesson?.advise) === true" class=" m-2 text-sm">
<wd-card title="修改建议"> <wd-card title="修改建议">
{{ selectedLesson?.advise }} {{ adviseText }}
</wd-card> </wd-card>
</div> </div>
<StatusBlock title="脚本制作已完成" subtitle="请核对并审核"> <StatusBlock title="脚本已提交" subtitle="请耐心等待审核">
<template #icon> <template #icon>
<div class="i-tabler-progress-check text-7xl text-neutral-400"></div> <div class="i-tabler-progress-bolt text-7xl text-neutral-400 "></div>
</template> </template>
</StatusBlock> </StatusBlock>
<div class="mt-4 space-y-4"> <div class="mt-4 space-y-4">
@ -418,33 +455,33 @@ onPullDownRefresh(() => {
</div> </div>
<div v-if="selectedLessonStage?.step === 2"> <div v-if="selectedLessonStage?.step === 2">
<div v-if="!user.hasRole('teacher')"> <div v-if="user.hasRole('teacher')">
<StatusBlock title="脚本确认进行中" subtitle="请等待脚本内容确认">
<template #icon>
<div class="i-tabler-file-text text-7xl text-neutral-400"></div>
</template>
</StatusBlock>
</div>
<div v-else>
<StatusBlock title="脚本审核已完成" subtitle="请确认脚本内容"> <StatusBlock title="脚本审核已完成" subtitle="请确认脚本内容">
<template #icon> <template #icon>
<div class="i-tabler-file-text text-7xl text-neutral-400"></div> <div class="i-tabler-file-text text-7xl text-neutral-400"></div>
</template> </template>
</StatusBlock> </StatusBlock>
</div> <div class="mt-4 space-y-4">
<div v-if="user.hasRole('teacher')" class="mt-4 space-y-4">
<div class="flex gap-3 px-4"> <div class="flex gap-3 px-4">
<wd-button type="primary" block @click="onStep2()">确认</wd-button> <wd-button type="primary" block @click="onStep2()">确认</wd-button>
<wd-button type="error" block @click="onStep2(true)">驳回</wd-button> <wd-button type="error" block @click="onStep2(true)">驳回</wd-button>
</div> </div>
</div> </div>
</div> </div>
<div v-else>
<StatusBlock title="脚本确认进行中" subtitle="请等待脚本内容确认">
<template #icon>
<div class="i-tabler-file-text text-7xl text-neutral-400"></div>
</template>
</StatusBlock>
</div>
</div>
<div v-if="selectedLessonStage?.step === 3"> <div v-if="selectedLessonStage?.step === 3">
<div v-if="user.hasRole('teacher')"> <div v-if="user.hasRole('teacher')">
<div v-if="selectedLesson?.advise && selectedLesson.advise.length > 0" class=" m-2 text-sm"> <div v-if="getAdviseText(selectedLesson?.advise).startsWith('huertian')" class=" m-2 text-sm">
<wd-card title="修改建议"> <wd-card title="修改建议">
{{ selectedLesson?.advise }} {{ getAdviseText(selectedLesson?.advise).substring('huertian'.length) }}
</wd-card> </wd-card>
</div> </div>
<StatusBlock title="视频拍摄制作进行中" subtitle="请等待视频拍摄制作"> <StatusBlock title="视频拍摄制作进行中" subtitle="请等待视频拍摄制作">
@ -454,16 +491,19 @@ onPullDownRefresh(() => {
</StatusBlock> </StatusBlock>
</div> </div>
<div v-else> <div v-else>
<div v-if="!getAdviseText(selectedLesson?.advise).startsWith('huertian')">
<div v-if="isRejectAdvise(selectedLesson?.advise) === true" class=" m-2 text-sm">
<wd-card title="修改建议">
{{ adviseText }}
</wd-card>
</div>
</div>
<StatusBlock title="视频拍摄制作进行中" subtitle="完成后请确认"> <StatusBlock title="视频拍摄制作进行中" subtitle="完成后请确认">
<template #icon> <template #icon>
<div class="i-tabler-video text-7xl text-neutral-400"></div> <div class="i-tabler-video text-7xl text-neutral-400"></div>
</template> </template>
</StatusBlock> </StatusBlock>
<div class="mt-4 space-y-4"> <div class="mt-4 space-y-4">
<div class="bg-neutral000 rounded-lg px-4 py-3">
<wd-textarea v-model="adviseText" title="审核建议" type="text" clear-trigger="focus" clearable auto-height
show-word-limit :focus-when-clear="false" :maxlength="100" placeholder="请输入审核建议..." block />
</div>
<div class="flex gap-3 px-4 center"> <div class="flex gap-3 px-4 center">
<wd-button type="primary" block @click="onStep3()">通过</wd-button> <wd-button type="primary" block @click="onStep3()">通过</wd-button>
<wd-button type="error" block @click="onStep3(true)">驳回</wd-button> <wd-button type="error" block @click="onStep3(true)">驳回</wd-button>
@ -473,30 +513,26 @@ onPullDownRefresh(() => {
</div> </div>
<div v-if="selectedLessonStage?.step === 4"> <div v-if="selectedLessonStage?.step === 4">
<div v-if="!user.hasRole('teacher')"> <div v-if="user.hasRole('teacher')">
<StatusBlock title="视频内容确认中" subtitle="请等待视频内容确认">
<template #icon>
<div class="i-tabler-brand-parsinta text-7xl text-neutral-400"></div>
</template>
</StatusBlock>
</div>
<div v-else>
<StatusBlock title="视频拍摄制作已完成" subtitle="请确认视频内容"> <StatusBlock title="视频拍摄制作已完成" subtitle="请确认视频内容">
<template #icon> <template #icon>
<div class="i-tabler-brand-parsinta text-7xl text-neutral-400"></div> <div class="i-tabler-brand-parsinta text-7xl text-neutral-400"></div>
</template> </template>
</StatusBlock> </StatusBlock>
<div class="mt-4 space-y-4"> <div class="mt-4 space-y-4">
<div class="bg-neutral000 rounded-lg px-4 py-3">
<wd-textarea v-model="adviseText" title="审核建议" type="text" clear-trigger="focus" clearable auto-height
show-word-limit :focus-when-clear="false" :maxlength="100" placeholder="请输入审核建议..." block />
</div>
<div class="flex gap-3 px-4"> <div class="flex gap-3 px-4">
<wd-button type="primary" block @click="onStep4()">通过</wd-button> <wd-button type="primary" block @click="onStep4()">通过</wd-button>
<wd-button type="error" block @click="onStep4(true)">驳回</wd-button> <wd-button type="error" block @click="onStep4(true)">驳回</wd-button>
</div> </div>
</div> </div>
</div> </div>
<div v-else>
<StatusBlock title="视频内容确认中" subtitle="请等待视频内容确认">
<template #icon>
<div class="i-tabler-brand-parsinta text-7xl text-neutral-400"></div>
</template>
</StatusBlock>
</div>
</div> </div>
<div v-else-if="selectedLessonStage?.step === 5"> <div v-else-if="selectedLessonStage?.step === 5">
@ -505,7 +541,6 @@ onPullDownRefresh(() => {
<div class="i-tabler-clipboard-check text-7xl text-neutral-400"></div> <div class="i-tabler-clipboard-check text-7xl text-neutral-400"></div>
</template> </template>
</StatusBlock> </StatusBlock>
<!-- <wd-status-tip image="comment" tip="该微课已完成" /> -->
</div> </div>
</div> </div>
</div> </div>