【功能新增】IoT:产品导出功能

This commit is contained in:
YunaiV 2024-12-07 20:48:28 +08:00
parent 48907bde60
commit 68f13accd3

View File

@ -37,6 +37,15 @@
> >
<Icon icon="ep:plus" class="mr-5px" /> 新增 <Icon icon="ep:plus" class="mr-5px" /> 新增
</el-button> </el-button>
<el-button
type="success"
plain
@click="handleExport"
:loading="exportLoading"
v-hasPermi="['iot:product:export']"
>
<Icon icon="ep:download" class="mr-5px" /> 导出
</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
</ContentWrap> </ContentWrap>
@ -44,17 +53,36 @@
<!-- 列表 --> <!-- 列表 -->
<ContentWrap> <ContentWrap>
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true"> <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
<el-table-column label="产品名称" align="center" prop="name"> <el-table-column label="ID" align="center" prop="id" />
<template #default="scope">
<el-link @click="openDetail(scope.row.id)">{{ scope.row.name }}</el-link>
</template>
</el-table-column>
<el-table-column label="ProductKey" align="center" prop="productKey" /> <el-table-column label="ProductKey" align="center" prop="productKey" />
<el-table-column label="品类" align="center" prop="categoryName" />
<el-table-column label="设备类型" align="center" prop="deviceType"> <el-table-column label="设备类型" align="center" prop="deviceType">
<template #default="scope"> <template #default="scope">
<dict-tag :type="DICT_TYPE.IOT_PRODUCT_DEVICE_TYPE" :value="scope.row.deviceType" /> <dict-tag :type="DICT_TYPE.IOT_PRODUCT_DEVICE_TYPE" :value="scope.row.deviceType" />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="产品图标" align="center" prop="icon">
<template #default="scope">
<el-image
v-if="scope.row.icon"
:src="scope.row.icon"
class="w-40px h-40px"
:preview-src-list="[scope.row.icon]"
/>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column label="产品图片" align="center" prop="picture">
<template #default="scope">
<el-image
v-if="scope.row.picUrl"
:src="scope.row.picUrl"
class="w-40px h-40px"
:preview-src-list="[scope.row.picture]"
/>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column <el-table-column
label="创建时间" label="创建时间"
align="center" align="center"
@ -62,11 +90,6 @@
:formatter="dateFormatter" :formatter="dateFormatter"
width="180px" width="180px"
/> />
<el-table-column label="产品状态" align="center" prop="status">
<template #default="scope">
<dict-tag :type="DICT_TYPE.IOT_PRODUCT_STATUS" :value="scope.row.status" />
</template>
</el-table-column>
<el-table-column label="操作" align="center"> <el-table-column label="操作" align="center">
<template #default="scope"> <template #default="scope">
<el-button <el-button
@ -77,6 +100,14 @@
> >
查看 查看
</el-button> </el-button>
<el-button
link
type="primary"
@click="openForm('update', scope.row.id)"
v-hasPermi="['iot:product:update']"
>
编辑
</el-button>
<el-button <el-button
link link
type="danger" type="danger"
@ -107,6 +138,7 @@ import { dateFormatter } from '@/utils/formatTime'
import { ProductApi, ProductVO } from '@/api/iot/product/product' import { ProductApi, ProductVO } from '@/api/iot/product/product'
import ProductForm from './ProductForm.vue' import ProductForm from './ProductForm.vue'
import { DICT_TYPE } from '@/utils/dict' import { DICT_TYPE } from '@/utils/dict'
import download from '@/utils/download'
/** iot 产品 列表 */ /** iot 产品 列表 */
defineOptions({ name: 'IoTProduct' }) defineOptions({ name: 'IoTProduct' })
@ -135,6 +167,8 @@ const queryParams = reactive({
}) })
const queryFormRef = ref() // const queryFormRef = ref() //
const exportLoading = ref(false) //
/** 查询列表 */ /** 查询列表 */
const getList = async () => { const getList = async () => {
loading.value = true loading.value = true
@ -184,6 +218,21 @@ const handleDelete = async (id: number) => {
} catch {} } catch {}
} }
/** 导出按钮操作 */
const handleExport = async () => {
try {
//
await message.exportConfirm()
//
exportLoading.value = true
const data = await ProductApi.exportProduct(queryParams)
download.excel(data, '物联网产品.xls')
} catch {
} finally {
exportLoading.value = false
}
}
/** 初始化 **/ /** 初始化 **/
onMounted(() => { onMounted(() => {
getList() getList()