huangxw 2 săptămâni în urmă
părinte
comite
a32353b15e

+ 2 - 1
src/main.ts

@@ -5,7 +5,7 @@ import 'uno.css';
 import { previewImage, selectDictLabel, selectDictLabels } from './utils/ruoyi';
 import { useDict } from '@/utils/dict';
 import uviewPlus, { setConfig } from 'uview-plus';
-import { navigateBackOrHome, showToast } from '@/utils/common';
+import { getDateRangeFrt, navigateBackOrHome, showToast } from '@/utils/common';
 import routerGuard from '@/uni_modules/hh-router-guard/src/index';
 import { useInfoStore } from '@/store';
 const uviewProps: any = {
@@ -87,6 +87,7 @@ export function createApp() {
     app.config.globalProperties.selectDictLabels = selectDictLabels;
     app.config.globalProperties.useDict = useDict;
     app.config.globalProperties.previewImage = previewImage;
+    app.config.globalProperties.getDateRangeFrt = getDateRangeFrt;
     return {
         app,
         Pinia: { pinia },

+ 66 - 0
src/plant/models/batch-info-popup.vue

@@ -0,0 +1,66 @@
+<template>
+    <root-portal>
+        <up-popup :show="show" closeable round="0" @close="close">
+            <view>
+                <view class="pd-24">
+                    <view class="f-s-34 f-w-5 c-#333">查看批次信息</view>
+                    <view class="f-s-24 c-#999">若下列溯源信息有误,请前往相应位置修改。</view>
+                </view>
+                <scroll-view scroll-y style="max-height: 70vh;">
+                    <view class="pd3-0-24-24">
+                        <batch-info v-if="info" :info="info"></batch-info>
+                    </view>
+                </scroll-view>
+            </view>
+        </up-popup>
+    </root-portal>
+</template>
+<script lang="ts" setup>
+import { useClientRequest } from '@/utils/request';
+ import batchInfo from './batch-info.vue';
+const props = defineProps({
+    show: {
+        type: Boolean,
+        default: false,
+    },
+    packId: {
+        type: String,
+        default: '',
+    },
+    title: {
+        type: String,
+        default: '系统提示',
+    },
+    showTitle: {
+        type: Boolean,
+        default: true,
+    },
+    tabs: {
+        type: Array,
+        default: () => [],
+    },
+    mode: {
+        type: String,
+    }
+})
+const emit = defineEmits<{
+    // 关闭事件
+    (e: 'close'): void;
+    // 更新 show 状态
+    (e: 'update:show', value: boolean): void;
+}>();
+const close = () => {
+    emit('update:show', false);
+    emit('close');
+};
+const info = ref<any>(null);
+// 获取批次信息接口
+const getBatchInfo = async () => {
+    const res = await useClientRequest.get(`/plt-api/app/packTask/getPackTraceSimpleInfo/${props?.packId}`);
+    console.log(res);
+    info.value = res?.data;
+}
+onMounted(() => {
+    getBatchInfo()
+})
+</script>

+ 52 - 0
src/plant/models/batch-info.vue

@@ -0,0 +1,52 @@
+<template>
+    <view v-if="info">
+        <view class="f-s-30 pd2-16-0 info-border-bottom">
+            <span class="c-#666">品名:</span>
+            <span class="c-#333">{{ info?.proName }}</span>
+        </view>
+        <view class="f-s-30 pd2-16-0 info-border-bottom">
+            <span class="c-#666">批号:</span>
+            <span class="c-#333">{{ info?.batchSn }}</span>
+        </view>
+        <view class="f-s-30 pd2-16-0 info-border-bottom">
+            <span class="c-#666">规格等级:</span>
+            <span class="c-#333">{{ info?.proSpecn }}</span>
+        </view>
+        <view class="f-s-30 pd2-16-0 info-border-bottom">
+            <span class="c-#666">产地:</span>
+            <span class="c-#333">{{ info?.proAdcodeDesc || '-' }}</span>
+        </view>
+        <view class="f-s-30 pd2-16-0 info-border-bottom">
+            <span class="c-#666">数量(重量):</span>
+            <span class="c-#333">{{ info?.specn }}</span>
+        </view>
+        <view class="f-s-30 pd2-16-0 info-border-bottom">
+            <span class="c-#666">采收日期:</span>
+            <span class="c-#333">{{ getDateRangeFrt(info?.harvestDate, info?.harvestDateEnd)}}</span>
+        </view>
+        <view class="f-s-30 pd2-16-0 info-border-bottom">
+            <span class="c-#666">包装日期:</span>
+            <span class="c-#333">{{ getDateRangeFrt(info?.packagingDateStart, info?.packagingDateStart) }}</span>
+        </view>
+        <view class="f-s-30 pd2-16-0 info-border-bottom">
+            <span class="c-#666">保质期:</span>
+            <span class="c-#333">{{ info?.expireDate }}{{ info?.expireDateUnit }}</span>
+        </view>
+        <view class="f-s-30 pd2-16-0 info-border-bottom">
+            <span class="c-#666">企业名称:</span>
+            <span class="c-#333">{{ info?.cpyName }}</span>
+        </view>
+        <view v-if="info?.gapFlag" class="f-s-30 pd2-16-0 info-border-bottom">
+            <span class="c-#666">是否符合GAP要求:</span>
+            <span class="c-#333">{{ +info?.gapFlag ? '是' : '否' }}</span>
+        </view>
+    </view>
+</template>
+<script setup lang="ts">
+const props = defineProps({
+    info: {
+        type: Object,
+        default: () => null,
+    },
+});
+</script>

+ 19 - 11
src/plant/packaging/list/index.vue

@@ -25,18 +25,16 @@
             <up-swipe-action>
                 <up-swipe-action-item v-for="(item, index) in list" :key="index" :name="item?.id" :options="optionsActionTemp" @click="clickTempSwipe" class="mb-20 b-radius">
                     <view class="b-radius bg-#fff pd-20 p-rtv">
-                        <view class="d-flex j-sb a-c">
+                        <view class="d-flex j-sb a-c mb-20">
                             <view class="f-s-20 f-w-5">{{ selectDictLabel(pt_pack_ref_type, item.refType) }}</view>
                             <view class="f-s-22 c-#666">
-                                {{ item?.packagingDateStart }}
-                                <span>至</span>
-                                {{ item?.packagingDateEnd }}
+                                {{ getDateRangeFrt(item?.packagingDateStart, item?.packagingDateStart) }}
                                 <span>包装</span>
                             </view>
                         </view>
                         <view>
                             <view class="d-flex a-c">
-                                <view>
+                                <view class="flex1 ov-hd">
                                     <span></span>
                                     <span></span>
                                 </view>
@@ -78,14 +76,21 @@
                         <view class="pt-10 d-flex">
                             <view class="flex1"></view>
                             <view class="d-flex a-c">
-                                <up-button color="#18BECA">查看批次信息</up-button>
+                                <up-button
+                                    @click="
+                                        rowId = item.id;
+                                        showBatchInfo = true;
+                                    "
+                                    color="#18BECA"
+                                    >查看批次信息</up-button
+                                >
                                 <template v-if="item.refType == '2'">
-                                    <up-button class="ml-10" color="#37A954">立即打印</up-button>
-                                    <up-button class="ml-10" color="#37A954">查看打印记录</up-button>
+                                    <up-button v-if="+item?.actualCount - item?.printCount" class="ml-10" color="#37A954">立即打印</up-button>
+                                    <up-button v-if="+item?.printCount" class="ml-10" color="#37A954">查看打印记录</up-button>
                                 </template>
                                 <template v-if="item.refType == '1'">
-                                    <up-button class="ml-10" color="#91C747">批量关联</up-button>
-                                    <up-button class="ml-10" color="#91C747">查看关联记录</up-button>
+                                    <up-button v-if="+item?.planCount - item?.actualCount" class="ml-10" color="#91C747">批量关联</up-button>
+                                    <up-button v-if="+item?.actualCount" class="ml-10" color="#91C747">查看关联记录</up-button>
                                 </template>
                             </view>
                         </view>
@@ -101,15 +106,18 @@
         </template>
     </z-paging>
     <ut-suspension @click="$u.route({ url: '/plant/packaging/create/index' })"></ut-suspension>
+    <batch-info-popup v-if="showBatchInfo && rowId" :packId="rowId" v-model:show="showBatchInfo"></batch-info-popup>
 </template>
 <script setup lang="ts">
 import { useClientRequest } from '@/utils/request';
+import batchInfoPopup from '../../models/batch-info-popup.vue';
 const { proxy } = getCurrentInstance() as ComponentInternalInstance;
 const { pt_pack_ref_type } = toRefs<any>(proxy?.useDict('pt_pack_ref_type'));
 const list = ref<any[]>();
 const form = ref({ keyword: '', refType: '', codeStatus: '0' });
 const paging = ref();
-
+const rowId = ref('');
+const showBatchInfo = ref(false);
 const tabs = ref([
     { label: '待包装赋码', value: '0' },
     { label: '已完成', value: '1' },

+ 2 - 0
src/types/module.d.ts

@@ -2,6 +2,7 @@ import type { useDict } from '@/utils/dict';
 import type { addDateRange, handleTree, selectDictLabel, selectDictLabels, parseTime } from '@/utils/ruoyi';
 import type { getConfigKey, updateConfigByKey } from '@/api/system/config';
 import type { download as rd } from '@/utils/request';
+import { getDateRangeFrt, navigateBackOrHome } from '@/utils/common';
 
 declare module '@vue/runtime-core' {
     interface ComponentCustomProperties {
@@ -9,6 +10,7 @@ declare module '@vue/runtime-core' {
         selectDictLabel: typeof selectDictLabel;
         selectDictLabels: typeof selectDictLabels;
         navigateBackOrHome: typeof navigateBackOrHome;
+        getDateRangeFrt: typeof getDateRangeFrt;
         previewImage: typeof import('@/utils/ruoyi').previewImage;
     }
 }

+ 64 - 85
src/utils/common.ts

@@ -33,7 +33,7 @@ interface LocationResult {
 export function toast(content: string): void {
     uni.showToast({
         icon: 'none',
-        title: content
+        title: content,
     });
 }
 
@@ -55,7 +55,7 @@ export function showConfirm(content: string): Promise<UniApp.ShowModalRes> {
             confirmText: '确定',
             success: function (res) {
                 resolve(res);
-            }
+            },
         });
     });
 }
@@ -89,10 +89,7 @@ export function tansParams(params: Record<string, any>): string {
 /**
  * 更新当前用户信息
  */
-export const updateUserInfo = async (
-    store: StoreModule, 
-    storeType: string[] = ['user', 'cpy', 'cpyLi', 'vip', 'card']
-): Promise<void> => {
+export const updateUserInfo = async (store: StoreModule, storeType: string[] = ['user', 'cpy', 'cpyLi', 'vip', 'card']): Promise<void> => {
     let res: any = null;
     if (storeType.includes('user')) {
         res = await store.dispatch('getUserInfoBytoken');
@@ -112,49 +109,15 @@ export const updateUserInfo = async (
     if (storeType.includes('card')) {
         // 获取当前名片信息
         await store.dispatch('getCurrentCard');
-        
     }
 };
 
-// 判断是否是会员并且会员是否过期
-export function isVip(options: VipOptions | null): VipResult {
-    if (!options) {
-        return {
-            isVip: false,
-            text: '非会员单位'
-        };
-    }
-    const { vipReviewStatus, vipEndDate, vipLevelName, vipLevel } = options;
-    if (vipReviewStatus !== '1') {
-        return {
-            isVip: false,
-            text: '非会员单位'
-        };
-    } else {
-        const now = new Date().getTime();
-        const end = new Date(vipEndDate).getTime();
-        if (now > end) {
-            return {
-                isVip: false,
-                text: '非会员单位',
-                level: vipLevel
-            };
-        } else {
-            return {
-                isVip: true,
-                text: vipLevelName,
-                level: vipLevel
-            };
-        }
-    }
-}
-
 // 返回上一页失败返回首页
 export function navigateBackOrHome(): void {
     const pages = getCurrentPages();
     if (pages.length === 1) {
         uni.switchTab({
-            url: '/pages/plant/base/index'
+            url: '/pages/plant/base/index',
         });
     } else {
         uni.navigateBack();
@@ -165,7 +128,7 @@ export function navigateBackOrHome(): void {
 export function showToast(title: string): void {
     uni.showToast({
         icon: 'none',
-        title
+        title,
     });
 }
 
@@ -176,15 +139,15 @@ export function saveImagePath(url: string): void {
         success: function () {
             uni.showToast({
                 title: '保存成功',
-                icon: 'success'
+                icon: 'success',
             });
         },
         fail: function () {
             uni.showToast({
                 title: '保存失败',
-                icon: 'none'
+                icon: 'none',
             });
-        }
+        },
     });
 }
 
@@ -195,15 +158,15 @@ export function shareImagePath(url: string): void {
         success: function () {
             uni.showToast({
                 title: '分享成功',
-                icon: 'success'
+                icon: 'success',
             });
         },
         fail: function () {
             uni.showToast({
                 title: '分享失败',
-                icon: 'none'
+                icon: 'none',
             });
-        }
+        },
     });
 }
 
@@ -223,7 +186,7 @@ export function getRemainingDays(endTime: string | Date): number {
 export function uniPreviewImage(url: string): void {
     uni.previewImage({
         urls: [url],
-        current: url
+        current: url,
     });
 }
 
@@ -269,19 +232,19 @@ export function chooseAddress(): Promise<LocationResult> {
                                             },
                                             fail: (err) => {
                                                 reject(err);
-                                            }
+                                            },
                                         });
                                     } else {
                                         reject(new Error('用户未授权地理位置权限'));
                                     }
