index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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 :span="8">
  12. <a-form-item label="游戏" name="game_id">
  13. <a-tree-select
  14. v-model="searchForm.game_id"
  15. :data="gameListTree"
  16. tree-checked-strategy="child"
  17. :tree-checkable="false"
  18. :max-tag-count="2"
  19. :fieldNames="{ title: 'name', key: 'id' }"
  20. allow-search
  21. allow-clear
  22. placeholder="请选择游戏"
  23. >
  24. </a-tree-select>
  25. </a-form-item>
  26. </a-col>
  27. </template>
  28. <!-- Table 自定义渲染 -->
  29. <template #game_id="{ record }">
  30. {{ record.game_id }}:{{ record.game_name }}
  31. </template>
  32. </sa-table>
  33. <!-- 编辑表单 -->
  34. <edit-form ref="editRef" @success="refresh" />
  35. </div>
  36. </template>
  37. <script setup>
  38. import { onMounted, ref, reactive } from "vue";
  39. import { Message } from "@arco-design/web-vue";
  40. import EditForm from "./edit.vue";
  41. import api from "../../api/center/iosPayWay";
  42. import commonApi from "../../api/common";
  43. // 引用定义
  44. const crudRef = ref();
  45. const editRef = ref();
  46. const viewRef = ref();
  47. const gameListTree = ref([]);
  48. // 搜索表单
  49. const searchForm = ref({
  50. game_id: "",
  51. });
  52. // SaTable 基础配置
  53. const options = reactive({
  54. api: api.getPageList,
  55. rowSelection: { showCheckedAll: true },
  56. add: {
  57. show: true,
  58. auth: ["/v1/center/IosPayWay/save"],
  59. func: async () => {
  60. editRef.value?.open();
  61. },
  62. },
  63. edit: {
  64. show: true,
  65. auth: ["/v1/center/IosPayWay/update"],
  66. func: async (record) => {
  67. editRef.value?.open("edit");
  68. editRef.value?.setFormData(record);
  69. },
  70. },
  71. delete: {
  72. show: true,
  73. auth: ["/v1/center/IosPayWay/destroy"],
  74. func: async (params) => {
  75. const resp = await api.destroy(params);
  76. if (resp.code === 200) {
  77. Message.success(`删除成功!`);
  78. crudRef.value?.refresh();
  79. }
  80. },
  81. },
  82. });
  83. // SaTable 列配置
  84. const columns = reactive([
  85. { title: "游戏", dataIndex: "game_id", width: 180 },
  86. { title: "开启时间", dataIndex: "pay_stime", width: 180 },
  87. { title: "结束时间", dataIndex: "pay_etime", width: 180 },
  88. { title: "充值金额", dataIndex: "pay_money", width: 180 },
  89. { title: "充值次数", dataIndex: "pay_num", width: 180 },
  90. { title: "注册天数", dataIndex: "reg_day", width: 180 },
  91. { title: "屏蔽地区", dataIndex: "city", width: 180 },
  92. {
  93. title: "充值渠道开关",
  94. dataIndex: "pay_way",
  95. type: "dict",
  96. dict: "ios_pay_way",
  97. width: 120,
  98. },
  99. ]);
  100. // 页面数据初始化
  101. const initPage = async () => {
  102. await getGameListTree();
  103. };
  104. // SaTable 数据请求
  105. const refresh = async () => {
  106. crudRef.value?.refresh();
  107. };
  108. // 获取游戏列表树形
  109. const getGameListTree = async () => {
  110. const resp = await commonApi.getGameListTreeNoAuthApi({
  111. single: true,
  112. });
  113. if (resp.code === 200) {
  114. gameListTree.value = resp.data;
  115. }
  116. };
  117. // 页面加载完成执行
  118. onMounted(async () => {
  119. initPage();
  120. refresh();
  121. });
  122. </script>