lisy 1 týždeň pred
rodič
commit
c9b4f20c72

+ 8 - 0
src/assets/styles/uview-plus.ts

@@ -5,4 +5,12 @@ export const formItemBtnStyle = {
     fontSize: '26rpx',
     padding: '0 20rpx',
     lineHeight: '50rpx',
+};
+
+export const formItemBtnListStyle = {
+    height: '68rpx',
+    fontSize: '30rpx',
+    lineHeight: '68rpx',
+    borderRadius: '10rpx',
+    padding: '0 20rpx',
 };

+ 2 - 2
src/components/ut-tabs/ut-tabs.vue

@@ -7,7 +7,7 @@
                         class="tab-label"
                         :style="{
                             fontSize: fontSize,
-                            color: idx === activeIndex ? themeColor : '#999',
+                            color: idx === activeIndex ? '#333' : '#999',
                             fontWeight: idx === activeIndex ? 'bold' : '500',
                         }"
                     >
@@ -51,7 +51,7 @@
                     class="tab-label"
                     :style="{
                         fontSize: fontSize,
-                        color: idx === activeIndex ? themeColor : '#999',
+                        color: idx === activeIndex ? '#333' : '#999',
                         fontWeight: idx === activeIndex ? 'bold' : '500',
                     }"
                 >

+ 15 - 2
src/plant/models/batch-info.vue

@@ -4,13 +4,26 @@
             <span class="c-#666">品名:</span>
             <span class="c-#333">{{ info?.proName || '-' }}</span>
         </view>
+        <view class="f-s-30 pd2-16-0 info-border-bottom">
+            <view class="c-#666 mb-10">基原:<span v-if="!info?.varietyInfo" class="c-#333">-</span></view>
+            <view v-if="info?.varietyInfo" class="bg-#FBFDFB card-info-block pd-24 p-rtv">
+                <view class="mb-10">
+                    <span class="f-s-34 c-#333 f-w-5 mr-16">{{ info?.varietyInfo?.varietyName }}</span>
+                    <span class="f-s-24 c-#666">{{ info?.varietyInfo?.latinName }}</span>
+                </view>
+                <view>
+                    <span class="f-s-28 c-#333 f-w-5 mr-16">{{ info?.varietyInfo?.genusName }}</span>
+                    <span class="f-s-24 c-#666">{{ info?.varietyInfo?.genusLatinName }}</span>
+                </view>
+            </view>
+        </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>
+            <span class="c-#333">{{ info?.proLevel || '-' }}</span>
         </view>
         <view class="f-s-30 pd2-16-0 info-border-bottom">
             <span class="c-#666">产地:</span>
@@ -22,7 +35,7 @@
         </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>
+            <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>

+ 84 - 0
src/plant/models/pack-card.vue

@@ -0,0 +1,84 @@
+<template>
+    <view v-if="item" @click="emit('click')">
+        <view class="d-flex j-sb a-c pr-24">
+            <view class="f-s-20 f-w-5 item-left-tag" :class="{[`bg-pack-${ item?.refType }`]: true }">{{ selectDictLabel(pt_pack_ref_type, item?.refType) }}</view>
+            <view class="f-s-22 c-#666">
+                {{ getDateRangeFrt(item?.packagingDateStart, item?.packagingDateStart) }}
+                <span>包装</span>
+            </view>
+        </view>
+        <view class="pd-20">
+            <view class="d-flex a-c">
+                <view class="flex1 ov-hd">
+                    <span class="f-s-34 c-#333 f-w-5 mr-10">{{ item?.proName || '-' }}</span>
+                    <span class="f-s-24 c-#666">{{ item?.proLevel || '-' }}</span>
+                </view>
+                <up-icon v-if="isArrow" name="arrow-right" color="#999" size="24rpx"></up-icon>
+            </view>
+            <view class="f-s-24 c-#666">{{ item?.proSpenc }}</view>
+            <view class="pd-6"></view>
+            <view class="f-s-28 pd2-4-0">
+                <span class="c-#666">成品批号:</span>
+                <span class="c-#333 f-w-5">{{ item?.batchSn }}</span>
+            </view>
+            <view class="f-s-28 pd2-4-0">
+                <span class="c-#666">包装批号:</span>
+                <span class="c-#333 f-w-5">{{ item?.packSn }}</span>
+            </view>
+            <view class="d-flex flex-wrap">
+                <view class="f-s-28 pd2-4-0 hcol-15">
+                    <span class="c-#666">包装规格:</span>
+                    <span class="c-#333 f-w-5">{{ item?.capacity }}{{ item?.storageUseUnit }}/{{ item?.unit }}</span>
+                </view>
+                <view class="f-s-28 pd2-4-0 hcol-15">
+                    <span class="c-#666">包装总总量:</span>
+                    <span class="c-#333 f-w-5">{{ item?.storageUseAmount }}{{ item?.storageUseUnit }}</span>
+                </view>
+                <view class="f-s-28 pd2-4-0 hcol-15">
+                    <span class="c-#666">分包数量:</span>
+                    <span class="c-#333 f-w-5">{{ item?.planCount }}{{ item?.unit }}</span>
+                </view>
+                <view v-if="item.refType == '1'" class="f-s-28 pd2-4-0 hcol-15">
+                    <span class="c-#666">待关联数量:</span>
+                    <span class="c-#333 f-w-5">{{ item?.planCount - item?.actualCount }}{{ item?.unit }}</span>
+                </view>
+                <view v-if="item.refType == '2'" class="f-s-28 pd2-4-0 hcol-15">
+                    <span class="c-#666">待打印数量:</span>
+                    <span class="c-#333 f-w-5">{{ item?.actualCount - item?.printCount }}{{ item?.unit }}</span>
+                </view>
+            </view>
+            <slot></slot>
+        </view>
+    </view>
+</template>
+<script lang="ts" setup>
+const props = defineProps({
+    item: {
+        type: Object,
+        default: () => null,
+    },
+    dict: {
+        type: Object,
+        default: () => null,
+    },
+    isArrow: {
+        type: Boolean,
+        default: false,
+    },
+});
+const { pt_pack_ref_type } = toRefs(props?.dict);
+const emit = defineEmits(['click']);
+</script>
+<style lang="scss" scoped>
+.item-left-tag {
+   padding: 6rpx 18rpx;
+   border-radius: 0 0 18rpx 0;
+   color: #fff;
+}
+.bg-pack-1 {
+    background-color: #2289E0;
+}
+.bg-pack-2 {
+    background-color: #37A954;
+}
+</style>

