Selaa lähdekoodia

修改删除基地信息

huangxw 1 viikko sitten
vanhempi
säilyke
8e97a0aec2
1 muutettua tiedostoa jossa 83 lisäystä ja 35 poistoa
  1. 83 35
      src/pages/plant/base/index.vue

+ 83 - 35
src/pages/plant/base/index.vue

@@ -48,7 +48,7 @@
                             </view>
                             <view v-if="speciesArray.length" class="c-#333 f-s-24 d-flex pl-40 pr-15 pb-15 pt-15">
                                 <view class="ov-hd tx-ov w-s-no">{{ speciesArray.join('、') }}</view>
-                                <view v-if="speciesArray.length > 4" class="flex1 w-s-no">等{{ speciesArray.length }}个品种 </view>
+                                <view v-if="(speciesArray.length > 4)" class="flex1 w-s-no">等{{ speciesArray.length }}个品种 </view>
                             </view>
                             <view v-if="!speciesArray.length" @click="$u.route({ url: '/plant/species/config/index' })" class="c-primary bg-#E3F6E7 f-s-22 mg-at radius-10 w-250 h-50 d-flex a-c j-c"> 暂未配置品种,去配置{{ '>' }}</view>
                             <view v-if="!speciesArray.length" class="pd-7"></view>
@@ -80,40 +80,51 @@
                     </up-sticky>
                     <view class="pd4-16-24-16-24">
                         <template>
-                            <view v-for="(item, index) in list" :key="index" class="b-radius bg-#fff pd-20 mb-20 p-rtv" @click="$u.route({ url: '/plant/base/base-detail/index', params: { id: item.id } })">
-                                <view class="c-333 f-s-34 pd-5 f-w-5">{{ item?.baseName }}</view>
-                                <view class="c-ccc f-s-24 pd-5 pt-0">{{ item?.baseCode }}</view>
-                                <view class="d-flex a-c">
-                                    <view class="c-333 f-s-28 pd-5">
-                                        <text class="c-#666">基地面积:</text>
-                                        <text class="f-w-5">{{ item?.gapInfo?.area || '-' }}</text>
+                            <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" @click.stop="$u.route({ url: '/plant/base/base-detail/index', params: { id: item.id } })">
+                                        <view class="c-333 f-s-34 pd-5 f-w-5">{{ item?.baseName }}</view>
+                                        <view class="c-ccc f-s-24 pd-5 pt-0">{{ item?.baseCode }}</view>
+                                        <view class="d-flex a-c">
+                                            <view class="c-333 f-s-28 pd-5">
+                                                <text class="c-#666">基地面积:</text>
+                                                <text class="f-w-5">{{ item?.gapInfo?.area || '-' }}</text>
+                                            </view>
+                                            <view class="flex1"></view>
+                                            <view class="c-333 f-s-28 pd-5">
+                                                <text class="c-#666">建设时间:</text>
+                                                <text class="f-w-5">{{ item?.buildDate || '-' }}</text>
+                                            </view>
+                                        </view>
+                                        <view class="c-333 f-s-28 pd-5">
+                                            <text class="c-#666">基地地址:</text>
+                                            <text class="f-w-5">{{ item?.gapInfo?.address || '-' }}</text>
+                                        </view>
+                                        <view v-if="item?.plantingVarieties?.length" class="c-333 f-s-28 pd-5 d-flex">
+                                            <text class="c-#666 w-s-no">当前在地品种:</text>
+                                            <text class="ov-hd tx-ov w-s-no f-w-5">{{ item.plantingVarieties?.map((items) => items.variety).join('、') || '-' }}</text>
+                                            <text v-if="item?.plantingVarieties?.length" class="flex1 w-s-no f-w-5">等{{ item.plantingVarieties?.length }}个品种</text>
+                                        </view>
+                                        <view class="pd-10"></view>
+                                        <view v-if="item.gapInfo?.basePic" class="p-rtv">
+                                            <image class="w-full h-310" :src="item.gapInfo?.basePic" mode="aspectFill"></image>
+                                            <view class="d-flex flex-cln a-ed" style="position: absolute; bottom: 20rpx; right: 0">
+                                                <view class="pd2-10-20 bg-black-op-0.5 c-#ccc f-s-20 mb-10" style="border-radius: 10rpx 0 0 10rpx; width: max-content">{{ item?.contactName }}负责</view>
+                                                <view class="pd2-10-20 bg-black-op-0.5 c-#ccc f-s-20 mb-10" style="border-radius: 10rpx 0 0 10rpx; width: max-content">公司+合作社</view>
+                                                <view class="pd2-10-20 bg-black-op-0.5 c-#ccc f-s-20" style="border-radius: 10rpx 0 0 10rpx; width: max-content">经度:E{{ item?.gapInfo?.lng }} 纬度:N{{ item?.gapInfo?.lat }}</view>
+                                            </view>
+                                        </view>
+                                        <view v-if="+(item?.tempFlag ?? 0)" class="temp_flag">暂存</view>
                                     </view>
