index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  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.getQuery([]);
  129. },
  130. watch: {
  131. // 监听数据变化,重绘折线图
  132. option: {
  133. deep: true,
  134. handler(newVal) {},
  135. },
  136. },
  137. destroyed() {},
  138. methods: {
  139. handleSizeChange(val) {
  140. this.pagesize = val;
  141. },
  142. handleCurrentChange(val) {
  143. this.currentPage = val;
  144. },
  145. getFormData(data) {
  146. this.listall.piclvall = 0;
  147. this.listall.acclvall = 0;
  148. this.listall.readlvall = 0;
  149. this.listall.oklvall = 0;
  150. this.listall.reCodeNumall = 0;
  151. this.listall.codeNumall = 0;
  152. this.listall.reAccNumall = 0;
  153. this.listall.accNumall = 0;
  154. this.listall.pcsall = 0;
  155. this.tableData.time = [];
  156. this.tableData.data1 = [];
  157. this.tableData.data2 = [];
  158. this.listname = "龙门架统计" + data.dateTime[0] + "--" + data.dateTime[1];
  159. this.uppps = data.pps;
  160. if (data.pps === 1) {
  161. (this.listqueryTemplateID = DATACONTENT_ID.modeChannelbased),
  162. (this.listHeader = [
  163. "序号",
  164. "日期",
  165. "通道",
  166. "龙门架扫码数",
  167. "龙门架扫码重复条码数",
  168. "加货条码数量",
  169. "加货重复条码数量",
  170. "加货记录的该通道运单件数",
  171. "龙门架重码率",
  172. "加货重码率",
  173. "识读率",
  174. "加货准确率",
  175. ]);
  176. this.changing = 12;
  177. } else if (data.pps === 2) {
  178. (this.listqueryTemplateID = DATACONTENT_ID.modeAgentbased),
  179. (this.listHeader = [
  180. "序号",
  181. "日期",
  182. "代理人",
  183. "通道",
  184. "龙门架扫码数",
  185. "龙门架扫码重复条码数",
  186. "加货条码数量",
  187. "加货重复条码数量",
  188. "加货记录的该通道运单件数",
  189. "龙门架重码率",
  190. "加货重码率",
  191. "识读率",
  192. "加货准确率",
  193. ]);
  194. this.changing = 13;
  195. }
  196. let option = [
  197. {
  198. fd1: data.dateTime[0],
  199. fd2: data.dateTime[1],
  200. },
  201. ];
  202. this.getQuery(option, null);
  203. },
  204. //获取表格数据
  205. async getQuery(data, dat) {
  206. try {
  207. const { code, returnData } = await Query({
  208. id: this.listqueryTemplateID,
  209. dataContent: data,
  210. });
  211. if (code == 0) {
  212. this.tableData.time = [];
  213. this.tableData.data1 = [];
  214. this.tableData.data2 = [];
  215. this.tableList = JSON.parse(JSON.stringify(returnData.listValues));
  216. this.tableListcop = JSON.parse(JSON.stringify(returnData.listValues));
  217. this.total = this.tableList.length;
  218. for (let i = 0; i < 9; i++) {
  219. if (!this.tableList[i]) {
  220. this.tableList.push({});
  221. }
  222. }
  223. this.tableList.forEach((item, index) => {
  224. item.reCodeNum = item.reCodeNum ? item.reCodeNum : 0;
  225. item.codeNum = item.codeNum ? item.codeNum : 0;
  226. item.reAccNum = item.reAccNum ? item.reAccNum : 0;
  227. item.accNum = item.accNum ? item.accNum : 0;
  228. item.pcs = item.pcs ? item.pcs : 0;
  229. if (item.codeNum === 0) {
  230. item.piclvs = ((item.reCodeNum * 100) / 1).toFixed(2);
  231. } else {
  232. item.piclvs = ((item.reCodeNum * 100) / item.codeNum).toFixed(2);
  233. }
  234. if (item.accNum === 0) {
  235. item.acclvs = ((item.reAccNum * 100) / 1).toFixed(2);
  236. } else {
  237. item.acclvs = ((item.reAccNum * 100) / item.accNum).toFixed(2);
  238. }
  239. if (item.pcs === 0) {
  240. item.readlvs = ((item.codeNum * 100) / 1).toFixed(2);
  241. } else {
  242. item.readlvs = ((item.codeNum * 100) / item.pcs).toFixed(2);
  243. }
  244. if (item.pcs === 0) {
  245. item.oklvs = (((item.accNum - item.reAccNum) * 100) / 1).toFixed(
  246. 2
  247. );
  248. } else {
  249. item.oklvs = (
  250. ((item.accNum - item.reAccNum) * 100) /
  251. item.pcs
  252. ).toFixed(2);
  253. }
  254. if (isNaN(item.piclvs)) {
  255. item.piclvs = "0%";
  256. } else {
  257. item.piclvs = item.piclvs + "%";
  258. }
  259. if (isNaN(item.acclvs)) {
  260. item.acclvs = "0%";
  261. } else {
  262. item.acclvs = item.acclvs + "%";
  263. }
  264. if (isNaN(item.readlvs)) {
  265. item.readlvs = "0%";
  266. } else {
  267. item.readlvs = item.readlvs + "%";
  268. }
  269. if (isNaN(item.oklvs)) {
  270. item.oklvs = "0%";
  271. } else {
  272. item.oklvs = item.oklvs + "%";
  273. }
  274. item.indexs = index + 1;
  275. });
  276. for (let i = 0; i < returnData.listValues.length; i++) {
  277. this.listall.reCodeNumall =
  278. this.listall.reCodeNumall + returnData.listValues[i].reCodeNum;
  279. this.listall.codeNumall =
  280. this.listall.codeNumall + returnData.listValues[i].codeNum;
  281. this.listall.reAccNumall =
  282. this.listall.reAccNumall + returnData.listValues[i].reAccNum;
  283. this.listall.accNumall =
  284. this.listall.accNumall + returnData.listValues[i].accNum;
  285. this.listall.pcsall =
  286. this.listall.pcsall + returnData.listValues[i].pcs;
  287. }
  288. if (this.listall.codeNumall === 0) {
  289. this.listall.piclvall =
  290. ((this.listall.reCodeNumall * 100) / 1).toFixed(2) + "%";
  291. } else {
  292. this.listall.piclvall =
  293. (
  294. (this.listall.reCodeNumall * 100) /
  295. this.listall.codeNumall
  296. ).toFixed(2) + "%";
  297. }
  298. if (this.listall.accNumall === 0) {
  299. this.listall.acclvall =
  300. ((this.listall.reAccNumall * 100) / 1).toFixed(2) + "%";
  301. } else {
  302. this.listall.acclvall =
  303. (
  304. (this.listall.reAccNumall * 100) /
  305. this.listall.accNumall
  306. ).toFixed(2) + "%";
  307. }
  308. if (this.listall.pcsall === 0) {
  309. this.listall.readlvall =
  310. ((this.listall.codeNumall * 100) / 1).toFixed(2) + "%";
  311. } else {
  312. this.listall.readlvall =
  313. ((this.listall.codeNumall * 100) / this.listall.pcsall).toFixed(
  314. 2
  315. ) + "%";
  316. }
  317. if (this.listall.pcsall === 0) {
  318. this.listall.oklvall =
  319. (
  320. ((this.listall.accNumall - this.listall.reAccNumall) * 100) /
  321. 1
  322. ).toFixed(2) + "%";
  323. } else {
  324. this.listall.oklvall =
  325. (
  326. ((this.listall.accNumall - this.listall.reAccNumall) * 100) /
  327. this.listall.pcsall
  328. ).toFixed(2) + "%";
  329. }
  330. this.tableListcop.forEach((item, index) => {
  331. item.indexs = index + 1;
  332. });
  333. returnData.listValues.forEach((element) => {
  334. this.tableData.data1 = [];
  335. });
  336. this.tableData.data1.push(0);
  337. for (let index = 0; index < this.tableData.data2.length; index++) {
  338. if (index > 0) {
  339. const element =
  340. (this.tableData.data2[index] -
  341. this.tableData.data2[index - 1]) /
  342. this.tableData.data2[index - 1];
  343. this.tableData.data1.push(
  344. element.toFixed(2) ? element.toFixed(2) : 0
  345. );
  346. this.tableData.data1.forEach((element) => {
  347. element = Number(element);
  348. if (typeof element !== "number") {
  349. element = 0;
  350. }
  351. });
  352. }
  353. }
  354. }
  355. } catch (error) {
  356. this.page--;
  357. }
  358. },
  359. //导出
  360. tableToExcel() {
  361. import("../../../utils/Export2Excel").then((excel) => {
  362. // 设置导出表格的头部
  363. const tHeader = this.listHeader;
  364. // 将要导出的数据进行一个过滤
  365. /**
  366. * 源数据导入到excel的数据每一条重新拼成一个数组,数组里的每个元素就是filterVal里的每个字段
  367. */
  368. const data = this.tableListcop.map((item, index) => {
  369. if (this.uppps === 1) {
  370. return [
  371. item.indexs,
  372. item.dat,
  373. item.ChannelId,
  374. item.codeNum,
  375. item.reCodeNum,
  376. item.accNum,
  377. item.reAccNum,
  378. item.pcs,
  379. item.piclv,
  380. item.acclv,
  381. item.readlv,
  382. item.oklv,
  383. ];
  384. } else if (this.uppps === 2) {
  385. return [
  386. item.indexs,
  387. item.dat,
  388. item.cargoCompany,
  389. item.ChannelId,
  390. item.codeNum,
  391. item.reCodeNum,
  392. item.accNum,
  393. item.reAccNum,
  394. item.pcs,
  395. item.piclv,
  396. item.acclv,
  397. item.readlv,
  398. item.oklv,
  399. ];
  400. }
  401. });
  402. data[data.length - 1].indexs = "总计";
  403. // 调用我们封装好的方法进行导出Excel
  404. excel.export_json_to_excel({
  405. // 导出的头部
  406. header: tHeader,
  407. // 导出的内容
  408. data,
  409. // 导出的文件名称
  410. filename: this.listname,
  411. // 导出的表格宽度是否自动
  412. autoWidth: true,
  413. // 导出文件的后缀类型
  414. bookType: "xlsx",
  415. });
  416. });
  417. },
  418. upset(data) {
  419. this.picShow = data;
  420. },
  421. },
  422. components: {
  423. Echarts,
  424. StatisticsHeader,
  425. Tableformbrs,
  426. },
  427. };
  428. </script>
  429. <style lang="scss" scoped>
  430. .airportInfo {
  431. position: relative;
  432. height: 100%;
  433. :deep(.el-pagination.is-background .el-pager li:not(.is-disabled).is-active) {
  434. background-color: #ac014d !important; //修改默认的背景色
  435. }
  436. .header {
  437. width: 103%;
  438. height: 36px;
  439. display: flex;
  440. align-items: center;
  441. justify-content: center;
  442. background: #f7f7f7;
  443. position: relative;
  444. left: -23px;
  445. > .nav {
  446. padding: 0 30px 0 30px;
  447. cursor: pointer;
  448. font-size: 16px;
  449. font-family: Microsoft YaHei;
  450. font-weight: 400;
  451. color: #101116;
  452. }
  453. > .navs {
  454. height: 100%;
  455. padding: 0 30px 0 30px;
  456. cursor: pointer;
  457. display: flex;
  458. align-items: center;
  459. font-size: 16px;
  460. font-family: Microsoft YaHei;
  461. font-weight: bold;
  462. color: #ac014d;
  463. border-bottom: 2px solid #ac014d;
  464. }
  465. }
  466. .variable {
  467. width: 100%;
  468. height: 52px;
  469. }
  470. .echart {
  471. width: 100%;
  472. height: 746px;
  473. position: absolute;
  474. // background: #ffffff;
  475. // box-shadow: 0px 3px 3px 0px rgba(0, 0, 0, 0.1);
  476. border-radius: 4px;
  477. }
  478. }
  479. </style>