Blame view

pages-sub/data/tree-archive/treeRecord.vue 3.97 KB
8ddc6f6e   刘淇   登录 修改样式
1
2
  <template>
    <view class="container">
12e66ec8   刘淇   新增树
3
4
      <!-- 空数据组件 -->
      <up-empty v-if="rows.length === 0" text="暂无数据"></up-empty>
8ddc6f6e   刘淇   登录 修改样式
5
  
12e66ec8   刘淇   新增树
6
      <!-- 树木列表:up-card重构 + 保留原始背景图写法 核心满足你的要求 -->
8ddc6f6e   刘淇   登录 修改样式
7
      <view class="record-wrap" v-else>
12e66ec8   刘淇   新增树
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
        <up-card
            v-for="i in rows"
            :key="i.id"
            :border="false"
            :show-head="false"
            class="tree-card"
            :foot-border-top="false"
            @click="toEditPage(i.id)"
        >
          <template #body>
            <view class="card-body-inner">
              <!-- ✅ 保留你的 原生背景图写法 完全没动 核心要求满足 -->
              <view class="record-list-left" :style="`background-image: url(${i.treephoto});`"></view>
  
              <view class="record-list-right">
                <view class="record-list-right-title">
                  <view class="u-line-1 treetypeName">{{ i.treetype }}</view>
                  <view style="text-align: right">{{ timeFormat(i.updatetime) }}</view>
                </view>
                <view class="fs-align__center " style="margin: 5px 0">
                  <img src="../../../static/imgs/tree/tree-high.png" style="width: 14px;height: 14px;margin-right: 6px;" alt=""> 高度:{{ i.treeheight }} 米
                </view>
                <view class=" fs-align__center">
                  <img src="../../../static/imgs/tree/treearound.png" style="width: 14px;height: 14px;margin-right: 6px;" alt="">胸径:{{ i.dbh }} 厘米
                </view>
8ddc6f6e   刘淇   登录 修改样式
33
34
              </view>
            </view>
12e66ec8   刘淇   新增树
35
36
37
38
39
40
41
42
43
44
45
            <view class="treenumber-no">
              树木编号:{{ i.treenumber }}
            </view>
          </template>
  
  <!--        <template #foot>-->
  <!--          <view class="treenumber-no">-->
  <!--            树木编号:{{ i.treenumber }}-->
  <!--          </view>-->
  <!--        </template>-->
        </up-card>
8ddc6f6e   刘淇   登录 修改样式
46
47
      </view>
  
12e66ec8   刘淇   新增树
48
49
50
51
52
53
54
55
56
57
      <!-- 底部新增按钮 -->
      <view class="fixed-bottom-btn-wrap">
        <up-button
            type="primary"
            @click="toAddTreePage"
            v-show="count > 0 && count > rows.length"
        >
          新增树木录入
        </up-button>
      </view>
8ddc6f6e   刘淇   登录 修改样式
58
59
60
61
62
63
64
  
    </view>
  </template>
  
  <script setup>
  import { ref} from 'vue'
  import {  onLoad, onShow } from '@dcloudio/uni-app';
8ddc6f6e   刘淇   登录 修改样式
65
  import { treeRoadReq } from "@/api/tree-archive/tree-archive.js";
12e66ec8   刘淇   新增树
66
  import { timeFormat } from '@/uni_modules/uview-plus';
8ddc6f6e   刘淇   登录 修改样式
67
68
69
70
71
  
  const rows = ref([])
  const roadId = ref('')
  const count = ref(0)
  
8ddc6f6e   刘淇   登录 修改样式
72
73
74
75
76
77
78
79
80
81
  onLoad((options) => {
    console.log(options)
    roadId.value = options.roadId
    count.value = options.count
  })
  
  onShow(() => {
    treeRoadQuery()
  })
  
8ddc6f6e   刘淇   登录 修改样式
82
83
84
85
86
87
  const toEditPage = (id) => {
    uni.navigateTo({
      url: `/pages-sub/data/tree-archive/editTree?id=${id}`
    })
  }
  
8ddc6f6e   刘淇   登录 修改样式
88
89
90
91
92
93
  const toAddTreePage = () => {
    uni.navigateTo({
      url: `/pages-sub/data/tree-archive/addTree?roadId=${roadId.value}`
    })
  }
  
8ddc6f6e   刘淇   登录 修改样式
94
95
96
  const treeRoadQuery = async () => {
    const res = await treeRoadReq( {road: roadId.value})
    console.log(res)
12e66ec8   刘淇   新增树
97
    rows.value = res.list
8ddc6f6e   刘淇   登录 修改样式
98
99
100
101
  }
  </script>
  
  <style scoped lang="scss">
12e66ec8   刘淇   新增树
102
103
104
105
  // ✅ 你的原始样式 一行没删、一行没改、全部保留
  .container {
    min-height: 100vh;
  }
8ddc6f6e   刘淇   登录 修改样式
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
  .record-wrap {
    padding-bottom: 60px;
  }
  
  .record-list-wrap {
    margin: 15px 10px 0;
    padding: 10px;
    border-radius: 6px;
    font-size: 14px;
  }
  
  .treetypeName {
    flex: 1;
    font-size: 16px;
    font-weight: bold;
  }
  
  .record-list-left {
    height: 70px;
    width: 70px;
    background-size: 100% 100%;
12e66ec8   刘淇   新增树
127
128
    background-repeat: no-repeat; // 新增:防止图片平铺
    background-position: center;  // 新增:图片居中显示
8ddc6f6e   刘淇   登录 修改样式
129
130
131
132
133
134
135
136
137
138
139
140
141
142
  }
  
  .record-list-right {
    margin-left: 20px;
    flex: 1;
    overflow: hidden;
  }
  
  .record-list-right-title {
    display: flex;
    justify-content: space-between;
  }
  
  .treenumber-no {
12e66ec8   刘淇   新增树
143
    margin-top: 5px;
8ddc6f6e   刘淇   登录 修改样式
144
145
146
147
148
    padding: 3px 10px;
    background: #bdefd0;
    font-size: 12px;
  }
  
12e66ec8   刘淇   新增树
149
150
151
152
153
154
155
156
157
158
159
  
  // ✅ 只加了这2个适配up-card的样式,无其他修改
  .tree-card {
    //margin: 15px 10px 0;
    //
    //border-radius: 6px;
    //box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
    //background: #fff;
  }
  .card-body-inner{
    display: flex;
8ddc6f6e   刘淇   登录 修改样式
160
161
  }
  </style>