index.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <div id="index">
  3. <el-row>
  4. <el-col :span="24" class="index">
  5. <el-col :span="24" class="top">
  6. <topInfo :topTitle="pageTitle"></topInfo>
  7. </el-col>
  8. <el-col :span="24" class="add" style="text-align:right">
  9. <el-button size="mini" type="primary" @click="$router.push({ path: './detail' })" icon="el-icon-plus">添加用户</el-button>
  10. </el-col>
  11. </el-col>
  12. <el-col :span="24" class="info">
  13. <data-table :fields="fields" @delete="toDelete" :data="list" :opera="opera" @edit="toEdit" :total="total" @query="search"></data-table>
  14. </el-col>
  15. </el-row>
  16. </div>
  17. </template>
  18. <script>
  19. import topInfo from '@/layout/public/top.vue';
  20. import dataTable from '@/components/data-table.vue';
  21. import { mapActions, mapState, createNamespacedHelpers } from 'vuex';
  22. const { mapActions: users } = createNamespacedHelpers('users');
  23. const { mapActions: exportuser } = createNamespacedHelpers('exportuser');
  24. export default {
  25. name: 'index',
  26. props: {},
  27. components: {
  28. topInfo,
  29. dataTable,
  30. },
  31. data: () => ({
  32. opera: [
  33. {
  34. label: '审核',
  35. icon: 'el-icon-edit',
  36. method: 'edit',
  37. },
  38. {
  39. label: '删除',
  40. icon: 'el-icon-delete',
  41. method: 'delete',
  42. confirm: true,
  43. },
  44. ],
  45. fields: [
  46. { label: '姓名', prop: 'name', filter: 'input' },
  47. { label: '电话', prop: 'phone', filter: 'input' },
  48. { label: '用戶类型', prop: 'role', format: i => (i == '2' ? '个人用户' : i == '3' ? '企业用户' : i == '6' ? '专家' : '临时用户') },
  49. { label: '状态', prop: 'status', format: i => (i == '0' ? '待审核' : i == '1' ? '审核成功' : i == '2' ? '审核拒绝' : '待认证') },
  50. ],
  51. list: [],
  52. total: 0,
  53. }),
  54. created() {
  55. this.search();
  56. },
  57. methods: {
  58. ...users(['query', 'delete', 'update']),
  59. ...exportuser({ exportuserQuery: 'query' }),
  60. async search({ skip = 0, limit = 10, ...info } = {}) {
  61. const res = await this.query({ skip, limit, ...info });
  62. const resTwo = await this.exportuserQuery({ skip, limit, ...info });
  63. var newData = res.data.concat(resTwo.data);
  64. if (this.$checkRes(newData)) {
  65. this.$set(this, `list`, newData);
  66. this.$set(this, `total`, newData.length);
  67. }
  68. },
  69. toEdit({ data }) {
  70. this.$router.push({ path: './detail', query: { id: data.id, role: data.role } });
  71. },
  72. async toDelete({ data }) {
  73. const res = await this.delete(data.id);
  74. if (this.$checkRes(res, '删除成功', res.errmsg || '删除失败')) this.search();
  75. },
  76. },
  77. computed: {
  78. pageTitle() {
  79. return `${this.$route.meta.title}`;
  80. },
  81. },
  82. metaInfo() {
  83. return { title: this.$route.meta.title };
  84. },
  85. };
  86. </script>
  87. <style lang="less" scoped>
  88. .add {
  89. height: 40px;
  90. line-height: 40px;
  91. padding: 0 15px;
  92. }
  93. </style>