Commit 851f4a84aec9c1dad1d2b75ed775c53ed322a86a

Authored by sqy
1 parent 4cfebeff

'feat:设备详情子设备开发,wip:租户管理:租户配置回显待完成'

... ... @@ -5,7 +5,7 @@ import {
5 5 DeviceProfileQueryParam,
6 6 DeviceQueryParam,
7 7 } from '/@/api/device/model/deviceModel';
8   -
  8 +import { ChildDeviceParams } from './model/deviceModel';
9 9 enum DeviceManagerApi {
10 10 /**
11 11 * 设备URL
... ... @@ -180,8 +180,18 @@ export const getGATEWAYdevice = async (params: { organization: string }) => {
180 180 );
181 181 };
182 182
  183 +// 获取网关设备
183 184 export const getGATEWAY = (tbDeviceId: string) => {
184 185 return defHttp.get({
185 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 41 createTime: string;
42 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 48
49 49 export const getTableTenantProfileApi = (params?: QueryTenantProfilesParam) => {
50 50 return defHttp.get({
51   - params: params,
52 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 64 export async function saveTenantProfileApi(params: tenantProfileDTO) {
57 65 await defHttp.post(
... ... @@ -75,33 +83,33 @@ export function getTenantAdminPage(params: TenantAdminPageRequestParams) {
75 83
76 84 export async function saveTenantAdmin(params: UserDTO) {
77 85 await defHttp.post({
78   - params: params,
  86 + params,
79 87 url: Api.saveTenantAdmin,
80 88 });
81 89 }
82 90
83 91 export async function updateOrCreateTenant(params: TenantRequestDTO) {
84 92 await defHttp.post({
85   - params: params,
86 93 url: Api.updateOrCreateTenant,
  94 + params,
87 95 });
88 96 }
89 97
90 98 export async function deleteTenant(tenantIds: Array<string>) {
91 99 await defHttp.delete({
  100 + url: Api.deleteTenant,
92 101 data: {
93 102 ids: tenantIds,
94 103 },
95   - url: Api.deleteTenant,
96 104 });
97 105 }
98 106
99 107 export async function deleteTenantAdmin(adminIds: Array<string>) {
100 108 await defHttp.delete({
  109 + url: Api.deleteTenantAdmin,
101 110 data: {
102 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 121
114 122 export async function sendMessageOrEmail(params: SendResetPasswordEmailMsg) {
115 123 await defHttp.post({
116   - params: params,
  124 + params,
117 125 url: Api.sendMessageOrEmail,
118 126 });
119 127 }
... ...
... ... @@ -216,16 +216,22 @@ export const alarmSchemasForm: FormSchema[] = [
216 216 // 子设备
217 217 export const childDeviceSchemas: FormSchema[] = [
218 218 {
219   - field: 'icon',
220   - label: '设备配置',
221   - component: 'Select',
  219 + field: 'deviceState',
  220 + label: '设备状态',
222 221 colProps: { span: 6 },
  222 + component: 'Select',
223 223 componentProps: {
  224 + size: 'small',
224 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 235 label: '设备名称',
230 236 component: 'Input',
231 237 colProps: { span: 6 },
... ... @@ -238,32 +244,30 @@ export const childDeviceSchemas: FormSchema[] = [
238 244 export const childDeviceColumns: BasicColumn[] = [
239 245 {
240 246 title: '名称',
241   - dataIndex: 'name',
  247 + dataIndex: 'tbDeviceName',
242 248 width: 120,
243 249 },
244 250 {
245   - title: '设备配置',
246   - dataIndex: 'label',
247   - width: 100,
248   - },
249   - {
250 251 title: '标签',
251   - dataIndex: 'aaa',
  252 + dataIndex: 'label',
252 253 width: 160,
253 254 },
254 255 {
255 256 title: '状态',
256   - dataIndex: 'bbb',
  257 + dataIndex: 'deviceState',
  258 + slots: { customRender: 'deviceState' },
257 259 width: 160,
258 260 },
259 261 {
260 262 title: '最后连接时间',
261   - dataIndex: 'ccc',
  263 + dataIndex: 'lastOnlineTime',
  264 + format: (text) => formatToDateTime(text, 'YYYY-MM-DD HH:mm:ss'),
262 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 271 width: 160,
268 272 },
269 273 ];
... ...
... ... @@ -7,7 +7,7 @@
7 7 centered
8 8 @ok="dispatchCustomer"
9 9 @cancel="resetFields"
10   - :minHeight="150"
  10 + :minHeight="100"
11 11 okText="分配"
12 12 >
13 13 <BasicForm @register="registerForm" />
... ...
... ... @@ -17,8 +17,8 @@
17 17 /></TabPane>
18 18 <TabPane key="3" tab="告警"><Alarm :id="deviceDetail.id" /></TabPane>
19 19 <TabPane key="4" tab="子设备" v-if="deviceDetail?.deviceType === 'GATEWAY'"
20   - ><ChildDevice
21   - /></TabPane>
  20 + ><ChildDevice :fromId="deviceDetail?.tbDeviceId" />
  21 + </TabPane>
22 22 </Tabs>
23 23 </BasicDrawer>
24 24 </template>
... ... @@ -61,6 +61,7 @@
61 61 deviceDetailRef.value.initMap(longitude, latitude, address);
62 62 }
63 63 });
  64 +
64 65 const closeDrawer = () => {
65 66 activeKey.value = '1';
66 67 };
... ...
... ... @@ -10,9 +10,9 @@
10 10 centered
11 11 >
12 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 16 </Steps>
17 17 </div>
18 18 <div class="mt-5">
... ...
1 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 24 </template>
4 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 29 import { BasicTable, useTable } from '/@/components/Table';
7 30 import { childDeviceColumns, childDeviceSchemas } from '../../config/detail.config';
8   -
  31 + import { getChildDevicePage } from '/@/api/device/deviceManager.ts';
9 32 export default defineComponent({
10 33 name: 'DeviceManagement',
11 34 components: {
12 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 49 const [registerTable] = useTable({
  50 + api: getChildDevicePage,
16 51 columns: childDeviceColumns,
17 52 formConfig: {
18 53 labelWidth: 120,
19 54 schemas: childDeviceSchemas,
20 55 },
  56 + beforeFetch: (data) => {
  57 + console.log(props.fromId);
  58 + Reflect.set(data, 'fromId', props.fromId);
  59 + },
21 60 useSearchForm: true,
22 61 showTableSetting: true,
23 62 bordered: true,
... ... @@ -26,6 +65,7 @@
26 65
27 66 return {
28 67 registerTable,
  68 + DeviceState,
29 69 };
30 70 },
31 71 });
... ...
... ... @@ -207,7 +207,7 @@
207 207 }
208 208
209 209 function handleDelete(record: Recordable) {
210   - let ids = [record.id];
  210 + const ids = [record.id];
211 211 deleteDevice(ids).then(() => {
212 212 createMessage.success('删除设备成功');
213 213 handleSuccess();
... ...
... ... @@ -97,9 +97,7 @@
97 97 getTenantRoles(data.record.tenantId).then((result) => {
98 98 Reflect.set(data.record, 'roleIds', result);
99 99 //为表单赋值
100   - setFieldsValue({
101   - ...data.record,
102   - });
  100 + setFieldsValue(data.record);
103 101 tenantLogo.value = data.record.icon;
104 102 //编辑模式,菜单名称为不可用
105 103 updateSchema({ field: 'title', componentProps: { disabled: true } });
... ... @@ -130,6 +128,10 @@
130 128 typeof values.tenantExpireTime != 'undefined' && values.tenantExpireTime != null
131 129 ? values.tenantExpireTime.format('YYYY-MM-DD HH:mm:ss')
132 130 : null,
  131 + tenantProfileId: {
  132 + id: values.tenantProfileId,
  133 + entityType: 'TENANT_PROFILE',
  134 + },
133 135 };
134 136 updateOrCreateTenant(req).then(() => {
135 137 closeDrawer(); //关闭侧框
... ...
1 1 import { BasicColumn } from '/@/components/Table/src/types/table';
2 2 import { FormSchema } from '/@/components/Form';
3 3 import { getAllRoleList } from '/@/api/system/system';
  4 +import { selectTenantProfileApi } from '/@/api/tenant/tenantApi';
4 5 import { RoleEnum } from '/@/enums/roleEnum';
5 6
6 7 export function getBasicColumns(): BasicColumn[] {
... ... @@ -49,7 +50,6 @@ export const tenantFormSchema: FormSchema[] = [
49 50 componentProps: {
50 51 maxLength: 36,
51 52 },
52   -
53 53 show: false,
54 54 },
55 55 {
... ... @@ -76,7 +76,7 @@ export const tenantFormSchema: FormSchema[] = [
76 76 },
77 77 {
78 78 field: 'icon',
79   - label: '租户图标: ',
  79 + label: '租户图标',
80 80 slot: 'iconSelect',
81 81 component: 'Input',
82 82 componentProps: {
... ... @@ -98,7 +98,7 @@ export const tenantFormSchema: FormSchema[] = [
98 98 },
99 99 {
100 100 field: 'name',
101   - label: '租户名称:',
  101 + label: '租户名称',
102 102 required: true,
103 103 component: 'Input',
104 104 componentProps: {
... ... @@ -107,7 +107,7 @@ export const tenantFormSchema: FormSchema[] = [
107 107 },
108 108 {
109 109 field: 'roleIds',
110   - label: '租户角色:',
  110 + label: '租户角色',
111 111 component: 'ApiSelect',
112 112 required: true,
113 113 componentProps: {
... ... @@ -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 138 field: 'enabled',
125 139 label: '状态',
126 140 component: 'RadioButtonGroup',
... ... @@ -134,7 +148,7 @@ export const tenantFormSchema: FormSchema[] = [
134 148 },
135 149 {
136 150 field: 'tenantExpireTime',
137   - label: '有效期: ',
  151 + label: '有效期',
138 152 component: 'DatePicker',
139 153 componentProps: {
140 154 showTime: true,
... ... @@ -142,7 +156,7 @@ export const tenantFormSchema: FormSchema[] = [
142 156 },
143 157 },
144 158 {
145   - label: '备注: ',
  159 + label: '备注',
146 160 field: 'description',
147 161 component: 'InputTextArea',
148 162 componentProps: {
... ...