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);
};
/**
*
*/
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 { getByJlIdApi, jlzxFindByJlParamsApi, relayFinishApi } from "@/api/base/server";
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 { showLoading, hideLoading } from "@/utils/uniapp";
@ -395,59 +403,33 @@ onLoad(async (options) => {
}
});
//
// zhxy-jsd indexList / / kkFileView
const previewAttachment = (filePath: string) => {
if (!filePath) {
uni.showToast({ title: "附件链接无效", icon: "none" });
return;
}
const fileName = getFileName(filePath);
const ext = fileName.includes(".") ? (fileName.split(".").pop() || "").toLowerCase() : "";
const fullUrl = imagUrl(filePath);
// URL
const baseUrl = BASE_IMAGE_URL; // 使URL
const fullUrl = filePath.startsWith('http') ? filePath : baseUrl + filePath;
//
const fileExtension = filePath.split('.').pop()?.toLowerCase();
const isImage = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp'].includes(fileExtension || '');
//
if (isImage) {
uni.previewImage({
urls: [fullUrl],
current: fullUrl
if (isVideo(ext)) {
const title = fileName.replace(/\.[^.]+$/i, "") || fileName;
previewVideo(fullUrl, title);
return;
}
if (isImage(ext)) {
previewImage(fullUrl);
return;
}
if (canPreview(fileName)) {
previewFile(fullUrl, fileName, ext).catch(() => {
downloadFile(fullUrl, fileName);
});
return;
}
uni.showLoading({ title: "正在准备附件..." });
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" });
},
});
uni.showToast({ title: "该文件格式暂不支持预览", icon: "none" });
downloadFile(fullUrl, fileName);
};
watch(noticeDetail, (val) => {

View File

@ -138,7 +138,15 @@ import { ref, computed, watch, nextTick, onUnmounted } from "vue";
import { onLoad } from "@dcloudio/uni-app";
import { getByJlIdApi, jlzxFindByJlParamsApi, relayFinishApi } from "@/api/base/server";
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 { showLoading, hideLoading } from "@/utils/uniapp";
@ -503,59 +511,33 @@ onLoad(async (options) => {
}
});
//
// zhxy-jsd indexList / / kkFileView
const previewAttachment = (filePath: string) => {
if (!filePath) {
uni.showToast({ title: "附件链接无效", icon: "none" });
return;
}
const fileName = getFileName(filePath);
const ext = fileName.includes(".") ? (fileName.split(".").pop() || "").toLowerCase() : "";
const fullUrl = imagUrl(filePath);
// URL
const baseUrl = BASE_IMAGE_URL; // 使URL
const fullUrl = filePath.startsWith('http') ? filePath : baseUrl + filePath;
//
const fileExtension = filePath.split('.').pop()?.toLowerCase();
const isImage = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp'].includes(fileExtension || '');
//
if (isImage) {
uni.previewImage({
urls: [fullUrl],
current: fullUrl
if (isVideo(ext)) {
const title = fileName.replace(/\.[^.]+$/i, "") || fileName;
previewVideo(fullUrl, title);
return;
}
if (isImage(ext)) {
previewImage(fullUrl);
return;
}
if (canPreview(fileName)) {
previewFile(fullUrl, fileName, ext).catch(() => {
downloadFile(fullUrl, fileName);
});
return;
}
uni.showLoading({ title: "正在准备附件..." });
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" });
},
});
uni.showToast({ title: "该文件格式暂不支持预览", icon: "none" });
downloadFile(fullUrl, fileName);
};
watch(noticeDetail, (val) => {

View File

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

View File

@ -5,6 +5,16 @@
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 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 = [
'pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx',
'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,
});
});
};