index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <view class="out-box">
  3. <view class="app-view">
  4. <view class="now-name">常用应用</view>
  5. <view class="app-ul">
  6. <block v-for="(app, appi) in now_list" :key="appi">
  7. <view class="app-li" @click="chooseMenu(app)" v-if="$accessCheck($Access[app.access])">
  8. <view class="icon-view" :style="{ background: app.color }"><text :class="[app.icon]" class="custom-icon"></text></view>
  9. <view class="label ellipsis">{{ app.label }}</view>
  10. <view class="icon-circle"><u-icon name="minus-circle-fill" color="#fa3534" size="24"></u-icon></view>
  11. </view>
  12. </block>
  13. </view>
  14. </view>
  15. <view class="app-view" v-for="(item, index) in app_list" :key="index">
  16. <view class="menu-name">{{ item.menuName }}</view>
  17. <view class="app-ul">
  18. <block v-for="(app, appi) in item.menuList" :key="appi">
  19. <view class="app-li" @click="chooseMenu(app)" v-if="$accessCheck($Access[app.access])">
  20. <view class="icon-view" :style="{ background: app.color, opacity: now_list.find(menu => menu.url === app.url) ? '0.6' : '1' }">
  21. <text :class="[app.icon]" class="custom-icon"></text>
  22. </view>
  23. <view class="label ellipsis">{{ app.label }}</view>
  24. <view class="icon-circle">
  25. <u-icon v-if="!!now_list.find(menu => menu.url === app.url)" name="checkmark-circle-fill" color="#B8C0C8" size="24"></u-icon>
  26. <u-icon v-else name="plus-circle-fill" color="#2979ff" size="24"></u-icon>
  27. </view>
  28. </view>
  29. </block>
  30. </view>
  31. </view>
  32. <view class="confirm-btn" @click="updateCommonApp">完成</view>
  33. </view>
  34. </template>
  35. <script>
  36. import { menus } from './app.js';
  37. export default {
  38. data() {
  39. return {
  40. now_list: [
  41. {
  42. url: '/pages/order/OrderAdd',
  43. label: '代客下单',
  44. icon: 'custom-icon-piliangxiadan',
  45. color: '#f29611',
  46. access: 'OrderAdd'
  47. },
  48. {
  49. url: '/pagesT/stock/SalesOrder',
  50. label: '出库单',
  51. icon: 'custom-icon-quehuoshangpinshu',
  52. color: '#5c6aff',
  53. access: 'InventoryOut'
  54. },
  55. {
  56. url: '/pagesT/customer/StaffList',
  57. label: '销售排行',
  58. icon: 'custom-icon-paihangbang',
  59. color: '#f29611',
  60. access: 'salesRanking'
  61. },
  62. {
  63. url: '/pagesT/customer/CommunicationLogs',
  64. label: '客户拜访',
  65. icon: 'custom-icon-fuwu',
  66. color: '#f29611',
  67. access: 'CustomerListvisitedLogs'
  68. }
  69. ],
  70. app_list: []
  71. };
  72. },
  73. computed: {
  74. userCenterId() {
  75. return this.$store.state.userInfo.userCenterId;
  76. },
  77. enterpriseScope() {
  78. return this.$store.state.enterprise.scope;
  79. }
  80. },
  81. onLoad() {
  82. if (parseInt(this.$store.state.enterprise.scope) === 4) {
  83. this.app_list = menus.map(item => {
  84. return{
  85. ...item,
  86. menuList:item.menuList.filter(menu=>menu.label !== '商品资料')
  87. }
  88. });
  89. } else {
  90. this.app_list = menus;
  91. }
  92. },
  93. onShow() {
  94. this.getCommonAppInfo();
  95. },
  96. methods: {
  97. chooseMenu(app) {
  98. const index = this.now_list.findIndex(menu => menu.url === app.url);
  99. if (index > -1) {
  100. if (this.now_list.length === 1) {
  101. this.$u.toast('最少保留一个应用');
  102. return;
  103. }
  104. this.now_list.splice(index, 1);
  105. } else {
  106. this.now_list.push(app);
  107. }
  108. },
  109. getCommonAppInfo() {
  110. this.$u.api.getCommonAppInfo(this.userCenterId).then(res => {
  111. if (res.data.jsonKey) {
  112. if(res.data.jsonKey[0].icon.indexOf('ibon')>-1){
  113. return
  114. }
  115. this.now_list = res.data.jsonKey;
  116. }
  117. });
  118. },
  119. updateCommonApp() {
  120. this.$u.api
  121. .updateCommonApp(this.userCenterId, {
  122. jsonKey: this.now_list
  123. })
  124. .then(res => {
  125. uni.navigateBack();
  126. });
  127. }
  128. }
  129. };
  130. </script>
  131. <style scoped lang="scss">
  132. .out-box {
  133. padding-bottom: 80rpx;
  134. }
  135. .app-view {
  136. .now-name {
  137. color: #333333;
  138. font-weight: bold;
  139. line-height: 80rpx;
  140. padding: 0 32rpx;
  141. }
  142. .menu-name {
  143. font-size: 24rpx;
  144. color: #879bba;
  145. line-height: 70rpx;
  146. padding: 0 32rpx;
  147. }
  148. .app-ul {
  149. display: flex;
  150. flex-wrap: wrap;
  151. background-color: #ffffff;
  152. padding-top: 40rpx;
  153. .app-li {
  154. text-align: center;
  155. width: 25%;
  156. margin-bottom: 40rpx;
  157. position: relative;
  158. .icon-circle {
  159. position: absolute;
  160. top: 0;
  161. right: 30rpx;
  162. height: 24rpx;
  163. width: 24rpx;
  164. line-height: 24rpx;
  165. }
  166. .icon-view {
  167. width: 72rpx;
  168. height: 72rpx;
  169. line-height: 72rpx;
  170. border-radius: 30rpx;
  171. margin: 0 auto;
  172. .custom-icon {
  173. font-size: 42rpx;
  174. color: #ffffff;
  175. }
  176. }
  177. .label {
  178. font-size: 24rpx;
  179. line-height: 36rpx;
  180. padding-top: 16rpx;
  181. color: #2d405e;
  182. }
  183. }
  184. }
  185. }
  186. .confirm-btn {
  187. background-color: $uni-color-primary;
  188. color: #ffffff;
  189. text-align: center;
  190. height: 80rpx;
  191. line-height: 80rpx;
  192. position: fixed;
  193. width: 100%;
  194. left: 0;
  195. bottom: 0;
  196. }
  197. </style>