|
@@ -1,202 +1,41 @@
|
|
|
-<template>
|
|
|
|
|
- <doc-alert title="用户体系" url="https://doc.iocoder.cn/user-center/" />
|
|
|
|
|
- <doc-alert title="三方登陆" url="https://doc.iocoder.cn/social-user/" />
|
|
|
|
|
- <doc-alert title="Excel 导入导出" url="https://doc.iocoder.cn/excel-import-and-export/" />
|
|
|
|
|
-
|
|
|
|
|
- <el-row :gutter="20">
|
|
|
|
|
- <!-- 左侧 设备分类 树 -->
|
|
|
|
|
- <el-col :span="4" :xs="24">
|
|
|
|
|
- <ContentWrap class="h-1/1">
|
|
|
|
|
- <ModelCategoryTree @node-click="handleModelCategoryTreeNodeClick" />
|
|
|
|
|
- </ContentWrap>
|
|
|
|
|
- </el-col>
|
|
|
|
|
- <el-col :span="20" :xs="24">
|
|
|
|
|
- <!-- 搜索 -->
|
|
|
|
|
- <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"
|
|
|
|
|
- ref="queryFormRef"
|
|
|
|
|
- :inline="true"
|
|
|
|
|
- label-width="68px"
|
|
|
|
|
- >
|
|
|
|
|
- <el-form-item :label="t('modelTemplate.name')" prop="name" style="margin-left: 45px">
|
|
|
|
|
- <el-input
|
|
|
|
|
- v-model="queryParams.name"
|
|
|
|
|
- :placeholder="t('modelTemplate.nameHolder')"
|
|
|
|
|
- clearable
|
|
|
|
|
- @keyup.enter="handleQuery"
|
|
|
|
|
- class="!w-240px"
|
|
|
|
|
- />
|
|
|
|
|
- </el-form-item>
|
|
|
|
|
- <!-- <el-form-item label="模板编码" prop="code">
|
|
|
|
|
- <el-input
|
|
|
|
|
- v-model="queryParams.code"
|
|
|
|
|
- placeholder="请输入模板编码"
|
|
|
|
|
- clearable
|
|
|
|
|
- @keyup.enter="handleQuery"
|
|
|
|
|
- class="!w-240px"
|
|
|
|
|
- />
|
|
|
|
|
- </el-form-item>-->
|
|
|
|
|
- <el-form-item :label="t('modelTemplate.status')" prop="status">
|
|
|
|
|
- <el-select
|
|
|
|
|
- v-model="queryParams.status"
|
|
|
|
|
- :placeholder="t('modelTemplate.status')"
|
|
|
|
|
- clearable
|
|
|
|
|
- class="!w-240px"
|
|
|
|
|
- >
|
|
|
|
|
- <el-option
|
|
|
|
|
- v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
|
|
|
|
|
- :key="dict.value"
|
|
|
|
|
- :label="dict.label"
|
|
|
|
|
- :value="dict.value"
|
|
|
|
|
- />
|
|
|
|
|
- </el-select>
|
|
|
|
|
- </el-form-item>
|
|
|
|
|
- <el-form-item :label="t('modelTemplate.createTime')" prop="createTime">
|
|
|
|
|
- <el-date-picker
|
|
|
|
|
- v-model="queryParams.createTime"
|
|
|
|
|
- value-format="YYYY-MM-DD HH:mm:ss"
|
|
|
|
|
- type="datetimerange"
|
|
|
|
|
- :start-placeholder="t('operationFill.start')"
|
|
|
|
|
- :end-placeholder="t('operationFill.end')"
|
|
|
|
|
- class="!w-240px"
|
|
|
|
|
- />
|
|
|
|
|
- </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
|
|
|
|
|
- type="primary"
|
|
|
|
|
- plain
|
|
|
|
|
- @click="openForm('create')"
|
|
|
|
|
- v-hasPermi="['rq:iot-model-template:create']"
|
|
|
|
|
- >
|
|
|
|
|
- <Icon icon="ep:plus" />{{ t('operationFill.add') }}
|
|
|
|
|
- </el-button>
|
|
|
|
|
- </el-form-item>
|
|
|
|
|
- </el-form>
|
|
|
|
|
- </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"
|
|
|
|
|
- />-->
|
|
|
|
|
- <zm-table-column
|
|
|
|
|
- :label="t('modelTemplate.name')"
|
|
|
|
|
- align="center"
|
|
|
|
|
- prop="name"
|
|
|
|
|
- :show-overflow-tooltip="true"
|
|
|
|
|
- />
|
|
|
|
|
- <zm-table-column
|
|
|
|
|
- :label="t('modelTemplate.ec')"
|
|
|
|
|
- align="center"
|
|
|
|
|
- key="deviceCategoryName"
|
|
|
|
|
- prop="deviceCategoryName"
|
|
|
|
|
- :show-overflow-tooltip="true"
|
|
|
|
|
- />
|
|
|
|
|
- <zm-table-column :label="t('modelTemplate.status')" key="status">
|
|
|
|
|
- <template #default="scope">
|
|
|
|
|
- <el-switch
|
|
|
|
|
- v-model="scope.row.status"
|
|
|
|
|
- :active-value="0"
|
|
|
|
|
- :inactive-value="1"
|
|
|
|
|
- @change="handleStatusChange(scope.row)"
|
|
|
|
|
- :disabled="!checkPermi(['rq:iot-model-template:update'])"
|
|
|
|
|
- />
|
|
|
|
|
- </template>
|
|
|
|
|
- </zm-table-column>
|
|
|
|
|
- <zm-table-column
|
|
|
|
|
- :label="t('modelTemplate.createTime')"
|
|
|
|
|
- align="center"
|
|
|
|
|
- prop="createTime"
|
|
|
|
|
- :formatter="dateFormatter"
|
|
|
|
|
- />
|
|
|
|
|
- <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
|
|
|
|
|
- )
|
|
|
|
|
- "
|
|
|
|
|
- >
|
|
|
|
|
- <Icon icon="ep:edit" />{{ t('operationFill.view') }}
|
|
|
|
|
- </el-button>
|
|
|
|
|
- <el-button
|
|
|
|
|
- type="primary"
|
|
|
|
|
- link
|
|
|
|
|
- @click="openForm('update', scope.row.id)"
|
|
|
|
|
- v-hasPermi="['rq:iot-model-template:update']"
|
|
|
|
|
- >
|
|
|
|
|
- <Icon icon="ep:edit" />{{ t('modelTemplate.update') }}
|
|
|
|
|
- </el-button>
|
|
|
|
|
-
|
|
|
|
|
- <el-button
|
|
|
|
|
- type="danger"
|
|
|
|
|
- link
|
|
|
|
|
- @click="handleDelete(scope.row.id, scope.row.deviceCategoryId)"
|
|
|
|
|
- v-hasPermi="['rq:iot-model-template:delete']"
|
|
|
|
|
- >
|
|
|
|
|
- <Icon icon="ep:delete" />{{ t('modelTemplate.delete') }}
|
|
|
|
|
- </el-button>
|
|
|
|
|
- </div>
|
|
|
|
|
- </template>
|
|
|
|
|
- </zm-table-column>
|
|
|
|
|
- </zm-table>
|
|
|
|
|
- <Pagination
|
|
|
|
|
- :total="total"
|
|
|
|
|
- v-model:page="queryParams.pageNo"
|
|
|
|
|
- v-model:limit="queryParams.pageSize"
|
|
|
|
|
- @pagination="getList"
|
|
|
|
|
- />
|
|
|
|
|
- </ContentWrap>
|
|
|
|
|
- </el-col>
|
|
|
|
|
- </el-row>
|
|
|
|
|
-
|
|
|
|
|
- <!-- 添加或修改 属性模板 对话框 -->
|
|
|
|
|
- <TemplateForm ref="formRef" :category_id="selectedId" @success="getList" />
|
|
|
|
|
-</template>
|
|
|
|
|
<script lang="ts" setup>
|
|
<script lang="ts" setup>
|
|
|
|
|
+import { useTableComponents } from '@/components/ZmTable/useTableComponents'
|
|
|
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
|
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
|
|
import { checkPermi } from '@/utils/permission'
|
|
import { checkPermi } from '@/utils/permission'
|
|
|
-import { dateFormatter } from '@/utils/formatTime'
|
|
|
|
|
|
|
+import { dateFormatter, rangeShortcuts } from '@/utils/formatTime'
|
|
|
import { CommonStatusEnum } from '@/utils/constants'
|
|
import { CommonStatusEnum } from '@/utils/constants'
|
|
|
import * as ModelTemplateApi from '@/api/pms/modeltemplate'
|
|
import * as ModelTemplateApi from '@/api/pms/modeltemplate'
|
|
|
|
|
+import DeviceCategoryTree from '@/components/DeviceCategoryTree/index.vue'
|
|
|
import TemplateForm from './TemplateForm.vue'
|
|
import TemplateForm from './TemplateForm.vue'
|
|
|
-import ModelCategoryTree from './ModelCategoryTree.vue'
|
|
|
|
|
import { useTreeStore } from '@/store/modules/attrTemplateTreeStore'
|
|
import { useTreeStore } from '@/store/modules/attrTemplateTreeStore'
|
|
|
-import { useTableComponents } from '@/components/ZmTable/useTableComponents'
|
|
|
|
|
-const { ZmTable, ZmTableColumn } = useTableComponents()
|
|
|
|
|
|
|
|
|
|
defineOptions({ name: 'ModelAttrsTemplate' })
|
|
defineOptions({ name: 'ModelAttrsTemplate' })
|
|
|
|
|
|
|
|
-const treeStore = useTreeStore()
|
|
|
|
|
-const message = useMessage() // 消息弹窗
|
|
|
|
|
-const { t } = useI18n() // 国际化
|
|
|
|
|
|
|
+type ModelTemplateRow = Omit<ModelTemplateApi.ModelAttrTemplateVO, 'status'> & {
|
|
|
|
|
+ status?: number
|
|
|
|
|
+ deviceCategoryName?: string
|
|
|
|
|
+ createTime?: string
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
|
|
+interface QueryParams extends PageParam {
|
|
|
|
|
+ name?: string
|
|
|
|
|
+ code?: string
|
|
|
|
|
+ status?: number
|
|
|
|
|
+ deviceCategoryId?: number
|
|
|
|
|
+ deviceCategoryName?: string
|
|
|
|
|
+ createTime?: string[]
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+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([]) // 列表的数
|
|
|
|
|
-const queryParams = reactive({
|
|
|
|
|
|
|
+const { ZmTable, ZmTableColumn } = useTableComponents<ModelTemplateRow>()
|
|
|
|
|
+
|
|
|
|
|
+const loading = ref(true)
|
|
|
|
|
+const total = ref(0)
|
|
|
|
|
+const list = ref<ModelTemplateRow[]>([])
|
|
|
|
|
+const queryParams = reactive<QueryParams>({
|
|
|
pageNo: 1,
|
|
pageNo: 1,
|
|
|
pageSize: 10,
|
|
pageSize: 10,
|
|
|
name: undefined,
|
|
name: undefined,
|
|
@@ -206,81 +45,106 @@ const queryParams = reactive({
|
|
|
deviceCategoryName: undefined,
|
|
deviceCategoryName: undefined,
|
|
|
createTime: []
|
|
createTime: []
|
|
|
})
|
|
})
|
|
|
-const queryFormRef = ref() // 搜索的表单
|
|
|
|
|
|
|
+const queryFormRef = ref()
|
|
|
|
|
|
|
|
-// 从 Store 中获取左侧 设备分类树 选中的 节点ID
|
|
|
|
|
const selectedId = computed(() => treeStore.selectedId)
|
|
const selectedId = computed(() => treeStore.selectedId)
|
|
|
|
|
|
|
|
-const isInitialized = ref(false)
|
|
|
|
|
-/** 查询 设备属性模板 列表 */
|
|
|
|
|
|
|
+const normalizeStatus = (status: unknown) => {
|
|
|
|
|
+ const value = Number(status)
|
|
|
|
|
+ if (value === CommonStatusEnum.ENABLE || value === CommonStatusEnum.DISABLE) {
|
|
|
|
|
+ return value
|
|
|
|
|
+ }
|
|
|
|
|
+ return undefined
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const isValidStatus = (status: unknown) => normalizeStatus(status) !== undefined
|
|
|
|
|
+
|
|
|
|
|
+const getStatusText = (status: unknown) => {
|
|
|
|
|
+ const value = normalizeStatus(status)
|
|
|
|
|
+ if (value === CommonStatusEnum.ENABLE) return '启用'
|
|
|
|
|
+ if (value === CommonStatusEnum.DISABLE) return '停用'
|
|
|
|
|
+ return '未知'
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
const getList = async () => {
|
|
const getList = async () => {
|
|
|
loading.value = true
|
|
loading.value = true
|
|
|
try {
|
|
try {
|
|
|
const data = await ModelTemplateApi.getModelTemplatePage(queryParams)
|
|
const data = await ModelTemplateApi.getModelTemplatePage(queryParams)
|
|
|
- list.value = data.list
|
|
|
|
|
|
|
+ list.value = data.list.map((item: ModelTemplateRow) => ({
|
|
|
|
|
+ ...item,
|
|
|
|
|
+ status: normalizeStatus(item.status)
|
|
|
|
|
+ }))
|
|
|
total.value = data.total
|
|
total.value = data.total
|
|
|
- // 数据加载完成后,标记为已初始化
|
|
|
|
|
- setTimeout(() => {
|
|
|
|
|
- isInitialized.value = true
|
|
|
|
|
- }, 100)
|
|
|
|
|
} finally {
|
|
} finally {
|
|
|
loading.value = false
|
|
loading.value = false
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-/** 搜索按钮操作 */
|
|
|
|
|
const handleQuery = () => {
|
|
const handleQuery = () => {
|
|
|
queryParams.pageNo = 1
|
|
queryParams.pageNo = 1
|
|
|
getList()
|
|
getList()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-/** 重置按钮操作 */
|
|
|
|
|
const resetQuery = () => {
|
|
const resetQuery = () => {
|
|
|
queryFormRef.value?.resetFields()
|
|
queryFormRef.value?.resetFields()
|
|
|
handleQuery()
|
|
handleQuery()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-/** 处理 设备分类树 被点击 */
|
|
|
|
|
-const handleModelCategoryTreeNodeClick = async (row) => {
|
|
|
|
|
|
|
+const handleSizeChange = (val: number) => {
|
|
|
|
|
+ queryParams.pageSize = val
|
|
|
|
|
+ handleQuery()
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const handleCurrentChange = (val: number) => {
|
|
|
|
|
+ queryParams.pageNo = val
|
|
|
|
|
+ getList()
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const handleDeviceCategoryTreeNodeClick = async (row: Tree) => {
|
|
|
|
|
+ treeStore.setSelectedId(row.id)
|
|
|
queryParams.deviceCategoryId = row.id
|
|
queryParams.deviceCategoryId = row.id
|
|
|
|
|
+ queryParams.pageNo = 1
|
|
|
await getList()
|
|
await getList()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-/** 添加/修改操作 */
|
|
|
|
|
const formRef = ref()
|
|
const formRef = ref()
|
|
|
const openForm = (type: string, id?: number) => {
|
|
const openForm = (type: string, id?: number) => {
|
|
|
formRef.value.open(type, id)
|
|
formRef.value.open(type, id)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-/** 打开详情 */
|
|
|
|
|
-const openDetail = (id: string) => {
|
|
|
|
|
- push({ name: 'ModelAttrTemplate', params: { id } })
|
|
|
|
|
|
|
+const openDetail = (row: ModelTemplateRow) => {
|
|
|
|
|
+ push({
|
|
|
|
|
+ name: 'ModelAttrTemplate',
|
|
|
|
|
+ params: {
|
|
|
|
|
+ id: `${row.deviceCategoryId},${row.deviceCategoryName},${row.name}`
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-/** 修改 设备属性模板 状态 */
|
|
|
|
|
-const handleStatusChange = async (row: ModelTemplateApi.ModelAttrTemplateVO) => {
|
|
|
|
|
- // 如果还未初始化完成,直接返回
|
|
|
|
|
- if (!isInitialized.value) {
|
|
|
|
|
|
|
+const handleStatusChange = async (row: ModelTemplateRow, nextStatus: string | number | boolean) => {
|
|
|
|
|
+ const status = normalizeStatus(nextStatus)
|
|
|
|
|
+ const oldStatus = normalizeStatus(row.status)
|
|
|
|
|
+ if (
|
|
|
|
|
+ !row.id ||
|
|
|
|
|
+ !row.name ||
|
|
|
|
|
+ status === undefined ||
|
|
|
|
|
+ oldStatus === undefined ||
|
|
|
|
|
+ status === oldStatus
|
|
|
|
|
+ ) {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- // 修改状态的二次确认
|
|
|
|
|
- const text = row.status === CommonStatusEnum.ENABLE ? '启用' : '停用'
|
|
|
|
|
- await message.confirm('确认要"' + text + '""' + row.name + '"属性模板吗?')
|
|
|
|
|
- // 发起修改状态
|
|
|
|
|
- await ModelTemplateApi.updateModelTemplateStatus(row.id, row.status)
|
|
|
|
|
- // 刷新列表
|
|
|
|
|
|
|
+ await message.confirm(`确认要${getStatusText(status)}"${row.name}"属性模板吗?`)
|
|
|
|
|
+ row.status = status
|
|
|
|
|
+ await ModelTemplateApi.updateModelTemplateStatus(row.id, status)
|
|
|
await getList()
|
|
await getList()
|
|
|
} catch {
|
|
} catch {
|
|
|
- // 取消后,进行恢复按钮
|
|
|
|
|
- row.status =
|
|
|
|
|
- row.status === CommonStatusEnum.ENABLE ? CommonStatusEnum.DISABLE : CommonStatusEnum.ENABLE
|
|
|
|
|
|
|
+ row.status = oldStatus
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-/** 操作分发 */
|
|
|
|
|
-const handleCommand = (command: string, row: ModelTemplateApi.ModelAttrTemplateVO) => {
|
|
|
|
|
|
|
+const handleCommand = (command: string, row: ModelTemplateRow) => {
|
|
|
switch (command) {
|
|
switch (command) {
|
|
|
case 'handleDelete':
|
|
case 'handleDelete':
|
|
|
handleDelete(row.id, row.deviceCategoryId)
|
|
handleDelete(row.id, row.deviceCategoryId)
|
|
@@ -290,27 +154,200 @@ const handleCommand = (command: string, row: ModelTemplateApi.ModelAttrTemplateV
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-/** 删除按钮操作 */
|
|
|
|
|
const handleDelete = async (id: number | undefined, deviceId: number) => {
|
|
const handleDelete = async (id: number | undefined, deviceId: number) => {
|
|
|
try {
|
|
try {
|
|
|
const data = await ModelTemplateApi.getIsRelated(deviceId)
|
|
const data = await ModelTemplateApi.getIsRelated(deviceId)
|
|
|
if (data.length === 0) {
|
|
if (data.length === 0) {
|
|
|
- // 删除的二次确认
|
|
|
|
|
await message.delConfirm()
|
|
await message.delConfirm()
|
|
|
- // 发起删除
|
|
|
|
|
await ModelTemplateApi.deleteModelTemplate(id)
|
|
await ModelTemplateApi.deleteModelTemplate(id)
|
|
|
message.success(t('common.delSuccess'))
|
|
message.success(t('common.delSuccess'))
|
|
|
} else {
|
|
} else {
|
|
|
message.error(t('form.relatedModel'))
|
|
message.error(t('form.relatedModel'))
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 刷新列表
|
|
|
|
|
await getList()
|
|
await getList()
|
|
|
} catch {}
|
|
} catch {}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-/** 初始化 */
|
|
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
|
getList()
|
|
getList()
|
|
|
})
|
|
})
|
|
|
</script>
|
|
</script>
|
|
|
|
|
+
|
|
|
|
|
+<template>
|
|
|
|
|
+ <div
|
|
|
|
|
+ class="grid grid-cols-[auto_1fr] grid-rows-[auto_1fr] gap-4 h-[calc(100vh-20px-var(--top-tool-height)-var(--tags-view-height)-var(--app-footer-height))]">
|
|
|
|
|
+ <DeviceCategoryTree
|
|
|
|
|
+ v-model="queryParams.deviceCategoryId"
|
|
|
|
|
+ :show-title="false"
|
|
|
|
|
+ class="row-span-2"
|
|
|
|
|
+ @node-click="handleDeviceCategoryTreeNodeClick" />
|
|
|
|
|
+
|
|
|
|
|
+ <el-form
|
|
|
|
|
+ ref="queryFormRef"
|
|
|
|
|
+ :model="queryParams"
|
|
|
|
|
+ size="default"
|
|
|
|
|
+ label-width="68px"
|
|
|
|
|
+ class="bg-white dark:bg-[#1d1e1f] rounded-lg shadow px-8 py-3 gap-6 flex items-center justify-between flex-wrap min-w-0">
|
|
|
|
|
+ <div class="flex items-center gap-6 flex-wrap">
|
|
|
|
|
+ <el-form-item :label="t('modelTemplate.name')" prop="name">
|
|
|
|
|
+ <el-input
|
|
|
|
|
+ v-model="queryParams.name"
|
|
|
|
|
+ :placeholder="t('modelTemplate.nameHolder')"
|
|
|
|
|
+ clearable
|
|
|
|
|
+ class="!w-200px"
|
|
|
|
|
+ @keyup.enter="handleQuery" />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ <el-form-item :label="t('modelTemplate.status')" prop="status">
|
|
|
|
|
+ <el-select
|
|
|
|
|
+ v-model="queryParams.status"
|
|
|
|
|
+ :placeholder="t('modelTemplate.status')"
|
|
|
|
|
+ clearable
|
|
|
|
|
+ class="!w-180px">
|
|
|
|
|
+ <el-option
|
|
|
|
|
+ v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
|
|
|
|
|
+ :key="dict.value"
|
|
|
|
|
+ :label="dict.label"
|
|
|
|
|
+ :value="dict.value" />
|
|
|
|
|
+ </el-select>
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ <el-form-item :label="t('modelTemplate.createTime')" prop="createTime">
|
|
|
|
|
+ <el-date-picker
|
|
|
|
|
+ v-model="queryParams.createTime"
|
|
|
|
|
+ value-format="YYYY-MM-DD HH:mm:ss"
|
|
|
|
|
+ type="datetimerange"
|
|
|
|
|
+ :start-placeholder="t('operationFill.start')"
|
|
|
|
|
+ :end-placeholder="t('operationFill.end')"
|
|
|
|
|
+ :shortcuts="rangeShortcuts"
|
|
|
|
|
+ :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
|
|
|
|
|
+ class="!w-320px" />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ <el-form-item>
|
|
|
|
|
+ <el-button type="primary" @click="handleQuery">
|
|
|
|
|
+ <Icon icon="ep:search" class="mr-5px" />{{ t('operationFill.search') }}
|
|
|
|
|
+ </el-button>
|
|
|
|
|
+ <el-button @click="resetQuery">
|
|
|
|
|
+ <Icon icon="ep:refresh" class="mr-5px" />{{ t('operationFill.reset') }}
|
|
|
|
|
+ </el-button>
|
|
|
|
|
+ <el-button
|
|
|
|
|
+ type="primary"
|
|
|
|
|
+ plain
|
|
|
|
|
+ @click="openForm('create')"
|
|
|
|
|
+ v-hasPermi="['rq:iot-model-template:create']">
|
|
|
|
|
+ <Icon icon="ep:plus" class="mr-5px" />{{ t('operationFill.add') }}
|
|
|
|
|
+ </el-button>
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ </el-form>
|
|
|
|
|
+
|
|
|
|
|
+ <div class="bg-white dark:bg-[#1d1e1f] shadow rounded-lg flex flex-col p-4 min-w-0">
|
|
|
|
|
+ <div class="flex-1 relative min-h-0">
|
|
|
|
|
+ <el-auto-resizer class="absolute">
|
|
|
|
|
+ <template #default="{ width, height }">
|
|
|
|
|
+ <ZmTable
|
|
|
|
|
+ :data="list"
|
|
|
|
|
+ :loading="loading"
|
|
|
|
|
+ :width="width"
|
|
|
|
|
+ :height="height"
|
|
|
|
|
+ :max-height="height"
|
|
|
|
|
+ show-border>
|
|
|
|
|
+ <ZmTableColumn
|
|
|
|
|
+ type="index"
|
|
|
|
|
+ :label="t('iotDevice.serial')"
|
|
|
|
|
+ :width="70"
|
|
|
|
|
+ fixed="left"
|
|
|
|
|
+ hide-in-column-settings />
|
|
|
|
|
+ <ZmTableColumn
|
|
|
|
|
+ prop="name"
|
|
|
|
|
+ :label="t('modelTemplate.name')"
|
|
|
|
|
+ fixed="left"
|
|
|
|
|
+ min-width="180"
|
|
|
|
|
+ show-overflow-tooltip />
|
|
|
|
|
+ <ZmTableColumn
|
|
|
|
|
+ prop="deviceCategoryName"
|
|
|
|
|
+ :label="t('modelTemplate.ec')"
|
|
|
|
|
+ min-width="160"
|
|
|
|
|
+ show-overflow-tooltip />
|
|
|
|
|
+ <ZmTableColumn
|
|
|
|
|
+ prop="status"
|
|
|
|
|
+ :label="t('modelTemplate.status')"
|
|
|
|
|
+ :real-value="(row) => getStatusText(row.status)"
|
|
|
|
|
+ width="90">
|
|
|
|
|
+ <template #default="{ row }">
|
|
|
|
|
+ <el-switch
|
|
|
|
|
+ v-if="isValidStatus(row.status)"
|
|
|
|
|
+ :model-value="row.status"
|
|
|
|
|
+ :active-value="0"
|
|
|
|
|
+ :inactive-value="1"
|
|
|
|
|
+ :disabled="!checkPermi(['rq:iot-model-template:update'])"
|
|
|
|
|
+ @change="(status) => handleStatusChange(row, status)" />
|
|
|
|
|
+ <el-tag v-else type="info">未知</el-tag>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </ZmTableColumn>
|
|
|
|
|
+ <ZmTableColumn
|
|
|
|
|
+ prop="createTime"
|
|
|
|
|
+ :label="t('modelTemplate.createTime')"
|
|
|
|
|
+ :formatter="dateFormatter"
|
|
|
|
|
+ width="180" />
|
|
|
|
|
+ <ZmTableColumn :label="t('operationFill.operation')" width="220" fixed="right" action>
|
|
|
|
|
+ <template #default="{ row }">
|
|
|
|
|
+ <div class="flex items-center justify-center gap-2">
|
|
|
|
|
+ <el-button type="primary" link @click="openDetail(row)">
|
|
|
|
|
+ <Icon icon="ep:view" class="mr-3px" />{{ t('operationFill.view') }}
|
|
|
|
|
+ </el-button>
|
|
|
|
|
+ <el-button
|
|
|
|
|
+ type="primary"
|
|
|
|
|
+ link
|
|
|
|
|
+ @click="openForm('update', row.id)"
|
|
|
|
|
+ v-hasPermi="['rq:iot-model-template:update']">
|
|
|
|
|
+ <Icon icon="ep:edit" class="mr-3px" />{{ t('modelTemplate.update') }}
|
|
|
|
|
+ </el-button>
|
|
|
|
|
+ <el-dropdown
|
|
|
|
|
+ @command="(command) => handleCommand(command, row)"
|
|
|
|
|
+ v-hasPermi="['rq:iot-model-template:delete']">
|
|
|
|
|
+ <el-button type="primary" link>
|
|
|
|
|
+ <Icon icon="ep:more-filled" class="mr-3px" />更多
|
|
|
|
|
+ </el-button>
|
|
|
|
|
+ <template #dropdown>
|
|
|
|
|
+ <el-dropdown-menu>
|
|
|
|
|
+ <el-dropdown-item
|
|
|
|
|
+ command="handleDelete"
|
|
|
|
|
+ v-if="checkPermi(['rq:iot-model-template:delete'])">
|
|
|
|
|
+ <Icon icon="ep:delete" class="mr-5px" />{{ t('modelTemplate.delete') }}
|
|
|
|
|
+ </el-dropdown-item>
|
|
|
|
|
+ </el-dropdown-menu>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-dropdown>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </ZmTableColumn>
|
|
|
|
|
+ </ZmTable>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-auto-resizer>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ <div class="h-8 mt-2 flex items-center justify-end">
|
|
|
|
|
+ <el-pagination
|
|
|
|
|
+ v-show="total > 0"
|
|
|
|
|
+ size="default"
|
|
|
|
|
+ :current-page="queryParams.pageNo"
|
|
|
|
|
+ :page-size="queryParams.pageSize"
|
|
|
|
|
+ :background="true"
|
|
|
|
|
+ :page-sizes="[10, 20, 30, 50, 100]"
|
|
|
|
|
+ :total="total"
|
|
|
|
|
+ layout="total, sizes, prev, pager, next, jumper"
|
|
|
|
|
+ @size-change="handleSizeChange"
|
|
|
|
|
+ @current-change="handleCurrentChange" />
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ <TemplateForm ref="formRef" :category_id="selectedId" @success="getList" />
|
|
|
|
|
+</template>
|
|
|
|
|
+
|
|
|
|
|
+<style scoped>
|
|
|
|
|
+:deep(.el-form-item) {
|
|
|
|
|
+ margin-bottom: 0;
|
|
|
|
|
+}
|
|
|
|
|
+</style>
|