Forráskód Böngészése

feat:文件上传限制图片类型

zhangxin 2 hónap óta
szülő
commit
47dfbbf32f

+ 5 - 0
components/order-file-upload/order-file-upload.vue

@@ -47,6 +47,11 @@
47 47
 				type: String,
48 48
 				default: '点击上传文件'
49 49
 			},
50
+			fileType: {
51
+				type: String,
52
+				default: 'all',
53
+				desc: '文件选择类型:all(所有)、image(图片)、video(视频)、audio(音频)、document(文档)等'
54
+			},
50 55
 		},
51 56
 		data() {
52 57
 			return {

+ 35 - 3
mixins/upload.js

@@ -20,9 +20,13 @@ export default {
20 20
         // H5 平台文件上传
21 21
         handleH5Upload() {
22 22
             console.log("H5 平台文件上传")
23
+            
24
+            // 根据fileType参数决定文件选择类型
25
+            const chooseType = this.fileType || 'all';
26
+            
23 27
             uni.chooseFile({
24 28
                 count: 100, // 最多可以选择100个文件
25
-                type: 'all', // 选择所有类型文件
29
+                type: chooseType, // 根据fileType选择文件类型:all, image, video, audio, document
26 30
                 success: async (res) => {
27 31
                     const { tempFilePaths, tempFiles } = res;
28 32
 
@@ -94,11 +98,39 @@ export default {
94 98
         // App 平台文件上传
95 99
         handleAppUpload() {
96 100
             const lemonjkFileSelect = uni.requireNativePlugin('lemonjk-FileSelect');
101
+            
102
+            // 根据fileType参数设置文件选择类型
103
+            let mimeType = "*/*";
104
+            let utisType = "public.data";
105
+            
106
+            switch (this.fileType) {
107
+                case 'image':
108
+                    mimeType = "image/*";
109
+                    utisType = "public.image";
110
+                    break;
111
+                case 'video':
112
+                    mimeType = "video/*";
113
+                    utisType = "public.movie";
114
+                    break;
115
+                case 'audio':
116
+                    mimeType = "audio/*";
117
+                    utisType = "public.audio";
118
+                    break;
119
+                case 'document':
120
+                    mimeType = "application/*";
121
+                    utisType = "public.data";
122
+                    break;
123
+                default:
124
+                    // 'all' 或其他未识别的类型
125
+                    mimeType = "*/*";
126
+                    utisType = "public.data";
127
+            }
128
+            
97 129
             //4.0.0+ 使用示例及高级筛选器配置示例
98 130
             lemonjkFileSelect.showNativePicker({
99 131
                 pathScope: "/DCIM/Camera",
100
-                mimeType: "*/*",
101
-                utisType: "public.data",
132
+                mimeType: mimeType,
133
+                utisType: utisType,
102 134
                 multi: 'yes'
103 135
             }, async result => {
104 136
                 const {

+ 4 - 4
pages/orderForm/index.vue

@@ -95,19 +95,19 @@
95 95
 		<!-- 文件上传区域 -->
96 96
 		<view class="upload_area" v-if="!sendFormId">
97 97
 			<!-- 聊天记录附件 -->
98
-			<order-file-upload title="聊天记录附件" orderFileType="1" :file-list="form.chatAttachmentList"
98
+			<order-file-upload title="聊天记录附件" orderFileType="1" fileType="image" :file-list="form.chatAttachmentList"
99 99
 				@update:fileList="updateChatFiles" tip-text="上传聊天截图、录音等文件"></order-file-upload>
100 100
 
101 101
 			<!-- 报价附件 -->
102
-			<order-file-upload title="报价附件" orderFileType="2" :file-list="form.quoteAttachmentList"
102
+			<order-file-upload title="报价附件" orderFileType="2" fileType="image" :file-list="form.quoteAttachmentList"
103 103
 				@update:fileList="updateQuoteFiles" tip-text="上传报价附件"></order-file-upload>
104 104
 
105 105
 			<!-- 高清图附件 -->
106
-			<order-file-upload title="高清图附件" orderFileType="3" :file-list="form.hdImageAttachmentList"
106
+			<order-file-upload title="高清图附件" orderFileType="3" fileType="image" :file-list="form.hdImageAttachmentList"
107 107
 				@update:fileList="updateHdImageFiles" tip-text="上传物品高清图片"></order-file-upload>
108 108
 
109 109
 			<!-- 其他附件 -->
110
-			<order-file-upload title="其他附件" orderFileType="4" :file-list="form.otherAttachmentList"
110
+			<order-file-upload title="其他附件" orderFileType="4" fileType="image" :file-list="form.otherAttachmentList"
111 111
 				@update:fileList="updateOtherFiles" tip-text="上传其他相关文件"></order-file-upload>
112 112
 		</view>
113 113
 

+ 7 - 2
pages/wareHouse/index.vue

@@ -120,7 +120,12 @@
120 120
 export default {
121 121
 	data() {
122 122
 		return {
123
-			wareHouseCard:{},
123
+			wareHouseCard:{
124
+				totalCost: '-',
125
+				uploadCostToday: '-',
126
+				outStockToday: '-',
127
+				totalNum: '-'
128
+			},
124 129
 			tabList: [
125 130
 				{ name: "全部" },
126 131
 				{ name: "腕表" },
@@ -211,7 +216,7 @@ export default {
211 216
 		},
212 217
 	},
213 218
 	mounted() {
214
-		this.getCard();
219
+		// this.getCard();
215 220
 	}
216 221
 };
217 222
 </script>