+ 1 - 1
src/plant/packaging/create/index.vue

@@ -92,7 +92,7 @@
                 <!-- 保质期 12月,数字加单位单位两个字段, expireDate,expireDateUnit -->
                 <view class="h-1" id="expireDatepppp"></view>
                 <view class="h-1" id="expireDateUnitpppp"></view>
-                <up-form-item label="保质期" prop="expireDate" required class="form-item-bottom-padding-0">
+                <up-form-item label="保质期" required class="form-item-bottom-padding-0">
                     <div class="flex1 d-flex a-c">
                         <div class="flex1 ov-hd">
                             <up-form-item prop="expireDate" border-bottom class="form-item-top-padding-0">

+ 33 - 2
src/plant/packaging/detail/index.vue

@@ -1,3 +1,34 @@
 <template>
-    <view>xx</view>
-</template>
+    <template v-if="viewMode == 'pack'">
+        <PackTestInfo v-if="form" :packId="did" :form="form" :dict="{ pt_pack_ref_type }" @changeTebs="changeTebs"></PackTestInfo>
+    </template>
+    <template v-if="viewMode == 'print'">
+        <PrintInfoPage v-if="form" :packId="did" :form="form" :dict="{ pt_pack_ref_type }" @changeTebs="changeTebs"></PrintInfoPage>
+    </template>
+</template>
+<script setup lang="ts">
+import { useClientRequest } from '@/utils/request';
+import { getUrlParams, recursiveDecodeURIComponent } from '@/utils/ruoyi';
+import PackTestInfo from './models/pack-test-info.vue';
+import PrintInfoPage from './models/print-info-page.vue';
+const viewMode = ref('print'); // print relate
+const { proxy } = getCurrentInstance() as ComponentInternalInstance;
+const { pt_pack_ref_type } = toRefs<any>(proxy?.useDict('pt_pack_ref_type'));
+const form = ref<any>(null);
+const did = ref('');
+// 获取详情(GAP获评信息)
+const getDetailById = async (id: string) => {
+    const res = await useClientRequest.get(`/plt-api/app/packTask/${id}`);
+    if (!res || res.code !== 200) return;
+    form.value = res.data || {};
+};
+onLoad((options: any) => {
+    did.value = options?.id || getUrlParams(recursiveDecodeURIComponent(options?.q))?.id || '';
+    viewMode.value = options?.viewMode || getUrlParams(recursiveDecodeURIComponent(options?.q))?.viewMode || 'pack';
+    getDetailById(did.value);
+});
+const changeTebs = (view: string) => {
+    viewMode.value = view;
+}
+</script>
+<style lang="scss" scoped></style>

+ 82 - 0
src/plant/packaging/detail/models/pack-test-info.vue

