index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  1. <template>
  2. <!-- 订单分析 -->
  3. <div class="orderExpotPage flex-col">
  4. <s-header :name="$t('orderExport.orderAnalysis')" :noback="false"></s-header>
  5. <div class="Body flex-col">
  6. <div class="mod3 flex-col">
  7. <div class="group1 flex-col">
  8. <div class="titleBox flex-col">
  9. <div class="layer2 flex-row">
  10. <div class="section5 flex-col"></div>
  11. <div class="TextGroup2 flex-col">
  12. <span class="txt4">{{ $t("orderExport.dataOverview") }}</span>
  13. </div>
  14. </div>
  15. </div>
  16. <div class="dateSelectBox">
  17. <dateSelectList @update="update($event)"></dateSelectList>
  18. </div>
  19. <div class="l-f l-flex-e o-plr-15 o-pt-10">
  20. <span class="o-mr-6 c-text-13 c-text-color">{{ $t("orderExport.groupType") }}:</span>
  21. <kTabs @tabchg="tabChg" :tabList="tabList"></kTabs>
  22. </div>
  23. <div class="mod7 flex-col">
  24. <div class="box1 flex-col justify-between">
  25. <div class="group4 l-flex-between">
  26. <div class="ImageText2 l-flex-RC">
  27. <div class="mod8 l-flex-RC">
  28. <div class="group5 flex-col"></div>
  29. <div class="TextGroup2 flex-col">
  30. <span class="txt1 c-text-w6">{{
  31. $t("orderExport.orderDetails")
  32. }}</span>
  33. </div>
  34. </div>
  35. </div>
  36. <div class="l-flex-RC">
  37. <div class="c-text-13 l-flex-RC text5">
  38. <span @click="noticeClk" class="">{{
  39. $t("orderExport.clickFilter")
  40. }}</span>
  41. <div class="outer4 flex-col o-ml-6"></div>
  42. </div>
  43. <div @click="exportOrder()" class="c-text-13 l-flex-RC o-ml-20 c-text-color">
  44. <span class="">{{
  45. $t("orderExport.exportToExcel")
  46. }}</span>
  47. <div class="outer4 flex-col o-ml-6"></div>
  48. </div>
  49. </div>
  50. </div>
  51. <img class="img2" referrerpolicy="no-referrer"
  52. src="https://lanhu.oss-cn-beijing.aliyuncs.com/SketchPng8947935ab81635fdedd8124b11e305eef66286421b69c84fef22233014a3fa9a" />
  53. </div>
  54. </div>
  55. <!-- <van-pull-refresh disabled v-model="refreshing" @refresh="onRefresh"> -->
  56. <van-list v-model:loading="loading" v-model:error="error" :error-text="$t('public.requestFailed')"
  57. :finished="finished" :finished-text="$t('public.noMore')" @load="onLoad"
  58. :immediate-check="false">
  59. <div v-for="(item, index) in tableData" :key="index" class="orderItem">
  60. <div class="mod9 flex-row">
  61. <span class="info7">&yen;</span>
  62. <span class="info8">{{ item.priceTotal }}</span>
  63. <span class="word9">{{ $t("orderExport.totalSales") }}</span>
  64. </div>
  65. <div class="mod10 flex-row">
  66. <span class="txt3 o-mr-10">{{ item.username }}</span>
  67. <span class="txt4 c-text-line1">{{ item.name }}</span><span class="txt4 c-text-line1">,{{ item.phone
  68. }}</span>
  69. </div>
  70. <span class="info9">{{ $t("orderExport.address") }}:{{ item.address }}</span>
  71. <div class="mod11 flex-col">
  72. <span v-if="type == 2" class="txt5">{{ item.equipmentTotal }}{{ $t("orderExport.machines") }},{{
  73. $t("orderExport.superior")
  74. }}:{{ item.lastUsername }}</span>
  75. <div v-else class="txt5 l-flex-RC">
  76. <div>{{ item.equipmentType }}</div>
  77. <div class="lineCon o-mlr-6"></div>
  78. <div>{{ item.clientId }}</div>
  79. </div>
  80. </div>
  81. </div>
  82. </van-list>
  83. <!-- </van-pull-refresh> -->
  84. </div>
  85. </div>
  86. </div>
  87. <!-- 筛选弹窗 -->
  88. <kDialog :dialogTitle="$t('orderExport.searchPop.title')" :cancelBtnTxt="$t('orderExport.searchPop.clearFilter')"
  89. :confirmBtnTxt="$t('orderExport.searchPop.filter')" ref="kDialogRef" @confirmclk="confirmClk"
  90. :isCloseForCancel="false" @cancelclk="cancelClk">
  91. <template #content>
  92. <div class="cust_vantBorder">
  93. <van-field clearable v-model="searchForm.orderNo" :placeholder="$t('orderExport.searchPop.orderNoPlace')"
  94. :label="$t('orderExport.searchPop.orderNo')" />
  95. <van-field clearable v-model="searchForm.busiName" :placeholder="$t('orderExport.searchPop.busiNamePlace')"
  96. :label="$t('orderExport.searchPop.busiName')" />
  97. <van-field @click-input="changeTypeInpClk" readonly clearable v-model="searchForm.ifForeignName"
  98. :placeholder="$t('orderExport.searchPop.mainOverPlace')" :label="$t('orderExport.searchPop.mainOver')">
  99. <template #right-icon>
  100. <div class="l-flex-RC">
  101. <van-icon v-if="searchForm.ifForeignName" @click="searchForm.ifForeignName = '';
  102. searchForm.ifForeign = '';" class="o-mr-6" name="clear" />
  103. <van-icon @click="changeTypeInpClk" name="arrow-down" />
  104. </div>
  105. </template>
  106. </van-field>
  107. <van-field v-if="isAdmin()" @click-input="companyTypeInpClk" readonly clearable
  108. v-model="searchForm.companyTypeName" :placeholder="$t('orderExport.searchPop.companyTypePlaceholder')"
  109. :label="$t('orderExport.searchPop.companyTypeLabel')">
  110. <template #right-icon>
  111. <div class="l-flex-RC">
  112. <van-icon v-if="searchForm.companyTypeName" @click="
  113. searchForm.companyTypeName = '';
  114. searchForm.companyType = '';
  115. " class="o-mr-6" name="clear" />
  116. <van-icon @click="companyTypeInpClk" name="arrow-down" />
  117. </div>
  118. </template>
  119. </van-field>
  120. </div>
  121. </template>
  122. </kDialog>
  123. <!-- 大陆或海外弹窗 -->
  124. <van-popup v-model:show="changeTypeShow" position="bottom">
  125. <van-picker :title="$t('orderExport.searchPop.mainOverPlace')" :columns="changeTypePopList"
  126. :columns-field-names="changeTypePopFieldName" @confirm="changeTypePopConfirm" @cancel="changeTypeShow = false" />
  127. </van-popup>
  128. <!-- 公司平台弹窗 -->
  129. <van-popup v-model:show="companyTypeShow" position="bottom">
  130. <van-picker :default-index="chgTypeDefaIdx" :title="$t('orderExport.searchPop.companyTypePlaceholder')"
  131. :columns="companyTypePopList" :columns-field-names="changeTypePopFieldName" @confirm="companyTypePopConfirm"
  132. @cancel="companyTypeShow = false" />
  133. </van-popup>
  134. </div>
  135. </template>
  136. <script>
  137. import { getOrderList, Api_getOrderExport } from "@/service/orderExport";
  138. import { onMounted, reactive, toRefs, ref } from "vue";
  139. import sHeader from "@/components/SimpleHeader";
  140. import { getLoginUser, $M_ExportFile } from "@/common/js/utils";
  141. import dateSelectList from "@/components/dateSelectList";
  142. import dateUtil from "@/utils/dateUtil";
  143. import kTabs from "@/components/commom/kTabs/index.vue";
  144. import { useI18n } from "vue-i18n";
  145. import kDialog from "@/components/commom/kDialog/index.vue";
  146. import moment from 'moment';
  147. import { styleUrl } from "../../common/js/utils";
  148. import { Toast } from "vant";
  149. export default {
  150. name: "orderExport",
  151. components: { sHeader, dateSelectList, kTabs, kDialog },
  152. setup() {
  153. // 分页
  154. const pageNo = ref(1);
  155. const pageSize = ref(10);
  156. // let ruleData = reactive({
  157. // tableData: [],
  158. // });
  159. const tableData = ref([]);
  160. const orderTotal = ref(0);
  161. // 上拉刷新
  162. const loading = ref(true);
  163. const finished = ref(false);
  164. const error = ref(false);
  165. // 下拉刷新
  166. // const refreshing = ref(false);
  167. const user = getLoginUser();
  168. const companyTypeShow = ref(false);
  169. // 是否管理员
  170. const isAdmin = () => { return (user && user.type === 0); }
  171. // 公司平台弹窗
  172. const companyTypeInpClk = () => {
  173. companyTypeShow.value = true;
  174. };
  175. onMounted(() => {
  176. // 加载样式
  177. styleUrl('orderExport');
  178. // ruleData.tableData = [];
  179. tableData.value = [];
  180. pageNo.value = 1;
  181. pageSize.value = 10;
  182. // 今日
  183. searchParams.startDate = moment().format("YYYY-MM-DD") + " 00:00:00";
  184. searchParams.endDate = moment().format("YYYY-MM-DD") + " 23:59:59";
  185. if (user) {
  186. // onRefresh();
  187. finished.value = false;
  188. getList();
  189. }
  190. });
  191. // 下拉刷新
  192. // const onRefresh = (idx) => {
  193. // ruleData.tableData = [];
  194. // // 解决请求两次问题
  195. // if (!idx) {
  196. // finished.value = false;
  197. // }
  198. // loading.value = true;
  199. // // 初始化分页
  200. // pageNo.value = 1;
  201. // pageSize.value = 10;
  202. // getList();
  203. // };
  204. // 上拉加载
  205. const onLoad = () => {
  206. // if (!finished.value) {
  207. // console.log("1");
  208. if (!finished.value) {
  209. // console.log("加载中")
  210. pageNo.value = pageNo.value + pageSize.value;
  211. getList();
  212. }
  213. };
  214. // 获取列表数据
  215. const getList = async () => {
  216. loading.value = true;
  217. finished.value = false;
  218. // 如果存在chartType去掉
  219. if (searchParams.chartType) {
  220. delete searchParams.chartType;
  221. }
  222. let param = {
  223. current: pageNo.value,
  224. size: pageSize.value,
  225. };
  226. const { data } = await getOrderList(Object.assign(param, searchParams));
  227. if (data.code === "00000") {
  228. if (data.data.total === 0) {
  229. finished.value = true;
  230. } else {
  231. if (param.current === 1) {
  232. tableData.value = [];
  233. orderTotal.value = 0;
  234. }
  235. // 列表值叠加
  236. if (data.data.records.length > 0) {
  237. tableData.value = tableData.value.concat(data.data.records);
  238. orderTotal.value = data.data.records.length + orderTotal.value;
  239. if (orderTotal.value === data.data.total) {
  240. finished.value = true;
  241. }
  242. } else {
  243. finished.value = true;
  244. }
  245. }
  246. loading.value = false;
  247. } else {
  248. loading.value = false;
  249. Toast.fail("数据加载失败");
  250. }
  251. };
  252. // getOrderList(Object.assign(param, searchParams)).then((res) => {
  253. // const { data } = res.data;
  254. // console.log('data的值是 >>>', data)
  255. // if (data) {
  256. // // refreshing.value = false;
  257. // ruleData.tableData.push(...data.records);
  258. // console.log("数据长度:", ruleData.tableData.length);
  259. // console.log("数据量:", data.total);
  260. // // 加载状态结束
  261. // loading.value = false;
  262. // if (ruleData.tableData.length === data.total) {
  263. // finished.value = true;
  264. // }
  265. // }
  266. // });
  267. // };
  268. // 引入语言
  269. const { t } = useI18n();
  270. // 大陆或海外弹窗
  271. // 控制显示
  272. const changeTypeShow = ref(false);
  273. // 点击显示弹窗
  274. const changeTypeInpClk = () => {
  275. changeTypeShow.value = true;
  276. };
  277. // 弹窗选中的值
  278. const changeTypePopFieldName = reactive({
  279. text: "name",
  280. value: "id",
  281. });
  282. // 弹窗选项
  283. const changeTypePopList = [
  284. {
  285. name: t('orderExport.searchPop.mainland'),
  286. id: "0",
  287. },
  288. {
  289. name: t('orderExport.searchPop.overseas'),
  290. id: "1",
  291. },
  292. ];
  293. // 点击弹窗的确定按钮
  294. const changeTypePopConfirm = (e) => {
  295. // console.log('e')
  296. searchForm.ifForeign = e.id;
  297. searchForm.ifForeignName = e.name;
  298. changeTypeShow.value = false;
  299. };
  300. const companyTypePopConfirm = (e) => {
  301. searchForm.companyType = e.id;
  302. searchForm.companyTypeName = e.name;
  303. companyTypeShow.value = false;
  304. };
  305. // 点击导出按钮
  306. const exportOrder = async () => {
  307. const param = {
  308. current: pageNo.value,
  309. size: pageSize.value,
  310. };
  311. const { headers, data } = await Api_getOrderExport(Object.assign(param, searchParams));
  312. // console.log('headers', headers)
  313. // console.log('data', data)
  314. $M_ExportFile(data, headers);
  315. };
  316. // 筛选弹窗的元素
  317. const kDialogRef = ref(null);
  318. // 点击筛选
  319. const noticeClk = () => {
  320. kDialogRef.value.openDialog();
  321. };
  322. // 筛选弹窗
  323. const searchForm = reactive({
  324. orderNo: "",
  325. busiName: "",
  326. ifForeign: "0",
  327. ifForeignName: "大陆",
  328. companyType: "",
  329. companyTypeName: "全部",
  330. });
  331. // 点击筛选条件的清空条件按钮
  332. const cancelClk = () => {
  333. searchForm.orderNo = '';
  334. searchForm.busiName = '';
  335. searchForm.ifForeign = '0';
  336. searchForm.ifForeignName = '大陆';
  337. searchForm.companyType = "";
  338. };
  339. // 点击筛选条件的筛选按钮
  340. const confirmClk = () => {
  341. searchParams.clientId = searchForm.orderNo;
  342. searchParams.username = searchForm.busiName;
  343. searchParams.ifForeign = searchForm.ifForeign;
  344. searchParams.companyType = searchForm.companyType;
  345. tableData.value = [];
  346. getList();
  347. };
  348. // 商户设备tab栏
  349. const tabList = ref([
  350. {
  351. name: t("orderExport.merchant"),
  352. icon: "",
  353. id: 1,
  354. },
  355. {
  356. name: t("orderExport.equipment"),
  357. icon: "",
  358. id: 2,
  359. },
  360. ]);
  361. // 公司平台
  362. const companyTypePopList = [
  363. {
  364. name: t("orderExport.searchPop.whole"),
  365. id: "",
  366. },
  367. {
  368. name: t("orderExport.searchPop.sz"),
  369. id: "0",
  370. },
  371. {
  372. name: t("orderExport.searchPop.sc"),
  373. id: "1",
  374. },
  375. ];
  376. // 点击tab
  377. const tabChg = (e) => {
  378. pageNo.value = 1;
  379. pageSize.value = 10;
  380. // ruleData.tableData = [];
  381. tableData.value = [];
  382. if (e == 1) {
  383. searchParams.type = 1;
  384. } else {
  385. searchParams.type = 2;
  386. }
  387. getList();
  388. };
  389. let searchParams = reactive({
  390. type: "2", // 分组类型
  391. clientId: "", // 设备编号
  392. username: "",
  393. startDate: "",
  394. endDate: "",
  395. ifForeign: '0',
  396. adminId: user.id,
  397. companyType: "",
  398. });
  399. // 搜索点击
  400. const searchClick = () => {
  401. // console.log("searchClick");
  402. };
  403. // 今日、明日、本周、本月、其他时间选择回调
  404. const update = (uDate) => {
  405. // console.log("日期修改")
  406. pageNo.value = 1;
  407. pageSize.value = 10;
  408. // ruleData.tableData = [];
  409. tableData.value = [];
  410. searchParams = Object.assign(searchParams, uDate);
  411. searchParams.startDate = dateUtil.formateDate(
  412. new Date(searchParams.startDate),
  413. "yyyy-MM-dd hh:mm:ss"
  414. );
  415. searchParams.endDate = dateUtil.formateDate(
  416. new Date(searchParams.endDate),
  417. "yyyy-MM-dd hh:mm:ss"
  418. );
  419. getList();
  420. // onRefresh(1);
  421. };
  422. return {
  423. ...toRefs(searchParams),
  424. companyTypePopConfirm,
  425. companyTypePopList,
  426. searchClick,
  427. companyTypeInpClk,
  428. companyTypeShow,
  429. update,
  430. exportOrder,
  431. tabChg,
  432. tabList,
  433. confirmClk,
  434. searchForm,
  435. noticeClk,
  436. kDialogRef,
  437. cancelClk,
  438. changeTypePopList,
  439. changeTypePopConfirm,
  440. changeTypeShow,
  441. changeTypeInpClk,
  442. changeTypePopFieldName,
  443. pageNo,
  444. pageSize,
  445. loading,
  446. finished,
  447. // refreshing,
  448. // onRefresh,
  449. onLoad,
  450. getList,
  451. isAdmin,
  452. tableData,
  453. error,
  454. // ...toRefs(ruleData),
  455. };
  456. },
  457. };
  458. </script>
  459. <style lang="less" scoped>
  460. @import "../../common/style/common.less";
  461. @import "../../styles/orderExport/index.less";
  462. </style>