-                                }
+                                },
                             });
-                        }
+                        },
                     });
                 } else {
                     reject(err);
                 }
-            }
+            },
         });
     });
 }
@@ -293,15 +256,15 @@ export function navigateToWithToken(url: string): void {
             type: 'reLaunch',
             url: '/pages/login/login',
             params: {
-                redirect: encodeURIComponent(url)
-            }
+                redirect: encodeURIComponent(url),
+            },
         });
         return;
     }
-	uni.$u.route({
-		type: 'navigateTo',
-		url: url
-	});
+    uni.$u.route({
+        type: 'navigateTo',
+        url: url,
+    });
 }
 // 判断开启微信小程序权限功能,如果开启则返回true,否则先引导开启
 export const isOpenSetting = async (scope?: string): Promise<boolean> => {
@@ -317,7 +280,7 @@ export const isOpenSetting = async (scope?: string): Promise<boolean> => {
                     console.log(res, 'getSetting res');
                     resolve(!!(res.authSetting && (res.authSetting as any)[scope as string]));
                 },
-                fail: () => resolve(false)
+                fail: () => resolve(false),
             });
         });
         console.log(hasAuth, 'hasAuth');
@@ -329,13 +292,13 @@ export const isOpenSetting = async (scope?: string): Promise<boolean> => {
                 success: () => resolve(true),
                 fail: (res) => {
                     console.log(res);
-                    
-                    resolve(false)
-                }
+
+                    resolve(false);
+                },
             });
         });
         console.log(authorized, 'authorized');
