robotRanking.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203
  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. name: t("home.productNum"),
  678. label: {
  679. show: true,
  680. position: "top",
  681. },
  682. },
  683. {
  684. ...data.data.series[1],
  685. type: "bar",
  686. itemStyle: { color: "#E59A6D" },
  687. name: t("home.salesAmount"),
  688. label: {
  689. show: true,
  690. position: "top",
  691. },
  692. },
  693. ];
  694. dayChartOption.dataZoom[0]["startValue"] =
  695. data.data.categories[data.data.categories.length - 5];
  696. dayChartOption.dataZoom[0]["endValue"] =
  697. data.data.categories[data.data.categories.length - 1];
  698. // 解决resize不起作用,配合onMounted里的方法使用
  699. switch (chartType) {
  700. case "day":
  701. chartObj.day = window.echarts.init(chartBox, null, {
  702. renderer: "canvas",
  703. useDirtyRect: false,
  704. });
  705. chartObj.day && chartObj.day.setOption(dayChartOption);
  706. break;
  707. case "week":
  708. chartObj.week = window.echarts.init(chartBox, null, {
  709. renderer: "canvas",
  710. useDirtyRect: false,
  711. });
  712. chartObj.week && chartObj.week.setOption(dayChartOption);
  713. break;
  714. case "month":
  715. chartObj.month = window.echarts.init(chartBox, null, {
  716. renderer: "canvas",
  717. useDirtyRect: false,
  718. });
  719. chartObj.month && chartObj.month.setOption(dayChartOption);
  720. break;
  721. case "year":
  722. chartObj.year = window.echarts.init(chartBox, null, {
  723. renderer: "canvas",
  724. useDirtyRect: false,
  725. });
  726. chartObj.year && chartObj.year.setOption(dayChartOption);
  727. break;
  728. }
  729. }
  730. }
  731. });
  732. };
  733. const user = getLoginUser();
  734. // 日、周、月、年的图表
  735. const dayChartBox = ref();
  736. const weekChartBox = ref();
  737. const monthChartBox = ref();
  738. const yearChartBox = ref();
  739. // 初始化页面获取列表
  740. onMounted(async () => {
  741. // 默认筛选选中
  742. searchForm.changeTypeName = t("robotRanking.salesStatistics");
  743. searchForm.changeType = 0;
  744. init();
  745. window.addEventListener("resize", () => {
  746. chartObj.day && chartObj.day.resize();
  747. chartObj.week && chartObj.week.resize();
  748. chartObj.month && chartObj.month.resize();
  749. chartObj.year && chartObj.year.resize();
  750. });
  751. });
  752. // 刚进页面获取
  753. const init = () => {
  754. // 获取日的排行数据
  755. getEquipRankList("day", defaultTime.todayStart, defaultTime.todayEnd);
  756. // 获取周的排行数据
  757. getEquipRankList("week", defaultTime.weekStart, defaultTime.weekEnd);
  758. // 获取月的排行数据
  759. getEquipRankList("month", defaultTime.monthStart, defaultTime.monthEnd);
  760. // 获取年的排行数据
  761. getEquipRankList("year", defaultTime.yearStart, defaultTime.yearEnd);
  762. };
  763. const searchForm = reactive({
  764. businessName: "",
  765. changeTypeName: "",
  766. changeType: "",
  767. });
  768. const kDialogRef = ref(null);
  769. const busiPopShow = ref(false);
  770. const busiPopList = reactive([
  771. {
  772. name: "商户1",
  773. id: "1",
  774. },
  775. {
  776. name: "商户2",
  777. id: "2",
  778. },
  779. ]);
  780. const busiPopFieldName = reactive({
  781. text: "name",
  782. value: "id",
  783. });
  784. // 点击筛选
  785. const noticeClk = () => {
  786. kDialogRef.value.openDialog();
  787. };
  788. // 点击右侧按钮
  789. const confirmClk = () => {
  790. if (searchForm.changeType === "") {
  791. changeType.value = 1;
  792. } else {
  793. changeType.value = searchForm.changeType;
  794. }
  795. init();
  796. };
  797. // 筛选弹窗
  798. // 点击商家输入框
  799. const busiInpClk = () => {
  800. console.log(111111111);
  801. busiPopShow.value = true;
  802. };
  803. const busiPopConfirm = (e) => {
  804. console.log("e", e);
  805. busiPopShow.value = false;
  806. searchForm.businessName = e.name;
  807. };
  808. const busiPopCancel = () => {
  809. busiPopShow.value = false;
  810. };
  811. return {
  812. dayChartBox,
  813. weekChartBox,
  814. monthChartBox,
  815. yearChartBox,
  816. tabclk,
  817. tabDayList,
  818. tabWeekList,
  819. tabMonthList,
  820. tabYearList,
  821. noticeClk,
  822. kDialogRef,
  823. busiInpClk,
  824. busiPopShow,
  825. busiPopConfirm,
  826. busiPopList,
  827. busiPopFieldName,
  828. busiPopCancel,
  829. confirmClk,
  830. searchForm,
  831. dayShow,
  832. minDate,
  833. calendarDayConfirm,
  834. weekShow,
  835. monthShow,
  836. calendarWeekOrMonConfirm,
  837. yearFormatter,
  838. currentDate,
  839. yearShow,
  840. yearPopList,
  841. yearPopConfirm,
  842. yearPopFieldName,
  843. changeTypeShow,
  844. changeTypePopList,
  845. changeTypePopConfirm,
  846. changeTypeInpClk,
  847. totalNoData,
  848. chgTypeDefaIdx,
  849. };
  850. },
  851. components: { sHeader, navBar, kTabs, kDialog, kNoData },
  852. };
  853. </script>
  854. <style lang="less" scoped>
  855. body * {
  856. box-sizing: border-box;
  857. flex-shrink: 0;
  858. }
  859. body {
  860. font-family: PingFangSC-Regular, Roboto, Helvetica Neue, Helvetica, Tahoma,
  861. Arial, PingFang SC-Light, Microsoft YaHei;
  862. }
  863. button {
  864. margin: 0;
  865. padding: 0;
  866. border: 1px solid transparent;
  867. outline: none;
  868. background-color: transparent;
  869. }
  870. button:active {
  871. opacity: 0.6;
  872. }
  873. .flex-col {
  874. display: flex;
  875. flex-direction: column;
  876. }
  877. .flex-row {
  878. display: flex;
  879. flex-direction: row;
  880. }
  881. .justify-start {
  882. display: flex;
  883. justify-content: flex-start;
  884. }
  885. .justify-center {
  886. display: flex;
  887. justify-content: center;
  888. }
  889. .justify-end {
  890. display: flex;
  891. justify-content: flex-end;
  892. }
  893. .justify-evenly {
  894. display: flex;
  895. justify-content: space-evenly;
  896. }
  897. .justify-around {
  898. display: flex;
  899. justify-content: space-around;
  900. }
  901. .justify-between {
  902. display: flex;
  903. justify-content: space-between;
  904. }
  905. .align-start {
  906. display: flex;
  907. align-items: flex-start;
  908. }
  909. .align-center {
  910. display: flex;
  911. align-items: center;
  912. }
  913. .align-end {
  914. display: flex;
  915. align-items: flex-end;
  916. }
  917. .robotRanking {
  918. background-color: #fff;
  919. position: relative;
  920. width: 100%;
  921. padding-bottom: 60px;
  922. overflow: hidden;
  923. overflow-y: auto;
  924. .box1 {
  925. height: 100%;
  926. width: 100%;
  927. .box2 {
  928. height: 64px;
  929. background: url(https://lanhu.oss-cn-beijing.aliyuncs.com/SketchPnged210ff8540d1e20d828b0758e650612a9ea018b41f720bede87fea0f933d8d8)
  930. 100% no-repeat;
  931. width: 100%;
  932. .layer1 {
  933. width: 364px;
  934. height: 20px;
  935. margin: 1px 0 0 7px;
  936. .group1 {
  937. width: 34px;
  938. height: 6px;
  939. background: url(https://lanhu.oss-cn-beijing.aliyuncs.com/SketchPnga64b2ae35561e96115c75cc6dfc235eedb108ecf95df957be1ef364417a9806e)
  940. 100% no-repeat;
  941. margin-top: 7px;
  942. }
  943. .word1 {
  944. width: 38px;
  945. height: 17px;
  946. overflow-wrap: break-word;
  947. color: rgba(81, 84, 106, 1);
  948. font-size: 12px;
  949. font-family: PingFangSC-Semibold;
  950. text-align: right;
  951. white-space: nowrap;
  952. line-height: 17px;
  953. margin-left: 21px;
  954. display: block;
  955. }
  956. .group2 {
  957. width: 30px;
  958. height: 17px;
  959. overflow-wrap: break-word;
  960. font-size: 0;
  961. font-family: PingFangSC-Semibold;
  962. text-align: right;
  963. white-space: nowrap;
  964. line-height: 17px;
  965. margin: 3px 0 0 73px;
  966. .info1 {
  967. width: 30px;
  968. height: 17px;
  969. overflow-wrap: break-word;
  970. color: rgba(81, 84, 106, 1);
  971. font-size: 12px;
  972. font-family: PingFangSC-Semibold;
  973. text-align: left;
  974. white-space: nowrap;
  975. line-height: 17px;
  976. }
  977. .word2 {
  978. width: 30px;
  979. height: 17px;
  980. overflow-wrap: break-word;
  981. color: rgba(81, 84, 106, 1);
  982. font-size: 12px;
  983. font-family: PingFangSC-Medium;
  984. text-align: left;
  985. white-space: nowrap;
  986. line-height: 17px;
  987. }
  988. }
  989. .group3 {
  990. width: 26px;
  991. height: 10px;
  992. background: url(https://lanhu.oss-cn-beijing.aliyuncs.com/SketchPng2e68dee6e62554db0f6ac40572f41b7be9cc24d35fc06b24c556fed2b7b18626)
  993. 100% no-repeat;
  994. margin: 5px 0 0 142px;
  995. }
  996. }
  997. .layer2 {
  998. width: 218px;
  999. height: 22px;
  1000. margin: 9px 0 12px 10px;
  1001. .label1 {
  1002. width: 10px;
  1003. height: 18px;
  1004. margin-top: 4px;
  1005. }
  1006. .txt1 {
  1007. width: 80px;
  1008. height: 22px;
  1009. overflow-wrap: break-word;
  1010. color: rgba(64, 77, 116, 1);
  1011. font-size: 16px;
  1012. font-family: PingFangSC-Medium;
  1013. text-align: center;
  1014. white-space: nowrap;
  1015. line-height: 22px;
  1016. display: block;
  1017. }
  1018. }
  1019. }
  1020. .box3 {
  1021. background-color: rgba(255, 255, 255, 1);
  1022. height: 100%;
  1023. margin-top: 1px;
  1024. width: 100%;
  1025. .main1 {
  1026. width: 100%;
  1027. height: 100%;
  1028. .groove {
  1029. height: 10px;
  1030. width: 100%;
  1031. background-color: #f5f5f5;
  1032. }
  1033. .mod1 {
  1034. background-color: rgba(255, 255, 255, 1);
  1035. height: 54px;
  1036. width: 100%;
  1037. .block1 {
  1038. width: 100%;
  1039. height: 33px;
  1040. margin-top: 21px;
  1041. .section1 {
  1042. width: 100%;
  1043. height: 17px;
  1044. padding-left: 15px;
  1045. padding-right: 15px;
  1046. .ImageText1 {
  1047. height: 16px;
  1048. margin-top: 1px;
  1049. width: 135px;
  1050. .group4 {
  1051. width: 135px;
  1052. height: 16px;
  1053. .layer3 {
  1054. width: 14px;
  1055. height: 16px;
  1056. background: url(https://lanhu.oss-cn-beijing.aliyuncs.com/SketchPngaf434f154dc423fe53e1c1f756bb2336f532874e7b7ea909f1680d0cabd0ab9d)
  1057. 100% no-repeat;
  1058. }
  1059. .TextGroup1 {
  1060. height: 14px;
  1061. margin-top: 2px;
  1062. width: 113px;
  1063. .word3 {
  1064. width: 113px;
  1065. height: 14px;
  1066. overflow-wrap: break-word;
  1067. color: rgba(64, 77, 116, 1);
  1068. font-size: 15px;
  1069. font-family: PingFangSC-Semibold;
  1070. text-align: left;
  1071. white-space: nowrap;
  1072. line-height: 15px;
  1073. display: block;
  1074. }
  1075. }
  1076. }
  1077. }
  1078. .ImageText2 {
  1079. height: 16px;
  1080. width: 39px;
  1081. .group5 {
  1082. width: 39px;
  1083. height: 16px;
  1084. .icon1 {
  1085. width: 14px;
  1086. height: 14px;
  1087. margin-top: 1px;
  1088. }
  1089. .TextGroup2 {
  1090. height: 16px;
  1091. width: 22px;
  1092. .word4 {
  1093. width: 22px;
  1094. height: 16px;
  1095. overflow-wrap: break-word;
  1096. color: rgba(64, 77, 116, 1);
  1097. font-size: 11px;
  1098. text-align: center;
  1099. white-space: nowrap;
  1100. line-height: 16px;
  1101. display: block;
  1102. }
  1103. }
  1104. }
  1105. }
  1106. }
  1107. .img1 {
  1108. width: 100%;
  1109. height: 2px;
  1110. margin-top: 14px;
  1111. }
  1112. }
  1113. }
  1114. .robotLabelName {
  1115. width: 22%;
  1116. }
  1117. .mod3 {
  1118. background-color: rgba(255, 255, 255, 1);
  1119. z-index: 24;
  1120. height: 350px;
  1121. width: 100%;
  1122. position: relative;
  1123. }
  1124. .mod5 {
  1125. background-color: rgba(255, 255, 255, 1);
  1126. z-index: 84;
  1127. height: 350px;
  1128. width: 100%;
  1129. position: relative;
  1130. }
  1131. .mod9 {
  1132. background-color: rgba(255, 255, 255, 1);
  1133. z-index: 156;
  1134. height: 350px;
  1135. width: 100%;
  1136. position: relative;
  1137. }
  1138. .mod11 {
  1139. background-color: rgba(255, 255, 255, 1);
  1140. z-index: 217;
  1141. height: 350px;
  1142. width: 100%;
  1143. position: relative;
  1144. }
  1145. }
  1146. }
  1147. }
  1148. }
  1149. </style>