Commit 851f4a84aec9c1dad1d2b75ed775c53ed322a86a
1 parent
4cfebeff
'feat:设备详情子设备开发,wip:租户管理:租户配置回显待完成'
Showing
11 changed files
with
125 additions
and
42 deletions
@@ -5,7 +5,7 @@ import { | @@ -5,7 +5,7 @@ import { | ||
5 | DeviceProfileQueryParam, | 5 | DeviceProfileQueryParam, |
6 | DeviceQueryParam, | 6 | DeviceQueryParam, |
7 | } from '/@/api/device/model/deviceModel'; | 7 | } from '/@/api/device/model/deviceModel'; |
8 | - | 8 | +import { ChildDeviceParams } from './model/deviceModel'; |
9 | enum DeviceManagerApi { | 9 | enum DeviceManagerApi { |
10 | /** | 10 | /** |
11 | * 设备URL | 11 | * 设备URL |
@@ -180,8 +180,18 @@ export const getGATEWAYdevice = async (params: { organization: string }) => { | @@ -180,8 +180,18 @@ export const getGATEWAYdevice = async (params: { organization: string }) => { | ||
180 | ); | 180 | ); |
181 | }; | 181 | }; |
182 | 182 | ||
183 | +// 获取网关设备 | ||
183 | export const getGATEWAY = (tbDeviceId: string) => { | 184 | export const getGATEWAY = (tbDeviceId: string) => { |
184 | return defHttp.get({ | 185 | return defHttp.get({ |
185 | url: '/device/gateway/' + tbDeviceId, | 186 | url: '/device/gateway/' + tbDeviceId, |
186 | }); | 187 | }); |
187 | }; | 188 | }; |
189 | + | ||
190 | +// 获取子设备的分页 | ||
191 | +export const getChildDevicePage = (params: ChildDeviceParams) => { | ||
192 | + console.log(params); | ||
193 | + return defHttp.get({ | ||
194 | + url: '/device/relation', | ||
195 | + params, | ||
196 | + }); | ||
197 | +}; |
@@ -41,3 +41,7 @@ export interface DeviceProfileModel { | @@ -41,3 +41,7 @@ export interface DeviceProfileModel { | ||
41 | createTime: string; | 41 | createTime: string; |
42 | description: string; | 42 | description: string; |
43 | } | 43 | } |
44 | + | ||
45 | +export type ChildDeviceParams = BasicPageParams & { | ||
46 | + formId: string; | ||
47 | +}; |
@@ -48,10 +48,18 @@ export async function deleteTenantProfileApi(params?: DeleteTenantProfilesParam) | @@ -48,10 +48,18 @@ export async function deleteTenantProfileApi(params?: DeleteTenantProfilesParam) | ||
48 | 48 | ||
49 | export const getTableTenantProfileApi = (params?: QueryTenantProfilesParam) => { | 49 | export const getTableTenantProfileApi = (params?: QueryTenantProfilesParam) => { |
50 | return defHttp.get({ | 50 | return defHttp.get({ |
51 | - params: params, | ||
52 | url: Api.getTenantProfile, | 51 | url: Api.getTenantProfile, |
52 | + params, | ||
53 | }); | 53 | }); |
54 | }; | 54 | }; |
55 | +export const selectTenantProfileApi = async (params?: QueryTenantProfilesParam) => { | ||
56 | + const { items } = await getTableTenantProfileApi(params); | ||
57 | + items.forEach((item) => { | ||
58 | + item.label = item.name; | ||
59 | + item.value = item.id.id; | ||
60 | + }); | ||
61 | + return Promise.resolve<any[]>(items); | ||
62 | +}; | ||
55 | 63 | ||
56 | export async function saveTenantProfileApi(params: tenantProfileDTO) { | 64 | export async function saveTenantProfileApi(params: tenantProfileDTO) { |
57 | await defHttp.post( | 65 | await defHttp.post( |
@@ -75,33 +83,33 @@ export function getTenantAdminPage(params: TenantAdminPageRequestParams) { | @@ -75,33 +83,33 @@ export function getTenantAdminPage(params: TenantAdminPageRequestParams) { | ||
75 | 83 | ||
76 | export async function saveTenantAdmin(params: UserDTO) { | 84 | export async function saveTenantAdmin(params: UserDTO) { |
77 | await defHttp.post({ | 85 | await defHttp.post({ |
78 | - params: params, | 86 | + params, |
79 | url: Api.saveTenantAdmin, | 87 | url: Api.saveTenantAdmin, |
80 | }); | 88 | }); |
81 | } | 89 | } |
82 | 90 | ||
83 | export async function updateOrCreateTenant(params: TenantRequestDTO) { | 91 | export async function updateOrCreateTenant(params: TenantRequestDTO) { |
84 | await defHttp.post({ | 92 | await defHttp.post({ |
85 | - params: params, | ||
86 | url: Api.updateOrCreateTenant, | 93 | url: Api.updateOrCreateTenant, |
94 | + params, | ||
87 | }); | 95 | }); |
88 | } | 96 | } |
89 | 97 | ||
90 | export async function deleteTenant(tenantIds: Array<string>) { | 98 | export async function deleteTenant(tenantIds: Array<string>) { |
91 | await defHttp.delete({ | 99 | await defHttp.delete({ |
100 | + url: Api.deleteTenant, | ||
92 | data: { | 101 | data: { |
93 | ids: tenantIds, | 102 | ids: tenantIds, |
94 | }, | 103 | }, |
95 | - url: Api.deleteTenant, | ||
96 | }); | 104 | }); |
97 | } | 105 | } |
98 | 106 | ||
99 | export async function deleteTenantAdmin(adminIds: Array<string>) { | 107 | export async function deleteTenantAdmin(adminIds: Array<string>) { |
100 | await defHttp.delete({ | 108 | await defHttp.delete({ |
109 | + url: Api.deleteTenantAdmin, | ||
101 | data: { | 110 | data: { |
102 | ids: adminIds, | 111 | ids: adminIds, |
103 | }, | 112 | }, |
104 | - url: Api.deleteTenantAdmin, | ||
105 | }); | 113 | }); |
106 | } | 114 | } |
107 | 115 | ||
@@ -113,7 +121,7 @@ export async function resetPassword(params: string) { | @@ -113,7 +121,7 @@ export async function resetPassword(params: string) { | ||
113 | 121 | ||
114 | export async function sendMessageOrEmail(params: SendResetPasswordEmailMsg) { | 122 | export async function sendMessageOrEmail(params: SendResetPasswordEmailMsg) { |
115 | await defHttp.post({ | 123 | await defHttp.post({ |
116 | - params: params, | 124 | + params, |
117 | url: Api.sendMessageOrEmail, | 125 | url: Api.sendMessageOrEmail, |
118 | }); | 126 | }); |
119 | } | 127 | } |
@@ -216,16 +216,22 @@ export const alarmSchemasForm: FormSchema[] = [ | @@ -216,16 +216,22 @@ export const alarmSchemasForm: FormSchema[] = [ | ||
216 | // 子设备 | 216 | // 子设备 |
217 | export const childDeviceSchemas: FormSchema[] = [ | 217 | export const childDeviceSchemas: FormSchema[] = [ |
218 | { | 218 | { |
219 | - field: 'icon', | ||
220 | - label: '设备配置', | ||
221 | - component: 'Select', | 219 | + field: 'deviceState', |
220 | + label: '设备状态', | ||
222 | colProps: { span: 6 }, | 221 | colProps: { span: 6 }, |
222 | + component: 'Select', | ||
223 | componentProps: { | 223 | componentProps: { |
224 | + size: 'small', | ||
224 | maxLength: 255, | 225 | maxLength: 255, |
226 | + options: [ | ||
227 | + { label: '待激活', value: 'INACTIVE' }, | ||
228 | + { label: '在线', value: 'ONLINE' }, | ||
229 | + { label: '离线', value: 'OFFLINE' }, | ||
230 | + ], | ||
225 | }, | 231 | }, |
226 | }, | 232 | }, |
227 | { | 233 | { |
228 | - field: 'icon', | 234 | + field: 'name', |
229 | label: '设备名称', | 235 | label: '设备名称', |
230 | component: 'Input', | 236 | component: 'Input', |
231 | colProps: { span: 6 }, | 237 | colProps: { span: 6 }, |
@@ -238,32 +244,30 @@ export const childDeviceSchemas: FormSchema[] = [ | @@ -238,32 +244,30 @@ export const childDeviceSchemas: FormSchema[] = [ | ||
238 | export const childDeviceColumns: BasicColumn[] = [ | 244 | export const childDeviceColumns: BasicColumn[] = [ |
239 | { | 245 | { |
240 | title: '名称', | 246 | title: '名称', |
241 | - dataIndex: 'name', | 247 | + dataIndex: 'tbDeviceName', |
242 | width: 120, | 248 | width: 120, |
243 | }, | 249 | }, |
244 | { | 250 | { |
245 | - title: '设备配置', | ||
246 | - dataIndex: 'label', | ||
247 | - width: 100, | ||
248 | - }, | ||
249 | - { | ||
250 | title: '标签', | 251 | title: '标签', |
251 | - dataIndex: 'aaa', | 252 | + dataIndex: 'label', |
252 | width: 160, | 253 | width: 160, |
253 | }, | 254 | }, |
254 | { | 255 | { |
255 | title: '状态', | 256 | title: '状态', |
256 | - dataIndex: 'bbb', | 257 | + dataIndex: 'deviceState', |
258 | + slots: { customRender: 'deviceState' }, | ||
257 | width: 160, | 259 | width: 160, |
258 | }, | 260 | }, |
259 | { | 261 | { |
260 | title: '最后连接时间', | 262 | title: '最后连接时间', |
261 | - dataIndex: 'ccc', | 263 | + dataIndex: 'lastOnlineTime', |
264 | + format: (text) => formatToDateTime(text, 'YYYY-MM-DD HH:mm:ss'), | ||
262 | width: 160, | 265 | width: 160, |
263 | }, | 266 | }, |
264 | { | 267 | { |
265 | - title: '创建时间', | ||
266 | - dataIndex: 'ddd', | 268 | + title: '更新时间', |
269 | + dataIndex: 'createdTime', | ||
270 | + format: (text) => formatToDateTime(text, 'YYYY-MM-DD HH:mm:ss'), | ||
267 | width: 160, | 271 | width: 160, |
268 | }, | 272 | }, |
269 | ]; | 273 | ]; |
@@ -7,7 +7,7 @@ | @@ -7,7 +7,7 @@ | ||
7 | centered | 7 | centered |
8 | @ok="dispatchCustomer" | 8 | @ok="dispatchCustomer" |
9 | @cancel="resetFields" | 9 | @cancel="resetFields" |
10 | - :minHeight="150" | 10 | + :minHeight="100" |
11 | okText="分配" | 11 | okText="分配" |
12 | > | 12 | > |
13 | <BasicForm @register="registerForm" /> | 13 | <BasicForm @register="registerForm" /> |
@@ -17,8 +17,8 @@ | @@ -17,8 +17,8 @@ | ||
17 | /></TabPane> | 17 | /></TabPane> |
18 | <TabPane key="3" tab="告警"><Alarm :id="deviceDetail.id" /></TabPane> | 18 | <TabPane key="3" tab="告警"><Alarm :id="deviceDetail.id" /></TabPane> |
19 | <TabPane key="4" tab="子设备" v-if="deviceDetail?.deviceType === 'GATEWAY'" | 19 | <TabPane key="4" tab="子设备" v-if="deviceDetail?.deviceType === 'GATEWAY'" |
20 | - ><ChildDevice | ||
21 | - /></TabPane> | 20 | + ><ChildDevice :fromId="deviceDetail?.tbDeviceId" /> |
21 | + </TabPane> | ||
22 | </Tabs> | 22 | </Tabs> |
23 | </BasicDrawer> | 23 | </BasicDrawer> |
24 | </template> | 24 | </template> |
@@ -61,6 +61,7 @@ | @@ -61,6 +61,7 @@ | ||
61 | deviceDetailRef.value.initMap(longitude, latitude, address); | 61 | deviceDetailRef.value.initMap(longitude, latitude, address); |
62 | } | 62 | } |
63 | }); | 63 | }); |
64 | + | ||
64 | const closeDrawer = () => { | 65 | const closeDrawer = () => { |
65 | activeKey.value = '1'; | 66 | activeKey.value = '1'; |
66 | }; | 67 | }; |
@@ -10,9 +10,9 @@ | @@ -10,9 +10,9 @@ | ||
10 | centered | 10 | centered |
11 | > | 11 | > |
12 | <div class="step-form-form"> | 12 | <div class="step-form-form"> |
13 | - <Steps :current="current"> | ||
14 | - <Step title="填写设备信息" v-if="!isUpdate" /> | ||
15 | - <Step title="添加设备凭证" v-if="!isUpdate" /> | 13 | + <Steps :current="current" v-if="!isUpdate"> |
14 | + <Step title="填写设备信息" /> | ||
15 | + <Step title="添加设备凭证" /> | ||
16 | </Steps> | 16 | </Steps> |
17 | </div> | 17 | </div> |
18 | <div class="mt-5"> | 18 | <div class="mt-5"> |
1 | <template> | 1 | <template> |
2 | - <BasicTable @register="registerTable" /> | 2 | + <BasicTable @register="registerTable"> |
3 | + <template #deviceState="{ record }"> | ||
4 | + <Tag | ||
5 | + :color=" | ||
6 | + record.deviceState == DeviceState.INACTIVE | ||
7 | + ? 'warning' | ||
8 | + : record.deviceState == DeviceState.ONLINE | ||
9 | + ? 'success' | ||
10 | + : 'error' | ||
11 | + " | ||
12 | + class="ml-2" | ||
13 | + > | ||
14 | + {{ | ||
15 | + record.deviceState == DeviceState.INACTIVE | ||
16 | + ? '待激活' | ||
17 | + : record.deviceState == DeviceState.ONLINE | ||
18 | + ? '在线' | ||
19 | + : '离线' | ||
20 | + }} | ||
21 | + </Tag> | ||
22 | + </template> | ||
23 | + </BasicTable> | ||
3 | </template> | 24 | </template> |
4 | <script lang="ts"> | 25 | <script lang="ts"> |
5 | - import { defineComponent } from 'vue'; | 26 | + import { defineComponent, onMounted } from 'vue'; |
27 | + import { Tag } from 'ant-design-vue'; | ||
28 | + import { DeviceState } from '/@/api/device/model/deviceModel'; | ||
6 | import { BasicTable, useTable } from '/@/components/Table'; | 29 | import { BasicTable, useTable } from '/@/components/Table'; |
7 | import { childDeviceColumns, childDeviceSchemas } from '../../config/detail.config'; | 30 | import { childDeviceColumns, childDeviceSchemas } from '../../config/detail.config'; |
8 | - | 31 | + import { getChildDevicePage } from '/@/api/device/deviceManager.ts'; |
9 | export default defineComponent({ | 32 | export default defineComponent({ |
10 | name: 'DeviceManagement', | 33 | name: 'DeviceManagement', |
11 | components: { | 34 | components: { |
12 | BasicTable, | 35 | BasicTable, |
36 | + Tag, | ||
37 | + }, | ||
38 | + props: { | ||
39 | + fromId: { | ||
40 | + type: String, | ||
41 | + required: true, | ||
42 | + }, | ||
13 | }, | 43 | }, |
14 | - setup(_) { | 44 | + setup(props) { |
45 | + console.log(123); | ||
46 | + onMounted(() => { | ||
47 | + console.log(props.fromId); | ||
48 | + }); | ||
15 | const [registerTable] = useTable({ | 49 | const [registerTable] = useTable({ |
50 | + api: getChildDevicePage, | ||
16 | columns: childDeviceColumns, | 51 | columns: childDeviceColumns, |
17 | formConfig: { | 52 | formConfig: { |
18 | labelWidth: 120, | 53 | labelWidth: 120, |
19 | schemas: childDeviceSchemas, | 54 | schemas: childDeviceSchemas, |
20 | }, | 55 | }, |
56 | + beforeFetch: (data) => { | ||
57 | + console.log(props.fromId); | ||
58 | + Reflect.set(data, 'fromId', props.fromId); | ||
59 | + }, | ||
21 | useSearchForm: true, | 60 | useSearchForm: true, |
22 | showTableSetting: true, | 61 | showTableSetting: true, |
23 | bordered: true, | 62 | bordered: true, |
@@ -26,6 +65,7 @@ | @@ -26,6 +65,7 @@ | ||
26 | 65 | ||
27 | return { | 66 | return { |
28 | registerTable, | 67 | registerTable, |
68 | + DeviceState, | ||
29 | }; | 69 | }; |
30 | }, | 70 | }, |
31 | }); | 71 | }); |
@@ -207,7 +207,7 @@ | @@ -207,7 +207,7 @@ | ||
207 | } | 207 | } |
208 | 208 | ||
209 | function handleDelete(record: Recordable) { | 209 | function handleDelete(record: Recordable) { |
210 | - let ids = [record.id]; | 210 | + const ids = [record.id]; |
211 | deleteDevice(ids).then(() => { | 211 | deleteDevice(ids).then(() => { |
212 | createMessage.success('删除设备成功'); | 212 | createMessage.success('删除设备成功'); |
213 | handleSuccess(); | 213 | handleSuccess(); |
@@ -97,9 +97,7 @@ | @@ -97,9 +97,7 @@ | ||
97 | getTenantRoles(data.record.tenantId).then((result) => { | 97 | getTenantRoles(data.record.tenantId).then((result) => { |
98 | Reflect.set(data.record, 'roleIds', result); | 98 | Reflect.set(data.record, 'roleIds', result); |
99 | //为表单赋值 | 99 | //为表单赋值 |
100 | - setFieldsValue({ | ||
101 | - ...data.record, | ||
102 | - }); | 100 | + setFieldsValue(data.record); |
103 | tenantLogo.value = data.record.icon; | 101 | tenantLogo.value = data.record.icon; |
104 | //编辑模式,菜单名称为不可用 | 102 | //编辑模式,菜单名称为不可用 |
105 | updateSchema({ field: 'title', componentProps: { disabled: true } }); | 103 | updateSchema({ field: 'title', componentProps: { disabled: true } }); |
@@ -130,6 +128,10 @@ | @@ -130,6 +128,10 @@ | ||
130 | typeof values.tenantExpireTime != 'undefined' && values.tenantExpireTime != null | 128 | typeof values.tenantExpireTime != 'undefined' && values.tenantExpireTime != null |
131 | ? values.tenantExpireTime.format('YYYY-MM-DD HH:mm:ss') | 129 | ? values.tenantExpireTime.format('YYYY-MM-DD HH:mm:ss') |
132 | : null, | 130 | : null, |
131 | + tenantProfileId: { | ||
132 | + id: values.tenantProfileId, | ||
133 | + entityType: 'TENANT_PROFILE', | ||
134 | + }, | ||
133 | }; | 135 | }; |
134 | updateOrCreateTenant(req).then(() => { | 136 | updateOrCreateTenant(req).then(() => { |
135 | closeDrawer(); //关闭侧框 | 137 | closeDrawer(); //关闭侧框 |
1 | import { BasicColumn } from '/@/components/Table/src/types/table'; | 1 | import { BasicColumn } from '/@/components/Table/src/types/table'; |
2 | import { FormSchema } from '/@/components/Form'; | 2 | import { FormSchema } from '/@/components/Form'; |
3 | import { getAllRoleList } from '/@/api/system/system'; | 3 | import { getAllRoleList } from '/@/api/system/system'; |
4 | +import { selectTenantProfileApi } from '/@/api/tenant/tenantApi'; | ||
4 | import { RoleEnum } from '/@/enums/roleEnum'; | 5 | import { RoleEnum } from '/@/enums/roleEnum'; |
5 | 6 | ||
6 | export function getBasicColumns(): BasicColumn[] { | 7 | export function getBasicColumns(): BasicColumn[] { |
@@ -49,7 +50,6 @@ export const tenantFormSchema: FormSchema[] = [ | @@ -49,7 +50,6 @@ export const tenantFormSchema: FormSchema[] = [ | ||
49 | componentProps: { | 50 | componentProps: { |
50 | maxLength: 36, | 51 | maxLength: 36, |
51 | }, | 52 | }, |
52 | - | ||
53 | show: false, | 53 | show: false, |
54 | }, | 54 | }, |
55 | { | 55 | { |
@@ -76,7 +76,7 @@ export const tenantFormSchema: FormSchema[] = [ | @@ -76,7 +76,7 @@ export const tenantFormSchema: FormSchema[] = [ | ||
76 | }, | 76 | }, |
77 | { | 77 | { |
78 | field: 'icon', | 78 | field: 'icon', |
79 | - label: '租户图标: ', | 79 | + label: '租户图标', |
80 | slot: 'iconSelect', | 80 | slot: 'iconSelect', |
81 | component: 'Input', | 81 | component: 'Input', |
82 | componentProps: { | 82 | componentProps: { |
@@ -98,7 +98,7 @@ export const tenantFormSchema: FormSchema[] = [ | @@ -98,7 +98,7 @@ export const tenantFormSchema: FormSchema[] = [ | ||
98 | }, | 98 | }, |
99 | { | 99 | { |
100 | field: 'name', | 100 | field: 'name', |
101 | - label: '租户名称:', | 101 | + label: '租户名称', |
102 | required: true, | 102 | required: true, |
103 | component: 'Input', | 103 | component: 'Input', |
104 | componentProps: { | 104 | componentProps: { |
@@ -107,7 +107,7 @@ export const tenantFormSchema: FormSchema[] = [ | @@ -107,7 +107,7 @@ export const tenantFormSchema: FormSchema[] = [ | ||
107 | }, | 107 | }, |
108 | { | 108 | { |
109 | field: 'roleIds', | 109 | field: 'roleIds', |
110 | - label: '租户角色:', | 110 | + label: '租户角色', |
111 | component: 'ApiSelect', | 111 | component: 'ApiSelect', |
112 | required: true, | 112 | required: true, |
113 | componentProps: { | 113 | componentProps: { |
@@ -121,6 +121,20 @@ export const tenantFormSchema: FormSchema[] = [ | @@ -121,6 +121,20 @@ export const tenantFormSchema: FormSchema[] = [ | ||
121 | }, | 121 | }, |
122 | }, | 122 | }, |
123 | { | 123 | { |
124 | + field: 'tenantProfileId', | ||
125 | + label: '租户配置', | ||
126 | + component: 'ApiSelect', | ||
127 | + required: true, | ||
128 | + componentProps: { | ||
129 | + api: selectTenantProfileApi, | ||
130 | + showSearch: true, | ||
131 | + params: { | ||
132 | + page: 1, | ||
133 | + pageSize: 100, | ||
134 | + }, | ||
135 | + }, | ||
136 | + }, | ||
137 | + { | ||
124 | field: 'enabled', | 138 | field: 'enabled', |
125 | label: '状态', | 139 | label: '状态', |
126 | component: 'RadioButtonGroup', | 140 | component: 'RadioButtonGroup', |
@@ -134,7 +148,7 @@ export const tenantFormSchema: FormSchema[] = [ | @@ -134,7 +148,7 @@ export const tenantFormSchema: FormSchema[] = [ | ||
134 | }, | 148 | }, |
135 | { | 149 | { |
136 | field: 'tenantExpireTime', | 150 | field: 'tenantExpireTime', |
137 | - label: '有效期: ', | 151 | + label: '有效期', |
138 | component: 'DatePicker', | 152 | component: 'DatePicker', |
139 | componentProps: { | 153 | componentProps: { |
140 | showTime: true, | 154 | showTime: true, |
@@ -142,7 +156,7 @@ export const tenantFormSchema: FormSchema[] = [ | @@ -142,7 +156,7 @@ export const tenantFormSchema: FormSchema[] = [ | ||
142 | }, | 156 | }, |
143 | }, | 157 | }, |
144 | { | 158 | { |
145 | - label: '备注: ', | 159 | + label: '备注', |
146 | field: 'description', | 160 | field: 'description', |
147 | component: 'InputTextArea', | 161 | component: 'InputTextArea', |
148 | componentProps: { | 162 | componentProps: { |