Browse Source

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

huangxw 2 tuần trước cách đây
mục cha
commit
ee2362cbed

+ 22 - 9
src/plant/port/port-create/index.vue

@@ -7,25 +7,24 @@
             <up-form class="p-rtv" labelPosition="top" :model="form" :rules="rules" labelWidth="auto" ref="upFormRef">
                 <view class="startline-title pl-24 ml-26 mb-16">基地信息</view>
                 <view class="bg-#fff pd-26">
-                    <view class="b-radius bg-#EBF6EE c-primary f-s-24 pd-26 pb-16"> 注意:关联时请确保已添加到地块;关联时必须选到地块/圈 舍/组培架。</view>
+                    <view class="b-radius bg-#EBF6EE c-primary f-s-24 pd-26 pb-16"> 注意:关联时请确保已添加到地块;关联时必须选到地块/圈舍/组培架。</view>
                 </view>
                 <view class="bg-#fff pd-26 mb-20 pt-0">
                     <up-form-item :borderBottom="false" label="种养殖所在基地" required prop="plantBase">
-                        <view class="w-100% d-flex a-c j-c pd-26 b-radius bg-#FBFDFB border-#AFDDBB" @click="openDrawer">
+                        <view v-if="!deawerData" class="w-100% d-flex a-c j-c pd-26 b-radius bg-#FBFDFB border-#AFDDBB" @click="openDrawer">
                             <view class=""></view>
                             <view class="f-s-34 c-primary">请选择种养殖所在的基地</view>
                         </view>
+                        <view class="w-100%" v-else>
+                            <Baseinfo :modeValue="deawerData" @close="handleBaseinfoClose" :baseType="form.baseType" />
+                        </view>
                     </up-form-item>
                 </view>
                 <view class="startline-title pl-24 ml-26 mb-16">种养殖信息</view>
                 <view class="bg-#fff pd-26 mb-20">
                     <ut-action-sheet v-model="form.queryType" :tabs="pt_task_type" title="选择任务类型">
                         <up-form-item borderBottom label="任务类型" required prop="baseType">
-                            <view v-if="form.queryType1" class="f-s-30 c-333 f-w-5 flex1">{{ selectDictLabel(pt_org_type, form.queryType1) }}</view>
-                            <view v-else class="f-s-30 c-ccc f-w-4 flex1">请选择任务类型</view>
-                            <template #right>
-                                <up-icon size="22rpx" color="#2A6D52" name="arrow-down-fill"></up-icon>
-                            </template>
+                            <view class="f-s-30 c-333 f-w-5 flex1">{{ selectDictLabel(pt_task_type, form.baseType) }}</view>
                         </up-form-item>
                     </ut-action-sheet>
                     <ut-action-sheet v-model="form.queryType1" :tabs="pt_org_type" title="选择溯源级别">
@@ -61,7 +60,7 @@
                     </up-form-item>
                     <ut-action-sheet v-model="form.queryType5" :tabs="pt_task_type" title="选择任务类型">
                         <up-form-item borderBottom label="任务类型" required prop="baseType">
-                            <view v-if="form.queryType1" class="f-s-30 c-333 f-w-5 flex1">{{ selectDictLabel(pt_org_type, form.queryType1) }}</view>
+                            <view v-if="form.queryType1" class="f-s-30 c-333 f-w-5 flex1">{{ selectDictLabel(pt_org_type, form.baseType) }}</view>
                             <view v-else class="f-s-30 c-ccc f-w-4 flex1">请选择养殖方式</view>
                             <template #right>
                                 <up-icon size="22rpx" color="#2A6D52" name="arrow-down-fill"></up-icon>
@@ -113,12 +112,13 @@
     </z-paging>
 
     <!-- 添加drawer组件 -->
-    <Drawer v-if="drawerVisible" :baseType="form.baseType" v-model="drawerVisible" @open="onDrawerOpen" @close="onDrawerClose" />
+    <Drawer v-if="drawerVisible" :baseType="form.baseType" v-model="drawerVisible" @open="onDrawerOpen" @close="onDrawerClose" @confirm="onDrawerConfirm" />
 </template>
 
 <script setup lang="ts">
 import { ref } from 'vue';
 import Drawer from './models/drawer.vue';
