index.vue 3.7 KB

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