SmsLog.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <div style="background-color: #f0f2f5" class="dark:bg-dark-900">
  3. <BasicTable @register="registerTable" class="dark:bg-dark-900">
  4. <template #toolbar>
  5. <!-- <Authority value="api:yt:smsLog:export">
  6. <a-button type="primary" @click="handleExport"> 导出 </a-button>
  7. </Authority> -->
  8. <Authority value="api:yt:smsLog:delete">
  9. <Popconfirm
  10. title="您确定要批量删除数据"
  11. ok-text="确定"
  12. cancel-text="取消"
  13. @confirm="handleDeleteOrBatchDelete(null)"
  14. >
  15. <a-button type="primary" color="error" :disabled="hasBatchDelete"> 批量删除 </a-button>
  16. </Popconfirm>
  17. </Authority>
  18. </template>
  19. <template #remark="{ record }">
  20. <Tooltip :title="record.remark">
  21. <div class="truncate w-full">{{ record.remark }}</div>
  22. </Tooltip>
  23. </template>
  24. <template #action="{ record }">
  25. <TableAction
  26. :actions="[
  27. {
  28. label: '查看',
  29. auth: 'api:yt:smsLog:get',
  30. icon: 'ant-design:fund-view-outlined',
  31. onClick: handleQuery.bind(null, record),
  32. },
  33. {
  34. label: '删除',
  35. auth: 'api:yt:smsLog:delete',
  36. icon: 'ant-design:delete-outlined',
  37. color: 'error',
  38. popConfirm: {
  39. title: '是否确认删除',
  40. confirm: handleDeleteOrBatchDelete.bind(null, record),
  41. },
  42. },
  43. ]"
  44. />
  45. </template>
  46. </BasicTable>
  47. </div>
  48. </template>
  49. <script lang="ts">
  50. import { defineComponent, h, nextTick } from 'vue';
  51. import { BasicTable, useTable, TableAction } from '/@/components/Table';
  52. import { columns, searchFormSchema } from './sms.data';
  53. import { Modal, Popconfirm, Tooltip } from 'ant-design-vue';
  54. import { smsLogPage, deleteSmsLog } from '/@/api/message/records';
  55. import { JsonPreview } from '/@/components/CodeEditor';
  56. import { useBatchDelete } from '/@/hooks/web/useBatchDelete';
  57. import { Authority } from '/@/components/Authority';
  58. export default defineComponent({
  59. name: 'SmsLog',
  60. components: { BasicTable, TableAction, Authority, Popconfirm, Tooltip },
  61. setup() {
  62. const [registerTable, { reload, setProps }] = useTable({
  63. title: '短信发送列表',
  64. api: smsLogPage,
  65. columns,
  66. formConfig: {
  67. labelWidth: 120,
  68. schemas: searchFormSchema,
  69. fieldMapToTime: [['sendTime', ['startTime', 'endTime'], 'YYYY-MM-DD HH:mm:ss']],
  70. },
  71. useSearchForm: true,
  72. showTableSetting: true,
  73. bordered: true,
  74. showIndexColumn: false,
  75. actionColumn: {
  76. width: 200,
  77. title: '操作',
  78. dataIndex: 'action',
  79. slots: { customRender: 'action' },
  80. fixed: 'right',
  81. },
  82. });
  83. const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions } = useBatchDelete(
  84. deleteSmsLog,
  85. handleSuccess,
  86. setProps
  87. );
  88. nextTick(() => {
  89. setProps(selectionOptions);
  90. });
  91. function handleQuery(record: Recordable) {
  92. Modal.info({
  93. title: '消息内容',
  94. width: 480,
  95. centered: true,
  96. maskClosable: true,
  97. content: h(JsonPreview, { data: JSON.parse(JSON.stringify(record.templateParam)) }),
  98. });
  99. }
  100. // 导出 TODO:待做
  101. const handleExport = () => {};
  102. // 刷新表格
  103. function handleSuccess() {
  104. reload();
  105. }
  106. return {
  107. hasBatchDelete,
  108. registerTable,
  109. handleExport,
  110. handleQuery,
  111. handleDeleteOrBatchDelete,
  112. };
  113. },
  114. });
  115. </script>