index.vue
3.46 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<template>
<BasicModal
v-bind="$attrs"
width="55rem"
@register="register"
:title="getTitle"
@ok="handleSubmit"
>
<CollapseContainer title="键名筛选器" class="border mb-8">
<BasicTable @register="registerTable">
<template #toolbar>
<a-button type="primary" @click="handleAddKey"> 新增键名筛选器 </a-button>
</template>
<template #action="{ record }">
<TableAction
:actions="[
{
label: '编辑',
icon: 'clarity:note-edit-line',
onClick: handleEdit.bind(null, record),
},
{
label: '删除',
icon: 'ant-design:delete-outlined',
color: 'error',
popConfirm: {
title: '是否确认删除',
confirm: handleDelete.bind(null, record),
},
},
]"
/>
</template>
</BasicTable>
</CollapseContainer>
<CollapseContainer title="筛选器预览" class="border mb-8"><div>1</div> </CollapseContainer>
<BasicForm :showResetButton="false" :showSubmitButton="false" @register="registerForm" />
</BasicModal>
<KeyValueModal @register="registerModal" />
</template>
<script lang="ts">
import { defineComponent, ref, computed, unref } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { BasicForm, useForm } from '/@/components/Form';
import { formSchema, columns } from './config';
import { CollapseContainer } from '/@/components/Container/index';
import { BasicTable, useTable } from '/@/components/Table';
import { useModal } from '/@/components/Modal';
import KeyValueModal from './cpns/index.vue';
export default defineComponent({
name: 'DetailTemplate',
components: {
KeyValueModal,
BasicModal,
BasicForm,
CollapseContainer,
BasicTable,
},
emits: ['success', 'register', 'getAllFieldsRule'],
setup(_, { emit }) {
const isUpdate = ref(true);
const [registerForm, { getFieldsValue }] = useForm({
labelWidth: 120,
schemas: formSchema,
});
const [registerModal, { openModal }] = useModal();
const getTitle = computed(() => (!unref(isUpdate) ? '添加报警规则条件' : '编辑报警规则条件'));
const [register, { closeModal }] = useModalInner((data) => {
isUpdate.value = !!data?.isUpdate;
});
const [registerTable] = useTable({
title: '键名筛选器',
// api: deviceConfigGetQuery,
columns,
bordered: true,
showIndexColumn: false,
actionColumn: {
width: 180,
title: '操作',
dataIndex: 'action',
slots: { customRender: 'action' },
},
});
const handleSubmit = () => {
const values = getFieldsValue();
emit('getAllFieldsRule', values);
closeModal();
};
const handleAddKey = () => {
openModal(true, {
isUpdate: false,
});
};
const handleEdit = () => {
openModal(true, {
isUpdate: true,
});
};
const handleDelete = () => {
console.log(1);
};
return {
handleEdit,
handleDelete,
registerModal,
registerTable,
handleAddKey,
registerForm,
handleSubmit,
register,
getTitle,
};
},
});
</script>