diff --git a/src/api/deviceTemplate.js b/src/api/deviceTemplate.js
new file mode 100644
index 00000000..109a2708
--- /dev/null
+++ b/src/api/deviceTemplate.js
@@ -0,0 +1,53 @@
+import http from '../utils/http.js';
+
+/**
+ * 设备模板管理API
+ */
+export class DeviceTemplateApi {
+ /**
+ * 获取设备模板列表
+ * @returns {Promise} 设备模板列表
+ */
+ static list() {
+ return http.get('/api/v1/device-templates');
+ }
+
+ /**
+ * 创建新设备模板
+ * @param {Object} deviceTemplateData 设备模板数据
+ * @returns {Promise} 创建结果
+ */
+ static create(deviceTemplateData) {
+ return http.post('/api/v1/device-templates', deviceTemplateData);
+ }
+
+ /**
+ * 获取设备模板详情
+ * @param {string|number} id 设备模板ID
+ * @returns {Promise} 设备模板详情
+ */
+ static get(id) {
+ return http.get(`/api/v1/device-templates/${id}`);
+ }
+
+ /**
+ * 更新设备模板信息
+ * @param {string|number} id 设备模板ID
+ * @param {Object} deviceTemplateData 设备模板数据
+ * @returns {Promise} 更新结果
+ */
+ static update(id, deviceTemplateData) {
+ return http.put(`/api/v1/device-templates/${id}`, deviceTemplateData);
+ }
+
+ /**
+ * 删除设备模板
+ * @param {string|number} id 设备模板ID
+ * @returns {Promise} 删除结果
+ */
+ static delete(id) {
+ return http.delete(`/api/v1/device-templates/${id}`);
+ }
+}
+
+export default DeviceTemplateApi;
\ No newline at end of file
diff --git a/src/api/index.js b/src/api/index.js
index 1a529417..eacb715a 100644
--- a/src/api/index.js
+++ b/src/api/index.js
@@ -1,6 +1,7 @@
import { AreaControllerApi, DeviceApi } from './device.js';
import PlanApi from './plan.js';
import UserApi from './user.js';
+import DeviceTemplateApi from './deviceTemplate.js'; // 导入设备模板API
/**
* API客户端
@@ -11,6 +12,7 @@ export class ApiClient {
this.devices = DeviceApi;
this.plans = PlanApi;
this.users = UserApi;
+ this.deviceTemplates = DeviceTemplateApi; // 添加设备模板API
}
}
diff --git a/src/components/DeviceTemplateForm.vue b/src/components/DeviceTemplateForm.vue
new file mode 100644
index 00000000..ff499855
--- /dev/null
+++ b/src/components/DeviceTemplateForm.vue
@@ -0,0 +1,282 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/components/DeviceTemplateList.vue b/src/components/DeviceTemplateList.vue
index cfd07aee..1d5b628f 100644
--- a/src/components/DeviceTemplateList.vue
+++ b/src/components/DeviceTemplateList.vue
@@ -3,17 +3,160 @@
-
+
+
+
+
+
+
+
+
+
+ 重新加载
+
+
+
+
+
+
+
+
+
+
+ {{ formatCategory(scope.row.category) }}
+
+
+
+
+
+
+
+ 编辑
+ 删除
+
+
+
+
+
+
@@ -31,10 +174,41 @@ export default {
padding: 15px 0;
}
+.title-container {
+ display: flex;
+ align-items: center;
+ gap: 5px;
+}
+
.page-title {
margin: 0;
font-size: 1.5rem;
font-weight: bold;
line-height: 1;
}
+
+.refresh-btn {
+ color: black;
+ background-color: transparent;
+ padding: 0;
+ width: 24px;
+ height: 24px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ border: none;
+}
+
+.loading {
+ padding: 20px 0;
+}
+
+.error {
+ padding: 20px 0;
+ text-align: center;
+}
+
+.retry-btn {
+ margin-top: 15px;
+}
\ No newline at end of file
diff --git a/src/services/deviceTemplateService.js b/src/services/deviceTemplateService.js
new file mode 100644
index 00000000..22156825
--- /dev/null
+++ b/src/services/deviceTemplateService.js
@@ -0,0 +1,79 @@
+import apiClient from '../api/index.js';
+
+class DeviceTemplateService {
+ /**
+ * 获取设备模板列表
+ * @returns {Promise} 设备模板列表
+ */
+ async getDeviceTemplates() {
+ try {
+ const response = await apiClient.deviceTemplates.list();
+ return response.data || [];
+ } catch (error) {
+ console.error('获取设备模板列表失败:', error);
+ throw error;
+ }
+ }
+
+ /**
+ * 创建新设备模板
+ * @param {Object} deviceTemplateData 设备模板数据
+ * @returns {Promise