allApp_apply.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template>
  2. <view class="allApp-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. </u-search>
  8. </view>
  9. </view>
  10. <view class="usualList">
  11. <view class="caption u-m-b-20">常用菜单</view>
  12. <view class="u-flex u-flex-wrap">
  13. <view class="item u-flex-col u-col-center" v-for="(item,i) in usualList" :key="i">
  14. <text class="u-font-40 item-icon" :class="item.icon"
  15. :style="{'background':item.iconBackground||'#008cff'}" />
  16. <text class="u-font-24 u-line-1 item-text">{{item.fullName}}</text>
  17. </view>
  18. </view>
  19. </view>
  20. <CommonTabs :list="allList" @change="change" :current="current" ref="CommonTabs" isBoxShadow></CommonTabs>
  21. <view class="allList u-m-t-20" v-if="allList.length">
  22. <view class="u-m-t-20" v-for="(item,i) in allList" :key="i">
  23. <template v-if="i==current && item?.children?.length">
  24. <view v-for="(child,ii) in item.children" class="u-flex childList-item u-p-b-28" :key="ii">
  25. <text class="u-font-40 item-icon" :class="child.icon"
  26. :style="{'background':child.iconBackground||'#008cff'}" />
  27. <text class="u-font-32 item-text u-m-l-28 u-m-r-28 u-line-2">{{child.fullName}}</text>
  28. <view class="btnBox">
  29. <u-button :custom-style="customStyle" @click="handelAdd(child)" v-if="!child.isData">添加
  30. </u-button>
  31. <u-button :custom-style="customStyle" type="error" @click="handelDel(child)" v-else>移除
  32. </u-button>
  33. </view>
  34. </view>
  35. </template>
  36. </view>
  37. </view>
  38. <NoData v-else :paddingTop="450"></NoData>
  39. </view>
  40. </template>
  41. <script>
  42. import NoData from '@/components/noData'
  43. import {
  44. FlowEngineListAll
  45. } from '@/api/workFlow/flowEngine'
  46. import CommonTabs from '@/components/CommonTabs'
  47. import {
  48. getDataList,
  49. getUsualList,
  50. addUsual,
  51. delUsual
  52. } from '@/api/apply/apply.js'
  53. export default {
  54. components: {
  55. CommonTabs,
  56. NoData
  57. },
  58. data() {
  59. return {
  60. current: 0,
  61. usualList: [],
  62. allList: [],
  63. customStyle: {
  64. width: "128rpx",
  65. fontSize: "24rpx",
  66. height: '60rpx'
  67. },
  68. type: '2',
  69. keyword: ''
  70. }
  71. },
  72. methods: {
  73. init() {
  74. uni.showLoading({
  75. title: '加载中'
  76. });
  77. this.getUsualList()
  78. },
  79. search() {
  80. this.searchTimer && clearTimeout(this.searchTimer);
  81. this.searchTimer = setTimeout(() => {
  82. this.allList = [];
  83. this.usualList = [];
  84. this.current = 0
  85. this.getUsualList();
  86. }, 300);
  87. },
  88. getUsualList() {
  89. getUsualList().then(res => {
  90. this.usualList = res.data.list.map(o => {
  91. const objectData = o.objectData ? JSON.parse(o.objectData) : {}
  92. return {
  93. ...o,
  94. ...objectData
  95. }
  96. })
  97. })
  98. this.getAllList()
  99. },
  100. getAllList() {
  101. getDataList({
  102. keyword: this.keyword
  103. }).then(res => {
  104. uni.hideLoading()
  105. let list = JSON.parse(JSON.stringify(res.data.list))
  106. for (let i = 0; i < list.length; i++) {
  107. let children = list[i].children
  108. if (Array.isArray(children) && children.length) {
  109. for (let j = 0; j < children.length; j++) {
  110. let iconBackground = '',
  111. moduleId = ''
  112. if (children[j].propertyJson) {
  113. let propertyJson = JSON.parse(children[j].propertyJson)
  114. iconBackground = propertyJson.iconBackgroundColor || ''
  115. moduleId = propertyJson.moduleId || ''
  116. }
  117. this.$set(children[j], 'iconBackground', iconBackground)
  118. this.$set(children[j], 'moduleId', moduleId)
  119. }
  120. }
  121. }
  122. this.allList = list.filter(o => o.children)
  123. })
  124. },
  125. handelAdd(item) {
  126. addUsual(item.id).then(res => {
  127. this.usualList.push(item)
  128. item.isData = true
  129. uni.$emit('updateUsualList')
  130. uni.showToast({
  131. title: res.msg
  132. })
  133. })
  134. },
  135. handelDel(item) {
  136. delUsual(item.id).then(res => {
  137. this.usualList = this.usualList.filter(o => o.id !== item.id)
  138. item.isData = false
  139. uni.$emit('updateUsualList')
  140. uni.showToast({
  141. title: res.msg
  142. })
  143. })
  144. },
  145. change(index) {
  146. this.current = index;
  147. }
  148. }
  149. }
  150. </script>
  151. <style lang="scss" scoped>
  152. .allApp-v {
  153. .notice-warp {
  154. height: 114rpx;
  155. .search-box {
  156. padding: 20rpx;
  157. }
  158. }
  159. .caption {
  160. font-size: 36rpx;
  161. line-height: 80rpx;
  162. padding: 0 32rpx;
  163. .tip {
  164. margin-left: 20rpx;
  165. font-size: 24rpx;
  166. color: #c6c6c6;
  167. }
  168. }
  169. .tabs_box {
  170. width: 100%;
  171. .sticky {
  172. width: 750rpx;
  173. height: 120rpx;
  174. color: #fff;
  175. padding-right: 32rpx;
  176. }
  177. }
  178. .usualList {
  179. margin-top: 4.2rem;
  180. margin-bottom: 20rpx;
  181. background-color: #FFFFFF;
  182. .item {
  183. margin-bottom: 32rpx;
  184. width: 25%;
  185. .item-icon {
  186. width: 88rpx;
  187. height: 88rpx;
  188. margin-bottom: 8rpx;
  189. line-height: 88rpx;
  190. text-align: center;
  191. border-radius: 20rpx;
  192. color: #fff;
  193. font-size: 56rpx;
  194. }
  195. .item-text {
  196. width: 100%;
  197. text-align: center;
  198. padding: 0 16rpx;
  199. }
  200. }
  201. }
  202. .allList {
  203. padding: 20rpx 32rpx 0;
  204. background-color: #FFFFFF;
  205. .childList-item {
  206. align-items: center;
  207. .item-text {
  208. width: calc(100% - 216rpx);
  209. }
  210. .item-icon {
  211. width: 88rpx;
  212. height: 88rpx;
  213. line-height: 88rpx;
  214. text-align: center;
  215. border-radius: 30rpx;
  216. color: #FFFFFF;
  217. flex-shrink: 0;
  218. font-size: 40rpx;
  219. }
  220. }
  221. }
  222. }
  223. </style>