index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <template>
  2. <div class="user-manage">
  3. <div class="user-manage-list">
  4. <div class="btn-box">
  5. <el-button class="add-btn" type="primary" size="small" icon="el-icon-plus" @click="updateOrg('')"
  6. >添加用户</el-button
  7. >
  8. <el-button class="add-btn" type="primary" size="small" @click="updateOrg('')">批量导入用户</el-button>
  9. </div>
  10. <el-table :data="list">
  11. <el-table-column
  12. type="index"
  13. label="序号"
  14. width="60"
  15. align="center"
  16. :index="(cur_page - 1) * page_capacity + 1"
  17. />
  18. <el-table-column prop="user_name" label="真实姓名" align="center" />
  19. <el-table-column prop="real_name" label="用户名" align="center" />
  20. <el-table-column prop="email" label="邮箱" align="center" width="170" />
  21. <el-table-column prop="is_org_manager" label="机构管理员" align="center">
  22. <template slot-scope="{ row }">
  23. <i class="el-icon-check" v-if="row.is_org_manager === 'true'"></i>
  24. </template>
  25. </el-table-column>
  26. <el-table-column prop="register_time" label="注册时间" align="center" width="170" />
  27. <el-table-column prop="is_audited" label="已审核" align="center"
  28. ><template slot-scope="{ row }">
  29. <i class="el-icon-check" v-if="row.is_audited === 'true'"></i>
  30. </template>
  31. </el-table-column>
  32. <el-table-column prop="audit_time" label="审核时间" align="center" width="170" />
  33. <el-table-column prop="operation" label="操作" fixed="right" width="200" align="center">
  34. <template slot-scope="{ row }">
  35. <span class="link" @click="setOrgManager(row)">{{
  36. row.is_audited === 'true' ? '审核拒绝' : '审核通过'
  37. }}</span>
  38. <span class="link" @click="setPower(row)">设置权限</span>
  39. </template>
  40. </el-table-column>
  41. </el-table>
  42. <PaginationPage ref="pagination" :total="total" @getList="queryOrgList" />
  43. </div>
  44. <el-dialog
  45. :visible.sync="orgAddFlag"
  46. width="300px"
  47. append-to-body
  48. :show-close="true"
  49. :title="org_Info.name ? '编辑机构' : '创建机构'"
  50. >
  51. <el-form ref="formDialog" :model="org_Info" :rules="rules" inline>
  52. <el-form-item class="label-input" label="名称" prop="name">
  53. <el-input
  54. v-model="org_Info.name"
  55. autocomplete="off"
  56. name="name"
  57. @blur="org_Info.name = org_Info.name.trim()"
  58. />
  59. </el-form-item>
  60. </el-form>
  61. <div slot="footer" class="dialog-footer">
  62. <el-button @click="orgAddFlag = false">取 消</el-button>
  63. <el-button :loading="loading" type="primary" @click="submitOrg">确 定</el-button>
  64. </div>
  65. </el-dialog>
  66. </div>
  67. </template>
  68. <script>
  69. import PaginationPage from '@/components/PaginationPage.vue';
  70. import { queryOrgUserList } from '@/api/list.js';
  71. import { createOrg } from '@/api/org.js';
  72. export default {
  73. name: 'UserManageOrg',
  74. components: {
  75. PaginationPage,
  76. },
  77. data() {
  78. return {
  79. list: [],
  80. total: 0,
  81. page_capacity: 10,
  82. cur_page: 1,
  83. org_Info: {
  84. name: '',
  85. },
  86. orgAddFlag: false,
  87. rules: {
  88. name: [{ required: true, trigger: 'blur', message: '请输入名称' }],
  89. },
  90. loading: false,
  91. };
  92. },
  93. methods: {
  94. queryOrgList(data) {
  95. queryOrgUserList(data).then(({ total_count, user_list }) => {
  96. this.total = total_count;
  97. this.list = user_list;
  98. this.page_capacity = data.page_capacity;
  99. this.cur_page = data.cur_page;
  100. });
  101. },
  102. /**
  103. * 修改机构
  104. * @param {string} id - 项目ID
  105. */
  106. updateOrg(row) {
  107. if (row) {
  108. this.org_Info = {
  109. name: row.name,
  110. };
  111. } else {
  112. this.org_Info = {
  113. name: '',
  114. };
  115. }
  116. // this.orgAddFlag = true;
  117. },
  118. setPower(row) {},
  119. setOrgManager(row) {},
  120. submitOrg() {
  121. const _this = this;
  122. _this.$refs.formDialog.validate((valid) => {
  123. if (valid) {
  124. this.loading = true;
  125. createOrg(_this.org_Info)
  126. .then((res) => {
  127. if (res.status === 1) {
  128. this.loading = false;
  129. _this.queryOrgList({ cur_page: _this.cur_page, page_capacity: _this.page_capacity });
  130. _this.$message({
  131. type: 'success',
  132. message: '创建成功!',
  133. });
  134. }
  135. })
  136. .catch(() => {
  137. this.loading = false;
  138. });
  139. }
  140. });
  141. },
  142. },
  143. };
  144. </script>
  145. <style lang="scss" scoped>
  146. @use '@/styles/mixin.scss' as *;
  147. .user-manage {
  148. @include page-base;
  149. .btn-box {
  150. display: flex;
  151. }
  152. .add-btn {
  153. width: 120px;
  154. margin-bottom: 5px;
  155. }
  156. &-list {
  157. display: flex;
  158. flex: 1;
  159. flex-direction: column;
  160. .el-table {
  161. flex: 1;
  162. }
  163. }
  164. }
  165. </style>