index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <!-- 通知公告-短信查询 -->
  2. <template>
  3. <app-view>
  4. <template #header>
  5. <app-filter :option="filterOption" />
  6. </template>
  7. <app-table :data="dataList" :columns="tableColumns" :loading="loading">
  8. <!-- 操作 -->
  9. <template #operate="{ row }">
  10. <app-operation size="small" :data-list="getActionButtons()"
  11. @click="(code: string) => openComponent(code, row)" circle />
  12. </template>
  13. <template #footer>
  14. <app-pagination :total="total" v-model:page-size="pageSize" v-model:page-index="pageIndex"
  15. @change="onSearch" />
  16. </template>
  17. </app-table>
  18. <component :is="componentMap.get(componentId)" v-bind="{ record }" @closed="closeComponent"
  19. v-if="componentId" />
  20. </app-view>
  21. </template>
  22. <script lang="ts" setup>
  23. import { shallowRef } from 'vue'
  24. import { ElMessage } from 'element-plus'
  25. import { formatDate } from '@/filters'
  26. import { useDataFilter } from '@/hooks/datatable-v2'
  27. import { useRequest } from '@/hooks/request'
  28. import { useOperation } from '@/hooks/operation'
  29. import { smsquery } from '@/services/api/notice'
  30. import { i18n } from '@/stores'
  31. import AppTable from '@pc/components/base/table/index.vue'
  32. import AppPagination from '@pc/components/base/pagination/index.vue'
  33. import AppOperation from '@pc/components/base/operation/index.vue'
  34. import AppFilter from '@pc/components/base/table-filter-v2/index.vue'
  35. const { global: { t } } = i18n
  36. const { componentMap, componentId, record, openComponent, closeComponent, getActionButtons } = useOperation<Notice.InformManqueryRsp>({
  37. onClose: () => onSearch()
  38. })
  39. const { dataList, total, pageSize, pageIndex, loading, run } = useRequest(smsquery, {
  40. params: {
  41. pageNum: 1,
  42. pageSize: 20
  43. },
  44. onError: (err) => {
  45. ElMessage.error(err)
  46. }
  47. })
  48. const tableColumns = shallowRef<Model.TableColumn[]>([
  49. { field: 'columnname', label: 'notice.sms.columnname' },
  50. { field: 'title', label: 'notice.sms.title' },
  51. { field: 'srcname', label: 'notice.sms.srcname' },
  52. { field: 'author', label: 'notice.sms.author' },
  53. { field: 'istop', label: 'notice.sms.istop', formatValue: (val) => formatDate(val) },
  54. { field: 'operate', label: 'common.operate', fixed: 'right' }
  55. ])
  56. const { filterOption, getQueryParams, resetFilters } = useDataFilter<Notice.SmsQueryReq>({
  57. filters: [
  58. {
  59. field: 'status',
  60. label: t('notice.sms.status'),
  61. options: () => []
  62. },
  63. {
  64. field: 'recvphone',
  65. label: t('notice.sms.recvphone')
  66. },
  67. ],
  68. buttons: [
  69. { label: t('operation.search'), className: 'el-button--primary', onClick: () => onSearch() },
  70. { label: t('operation.reset'), className: 'el-button--primary', validateEvent: false, onClick: () => resetFilters() }
  71. ]
  72. })
  73. const onSearch = () => {
  74. const qs = getQueryParams()
  75. run(qs)
  76. }
  77. </script>