index.vue
2.87 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 :clickToRowSelect="false" @register="registerTable">
<template #toolbar>
<Authority value="api:yt:product:category:post">
<Button type="primary" >
{{ t('inspection.serviceRecord.createCategoryText') }}
</Button>
</Authority>
</template>
<template #preserveStatus="{ record }">
<Tag
:color="
record.status == 'INCOMPLETE'
? 'red': record.status == 'COMPLETED'
? 'green': 'yellow'
"
class="ml-2"
>
{{ t(`inspection.serviceRecord.${record.preserveStatus}`) }}
</Tag>
</template>
<template #action="{ record }">
<TableAction
:actions="[
{
label: t('common.editText'),
auth: 'api:yt:product:category:update',
icon: 'clarity:note-edit-line',
// onClick: handleEdit.bind(null, record),
},
{
label: t('common.delText'),
auth: 'api:yt:product:category:delete',
icon: 'ant-design:delete-outlined',
color: 'error',
popConfirm: {
title: t('common.deleteConfirmText'),
confirm: handleDelete.bind(null, record),
},
},
]"
/>
</template>
</BasicTable>
</div>
</template>
<script setup lang="ts">
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { getServiceRecordList, deleteServeRecord } from '/@/api/inspection/serviceRecord';
import { columns, searchFormSchema } from './index';
import { useI18n } from '/@/hooks/web/useI18n';
import { Button, Tag } from 'ant-design-vue';
import {useMessage} from "/@/hooks/web/useMessage";
const { t } = useI18n();
const { createMessage } = useMessage();
const [
registerTable,
{ reload, setLoading, getSelectRowKeys, setSelectedRowKeys, getRowSelection },
] = useTable({
title: t('inspection.serviceRecord.listText'),
api: getServiceRecordList,
columns,
formConfig: {
labelWidth: 100,
schemas: searchFormSchema,
},
immediate: true,
useSearchForm: true,
showTableSetting: true,
bordered: true,
showIndexColumn: false,
clickToRowSelect: false,
rowKey: 'id',
actionColumn: {
width: 230,
title: t('common.actionText'),
slots: { customRender: 'action' },
fixed: 'right',
},
rowSelection: {
type: 'checkbox',
getCheckboxProps: (record: any) => {},
},
});
const handleDelete = async (record?: any) => {
let id = record.id;
try {
setLoading(true);
await deleteServeRecord({ id });
createMessage.success(t('common.deleteSuccessText'));
handleReload();
} catch (error) {
throw error;
} finally {
setLoading(false);
}
};
const handleReload = () => {
setSelectedRowKeys([]);
reload();
};
</script>