Force.vue 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915
  1. <template>
  2. <div class="force_box">
  3. <div v-show="show_org" class="station_tree">
  4. <div style="padding:5px;">
  5. <el-input
  6. size="small"
  7. v-model="search_data"
  8. prefix-icon="el-icon-search"
  9. placeholder="请输入关键字搜索"
  10. >
  11. </el-input>
  12. </div>
  13. <el-tree
  14. node-key="id"
  15. ref="zzj_tree"
  16. :data="station_tree"
  17. :default-expanded-keys="defaultShowNodes"
  18. :props="defaultProps"
  19. :highlight-current="isHighlight"
  20. :expand-on-click-node="true"
  21. :filter-node-method="filterNode"
  22. >
  23. <span slot-scope="{ node, data }">
  24. <span
  25. :class="{
  26. is_disabled: computed_is_disabled(data),
  27. }"
  28. :style="{ backgroundColor: data.id == click_id ? '#304156' : '' }"
  29. @click="handle_node_click(data, node)"
  30. >{{ data.name }}</span
  31. >
  32. </span>
  33. </el-tree>
  34. </div>
  35. <!-- format="yyyy-MM-dd HH:mm:00" -->
  36. <div class="charts">
  37. <div class="times">
  38. <i
  39. :class="[show_org ? 'el-icon-s-fold' : 'el-icon-s-unfold', 'show_org']"
  40. @click="show_org = !show_org"
  41. ></i>
  42. <el-date-picker
  43. v-model="times"
  44. size="small"
  45. :clearable="false"
  46. type="datetimerange"
  47. @change="get_curve_data('is_query')"
  48. style="width:400px;"
  49. value-format="timestamp"
  50. range-separator="至"
  51. format="yyyy-MM-dd HH:mm"
  52. start-placeholder="开始日期"
  53. end-placeholder="结束日期"
  54. >
  55. </el-date-picker>
  56. <el-button type="primary" style="margin-left: 5px;" size="mini" v-debounce="refresh_data"
  57. >查询</el-button
  58. >
  59. <el-button
  60. icon="el-icon-arrow-left"
  61. type="primary"
  62. style="margin-left: 5px;"
  63. size="mini"
  64. v-debounce="handle_time_left"
  65. >前一天</el-button
  66. >
  67. <el-button
  68. icon="el-icon-arrow-right"
  69. style="margin-left: 5px;"
  70. type="primary"
  71. size="mini"
  72. v-debounce="handle_time_right"
  73. >后一天</el-button
  74. >
  75. <el-button style="margin-left: 5px;" type="primary" size="mini" @click="localtion_curve_statics"
  76. >曲线统计</el-button
  77. >
  78. <el-button
  79. style="margin-left:8px;"
  80. v-show="$route.query.type"
  81. type="primary"
  82. size="small"
  83. @click="go_back"
  84. >返回</el-button
  85. >
  86. <el-switch
  87. v-model="show_label"
  88. v-if="show_switch"
  89. style="margin: 5px 0 0 5px;"
  90. active-color="#67C23A"
  91. inactive-color="#909399"
  92. active-text="显示峰值"
  93. inactive-text="不显示峰值"
  94. @change="get_move_info"
  95. >
  96. </el-switch>
  97. <el-button
  98. style="margin-left:8px;"
  99. v-if="curve_data.curve_data_list && curve_data.curve_data_list.length"
  100. type="primary"
  101. size="small"
  102. @click="get_resist_move"
  103. >重新识别扳动</el-button
  104. >
  105. <div class="threshold">
  106. <el-button size="small" @click="get_curve_data('threshold')" type="primary"
  107. >滤波数据</el-button
  108. >
  109. <el-input
  110. size="small"
  111. v-model="threshold_val"
  112. style="width:120px;"
  113. placeholder="滤波阈值:30≤X≤500,且为整数"
  114. ></el-input>
  115. <el-button size="small" @click="get_curve_data('all')" type="primary">所有数据</el-button>
  116. </div>
  117. </div>
  118. <!-- 参考曲线工具栏 -->
  119. <div class="refer_curve_tools">
  120. <el-button
  121. style="margin-left:8px;"
  122. type="primary"
  123. size="mini"
  124. @click="setting_params"
  125. v-if="$store.state.admin && click_id && is_nodata && $store.state.backend_type == 1"
  126. >报警设置</el-button
  127. >
  128. <el-button
  129. style="margin-left:8px;"
  130. type="primary"
  131. size="mini"
  132. @click="localtion_curve_compare"
  133. v-if="click_id && is_nodata"
  134. >曲线对比</el-button
  135. >
  136. <el-button
  137. v-if="$store.state.admin && click_id && show_switch && $store.state.backend_type == 1"
  138. style="margin-left:8px;"
  139. type="primary"
  140. size="mini"
  141. @click="handle_refer_curve('set')"
  142. >设置参考</el-button
  143. >
  144. <el-button
  145. v-if="$store.state.admin && click_id && show_switch && !show_xy"
  146. style="margin-left:8px;"
  147. type="primary"
  148. size="mini"
  149. @click="handle_refer_curve('get')"
  150. >展示参考</el-button
  151. >
  152. <el-button
  153. style="margin-left:8px;"
  154. type="primary"
  155. size="mini"
  156. v-if="show_xy"
  157. @click="handle_refer_curve('none')"
  158. >隐藏参考</el-button
  159. >
  160. <el-button
  161. style="margin-left:8px;"
  162. type="primary"
  163. size="mini"
  164. v-if="$store.state.admin && click_id && show_switch && $store.state.backend_type == 1"
  165. @click="handle_refer_curve('cancel')"
  166. >取消参考</el-button
  167. >
  168. <el-button
  169. style="margin-left:8px;"
  170. type="primary"
  171. size="mini"
  172. v-if="click_id && !loading"
  173. @click="get_tem_data"
  174. >显示温度</el-button
  175. >
  176. <!-- 移动x/y轴 -->
  177. <div class="x_y_val" v-if="show_xy">
  178. <div class="x_val">
  179. <span title="X轴左移" class="left" @click="handle_xy('left')">
  180. <i class="el-icon-back"></i>
  181. </span>
  182. <b class="x">X轴</b>
  183. <span title="X轴右移" class="right" @click="handle_xy('right')">
  184. <i class="el-icon-right"></i>
  185. </span>
  186. </div>
  187. <div class="y_val">
  188. <span title="Y轴上移" class="left" @click="handle_xy('top')">
  189. <i class="el-icon-top"></i>
  190. </span>
  191. <b class="y">Y轴</b>
  192. <span title="Y轴下移" class="right" @click="handle_xy('bottom')">
  193. <i class="el-icon-bottom"></i>
  194. </span>
  195. </div>
  196. </div>
  197. </div>
  198. <div
  199. v-if="show_chart"
  200. ref="line_echarts"
  201. v-loading="loading"
  202. element-loading-text="拼命加载中"
  203. element-loading-spinner="el-icon-loading"
  204. element-loading-background="rgba(31, 31, 31, 0.6)"
  205. id="line_chart"
  206. ></div>
  207. <el-empty v-else image="/static/img/no_data.png"></el-empty>
  208. </div>
  209. <div class="setting_box">
  210. <el-dialog
  211. width="450px"
  212. title="报警配置"
  213. :lock-scroll="true"
  214. :show-close="true"
  215. @close="cancel_setting"
  216. :close-on-click-modal="false"
  217. :close-on-press-escape="false"
  218. :visible.sync="setting_dialogVisible"
  219. >
  220. <el-tabs @tab-click="tab_click" v-model="post_data.type">
  221. <el-tab-pane label="最大值超限" name="monitor.alarm.max_over_limit">
  222. <p>选择测力点</p>
  223. <el-radio-group @change="radio_change" v-model="radio">
  224. <!-- <el-radio label="1#">定位测力曲线</el-radio>
  225. <el-radio label="2#">反位测力曲线</el-radio>
  226. <el-radio label="3#">转化阻力曲线</el-radio> -->
  227. <el-radio v-for="(item, index) in rename_list" :label="item.label" :key="index">
  228. {{ item.name }}
  229. </el-radio>
  230. </el-radio-group>
  231. <p><span class="mark">*</span>状态</p>
  232. <el-radio-group @change="enable_change" v-model="enable">
  233. <el-radio label="true">启用</el-radio>
  234. <el-radio label="false">未启用</el-radio>
  235. </el-radio-group>
  236. <template v-if="['1#', '2#'].includes(radio)">
  237. <p><span class="mark">*</span>锁闭力冲击力报警值</p>
  238. <el-input style="width:100px" v-model="lock_alarm_high_limit" size="small"></el-input>
  239. <p><span class="mark">*</span>锁闭力稳态预警值</p>
  240. <el-input style="width:100px" v-model="lock_warn_high_limit" size="small"></el-input>
  241. </template>
  242. <template v-else>
  243. <p></p>
  244. <span class="mark">*</span>定扳反报警值
  245. <el-input style="width:75px" v-model="d_alarm_high_limit" size="small"></el-input>
  246. <span class="mark">*</span><span>反扳定报警值</span>
  247. <el-input style="width:75px" v-model="f_alarm_high_limit" size="small"></el-input>
  248. <p></p>
  249. <span class="mark">*</span>定扳反预警值
  250. <el-input style="width:75px" v-model="d_warn_high_limit" size="small"></el-input>
  251. <span class="mark">*</span>反扳定预警值
  252. <el-input style="width:75px" v-model="f_warn_high_limit" size="small"></el-input>
  253. </template>
  254. <p><el-button size="small" type="primary" @click="submit_content">保 存</el-button></p>
  255. </el-tab-pane>
  256. <el-tab-pane label="摩擦力超限" name="monitor.alarm.friction_over_limit">
  257. <p>选择测力点</p>
  258. <el-radio-group @change="radio_change" v-model="radio">
  259. <el-radio label="3#">转换阻力曲线</el-radio>
  260. </el-radio-group>
  261. <p><span class="mark">*</span>状态</p>
  262. <el-radio-group @change="enable_change" v-model="enable">
  263. <el-radio label="true">启用</el-radio>
  264. <el-radio label="false">未启用</el-radio>
  265. </el-radio-group>
  266. <p></p>
  267. <span class="mark">*</span>上超低限报警值
  268. <el-input style="width:70px" v-model="up_alarm_low_limit" size="small"></el-input>
  269. <span class="mark">*</span><span>下超高限报警值</span>
  270. <el-input style="width:70px" v-model="dw_alarm_high_limit" size="small"></el-input>
  271. <p></p>
  272. <span class="mark">*</span>上超低限预警值
  273. <el-input style="width:70px" v-model="up_warn_low_limit" size="small"></el-input>
  274. <span class="mark">*</span>下超高限预警值
  275. <el-input style="width:70px" v-model="dw_warn_high_limit" size="small"></el-input>
  276. <p><el-button size="small" type="primary" @click="submit_content">保 存</el-button></p>
  277. </el-tab-pane>
  278. <el-tab-pane label="锁闭力报警" name="suobi_lock">
  279. <p class="enable_style">
  280. <span class="mark">*</span>
  281. 状态&nbsp;&nbsp;&nbsp;
  282. <el-radio-group v-model="suobi_lock.enable">
  283. <el-radio :label="true">启用</el-radio>
  284. <el-radio :label="false">未启用</el-radio>
  285. </el-radio-group>
  286. </p>
  287. <p class="no_show">1</p>
  288. <p class="enable_style">
  289. <span class="mark">*</span>
  290. 位置&nbsp;&nbsp;&nbsp;
  291. <el-radio-group @change="posi_change" v-model="posi">
  292. <el-radio :label="100">定位</el-radio>
  293. <el-radio :label="101">反位</el-radio>
  294. </el-radio-group>
  295. </p>
  296. <p class="no_show">1</p>
  297. <span class="mark">*</span>最小告警值
  298. <el-input
  299. style="width:75px"
  300. v-model.number="suobi_lock.alarm_low_limit"
  301. size="small"
  302. ></el-input>
  303. <span class="mark position_left">*</span><span>最小预警值</span>
  304. <el-input
  305. style="width:75px"
  306. v-model.number="suobi_lock.warn_low_limit"
  307. size="small"
  308. ></el-input>
  309. <p class="no_show">1</p>
  310. <span class="mark">*</span>最大告警值
  311. <el-input
  312. style="width:75px"
  313. v-model.number="suobi_lock.alarm_high_limit"
  314. size="small"
  315. ></el-input>
  316. <span class="mark position_left">*</span>最大预警值
  317. <el-input
  318. style="width:75px"
  319. v-model.number="suobi_lock.warn_high_limit"
  320. size="small"
  321. ></el-input>
  322. <p><el-button size="small" type="primary" @click="submit_content">保 存</el-button></p>
  323. </el-tab-pane>
  324. <el-tab-pane label="转换阻力报警" name="convert_resist">
  325. <p class="enable_style">
  326. <span class="mark">*</span>
  327. 状态&nbsp;&nbsp;&nbsp;
  328. <el-radio-group v-model="convert_resist.enable">
  329. <el-radio :label="true">启用</el-radio>
  330. <el-radio :label="false">未启用</el-radio>
  331. </el-radio-group>
  332. </p>
  333. <p class="no_show">1</p>
  334. <span class="mark">*</span>伸出告警值
  335. <el-input
  336. style="width:75px"
  337. v-model.number="convert_resist.dw_alarm_low_limit"
  338. size="small"
  339. ></el-input>
  340. <span class="mark position_left">*</span><span>伸出预警值</span>
  341. <el-input
  342. style="width:75px"
  343. v-model.number="convert_resist.dw_warn_low_limit"
  344. size="small"
  345. ></el-input>
  346. <p class="no_show">1</p>
  347. <span class="mark">*</span>缩进告警值
  348. <el-input
  349. style="width:75px"
  350. v-model.number="convert_resist.up_alarm_high_limit"
  351. size="small"
  352. ></el-input>
  353. <span class="mark position_left">*</span>缩进预警值
  354. <el-input
  355. style="width:75px"
  356. v-model.number="convert_resist.up_warn_high_limit"
  357. size="small"
  358. ></el-input>
  359. <p><el-button size="small" type="primary" @click="submit_content">保 存</el-button></p>
  360. </el-tab-pane>
  361. <el-tab-pane label="保持力异常报警" name="dw_alarm_low_drop">
  362. <p><span class="mark">*</span>状态</p>
  363. <el-radio-group @change="enable_change" v-model="enable">
  364. <el-radio label="true">启用</el-radio>
  365. <el-radio label="false">未启用</el-radio>
  366. </el-radio-group>
  367. <p class="enable_style">
  368. <span class="mark">*</span>
  369. 位置&nbsp;&nbsp;&nbsp;
  370. <el-radio-group @change="posi_change" v-model="posi">
  371. <el-radio :label="100">定位</el-radio>
  372. <el-radio :label="101">反位</el-radio>
  373. </el-radio-group>
  374. </p>
  375. <p><span class="mark">*</span>最低报警值</p>
  376. <el-input style="width:100px" v-model="dw_alarm_low_drop" size="small"></el-input>
  377. <p><span class="mark">*</span>下降超限百分比:(5≤值≤95)</p>
  378. <el-input style="width:100px" v-model="alarm_low_percent" size="small"></el-input>
  379. <p><span class="mark">*</span>上升超限百分比:(5≤值≤95)</p>
  380. <el-input style="width:100px" v-model="alarm_high_percent" size="small"></el-input>
  381. <p><el-button size="small" type="primary" @click="submit_content">保 存</el-button></p>
  382. </el-tab-pane>
  383. <el-tab-pane label="报警提醒间隔设置" name="alarm_interval">
  384. <span>间隔时间:</span>
  385. <el-input style="width:100px" v-model="alarm_interval" size="small"></el-input>
  386. <span>分钟</span>
  387. <p><el-button size="small" type="primary" @click="submit_content">保 存</el-button></p>
  388. </el-tab-pane>
  389. <!-- <el-tab-pane label="最小值超限" name="third">最小值超限</el-tab-pane>
  390. <el-tab-pane label="峰谷差值超标" name="fourth">峰谷差值超标</el-tab-pane>
  391. <el-tab-pane label="变化量超标" name="five">变化量超标</el-tab-pane>
  392. <el-tab-pane label="经验上限" name="six">经验上限</el-tab-pane> -->
  393. </el-tabs>
  394. <span slot="footer" class="dialog-footer">
  395. <!-- <el-button size="small" @click="cancel_setting">取 消</el-button> -->
  396. <!-- <el-button size="small" type="primary" @click="submit_content">提 交</el-button> -->
  397. <el-button size="small" @click="cancel_setting">关 闭</el-button>
  398. </span>
  399. </el-dialog>
  400. </div>
  401. </div>
  402. </template>
  403. <script>
  404. import {
  405. conf_read,
  406. get_tem_curve,
  407. get_data_temp,
  408. equip_list,
  409. commit_record,
  410. refer_option,
  411. refer_curve,
  412. post_refer_curve,
  413. read_convert_resist,
  414. write_convert_resist,
  415. read_mitie_lock,
  416. write_mitie_lock,
  417. get_reminder_interval,
  418. set_reminder_interval,
  419. get_retension_force,
  420. set_retension_force,
  421. resist_move,
  422. resist_data,
  423. } from '../api'
  424. import forceOption from '../chart/force-curve'
  425. export default {
  426. name: 'Force',
  427. data() {
  428. return {
  429. setting_dialogVisible: false,
  430. station_tree: [],
  431. defaultProps: {
  432. children: 'children',
  433. label: 'name',
  434. },
  435. isHighlight: true, // 是否高亮选中的tree节点
  436. show_chart: false,
  437. send_data: {
  438. cmd: 'query_hist',
  439. tag: '',
  440. time: '',
  441. }, //获取阻力曲线图
  442. query_hist_confirm: {
  443. cmd: 'query_hist_confirm',
  444. tag: '',
  445. }, //确认包
  446. // times: [+new Date() - 120 * 60000, new Date()],
  447. times: [null, null],
  448. click_id: '', //确认是否激活
  449. curve_data: new Object(), // 曲线数据
  450. loading: false,
  451. defaultShowNodes: [],
  452. search_data: '',
  453. title: '', // 曲线名称
  454. get_tem: {
  455. mo: '',
  456. mp: '',
  457. starttime: '',
  458. endtime: '',
  459. }, // 获取温度数据
  460. myCharts: null,
  461. get_max_over_tag: '',
  462. warn_line_data: [], // 警戒线数据
  463. warn_line_map: new Map([
  464. ['lock_alarm_high_limit', ''],
  465. ['lock_warn_high_limit', ''],
  466. ['d_alarm_high_limit', '定扳反'],
  467. ['f_alarm_high_limit', '反扳定'],
  468. ['d_warn_high_limit', '定扳反'],
  469. ['f_warn_high_limit', '反扳定'],
  470. ]),
  471. /**报警设置数据*/
  472. /**转换阻力报警值设置*/
  473. convert_resist: {
  474. enable: false,
  475. dw_alarm_low_limit: null,
  476. dw_warn_low_limit: null,
  477. up_alarm_high_limit: null,
  478. up_warn_high_limit: null,
  479. },
  480. /**锁闭力报警值设置*/
  481. suobi_lock: {
  482. enable: false,
  483. alarm_low_limit: null,
  484. warn_low_limit: null,
  485. alarm_high_limit: null,
  486. warn_high_limit: null,
  487. },
  488. posi: 100,
  489. radio: '1#', //测力点
  490. enable: '', // 是否启用
  491. lock_alarm_high_limit: '', //锁闭力冲击力报警值 短整数
  492. lock_warn_high_limit: '', //锁闭力稳态预警值 短整数
  493. d_alarm_high_limit: '', // 定扳反报警值
  494. d_warn_high_limit: '', // 定扳反预警值
  495. f_alarm_high_limit: '', // 反扳定报警值
  496. f_warn_high_limit: '', // 反扳定预警值
  497. up_alarm_low_limit: '', //上超低限报警值
  498. up_warn_low_limit: '', //上超低限预警值
  499. dw_alarm_high_limit: '', //下超高限报警值
  500. dw_warn_high_limit: '', //下超高限预警值
  501. dw_alarm_low_drop: '', // 最低报警值
  502. alarm_low_percent: '', // 下降超限百分比
  503. alarm_high_percent: '', // 上升超限百分比
  504. alarm_interval: 0, // 分钟
  505. conf: [],
  506. post_data: {
  507. cmd: 'conf_read',
  508. type: 'monitor.alarm.max_over_limit', // 最大值超限
  509. tag: '',
  510. }, // 获取配置
  511. get_name: {
  512. cmd: 'conf_read',
  513. type: 'monitor.resist.rename',
  514. tag: '',
  515. }, // 获取名称
  516. rename_list: [], // 获取到的名称
  517. equip_list_data: [],
  518. setting_index: null,
  519. show_org: true, //是否显示机构
  520. show_label: false, // 是否显示文字
  521. show_switch: false, // 是否显示按钮
  522. is_nodata: false, // 是否有数据
  523. datazoom_time: [], // 缩放后的起止值
  524. pullInformation: [], // 扳动信息
  525. show_xy: false, // 是否显示xy移动
  526. show_label: false,
  527. // 浏览记录
  528. commit_data: {
  529. module: 2,
  530. dura: '', // 必传
  531. analyze_type: '',
  532. station: '', // 必传
  533. station_name: '', // 必传
  534. mo: '', // 必传
  535. mo_name: '', // 必传
  536. mp: '', // 必传
  537. mp_name: '', // 必传
  538. start_time: '', // 必传
  539. end_time: '', // 必传
  540. time: '', // 必传
  541. name: this.$store.state.name, // 必传
  542. username: this.$store.state.user_name, // 必传
  543. },
  544. res_time: null,
  545. load_finished: false,
  546. refer_curve_data: [],
  547. threshold_val: 100,
  548. refresh_nodes: null,
  549. refresh_datas: null,
  550. is_get_more: false,
  551. }
  552. },
  553. watch: {
  554. search_data(val) {
  555. this.$refs.zzj_tree.filter(val)
  556. },
  557. },
  558. methods: {
  559. // 前一天
  560. handle_time_left() {
  561. let start_time = this.times[0] - 24 * 60 * 60 * 1000
  562. let end_time = this.times[1] - 24 * 60 * 60 * 1000
  563. this.times = [start_time, end_time]
  564. return this.get_curve_data('is_query')
  565. },
  566. // 后一天
  567. handle_time_right() {
  568. let start_time = this.times[0] + 24 * 60 * 60 * 1000
  569. let end_time = this.times[1] + 24 * 60 * 60 * 1000
  570. this.times = [start_time, end_time]
  571. return this.get_curve_data('is_query')
  572. },
  573. // 前往曲线对比
  574. localtion_curve_compare() {
  575. if (!this.click_id) return
  576. if (!this.load_finished) return this.$message.warning('曲线暂未加载完毕,请等加载完毕后再点击')
  577. let data = this.get_datazoom('get_value')
  578. let copy_data = _.cloneDeep(this.curve_data)
  579. copy_data.curve_data_list.forEach(item => {
  580. item.points = item.points.filter(ele => {
  581. return ele[0] >= Math.floor(data.startValue) && ele[0] <= Math.floor(data.endValue)
  582. })
  583. })
  584. copy_data = copy_data.curve_data_list
  585. let starttime,
  586. endtime = null
  587. if (copy_data[0].points.length) {
  588. starttime = copy_data[0].points[0][0]
  589. endtime = copy_data[0].points[copy_data[0].points.length - 1][0]
  590. } else {
  591. return this.$message.warning('此区间内无值,无法对比')
  592. }
  593. this.$router.push({
  594. name: 'curve_compare',
  595. query: {
  596. tag: this.click_id,
  597. name: this.title,
  598. starttime,
  599. endtime,
  600. },
  601. })
  602. this.$store.state.defaultActive = '/layout/curve_compare'
  603. this.$store.commit('handle_save_defaultActive', '/layout/curve_compare')
  604. },
  605. // 获取扳动信息
  606. get_move_info(val) {
  607. this.curve_data.show_label = val
  608. setTimeout(() => {
  609. this.get_datazoom()
  610. return this.draw_line_curve()
  611. }, 16)
  612. },
  613. /**报警配置开始*/
  614. // 位置变化
  615. posi_change() {
  616. return this.tab_click()
  617. },
  618. // 点击获取预告警值
  619. alarm_warn_setting(type) {
  620. if (!this.click_id) return this.$message.warning('请选择重要信息')
  621. let [mo, mp] = this.click_id.split('.')
  622. let send_data = { mo, mp }
  623. switch (type) {
  624. case 'convert_resist':
  625. read_convert_resist(send_data)
  626. .then(res => {
  627. console.log('转换阻力:', res)
  628. this.convert_resist = res
  629. })
  630. .catch(e => {
  631. console.log(e)
  632. })
  633. break
  634. case 'suobi_lock':
  635. send_data.posi = this.posi
  636. read_mitie_lock(send_data)
  637. .then(res => {
  638. console.log('锁闭力:', res)
  639. this.suobi_lock = res
  640. })
  641. .catch(e => {
  642. console.log(e)
  643. })
  644. break
  645. }
  646. },
  647. // 保存预告警设置
  648. save_settting(type) {
  649. if (!this.click_id) return this.$message.warning('请选择重要信息')
  650. let [mo, mp] = this.click_id.split('.')
  651. let send_data = {
  652. mo,
  653. mp,
  654. conf: {},
  655. }
  656. switch (type) {
  657. case 'convert_resist':
  658. send_data.conf = _.cloneDeep(this.convert_resist)
  659. write_convert_resist(send_data)
  660. .then(res => {
  661. return this.$message.success('设置成功...')
  662. })
  663. .catch(e => {
  664. console.log(e)
  665. })
  666. break
  667. case 'suobi_lock':
  668. send_data.posi = this.posi
  669. send_data.conf = _.cloneDeep(this.suobi_lock)
  670. write_mitie_lock(send_data)
  671. .then(res => {
  672. return this.$message.success('设置成功...')
  673. })
  674. .catch(e => {
  675. console.log(e)
  676. })
  677. break
  678. }
  679. },
  680. // 关闭预告警设置
  681. close_setting() {
  682. this.convert_resist = {
  683. enable: false,
  684. dw_alarm_low_limit: null,
  685. dw_warn_low_limit: null,
  686. up_alarm_high_limit: null,
  687. up_warn_high_limit: null,
  688. }
  689. this.posi = 100
  690. this.suobi_lock = {
  691. enable: false,
  692. alarm_low_limit: null,
  693. warn_low_limit: null,
  694. alarm_high_limit: null,
  695. warn_high_limit: null,
  696. }
  697. },
  698. // 点击tabs
  699. tab_click() {
  700. switch (this.post_data.type) {
  701. case 'monitor.alarm.max_over_limit':
  702. this.radio = '1#'
  703. return this.get_setting_data()
  704. case 'monitor.alarm.friction_over_limit':
  705. this.reset_val()
  706. this.radio = '3#'
  707. return this.get_setting_data()
  708. case 'dw_alarm_low_drop':
  709. if (!this.click_id) return this.$message.warning('请先选择设备...')
  710. let [mo, mp] = this.click_id.split('.')
  711. let send_data = { mo, mp, posi: this.posi }
  712. get_retension_force(send_data)
  713. .then(res => {
  714. this.enable = res.enable.toString()
  715. this.dw_alarm_low_drop = res.dw_alarm_low_drop
  716. this.alarm_high_percent = res.alarm_high_percent
  717. this.alarm_low_percent = res.alarm_low_percent
  718. })
  719. .catch(e => {
  720. console.log(e)
  721. })
  722. return
  723. case 'alarm_interval':
  724. return this.handle_interval('get')
  725. case 'suobi_lock':
  726. case 'convert_resist':
  727. return this.alarm_warn_setting(this.post_data.type)
  728. default:
  729. break
  730. }
  731. },
  732. // 提交其他配置
  733. submit_content_other() {
  734. switch (this.send_data.type) {
  735. case 'alarm_interval':
  736. return this.handle_interval('set')
  737. }
  738. },
  739. // 获取、设置间隔
  740. handle_interval(type) {
  741. if (type == 'get') {
  742. get_reminder_interval()
  743. .then(res => {
  744. this.alarm_interval = res.interval
  745. })
  746. .catch(e => {
  747. console.log(e)
  748. })
  749. } else {
  750. if (isNaN(this.alarm_interval)) return this.$message.warning('请输入大于0的数字')
  751. let interval = Number(this.alarm_interval)
  752. if (interval < 0) return this.$message.warning('请输入大于0的数字')
  753. set_reminder_interval({ interval })
  754. .then(res => {
  755. this.handle_interval('get')
  756. return this.$message.success('设置成功...')
  757. })
  758. .catch(e => {
  759. console.log(e)
  760. })
  761. }
  762. },
  763. // 点击报警设置
  764. setting_params() {
  765. this.setting_dialogVisible = true
  766. return this.send_get_name()
  767. // return this.get_setting_data()
  768. },
  769. // 重置数据
  770. reset_val(data) {
  771. let key_list = [
  772. 'enable',
  773. 'lock_alarm_high_limit',
  774. 'lock_warn_high_limit',
  775. 'd_alarm_high_limit',
  776. 'd_warn_high_limit',
  777. 'f_alarm_high_limit',
  778. 'f_warn_high_limit',
  779. 'up_alarm_low_limit',
  780. 'up_warn_low_limit',
  781. 'dw_alarm_high_limit',
  782. 'dw_warn_high_limit',
  783. 'dw_alarm_low_drop',
  784. 'alarm_low_percent',
  785. 'alarm_high_percent',
  786. ]
  787. this.alarm_interval = 0
  788. key_list.forEach(key => {
  789. this[key] = ''
  790. })
  791. this.close_setting()
  792. if (data) return
  793. this.radio = '1#'
  794. },
  795. // 关闭报警配置按钮
  796. cancel_setting() {
  797. this.setting_dialogVisible = false
  798. this.post_data.type = 'monitor.alarm.max_over_limit'
  799. return this.reset_val()
  800. },
  801. // 提交配置
  802. submit_content() {
  803. if (['alarm_interval'].includes(this.post_data.type)) return this.submit_content_other()
  804. if (!this.click_id) return this.$message.warning('请先选择设备...')
  805. let target_data = this.equip_list_data.find(item => item.mo_mp == this.click_id)
  806. if (
  807. !target_data.zl_1_loca ||
  808. !target_data.zl_2_loca ||
  809. !target_data.direct1 ||
  810. !target_data.direct2
  811. )
  812. return this.$message.warning(
  813. '请先去"设备管理"模块设置1号、2号测力点位置和3号测力点伸出位、缩进位位置...'
  814. )
  815. let key_list = []
  816. switch (this.post_data.type) {
  817. case 'monitor.alarm.max_over_limit':
  818. if (['1#', '2#'].includes(this.radio)) {
  819. key_list = ['enable', 'lock_alarm_high_limit', 'lock_warn_high_limit']
  820. } else {
  821. key_list = [
  822. 'enable',
  823. 'd_alarm_high_limit',
  824. 'd_warn_high_limit',
  825. 'f_alarm_high_limit',
  826. 'f_warn_high_limit',
  827. ]
  828. }
  829. break
  830. case 'monitor.alarm.friction_over_limit':
  831. key_list = [
  832. 'enable',
  833. 'up_alarm_low_limit',
  834. 'up_warn_low_limit',
  835. 'dw_alarm_high_limit',
  836. 'dw_warn_high_limit',
  837. ]
  838. break
  839. case 'dw_alarm_low_drop':
  840. if (isNaN(this.dw_alarm_low_drop)) return this.$message.warning('请输入数字')
  841. if (isNaN(this.alarm_low_percent)) return this.$message.warning('下降超限百分比请输入0~95数字')
  842. if (isNaN(this.alarm_high_percent))
  843. return this.$message.warning('上升超限百分比请输入0~95的数字')
  844. let alarm_low_percent = Number(this.alarm_low_percent)
  845. if (alarm_low_percent < 5 || alarm_low_percent > 95)
  846. return this.$message.warning('下降超限百分比请输入0~95的数字')
  847. let alarm_high_percent = Number(this.alarm_high_percent)
  848. if (alarm_high_percent < 5 || alarm_high_percent > 95)
  849. return this.$message.warning('上升超限百分比请输入0~95的数字')
  850. let [mo, mp] = this.click_id.split('.')
  851. let send_data = {
  852. mo,
  853. mp,
  854. posi: this.posi,
  855. conf: {
  856. enable: this.enable == 'true',
  857. dw_alarm_low_drop: Number(this.dw_alarm_low_drop),
  858. alarm_low_percent,
  859. alarm_high_percent,
  860. },
  861. }
  862. set_retension_force(send_data)
  863. .then(res => {
  864. this.tab_click()
  865. return this.$message.success('设置成功...')
  866. })
  867. .catch(e => {
  868. console.log(e)
  869. })
  870. return
  871. case 'suobi_lock':
  872. case 'convert_resist':
  873. return this.save_settting(this.post_data.type)
  874. default:
  875. break
  876. }
  877. let isEmpty = key_list.every(key => this[key] != '')
  878. if (!isEmpty) return this.$message.warning('请检查必填项...')
  879. this.conf = []
  880. key_list.forEach(item => {
  881. this.conf.push({
  882. name: item,
  883. val: this[item],
  884. })
  885. })
  886. this.post_data.tag = `${this.click_id}.${this.radio}.resist`
  887. let post_data = {
  888. cmd: 'conf_write',
  889. type: this.post_data.type,
  890. tag: this.post_data.tag,
  891. conf: this.conf,
  892. }
  893. console.log(post_data)
  894. this.$wsk.ws.send(JSON.stringify(post_data))
  895. },
  896. // 测力点变化
  897. radio_change(val) {
  898. this.post_data.tag = `${this.click_id}.${this.radio}.resist`
  899. this.reset_val('no_reset_radio')
  900. return this.get_setting_data()
  901. },
  902. // 状态变化
  903. enable_change(val) {
  904. console.log(val)
  905. },
  906. // 发送获取配置数据
  907. get_setting_data() {
  908. if (!this.click_id) return this.$message.warning('请先选择设备...')
  909. this.post_data.tag = `${this.click_id}.${this.radio}.resist`
  910. this.$wsk.ws.send(JSON.stringify(this.post_data))
  911. // 使用父路由统一接受数据
  912. this.$wsk.ws.onmessage = this.$parent.websocketonmessage
  913. },
  914. // 发送获取name
  915. send_get_name() {
  916. this.get_name.tag = `${this.click_id}`
  917. this.$wsk.ws.send(JSON.stringify(this.get_name))
  918. this.$wsk.ws.onmessage = this.$parent.websocketonmessage
  919. },
  920. // 获取name
  921. get_radio_name(re_msg) {
  922. let radio_list = ['1#', '2#', '3#']
  923. this.rename_list = []
  924. if (re_msg.conf && re_msg.conf.length) {
  925. re_msg.conf.forEach((item, index) => {
  926. this.rename_list.push({
  927. label: radio_list[index],
  928. name: item,
  929. })
  930. })
  931. // console.log(this.rename_list)
  932. return this.get_setting_data()
  933. }
  934. },
  935. // 父路由传过来的配置值
  936. parent_call_setting(re_msg) {
  937. if (!re_msg.conf || !re_msg.conf.length) return
  938. if (re_msg.type.includes('rename')) return this.get_radio_name(re_msg)
  939. return this.get_setting_list(re_msg)
  940. },
  941. // 获取配置数据
  942. get_setting_list(re_msg) {
  943. if (re_msg.tag != this.post_data.tag) return
  944. let key_list = []
  945. switch (this.post_data.type) {
  946. case 'monitor.alarm.max_over_limit':
  947. if (['1#', '2#'].includes(this.radio)) {
  948. key_list = ['enable', 'lock_alarm_high_limit', 'lock_warn_high_limit']
  949. } else {
  950. key_list = [
  951. 'enable',
  952. 'd_alarm_high_limit',
  953. 'd_warn_high_limit',
  954. 'f_alarm_high_limit',
  955. 'f_warn_high_limit',
  956. ]
  957. }
  958. break
  959. case 'monitor.alarm.friction_over_limit':
  960. key_list = [
  961. 'enable',
  962. 'up_alarm_low_limit',
  963. 'up_warn_low_limit',
  964. 'dw_alarm_high_limit',
  965. 'dw_warn_high_limit',
  966. ]
  967. break
  968. default:
  969. break
  970. }
  971. if (re_msg.conf && re_msg.conf.length) {
  972. key_list.forEach(key => {
  973. this[key] = re_msg.conf.find(item => item.name == key).val
  974. })
  975. }
  976. },
  977. /**报警配置结束*/
  978. // 获取站数据
  979. get_conf_read() {
  980. conf_read()
  981. .then(res => {
  982. this.station_tree = [res]
  983. return this.filterTree(this.station_tree)
  984. })
  985. .catch(e => {
  986. console.log(e)
  987. })
  988. // 获取设备列表
  989. equip_list()
  990. .then(res => {
  991. res.forEach(item => {
  992. item['mo_mp'] = `${item.mo}.${item.mp}`
  993. })
  994. this.equip_list_data = res
  995. })
  996. .catch(e => {
  997. console.log(e)
  998. })
  999. },
  1000. // 返回
  1001. go_back() {
  1002. this.$store.state.defaultActive = '/layout/alarm_management'
  1003. this.$store.commit('handle_save_defaultActive', '/layout/alarm_management')
  1004. this.$router.push('/layout/alarm_management')
  1005. },
  1006. // 展开站
  1007. filterTree(data) {
  1008. for (let i = 0; i < data.length; i++) {
  1009. if (data[i].children && data[i].children.length != 0) {
  1010. for (let j = 0; j < data[i].children.length; j++) {
  1011. if (data[i].children[j].children && data[i].children[j].children.length != 0) {
  1012. for (let k = 0; k < data[i].children[j].children.length; k++) {
  1013. if (
  1014. data[i].children[j].children[k].children &&
  1015. data[i].children[j].children[k].children.length != 0
  1016. ) {
  1017. for (let l = 0; l < data[i].children[j].children[k].children.length; l++) {
  1018. this.defaultShowNodes.push(data[i].children[j].children[k].children[l].id)
  1019. }
  1020. }
  1021. }
  1022. }
  1023. }
  1024. }
  1025. }
  1026. },
  1027. // 左侧树结构筛选转辙机
  1028. filterNode(value, data, node) {
  1029. if (!value) return true
  1030. return this.checkBelongToChooseNode(value, data, node)
  1031. },
  1032. // 判断传入的节点是不是选中节点的子节点
  1033. checkBelongToChooseNode(value, data, node) {
  1034. if (data.name.indexOf(value) !== -1) {
  1035. return true
  1036. }
  1037. const level = node.level
  1038. // 如果传入的节点本身就是一级节点就不用校验了
  1039. if (level === 1) {
  1040. return false
  1041. }
  1042. // 先取当前节点的父节点
  1043. let parentData = node.parent
  1044. // 遍历当前节点的父节点
  1045. let index = 0
  1046. while (index < level - 1) {
  1047. // 如果匹配到直接返回
  1048. if (parentData.data.name.indexOf(value) != -1) {
  1049. return true
  1050. }
  1051. // 否则的话再往上一层做匹配
  1052. parentData = parentData.parent
  1053. index++
  1054. }
  1055. // 没匹配到返回false
  1056. return false
  1057. },
  1058. // 计算是否禁用
  1059. computed_is_disabled(data) {
  1060. if (data.type == 'mo.mp' && this.$store.state.backend_type == 2) return false
  1061. return data.type == 'mo.mp' && !data['IMEI'] ? true : false
  1062. },
  1063. // 重新计算
  1064. get_resist_move() {
  1065. let starttime = this.$dayjs(this.times[0]).format('YYYY-MM-DD HH:mm:ss')
  1066. let endtime = this.$dayjs(this.times[1]).format('YYYY-MM-DD HH:mm:ss')
  1067. let send_data = {
  1068. mo: this.get_tem.mo,
  1069. mp: this.get_tem.mp,
  1070. starttime,
  1071. endtime,
  1072. tt: +new Date(),
  1073. }
  1074. resist_move(send_data)
  1075. .then(res => {
  1076. this.show_label = false
  1077. this.curve_data.show_label = false
  1078. this.pullInformation = []
  1079. if (!res || !res.data || !res.data.length) {
  1080. if (this.curve_data.curve_data_list.length) {
  1081. this.curve_data.curve_data_list.forEach(item => {
  1082. item.mark_points = []
  1083. })
  1084. }
  1085. this.get_datazoom()
  1086. this.$message.warning('无重新识别扳动后的数据')
  1087. return this.draw_line_curve()
  1088. }
  1089. let isEmpty = res.data.every(item => item.mark_points.length == 0)
  1090. if (isEmpty) {
  1091. if (this.curve_data.curve_data_list.length) {
  1092. this.curve_data.curve_data_list.forEach(item => {
  1093. item.mark_points = []
  1094. })
  1095. }
  1096. this.get_datazoom()
  1097. this.$message.warning('无重新识别扳动后的数据')
  1098. return this.draw_line_curve()
  1099. }
  1100. this.show_label = true
  1101. this.curve_data.show_label = true
  1102. this.pullInformation =
  1103. res.data
  1104. .filter(item => {
  1105. return item.name === '转换阻力曲线'
  1106. })
  1107. .find(item => {
  1108. return item.mark_points
  1109. }).mark_points || []
  1110. if (this.curve_data && this.curve_data.curve_data_list) {
  1111. if (this.curve_data.curve_data_list.length) {
  1112. this.curve_data.curve_data_list.forEach(item => {
  1113. let target_data = res.data.find(ele => ele.name == item.name)
  1114. if (target_data) {
  1115. item.mark_points = target_data.mark_points
  1116. }
  1117. })
  1118. }
  1119. }
  1120. this.get_datazoom()
  1121. return this.draw_line_curve()
  1122. })
  1123. .catch(e => {
  1124. console.log(e)
  1125. })
  1126. },
  1127. isValidNumber(value) {
  1128. // 判断是否为数字或可以转为数字
  1129. if (!isNaN(value)) {
  1130. // 判断是否为整数
  1131. if (Number.isInteger(Number(value))) {
  1132. // 判断是否在指定范围内
  1133. if (value >= 30 && value <= 500) {
  1134. return true
  1135. }
  1136. }
  1137. }
  1138. return false
  1139. },
  1140. // http请求阻力
  1141. get_resist_data(type) {
  1142. let starttime = this.$dayjs(this.times[0]).format('YYYY-MM-DD HH:mm:ss')
  1143. let endtime = this.$dayjs(this.times[1]).format('YYYY-MM-DD HH:mm:ss')
  1144. let send_data = {
  1145. mo: this.get_tem.mo,
  1146. mp: this.get_tem.mp,
  1147. starttime,
  1148. endtime,
  1149. tt: +new Date(),
  1150. }
  1151. if (type == 'all') {
  1152. send_data.threshold = 0
  1153. } else if (type == 'threshold') {
  1154. send_data.threshold = Number(this.threshold_val)
  1155. localStorage.setItem('threshold_val', this.threshold_val)
  1156. } else {
  1157. send_data.threshold = 100
  1158. }
  1159. this.curve_data = new Object()
  1160. let date_num = +new Date()
  1161. this.curve_data.title = this.title
  1162. resist_data(send_data)
  1163. .then(res => {
  1164. console.log(`1.获取数据耗时:${+new Date() - date_num} ms`)
  1165. date_num = +new Date()
  1166. this.pullInformation = []
  1167. if (!res || !res.data || !res.data.length) {
  1168. this.show_chart = false
  1169. this.loading = false
  1170. return this.$message.warning('该范围内无测力数据')
  1171. }
  1172. let isEmpty = res.data.every(item => item.points.length == 0)
  1173. if (isEmpty) {
  1174. this.show_chart = false
  1175. this.loading = false
  1176. return this.$message.warning('该范围内无测力数据')
  1177. }
  1178. this.is_nodata = true
  1179. let num_list = res.data.map(item => item.points.length || 0)
  1180. let sum = num_list.reduce((total, current) => total + current, 0)
  1181. this.curve_data.force_unit = '单位:' + res.unit
  1182. this.curve_data.curve_data_list = _.cloneDeep(res.data)
  1183. if (res.warn_line && res.warn_line.length) {
  1184. this.warn_line_data = _.cloneDeep(res.warn_line)
  1185. this.curve_data.line = _.cloneDeep(res.warn_line)
  1186. }
  1187. this.pullInformation =
  1188. res.data
  1189. .filter(item => {
  1190. return item.name === '转换阻力曲线'
  1191. })
  1192. .find(item => {
  1193. return item.mark_points
  1194. }).mark_points || []
  1195. if (this.pullInformation.length) {
  1196. this.show_label = true
  1197. this.curve_data.show_label = true
  1198. } else {
  1199. this.show_label = false
  1200. this.curve_data.show_label = false
  1201. }
  1202. console.log(`2.处理数据耗时:${+new Date() - date_num} ms`)
  1203. this.draw_line_curve()
  1204. if (res.has_more) {
  1205. this.is_get_more = true
  1206. console.log(`点个数: ${sum}`)
  1207. return this.get_more_data(res.data, send_data, 4, sum)
  1208. }
  1209. })
  1210. .catch(e => {
  1211. this.loading = false
  1212. if (this.show_chart) return this.draw_line_curve()
  1213. console.log(e)
  1214. })
  1215. },
  1216. // 前往历史数据
  1217. localtion_curve_statics() {
  1218. if (!this.get_tem.mo || !this.get_tem.mp)
  1219. return this.$message({
  1220. type: 'warning',
  1221. showClose: true,
  1222. duration: 1500,
  1223. message: '请选择重要信息',
  1224. })
  1225. let route_data = {
  1226. name: 'curve_statistical',
  1227. query: {
  1228. tag: this.click_id,
  1229. time: this.times[0] / 1000,
  1230. endtime: this.times[1] / 1000,
  1231. title: this.title,
  1232. },
  1233. }
  1234. this.$router.push(route_data)
  1235. this.$store.state.defaultActive = '/layout/curve_statistical'
  1236. this.$store.commit('handle_save_defaultActive', '/layout/curve_statistical')
  1237. },
  1238. // 获取更多数据
  1239. get_more_data(data, source, count, points_num) {
  1240. let date_num = +new Date()
  1241. if (!this.is_get_more) return
  1242. if (source.mo != this.get_tem.mo || source.mp != this.get_tem.mp) return
  1243. if (!this.is_get_more) return
  1244. let data_list = data.map(item => {
  1245. if (item.points && item.points.length) {
  1246. return item.points[item.points.length - 1][0]
  1247. }
  1248. })
  1249. if (!this.is_get_more) return
  1250. let last_time = Math.max(...data_list)
  1251. if (!this.is_get_more) return
  1252. let starttime = this.$dayjs(last_time).format('YYYY-MM-DD HH:mm:ss')
  1253. if (!this.is_get_more) return
  1254. let send_data = {
  1255. mo: source.mo,
  1256. mp: source.mp,
  1257. starttime,
  1258. endtime: source.endtime,
  1259. tt: +new Date(),
  1260. threshold: source.threshold,
  1261. }
  1262. if (!this.is_get_more) return
  1263. resist_data(send_data)
  1264. .then(res => {
  1265. if (!this.is_get_more) return
  1266. if (source.mo != this.get_tem.mo || source.mp != this.get_tem.mp) return
  1267. if (!this.is_get_more) return
  1268. let option = this.myCharts.getOption()
  1269. if (!this.is_get_more) return
  1270. option.series.forEach(item => {
  1271. if (!this.is_get_more) return
  1272. res.data.forEach(ele => {
  1273. if (!this.is_get_more) return
  1274. if (item.name == ele.name) {
  1275. if (!this.is_get_more) return
  1276. item.data.push(...ele.points)
  1277. if (!this.is_get_more) return
  1278. }
  1279. })
  1280. })
  1281. if (!this.is_get_more) return
  1282. this.myCharts.setOption(option, false)
  1283. if (!this.is_get_more) return
  1284. let num_list = res.data.map(item => item.points.length || 0)
  1285. let sum = num_list.reduce((total, current) => total + current, 0)
  1286. console.log(
  1287. `${count}.第${count - 3}次获取更多数据并追加绘制耗时:${+new Date() -
  1288. date_num} ms, 本次点个数:${sum}`
  1289. )
  1290. if (res.has_more) {
  1291. if (!this.is_get_more) return
  1292. return this.get_more_data(res.data, send_data, count + 1, points_num + sum)
  1293. }
  1294. console.log(`Tip:获取更多数据结束,总计点个数:${points_num + sum}`)
  1295. this.is_get_more = false
  1296. })
  1297. .catch(e => {
  1298. console.log(e)
  1299. })
  1300. },
  1301. // 点击树结构
  1302. handle_node_click(data, node) {
  1303. if (data.type != 'mo.mp') return
  1304. if (!data['IMEI'] && this.$store.state.backend_type == 1)
  1305. return this.$message.warning('未绑定设备...')
  1306. if (
  1307. this.times[0] == null ||
  1308. this.times[0] == undefined ||
  1309. this.times[1] == null ||
  1310. this.times[1] == undefined
  1311. )
  1312. return this.$message.warning('时间格式有误,请重新选择时间...')
  1313. this.pullInformation = []
  1314. /**浏览记录*/
  1315. if (this.res_time) {
  1316. this.commit_data.dura = +new Date() - this.res_time
  1317. let copy_data = _.cloneDeep(this.commit_data)
  1318. this.send_record(copy_data)
  1319. }
  1320. this.refresh_datas = _.cloneDeep(data)
  1321. this.refresh_nodes = _.cloneDeep(node)
  1322. this.res_time = +new Date()
  1323. this.commit_data.station = node.parent.data.id
  1324. this.commit_data.station_name = node.parent.data.name
  1325. let mo_mp = data.id.split('.')
  1326. let mo_mp_name = data.name.split('.')
  1327. this.commit_data.mo = mo_mp[0]
  1328. this.commit_data.mp = mo_mp[1]
  1329. this.commit_data.mo_name = mo_mp_name[0]
  1330. this.commit_data.mp_name = mo_mp_name[1]
  1331. this.commit_data.time = +new Date()
  1332. this.commit_data.start_time = this.times[0]
  1333. this.commit_data.end_time = this.times[1]
  1334. /**结束*/
  1335. this.show_label = false // 是否显示label
  1336. this.show_switch = false
  1337. this.is_query = false
  1338. this.show_xy = false
  1339. this.click_id = data.id
  1340. this.send_data.tag = data.id + '.resist'
  1341. this.query_hist_confirm.tag = data.id + '.resist'
  1342. this.get_tem.mo = mo_mp[0]
  1343. this.get_tem.mp = mo_mp[1]
  1344. this.get_max_over_tag = data.id
  1345. this.title = data.name
  1346. if (this.myCharts) {
  1347. this.myCharts.dispose()
  1348. this.myCharts = null
  1349. }
  1350. this.show_chart = true
  1351. this.loading = true
  1352. setTimeout(() => {
  1353. return this.get_curve_data()
  1354. }, 16)
  1355. },
  1356. // 刷新/查询数据
  1357. refresh_data() {
  1358. if (!this.refresh_datas || !this.refresh_nodes) return this.$message.warning('请选择重要信息')
  1359. return this.handle_node_click(this.refresh_datas, this.refresh_nodes)
  1360. },
  1361. // 获取警戒线
  1362. get_warnline() {
  1363. let key = ['1#', '2#', '3#']
  1364. let tag = ''
  1365. let get_warn_line = {
  1366. cmd: 'conf_read',
  1367. type: 'monitor.alarm.max_over_limit', // 最大值超限
  1368. tag: '',
  1369. }
  1370. for (let i = 0; i < key.length; i++) {
  1371. get_warn_line.tag = this.get_max_over_tag + '.' + key[i] + '.resist'
  1372. this.$wsk.ws.send(JSON.stringify(get_warn_line))
  1373. }
  1374. },
  1375. // 父路调用的获取警戒线数据
  1376. warnline(re_msg) {
  1377. console.log(re_msg)
  1378. },
  1379. // 父路由layout调用的方法,原先websocket获取阻力数据
  1380. parent_call(re_msg, status) {
  1381. console.log(re_msg)
  1382. },
  1383. // 开始时间变化
  1384. start_time_change(val) {
  1385. let end_time = val + 2 * 60 * 60 * 1000
  1386. this.times = [val, end_time]
  1387. return this.get_curve_data()
  1388. },
  1389. // 结束时间变化
  1390. end_time_change(val) {
  1391. if (val < this.times[0]) return this.$message.warning('结束时间需大于开始时间,请重新选择')
  1392. this.times = [this.times[0], val]
  1393. return this.get_curve_data()
  1394. },
  1395. // 获取曲线数据
  1396. get_curve_data(type) {
  1397. if (!this.send_data.tag) return this.$message.warning('请选择重要信息')
  1398. if (
  1399. this.times[0] == null ||
  1400. this.times[0] == undefined ||
  1401. this.times[1] == null ||
  1402. this.times[1] == undefined
  1403. )
  1404. return this.$message.warning('时间格式有误,请重新选择时间...')
  1405. if (this.times[1] < this.times[0])
  1406. return this.$message.warning('结束时间需大于开始时间,请重新选择')
  1407. if (type == 'threshold') {
  1408. if (!this.isValidNumber(this.threshold_val))
  1409. return this.$message.warning('滤波阈值范围:30≤X≤500,且为整数')
  1410. }
  1411. if (type == 'is_query') {
  1412. this.is_query = false
  1413. }
  1414. this.show_label = false // 是否显示label
  1415. this.show_switch = false
  1416. let starttime = this.$dayjs(this.times[0]).format('YYYY-MM-DD HH:mm:ss')
  1417. let endtime = this.$dayjs(this.times[1]).format('YYYY-MM-DD HH:mm:ss')
  1418. this.send_data.time = `${starttime}~${endtime}`
  1419. if (
  1420. this.send_data.time == 'Invalid Date~Invalid Date' ||
  1421. this.send_data.time.includes('Invalid')
  1422. )
  1423. return this.$message.warning('时间格式有误,请重新选择时间...')
  1424. this.is_get_more = false
  1425. this.get_tem.starttime = starttime
  1426. this.get_tem.endtime = endtime
  1427. this.curve_data = new Object() // 清空上一次的
  1428. this.curve_data.curve_data_list = [] // 重置为空数组
  1429. this.warn_line_data = [] // 警戒线清空
  1430. this.show_chart = true
  1431. this.loading = true
  1432. this.is_nodata = false
  1433. this.curve_data.title = this.title
  1434. console.log(`切换机位:${this.click_id}`)
  1435. console.log(`时间:${starttime}~${endtime}`)
  1436. setTimeout(() => {
  1437. return this.get_resist_data(type)
  1438. }, 16)
  1439. },
  1440. // 获取温度数据
  1441. get_tem_data() {
  1442. this.curve_data.tem_data = []
  1443. this.curve_data.tem_unit = ''
  1444. this.curve_data.show_tem = false
  1445. if (this.$store.state.backend_type == 1) {
  1446. get_tem_curve(this.get_tem)
  1447. .then(res => {
  1448. if (!res.data.length) {
  1449. this.$message.warning('无温度数据...')
  1450. if (!this.show_chart) return
  1451. this.get_datazoom()
  1452. return this.draw_line_curve()
  1453. }
  1454. if (!this.show_chart) {
  1455. this.show_chart = true
  1456. }
  1457. this.is_nodata = true
  1458. this.curve_data.tem_data = [
  1459. {
  1460. name: res.name,
  1461. data: res.data,
  1462. },
  1463. ]
  1464. this.curve_data.show_tem = true
  1465. this.curve_data.tem_unit = res.name + ':' + res.ValueSuffix
  1466. setTimeout(() => {
  1467. this.get_datazoom()
  1468. return this.draw_line_curve()
  1469. }, 160)
  1470. })
  1471. .catch(e => {
  1472. console.log(e)
  1473. })
  1474. } else {
  1475. get_data_temp(this.get_tem)
  1476. .then(res => {
  1477. if (!res.data.length) {
  1478. this.$message.warning('无温度数据...')
  1479. if (!this.show_chart) return
  1480. this.get_datazoom()
  1481. return this.draw_line_curve()
  1482. }
  1483. if (!this.show_chart) {
  1484. this.show_chart = true
  1485. }
  1486. this.is_nodata = true
  1487. this.curve_data.tem_data = [
  1488. {
  1489. name: res.name,
  1490. data: res.data,
  1491. },
  1492. ]
  1493. this.curve_data.show_tem = true
  1494. this.curve_data.tem_unit = res.name + ':' + res.ValueSuffix
  1495. setTimeout(() => {
  1496. this.get_datazoom()
  1497. return this.draw_line_curve()
  1498. }, 160)
  1499. })
  1500. .catch(e => {
  1501. console.log(e)
  1502. })
  1503. }
  1504. },
  1505. // 画图
  1506. draw_line_curve() {
  1507. let date_num = +new Date()
  1508. this.myCharts = this.$echarts.getInstanceByDom(document.getElementById('line_chart'))
  1509. if (this.myCharts == null) {
  1510. this.myCharts = this.$echarts.init(document.getElementById('line_chart'), null, {
  1511. renderer: 'canvas',
  1512. })
  1513. }
  1514. let pos_regex = /定位|1号/
  1515. let inv_regex = /反位|2号/
  1516. let zh_regex = /转换|3号/
  1517. if (this.curve_data.curve_data_list && this.curve_data.curve_data_list.length) {
  1518. this.show_switch = true
  1519. this.curve_data.curve_data_list.forEach(element => {
  1520. if (pos_regex.test(element.name)) element.color = '#a8ff78' // 苹果绿
  1521. if (inv_regex.test(element.name)) element.color = '#FFE000' // 芒果黄
  1522. if (zh_regex.test(element.name)) element.color = '#6DD5FA' // 天空蓝
  1523. })
  1524. }
  1525. let option = forceOption(this.curve_data)
  1526. this.myCharts.off('legendselectchanged') // 解除监听legend事件
  1527. this.myCharts.setOption(option, true) // 重新渲染
  1528. console.log(`3.绘制折线图耗时:${+new Date() - date_num} ms`)
  1529. this.loading = false
  1530. // legend点击事件
  1531. this.myCharts.on('legendselectchanged', params => {
  1532. // if (params.name == '温度') return
  1533. let target_list = this.refer_curve_data.map(item => item.name)
  1534. if (target_list.includes(params.name)) return
  1535. if (!this.warn_line_data.length && !this.refer_curve_data.length) return
  1536. let legend_list = [] // 有哪些数据
  1537. let legend_state = [] // 状态
  1538. let warn_line_data = []
  1539. let refer_curve = []
  1540. let refer_curve_legend = []
  1541. Object.keys(params.selected).forEach(item => {
  1542. if (item != '温度') {
  1543. legend_state.push({
  1544. name: item,
  1545. state: params.selected[item],
  1546. })
  1547. }
  1548. })
  1549. let legend_name = legend_state.filter(item => item.state == true).map(item => item.name)
  1550. if (!legend_name.length) {
  1551. this.curve_data.line = []
  1552. this.curve_data.refer_curve = []
  1553. legend_list = []
  1554. warn_line_data = []
  1555. refer_curve = []
  1556. refer_curve_legend = []
  1557. } else {
  1558. refer_curve_legend = []
  1559. if (legend_name.includes('1号') || legend_name.includes('定位测力曲线')) {
  1560. legend_list.push('定位')
  1561. refer_curve_legend.push('定位')
  1562. }
  1563. if (legend_name.includes('2号') || legend_name.includes('反位测力曲线')) {
  1564. legend_list.push('反位')
  1565. refer_curve_legend.push('反位')
  1566. }
  1567. if (legend_name.includes('3号') || legend_name.includes('转换阻力曲线')) {
  1568. legend_list.push('定扳反', '反扳定')
  1569. refer_curve_legend.push('转换')
  1570. }
  1571. for (let i = 0; i < legend_list.length; i++) {
  1572. let target_data = this.warn_line_data.filter(item => item.label.includes(legend_list[i]))
  1573. warn_line_data.push(...target_data)
  1574. }
  1575. for (let i = 0; i < refer_curve_legend.length; i++) {
  1576. for (let j = 0; j < this.refer_curve_data.length; j++) {
  1577. if (this.refer_curve_data[j].name.indexOf(refer_curve_legend[i]) != -1) {
  1578. refer_curve.push(this.refer_curve_data[j].name)
  1579. }
  1580. }
  1581. }
  1582. }
  1583. if (params.name == '温度') {
  1584. this.curve_data.show_tem = params.selected['温度']
  1585. }
  1586. this.curve_data.line = warn_line_data
  1587. this.get_datazoom()
  1588. let option = forceOption(this.curve_data)
  1589. let result = this.refer_curve_data
  1590. .map(item => item.name)
  1591. .filter(ele => !refer_curve.includes(ele))
  1592. result.forEach(key => {
  1593. option.legend.selected[key] = false
  1594. })
  1595. refer_curve.forEach(key => {
  1596. option.legend.selected[key] = true
  1597. })
  1598. this.myCharts.setOption(option, false)
  1599. })
  1600. window.addEventListener('resize', () => {
  1601. this.myCharts.resize()
  1602. })
  1603. const resizeOb = new ResizeObserver(entries => {
  1604. for (const entry of entries) {
  1605. this.$echarts.getInstanceByDom(entry.target).resize()
  1606. }
  1607. })
  1608. resizeOb.observe(this.$refs.line_echarts)
  1609. },
  1610. // 上下左右移动
  1611. handle_xy(type) {
  1612. switch (type) {
  1613. case 'top':
  1614. this.refer_curve_data.forEach(item => {
  1615. item.data.forEach(ele => {
  1616. ele[1] = ele[1] + 50
  1617. })
  1618. })
  1619. break
  1620. case 'bottom':
  1621. this.refer_curve_data.forEach(item => {
  1622. item.data.forEach(ele => {
  1623. ele[1] = ele[1] - 50
  1624. })
  1625. })
  1626. break
  1627. case 'left':
  1628. this.refer_curve_data.forEach(item => {
  1629. item.data.forEach(ele => {
  1630. ele[0] = ele[0] - 100
  1631. })
  1632. })
  1633. break
  1634. case 'right':
  1635. this.refer_curve_data.forEach(item => {
  1636. item.data.forEach(ele => {
  1637. ele[0] = ele[0] + 80
  1638. })
  1639. })
  1640. break
  1641. }
  1642. this.curve_data.refer_curve = JSON.parse(JSON.stringify(this.refer_curve_data))
  1643. setTimeout(() => {
  1644. this.get_datazoom()
  1645. this.draw_line_curve()
  1646. }, 16)
  1647. },
  1648. // 获取目前缩放层级
  1649. get_datazoom(type) {
  1650. if (!this.myCharts) return
  1651. let optionAfterZoom = this.myCharts.getOption()
  1652. let startValue = optionAfterZoom.dataZoom[0].startValue
  1653. let endValue = optionAfterZoom.dataZoom[0].endValue
  1654. if (type == 'get_value') return { startValue, endValue }
  1655. this.curve_data.start_value = startValue
  1656. this.curve_data.end_value = endValue
  1657. },
  1658. // 设置/获取参考
  1659. handle_refer_curve(type) {
  1660. if (type == 'none') {
  1661. this.curve_data.refer_curve = []
  1662. this.refer_curve_data = []
  1663. this.show_xy = false
  1664. this.get_datazoom()
  1665. return this.draw_line_curve()
  1666. }
  1667. if (!this.pullInformation.length)
  1668. return this.$message.warning(
  1669. `无对应转换阻力峰值信息,不可${type == 'set' ? '设置' : '展示'}参考曲线`
  1670. )
  1671. let optionAfterZoom = this.myCharts.getOption()
  1672. let startValue = optionAfterZoom.dataZoom[0].startValue
  1673. let endValue = optionAfterZoom.dataZoom[0].endValue
  1674. startValue = new Date(startValue).getTime()
  1675. endValue = new Date(endValue).getTime()
  1676. let target_data = this.pullInformation.filter(item => {
  1677. return new Date(item.time).getTime() >= startValue && new Date(item.time).getTime() <= endValue
  1678. })
  1679. if (target_data.length != 1)
  1680. return this.$message.warning(
  1681. `缩放区域内有且只有1个转换阻力峰值时方可${type == 'set' ? '设置' : '展示'}参考曲线`
  1682. )
  1683. target_data = {
  1684. time: target_data[0].time,
  1685. direct: target_data[0].label.includes('反扳定') ? 4 : 3,
  1686. }
  1687. let send_data = {
  1688. station: this.commit_data.station,
  1689. mo: this.commit_data.mo,
  1690. mp: this.commit_data.mp,
  1691. direct: target_data.direct,
  1692. show_time: target_data.time,
  1693. }
  1694. let other_data = {
  1695. mo_name: this.commit_data.mo_name,
  1696. mp_name: this.commit_data.mp_name,
  1697. full_name: this.$store.state.name,
  1698. }
  1699. let set_curve = data => {
  1700. post_refer_curve(data)
  1701. .then(res => {
  1702. let tip = data.show_time ? '设置' : '取消'
  1703. if (tip == '取消') {
  1704. this.curve_data.refer_curve = []
  1705. this.refer_curve_data = []
  1706. this.show_xy = false
  1707. setTimeout(() => {
  1708. this.get_datazoom()
  1709. return this.draw_line_curve()
  1710. }, 16)
  1711. }
  1712. return this.$message.success(`${tip}参考曲线成功!`)
  1713. })
  1714. .catch(e => {
  1715. console.log(e)
  1716. })
  1717. }
  1718. if (type == 'set') {
  1719. // 设置参考曲线
  1720. refer_option(send_data)
  1721. .then(res => {
  1722. this.$confirm('已存在,是否覆盖?', '提示', {
  1723. confirmButtonText: '确定',
  1724. cancelButtonText: '取消',
  1725. type: 'warning',
  1726. showClose: false,
  1727. closeOnClickModal: false,
  1728. closeOnHashChange: false,
  1729. closeOnPressEscape: false,
  1730. })
  1731. .then(() => {
  1732. set_curve({ ...send_data, ...other_data })
  1733. })
  1734. .catch(() => {})
  1735. })
  1736. .catch(e => {
  1737. set_curve({ ...send_data, ...other_data })
  1738. })
  1739. }
  1740. if (type == 'get') {
  1741. // 获取参考曲线
  1742. refer_option(send_data)
  1743. .then(res => {
  1744. this.curve_data.refer_curve = []
  1745. this.refer_curve_data = []
  1746. refer_curve(send_data)
  1747. .then(res => {
  1748. if (res.data.length) {
  1749. this.show_xy = true
  1750. this.refer_curve_data = res.data
  1751. this.curve_data.refer_curve = JSON.parse(JSON.stringify(this.refer_curve_data))
  1752. }
  1753. setTimeout(() => {
  1754. this.get_datazoom()
  1755. return this.draw_line_curve()
  1756. }, 16)
  1757. })
  1758. .catch(e => {
  1759. console.log(e)
  1760. })
  1761. })
  1762. .catch(e => {
  1763. return this.$message.warning('无参考曲线,请先设置')
  1764. })
  1765. }
  1766. if (type == 'cancel') {
  1767. // 取消参考
  1768. refer_option(send_data)
  1769. .then(res => {
  1770. this.$confirm('取消参考曲线将无法撤销此操作, 是否继续?', '提示', {
  1771. confirmButtonText: '确定',
  1772. cancelButtonText: '取消',
  1773. type: 'warning',
  1774. showClose: false,
  1775. closeOnClickModal: false,
  1776. closeOnHashChange: false,
  1777. closeOnPressEscape: false,
  1778. })
  1779. .then(() => {
  1780. send_data.show_time = ''
  1781. set_curve({ ...send_data, ...other_data })
  1782. })
  1783. .catch(() => {})
  1784. })
  1785. .catch(e => {
  1786. return this.$message.warning('无参考曲线,操作无效')
  1787. })
  1788. }
  1789. },
  1790. // 判断URL中是否有参数
  1791. url_is_query() {
  1792. if (this.$route.query.tag) {
  1793. let query = this.$route.query
  1794. return this.format_query(query)
  1795. }
  1796. return this.get_time()
  1797. },
  1798. // 解析query
  1799. format_query(query) {
  1800. this.is_query = true
  1801. let tag = query.tag.split('.')
  1802. let title = query.title
  1803. if (tag.length == 3) {
  1804. tag.splice(-1, 1)
  1805. }
  1806. this.get_tem.mo = tag[0]
  1807. this.get_tem.mp = tag[1]
  1808. this.send_data.tag = tag.join('.') + '.resist'
  1809. this.query_hist_confirm.tag = tag.join('.') + '.resist'
  1810. this.click_id = query.tag
  1811. if (!query.time) {
  1812. this.get_max_over_tag = tag.join('.')
  1813. this.get_time()
  1814. this.show_chart = true
  1815. this.loading = true
  1816. this.title = title
  1817. setTimeout(() => {
  1818. this.get_curve_data()
  1819. }, 150)
  1820. return
  1821. }
  1822. let time = null,
  1823. start_time = null,
  1824. end_time = null
  1825. if (query.time && query.endtime) {
  1826. start_time = query.time * 1000
  1827. end_time = query.endtime * 1000
  1828. } else {
  1829. time = this.$dayjs(query.time).unix()
  1830. start_time = (time - 600) * 1000
  1831. end_time = (time + 600) * 1000
  1832. }
  1833. this.times = [start_time, end_time]
  1834. this.title = tag.join('.')
  1835. if (title) this.title = title
  1836. if (query.alarm_layer) {
  1837. let content = query.alarm_layer.split('.')
  1838. this.title = content[1] + '.' + content[2]
  1839. }
  1840. setTimeout(() => {
  1841. if (this.title.includes('.')) {
  1842. let target_search = this.title.split('.')
  1843. this.search_data = target_search[0]
  1844. } else {
  1845. this.search_data = this.title
  1846. }
  1847. }, 300)
  1848. this.get_max_over_tag = tag.join('.')
  1849. this.show_chart = true
  1850. this.loading = true
  1851. setTimeout(() => {
  1852. this.get_curve_data()
  1853. }, 100)
  1854. },
  1855. // 获取默认时间
  1856. get_time() {
  1857. console.log(1)
  1858. let threshold_val = localStorage.getItem('threshold_val')
  1859. if (threshold_val) this.threshold_val = Number(threshold_val)
  1860. let start_times = this.$dayjs().format('YYYY-MM-DD 00:00:00')
  1861. let end_times = this.$dayjs().format('YYYY-MM-DD 23:59:59')
  1862. start_times = this.$dayjs(start_times).valueOf()
  1863. end_times = this.$dayjs(end_times).valueOf()
  1864. this.times = [start_times, end_times]
  1865. // let unix_time = this.$dayjs(times).unix() * 1000
  1866. // this.times = [unix_time - 2 * 60 * 60 * 1000, unix_time]
  1867. // this.times = [1714764900000, 1714766100000] // 2024年5月4号有数据
  1868. // this.times = [1716307200000, 1716393600000] // 2024年5月22~23号有数据
  1869. // this.times = [1715961600000, 1716048000000] // 2024年5月18~19号有数据
  1870. // this.times = [1715988120000, 1715988540000] // 2024年5月18~19号7点数据
  1871. },
  1872. // 发送浏览记录
  1873. send_record(commit_data) {
  1874. if (commit_data.dura <= 500) return
  1875. if (!commit_data.station || !commit_data.station_name) return
  1876. if (!commit_data.mo || !commit_data.mo_name) return
  1877. if (!commit_data.mp || !commit_data.mp_name) return
  1878. commit_record([commit_data])
  1879. .then(res => {})
  1880. .catch(e => {})
  1881. },
  1882. // 离开界面时
  1883. leave_page() {
  1884. if (!this.res_time) return
  1885. this.commit_data.dura = +new Date() - this.res_time
  1886. let copy_data = _.cloneDeep(this.commit_data)
  1887. return this.send_record(copy_data)
  1888. },
  1889. },
  1890. mounted() {
  1891. this.get_conf_read()
  1892. this.url_is_query()
  1893. },
  1894. beforeDestroy() {
  1895. // this.myCharts.clear()
  1896. this.leave_page()
  1897. },
  1898. // 监听路由变化
  1899. beforeRouteUpdate(to, from, next) {
  1900. this.leave_page()
  1901. return this.format_query(to.query)
  1902. },
  1903. }
  1904. </script>
  1905. <style lang="scss">
  1906. .station_tree {
  1907. .el-tree--highlight-current .el-tree-node.is-current > .el-tree-node__content {
  1908. background-color: transparent;
  1909. }
  1910. }
  1911. </style>
  1912. <style lang="scss" scoped>
  1913. @import '../../static/css/force.scss';
  1914. </style>