-        
+
         if (authorized) return true;
 
         const goSetting = await new Promise<boolean>((resolve) => {
@@ -344,7 +307,7 @@ export const isOpenSetting = async (scope?: string): Promise<boolean> => {
                 content: '请打开手机自身定位并且点击右上角三个点,进入设置,允许小程序获取定位,并选择您的位置。',
                 confirmText: '去设置',
                 success: (mRes: UniApp.ShowModalRes) => resolve(!!mRes.confirm),
-                fail: () => resolve(false)
+                fail: () => resolve(false),
             });
         });
         if (!goSetting) return false;
@@ -354,7 +317,7 @@ export const isOpenSetting = async (scope?: string): Promise<boolean> => {
                 success: (setRes) => {
                     resolve(!!(setRes.authSetting && (setRes.authSetting as any)[scope as string]));
                 },
-                fail: () => resolve(false)
+                fail: () => resolve(false),
             });
         });
         return !!finalAuth;
@@ -365,7 +328,7 @@ export const isOpenSetting = async (scope?: string): Promise<boolean> => {
 
     // 非微信小程序平台默认返回可用
     return true;
-}
+};
 // 根据传入url获取文件后缀名,根据文件后缀名返回相应的图片icon
 export const getFileIconByUrl = (url: string) => {
     const fileExtension = url.substring(url.lastIndexOf('.') + 1).toLowerCase();
@@ -390,7 +353,7 @@ export const getFileIconByUrl = (url: string) => {
         DOCX: 'doc',
         XLS: 'xlsx',
         XLSX: 'xlsx',
-        TXT: 'txt'
+        TXT: 'txt',
     };
     return `https://ta.zycpzs.cn/oss-file/smart-trace/szyy/images/file-type-sub/${iconMap?.[fileExtension] || 'def'}.png`; // 默认图标
 };
