chongzhi.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <template>
  2. <basic-container>
  3. <avue-crud :option="option"
  4. :table-loading="loading"
  5. :data="data"
  6. :page.sync="page"
  7. ref="crud"
  8. @row-del="rowDel"
  9. v-model="form"
  10. @row-update="rowUpdate"
  11. @row-save="rowSave"
  12. :before-open="beforeOpen"
  13. @search-change="searchChange"
  14. @search-reset="searchReset"
  15. @selection-change="selectionChange"
  16. @current-change="currentChange"
  17. @size-change="sizeChange"
  18. @refresh-change="refreshChange"
  19. @on-load="onLoad">
  20. </avue-crud>
  21. </basic-container>
  22. </template>
  23. <script>
  24. import {getBussinessList as getList} from "@/api/billrecord/billrecord";
  25. import {mapGetters} from "vuex";
  26. export default {
  27. data() {
  28. return {
  29. form: {},
  30. query: {},
  31. loading: true,
  32. page: {
  33. pageSize: 10,
  34. currentPage: 1,
  35. total: 0
  36. },
  37. selectionList: [],
  38. option: {
  39. // showHeader:false,
  40. addBtn: false,
  41. menu: false,
  42. height: 'auto',
  43. calcHeight: 30,
  44. dialogWidth: 950,
  45. tip: false,
  46. searchShow: true,
  47. searchMenuSpan: 6,
  48. border: true,
  49. index: true,
  50. viewBtn: true,
  51. selection: true,
  52. dialogClickModal: false,
  53. column: [
  54. {
  55. label: "广告商",
  56. prop: "userId",
  57. type: "select",
  58. dicUrl: "/api/cyzh-guosen/bussiness/list?size=500",
  59. dicFormatter:(res)=>{
  60. return res.data.records;
  61. },
  62. props:{
  63. label: "name",
  64. value: "id"
  65. },
  66. search: true,
  67. },
  68. {
  69. label: "充值金额",
  70. prop: "price",
  71. },
  72. {
  73. label: "充值状态",
  74. prop: "payStatus",
  75. type: "select",
  76. search: true,
  77. dicData:[
  78. {
  79. label:"待付款",
  80. value:0
  81. },
  82. {
  83. label:"已付款",
  84. value: 1
  85. },
  86. {
  87. label:"已取消",
  88. value: 2
  89. },
  90. ]
  91. },
  92. {
  93. label: "时间",
  94. prop: "createTime",
  95. },
  96. ]
  97. },
  98. data: []
  99. };
  100. },
  101. computed: {
  102. ...mapGetters(["permission"]),
  103. permissionList() {
  104. return {
  105. };
  106. },
  107. ids() {
  108. let ids = [];
  109. this.selectionList.forEach(ele => {
  110. ids.push(ele.id);
  111. });
  112. return ids.join(",");
  113. }
  114. },
  115. methods: {
  116. rowSave(row, done, loading) {
  117. add(row).then(() => {
  118. this.onLoad(this.page);
  119. this.$message({
  120. type: "success",
  121. message: "操作成功!"
  122. });
  123. done();
  124. }, error => {
  125. window.console.log(error);
  126. loading();
  127. });
  128. },
  129. rowUpdate(row, index, done, loading) {
  130. update(row).then(() => {
  131. this.onLoad(this.page);
  132. this.$message({
  133. type: "success",
  134. message: "操作成功!"
  135. });
  136. done();
  137. }, error => {
  138. window.console.log(error);
  139. loading();
  140. });
  141. },
  142. rowDel(row) {
  143. this.$confirm("确定将选择数据删除?", {
  144. confirmButtonText: "确定",
  145. cancelButtonText: "取消",
  146. type: "warning"
  147. })
  148. .then(() => {
  149. return remove(row.id);
  150. })
  151. .then(() => {
  152. this.onLoad(this.page);
  153. this.$message({
  154. type: "success",
  155. message: "操作成功!"
  156. });
  157. });
  158. },
  159. searchReset() {
  160. this.query = {};
  161. this.onLoad(this.page);
  162. },
  163. searchChange(params, done) {
  164. this.query = params;
  165. this.page.currentPage = 1;
  166. this.onLoad(this.page, params);
  167. done();
  168. },
  169. selectionChange(list) {
  170. this.selectionList = list;
  171. },
  172. selectionClear() {
  173. this.selectionList = [];
  174. this.$refs.crud.toggleSelection();
  175. },
  176. handleDelete() {
  177. if (this.selectionList.length === 0) {
  178. this.$message.warning("请选择至少一条数据");
  179. return;
  180. }
  181. this.$confirm("确定将选择数据删除?", {
  182. confirmButtonText: "确定",
  183. cancelButtonText: "取消",
  184. type: "warning"
  185. })
  186. .then(() => {
  187. return remove(this.ids);
  188. })
  189. .then(() => {
  190. this.onLoad(this.page);
  191. this.$message({
  192. type: "success",
  193. message: "操作成功!"
  194. });
  195. this.$refs.crud.toggleSelection();
  196. });
  197. },
  198. beforeOpen(done, type) {
  199. if (["edit", "view"].includes(type)) {
  200. getNotice(this.form.id).then(res => {
  201. this.form = res.data.data;
  202. });
  203. }
  204. done();
  205. },
  206. currentChange(currentPage) {
  207. this.page.currentPage = currentPage;
  208. },
  209. sizeChange(pageSize) {
  210. this.page.pageSize = pageSize;
  211. },
  212. refreshChange() {
  213. this.onLoad(this.page, this.query);
  214. },
  215. onLoad(page, params = {}) {
  216. const {releaseTimeRange} = this.query;
  217. let values = {
  218. ...params,
  219. };
  220. if (releaseTimeRange) {
  221. values = {
  222. ...params,
  223. releaseTime_datege: releaseTimeRange[0],
  224. releaseTime_datelt: releaseTimeRange[1],
  225. ...this.query
  226. };
  227. values.releaseTimeRange = null;
  228. }
  229. this.loading = true;
  230. getList(page.currentPage, page.pageSize, values).then(res => {
  231. const data = res.data.data;
  232. this.page.total = data.total;
  233. this.data = data.records;
  234. this.loading = false;
  235. this.selectionClear();
  236. });
  237. }
  238. }
  239. };
  240. </script>
  241. <style>
  242. </style>