+import Baseinfo from './models/baseinfo.vue';
 const { proxy } = getCurrentInstance() as ComponentInternalInstance;
 const { pt_task_type, pt_org_type, yes_no } = toRefs<any>(proxy?.useDict('pt_task_type', 'pt_org_type', 'yes_no'));
 const form = ref({
@@ -162,6 +162,19 @@ function onDrawerOpen() {
 function onDrawerClose() {
     console.log('抽屉关闭了');
 }
+const deawerData = ref<any>(null);
+// 处理抽屉确认事件
+function onDrawerConfirm(data: any) {
+    console.log('收到基地选择数据:', data);
+    deawerData.value = data;
+    // 这里可以将数据赋值给表单的相应字段
+    // 例如:form.value.plantBase = data.baseName;
+    // 可以根据需要添加其他处理逻辑
+}
+// 处理Baseinfo组件的关闭事件
+function handleBaseinfoClose() {
+    deawerData.value = null;
+}
 
 onLoad((options) => {
     console.log(options?.baseType, '??????');

+ 85 - 0
src/plant/port/port-create/models/baseinfo.vue

@@ -0,0 +1,85 @@
+<template>
+    <view class="border-#AFDDBB pd-26 pb-8 bg-#FBFDFB p-rtv">
+        <!-- 关闭按钮 -->
+        <view class="c-#F81242 f-s-30 ab2-10-20" @click="handleClose"> × </view>
+        <view class="c-#333 f-s-34 f-w-5 pt-8 pb-8 pr-16">{{ modeValue?.baseName }}</view>
+
+        <!-- 标签显示:GAP和三无一全 -->
+        <view v-if="modeValue?.gapFlag || modeValue?.swyqRes" class="pt-8 pb-8 d-flex" style="position: absolute; left: 0; top: 0">
+            <view v-if="modeValue?.gapFlag && Number(modeValue.gapFlag) === 1" class="label mr-10">GAP</view>
+            <view v-if="modeValue?.swyqRes && Number(modeValue.swyqRes) === 1" class="label">三无一全</view>
+        </view>
+
+        <view class="pt-8 pb-8">
+            <text class="c-#666 f-s-28">基地面积:</text>
+            <text class="c-#333 f-s-28 f-w-5">{{ modeValue?.area }}{{ modeValue?.areaUnit }}</text>
+        </view>
+        <view class="pt-8 pb-8">
+            <text class="c-#666 f-s-28">基地地址:</text>
+            <text class="c-#333 f-s-28 f-w-5">{{ modeValue?.adcodeName }}{{ modeValue?.address }}</text>
+        </view>
+        <view style="margin-left: -26rpx; margin-right: -26rpx; border-bottom: 1rpx solid #d4ecda"></view>
+        <view class="pt-16 pb-8">
+            <text v-if="+baseType == 1" class="c-#666 f-s-28">地块信息:</text>
+            <text v-if="+baseType == 2" class="c-#666 f-s-28">圈舍信息:</text>
+            <text v-if="+baseType == 3" class="c-#666 f-s-28">组培架信息:</text>
+            <text v-if="!modeValue?.aloneChecked" class="c-#333 f-s-28 f-w-5">{{ modeValue?.data?.length }}个</text>
+            <text v-if="modeValue?.aloneChecked" class="c-#333 f-s-28 f-w-5">该基地所有{{ baseType == '1' ? '地块' : baseType == '2' ? '圈舍' : '组培架' }}</text>
+        </view>
+        <view v-if="!modeValue?.aloneChecked" class="pt-8 pb-8" v-for="(item, index) in modeValue?.data" :key="index">
+            <text class="c-#666 f-s-28">{{ item?.landName }}:</text>
+            <text class="c-#333 f-s-28 f-w-5">{{ item?.area }}{{ item?.areaUnit }}</text>
+        </view>
+    </view>
+</template>
+<script setup lang="ts">
+// 定义props接口
+interface ModeValue {
+    baseName?: string;
+    area?: string | number;
+    areaUnit?: string;
+    address?: string;
+    adcodeName?: string;
+    gapFlag?: number | string;
+    swyqRes?: number | string;
+    aloneChecked?: boolean;
+    data?: any[];
+    // 保留原有字段以保持向后兼容
+    adultBearArea?: string;
+}
+
+// 接收modeValue对象
+const props = defineProps<{
+    modeValue?: ModeValue;
+    baseType: string;
+}>();
+
+// 定义emit事件
+const emit = defineEmits<{
+    (e: 'update:modeValue', value: ModeValue | null): void;
+    (e: 'close'): void;
+}>();
+
+// 处理关闭
+const handleClose = () => {
+    // 触发事件清空modeValue
+    console.log('?');
+
+    emit('update:modeValue', null);
+    emit('close');
+};
+</script>
+
+<style scoped lang="scss">
+.label {
+    font-size: 24rpx;
+    color: #37a954;
+    border-radius: 100rpx;
+    background-color: #e3efe6;
+    width: max-content;
+    padding-left: 14rpx;
+    padding-right: 14rpx;
+    padding-top: 6rpx;
+    padding-bottom: 6rpx;
+}
+</style>

+ 31 - 15
src/plant/port/port-create/models/drawer.vue

@@ -60,7 +60,6 @@ const form = ref({
     tempFlag: 0,
     gapFlag: '',
     swyqRes: '',
-    baseType: '',
 });
 // 左侧基地列表数据
 const list = ref<any[]>([]);
@@ -79,8 +78,8 @@ const emit = defineEmits<{
     (e: 'update:modelValue', value: boolean): void;
     (e: 'open'): void;
     (e: 'close'): void;
+    (e: 'confirm', data: { data: any[]; aloneChecked: boolean; baseName: string; area?: string; gapFlag: number; swyqRes: number; areaUnit: string; adcodeName: string; address: string }): void; // 新增
 }>();
-
 // 处理关闭事件
 function handleClose() {
     emit('update:modelValue', false);
@@ -179,6 +178,7 @@ const getBaseInfo = async (pageNum: number, pageSize: number) => {
         pageNum,
         pageSize,
         ...form.value,
+        baseType: props.baseType,
     };
     const res = await useClientRequest.get('/plt-api/app/base/pageList', params);
     if (res) {
@@ -195,21 +195,37 @@ const confirm = () => {
         });
         return;
     } else {
-        list.value.forEach((item) => {
-            if (item.id == baseID.value) {
-                if (item?.baseType !== props.baseType) {
-                    uni.showToast({
-                        title: '请选择符合类型的基地',
-                        icon: 'none',
-                    });
-                    return;
-                } else {
-                    console.log(item, 'item');
-                    console.log(checkBox.value);
-                }
-            }
+        if (checkBox.value.length == 0) {
+            uni.showToast({
+                title: '请选择地块',
+                icon: 'none',
+            });
+            return;
+        }
+    }
+
+    // 通过 baseID 查找选中的基地
+    const selectedBase = list.value.find((item) => item.id === baseID.value);
+    //checkBox是一个数组,里边存的是mixData里的id,找到对应的id的mixData
+    const data = checkBox.value.map((id) => mixData.value.find((item) => item.id === id));
+    if (selectedBase) {
+        // 抛出对象给父组件
+        emit('confirm', {
+            baseName: selectedBase.baseName,
+            area: selectedBase.gapInfo?.area,
+            areaUnit: selectedBase.gapInfo?.areaUnit,
+            adcodeName: selectedBase.gapInfo?.adcodeName,
+            address: selectedBase.gapInfo?.address,
+            aloneChecked: aloneChecked.value,
+            gapFlag: selectedBase.gapFlag,
+            swyqRes: selectedBase.swyqRes,
+            data: data,
         });
     }
+
+    // 关闭抽屉
+    emit('update:modelValue', false);
+    emit('close');
 };
 watch(
     () => baseID.value,

+ 21 - 1
unocss.config.js

@@ -70,6 +70,26 @@ export default defineConfig({
                 margin: `${top}rpx ${right}rpx ${bottom}rpx ${left}rpx`,
             }),
         ],
+        // ab2-40-20
+        [
+            /^ab2-([\.\d]+)-([\.\d]+)$/,
+            ([_, top, right]) => ({
+                position: 'absolute',
+                top: `${top}rpx`,
+                right: `${right}rpx`,
+            }),
+        ],
+        // ab4-40-20-10-5
+        [
+            /^ab4-([\.\d]+)-([\.\d]+)-([\.\d]+)-([\.\d]+)$/,
+            ([_, top, right, bottom, left]) => ({
+                position: 'absolute',
+                top: `${top}rpx`,
+                right: `${right}rpx`,
+                bottom: `${bottom}rpx`,
+                left: `${left}rpx`,
+            }),
+        ],
         // 左padding
         [/^pl-([\.\d]+)$/, ([_, num]) => ({ 'padding-left': `${num}rpx` })],
         // 右padding
@@ -187,7 +207,7 @@ export default defineConfig({
             ([_, num]) => ({
                 'background-color': `rgba(0, 0, 0, ${num})`,
             }),
-        ]
+        ],
     ],
     transformers: [
         {