@@ -0,0 +1,82 @@
+<template>
+    <z-paging ref="paging" bgColor="#F7F7F7" safe-area-inset-bottom  scroll-with-animation>
+        <template #top>
+            <ut-navbar title="包装任务详情" :fixed="false" border></ut-navbar>
+        </template>
+        <view class="d-flex a-c pd3-30-24-0 f-s-30 f-w-5">
+            <view @click="changeTebs" class="pd2-20-36 card-item-box mr-10">{{ form?.refType == '2' ? '打印详情' : '关联详情' }}</view>
+            <view class="pd2-20-36 card-item-box active">包装任务信息</view>
+        </view>
+        <view class="bg-fff pd-24">
+            <view class="f-s-30 pd2-16-0 info-border-bottom">
+                <span class="c-#666">包装对象:</span>
+                <span class="c-#333">挖个坑</span>
+            </view>
+            <view class="f-s-30 pd2-16-0 info-border-bottom">
+                <span class="c-#666">本次包装使用量:</span>
+                <span class="c-#333">{{ form?.storageUseAmount }}{{ form?.storageUseUnit }}</span>
+            </view>
+            <view class="f-s-30 pd2-16-0 info-border-bottom">
+                <span class="c-#666">包装规格:</span>
+                <span class="c-#333">{{ form?.capacity }}{{ form?.storageUseUnit }}/{{ form?.unit }}</span>
+            </view>
+            <view class="f-s-30 pd2-16-0 info-border-bottom">
+                <span class="c-#666">包装日期:</span>
+                <span class="c-#333">{{ getDateRangeFrt(form?.packagingDateStart, form?.packagingDateStart) }}</span>
+            </view>
+            <view class="f-s-30 pd2-16-0 info-border-bottom">
+                <span class="c-#666">包装批号:</span>
+                <span class="c-#333">{{ form?.packSn || '-' }}</span>
+            </view>
+            <view class="f-s-30 pd2-16-0 info-border-bottom">
+                <span class="c-#666">成品批号:</span>
+                <span class="c-#333">{{ form?.batchSn || '-' }}</span>
+            </view>
+            <view class="f-s-30 pd2-16-0 info-border-bottom">
+                <span class="c-#666">保质期:</span>
+                <span class="c-#333">{{ form?.expireDate || '-' }}{{ form?.expireDateUnit }}</span>
+            </view>
+            <view class="f-s-30 pd2-16-0 info-border-bottom">
+                <span class="c-#666">赋码方式:</span>
+                <span class="c-#333">{{ selectDictLabel(pt_pack_ref_type, form?.refType) }}</span>
+            </view>
+        </view>
+    </z-paging>
+</template>
+<script setup lang="ts">
+import { useClientRequest } from '@/utils/request';
+const paging = ref(null);
+const props = defineProps({
+    packId: {
+        type: String,
+        default: '',
+    },
+    form: {
+        type: Object,
+        default: () => null,
+    },
+    dict: {
+        type: Object,
+        default: () => null,
+    },
+});
+const { pt_pack_ref_type } = toRefs(props?.dict);
+const emit = defineEmits(['changeTebs']);
+const changeTebs = () => {
+    if (props?.form?.refType == '2') {
+        emit('changeTebs', 'print');
+    }
+    
+};
+</script>
+<style lang="scss" scoped>
+.card-item-box {
+    color: #999;
+    border-radius: 10rpx 10rpx 0 0;
+
+    &.active {
+        color: $u-primary;
+        background-color: #fff;
+    }
+}
+</style>

+ 143 - 0
src/plant/packaging/detail/models/print-info-page.vue

