ChildDevice.vue
1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<template>
<div style="background-color: #f0f2f5">
<BasicTable @register="registerTable">
<template #deviceState="{ record }">
<Tag
:color="
record.deviceState == DeviceState.INACTIVE
? 'warning'
: record.deviceState == DeviceState.ONLINE
? 'success'
: 'error'
"
class="ml-2"
>
{{
record.deviceState == DeviceState.INACTIVE
? '待激活'
: record.deviceState == DeviceState.ONLINE
? '在线'
: '离线'
}}
</Tag>
</template>
</BasicTable>
</div>
</template>
<script lang="ts">
import { defineComponent, onMounted } from 'vue';
import { Tag } from 'ant-design-vue';
import { DeviceState } from '/@/api/device/model/deviceModel';
import { BasicTable, useTable } from '/@/components/Table';
import { childDeviceColumns, childDeviceSchemas } from '../../config/detail.config';
import { getChildDevicePage } from '/@/api/device/deviceManager.ts';
export default defineComponent({
name: 'DeviceManagement',
components: {
BasicTable,
Tag,
},
props: {
fromId: {
type: String,
required: true,
},
},
setup(props) {
console.log(123);
onMounted(() => {
console.log(props.fromId);
});
const [registerTable] = useTable({
api: getChildDevicePage,
columns: childDeviceColumns,
formConfig: {
labelWidth: 120,
schemas: childDeviceSchemas,
},
beforeFetch: (data) => {
console.log(props.fromId);
Reflect.set(data, 'fromId', props.fromId);
},
useSearchForm: true,
showTableSetting: true,
bordered: true,
showIndexColumn: false,
});
return {
registerTable,
DeviceState,
};
},
});
</script>