treeRecord.vue 3.17 KB
<template>
  <view class="container">
    <!-- ✅ 替换tui-no-data 为 uview-plus的空数据组件 up-empty -->
    <up-empty
        v-if="rows.length === 0"
        text="暂无数据"
    ></up-empty>

    <view class="record-wrap" v-else>
      <view class="record-list-wrap cad-box-shadow fs-bg__white" v-for="i in rows" :key="i.id" @click="toEditPage(i.id)">
        <view style="display: flex">
          <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="fs-ellipsis treetypeName">{{ i.treetype }}</view>
              <view style="text-align: right">{{ i.updatetime.substring(0, 10) }}</view>
            </view>
            <view class="fs-mt8 fs-align__center">
              <img src="../../../static/imgs/tree/tree-high.png" style="width: 14px;height: 14px;margin-right: 6px;" alt=""> 高度:{{ i.treeheight }} 米
            </view>
            <view class="fs-mt8 fs-align__center">
              <img src="../../../static/imgs/tree/treearound.png" style="width: 14px;height: 14px;margin-right: 6px;" alt="">胸径:{{ i.dbh }} 厘米
            </view>
          </view>
        </view>
        <view class="fs-mt8 fs-ellipsis treenumber-no">
          树木编号:{{ i.treenumber }}
        </view>
      </view>
    </view>

  <view  class="fixed-bottom-btn-wrap">
    <up-button
        type="primary"
        class="addTree"
        @click="toAddTreePage"
        v-show="count > 0 && count > rows.length"
    >
      新增树木录入
    </up-button>
  </view>

  </view>
</template>

<script setup>
import { ref} from 'vue'
import {  onLoad, onShow } from '@dcloudio/uni-app';
// 引入接口请求方法
import { treeRoadReq } from "@/api/tree-archive/tree-archive.js";


const rows = ref([])
const roadId = ref('')
const count = ref(0)


onLoad((options) => {
  console.log(options)
  roadId.value = options.roadId
  count.value = options.count
})

onShow(() => {
  treeRoadQuery()
})

// 前往修改页面
const toEditPage = (id) => {
  uni.navigateTo({
    url: `/pages-sub/data/tree-archive/editTree?id=${id}`
  })
}

// 前往新增页面
const toAddTreePage = () => {
  uni.navigateTo({
    url: `/pages-sub/data/tree-archive/addTree?roadId=${roadId.value}`
  })
}

// 树木记录列表查询接口
const treeRoadQuery = async () => {
  const res = await treeRoadReq( {road: roadId.value})
  console.log(res)
  rows.value = res.rows
}
</script>

<style scoped lang="scss">
// 保留原页面所有样式,一行未改,样式完全一致
.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%;
}

.record-list-right {
  margin-left: 20px;
  flex: 1;
  overflow: hidden;
}

.record-list-right-title {
  display: flex;
  justify-content: space-between;
}

.treenumber-no {
  padding: 3px 10px;
  background: #bdefd0;
  font-size: 12px;
}

.addTree {
  width: 100%;
  position: fixed;
  bottom: 0;
}
</style>