index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  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.pcs - item.reAccNum) * 100) / 1).toFixed(2);
  247. } else {
  248. item.oklvs = (
  249. ((item.pcs - item.reAccNum) * 100) /
  250. item.pcs
  251. ).toFixed(2);
  252. }
  253. if (isNaN(item.piclvs)) {
  254. item.piclvs = "0%";
  255. } else {
  256. item.piclvs = item.piclvs + "%";
  257. }
  258. if (isNaN(item.acclvs)) {
  259. item.acclvs = "0%";
  260. } else {
  261. item.acclvs = item.acclvs + "%";
  262. }
  263. if (isNaN(item.readlvs)) {
  264. item.readlvs = "0%";
  265. } else {
  266. item.readlvs = item.readlvs + "%";
  267. }
  268. if (isNaN(item.oklvs)) {
  269. item.oklvs = "0%";
  270. } else {
  271. item.oklvs = item.oklvs + "%";
  272. }
  273. item.indexs = index + 1;
  274. });
  275. for (let i = 0; i < returnData.listValues.length; i++) {
  276. this.listall.reCodeNumall =
  277. this.listall.reCodeNumall + returnData.listValues[i].reCodeNum;
  278. this.listall.codeNumall =
  279. this.listall.codeNumall + returnData.listValues[i].codeNum;
  280. this.listall.reAccNumall =
  281. this.listall.reAccNumall + returnData.listValues[i].reAccNum;
  282. this.listall.accNumall =
  283. this.listall.accNumall + returnData.listValues[i].accNum;
  284. this.listall.pcsall =
  285. this.listall.pcsall + returnData.listValues[i].pcs;
  286. }
  287. if (this.listall.codeNumall === 0) {
  288. this.listall.piclvall =
  289. ((this.listall.reCodeNumall * 100) / 1).toFixed(2) + "%";
  290. } else {
  291. this.listall.piclvall =
  292. (
  293. (this.listall.reCodeNumall * 100) /
  294. this.listall.codeNumall
  295. ).toFixed(2) + "%";
  296. }
  297. if (this.listall.accNumall === 0) {
  298. this.listall.acclvall =
  299. ((this.listall.reAccNumall * 100) / 1).toFixed(2) + "%";
  300. } else {
  301. this.listall.acclvall =
  302. (
  303. (this.listall.reAccNumall * 100) /
  304. this.listall.accNumall
  305. ).toFixed(2) + "%";
  306. }
  307. if (this.listall.pcsall === 0) {
  308. this.listall.readlvall =
  309. ((this.listall.codeNumall * 100) / 1).toFixed(2) + "%";
  310. } else {
  311. this.listall.readlvall =
  312. ((this.listall.codeNumall * 100) / this.listall.pcsall).toFixed(
  313. 2
  314. ) + "%";
  315. }
  316. if (this.listall.pcsall === 0) {
  317. this.listall.oklvall =
  318. (
  319. ((this.listall.pcsall - this.listall.reAccNumall) * 100) /
  320. 1
  321. ).toFixed(2) + "%";
  322. } else {
  323. this.listall.oklvall =
  324. (
  325. ((this.listall.pcsall - this.listall.reAccNumall) * 100) /
  326. this.listall.pcsall
  327. ).toFixed(2) + "%";
  328. }
  329. this.tableListcop.forEach((item, index) => {
  330. item.indexs = index + 1;
  331. });
  332. returnData.listValues.forEach((element) => {
  333. this.tableData.data1 = [];
  334. });
  335. this.tableData.data1.push(0);
  336. for (let index = 0; index < this.tableData.data2.length; index++) {
  337. if (index > 0) {
  338. const element =
  339. (this.tableData.data2[index] -
  340. this.tableData.data2[index - 1]) /
  341. this.tableData.data2[index - 1];
  342. this.tableData.data1.push(
  343. element.toFixed(2) ? element.toFixed(2) : 0
  344. );
  345. this.tableData.data1.forEach((element) => {
  346. element = Number(element);
  347. if (typeof element !== "number") {
  348. element = 0;
  349. }
  350. });
  351. }
  352. }
  353. }
  354. } catch (error) {
  355. this.page--;
  356. }
  357. },
  358. //导出
  359. tableToExcel() {
  360. import("../../../utils/Export2Excel").then((excel) => {
  361. // 设置导出表格的头部
  362. const tHeader = this.listHeader;
  363. // 将要导出的数据进行一个过滤
  364. /**
  365. * 源数据导入到excel的数据每一条重新拼成一个数组,数组里的每个元素就是filterVal里的每个字段
  366. */
  367. const data = this.tableListcop.map((item, index) => {
  368. if (this.uppps === 1) {
  369. return [
  370. item.indexs,
  371. item.dat,
  372. item.ChannelId,
  373. item.codeNum,
  374. item.reCodeNum,
  375. item.accNum,
  376. item.reAccNum,
  377. item.pcs,
  378. item.piclv,
  379. item.acclv,
  380. item.readlv,
  381. item.oklv,
  382. ];
  383. } else if (this.uppps === 2) {
  384. return [
  385. item.indexs,
  386. item.dat,
  387. item.cargoCompany,
  388. item.ChannelId,
  389. item.codeNum,
  390. item.reCodeNum,
  391. item.accNum,
  392. item.reAccNum,
  393. item.pcs,
  394. item.piclv,
  395. item.acclv,
  396. item.readlv,
  397. item.oklv,
  398. ];
  399. }
  400. });
  401. // 调用我们封装好的方法进行导出Excel
  402. excel.export_json_to_excel({
  403. // 导出的头部
  404. header: tHeader,
  405. // 导出的内容
  406. data,
  407. // 导出的文件名称
  408. filename: this.listname,
  409. // 导出的表格宽度是否自动
  410. autoWidth: true,
  411. // 导出文件的后缀类型
  412. bookType: "xlsx",
  413. });
  414. });
  415. },
  416. upset(data) {
  417. this.picShow = data;
  418. },
  419. },
  420. components: {
  421. Echarts,
  422. StatisticsHeader,
  423. Tableformbrs,
  424. },
  425. };
  426. </script>
  427. <style lang="scss" scoped>
  428. .airportInfo {
  429. position: relative;
  430. height: 100%;
  431. :deep(.el-pagination.is-background .el-pager li:not(.is-disabled).is-active) {
  432. background-color: #ac014d !important; //修改默认的背景色
  433. }
  434. .header {
  435. width: 103%;
  436. height: 36px;
  437. display: flex;
  438. align-items: center;
  439. justify-content: center;
  440. background: #f7f7f7;
  441. position: relative;
  442. left: -23px;
  443. > .nav {
  444. padding: 0 30px 0 30px;
  445. cursor: pointer;
  446. font-size: 16px;
  447. font-family: Microsoft YaHei;
  448. font-weight: 400;
  449. color: #101116;
  450. }
  451. > .navs {
  452. height: 100%;
  453. padding: 0 30px 0 30px;
  454. cursor: pointer;
  455. display: flex;
  456. align-items: center;
  457. font-size: 16px;
  458. font-family: Microsoft YaHei;
  459. font-weight: bold;
  460. color: #ac014d;
  461. border-bottom: 2px solid #ac014d;
  462. }
  463. }
  464. .variable {
  465. width: 100%;
  466. height: 52px;
  467. }
  468. .echart {
  469. width: 100%;
  470. height: 746px;
  471. position: absolute;
  472. // background: #ffffff;
  473. // box-shadow: 0px 3px 3px 0px rgba(0, 0, 0, 0.1);
  474. border-radius: 4px;
  475. }
  476. }
  477. </style>