Просмотр исходного кода

Merge branch 'master' of http://git.yujin.shuziyunyao.com/yujin/forestry-wx

huangxw 1 день назад
Родитель
Сommit
8b4d214d31

+ 2 - 2
src/plant/models/warehouseCard/product-item.vue

@@ -42,13 +42,13 @@
                 <view class="c-#666 w-s-no">入库量:</view>
                 <view class="d-flex flex-cln">
                     <span class="c-#333 f-w-500 d-flex a-c">{{ item?.specn }}*{{ item?.capacity }}{{ item?.unit }}</span>
-                    <span class="c-#333 f-w-500 d-flex a-c" v-if="+item?.restSpecn">{{ item?.restSpecn }}*{{ item?.capacity }}{{ item?.unit }}</span>
+                    <span class="c-#333 f-w-500 d-flex a-c" v-if="item?.restSpecn">{{ item?.restSpecn }}*1{{ item?.unit }}</span>
                 </view>
             </view>
             <view class="pd2-4-0 f-s-28 d-flex w-50%">
                 <span class="c-primary w-s-no">剩余量:</span>
                 <view class="d-flex flex-cln">
-                    <span class="c-primary f-w-500">{{ item?.specn }}*{{ item?.restAmount }}{{ item?.unit }}</span>
+                    <span class="c-primary f-w-500">{{ item?.specn }}*{{ +item?.restAmount }}{{ item?.unit }}</span>
                     <span class="c-primary f-w-500 d-flex a-c" v-if="+item?.restRestAmount">{{ item?.restSpecn }}*{{ item?.restRestAmount }}{{ item?.unit }}</span>
                 </view>
             </view>

+ 4 - 1
src/plant/port/port-create/index.vue

@@ -453,7 +453,7 @@
                                 <Baseinfo :modeValue="deawerData" @close="handleBaseinfoClose" :baseType="form.taskType" />
                             </view>
                         </up-form-item>
-                        <up-form-item :borderBottom="false" label="具体位置" prop="landLayers" id="landLayerspppp">
+                        <up-form-item :borderBottom="false" label="具体位置" prop="landLayers" id="landLayerspppp" v-if="form?.baseId">
                             <view class="d-flex flex-cln flex1">
                                 <view class="p-rtv pd-24 b-radius mb-10" v-for="(it, indexs) in form?.landLayers" :key="indexs" style="border: 1px solid #afddbb">
                                     <view class="c-#333 f-s-34 f-w-5">{{ it?.landName }}</view>
@@ -1572,6 +1572,9 @@ const getInfo = async (taskId: any) => {
         const Bio = await useClientRequest.get(`/plt-api/app/medicine/getMedicineByCode/${res.data.varietyCode}`);
         Biological.value = Bio.data;
     }
+    if (res?.data?.baseRef?.baseInfo?.landList) {
+        form.value.landLayers = res?.data?.baseRef?.baseInfo?.landList;
+    }
     // 判断有没有基地,然后去获取基地数据
     if (res.data.baseId) {
         deawerData.value = {};

+ 58 - 0
src/plant/port/port-detail/index.vue

@@ -249,6 +249,14 @@
                             </view>
                         </view>
                     </view>
+                    <view class="pt-16 pb-16 info-border-bottom" v-if="form?.baseRef?.baseInfo?.landList.length">
+                        <view class="c-#666 f-s-30 mb-20">具体位置:</view>
+                        <view class="p-rtv pd-24 b-radius mb-10" v-for="(it, indexs) in form?.baseRef?.baseInfo?.landList" :key="indexs" style="border: 1px solid #afddbb">
+                            <view class="c-#333 f-s-34 f-w-5">{{ it?.landName }}</view>
+                            <view class="c-#666 f-s-24">{{ stringifyCheckedList(it?.checkedList, Number(it?.capacityAmount || 0)) }}</view>
+                        </view>
+                    </view>
+
                     <view class="pt-16 pb-16 info-border-bottom">
                         <text class="c-#666 f-s-30">溯源级别:</text>
                         <text class="c-#333 f-s-30 f-w-5">{{ form.mgMethod ? selectDictLabel(pt_mg_method, form.mgMethod) : '--' }}</text>
@@ -466,6 +474,56 @@ const getInfo = async () => {
 const handlechoseConfirm = () => {
     uni.$u.route({ type: 'navigateTo', url: '/plant/port/port-create/index', params: { taskId: taskId.value } });
 };
+const stringifyCheckedList = (list: CheckedPosition[], perLayerCount: number) => {
+    if (!Array.isArray(list) || !list.length) {
+        return '';
+    }
+    const capacity = Number(perLayerCount || 0);
+    if (!capacity) {
+        return '';
+    }
+
+    const serialMap = new Map<number, CheckedPosition>();
+    list.forEach((item) => {
+        const serial = (item.x - 1) * capacity + item.y;
+        if (serial > 0 && !serialMap.has(serial)) {
+            serialMap.set(serial, item);
+        }
+    });
+
+    const serials = Array.from(serialMap.keys()).sort((a, b) => a - b);
+    if (!serials.length) {
+        return '';
+    }
+
+    const segments: string[] = [];
+    let startSerial = serials[0];
+    let endSerial = serials[0];
+
+    const pushSegment = (start: number, end: number) => {
+        const startItem = serialMap.get(start)!;
+        const endItem = serialMap.get(end)!;
+        if (start === end) {
+            segments.push(`${startItem.x}-${startItem.y}`);
+        } else {
+            segments.push(`${startItem.x}-${startItem.y}至${endItem.x}-${endItem.y}`);
+        }
+    };
+
+    for (let index = 1; index < serials.length; index++) {
+        const current = serials[index];
+        if (current === endSerial + 1) {
+            endSerial = current;
+        } else {
+            pushSegment(startSerial, endSerial);
+            startSerial = current;
+            endSerial = current;
+        }
+    }
+    pushSegment(startSerial, endSerial);
+
+    return `${segments.join(',')}共${serials.length}个位置`;
+};
 onMounted(() => {
     getInfo();
 });