index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <div class="ma-content-block">
  3. <sa-table ref="crudRef" :options="options" :columns="columns" :searchForm="searchForm">
  4. <!-- 搜索区 tableSearch -->
  5. <template #tableSearch>
  6. <a-col :sm="8" :xs="24">
  7. <a-form-item label="媒体类型" field="media_id">
  8. <a-select v-model="searchForm.media_id" placeholder="请选择媒体类型" allow-clear allow-search>
  9. <a-option
  10. v-for="item in mediaOptions"
  11. :key="item.id"
  12. :value="item.id"
  13. :label="`${item.id}:${item.name}`" />
  14. </a-select>
  15. </a-form-item>
  16. </a-col>
  17. <a-col :sm="8" :xs="24">
  18. <a-form-item label="游戏" field="game_id">
  19. <game-select v-model="searchForm.game_id" multiple />
  20. </a-form-item>
  21. </a-col>
  22. </template>
  23. <!-- Table 自定义渲染 -->
  24. <template #letter="{ record }"> {{ record.game_id }}_{{ record.letter }} </template>
  25. </sa-table>
  26. <!-- 编辑表单 -->
  27. <edit-form ref="editRef" @success="refresh" />
  28. </div>
  29. </template>
  30. <script setup>
  31. import { onMounted, ref, reactive } from 'vue'
  32. import { Message } from '@arco-design/web-vue'
  33. import EditForm from './edit.vue'
  34. import advertCommonApi from '../../api/advert/common'
  35. import api from '../../api/advert/gamePackage'
  36. import GameSelect from '@/components/game-select/index.vue'
  37. // 引用定义
  38. const crudRef = ref()
  39. const editRef = ref()
  40. const mediaOptions = ref([])
  41. // 搜索表单
  42. const searchForm = ref({
  43. media_id: '',
  44. game_id: '',
  45. })
  46. // SaTable 基础配置
  47. const options = reactive({
  48. api: api.getPageList,
  49. add: {
  50. show: true,
  51. auth: ['/v1/gameLog/GamePackage/save'],
  52. func: async () => {
  53. editRef.value?.open()
  54. },
  55. },
  56. edit: {
  57. show: true,
  58. auth: ['/v1/gameLog/GamePackage/update'],
  59. func: async (record) => {
  60. editRef.value?.open('edit')
  61. editRef.value?.setFormData(record)
  62. },
  63. },
  64. delete: {
  65. show: false,
  66. auth: ['/v1/gameLog/GamePackage/destroy'],
  67. func: async (params) => {
  68. const resp = await api.destroy(params)
  69. if (resp.code === 200) {
  70. Message.success(`删除成功!`)
  71. crudRef.value?.refresh()
  72. }
  73. },
  74. },
  75. })
  76. // SaTable 列配置
  77. const columns = reactive([
  78. { title: 'ID', dataIndex: 'id', width: 80 },
  79. { title: '游戏ID', dataIndex: 'game_id', width: 80 },
  80. { title: '母包名称', dataIndex: 'name', width: 220 },
  81. { title: '打包目录', dataIndex: 'letter', width: 120 },
  82. { title: '包名', dataIndex: 'package_name', width: 180 },
  83. { title: 'APPID(头条)', dataIndex: 'tt_appid', width: 180 },
  84. { title: '账号ID(头条)', dataIndex: 'tt_advertiser_id', width: 180 },
  85. ])
  86. // 页面数据初始化
  87. const initPage = async () => {
  88. await getMediaOptions()
  89. }
  90. // 获取媒体列表
  91. const getMediaOptions = async () => {
  92. const resp = await advertCommonApi.getMediaOptionsApi()
  93. if (resp.code === 200) {
  94. mediaOptions.value = resp.data
  95. }
  96. }
  97. // SaTable 数据请求
  98. const refresh = async () => {
  99. crudRef.value?.refresh()
  100. }
  101. // 页面加载完成执行
  102. onMounted(async () => {
  103. initPage()
  104. refresh()
  105. })
  106. </script>