index.vue 18 KB

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