dev_check.vue 6.9 KB

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