list.vue
2.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
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
<template>
<div>
<BasicTable
@register="registerTable"
class="bg-neutral-100 dark:bg-dark-700"
>
<template #toolbar>
<Authority :value="PublicInterface.CREATE">
<a-button type="primary" @click="handleCreateOrEdit(null)">
{{ t('visual.dataview.sqlAdd') }}
</a-button>
</Authority>
</template>
<template #action="{ record }">
<TableAction
:actions="[
{
label: t('common.editText'),
icon: 'clarity:note-edit-line',
auth: PublicInterface.UPDATE,
onClick: handleCreateOrEdit.bind(null, record),
},
{
label: t('common.delText'),
icon: 'ant-design:delete-outlined',
auth: PublicInterface.DELETE,
color: 'error',
popConfirm: {
title: t('common.isDelete'),
confirm: handleDeleteOrBatchDelete.bind(null, record),
},
}]"
/>
</template>
</BasicTable>
</div>
<SqlApiForm @register="registerDrawer" @success="handleSuccess"/>
</template>
<script lang="ts" setup name="list">
import {BasicTable, TableAction, useTable} from "/@/components/Table";
import {
deleteBigViewSql,
getDataViewSqlPage
} from "/@/api/bigscreen/center/bigscreenCenter";
import {columns, searchFormSchema} from "/@/views/dataview/sqlApi/config/config";
import {useI18n} from "/@/hooks/web/useI18n";
import {PublicInterface} from "/@/views/dataview/config";
import {Authority} from "/@/components/Authority";
import {useDrawer} from "/@/components/Drawer";
import {SqlApiForm} from "./index";
import {useMessage} from "/@/hooks/web/useMessage";
const { t } = useI18n();
const [registerDrawer, { openDrawer }] = useDrawer();
const { createMessage } = useMessage();
const [registerTable, { reload, clearSelectedRowKeys }] = useTable({
api: getDataViewSqlPage,
columns,
showIndexColumn: false,
clickToRowSelect: false,
showTableSetting: true,
bordered: true,
formConfig: {
labelWidth: 120,
schemas: searchFormSchema,
baseColProps: { span: 9 },
actionColOptions: { span: 6 },
},
useSearchForm: true,
actionColumn: {
width: 180,
title: t('common.actionText'),
dataIndex: 'action',
slots: { customRender: 'action' },
fixed: 'right',
},
});
const handleCreateOrEdit = (record) => {
const isUpdate = record === null ? false : true;
const recordContent = record === null ? null : record;
openDrawer(true, {
isUpdate,
record: recordContent,
});
}
const handleSuccess = () => {
reload();
}
const handleDeleteOrBatchDelete = async (record) => {
try {
const ids = record?.id;
await deleteBigViewSql(ids);
createMessage.success(
`${ t('common.delText')}${t(
'common.successText'
)}`
);
} finally {
handleSuccess();
}
}
</script>
<script setup lang="ts">
</script>