2024-12-16 20:52:20 +08:00
|
|
|
|
<!-- TODO 目录,应该是 thinkModel 哈。 -->
|
2024-09-29 21:58:03 +08:00
|
|
|
|
<template>
|
|
|
|
|
<ContentWrap>
|
|
|
|
|
<!-- 搜索工作栏 -->
|
|
|
|
|
<el-form
|
|
|
|
|
ref="queryFormRef"
|
|
|
|
|
:inline="true"
|
2024-12-11 13:14:47 +08:00
|
|
|
|
:model="queryParams"
|
|
|
|
|
class="-mb-15px"
|
2024-09-29 21:58:03 +08:00
|
|
|
|
label-width="68px"
|
|
|
|
|
>
|
|
|
|
|
<el-form-item label="功能类型" prop="name">
|
|
|
|
|
<el-select
|
|
|
|
|
v-model="queryParams.type"
|
|
|
|
|
class="!w-240px"
|
2024-12-11 13:14:47 +08:00
|
|
|
|
clearable
|
|
|
|
|
placeholder="请选择功能类型"
|
2024-09-29 21:58:03 +08:00
|
|
|
|
>
|
|
|
|
|
<el-option
|
2024-12-17 16:20:09 +08:00
|
|
|
|
v-for="dict in getIntDictOptions(DICT_TYPE.IOT_PRODUCT_THINK_MODEL_TYPE)"
|
2024-09-29 21:58:03 +08:00
|
|
|
|
:key="dict.value"
|
|
|
|
|
:label="dict.label"
|
|
|
|
|
:value="dict.value"
|
|
|
|
|
/>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item>
|
2024-12-11 13:14:47 +08:00
|
|
|
|
<el-button @click="handleQuery">
|
|
|
|
|
<Icon class="mr-5px" icon="ep:search" />
|
|
|
|
|
搜索
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-button @click="resetQuery">
|
|
|
|
|
<Icon class="mr-5px" icon="ep:refresh" />
|
|
|
|
|
重置
|
|
|
|
|
</el-button>
|
2024-12-16 17:47:02 +08:00
|
|
|
|
<el-button
|
|
|
|
|
v-hasPermi="[`iot:product-thing-model:create`]"
|
|
|
|
|
plain
|
|
|
|
|
type="primary"
|
|
|
|
|
@click="openForm('create')"
|
|
|
|
|
>
|
2024-12-11 13:14:47 +08:00
|
|
|
|
<Icon class="mr-5px" icon="ep:plus" />
|
|
|
|
|
添加功能
|
2024-09-29 21:58:03 +08:00
|
|
|
|
</el-button>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
</ContentWrap>
|
|
|
|
|
<ContentWrap>
|
|
|
|
|
<el-tabs>
|
2024-12-11 13:14:47 +08:00
|
|
|
|
<el-table v-loading="loading" :data="list" :show-overflow-tooltip="true" :stripe="true">
|
|
|
|
|
<el-table-column align="center" label="功能类型" prop="type">
|
2024-09-30 12:19:55 +08:00
|
|
|
|
<template #default="scope">
|
2024-12-17 16:20:09 +08:00
|
|
|
|
<dict-tag :type="DICT_TYPE.IOT_PRODUCT_THINK_MODEL_TYPE" :value="scope.row.type" />
|
2024-09-30 12:19:55 +08:00
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
2024-12-11 13:14:47 +08:00
|
|
|
|
<el-table-column align="center" label="功能名称" prop="name" />
|
|
|
|
|
<el-table-column align="center" label="标识符" prop="identifier" />
|
2024-12-16 17:47:02 +08:00
|
|
|
|
<el-table-column align="center" label="数据类型" prop="identifier">
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
{{ dataTypeOptionsLabel(row.property.dataType) ?? '-' }}
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column align="center" label="数据定义" prop="identifier">
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
<!-- TODO puhui999: 数据定义展示待完善 -->
|
|
|
|
|
{{ row.property.dataSpecs ?? row.property.dataSpecsList }}
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
2024-12-11 13:14:47 +08:00
|
|
|
|
<el-table-column align="center" label="操作">
|
2024-09-29 21:58:03 +08:00
|
|
|
|
<template #default="scope">
|
|
|
|
|
<el-button
|
2024-12-16 17:47:02 +08:00
|
|
|
|
v-hasPermi="[`iot:product-thing-model:update`]"
|
2024-09-29 21:58:03 +08:00
|
|
|
|
link
|
|
|
|
|
type="primary"
|
|
|
|
|
@click="openForm('update', scope.row.id)"
|
|
|
|
|
>
|
|
|
|
|
编辑
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-button
|
2024-12-16 17:47:02 +08:00
|
|
|
|
v-hasPermi="['iot:product-thing-model:delete']"
|
2024-09-29 21:58:03 +08:00
|
|
|
|
link
|
|
|
|
|
type="danger"
|
|
|
|
|
@click="handleDelete(scope.row.id)"
|
|
|
|
|
>
|
|
|
|
|
删除
|
|
|
|
|
</el-button>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
</el-table>
|
|
|
|
|
<!-- 分页 -->
|
|
|
|
|
<Pagination
|
|
|
|
|
v-model:limit="queryParams.pageSize"
|
2024-12-11 13:14:47 +08:00
|
|
|
|
v-model:page="queryParams.pageNo"
|
|
|
|
|
:total="total"
|
2024-09-29 21:58:03 +08:00
|
|
|
|
@pagination="getList"
|
|
|
|
|
/>
|
|
|
|
|
</el-tabs>
|
|
|
|
|
</ContentWrap>
|
|
|
|
|
<!-- 表单弹窗:添加/修改 -->
|
2024-12-17 15:39:19 +08:00
|
|
|
|
<ThinkModelForm ref="formRef" @success="getList" />
|
2024-09-29 21:58:03 +08:00
|
|
|
|
</template>
|
2024-12-11 13:14:47 +08:00
|
|
|
|
<script lang="ts" setup>
|
2024-12-17 15:39:19 +08:00
|
|
|
|
import { ThinkModelApi, ThinkModelData } from '@/api/iot/thinkmodel'
|
2024-09-29 21:58:03 +08:00
|
|
|
|
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
2024-12-17 15:39:19 +08:00
|
|
|
|
import ThinkModelForm from './ThinkModelForm.vue'
|
2024-12-11 13:14:47 +08:00
|
|
|
|
import { ProductVO } from '@/api/iot/product/product'
|
|
|
|
|
import { IOT_PROVIDE_KEY } from '@/views/iot/utils/constants'
|
2024-12-17 15:39:19 +08:00
|
|
|
|
import { getDataTypeOptionsLabel } from '@/views/iot/thinkmodel/config'
|
2024-09-29 21:58:03 +08:00
|
|
|
|
|
2024-12-17 15:39:19 +08:00
|
|
|
|
defineOptions({ name: 'IoTProductThinkModel' })
|
2024-09-29 21:58:03 +08:00
|
|
|
|
|
2024-10-01 19:29:24 +08:00
|
|
|
|
const { t } = useI18n() // 国际化
|
2024-09-29 21:58:03 +08:00
|
|
|
|
const message = useMessage() // 消息弹窗
|
|
|
|
|
|
|
|
|
|
const loading = ref(true) // 列表的加载中
|
2024-12-17 15:39:19 +08:00
|
|
|
|
const list = ref<ThinkModelData[]>([]) // 列表的数据
|
2024-09-29 21:58:03 +08:00
|
|
|
|
const total = ref(0) // 列表的总页数
|
|
|
|
|
const queryParams = reactive({
|
|
|
|
|
pageNo: 1,
|
|
|
|
|
pageSize: 10,
|
|
|
|
|
type: undefined,
|
2024-10-01 19:29:24 +08:00
|
|
|
|
productId: -1
|
2024-09-29 21:58:03 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const queryFormRef = ref() // 搜索的表单
|
2024-12-11 13:14:47 +08:00
|
|
|
|
const product = inject<Ref<ProductVO>>(IOT_PROVIDE_KEY.PRODUCT) // 注入产品信息
|
2024-12-16 17:47:02 +08:00
|
|
|
|
const dataTypeOptionsLabel = computed(() => (value: string) => getDataTypeOptionsLabel(value)) // 解析数据类型
|
|
|
|
|
|
2024-09-29 21:58:03 +08:00
|
|
|
|
/** 查询列表 */
|
|
|
|
|
const getList = async () => {
|
|
|
|
|
loading.value = true
|
|
|
|
|
try {
|
2024-12-11 13:14:47 +08:00
|
|
|
|
queryParams.productId = product?.value?.id || -1
|
2024-12-17 16:20:09 +08:00
|
|
|
|
const data = await ThinkModelApi.getThinkModelPage(queryParams)
|
2024-09-29 21:58:03 +08:00
|
|
|
|
list.value = data.list
|
|
|
|
|
total.value = data.total
|
|
|
|
|
} finally {
|
|
|
|
|
loading.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/** 搜索按钮操作 */
|
|
|
|
|
const handleQuery = () => {
|
|
|
|
|
queryParams.pageNo = 1
|
|
|
|
|
getList()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 重置按钮操作 */
|
|
|
|
|
const resetQuery = () => {
|
|
|
|
|
queryFormRef.value.resetFields()
|
|
|
|
|
queryParams.type = undefined
|
|
|
|
|
handleQuery()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 添加/修改操作 */
|
|
|
|
|
const formRef = ref()
|
|
|
|
|
const openForm = (type: string, id?: number) => {
|
|
|
|
|
formRef.value.open(type, id)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 删除按钮操作 */
|
|
|
|
|
const handleDelete = async (id: number) => {
|
|
|
|
|
try {
|
|
|
|
|
// 删除的二次确认
|
|
|
|
|
await message.delConfirm()
|
|
|
|
|
// 发起删除
|
2024-12-17 16:20:09 +08:00
|
|
|
|
await ThinkModelApi.deleteThinkModel(id)
|
2024-09-29 21:58:03 +08:00
|
|
|
|
message.success(t('common.delSuccess'))
|
|
|
|
|
// 刷新列表
|
|
|
|
|
await getList()
|
|
|
|
|
} catch {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 初始化 **/
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
getList()
|
|
|
|
|
})
|
|
|
|
|
</script>
|