@@ -400,29 +363,45 @@ export const getRect = (selector: string, all: boolean = false): Promise<UniApp.
         const instance = getCurrentInstance();
         const query = uni.createSelectorQuery().in(instance);
         if (all) {
-            query.selectAll(selector).boundingClientRect((res: any) => {
-                if (res) {
-                    resolve(res);
-                } else {
-                    reject('未找到节点信息');
-                }
-            }).exec();
+            query
+                .selectAll(selector)
+                .boundingClientRect((res: any) => {
+                    if (res) {
+                        resolve(res);
+                    } else {
+                        reject('未找到节点信息');
+                    }
+                })
+                .exec();
         } else {
-            query.select(selector).boundingClientRect((res: any) => {
-                if (res) {
-                    resolve(res);
-                } else {
-                    reject('未找到节点信息');
-                }
-            }).exec();
+            query
+                .select(selector)
+                .boundingClientRect((res: any) => {
+                    if (res) {
+                        resolve(res);
+                    } else {
+                        reject('未找到节点信息');
+                    }
+                })
+                .exec();
         }
     });
 };
 
 // 根据传入存放库房数组返回文字
-export const getStorageRoomNames = (rooms: Array<{ warehouseName?: string, shelvesName?: string, shelfId?: string, warehouseId?: string }>): string => {
+export const getStorageRoomNames = (rooms: Array<{ warehouseName?: string; shelvesName?: string; shelfId?: string; warehouseId?: string }>): string => {
     if (!rooms || rooms.length === 0) {
         return '';
     }
-    return rooms.map(room => (room.warehouseName || '') +  (room.shelvesName ? '-' : '') + (room.shelvesName || '')).join(',');
-}
+    return rooms.map((room) => (room.warehouseName || '') + (room.shelvesName ? '-' : '') + (room.shelvesName || '')).join(',');
+};
+// 根据开始日期结束日期返回字符串
+export const getDateRangeFrt = (startDate: string, endDate: string): string => {
+    if (!startDate || !endDate) {
+        return '-';
+    }
+    if (startDate === endDate) {
+        return startDate;
+    }
+    return `${startDate}至${endDate}`;
+};