From 4ea899f874b30fd7e59c064cd61e98ec963f0369 Mon Sep 17 00:00:00 2001 From: JiangQiming <291854119@qq.com> Date: Tue, 31 Jan 2023 14:24:54 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20=E9=80=9A=E7=9F=A5=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=BC=96=E8=BE=91=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/notice/Config/Detail/index.vue | 47 +++++++++++++++--------- src/views/notice/Template/index.vue | 4 +- 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/src/views/notice/Config/Detail/index.vue b/src/views/notice/Config/Detail/index.vue index 700c6d89..abfc22a5 100644 --- a/src/views/notice/Config/Detail/index.vue +++ b/src/views/notice/Config/Detail/index.vue @@ -311,31 +311,42 @@ const msgType = ref([ // 表单数据 const formData = ref({ configuration: { - appKey: '', - appSecret: '', + host: '', + port: 25, + ssl: false, + sender: '', + username: '', + password: '', }, description: '', name: '', - provider: 'dingTalkMessage', - type: 'dingTalk', + provider: 'embedded', + type: 'email', }); // 根据通知方式展示对应的字段 watch( () => formData.value.type, (val) => { - // formData.value.configuration = Object.values(CONFIG_FIELD_MAP[val])[0]; msgType.value = MSG_TYPE[val]; formData.value.provider = msgType.value[0].value; + + formData.value.configuration = + CONFIG_FIELD_MAP[val][formData.value.provider]; + + clearValid(); }, ); -computed(() => - Object.assign( - formData.value.configuration, - CONFIG_FIELD_MAP[formData.value.type][formData.value.provider], - ), +watch( + () => formData.value.provider, + (val) => { + formData.value.configuration = + CONFIG_FIELD_MAP[formData.value.type][val]; + + clearValid(); + }, ); // 验证规则 @@ -405,15 +416,15 @@ const { resetFields, validate, validateInfos, clearValidate } = useForm( formData.value, formRules.value, ); -watch( - () => formData.value.type, - () => { + +const clearValid = () => { + setTimeout(() => { clearValidate(); - }, - { deep: true }, -); + }, 200); +}; const getDetail = async () => { + if (route.params.id === ':id') return; const res = await configApi.detail(route.params.id as string); // console.log('res: ', res); formData.value = res.result; @@ -441,10 +452,12 @@ const handleSubmit = () => { message.success('保存成功'); router.back(); } - btnLoading.value = false; }) .catch((err) => { console.log('err: ', err); + }) + .finally(() => { + btnLoading.value = false; }); }; diff --git a/src/views/notice/Template/index.vue b/src/views/notice/Template/index.vue index 7af08260..87c20444 100644 --- a/src/views/notice/Template/index.vue +++ b/src/views/notice/Template/index.vue @@ -256,7 +256,7 @@ const getMethodTxt = (type: string) => { * 新增 */ const handleAdd = () => { - router.push(`/notice/Config/detail/:id`); + router.push(`/notice/Template/detail/:id`); }; /** @@ -323,7 +323,7 @@ const getActions = ( onClick: () => { // visible.value = true; // current.value = data; - router.push(`/notice/Config/detail/${data.id}`); + router.push(`/notice/Template/detail/${data.id}`); }, }, { From f381453bceacff6fe59ef4017697ae76c007758a Mon Sep 17 00:00:00 2001 From: 100011797 <2642441182@qq.com> Date: Tue, 31 Jan 2023 15:38:04 +0800 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20=E6=A0=87=E7=AD=BE=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E5=92=8C=E5=85=B3=E7=B3=BB=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../images/device/{ => instance}/button.png | Bin src/api/device/instance.ts | 47 +++++++ src/components/Table/index.tsx | 4 +- .../Detail/Info/components/Config/index.vue | 40 ++++-- .../Detail/Info/components/Relation/Save.vue | 125 ++++++++++++++++++ .../Detail/Info/components/Relation/index.vue | 10 ++ .../Detail/Info/components/Tags/Save.vue | 117 ++++++++++++++++ .../Detail/Info/components/Tags/index.vue | 35 ++++- src/views/device/Instance/Detail/index.vue | 77 ++++++++++- src/views/device/Instance/index.vue | 28 ++-- 10 files changed, 456 insertions(+), 27 deletions(-) rename public/images/device/{ => instance}/button.png (100%) create mode 100644 src/views/device/Instance/Detail/Info/components/Relation/Save.vue create mode 100644 src/views/device/Instance/Detail/Info/components/Tags/Save.vue diff --git a/public/images/device/button.png b/public/images/device/instance/button.png similarity index 100% rename from public/images/device/button.png rename to public/images/device/instance/button.png diff --git a/src/api/device/instance.ts b/src/api/device/instance.ts index b1d01908..ceb17116 100644 --- a/src/api/device/instance.ts +++ b/src/api/device/instance.ts @@ -120,3 +120,50 @@ export const update = (data: Partial) => data.id ? server.patch( * @returns */ export const getConfigMetadata = (id: string) => server.get(`/device-instance/${id}/config-metadata`) + +/** + * 断开连接 + * @param id 设备id + * @returns + */ +export const _disconnect = (id: string) => server.post(`/device-instance/${id}/disconnect`) + +/** + * 查询用户列表 + * @returns + */ +export const queryUserListNoPaging = () => server.post(`/user/_query/no-paging`, { + paging: false, + sorts: [{name: 'name', order: "asc"}] +}) + +/** + * 保存设备关系 + * @param id 设备id + * @param data + * @returns + */ +export const saveRelations = (id: string, data: Record) => server.patch(`/device/instance/${id}/relations`, data) + +/** + * 修改标签 + * @param id 设备id + * @param data + * @returns + */ +export const saveTags = (id: string, data: Record) => server.patch(`/device/instance/${id}/tag`, data) + +/** + * 删除标签 + * @param deviceId 设备id + * @param id 标签id + * @returns + */ +export const delTags = (deviceId: string, id: string) => server.remove(`/device/instance/${deviceId}/tag/${id}`) + +/** + * 恢复默认配置 + * @param deviceId 设备id + * @returns + */ +export const configurationReset = (deviceId: string) => server.put(`/device-instance/${deviceId}/configuration/_reset`) \ No newline at end of file diff --git a/src/components/Table/index.tsx b/src/components/Table/index.tsx index 1a37be86..fb778495 100644 --- a/src/components/Table/index.tsx +++ b/src/components/Table/index.tsx @@ -333,7 +333,7 @@ const JTable = defineComponent({ total={total.value} showQuickJumper={false} showSizeChanger={true} - current={pageIndex.value} + current={pageIndex.value + 1} pageSize={pageSize.value} pageSizeOptions={['12', '24', '48', '60', '100']} showTotal={(num) => { @@ -345,7 +345,7 @@ const JTable = defineComponent({ handleSearch({ ...props.params, pageSize: size, - pageIndex: pageSize.value === size ? page : 0 + pageIndex: pageSize.value === size ? (page ? page - 1 : 0) : 0 }) }} /> diff --git a/src/views/device/Instance/Detail/Info/components/Config/index.vue b/src/views/device/Instance/Detail/Info/components/Config/index.vue index f22eabaa..4d7b0d78 100644 --- a/src/views/device/Instance/Detail/Info/components/Config/index.vue +++ b/src/views/device/Instance/Detail/Info/components/Config/index.vue @@ -4,8 +4,12 @@
配置
编辑 - 应用配置 - 恢复默认 + + 应用配置 + + + 恢复默认 + @@ -28,7 +32,8 @@ \ No newline at end of file diff --git a/src/views/device/Instance/Detail/Info/components/Relation/Save.vue b/src/views/device/Instance/Detail/Info/components/Relation/Save.vue new file mode 100644 index 00000000..bf7db937 --- /dev/null +++ b/src/views/device/Instance/Detail/Info/components/Relation/Save.vue @@ -0,0 +1,125 @@ + + + \ No newline at end of file diff --git a/src/views/device/Instance/Detail/Info/components/Relation/index.vue b/src/views/device/Instance/Detail/Info/components/Relation/index.vue index 2fa91436..293fddd2 100644 --- a/src/views/device/Instance/Detail/Info/components/Relation/index.vue +++ b/src/views/device/Instance/Detail/Info/components/Relation/index.vue @@ -7,17 +7,27 @@ {{ item?.related ? (item?.related || []).map(i => i.name).join(',') : '' }} + diff --git a/src/views/device/Instance/Detail/Info/components/Tags/Save.vue b/src/views/device/Instance/Detail/Info/components/Tags/Save.vue new file mode 100644 index 00000000..dafe416a --- /dev/null +++ b/src/views/device/Instance/Detail/Info/components/Tags/Save.vue @@ -0,0 +1,117 @@ + + + \ No newline at end of file diff --git a/src/views/device/Instance/Detail/Info/components/Tags/index.vue b/src/views/device/Instance/Detail/Info/components/Tags/index.vue index b672f699..f197d60f 100644 --- a/src/views/device/Instance/Detail/Info/components/Tags/index.vue +++ b/src/views/device/Instance/Detail/Info/components/Tags/index.vue @@ -1,3 +1,34 @@ \ No newline at end of file +
+ + + {{ item?.value }} + + +
+ + + diff --git a/src/views/device/Instance/Detail/index.vue b/src/views/device/Instance/Detail/index.vue index b4c055b5..d9f2f0e5 100644 --- a/src/views/device/Instance/Detail/index.vue +++ b/src/views/device/Instance/Detail/index.vue @@ -1,7 +1,40 @@ @@ -9,9 +42,18 @@ import { useInstanceStore } from '@/store/instance'; import Info from './Info/index.vue'; import Metadata from '../../components/Metadata/index.vue'; +import { _deploy, _disconnect } from '@/api/device/instance' +import { message } from 'ant-design-vue'; +import { getImage } from '@/utils/comm'; + const route = useRoute(); const instanceStore = useInstanceStore() +const statusMap = new Map(); +statusMap.set('online', 'processing'); +statusMap.set('offline', 'error'); +statusMap.set('notActive', 'warning'); + const list = [ { key: 'Info', @@ -46,4 +88,35 @@ const onBack = () => { const onTabChange = (e: string) => { instanceStore.tabActiveKey = e } + +const handleAction = async () => { + if(instanceStore.current.id){ + const resp = await _deploy(instanceStore.current.id) + if(resp.status === 200){ + message.success('操作成功!') + instanceStore.refresh(instanceStore.current.id) + } + } +} + +const handleDisconnect = async () => { + if(instanceStore.current.id){ + const resp = await _disconnect(instanceStore.current.id) + if(resp.status === 200){ + message.success('操作成功!') + instanceStore.refresh(instanceStore.current.id) + } + } +} + +const handleRefresh = async () => { + if(instanceStore.current.id){ + await instanceStore.refresh(instanceStore.current.id) + message.success('操作成功') + } +} + +const jumpProduct = () => { + message.warn('暂未开发') +} \ No newline at end of file diff --git a/src/views/device/Instance/index.vue b/src/views/device/Instance/index.vue index fb842bec..52fd4ef4 100644 --- a/src/views/device/Instance/index.vue +++ b/src/views/device/Instance/index.vue @@ -101,8 +101,8 @@ :actions="getActions(slotProps, 'card')" v-bind="slotProps" :active="_selectedRowKeys.includes(slotProps.id)" - :status="slotProps.state.value" - :statusText="slotProps.state.text" + :status="slotProps.state?.value" + :statusText="slotProps.state?.text" :statusNames="{ online: 'success', offline: 'error', @@ -126,7 +126,7 @@
设备类型
-
{{ slotProps.deviceType.text }}
+
{{ slotProps.deviceType?.text }}
产品名称
@@ -151,7 +151,7 @@ /> @@ -166,7 +166,7 @@ /> @@ -176,8 +176,8 @@