Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
85c0da5a
authored
Sep 07, 2024
by
YunaiV
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/feature/iot' into feature/iot
# Conflicts: # src/components/DictTag/src/DictTag.vue
parents
daddf796
e6d83c1b
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
126 additions
and
68 deletions
+126
-68
src/api/iot/product/index.ts
+6
-2
src/views/iot/product/ProductForm.vue
+10
-18
src/views/iot/product/detail/ProductDetailsHeader.vue
+64
-11
src/views/iot/product/detail/ProductDetailsInfo.vue
+29
-22
src/views/iot/product/detail/index.vue
+5
-1
src/views/iot/product/index.vue
+12
-14
No files found.
src/api/iot/product/index.ts
View file @
85c0da5a
...
@@ -46,5 +46,10 @@ export const ProductApi = {
...
@@ -46,5 +46,10 @@ export const ProductApi = {
// 导出iot 产品 Excel
// 导出iot 产品 Excel
exportProduct
:
async
(
params
)
=>
{
exportProduct
:
async
(
params
)
=>
{
return
await
request
.
download
({
url
:
`/iot/product/export-excel`
,
params
})
return
await
request
.
download
({
url
:
`/iot/product/export-excel`
,
params
})
},
// 更新产品状态
updateProductStatus
:
async
(
id
:
number
,
status
:
number
)
=>
{
return
await
request
.
put
({
url
:
`/iot/product/update-status?id=`
+
id
+
`&status=`
+
status
})
}
}
}
}
\ No newline at end of file
src/views/iot/product/ProductForm.vue
View file @
85c0da5a
...
@@ -103,16 +103,15 @@
...
@@ -103,16 +103,15 @@
import
{
ProductApi
,
ProductVO
}
from
'@/api/iot/product'
import
{
ProductApi
,
ProductVO
}
from
'@/api/iot/product'
import
{
DICT_TYPE
,
getIntDictOptions
}
from
'@/utils/dict'
import
{
DICT_TYPE
,
getIntDictOptions
}
from
'@/utils/dict'
/** iot 产品 表单 */
defineOptions
({
name
:
'ProductForm'
})
defineOptions
({
name
:
'ProductForm'
})
const
{
t
}
=
useI18n
()
// 国际化
const
{
t
}
=
useI18n
()
const
message
=
useMessage
()
// 消息弹窗
const
message
=
useMessage
()
const
dialogVisible
=
ref
(
false
)
// 弹窗的是否展示
const
dialogVisible
=
ref
(
false
)
const
dialogTitle
=
ref
(
''
)
// 弹窗的标题
const
dialogTitle
=
ref
(
''
)
const
formLoading
=
ref
(
false
)
// 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
const
formLoading
=
ref
(
false
)
const
formType
=
ref
(
''
)
// 表单的类型:create - 新增;update - 修改
const
formType
=
ref
(
''
)
const
formData
=
ref
({
const
formData
=
ref
({
name
:
undefined
,
name
:
undefined
,
id
:
undefined
,
id
:
undefined
,
...
@@ -161,15 +160,13 @@ const formRules = reactive({
...
@@ -161,15 +160,13 @@ const formRules = reactive({
}
}
]
]
})
})
const
formRef
=
ref
()
// 表单 Ref
const
formRef
=
ref
()
/** 打开弹窗 */
const
open
=
async
(
type
:
string
,
id
?:
number
)
=>
{
const
open
=
async
(
type
:
string
,
id
?:
number
)
=>
{
dialogVisible
.
value
=
true
dialogVisible
.
value
=
true
dialogTitle
.
value
=
t
(
'action.'
+
type
)
dialogTitle
.
value
=
t
(
'action.'
+
type
)
formType
.
value
=
type
formType
.
value
=
type
resetForm
()
resetForm
()
// 修改时,设置数据
if
(
id
)
{
if
(
id
)
{
formLoading
.
value
=
true
formLoading
.
value
=
true
try
{
try
{
...
@@ -179,14 +176,11 @@ const open = async (type: string, id?: number) => {
...
@@ -179,14 +176,11 @@ const open = async (type: string, id?: number) => {
}
}
}
}
}
}
defineExpose
({
open
})
// 提供 open 方法,用于打开弹窗
defineExpose
({
open
,
close
:
()
=>
(
dialogVisible
.
value
=
false
)
})
/** 提交表单 */
const
emit
=
defineEmits
([
'success'
])
const
emit
=
defineEmits
([
'success'
])
// 定义 success 事件,用于操作成功后的回调
const
submitForm
=
async
()
=>
{
const
submitForm
=
async
()
=>
{
// 校验表单
await
formRef
.
value
.
validate
()
await
formRef
.
value
.
validate
()
// 提交请求
formLoading
.
value
=
true
formLoading
.
value
=
true
try
{
try
{
const
data
=
formData
.
value
as
unknown
as
ProductVO
const
data
=
formData
.
value
as
unknown
as
ProductVO
...
@@ -197,15 +191,13 @@ const submitForm = async () => {
...
@@ -197,15 +191,13 @@ const submitForm = async () => {
await
ProductApi
.
updateProduct
(
data
)
await
ProductApi
.
updateProduct
(
data
)
message
.
success
(
t
(
'common.updateSuccess'
))
message
.
success
(
t
(
'common.updateSuccess'
))
}
}
dialogVisible
.
value
=
false
dialogVisible
.
value
=
false
// 确保关闭弹框
// 发送操作成功的事件
emit
(
'success'
)
emit
(
'success'
)
}
finally
{
}
finally
{
formLoading
.
value
=
false
formLoading
.
value
=
false
}
}
}
}
/** 重置表单 */
const
resetForm
=
()
=>
{
const
resetForm
=
()
=>
{
formData
.
value
=
{
formData
.
value
=
{
name
:
undefined
,
name
:
undefined
,
...
...
src/views/iot/product/detail/ProductDetailsHeader.vue
View file @
85c0da5a
...
@@ -10,36 +10,89 @@
...
@@ -10,36 +10,89 @@
</div>
</div>
<div>
<div>
<!-- 右上:按钮 -->
<!-- 右上:按钮 -->
<el-button
@
click=
"openForm('update', product.id)"
v-hasPermi=
"['iot:product:update']"
>
<el-button
@
click=
"openForm('update', product.id)"
v-hasPermi=
"['iot:product:update']"
v-if=
"product.status === 0"
>
编辑
编辑
</el-button>
</el-button>
<el-button
type=
"primary"
@
click=
"confirmPublish(product.id)"
v-hasPermi=
"['iot:product:update']"
v-if=
"product.status === 0"
>
发布
</el-button>
<el-button
type=
"danger"
@
click=
"confirmUnpublish(product.id)"
v-hasPermi=
"['iot:product:update']"
v-if=
"product.status === 1"
>
撤销发布
</el-button>
</div>
</div>
</div>
</div>
</div>
</div>
<ContentWrap
class=
"mt-10px"
>
<ContentWrap
class=
"mt-10px"
>
<el-descriptions
:column=
"5"
direction=
"vertical"
>
<el-descriptions
:column=
"5"
direction=
"horizontal"
>
<el-descriptions-item
label=
"产品名称"
>
{{
product
.
name
}}
</el-descriptions-item>
<el-descriptions-item
label=
"ProductKey"
>
<el-descriptions-item
label=
"产品标识"
>
{{
product
.
identification
}}
</el-descriptions-item>
{{
product
.
productKey
}}
<el-descriptions-item
label=
"设备类型"
>
<el-button
@
click=
"copyToClipboard(product.productKey)"
>
复制
</el-button>
<dict-tag
:type=
"DICT_TYPE.IOT_PRODUCT_DEVICE_TYPE"
:value=
"product.deviceType"
/>
</el-descriptions-item>
</el-descriptions-item>
<el-descriptions-item
label=
"产品状态"
>
</el-descriptions>
<dict-tag
:type=
"DICT_TYPE.IOT_PRODUCT_STATUS"
:value=
"product.status"
/>
<el-descriptions
:column=
"5"
direction=
"horizontal"
>
<el-descriptions-item
label=
"设备数"
>
0
<el-button
@
click=
"goToManagement(product.productKey)"
>
前往管理
</el-button>
</el-descriptions-item>
</el-descriptions-item>
</el-descriptions>
</el-descriptions>
</ContentWrap>
</ContentWrap>
<!-- 表单弹窗:添加/修改 -->
<!-- 表单弹窗:添加/修改 -->
<ProductForm
ref=
"formRef"
@
success=
"
openForm('update', product.id
)"
/>
<ProductForm
ref=
"formRef"
@
success=
"
emit('refresh'
)"
/>
</
template
>
</
template
>
<
script
setup
lang=
"ts"
>
<
script
setup
lang=
"ts"
>
import
ProductForm
from
'@/views/iot/product/ProductForm.vue'
import
ProductForm
from
'@/views/iot/product/ProductForm.vue'
import
{
DICT_TYPE
}
from
'@/utils/dict'
import
{
ProductApi
,
ProductVO
}
from
'@/api/iot/product'
import
{
ProductVO
}
from
'@/api/iot/product'
const
message
=
useMessage
()
const
copyToClipboard
=
(
text
:
string
)
=>
{
navigator
.
clipboard
.
writeText
(
text
).
then
(()
=>
{
message
.
success
(
'复制成功'
)
})
}
const
goToManagement
=
(
productKey
:
string
)
=>
{
message
.
warning
(
'暂未开放'
)
}
// 操作修改
// 操作修改
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
confirmPublish
=
async
(
id
:
number
)
=>
{
try
{
await
ProductApi
.
updateProductStatus
(
id
,
1
)
message
.
success
(
'发布成功'
)
formRef
.
value
.
close
()
// 关闭弹框
emit
(
'refresh'
)
}
catch
(
error
)
{
message
.
error
(
'发布失败'
)
}
}
const
confirmUnpublish
=
async
(
id
:
number
)
=>
{
try
{
await
ProductApi
.
updateProductStatus
(
id
,
0
)
message
.
success
(
'撤销发布成功'
)
formRef
.
value
.
close
()
// 关闭弹框
emit
(
'refresh'
)
}
catch
(
error
)
{
message
.
error
(
'撤销发布失败'
)
}
}
const
{
product
}
=
defineProps
<
{
product
:
ProductVO
}
>
()
const
{
product
}
=
defineProps
<
{
product
:
ProductVO
}
>
()
const
emit
=
defineEmits
([
'refresh'
])
</
script
>
</
script
>
src/views/iot/product/detail/ProductDetailsInfo.vue
View file @
85c0da5a
<
template
>
<
template
>
<ContentWrap>
<ContentWrap>
<el-collapse
v-model=
"activeNames"
>
<el-collapse
v-model=
"activeNames"
>
<el-collapse-item
name=
"basicInfo"
>
<el-descriptions
:column=
"3"
title=
"产品信息"
>
<template
#
title
>
<el-descriptions-item
label=
"产品名称"
>
{{
product
.
name
}}
</el-descriptions-item>
<span
class=
"text-base font-bold"
>
基本信息
</span>
<el-descriptions-item
label=
"设备类型"
>
</
template
>
<dict-tag
:type=
"DICT_TYPE.IOT_PRODUCT_DEVICE_TYPE"
:value=
"product.deviceType"
/>
<el-descriptions
:column=
"4"
>
</el-descriptions-item>
<el-descriptions-item
label=
"产品名称"
>
{{ product.name }}
</el-descriptions-item>
<el-descriptions-item
label=
"创建时间"
>
{{
<el-descriptions-item
label=
"产品标识"
>
{{ product.identification }}
</el-descriptions-item>
formatDate
(
product
.
createTime
)
<el-descriptions-item
label=
"设备类型"
>
}}
</el-descriptions-item>
<dict-tag
:type=
"DICT_TYPE.IOT_PRODUCT_DEVICE_TYPE"
:value=
"product.deviceType"
/>
<el-descriptions-item
label=
"数据格式"
>
</el-descriptions-item>
<dict-tag
:type=
"DICT_TYPE.IOT_DATA_FORMAT"
:value=
"product.dataFormat"
/>
<el-descriptions-item
label=
"数据格式"
>
</el-descriptions-item>
<dict-tag
:type=
"DICT_TYPE.IOT_PRODUCT_DATA_FORMAT"
:value=
"product.dataFormat"
/>
<el-descriptions-item
label=
"数据校验级别"
>
</el-descriptions-item>
<dict-tag
:type=
"DICT_TYPE.IOT_VALIDATE_TYPE"
:value=
"product.validateType"
/>
<el-descriptions-item
label=
"协议类型"
>
</el-descriptions-item>
<dict-tag
:type=
"DICT_TYPE.IOT_PRODUCT_PROTOCOL_TYPE"
:value=
"product.protocolType"
/>
<el-descriptions-item
label=
"产品状态"
>
</el-descriptions-item>
<dict-tag
:type=
"DICT_TYPE.IOT_PRODUCT_STATUS"
:value=
"product.status"
/>
<el-descriptions-item
label=
"产品状态"
>
</el-descriptions-item>
<dict-tag
:type=
"DICT_TYPE.IOT_PRODUCT_STATUS"
:value=
"product.status"
/>
<el-descriptions-item
</el-descriptions-item>
label=
"联网方式"
<el-descriptions-item
label=
"产品描述"
>
{{ product.description }}
</el-descriptions-item>
v-if=
"product.deviceType === 0 || product.deviceType === 2"
</el-descriptions>
>
</el-collapse-item>
<dict-tag
:type=
"DICT_TYPE.IOT_NET_TYPE"
:value=
"product.netType"
/>
</el-descriptions-item>
<el-descriptions-item
label=
"接入网关协议"
v-if=
"product.deviceType === 1"
>
<dict-tag
:type=
"DICT_TYPE.IOT_PROTOCOL_TYPE"
:value=
"product.protocolType"
/>
</el-descriptions-item>
<el-descriptions-item
label=
"产品描述"
>
{{
product
.
description
}}
</el-descriptions-item>
</el-descriptions>
</el-collapse>
</el-collapse>
</ContentWrap>
</ContentWrap>
</
template
>
</
template
>
<
script
setup
lang=
"ts"
>
<
script
setup
lang=
"ts"
>
import
{
DICT_TYPE
}
from
'@/utils/dict'
import
{
DICT_TYPE
}
from
'@/utils/dict'
import
{
ProductVO
}
from
'@/api/iot/product'
import
{
ProductVO
}
from
'@/api/iot/product'
import
{
formatDate
}
from
'@/utils/formatTime'
const
{
product
}
=
defineProps
<
{
product
:
ProductVO
}
>
()
const
{
product
}
=
defineProps
<
{
product
:
ProductVO
}
>
()
...
...
src/views/iot/product/detail/index.vue
View file @
85c0da5a
...
@@ -2,12 +2,15 @@
...
@@ -2,12 +2,15 @@
<ProductDetailsHeader
:loading=
"loading"
:product=
"product"
@
refresh=
"getProductData(id)"
/>
<ProductDetailsHeader
:loading=
"loading"
:product=
"product"
@
refresh=
"getProductData(id)"
/>
<el-col>
<el-col>
<el-tabs>
<el-tabs>
<el-tab-pane
label=
"
详细资料
"
>
<el-tab-pane
label=
"
产品信息
"
>
<ProductDetailsInfo
:product=
"product"
/>
<ProductDetailsInfo
:product=
"product"
/>
</el-tab-pane>
</el-tab-pane>
<el-tab-pane
label=
"Topic 类列表"
/>
<el-tab-pane
label=
"物模型"
>
<el-tab-pane
label=
"物模型"
>
<!--
<ProductDetailsModel
:product=
"product"
/>
-->
<!--
<ProductDetailsModel
:product=
"product"
/>
-->
</el-tab-pane>
</el-tab-pane>
<el-tab-pane
label=
"消息解析"
/>
<el-tab-pane
label=
"服务端订阅"
/>
</el-tabs>
</el-tabs>
</el-col>
</el-col>
</
template
>
</
template
>
...
@@ -30,6 +33,7 @@ const getProductData = async (id: number) => {
...
@@ -30,6 +33,7 @@ const getProductData = async (id: number) => {
loading
.
value
=
true
loading
.
value
=
true
try
{
try
{
product
.
value
=
await
ProductApi
.
getProduct
(
id
)
product
.
value
=
await
ProductApi
.
getProduct
(
id
)
console
.
log
(
product
.
value
)
}
finally
{
}
finally
{
loading
.
value
=
false
loading
.
value
=
false
}
}
...
...
src/views/iot/product/index.vue
View file @
85c0da5a
...
@@ -37,15 +37,6 @@
...
@@ -37,15 +37,6 @@
>
>
<Icon
icon=
"ep:plus"
class=
"mr-5px"
/>
新增
<Icon
icon=
"ep:plus"
class=
"mr-5px"
/>
新增
</el-button>
</el-button>
<el-button
type=
"success"
plain
@
click=
"handleExport"
:loading=
"exportLoading"
v-hasPermi=
"['iot:product:export']"
>
<Icon
icon=
"ep:download"
class=
"mr-5px"
/>
导出
</el-button>
</el-form-item>
</el-form-item>
</el-form>
</el-form>
</ContentWrap>
</ContentWrap>
...
@@ -57,7 +48,7 @@
...
@@ -57,7 +48,7 @@
<el-table-column
label=
"ProductKey"
align=
"center"
prop=
"productKey"
/>
<el-table-column
label=
"ProductKey"
align=
"center"
prop=
"productKey"
/>
<el-table-column
label=
"设备类型"
align=
"center"
prop=
"deviceType"
>
<el-table-column
label=
"设备类型"
align=
"center"
prop=
"deviceType"
>
<template
#
default=
"scope"
>
<template
#
default=
"scope"
>
<dict-tag
:type=
"DICT_TYPE.IOT_PRODUCT_DEVICE_TYPE"
:
cod
e=
"scope.row.deviceType"
/>
<dict-tag
:type=
"DICT_TYPE.IOT_PRODUCT_DEVICE_TYPE"
:
valu
e=
"scope.row.deviceType"
/>
</
template
>
</
template
>
</el-table-column>
</el-table-column>
<el-table-column
<el-table-column
...
@@ -69,7 +60,7 @@
...
@@ -69,7 +60,7 @@
/>
/>
<el-table-column
label=
"产品状态"
align=
"center"
prop=
"status"
>
<el-table-column
label=
"产品状态"
align=
"center"
prop=
"status"
>
<
template
#
default=
"scope"
>
<
template
#
default=
"scope"
>
<dict-tag
:type=
"DICT_TYPE.IOT_PRODUCT_STATUS"
:
cod
e=
"scope.row.status"
/>
<dict-tag
:type=
"DICT_TYPE.IOT_PRODUCT_STATUS"
:
valu
e=
"scope.row.status"
/>
</
template
>
</
template
>
</el-table-column>
</el-table-column>
<el-table-column
label=
"操作"
align=
"center"
>
<el-table-column
label=
"操作"
align=
"center"
>
...
@@ -77,16 +68,17 @@
...
@@ -77,16 +68,17 @@
<el-button
<el-button
link
link
type=
"primary"
type=
"primary"
@
click=
"open
Form('update',
scope.row.id)"
@
click=
"open
Detail(
scope.row.id)"
v-hasPermi=
"['iot:product:
update
']"
v-hasPermi=
"['iot:product:
query
']"
>
>
编辑
查看
</el-button>
</el-button>
<el-button
<el-button
link
link
type=
"danger"
type=
"danger"
@
click=
"handleDelete(scope.row.id)"
@
click=
"handleDelete(scope.row.id)"
v-hasPermi=
"['iot:product:delete']"
v-hasPermi=
"['iot:product:delete']"
:disabled=
"scope.row.status === 1"
>
>
删除
删除
</el-button>
</el-button>
...
@@ -171,6 +163,12 @@ const openForm = (type: string, id?: number) => {
...
@@ -171,6 +163,12 @@ const openForm = (type: string, id?: number) => {
formRef
.
value
.
open
(
type
,
id
)
formRef
.
value
.
open
(
type
,
id
)
}
}
/** 打开详情 */
const
{
currentRoute
,
push
}
=
useRouter
()
const
openDetail
=
(
id
:
number
)
=>
{
push
({
name
:
'IotProductDetail'
,
params
:
{
id
}
})
}
/** 删除按钮操作 */
/** 删除按钮操作 */
const
handleDelete
=
async
(
id
:
number
)
=>
{
const
handleDelete
=
async
(
id
:
number
)
=>
{
try
{
try
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment