Force.vue 63 KB

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