-                                    <view class="flex1"></view>
-                                    <view class="c-333 f-s-28 pd-5">
-                                        <text class="c-#666">建设时间:</text>
-                                        <text class="f-w-5">{{ item?.buildDate || '-' }}</text>
-                                    </view>
-                                </view>
-                                <view class="c-333 f-s-28 pd-5">
-                                    <text class="c-#666">基地地址:</text>
-                                    <text class="f-w-5">{{ item?.gapInfo?.address || '-' }}</text>
-                                </view>
-                                <view v-if="item?.plantingVarieties?.length" class="c-333 f-s-28 pd-5 d-flex">
-                                    <text class="c-#666 w-s-no">当前在地品种:</text>
-                                    <text class="ov-hd tx-ov w-s-no f-w-5">{{ item.plantingVarieties?.map((items) => items.variety).join('、') || '-' }}</text>
-                                    <text v-if="item?.plantingVarieties?.length" class="flex1 w-s-no f-w-5">等{{ item.plantingVarieties?.length }}个品种</text>
-                                </view>
-                                <view class="pd-10"></view>
-                                <view v-if="item.gapInfo?.basePic" class="p-rtv">
-                                    <image class="w-full h-310" :src="item.gapInfo?.basePic" mode="aspectFill"></image>
-                                    <view class="d-flex flex-cln a-ed" style="position: absolute; bottom: 20rpx; right: 0">
-                                        <view class="pd2-10-20 bg-black-op-0.5 c-#ccc f-s-20 mb-10" style="border-radius: 10rpx 0 0 10rpx; width: max-content"> {{ item?.contactName }}负责</view>
-                                        <view class="pd2-10-20 bg-black-op-0.5 c-#ccc f-s-20 mb-10" style="border-radius: 10rpx 0 0 10rpx; width: max-content"> 公司+合作社</view>
-                                        <view class="pd2-10-20 bg-black-op-0.5 c-#ccc f-s-20" style="border-radius: 10rpx 0 0 10rpx; width: max-content"> 经度:E{{ item?.gapInfo?.lng }} 纬度:N{{ item?.gapInfo?.lat }}</view>
-                                    </view>
-                                </view>
-                                <view v-if="+(item?.tempFlag ?? 0)" class="temp_flag">暂存</view>
-                            </view>
+                                </up-swipe-action-item>
+                            </up-swipe-action>
                         </template>
                     </view>
                 </view>
@@ -158,7 +169,6 @@
 import { useClientRequest } from '@/utils/request';
 import { setCipByNum } from '@/utils/public';
 import { useInfoStore } from '@/store';
-import { computed, ref } from 'vue';
 const { proxy } = getCurrentInstance() as ComponentInternalInstance;
 const { pt_base_type } = toRefs<any>(proxy?.useDict('pt_base_type'));
 const infoStore = useInfoStore();
@@ -305,6 +315,44 @@ const handlechoseConfirm = () => {
     uni.$u.route({ type: 'navigateTo', url: '/plant/base/base-edit/index', params: { baseType: basetype.value } });
 };
 
+// 暂存项左滑删除配置
+const optionsActionTemp = reactive([
+    {
+        text: '删除',
+        style: {
+            backgroundColor: '#f56c6c',
+        },
+    },
+]);
+
+// 暂存项删除点击(本地移除)
+const clickTempSwipe = async (event: object) => {
+    const { name, index } = event as any;
+    if (index === 0) {
+        try {
+            const res = await uni.showModal({
+                title: '提示',
+                content: '确定删除该基地吗?',
+                confirmColor: '#FF4C4C',
+            });
+            if (!res.confirm) return
+            await uni.showLoading({
+                title: '删除中...',
+                mask: true,
+            });
+            await useClientRequest.get(`/plt-api/app/base/delById/${name}`);
+            uni.hideLoading();
+            uni.showToast({
+                title: '删除成功',
+                icon: 'success',
+            });
+            paging.value?.reload();
+        } catch (error) {
+            console.error('删除暂存基地失败:', error);
+        }
+    }
+};
+
 onMounted(() => {
     const querys = uni.createSelectorQuery().in(instance?.proxy);
     querys