robotRanking.vue 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201
  1. <template>
  2. <div class="robotRanking flex-col">
  3. <s-header
  4. :name="$t('robotRanking.machineSalesRanking')"
  5. :noback="true"
  6. ></s-header>
  7. <div class="box1 flex-col">
  8. <div class="box3 flex-col">
  9. <div class="main1 flex-col">
  10. <div class="mod1 flex-col">
  11. <div class="block1 flex-col justify-between">
  12. <div class="section1 flex-row justify-between">
  13. <div class="ImageText1 flex-col">
  14. <div class="group4 flex-row justify-between">
  15. <div class="layer3 flex-col"></div>
  16. <div class="TextGroup1 flex-col">
  17. <span class="word3">{{
  18. $t("robotRanking.machineSalesRanking")
  19. }}</span>
  20. </div>
  21. </div>
  22. </div>
  23. <div @click="noticeClk" class="l-flex-RC">
  24. <img class="label2" src="@/assets/device/searchIcon.png" />
  25. <span class="txt3">{{ $t("robotRanking.rankMethod") }}</span>
  26. </div>
  27. </div>
  28. <img
  29. class="img1"
  30. referrerpolicy="no-referrer"
  31. src="https://lanhu.oss-cn-beijing.aliyuncs.com/SketchPng8947935ab81635fdedd8124b11e305eef66286421b69c84fef22233014a3fa9a"
  32. />
  33. </div>
  34. </div>
  35. <div class="l-f l-flex-e o-plr-15">
  36. <span class="robotLabelName l-in c-text-13" style="color: #404d74"
  37. >{{ $t("robotRanking.dailySalesRanking") }}:</span
  38. >
  39. <kTabs
  40. @tabclk="(e) => tabclk(e, 'day')"
  41. :tabList="tabDayList"
  42. ></kTabs>
  43. </div>
  44. <div
  45. v-if="!totalNoData('day')"
  46. ref="dayChartBox"
  47. class="mod3 flex-col"
  48. ></div>
  49. <kNoData v-else></kNoData>
  50. <div class="groove"></div>
  51. <div class="l-f l-flex-e o-plr-15">
  52. <span
  53. class="robotLabelName l-in o-mr-6 c-text-13"
  54. style="color: #404d74"
  55. >{{ $t("robotRanking.salesRankingThisWeek") }}:</span
  56. >
  57. <kTabs
  58. @tabclk="(e) => tabclk(e, 'week')"
  59. :tabList="tabWeekList"
  60. ></kTabs>
  61. </div>
  62. <div
  63. v-if="!totalNoData('week')"
  64. ref="weekChartBox"
  65. class="mod5 flex-col"
  66. ></div>
  67. <kNoData v-else></kNoData>
  68. <div class="groove"></div>
  69. <div class="l-f l-flex-e o-plr-15">
  70. <span
  71. class="robotLabelName l-in o-mr-6 c-text-13"
  72. style="color: #404d74"
  73. >{{ $t("robotRanking.salesRankingThisMonth") }}:</span
  74. >
  75. <kTabs
  76. @tabclk="(e) => tabclk(e, 'month')"
  77. :tabList="tabMonthList"
  78. ></kTabs>
  79. </div>
  80. <div
  81. v-if="!totalNoData('month')"
  82. ref="monthChartBox"
  83. class="mod9 flex-col"
  84. ></div>
  85. <kNoData v-else></kNoData>
  86. <div class="groove"></div>
  87. <div class="l-f l-flex-e o-plr-15">
  88. <span
  89. class="robotLabelName l-in o-mr-6 c-text-13"
  90. style="color: #404d74"
  91. >{{ $t("robotRanking.salesRankingThisYear") }}:</span
  92. >
  93. <kTabs
  94. @tabclk="(e) => tabclk(e, 'year')"
  95. :tabList="tabYearList"
  96. ></kTabs>
  97. </div>
  98. <div
  99. v-if="!totalNoData('year')"
  100. ref="yearChartBox"
  101. class="mod11 flex-col"
  102. ></div>
  103. <kNoData v-else></kNoData>
  104. <div class="groove"></div>
  105. </div>
  106. </div>
  107. </div>
  108. <!-- 筛选弹窗 -->
  109. <kDialog
  110. :dialogTitle="$t('subLedgerManage.search.title')"
  111. :confirmBtnTxt="$t('subLedgerManage.search.screen')"
  112. ref="kDialogRef"
  113. @confirmclk="confirmClk"
  114. >
  115. <template #content>
  116. <div class="cust_vantBorder">
  117. <!-- <van-field @click-input="busiInpClk" readonly clearable v-model="searchForm.businessName"
  118. :placeholder="$t('subLedgerManage.search.busiPlaceholder')" :label="$t('subLedgerManage.search.business')">
  119. <template #right-icon>
  120. <div class="l-flex-RC">
  121. <van-icon v-if="searchForm.businessName" @click="searchForm.businessName = ''" class="o-mr-6"
  122. name="clear" />
  123. <van-icon @click="busiInpClk" name="arrow-down" />
  124. </div>
  125. </template>
  126. </van-field> -->
  127. <van-field
  128. @click-input="changeTypeInpClk"
  129. readonly
  130. clearable
  131. v-model="searchForm.changeTypeName"
  132. :placeholder="$t('robotRanking.changeTypePlace')"
  133. :label="$t('robotRanking.changeType')"
  134. >
  135. <template #right-icon>
  136. <div class="l-flex-RC">
  137. <van-icon
  138. v-if="searchForm.changeTypeName"
  139. @click="
  140. searchForm.changeTypeName = '';
  141. searchForm.changeType = '';
  142. "
  143. class="o-mr-6"
  144. name="clear"
  145. />
  146. <van-icon @click="changeTypeInpClk" name="arrow-down" />
  147. </div>
  148. </template>
  149. </van-field>
  150. </div>
  151. </template>
  152. </kDialog>
  153. <!-- 商家选择框 -->
  154. <van-popup v-model:show="busiPopShow" position="bottom">
  155. <van-picker
  156. :title="$t('subLedgerManage.search.busiPlaceholder')"
  157. :columns="busiPopList"
  158. :columns-field-names="busiPopFieldName"
  159. @confirm="busiPopConfirm"
  160. @cancel="busiPopShow = false"
  161. />
  162. </van-popup>
  163. <!-- 统计方式弹窗 -->
  164. <van-popup v-model:show="changeTypeShow" position="bottom">
  165. <van-picker
  166. :default-index="chgTypeDefaIdx"
  167. :title="$t('robotRanking.changeTypePlace')"
  168. :columns="changeTypePopList"
  169. :columns-field-names="yearPopFieldName"
  170. @confirm="changeTypePopConfirm"
  171. @cancel="changeTypeShow = false"
  172. />
  173. </van-popup>
  174. <!-- 日的日期选择弹窗 -->
  175. <van-calendar
  176. @confirm="calendarDayConfirm"
  177. v-model:show="dayShow"
  178. color="#4d6add"
  179. :min-date="minDate"
  180. :show-confirm="false"
  181. />
  182. <!-- 周的日期选择弹窗 -->
  183. <van-calendar
  184. @confirm="
  185. (e) => {
  186. calendarWeekOrMonConfirm(e, 1);
  187. }
  188. "
  189. v-model:show="weekShow"
  190. :allow-same-day="true"
  191. color="#4d6add"
  192. :min-date="minDate"
  193. type="range"
  194. />
  195. <!-- 月的日期选择弹窗 -->
  196. <van-calendar
  197. @confirm="
  198. (e) => {
  199. calendarWeekOrMonConfirm(e, 2);
  200. }
  201. "
  202. v-model:show="monthShow"
  203. :allow-same-day="true"
  204. color="#4d6add"
  205. :min-date="minDate"
  206. type="range"
  207. />
  208. <!-- 年的日期选择弹窗 -->
  209. <van-popup v-model:show="yearShow" position="bottom">
  210. <van-picker
  211. :title="$t('robotRanking.yearPopTitle')"
  212. :columns="yearPopList"
  213. :columns-field-names="yearPopFieldName"
  214. @confirm="yearPopConfirm"
  215. @cancel="yearShow = false"
  216. />
  217. </van-popup>
  218. <nav-bar></nav-bar>
  219. </div>
  220. </template>
  221. <script>
  222. // 导入无数据组件
  223. import kNoData from "@/components/commom/kNoData/index.vue";
  224. import { onMounted, ref, reactive, computed, nextTick } from "vue";
  225. import sHeader from "@/components/SimpleHeader";
  226. import navBar from "@/components/NavBar";
  227. import { getRankingList } from "@/service/robotRanking";
  228. import { getLoginUser } from "@/common/js/utils";
  229. // import dateUtil from "@/utils/dateUtil";
  230. import kTabs from "@/components/commom/kTabs/index.vue";
  231. import kDialog from "@/components/commom/kDialog/index.vue";
  232. import moment from "moment";
  233. import { Toast } from "vant";
  234. import { useI18n } from "vue-i18n";
  235. export default {
  236. setup() {
  237. // 引入语言
  238. const { t } = useI18n();
  239. // 日周月年的数据
  240. const totalObj = reactive({
  241. dayData: {},
  242. weekData: {},
  243. monthData: {},
  244. yearData: {},
  245. });
  246. // 日周月年图表没有数据
  247. const totalNoData = computed(() => (idx) => {
  248. let dataObj;
  249. switch (idx) {
  250. case "day":
  251. dataObj = totalObj.dayData;
  252. break;
  253. case "week":
  254. dataObj = totalObj.weekData;
  255. break;
  256. case "month":
  257. dataObj = totalObj.monthData;
  258. break;
  259. case "year":
  260. dataObj = totalObj.yearData;
  261. break;
  262. }
  263. if (!dataObj || dataObj?.categories?.length === 0) {
  264. return true;
  265. }
  266. return false;
  267. });
  268. // 统计方式弹窗
  269. const changeTypeInpClk = () => {
  270. changeTypeShow.value = true;
  271. };
  272. const changeTypeShow = ref(false);
  273. // 默认选中
  274. const chgTypeDefaIdx = ref(1);
  275. const changeTypePopList = [
  276. {
  277. name: t("robotRanking.patternStatistics"),
  278. id: 1,
  279. },
  280. {
  281. name: t("robotRanking.salesStatistics"),
  282. id: 0,
  283. },
  284. ];
  285. const changeTypePopConfirm = (e) => {
  286. searchForm.changeType = e.id;
  287. searchForm.changeTypeName = e.name;
  288. changeTypeShow.value = false;
  289. };
  290. // 年的日期选择弹窗
  291. // 点击确定
  292. const yearPopConfirm = (e) => {
  293. console.log("e11", e);
  294. const year = e.id;
  295. const startDate =
  296. moment().year(year).startOf("year").format("YYYY-MM-DD") + " 00:00:00";
  297. const endDate =
  298. moment().year(year).endOf("year").format("YYYY-MM-DD") + " 23:59:59";
  299. getEquipRankList("year", startDate, endDate);
  300. yearShow.value = false;
  301. };
  302. // 获取当前年前4年后1年
  303. let yearPopList = [];
  304. for (let i = -1; i < 5; i++) {
  305. const year = moment().subtract(i, "years").format("YYYY");
  306. yearPopList.push({
  307. name: year,
  308. id: year,
  309. });
  310. }
  311. const yearPopFieldName = reactive({
  312. text: "name",
  313. value: "id",
  314. });
  315. const yearShow = ref(false);
  316. const currentDate = ref(new Date());
  317. const yearFormatter = (type, val) => {
  318. if (type === "year") {
  319. return val;
  320. }
  321. return val;
  322. };
  323. // 周和月的日期选择弹窗
  324. const weekShow = ref(false);
  325. const monthShow = ref(false);
  326. const calendarWeekOrMonConfirm = (e, idx) => {
  327. const startDate = e[0];
  328. const endDate = e[1];
  329. let weekOrMont = "month";
  330. // 如果是周计算开始和结束日期相差多少天,因为周不能超过7天
  331. if (idx === 1) {
  332. weekOrMont = "week";
  333. const differDays = moment(endDate).diff(moment(startDate), "days");
  334. if (differDays >= 7) {
  335. Toast(t("robotRanking.seleWeekDateRangeNotSeveDays"));
  336. return;
  337. }
  338. }
  339. const startTime = moment(e[0]).format("YYYY-MM-DD") + " 00:00:00";
  340. const endTime = moment(e[1]).format("YYYY-MM-DD") + " 23:59:59";
  341. getEquipRankList(weekOrMont, startTime, endTime);
  342. if (idx === 1) {
  343. weekShow.value = false;
  344. } else {
  345. monthShow.value = false;
  346. }
  347. };
  348. // 日的日期选择弹窗
  349. // 日历选择触发
  350. const calendarDayConfirm = (e) => {
  351. const startDate = moment(e).format("YYYY-MM-DD") + " 00:00:00";
  352. const endDate = moment(e).format("YYYY-MM-DD") + " 23:59:59";
  353. getEquipRankList("day", startDate, endDate);
  354. dayShow.value = false;
  355. };
  356. // 最小日期选择
  357. const minDate = new Date(2018, 1, 1);
  358. const dayShow = ref(false);
  359. // 日,周,月,年的tab栏数据
  360. const tabDayList = ref([
  361. {
  362. name: t("robotRanking.today"),
  363. icon: "",
  364. id: 1,
  365. },
  366. {
  367. name: t("robotRanking.yesterday"),
  368. icon: "",
  369. id: 2,
  370. },
  371. {
  372. name: t("robotRanking.other"),
  373. icon: "arrow-down",
  374. id: 3,
  375. },
  376. ]);
  377. const tabWeekList = ref([
  378. {
  379. name: t("robotRanking.thisWeek"),
  380. icon: "",
  381. id: 1,
  382. },
  383. {
  384. name: t("robotRanking.lastWeek"),
  385. icon: "",
  386. id: 2,
  387. },
  388. {
  389. name: t("robotRanking.other"),
  390. icon: "arrow-down",
  391. id: 3,
  392. },
  393. ]);
  394. const tabMonthList = ref([
  395. {
  396. name: t("robotRanking.thisMonth"),
  397. icon: "",
  398. id: 1,
  399. },
  400. {
  401. name: t("robotRanking.lastMonth"),
  402. icon: "",
  403. id: 2,
  404. },
  405. {
  406. name: t("robotRanking.other"),
  407. icon: "arrow-down",
  408. id: 3,
  409. },
  410. ]);
  411. const tabYearList = ref([
  412. {
  413. name: t("robotRanking.thisYear"),
  414. icon: "",
  415. id: 1,
  416. },
  417. {
  418. name: t("robotRanking.lastYear"),
  419. icon: "",
  420. id: 2,
  421. },
  422. {
  423. name: t("robotRanking.other"),
  424. icon: "arrow-down",
  425. id: 3,
  426. },
  427. ]);
  428. // 默认进来的时间
  429. const defaultTime = reactive({
  430. // 今日
  431. todayStart: moment().format("YYYY-MM-DD") + " 00:00:00",
  432. todayEnd: moment().format("YYYY-MM-DD") + " 23:59:59",
  433. // 昨日
  434. colastdayStart:
  435. moment()
  436. .day(moment().day() - 1)
  437. .format("YYYY-MM-DD") + " 00:00:00",
  438. colastdayEnd:
  439. moment()
  440. .day(moment().day() - 1)
  441. .format("YYYY-MM-DD") + " 23:59:59",
  442. // 这周
  443. weekStart: moment().weekday(1).format("YYYY-MM-DD") + " 00:00:00",
  444. weekEnd: moment().weekday(7).format("YYYY-MM-DD") + " 23:59:59",
  445. // 上周
  446. lastWeekStart:moment().week(moment().week() - 1).startOf('week').add(1,'days').format("YYYY-MM-DD") + " 00:00:00",
  447. // moment()
  448. // .week(moment().week() - 1)
  449. // .startOf("week")
  450. // .format("YYYY-MM-DD") + " 00:00:00",
  451. lastWeekEnd:moment().week(moment().week() - 1).endOf('week').add(1,'days').format("YYYY-MM-DD") + " 23:59:59",
  452. // moment()
  453. // .week(moment().week() - 1)
  454. // .endOf("week")
  455. // .format("YYYY-MM-DD") + " 23:59:59",
  456. // 这个月
  457. monthStart: moment().startOf("month").format("YYYY-MM-DD") + " 00:00:00",
  458. monthEnd: moment().endOf("month").format("YYYY-MM-DD") + " 23:59:59",
  459. // 上个月
  460. lastmonthStart:
  461. moment()
  462. .month(moment().month() - 1)
  463. .startOf("month")
  464. .format("YYYY-MM-DD") + " 00:00:00",
  465. lastmonthEnd:
  466. moment()
  467. .month(moment().month() - 1)
  468. .endOf("month")
  469. .format("YYYY-MM-DD") + " 23:59:59",
  470. // 今年
  471. yearStart: moment().startOf("year").format("YYYY-MM-DD") + " 00:00:00",
  472. yearEnd: moment().endOf("year").format("YYYY-MM-DD") + " 23:59:59",
  473. // 上年
  474. lastYearStart:
  475. moment()
  476. .year(moment().year() - 1)
  477. .startOf("year")
  478. .format("YYYY-MM-DD") + " 00:00:00",
  479. lastYearEnd:
  480. moment()
  481. .year(moment().year() - 1)
  482. .endOf("year")
  483. .format("YYYY-MM-DD") + " 23:59:59",
  484. });
  485. // 点击tab
  486. const tabclk = (e, type) => {
  487. let startDate = "";
  488. let endDate = "";
  489. switch (type) {
  490. case "day":
  491. switch (e.name) {
  492. case 0:
  493. startDate = defaultTime.todayStart;
  494. endDate = defaultTime.todayEnd;
  495. break;
  496. case 1:
  497. startDate = defaultTime.colastdayStart;
  498. endDate = defaultTime.colastdayEnd;
  499. break;
  500. case 2:
  501. // 打开日历弹窗
  502. dayShow.value = true;
  503. break;
  504. }
  505. break;
  506. case "week":
  507. switch (e.name) {
  508. case 0:
  509. startDate = defaultTime.weekStart;
  510. endDate = defaultTime.weekEnd;
  511. break;
  512. case 1:
  513. startDate = defaultTime.lastWeekStart;
  514. endDate = defaultTime.lastWeekEnd;
  515. break;
  516. case 2:
  517. // 打开周的日期选择弹窗
  518. weekShow.value = true;
  519. break;
  520. }
  521. break;
  522. case "month":
  523. switch (e.name) {
  524. case 0:
  525. startDate = defaultTime.monthStart;
  526. endDate = defaultTime.monthEnd;
  527. break;
  528. case 1:
  529. startDate = defaultTime.lastmonthStart;
  530. endDate = defaultTime.lastmonthEnd;
  531. break;
  532. case 2:
  533. // 打开月的日期选择弹窗
  534. monthShow.value = true;
  535. break;
  536. }
  537. break;
  538. case "year":
  539. switch (e.name) {
  540. case 0:
  541. startDate = defaultTime.yearStart;
  542. endDate = defaultTime.yearEnd;
  543. break;
  544. case 1:
  545. startDate = defaultTime.lastYearStart;
  546. endDate = defaultTime.lastYearEnd;
  547. break;
  548. case 2:
  549. // 打开年的日期弹窗
  550. yearShow.value = true;
  551. break;
  552. }
  553. break;
  554. }
  555. // 如果是点击其他,不用请求
  556. if (e.name !== 2) {
  557. // 获取日、周、月、年的排行数据
  558. getEquipRankList(type, startDate, endDate);
  559. }
  560. };
  561. const changeType = ref(0);
  562. let chartObj = {
  563. day: null,
  564. week: null,
  565. month: null,
  566. year: null,
  567. };
  568. // 获取日、周、月、年的排行数据
  569. const getEquipRankList = (chartType, startDate, endDate) => {
  570. let param = {
  571. adminId: user.id,
  572. ifForeign: user.ifForeign,
  573. changeType: changeType.value, //必填,默认为一0:销售额统计,1:花型统计
  574. chartType,
  575. startDate,
  576. endDate,
  577. };
  578. getRankingList(param).then(async (res) => {
  579. const { data } = res;
  580. switch (chartType) {
  581. case "day":
  582. totalObj.dayData = data.data;
  583. console.log("日返回值", data);
  584. break;
  585. case "week":
  586. totalObj.weekData = data.data;
  587. console.log("周返回值", data);
  588. break;
  589. case "month":
  590. totalObj.monthData = data.data;
  591. console.log("月返回值", data);
  592. break;
  593. case "year":
  594. totalObj.yearData = data.data;
  595. console.log("年返回值", data);
  596. break;
  597. }
  598. // 有数据返回则处理
  599. if (data.code && data.data) {
  600. // echarts的配置
  601. const chartOption = {
  602. tooltip: {
  603. trigger: "axis",
  604. axisPointer: {
  605. type: "shadow",
  606. },
  607. },
  608. // 固定屏幕显示多少个,其余的滑动
  609. dataZoom: [
  610. // {
  611. // type: 'slider',
  612. // xAxisIndex: 0,
  613. // filterMode: 'none',
  614. // // 开始的值
  615. // startValue: null,
  616. // // 结束的值
  617. // endValue: null,
  618. // // 锁定滑动的区域
  619. // // zoomLock:true,
  620. // },
  621. {
  622. type: "inside",
  623. xAxisIndex: 0,
  624. filterMode: "none",
  625. startValue: null,
  626. endValue: null,
  627. zoomLock: true,
  628. },
  629. ],
  630. grid: {
  631. left: "3%",
  632. right: "4%",
  633. bottom: "10%",
  634. containLabel: true,
  635. },
  636. legend: {
  637. bottom: 0,
  638. right: 10,
  639. itemWidth: 10,
  640. itemHeight: 10,
  641. icon: "rect",
  642. },
  643. yAxis: { type: "value" },
  644. xAxis: {
  645. type: "category",
  646. axisLabel: {
  647. rotate: 45,
  648. },
  649. data: [],
  650. },
  651. series: [],
  652. };
  653. await nextTick();
  654. let chartBox;
  655. switch (chartType) {
  656. case "day":
  657. chartBox = dayChartBox.value;
  658. break;
  659. case "week":
  660. chartBox = weekChartBox.value;
  661. break;
  662. case "month":
  663. chartBox = monthChartBox.value;
  664. break;
  665. case "year":
  666. chartBox = yearChartBox.value;
  667. break;
  668. }
  669. if (chartBox) {
  670. const dayChartOption = Object.assign({}, chartOption);
  671. dayChartOption.xAxis.data = data.data.categories;
  672. dayChartOption.series = [
  673. {
  674. ...data.data.series[0],
  675. type: "bar",
  676. itemStyle: { color: "#4D6ADD" },
  677. label: {
  678. show: true,
  679. position: "top",
  680. },
  681. },
  682. {
  683. ...data.data.series[1],
  684. type: "bar",
  685. itemStyle: { color: "#E59A6D" },
  686. label: {
  687. show: true,
  688. position: "top",
  689. },
  690. },
  691. ];
  692. dayChartOption.dataZoom[0]["startValue"] =
  693. data.data.categories[data.data.categories.length - 5];
  694. dayChartOption.dataZoom[0]["endValue"] =
  695. data.data.categories[data.data.categories.length - 1];
  696. // 解决resize不起作用,配合onMounted里的方法使用
  697. switch (chartType) {
  698. case "day":
  699. chartObj.day = window.echarts.init(chartBox, null, {
  700. renderer: "canvas",
  701. useDirtyRect: false,
  702. });
  703. chartObj.day && chartObj.day.setOption(dayChartOption);
  704. break;
  705. case "week":
  706. chartObj.week = window.echarts.init(chartBox, null, {
  707. renderer: "canvas",
  708. useDirtyRect: false,
  709. });
  710. chartObj.week && chartObj.week.setOption(dayChartOption);
  711. break;
  712. case "month":
  713. chartObj.month = window.echarts.init(chartBox, null, {
  714. renderer: "canvas",
  715. useDirtyRect: false,
  716. });
  717. chartObj.month && chartObj.month.setOption(dayChartOption);
  718. break;
  719. case "year":
  720. chartObj.year = window.echarts.init(chartBox, null, {
  721. renderer: "canvas",
  722. useDirtyRect: false,
  723. });
  724. chartObj.year && chartObj.year.setOption(dayChartOption);
  725. break;
  726. }
  727. }
  728. }
  729. });
  730. };
  731. const user = getLoginUser();
  732. // 日、周、月、年的图表
  733. const dayChartBox = ref();
  734. const weekChartBox = ref();
  735. const monthChartBox = ref();
  736. const yearChartBox = ref();
  737. // 初始化页面获取列表
  738. onMounted(async () => {
  739. // 默认筛选选中
  740. searchForm.changeTypeName = t("robotRanking.salesStatistics");
  741. searchForm.changeType = 0;
  742. init();
  743. window.addEventListener("resize", () => {
  744. chartObj.day && chartObj.day.resize();
  745. chartObj.week && chartObj.week.resize();
  746. chartObj.month && chartObj.month.resize();
  747. chartObj.year && chartObj.year.resize();
  748. });
  749. });
  750. // 刚进页面获取
  751. const init = () => {
  752. // 获取日的排行数据
  753. getEquipRankList("day", defaultTime.todayStart, defaultTime.todayEnd);
  754. // 获取周的排行数据
  755. getEquipRankList("week", defaultTime.weekStart, defaultTime.weekEnd);
  756. // 获取月的排行数据
  757. getEquipRankList("month", defaultTime.monthStart, defaultTime.monthEnd);
  758. // 获取年的排行数据
  759. getEquipRankList("year", defaultTime.yearStart, defaultTime.yearEnd);
  760. };
  761. const searchForm = reactive({
  762. businessName: "",
  763. changeTypeName: "",
  764. changeType: "",
  765. });
  766. const kDialogRef = ref(null);
  767. const busiPopShow = ref(false);
  768. const busiPopList = reactive([
  769. {
  770. name: "商户1",
  771. id: "1",
  772. },
  773. {
  774. name: "商户2",
  775. id: "2",
  776. },
  777. ]);
  778. const busiPopFieldName = reactive({
  779. text: "name",
  780. value: "id",
  781. });
  782. // 点击筛选
  783. const noticeClk = () => {
  784. kDialogRef.value.openDialog();
  785. };
  786. // 点击右侧按钮
  787. const confirmClk = () => {
  788. if (searchForm.changeType === "") {
  789. changeType.value = 1;
  790. } else {
  791. changeType.value = searchForm.changeType;
  792. }
  793. init();
  794. };
  795. // 筛选弹窗
  796. // 点击商家输入框
  797. const busiInpClk = () => {
  798. console.log(111111111);
  799. busiPopShow.value = true;
  800. };
  801. const busiPopConfirm = (e) => {
  802. console.log("e", e);
  803. busiPopShow.value = false;
  804. searchForm.businessName = e.name;
  805. };
  806. const busiPopCancel = () => {
  807. busiPopShow.value = false;
  808. };
  809. return {
  810. dayChartBox,
  811. weekChartBox,
  812. monthChartBox,
  813. yearChartBox,
  814. tabclk,
  815. tabDayList,
  816. tabWeekList,
  817. tabMonthList,
  818. tabYearList,
  819. noticeClk,
  820. kDialogRef,
  821. busiInpClk,
  822. busiPopShow,
  823. busiPopConfirm,
  824. busiPopList,
  825. busiPopFieldName,
  826. busiPopCancel,
  827. confirmClk,
  828. searchForm,
  829. dayShow,
  830. minDate,
  831. calendarDayConfirm,
  832. weekShow,
  833. monthShow,
  834. calendarWeekOrMonConfirm,
  835. yearFormatter,
  836. currentDate,
  837. yearShow,
  838. yearPopList,
  839. yearPopConfirm,
  840. yearPopFieldName,
  841. changeTypeShow,
  842. changeTypePopList,
  843. changeTypePopConfirm,
  844. changeTypeInpClk,
  845. totalNoData,
  846. chgTypeDefaIdx,
  847. };
  848. },
  849. components: { sHeader, navBar, kTabs, kDialog, kNoData },
  850. };
  851. </script>
  852. <style lang="less" scoped>
  853. body * {
  854. box-sizing: border-box;
  855. flex-shrink: 0;
  856. }
  857. body {
  858. font-family: PingFangSC-Regular, Roboto, Helvetica Neue, Helvetica, Tahoma,
  859. Arial, PingFang SC-Light, Microsoft YaHei;
  860. }
  861. button {
  862. margin: 0;
  863. padding: 0;
  864. border: 1px solid transparent;
  865. outline: none;
  866. background-color: transparent;
  867. }
  868. button:active {
  869. opacity: 0.6;
  870. }
  871. .flex-col {
  872. display: flex;
  873. flex-direction: column;
  874. }
  875. .flex-row {
  876. display: flex;
  877. flex-direction: row;
  878. }
  879. .justify-start {
  880. display: flex;
  881. justify-content: flex-start;
  882. }
  883. .justify-center {
  884. display: flex;
  885. justify-content: center;
  886. }
  887. .justify-end {
  888. display: flex;
  889. justify-content: flex-end;
  890. }
  891. .justify-evenly {
  892. display: flex;
  893. justify-content: space-evenly;
  894. }
  895. .justify-around {
  896. display: flex;
  897. justify-content: space-around;
  898. }
  899. .justify-between {
  900. display: flex;
  901. justify-content: space-between;
  902. }
  903. .align-start {
  904. display: flex;
  905. align-items: flex-start;
  906. }
  907. .align-center {
  908. display: flex;
  909. align-items: center;
  910. }
  911. .align-end {
  912. display: flex;
  913. align-items: flex-end;
  914. }
  915. .robotRanking {
  916. background-color: #fff;
  917. position: relative;
  918. width: 100%;
  919. padding-bottom: 60px;
  920. overflow: hidden;
  921. overflow-y: auto;
  922. .box1 {
  923. height: 100%;
  924. width: 100%;
  925. .box2 {
  926. height: 64px;
  927. background: url(https://lanhu.oss-cn-beijing.aliyuncs.com/SketchPnged210ff8540d1e20d828b0758e650612a9ea018b41f720bede87fea0f933d8d8)
  928. 100% no-repeat;
  929. width: 100%;
  930. .layer1 {
  931. width: 364px;
  932. height: 20px;
  933. margin: 1px 0 0 7px;
  934. .group1 {
  935. width: 34px;
  936. height: 6px;
  937. background: url(https://lanhu.oss-cn-beijing.aliyuncs.com/SketchPnga64b2ae35561e96115c75cc6dfc235eedb108ecf95df957be1ef364417a9806e)
  938. 100% no-repeat;
  939. margin-top: 7px;
  940. }
  941. .word1 {
  942. width: 38px;
  943. height: 17px;
  944. overflow-wrap: break-word;
  945. color: rgba(81, 84, 106, 1);
  946. font-size: 12px;
  947. font-family: PingFangSC-Semibold;
  948. text-align: right;
  949. white-space: nowrap;
  950. line-height: 17px;
  951. margin-left: 21px;
  952. display: block;
  953. }
  954. .group2 {
  955. width: 30px;
  956. height: 17px;
  957. overflow-wrap: break-word;
  958. font-size: 0;
  959. font-family: PingFangSC-Semibold;
  960. text-align: right;
  961. white-space: nowrap;
  962. line-height: 17px;
  963. margin: 3px 0 0 73px;
  964. .info1 {
  965. width: 30px;
  966. height: 17px;
  967. overflow-wrap: break-word;
  968. color: rgba(81, 84, 106, 1);
  969. font-size: 12px;
  970. font-family: PingFangSC-Semibold;
  971. text-align: left;
  972. white-space: nowrap;
  973. line-height: 17px;
  974. }
  975. .word2 {
  976. width: 30px;
  977. height: 17px;
  978. overflow-wrap: break-word;
  979. color: rgba(81, 84, 106, 1);
  980. font-size: 12px;
  981. font-family: PingFangSC-Medium;
  982. text-align: left;
  983. white-space: nowrap;
  984. line-height: 17px;
  985. }
  986. }
  987. .group3 {
  988. width: 26px;
  989. height: 10px;
  990. background: url(https://lanhu.oss-cn-beijing.aliyuncs.com/SketchPng2e68dee6e62554db0f6ac40572f41b7be9cc24d35fc06b24c556fed2b7b18626)
  991. 100% no-repeat;
  992. margin: 5px 0 0 142px;
  993. }
  994. }
  995. .layer2 {
  996. width: 218px;
  997. height: 22px;
  998. margin: 9px 0 12px 10px;
  999. .label1 {
  1000. width: 10px;
  1001. height: 18px;
  1002. margin-top: 4px;
  1003. }
  1004. .txt1 {
  1005. width: 80px;
  1006. height: 22px;
  1007. overflow-wrap: break-word;
  1008. color: rgba(64, 77, 116, 1);
  1009. font-size: 16px;
  1010. font-family: PingFangSC-Medium;
  1011. text-align: center;
  1012. white-space: nowrap;
  1013. line-height: 22px;
  1014. display: block;
  1015. }
  1016. }
  1017. }
  1018. .box3 {
  1019. background-color: rgba(255, 255, 255, 1);
  1020. height: 100%;
  1021. margin-top: 1px;
  1022. width: 100%;
  1023. .main1 {
  1024. width: 100%;
  1025. height: 100%;
  1026. .groove {
  1027. height: 10px;
  1028. width: 100%;
  1029. background-color: #f5f5f5;
  1030. }
  1031. .mod1 {
  1032. background-color: rgba(255, 255, 255, 1);
  1033. height: 54px;
  1034. width: 100%;
  1035. .block1 {
  1036. width: 100%;
  1037. height: 33px;
  1038. margin-top: 21px;
  1039. .section1 {
  1040. width: 100%;
  1041. height: 17px;
  1042. padding-left: 15px;
  1043. padding-right: 15px;
  1044. .ImageText1 {
  1045. height: 16px;
  1046. margin-top: 1px;
  1047. width: 135px;
  1048. .group4 {
  1049. width: 135px;
  1050. height: 16px;
  1051. .layer3 {
  1052. width: 14px;
  1053. height: 16px;
  1054. background: url(https://lanhu.oss-cn-beijing.aliyuncs.com/SketchPngaf434f154dc423fe53e1c1f756bb2336f532874e7b7ea909f1680d0cabd0ab9d)
  1055. 100% no-repeat;
  1056. }
  1057. .TextGroup1 {
  1058. height: 14px;
  1059. margin-top: 2px;
  1060. width: 113px;
  1061. .word3 {
  1062. width: 113px;
  1063. height: 14px;
  1064. overflow-wrap: break-word;
  1065. color: rgba(64, 77, 116, 1);
  1066. font-size: 15px;
  1067. font-family: PingFangSC-Semibold;
  1068. text-align: left;
  1069. white-space: nowrap;
  1070. line-height: 15px;
  1071. display: block;
  1072. }
  1073. }
  1074. }
  1075. }
  1076. .ImageText2 {
  1077. height: 16px;
  1078. width: 39px;
  1079. .group5 {
  1080. width: 39px;
  1081. height: 16px;
  1082. .icon1 {
  1083. width: 14px;
  1084. height: 14px;
  1085. margin-top: 1px;
  1086. }
  1087. .TextGroup2 {
  1088. height: 16px;
  1089. width: 22px;
  1090. .word4 {
  1091. width: 22px;
  1092. height: 16px;
  1093. overflow-wrap: break-word;
  1094. color: rgba(64, 77, 116, 1);
  1095. font-size: 11px;
  1096. text-align: center;
  1097. white-space: nowrap;
  1098. line-height: 16px;
  1099. display: block;
  1100. }
  1101. }
  1102. }
  1103. }
  1104. }
  1105. .img1 {
  1106. width: 100%;
  1107. height: 2px;
  1108. margin-top: 14px;
  1109. }
  1110. }
  1111. }
  1112. .robotLabelName {
  1113. width: 22%;
  1114. }
  1115. .mod3 {
  1116. background-color: rgba(255, 255, 255, 1);
  1117. z-index: 24;
  1118. height: 350px;
  1119. width: 100%;
  1120. position: relative;
  1121. }
  1122. .mod5 {
  1123. background-color: rgba(255, 255, 255, 1);
  1124. z-index: 84;
  1125. height: 350px;
  1126. width: 100%;
  1127. position: relative;
  1128. }
  1129. .mod9 {
  1130. background-color: rgba(255, 255, 255, 1);
  1131. z-index: 156;
  1132. height: 350px;
  1133. width: 100%;
  1134. position: relative;
  1135. }
  1136. .mod11 {
  1137. background-color: rgba(255, 255, 255, 1);
  1138. z-index: 217;
  1139. height: 350px;
  1140. width: 100%;
  1141. position: relative;
  1142. }
  1143. }
  1144. }
  1145. }
  1146. }
  1147. </style>