| src/pages/routingInspection/detail/indexJX.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/pages/routingInspection/detail/indexLS.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/pages/routingInspection/upload.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | 
src/pages/routingInspection/detail/indexJX.vue
@@ -138,6 +138,7 @@ style="padding-bottom: 10px" > <wd-form-item prop="structureItemsGroup" :label="formatValue(item.structureName)" label-width="400rpx" style="color: red" @@ -184,6 +185,7 @@ :label="formatValue(item.twistName)" label-width="400rpx" style="color: red" prop="inspectTwistGroup" required ></wd-form-item> <wd-form-item label="ç»å" prop="direction" required> @@ -290,40 +292,15 @@ <view style="margin: 10rpx"> <text class="title">{{ "éä»¶" }}</text> </view> <view class="attachment-grid"> <!-- å·²ä¸ä¼ éä»¶ï¼å 嫿°ä¸ä¼ çï¼ --> <wd-col v-for="(file, index) in allFiles" :key="file.id || index" class="attachment-item"> <wd-img :width="80" :height="80" :src="file.url" @click="previewImage(file.url)"> <template #error> <view class="error-wrap">å 载失败</view> </template> <template #loading> <view class="loading-wrap"> <wd-loading /> </view> </template> </wd-img> <!-- ç¼è¾æ¨¡å¼ä¸æ¾ç¤ºå é¤æé® --> <!-- <wd-icon v-if="isEdit" name="close-circle" class="delete-icon" @click.stop="deleteFile(file.id || index)" ></wd-icon> --> <wd-col :span="24"> <AttachmentUpload :detailData="detailData" :isEdit="isEdit" :deviceType="paramsType" ref="attachmentRef" v-if="detailDataLoaded" /> </wd-col> <!-- ä¸ä¼ æé®ï¼ä» ç¼è¾æ¨¡å¼æ¾ç¤ºï¼ --> <wd-col v-if="isEdit" class="attachment-item upload-btn"> <wd-upload :multiple="true" :max-count="5" :before-upload="beforeUpload" @success="handleUploadSuccess" @fail="handleUploadFail" > <view class="upload-icon">+</view> </wd-upload> </wd-col> </view> </wd-row> <wd-popup v-model="show" custom-style="border-radius:32rpx;" @close="handleClose"> @@ -342,8 +319,9 @@ import RoutingInspectionApi from "@/api/routingInspection/routingInspection"; import Scan from "@/components/scan/index.vue"; import { useToast } from "wot-design-uni"; import AttachmentUpload from "../upload.vue"; // æ ¸å¿ç¶æ const paramsType = ref(""); const paramsId = ref(""); const recordData = ref<any>({ structureInfo: { files: [], structureRecordResult: {} } }); const show = ref(false); @@ -353,8 +331,10 @@ const deviceUid = ref(""); const scanRef = ref(); const toast = useToast(); const attachmentRef = ref<any>(null); const detailData = reactive<any>({}); const detailDataLoaded = ref(false); // 表åä¸´æ¶æ°æ®ï¼ç¼è¾æ¨¡å¼ç»å®ï¼ const formData = reactive({ twistDiameter: "", // ç»å¶å¤å¾ structureFormula: "", // æåç»æ @@ -365,7 +345,6 @@ sampleComplete: "", // æ ·åæ¯å¦é½å ¨ }); // éé¡¹æ°æ® const twistDirectionOptions = [ { label: "å·¦å", value: "å·¦å" }, { label: "å³å", value: "å³å" }, @@ -387,47 +366,40 @@ { label: "å¦", value: "å¦" }, ]; // åå¹¶åæéä»¶åæ°ä¸ä¼ éä»¶ const allFiles = computed(() => { return [...(recordData.value.structureInfo?.files || []), ...tempFiles.value]; }); // åå§åè¡¨åæ°æ®ï¼æ¥å£æ°æ®åæ¥å°è¡¨åï¼ const initFormData = () => { const structureResult = recordData.value.structureInfo?.structureRecordResult || {}; const inspectionResult = recordData.value.inspectionResult || {}; // åºç¡å¯ç¼è¾å段 formData.twistDiameter = inspectionResult.twistDiameter || ""; formData.structureFormula = structureResult.inspectStructure?.structureFormula || ""; formData.sampleComplete = inspectionResult.sampleComplete || ""; formData.conclusion = structureResult.conclusion || ""; // ä¿®å¤äº§åå¤è§åç»è®ºçæ°æ®æ ¼å¼ formData.productAppearance = Array.isArray(structureResult.productAppearance) ? structureResult.productAppearance : structureResult.productAppearance ? [structureResult.productAppearance] : []; // 循ç¯ç±»åæ®µï¼æ·±æ·è´é¿å åæ°æ®æ±¡æï¼ formData.structureItems = JSON.parse( JSON.stringify(structureResult.inspectStructure?.structureItems || []) ); formData.inspectTwist = JSON.parse(JSON.stringify(structureResult.inspectTwist || [])); // åå§åç»åæ°æ®ï¼ç¡®ä¿æå¼ï¼ formData.inspectTwist.forEach((item: any) => { if (!item.direction) item.direction = ""; }); }; // è·åè¯¦æ æ°æ® const getDetailData = async (id: string, deviceType: string) => { try { const response = await RoutingInspectionApi.getStrandedInspectionStructureInfoById({ id }); recordData.value = response.data; detailData.value = response.data.structureInfo; console.log("detailData.value", detailData.value); tempFiles.value = []; // æ¸ ç©ºä¸´æ¶æä»¶ initFormData(); // æ°æ®è¿åååå§å表å detailDataLoaded.value = true; // æ°æ®å è½½å®æåï¼æ¸²æåç»ä»¶ console.log("ç¶ç»ä»¶-æ°æ®å°±ç»ªåæå°"); } catch (error) { console.error("è·å详æ 失败:", error); uni.showToast({ title: "å 载失败", icon: "error" }); @@ -436,8 +408,14 @@ // 页é¢å è½½ onLoad((options: any) => { try { paramsId.value = options.id; paramsType.value = options.deviceType; getDetailData(options.id, options.deviceType); } catch (error) { console.error("è·å详æ 失败:", error); uni.showToast({ title: "å 载失败", icon: "error" }); } }); // ç¼è¾æ¨¡å¼åæ¢ @@ -448,8 +426,8 @@ // åæ¶ç¼è¾ï¼é置表åï¼ const close = () => { isEdit.value = false; tempFiles.value = []; // åæ¶æ¶æ¸ 空临æ¶ä¸ä¼ çæä»¶ initFormData(); // æ¢å¤åå§æ°æ® tempFiles.value = []; initFormData(); }; // ä¿åç¼è¾ï¼å«å¿ å¡«é¡¹æ ¡éªï¼ @@ -482,7 +460,9 @@ } console.log("1111", deviceUid.value); if (!deviceUid.value) return uni.showToast({ title: "è¯·æ«æäºç»´ç ", icon: "none" }); // 4. æäº¤æ°æ®å°æ¥å£ const { newFiles } = attachmentRef.value.getSubmitFiles(); console.log("newFiles", newFiles); const allFileIds = [...newFiles]; try { const res = await RoutingInspectionApi.strandedPatrolCheckInspection({ deviceUid: deviceUid.value, @@ -499,13 +479,13 @@ inspectionResult: { sampleComplete: formData.sampleComplete, }, processInspectionAttachmentList: tempFiles.value.map((f) => f.url), // æ°ä¸ä¼ çéä»¶ processInspectionAttachmentList: allFileIds, }); if (res.code === 200) { uni.showToast({ title: "ä¿åæå", icon: "success" }); isEdit.value = false; getDetailData(paramsId.value, recordData.value.deviceType); // å·æ°æ°æ® getDetailData(paramsId.value, paramsType.value); } else { uni.showModal({ title: res.msg || "ä¿å失败", icon: "error" }); } @@ -513,61 +493,6 @@ console.error("ä¿å失败:", e); uni.showModal({ title: e.message || "ä¿å失败", icon: "error" }); } }; // éä»¶ä¸ä¼ åç½®æ ¡éª const beforeUpload = (file: any) => { // éå¶å¾ç大å°ä¸è¶ è¿2M const maxSize = 2 * 1024 * 1024; if (file.size > maxSize) { uni.showToast({ title: "å¾ç大å°ä¸è½è¶ è¿2M", icon: "none" }); return false; } return true; }; // éä»¶ä¸ä¼ æååè° const handleUploadSuccess = (res: any) => { // å设æ¥å£è¿åæ ¼å¼: { url: 'xxx', id: 'xxx' } if (Array.isArray(res)) { tempFiles.value = [ ...tempFiles.value, ...res.map((file) => ({ ...file, id: `temp-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, // çæä¸´æ¶ID })), ]; } else { tempFiles.value.push({ ...res, id: `temp-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, }); } }; // éä»¶ä¸ä¼ 失败åè° const handleUploadFail = (err: any) => { uni.showToast({ title: "éä»¶ä¸ä¼ 失败", icon: "error" }); }; // å é¤éä»¶ const deleteFile = (id: string | number) => { // å é¤ä¸´æ¶æä»¶ tempFiles.value = tempFiles.value.filter((file) => file.id !== id); // 妿æ¯åææä»¶ï¼éè¦æ è®°å é¤ï¼å®é 项ç®ä¸å¯è½éè¦æ¥å£äº¤äºï¼ if (typeof id !== "string" || !id.startsWith("temp-")) { // è¿éå¯ä»¥å®ç°å é¤åææä»¶çé»è¾ recordData.value.structureInfo.files = recordData.value.structureInfo.files.filter( (file: any, index: number) => index !== id ); } }; // å¾çé¢è§ const previewImage = (url: string) => { previewImageUrl.value = url; show.value = true; }; const handleClose = () => { @@ -639,7 +564,7 @@ } catch (err) { console.error("JSONè§£æå¤±è´¥ï¼", err); toast.error("æ«ç æ°æ®å¼å¸¸"); return; // è§£æå¤±è´¥ç´æ¥è¿åï¼é¿å åç»é误 return; } deviceUid.value = codeObj?.uid; toast.success("æ«ç æå"); src/pages/routingInspection/detail/indexLS.vue
@@ -40,7 +40,6 @@ </view> </view> <view class="list"> <div class="inspection-report"> <!-- åºæ¬ä¿¡æ¯æ¨¡å --> <wd-row> <view style="margin: 10rpx"> @@ -140,9 +139,7 @@ </wd-checkbox-group> </template> <template v-else> {{ formatProductAppearance(detailData.inspectionResult?.appearance).join("ã") || "-" }} {{ formatProductAppearance(formData.appearance) }} </template> </wd-form-item> @@ -208,18 +205,9 @@ </template> </wd-form-item> <wd-form-item label="æåæ¨¡åæ¥å¤´æ åµ" prop="jointCondition" label-width="280rpx" required > <wd-form-item label="æåæ¨¡åæ¥å¤´æ åµ" prop="jointCondition" label-width="280rpx" required> <template v-if="isEdit"> <wd-radio-group v-model="formData.jointCondition" inline class="conclusion-radio-group" > <wd-radio-group v-model="formData.jointCondition" inline class="conclusion-radio-group"> <wd-radio v-for="(opt, idx) in jointConditionOptions" :key="idx" @@ -291,36 +279,15 @@ <view style="margin: 10rpx"> <text class="title">{{ "éä»¶" }}</text> </view> <view class="attachment-grid"> <wd-col v-for="(file, index) in detailData.files" :key="index" class="attachment-item"> <wd-img :width="80" :height="80" :src="file.url" @click="previewImage(file.url)"> <template #error><view class="error-wrap">å 载失败</view></template> <template #loading> <view class="loading-wrap"><wd-loading /></view> </template> </wd-img> <!-- <wd-icon v-if="isEdit" name="close-circle" class="delete-icon" @click.stop="deleteFile(index)" ></wd-icon> --> <wd-col :span="24"> <AttachmentUpload :detailData="detailData" :isEdit="isEdit" :deviceType="paramsType" ref="attachmentRef" /> </wd-col> <wd-col v-if="isEdit" class="attachment-item upload-btn"> <wd-upload :multiple="true" :max-count="5" :before-upload="beforeUpload" @success="handleUploadSuccess" @fail="handleUploadFail" accept="all" > <view class="upload-icon">+</view> </wd-upload> </wd-col> </view> </wd-row> </div> <wd-popup v-model="show" custom-style="border-radius:32rpx;" @close="handleClose"> <div class="image-preview"> <img :src="previewImageUrl" alt="é¢è§å¾ç" style="width: 100%; height: auto" /> @@ -337,8 +304,11 @@ import RoutingInspectionApi from "@/api/routingInspection/routingInspection"; import Scan from "@/components/scan/index.vue"; import { useToast } from "wot-design-uni"; import AttachmentUpload from "../upload.vue"; // æ ¸å¿ç¶æ const paramsId = ref(""); const paramsType = ref(""); const detailData = ref<any>({}); const show = ref(false); const previewImageUrl = ref(""); @@ -347,13 +317,14 @@ const deviceUid = ref(""); const scanRef = ref(); const toast = useToast(); const attachmentRef = ref<any>(null); // è¡¨åæ°æ® const formData = reactive({ dia: "", maxDia: "", minDia: "", appearance: "", appearance: [], windingTightness: "", arrangementNeatness: "", aluminumWireDistance: "", @@ -413,8 +384,8 @@ }; // æ ¼å¼åå·¥å · const formatProductAppearance = (productAppearance: string) => { return !productAppearance ? "-" : productAppearance; const formatProductAppearance = (productAppearance: string[]) => { return !productAppearance.length ? "-" : productAppearance.join("ã"); }; const formatValue = (value: any, unit?: string) => { @@ -438,7 +409,7 @@ formData.dia = inspectionResult.dia || ""; formData.maxDia = inspectionResult.maxDia || ""; formData.minDia = inspectionResult.minDia || ""; formData.appearance = inspectionResult.appearance || ""; formData.appearance = inspectionResult.appearance || []; formData.windingTightness = inspectionResult.windingTightness || ""; formData.arrangementNeatness = inspectionResult.arrangementNeatness || ""; formData.aluminumWireDistance = inspectionResult.aluminumWireDistance || ""; @@ -462,6 +433,7 @@ // 页é¢å è½½ onLoad((options: any) => { paramsId.value = options.id; paramsType.value = options.deviceType; getDetailData(options.id, options.deviceType); }); @@ -482,7 +454,7 @@ // æ ¡éª if (!formData.maxDia) return uni.showToast({ title: "æå¤§ç´å¾ä¸ºå¿ 填项", icon: "none" }); if (!formData.minDia) return uni.showToast({ title: "æå°ç´å¾ä¸ºå¿ 填项", icon: "none" }); if (!formData.appearance) return uni.showToast({ title: "å¤è§ä¸ºå¿ 填项", icon: "none" }); if (!formData.appearance.length) return uni.showToast({ title: "å¤è§ä¸ºå¿ 填项", icon: "none" }); if (!formData.windingTightness) return uni.showToast({ title: "å·ç»ç´§å¯ä¸ºå¿ 填项", icon: "none" }); if (!formData.arrangementNeatness) return uni.showToast({ title: "æåæ´é½ä¸ºå¿ 填项", icon: "none" }); @@ -493,6 +465,9 @@ if (!formData.conclusion) return uni.showToast({ title: "ç»è®ºä¸ºå¿ 填项", icon: "none" }); if (!formData.isFully) return uni.showToast({ title: "éææ ·åæ¯å¦é½å ¨ä¸ºå¿ 填项", icon: "none" }); if (!deviceUid.value) return uni.showToast({ title: "è¯·æ«æäºç»´ç ", icon: "none" }); const { newFiles } = attachmentRef.value.getSubmitFiles(); console.log("newFiles", newFiles); const allFileIds = [...newFiles]; // æäº¤ try { const res = await RoutingInspectionApi.drawPatrolCheckInspection({ @@ -510,12 +485,12 @@ conclusion: formData.conclusion, }, inspectionResult: { isFully: formData.isFully }, processInspectionAttachmentList: tempFiles.value.map((f) => f.url), processInspectionAttachmentList: allFileIds, }); if (res.code === 200) { uni.showToast({ title: "ä¿åæå", icon: "success" }); isEdit.value = false; getDetailData(paramsId.value, detailData.value.deviceType); getDetailData(paramsId.value, paramsType.value); } else { uni.showModal({ title: res.msg || "ä¿å失败", icon: "error" }); } @@ -523,56 +498,6 @@ console.error("ä¿å失败:", e); uni.showModal({ title: e.message || "ä¿å失败", icon: "error" }); } }; // éä»¶ä¸ä¼ æ ¡éª const beforeUpload = (file: any) => { const maxSize = 2 * 1024 * 1024; if (file.size > maxSize) { uni.showToast({ title: "å¾ç大å°ä¸è½è¶ è¿2M", icon: "none" }); return false; } return true; }; // éä»¶ä¸ä¼ æå const handleUploadSuccess = (res: any) => { if (Array.isArray(res)) { tempFiles.value = [ ...tempFiles.value, ...res.map((file) => ({ ...file, id: `temp-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, })), ]; } else { tempFiles.value.push({ ...res, id: `temp-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, }); } }; // éä»¶ä¸ä¼ 失败 const handleUploadFail = (err: any) => { uni.showToast({ title: "éä»¶ä¸ä¼ 失败", icon: "error" }); }; // å é¤éä»¶ const deleteFile = (index: number) => { if (index >= detailData.value.files.length) { tempFiles.value = tempFiles.value.filter( (_, idx) => idx !== index - detailData.value.files.length ); } else { detailData.value.files = detailData.value.files.filter((_, idx) => idx !== index); } }; // å¾çé¢è§ const previewImage = (url: string) => { previewImageUrl.value = url; show.value = true; }; const handleClose = () => { @@ -583,12 +508,10 @@ scanRef.value.triggerScan(); }; const getScanCode = (params: any) => { console.log("宿´åæ°ï¼", params); let codeObj = {}; try { codeObj = JSON.parse(params.code); } catch (err) { console.error("JSONè§£æå¤±è´¥ï¼", err); toast.error("æ«ç æ°æ®å¼å¸¸"); return; // è§£æå¤±è´¥ç´æ¥è¿åï¼é¿å åç»é误 } src/pages/routingInspection/upload.vue
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,359 @@ <template> <view class="attachment-container"> <!-- 头鍿ä½åº --> <view class="header-actions"> <wd-button icon="file-add" :round="false" size="small" custom-class="add_btn" @click="addAttachment" v-if="isEdit" > æ°å¢ </wd-button> </view> <!-- éä»¶å表 --> <view class="attachment-list"> <wd-status-tip v-if="attachmentList.length === 0" image="content" tip="ææ éä»¶" /> <wd-card v-for="item in attachmentList" :key="item.id" type="rectangle" custom-class="attachment-card" :border="false" > <view class="attachment-item" @click="previewAttachment(item)"> <view class="attachment-info"> <view class="attachment-name">{{ item.bucketFileName || item.name }}</view> <view class="attachment-meta"> <text class="file-type">{{ getFileType(item.bucketFileName) }}</text> <text class="upload-time">{{ formatTime(item.createTime) }}</text> </view> </view> <view class="attachment-actions" @click.stop v-if="isEdit"> <wd-icon name="delete" color="#ff4757" @click="deleteAttachment(item.id)" /> </view> </view> </wd-card> </view> <wd-toast /> </view> </template> <script setup lang="ts"> import { ref, onMounted } from "vue"; import { useToast } from "wot-design-uni"; import AttachmentAPI from "@/api/product/attachment"; // å¤é¨åæ° const props = defineProps({ detailData: { type: Object, default: () => ({}) }, isEdit: { type: Boolean, default: false }, deviceType: { type: String, default: "" }, }); const toast = useToast(); const attachmentList = props.deviceType == "1" ? ref<any[]>(props.detailData.value.files || []) : ref<any[]>(props.detailData.files || []); const attachmentIds = props.deviceType == "1" ? ref<string[]>(props.detailData.value.attachmentId || []) : ref<string[]>(props.detailData.attachmentId || []); // æ°å¢éä»¶ const addAttachment = () => { // æ¾ç¤ºéæ©æä»¶ç±»åçå¼¹çª uni.showActionSheet({ itemList: ["éæ©å¾ç", "éæ©è§é¢", "æç §", "å½å"], success: (res) => { switch (res.tapIndex) { case 0: // éæ©å¾ç chooseImages(); break; case 1: // éæ©è§é¢ chooseVideos(); break; case 2: // æç § takePhoto(); break; case 3: // å½å recordVideo(); break; } }, fail: (error) => { console.error("éæ©æä»¶ç±»å失败:", error); toast.show("éæ©æä»¶ç±»å失败"); }, }); }; // éæ©å¾ç const chooseImages = () => { uni.chooseImage({ count: 9, sizeType: ["original", "compressed"], sourceType: ["album"], success: async (res) => { const filePaths = Array.isArray(res.tempFilePaths) ? res.tempFilePaths : [res.tempFilePaths]; await handleFileUpload(filePaths); }, fail: (error) => { console.error("éæ©å¾ç失败:", error); toast.show("éæ©å¾ç失败"); }, }); }; // éæ©è§é¢ const chooseVideos = () => { uni.chooseVideo({ sourceType: ["album"], maxDuration: 60, camera: "back", success: async (res) => { await handleFileUpload([res.tempFilePath]); }, fail: (error) => { console.error("éæ©è§é¢å¤±è´¥:", error); toast.show("éæ©è§é¢å¤±è´¥"); }, }); }; // æç § const takePhoto = () => { uni.chooseImage({ count: 1, sizeType: ["original", "compressed"], sourceType: ["camera"], success: async (res) => { const filePaths = Array.isArray(res.tempFilePaths) ? res.tempFilePaths : [res.tempFilePaths]; await handleFileUpload(filePaths); }, fail: (error) => { console.error("æç §å¤±è´¥:", error); toast.show("æç §å¤±è´¥"); }, }); }; // å½å const recordVideo = () => { uni.chooseVideo({ sourceType: ["camera"], maxDuration: 60, camera: "back", success: async (res) => { await handleFileUpload([res.tempFilePath]); }, fail: (error) => { console.error("å½å失败:", error); toast.show("å½å失败"); }, }); }; // å¤çæä»¶ä¸ä¼ const handleFileUpload = async (filePaths: string[]) => { try { toast.show("æ£å¨ä¸ä¼ ..."); // ä¸ä¼ æä»¶ const uploadResults: any = await AttachmentAPI.uploadAttachmentFiles(filePaths); const result = uploadResults.map((it: any) => { return it.data; }); console.log("result", result); // æ´æ°éä»¶å表 const flattenedResult = result.flat(); attachmentList.value.push(...flattenedResult); console.log(attachmentList.value); // æåéä»¶ID attachmentIds.value = attachmentList.value.map((item: any) => item.id); toast.show("ä¸ä¼ æå"); console.log("111", attachmentIds.value.attachmentId); } catch (error) { console.error("ä¸ä¼ 失败:", error); toast.show("ä¸ä¼ 失败"); } }; // å é¤éä»¶ const deleteAttachment = async (aid: number) => { try { uni.showModal({ title: "确认å é¤", content: "ç¡®å®è¦å é¤è¿ä¸ªéä»¶åï¼", success: async (res) => { if (res.confirm) { // å端æå¨å é¤ï¼ç´æ¥ä»å表ä¸ç§»é¤è¿æ¡æ°æ® attachmentList.value = attachmentList.value.filter((item) => item.id !== aid); // è·åå©ä½çéä»¶IDç»å attachmentIds.value = attachmentList.value.map((item) => item.id).join(","); toast.show("å 餿å"); } }, }); console.log("111", attachmentIds.value.attachmentId); } catch (error) { console.error("å é¤å¤±è´¥:", error); toast.show("å é¤å¤±è´¥"); } }; // é¢è§éä»¶ const previewAttachment = (item: any) => { // æ ¹æ®æä»¶ç±»åè¿è¡é¢è§ const fileName = item.bucketFileName || item.name; const fileType = getFileType(fileName); if (fileType.startsWith("image")) { // å¾çé¢è§ uni.previewImage({ urls: [item.url], current: item.url, }); } else { // å ¶ä»æä»¶ç±»åï¼å¯ä»¥ä¸è½½ææå¼ uni.downloadFile({ url: item.url, success: (res) => { uni.openDocument({ filePath: res.tempFilePath, success: () => { console.log("æå¼ææ¡£æå"); }, fail: (error) => { console.error("æå¼ææ¡£å¤±è´¥:", error); toast.show("æ æ³é¢è§æ¤æä»¶ç±»å"); }, }); }, fail: (error) => { console.error("ä¸è½½æä»¶å¤±è´¥:", error); toast.show("ä¸è½½æä»¶å¤±è´¥"); }, }); } }; // è·åæä»¶ç±»å const getFileType = (fileName: string) => { if (!fileName) return "unknown"; const extension = fileName.split(".").pop()?.toLowerCase(); switch (extension) { case "jpg": case "jpeg": case "png": case "gif": case "bmp": case "webp": return "image"; case "pdf": return "pdf"; case "doc": case "docx": return "word"; case "xls": case "xlsx": return "excel"; case "ppt": case "pptx": return "powerpoint"; case "txt": return "text"; case "zip": case "rar": return "archive"; default: return "file"; } }; // æ ¼å¼åæä»¶å¤§å° const formatFileSize = (size: number) => { if (size < 1024) return size + " B"; if (size < 1024 * 1024) return (size / 1024).toFixed(1) + " KB"; return (size / (1024 * 1024)).toFixed(1) + " MB"; }; // æ ¼å¼åæ¶é´ const formatTime = (time: string) => { const date = new Date(time); return date.toLocaleString(); }; // 坹夿´é²æ¹æ³ï¼è·åææéæäº¤çæä»¶ const getSubmitFiles = () => ({ newFiles: attachmentIds.value || [], }); defineExpose({ getSubmitFiles }); </script> <style lang="scss" scoped> .attachment-container { padding: 12px; background: #f3f9f8; min-height: 100vh; } .header-actions { margin-bottom: 12px; :deep(.add_btn) { background: #0d867f; color: white; border: none; } } .attachment-list { .attachment-card { margin-bottom: 12px; border-radius: 4px; } } .attachment-item { display: flex; align-items: center; padding: 12px; .attachment-info { flex: 1; .attachment-name { font-size: 16px; font-weight: 500; color: #333; margin-bottom: 4px; word-break: break-all; } .attachment-meta { display: flex; gap: 12px; font-size: 12px; color: #999; } } .attachment-actions { margin-left: 12px; :deep(.wd-icon) { font-size: 20px; cursor: pointer; } } } </style>