index.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  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="action"
  31. :set="set"
  32. />
  33. </div>
  34. <el-pagination
  35. background
  36. v-if="tableList.length > 0"
  37. @size-change="handleSizeChange"
  38. @current-change="handleCurrentChange"
  39. layout="total, prev, pager, next, jumper"
  40. :total="total"
  41. :page-size="pagesize"
  42. style="position: absolute; right: 0; bottom: 0"
  43. >
  44. </el-pagination>
  45. </div>
  46. </template>
  47. <script>
  48. import Echarts from "../components/echart/index.vue";
  49. import Tableformbrs from "../components/echart/tableforms.vue";
  50. import StatisticsHeader from "../components/echart/statisticsHeader.vue";
  51. import { export_json_to_excel } from "@/utils/Export2Excel";
  52. import { Query } from "@/api/webApi";
  53. export default {
  54. name: "ChartsBar",
  55. data() {
  56. return {
  57. currentPage: 1,
  58. pagesize: 10,
  59. total: 0,
  60. asShow: false,
  61. optiondata: [],
  62. picShow: true, //图片表格切换
  63. action: null,
  64. dataid: "collection_ecahrt0",
  65. listqueryTemplateID: [
  66. DATACONTENT_ID.modeDomesticexportTable,
  67. DATACONTENT_ID.modeDomesticentryTable,
  68. DATACONTENT_ID.modeInternationalexportTable,
  69. DATACONTENT_ID.modeInternationaladvanceTable,
  70. ],
  71. eledata: null,
  72. set: "",
  73. isShow: Echarts,
  74. tableList: [],
  75. tableListcop: [],
  76. listname: "",
  77. listHeader: [],
  78. tableData: {
  79. time: [],
  80. data1: [],
  81. data2: [],
  82. kg: "",
  83. tyol: "",
  84. },
  85. formData: {
  86. airport: "",
  87. dateTime: "",
  88. },
  89. titleTop: "航班统计",
  90. formItems: [
  91. {
  92. prop: "fttp",
  93. inputType: "select",
  94. placeholder: "国内国际",
  95. requiredWarning: "",
  96. clearable: true,
  97. options: [
  98. {
  99. value: 0,
  100. label: "国内出港",
  101. },
  102. {
  103. value: 1,
  104. label: "国内进港",
  105. },
  106. {
  107. value: 2,
  108. label: "国际出港",
  109. },
  110. {
  111. value: 3,
  112. label: "国际进港",
  113. },
  114. ],
  115. },
  116. {
  117. prop: "dateTime",
  118. inputType: "datePicker",
  119. clearable: true,
  120. width: "240px",
  121. options: [],
  122. },
  123. ],
  124. };
  125. },
  126. mounted() {
  127. this.pagesize = window.screen.height > 1080 ? 20 : 10;
  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.tableData.time = [];
  147. this.tableData.data1 = [];
  148. this.tableData.data2 = [];
  149. this.tableList = [];
  150. if (data.fttp === 0) {
  151. this.action = 6;
  152. } else if (data.fttp === 1) {
  153. this.action = 7;
  154. } else if (data.fttp === 2) {
  155. this.action = 8;
  156. } else if (data.fttp === 3) {
  157. this.action = 9;
  158. }
  159. let option = [
  160. {
  161. fd1: data.dateTime[0] + " 00:00:00",
  162. fd2: data.dateTime[1] + " 23:59:59",
  163. },
  164. ];
  165. this.getQuery(option, data.fttp);
  166. this.listname =
  167. "航班统计国内出港" + data.dateTime[0] + "--" + data.dateTime[1];
  168. this.listHeader = [
  169. "序号",
  170. "执飞日期",
  171. "计划航班数",
  172. "已完成航班数",
  173. "一个码航班数",
  174. "特货航班数",
  175. "收运核单航班数",
  176. "安检放行航班数",
  177. "加货航班数",
  178. "预配载航班数",
  179. "交接复核航班数",
  180. "机下交接航班数",
  181. "拉下航班数",
  182. "拉回确认航班数",
  183. ];
  184. },
  185. //获取表格数据
  186. async getQuery(data, dat) {
  187. try {
  188. const { code, returnData } = await Query({
  189. id: this.listqueryTemplateID[dat],
  190. dataContent: data,
  191. });
  192. if (code == 0) {
  193. this.tableData.time = [];
  194. this.tableData.data1 = [];
  195. this.tableData.data2 = [];
  196. this.tableList = JSON.parse(JSON.stringify(returnData.listValues));
  197. this.tableListcop = JSON.parse(JSON.stringify(returnData.listValues));
  198. this.total = this.tableList.length;
  199. this.tableList.forEach((item, index) => {
  200. item.indexs = index + 1;
  201. });
  202. // for (let i = 0; i < 9; i++) {
  203. // if (!this.tableList[i]) {
  204. // this.tableList.push({});
  205. // }
  206. // }
  207. this.tableListcop.forEach((item, index) => {
  208. item.indexs = index + 1;
  209. });
  210. // let objar = {
  211. // indexs: "合计",
  212. // flightDate: returnData.listValues[0].totalPullFlightNum,
  213. // pullWeight: returnData.listValues[0].totalPullWeight,
  214. // };
  215. this.tableListcop.push(objar);
  216. returnData.listValues.forEach((element) => {
  217. this.tableData.data1 = [];
  218. });
  219. this.tableData.data1.push(0);
  220. for (let index = 0; index < this.tableData.data2.length; index++) {
  221. if (index > 0) {
  222. const element =
  223. (this.tableData.data2[index] -
  224. this.tableData.data2[index - 1]) /
  225. this.tableData.data2[index - 1];
  226. this.tableData.data1.push(
  227. element.toFixed(2) ? element.toFixed(2) : 0
  228. );
  229. this.tableData.data1.forEach((element) => {
  230. element = Number(element);
  231. if (typeof element !== "number") {
  232. element = "";
  233. }
  234. });
  235. }
  236. }
  237. }
  238. } catch (error) {
  239. this.page--;
  240. }
  241. },
  242. //导出
  243. tableToExcel() {
  244. import("../../../utils/Export2Excel").then((excel) => {
  245. // 设置导出表格的头部
  246. const tHeader = this.listHeader;
  247. // 将要导出的数据进行一个过滤
  248. /**
  249. * 源数据导入到excel的数据每一条重新拼成一个数组,数组里的每个元素就是filterVal里的每个字段
  250. */
  251. const data = this.tableListcop.map((item, index) => {
  252. return [
  253. item.indexs,
  254. item.flightDate,
  255. item.planFlightNum,
  256. item.finishFlightNum,
  257. item.ygmNum,
  258. item.speNum,
  259. item.receiveSureNum,
  260. item.securityNum,
  261. item.addCargoNum,
  262. item.stowageNum,
  263. item.depotJoinNum,
  264. item.planeDownNum,
  265. item.pullNum,
  266. item.pullSureNum,
  267. ];
  268. });
  269. data[data.length - 1].indexs = "总计";
  270. // 调用我们封装好的方法进行导出Excel
  271. excel.export_json_to_excel({
  272. // 导出的头部
  273. header: tHeader,
  274. // 导出的内容
  275. data,
  276. // 导出的文件名称
  277. filename: this.listname,
  278. // 导出的表格宽度是否自动
  279. autoWidth: true,
  280. // 导出文件的后缀类型
  281. bookType: "xlsx",
  282. });
  283. });
  284. },
  285. upset(data) {
  286. this.picShow = data;
  287. },
  288. },
  289. components: {
  290. Echarts,
  291. StatisticsHeader,
  292. Tableformbrs,
  293. },
  294. };
  295. </script>
  296. <style lang="scss" scoped>
  297. .airportInfo {
  298. position: relative;
  299. height: 100%;
  300. :deep(.el-pagination.is-background .el-pager li:not(.is-disabled).is-active) {
  301. background-color: #ac014d !important; //修改默认的背景色
  302. }
  303. .header {
  304. width: 103%;
  305. height: 36px;
  306. display: flex;
  307. align-items: center;
  308. justify-content: center;
  309. background: #f7f7f7;
  310. position: relative;
  311. left: -23px;
  312. > .nav {
  313. padding: 0 30px 0 30px;
  314. cursor: pointer;
  315. font-size: 16px;
  316. font-family: Microsoft YaHei;
  317. font-weight: 400;
  318. color: #101116;
  319. }
  320. > .navs {
  321. height: 100%;
  322. padding: 0 30px 0 30px;
  323. cursor: pointer;
  324. display: flex;
  325. align-items: center;
  326. font-size: 16px;
  327. font-family: Microsoft YaHei;
  328. font-weight: bold;
  329. color: #ac014d;
  330. border-bottom: 2px solid #ac014d;
  331. }
  332. }
  333. .variable {
  334. width: 100%;
  335. height: 52px;
  336. }
  337. .echart {
  338. width: 100%;
  339. height: 746px;
  340. position: absolute;
  341. // background: #ffffff;
  342. // box-shadow: 0px 3px 3px 0px rgba(0, 0, 0, 0.1);
  343. border-radius: 4px;
  344. }
  345. }
  346. </style>