|
@@ -0,0 +1,342 @@
|
|
|
|
+<template>
|
|
|
|
+ <el-row :gutter="20">
|
|
|
|
+ <!-- 左侧部门树 -->
|
|
|
|
+ <el-col :span="4" :xs="24">
|
|
|
|
+ <ContentWrap class="h-1/1" v-if="treeShow">
|
|
|
|
+ <DeptTree @node-click="handleDeptNodeClick" />
|
|
|
|
+ </ContentWrap>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="contentSpan" :xs="24">
|
|
|
|
+ <ContentWrap>
|
|
|
|
+ <!-- 搜索工作栏 -->
|
|
|
|
+ <el-form
|
|
|
|
+ class="-mb-15px"
|
|
|
|
+ :model="queryParams"
|
|
|
|
+ ref="queryFormRef"
|
|
|
|
+ :inline="true"
|
|
|
|
+ label-width="68px"
|
|
|
|
+ >
|
|
|
|
+ <el-form-item label="资产编码" prop="deviceCode">
|
|
|
|
+ <el-input
|
|
|
|
+ v-model="queryParams.deviceCode"
|
|
|
|
+ placeholder="请输入资产编码"
|
|
|
|
+ clearable
|
|
|
|
+ @keyup.enter="handleQuery"
|
|
|
|
+ class="!w-200px"
|
|
|
|
+ />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="设备名称" prop="deviceName">
|
|
|
|
+ <el-input
|
|
|
|
+ v-model="queryParams.deviceName"
|
|
|
|
+ placeholder="请输入设备名称"
|
|
|
|
+ clearable
|
|
|
|
+ @keyup.enter="handleQuery"
|
|
|
|
+ class="!w-200px"
|
|
|
|
+ />
|
|
|
|
+ </el-form-item>
|
|
|
|
+
|
|
|
|
+ <el-form-item>
|
|
|
|
+ <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
|
|
|
|
+ type="success"
|
|
|
|
+ plain
|
|
|
|
+ @click="handleExport"
|
|
|
|
+ :loading="exportLoading"
|
|
|
|
+ v-hasPermi="['rq:iot-device:export']"
|
|
|
|
+ >
|
|
|
|
+ <Icon icon="ep:download" class="mr-5px" /> 导出
|
|
|
|
+ </el-button>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-form>
|
|
|
|
+ </ContentWrap>
|
|
|
|
+
|
|
|
|
+ <!-- 列表 -->
|
|
|
|
+ <ContentWrap>
|
|
|
|
+ <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
|
|
|
+ <el-table-column label="序号" width="60" align="center">
|
|
|
|
+ <template #default="scope">
|
|
|
|
+ {{ scope.$index + 1 }}
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column label="资产编码" align="center" prop="deviceCode" />
|
|
|
|
+ <el-table-column label="设备名称" align="center" prop="deviceName">
|
|
|
|
+ <template #default="scope">
|
|
|
|
+ <el-link :underline="false" type="primary" @click="handleDetail(scope.row.id)">
|
|
|
|
+ {{ scope.row.deviceName }}
|
|
|
|
+ </el-link>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column label="距离保养" align="center">
|
|
|
|
+ <template #default="scope">
|
|
|
|
+ <span :class="getDistanceClass(scope.row.mainDistance)">
|
|
|
|
+ {{ scope.row.mainDistance }}
|
|
|
|
+ </span>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column label="所在部门" align="center" prop="deptName" />
|
|
|
|
+ <el-table-column label="设备状态" align="center" prop="deviceStatus">
|
|
|
|
+ <template #default="scope">
|
|
|
|
+ <dict-tag :type="DICT_TYPE.PMS_DEVICE_STATUS" :value="scope.row.deviceStatus" />
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column label="操作" align="center" min-width="120px">
|
|
|
|
+ <!-- <template #default="scope">
|
|
|
|
+
|
|
|
|
+ <el-button
|
|
|
|
+ link
|
|
|
|
+ type="primary"
|
|
|
|
+ @click="handleView(scope.row.id)"
|
|
|
|
+ v-hasPermi="['rq:iot-device:query']"
|
|
|
|
+ >
|
|
|
|
+ 调整记录
|
|
|
|
+ </el-button>
|
|
|
|
+ </template> -->
|
|
|
|
+ </el-table-column>
|
|
|
|
+ </el-table>
|
|
|
|
+ <!-- 分页 -->
|
|
|
|
+ <Pagination
|
|
|
|
+ :total="total"
|
|
|
|
+ v-model:page="queryParams.pageNo"
|
|
|
|
+ v-model:limit="queryParams.pageSize"
|
|
|
|
+ @pagination="getList"
|
|
|
|
+ />
|
|
|
|
+ </ContentWrap>
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-row>
|
|
|
|
+ <DevicePersonLogDrawer
|
|
|
|
+ :model-value="drawerVisible"
|
|
|
|
+ @update:model-value="val => drawerVisible = val"
|
|
|
|
+ :device-id="currentDeviceId"
|
|
|
|
+ ref="showDrawer"
|
|
|
|
+ />
|
|
|
|
+</template>
|
|
|
|
+
|
|
|
|
+<script setup lang="ts">
|
|
|
|
+import download from '@/utils/download'
|
|
|
|
+import { IotDeviceApi, IotDeviceVO } from '@/api/pms/device'
|
|
|
|
+import { IotMainWorkOrderApi, IotMainWorkOrderVO } from '@/api/pms/iotmainworkorder'
|
|
|
|
+import { DICT_TYPE, getStrDictOptions } from '@/utils/dict'
|
|
|
|
+import { dateFormatter } from '@/utils/formatTime'
|
|
|
|
+import DeptTree from '@/views/system/user/DeptTree.vue'
|
|
|
|
+import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
|
|
|
|
+import DevicePersonLogDrawer from "@/views/pms/device/DevicePersonLogDrawer.vue";
|
|
|
|
+
|
|
|
|
+/** 设备台账 列表 */
|
|
|
|
+defineOptions({ name: 'IotDevicePerson' })
|
|
|
|
+
|
|
|
|
+const message = useMessage() // 消息弹窗
|
|
|
|
+const { t } = useI18n() // 国际化
|
|
|
|
+const { push } = useRouter() // 路由跳转
|
|
|
|
+
|
|
|
|
+const loading = ref(true) // 列表的加载中
|
|
|
|
+const ifShow = ref(false)
|
|
|
|
+const isDetail = ref(false) // 是否查看详情
|
|
|
|
+const list = ref<IotDeviceVO[]>([]) // 列表的数据
|
|
|
|
+const total = ref(0) // 列表的总页数
|
|
|
|
+const queryParams = reactive({
|
|
|
|
+ pageNo: 1,
|
|
|
|
+ pageSize: 10,
|
|
|
|
+ deviceCode: undefined,
|
|
|
|
+ deviceName: undefined,
|
|
|
|
+ brand: undefined,
|
|
|
|
+ model: undefined,
|
|
|
|
+ deptId: undefined,
|
|
|
|
+ deviceStatus: undefined,
|
|
|
|
+ assetProperty: undefined,
|
|
|
|
+ picUrl: undefined,
|
|
|
|
+ remark: undefined,
|
|
|
|
+ manufacturerId: undefined,
|
|
|
|
+ supplierId: undefined,
|
|
|
|
+ manDate: [],
|
|
|
|
+ nameplate: undefined,
|
|
|
|
+ expires: undefined,
|
|
|
|
+ plPrice: undefined,
|
|
|
|
+ plDate: [],
|
|
|
|
+ plYear: undefined,
|
|
|
|
+ plStartDate: [],
|
|
|
|
+ plMonthed: undefined,
|
|
|
|
+ plAmounted: undefined,
|
|
|
|
+ remainAmount: undefined,
|
|
|
|
+ infoId: undefined,
|
|
|
|
+ infoType: undefined,
|
|
|
|
+ infoName: undefined,
|
|
|
|
+ infoRemark: undefined,
|
|
|
|
+ infoUrl: undefined,
|
|
|
|
+ templateJson: undefined,
|
|
|
|
+ creator: undefined,
|
|
|
|
+ setFlag: ''
|
|
|
|
+})
|
|
|
|
+const queryFormRef = ref() // 搜索的表单
|
|
|
|
+const exportLoading = ref(false) // 导出的加载中
|
|
|
|
+const contentSpan = ref(20)
|
|
|
|
+const treeShow = ref(true)
|
|
|
|
+const shou = (tree) =>{
|
|
|
|
+ treeShow.value = !tree
|
|
|
|
+ if (tree) {
|
|
|
|
+ contentSpan.value = 20
|
|
|
|
+ } else {
|
|
|
|
+ contentSpan.value = 24
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+/** 查询列表 */
|
|
|
|
+const getList = async () => {
|
|
|
|
+ loading.value = true
|
|
|
|
+ try {
|
|
|
|
+ const data = await IotMainWorkOrderApi.deviceMainDistances(queryParams)
|
|
|
|
+ list.value = data.list
|
|
|
|
+ total.value = data.total
|
|
|
|
+ } finally {
|
|
|
|
+ loading.value = false
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/** 处理部门被点击 */
|
|
|
|
+const handleDeptNodeClick = async (row) => {
|
|
|
|
+ queryParams.deptId = row.id
|
|
|
|
+ await getList()
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/** 搜索按钮操作 */
|
|
|
|
+const handleQuery = () => {
|
|
|
|
+ queryParams.pageNo = 1
|
|
|
|
+ getList()
|
|
|
|
+}
|
|
|
|
+const moreQuery = (show) => {
|
|
|
|
+ ifShow.value = show
|
|
|
|
+}
|
|
|
|
+/** 重置按钮操作 */
|
|
|
|
+const resetQuery = () => {
|
|
|
|
+ queryFormRef.value.resetFields()
|
|
|
|
+ handleQuery()
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/** 添加/修改操作 */
|
|
|
|
+const formRef = ref()
|
|
|
|
+const openForm = (type: string, id?: number) => {
|
|
|
|
+ //修改
|
|
|
|
+ if (typeof id === 'number') {
|
|
|
|
+ push({ name: 'DeviceDetailEdit', params: { id } })
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ // 新增
|
|
|
|
+ push({ name: 'ConfigDevicePerson', params: {} })
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+const getDistanceClass = (distance: number | string | null) => {
|
|
|
|
+ if (distance === null || distance === undefined) return '';
|
|
|
|
+
|
|
|
|
+ // 如果是数字类型,直接处理
|
|
|
|
+ if (typeof distance === 'number') {
|
|
|
|
+ return distance < 0 ? 'negative-distance' :
|
|
|
|
+ distance > 0 ? 'positive-distance' : '';
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 如果是字符串,提取数字部分
|
|
|
|
+ if (typeof distance === 'string') {
|
|
|
|
+ // 使用正则提取数字部分(包括负号、小数点和科学计数法)
|
|
|
|
+ const numericPart = distance.match(/[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/)?.[0];
|
|
|
|
+
|
|
|
|
+ // 如果提取到数字部分,转换为数值
|
|
|
|
+ if (numericPart) {
|
|
|
|
+ const num = parseFloat(numericPart);
|
|
|
|
+ return num < 0 ? 'negative-distance' :
|
|
|
|
+ num > 0 ? 'positive-distance' : '';
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return '';
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+/** 删除按钮操作 */
|
|
|
|
+const handleDelete = async (id: number) => {
|
|
|
|
+ try {
|
|
|
|
+ // 删除的二次确认
|
|
|
|
+ await message.delConfirm()
|
|
|
|
+ // 发起删除
|
|
|
|
+ await IotDeviceApi.deleteIotDevice(id)
|
|
|
|
+ message.success(t('common.delSuccess'))
|
|
|
|
+ // 刷新列表
|
|
|
|
+ await getList()
|
|
|
|
+ } catch {}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// 是否设置过责任人 下拉列表 模拟字典项
|
|
|
|
+const resultOptions = computed(() => [
|
|
|
|
+ {
|
|
|
|
+ label: '全部',
|
|
|
|
+ value: 'A' // 空值会触发 clearable 效果
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ label: '是',
|
|
|
|
+ value: 'Y' // 空值会触发 clearable 效果
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ label: '否',
|
|
|
|
+ value: 'N' // 空值会触发 clearable 效果
|
|
|
|
+ },
|
|
|
|
+])
|
|
|
|
+
|
|
|
|
+const handleDetail = (id: number) => {
|
|
|
|
+ push({ name: 'DeviceDetailInfo', params: { id } })
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+const handleUpload = (id: number) => {
|
|
|
|
+ push({ name: 'DeviceUpload', params: { id } })
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/** 查看设备责任人调整详情 */
|
|
|
|
+const currentDeviceId = ref() // 设备id
|
|
|
|
+const drawerVisible = ref<boolean>(false)
|
|
|
|
+const showDrawer = ref()
|
|
|
|
+const handleView = async (deviceId) => {
|
|
|
|
+ currentDeviceId.value = deviceId
|
|
|
|
+ drawerVisible.value = true
|
|
|
|
+ showDrawer.value.openDrawer()
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/** 导出按钮操作 */
|
|
|
|
+const handleExport = async () => {
|
|
|
|
+ try {
|
|
|
|
+ // 导出的二次确认
|
|
|
|
+ await message.exportConfirm()
|
|
|
|
+ // 发起导出
|
|
|
|
+ exportLoading.value = true
|
|
|
|
+ const data = await IotDeviceApi.exportIotDevice(queryParams)
|
|
|
|
+ download.excel(data, '设备台账.xls')
|
|
|
|
+ } catch {
|
|
|
|
+ } finally {
|
|
|
|
+ exportLoading.value = false
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+const { wsCache } = useCache()
|
|
|
|
+/** 初始化 **/
|
|
|
|
+onMounted(() => {
|
|
|
|
+ const user = wsCache.get(CACHE_KEY.USER)
|
|
|
|
+ // queryParams.deptId = user.user.deptId
|
|
|
|
+ getList()
|
|
|
|
+})
|
|
|
|
+</script>
|
|
|
|
+<style scoped>
|
|
|
|
+/* 正数样式 - 淡绿色 */
|
|
|
|
+.positive-distance {
|
|
|
|
+ color: #67c23a; /* element-plus 成功色 */
|
|
|
|
+ background-color: rgba(103, 194, 58, 0.1); /* 10% 透明度的淡绿色背景 */
|
|
|
|
+ padding: 2px 8px;
|
|
|
|
+ border-radius: 4px;
|
|
|
|
+ display: inline-block;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/* 负数样式 - 淡红色 */
|
|
|
|
+.negative-distance {
|
|
|
|
+ color: #f56c6c; /* element-plus 危险色 */
|
|
|
|
+ background-color: rgba(245, 108, 108, 0.1); /* 10% 透明度的淡红色背景 */
|
|
|
|
+ padding: 2px 8px;
|
|
|
|
+ border-radius: 4px;
|
|
|
|
+ display: inline-block;
|
|
|
|
+}
|
|
|
|
+</style>
|