index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736
  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. const obj = JSON.parse(res.data.configInfo)
  380. this.privateBoard = obj.num_report_config || []
  381. this.echarts = obj.data_report_config || []
  382. this.getHomeNumReportData()
  383. },
  384. // 获取首页个人看板数据
  385. async getHomeNumReportData() {
  386. let ids = this.privateBoard.map((item) => {
  387. return item.id
  388. })
  389. const {
  390. data: { num_report_response },
  391. } = await indexApi.getHomeNumReportData({ ids: ids })
  392. let privateBoardData = []
  393. this.privateBoard.forEach((item, index) => {
  394. num_report_response.forEach((val) => {
  395. if (item.id === val.id) {
  396. this.privateBoard[index].report_data = val.data
  397. privateBoardData.push(this.privateBoard[index])
  398. }
  399. })
  400. })
  401. this.privateBoard = privateBoardData.splice(0, 6)
  402. // console.log(this.privateBoard)
  403. },
  404. async init(id) {
  405. // console.log(id, '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. console.log(res)
  425. if (err) return
  426. let yAxis =
  427. id == 20006 || id == 20007
  428. ? [
  429. {
  430. type: 'value',
  431. name: '金额(元)',
  432. alignTicks: true,
  433. },
  434. ]
  435. : [
  436. {
  437. type: 'value',
  438. name: '金额(元)',
  439. alignTicks: true,
  440. },
  441. {
  442. type: 'value',
  443. name: res.data.id == 20000 ? '签约完成率(%)' : '回款率(%)',
  444. min: 0,
  445. max: 100,
  446. alignTicks: true,
  447. interval: 20,
  448. axisLabel: {
  449. formatter: '{value} %',
  450. },
  451. },
  452. ]
  453. const option = {
  454. grid: {
  455. bottom: 30,
  456. top: 40,
  457. right: 10,
  458. left: 10,
  459. containLabel: true,
  460. },
  461. tooltip: {
  462. trigger: 'axis',
  463. },
  464. xAxis: [
  465. {
  466. type: 'category',
  467. data: res.data.data ? res.data.data.xData : [],
  468. axisTick: {
  469. alignWithLabel: true,
  470. },
  471. },
  472. ],
  473. yAxis,
  474. series: [
  475. {
  476. name: '销售指标',
  477. type: 'bar',
  478. data: res.data.data ? res.data.data.yDataTarget : [],
  479. },
  480. {
  481. name: '销售额度',
  482. type: 'bar',
  483. data: res.data.data ? res.data.data.yDataReal : [],
  484. },
  485. ],
  486. }
  487. // console.log('option', option)
  488. this.$refs[id][0].init(echarts, (chart) => {
  489. chart.setOption(option)
  490. })
  491. },
  492. toCheckIn() {
  493. uni.navigateTo({
  494. //保留当前页面,跳转到应用内的某个页面
  495. url: '/pages/home/checkIn',
  496. })
  497. },
  498. },
  499. }
  500. </script>
  501. <style>
  502. page {
  503. background: #f2f3f5;
  504. }
  505. </style>
  506. <style lang="scss" scoped>
  507. .home {
  508. padding-top: 200rpx;
  509. // position: relative;
  510. .check {
  511. position: fixed;
  512. right: 20rpx;
  513. bottom: 20rpx;
  514. width: 90rpx;
  515. height: 90rpx;
  516. line-height: 90rpx;
  517. text-align: center;
  518. border-radius: 45rpx;
  519. background-color: #3e7ef8;
  520. color: #fff;
  521. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  522. }
  523. .nav {
  524. position: absolute;
  525. left: 0;
  526. top: 0;
  527. width: 100%;
  528. height: 556rpx;
  529. background: #3e7ef8;
  530. border-radius: 0 0 92rpx 92rpx;
  531. z-index: -1;
  532. .title {
  533. text-align: center;
  534. font-size: 32rpx;
  535. font-weight: bold;
  536. color: #ffffff;
  537. }
  538. }
  539. .main {
  540. box-sizing: border-box;
  541. padding: 0 0 46rpx;
  542. position: absolute;
  543. width: 100%;
  544. height: calc(100vh - 200rpx);
  545. .content {
  546. padding: 0 32rpx;
  547. }
  548. // overflow: hidden;
  549. .msg-box {
  550. width: 100%;
  551. height: 185rpx;
  552. background: #ffffff;
  553. box-shadow: 0 6rpx 19rpx 2rpx rgba(0, 45, 132, 0.15);
  554. border-radius: 31rpx 31rpx 31rpx 31rpx;
  555. margin: 0 auto;
  556. .tab-date-wrap {
  557. padding: 8rpx 0 24rpx 38rpx;
  558. .tab-date-item {
  559. font-size: 24rpx;
  560. font-weight: bold;
  561. color: #d8e5fe;
  562. margin-right: 16rpx;
  563. }
  564. .dateActive {
  565. font-size: 28rpx;
  566. color: #3e7ef8;
  567. }
  568. }
  569. .date-msg {
  570. .num {
  571. font-size: 38rpx;
  572. font-weight: bold;
  573. color: #fe6936;
  574. margin-bottom: 4rpx;
  575. }
  576. .txt {
  577. font-size: 24rpx;
  578. color: #646464;
  579. }
  580. }
  581. }
  582. .menu-wrap {
  583. .menu-item {
  584. margin-top: 32rpx;
  585. background: #ffffff;
  586. box-shadow: 0 6rpx 19rpx 2rpx rgba(0, 45, 132, 0.15);
  587. border-radius: 31rpx;
  588. padding: 40rpx 0 40rpx 52rpx;
  589. .menu-img-box {
  590. margin-right: 14rpx;
  591. display: flex;
  592. align-items: center;
  593. justify-content: center;
  594. }
  595. .menu-img {
  596. width: 36px;
  597. height: 36px;
  598. }
  599. .menu-info {
  600. display: flex;
  601. .tit1 {
  602. font-size: 28rpx;
  603. font-weight: bold;
  604. color: #323232;
  605. margin-bottom: 12rpx;
  606. }
  607. .tit2 {
  608. font-size: 24rpx;
  609. color: #646464;
  610. }
  611. }
  612. }
  613. }
  614. .rank-wrap {
  615. margin-top: 34rpx;
  616. .rank-tit {
  617. margin-bottom: 18rpx;
  618. .rank-tit-img {
  619. margin: 0 10rpx 0 28rpx;
  620. width: 31rpx;
  621. height: 31rpx;
  622. }
  623. text {
  624. font-size: 28rpx;
  625. font-weight: bold;
  626. color: #323232;
  627. }
  628. }
  629. .rank-list-wrap {
  630. width: 100%;
  631. background: #ffffff;
  632. border-radius: 31rpx;
  633. .rank-th {
  634. padding: 34rpx 0 20rpx 72rpx;
  635. }
  636. .rank-list {
  637. margin-bottom: 24rpx;
  638. .rank-item {
  639. .rank-box {
  640. .rank-img {
  641. width: 41px;
  642. height: 42px;
  643. }
  644. .rank {
  645. width: 41px;
  646. height: 42px;
  647. line-height: 42px;
  648. font-size: 28rpx;
  649. font-weight: bold;
  650. color: #969696;
  651. }
  652. }
  653. padding: 19rpx 0 19rpx 72rpx;
  654. &:not(:last-child) {
  655. border-bottom: 2rpx solid #f2f3f5;
  656. }
  657. }
  658. }
  659. }
  660. .view-all {
  661. font-size: 24rpx;
  662. color: #3e7ef8;
  663. text-align: center;
  664. height: 60rpx;
  665. }
  666. }
  667. .data-container {
  668. background-color: #fff;
  669. box-shadow: 0 6rpx 19rpx 2rpx rgba(0, 45, 132, 0.15);
  670. border-radius: 31rpx 31rpx 31rpx 31rpx;
  671. margin: 0 auto;
  672. margin-top: 32rpx;
  673. padding: 0 20rpx 20rpx;
  674. h4 {
  675. font-size: 28rpx;
  676. line-height: 80rpx;
  677. font-weight: bold;
  678. color: #323232;
  679. padding-left: 40rpx;
  680. }
  681. .board-data {
  682. width: 46%;
  683. border-radius: 10rpx;
  684. padding: 0 20rpx;
  685. border: 1px solid #eee;
  686. line-height: 50rpx;
  687. margin-bottom: 20rpx;
  688. }
  689. .echarts {
  690. height: 500rpx;
  691. box-shadow: 0 6rpx 19rpx 2rpx rgba(0, 45, 132, 0.15);
  692. border-radius: 31rpx 31rpx 31rpx 31rpx;
  693. + .echarts {
  694. margin-top: 32rpx;
  695. }
  696. .chart {
  697. height: 420rpx;
  698. }
  699. }
  700. }
  701. }
  702. }
  703. </style>