Przeglądaj źródła

基地信息数据嵌套

huangxw 2 tygodni temu
rodzic
commit
c853e220a8

+ 16 - 10
src/components/ut-album/ut-album.vue

@@ -75,8 +75,11 @@ const inputValue = computed(() => (props.modelValue !== null && props.modelValue
 // 解析后缀,识别文件类型
 const getTypeByUrl = (url) => {
     if (!url) return 'file';
-    const u = (url.split('?')[0] || '').toLowerCase();
-    const ext = (u.split('.').pop() || '').trim();
+    // 清理可能包裹的引号并取无查询参数的部分
+    const cleaned = String(url).trim().replace(/^['"]+|['"]+$/g, '');
+    const u = (cleaned.split('?')[0] || '').toLowerCase();
+    // 提取扩展名并去除非字母数字的尾随字符(如引号)
+    let ext = (u.split('.').pop() || '').trim().replace(/[^a-z0-9]+$/g, '');
     const imgExt = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'svg'];
     const videoExt = ['mp4', 'mov', 'avi', 'mkv', 'webm', 'm4v'];
     if (imgExt.includes(ext)) return 'image';
@@ -96,23 +99,26 @@ const items = computed(() => {
         let size = undefined;
         let coverUrl = '';
         if (typeof raw === 'string') {
-            url = raw;
+            url = String(raw).trim().replace(/^['"]+|['"]+$/g, '');
         } else if (typeof raw === 'object') {
-            url = raw[props.keyName] || raw.url || '';
+            url = String(raw[props.keyName] || raw.url || '').trim().replace(/^['"]+|['"]+$/g, '');
             name = raw[props.nameKey] || raw.name || '';
             size = raw[props.sizeKey] || raw.size;
-            coverUrl = raw[props.coverKey] || raw.coverUrl || '';
+            coverUrl = String(raw[props.coverKey] || raw.coverUrl || '').trim().replace(/^['"]+|['"]+$/g, '');
         }
         if (!url) return;
         const originalUrl = (url.split('?')[0] || url);
         const type = getTypeByUrl(originalUrl);
+        
         out.push({ type, url, originalUrl, name, size, coverUrl });
     };
-    if (Array.isArray(v)) {
-        v.forEach(pushItem);
-    } else {
-        pushItem(v);
-    }
+        if (Array.isArray(v)) {
+            v.forEach(pushItem);
+        } else if (typeof v === 'string') {
+            v.split(',').forEach((s) => pushItem(s));
+        } else {
+            pushItem(v);
+        }
     return out;
 });
 

+ 6 - 2
src/components/ut-upload/ut-upload.vue

@@ -280,7 +280,7 @@ function emitCurrentValue() {
     const urls = validList.map((i) => i.url).filter(Boolean);
     let out: any;
     if (props.valueType === 'string') {
-        out = urls[0] || '';
+        out = props.multiple ? urls.join(',') : (urls[0] || '');
     } else if (props.valueType === 'array') {
         out = validList;
     } else {
@@ -298,7 +298,11 @@ watch(
         }
         if (props.valueType === 'string') {
             if (typeof val === 'string') {
-                fileList.value = val ? [{ url: val }] : [];
+                const parts = val
+                    .split(',')
+                    .map((s) => String(s).trim().replace(/^['"]+|['"]+$/g, ''))
+                    .filter((s) => !!s);
+                fileList.value = parts.map((u) => ({ url: u }));
             }
         } else if (props.valueType === 'array') {
             if (Array.isArray(val)) {

+ 8 - 6
src/plant/base/gap-base-info-detail/index.vue

@@ -6,7 +6,7 @@
             </template>
             <view class="p-rtv">
                 <!-- 基本信息 -->
-
+                <image class="gap_res_image w-160 h-160" :src="`/static/images/plant/base/gap_res${form.res}.png`" mode="widthFix" />
                 <view class="pd-24 bg-#fff mb-10">
                     <view class="f-s-30 pd2-16-0 info-border-bottom">
                         <span class="c-#666">基地类型:</span>
@@ -47,9 +47,9 @@
                         <span class="c-#666">基地经纬度:</span>
                         <span class="c-#333">E{{ form?.lng || '-' }}, N{{ form?.lat || '-' }}</span>
                     </view>
-                    <view v-if="form?.certFile?.length" class="f-s-30 pd2-16-0 info-border-bottom">
+                    <view v-if="form?.certFile" class="f-s-30 pd2-16-0 info-border-bottom">
                         <view class="f-s-30 c-#666 mb-10">官方公示证明材料</view>
-                        <ut-album :model-value="form?.certFile" :max-count="9"></ut-album>
+                        <ut-album :urls="form?.certFile"></ut-album>
                     </view>
                     <view v-if="form?.url" class="f-s-30 pd2-16-0 info-border-bottom">
                         <span class="c-#666">官方公示网址:</span>
@@ -125,8 +125,10 @@ const previewBasePic = () => {
 .gap-info-card {
     border: 1rpx solid rgba($u-primary, 0.4);
 }
-.ksqulc {
-    position: relative;
-    height: 100vh;
+
+.gap_res_image {
+    position: absolute;
+    right: 30rpx;
+    top: 30rpx;
 }
 </style>

+ 2 - 2
src/plant/base/gap-base-info/index.vue

@@ -20,7 +20,7 @@
             <template>
                 <view class="pl-25 pr-25">
                     <up-swipe-action>
-                        <up-swipe-action-item v-for="item in list" :name="item?.id" :key="item?.id" :disabled="item?.res == '1'" :options="optionsAction" @click="clickSwipe" class="mb-20 b-radius">
+                        <up-swipe-action-item v-for="item in list" :name="item?.id" :key="item?.id" :disabled="item?.res !== '2'" :options="optionsAction" @click="clickSwipe" class="mb-20 b-radius">
                             <view @click.stop="clickItem(item)" class="b-radius bg-#fff pd-20 p-rtv">
                                 <view class="c-#333 f-s-34 f-w-5 pb-5">{{ item?.gapBaseName }}</view>
                                 <view class="c-#999 f-s-24 pb-20">{{ item?.ratedDate }}获评</view>
@@ -130,7 +130,7 @@ const clickSwipe = async (event: object) => {
         console.log(res);
         
         if (res.confirm) {
-            const delRes = await useClientRequest.delete(`/plt-api/app/gapCertificationInfo/delById/${name}`);
+            const delRes = await useClientRequest.get(`/plt-api/app/gapCertificationInfo/delById/${name}`);
             if (delRes && delRes.code === 200) {
                 uni.showToast({ title: '删除成功', icon: 'none' });
                 onRefresh();

BIN
src/static/images/plant/base/gap_res0.png


BIN
src/static/images/plant/base/gap_res1.png


+ 3 - 0
src/utils/ruoyi.ts

@@ -413,6 +413,9 @@ export const recursiveDecodeURIComponentSimple = (obj: any): any => {
 };
 // 将url提取参数
 export const getUrlParams = (url: string): Record<string, string> => {
+    if (!url || typeof url !== 'string') {
+        return {};
+    }
     const params: Record<string, string> = {};
     const queryString = url.split('?')[1];
     if (!queryString) {