index.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <template>
  2. <div class="org-manager">
  3. <el-input v-model="search" type="text" prefix-icon="el-icon-search" @keyup.enter.native="queryOrgList">
  4. <el-button slot="append" icon="el-icon-search" @click="queryOrgList"></el-button>
  5. </el-input>
  6. <div class="org-manager-list">
  7. <div class="org-manager-list-title">
  8. <div>机构管理</div>
  9. <div>
  10. <el-button icon="el-icon-plus" @click="$router.push('/add_org')">创建机构</el-button>
  11. </div>
  12. </div>
  13. <el-table :data="org_list">
  14. <el-table-column prop="name" label="名称" width="240" />
  15. <el-table-column prop="teacher_count" label="注册教师人数" width="110" />
  16. <el-table-column prop="teacher_count_audited" label="审核通过的注册教师人数" width="180" />
  17. <el-table-column prop="admin_user_name" label="机构管理员" />
  18. <el-table-column fixed="right" width="70">
  19. <template slot-scope="{ row }">
  20. <a @click="showOrg(row.id)">查看</a>
  21. </template>
  22. </el-table-column>
  23. <el-table-column fixed="right" width="70">
  24. <template slot-scope="{ row }">
  25. <el-dropdown placement="top">
  26. <a class="el-dropdown-link">管理</a>
  27. <el-dropdown-menu slot="dropdown">
  28. <el-dropdown-item @click.native="updateOrg(row.id)">修改</el-dropdown-item>
  29. <el-dropdown-item @click.native="resetOrgAdminPassword(row.admin_user_id)">
  30. 重置机构管理员密码
  31. </el-dropdown-item>
  32. </el-dropdown-menu>
  33. </el-dropdown>
  34. </template>
  35. </el-table-column>
  36. <el-table-column fixed="right" width="180">
  37. <template slot-scope="{ row }">
  38. <el-popover trigger="click" width="200" @show="getDistributablePopedomList_OrgManager(row.id)">
  39. <div class="popedom">
  40. <span class="popedom-manager">权限管理</span>
  41. <div v-for="item in popedom_list" :key="item.popedom_code" class="popedom-list">
  42. <span>{{ item.popedom_name }}</span>
  43. <el-switch v-model="item.is_selected" active-color="#34CC83" inactive-color="#C4C4C4" />
  44. </div>
  45. <el-button type="primary" @click="setDistributablePopedom_OrgManager(row.id)">保存</el-button>
  46. </div>
  47. <el-link slot="reference" :underline="false">管理员可分配权限</el-link>
  48. </el-popover>
  49. </template>
  50. </el-table-column>
  51. </el-table>
  52. </div>
  53. <el-pagination
  54. background
  55. :page-sizes="[10, 20, 30, 40, 50]"
  56. :page-size="page_capacity"
  57. layout="prev, pager, next, total, sizes, jumper"
  58. :total="total_count"
  59. :current-page="cur_page"
  60. @prev-click="changePage"
  61. @next-click="changePage"
  62. @current-change="changePage"
  63. @size-change="changePageSize"
  64. />
  65. <reset-password ref="reset" :user-id="curUserId" />
  66. <show-org ref="showOrg" :org-id="curOrgId" />
  67. <update-org ref="updateOrg" :org-id="curOrgId" @refresh="queryOrgList" />
  68. </div>
  69. </template>
  70. <script>
  71. import ResetPassword from '@/components/ResetPassword.vue';
  72. import ShowOrg from './ShowOrg.vue';
  73. import UpdateOrg from './UpdateOrg.vue';
  74. import { pageQueryOrgList } from '@/api/list';
  75. import { GetDistributablePopedomList_OrgManager, SetDistributablePopedom_OrgManager } from '@/api/org';
  76. export default {
  77. name: 'OrgManager',
  78. components: {
  79. ResetPassword,
  80. ShowOrg,
  81. UpdateOrg
  82. },
  83. data() {
  84. return {
  85. search: '',
  86. page_capacity: 10,
  87. cur_page: 1,
  88. org_list: [],
  89. total_count: 0,
  90. curUserId: '',
  91. curOrgId: '',
  92. // 权限列表
  93. popedom_list: []
  94. };
  95. },
  96. created() {
  97. this.queryOrgList();
  98. },
  99. methods: {
  100. changePage(newPage) {
  101. this.cur_page = newPage;
  102. this.queryOrgList();
  103. },
  104. changePageSize(pageSize) {
  105. this.page_capacity = pageSize;
  106. this.queryOrgList();
  107. },
  108. queryOrgList() {
  109. pageQueryOrgList({
  110. name: this.search,
  111. page_capacity: this.page_capacity,
  112. cur_page: this.cur_page
  113. }).then(({ cur_page, org_list, total_count }) => {
  114. this.cur_page = cur_page;
  115. this.org_list = org_list;
  116. this.total_count = total_count;
  117. });
  118. },
  119. showOrg(id) {
  120. this.curOrgId = id;
  121. this.$refs.showOrg.show();
  122. },
  123. updateOrg(id) {
  124. this.curOrgId = id;
  125. this.$refs.updateOrg.show();
  126. },
  127. getDistributablePopedomList_OrgManager(org_id) {
  128. GetDistributablePopedomList_OrgManager({ org_id }).then(({ popedom_list }) => {
  129. popedom_list.forEach((el, i, arr) => {
  130. el.is_selected = el.is_selected === 'true';
  131. arr[i] = el;
  132. });
  133. this.popedom_list = popedom_list;
  134. });
  135. },
  136. setDistributablePopedom_OrgManager(org_id) {
  137. let popedom_code_list = [];
  138. this.popedom_list.forEach(({ popedom_code, is_selected }) => {
  139. if (is_selected) popedom_code_list.push(popedom_code);
  140. });
  141. SetDistributablePopedom_OrgManager({ org_id, popedom_code_list }).then(() => {
  142. this.$message.success('为机构管理员设置可分配的权限成功');
  143. });
  144. },
  145. resetOrgAdminPassword(id) {
  146. this.curUserId = id;
  147. this.$refs.reset.show();
  148. }
  149. }
  150. };
  151. </script>
  152. <style lang="scss" scope>
  153. @import '~@/styles/mixin';
  154. .org-manager {
  155. @include container;
  156. @include pagination;
  157. padding: 24px 0 46px;
  158. > .el-input {
  159. width: 528px;
  160. }
  161. &-list {
  162. @include list;
  163. &-title {
  164. display: flex;
  165. justify-content: space-between;
  166. &:first-child {
  167. font-size: 24px;
  168. font-weight: 700;
  169. }
  170. }
  171. }
  172. }
  173. </style>
  174. <style lang="scss">
  175. // 权限管理
  176. .popedom {
  177. &-manager {
  178. display: flex;
  179. justify-content: space-between;
  180. padding-bottom: 8px;
  181. font-weight: 700;
  182. border-bottom: 1px solid #d9d9d9;
  183. }
  184. &-list {
  185. display: flex;
  186. justify-content: space-between;
  187. padding-top: 10px;
  188. }
  189. .el-button {
  190. width: 100%;
  191. padding: 6px 20px;
  192. margin-top: 16px;
  193. }
  194. }
  195. </style>