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/product/product/index.vue |  355 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 355 insertions(+), 0 deletions(-)

diff --git a/src/views/iot/product/product/index.vue b/src/views/iot/product/product/index.vue
new file mode 100644
index 0000000..ea7c94a
--- /dev/null
+++ b/src/views/iot/product/product/index.vue
@@ -0,0 +1,355 @@
+<template>
+  <ContentWrap>
+    <!-- 鎼滅储宸ヤ綔鏍� -->
+    <el-form
+      ref="queryFormRef"
+      :inline="true"
+      :model="queryParams"
+      class="-mb-15px"
+      label-width="68px"
+    >
+      <el-form-item label="浜у搧鍚嶇О" prop="name">
+        <el-input
+          v-model="queryParams.name"
+          class="!w-240px"
+          clearable
+          placeholder="璇疯緭鍏ヤ骇鍝佸悕绉�"
+          @keyup.enter="handleQuery"
+        />
+      </el-form-item>
+      <el-form-item label="ProductKey" prop="productKey">
+        <el-input
+          v-model="queryParams.productKey"
+          class="!w-240px"
+          clearable
+          placeholder="璇疯緭鍏ヤ骇鍝佹爣璇�"
+          @keyup.enter="handleQuery"
+        />
+      </el-form-item>
+      <el-form-item>
+        <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>
+        <el-button
+          v-hasPermi="['iot:product:create']"
+          plain
+          type="primary"
+          @click="openForm('create')"
+        >
+          <Icon class="mr-5px" icon="ep:plus" />
+          鏂板
+        </el-button>
+        <el-button
+          v-hasPermi="['iot:product:export']"
+          :loading="exportLoading"
+          plain
+          type="success"
+          @click="handleExport"
+        >
+          <Icon class="mr-5px" icon="ep:download" />
+          瀵煎嚭
+        </el-button>
+      </el-form-item>
+      <!-- 瑙嗗浘鍒囨崲鎸夐挳 -->
+      <el-form-item class="float-right !mr-0 !mb-0">
+        <el-button-group>
+          <el-button :type="viewMode === 'card' ? 'primary' : 'default'" @click="viewMode = 'card'">
+            <Icon icon="ep:grid" />
+          </el-button>
+          <el-button :type="viewMode === 'list' ? 'primary' : 'default'" @click="viewMode = 'list'">
+            <Icon icon="ep:list" />
+          </el-button>
+        </el-button-group>
+      </el-form-item>
+    </el-form>
+  </ContentWrap>
+
+  <!-- 鍗$墖瑙嗗浘 -->
+  <ContentWrap>
+    <el-row v-if="viewMode === 'card'" :gutter="16">
+      <el-col v-for="item in list" :key="item.id" :lg="6" :md="12" :sm="12" :xs="24" class="mb-4">
+        <el-card :body-style="{ padding: '0' }" class="h-full transition-colors">
+          <!-- 鍐呭鍖哄煙 -->
+          <div class="p-4">
+            <!-- 鏍囬鍖哄煙 -->
+            <div class="flex items-center mb-3">
+              <div class="mr-2.5 flex items-center">
+                <el-image :src="item.icon || defaultIconUrl" class="w-[35px] h-[35px]" />
+              </div>
+              <div class="text-[16px] font-600">{{ item.name }}</div>
+            </div>
+
+            <!-- 淇℃伅鍖哄煙 -->
+            <div class="flex items-center text-[14px]">
+              <div class="flex-1">
+                <div class="mb-2.5 last:mb-0">
+                  <span class="text-[#717c8e] mr-2.5">浜у搧鍒嗙被</span>
+                  <span class="text-[#0070ff]">{{ item.categoryName }}</span>
+                </div>
+                <div class="mb-2.5 last:mb-0">
+                  <span class="text-[#717c8e] mr-2.5">浜у搧绫诲瀷</span>
+                  <dict-tag :type="DICT_TYPE.IOT_PRODUCT_DEVICE_TYPE" :value="item.deviceType" />
+                </div>
+                <div class="mb-2.5 last:mb-0">
+                  <span class="text-[#717c8e] mr-2.5">浜у搧鏍囪瘑</span>
+                  <span class="text-[#0b1d30] inline-block align-middle overflow-hidden text-ellipsis whitespace-nowrap max-w-[140px]">
+                    {{ item.productKey }}
+                  </span>
+                </div>
+              </div>
+              <div class="w-[100px] h-[100px]">
+                <el-image :src="item.picUrl || defaultPicUrl" class="w-full h-full" />
+              </div>
+            </div>
+
+            <!-- 鍒嗛殧绾� -->
+            <el-divider class="!my-3" />
+
+            <!-- 鎸夐挳缁� -->
+            <div class="flex items-center px-0">
+              <el-button
+                v-hasPermi="['iot:product:update']"
+                class="flex-1 !px-2 !h-[32px] text-[13px]"
+                plain
+                type="primary"
+                @click="openForm('update', item.id)"
+              >
+                <Icon class="mr-1" icon="ep:edit-pen" />
+                缂栬緫
+              </el-button>
+              <el-button
+                class="flex-1 !px-2 !h-[32px] !ml-[10px] text-[13px]"
+                plain
+                type="warning"
+                @click="openDetail(item.id)"
+              >
+                <Icon class="mr-1" icon="ep:view" />
+                璇︽儏
+              </el-button>
+              <el-button
+                class="flex-1 !px-2 !h-[32px] !ml-[10px] text-[13px]"
+                plain
+                type="success"
+                @click="openObjectModel(item)"
+              >
+                <Icon class="mr-1" icon="ep:scale-to-original" />
+                鐗╂ā鍨�
+              </el-button>
+              <div class="mx-[10px] h-[20px] w-[1px] bg-[#dcdfe6]"></div>
+              <el-button
+                v-hasPermi="['iot:product:delete']"
+                :disabled="item.status === 1"
+                class="!px-2 !h-[32px] text-[13px]"
+                plain
+                type="danger"
+                @click="handleDelete(item.id)"
+              >
+                <Icon icon="ep:delete" />
+              </el-button>
+            </div>
+          </div>
+        </el-card>
+      </el-col>
+    </el-row>
+
+    <!-- 鍒楄〃瑙嗗浘 -->
+    <el-table v-else v-loading="loading" :data="list" :show-overflow-tooltip="true" :stripe="true">
+      <el-table-column align="center" label="ID" prop="id" />
+      <el-table-column align="center" label="ProductKey" prop="productKey" />
+      <el-table-column align="center" label="鍝佺被" prop="categoryName" />
+      <el-table-column align="center" label="璁惧绫诲瀷" prop="deviceType">
+        <template #default="scope">
+          <dict-tag :type="DICT_TYPE.IOT_PRODUCT_DEVICE_TYPE" :value="scope.row.deviceType" />
+        </template>
+      </el-table-column>
+      <el-table-column align="center" label="浜у搧鍥炬爣" prop="icon">
+        <template #default="scope">
+          <el-image
+            v-if="scope.row.icon"
+            :preview-src-list="[scope.row.icon]"
+            :src="scope.row.icon"
+            class="w-40px h-40px"
+          />
+          <span v-else>-</span>
+        </template>
+      </el-table-column>
+      <el-table-column align="center" label="浜у搧鍥剧墖" prop="picture">
+        <template #default="scope">
+          <el-image
+            v-if="scope.row.picUrl"
+            :preview-src-list="[scope.row.picture]"
+            :src="scope.row.picUrl"
+            class="w-40px h-40px"
+          />
+          <span v-else>-</span>
+        </template>
+      </el-table-column>
+      <el-table-column
+        :formatter="dateFormatter"
+        align="center"
+        label="鍒涘缓鏃堕棿"
+        prop="createTime"
+        width="180px"
+      />
+      <el-table-column align="center" label="鎿嶄綔">
+        <template #default="scope">
+          <el-button
+            v-hasPermi="['iot:product:query']"
+            link
+            type="primary"
+            @click="openDetail(scope.row.id)"
+          >
+            鏌ョ湅
+          </el-button>
+          <el-button
+            v-hasPermi="['iot:product:update']"
+            link
+            type="primary"
+            @click="openForm('update', scope.row.id)"
+          >
+            缂栬緫
+          </el-button>
+          <el-button
+            v-hasPermi="['iot:product:delete']"
+            :disabled="scope.row.status === 1"
+            link
+            type="danger"
+            @click="handleDelete(scope.row.id)"
+          >
+            鍒犻櫎
+          </el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+
+    <!-- 鍒嗛〉 -->
+    <Pagination
+      v-model:limit="queryParams.pageSize"
+      v-model:page="queryParams.pageNo"
+      :total="total"
+      @pagination="getList"
+    />
+  </ContentWrap>
+
+  <!-- 琛ㄥ崟寮圭獥锛氭坊鍔�/淇敼 -->
+  <ProductForm ref="formRef" @success="getList" />
+</template>
+
+<script lang="ts" setup>
+import { dateFormatter } from '@/utils/formatTime'
+import { ProductApi, ProductVO } from '@/api/iot/product/product'
+import ProductForm from './ProductForm.vue'
+import { DICT_TYPE } from '@/utils/dict'
+import download from '@/utils/download'
+import defaultPicUrl from '@/assets/imgs/iot/device.png'
+import defaultIconUrl from '@/assets/svgs/iot/cube.svg'
+
+/** iot 浜у搧鍒楄〃 */
+defineOptions({ name: 'IoTProduct' })
+
+const message = useMessage() // 娑堟伅寮圭獥
+const { t } = useI18n() // 鍥介檯鍖�
+const { push } = useRouter()
+const route = useRoute()
+
+const loading = ref(true) // 鍒楄〃鐨勫姞杞戒腑
+const activeName = ref('info') // 褰撳墠婵�娲荤殑鏍囩椤�
+const list = ref<ProductVO[]>([]) // 鍒楄〃鐨勬暟鎹�
+const total = ref(0) // 鍒楄〃鐨勬�婚〉鏁�
+const queryParams = reactive({
+  pageNo: 1,
+  pageSize: 10,
+  name: undefined,
+  productKey: undefined
+})
+const queryFormRef = ref() // 鎼滅储鐨勮〃鍗�
+const exportLoading = ref(false) // 瀵煎嚭鍔犺浇涓�
+const viewMode = ref<'card' | 'list'>('card') // 瑙嗗浘妯″紡鐘舵��
+
+/** 鏌ヨ鍒楄〃 */
+const getList = async () => {
+  loading.value = true
+  try {
+    const data = await ProductApi.getProductPage(queryParams)
+    list.value = data.list
+    total.value = data.total
+  } finally {
+    loading.value = false
+  }
+}
+
+/** 鎼滅储鎸夐挳鎿嶄綔 */
+const handleQuery = () => {
+  queryParams.pageNo = 1
+  getList()
+}
+
+/** 閲嶇疆鎸夐挳鎿嶄綔 */
+const resetQuery = () => {
+  queryFormRef.value.resetFields()
+  handleQuery()
+}
+
+/** 娣诲姞/淇敼鎿嶄綔 */
+const formRef = ref()
+const openForm = (type: string, id?: number) => {
+  formRef.value.open(type, id)
+}
+
+/** 鎵撳紑璇︽儏 */
+const openDetail = (id: number) => {
+  push({ name: 'IoTProductDetail', params: { id } })
+}
+
+/** 鎵撳紑鐗╂ā鍨� */
+const openObjectModel = (item: ProductVO) => {
+  push({
+    name: 'IoTProductDetail',
+    params: { id: item.id },
+    query: { tab: 'thingModel' }
+  })
+}
+
+/** 鍒犻櫎鎸夐挳鎿嶄綔 */
+const handleDelete = async (id: number) => {
+  try {
+    // 鍒犻櫎鐨勪簩娆$‘璁�
+    await message.delConfirm()
+    // 鍙戣捣鍒犻櫎
+    await ProductApi.deleteProduct(id)
+    message.success(t('common.delSuccess'))
+    // 鍒锋柊鍒楄〃
+    await getList()
+  } catch {}
+}
+
+/** 瀵煎嚭鎸夐挳鎿嶄綔 */
+const handleExport = async () => {
+  try {
+    // 瀵煎嚭鐨勪簩娆$‘璁�
+    await message.exportConfirm()
+    // 鍙戣捣瀵煎嚭
+    exportLoading.value = true
+    const data = await ProductApi.exportProduct(queryParams)
+    download.excel(data, '鐗╄仈缃戜骇鍝�.xls')
+  } catch {
+  } finally {
+    exportLoading.value = false
+  }
+}
+
+/** 鍒濆鍖� **/
+onMounted(() => {
+  getList()
+  // 澶勭悊 tab 鍙傛暟
+  const { tab } = route.query
+  if (tab) {
+    activeName.value = tab as string
+  }
+})
+</script>

--
Gitblit v1.8.0