index.vue 5.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <template>
  2. <div class="page_staffManagement">
  3. <van-sticky>
  4. <div class="staffManagementTitle">
  5. <i class="iconfont icon-zuojiantou jiantou" @click="$router.go(-1)"></i>
  6. <span class="titleName">{{ name }}用户管理</span>
  7. </div>
  8. </van-sticky>
  9. <div class="staffBox" v-if="admin_user.length > 0">
  10. <div
  11. class="staffOne"
  12. v-for="(item, index) in admin_user"
  13. :key="index"
  14. @click="goEditStaff(item.is_sub_admin,item.user_id)"
  15. >
  16. <img v-if="item.avatar.length > 0" :src="item.avatar" alt />
  17. <img
  18. v-if="item.avatar.length == 0"
  19. src="../../../../../assets/images/default_avatar.jpg"
  20. alt
  21. />
  22. <p >
  23. <span>{{ item.user_name }}</span>
  24. <i
  25. v-if="isShow(item.is_sub_admin,item.user_id)"
  26. class="iconfont icon-bianji bianji"
  27. ></i>
  28. </p>
  29. </div>
  30. </div>
  31. <div class="noDataBox" v-else>
  32. <img src="../../../../../assets/images/none.png" alt />
  33. </div>
  34. <van-overlay :show="loading" type="spinner" size="30px">
  35. <div class="wrapper">
  36. <van-loading size="24px" vertical>正在加载中...</van-loading>
  37. </div>
  38. </van-overlay>
  39. </div>
  40. </template>
  41. <script>
  42. // import "../libs/rem.js";
  43. import { setRem } from "@/libs/functionRem";
  44. import { GetAllStaff } from "@/api/admin_user";
  45. import {Toast} from "vant";
  46. export default {
  47. data() {
  48. return {
  49. loading:false,
  50. active: 0,
  51. admin_user: [],
  52. org_creator: 0,
  53. name:'',
  54. isSubSuperAdmin:false,
  55. };
  56. },
  57. methods: {
  58. isShow:function(is_sub_admin,user_id){
  59. if (!this.isSubSuperAdmin){
  60. return true
  61. }else {
  62. if (is_sub_admin) {
  63. if (user_id == this.$store.getters.user.admin.id) {
  64. return true
  65. }else{
  66. return false
  67. }
  68. } else {
  69. if (user_id != this.$store.getters.user.org.creator) {
  70. return true
  71. } else {
  72. return false
  73. }
  74. }
  75. }
  76. },
  77. GetAllStaff: function() {
  78. this.loading = true
  79. GetAllStaff().then(response => {
  80. if (response.data.state === 1) {
  81. this.admin_user = response.data.data.admins;
  82. this.isSubSuperAdmin = response.data.data.isSubSuperAdmin;
  83. for (let i = 0; i < this.admin_user.length; i++) {
  84. console.log(this.admin_user[i].role_ids.length)
  85. if (this.admin_user[i].role_ids.length >= 0) {
  86. let isExist = -1;
  87. let ids = this.admin_user[i].role_ids.split(",");
  88. isExist = ids.indexOf(this.$route.query.id.toString());
  89. if (isExist < 0) {
  90. this.admin_user.splice(i, 1);
  91. i = i - 1;
  92. }
  93. }
  94. }
  95. this.loading = false
  96. } else {
  97. this.loading = false
  98. this.$toast({
  99. message: response.data.msg
  100. });
  101. }
  102. });
  103. },
  104. goEditStaff: function(is_sub_admin, user_id) {
  105. if (this.isShow(is_sub_admin,user_id)){
  106. this.$router.push({ path: "/staff/editstaff?id=" + user_id });
  107. }else{
  108. if (!this.isSubSuperAdmin){
  109. }else {
  110. if (is_sub_admin) {
  111. if (user_id == this.$store.getters.user.admin.id) {
  112. }else{
  113. Toast("无法修改其他子管理员或者管理员信息");
  114. }
  115. } else {
  116. if (user_id != this.$store.getters.user.org.creator) {
  117. } else {
  118. Toast("无法修改其他子管理员或者管理员信息");
  119. }
  120. }
  121. }
  122. }
  123. },
  124. goAddStaff: function() {
  125. this.$router.push({ path: "/staff/addstaff" });
  126. }
  127. },
  128. created() {
  129. this.name = this.$route.query.name
  130. setRem();
  131. //获取没被禁用的用户
  132. this.org_creator = this.$store.getters.user.org.creator
  133. this.GetAllStaff();
  134. }
  135. };
  136. </script>
  137. <style lang="scss" scoped>
  138. .page_staffManagement {
  139. height: 100%;
  140. overflow-y: auto;
  141. background: #fafafa;
  142. .staffManagementTitle {
  143. background: #fff;
  144. padding: 0 1.125rem;
  145. height: 3.125rem;
  146. display: flex;
  147. align-items: center;
  148. }
  149. .jiantou {
  150. font-size: 1.5rem;
  151. font-weight: 600;
  152. margin-right: 6rem;
  153. }
  154. .titleName {
  155. font-size: 1.125rem;
  156. font-weight: 600;
  157. }
  158. .iconOne {
  159. font-size: 1.5rem;
  160. }
  161. .staffBox {
  162. padding-left: 0.875rem;
  163. background: #fff;
  164. .staffOne {
  165. display: flex;
  166. align-items: center;
  167. height: 3.75rem;
  168. img {
  169. width: 2.5rem;
  170. height: 2.5rem;
  171. margin-right: 0.875rem;
  172. border-radius: 50%;
  173. }
  174. p {
  175. display: flex;
  176. align-items: center;
  177. justify-content: space-between;
  178. padding-right: 0.875rem;
  179. flex: 1;
  180. height: 100%;
  181. // box-shadow: 0px 1px 0px 0px rgba(0, 0, 0, 0.1);
  182. border-bottom: 1px solid #e5e5e5;
  183. font-size: 1rem;
  184. }
  185. .bianji {
  186. font-size: 1.25rem;
  187. color: #cccccc;
  188. }
  189. }
  190. }
  191. .noDataBox{
  192. position: fixed;
  193. left: 50%;
  194. top: 50%;
  195. transform: translate(-50%,-50%);
  196. img {
  197. width: 9.375rem;
  198. height: 9.375rem;
  199. margin: 0 auto;
  200. display: block;
  201. }
  202. }
  203. .wrapper {
  204. position: fixed;
  205. left: 50%;
  206. top: 50%;
  207. transform: translate(-50%, -50%);
  208. }
  209. }
  210. ::-webkit-scrollbar {
  211. width: 0;
  212. }
  213. </style>
  214. <style lang="scss">
  215. .page_staffManagement {
  216. .van-tabs__line {
  217. background: #5b98ff;
  218. }
  219. }
  220. </style>