@@ -0,0 +1,143 @@
+<template>
+    <z-paging
+        ref="paging"
+        bgcolor="#F7F7F7"
+        v-model="list"
+        @query="query"
+        safe-area-inset-bottom
+        scroll-with-animation
+    >
+        <template #top>
+            <ut-navbar title="包装任务详情" :fixed="false" border></ut-navbar>
+        </template>
+        <view class="d-flex a-c pd3-30-24-0 f-s-30 f-w-5">
+            <view
+                class="pd2-20-36 card-item-box mr-10 active"
+            >{{ form?.refType == '2' ? '打印详情' : '关联详情' }}</view>
+            <view @click="changeTebs" class="pd2-20-36 card-item-box">包装任务信息</view>
+        </view>
+        <view class="bg-fff pd-24">
+            <view class="detail-info-card ov-hd p-rtv mb-40">
+                <pack-card :item="form" :dict="dict"></pack-card>
+                <view>
+                    <view class></view>
+                    <view></view>
+                    <view></view>
+                </view>
+            </view>
+            <view
+                class="d-flex a-c pd2-10-0 j-ed"
+                @click="$u.route({ url: '/tools/view-html/index', params: { url: 'https://ta.zycpzs.cn/oss-file/smart-trace/szyy/template/pack_code_type.html', title: '赋码方式区别' } })"
+            >
+                <up-icon size="28rpx" name="question-circle" color="#999"></up-icon>
+                <span class="c-#999 f-s-24">三种打印方式的区别?怎么选择?</span>
+            </view>
+            <view class="mb-20">
+                <ut-tabs v-model="printType" :tabs="tabs" @change="onRefresh"></ut-tabs>
+            </view>
+            <view>
+                <template v-for="(item, index) in list" :key="index">
+                    <template v-if="item?.printType == '1'">
+                        <view class="mb-20 pd-20 bg-#F7F7F7 b-radius">
+                            <view class="f-s-28 pd2-4-0">
+                                <span class="c-#666">打印数量:</span>
+                                <span class="c-#333 f-w-5">{{ item?.printCount }}</span>
+                            </view>
+                            <view class="f-s-28 pd2-4-0 d-flex">
+                                <span class="c-#666">打印码值:</span>
+                                <view class="flex1 ov-hd c-#333 f-w-5">
+                                    <view>{{ item?.traceCodeStart }} 至</view>
+                                    <view>{{ item?.traceCodeEnd }}</view>
+                                </view>
+                            </view>
+                            <view class="d-flex f-s-24 c-#666">
+                                <view class="flex1 ov-hd">打印人:{{ item?.createByName || '-' }}</view>
+                                <view class="pr-100">打印时间:{{ item?.createTime || '-' }}</view>
+                            </view>
+                             <view class="pt-20 d-flex">
+                                <view class="flex1"></view>
+                                <view class="d-flex a-c">
+                                    <up-button :customStyle="formItemBtnListStyle" class="ml-20" color="#18BECA">全部打印</up-button>
+                                    <up-button @click="$u.route({ url: '/plant/print/print-range/index', params: item })" :customStyle="formItemBtnListStyle" class="ml-20" color="#37A954">区间打印</up-button>
+                                </view>
+                            </view>
+                        </view>
+                    </template>
+                    <template></template>
+                    <template></template>
+                </template>
+            </view>
+        </view>
+    </z-paging>
+</template>
+<script setup lang="ts">
+import { useClientRequest } from "@/utils/request";
+import PackCard from "@/plant/models/pack-card.vue";
+import { formItemBtnListStyle } from "@/assets/styles/uview-plus";
+
+const paging = ref(null);
+const props = defineProps({
+    packId: {
+        type: String,
+        default: ""
+    },
+    form: {
+        type: Object,
+        default: () => null
+    },
+    dict: {
+        type: Object,
+        default: () => null
+    }
+});
+const printType = ref("1");
+const { pt_pack_ref_type } = toRefs(props?.dict);
+const emit = defineEmits(["changeTebs"]);
+const tabs = reactive([
+    { label: "打印记录", value: "1" },
+    { label: "导出记录", value: "2" },
+    { label: "找人代打记录", value: "3" }
+]);
+const changeTebs = () => {
+    emit("changeTebs", "pack");
+};
+const list = ref([]);
+const query = async (pageNum: number, pageSize: number) => {
+    const params = {
+        pageNum,
+        pageSize,
+        packId: props.packId,
+        printType: printType.value
+    };
+    const res = await useClientRequest.get(
+        "/plt-api/app/printLog/list",
+        params
+    );
+    if (res && res?.rows) {
+        const { rows } = res;
+        paging.value.complete(rows);
+    }
+};
+const onRefresh = () => {
+    try {
+        paging.value?.reload();
+    } catch (error) {
+        console.error("刷新列表失败:", error);
+    }
+};
+</script>
+<style lang="scss" scoped>
+.card-item-box {
+    color: #999;
+    border-radius: 10rpx 10rpx 0 0;
+
+    &.active {
+        color: $u-primary;
+        background-color: #fff;
+    }
+}
+.detail-info-card {
+    border-radius: 16rpx;
+    border: 1rpx solid #9dd5ab;
+}
+</style>

+ 25 - 68
src/plant/packaging/list/index.vue

@@ -24,76 +24,30 @@
         <view class="pd-24 bg-#f7f7f7">
             <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 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">
-                                {{ getDateRangeFrt(item?.packagingDateStart, item?.packagingDateStart) }}
-                                <span>包装</span>
-                            </view>
-                        </view>
-                        <view>
-                            <view class="d-flex a-c">
-                                <view class="flex1 ov-hd">
-                                    <span></span>
-                                    <span></span>
-                                </view>
-                                <up-icon name="arrow-right"></up-icon>
-                            </view>
-                            <view class="pd-6"></view>
-                            <view class="f-s-28 pd2-4-0">
-                                <span class="c-#666">成品批号:</span>
-                                <span class="c-#333 f-w-5">{{ item?.batchSn }}</span>
-                            </view>
-                            <view class="f-s-28 pd2-4-0">
-                                <span class="c-#666">包装批号:</span>
-                                <span class="c-#333 f-w-5">{{ item?.packSn }}</span>
-                            </view>
-                            <view class="d-flex flex-wrap">
-                                <view class="f-s-28 pd2-4-0 hcol-15">
-                                    <span class="c-#666">包装规格:</span>
-                                    <span class="c-#333 f-w-5">{{ item?.capacity }}{{ item?.storageUseUnit }}/{{ item?.unit }}</span>
-                                </view>
-                                <view class="f-s-28 pd2-4-0 hcol-15">
-                                    <span class="c-#666">包装总总量:</span>
-                                    <span class="c-#333 f-w-5">{{ item?.storageUseAmount }}{{ item?.storageUseUnit }}</span>
-                                </view>
-                                <view class="f-s-28 pd2-4-0 hcol-15">
-                                    <span class="c-#666">分包数量:</span>
-                                    <span class="c-#333 f-w-5">{{ item?.planCount }}{{ item?.unit }}</span>
-                                </view>
-                                <view v-if="item.refType == '1'" class="f-s-28 pd2-4-0 hcol-15">
-                                    <span class="c-#666">待关联数量:</span>
-                                    <span class="c-#333 f-w-5">{{ item?.planCount - item?.actualCount }}{{ item?.unit }}</span>
-                                </view>
-                                <view v-if="item.refType == '2'" class="f-s-28 pd2-4-0 hcol-15">
-                                    <span class="c-#666">待打印数量:</span>
-                                    <span class="c-#333 f-w-5">{{ item?.actualCount - item?.printCount }}{{ item?.unit }}</span>
+                    <view @click="$u.route({ url: '/plant/packaging/detail/index', params: { id: item?.id } })" class="b-radius bg-#fff p-rtv">
+                        <pack-card :item="item" :dict="{ pt_pack_ref_type }" isArrow>
+                            <view class="h-1 bg-#F7F7F7 mg2-10-0"></view>
+                            <view class="pt-10 d-flex">
+                                <view class="flex1"></view>
+                                <view class="d-flex a-c" @click.stop>
+                                    <up-button
+                                        @click="
+                                            rowId = item.id;
+                                            showBatchInfo = true;
+                                        "
+                                        color="#18BECA"
+                                        >查看批次信息</up-button>
+                                    <template v-if="item.refType == '2'">
+                                        <up-button :customStyle="formItemBtnListStyle" v-if="+item?.actualCount - item?.printCount" @click.stop="$u.route({ url: '/plant/print/print-self/index', params: { packId: item?.id, autoRelationId: item?.autoRelationId, unit: item?.unit, printedCount: item?.actualCount - item?.printCount } })" class="ml-10" color="#37A954">立即打印</up-button>
+                                        <up-button :customStyle="formItemBtnListStyle" v-if="+item?.printCount" @click="$u.route({ url: '/plant/packaging/detail/index', params: { id: item?.id, viewMode: 'print' } })" class="ml-10" color="#37A954">查看打印记录</up-button>
+                                    </template>
+                                    <template v-if="item.refType == '1'">
+                                        <up-button :customStyle="formItemBtnListStyle" v-if="+item?.planCount - item?.actualCount" class="ml-10" color="#91C747">批量关联</up-button>
+                                        <up-button :customStyle="formItemBtnListStyle" v-if="+item?.actualCount" class="ml-10" color="#91C747">查看关联记录</up-button>
+                                    </template>
                                 </view>
                             </view>
