index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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="6" :xs="24">
  7. <a-form-item label="主包" field="main_id">
  8. <a-select v-model="searchForm.main_id" :options="mainGameOptions" placeholder="请选择主包" allow-clear />
  9. </a-form-item>
  10. </a-col>
  11. <a-col :sm="6" :xs="24">
  12. <a-form-item label="游戏名称" field="name">
  13. <a-input v-model="searchForm.name" placeholder="请输入游戏名称" allow-clear />
  14. </a-form-item>
  15. </a-col>
  16. <a-col :sm="6" :xs="24">
  17. <a-form-item label="平台" field="os">
  18. <sa-select v-model="searchForm.os" dict="os" placeholder="请选择平台" allow-clear />
  19. </a-form-item>
  20. </a-col>
  21. <a-col :sm="6" :xs="24">
  22. <a-form-item label="状态" field="status">
  23. <sa-select v-model="searchForm.status" dict="data_status" placeholder="请选择状态" />
  24. </a-form-item>
  25. </a-col>
  26. </template>
  27. <!-- Table 自定义渲染 -->
  28. <template #status="{ record }">
  29. <a-tag :color="record.status === 1 ? 'green' : 'red'">
  30. {{ record.status === 1 ? '正常' : '停用' }}
  31. </a-tag>
  32. </template>
  33. <template #operationBeforeExtend="{ record }">
  34. <a-button type="text" @click="checkCpInfo(record)"><icon-thunderbolt /> cp对接信息</a-button>
  35. </template>
  36. </sa-table>
  37. <!-- 编辑表单 -->
  38. <edit-form ref="editRef" @success="refresh" />
  39. <!-- 查看CP对接信息 -->
  40. <cp-info ref="cpInfoRef" @success="refresh" />
  41. </div>
  42. </template>
  43. <script setup>
  44. import { onMounted, ref, reactive } from 'vue'
  45. import { Message } from '@arco-design/web-vue'
  46. import EditForm from './edit.vue'
  47. import CpInfo from './cp-info.vue'
  48. import api from '../../api/center/game'
  49. import apiCommon from '../../api/center/common'
  50. // 引用定义
  51. const crudRef = ref()
  52. const editRef = ref()
  53. const cpInfoRef = ref()
  54. const mainGameOptions = ref([])
  55. // 搜索表单
  56. const searchForm = ref({
  57. id: '',
  58. main_id: '',
  59. name: '',
  60. os: '',
  61. status: 1,
  62. })
  63. // SaTable 基础配置
  64. const options = reactive({
  65. api: api.getPageList,
  66. operationColumnWidth: 280,
  67. add: {
  68. show: true,
  69. auth: ['/v1/center/Game/save'],
  70. func: async () => {
  71. editRef.value?.open()
  72. },
  73. },
  74. edit: {
  75. show: true,
  76. auth: ['/v1/center/Game/update'],
  77. func: async (record) => {
  78. console.log(record)
  79. editRef.value?.open('edit')
  80. editRef.value?.setFormData(record)
  81. },
  82. },
  83. delete: {
  84. show: false,
  85. auth: ['/v1/center/Game/destroy'],
  86. func: async (params) => {
  87. const resp = await api.destroy(params)
  88. if (resp.code === 200) {
  89. Message.success(`删除成功!`)
  90. crudRef.value?.refresh()
  91. }
  92. },
  93. },
  94. })
  95. // SaTable 列配置
  96. const columns = reactive([
  97. { title: '游戏ID', dataIndex: 'id', width: 60 },
  98. { title: '游戏名称', dataIndex: 'name', width: 130 },
  99. // { title: "产品归属", dataIndex: "main_game_name", width: 130 },
  100. { title: '包名', dataIndex: 'package_name', width: 130 },
  101. {
  102. title: '平台',
  103. dataIndex: 'os',
  104. type: 'dict',
  105. dict: 'os',
  106. width: 120,
  107. },
  108. { title: '状态', dataIndex: 'status', width: 80 },
  109. {
  110. title: '实名',
  111. dataIndex: 'realname_switch',
  112. width: 80,
  113. type: 'dict',
  114. dict: 'realname_switch',
  115. },
  116. { title: '充值回调地址', dataIndex: 'cp_callback_url', width: 180 },
  117. { title: '分成比例', dataIndex: 'divide', width: 120 },
  118. // { title: "创建时间", dataIndex: "create_time", width: 180 },
  119. { title: '修改时间', dataIndex: 'update_time', width: 180 },
  120. ])
  121. // 页面数据初始化
  122. const initPage = async () => {
  123. await getMainGameOptions()
  124. }
  125. // 获取主包下拉数据
  126. const getMainGameOptions = async () => {
  127. const { code, data } = await apiCommon.getMainGameOptionsApi()
  128. if (code === 200) {
  129. mainGameOptions.value = data
  130. }
  131. }
  132. // SaTable 数据请求
  133. const refresh = async () => {
  134. crudRef.value?.refresh()
  135. }
  136. // 查看CP对接信息
  137. const checkCpInfo = async (record) => {
  138. let { appkey, login_key, pay_key, name, id, os } = record
  139. let cp_info = {
  140. name: name,
  141. game_id: id,
  142. appkey: appkey,
  143. login_key: login_key,
  144. pay_key: pay_key,
  145. os: os,
  146. channel_h5_url: `https://pf.game.com/game/login?appid=${id}`,
  147. }
  148. cpInfoRef.value?.open()
  149. cpInfoRef.value?.setFormData(cp_info)
  150. }
  151. // 页面加载完成执行
  152. onMounted(async () => {
  153. initPage()
  154. refresh()
  155. })
  156. </script>
  157. <script>
  158. export default { name: 'v1/center/game' }
  159. </script>