index.vue 21 KB

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