|
|
@@ -12,7 +12,10 @@
|
|
|
</el-col>
|
|
|
<el-col :span="20" :xs="24">
|
|
|
<!-- 搜索 -->
|
|
|
- <ContentWrap>
|
|
|
+ <div
|
|
|
+ style="border: none; background: #fff; display: flex; align-items: center"
|
|
|
+ class="py-2 rounded-sm px-2"
|
|
|
+ >
|
|
|
<el-form
|
|
|
class="-mb-15px"
|
|
|
:model="queryParams"
|
|
|
@@ -29,7 +32,7 @@
|
|
|
class="!w-240px"
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
-<!-- <el-form-item label="模板编码" prop="code">
|
|
|
+ <!-- <el-form-item label="模板编码" prop="code">
|
|
|
<el-input
|
|
|
v-model="queryParams.code"
|
|
|
placeholder="请输入模板编码"
|
|
|
@@ -64,41 +67,45 @@
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
<el-form-item>
|
|
|
- <el-button @click="handleQuery"><Icon icon="ep:search" />{{t('operationFill.search')}}</el-button>
|
|
|
- <el-button @click="resetQuery"><Icon icon="ep:refresh" />{{t('operationFill.reset')}}</el-button>
|
|
|
+ <el-button @click="handleQuery"
|
|
|
+ ><Icon icon="ep:search" />{{ t('operationFill.search') }}</el-button
|
|
|
+ >
|
|
|
+ <el-button @click="resetQuery"
|
|
|
+ ><Icon icon="ep:refresh" />{{ t('operationFill.reset') }}</el-button
|
|
|
+ >
|
|
|
<el-button
|
|
|
type="primary"
|
|
|
plain
|
|
|
@click="openForm('create')"
|
|
|
v-hasPermi="['rq:iot-model-template:create']"
|
|
|
>
|
|
|
- <Icon icon="ep:plus" />{{t('operationFill.add')}}
|
|
|
+ <Icon icon="ep:plus" />{{ t('operationFill.add') }}
|
|
|
</el-button>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
- </ContentWrap>
|
|
|
- <ContentWrap>
|
|
|
- <el-table v-loading="loading" :data="list">
|
|
|
-<!-- <el-table-column
|
|
|
+ </div>
|
|
|
+ <ContentWrap style="border: none; margin-top: 20px">
|
|
|
+ <zm-table :loading="loading" :data="list">
|
|
|
+ <!-- <el-table-column
|
|
|
label="模板编码"
|
|
|
align="center"
|
|
|
prop="code"
|
|
|
:show-overflow-tooltip="true"
|
|
|
/>-->
|
|
|
- <el-table-column
|
|
|
+ <zm-table-column
|
|
|
:label="t('modelTemplate.name')"
|
|
|
align="center"
|
|
|
prop="name"
|
|
|
:show-overflow-tooltip="true"
|
|
|
/>
|
|
|
- <el-table-column
|
|
|
+ <zm-table-column
|
|
|
:label="t('modelTemplate.ec')"
|
|
|
align="center"
|
|
|
key="deviceCategoryName"
|
|
|
prop="deviceCategoryName"
|
|
|
:show-overflow-tooltip="true"
|
|
|
/>
|
|
|
- <el-table-column :label="t('modelTemplate.status')" key="status">
|
|
|
+ <zm-table-column :label="t('modelTemplate.status')" key="status">
|
|
|
<template #default="scope">
|
|
|
<el-switch
|
|
|
v-model="scope.row.status"
|
|
|
@@ -108,23 +115,30 @@
|
|
|
:disabled="!checkPermi(['rq:iot-model-template:update'])"
|
|
|
/>
|
|
|
</template>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column
|
|
|
+ </zm-table-column>
|
|
|
+ <zm-table-column
|
|
|
:label="t('modelTemplate.createTime')"
|
|
|
align="center"
|
|
|
prop="createTime"
|
|
|
:formatter="dateFormatter"
|
|
|
- width="180"
|
|
|
/>
|
|
|
- <el-table-column :label="t('operationFill.operation')" align="center" width="260">
|
|
|
+ <zm-table-column :label="t('operationFill.operation')" align="center" width="220" action>
|
|
|
<template #default="scope">
|
|
|
<div class="flex items-center justify-center">
|
|
|
<el-button
|
|
|
type="primary"
|
|
|
link
|
|
|
- @click="openDetail(scope.row.deviceCategoryId+','+scope.row.deviceCategoryName+','+scope.row.name)"
|
|
|
+ @click="
|
|
|
+ openDetail(
|
|
|
+ scope.row.deviceCategoryId +
|
|
|
+ ',' +
|
|
|
+ scope.row.deviceCategoryName +
|
|
|
+ ',' +
|
|
|
+ scope.row.name
|
|
|
+ )
|
|
|
+ "
|
|
|
>
|
|
|
- <Icon icon="ep:edit" />{{t('operationFill.view')}}
|
|
|
+ <Icon icon="ep:edit" />{{ t('operationFill.view') }}
|
|
|
</el-button>
|
|
|
<el-button
|
|
|
type="primary"
|
|
|
@@ -132,22 +146,21 @@
|
|
|
@click="openForm('update', scope.row.id)"
|
|
|
v-hasPermi="['rq:iot-model-template:update']"
|
|
|
>
|
|
|
- <Icon icon="ep:edit" />{{t('modelTemplate.update')}}
|
|
|
+ <Icon icon="ep:edit" />{{ t('modelTemplate.update') }}
|
|
|
</el-button>
|
|
|
|
|
|
<el-button
|
|
|
type="danger"
|
|
|
link
|
|
|
- @click="handleDelete(scope.row.id,scope.row.deviceCategoryId)"
|
|
|
+ @click="handleDelete(scope.row.id, scope.row.deviceCategoryId)"
|
|
|
v-hasPermi="['rq:iot-model-template:delete']"
|
|
|
>
|
|
|
- <Icon icon="ep:delete" />{{t('modelTemplate.delete')}}
|
|
|
+ <Icon icon="ep:delete" />{{ t('modelTemplate.delete') }}
|
|
|
</el-button>
|
|
|
-
|
|
|
</div>
|
|
|
</template>
|
|
|
- </el-table-column>
|
|
|
- </el-table>
|
|
|
+ </zm-table-column>
|
|
|
+ </zm-table>
|
|
|
<Pagination
|
|
|
:total="total"
|
|
|
v-model:page="queryParams.pageNo"
|
|
|
@@ -169,16 +182,17 @@ import { CommonStatusEnum } from '@/utils/constants'
|
|
|
import * as ModelTemplateApi from '@/api/pms/modeltemplate'
|
|
|
import TemplateForm from './TemplateForm.vue'
|
|
|
import ModelCategoryTree from './ModelCategoryTree.vue'
|
|
|
-import { useTreeStore } from '@/store/modules/attrTemplateTreeStore';
|
|
|
-import {DeviceAttrModelApi} from "@/api/pms/modelattrtemplate";
|
|
|
+import { useTreeStore } from '@/store/modules/attrTemplateTreeStore'
|
|
|
+import { useTableComponents } from '@/components/ZmTable/useTableComponents'
|
|
|
+const { ZmTable, ZmTableColumn } = useTableComponents()
|
|
|
|
|
|
defineOptions({ name: 'ModelAttrsTemplate' })
|
|
|
|
|
|
-const treeStore = useTreeStore();
|
|
|
+const treeStore = useTreeStore()
|
|
|
const message = useMessage() // 消息弹窗
|
|
|
const { t } = useI18n() // 国际化
|
|
|
|
|
|
-const {push} = useRouter()
|
|
|
+const { push } = useRouter()
|
|
|
const loading = ref(true) // 列表的加载中
|
|
|
const total = ref(0) // 列表的总页数
|
|
|
const list = ref([]) // 列表的数
|
|
|
@@ -189,14 +203,15 @@ const queryParams = reactive({
|
|
|
code: undefined,
|
|
|
status: undefined,
|
|
|
deviceCategoryId: undefined,
|
|
|
- deviceCategoryName:undefined,
|
|
|
+ deviceCategoryName: undefined,
|
|
|
createTime: []
|
|
|
})
|
|
|
const queryFormRef = ref() // 搜索的表单
|
|
|
|
|
|
// 从 Store 中获取左侧 设备分类树 选中的 节点ID
|
|
|
-const selectedId = computed(() => treeStore.selectedId);
|
|
|
+const selectedId = computed(() => treeStore.selectedId)
|
|
|
|
|
|
+const isInitialized = ref(false)
|
|
|
/** 查询 设备属性模板 列表 */
|
|
|
const getList = async () => {
|
|
|
loading.value = true
|
|
|
@@ -204,6 +219,10 @@ const getList = async () => {
|
|
|
const data = await ModelTemplateApi.getModelTemplatePage(queryParams)
|
|
|
list.value = data.list
|
|
|
total.value = data.total
|
|
|
+ // 数据加载完成后,标记为已初始化
|
|
|
+ setTimeout(() => {
|
|
|
+ isInitialized.value = true
|
|
|
+ }, 100)
|
|
|
} finally {
|
|
|
loading.value = false
|
|
|
}
|
|
|
@@ -235,12 +254,16 @@ const openForm = (type: string, id?: number) => {
|
|
|
|
|
|
/** 打开详情 */
|
|
|
const openDetail = (id: string) => {
|
|
|
- push({ name: 'ModelAttrTemplate', params: {id} })
|
|
|
+ push({ name: 'ModelAttrTemplate', params: { id } })
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/** 修改 设备属性模板 状态 */
|
|
|
const handleStatusChange = async (row: ModelTemplateApi.ModelAttrTemplateVO) => {
|
|
|
+ // 如果还未初始化完成,直接返回
|
|
|
+ if (!isInitialized.value) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
try {
|
|
|
// 修改状态的二次确认
|
|
|
const text = row.status === CommonStatusEnum.ENABLE ? '启用' : '停用'
|
|
|
@@ -260,7 +283,7 @@ const handleStatusChange = async (row: ModelTemplateApi.ModelAttrTemplateVO) =>
|
|
|
const handleCommand = (command: string, row: ModelTemplateApi.ModelAttrTemplateVO) => {
|
|
|
switch (command) {
|
|
|
case 'handleDelete':
|
|
|
- handleDelete(row.id,row.deviceCategoryId)
|
|
|
+ handleDelete(row.id, row.deviceCategoryId)
|
|
|
break
|
|
|
default:
|
|
|
break
|
|
|
@@ -270,14 +293,14 @@ const handleCommand = (command: string, row: ModelTemplateApi.ModelAttrTemplateV
|
|
|
/** 删除按钮操作 */
|
|
|
const handleDelete = async (id: number | undefined, deviceId: number) => {
|
|
|
try {
|
|
|
- const data = await ModelTemplateApi.getIsRelated(deviceId);
|
|
|
- if(data.length===0){
|
|
|
+ const data = await ModelTemplateApi.getIsRelated(deviceId)
|
|
|
+ if (data.length === 0) {
|
|
|
// 删除的二次确认
|
|
|
await message.delConfirm()
|
|
|
// 发起删除
|
|
|
await ModelTemplateApi.deleteModelTemplate(id)
|
|
|
message.success(t('common.delSuccess'))
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
message.error(t('form.relatedModel'))
|
|
|
}
|
|
|
|