index.vue 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <template>
  2. <div class="h-full">
  3. <fs-crud ref="crudRef" v-bind="crudBinding">
  4. <template #pagination-left>
  5. <fs-button icon="ion:trash-outline" @click="handleBatchDelete" />
  6. </template>
  7. <template #cell_url="scope">
  8. <n-tooltip trigger="hover">
  9. <template #trigger>
  10. <n-button>预览 </n-button>
  11. </template>
  12. <n-image width="120px" height="120px" :src="baseURL + '/' + scope.row.url"></n-image>
  13. </n-tooltip>
  14. </template>
  15. </fs-crud>
  16. </div>
  17. </template>
  18. <script lang="ts">
  19. import { defineComponent, onMounted, ref, nextTick } from 'vue';
  20. import { useFs, useExpose, useCrud } from '@fast-crud/fast-crud';
  21. import createCrudOptions from './crud';
  22. import { getAPI } from '/@/utils/axios-utils';
  23. import { SysNoticeApi } from '/@/api-services/api';
  24. import { ElMessage, ElMessageBox } from 'element-plus';
  25. const baseURL = import.meta.env.VITE_API_URL;
  26. export default defineComponent({
  27. name: 'ComponentCrud',
  28. setup() {
  29. const crudRef = ref();
  30. const crudBinding = ref();
  31. const { expose } = useExpose({ crudRef, crudBinding });
  32. const { crudOptions, selectedIds } = createCrudOptions({ expose });
  33. const { resetCrudOptions } = useCrud({ expose, crudOptions });
  34. onMounted(() => {
  35. expose.doRefresh();
  36. });
  37. const handleBatchDelete = async () => {
  38. if (selectedIds.value?.length > 0) {
  39. // ElMessageBox.confirm(`确定要批量删除这${selectedIds.value.length}条记录吗`, '确认', {
  40. // confirmButtonText: '确定',
  41. // cancelButtonText: '取消',
  42. // type: 'info',
  43. // }).then(async () => {
  44. // await delBatchSysFile(selectedIds.value);
  45. // message.success('删除成功');
  46. // selectedIds.value = [];
  47. // await expose.doRefresh();
  48. // ElMessage.success('删除成功');
  49. // })
  50. // .catch(() => { });
  51. } else {
  52. // ElMessage.success('请勾选要删除的记录');
  53. }
  54. };
  55. return {
  56. crudBinding,
  57. crudRef,
  58. handleBatchDelete,
  59. baseURL
  60. };
  61. }
  62. });
  63. </script>