ManageAdmin.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. <script setup>
  2. import { onMounted, ref } from 'vue'
  3. import Download from '@/components/icon/download.vue'
  4. import Warning from '@/components/icon/warning.vue'
  5. import Search from '@/components/icon/search.vue'
  6. import { get, post } from '../../utils/request'
  7. const currentPage = ref(1)
  8. const size = ref(5)
  9. const queryString = ref('')
  10. const teamId = ref('')
  11. const role = ref('')
  12. const tableData = ref([])
  13. const teamList = ref([])
  14. const total = ref(0)
  15. const dialogVisible = ref(false)
  16. const cancelEmail = ref('')
  17. let click = true
  18. let memberRole = ''
  19. onMounted(() => {
  20. let pageText = document.getElementsByClassName('el-pagination__jump')[0]
  21. if (pageText) {
  22. pageText.childNodes[0].nodeValue = '跳至'
  23. }
  24. get('/pdf-tech/vppMember/getMemberInfo').then((res)=>{
  25. if(res.data.code === 200){
  26. memberRole = res.data.result.role
  27. }
  28. })
  29. pagingQuery()
  30. getTeamList()
  31. })
  32. //打开对话框
  33. const handleClick = (val) => {
  34. if( memberRole?.indexOf("1") !== -1){
  35. dialogVisible.value = true
  36. cancelEmail.value = val.email
  37. }
  38. }
  39. //获取分页数据
  40. const pagingQuery = () => {
  41. get(
  42. '/pdf-tech/vppRTeamMemberRole/pageForAdmin/?page=' +
  43. currentPage.value +
  44. '&' +
  45. 'pageSize=' +
  46. size.value +
  47. '&' +
  48. 'teamId=' +
  49. teamId.value +
  50. '&' +
  51. 'role=' +
  52. role.value +
  53. '&' +
  54. 'queryString=' +
  55. queryString.value
  56. ).then((res) => {
  57. //限制点击
  58. setTimeout(() => {
  59. click = true
  60. }, 1000)
  61. if(res.data.code === 200){
  62. const data = res.data.result.list
  63. for (let i = 0; i < data.length; i++) {
  64. if (data[i].memberRole ?.indexOf("1") !== -1) {
  65. data[i].memberRole = 'Super admin'
  66. } else if (data[i].memberRole ?.indexOf("2") !== -1) {
  67. data[i].memberRole = 'Team admin'
  68. } else {
  69. data[i].memberRole = 'Team member'
  70. }
  71. }
  72. tableData.value = data
  73. total.value = res.data.result.total
  74. }
  75. })
  76. }
  77. //筛选
  78. const searchInfo = () => {
  79. if(click){
  80. click = false
  81. pagingQuery()
  82. }
  83. }
  84. // 获取团队管理列表
  85. const getTeamList = (val) => {
  86. get('/pdf-tech/vppTeam/getManageTeamList', {
  87. teamId: '',
  88. keyword: ''
  89. }).then((res) => {
  90. if (res.data.code === 200) {
  91. teamList.value = res.data.result.list
  92. }
  93. })
  94. }
  95. //
  96. const deleteAdmin = (val) => {
  97. dialogVisible.value = false
  98. var urlencoded = new URLSearchParams()
  99. urlencoded.append("memberId", val.id)
  100. post('/pdf-tech/vppTeam/deleteAdmin',urlencoded).then((res) => {
  101. if(res.data.code === 200){
  102. pagingQuery()
  103. }
  104. })
  105. }
  106. //切换每页条数
  107. const handleSizeChange = (val) => {
  108. size.value = val
  109. pagingQuery()
  110. }
  111. //切换分页
  112. const handleCurrentChange = (val) => {
  113. currentPage.value = val
  114. pagingQuery()
  115. }
  116. </script>
  117. <template>
  118. <div class="flex flex-col items-center">
  119. <div class="w-full">
  120. <h1 class="leading-40px">Manage Admin</h1>
  121. <div
  122. class="
  123. mt-36px
  124. mb-16px
  125. leading-20px
  126. text-16px
  127. font-bold
  128. flex
  129. justify-between
  130. "
  131. >
  132. <span>Content</span>
  133. <div class="flex">
  134. <router-link
  135. :to="{ path: '/manageAdmin/addAdmin', query: {} }"
  136. class="
  137. bg-[#1460F3]
  138. h-28px
  139. w-111px
  140. flex
  141. justify-center
  142. items-center
  143. font-500
  144. text-14px
  145. ml-12px
  146. rounded-4px
  147. text-[#fff]
  148. hover:opacity-80
  149. "
  150. >
  151. Add Admin
  152. </router-link>
  153. </div>
  154. </div>
  155. <div class="flex bg-[#fff] pt-32px px-24px rounded-t-8px w-full">
  156. <select class="w-140px" v-model="teamId">
  157. <option value="" selected>Team</option>
  158. <option v-for="item in teamList" :key="item.value" :value="item.id">
  159. {{ item.name }}
  160. </option>
  161. </select>
  162. <select class="w-140px ml-16px" v-model="role">
  163. <option value="" selected>Role</option>
  164. <option value="1">Super admin</option>
  165. <option value="2">Team admin</option>
  166. </select>
  167. <div class="relative">
  168. <el-input
  169. v-model="queryString"
  170. size="mini"
  171. class="!w-316px ml-16px input-with-select"
  172. placeholder="Search Name/Email"
  173. >
  174. </el-input>
  175. <button type="button" @click="searchInfo()" class="absolute top-8px right-8px"><Search /></button>
  176. </div>
  177. <button
  178. type="button"
  179. @click="searchInfo()"
  180. class="
  181. w-70px
  182. h-28px
  183. border-1px border-[#1460F3]
  184. rounded-4px
  185. ml-16px
  186. text-[#1460F3]
  187. hover:opacity-80
  188. "
  189. >
  190. Confirm
  191. </button>
  192. </div>
  193. <el-table :data="tableData" class="px-24px rounded-b-8px w-full">
  194. <el-table-column prop="fullName" label="Name"> </el-table-column>
  195. <el-table-column prop="email" label="Email"> </el-table-column>
  196. <el-table-column prop="teamNames" label="Team"> </el-table-column>
  197. <el-table-column prop="memberRole" label="Role"> </el-table-column>
  198. <el-table-column prop="createdAt" label="Added date"> </el-table-column>
  199. <el-table-column prop="operate" label="Operate">
  200. <template slot-scope="scope">
  201. <div class="flex flex-col">
  202. <router-link
  203. :to="{ path: '/manageAdmin/editAdmin', query: { Email: scope.row.email, Team: scope.row.teamName, Id: scope.row.id } }"
  204. class="
  205. w-60px
  206. h-20px
  207. flex
  208. justify-center
  209. items-center
  210. rounded-4px
  211. border-1px border-[#1460F3]
  212. text-[#1460F3]
  213. leading-12px
  214. "
  215. >
  216. Edit
  217. </router-link>
  218. <button
  219. @click="handleClick(scope.row)"
  220. type="text"
  221. class="
  222. w-60px
  223. h-20px
  224. mt-8px
  225. rounded-4px
  226. border-1px border-[#1460F3]
  227. text-[#1460F3]
  228. leading-12px
  229. "
  230. >
  231. Delete
  232. </button>
  233. </div>
  234. <el-dialog title="" :visible.sync="dialogVisible" width="376px" top="30vh" center :show-close="false">
  235. <Warning />
  236. <p class="mt-16px">Sure Delete Team admin?</p>
  237. <p>
  238. User Name:<span class="text-16px font-bold">{{
  239. cancelEmail
  240. }}</span>
  241. </p>
  242. <span slot="footer" class="dialog-footer">
  243. <el-button @click="dialogVisible = false">Cancel</el-button>
  244. <el-button type="primary" @click="deleteAdmin(scope.row)">
  245. Delete
  246. </el-button>
  247. </span>
  248. </el-dialog>
  249. </template>
  250. </el-table-column>
  251. </el-table>
  252. <el-pagination
  253. @size-change="handleSizeChange"
  254. @current-change="handleCurrentChange"
  255. :current-page.sync="currentPage"
  256. :page-sizes="[5, 10, 20]"
  257. :page-size="size"
  258. :background="true"
  259. layout="prev, pager, next, sizes, jumper"
  260. :total="total"
  261. class="px-24px !rounded-0 rounded-b-8px mt-20px flex justify-end"
  262. >
  263. </el-pagination>
  264. </div>
  265. </div>
  266. </template>
  267. <style lang="scss" scoped>
  268. .el-table::v-deep .el-table__cell{
  269. padding-right: 20px !important;
  270. padding-left: 20px !important;
  271. }
  272. .el-table__header-wrapper::v-deep .el-table__header {
  273. display: flex;
  274. width: 1100px !important;
  275. }
  276. .el-table__header {
  277. display: flex;
  278. width: 1100px !important;
  279. }
  280. .el-table::v-deep thead {
  281. color: #000 !important;
  282. }
  283. </style>