From a1d7e81859f554f3a53680cc35f0f49bf1f77098 Mon Sep 17 00:00:00 2001
From: wwf <1971391498@qq.com>
Date: 星期四, 14 五月 2026 14:37:02 +0800
Subject: [PATCH] 导入项目

---
 src/views/iot/ota/task/OtaTaskList.vue |  187 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 187 insertions(+), 0 deletions(-)

diff --git a/src/views/iot/ota/task/OtaTaskList.vue b/src/views/iot/ota/task/OtaTaskList.vue
new file mode 100644
index 0000000..f6c3a6b
--- /dev/null
+++ b/src/views/iot/ota/task/OtaTaskList.vue
@@ -0,0 +1,187 @@
+<template>
+  <ContentWrap title="鍗囩骇浠诲姟绠$悊" class="mb-20px">
+    <!-- 鎼滅储鏍� -->
+    <el-form
+      class="-mb-15px"
+      :model="queryParams"
+      ref="queryFormRef"
+      :inline="true"
+      label-width="68px"
+      @submit.prevent
+    >
+      <el-form-item>
+        <el-button type="primary" @click="openTaskForm" v-hasPermi="['iot:ota-task:create']">
+          <Icon icon="ep:plus" class="mr-5px" /> 鏂板
+        </el-button>
+      </el-form-item>
+      <el-form-item class="float-right">
+        <el-input
+          v-model="queryParams.name"
+          placeholder="璇疯緭鍏ヤ换鍔″悕绉�"
+          clearable
+          @keyup.enter="handleQuery"
+          class="!w-240px"
+        />
+      </el-form-item>
+    </el-form>
+
+    <!-- 浠诲姟鍒楄〃 -->
+    <el-table
+      v-loading="taskLoading"
+      :data="taskList"
+      :stripe="true"
+      :show-overflow-tooltip="true"
+      class="mt-15px"
+    >
+      <el-table-column label="浠诲姟缂栧彿" align="center" prop="id" width="80" />
+      <el-table-column label="浠诲姟鍚嶇О" align="center" prop="name" />
+      <el-table-column label="鍗囩骇鑼冨洿" align="center" prop="deviceScope">
+        <template #default="scope">
+          <dict-tag :type="DICT_TYPE.IOT_OTA_TASK_DEVICE_SCOPE" :value="scope.row.deviceScope" />
+        </template>
+      </el-table-column>
+      <el-table-column label="鍗囩骇杩涘害" align="center">
+        <template #default="scope">
+          {{ scope.row.deviceSuccessCount }}/{{ scope.row.deviceTotalCount }}
+        </template>
+      </el-table-column>
+      <el-table-column
+        label="鍒涘缓鏃堕棿"
+        align="center"
+        prop="createTime"
+        :formatter="dateFormatter"
+      />
+      <el-table-column label="浠诲姟鎻忚堪" align="center" prop="description" show-overflow-tooltip />
+      <el-table-column label="浠诲姟鐘舵��" align="center" prop="status">
+        <template #default="scope">
+          <dict-tag :type="DICT_TYPE.IOT_OTA_TASK_STATUS" :value="scope.row.status" />
+        </template>
+      </el-table-column>
+      <el-table-column label="鎿嶄綔" align="center" width="120">
+        <template #default="scope">
+          <el-button link type="primary" @click="handleTaskDetail(scope.row.id)"> 璇︽儏 </el-button>
+          <el-button
+            v-if="scope.row.status === IoTOtaTaskStatusEnum.IN_PROGRESS.value"
+            link
+            type="danger"
+            @click="handleCancelTask(scope.row.id)"
+            v-hasPermi="['iot:ota-task:cancel']"
+          >
+            鍙栨秷
+          </el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+
+    <!-- 鍒嗛〉 -->
+    <Pagination
+      :total="taskTotal"
+      v-model:page="queryParams.pageNo"
+      v-model:limit="queryParams.pageSize"
+      @pagination="getTaskList"
+    />
+
+    <!-- 鏂板浠诲姟寮圭獥 -->
+    <OtaTaskForm
+      ref="taskFormRef"
+      :firmware-id="firmwareId"
+      :product-id="productId"
+      @success="handleTaskCreateSuccess"
+    />
+
+    <!-- 浠诲姟璇︽儏寮圭獥 -->
+    <OtaTaskDetail ref="taskDetailRef" @success="refresh" />
+  </ContentWrap>
+</template>
+
+<script setup lang="ts">
+import { dateFormatter } from '@/utils/formatTime'
+import { IoTOtaTaskApi, OtaTask } from '@/api/iot/ota/task'
+import { DICT_TYPE } from '@/utils/dict'
+import { IoTOtaTaskStatusEnum } from '@/views/iot/utils/constants'
+import OtaTaskForm from './OtaTaskForm.vue'
+import OtaTaskDetail from './OtaTaskDetail.vue'
+
+/** IoT OTA 浠诲姟鍒楄〃 */
+defineOptions({ name: 'OtaTaskList' })
+
+const props = defineProps<{
+  firmwareId: number
+  productId: number
+}>()
+
+const message = useMessage() // 娑堟伅寮圭獥
+
+// 浠诲姟鍒楄〃
+const taskLoading = ref(false)
+const taskList = ref<OtaTask[]>([])
+const taskTotal = ref(0)
+const queryParams = reactive({
+  pageNo: 1,
+  pageSize: 10,
+  name: '',
+  firmwareId: props.firmwareId
+})
+const queryFormRef = ref() // 鏌ヨ琛ㄥ崟寮曠敤
+const taskFormRef = ref() // 浠诲姟琛ㄥ崟寮曠敤
+const taskDetailRef = ref() // 浠诲姟璇︽儏寮曠敤
+
+/** 鑾峰彇浠诲姟鍒楄〃 */
+const getTaskList = async () => {
+  taskLoading.value = true
+  try {
+    const data = await IoTOtaTaskApi.getOtaTaskPage(queryParams)
+    taskList.value = data.list
+    taskTotal.value = data.total
+  } finally {
+    taskLoading.value = false
+  }
+}
+
+/** 鎼滅储 */
+const handleQuery = () => {
+  queryParams.pageNo = 1
+  getTaskList()
+}
+
+/** 鎵撳紑浠诲姟琛ㄥ崟 */
+const openTaskForm = () => {
+  taskFormRef.value?.open()
+}
+
+/** 澶勭悊浠诲姟鍒涘缓鎴愬姛 */
+const emit = defineEmits(['success']) // 瀹氫箟 success 浜嬩欢锛岀敤浜庢搷浣滄垚鍔熷悗鐨勫洖璋�
+const handleTaskCreateSuccess = () => {
+  getTaskList()
+  emit('success')
+}
+
+/** 鏌ョ湅浠诲姟璇︽儏 */
+const handleTaskDetail = (id: number) => {
+  taskDetailRef.value?.open(id)
+}
+
+/** 鍙栨秷浠诲姟 */
+const handleCancelTask = async (id: number) => {
+  try {
+    await message.confirm('纭瑕佸彇娑堣鍗囩骇浠诲姟鍚楋紵')
+    await IoTOtaTaskApi.cancelOtaTask(id)
+    message.success('鍙栨秷鎴愬姛')
+    // 鍒锋柊鏁版嵁
+    await refresh()
+  } catch (error) {
+    console.error('鍙栨秷浠诲姟澶辫触', error)
+  }
+}
+
+/** 鍒锋柊鏁版嵁 */
+const refresh = async () => {
+  await getTaskList()
+  emit('success')
+}
+
+/** 鍒濆鍖� */
+onMounted(() => {
+  getTaskList()
+})
+</script>

--
Gitblit v1.8.0