| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <script lang="ts" setup> |
| | | import type { VxeTableGridOptions } from '#/adapter/vxe-table'; |
| | | import type { ImManagerFacePackItemApi } from '#/api/im/manager/face/item'; |
| | | import type { ImManagerFacePackApi } from '#/api/im/manager/face/pack'; |
| | | |
| | | import { computed, nextTick, ref } from 'vue'; |
| | | |
| | | import { useVbenModal } from '#/packages/effects/common-ui/src'; |
| | | import { isEmpty } from '#/packages/utils/src'; |
| | | |
| | | import { Drawer, Image, message } from 'ant-design-vue'; |
| | | |
| | | import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table'; |
| | | import { |
| | | deleteManagerFacePackItem, |
| | | deleteManagerFacePackItemList, |
| | | getManagerFacePackItemPage, |
| | | } from '#/api/im/manager/face/item'; |
| | | import { $t } from '#/locales'; |
| | | |
| | | import { useItemGridColumns, useItemGridFormSchema } from '../data'; |
| | | import ItemForm from './item-form.vue'; |
| | | |
| | | const visible = ref(false); |
| | | const currentPack = ref<ImManagerFacePackApi.FacePack>(); |
| | | const checkedIds = ref<number[]>([]); |
| | | const title = computed(() => |
| | | currentPack.value ? `ã${currentPack.value.name}ã表æ
管ç` : '表æ
管ç', |
| | | ); |
| | | |
| | | const [ItemFormModal, itemFormModalApi] = useVbenModal({ |
| | | connectedComponent: ItemForm, |
| | | destroyOnClose: true, |
| | | }); |
| | | |
| | | /** æå¼æ½å± */ |
| | | function open(pack: ImManagerFacePackApi.FacePack) { |
| | | currentPack.value = pack; |
| | | visible.value = true; |
| | | checkedIds.value = []; |
| | | } |
| | | |
| | | defineExpose({ open }); |
| | | |
| | | /** æ½å±æå¼åæ¥è¯¢è¡¨æ
å表 */ |
| | | async function handleOpenChange(open: boolean) { |
| | | if (!open) { |
| | | return; |
| | | } |
| | | await nextTick(); |
| | | gridApi.query(); |
| | | } |
| | | |
| | | /** å·æ°è¡¨æ ¼ */ |
| | | function handleRefresh() { |
| | | gridApi.query(); |
| | | } |
| | | |
| | | /** å建表æ
*/ |
| | | function handleCreate() { |
| | | itemFormModalApi.setData({ packId: currentPack.value?.id }).open(); |
| | | } |
| | | |
| | | /** ç¼è¾è¡¨æ
*/ |
| | | function handleEdit(row: ImManagerFacePackItemApi.FacePackItem) { |
| | | itemFormModalApi |
| | | .setData({ id: row.id, packId: currentPack.value?.id }) |
| | | .open(); |
| | | } |
| | | |
| | | /** å é¤è¡¨æ
*/ |
| | | async function handleDelete(row: ImManagerFacePackItemApi.FacePackItem) { |
| | | const hideLoading = message.loading({ |
| | | content: $t('ui.actionMessage.deleting', [row.name || row.id]), |
| | | duration: 0, |
| | | }); |
| | | try { |
| | | await deleteManagerFacePackItem(row.id); |
| | | message.success($t('ui.actionMessage.deleteSuccess', [row.name || row.id])); |
| | | handleRefresh(); |
| | | } finally { |
| | | hideLoading(); |
| | | } |
| | | } |
| | | |
| | | /** æ¹éå é¤è¡¨æ
*/ |
| | | async function handleDeleteBatch() { |
| | | const hideLoading = message.loading({ |
| | | content: $t('ui.actionMessage.deletingBatch'), |
| | | duration: 0, |
| | | }); |
| | | try { |
| | | await deleteManagerFacePackItemList(checkedIds.value); |
| | | checkedIds.value = []; |
| | | message.success($t('ui.actionMessage.deleteSuccess')); |
| | | handleRefresh(); |
| | | } finally { |
| | | hideLoading(); |
| | | } |
| | | } |
| | | |
| | | /** è¡¨æ ¼éä¸åå */ |
| | | function handleRowCheckboxChange({ |
| | | records, |
| | | }: { |
| | | records: ImManagerFacePackItemApi.FacePackItem[]; |
| | | }) { |
| | | checkedIds.value = records.map((item) => item.id); |
| | | } |
| | | |
| | | const [Grid, gridApi] = useVbenVxeGrid({ |
| | | formOptions: { |
| | | schema: useItemGridFormSchema(), |
| | | }, |
| | | gridOptions: { |
| | | columns: useItemGridColumns(), |
| | | height: 'auto', |
| | | keepSource: true, |
| | | proxyConfig: { |
| | | ajax: { |
| | | query: async ({ page }, formValues) => { |
| | | return await getManagerFacePackItemPage({ |
| | | pageNo: page.currentPage, |
| | | pageSize: page.pageSize, |
| | | packId: currentPack.value?.id, |
| | | ...formValues, |
| | | }); |
| | | }, |
| | | }, |
| | | }, |
| | | rowConfig: { |
| | | keyField: 'id', |
| | | isHover: true, |
| | | }, |
| | | toolbarConfig: { |
| | | refresh: true, |
| | | search: true, |
| | | }, |
| | | } as VxeTableGridOptions<ImManagerFacePackItemApi.FacePackItem>, |
| | | gridEvents: { |
| | | checkboxAll: handleRowCheckboxChange, |
| | | checkboxChange: handleRowCheckboxChange, |
| | | }, |
| | | }); |
| | | </script> |
| | | |
| | | <template> |
| | | <Drawer |
| | | v-model:open="visible" |
| | | :title="title" |
| | | destroy-on-close |
| | | width="65%" |
| | | @after-open-change="handleOpenChange" |
| | | > |
| | | <ItemFormModal @success="handleRefresh" /> |
| | | <Grid table-title="表æ
å表"> |
| | | <template #toolbar-tools> |
| | | <TableAction |
| | | :actions="[ |
| | | { |
| | | label: $t('ui.actionTitle.create', ['表æ
']), |
| | | type: 'primary', |
| | | icon: ACTION_ICON.ADD, |
| | | auth: ['im:manager:face-pack-item:create'], |
| | | onClick: handleCreate, |
| | | }, |
| | | { |
| | | label: $t('ui.actionTitle.deleteBatch'), |
| | | type: 'primary', |
| | | danger: true, |
| | | icon: ACTION_ICON.DELETE, |
| | | auth: ['im:manager:face-pack-item:delete'], |
| | | disabled: isEmpty(checkedIds), |
| | | popConfirm: { |
| | | title: $t('ui.actionMessage.deleteBatchConfirm'), |
| | | confirm: handleDeleteBatch, |
| | | }, |
| | | }, |
| | | ]" |
| | | /> |
| | | </template> |
| | | <template #image="{ row }"> |
| | | <Image v-if="row.url" :height="40" :src="row.url" :width="40" /> |
| | | </template> |
| | | <template #size="{ row }"> |
| | | <span v-if="row.width || row.height"> |
| | | {{ row.width || '?' }} Ã {{ row.height || '?' }} |
| | | </span> |
| | | <span v-else>-</span> |
| | | </template> |
| | | <template #actions="{ row }"> |
| | | <TableAction |
| | | :actions="[ |
| | | { |
| | | label: $t('common.edit'), |
| | | type: 'link', |
| | | icon: ACTION_ICON.EDIT, |
| | | auth: ['im:manager:face-pack-item:update'], |
| | | onClick: handleEdit.bind(null, row), |
| | | }, |
| | | { |
| | | label: $t('common.delete'), |
| | | type: 'link', |
| | | danger: true, |
| | | icon: ACTION_ICON.DELETE, |
| | | auth: ['im:manager:face-pack-item:delete'], |
| | | popConfirm: { |
| | | title: $t('ui.actionMessage.deleteConfirm', [row.name || row.id]), |
| | | confirm: handleDelete.bind(null, row), |
| | | }, |
| | | }, |
| | | ]" |
| | | /> |
| | | </template> |
| | | </Grid> |
| | | </Drawer> |
| | | </template> |