echarts.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  1. <template>
  2. <div class="view-carrierFlightMission">
  3. <div class="view-carrierFlightMission-FlightMission-btn">
  4. <div class="view-carrierFlightMission-FlightMission-btn-right">
  5. <div class="input-with-select">
  6. <span>日期</span>
  7. <el-date-picker type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd" format="yyyy-MM-dd" v-model="statisticsDate"> </el-date-picker>
  8. </div>
  9. <div class="input-with-select">
  10. <span>地区</span>
  11. <el-select v-model="select.groups" placeholder="请选择" filterable clearable>
  12. <el-option v-for="item in groupsList" :key="item.groups" :label="item.groups" :value="item.groups"> </el-option>
  13. </el-select>
  14. </div>
  15. <div class="input-with-select">
  16. <span>专业</span>
  17. <el-select v-model="select.major" placeholder="请选择" filterable clearable>
  18. <el-option v-for="item in majorList" :key="item.major" :label="item.major" :value="item.major"> </el-option>
  19. </el-select>
  20. </div>
  21. <div class="input-with-select">
  22. <span>机型</span>
  23. <el-select v-model="select.aircraftModel" placeholder="请选择" @change="getFaultStatisticsListAllAPI({ distinctField: 'aircraft_num' })" filterable clearable>
  24. <el-option v-for="item in aircraftModelList" :key="item.aircraftModel" :label="item.aircraftModel" :value="item.aircraftModel"> </el-option>
  25. </el-select>
  26. </div>
  27. <div class="input-with-select">
  28. <span>机号</span>
  29. <el-select v-model="select.aircraftNum" placeholder="请选择" filterable clearable>
  30. <el-option v-for="item in aircraftNumList" :key="item.aircraftNum" :label="item.aircraftNum" :value="item.aircraftNum"> </el-option>
  31. </el-select>
  32. </div>
  33. <div class="input-with-select">
  34. <span>部件</span>
  35. <el-select v-model="select.faultyPartsName" placeholder="请选择" filterable clearable>
  36. <el-option v-for="item in faultyPartsNameList" :key="item.faultyPartsName" :label="item.faultyPartsName" :value="item.faultyPartsName"> </el-option>
  37. </el-select>
  38. </div>
  39. <el-button @click="searchClick" style="border-color: rgb(13, 128, 164); background-color: rgb(13, 128, 164); color: #fff">查询</el-button>
  40. </div>
  41. </div>
  42. <div class="view-dataType-table">
  43. <el-row>
  44. <el-col :span="12">
  45. <CardEcharts title="故障件数量统计图">
  46. <template slot="content">
  47. <div class="baseBar-box-1" ref="echartLeft"></div>
  48. </template>
  49. </CardEcharts>
  50. </el-col>
  51. <el-col :span="12">
  52. <CardEcharts title="故障件数量统计图">
  53. <template slot="content">
  54. <div class="baseBar-box-1" ref="echartRight"></div>
  55. </template>
  56. </CardEcharts>
  57. </el-col>
  58. </el-row>
  59. </div>
  60. </div>
  61. </template>
  62. <script>
  63. import { getFaultStatisticsListAll, getAircaftTypeAndModelTree, removeFaultStatistics, getFaultStatisticsEcharts } from '@/api/als/faultStatistics'
  64. import { debounce } from '@/utils/index'
  65. import * as echarts from 'echarts'
  66. import CardEcharts from '@/components/CardEcharts/index.vue'
  67. export default {
  68. name: 'FaultStatistics',
  69. components: { CardEcharts },
  70. name: 'FaultStatisticsEcharts',
  71. data() {
  72. // 这里存放数据
  73. return {
  74. keyWord: '',
  75. aircaftModelIdList: [],
  76. currentNodeKey: null,
  77. currentNode: null,
  78. menuTreeData: [],
  79. treeObj: {
  80. title: '所属机种',
  81. activityheight: '275px',
  82. searchIcon: false,
  83. configure: {
  84. children: 'children',
  85. label: 'label'
  86. }
  87. },
  88. groupsList: [],
  89. majorList: [],
  90. aircraftModelList: [],
  91. aircraftNumList: [],
  92. faultyPartsNameList: [],
  93. statisticsDate: [],
  94. select: {
  95. startStatisticsDate: '',
  96. endStatisticsDate: '',
  97. major: '',
  98. groups: '',
  99. aircraftModel: ''
  100. },
  101. typeTree: {
  102. children: 'children',
  103. label: 'label'
  104. },
  105. searchValue: '',
  106. options: {
  107. stripe: true, // 斑马纹
  108. mutiSelect: true, // 多选框
  109. index: false, // 显示序号, 多选则 mutiSelect
  110. loading: false, // 表格动画
  111. initTable: false, // 是否一挂载就加载数据
  112. border: true,
  113. height: 'calc(100vh - 300px)'
  114. },
  115. tableCheckItems: [],
  116. form: {
  117. id: '',
  118. statisticsDate: '',
  119. warZone: '',
  120. army: '',
  121. division: '',
  122. groups: '',
  123. squadron: '',
  124. aircraftNum: '',
  125. aircraftModel: '',
  126. factoryNum: '',
  127. machineType: '',
  128. machineNum: '',
  129. machineModel: '',
  130. machineName: '',
  131. landingGear: '',
  132. major: '',
  133. faultyPartsName: '',
  134. faultyPartsModel: '',
  135. faultyPartsNum: '',
  136. engineModel: '',
  137. engineNum: '',
  138. engineSerialNum: '',
  139. faultyPartsPosition: '',
  140. faultyPhenomenon: '',
  141. faultyPlace: '',
  142. findOpportunity: '',
  143. systems: '',
  144. timingType: '',
  145. faultyPartsManufacturer: '',
  146. faultyPartsRenovate: '',
  147. installationTime: '',
  148. totalWorkTime: '',
  149. repairTime: '',
  150. replacementPartsModel: '',
  151. replacementPartsNum: '',
  152. replacementPartsManufacturer: '',
  153. replacementTotalWorkTime: '',
  154. replacementPartsRenovate: '',
  155. replacementRepairTime: '',
  156. faultyAbnormalCode: '',
  157. faultyPartsInstallDate: '',
  158. faultyReason: '',
  159. faultyNature: '',
  160. faultyResponsibility: '',
  161. faultyConsequence: '',
  162. handlingSuggestions: '',
  163. influenceFrequency: '',
  164. errorFlyFrequency: '',
  165. identificationMethod: '',
  166. discoveredPeople: '',
  167. exclusionMethod: '',
  168. exclusionPeople: '',
  169. examinePeople: '',
  170. examineTime: '',
  171. exclusionDate: '',
  172. exclusionWorkTime: '',
  173. exclusionPeopleNum: '',
  174. exclusionTime: '',
  175. isAchievement: '',
  176. needTestFly: '',
  177. repairStatus: '',
  178. remarks: '',
  179. tenantId: '',
  180. delFlag: '',
  181. version: '',
  182. createBy: '',
  183. createTime: '',
  184. updateBy: '',
  185. updateTime: ''
  186. },
  187. debounceFn: debounce(this.fetch, 500)
  188. }
  189. },
  190. watch: {
  191. keyWord() {
  192. this.debounceFn()
  193. }
  194. },
  195. created() {
  196. let now = new Date()
  197. let year = now.getFullYear()
  198. let month = ('0' + (now.getMonth() + 1)).slice(-2)
  199. let day = ('0' + now.getDate()).slice(-2)
  200. const formattedTimeEnd = year + '-' + month + '-' + day
  201. now = now.setMonth(now.getMonth() - 6)
  202. now = new Date(now)
  203. year = now.getFullYear()
  204. month = ('0' + (now.getMonth() + 1)).slice(-2)
  205. day = ('0' + now.getDate()).slice(-2)
  206. const formattedTimeStart = year + '-' + month + '-' + day
  207. this.statisticsDate = [formattedTimeStart, formattedTimeEnd]
  208. },
  209. mounted() {
  210. if (this.statisticsDate != null) {
  211. this.select.startStatisticsDate = this.statisticsDate[0]
  212. this.select.endStatisticsDate = this.statisticsDate[1]
  213. }
  214. this.getFaultStatisticsAPI(this.select)
  215. },
  216. methods: {
  217. async getFaultStatisticsListAllAPI(params) {
  218. if (params.distinctField == 'aircraft_num') {
  219. params.aircraftModel = this.select.aircraftModel
  220. }
  221. const { data } = await getFaultStatisticsListAll({ ...params })
  222. if (params.distinctField == 'groups') {
  223. this.groupsList = data
  224. } else if (params.distinctField == 'major') {
  225. this.majorList = data
  226. } else if (params.distinctField == 'aircraft_model') {
  227. this.aircraftModelList = data
  228. } else if (params.distinctField == 'aircraft_num') {
  229. this.aircraftNumList = data
  230. } else if (params.distinctField == 'faulty_parts_name') {
  231. this.faultyPartsNameList = data
  232. }
  233. },
  234. async getAircaftTypeAndModelTreeAPI(params) {
  235. const { data } = await getAircaftTypeAndModelTree(params)
  236. this.menuTreeData = data
  237. if (data.length) {
  238. this.currentNodeKey = data[0].value
  239. this.currentNode = data[0]
  240. this.aircaftModelIdList = this.getTreeLeafData(data[0]?.children).map((e) => e.id)
  241. this.getFaultStatisticsAPI({ aircaftModelIdList: this.aircaftModelIdList })
  242. }
  243. },
  244. getTreeLeafData(list) {
  245. const newArr = []
  246. function getLeaf(data, arr) {
  247. data.forEach((e) => {
  248. if (e.type === 1) {
  249. arr.push(e)
  250. }
  251. if (e.children.length) {
  252. getLeaf(e.children, arr)
  253. }
  254. })
  255. }
  256. getLeaf(list, newArr)
  257. return newArr
  258. },
  259. echartsLeft(names, values) {
  260. const echartLeft = echarts.init(this.$refs.echartLeft)
  261. const option = {
  262. tooltip: {
  263. trigger: 'item'
  264. },
  265. xAxis: {
  266. axisLabel: {
  267. color: '#fff'
  268. },
  269. type: 'category',
  270. data: names
  271. },
  272. yAxis: {
  273. type: 'value',
  274. axisLabel: {
  275. color: '#fff'
  276. }
  277. },
  278. series: [
  279. {
  280. data: values,
  281. type: 'bar'
  282. }
  283. ]
  284. }
  285. echartLeft.setOption(option)
  286. },
  287. echartsRight(values) {
  288. const echartRight = echarts.init(this.$refs.echartRight)
  289. const option = {
  290. tooltip: {
  291. trigger: 'item'
  292. },
  293. legend: {
  294. orient: 'vertical',
  295. left: 'left',
  296. textStyle: {
  297. color: '#fff'
  298. }
  299. },
  300. series: [
  301. {
  302. type: 'pie',
  303. radius: '50%',
  304. label: {
  305. show: true,
  306. color: '#fff'
  307. },
  308. emphasis: null,
  309. data: values
  310. },
  311. {
  312. type: 'pie',
  313. radius: '50%',
  314. label: {
  315. show: true,
  316. position: 'inside',
  317. formatter: '{d}%' // 显示名称和百分比
  318. },
  319. data: values,
  320. emphasis: {
  321. itemStyle: {
  322. shadowBlur: 10,
  323. shadowOffsetX: 0,
  324. shadowColor: 'rgba(0, 0, 0, 0.5)'
  325. }
  326. }
  327. }
  328. ]
  329. }
  330. echartRight.setOption(option)
  331. },
  332. async getFaultStatisticsAPI(params) {
  333. const res = await getFaultStatisticsEcharts({ ...params })
  334. this.getFaultStatisticsListAllAPI({ distinctField: 'groups' })
  335. this.getFaultStatisticsListAllAPI({ distinctField: 'major' })
  336. this.getFaultStatisticsListAllAPI({ distinctField: 'aircraft_model' })
  337. this.getFaultStatisticsListAllAPI({ distinctField: 'aircraft_num' })
  338. this.getFaultStatisticsListAllAPI({ distinctField: 'faulty_parts_name' })
  339. const names = []
  340. const values = []
  341. const data = []
  342. res.data.forEach((e) => {
  343. names.push(e.faultyPartsName)
  344. values.push(e.nameCount)
  345. data.push({
  346. name: e.faultyPartsName,
  347. value: e.nameCount
  348. })
  349. })
  350. const sortPieData = data.sort((a, b) => {
  351. return b.value - a.value
  352. })
  353. const sortBarData = values.sort((a, b) => {
  354. return b - a
  355. })
  356. this.echartsLeft(names, sortBarData)
  357. this.echartsRight(sortPieData)
  358. },
  359. fetch() {
  360. this.getFaultStatisticsAPI()
  361. },
  362. searchClick() {
  363. console.log(this.statisticsDate)
  364. if (this.statisticsDate != null) {
  365. this.select.startStatisticsDate = this.statisticsDate[0]
  366. this.select.endStatisticsDate = this.statisticsDate[1]
  367. }
  368. this.getFaultStatisticsAPI(this.select)
  369. },
  370. handleClose() {
  371. this.dialogVisible = false
  372. this.form = {
  373. id: '',
  374. statisticsDate: '',
  375. warZone: '',
  376. army: '',
  377. division: '',
  378. groups: '',
  379. squadron: '',
  380. aircraftNum: '',
  381. aircraftModel: '',
  382. factoryNum: '',
  383. machineType: '',
  384. machineNum: '',
  385. machineModel: '',
  386. machineName: '',
  387. landingGear: '',
  388. major: '',
  389. faultyPartsName: '',
  390. faultyPartsModel: '',
  391. faultyPartsNum: '',
  392. engineModel: '',
  393. engineNum: '',
  394. engineSerialNum: '',
  395. faultyPartsPosition: '',
  396. faultyPhenomenon: '',
  397. faultyPlace: '',
  398. findOpportunity: '',
  399. systems: '',
  400. timingType: '',
  401. faultyPartsManufacturer: '',
  402. faultyPartsRenovate: '',
  403. installationTime: '',
  404. totalWorkTime: '',
  405. repairTime: '',
  406. replacementPartsModel: '',
  407. replacementPartsNum: '',
  408. replacementPartsManufacturer: '',
  409. replacementTotalWorkTime: '',
  410. replacementPartsRenovate: '',
  411. replacementRepairTime: '',
  412. faultyAbnormalCode: '',
  413. faultyPartsInstallDate: '',
  414. faultyReason: '',
  415. faultyNature: '',
  416. faultyResponsibility: '',
  417. faultyConsequence: '',
  418. handlingSuggestions: '',
  419. influenceFrequency: '',
  420. errorFlyFrequency: '',
  421. identificationMethod: '',
  422. discoveredPeople: '',
  423. exclusionMethod: '',
  424. exclusionPeople: '',
  425. examinePeople: '',
  426. examineTime: '',
  427. exclusionDate: '',
  428. exclusionWorkTime: '',
  429. exclusionPeopleNum: '',
  430. exclusionTime: '',
  431. isAchievement: '',
  432. needTestFly: '',
  433. repairStatus: '',
  434. remarks: '',
  435. tenantId: '',
  436. delFlag: '',
  437. version: '',
  438. createBy: '',
  439. createTime: '',
  440. updateBy: '',
  441. updateTime: ''
  442. }
  443. }
  444. }
  445. }
  446. </script>
  447. <style lang="scss">
  448. @import '../index.scss';
  449. </style>