allCommonMenus.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. <template>
  2. <view class="all-apply-v">
  3. <view class="notice-warp">
  4. <view class="search-box">
  5. <u-search :placeholder="$t('app.apply.pleaseKeyword')" v-model="keyword" height="72"
  6. :show-action="false" @change="search" bg-color="#f0f2f6" shape="square" />
  7. </view>
  8. <view>
  9. <CommonTabs :list="tabsMenuList" @change="change" :current="current" ref="CommonTabs">
  10. </CommonTabs>
  11. </view>
  12. </view>
  13. <mescroll-uni @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption"
  14. top='220'>
  15. <view class="workFlow-list">
  16. <view class="part" v-for="(item, i) in menuList" :key="i" v-if=" menuList.length && hasChildren">
  17. <view class="caption u-line-1">
  18. {{ item.fullName }}
  19. </view>
  20. <view class="u-flex u-flex-wrap">
  21. <view class="item u-flex-col u-col-center" v-for="(child, ii) in item.children" :key="ii"
  22. @click="handleClick(child)">
  23. <text class="u-font-40 item-icon" :class="child.icon"
  24. :style="{ background: child.iconBackground || '#008cff' }" />
  25. <text class="u-font-24 u-line-1 item-text">{{child.fullName}}</text>
  26. </view>
  27. </view>
  28. </view>
  29. <NoData v-else :paddingTop="400"></NoData>
  30. </view>
  31. </mescroll-uni>
  32. </view>
  33. </template>
  34. <script>
  35. import {
  36. getAppDataList
  37. } from "@/api/apply/apply.js";
  38. import NoData from '@/components/noData'
  39. import resources from "@/libs/resources.js";
  40. import CommonTabs from '@/components/CommonTabs'
  41. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  42. export default {
  43. mixins: [MescrollMixin],
  44. components: {
  45. NoData,
  46. CommonTabs
  47. },
  48. data() {
  49. return {
  50. showPopup: false,
  51. topSearch: 80,
  52. current: 0,
  53. usualList: [],
  54. tabsMenuList: [],
  55. menuList: [],
  56. downOption: {
  57. use: true,
  58. auto: true,
  59. },
  60. upOption: {
  61. page: {
  62. num: 0,
  63. size: 50,
  64. time: null,
  65. },
  66. empty: {
  67. use: false,
  68. icon: resources.message.nodata,
  69. tip: "暂无数据",
  70. fixed: true,
  71. top: "560rpx",
  72. },
  73. textNoMore: "",
  74. },
  75. keyword: "",
  76. userInfo: {
  77. systemIds: [],
  78. }, //CurrentUser接口中的userInfo数据
  79. modelId: "",
  80. config: {},
  81. key: +new Date()
  82. };
  83. },
  84. computed: {
  85. baseURL() {
  86. return this.define.baseURL;
  87. },
  88. token() {
  89. return uni.getStorageSync('token')
  90. },
  91. report() {
  92. return this.define.report;
  93. },
  94. hasChildren() {
  95. let hasChildren = false
  96. for (let i = 0; i < this.menuList.length; i++) {
  97. if (this.menuList[i].children && this.menuList[i].children.length) {
  98. hasChildren = true
  99. break
  100. }
  101. }
  102. return hasChildren
  103. }
  104. },
  105. created() {
  106. uni.$on('refresh', () => {
  107. this.menuList = [];
  108. this.current = 0;
  109. this.mescroll.resetUpScroll();
  110. });
  111. },
  112. methods: {
  113. classifyItem(index) {
  114. this.showPopup = false
  115. this.change(index)
  116. },
  117. upCallback(keyword) {
  118. let query = {
  119. keyword: this.keyword,
  120. type: 2
  121. };
  122. uni.showLoading({
  123. title: '正在加载',
  124. mask: true
  125. })
  126. getAppDataList(query).then(res => {
  127. let list = res.data.list || [];
  128. if (!list.length) this.current = 0
  129. this.tabsMenuList = [{
  130. fullName: "全部功能"
  131. }];
  132. this.mescroll.endSuccess(list.length);
  133. for (let i = 0; i < list.length; i++) {
  134. let children = list[i].children;
  135. let tabsMenuList = {
  136. fullName: list[i].fullName,
  137. };
  138. this.tabsMenuList.push(tabsMenuList);
  139. if (Array.isArray(children) && children.length) {
  140. for (let j = 0; j < children.length; j++) {
  141. let iconBackground = "",
  142. moduleId = "";
  143. if (children[j].propertyJson) {
  144. let propertyJson = JSON.parse(children[j].propertyJson);
  145. iconBackground = propertyJson.iconBackgroundColor || "";
  146. moduleId = propertyJson.moduleId || "";
  147. }
  148. this.$set(children[j], "iconBackground", iconBackground);
  149. this.$set(children[j], "moduleId", moduleId);
  150. }
  151. }
  152. }
  153. this.list = JSON.parse(JSON.stringify(list));
  154. if (this.current === 0) {
  155. let allApp = [{
  156. fullName: '全部功能',
  157. children: this.jnpf.treeToArray(this.list).filter(o => !o.hasChildren),
  158. id: 0
  159. }]
  160. this.menuList = allApp
  161. } else {
  162. this.menuList = this.list
  163. }
  164. uni.hideLoading()
  165. this.key = +new Date();
  166. this.mescroll.endSuccess(this.menuList.length, false);
  167. }).catch(() => {
  168. this.mescroll.endSuccess(0);
  169. this.mescroll.endErr();
  170. });
  171. },
  172. change(index) {
  173. this.current = index;
  174. this.menuList = this.list;
  175. if (this.current === 0) {
  176. let allApp = [{
  177. fullName: '全部功能',
  178. children: this.jnpf.treeToArray(this.list).filter(o => !o.hasChildren),
  179. id: 0
  180. }]
  181. this.menuList = allApp
  182. } else {
  183. this.menuList = [this.list[index - 1]] || [];
  184. }
  185. },
  186. search() {
  187. this.searchTimer && clearTimeout(this.searchTimer);
  188. this.searchTimer = setTimeout(() => {
  189. this.list = [];
  190. this.menuList = [];
  191. this.tabsMenuList = [];
  192. this.current = 0
  193. this.mescroll.resetUpScroll();
  194. }, 300);
  195. },
  196. handleClick(item) {
  197. if (item.type == 2) {
  198. uni.navigateTo({
  199. url: item.urlAddress +
  200. "?menuId=" +
  201. item.id +
  202. "&fullName=" +
  203. item.fullName,
  204. fail: (err) => {
  205. this.$u.toast("暂无此页面");
  206. },
  207. });
  208. return;
  209. }
  210. if (item.type == 3) {
  211. this.modelId = item.moduleId;
  212. if (!item.moduleId) {
  213. this.$u.toast("暂无此页面");
  214. return;
  215. }
  216. uni.navigateTo({
  217. url: "/pages/apply/dynamicModel/index?config=" +
  218. this.jnpf.base64.encode(JSON.stringify(item)),
  219. fail: (err) => {
  220. this.$u.toast("暂无此页面");
  221. },
  222. });
  223. }
  224. if (item.type == 7 || item.type == 5) {
  225. let url =
  226. encodeURIComponent(item.urlAddress) + "&fullName=" + item.fullName;
  227. if (item.type == 5) {
  228. url = encodeURIComponent(
  229. `${this.report}/preview.html?id=${item.moduleId}&token=${this.token}&page=1&from=menu`
  230. );
  231. }
  232. if (!item.urlAddress && item.type == 7) {
  233. this.$u.toast("暂无此页面");
  234. return;
  235. }
  236. uni.navigateTo({
  237. url: "/pages/apply/externalLink/index?url=" +
  238. url +
  239. "&fullName=" +
  240. item.fullName +
  241. "&type=" +
  242. item.type,
  243. fail: (err) => {
  244. this.$u.toast("暂无此页面");
  245. },
  246. });
  247. return;
  248. }
  249. if (item.type == 8) {
  250. if (!item.urlAddress) {
  251. this.$u.toast("暂无此页面");
  252. return;
  253. }
  254. uni.navigateTo({
  255. url: "/pages/portal/scanPortal/index?id=" + item.moduleId + "&portalType=1&fullName=" +
  256. item.fullName,
  257. fail: (err) => {
  258. this.$u.toast("暂无此页面");
  259. },
  260. });
  261. return
  262. }
  263. }
  264. },
  265. };
  266. </script>
  267. <style lang="scss" scoped>
  268. page {
  269. background-color: #f0f2f6;
  270. }
  271. .all-apply-v {
  272. height: 100%;
  273. .notice-warp {
  274. height: 3.59rem !important;
  275. text-align: left;
  276. .search-box {
  277. padding: 20rpx;
  278. }
  279. }
  280. .commonTabs-box {
  281. height: 2.8rem;
  282. }
  283. }
  284. </style>