-                        </view>
-                        <view class="h-1 bg-#F7F7F7 mg2-10-0"></view>
-                        <view class="pt-10 d-flex">
-                            <view class="flex1"></view>
-                            <view class="d-flex a-c">
-                                <up-button
-                                    @click="
-                                        rowId = item.id;
-                                        showBatchInfo = true;
-                                    "
-                                    color="#18BECA"
-                                    >查看批次信息</up-button
-                                >
-                                <template v-if="item.refType == '2'">
-                                    <up-button v-if="+item?.actualCount - item?.printCount" @click="$u.route({ url: '/plant/print/print-self/index', params: { packId: item?.id, autoRelationId: item?.autoRelationId, unit: item?.unit, printedCount: 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 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>
+                        </pack-card>
                     </view>
                 </up-swipe-action-item>
             </up-swipe-action>
@@ -111,6 +65,9 @@
 <script setup lang="ts">
 import { useClientRequest } from '@/utils/request';
 import batchInfoPopup from '../../models/batch-info-popup.vue';
+import PackCard from '@/plant/models/pack-card.vue';
+import { formItemBtnListStyle } from '@/assets/styles/uview-plus';
+
 const { proxy } = getCurrentInstance() as ComponentInternalInstance;
 const { pt_pack_ref_type } = toRefs<any>(proxy?.useDict('pt_pack_ref_type'));
 const list = ref<any[]>();

+ 16 - 1
src/plant/print/models/connect-printer.vue

@@ -15,7 +15,6 @@
             <up-button @click="handleStartSearch" class="mb-30" type="primary" :disabled="isConnected">
                 {{ isSearching ? '搜索中...' : '开始搜索' }}
             </up-button>
-            <up-button v-if="isConnected" @click="handleDisconnect" class="mb-30" type="warning"> 断开连接 </up-button>
             <view class="d-flex a-c j-c">
                 <up-button @click="prevSteps" class="mr-30" plain type="primary">上一步</up-button>
                 <up-button @click="nextSteps" type="primary">下一步</up-button>
@@ -253,6 +252,7 @@ const handleDisconnect = async () => {
     connectedDevice.value = null;
 };
 const nextSteps = () => {
+<<<<<<< HEAD
     // if (!connectedDevice.value) {
     //     toast('请先连接设备');
     //     return;
@@ -266,6 +266,21 @@ const nextSteps = () => {
         nextStepValue: props.nextStepValue || 'print',
 
     });
