index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. <template>
  2. <view class="container">
  3. <view class="title">
  4. <view class="title-text">{{title}}</view>
  5. </view>
  6. <view class="header">
  7. <view class="query">
  8. <u-row customStyle="margin-bottom: 10px" gutter="20">
  9. <u-col span="9">
  10. <u--input
  11. @focus="timeShow = true"
  12. v-model="startTimeXd"
  13. placeholder="开始日期 ~ 结束日期"
  14. prefixIcon="calendar"
  15. prefixIconStyle="font-size: 22px;color: #909399"
  16. ></u--input>
  17. </u-col>
  18. <u-col span="3">
  19. <view class="query-btn" @click="timeShow = !timeShow">
  20. <view class="query-btn-icon">
  21. </view>
  22. <view class="query-btn-text">筛选</view>
  23. </view>
  24. </u-col>
  25. </u-row>
  26. </view>
  27. <view class="filter">
  28. <view class="item-one">
  29. <view class="type-icon-hexiao"></view>
  30. <view class="type-data">
  31. <view class="number">{{hexiaoNumber}}</view>
  32. <view class="text">核销</view>
  33. </view>
  34. </view>
  35. <view class="item-one" v-if="type === 2">
  36. <view class="type-icon-xundian"></view>
  37. <view class="type-data">
  38. <view class="number">{{ xundianNumber}}</view>
  39. <view class="text">巡店</view>
  40. </view>
  41. </view>
  42. <view class="item-one" v-if="type !== 3">
  43. <view class="type-icon-shanghuo"></view>
  44. <view class="type-data">
  45. <view class="number">{{ shangHuoNumber}}</view>
  46. <view class="text">上货</view>
  47. </view>
  48. </view>
  49. <view class="item-one" v-if="type === 3">
  50. <view class="type-icon-xiadan"></view>
  51. <view class="type-data">
  52. <view class="number">{{xiaDanNumber}}</view>
  53. <view class="text">下单</view>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. <view class="content">
  59. <view class="t-one">
  60. <view class="t-text">核销和上货趋势统计</view>
  61. <view class="charts-box">
  62. <qiun-data-charts
  63. type="line"
  64. :opts="opts"
  65. :chartData="chartData"
  66. />
  67. </view>
  68. </view>
  69. <view class="t-one" v-show=" type == 2">
  70. <view class="t-text">巡店统计</view>
  71. <view class="charts-box">
  72. <qiun-data-charts
  73. type="column"
  74. :opts="opts"
  75. :chartData="chartDataXd"
  76. />
  77. </view>
  78. </view>
  79. </view>
  80. <u-popup :show="show" mode="bottom" @close="show = false" >
  81. <view class="popup-content">
  82. <view class="popup-text">筛选</view>
  83. <u-row customStyle="margin-bottom: 10px">
  84. <u-col span="3">
  85. <view class="explain">选择日期</view>
  86. </u-col>
  87. <u-col span="9">
  88. <u--input
  89. v-model="startTimeXd"
  90. placeholder="开始日期 ~ 结束日期"
  91. prefixIcon="calendar"
  92. prefixIconStyle="font-size: 22px;color: #909399"
  93. @focus="timeShow = true"
  94. ></u--input>
  95. </u-col>
  96. </u-row>
  97. <u-row customStyle="margin-bottom: 10px">
  98. <u-col span="3">
  99. <view class="explain">门店名称</view>
  100. </u-col>
  101. <u-col span="9">
  102. <u--input
  103. placeholder="请输入内容"
  104. border="surround"
  105. ></u--input>
  106. </u-col>
  107. </u-row>
  108. <u-row customStyle="margin-bottom: 10px">
  109. <u-col span="3">
  110. <view class="explain">业务员</view>
  111. </u-col>
  112. <u-col span="9">
  113. <u--input
  114. placeholder="请输入内容"
  115. border="surround"
  116. ></u--input>
  117. </u-col>
  118. </u-row>
  119. <u-row customStyle="margin-bottom: 10px">
  120. <u-col span="3">
  121. <view class="explain">订单编号</view>
  122. </u-col>
  123. <u-col span="9">
  124. <u--input
  125. placeholder="请输入内容"
  126. border="surround"
  127. ></u--input>
  128. </u-col>
  129. </u-row>
  130. <view class="popup-btn">
  131. <u-button class="popup-btn-one">搜索</u-button>
  132. <u-button class="popup-btn-one" type="primary">重置</u-button>
  133. </view>
  134. </view>
  135. </u-popup>
  136. <u-calendar :minDate="minDate" :monthNumber="6" :show="timeShow" :mode="mode" @confirm="confirm" @close="timeShow = false"></u-calendar>
  137. </view>
  138. </template>
  139. <script>
  140. import {getSalesTotal,getSalesTrend,getSalesmanSalesTotal,getSalesmanSalesTrend,getSalesmanVisitTrend,getStoreSalesSummary,getStoreSalesTrend} from "../../../api/hexiao";
  141. export default {
  142. data() {
  143. return {
  144. storeId: 0,
  145. ywyId:0,
  146. minDate: new Date(new Date().setMonth(new Date().getMonth() - 2)),
  147. maxDate: new Date(),
  148. hexiaoNumber: 0,
  149. xundianNumber: 0,
  150. shangHuoNumber: 0,
  151. xiaDanNumber: 0,
  152. type: 1,
  153. title: '',
  154. startTime: '',
  155. endTime: '',
  156. startTimeXd: '',
  157. timeShow: false,
  158. mode: 'range',
  159. show: false,
  160. chartDataXd: {},
  161. chartData: {},
  162. //您可以通过修改 config-ucharts.js 文件中下标为 ['line'] 的节点来配置全局默认参数,如都是默认参数,此处可以不传 opts 。实际应用过程中 opts 只需传入与全局默认参数中不一致的【某一个属性】即可实现同类型的图表显示不同的样式,达到页面简洁的需求。
  163. opts: {
  164. height: 210,
  165. color: ["#1890FF","#91CB74","#FAC858","#EE6666","#73C0DE","#3CA272","#FC8452","#9A60B4","#ea7ccc"],
  166. padding: [15,10,0,15],
  167. enableScroll: false,
  168. legend: {},
  169. xAxis: {
  170. disableGrid: true
  171. },
  172. yAxis: {
  173. gridType: "dash",
  174. dashLength: 2
  175. },
  176. extra: {
  177. line: {
  178. type: "straight",
  179. width: 2,
  180. activeType: "hollow"
  181. }
  182. }
  183. }
  184. };
  185. },
  186. onLoad: function(options) {
  187. //门店
  188. if (options.type == 1){
  189. this.title = '门店销售数据';
  190. this.type = 1;
  191. this.storeId = options.storeId;
  192. this.initMenDian();
  193. }
  194. //业务员
  195. if (options.type == 2){
  196. this.title = '业务员销售数据';
  197. this.type = 2;
  198. this.ywyId = options.ywyId;
  199. console.log(this.type);
  200. this.initYWY();
  201. }
  202. //经销商
  203. if (options.type == 3){
  204. this.title = '经销商销售数据';
  205. this.type = 3;
  206. this.initJXS();
  207. }
  208. },
  209. onReady() {
  210. },
  211. methods: {
  212. initMenDian() {
  213. let that = this;
  214. getStoreSalesSummary(this.startTime,this.endTime,this.storeId).then(res => {
  215. if (res.code === 0){
  216. that.hexiaoNumber = res.data.verificationTotal;
  217. that.shangHuoNumber = res.data.activateTotal;
  218. }
  219. }).catch(err => {
  220. });
  221. getStoreSalesTrend(this.startTime,this.endTime,this.storeId).then(resData => {
  222. if (resData.code === 0){
  223. let apiResponse = resData.data;
  224. // 提取日期列表并排序
  225. let categories = apiResponse.map(item => {
  226. // 从日期中提取月日,例如 "2025-08-01" -> "08-01" -> "8/1" 或者只显示日 "1"
  227. return item.date.split("-")[2]; // 这里提取日期中的日部分
  228. });
  229. // 排序日期列表
  230. categories.sort((a, b) => {
  231. return a.localeCompare(b);
  232. })
  233. // 按日期排序数据
  234. let sortedData = apiResponse.sort((a, b) => new Date(a.date) - new Date(b.date));
  235. // 提取核销数据和上货数据
  236. let verificationData = sortedData.map(item => item.verificationCount);
  237. let activateData = sortedData.map(item => item.activateCount);
  238. // 构造图表需要的格式
  239. let resTb = {
  240. categories: categories,
  241. series: [
  242. {
  243. name: "核销",
  244. data: verificationData
  245. },
  246. {
  247. name: "上货",
  248. data: activateData
  249. }
  250. ]
  251. };
  252. this.chartData = JSON.parse(JSON.stringify(resTb));
  253. }
  254. })
  255. },
  256. initYWY() {
  257. let that = this;
  258. getSalesmanSalesTotal(this.startTime,this.endTime,this.ywyId).then(res => {
  259. if (res.code === 0){
  260. console.log(res.data);
  261. that.hexiaoNumber = res.data.verificationTotal;
  262. that.xundianNumber = res.data.visitTotal;
  263. that.shangHuoNumber = res.data.activateTotal;
  264. }
  265. }).catch(err => {
  266. });
  267. getSalesmanSalesTrend(this.startTime,this.endTime,this.ywyId).then(res => {
  268. if (res.code === 0){
  269. console.log(res.data);
  270. let apiResponse = res.data;
  271. // 提取日期列表并排序
  272. let categories = apiResponse.map(item => {
  273. // 从日期中提取月日,例如 "2025-08-01" -> "08-01" -> "8/1" 或者只显示日 "1"
  274. return item.date.split("-")[2]; // 这里提取日期中的日部分
  275. });
  276. // 排序日期
  277. categories.sort((a, b) => parseInt(a) - parseInt(b));
  278. // 按日期排序数据
  279. let sortedData = apiResponse.sort((a, b) => new Date(a.date) - new Date(b.date));
  280. // 提取核销数据和上货数据
  281. let verificationData = sortedData.map(item => item.verificationCount);
  282. let activateData = sortedData.map(item => item.activateCount);
  283. // 构造图表需要的格式
  284. let resTb = {
  285. categories: categories,
  286. series: [
  287. {
  288. name: "核销",
  289. data: verificationData
  290. },
  291. {
  292. name: "上货",
  293. data: activateData
  294. }
  295. ]
  296. };
  297. this.chartData = JSON.parse(JSON.stringify(resTb));
  298. }
  299. }).catch(err => {
  300. });
  301. getSalesmanVisitTrend(this.startTime,this.endTime,this.ywyId).then(res => {
  302. if (res.code === 0){
  303. // 处理巡店趋势数据
  304. let apiResponse = res.data;
  305. // 提取日期列表(这里提取日部分)
  306. let categories = apiResponse.map(item => {
  307. return item.date.split("-")[2]; // 提取日期中的日部分
  308. });
  309. // 按日期排序数据
  310. let sortedData = apiResponse.sort((a, b) => new Date(a.date) - new Date(b.date));
  311. // 提取巡店数据
  312. let visitData = sortedData.map(item => item.visitCount || 0);
  313. // 构造图表需要的格式(与selectedCode中格式一致)
  314. let resFormat = {
  315. categories: categories,
  316. series: [
  317. {
  318. name: "巡店",
  319. data: visitData
  320. }
  321. ]
  322. };
  323. this.chartDataXd = JSON.parse(JSON.stringify(resFormat));
  324. }
  325. }).catch(err => {
  326. console.error(err);
  327. });
  328. },
  329. initJXS() {
  330. getSalesTotal(this.startTime,this.endTime).then(res => {
  331. if (res.code === 0){
  332. this.hexiaoNumber = res.data.orderTotal;
  333. this.xiaDanNumber = res.data.verificationTotal;
  334. }
  335. }).catch(err => {
  336. });
  337. getSalesTrend(this.startTime,this.endTime).then(data => {
  338. if (data.code === 0){
  339. let apiResponse = data.data;
  340. // 提取日期列表并排序
  341. let categories = apiResponse.map(item => {
  342. // 从日期中提取月日,例如 "2025-08-01" -> "08-01" -> "8/1" 或者只显示日 "1"
  343. return item.date.split("-")[2];
  344. })
  345. categories.sort((a, b) => parseInt(a) - parseInt(b));
  346. // 按日期排序数据
  347. let sortedData = apiResponse.sort((a, b) => new Date(a.date) - new Date(b.date));
  348. let verificationData = sortedData.map(item => item.verificationCount);
  349. let orderCountData = sortedData.map(item => item.orderCount);
  350. let res = {
  351. categories: categories,
  352. series: [
  353. {
  354. name: "核销",
  355. data: verificationData
  356. },
  357. {
  358. name: "下单",
  359. data: orderCountData
  360. }
  361. ]
  362. };
  363. this.chartData = JSON.parse(JSON.stringify(res));
  364. }
  365. })
  366. },
  367. confirm(e) {
  368. this.startTime = e[0];
  369. this.endTime = e[e.length -1];
  370. this.startTimeXd = e[0]+' ~ '+e[e.length -1];
  371. this.timeShow = false;
  372. if (this.type == 1){
  373. this.initMenDian();
  374. }
  375. if (this.type == 2){
  376. this.initYWY();
  377. }
  378. if (this.type == 3){
  379. this.initJXS();
  380. }
  381. },
  382. }
  383. };
  384. </script>
  385. <style scoped>
  386. .container {
  387. background-image: url("https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/cjx/bgi_2.png");
  388. background-size: 100% 100%;
  389. background-position: center;
  390. background-repeat: no-repeat;
  391. height: 100vh;
  392. padding: 0px 10px;
  393. }
  394. .title-text{
  395. font-weight: bold;
  396. font-size: 18px;
  397. color: #102A3C;
  398. text-align: center;
  399. height: 12vh;
  400. line-height: 16vh;
  401. }
  402. /* 请根据实际需求修改父元素尺寸,组件自动识别宽高 */
  403. .charts-box {
  404. width: 100%;
  405. height: 210px;
  406. }
  407. .query-btn {
  408. background-color: #409eff;
  409. color: #fff;
  410. padding: 20rpx;
  411. border-radius: 10rpx;
  412. height: 34rpx;
  413. display: flex;
  414. justify-content: center;
  415. align-items: center;
  416. }
  417. .query-btn-icon {
  418. height: 32rpx;
  419. width: 32rpx;
  420. background-image:
  421. url("https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/cjx/queryIoc.png");
  422. background-size: cover;
  423. background-position: center;
  424. background-repeat: no-repeat;
  425. }
  426. .query-btn-text {
  427. font-weight: 400;
  428. font-size: 30rpx;
  429. color: #F5F5F5;
  430. }
  431. .filter{
  432. display: flex;
  433. justify-content: space-around;
  434. align-items: center;
  435. height: 160rpx;
  436. background: #FFFFFF;
  437. box-shadow: 0rpx 10rpx 20rpx 0rpx rgba(168,168,168,0.22);
  438. border-radius: 12rpx;
  439. border: 2px solid #FFFFFF;
  440. }
  441. .item-one{
  442. display: flex;
  443. }
  444. .type-icon-hexiao {
  445. height: 80rpx;
  446. width: 80rpx;
  447. background-image:
  448. url("https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/cjx/hexiaoIoc.png");
  449. background-size: cover;
  450. background-position: center;
  451. background-repeat: no-repeat;
  452. }
  453. .type-icon-xundian {
  454. height: 80rpx;
  455. width: 80rpx;
  456. background-image:
  457. url("https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/cjx/xundianIoc.png");
  458. background-size: cover;
  459. background-position: center;
  460. background-repeat: no-repeat;
  461. }
  462. .type-icon-shanghuo {
  463. height: 80rpx;
  464. width: 80rpx;
  465. background-image:
  466. url("https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/cjx/shanghuoIoc.png");
  467. background-size: cover;
  468. background-position: center;
  469. background-repeat: no-repeat;
  470. }
  471. .type-icon-xiadan {
  472. height: 80rpx;
  473. width: 80rpx;
  474. background-image:
  475. url("https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/cjx/xiadanIoc.png");
  476. background-size: cover;
  477. background-position: center;
  478. background-repeat: no-repeat;
  479. }
  480. .number{
  481. font-weight: bold;
  482. font-size: 30rpx;
  483. color: #3B3638;
  484. }
  485. .text{
  486. font-weight: 400;
  487. font-size: 28rpx;
  488. color: #84868A;
  489. }
  490. .type-data{
  491. margin-left: 10rpx;
  492. }
  493. .t-one{
  494. margin-top: 10px;
  495. background-color: #fff;
  496. }
  497. .t-text {
  498. position: relative;
  499. padding-left: 10px; /* 为竖杠留出空间 */
  500. font-size: 30rpx; /* 根据需要调整字体大小 */
  501. color: #3B3638; /* 标题颜色 */
  502. font-weight: bold;
  503. }
  504. .t-text::before {
  505. content: ''; /* 必须设置 content 属性 */
  506. position: absolute;
  507. left: 0;
  508. top: 50%;
  509. transform: translateY(-50%); /* 垂直居中 */
  510. width: 4px; /* 竖杠宽度 */
  511. height: 16px; /* 竖杠高度 */
  512. background-color: #1890FF; /* 蓝色 */
  513. }
  514. ::v-deep .u-input{
  515. background-color: #fff;
  516. }
  517. .popup-content{
  518. height: 45vh;
  519. padding: 10px;
  520. }
  521. .popup-text{
  522. font-family: PingFang SC;
  523. font-weight: bold;
  524. font-size: 36rpx;
  525. color: #1C1E1D;
  526. text-align: center;
  527. margin-bottom: 10px;
  528. }
  529. .popup-btn{
  530. display: flex;
  531. justify-content: space-around;
  532. }
  533. .popup-btn-one{
  534. width: 275rpx;
  535. height: 70rpx;
  536. background: linear-gradient(0deg, #6FA4FE, #488CFF);
  537. box-shadow: 0rpx 9rpx 16rpx 0rpx rgba(153,153,153,0.35);
  538. border-radius: 35rpx;
  539. }
  540. .explain{
  541. font-weight: 400;
  542. font-size: 28rpx;
  543. color: #3B3638;
  544. }
  545. </style>