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/detail/ProductDetailsHeader.vue | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 113 insertions(+), 0 deletions(-)
diff --git a/src/views/iot/product/product/detail/ProductDetailsHeader.vue b/src/views/iot/product/product/detail/ProductDetailsHeader.vue
new file mode 100644
index 0000000..311900c
--- /dev/null
+++ b/src/views/iot/product/product/detail/ProductDetailsHeader.vue
@@ -0,0 +1,113 @@
+<template>
+ <div>
+ <div class="flex items-start justify-between">
+ <div>
+ <el-col>
+ <el-row>
+ <span class="text-xl font-bold">{{ product.name }}</span>
+ </el-row>
+ </el-col>
+ </div>
+ <div>
+ <!-- 鍙充笂锛氭寜閽� -->
+ <el-button
+ @click="openForm('update', product.id)"
+ v-hasPermi="['iot:product:update']"
+ :disabled="product.status === 1"
+ >
+ 缂栬緫
+ </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>
+ <ContentWrap class="mt-10px">
+ <el-descriptions :column="1" direction="horizontal">
+ <el-descriptions-item label="ProductKey">
+ {{ product.productKey }}
+ <el-button @click="copyToClipboard(product.productKey)">澶嶅埗</el-button>
+ </el-descriptions-item>
+ <el-descriptions-item label="璁惧鎬绘暟">
+ <span class="ml-20px mr-10px">{{ product.deviceCount ?? '鍔犺浇涓�...' }}</span>
+ <el-button @click="goToDeviceList(product.id)">鍓嶅線绠$悊</el-button>
+ </el-descriptions-item>
+ </el-descriptions>
+ </ContentWrap>
+ <!-- 琛ㄥ崟寮圭獥锛氭坊鍔�/淇敼 -->
+ <ProductForm ref="formRef" @success="emit('refresh')" />
+</template>
+<script setup lang="ts">
+import ProductForm from '@/views/iot/product/product/ProductForm.vue'
+import { ProductApi, ProductVO } from '@/api/iot/product/product'
+import { useClipboard } from '@vueuse/core'
+
+const message = useMessage()
+const { t } = useI18n() // 鍥介檯鍖�
+
+const { product } = defineProps<{ product: ProductVO }>() // 瀹氫箟 Props
+
+/** 澶嶅埗鍒板壀璐存澘鏂规硶 */
+const copyToClipboard = async (text: string) => {
+ const { copy, copied, isSupported } = useClipboard({ legacy: true, source: text })
+ if (!isSupported) {
+ message.error(t('common.copyError'))
+ return
+ }
+ await copy()
+ if (unref(copied)) {
+ message.success(t('common.copySuccess'))
+ }
+}
+
+/** 璺敱璺宠浆鍒拌澶囩鐞� */
+const { push } = useRouter()
+const goToDeviceList = (productId: number) => {
+ push({ name: 'IoTDevice', query: { productId } })
+}
+
+/** 淇敼鎿嶄綔 */
+const emit = defineEmits(['refresh']) // 瀹氫箟 Emits
+const formRef = ref()
+const openForm = (type: string, id?: number) => {
+ 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('鎾ら攢鍙戝竷澶辫触')
+ }
+}
+</script>
--
Gitblit v1.8.0