+=======
+    if (!connectedDevice.value || !connectedDevice.value?.deviceId || !connectedDevice.value?.serviceId) {
+        toast('请先连接设备');
+        return;
+    }
+   emit('next', {
+      info: {
+        ...props.info,
+        status: 'completed',
+        device: connectedDevice.value
+      },
+      nextStepValue: props.nextStepValue || 'print',
+     
+   });
+>>>>>>> 42a6860549d82abd37fa4869d071b529277a834e
 };
 const prevSteps = () => {
     emit('prev', {

+ 1 - 1
src/plant/print/models/print-confirm-count.vue

@@ -1,6 +1,6 @@
 <template>
     <view class="pd-24 bg-fff">
-        <up-form class="p-rtv bg-#fff" labelPosition="top" :model="form" :rules="rules" labelWidth="auto" ref="upFormUpRef">
+        <up-form class="p-rtv bg-#fff" labelPosition="top" :model="form" errorType="toast" :rules="rules" labelWidth="auto" ref="upFormUpRef">
             <view class="f-s-24 c-#999">自行打印功能目前仅适配<span class="c-#333">佳博GP-M322打印机</span>,且标签显示字段 会根据不同规格纸张大小调整。如有疑问,请<span class="c-primary">点击此处联系客服</span>。</view>
             <up-form-item :label="`待打印数量`" borderBottom>
                 <view class="f-s-30 c-#333 f-w-5">{{ opts?.printedCount }}</view>

+ 117 - 0
src/plant/print/models/range-print.vue

@@ -0,0 +1,117 @@
+<template>
+    <view class="pd-24 bg-fff">
+        <up-form class="p-rtv bg-#fff" labelPosition="top" :model="form" :rules="rules" errorType="toast" labelWidth="auto" ref="upFormUpRef">
+            <up-form-item label="打印追溯码" required class="form-item-bottom-padding-0">
+                <div class="flex1 d-flex a-c">
+                    <div class="flex1 ov-hd">
+                        <up-form-item prop="start" border-bottom class="form-item-top-padding-0">
+                            <up-input v-model="form.start" placeholder="7位追溯码起始序号" border="none" clearable></up-input>
+                        </up-form-item>
+                    </div>
+                    <div class="pd2-0-10 f-s-30 c-#333">至</div>
+                    <div class="flex1 ov-hd">
+                        <up-form-item prop="end" border-bottom class="form-item-top-padding-0">
+                            <up-input v-model="form.end" placeholder="7位追溯码结束序号" border="none" clearable></up-input>
+                        </up-form-item>
+                    </div>
+                </div>
+            </up-form-item>
+            <view v-if="opts" class="f-s-30 f-w-5 pt-30">
+                <span>可打印范围:</span>
+                <span class="c-primary">{{ opts?.startSn.toString().padStart(7, '0') }}</span>
+                <span class="c-primary pd2-0-10">-</span>
+                <span class="c-primary">{{ opts?.endSn.toString().padStart(7, '0') }}</span>
+            </view>
+        </up-form>
+    </view>
+    <view class="pd3-40-24-30">
+        <up-button type="primary" @click="submitForm">下一步</up-button>
+    </view>
+</template>
+<script setup lang="ts">
+
+const props = defineProps({
+    info: {
+        type: Object,
+        default: () => null,
+    },
+    nextStepValue: {
+        type: String,
+        default: '',
+    },
+    prevStepValue: {
+        type: String,
+        default: '',
+    },
+    item: {
+        type: Object,
+        default: () => null,
+    },
+    opts: {
+        type: Object,
+        default: () => null,
+    },
+});
+const upFormUpRef = ref();
+const emit = defineEmits(['next', 'prev', 'formdata']);
+const form = ref({
+    start: '',
+    end: '',
+});
+const rules = reactive({
+    start: [
+        { required: true, message: '请输入追溯码起始序号', trigger: 'blur' },
+        {
+            asyncValidator (rule: any, value: string, callback: any) { 
+                if (!value) {
+                    return callback(new Error('请输入追溯码起始序号'));
+                }
+                if (!/^\d{1,7}$/.test(value)) {
+                    return callback(new Error('请输入7位始序号'));
+                }
+                if (Number(value) < +props.opts?.startSn || Number(value) > +props.opts?.endSn) {
+                    return callback(new Error(`请输入${props.opts?.startSn.toString().padStart(7, '0')}-${props.opts?.endSn.toString().padStart(7, '0')}的序号`));
+                }
+                callback();
+            },
+        }
+    ],
+    end: [
+        { required: true, message: '请输入追溯码结束序号', trigger: 'blur' },
+        {
+            asyncValidator (rule: any, value: string, callback: any) { 
+                if (!value) {
+                    return callback(new Error('请输入追溯码结束序号'));
+                }
+                if (!/^\d{1,7}$/.test(value)) {
+                    return callback(new Error('请输入7位结束序号'));
+                }
+                if (Number(value) < +props.opts?.startSn || Number(value) > +props.opts?.endSn) {
+                    return callback(new Error(`请输入${props.opts?.startSn.toString().padStart(7, '0')}-${props.opts?.endSn.toString().padStart(7, '0')}的序号`));
+                }
+                callback();
+            }
+        }
+    ]
+
+});
+const submitForm = async () => {
+    try {
+        await upFormUpRef.value?.validate();
+    } catch (error: any) {
+        return;
+    }
+    emit('formdata', {
+        ...form.value,
+    });
+    emit('next', {
+        info: {
+            ...props.info,
+            status: 'completed',
+        },
+        nextStepValue: props.nextStepValue || 'print',
+    });
+};
+
+onMounted(() => {});
+</script>

+ 87 - 46
src/plant/print/print-range/index.vue

@@ -1,21 +1,21 @@
 <template>
-    <z-paging ref="paging" bgColor="#fff" safe-area-inset-bottom scroll-with-animation>
+    <z-paging ref="paging" bgColor="#f7f7f7" safe-area-inset-bottom scroll-with-animation>
         <template #top>
             <ut-navbar :title="stepsObject[currentStep].title" :fixed="false" border :breadcrumb="false"></ut-navbar>
-            <view class="pd-24">
-                <ut-steps-title :stepsObject="stepsObject"></ut-steps-title>
-            </view>
-            <view class="pd-5 bg-#f7f7f7"></view>
+            <view class="pd-5"></view>
         </template>
         <view>
-            <view v-show="currentStep === 'connect'">
+            <view v-show="currentStep === 'range'">
+                <range-print :info="stepsObject[currentStep]" :opts="opts" @next="nextSteps" @formdata="getFormData"  nextStepValue="connect"></range-print>
+            </view>
+            <view v-show="currentStep === 'connect'" class="bg-fff">
                 <!-- 业务组件链接打印机 -->
-                <connect-printer :info="stepsObject[currentStep]" @next="nextSteps" @prev="prevSteps" prevStepValue="confirm" nextStepValue="print"></connect-printer>
+                <connect-printer :info="stepsObject[currentStep]" @next="nextSteps" @prev="prevSteps" prevStepValue="range" nextStepValue="print"></connect-printer>
             </view>
-            <view v-show="currentStep === 'print'">
+            <view v-show="currentStep === 'print'" class="bg-fff">
                 <!-- 业务组件打印 -->
                 <!-- 打印写入打印机 -->
-                <print-wrapper :info="stepsObject[currentStep]" @test="printTest" @prev="prevSteps" prevStepValue="connect"></print-wrapper>
+                <print-wrapper :info="stepsObject[currentStep]" :printCount="form?.printCount" @test="printTest" @prev="prevSteps" @print="printCodes" prevStepValue="connect"></print-wrapper>
             </view>
         </view>
     </z-paging>
@@ -27,23 +27,48 @@ import { tem30x30, tem60x40, tem60x60 } from '../models/print-tem';
 import PrintWrapper from '../models/print-wrapper.vue';
 import { writeBLECharacteristicSend } from '@/utils/blue-device-services';
 import jpPrinter from '../models/tspl';
+import { useClientRequest } from '@/utils/request';
+import RangePrint from '../models/range-print.vue';
+const printSpec = ref('30x30');
+const printCodes = async (data: any) => {
+    printSpec.value = data.printSpec;
+    // 检查是否正在打印
+    if (isPrinting.value) {
+        uni.showToast({ icon: 'none', title: '当前打印任务未完成,请稍后' });
+        return;
+    }
+    isPrinting.value = true;
+
+    getPrintCodeList();
+};
+
+// 打印列表
+const getPrintCodeList = async () => {
+    const res = await useClientRequest
+        .get(`/plt-api/app/printLog/getPrintCodeList/${opts.value?.id}`, {
+            start: form.value?.start,
+            end: form.value?.end,
+        })
+        .catch((err) => {
+            isPrinting.value = false;
+        });
+    if (!res || res.code !== 200) {
+        isPrinting.value = false;
+        return;
+    }
+    prepareSend(res?.data, printSpec.value)
+};
 const stepsObject = reactive<any>({
-    check: {
-        title: '核对信息',
-        value: 'check',
-        status: 'completed', // 为开始、进行中、已完成 三种状态分别值为 'not-started'、'in-progress'、'completed'
-        sort: 0,
-    },
-    confirm: {
-        title: '确认数量',
-        value: 'confirm',
-        status: 'completed', // 为开始、进行中、已完成 三种状态分别值为 'not-started'、'in-progress'、'completed'
+    range: {
+        title: '区间打印',
+        value: 'range',
+        status: 'in-progress', // 为开始、进行中、已完成 三种状态分别值为 'not-started'、'in-progress'、'completed'
         sort: 1,
     },
     connect: {
         title: '连接打印机',
         value: 'connect',
-        status: 'in-progress', // 为开始、进行中、已完成 三种状态分别值为 'not-started'、'in-progress'、'completed'
+        status: 'not-started', // 为开始、进行中、已完成 三种状态分别值为 'not-started'、'in-progress'、'completed'
         sort: 2,
     },
     print: {
@@ -53,12 +78,15 @@ const stepsObject = reactive<any>({
         sort: 3,
     },
 });
-// 打印模式
-const mode = ref('self'); // 自行打印, 区间打印 值分别为 self, range
+
 const currentStep = ref('connect');
-const paging = ref(null);
 const isPrinting = ref(false);
-onLoad((options: any) => {});
+const opts = ref<any>(null);
+onLoad((options: any) => {
+    console.log(options);
+    opts.value = options;
+    getBatchInfo()
+});
 const nextSteps = (data: any) => {
     if (!data.info || !data?.info?.value) return;
     stepsObject[data?.info?.value] = {
@@ -67,42 +95,52 @@ const nextSteps = (data: any) => {
     stepsObject[data?.nextStepValue].status = 'in-progress';
     currentStep.value = data?.nextStepValue;
 };
+const info = ref<any>(null);
+const form = ref<any>(null);
+const getFormData = (data: any) => {
+    console.log(data);
+    
+    form.value = data;
+};
 const prevSteps = (data: any) => {
     currentStep.value = data?.prevStepValue;
 };
 const testList = reactive([
     {
-        pm: '三七',
-        zl: '20g',
-        scrq: '2012.09.18',
-        zzph: 87391273912,
-        cj: '云南省文山市县中药材有限公司',
-        zsm: 'QX0000005600000318',
-        qr: 'https://t.zycpzs.cn/?c=QCCS412507030000101ND'
+        padSn: '0000002',
+        prefix: 'PCC1W1260311',
+        sn: 2,
+        traceCode: 'PCC1W12603110000002AV',
+        url: 'https://t.yujin.shuziyunyao.com/pt?c=PCC1W12603110000002AV',
     },
 ]);
 const printTest = (data: any) => {
+    const device = stepsObject['connect']?.device;
+    if (!device) {
+        uni.showToast({ icon: 'none', title: '未连接设备' });
+        return;
+    }
     // 检查是否正在打印
     if (isPrinting.value) {
         uni.showToast({ icon: 'none', title: '当前打印任务未完成,请稍后' });
         return;
     }
+    isPrinting.value = true;
     // 测试数据
     prepareSend(testList, data.printSpec);
 };
 // 打印写入
 const prepareSend = (list: any[], spec: string = '30x30') => {
     if (spec == '30x30') {
-        // 判断idx是否是奇数
         writeSend30x30(list);
     }
     if (spec == '60x40') {
         // 40x40
-        writeSendCommand(list, '60x40', 0)
+        writeSendCommand(list, '60x40', 0);
     }
     if (spec == '60x60') {
         // 30x30
-        writeSendCommand(list, '60x60', 0)
+        writeSendCommand(list, '60x60', 0);
     }
 };
 const writeSend30x30 = (list: any[]) => {
@@ -115,14 +153,11 @@ const writeSend30x30 = (list: any[]) => {
         }
         return acc;
     }, []);
-    writeSendCommand(arr, '30x30', 0)
+    writeSendCommand(arr, '30x30', 0);
 };
 // writeSend
 const writeSendCommand = async (list: any[], spec: string = '30x30', idx = 0) => {
     // 首次调用时设置打印状态为进行中
-    if (idx === 0) {
-        isPrinting.value = true;
-    }
     let command = new jpPrinter();
     if (spec == '30x30') {
         // 判断idx是否是奇数
@@ -130,7 +165,7 @@ const writeSendCommand = async (list: any[], spec: string = '30x30', idx = 0) =>
         command.setGap(10);
         command.setCls();
         command.setDirection(1);
-        command = tem30x30(command, list[idx]);
+        command = tem30x30(command, list[idx], info.value);
     }
     if (spec == '60x40') {
         // 判断idx是否是奇数
@@ -138,7 +173,7 @@ const writeSendCommand = async (list: any[], spec: string = '30x30', idx = 0) =>
         command.setGap(10);
         command.setCls();
         command.setDirection(1);
-        command = tem60x40(command, list[idx]);
+        command = tem60x40(command, list[idx], info.value);
     }
     if (spec == '60x60') {
         // 判断idx是否是奇数
@@ -146,16 +181,16 @@ const writeSendCommand = async (list: any[], spec: string = '30x30', idx = 0) =>
         command.setGap(10);
         command.setCls();
         command.setDirection(1);
-        command = tem60x60(command, list[idx]);
+        command = tem60x60(command, list[idx], info.value);
     }
-    command.setPagePrint()
+    command.setPagePrint();
     const device = stepsObject['connect']?.device;
     if (!device) {
         uni.showToast({ icon: 'none', title: '未连接设备' });
         return;
     }
     console.log(command.getData());
-    
+
     await writeBLECharacteristicSend({
         deviceId: device.deviceId,
         serviceId: device.serviceId,
@@ -163,16 +198,22 @@ const writeSendCommand = async (list: any[], spec: string = '30x30', idx = 0) =>
         uint8Array: command.getData(),
     });
     if (list.length - 1 > idx) {
-        writeSendCommand(list, spec, idx + 1)
+        writeSendCommand(list, spec, idx + 1);
     } else {
         // 打印完成,重置状态
         isPrinting.value = false;
         uni.showToast({
             icon: 'none',
-            title: '打印完成'
-        })
+            title: '打印完成',
+        });
     }
 };
+// 获取批次信息接口
+const getBatchInfo = async () => {
+    const res = await useClientRequest.get(`/plt-api/app/packTask/getPackTraceSimpleInfo/${opts.value?.packId}`);
+    if (!res?.data) return
+    info.value = res?.data;
+}
 // 如果是 30x30
 </script>
 <style lang="scss" scoped></style>

+ 1 - 0
src/utils/common.ts

@@ -405,3 +405,4 @@ export const getDateRangeFrt = (startDate: string, endDate: string): string => {
     }
     return `${startDate}至${endDate}`;
 };
+