cancel_account.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <template>
  2. <section id="dev_check">
  3. <el-select v-model="value" @change="changeSelect" placeholder="请选择">
  4. <el-option
  5. v-for="item in options"
  6. :key="item.value"
  7. :label="item.label"
  8. :value="item.value">
  9. </el-option>
  10. </el-select>
  11. <section class="table">
  12. <el-table
  13. :data="tableData"
  14. style="width: 100%">
  15. <el-table-column
  16. prop="uid"
  17. label="用户uid"
  18. >
  19. <template slot-scope="scope">
  20. <el-button
  21. type="text"
  22. @click="clickUID(scope.row)"
  23. >{{scope.row.uid}}</el-button>
  24. </template>
  25. </el-table-column>
  26. <el-table-column
  27. prop="create_time"
  28. label="申请时间" :formatter="dateFormatStart">
  29. </el-table-column>
  30. <el-table-column
  31. label="来源" :formatter="dateFormatStart">
  32. <template slot-scope="scope">
  33. <span v-if="scope.row.source_type">
  34. <el-tooltip class="item" effect="dark" :content="scope.row.version" placement="top">
  35. <el-link type="primary">{{scope.row['source_type'] || '--'}}</el-link>
  36. </el-tooltip>
  37. </span>
  38. <span v-else>--</span>
  39. </template>
  40. </el-table-column>
  41. <el-table-column
  42. prop="update_time"
  43. label="注销时间" :formatter="dateFormat">
  44. </el-table-column>
  45. <el-table-column
  46. prop="reason"
  47. label="注销理由">
  48. </el-table-column>
  49. <el-table-column
  50. prop="status"
  51. label="当前状态">
  52. <template slot-scope="scope">
  53. <template v-if="scope.row['status'] == 1">
  54. <p>待注销</p>
  55. </template>
  56. <template v-else>
  57. <p>已注销</p>
  58. </template>
  59. </template>
  60. </el-table-column>
  61. <el-table-column
  62. prop="nickname"
  63. label="操作人">
  64. </el-table-column>
  65. <el-table-column
  66. label="操作">
  67. <template slot-scope="scope">
  68. <template v-if="scope.row['status'] == 1">
  69. <el-button
  70. type="text"
  71. @click="cancelAccount(scope.row)"
  72. >确认注销</el-button>
  73. <el-button
  74. type="text"
  75. @click="refuseCancelAccount(scope.row)"
  76. >拒绝注销</el-button>
  77. </template>
  78. </template>
  79. </el-table-column>
  80. </el-table>
  81. </section>
  82. <el-pagination
  83. background
  84. @current-change="changePagination"
  85. @size-change="changePageSize"
  86. :current-page.sync="currentPage"
  87. :page-sizes="[10, 20, 30, 40]"
  88. :page-size="20"
  89. layout="total, sizes, prev, pager, next, jumper"
  90. :total="totalCount"
  91. ></el-pagination>
  92. </section>
  93. </template>
  94. <script>
  95. export default {
  96. data() {
  97. return {
  98. // 列表数据
  99. tableData: [],
  100. options: [{
  101. value: '0',
  102. label: '已注销'
  103. }, {
  104. value: '1',
  105. label: '待注销'
  106. }],
  107. value: '1',
  108. totalCount: 0,
  109. currentPage: 1,
  110. currentPageSize: 10,
  111. };
  112. },
  113. watch: {
  114. $route(to, from) {
  115. this.handleRouteParams();
  116. }
  117. },
  118. created: function () {
  119. this.getTableData();
  120. },
  121. methods: {
  122. // 点击用户的 uid
  123. clickUID(item) {
  124. if(Number(item.status) > 0){
  125. window.open(
  126. this.$store.state.domainConfig.siteUrl + `/rooter/user/${item.uid}`
  127. );
  128. }else{
  129. window.open(
  130. this.$store.state.domainConfig.siteUrl + `/rooter/canceluser/${item.uid}`
  131. );
  132. }
  133. },
  134. // 页码变动
  135. changePagination(page) {
  136. this.$router.replace({
  137. path: `/main/cancel_account`,
  138. query: { page, value: this.value }
  139. });
  140. },
  141. // 切换当页显示条数
  142. changePageSize(pageSize) {
  143. this.currentPageSize = pageSize;
  144. },
  145. // 筛选框变动
  146. changeSelect() {
  147. this.$router.replace({
  148. path: `/main/cancel_account`,
  149. query: { page: this.currentPage, value: this.value}
  150. });
  151. },
  152. dateFormatStart:function(item){
  153. let d = new Date(Number(item.create_time) * 1000);
  154. return d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate() + ' ' + d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds();
  155. },
  156. dateFormat:function(item){
  157. if(item.update_time > 0){
  158. let d = new Date(Number(item.update_time) * 1000);
  159. return d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate() + ' ' + d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds();
  160. }
  161. },
  162. /**
  163. * 路由钩子触发获取路由携带query, 首次进入也算一次
  164. */
  165. handleRouteParams() {
  166. this.currentPage = Number(this.$route.query.page);
  167. this.value = this.$route.query.value;
  168. this.getTableData();
  169. },
  170. // 获取列表数据
  171. async getTableData() {
  172. this.tableData = [];
  173. let page = this.currentPage;
  174. let limit = this.currentPageSize;
  175. let status = this.value;
  176. let body = { page, limit, status};
  177. let res = await this.$post("/api/admin/cancelAccount/findWaitCancelAccount", body);
  178. let data = res.data;
  179. this.tableData = res.data.list;
  180. this.totalCount = Number(data.count);
  181. this.currentPage = data.page;
  182. },
  183. // 确认注销账号
  184. async cancelAccount(item) {
  185. let uid = item.uid
  186. let body = {uid: uid}
  187. let res = await this.$post("/api/admin/cancelAccount/cancelAccount", body);
  188. if (res.status > 0)
  189. this.$message({
  190. message: res.info,
  191. type: "success"
  192. });
  193. this.getTableData();
  194. },
  195. // 拒绝注销账号
  196. async refuseCancelAccount(item) {
  197. let uid = item.uid
  198. let body = {uid: uid}
  199. let res = await this.$post("/api/admin/cancelAccount/refuseCancelAccount", body);
  200. if (res.status > 0)
  201. this.$message({
  202. message: res.info,
  203. type: "success"
  204. });
  205. this.getTableData();
  206. }
  207. }
  208. };
  209. </script>
  210. <style scoped>
  211. .table {
  212. height: calc(100% - 60px);
  213. }
  214. .img {
  215. width: 100%;
  216. height: auto;
  217. }
  218. </style>