index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. <template>
  2. <div class="table-box">
  3. <div class="card table-search" style="overflow: hidden;">
  4. <el-form ref="formRef" :model="pageable" :inline="true" label-width="auto">
  5. <el-form-item label="自动站:" prop="base">
  6. <el-select v-model="pageable.as_code" filterable placeholder="请搜索自动站" remote reserve-keyword
  7. clearable style="width: 200px" @change="changeStation">
  8. <el-option v-for="item in platformList" :key="item.as_code"
  9. :label="item.as_code + ' ' + item.as_name" :value="item.as_code" />
  10. <template #prefix>
  11. <el-icon class="el-input__icon">
  12. <search />
  13. </el-icon>
  14. </template>
  15. </el-select>
  16. </el-form-item>
  17. <el-form-item label="观测时间:" prop="base">
  18. <div>
  19. <el-switch v-model="value1" @change="changetype" class="ml-2" inline-prompt active-text="日"
  20. inactive-text="小时" style="margin-right: 10px;" />
  21. <el-date-picker v-model="dateRange" value-format="YYYY-MM-DD HH:mm"
  22. :format="value1 ? 'YYYY-MM-DD' : 'YYYY-MM-DD HH:mm'"
  23. :type="value1 ? 'daterange' : 'datetimerange'" range-separator="-" start-placeholder="开始时间"
  24. end-placeholder="结束时间" :disabled-date="disabledDate"
  25. @focus="handleFocus" @calendar-change="handleChange" @change="handleDateChange"
  26. :default-time="[new Date(2000, 1, 1, 0, 0), new Date(2000, 1, 1, new Date().getHours(), 0)]"
  27. style="width: 300px;"></el-date-picker>
  28. </div>
  29. </el-form-item>
  30. <el-form-item>
  31. <div>
  32. <el-button type="primary" @click="handleDateChange(dateRange)">查询</el-button>
  33. <el-button plain @click="resetForm">重置</el-button>
  34. </div>
  35. </el-form-item>
  36. </el-form>
  37. </div>
  38. <div class="main_list">
  39. <el-row :gutter="15">
  40. <el-col :span="24">
  41. <div class="chart_item zhuti">
  42. <div style="font-weight: bold;" class="item_title">
  43. <span>雷电区域分析</span>
  44. </div>
  45. <div class="mt5">
  46. <div ref="data" class="data_box"></div>
  47. </div>
  48. </div>
  49. </el-col>
  50. </el-row>
  51. </div>
  52. </div>
  53. </template>
  54. <script setup lang="ts" name="dataSynthesis">
  55. import * as echarts from 'echarts';
  56. import { ElMessage } from "element-plus";
  57. import { useGlobalStore } from "@/stores/modules/global";
  58. import { ref, computed, onMounted, reactive, watch, onDeactivated, onActivated, nextTick } from "vue";
  59. import { getDataItemList, getPlatformList, getRgDataList, getTacRecordList } from "@/api/modules/allData";
  60. import { Platform } from "@/api/interface";
  61. import { parseTime } from '@/utils/index';
  62. import { isToday, isWithinThirtyMinutes, getTimeStamp, getStamp, isDateFuture, isDateRangeWithinDays } from "@/utils/dateTime";
  63. import {useUserStore} from "@/stores/modules/user";
  64. const value1 = ref(true)
  65. const dateRange = ref<[any, any]>([parseTime(new Date(), '{y}-{m}-{d}') + ' 00:00', parseTime(new Date(), '{y}-{m}-{d} {h}:{i}')]);
  66. const changetype = (e) => {
  67. if (!e) {
  68. dateRange.value = [parseTime(getTimeStamp(1), '{y}-{m}-{d} {h}:{i}'), parseTime(new Date(), '{y}-{m}-{d} {h}:{i}')]
  69. } else {
  70. dateRange.value = [parseTime(new Date(), '{y}-{m}-{d}') + ' 00:00', parseTime(new Date(), '{y}-{m}-{d} {h}:{i}')]
  71. }
  72. }
  73. const handleDateRangeChange = (newVal) => {
  74. const [startDate, endDate] = newVal;
  75. if (endDate && isToday(endDate)) {
  76. // 获取当前时间的整点
  77. const currentHour = new Date().getHours();
  78. const roundedEndDate = new Date(endDate);
  79. roundedEndDate.setMinutes(0, 0, 0); // 设置分钟、秒、毫秒为0
  80. const startZeroed = new Date(startDate);
  81. startZeroed.setHours(0, 0, 0, 0);
  82. dateRange.value = [parseTime(new Date(startZeroed)), parseTime(new Date(roundedEndDate))];
  83. } else {
  84. const noTodayStart = new Date(startDate).setMinutes(0, 0, 0);
  85. const noTodayEnd = new Date(endDate).setHours(23, 0, 0, 0);
  86. dateRange.value = [parseTime(new Date(noTodayStart)), parseTime(new Date(noTodayEnd))];
  87. }
  88. };
  89. const handleDateChange = async (e) => {
  90. if (isDateFuture(e[0]) || isDateFuture(e[1])) {
  91. ElMessage.error("不得选择未来的时间");
  92. } else {
  93. if (!value1.value) {
  94. if (isWithinThirtyMinutes(e[0], e[1])) {
  95. // 获取参数
  96. getHistoryList()
  97. } else {
  98. ElMessage.error("分钟模式下时间间隔不能大于3小时");
  99. }
  100. } else {
  101. if (isDateRangeWithinDays(e[0], e[1], 7)) {
  102. await handleDateRangeChange(e)
  103. getHistoryList()
  104. } else {
  105. ElMessage.error("日模式下时间间隔不能大于7天");
  106. }
  107. }
  108. }
  109. }
  110. const pickDay = ref()
  111. const handleFocus = () => {
  112. pickDay.value = null
  113. }
  114. const limitTime = 1000 * 60 * 60 * 24 * 6
  115. const disabledDate = (time: Date) => {
  116. return time.getTime() > Date.now() - 8.64e6
  117. }
  118. const handleChange = (val: Date[]) => {
  119. const [pointDay] = val
  120. pickDay.value = pointDay
  121. }
  122. const pageable = ref({
  123. data_type: true,
  124. time_order: 1,
  125. as_code: undefined,
  126. data_items: [],
  127. pageNum: 1,
  128. });
  129. let historyColumns = [
  130. {
  131. data_id: 1003,
  132. data_r_table: "SHI_SHI_DA_QI_DIAN_CHANG_SHAN_DIAN_SHU_JU",
  133. data_type: "闪电",
  134. data_name: "1分钟最强闪电的强度",
  135. data_item: "YI_FEN_ZHONG_ZUI_QIANG_SHAN_DIAN_DE_QIANG_DU",
  136. data_unit: "V/m",
  137. data_h_table: "LI_SHI_DA_QI_DIAN_CHANG_SHAN_DIAN_SHU_JU",
  138. data_value: "",
  139. data_order: 0,
  140. data_condition: 0
  141. },
  142. {
  143. data_id: 1010,
  144. data_r_table: "SHI_SHI_DA_QI_DIAN_CHANG_SHAN_DIAN_SHU_JU",
  145. data_type: "闪电",
  146. data_name: "1分钟最强闪电的距离",
  147. data_item: "YI_FEN_ZHONG_ZUI_QIANG_SHAN_DIAN_DE_JU_LI",
  148. data_unit: "km",
  149. data_h_table: "LI_SHI_DA_QI_DIAN_CHANG_SHAN_DIAN_SHU_JU",
  150. data_value: "",
  151. data_order: 0,
  152. data_condition: 0
  153. },
  154. {
  155. data_id: 1011,
  156. data_r_table: "SHI_SHI_DA_QI_DIAN_CHANG_SHAN_DIAN_SHU_JU",
  157. data_type: "闪电",
  158. data_name: "1分钟最强闪电的方位角",
  159. data_item: "YI_FEN_ZHONG_ZUI_QIANG_SHAN_DIAN_DE_FANG_WEI_JIAO",
  160. data_unit: "°",
  161. data_h_table: "LI_SHI_DA_QI_DIAN_CHANG_SHAN_DIAN_SHU_JU",
  162. data_value: "",
  163. data_order: 0,
  164. data_condition: 0
  165. },
  166. ]
  167. // 查询自动站列表
  168. const queryas = ref<Platform>({
  169. pageSize: 50,
  170. pageNum: 1,
  171. currentpage: 1
  172. })
  173. const userStore = useUserStore();
  174. const platformList =ref<any>(computed(() => userStore.stations))
  175. const selectPlatform = ref()
  176. const getPlatforms = async () => {
  177. pageable.value.as_code = platformList.value[0].as_code
  178. selectPlatform.value = platformList.value[0]
  179. getHistoryList()
  180. };
  181. const changeStation = () => {
  182. getHistoryList()
  183. }
  184. //时间戳转换为指定格式的日期字符串
  185. function formatDate(timestamp, type) {
  186. const date = new Date(timestamp * 1000); // 将时间戳转换为毫秒
  187. const year = date.getFullYear();
  188. const month = String(date.getMonth() + 1).padStart(2, '0');
  189. const day = String(date.getDate()).padStart(2, '0');
  190. const hours = String(date.getHours()).padStart(2, '0');
  191. const minutes = String(date.getMinutes()).padStart(2, '0');
  192. if (type === 1) {
  193. return `${month}/${day} ${hours}:${minutes}`;
  194. } else {
  195. return `${year}-${month}-${day} ${hours}:${minutes}`;
  196. }
  197. }
  198. const timeArr = ref()
  199. const series = ref<any>([])
  200. const getHistoryList = async () => {
  201. const { data } = await getDataItemList({ ...pageable.value, pageSize: 9999, as_code_list: [pageable.value.as_code], data_items: historyColumns, data_type: false, time_space: value1.value ? 60 : 1, end_time: getStamp(dateRange.value[1]), begin_time: getStamp(dateRange.value[0]) });
  202. timeArr.value = data.list?.map(item => {
  203. return formatDate(item.data_time_i, 1)
  204. })
  205. data.list?.forEach((item, index) => {
  206. // 初始化一个空数组来存储生成的对象
  207. let resultArray = <any>[];
  208. // 初始化起始角度和结束角度
  209. let startAngle = 359.50;
  210. let endAngle = 0.00; // 注意,这个值实际上是开区间 (0, 360] 的起点前一个值,所以设置为0 - 0.5的极限情况
  211. let step = -0.50;
  212. // 循环生成对象
  213. for (let angle = startAngle; angle >= endAngle; angle += step) {
  214. if (item[1001] != '--') {
  215. if (angle == 0 && (Number(item[1011]) >= 359.75 || Number(item[1011]) < 0.25)) {
  216. resultArray.push(Number(item[1010]))
  217. } else if (Number(item[1011]) >= angle - 0.25 && Number(item[1011]) < angle + 0.25) {
  218. resultArray.push(Number(item[1010]))
  219. } else {
  220. resultArray.push(null)
  221. }
  222. }
  223. // if (item[1011] != '--' && Number(item[1011]) == angle) {
  224. // resultArray.push(Number(item[1010]))
  225. // console.log(resultArray, 'resultArray');
  226. // } else {
  227. // resultArray.push(0)
  228. // }
  229. // resultArray.push(obj);
  230. }
  231. series.value.push({
  232. name: 'No.' + index,
  233. type: 'radar',
  234. itemStyle: {
  235. borderWidth: 10,
  236. borderColor: 'transparent'
  237. },
  238. data: [
  239. {
  240. value: resultArray,
  241. name: item.data_time,
  242. info: item,
  243. lineStyle: {
  244. normal: {
  245. color: 'transparent'
  246. }
  247. },
  248. itemStyle: { // 单个拐点标志的样式设置。
  249. normal: {
  250. color: '#5470c6'
  251. }
  252. },
  253. },
  254. ]
  255. })
  256. })
  257. nextTick(()=>{
  258. showData()
  259. })
  260. };
  261. const formRef = ref()
  262. const data = ref()
  263. const globalStore = useGlobalStore();
  264. const isDark = computed(() => globalStore.isDark);
  265. // resetForm
  266. const resetForm = () => {
  267. dateRange.value =[parseTime(new Date(), '{y}-{m}-{d}') + ' 00:00', parseTime(new Date(), '{y}-{m}-{d} {h}:{i}')]
  268. value1.value = true
  269. pageable.value.as_code = platformList.value[0].as_code
  270. getHistoryList()
  271. };
  272. const clickNum=ref(0)
  273. const showData = () => {
  274. // 初始化一个空数组来存储生成的对象
  275. let resultArray = <any>[];
  276. // 初始化起始角度和结束角度
  277. let startAngle = 360;
  278. let endAngle = 0; // 注意,这个值实际上是开区间 (0, 360] 的起点前一个值,所以设置为0 - 0.5的极限情况
  279. let step = -0.5;
  280. // 循环生成对象
  281. for (let angle = startAngle; angle > endAngle; angle += step) {
  282. let obj = {
  283. name: (angle === 360 || angle % 45 === 0) ? angle.toFixed(1) + '°' : '',
  284. max: 200,
  285. // alignTicks: false,
  286. color: isDark.value ? '#fff' : "#000",
  287. axisLabel: angle === 360 ? {
  288. show: angle === 360,
  289. formatter: '{value}km', color: "#000", showMinLabel: false
  290. } : {},
  291. axisLine: {
  292. show: angle === 360 || angle % 22.5 === 0
  293. }
  294. };
  295. resultArray.push(obj);
  296. }
  297. let mychart = echarts.init(data.value);
  298. let option = {
  299. tooltip: {
  300. show: true,
  301. triggerOn: 'click',
  302. formatter: function (params) {
  303. return `一分钟最强闪电的强度:${params.data.info[1003]}V/m <br />时间:${formatDate(params.data.info.data_time_i, 2)}`
  304. }
  305. },
  306. radar: {
  307. shape: 'circle',
  308. // radius: 320, // 大小
  309. name: { // (圆外的标签)雷达图每个指示器名称的配置项。
  310. formatter: '{value}',
  311. textStyle: {
  312. fontSize: 15,
  313. color: isDark.value ? '#fff' : "#000"
  314. }
  315. },
  316. nameGap: 5,
  317. // 指示器名称和指示器轴的距离。[ default: 15 ]
  318. splitNumber: 5,
  319. splitLine: { // (这里是指所有圆环)坐标轴在 grid 区域中的分隔线。
  320. lineStyle: {
  321. color: '#bbbbbb',
  322. // 分隔线颜色
  323. width: 1,
  324. // 分隔线线宽
  325. }
  326. },
  327. splitArea: { // 坐标轴在 grid 区域中的分隔区域,默认不显示。
  328. show: true,
  329. areaStyle: { // 分隔区域的样式设置。
  330. color: [isDark.value ? '#000' : "#fff", isDark.value ? '#000' : "#fff"],
  331. // 分隔区域颜色。分隔区域会按数组中颜色的顺序依次循环设置颜色。默认是一个深浅的间隔色。
  332. }
  333. },
  334. indicator: resultArray
  335. },
  336. series: series.value
  337. };
  338. mychart.setOption(option);
  339. window.addEventListener("resize", function () {
  340. mychart.resize();
  341. });
  342. }
  343. watch(isDark, () => {
  344. showData()
  345. });
  346. onMounted(() => {
  347. getPlatforms()
  348. })
  349. </script>
  350. <style scoped lang="scss">
  351. .main_list {
  352. background: transparent !important;
  353. box-shadow: none !important;
  354. padding: 0 !important;
  355. height: calc(100vh - 150px);
  356. margin-bottom: 10px;
  357. overflow-y: scroll;
  358. overflow-x: hidden;
  359. .chart_item {
  360. border-radius: 10px;
  361. padding: 10px;
  362. background-color: #fff;
  363. // height: 100%;
  364. // margin-bottom: 15px;
  365. .item_title {
  366. display: flex;
  367. justify-content: space-between;
  368. align-items: center;
  369. }
  370. .FTP_box {
  371. padding: 0 50px;
  372. display: flex;
  373. align-items: center;
  374. justify-content: space-between;
  375. .FTP_item {
  376. flex: 1;
  377. flex-shrink: 0;
  378. display: flex;
  379. flex-direction: column;
  380. justify-content: center;
  381. align-items: center;
  382. img {
  383. width: 56px;
  384. margin-bottom: 20px;
  385. }
  386. }
  387. }
  388. }
  389. .info_box {
  390. .info_title {
  391. color: #999999;
  392. font-size: 16px;
  393. }
  394. .info_content {
  395. height: 40px;
  396. font-weight: bold;
  397. color: #000;
  398. font-size: 26px;
  399. }
  400. }
  401. }
  402. .data_box {
  403. height: calc(100vh - 215px);
  404. // height: 100%;
  405. }
  406. </style>