...
|
...
|
@@ -182,7 +182,7 @@ |
182
|
182
|
</div>
|
183
|
183
|
</template>
|
184
|
184
|
<script lang="ts">
|
185
|
|
- import { defineComponent, reactive, unref, nextTick, h, onUnmounted, ref } from 'vue';
|
|
185
|
+ import { defineComponent, reactive, unref, h, onMounted } from 'vue';
|
186
|
186
|
import {
|
187
|
187
|
DeviceModel,
|
188
|
188
|
DeviceRecord,
|
...
|
...
|
@@ -216,7 +216,7 @@ |
216
|
216
|
import { useCopyToClipboard } from '/@/hooks/web/useCopyToClipboard';
|
217
|
217
|
import { QuestionCircleOutlined } from '@ant-design/icons-vue';
|
218
|
218
|
import { Authority } from '/@/components/Authority';
|
219
|
|
- import { useRouter } from 'vue-router';
|
|
219
|
+ import { useRoute, useRouter } from 'vue-router';
|
220
|
220
|
import { useBatchOperation } from '/@/utils/useBatchOperation';
|
221
|
221
|
|
222
|
222
|
export default defineComponent({
|
...
|
...
|
@@ -243,7 +243,7 @@ |
243
|
243
|
const { createMessage } = useMessage();
|
244
|
244
|
const go = useGo();
|
245
|
245
|
const ROUTER = useRouter();
|
246
|
|
- const immediateStatus = ref(false);
|
|
246
|
+ const ROUTE = useRoute();
|
247
|
247
|
const searchInfo = reactive<Recordable>({});
|
248
|
248
|
const { organizationIdTreeRef, resetFn } = useResetOrganizationTree(searchInfo);
|
249
|
249
|
const [registerModal, { openModal }] = useModal();
|
...
|
...
|
@@ -259,9 +259,7 @@ |
259
|
259
|
reload,
|
260
|
260
|
setLoading,
|
261
|
261
|
setSelectedRowKeys,
|
262
|
|
- setTableData,
|
263
|
262
|
getForm,
|
264
|
|
- setPagination,
|
265
|
263
|
getSelectRowKeys,
|
266
|
264
|
getSelectRows,
|
267
|
265
|
getRowSelection,
|
...
|
...
|
@@ -269,17 +267,13 @@ |
269
|
267
|
] = useTable({
|
270
|
268
|
title: '设备列表',
|
271
|
269
|
api: devicePage,
|
272
|
|
- immediate: immediateStatus.value,
|
273
|
270
|
columns,
|
274
|
271
|
beforeFetch: (params) => {
|
275
|
272
|
const { deviceProfileId } = params;
|
276
|
273
|
const obj = {
|
277
|
274
|
...params,
|
278
|
275
|
...{
|
279
|
|
- deviceProfileIds:
|
280
|
|
- deviceProfileId === undefined || deviceProfileId === null || deviceProfileId == ''
|
281
|
|
- ? null
|
282
|
|
- : [deviceProfileId],
|
|
276
|
+ deviceProfileIds: deviceProfileId ? [deviceProfileId] : null,
|
283
|
277
|
},
|
284
|
278
|
};
|
285
|
279
|
delete obj.deviceProfileId;
|
...
|
...
|
@@ -313,54 +307,6 @@ |
313
|
307
|
|
314
|
308
|
const { isExistOption } = useBatchOperation(getRowSelection, setSelectedRowKeys);
|
315
|
309
|
|
316
|
|
- function getParams(keyword) {
|
317
|
|
- const reg = new RegExp('(^|&)' + keyword + '=([^&]*)(&|$)', 'i');
|
318
|
|
- const r = window.location.search.substr(1).match(reg);
|
319
|
|
- if (r != null) return unescape(r[2]);
|
320
|
|
- return null; //注意此处参数是中文,解码使用的方法是unescape ,那么在传值的时候如果是中文,需要使用escape('曲浩')方法来编码。
|
321
|
|
- }
|
322
|
|
-
|
323
|
|
- const count = ref(0);
|
324
|
|
- const onCloseVal = ref(0);
|
325
|
|
- const deviceProfileId = ref('');
|
326
|
|
- count.value = Number(getParams('count'));
|
327
|
|
- deviceProfileId.value = getParams('deviceProfileId') || '';
|
328
|
|
- const setRowClassName = async () => {
|
329
|
|
- if (deviceProfileId.value !== undefined) {
|
330
|
|
- const { items, total } = await devicePage({
|
331
|
|
- page: 1,
|
332
|
|
- pageSize: count.value === 0 ? 10 : count.value,
|
333
|
|
- deviceProfileIds:
|
334
|
|
- deviceProfileId.value === undefined ||
|
335
|
|
- deviceProfileId.value === null ||
|
336
|
|
- deviceProfileId.value == ''
|
337
|
|
- ? null
|
338
|
|
- : [deviceProfileId.value],
|
339
|
|
- });
|
340
|
|
- setPagination({ total });
|
341
|
|
- nextTick(() => {
|
342
|
|
- setTableData(items);
|
343
|
|
- const { setFieldsValue, resetFields } = getForm();
|
344
|
|
- setFieldsValue({
|
345
|
|
- deviceProfileId: deviceProfileId.value || null,
|
346
|
|
- });
|
347
|
|
- if (onCloseVal.value == 1) {
|
348
|
|
- resetFields();
|
349
|
|
- }
|
350
|
|
- });
|
351
|
|
- } else {
|
352
|
|
- setTimeout(() => {
|
353
|
|
- reload();
|
354
|
|
- }, 80);
|
355
|
|
- }
|
356
|
|
- };
|
357
|
|
- setRowClassName();
|
358
|
|
- onUnmounted(() => {
|
359
|
|
- deviceProfileId.value = '';
|
360
|
|
- count.value = 10;
|
361
|
|
- onCloseVal.value = 1;
|
362
|
|
- });
|
363
|
|
-
|
364
|
310
|
const userInfo: any = getAuthCache(USER_INFO_KEY);
|
365
|
311
|
const role: string = userInfo.roles[0];
|
366
|
312
|
|
...
|
...
|
@@ -494,6 +440,11 @@ |
494
|
440
|
reload();
|
495
|
441
|
};
|
496
|
442
|
|
|
443
|
+ onMounted(() => {
|
|
444
|
+ const queryParams = ROUTE.query as Record<'deviceProfileId', undefined | string>;
|
|
445
|
+ const { setFieldsValue } = getForm();
|
|
446
|
+ setFieldsValue({ deviceProfileId: queryParams.deviceProfileId });
|
|
447
|
+ });
|
497
|
448
|
return {
|
498
|
449
|
registerTable,
|
499
|
450
|
handleCreate,
|
...
|
...
|
|