index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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="结算日期" field="tdate">
  13. <a-range-picker
  14. v-model="searchForm.tdate"
  15. :show-time="false"
  16. mode="date"
  17. />
  18. </a-form-item>
  19. </a-col>
  20. <a-col :sm="8" :xs="24">
  21. <a-form-item label="投放游戏" field="game_id">
  22. <a-select
  23. v-model="searchForm.game_id"
  24. placeholder="请选择投放游戏"
  25. allow-clear
  26. allow-search
  27. >
  28. <a-option
  29. v-for="item in gameOptions"
  30. :key="item.id"
  31. :value="item.id"
  32. :label="`${item.id}:${item.name}`"
  33. />
  34. </a-select>
  35. </a-form-item>
  36. </a-col>
  37. <a-col :sm="8" :xs="24">
  38. <a-form-item label="媒体类型" field="media_id">
  39. <a-select
  40. v-model="searchForm.media_id"
  41. placeholder="请选择媒体类型"
  42. allow-clear
  43. allow-search
  44. >
  45. <a-option
  46. v-for="item in mediaOptions"
  47. :key="item.id"
  48. :value="item.id"
  49. :label="`${item.id}:${item.name}`"
  50. />
  51. </a-select>
  52. </a-form-item>
  53. </a-col>
  54. <a-col :sm="8" :xs="24">
  55. <a-form-item label="渠道ID" field="agent_id">
  56. <a-input
  57. v-model="searchForm.agent_id"
  58. placeholder="请输入渠道ID"
  59. allow-clear
  60. />
  61. </a-form-item>
  62. </a-col>
  63. <a-col :sm="8" :xs="24">
  64. <a-form-item label="广告位ID" field="site_id">
  65. <a-input
  66. v-model="searchForm.site_id"
  67. placeholder="请输入广告位ID"
  68. allow-clear
  69. />
  70. </a-form-item>
  71. </a-col>
  72. <a-col :sm="8" :xs="24">
  73. <a-form-item label="负责人" field="auth_id">
  74. <sa-select
  75. v-model="searchForm.auth_id"
  76. :options="authOptions"
  77. placeholder="请选择负责人"
  78. allow-clear
  79. />
  80. </a-form-item>
  81. </a-col>
  82. <a-col :sm="8" :xs="24">
  83. <a-form-item label="录入方式" field="add_type">
  84. <sa-select
  85. v-model="searchForm.add_type"
  86. dict="add_type"
  87. placeholder="请选择录入方式"
  88. allow-clear
  89. />
  90. </a-form-item>
  91. </a-col>
  92. <a-col :sm="8" :xs="24">
  93. <a-form-item label="备注" field="memo">
  94. <a-input
  95. v-model="searchForm.memo"
  96. placeholder="请输入备注"
  97. allow-clear
  98. />
  99. </a-form-item>
  100. </a-col>
  101. <a-col :sm="8" :xs="24">
  102. <a-form-item label="录入时间" field="create_time">
  103. <a-range-picker
  104. v-model="searchForm.create_time"
  105. :show-time="true"
  106. mode="date"
  107. />
  108. </a-form-item>
  109. </a-col>
  110. </template>
  111. <!-- Table 自定义渲染 -->
  112. </sa-table>
  113. <!-- 编辑表单 -->
  114. <edit-form ref="editRef" @success="refresh" />
  115. </div>
  116. </template>
  117. <script setup>
  118. import { onMounted, ref, reactive } from "vue";
  119. import { Message } from "@arco-design/web-vue";
  120. import EditForm from "./edit.vue";
  121. import api from "../../api/advert/mediaCost";
  122. import commonAdvertApi from "../../api/advert/common";
  123. import commonCenterApi from "../../api/center/common";
  124. // 引用定义
  125. const crudRef = ref();
  126. const editRef = ref();
  127. const viewRef = ref();
  128. const mediaOptions = ref([]);
  129. const gameOptions = ref([]);
  130. const authOptions = ref([]);
  131. // 搜索表单
  132. const searchForm = ref({
  133. tdate: [],
  134. game_id: "",
  135. media_id: "",
  136. agent_id: "",
  137. site_id: "",
  138. auth_id: "",
  139. add_type: "",
  140. memo: "",
  141. create_time: [],
  142. });
  143. // SaTable 基础配置
  144. const options = reactive({
  145. api: api.getPageList,
  146. rowSelection: { showCheckedAll: true },
  147. add: {
  148. show: true,
  149. auth: ["/v1/advert/MediaCost/save"],
  150. func: async () => {
  151. editRef.value?.open();
  152. },
  153. },
  154. edit: {
  155. show: true,
  156. auth: ["/v1/advert/MediaCost/update"],
  157. func: async (record) => {
  158. editRef.value?.open("edit");
  159. editRef.value?.setFormData(record);
  160. },
  161. },
  162. delete: {
  163. show: true,
  164. auth: ["/v1/advert/MediaCost/destroy"],
  165. func: async (params) => {
  166. const resp = await api.destroy(params);
  167. if (resp.code === 200) {
  168. Message.success(`删除成功!`);
  169. crudRef.value?.refresh();
  170. }
  171. },
  172. },
  173. });
  174. // SaTable 列配置
  175. const columns = reactive([
  176. { title: "结算日期", dataIndex: "tdate", width: 120 },
  177. { title: "广告位ID", dataIndex: "site_id", width: 120 },
  178. { title: "广告位名称", dataIndex: "site_name", width: 120 },
  179. { title: "渠道ID", dataIndex: "agent_id", width: 120 },
  180. { title: "游戏", dataIndex: "game_name", width: 120 },
  181. { title: "原始金额", dataIndex: "ori_money", width: 120 },
  182. { title: "结算金额", dataIndex: "money", width: 120 },
  183. { title: "录入时间", dataIndex: "create_time", width: 120 },
  184. {
  185. title: "录入方式",
  186. dataIndex: "add_type",
  187. type: "dict",
  188. dict: "add_type",
  189. width: 120,
  190. },
  191. { title: "备注", dataIndex: "memo", width: 120 },
  192. { title: "负责人", dataIndex: "auth_name", width: 120 },
  193. ]);
  194. // 页面数据初始化
  195. const initPage = async () => {
  196. await getMediaOptions();
  197. await getGameOptions();
  198. await getAuthOptions();
  199. };
  200. // 获取媒体类型
  201. const getMediaOptions = async () => {
  202. const resp = await commonAdvertApi.getAgentOptionsApi();
  203. if (resp.code === 200) {
  204. mediaOptions.value = resp.data;
  205. }
  206. };
  207. // 获取负责人
  208. const getAuthOptions = async () => {
  209. const resp = await commonAdvertApi.getAuthOptionsApi();
  210. if (resp.code === 200) {
  211. authOptions.value = resp.data;
  212. }
  213. };
  214. // 获取投放游戏
  215. const getGameOptions = async () => {
  216. const resp = await commonCenterApi.getGameOptionsApi();
  217. if (resp.code === 200) {
  218. gameOptions.value = resp.data;
  219. }
  220. };
  221. // SaTable 数据请求
  222. const refresh = async () => {
  223. crudRef.value?.refresh();
  224. };
  225. // 页面加载完成执行
  226. onMounted(async () => {
  227. initPage();
  228. refresh();
  229. });
  230. </script>