|
|
|
@ -27,7 +27,7 @@
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</el-form-item>
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
|
|
<el-form-item label="连接状态" prop="status">
|
|
|
|
<!-- <el-form-item label="连接状态" prop="status">
|
|
|
|
<el-select
|
|
|
|
<el-select
|
|
|
|
v-model="queryParams.status"
|
|
|
|
v-model="queryParams.status"
|
|
|
|
placeholder="请选择状态"
|
|
|
|
placeholder="请选择状态"
|
|
|
|
@ -41,9 +41,9 @@
|
|
|
|
:value="dict.value"
|
|
|
|
:value="dict.value"
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</el-select>
|
|
|
|
</el-select>
|
|
|
|
</el-form-item>
|
|
|
|
</el-form-item> -->
|
|
|
|
|
|
|
|
|
|
|
|
<el-form-item label="创建时间" prop="createTime">
|
|
|
|
<!-- <el-form-item label="创建时间" prop="createTime">
|
|
|
|
<el-date-picker
|
|
|
|
<el-date-picker
|
|
|
|
v-model="queryParams.createTime"
|
|
|
|
v-model="queryParams.createTime"
|
|
|
|
value-format="YYYY-MM-DD HH:mm:ss"
|
|
|
|
value-format="YYYY-MM-DD HH:mm:ss"
|
|
|
|
@ -53,7 +53,7 @@
|
|
|
|
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
|
|
|
|
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
|
|
|
|
class="!w-240px"
|
|
|
|
class="!w-240px"
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</el-form-item>
|
|
|
|
</el-form-item> -->
|
|
|
|
<el-form-item>
|
|
|
|
<el-form-item>
|
|
|
|
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
|
|
|
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
|
|
|
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
|
|
|
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
|
|
|
@ -74,6 +74,9 @@
|
|
|
|
>
|
|
|
|
>
|
|
|
|
<Icon icon="ep:download" class="mr-5px" /> 导出
|
|
|
|
<Icon icon="ep:download" class="mr-5px" /> 导出
|
|
|
|
</el-button>
|
|
|
|
</el-button>
|
|
|
|
|
|
|
|
<el-button type="danger" plain @click="handleBatchDelete" v-hasPermi="['iot:device:delete']">
|
|
|
|
|
|
|
|
<Icon icon="ep:delete" class="mr-5px" /> 批量删除
|
|
|
|
|
|
|
|
</el-button>
|
|
|
|
</el-form-item>
|
|
|
|
</el-form-item>
|
|
|
|
</el-form>
|
|
|
|
</el-form>
|
|
|
|
</ContentWrap>
|
|
|
|
</ContentWrap>
|
|
|
|
@ -81,44 +84,47 @@
|
|
|
|
<!-- 列表 -->
|
|
|
|
<!-- 列表 -->
|
|
|
|
<ContentWrap>
|
|
|
|
<ContentWrap>
|
|
|
|
<el-table
|
|
|
|
<el-table
|
|
|
|
|
|
|
|
ref="tableRef"
|
|
|
|
v-loading="loading"
|
|
|
|
v-loading="loading"
|
|
|
|
:data="list"
|
|
|
|
:data="list"
|
|
|
|
:stripe="true"
|
|
|
|
:stripe="true"
|
|
|
|
:show-overflow-tooltip="true"
|
|
|
|
:show-overflow-tooltip="true"
|
|
|
|
highlight-current-row
|
|
|
|
row-key="id"
|
|
|
|
@current-change="handleCurrentChange"
|
|
|
|
@selection-change="handleSelectionChange"
|
|
|
|
>
|
|
|
|
>
|
|
|
|
<el-table-column label="设备编号" align="left" prop="deviceCode" width="150px"/>
|
|
|
|
<el-table-column type="selection" width="55" reserve-selection />
|
|
|
|
<el-table-column label="设备名称" align="left" prop="deviceName" width="200px"/>
|
|
|
|
<el-table-column label="设备编号" align="left" prop="deviceCode"/>
|
|
|
|
|
|
|
|
<el-table-column label="设备名称" align="left" prop="deviceName"/>
|
|
|
|
<!-- <el-table-column label="设备类型" align="left" prop="deviceType" width="150px"> -->
|
|
|
|
<!-- <el-table-column label="设备类型" align="left" prop="deviceType" width="150px"> -->
|
|
|
|
<!-- <template #default="scope">
|
|
|
|
<!-- <template #default="scope">
|
|
|
|
<dict-tag :type="DICT_TYPE.IOT_DEVICE_TYPE" :value="scope.row.deviceType" />
|
|
|
|
<dict-tag :type="DICT_TYPE.IOT_DEVICE_TYPE" :value="scope.row.deviceType" />
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
</el-table-column> -->
|
|
|
|
</el-table-column> -->
|
|
|
|
<el-table-column label="通讯协议" align="left" prop="protocol" width="200px">
|
|
|
|
<el-table-column label="采集协议" align="left" prop="protocol" width="250px">
|
|
|
|
<template #default="scope">
|
|
|
|
<template #default="scope">
|
|
|
|
<dict-tag :type="DICT_TYPE.IOT_PROTOCOL" :value="scope.row.procotol" />
|
|
|
|
<dict-tag :type="DICT_TYPE.IOT_PROTOCOL" :value="scope.row.protocol" />
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
</el-table-column>
|
|
|
|
<el-table-column label="采集周期" align="left" prop="sampleCycle" width="150px"/>
|
|
|
|
<el-table-column label="连接状态" align="center" prop="status" width="200px">
|
|
|
|
<el-table-column label="状态" align="center" prop="status">
|
|
|
|
|
|
|
|
<template #default="scope">
|
|
|
|
<template #default="scope">
|
|
|
|
<dict-tag :type="DICT_TYPE.IOT_GATEWAY_STATUS" :value="scope.row.status" />
|
|
|
|
<dict-tag :type="DICT_TYPE.IOT_GATEWAY_STATUS" :value="scope.row.status" />
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
</el-table-column>
|
|
|
|
|
|
|
|
<el-table-column label="采集周期(s)" align="left" prop="sampleCycle" width="200px"/>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- <el-table-column label="读主题" align="center" prop="readTopic" />
|
|
|
|
<!-- <el-table-column label="读主题" align="center" prop="readTopic" />
|
|
|
|
<el-table-column label="写主题" align="center" prop="writeTopic" />
|
|
|
|
<el-table-column label="写主题" align="center" prop="writeTopic" />
|
|
|
|
<el-table-column label="网关id" align="center" prop="gatewayId" /> -->
|
|
|
|
<el-table-column label="网关id" align="center" prop="gatewayId" /> -->
|
|
|
|
<!-- <el-table-column label="设备品牌id" align="center" prop="deviceBrandId" />-->
|
|
|
|
<!-- <el-table-column label="设备品牌id" align="center" prop="deviceBrandId" />-->
|
|
|
|
<!-- <el-table-column label="离线间隔" align="center" prop="offLineDuration" /> -->
|
|
|
|
<!-- <el-table-column label="离线间隔" align="center" prop="offLineDuration" /> -->
|
|
|
|
<el-table-column
|
|
|
|
<!-- <el-table-column
|
|
|
|
label="最后上线时间"
|
|
|
|
label="最后上线时间"
|
|
|
|
align="center"
|
|
|
|
align="center"
|
|
|
|
prop="lastOnlineTime"
|
|
|
|
prop="lastOnlineTime"
|
|
|
|
:formatter="dateFormatter"
|
|
|
|
:formatter="dateFormatter"
|
|
|
|
width="180px"
|
|
|
|
width="180px"
|
|
|
|
/>
|
|
|
|
/> -->
|
|
|
|
<el-table-column label="备注" align="center" prop="remark" />
|
|
|
|
<!-- <el-table-column label="备注" align="center" prop="remark" /> -->
|
|
|
|
<!-- <el-table-column
|
|
|
|
<!-- <el-table-column
|
|
|
|
label="创建时间"
|
|
|
|
label="创建时间"
|
|
|
|
align="center"
|
|
|
|
align="center"
|
|
|
|
@ -126,13 +132,30 @@
|
|
|
|
:formatter="dateFormatter"
|
|
|
|
:formatter="dateFormatter"
|
|
|
|
width="170px"
|
|
|
|
width="170px"
|
|
|
|
/> -->
|
|
|
|
/> -->
|
|
|
|
<el-table-column label="是否启用" align="center" prop="isEnable" fixed="right">
|
|
|
|
<el-table-column label="是否启用" align="center" prop="isEnable" fixed="right" width="200px">
|
|
|
|
<template #default="scope">
|
|
|
|
<template #default="scope">
|
|
|
|
<dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.isEnable" />
|
|
|
|
<dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.isEnable" />
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
</el-table-column>
|
|
|
|
<el-table-column label="操作" align="center" fixed="right" width="150px">
|
|
|
|
<el-table-column label="操作" align="center" fixed="right" width="380px">
|
|
|
|
<template #default="scope">
|
|
|
|
<template #default="scope">
|
|
|
|
|
|
|
|
<el-button link type="primary" @click.stop="handleShowAttribute(scope.row)">点位</el-button>
|
|
|
|
|
|
|
|
<el-button
|
|
|
|
|
|
|
|
link
|
|
|
|
|
|
|
|
type="primary"
|
|
|
|
|
|
|
|
@click="openForm('setting', scope.row.id)"
|
|
|
|
|
|
|
|
v-hasPermi="['iot:device:update']"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
设置
|
|
|
|
|
|
|
|
</el-button>
|
|
|
|
|
|
|
|
<el-button
|
|
|
|
|
|
|
|
link
|
|
|
|
|
|
|
|
type="primary"
|
|
|
|
|
|
|
|
@click="handleCopy(scope.row.id)"
|
|
|
|
|
|
|
|
v-hasPermi="['iot:device:create']"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
复制
|
|
|
|
|
|
|
|
</el-button>
|
|
|
|
<el-button
|
|
|
|
<el-button
|
|
|
|
link
|
|
|
|
link
|
|
|
|
type="primary"
|
|
|
|
type="primary"
|
|
|
|
@ -141,6 +164,14 @@
|
|
|
|
>
|
|
|
|
>
|
|
|
|
编辑
|
|
|
|
编辑
|
|
|
|
</el-button>
|
|
|
|
</el-button>
|
|
|
|
|
|
|
|
<el-button
|
|
|
|
|
|
|
|
link
|
|
|
|
|
|
|
|
:type="isRowConnected(scope.row) ? 'warning' : 'success'"
|
|
|
|
|
|
|
|
:loading="!!connectLoadingMap[scope.row.id]"
|
|
|
|
|
|
|
|
@click.stop="handleToggleConnect(scope.row)"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
{{ isRowConnected(scope.row) ? '断开连接' : '连接' }}
|
|
|
|
|
|
|
|
</el-button>
|
|
|
|
<el-button
|
|
|
|
<el-button
|
|
|
|
link
|
|
|
|
link
|
|
|
|
type="danger"
|
|
|
|
type="danger"
|
|
|
|
@ -166,8 +197,9 @@
|
|
|
|
<!-- 子表的列表 -->
|
|
|
|
<!-- 子表的列表 -->
|
|
|
|
<ContentWrap>
|
|
|
|
<ContentWrap>
|
|
|
|
<el-tabs model-value="deviceAttribute">
|
|
|
|
<el-tabs model-value="deviceAttribute">
|
|
|
|
<el-tab-pane label="设备属性" name="deviceAttribute">
|
|
|
|
<el-tab-pane :label="deviceAttributeTabLabel" name="deviceAttribute">
|
|
|
|
<DeviceAttributeList :device-id="currentRow.id" />
|
|
|
|
<DeviceAttributeList v-if="attributeDeviceId" :device-id="attributeDeviceId" />
|
|
|
|
|
|
|
|
<el-empty v-else description="请点击设备列表的“点位”查看设备属性" />
|
|
|
|
</el-tab-pane>
|
|
|
|
</el-tab-pane>
|
|
|
|
</el-tabs>
|
|
|
|
</el-tabs>
|
|
|
|
</ContentWrap>
|
|
|
|
</ContentWrap>
|
|
|
|
@ -177,7 +209,7 @@
|
|
|
|
import { getStrDictOptions, DICT_TYPE } from '@/utils/dict'
|
|
|
|
import { getStrDictOptions, DICT_TYPE } from '@/utils/dict'
|
|
|
|
import { dateFormatter } from '@/utils/formatTime'
|
|
|
|
import { dateFormatter } from '@/utils/formatTime'
|
|
|
|
import download from '@/utils/download'
|
|
|
|
import download from '@/utils/download'
|
|
|
|
import { DeviceApi, DeviceVO } from '@/api/iot/device'
|
|
|
|
import { DeviceApi, DeviceConnectParams, DeviceVO } from '@/api/iot/device'
|
|
|
|
import DeviceForm from './DeviceForm.vue'
|
|
|
|
import DeviceForm from './DeviceForm.vue'
|
|
|
|
import DeviceAttributeList from './components/DeviceAttributeList.vue'
|
|
|
|
import DeviceAttributeList from './components/DeviceAttributeList.vue'
|
|
|
|
|
|
|
|
|
|
|
|
@ -188,6 +220,8 @@ defineOptions({ name: 'Device' })
|
|
|
|
const message = useMessage() // 消息弹窗
|
|
|
|
const message = useMessage() // 消息弹窗
|
|
|
|
const { t } = useI18n() // 国际化
|
|
|
|
const { t } = useI18n() // 国际化
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const tableRef = ref()
|
|
|
|
|
|
|
|
|
|
|
|
const loading = ref(true) // 列表的加载中
|
|
|
|
const loading = ref(true) // 列表的加载中
|
|
|
|
const list = ref<DeviceVO[]>([]) // 列表的数据
|
|
|
|
const list = ref<DeviceVO[]>([]) // 列表的数据
|
|
|
|
const total = ref(0) // 列表的总页数
|
|
|
|
const total = ref(0) // 列表的总页数
|
|
|
|
@ -211,6 +245,11 @@ const queryParams = reactive({
|
|
|
|
const queryFormRef = ref() // 搜索的表单
|
|
|
|
const queryFormRef = ref() // 搜索的表单
|
|
|
|
const exportLoading = ref(false) // 导出的加载中
|
|
|
|
const exportLoading = ref(false) // 导出的加载中
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const selectedIds = ref<number[]>([])
|
|
|
|
|
|
|
|
const handleSelectionChange = (rows: any[]) => {
|
|
|
|
|
|
|
|
selectedIds.value = rows?.map((row) => row.id).filter((id) => id !== undefined) ?? []
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** 查询列表 */
|
|
|
|
/** 查询列表 */
|
|
|
|
const getList = async () => {
|
|
|
|
const getList = async () => {
|
|
|
|
loading.value = true
|
|
|
|
loading.value = true
|
|
|
|
@ -242,26 +281,57 @@ const openForm = (type: string, id?: number) => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** 删除按钮操作 */
|
|
|
|
/** 删除按钮操作 */
|
|
|
|
const handleDelete = async (id: number) => {
|
|
|
|
const buildIdsParam = (ids: number | number[]) => {
|
|
|
|
|
|
|
|
return Array.isArray(ids) ? ids.join(',') : String(ids)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const handleDelete = async (ids: number | number[]) => {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
// 删除的二次确认
|
|
|
|
// 删除的二次确认
|
|
|
|
await message.delConfirm()
|
|
|
|
await message.delConfirm()
|
|
|
|
// 发起删除
|
|
|
|
// 发起删除
|
|
|
|
await DeviceApi.deleteDevice(id)
|
|
|
|
const idsParam = buildIdsParam(ids)
|
|
|
|
|
|
|
|
await DeviceApi.deleteDevice(idsParam)
|
|
|
|
message.success(t('common.delSuccess'))
|
|
|
|
message.success(t('common.delSuccess'))
|
|
|
|
|
|
|
|
selectedIds.value = []
|
|
|
|
|
|
|
|
tableRef.value?.clearSelection?.()
|
|
|
|
|
|
|
|
if (attributeDeviceId.value && idsParam.split(',').includes(String(attributeDeviceId.value))) {
|
|
|
|
|
|
|
|
attributeDeviceId.value = undefined
|
|
|
|
|
|
|
|
attributeDeviceName.value = ''
|
|
|
|
|
|
|
|
}
|
|
|
|
// 刷新列表
|
|
|
|
// 刷新列表
|
|
|
|
await getList()
|
|
|
|
await getList()
|
|
|
|
} catch {}
|
|
|
|
} catch {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const handleBatchDelete = async () => {
|
|
|
|
|
|
|
|
if (!selectedIds.value.length) {
|
|
|
|
|
|
|
|
message.error('请选择需要删除的数据')
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
await handleDelete(selectedIds.value)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const handleCopy = async (id: number) => {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
await DeviceApi.copyDevice(id)
|
|
|
|
|
|
|
|
message.success('复制成功')
|
|
|
|
|
|
|
|
await getList()
|
|
|
|
|
|
|
|
} catch {}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** 导出按钮操作 */
|
|
|
|
/** 导出按钮操作 */
|
|
|
|
const handleExport = async () => {
|
|
|
|
const handleExport = async () => {
|
|
|
|
|
|
|
|
if (!selectedIds.value.length) {
|
|
|
|
|
|
|
|
message.error('请选择需要导出的数据')
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
// 导出的二次确认
|
|
|
|
// 导出的二次确认
|
|
|
|
await message.exportConfirm()
|
|
|
|
await message.exportConfirm()
|
|
|
|
// 发起导出
|
|
|
|
// 发起导出
|
|
|
|
exportLoading.value = true
|
|
|
|
exportLoading.value = true
|
|
|
|
const data = await DeviceApi.exportDevice(queryParams)
|
|
|
|
const data = await DeviceApi.exportDevice({ ids: selectedIds.value.join(',') })
|
|
|
|
download.excel(data, '物联设备.xls')
|
|
|
|
download.excel(data, '物联设备.xls')
|
|
|
|
} catch {
|
|
|
|
} catch {
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
@ -269,10 +339,53 @@ const handleExport = async () => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** 选中行操作 */
|
|
|
|
const attributeDeviceId = ref<number | undefined>(undefined)
|
|
|
|
const currentRow = ref({}) // 选中行
|
|
|
|
const attributeDeviceName = ref('')
|
|
|
|
const handleCurrentChange = (row) => {
|
|
|
|
|
|
|
|
currentRow.value = row
|
|
|
|
const deviceAttributeTabLabel = computed(() => {
|
|
|
|
|
|
|
|
if (!attributeDeviceId.value) {
|
|
|
|
|
|
|
|
return '设备属性'
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return attributeDeviceName.value ? `设备属性:${attributeDeviceName.value}` : '设备属性'
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const handleShowAttribute = (row: any) => {
|
|
|
|
|
|
|
|
attributeDeviceId.value = row?.id
|
|
|
|
|
|
|
|
attributeDeviceName.value = row?.deviceName ?? ''
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const connectLoadingMap = reactive<Record<number, boolean>>({})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const getRowConnectValue = (row: any) => {
|
|
|
|
|
|
|
|
return row?.isConnect ?? row?.status
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const isRowConnected = (row: any) => {
|
|
|
|
|
|
|
|
return String(getRowConnectValue(row)) === '1'
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const handleToggleConnect = async (row: DeviceVO) => {
|
|
|
|
|
|
|
|
const id = row?.id
|
|
|
|
|
|
|
|
if (!id) {
|
|
|
|
|
|
|
|
message.error('设备信息不完整')
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const nextIsConnect = isRowConnected(row) ? '2' : '1'
|
|
|
|
|
|
|
|
const actionText = nextIsConnect === '1' ? '连接' : '断开连接'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
await message.confirm(`确认${actionText}设备“${row.deviceName ?? ''}”吗?`)
|
|
|
|
|
|
|
|
connectLoadingMap[id] = true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const params: DeviceConnectParams = { id: String(id), isConnect: nextIsConnect }
|
|
|
|
|
|
|
|
await DeviceApi.connectDevice(params)
|
|
|
|
|
|
|
|
message.success(`${actionText}成功`)
|
|
|
|
|
|
|
|
await getList()
|
|
|
|
|
|
|
|
} catch {
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
connectLoadingMap[id] = false
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let timer: any = null;
|
|
|
|
let timer: any = null;
|
|
|
|
|