index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  1. <template>
  2. <view class="uni-app">
  3. <view class="status-bar" />
  4. <view class="nav-bar linear-gradient">
  5. 我的
  6. </view>
  7. <scroll-view :scroll-y="true" class="main-container">
  8. <view class="header-top">
  9. <view class="bg linear-gradient" />
  10. <view class="card">
  11. <view class="user-box" @click="handleTo('/pages_personal/user')">
  12. <wk-avatar :name="userInfo.realname" :avatar="userInfo.img" :size="16" class="avatar" />
  13. <view class="info">
  14. <view class="name">
  15. {{ userInfo.realname }}
  16. </view>
  17. <view class="position">
  18. {{ userDesc }}
  19. </view>
  20. </view>
  21. <text class="more-icon" />
  22. </view>
  23. <view class="company-name">
  24. <text class="wk wk-customer" />
  25. {{ companyInfo.companyName || appName }}
  26. </view>
  27. <view class="statistics">
  28. <view
  29. v-for="(item, index) in statisticsList"
  30. :key="index"
  31. class="statistics-item"
  32. @click="handleTo(item.path, item.query)">
  33. <text class="statistics-item__value">
  34. {{ item.value }}
  35. </text>
  36. <text class="statistics-item__label">
  37. {{ item.label }}
  38. </text>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. <view class="section backlog">
  44. <view class="backlog-item" @click="handleTo('/pages_message/messageIndex')">
  45. <view v-if="backlogDetail.messageNum" class="badge">
  46. {{ formatBadge(backlogDetail.messageNum) }}
  47. </view>
  48. <image :src="$static('images/application/clock.png')" class="pic" />
  49. <text class="text">
  50. 消息
  51. </text>
  52. </view>
  53. <view class="line" />
  54. <view class="backlog-item" @click="handleTo('/pages_message/backlogIndex')">
  55. <view v-if="backlogDetail.backlogNum" class="badge">
  56. {{ formatBadge(backlogDetail.backlogNum) }}
  57. </view>
  58. <image :src="$static('images/application/chat.png')" class="pic" />
  59. <text class="text">
  60. 待办
  61. </text>
  62. </view>
  63. </view>
  64. <view v-if="crmList.length > 0" class="section">
  65. <view class="section-title">
  66. <image :src="$static('images/icon/crm.png')" class="icon" />
  67. <text class="text">
  68. 客户管理
  69. </text>
  70. </view>
  71. <view class="section-body">
  72. <template v-for="(item, index) in crmList">
  73. <view
  74. :key="index"
  75. class="nav-list-item"
  76. @click="handleTo(item.url)">
  77. <image :src="$static(item.icon)" alt="" class="nav-list-item-icon" />
  78. <text class="nav-list-item-label">
  79. {{ item.label }}
  80. </text>
  81. </view>
  82. </template>
  83. <template v-if="crmList.length % 4 !== 0">
  84. <view
  85. v-for="i in (4 - crmList.length % 4)"
  86. :key="i | emptyKey"
  87. style="visibility: hidden;"
  88. class="nav-list-item" />
  89. </template>
  90. </view>
  91. </view>
  92. <view v-if="oaList.length > 0" class="section">
  93. <view class="section-title">
  94. <image :src="$static('images/icon/work.png')" class="icon" />
  95. <text class="text">
  96. 办公
  97. </text>
  98. </view>
  99. <view class="section-body">
  100. <template v-for="(item, index) in oaList">
  101. <view
  102. :key="index"
  103. class="nav-list-item"
  104. @click="handleTo(item.url)">
  105. <image :src="$static(item.icon)" alt="" class="nav-list-item-icon" />
  106. <text class="nav-list-item-label">
  107. {{ item.label }}
  108. </text>
  109. </view>
  110. </template>
  111. <template v-if="oaList.length % 4 !== 0">
  112. <view
  113. v-for="i in (4 - oaList.length % 4)"
  114. :key="i | emptyKey"
  115. style="visibility: hidden;"
  116. class="nav-list-item" />
  117. </template>
  118. </view>
  119. </view>
  120. <view class="section cell">
  121. <view class="cell-box" @click="handleTo('/pages_personal/about')">
  122. <image :src="$static('images/icon/airplane.png')" class="icon" />
  123. <text class="text">
  124. 关于
  125. </text>
  126. <text class="more-icon" />
  127. </view>
  128. <view class="cell-box" @click="handleTo('/pages_personal/setting')">
  129. <image :src="$static('images/icon/setting.png')" class="icon" />
  130. <text class="text">
  131. 设置
  132. </text>
  133. <text class="more-icon" />
  134. </view>
  135. </view>
  136. <view class="empty" />
  137. </scroll-view>
  138. <wk-tabbar v-model="footerIndex" :list="mixinFooterNav" />
  139. <uni-popup ref="popup" :mask-click="false" type="dialog">
  140. <wk-popup-expiration />
  141. </uni-popup>
  142. </view>
  143. </template>
  144. <script>
  145. import {
  146. QueryCompanyConfig
  147. } from 'API/admin'
  148. import {
  149. QueryOaBusinessNum
  150. } from 'API/oa/journal'
  151. import { crmLibList, oaLibList } from '@/utils/data.js'
  152. import tabbar from '@/mixins/tabbar.js'
  153. import {
  154. mapGetters,
  155. mapActions
  156. } from 'vuex'
  157. import {
  158. appName
  159. } from '@/config.js'
  160. export default {
  161. name: 'ApplicationIndex',
  162. filters: {
  163. emptyKey(key) {
  164. return `empty_${key}`
  165. }
  166. },
  167. mixins: [tabbar],
  168. data() {
  169. return {
  170. appName: appName,
  171. companyInfo: {},
  172. statisticsList: [
  173. { label: '我的日志', field: 'logNum', value: 0, path: '/pages_log/index', query: {by: 1} },
  174. { label: '我的审批', field: 'examineNum', value: 0, path: '/pages_examine/list', query: {by: 'my', tab: 1} },
  175. { label: '我的任务', field: 'taskNum', value: 0, path: '/pages_task/index', query: {type: 1} },
  176. { label: '我的跟进', field: 'activityNum', value: 0, path: '/pages_oa/record/index', query: {subUser: 0} }
  177. ]
  178. }
  179. },
  180. computed: {
  181. ...mapGetters({
  182. userInfo: 'user/userInfo',
  183. showExpiration: 'user/showExpiration',
  184. backlogDetail: 'base/backlogDetail'
  185. }),
  186. userDesc() {
  187. let str = ''
  188. str = `${this.userInfo.deptName || ''}-${this.userInfo.post || ''}`
  189. if (
  190. str.startsWith('-') ||
  191. str.endsWith('-')
  192. ) {
  193. return str.replace(/-/g, '')
  194. }
  195. return str
  196. },
  197. crmList() {
  198. const that = this
  199. return crmLibList.filter(o => {
  200. return that.$auth(o.auth)
  201. })
  202. },
  203. oaList() {
  204. const that = this
  205. return oaLibList.filter(o => {
  206. return that.$auth(o.auth)
  207. })
  208. },
  209. },
  210. watch: {
  211. showExpiration: {
  212. handler() {
  213. if (this.showExpiration) {
  214. this.$nextTick(function() {
  215. this.$refs.popup.open()
  216. })
  217. }
  218. },
  219. immediate: true,
  220. deep: true
  221. }
  222. },
  223. created() {
  224. this.getCompanyConfig()
  225. console.log('auth: ', this.$auth('crm.taskExamine'))
  226. },
  227. onShow() {
  228. this.getStatistics()
  229. this.getBacklogTotal()
  230. },
  231. methods: {
  232. ...mapActions({
  233. getBacklogTotal: 'base/getBacklogTotal'
  234. }),
  235. getCompanyConfig() {
  236. QueryCompanyConfig().then(res => {
  237. this.companyInfo = res || {}
  238. }).catch()
  239. },
  240. getStatistics() {
  241. QueryOaBusinessNum().then(res => {
  242. this.statisticsList.forEach(item => {
  243. if (res.hasOwnProperty(item.field)) {
  244. this.$set(item, 'value', res[item.field])
  245. }
  246. })
  247. }).catch()
  248. },
  249. handleTo(url, query = {}) {
  250. if (!url) return
  251. this.$Router.navigateTo({
  252. url,
  253. query
  254. })
  255. },
  256. formatBadge(num) {
  257. const val = Number(num)
  258. if (isNaN(val)) return null
  259. if (val > 99) return '99+'
  260. return val
  261. }
  262. }
  263. }
  264. </script>
  265. <style scoped lang="scss">
  266. .nav-bar {
  267. width: 100%;
  268. height: 88rpx;
  269. font-size: 34rpx;
  270. color: white;
  271. padding: 0 32rpx;
  272. @include left;
  273. }
  274. .more-icon {
  275. width: 18rpx;
  276. height: 18rpx;
  277. border-top: 5rpx solid #999;
  278. border-right: 5rpx solid #999;
  279. transform: translate(-50%, 0) rotate(45deg);
  280. display: inline-block;
  281. }
  282. .main-container {
  283. .header-top {
  284. position: relative;
  285. width: 100%;
  286. padding-bottom: 30rpx;
  287. .bg {
  288. position: absolute;
  289. top: 0;
  290. left: 0;
  291. width: 100%;
  292. height: 190rpx;
  293. }
  294. .card {
  295. position: relative;
  296. width: calc(100% - 48rpx);
  297. border-radius: 10rpx;
  298. background-color: white;
  299. box-shadow: 0 14rpx 16rpx 0 rgba(28, 108, 255, 0.10);
  300. margin: 0 auto;
  301. .user-box {
  302. padding: 32rpx 32rpx 12rpx;
  303. @include left;
  304. .avatar {
  305. width: 98rpx;
  306. height: 98rpx;
  307. border-radius: 50%;
  308. overflow: hidden;
  309. border: 2rpx solid #fff;
  310. }
  311. .info {
  312. flex: 1;
  313. font-size: $wk-font-sm;
  314. margin-left: 36rpx;
  315. .name {
  316. font-size: 34rpx;
  317. font-weight: 500;
  318. color: $dark;
  319. }
  320. .position {
  321. color: $gray;
  322. font-size: $wk-font-base;
  323. }
  324. }
  325. }
  326. .company-name {
  327. width: 100%;
  328. font-size: $wk-font-base;
  329. color: $gray;
  330. padding: 10rpx 32rpx 20rpx;
  331. @include ellipsis;
  332. .wk {
  333. color: $theme-color;
  334. margin-right: 15rpx;
  335. }
  336. }
  337. .statistics {
  338. width: 100%;
  339. display: flex;
  340. align-items: center;
  341. justify-content: space-between;
  342. padding: 20rpx 50rpx;
  343. .statistics-item {
  344. font-weight: 500;
  345. color: $dark;
  346. flex-direction: column;
  347. @include center;
  348. .statistics-item__value {
  349. font-size: 34rpx;
  350. margin-bottom: 10rpx;
  351. }
  352. .statistics-item__label {
  353. font-size: $wk-font-sm;
  354. }
  355. }
  356. }
  357. }
  358. }
  359. .section {
  360. width: calc(100% - 48rpx);
  361. background-color: white;
  362. border-radius: 12rpx;
  363. border: 1rpx solid $border-color;
  364. margin: 0 auto 20rpx;
  365. .section-title {
  366. border-bottom: 1rpx solid $border-color;
  367. padding: 20rpx 32rpx;
  368. @include left;
  369. .icon {
  370. width: 34rpx;
  371. height: 34rpx;
  372. margin-right: 15rpx;
  373. }
  374. .text {
  375. font-size: $wk-font-large;
  376. font-weight: 500;
  377. color: $dark;
  378. line-height: 1;
  379. }
  380. }
  381. .section-body {
  382. width: 100%;
  383. display: flex;
  384. flex-wrap: wrap;
  385. align-items: center;
  386. justify-content: space-between;
  387. padding: 15rpx 0;
  388. .nav-list-item {
  389. width: 20%;
  390. flex-direction: column;
  391. margin: 15rpx;
  392. @include center;
  393. .nav-list-item-icon {
  394. width: 58rpx;
  395. height: 58rpx;
  396. }
  397. .nav-list-item-label {
  398. font-size: $wk-font-base;
  399. color: $dark;
  400. margin-top: 12rpx;
  401. margin-bottom: 10rpx;
  402. }
  403. }
  404. }
  405. }
  406. .backlog {
  407. padding: 38rpx 0 28rpx;
  408. display: flex;
  409. align-items: center;
  410. justify-content: space-between;
  411. .line {
  412. width: 2rpx;
  413. height: 80rpx;
  414. background: $border-color;
  415. }
  416. .backlog-item {
  417. position: relative;
  418. flex: 1;
  419. margin: 0 112rpx;
  420. flex-direction: column;
  421. @include center;
  422. .pic {
  423. width: 72rpx;
  424. height: 72rpx;
  425. }
  426. .text {
  427. font-size: $wk-font-sm;
  428. margin-top: 10rpx;
  429. }
  430. .badge {
  431. position: absolute;
  432. top: -10rpx;
  433. left: calc(50% + 15rpx);
  434. z-index: 10;
  435. min-width: 32rpx;
  436. height: 32rpx;
  437. font-size: $wk-font-mini;
  438. line-height: normal;
  439. color: white;
  440. background-color: #E60000;
  441. border-radius: 32rpx;
  442. padding: 0 10rpx;
  443. @include center;
  444. }
  445. }
  446. }
  447. .empty {
  448. width: 100%;
  449. height: 1rpx;
  450. visibility: hidden;
  451. }
  452. .cell {
  453. padding: 15rpx;
  454. .cell-box {
  455. width: 100%;
  456. padding: 20rpx 15rpx;
  457. @include left;
  458. .icon {
  459. width: 38rpx;
  460. height: 38rpx;
  461. }
  462. .text {
  463. flex: 1;
  464. font-size: $wk-font-medium;
  465. color: $dark;
  466. margin-left: 15rpx;
  467. }
  468. }
  469. }
  470. }
  471. </style>