activityuv.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <template>
  2. <basic-container>
  3. <avue-crud :option="option"
  4. :table-loading="loading"
  5. :data="data"
  6. :page.sync="page"
  7. :permission="permissionList"
  8. :before-open="beforeOpen"
  9. v-model="form"
  10. ref="crud"
  11. @row-update="rowUpdate"
  12. @row-save="rowSave"
  13. @row-del="rowDel"
  14. @search-change="searchChange"
  15. @search-reset="searchReset"
  16. @selection-change="selectionChange"
  17. @current-change="currentChange"
  18. @size-change="sizeChange"
  19. @refresh-change="refreshChange"
  20. @on-load="onLoad">
  21. <template slot="menuLeft">
  22. <el-button type="danger"
  23. size="small"
  24. icon="el-icon-delete"
  25. plain
  26. v-if="permission.activityuv_delete"
  27. @click="handleDelete">删 除
  28. </el-button>
  29. </template>
  30. <template slot="userInfo" slot-scope="scope">
  31. <div style="display: flex;" v-if="scope.row.loginWebVO.id">
  32. <div style="display: flex;justify-content: center;align-items: center;">
  33. <el-avatar size="large" :src="scope.row.loginWebVO.avatar"></el-avatar>
  34. </div>
  35. <div style="padding: 10px;">
  36. <div >昵称:{{scope.row.loginWebVO.nickName}}</div>
  37. <div>手机:{{scope.row.loginWebVO.phone}}</div>
  38. </div>
  39. </div>
  40. <div style="display: flex;" v-else>
  41. <div style="display: flex;justify-content: center;align-items: center;">
  42. <el-avatar size="large" src="https://yyzs.nanyue6688.com/obsfile/0ad6d53ecf5448bfb9694fdaed27eadc-avatar.png"></el-avatar>
  43. </div>
  44. <div style="padding: 10px;">
  45. <div style="color: #DD6161;">用户已注销</div>
  46. </div>
  47. </div>
  48. </template>
  49. </avue-crud>
  50. </basic-container>
  51. </template>
  52. <script>
  53. import {getList, getDetail, add, update, remove} from "@/api/activityuv/activityuv";
  54. import {mapGetters} from "vuex";
  55. export default {
  56. props:{
  57. activityId:String
  58. },
  59. data() {
  60. return {
  61. form: {},
  62. query: {},
  63. loading: true,
  64. page: {
  65. pageSize: 10,
  66. currentPage: 1,
  67. total: 0
  68. },
  69. selectionList: [],
  70. option: {
  71. height:'auto',
  72. calcHeight: 30,
  73. tip: false,
  74. searchShow: true,
  75. searchMenuSpan: 6,
  76. border: true,
  77. index: true,
  78. viewBtn: true,
  79. selection: true,
  80. dialogClickModal: false,
  81. column: [
  82. {
  83. label: "用户id",
  84. hide:true,
  85. prop: "userId",
  86. rules: [{
  87. required: true,
  88. message: "请输入用户id",
  89. trigger: "blur"
  90. }]
  91. },
  92. {
  93. label:"用户信息",
  94. prop:"userInfo",
  95. slot:true
  96. },
  97. {
  98. label: "活动id",
  99. hide:true,
  100. prop: "activityId",
  101. rules: [{
  102. required: true,
  103. message: "请输入活动id",
  104. trigger: "blur"
  105. }]
  106. },
  107. ]
  108. },
  109. data: []
  110. };
  111. },
  112. computed: {
  113. ...mapGetters(["permission"]),
  114. permissionList() {
  115. return {
  116. addBtn: this.vaildData(this.permission.activityuv_add, false),
  117. viewBtn: this.vaildData(this.permission.activityuv_view, false),
  118. delBtn: this.vaildData(this.permission.activityuv_delete, false),
  119. editBtn: this.vaildData(this.permission.activityuv_edit, false)
  120. };
  121. },
  122. ids() {
  123. let ids = [];
  124. this.selectionList.forEach(ele => {
  125. ids.push(ele.id);
  126. });
  127. return ids.join(",");
  128. }
  129. },
  130. methods: {
  131. rowSave(row, done, loading) {
  132. add(row).then(() => {
  133. this.onLoad(this.page);
  134. this.$message({
  135. type: "success",
  136. message: "操作成功!"
  137. });
  138. done();
  139. }, error => {
  140. loading();
  141. window.console.log(error);
  142. });
  143. },
  144. rowUpdate(row, index, done, loading) {
  145. update(row).then(() => {
  146. this.onLoad(this.page);
  147. this.$message({
  148. type: "success",
  149. message: "操作成功!"
  150. });
  151. done();
  152. }, error => {
  153. loading();
  154. console.log(error);
  155. });
  156. },
  157. rowDel(row) {
  158. this.$confirm("确定将选择数据删除?", {
  159. confirmButtonText: "确定",
  160. cancelButtonText: "取消",
  161. type: "warning"
  162. })
  163. .then(() => {
  164. return remove(row.id);
  165. })
  166. .then(() => {
  167. this.onLoad(this.page);
  168. this.$message({
  169. type: "success",
  170. message: "操作成功!"
  171. });
  172. });
  173. },
  174. handleDelete() {
  175. if (this.selectionList.length === 0) {
  176. this.$message.warning("请选择至少一条数据");
  177. return;
  178. }
  179. this.$confirm("确定将选择数据删除?", {
  180. confirmButtonText: "确定",
  181. cancelButtonText: "取消",
  182. type: "warning"
  183. })
  184. .then(() => {
  185. return remove(this.ids);
  186. })
  187. .then(() => {
  188. this.onLoad(this.page);
  189. this.$message({
  190. type: "success",
  191. message: "操作成功!"
  192. });
  193. this.$refs.crud.toggleSelection();
  194. });
  195. },
  196. beforeOpen(done, type) {
  197. if (["edit", "view"].includes(type)) {
  198. getDetail(this.form.id).then(res => {
  199. this.form = res.data.data;
  200. });
  201. }
  202. done();
  203. },
  204. searchReset() {
  205. this.query = {};
  206. this.onLoad(this.page);
  207. },
  208. searchChange(params, done) {
  209. this.query = params;
  210. this.page.currentPage = 1;
  211. this.onLoad(this.page, params);
  212. done();
  213. },
  214. selectionChange(list) {
  215. this.selectionList = list;
  216. },
  217. selectionClear() {
  218. this.selectionList = [];
  219. this.$refs.crud.toggleSelection();
  220. },
  221. currentChange(currentPage){
  222. this.page.currentPage = currentPage;
  223. },
  224. sizeChange(pageSize){
  225. this.page.pageSize = pageSize;
  226. },
  227. refreshChange() {
  228. this.onLoad(this.page, this.query);
  229. },
  230. onLoad(page, params = {}) {
  231. this.loading = true;
  232. if (this.activityId) {
  233. this.query.activityId=this.activityId
  234. }
  235. getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
  236. const data = res.data.data;
  237. this.page.total = data.total;
  238. this.data = data.records;
  239. this.loading = false;
  240. this.selectionClear();
  241. });
  242. }
  243. }
  244. };
  245. </script>
  246. <style>
  247. </style>