index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  1. <template>
  2. <div class="airportInfo">
  3. <div class="variable">
  4. <StatisticsHeader
  5. :title="titleTop"
  6. :items="formItems"
  7. :data="formData"
  8. :eledata="eledata"
  9. with-setting
  10. :withSetting="false"
  11. :withExport="true"
  12. :set="set"
  13. :action="action"
  14. :asShow="asShow"
  15. @getFormData="getFormData"
  16. @export="tableToExcel"
  17. @upset="upset"
  18. />
  19. </div>
  20. <div
  21. class="echart"
  22. :style="
  23. tableList.length > 0 ? 'background:rgba(0,0,0,0)' : 'background:#ffffff'
  24. "
  25. >
  26. <Tableformbrs
  27. :tableList="
  28. tableList.slice((currentPage - 1) * pagesize, currentPage * pagesize)
  29. "
  30. :action="changing"
  31. :set="set"
  32. :listall="listall"
  33. />
  34. </div>
  35. <el-pagination
  36. background
  37. v-if="tableList.length > 0"
  38. @size-change="handleSizeChange"
  39. @current-change="handleCurrentChange"
  40. layout="total, prev, pager, next, jumper"
  41. :total="total"
  42. :page-size="pagesize"
  43. style="position: absolute; right: 0; bottom: 0"
  44. >
  45. </el-pagination>
  46. </div>
  47. </template>
  48. <script>
  49. import Echarts from "../components/echart/index.vue";
  50. import Tableformbrs from "../components/echart/tableforms.vue";
  51. import StatisticsHeader from "../components/echart/statisticsHeader.vue";
  52. import { export_json_to_excel } from "@/utils/Export2Excel";
  53. import { Query } from "@/api/webApi";
  54. export default {
  55. name: "ChartsBar",
  56. data() {
  57. return {
  58. currentPage: 1,
  59. pagesize: 10,
  60. total: 0,
  61. changing: "12",
  62. asShow: false,
  63. optiondata: [],
  64. picShow: true, //图片表格切换
  65. action: 0,
  66. uppps: null,
  67. dataid: "collection_ecahrt0",
  68. listqueryTemplateID: DATACONTENT_ID.modeChannelbased,
  69. eledata: null,
  70. set: "",
  71. isShow: Echarts,
  72. tableList: [],
  73. tableListcop: [],
  74. listname: "",
  75. listHeader: [],
  76. tableData: {
  77. time: [],
  78. data1: [],
  79. data2: [],
  80. kg: "",
  81. tyol: "",
  82. },
  83. formData: {
  84. airport: "",
  85. dateTime: "",
  86. },
  87. titleTop: "龙门架统计",
  88. formItems: [
  89. {
  90. prop: "pps",
  91. inputType: "select",
  92. placeholder: "统计范围",
  93. requiredWarning: "请先选择统计范围",
  94. clearable: true,
  95. options: [
  96. {
  97. value: 1,
  98. label: "基于通道",
  99. },
  100. {
  101. value: 2,
  102. label: "基于代理人",
  103. },
  104. ],
  105. },
  106. {
  107. prop: "dateTime",
  108. inputType: "datePicker",
  109. clearable: true,
  110. width: "240px",
  111. options: [],
  112. },
  113. ],
  114. listall: {
  115. piclvall: 0,
  116. acclvall: 0,
  117. readlvall: 0,
  118. oklvall: 0,
  119. reCodeNumall: 0,
  120. codeNumall: 0,
  121. reAccNumall: 0,
  122. accNumall: 0,
  123. pcsall: 0,
  124. },
  125. };
  126. },
  127. mounted() {
  128. this.pagesize = window.screen.height > 1080 ? 20 : 10;
  129. // this.getQuery([]);
  130. },
  131. watch: {
  132. // 监听数据变化,重绘折线图
  133. option: {
  134. deep: true,
  135. handler(newVal) {},
  136. },
  137. },
  138. destroyed() {},
  139. methods: {
  140. handleSizeChange(val) {
  141. this.pagesize = val;
  142. },
  143. handleCurrentChange(val) {
  144. this.currentPage = val;
  145. },
  146. getFormData(data) {
  147. this.listall.piclvall = 0;
  148. this.listall.acclvall = 0;
  149. this.listall.readlvall = 0;
  150. this.listall.oklvall = 0;
  151. this.listall.reCodeNumall = 0;
  152. this.listall.codeNumall = 0;
  153. this.listall.reAccNumall = 0;
  154. this.listall.accNumall = 0;
  155. this.listall.pcsall = 0;
  156. this.tableData.time = [];
  157. this.tableData.data1 = [];
  158. this.tableData.data2 = [];
  159. this.listname = "龙门架统计" + data.dateTime[0] + "--" + data.dateTime[1];
  160. this.uppps = data.pps;
  161. if (data.pps === 1) {
  162. (this.listqueryTemplateID = DATACONTENT_ID.modeChannelbased),
  163. (this.listHeader = [
  164. "序号",
  165. "日期",
  166. "通道",
  167. "龙门架扫码数",
  168. "龙门架扫码重复条码数",
  169. "加货条码数量",
  170. "加货重复条码数量",
  171. "加货记录的该通道运单件数",
  172. "龙门架重码率",
  173. "加货重码率",
  174. "识读率",
  175. "加货准确率",
  176. ]);
  177. this.changing = 12;
  178. } else if (data.pps === 2) {
  179. (this.listqueryTemplateID = DATACONTENT_ID.modeAgentbased),
  180. (this.listHeader = [
  181. "序号",
  182. "日期",
  183. "代理人",
  184. "通道",
  185. "龙门架扫码数",
  186. "龙门架扫码重复条码数",
  187. "加货条码数量",
  188. "加货重复条码数量",
  189. "加货记录的该通道运单件数",
  190. "龙门架重码率",
  191. "加货重码率",
  192. "识读率",
  193. "加货准确率",
  194. ]);
  195. this.changing = 13;
  196. }
  197. let option = [
  198. {
  199. fd1: data.dateTime[0],
  200. fd2: data.dateTime[1],
  201. },
  202. ];
  203. this.getQuery(option, null);
  204. },
  205. //获取表格数据
  206. async getQuery(data, dat) {
  207. try {
  208. const { code, returnData } = await Query({
  209. id: this.listqueryTemplateID,
  210. dataContent: data,
  211. });
  212. if (code == 0) {
  213. this.tableData.time = [];
  214. this.tableData.data1 = [];
  215. this.tableData.data2 = [];
  216. this.tableList = JSON.parse(JSON.stringify(returnData.listValues));
  217. this.tableListcop = JSON.parse(JSON.stringify(returnData.listValues));
  218. this.total = this.tableList.length;
  219. for (let i = 0; i < 9; i++) {
  220. if (!this.tableList[i]) {
  221. this.tableList.push({});
  222. }
  223. }
  224. this.tableList.forEach((item, index) => {
  225. item.reCodeNum = item.reCodeNum ? item.reCodeNum : 0;
  226. item.codeNum = item.codeNum ? item.codeNum : 0;
  227. item.reAccNum = item.reAccNum ? item.reAccNum : 0;
  228. item.accNum = item.accNum ? item.accNum : 0;
  229. item.pcs = item.pcs ? item.pcs : 0;
  230. if (item.codeNum === 0) {
  231. item.piclvs = ((item.reCodeNum * 100) / 1).toFixed(2);
  232. } else {
  233. item.piclvs = ((item.reCodeNum * 100) / item.codeNum).toFixed(2);
  234. }
  235. if (item.accNum === 0) {
  236. item.acclvs = ((item.reAccNum * 100) / 1).toFixed(2);
  237. } else {
  238. item.acclvs = ((item.reAccNum * 100) / item.accNum).toFixed(2);
  239. }
  240. if (item.pcs === 0) {
  241. item.readlvs = ((item.codeNum * 100) / 1).toFixed(2);
  242. } else {
  243. item.readlvs = ((item.codeNum * 100) / item.pcs).toFixed(2);
  244. }
  245. if (item.pcs === 0) {
  246. item.oklvs = (((item.accNum - item.reAccNum) * 100) / 1).toFixed(
  247. 2
  248. );
  249. } else {
  250. item.oklvs = (
  251. ((item.accNum - item.reAccNum) * 100) /
  252. item.pcs
  253. ).toFixed(2);
  254. }
  255. if (isNaN(item.piclvs)) {
  256. item.piclvs = "0%";
  257. } else {
  258. item.piclvs = item.piclvs + "%";
  259. }
  260. if (isNaN(item.acclvs)) {
  261. item.acclvs = "0%";
  262. } else {
  263. item.acclvs = item.acclvs + "%";
  264. }
  265. if (isNaN(item.readlvs)) {
  266. item.readlvs = "0%";
  267. } else {
  268. item.readlvs = item.readlvs + "%";
  269. }
  270. if (isNaN(item.oklvs)) {
  271. item.oklvs = "0%";
  272. } else {
  273. item.oklvs = item.oklvs + "%";
  274. }
  275. item.indexs = index + 1;
  276. });
  277. for (let i = 0; i < returnData.listValues.length; i++) {
  278. this.listall.reCodeNumall =
  279. this.listall.reCodeNumall + returnData.listValues[i].reCodeNum;
  280. this.listall.codeNumall =
  281. this.listall.codeNumall + returnData.listValues[i].codeNum;
  282. this.listall.reAccNumall =
  283. this.listall.reAccNumall + returnData.listValues[i].reAccNum;
  284. this.listall.accNumall =
  285. this.listall.accNumall + returnData.listValues[i].accNum;
  286. this.listall.pcsall =
  287. this.listall.pcsall + returnData.listValues[i].pcs;
  288. }
  289. if (this.listall.codeNumall === 0) {
  290. this.listall.piclvall =
  291. ((this.listall.reCodeNumall * 100) / 1).toFixed(2) + "%";
  292. } else {
  293. this.listall.piclvall =
  294. (
  295. (this.listall.reCodeNumall * 100) /
  296. this.listall.codeNumall
  297. ).toFixed(2) + "%";
  298. }
  299. if (this.listall.accNumall === 0) {
  300. this.listall.acclvall =
  301. ((this.listall.reAccNumall * 100) / 1).toFixed(2) + "%";
  302. } else {
  303. this.listall.acclvall =
  304. (
  305. (this.listall.reAccNumall * 100) /
  306. this.listall.accNumall
  307. ).toFixed(2) + "%";
  308. }
  309. if (this.listall.pcsall === 0) {
  310. this.listall.readlvall =
  311. ((this.listall.codeNumall * 100) / 1).toFixed(2) + "%";
  312. } else {
  313. this.listall.readlvall =
  314. ((this.listall.codeNumall * 100) / this.listall.pcsall).toFixed(
  315. 2
  316. ) + "%";
  317. }
  318. if (this.listall.pcsall === 0) {
  319. this.listall.oklvall =
  320. (
  321. ((this.listall.accNumall - this.listall.reAccNumall) * 100) /
  322. 1
  323. ).toFixed(2) + "%";
  324. } else {
  325. this.listall.oklvall =
  326. (
  327. ((this.listall.accNumall - this.listall.reAccNumall) * 100) /
  328. this.listall.pcsall
  329. ).toFixed(2) + "%";
  330. }
  331. this.tableListcop.forEach((item, index) => {
  332. item.indexs = index + 1;
  333. });
  334. returnData.listValues.forEach((element) => {
  335. this.tableData.data1 = [];
  336. });
  337. this.tableData.data1.push(0);
  338. for (let index = 0; index < this.tableData.data2.length; index++) {
  339. if (index > 0) {
  340. const element =
  341. (this.tableData.data2[index] -
  342. this.tableData.data2[index - 1]) /
  343. this.tableData.data2[index - 1];
  344. this.tableData.data1.push(
  345. element.toFixed(2) ? element.toFixed(2) : 0
  346. );
  347. this.tableData.data1.forEach((element) => {
  348. element = Number(element);
  349. if (typeof element !== "number") {
  350. element = 0;
  351. }
  352. });
  353. }
  354. }
  355. }
  356. } catch (error) {
  357. this.page--;
  358. }
  359. },
  360. //导出
  361. tableToExcel() {
  362. import("../../../utils/Export2Excel").then((excel) => {
  363. // 设置导出表格的头部
  364. const tHeader = this.listHeader;
  365. // 将要导出的数据进行一个过滤
  366. /**
  367. * 源数据导入到excel的数据每一条重新拼成一个数组,数组里的每个元素就是filterVal里的每个字段
  368. */
  369. const data = this.tableListcop.map((item, index) => {
  370. if (this.uppps === 1) {
  371. return [
  372. item.indexs,
  373. item.dat,
  374. item.ChannelId,
  375. item.codeNum,
  376. item.reCodeNum,
  377. item.accNum,
  378. item.reAccNum,
  379. item.pcs,
  380. item.piclv,
  381. item.acclv,
  382. item.readlv,
  383. item.oklv,
  384. ];
  385. } else if (this.uppps === 2) {
  386. return [
  387. item.indexs,
  388. item.dat,
  389. item.cargoCompany,
  390. item.ChannelId,
  391. item.codeNum,
  392. item.reCodeNum,
  393. item.accNum,
  394. item.reAccNum,
  395. item.pcs,
  396. item.piclv,
  397. item.acclv,
  398. item.readlv,
  399. item.oklv,
  400. ];
  401. }
  402. });
  403. data[data.length - 1].indexs = "总计";
  404. // 调用我们封装好的方法进行导出Excel
  405. excel.export_json_to_excel({
  406. // 导出的头部
  407. header: tHeader,
  408. // 导出的内容
  409. data,
  410. // 导出的文件名称
  411. filename: this.listname,
  412. // 导出的表格宽度是否自动
  413. autoWidth: true,
  414. // 导出文件的后缀类型
  415. bookType: "xlsx",
  416. });
  417. });
  418. },
  419. upset(data) {
  420. this.picShow = data;
  421. },
  422. },
  423. components: {
  424. Echarts,
  425. StatisticsHeader,
  426. Tableformbrs,
  427. },
  428. };
  429. </script>
  430. <style lang="scss" scoped>
  431. .airportInfo {
  432. position: relative;
  433. height: 100%;
  434. :deep(.el-pagination.is-background .el-pager li:not(.is-disabled).is-active) {
  435. background-color: #ac014d !important; //修改默认的背景色
  436. }
  437. .header {
  438. width: 103%;
  439. height: 36px;
  440. display: flex;
  441. align-items: center;
  442. justify-content: center;
  443. background: #f7f7f7;
  444. position: relative;
  445. left: -23px;
  446. > .nav {
  447. padding: 0 30px 0 30px;
  448. cursor: pointer;
  449. font-size: 16px;
  450. font-family: Microsoft YaHei;
  451. font-weight: 400;
  452. color: #101116;
  453. }
  454. > .navs {
  455. height: 100%;
  456. padding: 0 30px 0 30px;
  457. cursor: pointer;
  458. display: flex;
  459. align-items: center;
  460. font-size: 16px;
  461. font-family: Microsoft YaHei;
  462. font-weight: bold;
  463. color: #ac014d;
  464. border-bottom: 2px solid #ac014d;
  465. }
  466. }
  467. .variable {
  468. width: 100%;
  469. height: 52px;
  470. }
  471. .echart {
  472. width: 100%;
  473. height: 746px;
  474. position: absolute;
  475. // background: #ffffff;
  476. // box-shadow: 0px 3px 3px 0px rgba(0, 0, 0, 0.1);
  477. border-radius: 4px;
  478. }
  479. }
  480. </style>