dev_check.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <template>
  2. <section id="dev_check">
  3. <el-select v-model="selected" @change="changeSelect" placeholder="筛选">
  4. <el-option v-for="(item, index) of statuses" :key="index" :label="item.name" :value="item.id">
  5. <span>{{item.name}}</span>
  6. </el-option>
  7. </el-select>
  8. <section class="table">
  9. <el-table
  10. v-if="tableData.length"
  11. height="100%"
  12. border
  13. style="width: 100%"
  14. :data="tableData"
  15. :row-class-name="tableRowClassName"
  16. >
  17. <el-table-column
  18. v-for="(prop, index) of tableProps"
  19. :key="index"
  20. :prop="prop"
  21. :label="tableHeaders[index]"
  22. >
  23. <template slot-scope="scope">
  24. <el-button
  25. type="text"
  26. v-if="prop === 'uid'"
  27. @click="clickUID(scope.row)"
  28. >{{scope.row[prop]}}</el-button>
  29. <el-button
  30. type="text"
  31. v-else-if="prop === 'ctrl'"
  32. @click="clickCtrl(scope.row, index)"
  33. >查看详情</el-button>
  34. <img class="img" v-else-if="prop === 'img'" :src="scope.row.img" alt="img">
  35. <span v-else>{{scope.row[prop]}}</span>
  36. </template>
  37. </el-table-column>
  38. </el-table>
  39. <span v-else>暂无数据</span>
  40. </section>
  41. <el-pagination
  42. background
  43. @current-change="changePagination"
  44. @size-change="changePageSize"
  45. :current-page.sync="currentPage"
  46. :page-sizes="[10, 20, 30, 40]"
  47. :page-size="20"
  48. layout="total, sizes, prev, pager, next, jumper"
  49. :total="totalCount"
  50. ></el-pagination>
  51. </section>
  52. </template>
  53. <script>
  54. const tableHeaders = [
  55. "uid",
  56. "昵称",
  57. "职业方向",
  58. "类型",
  59. "申请时间",
  60. "审核时间",
  61. "申请状态",
  62. "详情",
  63. ]
  64. const tableProps = [
  65. "uid",
  66. "nickname",
  67. "occupation_name",
  68. "name",
  69. "create_date",
  70. "chk_date",
  71. "status_name",
  72. "ctrl",
  73. ]
  74. let env = 'test'
  75. export default {
  76. data() {
  77. return {
  78. // 筛选状态
  79. statuses: [],
  80. selected: "",
  81. // 数据总条目
  82. totalCount: 0,
  83. currentPage: 1,
  84. currentPageSize: 20,
  85. certID: '',
  86. // 列表头显示内容
  87. tableHeaders,
  88. // 列表头字段
  89. tableProps,
  90. // 列表数据
  91. tableData: []
  92. }
  93. },
  94. watch: {
  95. '$route'(to, from) {
  96. this.handleRouteParams()
  97. }
  98. },
  99. mounted() {
  100. // console.log(this.currentPage)
  101. this.getFilters()
  102. },
  103. methods: {
  104. // 页码变动
  105. changePagination(page) {
  106. // console.log(this.certID, page)
  107. this.$router.replace({
  108. // path: `/main/dev_check`,
  109. query: { page, cert_id: this.certID }
  110. })
  111. },
  112. changePageSize(pageSize) {
  113. this.currentPageSize = pageSize
  114. },
  115. // 筛选框变动
  116. changeSelect(id) {
  117. this.certID = id
  118. this.$router.replace({
  119. // path: `/main/dev_check`,
  120. query: { page: this.currentPage, cert_id: id }
  121. })
  122. },
  123. // 获取筛选
  124. async getFilters() {
  125. const res = await this.$post("/api/admin/cert/getEnum")
  126. const data = res.data
  127. data.cert_type_list.unshift({
  128. id: 0,
  129. name: '全部'
  130. })
  131. this.statuses = data.cert_type_list || []
  132. this.selected = this.statuses[0].name
  133. this.handleRouteParams()
  134. },
  135. /**
  136. * 路由钩子触发获取路由携带query, 首次进入也算一次
  137. */
  138. handleRouteParams() {
  139. this.currentPage = Number(this.$route.query.page)
  140. this.certID = this.$route.query.cert_id
  141. for (var i=0; i< this.statuses.length; i++){
  142. if (this.certID == this.statuses[i].id) {
  143. this.selected = this.statuses[i].name
  144. }
  145. }
  146. this.getTableData()
  147. },
  148. clickCtrl(item, index) {
  149. this.$router.push({
  150. path: '/main/dev_check_detail',
  151. query: {
  152. uid: item.uid,
  153. cert_id: item.cert_id
  154. }
  155. })
  156. },
  157. // 点击用户的 uid
  158. clickUID(item) {
  159. window.open(`https://www.proginn.com/rooter/user/${item.uid}`)
  160. },
  161. // 根据状态显示图表样式
  162. tableRowClassName({ row, rowIndex }) {
  163. let className = ""
  164. if(row.status === "1") className = "success-row"
  165. return className
  166. },
  167. // 格式化列表数据
  168. formatTableData(data) {
  169. return data.map(i => ({
  170. ...i,
  171. statusShow: i.status === "1" ? "到账" : "失败",
  172. created_atShow: new Date(Number(i.created_at) * 1000).toLocaleString(),
  173. taken_atShow: new Date(Number(i.taken_at) * 1000).toLocaleString(),
  174. ctrl: 1
  175. }))
  176. },
  177. // 获取列表数据
  178. async getTableData() {
  179. this.tableData = []
  180. let page = this.currentPage
  181. let page_size = this.currentPageSize
  182. let cert_id = Number(this.certID)
  183. let body = { page, page_size, cert_id }
  184. let res = await this.$post("/api/admin/audit/getList", body)
  185. let data = res.data
  186. env = data.current_env
  187. this.tableData = this.formatTableData(res.data.list)
  188. this.totalCount = Number(data.total)
  189. this.totalPage = data.totalPage
  190. }
  191. }
  192. };
  193. </script>
  194. <style scoped>
  195. .table {
  196. height: calc(100% - 80px);
  197. }
  198. .img {
  199. width: 100%;
  200. height: auto;
  201. }
  202. </style>