dev_check.vue 5.7 KB

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