|
|
@@ -1,14 +1,14 @@
|
|
|
<template>
|
|
|
<a-card>
|
|
|
- <a-row align="middle" style="width: 100%;height: 68px" class="title">
|
|
|
+ <a-row align="middle" justify="space-between" style="width: 100%;height: 68px" class="title">
|
|
|
<a-col>
|
|
|
<a-space>
|
|
|
<span>设备名称:{{state.otaDetail.otaPkgLabel}}</span>
|
|
|
<span>设备版本:{{state.otaDetail.otaPkgVersion}}</span>
|
|
|
</a-space>
|
|
|
</a-col>
|
|
|
- <a-col>
|
|
|
- <a-button type="primary" >下发OTA程序包</a-button>
|
|
|
+ <a-col :span="2" >
|
|
|
+ <a-button type="primary" @click="openModal" >下发OTA程序包</a-button>
|
|
|
</a-col>
|
|
|
</a-row>
|
|
|
<a-table
|
|
|
@@ -28,12 +28,36 @@
|
|
|
</template>
|
|
|
</a-table>
|
|
|
</a-card>
|
|
|
+
|
|
|
+ <modal-pro
|
|
|
+ label="下发OTA程序包"
|
|
|
+ :open="state.visible"
|
|
|
+ @cancel="state.visible = false"
|
|
|
+ @ok="ok"
|
|
|
+ >
|
|
|
+ <a-form :labelCol="{span: 6}" :wrapperCol="{span: 14}" >
|
|
|
+ <a-form-item label="所属产品" v-bind="validateInfos.deviceId" >
|
|
|
+ <!-- 这个写法丑陋的一批 -->
|
|
|
+ <select-tsx
|
|
|
+ v-model:value="otaState.deviceId"
|
|
|
+ :request="async () => {
|
|
|
+ const { data } = await DeviceContriller.list()
|
|
|
+ return data.map(item => ({name: item.deviceLabel, value: item.id, key: item.id}))
|
|
|
+ }"
|
|
|
+ />
|
|
|
+ </a-form-item>
|
|
|
+ <a-form-item label="所属产品" v-bind="validateInfos.otaPkgId" >
|
|
|
+ </a-form-item>
|
|
|
+ </a-form>
|
|
|
+ </modal-pro>
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts" >
|
|
|
import { DeviceContriller } from '@/controller'
|
|
|
import { onMounted, reactive } from 'vue'
|
|
|
import { useRoute } from 'vue-router'
|
|
|
+import { Form } from 'ant-design-vue'
|
|
|
+import { SelectTsx } from '@/components/MicroComponents/index'
|
|
|
|
|
|
const route = useRoute()
|
|
|
|
|
|
@@ -64,21 +88,47 @@ const queryState = reactive<IOT.API.DEVICE.OtaQueryParams & {total: number}>({
|
|
|
pageSize: 10,
|
|
|
deviceId: deviceId,
|
|
|
otaLabel: '',
|
|
|
- otaStatus: 'DELIVERED',
|
|
|
+ otaStatus: '',
|
|
|
otaVersion: '',
|
|
|
total: 0
|
|
|
})
|
|
|
|
|
|
const state = reactive<{
|
|
|
loading: boolean,
|
|
|
+ visible: boolean
|
|
|
dataSource: IOT.API.DEVICE.Ota[]
|
|
|
otaDetail: Partial<IOT.API.DEVICE.Ota>
|
|
|
}>({
|
|
|
loading: false,
|
|
|
+ visible: false,
|
|
|
dataSource: [],
|
|
|
otaDetail: {}
|
|
|
})
|
|
|
|
|
|
+const otaState = reactive({
|
|
|
+ deviceId: '',
|
|
|
+ otaPkgId: ''
|
|
|
+})
|
|
|
+
|
|
|
+const useForm = Form.useForm
|
|
|
+
|
|
|
+const { resetFields, validate, validateInfos } = useForm(otaState, {
|
|
|
+ deviceId: [{ required: true, message: '请选择设备' }],
|
|
|
+ otaPkgId: [{ required: true, message: '请选择OTA程序包' }]
|
|
|
+})
|
|
|
+
|
|
|
+const openModal = () => {
|
|
|
+ state.visible = true
|
|
|
+}
|
|
|
+
|
|
|
+const ok = () => {
|
|
|
+ validate().then(async () => {
|
|
|
+ await DeviceContriller.upgradationOtaByDeviceId(otaState)
|
|
|
+ state.visible = false
|
|
|
+ getOtaPkgByDeviceId()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
const changePage = ({ current }) => {
|
|
|
queryState.page = current
|
|
|
getOtaPkgPageByDeviceId()
|