index.vue 6.3 KB

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