diff --git a/src/api/device.ts b/src/api/device.ts
index d4ceacb..aa26e7e 100644
--- a/src/api/device.ts
+++ b/src/api/device.ts
@@ -22,6 +22,10 @@ export interface DeviceCreateRecord {
productId: number;
}
+export interface DeviceUpdateRecord extends DeviceCreateRecord {
+ id: number;
+}
+
export interface DeviceEventRecord {
id: number;
clientId: string;
@@ -49,8 +53,8 @@ export function createDevice(data: DeviceCreateRecord) {
}
// 修改
-export function updateDevice(id: number, data: DeviceCreateRecord) {
- return axios.put(`/api/rest/device/${id}`, data);
+export function updateDevice(data:DeviceUpdateRecord) {
+ return axios.put(`/api/rest/device/${data.id}`, data);
}
// 删除
export function deleteDevice(id: number) {
diff --git a/src/api/product.ts b/src/api/product.ts
index 3a841e0..c71d190 100644
--- a/src/api/product.ts
+++ b/src/api/product.ts
@@ -23,6 +23,11 @@ export interface ProductCreateRecord {
}];
}
+export interface ProductUpdateRecord extends ProductCreateRecord {
+ id: number;
+ productType: string;
+}
+
// 分页查询
export function queryProductList(data: ProductRecord) {
@@ -52,8 +57,8 @@ export function createProduct(data: ProductCreateRecord) {
}
// 修改
-export function updateProduct(id: number, data: ProductCreateRecord){
- return axios.patch(`/api/rest/product/${id}`, data);
+export function updateProduct(data: ProductUpdateRecord){
+ return axios.patch(`/api/rest/product/${data.id}`, data);
}
// 删除
diff --git a/src/router/routes/modules/iot.ts b/src/router/routes/modules/iot.ts
index d5067ef..698c191 100644
--- a/src/router/routes/modules/iot.ts
+++ b/src/router/routes/modules/iot.ts
@@ -13,17 +13,6 @@ const IOT: AppRouteRecordRaw = {
order: 1,
},
children: [
- {
- path: 'device',
- name: 'Device',
- component: () => import('@/views/iot/device/index.vue'),
- meta: {
- // locale: 'menu.system.role',
- title: '设备管理',
- requiresAuth: true,
- permissions: ['*'],
- },
- },
{
path: 'product',
name: 'Product',
@@ -35,6 +24,17 @@ const IOT: AppRouteRecordRaw = {
permissions: ['*'],
},
},
+ {
+ path: 'device',
+ name: 'Device',
+ component: () => import('@/views/iot/device/index.vue'),
+ meta: {
+ // locale: 'menu.system.role',
+ title: '设备管理',
+ requiresAuth: true,
+ permissions: ['*'],
+ },
+ }
],
};
diff --git a/src/views/iot/device/components/device-edit.vue b/src/views/iot/device/components/device-edit.vue
index 368b786..540db64 100644
--- a/src/views/iot/device/components/device-edit.vue
+++ b/src/views/iot/device/components/device-edit.vue
@@ -20,7 +20,77 @@
@cancel="handleCancel"
>
{{ modalTitle }}
-
+
+
+
+
+ {{item}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
取消
@@ -36,10 +106,8 @@
import { FormInstance } from '@arco-design/web-vue/es/form';
import { Message } from '@arco-design/web-vue';
import { useMessageStore } from '@/store';
- import DynamicForm from '@/components/dynamic-form/index.vue';
- import { Editor, Toolbar } from '@wangeditor/editor-for-vue';
- import { IEditorConfig } from '@wangeditor/editor'
import '@wangeditor/editor/dist/css/style.css'
+ import { createDevice, updateDevice } from '@/api/device';
const props = defineProps({
prem: {
@@ -47,8 +115,6 @@
},
isCreate: Boolean,
});
- // 部门树模态框状态
- const deptVisible=ref(false);
const emit = defineEmits(['refresh']);
const modalTitle = computed(() => {
return props.isCreate ? '创建设备' : '编辑设备';
@@ -60,136 +126,36 @@
const formData = ref({
...props.prem,
});
- const messageStore = useMessageStore();
const editorRef = shallowRef()
- const selectedIds= ref([]);
- const columns = computed(()=>[
- {
- title: '操作',
- dataIndex: 'key',
- slotName: 'key',
- },
- {
- title: '用户',
- dataIndex: 'title',
- },
- ])
+ const options = ref(['Option1', 'Option2', 'Option3']);
+ const loading = ref(false);
- const formSystem = ref(
- {
- productId:{
- label: '产品ID',
- component: 'input',
- type:'text'
- },
- name:{
- label: '设备名称',
- component: 'input',
- type:'text'
- },
- hardwareVersion:{
- label: '硬件版本',
- component: 'input',
- type:'text'
- },
- firmwareVersion:{
- label: '固件版本',
- component: 'input',
- type:'text'
- },
- extendParams:{
- label: '扩展属性',
- component: 'input',
- type:'text'
- },
- properties:{
- label: '设备物模型属性',
- component: 'input',
- type:'text'
- },
- },
- );
- const deptTreeData = reactive([
- {
- key: '1',
- title: '总部门',
- children: [
- {
- key: '2',
- title: '部门1',
- members: [
- { key: '101', title: '成员1' },
- { key: '102', title: '成员2' }
- ]
- },
- {
- key: '3',
- title: '部门2',
- members: [
- { key: '201', title: '成员3' },
- { key: '202', title: '成员4' }
- ]
- },
- {
- key: '4',
- title: '部门3',
- members: [
- { key: '203', title: '成员5' },
- { key: '204', title: '成员6' }
- ]
- }
- ]
+ // 搜索
+ const handleSearch = (value: any) => {
+ if (value) {
+ loading.value = true;
+ window.setTimeout(() => {
+ options.value = [`${value}-Option1`, `${value}-Option2`, `${value}-Option3`]
+ loading.value = false;
+ }, 2000)
+ } else {
+ options.value = []
}
- ]);
- const selectedDepartmentMembers: any = ref([]);
- const renderData = ref([]);
- // 部门树查询
- const queryDeptTree= async ()=>{
- deptVisible.value = true;
- }
-
- // 广度优先遍历树,获取选中的成员
- const getSelectedMembers = (treeData: any[], selectedKeys: string[]) => {
- const queue = [...treeData];
- const selectedMembers: any[] = [];
- while (queue.length > 0) {
- const node = queue.shift()!;
- if (selectedKeys.includes(node.key)) {
- if (node.members) {
- selectedMembers.push(...node.members);
- }
- }
- if (node.children) {
- queue.push(...node.children);
- }
- }
- return selectedMembers;
- }
+ };
// 组件被点击
const handleClick = () => {
setVisible(true);
};
- const editorConfig: Partial = { placeholder: '请输入内容...',MENU_CONF:{
- // 隐藏菜单
- hide: ['code', 'table', 'emoticon', 'uploadImage', 'video', 'todo', 'specialChar'],
- // 配置上传图片
- uploadImage: {
- base64LimitSize: 1024 * 1024,
- // server: '/api/rest/bulletin/1/add',
- }
- }
- }
// 提交
const handleSubmit = async () => {
const valid = await CreateRef.value?.validate();
if (!valid) {
- formData.value.permissionIds = checkKeys.value;
// 新增
if (props.isCreate) {
// formData.value.username = formData.value.email;
- const res = await messageStore.createMessage(formData.value);
+ const res = await createDevice(formData.value);
if (res.status === 200) {
Message.success({
content: '新建成功',
@@ -199,6 +165,17 @@
setVisible(false);
}
CreateRef.value?.resetFields();
+ } else {
+ // 编辑
+ const res = await updateDevice(formData.value);
+ if (res.status === 200) {
+ Message.success({
+ content: '修改成功',
+ duration: 5 * 1000,
+ });
+ emit('refresh');
+ setVisible(false);
+ }
}
}
};
@@ -216,33 +193,9 @@
setVisible(false);
};
- // 设备模态框提交
- const deptTreeSubmit = () => {
- deptVisible.value = false;
- formData.value.userIds = selectedIds.value;
- console.log(formData.value.userIds);
- };
\ No newline at end of file