register-data.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template>
  2. <div class="page-wrap page-wrap-put-books">
  3. <div class="table-filter">
  4. <div class="item-right">
  5. <a-radio-group v-model:value="selectValue" @change="onChange">
  6. <a-radio-button value="paid">
  7. 付费
  8. </a-radio-button>
  9. <a-radio-button value="unpaid">
  10. 未付费
  11. </a-radio-button>
  12. <a-radio-button value="all">
  13. 显示全部
  14. </a-radio-button>
  15. </a-radio-group>
  16. </div>
  17. </div>
  18. <a-table
  19. :columns="columns"
  20. :data-source="list"
  21. rowKey="id"
  22. bordered
  23. :pagination="tablePageOptions"
  24. :loading="loading.value"
  25. @change="handleTableChange"
  26. :scroll="{ x: true,y:true }"
  27. >
  28. <template #report_register_num="{ text, record }">
  29. <p v-if="record.report_register_num >= 1">
  30. 已上报
  31. </p>
  32. <a-popconfirm
  33. title="是否要继续强制回传?"
  34. ok-text="是"
  35. cancel-text="否"
  36. @confirm="confirmEdit"
  37. >
  38. <p
  39. @click="mustUp(record, 'register', 'report_register_num')"
  40. v-if="record.report_register_num <= 0"
  41. >
  42. <a>强制回传</a>
  43. </p>
  44. </a-popconfirm>
  45. </template>
  46. <template #report_recharge_num="{ text, record }">
  47. <p v-if="record.report_recharge_num >= 1">
  48. 已上报
  49. </p>
  50. <a-popconfirm
  51. title="是否要继续强制回传?"
  52. ok-text="是"
  53. cancel-text="否"
  54. @confirm="confirmEdit"
  55. >
  56. <p
  57. @click="mustUp(record, 'recharge', 'report_recharge_num')"
  58. v-if="record.report_recharge_num <= 0"
  59. >
  60. <a>强制回传</a>
  61. </p>
  62. </a-popconfirm>
  63. </template>
  64. </a-table>
  65. </div>
  66. </template>
  67. <script lang="ts">
  68. import { defineComponent, reactive, toRefs, ref, watchEffect } from "vue";
  69. import { MatchList } from "../_pageOptions/table-put";
  70. import { getRegisterData, setMustUpback } from "@/api";
  71. import usePagination from "@/hooks/usePagination";
  72. import { RegisterData, PageOptions } from "#/api";
  73. import useApp from "@/hooks/useApp";
  74. const RegisterDatad = defineComponent({
  75. props: {
  76. ad_lid: Number,
  77. back_platform: String,
  78. },
  79. setup(props) {
  80. const { router } = useApp();
  81. let { loading, meta, tablePageOptions } = usePagination();
  82. const state = reactive({
  83. list: ref<RegisterData[]>([]),
  84. columns: MatchList,
  85. loading,
  86. tablePageOptions,
  87. tableIndex: 0,
  88. filterList:[],
  89. selectValue: "all",
  90. selectValueAll: 1,
  91. selectValuePaid: 1,
  92. form: {
  93. report_type: "",
  94. uid: 0,
  95. platform: "",
  96. val: "",
  97. },
  98. });
  99. const getData = (
  100. ad_lid = props.ad_lid,
  101. back_platform = props.back_platform,
  102. page = 1,
  103. is_paid = 0,
  104. show_all = 1
  105. ) => {
  106. getRegisterData({
  107. ad_lid,
  108. back_platform,
  109. page,
  110. is_paid,
  111. show_all,
  112. }).then((res:any) => {
  113. state.list = res.data.list;
  114. meta.value = res.data.meta;
  115. let nCloumn = MatchList.filter(r=>{
  116. return !res.data.hiddenFields.includes(r.dataIndex);
  117. })
  118. state.columns = nCloumn;
  119. });
  120. };
  121. watchEffect(() => {
  122. getData(
  123. props.ad_lid,
  124. props.back_platform,
  125. 1,
  126. state.selectValuePaid,
  127. state.selectValueAll
  128. );
  129. });
  130. const onChange = (e: any) => {
  131. if (e.target.value == "all") {
  132. state.selectValueAll = 1;
  133. } else {
  134. state.selectValueAll = 0;
  135. if (e.target.value == "paid") {
  136. state.selectValuePaid = 1;
  137. } else {
  138. state.selectValuePaid = 0;
  139. }
  140. }
  141. };
  142. const handleTableChange = (pagination: PageOptions) => {
  143. const { current, pageSize, total } = pagination;
  144. meta.value.current_page = current;
  145. getRegisterData({
  146. ad_lid: props.ad_lid,
  147. back_platform: props.back_platform,
  148. is_paid: state.selectValuePaid,
  149. show_all: state.selectValueAll,
  150. page: current,
  151. }).then((res) => {
  152. state.list = res.data.list;
  153. meta.value = res.data.meta;
  154. });
  155. };
  156. return { ...toRefs(state), handleTableChange, meta, onChange };
  157. },
  158. methods: {
  159. confirmEdit() {
  160. setMustUpback(this.form).then((res) => {
  161. this.$message.success("修改成功!");
  162. let list = this.list.map((d: any, i: number) => {
  163. if (i == this.tableIndex) {
  164. d[this.form.val] = 1;
  165. }
  166. return d;
  167. });
  168. this.list = list;
  169. });
  170. },
  171. mustUp(record: any, type: string, val: string) {
  172. let { uid, platform } = record;
  173. console.log(uid);
  174. this.form.uid = uid;
  175. this.form.platform = platform;
  176. this.form.val = val;
  177. this.form.report_type = type;
  178. this.tableIndex = this.list.findIndex((r: any) => r.uid == uid);
  179. },
  180. },
  181. });
  182. export default RegisterDatad;
  183. </script>
  184. <style lang="scss" scoped>
  185. .table-p {
  186. max-width: 500px;
  187. white-space: normal;
  188. word-break: break-all;
  189. line-height: 200%;
  190. }
  191. .item-right {
  192. margin-right: 10px;
  193. }
  194. .hover-content {
  195. margin: 8px 0 5px;
  196. display: flex;
  197. align-items: center;
  198. .label {
  199. padding-right: 15px;
  200. display: inline-block;
  201. max-width: 72px;
  202. width: 72px;
  203. }
  204. .ant-switch {
  205. width: 50px;
  206. }
  207. }
  208. .footer-slot {
  209. margin-top: 10px;
  210. button {
  211. margin-right: 10px;
  212. }
  213. }
  214. </style>