index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  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 class="echart">
  21. <Tableformbrs :tableList="tableList" action="7" :set="set" />
  22. </div>
  23. </div>
  24. </template>
  25. <script>
  26. import Echarts from "../components/echart/index.vue";
  27. import Tableformbrs from "../components/echart/tableforms.vue";
  28. import StatisticsHeader from "../components/echart/statisticsHeader.vue";
  29. import { export_json_to_excel } from "@/utils/Export2Excel";
  30. import { Query } from "@/api/webApi";
  31. export default {
  32. name: "ChartsBar",
  33. data() {
  34. return {
  35. asShow: false,
  36. optiondata: [],
  37. picShow: true, //图片表格切换
  38. action: 6,
  39. dataid: "collection_ecahrt0",
  40. listqueryTemplateID: DATACONTENT_ID.modeDomesticentryTable,
  41. eledata: null,
  42. set: "",
  43. isShow: Echarts,
  44. tableList: [],
  45. tableListcop: [],
  46. listname: "",
  47. listHeader: [],
  48. tableData: {
  49. time: [],
  50. data1: [],
  51. data2: [],
  52. kg: "",
  53. tyol: "",
  54. },
  55. formData: {
  56. airport: "",
  57. dateTime: "",
  58. },
  59. titleTop: "航班统计国内进港",
  60. formItems: [
  61. {
  62. prop: "dateTime",
  63. inputType: "datetimerange",
  64. clearable: true,
  65. width: "240px",
  66. options: [],
  67. },
  68. ],
  69. };
  70. },
  71. mounted() {
  72. // this.getQuery([]);
  73. },
  74. watch: {
  75. // 监听数据变化,重绘折线图
  76. option: {
  77. deep: true,
  78. handler(newVal) {},
  79. },
  80. },
  81. destroyed() {},
  82. methods: {
  83. getFormData(data) {
  84. this.tableData.time = [];
  85. this.tableData.data1 = [];
  86. this.tableData.data2 = [];
  87. let option = [
  88. {
  89. fd1: data.dateTime[0],
  90. fd2: data.dateTime[1],
  91. },
  92. ];
  93. this.getQuery(option, null);
  94. this.listname =
  95. "航班统计国内进港" + data.dateTime[0] + "--" + data.dateTime[1];
  96. this.listHeader = [
  97. "序号",
  98. "执飞日期",
  99. "计划航班数",
  100. "已完成航班数",
  101. "特货航班数",
  102. "卸机航班数",
  103. "库区到达航班数",
  104. "货站交接航班数",
  105. "理货航班数",
  106. "出库航班数",
  107. ];
  108. },
  109. //获取表格数据
  110. async getQuery(data, dat) {
  111. try {
  112. const { code, returnData } = await Query({
  113. id: this.listqueryTemplateID,
  114. dataContent: data,
  115. });
  116. if (code == 0) {
  117. this.tableData.time = [];
  118. this.tableData.data1 = [];
  119. this.tableData.data2 = [];
  120. this.tableList = JSON.parse(JSON.stringify(returnData.listValues));
  121. this.tableListcop = JSON.parse(JSON.stringify(returnData.listValues));
  122. this.tableList.forEach((item, index) => {
  123. item.indexs = index + 1;
  124. });
  125. this.tableListcop.forEach((item, index) => {
  126. item.indexs = index + 1;
  127. });
  128. // let objar = {
  129. // indexs: "合计",
  130. // flightDate: returnData.listValues[0].totalPullFlightNum,
  131. // pullWeight: returnData.listValues[0].totalPullWeight,
  132. // };
  133. this.tableListcop.push(objar);
  134. returnData.listValues.forEach((element) => {
  135. this.tableData.data1 = [];
  136. });
  137. this.tableData.data1.push(0);
  138. for (let index = 0; index < this.tableData.data2.length; index++) {
  139. if (index > 0) {
  140. const element =
  141. (this.tableData.data2[index] -
  142. this.tableData.data2[index - 1]) /
  143. this.tableData.data2[index - 1];
  144. this.tableData.data1.push(
  145. element.toFixed(2) ? element.toFixed(2) : 0
  146. );
  147. this.tableData.data1.forEach((element) => {
  148. element = Number(element);
  149. if (typeof element !== "number") {
  150. element = "";
  151. }
  152. });
  153. }
  154. }
  155. }
  156. } catch (error) {
  157. this.page--;
  158. }
  159. },
  160. //导出
  161. tableToExcel() {
  162. import("../../../utils/Export2Excel").then((excel) => {
  163. // 设置导出表格的头部
  164. const tHeader = this.listHeader;
  165. // 将要导出的数据进行一个过滤
  166. /**
  167. * 源数据导入到excel的数据每一条重新拼成一个数组,数组里的每个元素就是filterVal里的每个字段
  168. */
  169. const data = this.tableListcop.map((item, index) => {
  170. return [
  171. item.indexs,
  172. item.flightDate,
  173. item.planFlightNum,
  174. item.finishFlightNum,
  175. item.speNum,
  176. item.unLoadNum,
  177. item.arriveNum,
  178. item.depotJoinNum,
  179. item.tallyNum,
  180. item.outWarehouseNum,
  181. ];
  182. });
  183. data[data.length - 1].indexs = "总计";
  184. // 调用我们封装好的方法进行导出Excel
  185. excel.export_json_to_excel({
  186. // 导出的头部
  187. header: tHeader,
  188. // 导出的内容
  189. data,
  190. // 导出的文件名称
  191. filename: this.listname,
  192. // 导出的表格宽度是否自动
  193. autoWidth: true,
  194. // 导出文件的后缀类型
  195. bookType: "xlsx",
  196. });
  197. });
  198. },
  199. upset(data) {
  200. this.picShow = data;
  201. },
  202. },
  203. components: {
  204. Echarts,
  205. StatisticsHeader,
  206. Tableformbrs,
  207. },
  208. };
  209. </script>
  210. <style lang="scss" scoped>
  211. .airportInfo {
  212. position: relative;
  213. .header {
  214. width: 103%;
  215. height: 36px;
  216. display: flex;
  217. align-items: center;
  218. justify-content: center;
  219. background: #f7f7f7;
  220. position: relative;
  221. left: -23px;
  222. > .nav {
  223. padding: 0 30px 0 30px;
  224. cursor: pointer;
  225. font-size: 16px;
  226. font-family: Microsoft YaHei;
  227. font-weight: 400;
  228. color: #101116;
  229. }
  230. > .navs {
  231. height: 100%;
  232. padding: 0 30px 0 30px;
  233. cursor: pointer;
  234. display: flex;
  235. align-items: center;
  236. font-size: 16px;
  237. font-family: Microsoft YaHei;
  238. font-weight: bold;
  239. color: #ac014d;
  240. border-bottom: 2px solid #ac014d;
  241. }
  242. }
  243. .variable {
  244. width: 100%;
  245. height: 52px;
  246. }
  247. .echart {
  248. width: 100%;
  249. height: 746px;
  250. position: absolute;
  251. background: #ffffff;
  252. box-shadow: 0px 3px 3px 0px rgba(0, 0, 0, 0.1);
  253. border-radius: 4px;
  254. }
  255. }
  256. </style>