index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. <template>
  2. <!-- 应用中心 -->
  3. <el-container class="app-center">
  4. <div class="app-center__header">
  5. <!-- <el-input
  6. v-model="searchWord"
  7. placeholder="请输入关键词"
  8. clearable
  9. @change="loadAppData"
  10. >
  11. <i slot="suffix" class="iconfont-5039297 iconfont-5039297 icon-chaxun" @click="loadAppData"></i>
  12. </el-input> -->
  13. <header-search-input
  14. search-tips="请输入关键词"
  15. @search-by-key="searchChange"
  16. ></header-search-input>
  17. </div>
  18. <el-container class="app-center__container">
  19. <el-aside width="180px" class="app-center__aside">
  20. <ht-tree
  21. ref="tree"
  22. class="ht-tree treeCont"
  23. :tree-data="menus"
  24. node-key="id"
  25. default-expand-all
  26. highlight-current
  27. :show-checkbox="false"
  28. :support-filter="true"
  29. :expand-on-click-node="false"
  30. :props="{
  31. children: 'children',
  32. label: 'name',
  33. }"
  34. @node-click="menuNodeClick"
  35. @refresh="menuTreeRefresh"
  36. >
  37. <span slot-scope="{ node }">
  38. <span :title="node.label">
  39. {{ node.label }}
  40. </span>
  41. </span>
  42. </ht-tree>
  43. </el-aside>
  44. <el-main class="app-center_main">
  45. <div v-if="currentMenuId" class="app-center__main-header">
  46. <span class="label">标签:</span>
  47. <ul class="tag-wrap">
  48. <li
  49. class="tag-item all-tag"
  50. :class="{ 'tag-check': checkAll }"
  51. @click="allBtnClick"
  52. >
  53. <span class="tag-name">
  54. <template v-if="checkAll">
  55. <ht-icon name="checked" class="tag-check"></ht-icon>
  56. </template>
  57. 全部
  58. </span>
  59. </li>
  60. <li
  61. v-for="(tag, index) in curTagList"
  62. :key="index"
  63. class="tag-item"
  64. :class="{ 'tag-check': tag.check }"
  65. @click="tagClick(tag)"
  66. >
  67. <span class="tag-name">
  68. <template v-if="tag.check">
  69. <ht-icon name="checked" class="tag-check"></ht-icon>
  70. </template>
  71. {{ tag.name }}
  72. </span>
  73. </li>
  74. </ul>
  75. </div>
  76. <div class="tab-container" :class="{ 'no-tags': !currentMenuId }">
  77. <div class="app-statistics">
  78. <span class="app-total">{{ pageResult.total }}</span>
  79. 个应用
  80. </div>
  81. <app-main v-if="apps && apps.length > 0" :apps="apps"></app-main>
  82. <el-empty
  83. v-else
  84. :image="noDataImg"
  85. :image-size="380"
  86. description="暂无应用哦~"
  87. ></el-empty>
  88. </div>
  89. <el-footer>
  90. <el-pagination
  91. background
  92. :page-sizes="[50, 100, 200, 300, 400]"
  93. layout="total, sizes, prev, pager, next, jumper"
  94. :total="pageResult.total"
  95. :page-size="pageResult.pageSize"
  96. class="pagination"
  97. style="float: right"
  98. @size-change="handleSizeChange"
  99. @current-change="handleCurrentChange"
  100. ></el-pagination>
  101. </el-footer>
  102. </el-main>
  103. </el-container>
  104. </el-container>
  105. </template>
  106. <script>
  107. import {
  108. getSubMenus,
  109. getValidMenu,
  110. getAppTagTypes,
  111. getSysTag,
  112. getSysAppList,
  113. queryByTagIds,
  114. queryByFilter,
  115. getSysMenuByAlias,
  116. getSysMenuByAuthApp,
  117. } from '@/api/appCenter.js'
  118. import appMain from './appMain/index.vue'
  119. import HeaderSearchInput from '../../components/searchInput/HeaderSearchInput.vue'
  120. export default {
  121. name: 'AppCenter',
  122. components: {
  123. appMain,
  124. HeaderSearchInput,
  125. },
  126. data() {
  127. return {
  128. apps: [],
  129. pageResult: {
  130. page: 1,
  131. pageSize: 50,
  132. total: 0,
  133. },
  134. checkAll: false,
  135. menus: [],
  136. tagMap: {},
  137. currentMenuId: '',
  138. searchWord: '',
  139. curTagList: [],
  140. menuAlias: 'app_menu',
  141. rootMenuId: '',
  142. noDataImg: require('@/assets/nodata_images/no-draft.png'),
  143. }
  144. },
  145. computed: {
  146. allButtonType: function (val) {
  147. let checkArr = this.curTagList.filter((e) => {
  148. if (e.check) {
  149. return e
  150. }
  151. })
  152. return this.curTagList.length === checkArr.length ? 'primary' : 'plain'
  153. },
  154. },
  155. mounted() {
  156. this.loadMenuData()
  157. this.loadAppData()
  158. },
  159. methods: {
  160. allBtnClick() {
  161. this.checkAll = !this.checkAll
  162. let check = this.allButtonType === 'primary' ? false : true
  163. for (let i = 0; i < this.curTagList.length; i++) {
  164. const element = this.curTagList[i]
  165. element.check = check
  166. this.curTagList.splice(i, 1, element)
  167. }
  168. this.loadAppData()
  169. },
  170. menuNodeClick(node) {
  171. if (node.id === this.rootMenuId) {
  172. this.currentMenuId = null
  173. } else {
  174. this.currentMenuId = node.id
  175. }
  176. this.loadMenuTagsData()
  177. this.loadAppData()
  178. },
  179. menuTreeRefresh(cb) {
  180. this.currentMenuId = null
  181. this.curTagList = []
  182. this.pageResult.page = 1
  183. this.loadMenuData(cb)
  184. this.loadAppData()
  185. },
  186. loadMenuData(cb) {
  187. getSysMenuByAlias(this.menuAlias).then((response) => {
  188. this.rootMenuId = response.id
  189. getSysMenuByAuthApp(this.menuAlias)
  190. .then((resp) => {
  191. response.children = resp.value
  192. this.menus = [response]
  193. })
  194. .finally(() => {
  195. cb && cb()
  196. })
  197. })
  198. },
  199. searchChange(searchKey) {
  200. this.searchWord = searchKey
  201. this.loadAppData()
  202. },
  203. //加载应用数据
  204. loadAppData() {
  205. let query = { pageBean: this.pageResult, params: {} }
  206. //如果没选中标签,则按菜单查找
  207. if (this.allButtonType === 'primary') {
  208. query.params.menuId = this.currentMenuId
  209. } else {
  210. //选中的标签
  211. let checkedTags = this.curTagList.filter((e) => {
  212. if (e.check) {
  213. return e
  214. }
  215. })
  216. if (!checkedTags || checkedTags.length == 0) {
  217. query.params.menuId = this.currentMenuId
  218. } else {
  219. //如果有选中的标签,则按标签精确查找
  220. let tagIds = checkedTags.map((e) => {
  221. return e.id
  222. })
  223. query.params.tagIds = tagIds.join(',')
  224. }
  225. }
  226. if (this.searchWord) {
  227. query.params.searchWord = this.searchWord
  228. }
  229. queryByFilter(query).then((resp) => {
  230. this.apps = resp.rows
  231. this.pageResult.page = resp.page
  232. this.pageResult.pageSize = resp.pageSize
  233. this.pageResult.total = resp.total
  234. })
  235. },
  236. tagClick(tag) {
  237. this.$set(tag, 'check', tag.check ? false : true)
  238. // let t = this.curTagList[index]
  239. // t.check = !t.check
  240. // this.curTagList.splice(index, 1, t)
  241. // this.$forceUpdate()
  242. this.loadAppData()
  243. },
  244. loadMenuTagsData() {
  245. if (!this.currentMenuId) {
  246. return
  247. }
  248. if (this.tagMap[this.currentMenuId]) {
  249. this.curTagList = [...this.tagMap[this.currentMenuId]]
  250. return
  251. }
  252. let querys = [
  253. {
  254. property: 'type_id_',
  255. value: this.currentMenuId,
  256. group: 'main',
  257. operation: 'EQUAL',
  258. relation: 'AND',
  259. },
  260. ]
  261. getSysTag({ querys: querys }).then((resp) => {
  262. this.curTagList = [...resp.rows]
  263. this.tagMap[this.currentMenuId] = resp.rows
  264. this.$forceUpdate()
  265. })
  266. },
  267. handleSizeChange(size) {
  268. this.pageResult.pageSize = size
  269. this.loadAppData()
  270. },
  271. handleCurrentChange(currentPage) {
  272. this.pageResult.page = currentPage
  273. this.loadAppData()
  274. },
  275. },
  276. }
  277. </script>
  278. <style lang="scss" scoped>
  279. .app-center {
  280. flex-direction: column;
  281. // height: 100%;
  282. height: calc(100% - 24px);
  283. .app-center__header {
  284. // width: 288px;
  285. text-align: right;
  286. ::v-deep {
  287. .el-input__suffix {
  288. font-size: $base-font-size-big;
  289. line-height: 32px;
  290. }
  291. }
  292. .icon-chaxun {
  293. cursor: pointer;
  294. }
  295. }
  296. .app-center__container {
  297. height: calc(100% - 16px);
  298. padding-top: 16px;
  299. .app-center__aside {
  300. background-color: $base-color-white;
  301. ::v-deep {
  302. .tree-button-group {
  303. align-items: center;
  304. }
  305. }
  306. }
  307. }
  308. .app-center_main {
  309. padding: 0;
  310. margin-left: 1px;
  311. background: $base-color-white;
  312. .app-center__main-header {
  313. display: flex;
  314. align-items: center;
  315. padding: 24px 0;
  316. margin: 0 24px;
  317. border-bottom: 1px solid $base-content-border-color;
  318. .label {
  319. padding-right: 24px;
  320. color: $base-color-second-color;
  321. }
  322. .tag-wrap {
  323. display: flex;
  324. margin: 0;
  325. .tag-item {
  326. padding-right: 8px;
  327. color: $base-color-second-color;
  328. cursor: pointer;
  329. .tag-name {
  330. position: relative;
  331. padding: 4px 8px;
  332. border-radius: $base-border-radius;
  333. .tag-check {
  334. position: absolute;
  335. right: 0;
  336. bottom: 0;
  337. width: 18px !important;
  338. height: 14px !important;
  339. color: var(--themeColor);
  340. }
  341. }
  342. }
  343. .all-tag {
  344. padding-right: 8px;
  345. }
  346. .tag-check {
  347. .tag-name {
  348. border: 1px solid var(--themeColor);
  349. }
  350. }
  351. }
  352. }
  353. }
  354. }
  355. .aside_top_title {
  356. font-size: 14px;
  357. color: #303133;
  358. }
  359. .el-card {
  360. background-color: transparent;
  361. }
  362. .el-card ::v-deep .el-card__header {
  363. height: 48px;
  364. color: #a2a2a2;
  365. border-bottom: 1.5px solid #dedede;
  366. }
  367. .el-card ::v-deep .el-card__body {
  368. padding: 0;
  369. }
  370. .tagList {
  371. display: flex;
  372. flex-direction: row;
  373. }
  374. .tab-container {
  375. height: calc(100% - 174px);
  376. padding: 24px;
  377. overflow-x: hidden;
  378. overflow-y: auto;
  379. .app-statistics {
  380. padding-bottom: 24px;
  381. color: $base-color-second-color;
  382. .app-total {
  383. color: var(--themeColor);
  384. }
  385. }
  386. ::v-deep {
  387. .el-empty__description {
  388. margin-top: -38px;
  389. p {
  390. font-size: $base-font-size-big;
  391. color: $base-dark-title-color;
  392. }
  393. }
  394. }
  395. }
  396. .no-tags {
  397. height: calc(100% - 108px);
  398. }
  399. .ht-tree ::v-deep div[role='tree'] {
  400. background-color: #fff !important;
  401. }
  402. .tag-header {
  403. height: auto;
  404. padding: 10px;
  405. background-color: #fff;
  406. }
  407. </style>