ManageTeam.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. <script setup>
  2. import { onMounted, ref, getCurrentInstance } from 'vue'
  3. import Search from '@/components/icon/search.vue'
  4. import Warning from '@/components/icon/warning.vue'
  5. import { get, _delete, downLoad} from '../../../utils/request'
  6. import { userStore } from '@/store/userInfo'
  7. const { proxy } = getCurrentInstance()
  8. const tableData = ref([])
  9. const teamList = ref([])
  10. const currentPage = ref(1)
  11. const pageSize = ref(5)
  12. const total = ref(0)
  13. const dialogVisible = ref(false)
  14. const teamId = ref('')
  15. const queryString = ref('')
  16. const deleteTeamName = ref('')
  17. const deleteTeamId = ref('')
  18. const deleteTeamIndex = ref('')
  19. const role = ref('')
  20. //限制用户点击
  21. let click = true
  22. //打开对话框
  23. const handleClick = (index, val) => {
  24. deleteTeamName.value = val.name
  25. deleteTeamId.value = val.id
  26. deleteTeamIndex.value = index
  27. dialogVisible.value = true
  28. }
  29. function handleSizeChange(val) {
  30. pageSize.value = val
  31. getManageTeamList()
  32. }
  33. function handleCurrentChange(val) {
  34. currentPage.value = val
  35. getManageTeamList()
  36. }
  37. // 获取团队管理列表
  38. function getManageTeamList() {
  39. get('/pdf-tech/vppTeam/getManageTeamList', {
  40. page: currentPage.value,
  41. pageSize: pageSize.value,
  42. teamId: teamId.value,
  43. keyword: queryString.value
  44. }).then((res) => {
  45. //限制点击
  46. setTimeout(() => {
  47. click = true
  48. }, 1000)
  49. if (res.data.code === 200) {
  50. tableData.value = res.data.result.list
  51. total.value = res.data.result.total
  52. }
  53. })
  54. }
  55. // 获取团队管理列表
  56. const getTeamList = () => {
  57. get('/pdf-tech/vppTeam/getManageTeamList', {
  58. teamId: '',
  59. keyword: ''
  60. }).then((res) => {
  61. if (res.data.code === 200) {
  62. teamList.value = res.data.result.list
  63. }
  64. })
  65. }
  66. // 团队管理列表导出
  67. function exportManageTeamList() {
  68. if(click){
  69. click = false
  70. downLoad('/pdf-tech/vppTeam/exportManageTeamList?teamId='+
  71. teamId.value +
  72. '&' +
  73. 'keyword=' +
  74. queryString.value
  75. ).then((res) => {
  76. //限制点击
  77. setTimeout(() => {
  78. click = true
  79. }, 1000)
  80. let url = window.URL.createObjectURL(new Blob([res.data], { type: '.xlsx' }))
  81. let a= document.createElement('a')
  82. a.style.display = 'none'
  83. a.href = url
  84. // 自定义文件名
  85. a.setAttribute('download', `团队.xlsx`)
  86. document.body.appendChild(a)
  87. // 下载文件
  88. a.click()
  89. // 释放内存
  90. url = window.URL.revokeObjectURL(url)
  91. document.body.removeChild(a)
  92. }
  93. )
  94. }
  95. }
  96. // 删除
  97. function handleDelete() {
  98. _delete('/pdf-tech/vppTeam/deleteTeam', {
  99. teamId: deleteTeamId.value
  100. }).then((res) => {
  101. if (res.data.code === 200) {
  102. proxy.$message({
  103. duration: 5000,
  104. message: 'Delete Success',
  105. type: 'success'
  106. })
  107. tableData.value.splice(deleteTeamIndex.value, 1)
  108. } else (
  109. proxy.$message.error(res.data.msg)
  110. )
  111. dialogVisible.value = false
  112. })
  113. }
  114. //筛选
  115. const searchInfo = () => {
  116. if(click){
  117. click = false
  118. getManageTeamList()
  119. }
  120. }
  121. onMounted(() => {
  122. role.value = userStore().user.role
  123. let pageText = document.getElementsByClassName('el-pagination__jump')[0]
  124. if (pageText) {
  125. pageText.childNodes[0].nodeValue = '跳至'
  126. }
  127. getManageTeamList()
  128. getTeamList()
  129. })
  130. </script>
  131. <template>
  132. <div>
  133. <h1>Manage Team</h1>
  134. <div class="mt-36px mb-16px flex justify-between">
  135. <h2>Content</h2>
  136. <div class="flex">
  137. <el-tooltip
  138. class="item"
  139. effect="dark"
  140. content="Download data"
  141. placement="bottom"
  142. >
  143. <div
  144. class="
  145. w-28px
  146. h-28px
  147. border-1 border-[#D9D9D9]
  148. rounded-4px
  149. bg-[#F9FAFB]
  150. flex
  151. justify-center
  152. items-center
  153. mr-12px
  154. cursor-pointer
  155. "
  156. @click="exportManageTeamList"
  157. >
  158. <img src="@/assets/images/download.svg" alt="download" />
  159. </div>
  160. </el-tooltip>
  161. <router-link
  162. v-if="role === '1'"
  163. :to="{ name: 'CreateManageTeam', params: { flag: 'create' } }"
  164. >
  165. <div
  166. class="
  167. h-28px
  168. px-10px
  169. py-4px
  170. bg-[#1460F3]
  171. rounded-4px
  172. text-14px
  173. leading-20px
  174. font-400
  175. text-[#fff]
  176. cursor-pointer
  177. hover:opacity-80
  178. "
  179. >
  180. Create Team
  181. </div>
  182. </router-link>
  183. </div>
  184. </div>
  185. <div class="block px-24px pt-32px pb-40px">
  186. <div class="flex">
  187. <select v-model="teamId" name="team" class="min-w-140px mr-16px" :class="{ '!text-[#232A40]': teamId !== '' }">
  188. <option value="">Team</option>
  189. <option v-for="item in teamList" :value="item.id" :key="item.id">
  190. {{ item.name }}
  191. </option>
  192. </select>
  193. <div class="relative mr-16px">
  194. <el-input
  195. v-model="queryString"
  196. size="mini"
  197. class="!w-316px input-with-select"
  198. placeholder="Search Team Description / Team Admin"
  199. >
  200. </el-input>
  201. <button
  202. type="button"
  203. @click="searchInfo()"
  204. class="absolute top-8px right-8px"
  205. >
  206. <Search />
  207. </button>
  208. </div>
  209. <button
  210. type="button"
  211. @click="searchInfo()"
  212. class="
  213. w-70px
  214. h-28px
  215. border-[#1460F3] border-1px
  216. rounded-4px
  217. px-10px
  218. py-4px
  219. text-14px
  220. leading-20px
  221. text-[#1460F3]
  222. cursor-pointer
  223. hover:opacity-80
  224. "
  225. >
  226. Confirm
  227. </button>
  228. </div>
  229. <el-table :data="tableData" style="width: 100%">
  230. <el-table-column prop="name" label="Team name" min-width="14%">
  231. </el-table-column>
  232. <el-table-column prop="members" label="Members" min-width="11%">
  233. </el-table-column>
  234. <el-table-column
  235. prop="licenseAmount"
  236. label="License Amount"
  237. min-width="17%"
  238. >
  239. </el-table-column>
  240. <el-table-column
  241. prop="description"
  242. label="Team Description"
  243. min-width="18%"
  244. >
  245. </el-table-column>
  246. <el-table-column label="Team Admin" min-width="14.5%">
  247. <template slot-scope="scope">
  248. <span v-for="(item, index) in scope.row.teamAdmin" :key="index">{{ item }}<br /></span>
  249. </template>
  250. </el-table-column>
  251. <el-table-column
  252. prop="createTime"
  253. label="Created date"
  254. min-width="13.5%"
  255. >
  256. </el-table-column>
  257. <el-table-column label="Operate" min-width="12%">
  258. <template slot-scope="scope">
  259. <div>
  260. <router-link :to="{ name: 'EditManageTeam', params: { flag: 'edit', teamInfo: scope.row } }">
  261. <div class="w-61px h-20px border-1 border-[#1460F3] rounded-4px text-center text-14px leading-20px text-[#1460F3] cursor-pointer mb-8px">Edit</div>
  262. </router-link>
  263. <div
  264. class="
  265. w-61px
  266. h-20px
  267. border-1 border-[#1460F3]
  268. rounded-4px
  269. text-center text-14px
  270. leading-20px
  271. text-[#1460F3]
  272. cursor-pointer
  273. "
  274. @click="handleClick(scope.$index, scope.row)"
  275. >
  276. Delete
  277. </div>
  278. </div>
  279. </template>
  280. </el-table-column>
  281. </el-table>
  282. </div>
  283. <el-dialog
  284. title=""
  285. :visible.sync="dialogVisible"
  286. width="376px"
  287. top="30vh"
  288. center
  289. :show-close="false"
  290. >
  291. <Warning class="inline-block" />
  292. <div class="mt-16px text-16px leading-24px text-[#232A40]">
  293. <p>Sure Delete Team?</p>
  294. <p>
  295. Team Name: <span class="font-bold">{{ deleteTeamName }}</span>
  296. </p>
  297. </div>
  298. <span slot="footer" class="dialog-footer">
  299. <el-button @click="dialogVisible = false">No</el-button>
  300. <el-button type="primary" @click="handleDelete()">Yes</el-button>
  301. </span>
  302. </el-dialog>
  303. <el-pagination
  304. @size-change="handleSizeChange"
  305. @current-change="handleCurrentChange"
  306. :current-page.sync="currentPage"
  307. :page-sizes="[5, 10, 20]"
  308. :page-size="pageSize"
  309. :background="true"
  310. layout="prev, pager, next, sizes, jumper"
  311. :total="total"
  312. class="px-24px !rounded-0 rounded-b-8px flex justify-end"
  313. >
  314. </el-pagination>
  315. </div>
  316. </template>
  317. <style lang="scss" scoped>
  318. .el-table::v-deep thead {
  319. color: #000 !important;
  320. }
  321. .el-table::v-deep .el-table__cell{
  322. padding-right: 20px !important;
  323. padding-left: 20px !important;
  324. }
  325. ::v-deep .input-with-select .el-input__inner {
  326. padding: 0 20px 0 8px;
  327. border-color: #d9d9d9;
  328. font-size: 14px;
  329. color: #232A40;
  330. }
  331. ::v-deep .input-with-select .el-input__inner::placeholder {
  332. font-size: 14px;
  333. font-weight: 400;
  334. color: #808185;
  335. }
  336. </style>