|
@@ -8,10 +8,23 @@
|
|
|
<template v-if="state.tasActive == 'msg'" >
|
|
<template v-if="state.tasActive == 'msg'" >
|
|
|
<a-alert :message="tipMessage" type="info" show-icon />
|
|
<a-alert :message="tipMessage" type="info" show-icon />
|
|
|
<div class="subtitle" >注意:平台为每个设备默认最多保存20条消息,超过20条后,后续的消息会替换下发最早的消息。</div>
|
|
<div class="subtitle" >注意:平台为每个设备默认最多保存20条消息,超过20条后,后续的消息会替换下发最早的消息。</div>
|
|
|
- <a-row>
|
|
|
|
|
|
|
+ <a-row justify="space-between" >
|
|
|
|
|
+ <a-col></a-col>
|
|
|
<a-col> <a-button type="primary" @click="state.visible = true">下发消息</a-button> </a-col>
|
|
<a-col> <a-button type="primary" @click="state.visible = true">下发消息</a-button> </a-col>
|
|
|
</a-row>
|
|
</a-row>
|
|
|
- <a-table
|
|
|
|
|
|
|
+ </template>
|
|
|
|
|
+ <template v-else >
|
|
|
|
|
+ <a-alert :message="tipMessage" type="info" show-icon style="margin-bottom: 20px;" />
|
|
|
|
|
+ <a-row justify="space-between" >
|
|
|
|
|
+ <a-col class="msg-title" >
|
|
|
|
|
+ <div class="title" >同步命令下发</div>
|
|
|
|
|
+ <div class="subtitle" >同步命令暂不支持历史记录查看。</div>
|
|
|
|
|
+ </a-col>
|
|
|
|
|
+ <a-col> <a-button type="primary" @click="state.visible = true">命令下发</a-button> </a-col>
|
|
|
|
|
+ </a-row>
|
|
|
|
|
+ </template>
|
|
|
|
|
+
|
|
|
|
|
+ <a-table
|
|
|
style="margin-top: 20px;"
|
|
style="margin-top: 20px;"
|
|
|
:columns="columns"
|
|
:columns="columns"
|
|
|
:dataSource="state.msgDataSource"
|
|
:dataSource="state.msgDataSource"
|
|
@@ -26,19 +39,18 @@
|
|
|
</template>
|
|
</template>
|
|
|
</template>
|
|
</template>
|
|
|
</a-table>
|
|
</a-table>
|
|
|
- </template>
|
|
|
|
|
- <template v-if="state.tasActive == 'cmd'" >
|
|
|
|
|
|
|
|
|
|
- </template>
|
|
|
|
|
</a-card>
|
|
</a-card>
|
|
|
|
|
|
|
|
<modal-pro
|
|
<modal-pro
|
|
|
|
|
+ style="width: 700px;"
|
|
|
:title="modalTitle"
|
|
:title="modalTitle"
|
|
|
:visible="state.visible"
|
|
:visible="state.visible"
|
|
|
@cancel="state.visible = false"
|
|
@cancel="state.visible = false"
|
|
|
@ok="ok"
|
|
@ok="ok"
|
|
|
>
|
|
>
|
|
|
<a-form
|
|
<a-form
|
|
|
|
|
+ v-if="state.tasActive === 'msg'"
|
|
|
:labelCol="{span: 4}"
|
|
:labelCol="{span: 4}"
|
|
|
:wrapperCol="{span: 14}"
|
|
:wrapperCol="{span: 14}"
|
|
|
>
|
|
>
|
|
@@ -60,6 +72,23 @@
|
|
|
<a-textarea v-model:value="msgState.msgPayload" > </a-textarea>
|
|
<a-textarea v-model:value="msgState.msgPayload" > </a-textarea>
|
|
|
</a-form-item>
|
|
</a-form-item>
|
|
|
</a-form>
|
|
</a-form>
|
|
|
|
|
+ <template v-else >
|
|
|
|
|
+ <a-alert message="同步命令成功下发后,设备需要在20秒内向平台回复响应,否则会认为命令请求超时。" type="info" show-icon style="margin-bottom: 20px;" />
|
|
|
|
|
+ <a-form
|
|
|
|
|
+ :labelCol="{span: 4}"
|
|
|
|
|
+ :wrapperCol="{span: 14}"
|
|
|
|
|
+ >
|
|
|
|
|
+ <a-form-item
|
|
|
|
|
+ label="选择命令"
|
|
|
|
|
+ v-bind="validateInfos.msgLabel"
|
|
|
|
|
+ >
|
|
|
|
|
+ <a-input v-model:value="msgState.msgLabel" > </a-input>
|
|
|
|
|
+ </a-form-item>
|
|
|
|
|
+ <a-form-item label="设置命令参数" >
|
|
|
|
|
+ 产品尚未配置命令,请先去 <a @click="pushProductDetail" >产品详情</a> 定义命令。
|
|
|
|
|
+ </a-form-item>
|
|
|
|
|
+ </a-form>
|
|
|
|
|
+ </template>
|
|
|
</modal-pro>
|
|
</modal-pro>
|
|
|
|
|
|
|
|
<modal-pro
|
|
<modal-pro
|
|
@@ -82,6 +111,7 @@
|
|
|
</a-descriptions-item>
|
|
</a-descriptions-item>
|
|
|
</a-descriptions>
|
|
</a-descriptions>
|
|
|
</modal-pro>
|
|
</modal-pro>
|
|
|
|
|
+
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup >
|
|
<script lang="ts" setup >
|
|
@@ -141,19 +171,19 @@ const tipMessage = computed(() => state.tasActive === 'msg' ? msg : cmdMsg)
|
|
|
|
|
|
|
|
const state = reactive<{
|
|
const state = reactive<{
|
|
|
tasActive: 'msg' | 'cmd',
|
|
tasActive: 'msg' | 'cmd',
|
|
|
- msgDataSource: IOT.API.DEVICE.Msg[],
|
|
|
|
|
|
|
+ msgDataSource: (IOT.API.DEVICE.Msg | IOT.API.DEVICE.Cmd)[],
|
|
|
visible: boolean,
|
|
visible: boolean,
|
|
|
loading: boolean,
|
|
loading: boolean,
|
|
|
detailVisible: boolean,
|
|
detailVisible: boolean,
|
|
|
msgDetail: Partial<IOT.API.DEVICE.Msg >
|
|
msgDetail: Partial<IOT.API.DEVICE.Msg >
|
|
|
-}>({
|
|
|
|
|
- tasActive: 'msg',
|
|
|
|
|
- msgDataSource: [],
|
|
|
|
|
- visible: false,
|
|
|
|
|
- loading: false,
|
|
|
|
|
- detailVisible: false,
|
|
|
|
|
- msgDetail: {}
|
|
|
|
|
-})
|
|
|
|
|
|
|
+ }>({
|
|
|
|
|
+ tasActive: 'msg',
|
|
|
|
|
+ msgDataSource: [],
|
|
|
|
|
+ visible: false,
|
|
|
|
|
+ loading: false,
|
|
|
|
|
+ detailVisible: false,
|
|
|
|
|
+ msgDetail: {}
|
|
|
|
|
+ })
|
|
|
|
|
|
|
|
const msgState = reactive({
|
|
const msgState = reactive({
|
|
|
deviceId: deviceId,
|
|
deviceId: deviceId,
|
|
@@ -162,17 +192,38 @@ const msgState = reactive({
|
|
|
topic: ''
|
|
topic: ''
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+const cmdState = reactive({
|
|
|
|
|
+ deviceId: deviceId,
|
|
|
|
|
+ cmdLabel: '',
|
|
|
|
|
+ cmdParameters: {}
|
|
|
|
|
+})
|
|
|
|
|
+
|
|
|
const { resetFields, validate, validateInfos } = useForm(msgState, reactive({
|
|
const { resetFields, validate, validateInfos } = useForm(msgState, reactive({
|
|
|
msgPayload: [{ required: true, message: '请填写消息内容' }],
|
|
msgPayload: [{ required: true, message: '请填写消息内容' }],
|
|
|
msgLabel: [{ required: true, message: '请填写消息标题' }]
|
|
msgLabel: [{ required: true, message: '请填写消息标题' }]
|
|
|
}))
|
|
}))
|
|
|
|
|
|
|
|
|
|
+const { resetFields: resetFieldsCmd, validate: validateCmd, validateInfos: validateInfosCmd } = useForm(cmdState, reactive({
|
|
|
|
|
+}))
|
|
|
|
|
+
|
|
|
|
|
+const pushProductDetail = () => {
|
|
|
|
|
+ console.log('pushProductDetail')
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
const ok = () => {
|
|
const ok = () => {
|
|
|
- validate().then(async () => {
|
|
|
|
|
- await DeviceContriller.addDeviceMsg(msgState)
|
|
|
|
|
- state.visible = false
|
|
|
|
|
- getDeviceMsgList()
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ if (state.tasActive === 'msg') {
|
|
|
|
|
+ validate().then(async () => {
|
|
|
|
|
+ await DeviceContriller.addDeviceMsg(msgState)
|
|
|
|
|
+ state.visible = false
|
|
|
|
|
+ getDeviceMsgList()
|
|
|
|
|
+ })
|
|
|
|
|
+ } else {
|
|
|
|
|
+ validateCmd().then(async () => {
|
|
|
|
|
+ await DeviceContriller.addDeviceCmd(cmdState)
|
|
|
|
|
+ state.visible = false
|
|
|
|
|
+ getDeviceMsgList()
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const openDetailModal = (record: IOT.API.DEVICE.Msg) => {
|
|
const openDetailModal = (record: IOT.API.DEVICE.Msg) => {
|
|
@@ -182,11 +233,14 @@ const openDetailModal = (record: IOT.API.DEVICE.Msg) => {
|
|
|
|
|
|
|
|
const getDeviceMsgList = async () => {
|
|
const getDeviceMsgList = async () => {
|
|
|
state.loading = true
|
|
state.loading = true
|
|
|
- state.msgDataSource = await DeviceContriller.listDeviceMsg({ deviceId })
|
|
|
|
|
|
|
+ state.msgDataSource = state.tasActive === 'msg' ? await DeviceContriller.listDeviceMsg({ deviceId }) : await DeviceContriller.listDeviceCmd({ deviceId })
|
|
|
state.loading = false
|
|
state.loading = false
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-const onTabChange = (value: 'msg' | 'cmd') => state.tasActive = value
|
|
|
|
|
|
|
+const onTabChange = (value: 'msg' | 'cmd') => {
|
|
|
|
|
+ state.tasActive = value
|
|
|
|
|
+ getDeviceMsgList()
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
|
getDeviceMsgList()
|
|
getDeviceMsgList()
|
|
@@ -199,4 +253,14 @@ onMounted(() => {
|
|
|
color: @sublabel-color;
|
|
color: @sublabel-color;
|
|
|
margin: 20px 0px;
|
|
margin: 20px 0px;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+.msg-title {
|
|
|
|
|
+ .title {
|
|
|
|
|
+ font-size: 20px;
|
|
|
|
|
+ }
|
|
|
|
|
+ .subtitle {
|
|
|
|
|
+ color: @sublabel-color;
|
|
|
|
|
+ font-size: 14px;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
</style>
|
|
</style>
|