220 lines
5.9 KiB
Vue
220 lines
5.9 KiB
Vue
|
<script setup lang="ts">
|
|||
|
import { onMounted, reactive, ref } from "vue";
|
|||
|
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
|
|||
|
import { getSmartCabinetList, type SmartCabinetDTO } from "@/api/cabinet/smart-cabinet";
|
|||
|
import { type PaginationProps } from "@pureadmin/table";
|
|||
|
import { CommonUtils } from "@/utils/common";
|
|||
|
import { useRouter } from "vue-router";
|
|||
|
import { CabinetImgMap } from "@/utils/cabinetImgMap";
|
|||
|
|
|||
|
import Search from "@iconify-icons/ep/search";
|
|||
|
import Refresh from "@iconify-icons/ep/refresh";
|
|||
|
import View from "@iconify-icons/ep/view";
|
|||
|
import AddFill from "@iconify-icons/ri/add-circle-line";
|
|||
|
import SmartCabinetCardFormModal from "./smart-cabinet-card-form-modal.vue";
|
|||
|
|
|||
|
defineOptions({
|
|||
|
name: "SmartCabinetCard"
|
|||
|
});
|
|||
|
|
|||
|
const router = useRouter();
|
|||
|
const formRef = ref();
|
|||
|
const modalVisible = ref(false);
|
|||
|
const searchFormParams = ref({
|
|||
|
cabinetName: "",
|
|||
|
cabinetType: null
|
|||
|
});
|
|||
|
|
|||
|
const pageLoading = ref(false);
|
|||
|
const dataList = ref<SmartCabinetDTO[]>([]);
|
|||
|
const pagination = ref<PaginationProps>({
|
|||
|
total: 0,
|
|||
|
pageSize: 5,
|
|||
|
currentPage: 1,
|
|||
|
background: true
|
|||
|
});
|
|||
|
|
|||
|
async function onSearch() {
|
|||
|
pagination.value.currentPage = 1;
|
|||
|
getList();
|
|||
|
}
|
|||
|
|
|||
|
async function getList() {
|
|||
|
try {
|
|||
|
pageLoading.value = true;
|
|||
|
const { data } = await getSmartCabinetList({
|
|||
|
...searchFormParams.value,
|
|||
|
pageSize: pagination.value.pageSize,
|
|||
|
pageNum: pagination.value.currentPage
|
|||
|
});
|
|||
|
dataList.value = data.rows;
|
|||
|
pagination.value.total = data.total;
|
|||
|
} finally {
|
|||
|
pageLoading.value = false;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
const resetForm = formEl => {
|
|||
|
if (!formEl) return;
|
|||
|
formEl.resetFields();
|
|||
|
onSearch();
|
|||
|
};
|
|||
|
|
|||
|
const handleViewDetail = (row: SmartCabinetDTO) => {
|
|||
|
router.push({
|
|||
|
path: '/cabinet/card/detail',
|
|||
|
query: {
|
|||
|
id: row.cabinetId
|
|||
|
}
|
|||
|
});
|
|||
|
};
|
|||
|
|
|||
|
onMounted(() => {
|
|||
|
getList();
|
|||
|
});
|
|||
|
</script>
|
|||
|
|
|||
|
<template>
|
|||
|
<div class="main">
|
|||
|
<div class="float-right w-full">
|
|||
|
<el-form ref="formRef" :inline="true" :model="searchFormParams"
|
|||
|
class="search-form bg-bg_color w-[99/100] pl-8 pt-[12px]">
|
|||
|
<el-form-item label="柜体名称:" prop="cabinetName">
|
|||
|
<el-input v-model="searchFormParams.cabinetName" placeholder="请输入柜体名称" clearable class="!w-[200px]" />
|
|||
|
</el-form-item>
|
|||
|
<el-form-item label="柜体类型:" prop="cabinetType">
|
|||
|
<el-select v-model="searchFormParams.cabinetType" placeholder="请选择类型" clearable class="!w-[180px]">
|
|||
|
<el-option label="主柜" :value="0" />
|
|||
|
<el-option label="副柜" :value="1" />
|
|||
|
</el-select>
|
|||
|
</el-form-item>
|
|||
|
<el-form-item>
|
|||
|
<el-button type="primary" :icon="useRenderIcon(Search)" :loading="pageLoading" @click="onSearch">
|
|||
|
搜索
|
|||
|
</el-button>
|
|||
|
</el-form-item>
|
|||
|
<el-form-item>
|
|||
|
<el-button :icon="useRenderIcon(Refresh)" @click="resetForm(formRef)">
|
|||
|
重置
|
|||
|
</el-button>
|
|||
|
</el-form-item>
|
|||
|
<el-form-item>
|
|||
|
<el-button type="primary" :icon="useRenderIcon(AddFill)" @click="modalVisible = true"
|
|||
|
style="margin-right: 10px;">
|
|||
|
新增设备
|
|||
|
</el-button>
|
|||
|
</el-form-item>
|
|||
|
</el-form>
|
|||
|
|
|||
|
<div class="grid-container">
|
|||
|
<el-row :gutter="20">
|
|||
|
<el-col v-for="(item, index) in dataList" :key="item.cabinetId" :xs="24" :sm="12" :md="8" :lg="4" :xl="4">
|
|||
|
<el-card class="cabinet-card" :body-style="{ padding: '8px 20px' }">
|
|||
|
<div class="card-content">
|
|||
|
<img :src="`/img/cabinet/${CabinetImgMap[item.templateNo]?.img || 'default.jpg'}`"
|
|||
|
class="cabinet-image" />
|
|||
|
<div class="cabinet-info">
|
|||
|
<div class="name">柜体名称:{{ item.cabinetName }}</div>
|
|||
|
<div class="type">柜体类型:{{ item.cabinetType === 0 ? '主柜' : '副柜' }}</div>
|
|||
|
<div class="template">模板:{{ CabinetImgMap[item.templateNo]?.name || '-' }}</div>
|
|||
|
<div class="shop">归属商店:{{ item.shopName || '-' }}</div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<el-divider class="divider" />
|
|||
|
<el-button class="detail-btn" :icon="useRenderIcon(View)" @click="handleViewDetail(item)" />
|
|||
|
</el-card>
|
|||
|
</el-col>
|
|||
|
</el-row>
|
|||
|
<div class="pagination-wrapper">
|
|||
|
<el-pagination background layout="prev, pager, next" :page-size="pagination.pageSize"
|
|||
|
:total="pagination.total" v-model:current-page="pagination.currentPage" @current-change="getList"
|
|||
|
@size-change="getList" />
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<smart-cabinet-card-form-modal v-model:visible="modalVisible" @refresh="getList" />
|
|||
|
</div>
|
|||
|
</template>
|
|||
|
|
|||
|
<style scoped lang="scss">
|
|||
|
.search-form {
|
|||
|
:deep(.el-form-item) {
|
|||
|
margin-bottom: 12px;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
.cabinet-card {
|
|||
|
margin-bottom: 20px;
|
|||
|
min-height: 210px;
|
|||
|
display: flex;
|
|||
|
flex-direction: column;
|
|||
|
justify-content: space-between;
|
|||
|
|
|||
|
.cabinet-image {
|
|||
|
width: 100%;
|
|||
|
height: 420px;
|
|||
|
object-fit: cover;
|
|||
|
border-radius: 4px;
|
|||
|
margin-bottom: 10px;
|
|||
|
}
|
|||
|
|
|||
|
.card-content {
|
|||
|
flex: 1;
|
|||
|
margin: 15px 0px;
|
|||
|
|
|||
|
.cabinet-info {
|
|||
|
text-align: left;
|
|||
|
|
|||
|
.name,
|
|||
|
.type,
|
|||
|
.shop,
|
|||
|
.location,
|
|||
|
.template {
|
|||
|
font-size: 14px;
|
|||
|
color: #606266;
|
|||
|
margin-bottom: 6px;
|
|||
|
line-height: 1.5;
|
|||
|
}
|
|||
|
|
|||
|
.name {
|
|||
|
font-weight: 500;
|
|||
|
color: #303133;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
.divider {
|
|||
|
margin: 10px 0px;
|
|||
|
}
|
|||
|
|
|||
|
.detail-btn {
|
|||
|
width: 100%;
|
|||
|
border: 0;
|
|||
|
margin-top: auto;
|
|||
|
padding: 12px 0;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
.grid-container {
|
|||
|
margin: 20px 0;
|
|||
|
padding-bottom: 60px;
|
|||
|
position: relative;
|
|||
|
|
|||
|
.el-row {
|
|||
|
margin-bottom: -20px;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
.pagination-wrapper {
|
|||
|
position: relative;
|
|||
|
background: var(--el-bg-color);
|
|||
|
padding: 12px 12px;
|
|||
|
margin-top: 20px;
|
|||
|
text-align: center;
|
|||
|
|
|||
|
:deep(.el-pagination) {
|
|||
|
margin: 0;
|
|||
|
padding: 8px 0;
|
|||
|
}
|
|||
|
}
|
|||
|
</style>
|