index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  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="show = 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="show = !show">
  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">0</view>
  32. <view class="text">核销</view>
  33. </view>
  34. </view>
  35. <view class="item-one" v-show="type == 2">
  36. <view class="type-icon-xundian"></view>
  37. <view class="type-data">
  38. <view class="number">0</view>
  39. <view class="text">巡店</view>
  40. </view>
  41. </view>
  42. <view class="item-one">
  43. <view class="type-icon-shanghuo"></view>
  44. <view class="type-data">
  45. <view class="number">0</view>
  46. <view class="text">上货</view>
  47. </view>
  48. </view>
  49. <view class="item-one" v-show="type == 3">
  50. <view class="type-icon-xiadan"></view>
  51. <view class="type-data">
  52. <view class="number">0</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 :show="timeShow" :mode="mode" @confirm="confirm"></u-calendar>
  137. </view>
  138. </template>
  139. <script>
  140. import {getSalesTotal,getSalesTrend,getSalesmanSalesTotal,getSalesmanSalesTrend,getSalesmanVisitTrend} from "../../../api/hexiao";
  141. export default {
  142. data() {
  143. return {
  144. hexiaoNumber: 0,
  145. xundianNumber: 0,
  146. shangHuoNumber: 0,
  147. xiaDanNumber: 0,
  148. type: 1,
  149. title: '',
  150. startTime: '',
  151. endTime: '',
  152. startTimeXd: '',
  153. timeShow: false,
  154. mode: 'range',
  155. show: false,
  156. chartDataXd: {},
  157. chartData: {},
  158. //您可以通过修改 config-ucharts.js 文件中下标为 ['line'] 的节点来配置全局默认参数,如都是默认参数,此处可以不传 opts 。实际应用过程中 opts 只需传入与全局默认参数中不一致的【某一个属性】即可实现同类型的图表显示不同的样式,达到页面简洁的需求。
  159. opts: {
  160. height: 210,
  161. color: ["#1890FF","#91CB74","#FAC858","#EE6666","#73C0DE","#3CA272","#FC8452","#9A60B4","#ea7ccc"],
  162. padding: [15,10,0,15],
  163. enableScroll: false,
  164. legend: {},
  165. xAxis: {
  166. disableGrid: true
  167. },
  168. yAxis: {
  169. gridType: "dash",
  170. dashLength: 2
  171. },
  172. extra: {
  173. line: {
  174. type: "straight",
  175. width: 2,
  176. activeType: "hollow"
  177. }
  178. }
  179. }
  180. };
  181. },
  182. onLoad: function(options) {
  183. options.id = 2;
  184. //门店
  185. if (options.id == 1){
  186. this.title = '门店销售数据';
  187. this.type = 1;
  188. this.initMenDian();
  189. }
  190. //业务员
  191. if (options.id == 2){
  192. this.title = '业务员销售数据';
  193. this.type = 2;
  194. this.initYWY(options.ywyId);
  195. }
  196. //经销商
  197. if (options.id == 3){
  198. this.title = '经销商销售数据';
  199. this.type = 3;
  200. this.initJXS();
  201. }
  202. },
  203. onReady() {
  204. this.getXdData();
  205. },
  206. methods: {
  207. initMenDian() {
  208. },
  209. initYWY(ywyId) {
  210. getSalesmanSalesTotal(this.startTime,this.endTime,ywyId).then(res => {
  211. if (res.code === 0){
  212. this.hexiaoNumber = res.data.verificationTotal;
  213. this.xundianNumber = res.data.visitTotal;
  214. this.shangHuoNumber = res.data.activateTotal;
  215. }
  216. }).catch(err => {
  217. });
  218. getSalesmanSalesTrend(this.startTime,this.endTime,ywyId).then(res => {
  219. if (res.code === 0){
  220. let apiResponse = res.data;
  221. // 提取日期列表并排序
  222. let categories = apiResponse.data.map(item => {
  223. // 从日期中提取月日,例如 "2025-08-01" -> "08-01" -> "8/1" 或者只显示日 "1"
  224. return item.date.split("-")[2]; // 这里提取日期中的日部分
  225. });
  226. // 排序日期
  227. categories.sort((a, b) => parseInt(a) - parseInt(b));
  228. // 按日期排序数据
  229. let sortedData = apiResponse.data.sort((a, b) => new Date(a.date) - new Date(b.date));
  230. // 提取核销数据和上货数据
  231. let verificationData = sortedData.map(item => item.verificationCount);
  232. let activateData = sortedData.map(item => item.activateCount);
  233. // 构造图表需要的格式
  234. let res = {
  235. categories: categories,
  236. series: [
  237. {
  238. name: "核销",
  239. data: verificationData
  240. },
  241. {
  242. name: "上货",
  243. data: activateData
  244. }
  245. ]
  246. };
  247. this.chartData = JSON.parse(JSON.stringify(res));
  248. }
  249. }).catch(err => {
  250. });
  251. getSalesmanVisitTrend(this.startTime,this.endTime,ywyId).then(res => {
  252. if (res.code === 0){
  253. // 处理巡店趋势数据
  254. let apiResponse = res.data;
  255. // 提取日期列表(这里提取日部分)
  256. let categories = apiResponse.map(item => {
  257. return item.date.split("-")[2]; // 提取日期中的日部分
  258. });
  259. // 按日期排序数据
  260. let sortedData = apiResponse.sort((a, b) => new Date(a.date) - new Date(b.date));
  261. // 提取巡店数据
  262. let visitData = sortedData.map(item => item.visitCount || 0);
  263. // 构造图表需要的格式(与selectedCode中格式一致)
  264. let resFormat = {
  265. categories: categories,
  266. series: [
  267. {
  268. name: "巡店",
  269. data: visitData
  270. }
  271. ]
  272. };
  273. this.chartDataXd = JSON.parse(JSON.stringify(resFormat));
  274. }
  275. }).catch(err => {
  276. console.error(err);
  277. });
  278. },
  279. initJXS() {
  280. getSalesTotal(this.startTime,this.endTime).then(res => {
  281. if (res.code === 0){
  282. this.hexiaoNumber = res.data.verificationTotal;
  283. this.xundianNumber = res.data.visitTotal;
  284. }
  285. }).catch(err => {
  286. });
  287. getSalesTrend(this.startTime,this.endTime).then(res => {
  288. if (res.code === 0){
  289. let apiResponse = res.data;
  290. // 提取日期列表并排序
  291. let categories = apiResponse.data.map(item => {
  292. // 从日期中提取月日,例如 "2025-08-01" -> "08-01" -> "8/1" 或者只显示日 "1"
  293. return item.date.split("-")[2];
  294. })
  295. categories.sort((a, b) => parseInt(a) - parseInt(b));
  296. // 按日期排序数据
  297. let sortedData = apiResponse.data.sort((a, b) => new Date(a.date) - new Date(b.date));
  298. let verificationData = sortedData.map(item => item.verificationCount);
  299. let orderCountData = sortedData.map(item => item.orderCount);
  300. let res = {
  301. categories: categories,
  302. series: [
  303. {
  304. name: "核销",
  305. data: verificationData
  306. },
  307. {
  308. name: "下单",
  309. data: orderCountData
  310. }
  311. ]
  312. };
  313. this.chartData = JSON.parse(JSON.stringify(res));
  314. }
  315. })
  316. },
  317. confirm(e) {
  318. this.startTime = e[0];
  319. this.endTime = e[1];
  320. this.startTimeXd = e[0]+' ~ '+e[1];
  321. this.timeShow = false;
  322. },
  323. getXdData() {
  324. //模拟服务器返回数据,如果数据格式和标准格式不同,需自行按下面的格式拼接
  325. let res = {
  326. categories: ["7","8","9","10","11","12"],
  327. series: [
  328. {
  329. name: "巡店",
  330. data: [35,8,25,37,4,20]
  331. },
  332. ]
  333. };
  334. this.chartDataXd = JSON.parse(JSON.stringify(res));
  335. }
  336. }
  337. };
  338. </script>
  339. <style scoped>
  340. .container {
  341. background-image: url("https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/cjx/bgi_2.png");
  342. background-size: 100% 100%;
  343. background-position: center;
  344. background-repeat: no-repeat;
  345. height: 100vh;
  346. padding: 0px 10px;
  347. }
  348. .title-text{
  349. font-weight: bold;
  350. font-size: 18px;
  351. color: #102A3C;
  352. text-align: center;
  353. height: 10vh;
  354. line-height: 10vh;
  355. }
  356. /* 请根据实际需求修改父元素尺寸,组件自动识别宽高 */
  357. .charts-box {
  358. width: 100%;
  359. height: 210px;
  360. }
  361. .query-btn {
  362. background-color: #409eff;
  363. color: #fff;
  364. padding: 20rpx;
  365. border-radius: 10rpx;
  366. height: 34rpx;
  367. display: flex;
  368. justify-content: center;
  369. align-items: center;
  370. }
  371. .query-btn-icon {
  372. height: 32rpx;
  373. width: 32rpx;
  374. background-image:
  375. url("https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/cjx/queryIoc.png");
  376. background-size: cover;
  377. background-position: center;
  378. background-repeat: no-repeat;
  379. }
  380. .query-btn-text {
  381. font-weight: 400;
  382. font-size: 30rpx;
  383. color: #F5F5F5;
  384. }
  385. .filter{
  386. display: flex;
  387. justify-content: space-around;
  388. align-items: center;
  389. height: 160rpx;
  390. background: #FFFFFF;
  391. box-shadow: 0rpx 10rpx 20rpx 0rpx rgba(168,168,168,0.22);
  392. border-radius: 12rpx;
  393. border: 2px solid #FFFFFF;
  394. }
  395. .item-one{
  396. display: flex;
  397. }
  398. .type-icon-hexiao {
  399. height: 80rpx;
  400. width: 80rpx;
  401. background-image:
  402. url("https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/cjx/hexiaoIoc.png");
  403. background-size: cover;
  404. background-position: center;
  405. background-repeat: no-repeat;
  406. }
  407. .type-icon-xundian {
  408. height: 80rpx;
  409. width: 80rpx;
  410. background-image:
  411. url("https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/cjx/xundianIoc.png");
  412. background-size: cover;
  413. background-position: center;
  414. background-repeat: no-repeat;
  415. }
  416. .type-icon-shanghuo {
  417. height: 80rpx;
  418. width: 80rpx;
  419. background-image:
  420. url("https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/cjx/shanghuoIoc.png");
  421. background-size: cover;
  422. background-position: center;
  423. background-repeat: no-repeat;
  424. }
  425. .type-icon-xiadan {
  426. height: 80rpx;
  427. width: 80rpx;
  428. background-image:
  429. url("https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/cjx/xiadanIoc.png");
  430. background-size: cover;
  431. background-position: center;
  432. background-repeat: no-repeat;
  433. }
  434. .number{
  435. font-weight: bold;
  436. font-size: 30rpx;
  437. color: #3B3638;
  438. }
  439. .text{
  440. font-weight: 400;
  441. font-size: 28rpx;
  442. color: #84868A;
  443. }
  444. .type-data{
  445. margin-left: 10rpx;
  446. }
  447. .t-one{
  448. margin-top: 10px;
  449. background-color: #fff;
  450. }
  451. .t-text {
  452. position: relative;
  453. padding-left: 10px; /* 为竖杠留出空间 */
  454. font-size: 30rpx; /* 根据需要调整字体大小 */
  455. color: #3B3638; /* 标题颜色 */
  456. font-weight: bold;
  457. }
  458. .t-text::before {
  459. content: ''; /* 必须设置 content 属性 */
  460. position: absolute;
  461. left: 0;
  462. top: 50%;
  463. transform: translateY(-50%); /* 垂直居中 */
  464. width: 4px; /* 竖杠宽度 */
  465. height: 16px; /* 竖杠高度 */
  466. background-color: #1890FF; /* 蓝色 */
  467. }
  468. ::v-deep .u-input{
  469. background-color: #fff;
  470. }
  471. .popup-content{
  472. height: 45vh;
  473. padding: 10px;
  474. }
  475. .popup-text{
  476. font-family: PingFang SC;
  477. font-weight: bold;
  478. font-size: 36rpx;
  479. color: #1C1E1D;
  480. text-align: center;
  481. margin-bottom: 10px;
  482. }
  483. .popup-btn{
  484. display: flex;
  485. justify-content: space-around;
  486. }
  487. .popup-btn-one{
  488. width: 275rpx;
  489. height: 70rpx;
  490. background: linear-gradient(0deg, #6FA4FE, #488CFF);
  491. box-shadow: 0rpx 9rpx 16rpx 0rpx rgba(153,153,153,0.35);
  492. border-radius: 35rpx;
  493. }
  494. .explain{
  495. font-weight: 400;
  496. font-size: 28rpx;
  497. color: #3B3638;
  498. }
  499. </style>