index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  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.getQuery([]);
  128. },
  129. watch: {
  130. // 监听数据变化,重绘折线图
  131. option: {
  132. deep: true,
  133. handler(newVal) {},
  134. },
  135. },
  136. destroyed() {},
  137. methods: {
  138. handleSizeChange(val) {
  139. this.pagesize = val;
  140. },
  141. handleCurrentChange(val) {
  142. this.currentPage = val;
  143. },
  144. getFormData(data) {
  145. this.tableData.time = [];
  146. this.tableData.data1 = [];
  147. this.tableData.data2 = [];
  148. this.tableList = [];
  149. if (data.fttp === 0) {
  150. this.action = 6;
  151. } else if (data.fttp === 1) {
  152. this.action = 7;
  153. } else if (data.fttp === 2) {
  154. this.action = 8;
  155. } else if (data.fttp === 3) {
  156. this.action = 9;
  157. }
  158. let option = [
  159. {
  160. fd1: data.dateTime[0] + " 00:00:00",
  161. fd2: data.dateTime[1] + " 23:59:59",
  162. },
  163. ];
  164. this.getQuery(option, data.fttp);
  165. this.listname =
  166. "航班统计国内出港" + data.dateTime[0] + "--" + data.dateTime[1];
  167. this.listHeader = [
  168. "序号",
  169. "执飞日期",
  170. "计划航班数",
  171. "已完成航班数",
  172. "一个码航班数",
  173. "特货航班数",
  174. "收运核单航班数",
  175. "安检放行航班数",
  176. "加货航班数",
  177. "预配载航班数",
  178. "交接复核航班数",
  179. "机下交接航班数",
  180. "拉下航班数",
  181. "拉回确认航班数",
  182. ];
  183. },
  184. //获取表格数据
  185. async getQuery(data, dat) {
  186. try {
  187. const { code, returnData } = await Query({
  188. id: this.listqueryTemplateID[dat],
  189. dataContent: data,
  190. });
  191. if (code == 0) {
  192. this.tableData.time = [];
  193. this.tableData.data1 = [];
  194. this.tableData.data2 = [];
  195. this.tableList = JSON.parse(JSON.stringify(returnData.listValues));
  196. this.tableListcop = JSON.parse(JSON.stringify(returnData.listValues));
  197. this.total = this.tableList.length;
  198. this.tableList.forEach((item, index) => {
  199. item.indexs = index + 1;
  200. });
  201. // for (let i = 0; i < 9; i++) {
  202. // if (!this.tableList[i]) {
  203. // this.tableList.push({});
  204. // }
  205. // }
  206. this.tableListcop.forEach((item, index) => {
  207. item.indexs = index + 1;
  208. });
  209. // let objar = {
  210. // indexs: "合计",
  211. // flightDate: returnData.listValues[0].totalPullFlightNum,
  212. // pullWeight: returnData.listValues[0].totalPullWeight,
  213. // };
  214. this.tableListcop.push(objar);
  215. returnData.listValues.forEach((element) => {
  216. this.tableData.data1 = [];
  217. });
  218. this.tableData.data1.push(0);
  219. for (let index = 0; index < this.tableData.data2.length; index++) {
  220. if (index > 0) {
  221. const element =
  222. (this.tableData.data2[index] -
  223. this.tableData.data2[index - 1]) /
  224. this.tableData.data2[index - 1];
  225. this.tableData.data1.push(
  226. element.toFixed(2) ? element.toFixed(2) : 0
  227. );
  228. this.tableData.data1.forEach((element) => {
  229. element = Number(element);
  230. if (typeof element !== "number") {
  231. element = "";
  232. }
  233. });
  234. }
  235. }
  236. }
  237. } catch (error) {
  238. this.page--;
  239. }
  240. },
  241. //导出
  242. tableToExcel() {
  243. import("../../../utils/Export2Excel").then((excel) => {
  244. // 设置导出表格的头部
  245. const tHeader = this.listHeader;
  246. // 将要导出的数据进行一个过滤
  247. /**
  248. * 源数据导入到excel的数据每一条重新拼成一个数组,数组里的每个元素就是filterVal里的每个字段
  249. */
  250. const data = this.tableListcop.map((item, index) => {
  251. return [
  252. item.indexs,
  253. item.flightDate,
  254. item.planFlightNum,
  255. item.finishFlightNum,
  256. item.ygmNum,
  257. item.speNum,
  258. item.receiveSureNum,
  259. item.securityNum,
  260. item.addCargoNum,
  261. item.stowageNum,
  262. item.depotJoinNum,
  263. item.planeDownNum,
  264. item.pullNum,
  265. item.pullSureNum,
  266. ];
  267. });
  268. data[data.length - 1].indexs = "总计";
  269. // 调用我们封装好的方法进行导出Excel
  270. excel.export_json_to_excel({
  271. // 导出的头部
  272. header: tHeader,
  273. // 导出的内容
  274. data,
  275. // 导出的文件名称
  276. filename: this.listname,
  277. // 导出的表格宽度是否自动
  278. autoWidth: true,
  279. // 导出文件的后缀类型
  280. bookType: "xlsx",
  281. });
  282. });
  283. },
  284. upset(data) {
  285. this.picShow = data;
  286. },
  287. },
  288. components: {
  289. Echarts,
  290. StatisticsHeader,
  291. Tableformbrs,
  292. },
  293. };
  294. </script>
  295. <style lang="scss" scoped>
  296. .airportInfo {
  297. position: relative;
  298. height: 100%;
  299. :deep(.el-pagination.is-background .el-pager li:not(.is-disabled).is-active) {
  300. background-color: #ac014d !important; //修改默认的背景色
  301. }
  302. .header {
  303. width: 103%;
  304. height: 36px;
  305. display: flex;
  306. align-items: center;
  307. justify-content: center;
  308. background: #f7f7f7;
  309. position: relative;
  310. left: -23px;
  311. > .nav {
  312. padding: 0 30px 0 30px;
  313. cursor: pointer;
  314. font-size: 16px;
  315. font-family: Microsoft YaHei;
  316. font-weight: 400;
  317. color: #101116;
  318. }
  319. > .navs {
  320. height: 100%;
  321. padding: 0 30px 0 30px;
  322. cursor: pointer;
  323. display: flex;
  324. align-items: center;
  325. font-size: 16px;
  326. font-family: Microsoft YaHei;
  327. font-weight: bold;
  328. color: #ac014d;
  329. border-bottom: 2px solid #ac014d;
  330. }
  331. }
  332. .variable {
  333. width: 100%;
  334. height: 52px;
  335. }
  336. .echart {
  337. width: 100%;
  338. height: 746px;
  339. position: absolute;
  340. // background: #ffffff;
  341. // box-shadow: 0px 3px 3px 0px rgba(0, 0, 0, 0.1);
  342. border-radius: 4px;
  343. }
  344. }
  345. </style>