You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

threshold.vue 24 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  1. <!--
  2. Copyright 2020 Huawei Technologies Co., Ltd.All Rights Reserved.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. -->
  13. <script>
  14. export default {
  15. data() {
  16. return {
  17. thresholdDialogVisible: false,
  18. delThresholdVisible: false,
  19. currentTagName: '',
  20. currentSample: {},
  21. thresholdErrorMsg: '',
  22. thresholdRelational: '',
  23. thresholdValue: [
  24. { filterCondition: this.$t('scalar.lessThan'), value: '' },
  25. { filterCondition: this.$t('scalar.lessThan'), value: '' },
  26. ],
  27. filterOptions: [
  28. {
  29. value: this.$t('scalar.lessThan'),
  30. label: this.$t('scalar.lessThan'),
  31. },
  32. {
  33. value: this.$t('scalar.greaterThan'),
  34. label: this.$t('scalar.greaterThan'),
  35. },
  36. ],
  37. thresholdLocal: null,
  38. thresholdSwitch: false,
  39. delThresholdSwitch: false,
  40. thresholdColor: '#f00',
  41. };
  42. },
  43. methods: {
  44. /**
  45. * Get localStorge
  46. */
  47. getCache() {
  48. if (localStorage.getItem('thresholdCache')) {
  49. try {
  50. this.thresholdLocal = JSON.parse(
  51. localStorage.getItem('thresholdCache')
  52. );
  53. this.clearCache();
  54. } catch (e) {
  55. localStorage.removeItem('thresholdCache');
  56. this.thresholdLocal = {};
  57. }
  58. } else {
  59. this.thresholdLocal = {};
  60. }
  61. },
  62. /**
  63. * Clear localStorge
  64. */
  65. clearCache() {
  66. if (
  67. this.thresholdLocal &&
  68. this.thresholdLocal[this.decodeTrainingJobId]
  69. ) {
  70. if (
  71. Object.keys(this.thresholdLocal[this.decodeTrainingJobId]).length ===
  72. 0
  73. ) {
  74. delete this.thresholdLocal[this.decodeTrainingJobId];
  75. localStorage.setItem(
  76. 'thresholdCache',
  77. JSON.stringify(this.thresholdLocal)
  78. );
  79. }
  80. }
  81. },
  82. /**
  83. * Set one point style
  84. * @param {Object} sampleObject
  85. */
  86. setOnePoint(sampleObject) {
  87. const that = this;
  88. sampleObject.charObj.on('datazoom', function (params) {
  89. const xAxisObject = params.batch[0];
  90. const yAxisObject = params.batch[1];
  91. const charData = sampleObject.charData.charOption.series[0].data;
  92. const tempCharOption = sampleObject.charData.charOption;
  93. // one point
  94. if (charData.length === 1) {
  95. sampleObject.onePoint = true;
  96. tempCharOption.series[0].showSymbol = true;
  97. sampleObject.charObj.setOption(tempCharOption, false);
  98. return;
  99. }
  100. let filtetArr = [];
  101. for (let i = 0; i < charData.length; i++) {
  102. if (
  103. Math.ceil(charData[i][0] * 10000) / 10000 >=
  104. xAxisObject.startValue &&
  105. Math.floor(charData[i][0] * 10000) / 10000 <=
  106. xAxisObject.endValue &&
  107. Math.ceil(charData[i][1] * 10000) / 10000 >=
  108. yAxisObject.startValue &&
  109. Math.floor(charData[i][1] * 10000) / 10000 <= yAxisObject.endValue
  110. ) {
  111. filtetArr.push(charData[i]);
  112. if (filtetArr.length > 1) {
  113. filtetArr = [];
  114. break;
  115. }
  116. }
  117. }
  118. if (filtetArr.length === 1) {
  119. sampleObject.onePoint = true;
  120. tempCharOption.series[0].showSymbol = true;
  121. } else {
  122. sampleObject.onePoint = false;
  123. tempCharOption.series[0].showSymbol = false;
  124. }
  125. if (
  126. tempCharOption.visualMap &&
  127. tempCharOption.visualMap['pieces'] &&
  128. tempCharOption.visualMap['pieces'].length > 0
  129. ) {
  130. tempCharOption.visualMap = null;
  131. tempCharOption.series[0].markLine = null;
  132. that.updateVisualMap(sampleObject);
  133. } else {
  134. sampleObject.charObj.setOption(tempCharOption, false);
  135. }
  136. });
  137. },
  138. /**
  139. * Set restore
  140. * @param {Object} sampleObject
  141. */
  142. setRestore(sampleObject) {
  143. const that = this;
  144. sampleObject.charObj.on('restore', function (params) {
  145. const charData = sampleObject.charData.charOption.series[0].data;
  146. const tempCharOption = sampleObject.charData.charOption;
  147. // One point
  148. if (charData.length === 1) {
  149. sampleObject.onePoint = true;
  150. tempCharOption.series[0].showSymbol = true;
  151. sampleObject.charObj.setOption(tempCharOption, false);
  152. return;
  153. }
  154. sampleObject.onePoint = false;
  155. tempCharOption.series[0].showSymbol = false;
  156. if (
  157. tempCharOption.visualMap &&
  158. tempCharOption.visualMap['pieces'] &&
  159. tempCharOption.visualMap['pieces'].length > 0
  160. ) {
  161. tempCharOption.visualMap = null;
  162. tempCharOption.series[0].markLine = null;
  163. that.updateVisualMap(sampleObject);
  164. } else {
  165. sampleObject.charObj.setOption(tempCharOption, false);
  166. }
  167. });
  168. },
  169. /**
  170. * Update visualMap
  171. * @param {Object} sampleObject
  172. */
  173. updateVisualMap(sampleObject) {
  174. this.getCache();
  175. if (
  176. this.thresholdLocal &&
  177. this.thresholdLocal[this.decodeTrainingJobId] &&
  178. this.thresholdLocal[this.decodeTrainingJobId][sampleObject.tagName]
  179. ) {
  180. const tempStorgeArr = JSON.parse(
  181. JSON.stringify(
  182. this.thresholdLocal[this.decodeTrainingJobId][sampleObject.tagName]
  183. )
  184. );
  185. let pieceStr = '';
  186. pieceStr = this.formatePieceStr(tempStorgeArr);
  187. sampleObject.pieceStr = pieceStr;
  188. tempStorgeArr.forEach((item) => {
  189. item.color = this.thresholdColor;
  190. });
  191. if (sampleObject.charObj) {
  192. this.setVisualMap(sampleObject, tempStorgeArr);
  193. }
  194. } else {
  195. sampleObject.pieceStr = '';
  196. sampleObject.charData.charOption.series[0].markLine = null;
  197. }
  198. },
  199. /**
  200. * Set threshold
  201. * @param {Object} sampleItem sampleItem
  202. */
  203. setThreshold(sampleItem) {
  204. this.stopUpdateSamples();
  205. this.getCache();
  206. if (
  207. this.thresholdLocal &&
  208. this.thresholdLocal[this.decodeTrainingJobId] &&
  209. this.thresholdLocal[this.decodeTrainingJobId][sampleItem.tagName]
  210. ) {
  211. delete this.thresholdLocal[this.decodeTrainingJobId][
  212. sampleItem.tagName
  213. ];
  214. }
  215. this.currentTagName = sampleItem.tagName;
  216. this.currentSample = sampleItem;
  217. this.thresholdDialogVisible = true;
  218. },
  219. /**
  220. * Delete threshold
  221. * @param {Object} sampleItem sampleItem
  222. */
  223. delThreshold(sampleItem) {
  224. this.stopUpdateSamples();
  225. this.currentTagName = sampleItem.tagName;
  226. this.currentSample = sampleItem;
  227. this.delThresholdVisible = true;
  228. },
  229. /**
  230. * Threshold validate
  231. */
  232. thresholdValidate() {
  233. let isValidate = true;
  234. const valueFirst = this.thresholdValue[0].value;
  235. const valueSec = this.thresholdValue[1].value;
  236. const filterConditionFirst = this.thresholdValue[0].filterCondition;
  237. const filterConditionSec = this.thresholdValue[1].filterCondition;
  238. if (!this.thresholdRelational) {
  239. if (!valueFirst) {
  240. this.thresholdErrorMsg = this.$t('scalar.placeHolderThreshold');
  241. isValidate = false;
  242. } else if (valueFirst.indexOf(' ') > -1) {
  243. this.thresholdErrorMsg = this.$t('scalar.noSpace');
  244. isValidate = false;
  245. } else if (isNaN(valueFirst) || valueFirst.indexOf('Infinity') > -1) {
  246. this.thresholdErrorMsg = this.$t('scalar.placeHolderNumber');
  247. isValidate = false;
  248. }
  249. } else {
  250. if (filterConditionFirst === filterConditionSec) {
  251. this.thresholdErrorMsg = this.$t('scalar.sameCompare');
  252. isValidate = false;
  253. } else if (!valueFirst || !valueSec) {
  254. this.thresholdErrorMsg = this.$t('scalar.placeHolderThreshold');
  255. isValidate = false;
  256. } else if (valueFirst.indexOf(' ') > -1 || valueSec.indexOf(' ') > -1) {
  257. this.thresholdErrorMsg = this.$t('scalar.noSpace');
  258. isValidate = false;
  259. } else if (valueFirst === valueSec) {
  260. this.thresholdErrorMsg = this.$t('scalar.unreasonable');
  261. isValidate = false;
  262. } else if (isNaN(valueFirst) || isNaN(valueSec)) {
  263. this.thresholdErrorMsg = this.$t('scalar.placeHolderNumber');
  264. isValidate = false;
  265. } else if (
  266. valueFirst.indexOf('Infinity') > -1 ||
  267. valueSec.indexOf('Infinity') > -1
  268. ) {
  269. this.thresholdErrorMsg = this.$t('scalar.placeHolderNumber');
  270. isValidate = false;
  271. } else {
  272. if (this.thresholdRelational === this.$t('scalar.or')) {
  273. if (
  274. filterConditionFirst === this.$t('scalar.greaterThan') &&
  275. Number(valueFirst) < Number(valueSec)
  276. ) {
  277. this.thresholdErrorMsg = this.$t('scalar.unreasonable');
  278. isValidate = false;
  279. } else if (
  280. filterConditionFirst === this.$t('scalar.lessThan') &&
  281. Number(valueFirst) > Number(valueSec)
  282. ) {
  283. this.thresholdErrorMsg = this.$t('scalar.unreasonable');
  284. isValidate = false;
  285. }
  286. }
  287. if (this.thresholdRelational === this.$t('scalar.and')) {
  288. if (
  289. filterConditionFirst === this.$t('scalar.greaterThan') &&
  290. Number(valueFirst) > Number(valueSec)
  291. ) {
  292. this.thresholdErrorMsg = this.$t('scalar.unreasonable');
  293. isValidate = false;
  294. } else if (
  295. filterConditionFirst === this.$t('scalar.lessThan') &&
  296. Number(valueFirst) < Number(valueSec)
  297. ) {
  298. this.thresholdErrorMsg = this.$t('scalar.unreasonable');
  299. isValidate = false;
  300. }
  301. }
  302. }
  303. }
  304. return isValidate;
  305. },
  306. /**
  307. * Set visualMap
  308. * @param {Object} sampleObject SampleObject
  309. * @param {Array} chartPieces ChartPieces
  310. */
  311. setVisualMap(sampleObject, chartPieces) {
  312. // Empty array
  313. if (chartPieces.length === 0) {
  314. return;
  315. }
  316. const markLineData = [];
  317. chartPieces.forEach((item) => {
  318. if (!isNaN(item.lt)) {
  319. const markLineDataItem = {};
  320. markLineDataItem.yAxis = item.lt;
  321. markLineData.push(markLineDataItem);
  322. }
  323. if (!isNaN(item.gt)) {
  324. const markLineDataItem = {};
  325. markLineDataItem.yAxis = item.gt;
  326. markLineData.push(markLineDataItem);
  327. }
  328. });
  329. const tempCharOption = sampleObject.charData.charOption;
  330. let chartPiecesTemp = JSON.parse(JSON.stringify(chartPieces));
  331. chartPiecesTemp.forEach((item) => {
  332. item.color = this.thresholdColor;
  333. });
  334. // One filter condition
  335. if (chartPiecesTemp.length === 1) {
  336. if (
  337. !isNaN(chartPiecesTemp[0]['lt']) &&
  338. isNaN(chartPiecesTemp[0]['gt'])
  339. ) {
  340. if (chartPiecesTemp[0]['lt'] <= sampleObject.zoomData[0]) {
  341. chartPiecesTemp = [];
  342. } else if (
  343. chartPiecesTemp[0]['lt'] < sampleObject.zoomData[1] &&
  344. chartPiecesTemp[0]['lt'] > sampleObject.zoomData[0]
  345. ) {
  346. chartPiecesTemp[0]['gt'] = sampleObject.zoomData[0];
  347. } else if (chartPiecesTemp[0]['lt'] >= sampleObject.zoomData[1]) {
  348. chartPiecesTemp[0]['lt'] = sampleObject.zoomData[1];
  349. chartPiecesTemp[0]['gt'] = sampleObject.zoomData[0];
  350. }
  351. } else if (
  352. !isNaN(chartPiecesTemp[0]['gt']) &&
  353. isNaN(chartPiecesTemp[0]['lt'])
  354. ) {
  355. if (chartPiecesTemp[0]['gt'] >= sampleObject.zoomData[1]) {
  356. chartPiecesTemp = [];
  357. } else if (
  358. chartPiecesTemp[0]['gt'] > sampleObject.zoomData[0] &&
  359. chartPiecesTemp[0]['gt'] < sampleObject.zoomData[1]
  360. ) {
  361. chartPiecesTemp[0]['lt'] = sampleObject.zoomData[1];
  362. } else if (chartPiecesTemp[0]['gt'] <= sampleObject.zoomData[0]) {
  363. chartPiecesTemp[0]['lt'] = sampleObject.zoomData[1];
  364. chartPiecesTemp[0]['gt'] = sampleObject.zoomData[0];
  365. }
  366. } else if (
  367. !isNaN(chartPiecesTemp[0]['lt']) &&
  368. !isNaN(chartPiecesTemp[0]['gt'])
  369. ) {
  370. if (chartPiecesTemp[0]['gt'] >= sampleObject.zoomData[1]) {
  371. chartPiecesTemp = [];
  372. } else {
  373. if (chartPiecesTemp[0]['gt'] <= sampleObject.zoomData[0]) {
  374. chartPiecesTemp[0]['gt'] = sampleObject.zoomData[0];
  375. }
  376. if (chartPiecesTemp[0]['lt'] >= sampleObject.zoomData[1]) {
  377. chartPiecesTemp[0]['lt'] = sampleObject.zoomData[1];
  378. }
  379. if (chartPiecesTemp[0]['lt'] <= sampleObject.zoomData[0]) {
  380. chartPiecesTemp = [];
  381. }
  382. }
  383. }
  384. }
  385. // Two filter condition
  386. if (chartPiecesTemp.length === 2) {
  387. const relationalArr = [];
  388. relationalArr[0] = chartPiecesTemp[0].lt || chartPiecesTemp[1].lt || 0;
  389. relationalArr[1] = chartPiecesTemp[0].gt || chartPiecesTemp[1].gt || 0;
  390. if (
  391. relationalArr[0] >= sampleObject.zoomData[1] ||
  392. relationalArr[1] <= sampleObject.zoomData[0]
  393. ) {
  394. chartPiecesTemp = [
  395. {
  396. gt: sampleObject.zoomData[0],
  397. lt: sampleObject.zoomData[1],
  398. color: this.thresholdColor,
  399. },
  400. ];
  401. } else {
  402. if (relationalArr[0] <= sampleObject.zoomData[0]) {
  403. if (!isNaN(chartPiecesTemp[0].lt)) {
  404. chartPiecesTemp[0].lt = sampleObject.zoomData[0];
  405. } else {
  406. chartPiecesTemp[1].lt = sampleObject.zoomData[0];
  407. }
  408. }
  409. if (relationalArr[1] >= sampleObject.zoomData[1]) {
  410. if (!isNaN(chartPiecesTemp[0].gt)) {
  411. chartPiecesTemp[0].gt = sampleObject.zoomData[1];
  412. } else {
  413. chartPiecesTemp[1].gt = sampleObject.zoomData[1];
  414. }
  415. }
  416. }
  417. }
  418. if (chartPiecesTemp.length > 0) {
  419. tempCharOption.series[0].lineStyle['color'] = null;
  420. tempCharOption.visualMap = {};
  421. tempCharOption.visualMap['show'] = false;
  422. tempCharOption.visualMap['pieces'] = chartPiecesTemp;
  423. tempCharOption.visualMap['outOfRange'] = {
  424. color: sampleObject.colors,
  425. };
  426. tempCharOption.series[0]['markLine'] = {
  427. precision: 5,
  428. silent: true,
  429. data: markLineData,
  430. };
  431. sampleObject.charObj.setOption(tempCharOption, false);
  432. } else {
  433. tempCharOption.series[0].lineStyle['color'] = sampleObject.colors;
  434. sampleObject.charObj.setOption(tempCharOption, false);
  435. }
  436. },
  437. /**
  438. * Formate pieceStr
  439. * @param {Array} piecesArr PiecesArr
  440. * @return {String}
  441. */
  442. formatePieceStr(piecesArr) {
  443. // Empty array
  444. if (piecesArr.length === 0) {
  445. return;
  446. }
  447. piecesArr.forEach((item) => {
  448. if (item.lt) {
  449. item.lt = Number(item.lt.toFixed(5));
  450. }
  451. if (item.gt) {
  452. item.gt = Number(item.gt.toFixed(5));
  453. }
  454. });
  455. let pieceStr;
  456. // Only one filter condition
  457. if (piecesArr.length === 1) {
  458. if (!isNaN(piecesArr[0].gt) && !isNaN(piecesArr[0].lt)) {
  459. pieceStr = `(${piecesArr[0].gt},${piecesArr[0].lt})`;
  460. } else if (!isNaN(piecesArr[0].gt) && isNaN(piecesArr[0].lt)) {
  461. pieceStr = `(${piecesArr[0].gt},Infinity)`;
  462. } else if (!isNaN(piecesArr[0].lt) && isNaN(piecesArr[0].gt)) {
  463. pieceStr = `(-Infinity,${piecesArr[0].lt})`;
  464. }
  465. }
  466. // Two filter condition
  467. if (piecesArr.length === 2) {
  468. if (!isNaN(piecesArr[0].lt) && !isNaN(piecesArr[1].gt)) {
  469. pieceStr = `(-Infinity,${piecesArr[0].lt}),(${piecesArr[1].gt},Infinity)`;
  470. } else if (!isNaN(piecesArr[0].gt) && !isNaN(piecesArr[1].lt)) {
  471. pieceStr = `(-Infinity,${piecesArr[1].lt}),(${piecesArr[0].gt},Infinity)`;
  472. }
  473. }
  474. return pieceStr;
  475. },
  476. /**
  477. * Threshold commit
  478. */
  479. thresholdCommit() {
  480. const isValidate = this.thresholdValidate();
  481. if (isValidate) {
  482. const chartPieces = [];
  483. if (this.thresholdValue[0].value && this.thresholdValue[1].value) {
  484. if (this.thresholdRelational === this.$t('scalar.or')) {
  485. this.thresholdValue.forEach((item) => {
  486. const chartPiecesData = {};
  487. if (item.filterCondition === this.$t('scalar.greaterThan')) {
  488. chartPiecesData.gt = Number(item.value);
  489. chartPieces.push(chartPiecesData);
  490. } else {
  491. chartPiecesData.lt = Number(item.value);
  492. chartPieces.push(chartPiecesData);
  493. }
  494. });
  495. } else {
  496. const tempArr = [];
  497. const chartPiecesData = {};
  498. this.thresholdValue.forEach((item) => {
  499. tempArr.push(item.value);
  500. });
  501. if (Number(tempArr[0]) > Number(tempArr[1])) {
  502. chartPiecesData.gt = Number(tempArr[1]);
  503. chartPiecesData.lt = Number(tempArr[0]);
  504. chartPieces.push(chartPiecesData);
  505. } else {
  506. chartPiecesData.gt = Number(tempArr[0]);
  507. chartPiecesData.lt = Number(tempArr[1]);
  508. chartPieces.push(chartPiecesData);
  509. }
  510. }
  511. } else {
  512. this.thresholdValue.forEach((item) => {
  513. const chartPiecesData = {};
  514. if (!item.value) {
  515. return;
  516. } else if (item.filterCondition === this.$t('scalar.greaterThan')) {
  517. chartPiecesData.gt = Number(item.value);
  518. chartPieces.push(chartPiecesData);
  519. } else if (item.filterCondition === this.$t('scalar.lessThan')) {
  520. chartPiecesData.lt = Number(item.value);
  521. chartPieces.push(chartPiecesData);
  522. }
  523. });
  524. }
  525. let pieceStr = '';
  526. pieceStr = this.formatePieceStr(chartPieces);
  527. if (!this.thresholdLocal) {
  528. this.thresholdLocal = {};
  529. }
  530. if (!this.thresholdLocal[this.decodeTrainingJobId]) {
  531. this.thresholdLocal[this.decodeTrainingJobId] = {};
  532. }
  533. const chartPiecesTemp = JSON.parse(JSON.stringify(chartPieces));
  534. chartPiecesTemp.forEach((item) => {
  535. item.color = this.thresholdColor;
  536. });
  537. if (this.thresholdSwitch) {
  538. this.originDataArr.forEach((sampleObject) => {
  539. if (this.multiSelectedTagNames[sampleObject.tagName]) {
  540. this.thresholdLocal[this.decodeTrainingJobId][
  541. sampleObject.tagName
  542. ] = chartPieces;
  543. sampleObject.pieceStr = pieceStr;
  544. if (sampleObject.charObj) {
  545. this.setVisualMap(sampleObject, chartPieces);
  546. }
  547. }
  548. });
  549. } else {
  550. this.thresholdLocal[this.decodeTrainingJobId][
  551. this.currentTagName
  552. ] = chartPieces;
  553. this.currentSample.pieceStr = pieceStr;
  554. this.setVisualMap(this.currentSample, chartPieces);
  555. }
  556. localStorage.setItem(
  557. 'thresholdCache',
  558. JSON.stringify(this.thresholdLocal)
  559. );
  560. this.thresholdDialogVisible = false;
  561. }
  562. },
  563. /**
  564. * Relational change
  565. */
  566. relationalChange(val) {
  567. if (!val) {
  568. this.thresholdValue[1].value = '';
  569. this.thresholdErrorMsg = '';
  570. this.thresholdValue[1].filterCondition = this.$t('scalar.lessThan');
  571. }
  572. },
  573. /**
  574. * Threshold cancel
  575. */
  576. thresholdCancel() {
  577. this.thresholdValue[0].value = '';
  578. this.thresholdValue[1].value = '';
  579. this.thresholdErrorMsg = '';
  580. this.currentTagName = '';
  581. this.currentSample = {};
  582. this.thresholdSwitch = false;
  583. this.thresholdRelational = '';
  584. this.thresholdValue[1].filterCondition = this.$t('scalar.lessThan');
  585. this.thresholdDialogVisible = false;
  586. if (this.isTimeReload) {
  587. this.autoUpdateSamples();
  588. }
  589. },
  590. /**
  591. * Delete threshold cancel
  592. */
  593. delThresholdCancel() {
  594. this.currentTagName = '';
  595. this.currentSample = {};
  596. this.delThresholdSwitch = false;
  597. this.delThresholdVisible = false;
  598. if (this.isTimeReload) {
  599. this.autoUpdateSamples();
  600. }
  601. },
  602. /**
  603. * Delete threshold commit
  604. */
  605. delThresholdCommit() {
  606. this.getCache();
  607. if (this.delThresholdSwitch) {
  608. this.originDataArr.forEach((sampleObject) => {
  609. if (this.multiSelectedTagNames[sampleObject.tagName]) {
  610. if (
  611. this.thresholdLocal &&
  612. this.thresholdLocal[this.decodeTrainingJobId] &&
  613. this.thresholdLocal[this.decodeTrainingJobId][
  614. sampleObject.tagName
  615. ]
  616. ) {
  617. delete this.thresholdLocal[this.decodeTrainingJobId][
  618. sampleObject.tagName
  619. ];
  620. sampleObject.pieceStr = '';
  621. const tempCharOption = sampleObject.charData.charOption;
  622. if (
  623. tempCharOption.visualMap &&
  624. tempCharOption.visualMap['pieces'] &&
  625. tempCharOption.visualMap['pieces'].length > 0
  626. ) {
  627. tempCharOption.visualMap = null;
  628. tempCharOption.series[0].markLine = null;
  629. tempCharOption.series[0].lineStyle['color'] =
  630. sampleObject.colors;
  631. }
  632. if (sampleObject.charObj) {
  633. sampleObject.charObj.setOption(tempCharOption, false);
  634. }
  635. }
  636. }
  637. });
  638. } else {
  639. if (
  640. this.thresholdLocal &&
  641. this.thresholdLocal[this.decodeTrainingJobId] &&
  642. this.thresholdLocal[this.decodeTrainingJobId][this.currentTagName]
  643. ) {
  644. delete this.thresholdLocal[this.decodeTrainingJobId][
  645. this.currentTagName
  646. ];
  647. this.currentSample.pieceStr = '';
  648. const tempCharOption = this.currentSample.charData.charOption;
  649. if (
  650. tempCharOption.visualMap &&
  651. tempCharOption.visualMap['pieces'] &&
  652. tempCharOption.visualMap['pieces'].length > 0
  653. ) {
  654. tempCharOption.visualMap = null;
  655. tempCharOption.series[0].markLine = null;
  656. tempCharOption.series[0].lineStyle[
  657. 'color'
  658. ] = this.currentSample.colors;
  659. }
  660. this.currentSample.charObj.setOption(tempCharOption, false);
  661. }
  662. }
  663. this.clearCache();
  664. localStorage.setItem(
  665. 'thresholdCache',
  666. JSON.stringify(this.thresholdLocal)
  667. );
  668. this.delThresholdVisible = false;
  669. },
  670. },
  671. };
  672. </script>