index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  1. <!--
  2. * @Author: liuzhenlin 461480418@qq.ocm
  3. * @Date: 2023-01-12 11:57:48
  4. * @LastEditors: liuzhenlin
  5. * @LastEditTime: 2023-03-06 16:46:52
  6. * @Description: file content
  7. * @FilePath: \oms\pages\home\index.vue
  8. -->
  9. <template>
  10. <view class="home">
  11. <!-- <WaterMark></WaterMark> -->
  12. <view class="nav">
  13. <view :style="{ paddingTop }">
  14. <view class="title" :style="[{ height }, { lineHeight: height }]">首页</view>
  15. </view>
  16. </view>
  17. <view class="main">
  18. <view class="header">
  19. <u-swiper :list="bannerList" radius="0" interval="5000" circular></u-swiper>
  20. <!-- <view class="h-left">
  21. <text class="name">大数华创</text>
  22. <text class="txt">提升工作效率,降低管理难度</text>
  23. <view class="line"></view>
  24. </view>
  25. <view class="h-right"></view> -->
  26. </view>
  27. <view class="content">
  28. <view class="msg-box">
  29. <view class="tab-date-wrap">
  30. <text class="tab-date-item" @click="getReport('week')" :class="{ dateActive: tabDate == 'week' }">
  31. 本周
  32. </text>
  33. <text class="tab-date-item" @click="getReport('month')" :class="{ dateActive: tabDate == 'month' }">
  34. 本月
  35. </text>
  36. </view>
  37. <view class="date-msg">
  38. <u-row justify="space-between">
  39. <u-col span="4">
  40. <view class="center flex-column" @click="handleHomeLink('/pages/openSeaCustomer/index')">
  41. <view class="num">{{ newCustomer }}</view>
  42. <view class="txt">新增客户</view>
  43. </view>
  44. </u-col>
  45. <u-col span="4">
  46. <view class="center flex-column" @click="handleHomeLink('/pages/project/index')">
  47. <view class="num">{{ newBusiness }}</view>
  48. <view class="txt">新增项目</view>
  49. </view>
  50. </u-col>
  51. <u-col span="4">
  52. <view class="center flex-column" @click="handleHomeLink('/pages/schedule/index?type=1', 2)">
  53. <view class="num">{{ newTask }}</view>
  54. <view class="txt">督办事项</view>
  55. </view>
  56. </u-col>
  57. </u-row>
  58. </view>
  59. </view>
  60. <view class="menu-wrap">
  61. <u-row justify="space-between" gutter="14">
  62. <u-col span="6">
  63. <view class="menu-item flex_l flex-colunm" @click="handleHomeLink('/pages/openSeaCustomer/index')">
  64. <view class="menu-img-box">
  65. <image class="menu-img" src="../../static/images/menu5.png" mode="scaleToFill" />
  66. </view>
  67. <view class="menu-info flex flex-column">
  68. <view class="tit1">公海客户</view>
  69. <view class="tit2">公海客户管理</view>
  70. </view>
  71. </view>
  72. </u-col>
  73. <u-col span="6">
  74. <view class="menu-item flex_l flex-colunm" @click="handleHomeLink('/pages/customer/index')">
  75. <view class="menu-img-box">
  76. <image class="menu-img" src="../../static/images/menu1.png" mode="scaleToFill" />
  77. </view>
  78. <view class="menu-info flex flex-column">
  79. <view class="tit1">客户管理</view>
  80. <view class="tit2">客户信息管理</view>
  81. </view>
  82. </view>
  83. </u-col>
  84. </u-row>
  85. <u-row justify="space-between" gutter="14">
  86. <u-col span="6">
  87. <view class="menu-item flex_l flex-colunm" @click="handleHomeLink('/pages/project/index')">
  88. <view class="menu-img-box">
  89. <image class="menu-img" src="../../static/images/menu2.png" mode="scaleToFill" />
  90. </view>
  91. <view class="menu-info flex flex-column">
  92. <view class="tit1">项目管理</view>
  93. <view class="tit2">项目进展查询</view>
  94. </view>
  95. </view>
  96. </u-col>
  97. <u-col span="6">
  98. <view class="menu-item flex_l flex-colunm" @click="handleHomeLink('/pages/contract/index')">
  99. <view class="menu-img-box">
  100. <image class="menu-img" src="../../static/images/menu3.png" mode="scaleToFill" />
  101. </view>
  102. <view class="menu-info flex flex-column">
  103. <view class="tit1">合同管理</view>
  104. <view class="tit2">合同信息查阅</view>
  105. </view>
  106. </view>
  107. </u-col>
  108. </u-row>
  109. <u-row justify="space-between" gutter="14">
  110. <u-col span="6">
  111. <view class="menu-item flex_l flex-colunm" @click="handleHomeLink('/pages/distributor/index')">
  112. <view class="menu-img-box">
  113. <image class="menu-img" src="../../static/images/menu4.png" mode="scaleToFill" />
  114. </view>
  115. <view class="menu-info flex flex-column">
  116. <view class="tit1">合作伙伴</view>
  117. <view class="tit2">合作伙伴展示</view>
  118. </view>
  119. </view>
  120. </u-col>
  121. <u-col span="6">
  122. <view class="menu-item flex_l flex-colunm" @click="handleHomeLink()">
  123. <view class="menu-img-box">
  124. <image class="menu-img" src="../../static/images/menu6.png" mode="scaleToFill" />
  125. </view>
  126. <view class="menu-info flex flex-column">
  127. <view class="tit1">工单管理</view>
  128. <view class="tit2">工单进度查询</view>
  129. </view>
  130. </view>
  131. </u-col>
  132. </u-row>
  133. </view>
  134. <view class="data-container">
  135. <h4>个人看板</h4>
  136. <view class="flex flex-wrap flex-around">
  137. <view class="board-data" v-for="(v, i) in privateBoard" :key="i">
  138. <view>
  139. <u-text :bold="true" :text="v.report_data"></u-text>
  140. </view>
  141. <view>
  142. <u-text lines="1" :text="v.report_name"></u-text>
  143. </view>
  144. </view>
  145. </view>
  146. </view>
  147. <view class="data-container">
  148. <h4>个人报表</h4>
  149. <view class="echarts" v-for="item in echarts" :key="item.id">
  150. <h4>{{ item.report_name }}</h4>
  151. <view class="chart">
  152. <l-echart :ref="item.id + ''" @finished="init(item.id)"></l-echart>
  153. </view>
  154. </view>
  155. </view>
  156. </view>
  157. <!-- <view class="rank-wrap">
  158. <view class="rank-tit flex_l">
  159. <image class="rank-tit-img" src="../../static/images/rank-img.png" mode="scaleToFill" />
  160. <text>回款排名</text>
  161. </view>
  162. <view class="rank-list-wrap">
  163. <view class="rank-th">
  164. <u-row justify="space-between">
  165. <u-col span="2">
  166. <view class="th1 text-center">排名</view>
  167. </u-col>
  168. <u-col span="4">
  169. <view class="th2 text-center">姓名</view>
  170. </u-col>
  171. <u-col span="6">
  172. <view class="th3 text-center">回款额</view>
  173. </u-col>
  174. </u-row>
  175. </view>
  176. <view class="rank-list">
  177. <view class="rank-item" v-for="(v, i) in rankList" :key="i">
  178. <u-row justify="space-between">
  179. <u-col span="2">
  180. <view class="rank-box center">
  181. <image
  182. class="rank-img"
  183. v-if="i < 3"
  184. :src="require(`../../static/images/rank${i + 1}.png`)"
  185. mode=""></image>
  186. <view v-else class="th1 text-center rank">{{ i + 1 }}</view>
  187. </view>
  188. </u-col>
  189. <u-col span="4">
  190. <view class="th2 text-center">{{ v.name }}</view>
  191. </u-col>
  192. <u-col span="6">
  193. <view class="th3 text-center">
  194. <u-text mode="price" :text="v.money"></u-text>
  195. </view>
  196. </u-col>
  197. </u-row>
  198. </view>
  199. </view>
  200. <view class="view-all">查看全部排名 ></view>
  201. </view>
  202. </view> -->
  203. </view>
  204. <view class="check" @click="toCheckIn">卡</view>
  205. </view>
  206. </template>
  207. <script>
  208. import indexApi from '@/api/system/index.js'
  209. import homeApi from '@/api/home'
  210. import to from 'await-to-js'
  211. import LEchart from '@/uni_modules/lime-echart/components/l-echart/l-echart.vue'
  212. import * as echarts from '@/uni_modules/lime-echart/static/echarts.min'
  213. export default {
  214. name: 'omsIndex',
  215. data() {
  216. return {
  217. bannerList: [
  218. require('@/static/images/swiper/banner1.png'),
  219. require('@/static/images/swiper/banner2.png'),
  220. require('@/static/images/swiper/banner3.png'),
  221. ],
  222. privateBoard: [], //个人看板数据
  223. height: '',
  224. paddingTop: '',
  225. tabDate: 'week',
  226. newCustomer: 0,
  227. newBusiness: 0,
  228. newTask: 0,
  229. rankList: [
  230. // {
  231. // name: '邱国辉',
  232. // money: '100000',
  233. // },
  234. // {
  235. // name: '邱国辉',
  236. // money: '100000000',
  237. // },
  238. // {
  239. // name: '邱国辉',
  240. // money: '100000000',
  241. // },
  242. // {
  243. // name: '邱国辉',
  244. // money: '100000000',
  245. // },
  246. // {
  247. // name: '邱国辉',
  248. // money: '100000000',
  249. // },
  250. ],
  251. echarts: [],
  252. }
  253. },
  254. created() {
  255. const navData = uni.getMenuButtonBoundingClientRect()
  256. this.height = navData.height + 'px'
  257. this.paddingTop = navData.top + 'px'
  258. },
  259. mounted() {
  260. this.getHomeConfig()
  261. },
  262. onShow() {
  263. this.getReport('week')
  264. },
  265. components: {
  266. LEchart,
  267. },
  268. methods: {
  269. async getReport(type) {
  270. this.tabDate = type
  271. let params = { viewInterval: this.tabDate }
  272. const [err, res] = await to(homeApi.getReportData(params))
  273. if (err) return
  274. if (res.code == 200) {
  275. this.newCustomer = res.data.newCustomer
  276. this.newBusiness = res.data.newBusiness
  277. this.newTask = res.data.newTask
  278. }
  279. },
  280. handleHomeLink(url, linkType) {
  281. if (!url) {
  282. uni.showToast({
  283. title: '功能开发中~',
  284. icon: 'none',
  285. })
  286. return
  287. }
  288. if (linkType && linkType == '2') {
  289. uni.reLaunch({
  290. url,
  291. })
  292. } else {
  293. uni.navigateTo({
  294. //保留当前页面,跳转到应用内的某个页面
  295. url,
  296. })
  297. }
  298. },
  299. // 获取首页配置
  300. async getHomeConfig() {
  301. const [err, res] = await to(
  302. indexApi.getHomeReport({
  303. module_code: 'HomePage',
  304. })
  305. )
  306. if (err) return
  307. const obj = JSON.parse(res.data.configInfo)
  308. this.privateBoard = obj.num_report_config || []
  309. this.echarts = obj.data_report_config || []
  310. this.getHomeNumReportData()
  311. },
  312. // 获取首页个人看板数据
  313. async getHomeNumReportData() {
  314. let ids = this.privateBoard.map((item) => {
  315. return item.id
  316. })
  317. const {
  318. data: { num_report_response },
  319. } = await indexApi.getHomeNumReportData({ ids: ids })
  320. let privateBoardData = []
  321. this.privateBoard.forEach((item, index) => {
  322. num_report_response.forEach((val) => {
  323. if (item.id === val.id) {
  324. this.privateBoard[index].report_data = val.data
  325. privateBoardData.push(this.privateBoard[index])
  326. }
  327. })
  328. })
  329. this.privateBoard = privateBoardData.splice(0, 6)
  330. // console.log(this.privateBoard)
  331. },
  332. async init(id) {
  333. // console.log(id, 'id')
  334. const [err, res] = await to(
  335. indexApi.getHomeDataReportData({
  336. id,
  337. })
  338. )
  339. if (err) return
  340. const option = {
  341. grid: {
  342. bottom: 10,
  343. top: 20,
  344. right: 10,
  345. containLabel: true,
  346. },
  347. tooltip: {
  348. trigger: 'axis',
  349. },
  350. xAxis: [
  351. {
  352. type: 'category',
  353. data: res.data.data.xData,
  354. axisTick: {
  355. alignWithLabel: true,
  356. },
  357. },
  358. ],
  359. yAxis: [
  360. {
  361. type: 'value',
  362. name: '(元)',
  363. nameLocation: 'start',
  364. },
  365. ],
  366. series: [
  367. {
  368. name: '销售指标',
  369. type: 'bar',
  370. data: res.data.data.yDataTarget,
  371. },
  372. {
  373. name: '销售额度',
  374. type: 'bar',
  375. data: res.data.data.yDataReal,
  376. },
  377. ],
  378. }
  379. // console.log('option', option)
  380. this.$refs[id][0].init(echarts, (chart) => {
  381. chart.setOption(option)
  382. })
  383. },
  384. toCheckIn() {
  385. uni.navigateTo({
  386. //保留当前页面,跳转到应用内的某个页面
  387. url: '/pages/home/checkIn',
  388. })
  389. },
  390. },
  391. }
  392. </script>
  393. <style>
  394. page {
  395. background: #f2f3f5;
  396. }
  397. </style>
  398. <style lang="scss" scoped>
  399. .home {
  400. padding-top: 200rpx;
  401. // position: relative;
  402. .check {
  403. position: fixed;
  404. right: 20rpx;
  405. bottom: 20rpx;
  406. width: 90rpx;
  407. height: 90rpx;
  408. line-height: 90rpx;
  409. text-align: center;
  410. border-radius: 45rpx;
  411. background-color: #3e7ef8;
  412. color: #fff;
  413. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  414. }
  415. .nav {
  416. position: absolute;
  417. left: 0;
  418. top: 0;
  419. width: 100%;
  420. height: 556rpx;
  421. background: #3e7ef8;
  422. border-radius: 0 0 92rpx 92rpx;
  423. z-index: -1;
  424. .title {
  425. text-align: center;
  426. font-size: 32rpx;
  427. font-weight: bold;
  428. color: #ffffff;
  429. }
  430. }
  431. .main {
  432. box-sizing: border-box;
  433. padding: 0 0 46rpx;
  434. position: absolute;
  435. width: 100%;
  436. height: calc(100vh - 200rpx);
  437. .content {
  438. padding: 0 32rpx;
  439. }
  440. // overflow: hidden;
  441. .msg-box {
  442. width: 100%;
  443. height: 185rpx;
  444. background: #ffffff;
  445. box-shadow: 0 6rpx 19rpx 2rpx rgba(0, 45, 132, 0.15);
  446. border-radius: 31rpx 31rpx 31rpx 31rpx;
  447. margin: 0 auto;
  448. .tab-date-wrap {
  449. padding: 8rpx 0 24rpx 38rpx;
  450. .tab-date-item {
  451. font-size: 24rpx;
  452. font-weight: bold;
  453. color: #d8e5fe;
  454. margin-right: 16rpx;
  455. }
  456. .dateActive {
  457. font-size: 28rpx;
  458. color: #3e7ef8;
  459. }
  460. }
  461. .date-msg {
  462. .num {
  463. font-size: 38rpx;
  464. font-weight: bold;
  465. color: #fe6936;
  466. margin-bottom: 4rpx;
  467. }
  468. .txt {
  469. font-size: 24rpx;
  470. color: #646464;
  471. }
  472. }
  473. }
  474. .menu-wrap {
  475. .menu-item {
  476. margin-top: 32rpx;
  477. background: #ffffff;
  478. box-shadow: 0 6rpx 19rpx 2rpx rgba(0, 45, 132, 0.15);
  479. border-radius: 31rpx;
  480. padding: 40rpx 0 40rpx 52rpx;
  481. .menu-img-box {
  482. margin-right: 14rpx;
  483. display: flex;
  484. align-items: center;
  485. justify-content: center;
  486. }
  487. .menu-img {
  488. width: 36px;
  489. height: 36px;
  490. }
  491. .menu-info {
  492. display: flex;
  493. .tit1 {
  494. font-size: 28rpx;
  495. font-weight: bold;
  496. color: #323232;
  497. margin-bottom: 12rpx;
  498. }
  499. .tit2 {
  500. font-size: 24rpx;
  501. color: #646464;
  502. }
  503. }
  504. }
  505. }
  506. .rank-wrap {
  507. margin-top: 34rpx;
  508. .rank-tit {
  509. margin-bottom: 18rpx;
  510. .rank-tit-img {
  511. margin: 0 10rpx 0 28rpx;
  512. width: 31rpx;
  513. height: 31rpx;
  514. }
  515. text {
  516. font-size: 28rpx;
  517. font-weight: bold;
  518. color: #323232;
  519. }
  520. }
  521. .rank-list-wrap {
  522. width: 100%;
  523. background: #ffffff;
  524. border-radius: 31rpx;
  525. .rank-th {
  526. padding: 34rpx 0 20rpx 72rpx;
  527. }
  528. .rank-list {
  529. margin-bottom: 24rpx;
  530. .rank-item {
  531. .rank-box {
  532. .rank-img {
  533. width: 41px;
  534. height: 42px;
  535. }
  536. .rank {
  537. width: 41px;
  538. height: 42px;
  539. line-height: 42px;
  540. font-size: 28rpx;
  541. font-weight: bold;
  542. color: #969696;
  543. }
  544. }
  545. padding: 19rpx 0 19rpx 72rpx;
  546. &:not(:last-child) {
  547. border-bottom: 2rpx solid #f2f3f5;
  548. }
  549. }
  550. }
  551. }
  552. .view-all {
  553. font-size: 24rpx;
  554. color: #3e7ef8;
  555. text-align: center;
  556. height: 60rpx;
  557. }
  558. }
  559. .data-container {
  560. background-color: #fff;
  561. box-shadow: 0 6rpx 19rpx 2rpx rgba(0, 45, 132, 0.15);
  562. border-radius: 31rpx 31rpx 31rpx 31rpx;
  563. margin: 0 auto;
  564. margin-top: 32rpx;
  565. padding: 0 20rpx 20rpx;
  566. h4 {
  567. font-size: 28rpx;
  568. line-height: 80rpx;
  569. font-weight: bold;
  570. color: #323232;
  571. padding-left: 40rpx;
  572. }
  573. .board-data {
  574. width: 46%;
  575. border-radius: 10rpx;
  576. padding: 0 20rpx;
  577. border: 1px solid #eee;
  578. line-height: 50rpx;
  579. margin-bottom: 20rpx;
  580. }
  581. .echarts {
  582. height: 480rpx;
  583. box-shadow: 0 6rpx 19rpx 2rpx rgba(0, 45, 132, 0.15);
  584. border-radius: 31rpx 31rpx 31rpx 31rpx;
  585. + .echarts {
  586. margin-top: 32rpx;
  587. }
  588. .chart {
  589. height: 400rpx;
  590. }
  591. }
  592. }
  593. }
  594. }
  595. </style>