| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <script lang="ts" setup> |
| | | import type { VxeTableGridOptions } from '#/adapter/vxe-table'; |
| | | import type { ImManagerChannelMessageApi } from '#/api/im/manager/channel/message'; |
| | | |
| | | import { Page, useVbenModal } from '#/packages/effects/common-ui/src'; |
| | | |
| | | import { Image, message, Tag } from 'ant-design-vue'; |
| | | |
| | | import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table'; |
| | | import { |
| | | deleteManagerChannelMessage, |
| | | getManagerChannelMessagePage, |
| | | } from '#/api/im/manager/channel/message'; |
| | | import { $t } from '#/locales'; |
| | | |
| | | import { useMessageGridColumns, useMessageGridFormSchema } from '../material/data'; |
| | | import SendForm from './modules/send-form.vue'; |
| | | |
| | | defineOptions({ name: 'ImManagerChannelMessage' }); |
| | | |
| | | const [SendModal, sendModalApi] = useVbenModal({ |
| | | connectedComponent: SendForm, |
| | | destroyOnClose: true, |
| | | }); |
| | | |
| | | /** å·æ°è¡¨æ ¼ */ |
| | | function handleRefresh() { |
| | | gridApi.query(); |
| | | } |
| | | |
| | | /** æå¼åéå¼¹çª */ |
| | | function handleSend() { |
| | | sendModalApi.open(); |
| | | } |
| | | |
| | | /** å é¤é¢éæ¶æ¯ */ |
| | | async function handleDelete(row: ImManagerChannelMessageApi.ChannelMessage) { |
| | | const hideLoading = message.loading({ |
| | | content: $t('ui.actionMessage.deleting', [row.id]), |
| | | duration: 0, |
| | | }); |
| | | try { |
| | | await deleteManagerChannelMessage(row.id); |
| | | message.success($t('ui.actionMessage.deleteSuccess', [row.id])); |
| | | handleRefresh(); |
| | | } finally { |
| | | hideLoading(); |
| | | } |
| | | } |
| | | |
| | | const [Grid, gridApi] = useVbenVxeGrid({ |
| | | formOptions: { |
| | | schema: useMessageGridFormSchema(), |
| | | }, |
| | | gridOptions: { |
| | | columns: useMessageGridColumns(), |
| | | height: 'auto', |
| | | keepSource: true, |
| | | proxyConfig: { |
| | | ajax: { |
| | | query: async ({ page }, formValues) => { |
| | | return await getManagerChannelMessagePage({ |
| | | pageNo: page.currentPage, |
| | | pageSize: page.pageSize, |
| | | ...formValues, |
| | | }); |
| | | }, |
| | | }, |
| | | }, |
| | | rowConfig: { |
| | | keyField: 'id', |
| | | isHover: true, |
| | | }, |
| | | toolbarConfig: { |
| | | refresh: true, |
| | | search: true, |
| | | }, |
| | | } as VxeTableGridOptions<ImManagerChannelMessageApi.ChannelMessage>, |
| | | }); |
| | | </script> |
| | | |
| | | <template> |
| | | <Page auto-content-height> |
| | | <SendModal @success="handleRefresh" /> |
| | | <Grid table-title="é¢éæ¶æ¯å表"> |
| | | <template #toolbar-tools> |
| | | <TableAction |
| | | :actions="[ |
| | | { |
| | | label: 'ç«å³æ¨é', |
| | | type: 'primary', |
| | | icon: ACTION_ICON.ADD, |
| | | auth: ['im:manager:channel-message:send'], |
| | | onClick: handleSend, |
| | | }, |
| | | ]" |
| | | /> |
| | | </template> |
| | | <template #cover="{ row }"> |
| | | <Image |
| | | v-if="row.materialCoverUrl" |
| | | :height="40" |
| | | :src="row.materialCoverUrl" |
| | | :width="40" |
| | | /> |
| | | </template> |
| | | <template #receivers="{ row }"> |
| | | <Tag v-if="!row.receiverUserIds || row.receiverUserIds.length === 0" color="warning"> |
| | | å
¨å |
| | | </Tag> |
| | | <span v-else>{{ row.receiverUserIds.length }} 人</span> |
| | | </template> |
| | | <template #actions="{ row }"> |
| | | <TableAction |
| | | :actions="[ |
| | | { |
| | | label: $t('common.delete'), |
| | | type: 'link', |
| | | danger: true, |
| | | icon: ACTION_ICON.DELETE, |
| | | auth: ['im:manager:channel-message:delete'], |
| | | popConfirm: { |
| | | title: $t('ui.actionMessage.deleteConfirm', [row.id]), |
| | | confirm: handleDelete.bind(null, row), |
| | | }, |
| | | }, |
| | | ]" |
| | | /> |
| | | </template> |
| | | </Grid> |
| | | </Page> |
| | | </template> |