index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734
  1. <!--
  2. * @Author: liuzhenlin 461480418@qq.ocm
  3. * @Date: 2023-01-12 11:57:48
  4. * @LastEditors: liuzhenlin
  5. * @LastEditTime: 2023-03-10 16:59:38
  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. <view class="flex">
  151. <h4>{{ item.report_name }}</h4>
  152. <view class="center" style="padding-left: 30rpx" v-if="item.id == 20006">
  153. <u-button
  154. :text="saleVal"
  155. type="primary"
  156. size="mini"
  157. @click="
  158. showSaleType = true
  159. hideKeyboard()
  160. "></u-button>
  161. </view>
  162. <view class="center" style="padding-left: 30rpx" v-if="item.id == 20007">
  163. <u-button
  164. :text="collectionVal"
  165. type="primary"
  166. size="mini"
  167. @click="
  168. showCollectionType = true
  169. hideKeyboard()
  170. "></u-button>
  171. </view>
  172. </view>
  173. <view class="chart">
  174. <l-echart :ref="item.id + ''" @finished="init(item.id)"></l-echart>
  175. </view>
  176. </view>
  177. </view>
  178. </view>
  179. <!-- <view class="rank-wrap">
  180. <view class="rank-tit flex_l">
  181. <image class="rank-tit-img" src="../../static/images/rank-img.png" mode="scaleToFill" />
  182. <text>回款排名</text>
  183. </view>
  184. <view class="rank-list-wrap">
  185. <view class="rank-th">
  186. <u-row justify="space-between">
  187. <u-col span="2">
  188. <view class="th1 text-center">排名</view>
  189. </u-col>
  190. <u-col span="4">
  191. <view class="th2 text-center">姓名</view>
  192. </u-col>
  193. <u-col span="6">
  194. <view class="th3 text-center">回款额</view>
  195. </u-col>
  196. </u-row>
  197. </view>
  198. <view class="rank-list">
  199. <view class="rank-item" v-for="(v, i) in rankList" :key="i">
  200. <u-row justify="space-between">
  201. <u-col span="2">
  202. <view class="rank-box center">
  203. <image
  204. class="rank-img"
  205. v-if="i < 3"
  206. :src="require(`../../static/images/rank${i + 1}.png`)"
  207. mode=""></image>
  208. <view v-else class="th1 text-center rank">{{ i + 1 }}</view>
  209. </view>
  210. </u-col>
  211. <u-col span="4">
  212. <view class="th2 text-center">{{ v.name }}</view>
  213. </u-col>
  214. <u-col span="6">
  215. <view class="th3 text-center">
  216. <u-text mode="price" :text="v.money"></u-text>
  217. </view>
  218. </u-col>
  219. </u-row>
  220. </view>
  221. </view>
  222. <view class="view-all">查看全部排名 ></view>
  223. </view>
  224. </view> -->
  225. </view>
  226. <view class="check" @click="toCheckIn">卡</view>
  227. <u-action-sheet
  228. :show="showSaleType"
  229. :actions="quarter"
  230. title="请选择季度"
  231. @close="showSaleType = false"
  232. @select="selectSaleVal"></u-action-sheet>
  233. <u-action-sheet
  234. :show="showCollectionType"
  235. :actions="quarter"
  236. title="请选择季度"
  237. @close="showCollectionType = false"
  238. @select="selectCollectionVal"></u-action-sheet>
  239. </view>
  240. </template>
  241. <script>
  242. import indexApi from '@/api/system/index.js'
  243. import homeApi from '@/api/home'
  244. import to from 'await-to-js'
  245. import LEchart from '@/uni_modules/lime-echart/components/l-echart/l-echart.vue'
  246. import * as echarts from '@/uni_modules/lime-echart/static/echarts.min'
  247. export default {
  248. name: 'omsIndex',
  249. data() {
  250. return {
  251. showSaleType: false,
  252. showCollectionType: false,
  253. saleVal: '全年',
  254. collectionVal: '全年',
  255. saleType: 0,
  256. collectionType: 0,
  257. quarter: [
  258. {
  259. name: '一季度',
  260. type: 1,
  261. },
  262. {
  263. name: '二季度',
  264. type: 2,
  265. },
  266. {
  267. name: '三季度',
  268. type: 3,
  269. },
  270. {
  271. name: '四季度',
  272. type: 4,
  273. },
  274. {
  275. name: '全年',
  276. type: 0,
  277. },
  278. ],
  279. bannerList: [
  280. require('@/static/images/swiper/banner1.png'),
  281. require('@/static/images/swiper/banner2.png'),
  282. require('@/static/images/swiper/banner3.png'),
  283. ],
  284. privateBoard: [], //个人看板数据
  285. height: '',
  286. paddingTop: '',
  287. tabDate: 'week',
  288. newCustomer: 0,
  289. newBusiness: 0,
  290. newTask: 0,
  291. rankList: [
  292. // {
  293. // name: '邱国辉',
  294. // money: '100000',
  295. // },
  296. // {
  297. // name: '邱国辉',
  298. // money: '100000000',
  299. // },
  300. // {
  301. // name: '邱国辉',
  302. // money: '100000000',
  303. // },
  304. // {
  305. // name: '邱国辉',
  306. // money: '100000000',
  307. // },
  308. // {
  309. // name: '邱国辉',
  310. // money: '100000000',
  311. // },
  312. ],
  313. echarts: [],
  314. }
  315. },
  316. created() {
  317. const navData = uni.getMenuButtonBoundingClientRect()
  318. this.height = navData.height + 'px'
  319. this.paddingTop = navData.top + 'px'
  320. },
  321. mounted() {
  322. this.getHomeConfig()
  323. },
  324. onShow() {
  325. this.getReport('week')
  326. },
  327. components: {
  328. LEchart,
  329. },
  330. methods: {
  331. selectSaleVal(e) {
  332. this.saleVal = e.name
  333. this.saleType = e.type
  334. this.init(20006)
  335. },
  336. selectCollectionVal(e) {
  337. this.collectionVal = e.name
  338. this.collectionType = e.type
  339. this.init(20007)
  340. },
  341. async getReport(type) {
  342. this.tabDate = type
  343. let params = { viewInterval: this.tabDate }
  344. const [err, res] = await to(homeApi.getReportData(params))
  345. if (err) return
  346. if (res.code == 200) {
  347. this.newCustomer = res.data.newCustomer
  348. this.newBusiness = res.data.newBusiness
  349. this.newTask = res.data.newTask
  350. }
  351. },
  352. handleHomeLink(url, linkType) {
  353. if (!url) {
  354. uni.showToast({
  355. title: '功能开发中~',
  356. icon: 'none',
  357. })
  358. return
  359. }
  360. if (linkType && linkType == '2') {
  361. uni.reLaunch({
  362. url,
  363. })
  364. } else {
  365. uni.navigateTo({
  366. //保留当前页面,跳转到应用内的某个页面
  367. url,
  368. })
  369. }
  370. },
  371. // 获取首页配置
  372. async getHomeConfig() {
  373. const [err, res] = await to(
  374. indexApi.getHomeReport({
  375. module_code: 'HomePage',
  376. })
  377. )
  378. if (err) return
  379. if (res && res.data) {
  380. const obj = JSON.parse(res.data.configInfo)
  381. this.privateBoard = obj.num_report_config || []
  382. this.echarts = obj.data_report_config || []
  383. this.getHomeNumReportData()
  384. }
  385. },
  386. // 获取首页个人看板数据
  387. async getHomeNumReportData() {
  388. let ids = this.privateBoard.map((item) => {
  389. return item.id
  390. })
  391. const {
  392. data: { num_report_response },
  393. } = await indexApi.getHomeNumReportData({ ids: ids })
  394. let privateBoardData = []
  395. this.privateBoard.forEach((item, index) => {
  396. num_report_response.forEach((val) => {
  397. if (item.id === val.id) {
  398. this.privateBoard[index].report_data = val.data
  399. privateBoardData.push(this.privateBoard[index])
  400. }
  401. })
  402. })
  403. this.privateBoard = privateBoardData.splice(0, 6)
  404. },
  405. async init(id) {
  406. let params = {}
  407. if (id == 20006) {
  408. params = {
  409. Params: { year: new Date().getFullYear(), quarter: this.saleType },
  410. id,
  411. }
  412. } else if (id == 20007) {
  413. params = {
  414. Params: { year: new Date().getFullYear(), quarter: this.collectionType },
  415. id,
  416. }
  417. } else {
  418. params = {
  419. Params: {},
  420. id,
  421. }
  422. }
  423. const [err, res] = await to(indexApi.getHomeDataReportData(params))
  424. if (err) return
  425. let yAxis =
  426. id == 20006 || id == 20007
  427. ? [
  428. {
  429. type: 'value',
  430. name: '金额(元)',
  431. alignTicks: true,
  432. },
  433. ]
  434. : [
  435. {
  436. type: 'value',
  437. name: '金额(元)',
  438. alignTicks: true,
  439. },
  440. {
  441. type: 'value',
  442. name: res.data.id == 20000 || 20002 ? '签约完成率(%)' : '回款率(%)',
  443. min: 0,
  444. max: 100,
  445. alignTicks: true,
  446. interval: 20,
  447. axisLabel: {
  448. formatter: '{value} %',
  449. },
  450. },
  451. ]
  452. const option = {
  453. grid: {
  454. bottom: 30,
  455. top: 40,
  456. right: 10,
  457. left: 10,
  458. containLabel: true,
  459. },
  460. tooltip: {
  461. trigger: 'axis',
  462. },
  463. xAxis: [
  464. {
  465. type: 'category',
  466. data: res.data.data ? res.data.data.xData : [],
  467. axisTick: {
  468. alignWithLabel: true,
  469. },
  470. },
  471. ],
  472. yAxis,
  473. series: [
  474. {
  475. name: '销售指标',
  476. type: 'bar',
  477. data: res.data.data ? res.data.data.yDataTarget : [],
  478. },
  479. {
  480. name: '销售额度',
  481. type: 'bar',
  482. data: res.data.data ? res.data.data.yDataReal : [],
  483. },
  484. ],
  485. }
  486. this.$refs[id][0].init(echarts, (chart) => {
  487. chart.setOption(option)
  488. })
  489. },
  490. toCheckIn() {
  491. uni.navigateTo({
  492. //保留当前页面,跳转到应用内的某个页面
  493. url: '/pages/home/checkIn',
  494. })
  495. },
  496. },
  497. }
  498. </script>
  499. <style>
  500. page {
  501. background: #f2f3f5;
  502. }
  503. </style>
  504. <style lang="scss" scoped>
  505. .home {
  506. padding-top: 200rpx;
  507. // position: relative;
  508. .check {
  509. position: fixed;
  510. right: 20rpx;
  511. bottom: 20rpx;
  512. width: 90rpx;
  513. height: 90rpx;
  514. line-height: 90rpx;
  515. text-align: center;
  516. border-radius: 45rpx;
  517. background-color: #3e7ef8;
  518. color: #fff;
  519. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  520. }
  521. .nav {
  522. position: absolute;
  523. left: 0;
  524. top: 0;
  525. width: 100%;
  526. height: 556rpx;
  527. background: #3e7ef8;
  528. border-radius: 0 0 92rpx 92rpx;
  529. z-index: -1;
  530. .title {
  531. text-align: center;
  532. font-size: 32rpx;
  533. font-weight: bold;
  534. color: #ffffff;
  535. }
  536. }
  537. .main {
  538. box-sizing: border-box;
  539. padding: 0 0 46rpx;
  540. position: absolute;
  541. width: 100%;
  542. height: calc(100vh - 200rpx);
  543. .content {
  544. padding: 0 32rpx;
  545. }
  546. // overflow: hidden;
  547. .msg-box {
  548. width: 100%;
  549. height: 185rpx;
  550. background: #ffffff;
  551. box-shadow: 0 6rpx 19rpx 2rpx rgba(0, 45, 132, 0.15);
  552. border-radius: 31rpx 31rpx 31rpx 31rpx;
  553. margin: 0 auto;
  554. .tab-date-wrap {
  555. padding: 8rpx 0 24rpx 38rpx;
  556. .tab-date-item {
  557. font-size: 24rpx;
  558. font-weight: bold;
  559. color: #d8e5fe;
  560. margin-right: 16rpx;
  561. }
  562. .dateActive {
  563. font-size: 28rpx;
  564. color: #3e7ef8;
  565. }
  566. }
  567. .date-msg {
  568. .num {
  569. font-size: 38rpx;
  570. font-weight: bold;
  571. color: #fe6936;
  572. margin-bottom: 4rpx;
  573. }
  574. .txt {
  575. font-size: 24rpx;
  576. color: #646464;
  577. }
  578. }
  579. }
  580. .menu-wrap {
  581. .menu-item {
  582. margin-top: 32rpx;
  583. background: #ffffff;
  584. box-shadow: 0 6rpx 19rpx 2rpx rgba(0, 45, 132, 0.15);
  585. border-radius: 31rpx;
  586. padding: 40rpx 0 40rpx 52rpx;
  587. .menu-img-box {
  588. margin-right: 14rpx;
  589. display: flex;
  590. align-items: center;
  591. justify-content: center;
  592. }
  593. .menu-img {
  594. width: 36px;
  595. height: 36px;
  596. }
  597. .menu-info {
  598. display: flex;
  599. .tit1 {
  600. font-size: 28rpx;
  601. font-weight: bold;
  602. color: #323232;
  603. margin-bottom: 12rpx;
  604. }
  605. .tit2 {
  606. font-size: 24rpx;
  607. color: #646464;
  608. }
  609. }
  610. }
  611. }
  612. .rank-wrap {
  613. margin-top: 34rpx;
  614. .rank-tit {
  615. margin-bottom: 18rpx;
  616. .rank-tit-img {
  617. margin: 0 10rpx 0 28rpx;
  618. width: 31rpx;
  619. height: 31rpx;
  620. }
  621. text {
  622. font-size: 28rpx;
  623. font-weight: bold;
  624. color: #323232;
  625. }
  626. }
  627. .rank-list-wrap {
  628. width: 100%;
  629. background: #ffffff;
  630. border-radius: 31rpx;
  631. .rank-th {
  632. padding: 34rpx 0 20rpx 72rpx;
  633. }
  634. .rank-list {
  635. margin-bottom: 24rpx;
  636. .rank-item {
  637. .rank-box {
  638. .rank-img {
  639. width: 41px;
  640. height: 42px;
  641. }
  642. .rank {
  643. width: 41px;
  644. height: 42px;
  645. line-height: 42px;
  646. font-size: 28rpx;
  647. font-weight: bold;
  648. color: #969696;
  649. }
  650. }
  651. padding: 19rpx 0 19rpx 72rpx;
  652. &:not(:last-child) {
  653. border-bottom: 2rpx solid #f2f3f5;
  654. }
  655. }
  656. }
  657. }
  658. .view-all {
  659. font-size: 24rpx;
  660. color: #3e7ef8;
  661. text-align: center;
  662. height: 60rpx;
  663. }
  664. }
  665. .data-container {
  666. background-color: #fff;
  667. box-shadow: 0 6rpx 19rpx 2rpx rgba(0, 45, 132, 0.15);
  668. border-radius: 31rpx 31rpx 31rpx 31rpx;
  669. margin: 0 auto;
  670. margin-top: 32rpx;
  671. padding: 0 20rpx 20rpx;
  672. h4 {
  673. font-size: 28rpx;
  674. line-height: 80rpx;
  675. font-weight: bold;
  676. color: #323232;
  677. padding-left: 40rpx;
  678. }
  679. .board-data {
  680. width: 46%;
  681. border-radius: 10rpx;
  682. padding: 0 20rpx;
  683. border: 1px solid #eee;
  684. line-height: 50rpx;
  685. margin-bottom: 20rpx;
  686. }
  687. .echarts {
  688. height: 500rpx;
  689. box-shadow: 0 6rpx 19rpx 2rpx rgba(0, 45, 132, 0.15);
  690. border-radius: 31rpx 31rpx 31rpx 31rpx;
  691. + .echarts {
  692. margin-top: 32rpx;
  693. }
  694. .chart {
  695. height: 420rpx;
  696. }
  697. }
  698. }
  699. }
  700. }
  701. </style>