<template>
  <div class="home">
    <van-nav-bar title="设备管理" fixed left-arrow @click-left="onClickLeft">
    </van-nav-bar>
    <van-search
      shape="round"
      v-model="value"
      :show-action="false"
      placeholder="请输入设备名称"
    />
    <van-cell-group>
      <van-cell title="当前站点" value="李家坝仓库" />
    </van-cell-group>

    <div class="content">
      <van-cell-group>
        <van-cell
          title="高枝锯、绿篱机、油锯"
          is-link
          label="设备类型：绿化修剪设备"
        >
          <template #value>
            <span class="status-tag status-good">完好</span>
          </template>
        </van-cell>
        <van-cell title="撒布机三台" is-link label="设备类型：除雪设备">
          <template #value>
            <span class="status-tag status-warning">损坏</span>
          </template>
        </van-cell>
        <van-cell title="撒布机三台" is-link label="设备类型：除雪设备">
          <template #value>
            <span class="status-tag status-danger">报废</span>
          </template>
        </van-cell>
      </van-cell-group>
    </div>

    <van-button
      type="primary"
      class="add-btn"
      icon="plus"
      @click="handleAddDevice"
    >
      添加设备
    </van-button>
  </div>
</template>
  
  <script setup>
import { ref } from "vue";
import { useRouter } from "vue-router";
import { showToast } from "vant";

const router = useRouter();
const active = ref(0);

const onClickLeft = () => {
  router.push("/");
};
</script> 
  
  <style scoped>
.home {
  padding-top: var(--van-nav-bar-height); /* 自动匹配导航栏高度 */
}

.content {
  padding: 16px;
}

.content .van-cell-group .van-cell {
  margin-bottom: 10px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.add-btn {
  position: fixed;
  bottom: 20px;
  left: 16px;
  right: 16px;
  width: calc(100% - 32px);
  margin: 0 auto;
  border-radius: 24px;
  font-size: 16px;
  height: 44px;
  z-index: 999;
}

.grid {
  margin-top: 16px;
}

.btn {
  margin-top: 24px;
}

.status-tag {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  color: white;
  font-size: 12px;
}
.status-good {
  background-color: #07c160;
}
.status-warning {
  background-color: #ff976a;
}
.status-danger {
  background-color: #ee0a24;
}
</style>
  