SAAS模式调整

This commit is contained in:
hebo 2026-05-11 15:52:59 +08:00
parent 79ea4d33ce
commit dda9a21de3
5 changed files with 101 additions and 94 deletions

View File

@ -46,6 +46,20 @@ export const questionnaireAnswerFindByUserApi = async (params: { questionnaireId
return await get("/api/questionnaireAnswer/findByUser", params); return await get("/api/questionnaireAnswer/findByUser", params);
}; };
/**
*
*/
export const questionnaireAnswerFindByUserOrFamilyApi = async (params: {
questionnaireId: string;
xxtsId?: string;
xsId?: string;
}) => {
const q: Record<string, string> = { questionnaireId: params.questionnaireId };
if (params.xxtsId) q.xxtsId = params.xxtsId;
if (params.xsId) q.xsId = params.xsId;
return await get("/api/questionnaireAnswer/findByUserOrFamily", q);
};
/** /**
* *
*/ */

View File

@ -118,7 +118,15 @@ import { ref, computed, watch, nextTick } from "vue";
import { onLoad } from "@dcloudio/uni-app"; import { onLoad } from "@dcloudio/uni-app";
import { getByJlIdApi, jlzxFindByJlParamsApi, relayFinishApi } from "@/api/base/server"; import { getByJlIdApi, jlzxFindByJlParamsApi, relayFinishApi } from "@/api/base/server";
import { imagUrl } from "@/utils"; import { imagUrl } from "@/utils";
import { BASE_IMAGE_URL } from "@/config"; import {
canPreview,
isImage,
isVideo,
previewFile,
previewImage,
previewVideo,
downloadFile,
} from "@/utils/filePreview";
import { useUserStore } from "@/store/modules/user"; import { useUserStore } from "@/store/modules/user";
import { showLoading, hideLoading } from "@/utils/uniapp"; import { showLoading, hideLoading } from "@/utils/uniapp";
@ -395,59 +403,33 @@ onLoad(async (options) => {
} }
}); });
// // zhxy-jsd indexList / / kkFileView
const previewAttachment = (filePath: string) => { const previewAttachment = (filePath: string) => {
if (!filePath) { if (!filePath) {
uni.showToast({ title: "附件链接无效", icon: "none" }); uni.showToast({ title: "附件链接无效", icon: "none" });
return; return;
} }
const fileName = getFileName(filePath);
const ext = fileName.includes(".") ? (fileName.split(".").pop() || "").toLowerCase() : "";
const fullUrl = imagUrl(filePath);
// URL if (isVideo(ext)) {
const baseUrl = BASE_IMAGE_URL; // 使URL const title = fileName.replace(/\.[^.]+$/i, "") || fileName;
const fullUrl = filePath.startsWith('http') ? filePath : baseUrl + filePath; previewVideo(fullUrl, title);
return;
// }
const fileExtension = filePath.split('.').pop()?.toLowerCase(); if (isImage(ext)) {
const isImage = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp'].includes(fileExtension || ''); previewImage(fullUrl);
return;
// }
if (isImage) { if (canPreview(fileName)) {
uni.previewImage({ previewFile(fullUrl, fileName, ext).catch(() => {
urls: [fullUrl], downloadFile(fullUrl, fileName);
current: fullUrl
}); });
return; return;
} }
uni.showToast({ title: "该文件格式暂不支持预览", icon: "none" });
uni.showLoading({ title: "正在准备附件..." }); downloadFile(fullUrl, fileName);
uni.downloadFile({
url: fullUrl,
success: (res) => {
if (res.statusCode === 200) {
const tempFilePath = res.tempFilePath;
uni.hideLoading();
// Attempt to open the downloaded file
uni.openDocument({
filePath: tempFilePath,
success: function (res) {
//
},
fail: function (err) {
uni.showToast({ title: "无法打开该文件类型", icon: "none" });
uni.hideLoading(); // Ensure loading is hidden on failure too
},
});
} else {
uni.hideLoading();
uni.showToast({ title: "下载附件失败", icon: "none" });
}
},
fail: (err) => {
uni.hideLoading();
uni.showToast({ title: "下载附件失败", icon: "none" });
},
});
}; };
watch(noticeDetail, (val) => { watch(noticeDetail, (val) => {

View File

@ -138,7 +138,15 @@ import { ref, computed, watch, nextTick, onUnmounted } from "vue";
import { onLoad } from "@dcloudio/uni-app"; import { onLoad } from "@dcloudio/uni-app";
import { getByJlIdApi, jlzxFindByJlParamsApi, relayFinishApi } from "@/api/base/server"; import { getByJlIdApi, jlzxFindByJlParamsApi, relayFinishApi } from "@/api/base/server";
import { imagUrl } from "@/utils"; import { imagUrl } from "@/utils";
import { BASE_IMAGE_URL } from "@/config"; import {
canPreview,
isImage,
isVideo,
previewFile,
previewImage,
previewVideo,
downloadFile,
} from "@/utils/filePreview";
import { useUserStore } from "@/store/modules/user"; import { useUserStore } from "@/store/modules/user";
import { showLoading, hideLoading } from "@/utils/uniapp"; import { showLoading, hideLoading } from "@/utils/uniapp";
@ -503,59 +511,33 @@ onLoad(async (options) => {
} }
}); });
// // zhxy-jsd indexList / / kkFileView
const previewAttachment = (filePath: string) => { const previewAttachment = (filePath: string) => {
if (!filePath) { if (!filePath) {
uni.showToast({ title: "附件链接无效", icon: "none" }); uni.showToast({ title: "附件链接无效", icon: "none" });
return; return;
} }
const fileName = getFileName(filePath);
const ext = fileName.includes(".") ? (fileName.split(".").pop() || "").toLowerCase() : "";
const fullUrl = imagUrl(filePath);
// URL if (isVideo(ext)) {
const baseUrl = BASE_IMAGE_URL; // 使URL const title = fileName.replace(/\.[^.]+$/i, "") || fileName;
const fullUrl = filePath.startsWith('http') ? filePath : baseUrl + filePath; previewVideo(fullUrl, title);
return;
// }
const fileExtension = filePath.split('.').pop()?.toLowerCase(); if (isImage(ext)) {
const isImage = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp'].includes(fileExtension || ''); previewImage(fullUrl);
return;
// }
if (isImage) { if (canPreview(fileName)) {
uni.previewImage({ previewFile(fullUrl, fileName, ext).catch(() => {
urls: [fullUrl], downloadFile(fullUrl, fileName);
current: fullUrl
}); });
return; return;
} }
uni.showToast({ title: "该文件格式暂不支持预览", icon: "none" });
uni.showLoading({ title: "正在准备附件..." }); downloadFile(fullUrl, fileName);
uni.downloadFile({
url: fullUrl,
success: (res) => {
if (res.statusCode === 200) {
const tempFilePath = res.tempFilePath;
uni.hideLoading();
// Attempt to open the downloaded file
uni.openDocument({
filePath: tempFilePath,
success: function (res) {
//
},
fail: function (err) {
uni.showToast({ title: "无法打开该文件类型", icon: "none" });
uni.hideLoading(); // Ensure loading is hidden on failure too
},
});
} else {
uni.hideLoading();
uni.showToast({ title: "下载附件失败", icon: "none" });
}
},
fail: (err) => {
uni.hideLoading();
uni.showToast({ title: "下载附件失败", icon: "none" });
},
});
}; };
watch(noticeDetail, (val) => { watch(noticeDetail, (val) => {

View File

@ -353,7 +353,7 @@ import {
questionnaireCheckPermissionApi, questionnaireCheckPermissionApi,
questionnaireQuestionFindPageApi, questionnaireQuestionFindPageApi,
questionnaireAnswerSaveApi, questionnaireAnswerSaveApi,
questionnaireAnswerFindByUserApi, questionnaireAnswerFindByUserOrFamilyApi,
questionnaireAnswerFindDetailApi questionnaireAnswerFindDetailApi
} from '@/api/base/wjApi'; } from '@/api/base/wjApi';
import { useUserStore } from '@/store/modules/user'; import { useUserStore } from '@/store/modules/user';
@ -368,6 +368,7 @@ const options = ref<any>({});
const questionnaireId = ref(''); const questionnaireId = ref('');
const openId = ref<string>(""); // openId const openId = ref<string>(""); // openId
const xxtsId = ref<string>(""); // IDURLid const xxtsId = ref<string>(""); // IDURLid
const xsId = ref<string>(""); // ID xsId
const loading = ref(true); const loading = ref(true);
const submitting = ref(false); // const submitting = ref(false); //
const currentStep = ref<'fill' | 'success' | 'noPermission' | 'alreadyFilled' | 'timeInvalid'>('fill'); const currentStep = ref<'fill' | 'success' | 'noPermission' | 'alreadyFilled' | 'timeInvalid'>('fill');
@ -415,6 +416,7 @@ onLoad(async (params) => {
options.value = params; options.value = params;
openId.value = params?.openId || ''; openId.value = params?.openId || '';
xxtsId.value = params?.id || ''; // URLidxxtsId xxtsId.value = params?.id || ''; // URLidxxtsId
xsId.value = (params?.xsId as string) || '';
// openId // openId
if (openId.value) { if (openId.value) {
@ -500,8 +502,10 @@ const initializePage = async () => {
// 4. // 4.
if (!allowResubmit.value) { if (!allowResubmit.value) {
const answerResult = await questionnaireAnswerFindByUserApi({ const answerResult = await questionnaireAnswerFindByUserOrFamilyApi({
questionnaireId: questionnaireId.value questionnaireId: questionnaireId.value,
xxtsId: xxtsId.value || undefined,
xsId: xsId.value || undefined,
}); });
if (answerResult && answerResult.resultCode === 1) { if (answerResult && answerResult.resultCode === 1) {
const hasAnswered = answerResult.result || answerResult.data; const hasAnswered = answerResult.result || answerResult.data;
@ -1091,6 +1095,9 @@ const doSubmitQuestionnaire = async () => {
if (xxtsId.value) { if (xxtsId.value) {
submitParams.xxtsId = xxtsId.value; submitParams.xxtsId = xxtsId.value;
} }
if (xsId.value) {
submitParams.xsId = xsId.value;
}
// //
const result = await questionnaireAnswerSaveApi(submitParams); const result = await questionnaireAnswerSaveApi(submitParams);

View File

@ -5,6 +5,16 @@
import { KK_FILE_VIEW_URL } from '@/config'; import { KK_FILE_VIEW_URL } from '@/config';
export const isVideo = (fileType: string): boolean => {
const videoTypes = ['mp4', 'avi', 'mov', 'wmv', 'flv', 'webm', 'mkv', '3gp', 'm4v'];
return videoTypes.includes(fileType.toLowerCase());
};
export const isImage = (fileType: string): boolean => {
const imageTypes = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp'];
return imageTypes.includes(fileType.toLowerCase());
};
// 检查是否是压缩包文件 // 检查是否是压缩包文件
const isCompressedFile = (fileName: string): boolean => { const isCompressedFile = (fileName: string): boolean => {
const compressedExtensions = ['zip', 'rar', '7z', 'tar', 'gz', 'bz2']; const compressedExtensions = ['zip', 'rar', '7z', 'tar', 'gz', 'bz2'];
@ -13,7 +23,7 @@ const isCompressedFile = (fileName: string): boolean => {
}; };
// 检查文件是否可以预览 // 检查文件是否可以预览
const canPreview = (fileName: string): boolean => { export const canPreview = (fileName: string): boolean => {
const previewableExtensions = [ const previewableExtensions = [
'pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx',
'txt', 'rtf', 'odt', 'ods', 'odp', 'txt', 'rtf', 'odt', 'ods', 'odp',
@ -269,3 +279,15 @@ export const previewVideo = (videoUrl: string, videoTitle: string) => {
}); });
}); });
}; };
// 图片预览
export const previewImage = (imageUrl: string) => {
return new Promise((resolve) => {
uni.previewImage({
urls: [imageUrl],
current: imageUrl,
success: resolve,
fail: resolve,
});
});
};