|
@@ -22,71 +22,61 @@
|
|
|
新增档案
|
|
|
</el-button>
|
|
|
|
|
|
- <el-button type="primary" @click="addOrEdit()" v-if="productIno">
|
|
|
+ <!-- <el-button type="primary" @click="addOrEdit()" v-if="productIno">
|
|
|
<el-icon>
|
|
|
<ele-FolderAdd />
|
|
|
</el-icon>
|
|
|
批量添加
|
|
|
- </el-button>
|
|
|
+ </el-button> -->
|
|
|
|
|
|
- <el-button type="danger" @click="addOrEdit()">
|
|
|
+ <!-- <el-button type="danger" @click="addOrEdit()">
|
|
|
<el-icon>
|
|
|
<ele-FolderAdd />
|
|
|
</el-icon>
|
|
|
批量删除
|
|
|
- </el-button>
|
|
|
+ </el-button> -->
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
</div>
|
|
|
<el-row>
|
|
|
<el-col :span="6">
|
|
|
- <el-tree :data="mergedData" :props="defaultProps" accordion default-expand-all @node-click="handleNodeClick" style="border: 1px solid #eee;padding: 10px;margin-right: 10px;">
|
|
|
+ <el-tree
|
|
|
+ :data="mergedData"
|
|
|
+ :props="defaultProps"
|
|
|
+ accordion
|
|
|
+ default-expand-all
|
|
|
+ @node-click="handleNodeClick"
|
|
|
+ style="border: 1px solid #eee; padding: 10px; margin-right: 10px"
|
|
|
+ >
|
|
|
<template #default="{ node, data }">
|
|
|
<span :style="data.is_type === '2' ? { color: '#409eff' } : {}">
|
|
|
- <el-icon v-if="data.is_type == '2'"><Expand /></el-icon>
|
|
|
- {{ node.label }}
|
|
|
+ <el-icon v-if="data.is_type == '2'"><Check /></el-icon>
|
|
|
+ {{ node.label }}
|
|
|
</span>
|
|
|
</template>
|
|
|
- </el-tree>
|
|
|
+ </el-tree>
|
|
|
</el-col>
|
|
|
- <el-col :span="18"><el-table :data="tableData" style="width: 100%" row-key="id" v-loading="loading">
|
|
|
- <el-table-column prop="id" label="设备名称" min-width="100" show-overflow-tooltip></el-table-column>
|
|
|
- <el-table-column prop="name" label="设备ID" show-overflow-tooltip></el-table-column>
|
|
|
- <el-table-column prop="sceneType" label="设备编码" align="center">
|
|
|
- <template #default="scope">
|
|
|
- <el-tag size="small" v-if="scope.row.sceneType == 'device'">设备触发</el-tag>
|
|
|
- <el-tag size="small" v-if="scope.row.sceneType == 'manual'">手动触发</el-tag>
|
|
|
- <el-tag size="small" v-if="scope.row.sceneType == 'timer'">定时触发</el-tag>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
+ <el-col :span="18"
|
|
|
+ ><el-table :data="tableData" style="width: 100%" row-key="id" v-loading="loading">
|
|
|
+ <el-table-column type="selection" width="55" align="center" />
|
|
|
|
|
|
- <el-table-column prop="name" label="所属区域" show-overflow-tooltip></el-table-column>
|
|
|
- <el-table-column prop="name" label="管理单位" show-overflow-tooltip></el-table-column>
|
|
|
- <el-table-column prop="name" label="建设单位" show-overflow-tooltip></el-table-column>
|
|
|
- <el-table-column prop="name" label="维护单位" show-overflow-tooltip></el-table-column>
|
|
|
- <el-table-column prop="name" label="设备类型" show-overflow-tooltip></el-table-column>
|
|
|
+ <el-table-column prop="deviceName" label="设备名称" min-width="100" show-overflow-tooltip></el-table-column>
|
|
|
+ <el-table-column prop="deviceKey" label="设备KEY" show-overflow-tooltip></el-table-column>
|
|
|
|
|
|
- <el-table-column prop="status" label="状态" align="center">
|
|
|
- <template #default="scope">
|
|
|
- <el-tag size="small" type="success" v-if="scope.row.status == 1">启用</el-tag>
|
|
|
- <el-tag size="small" type="info" v-if="scope.row.status == 0">禁用</el-tag>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
+ <el-table-column prop="deviceNumber" label="设备编码" show-overflow-tooltip></el-table-column>
|
|
|
+
|
|
|
+ <el-table-column prop="deviceCategory" label="设备类型" show-overflow-tooltip></el-table-column>
|
|
|
|
|
|
- <el-table-column prop="createdAt" label="创建时间" width="160" align="center"></el-table-column>
|
|
|
+ <el-table-column prop="installTime" label="安装时间" width="160" align="center"></el-table-column>
|
|
|
<el-table-column label="操作" width="200" align="center">
|
|
|
<template #default="scope">
|
|
|
- <el-button size="small" text type="primary" v-if="!scope.row.folderName"
|
|
|
- @click="toDetail(scope.row.id)">属性</el-button>
|
|
|
- <el-button size="small" text type="warning" v-auth="'edit'"
|
|
|
- @click="addOrEdit(scope.row)">编辑</el-button>
|
|
|
+ <el-button size="small" text type="warning" v-auth="'edit'" @click="addOrEdit(scope.row)">编辑</el-button>
|
|
|
|
|
|
<el-button size="small" text type="info" v-auth="'del'" @click="del(scope.row)">删除</el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
- <pagination v-if="params.total" :total="params.total" v-model:page="params.pageNum"
|
|
|
- v-model:limit="params.pageSize" @pagination="getList()" />
|
|
|
+ <pagination v-if="params.total" :total="params.total" v-model:page="params.pageNum" v-model:limit="params.pageSize" @pagination="getList()" />
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
|
|
@@ -97,19 +87,19 @@
|
|
|
<script lang="ts" setup>
|
|
|
import device from '/@/api/device'
|
|
|
import { useSearch } from '/@/hooks/useCommon'
|
|
|
-import { Expand } from '@element-plus/icons-vue';
|
|
|
+import { Check } from '@element-plus/icons-vue'
|
|
|
|
|
|
import { ElMessageBox, ElMessage } from 'element-plus'
|
|
|
import EditForm from './edit.vue'
|
|
|
interface Tree {
|
|
|
- label: string
|
|
|
- children?: Tree[]
|
|
|
+ label: string
|
|
|
+ children?: Tree[]
|
|
|
}
|
|
|
-import { ref,onMounted} from 'vue'
|
|
|
+import { ref, onMounted } from 'vue'
|
|
|
import { useRouter } from 'vue-router'
|
|
|
const defaultProps = {
|
|
|
- children: 'children',
|
|
|
- label: 'label',
|
|
|
+ children: 'children',
|
|
|
+ label: 'label',
|
|
|
}
|
|
|
|
|
|
const queryRef = ref()
|
|
@@ -118,8 +108,7 @@ const productData = ref([])
|
|
|
const mergedData = ref()
|
|
|
const cateData = ref()
|
|
|
const editFormRef = ref()
|
|
|
-const productIno=ref();
|
|
|
-
|
|
|
+const productIno = ref()
|
|
|
|
|
|
const { params, tableData, getList, loading } = useSearch<any[]>(device.dev_asset.getList, 'Data', { keyWord: '' })
|
|
|
getList()
|
|
@@ -128,76 +117,72 @@ const toDetail = (id: number) => {
|
|
|
}
|
|
|
onMounted(() => {
|
|
|
getCateList()
|
|
|
-
|
|
|
-});
|
|
|
+})
|
|
|
const addOrEdit = async (row?: any) => {
|
|
|
if (row) {
|
|
|
- editFormRef.value.open(row,productIno.value)
|
|
|
+ editFormRef.value.open(row, productIno.value)
|
|
|
return
|
|
|
} else {
|
|
|
- editFormRef.value.open({},productIno.value)
|
|
|
+ editFormRef.value.open({}, productIno.value)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
const getCateList = () => {
|
|
|
device.category.getList({}).then((res: any) => {
|
|
|
- cateData.value = res.category;
|
|
|
+ cateData.value = res.category
|
|
|
|
|
|
device.product.getLists({}).then((res: any) => {
|
|
|
- productData.value = res.product;
|
|
|
- mergedData.value = matchProductsToCategories(productData.value, cateData.value);
|
|
|
+ productData.value = res.product
|
|
|
+ mergedData.value = matchProductsToCategories(productData.value, cateData.value)
|
|
|
})
|
|
|
-
|
|
|
})
|
|
|
}
|
|
|
|
|
|
const handleNodeClick = (data: any) => {
|
|
|
- if(data.is_type==='2'){
|
|
|
- productIno.value=data;
|
|
|
- }else{
|
|
|
- productIno.value='';
|
|
|
-
|
|
|
+ if (data.is_type === '2') {
|
|
|
+ productIno.value = data
|
|
|
+ } else {
|
|
|
+ productIno.value = ''
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-const matchProductsToCategories = (productData:any, cateData:any) => {
|
|
|
- const treeData = []
|
|
|
- for (let category of cateData) {
|
|
|
- const treeNode = buildTree(category, productData)
|
|
|
- treeData.push(treeNode)
|
|
|
- }
|
|
|
- return treeData
|
|
|
+const matchProductsToCategories = (productData: any, cateData: any) => {
|
|
|
+ const treeData = []
|
|
|
+ for (let category of cateData) {
|
|
|
+ const treeNode = buildTree(category, productData)
|
|
|
+ treeData.push(treeNode)
|
|
|
+ }
|
|
|
+ return treeData
|
|
|
}
|
|
|
|
|
|
-const buildTree = (category:any, productData:any) => {
|
|
|
- const treeNode = {
|
|
|
- id: category.id,
|
|
|
- label: category.name,
|
|
|
- key: category.key,
|
|
|
- is_type: '1', // 1是分类
|
|
|
- children: [],
|
|
|
- }
|
|
|
-
|
|
|
- if (category.children && category.children.length > 0) {
|
|
|
- for (let child of category.children) {
|
|
|
- const childNode = buildTree(child, productData)
|
|
|
- treeNode.children.push(childNode)
|
|
|
- }
|
|
|
- } else {
|
|
|
- const products = productData.filter((product:any) => product.categoryId === category.id)
|
|
|
- for (let product of products) {
|
|
|
- const productNode = {
|
|
|
- id: product.id,
|
|
|
- label: product.name,
|
|
|
- key: product.key,
|
|
|
- is_type: '2', // 2是产品
|
|
|
- }
|
|
|
- treeNode.children.push(productNode)
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return treeNode
|
|
|
+const buildTree = (category: any, productData: any) => {
|
|
|
+ const treeNode = {
|
|
|
+ id: category.id,
|
|
|
+ label: category.name,
|
|
|
+ key: category.key,
|
|
|
+ is_type: '1', // 1是分类
|
|
|
+ children: [],
|
|
|
+ }
|
|
|
+
|
|
|
+ if (category.children && category.children.length > 0) {
|
|
|
+ for (let child of category.children) {
|
|
|
+ const childNode = buildTree(child, productData)
|
|
|
+ treeNode.children.push(childNode)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ const products = productData.filter((product: any) => product.categoryId === category.id)
|
|
|
+ for (let product of products) {
|
|
|
+ const productNode = {
|
|
|
+ id: product.id,
|
|
|
+ label: product.name,
|
|
|
+ key: product.key,
|
|
|
+ is_type: '2', // 2是产品
|
|
|
+ }
|
|
|
+ treeNode.children.push(productNode)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return treeNode
|
|
|
}
|
|
|
|
|
|
const del = (row: any) => {
|
|
@@ -206,11 +191,12 @@ const del = (row: any) => {
|
|
|
cancelButtonText: '取消',
|
|
|
type: 'warning',
|
|
|
}).then(async () => {
|
|
|
- await device.dev_asset.delete(row.id)
|
|
|
+ await device.dev_asset.delete({ids:row.id})
|
|
|
ElMessage.success('删除成功')
|
|
|
getList()
|
|
|
})
|
|
|
}
|
|
|
-getCateList()
|
|
|
|
|
|
+
|
|
|
+getCateList()
|
|
|
</script>
|