From eb87177bae3fc7d206958d7551d1256dc8b383a7 Mon Sep 17 00:00:00 2001
From: zyy <1787816799@qq.com>
Date: Tue, 13 Oct 2020 16:19:13 +0800
Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=BC=96=E7=BB=84=E5=86=85?=
=?UTF-8?q?=E5=AE=B9=E6=95=B0=E5=AD=97=E8=B7=9F=E7=9D=80=E5=8F=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/iscs/iscs.js | 4 +-
src/iscs/shape/text.js | 6 ++-
src/iscs/status/mapElement.js | 40 ++++++++++++++++++-
.../iscs/iscsDraw/icscComponents/text.vue | 7 ++++
4 files changed, 52 insertions(+), 5 deletions(-)
diff --git a/src/iscs/iscs.js b/src/iscs/iscs.js
index 21b94f746..c590a1b82 100644
--- a/src/iscs/iscs.js
+++ b/src/iscs/iscs.js
@@ -33,8 +33,8 @@ class Iscs {
const height = opts.config.height;
this.isAllowDragging = false;
this.$iscsZr = zrender.init(opts.dom, Object.assign({ renderer, devicePixelRatio, width, height }, opts.config));
- this.$iscsZr.dom.setAttribute('tabIndex', -1);
- this.$options = new Options(Object.assign({ scaleRate: 1, offsetX: 0, offsetY: 0 }, opts.options || {})); // 缩放
+ this.$iscsZr.dom.setAttribute('tabIndex', -1);
+ this.$options = new Options(Object.assign({ scaleRate: 1, offsetX: 0, offsetY: 0 }, opts.options || {})); // 缩放
this.$mouseController = new MouseController(this);
this.$mouseController.enable();
diff --git a/src/iscs/shape/text.js b/src/iscs/shape/text.js
index 1969de132..6341ed541 100644
--- a/src/iscs/shape/text.js
+++ b/src/iscs/shape/text.js
@@ -18,6 +18,10 @@ export default class text extends Group {
id: model.code,
position: [model.point.x, model.point.y]
});
+ let text = model.context;
+ if (model.unit) {
+ text = model.context + model.unit;
+ }
this.textName = new Text({
zlevel: model.zlevel,
z: model.z,
@@ -28,7 +32,7 @@ export default class text extends Group {
fontWeight: model.fontWeight,
fontSize: model.fontSize,
fontFamily: 'consolas',
- text: model.context,
+ text: text,
textStrokeWidth: model.textStrokeWidth,
textFill: model.textFill,
textAlign: model.textAlign || 'center',
diff --git a/src/iscs/status/mapElement.js b/src/iscs/status/mapElement.js
index 1eca0bf7c..66e128dec 100644
--- a/src/iscs/status/mapElement.js
+++ b/src/iscs/status/mapElement.js
@@ -1,4 +1,5 @@
import elType from './elType';
+import iscs from '../iscs';
export default {
[elType.A.lab]: {
@@ -31,11 +32,46 @@ export default {
defval: 'stateA',
stateMap: {
stateA: {
- context: '8.3'
+ context: ''
},
stateB: {
- context: '7.6'
+ context: ''
}
}
} // 数组
};
+const arrNumA = [2.9, 8.1, 9.4, 1.8, 2.8, 9.4, 7.6, 6.8, 5.8, 9.8, 8.5];
+const arrNumV = [1657.0, 1558.3, 1768.8, 2486.3, 584.0];
+const arrNumKV = [45.8, 57.4, 67.1, 25.8, 34.8, 48.1];
+const arrNumKW = [113.5, 178.0, 254.6, 157.6, 135.7];
+const arrNumMVar = [0.254, 0.54, 0.971, 1.257];
+
+export function setNum(groupList) {
+ groupList.forEach(group => {
+ group.elemList.forEach(el => {
+ switch (el.type) {
+ case elType.C.lab:
+ switch (iscs.iscsDevice[el.code].unit) {
+ case 'A':
+ el.context = Math.floor(Math.random() * arrNumA.length + 1) - 1;
+ break;
+ case 'V':
+ el.context = Math.floor(Math.random() * arrNumV.length + 1) - 1;
+ break;
+ case 'KV':
+ el.context = Math.floor(Math.random() * arrNumKV.length + 1) - 1;
+ break;
+ case 'KW':
+ el.context = Math.floor(Math.random() * arrNumKW.length + 1) - 1;
+ break;
+ case 'MVar':
+ el.context = Math.floor(Math.random() * arrNumMVar.length + 1) - 1;
+ break;
+ }
+ break;
+ }
+ });
+ });
+
+ return groupList;
+}
diff --git a/src/views/iscs/iscsDraw/icscComponents/text.vue b/src/views/iscs/iscsDraw/icscComponents/text.vue
index 17fa17cbb..834576f80 100644
--- a/src/views/iscs/iscsDraw/icscComponents/text.vue
+++ b/src/views/iscs/iscsDraw/icscComponents/text.vue
@@ -4,6 +4,9 @@
+
+
+
@@ -58,6 +61,7 @@ export default {
form: {
code: '',
context: '',
+ unit: '',
textFill: '',
fontSize: 14,
fontWeight: 450,
@@ -108,6 +112,7 @@ export default {
this.isUpdate = true;
this.form.code = model.code;
this.form.context = model.context;
+ this.form.unit = model.unit || '';
this.form.fontSize = model.fontSize;
this.form.fontWeight = model.fontWeight;
this.form.textFill = model.textFill;
@@ -134,6 +139,7 @@ export default {
code: this.isUpdate ? this.form.code : getUID('IscsText', this.iscs.iscsTextList),
_type: 'IscsText',
context: this.form.context,
+ unit: this.form.unit,
textFill: this.form.textFill,
fontSize: this.form.fontSize,
fontWeight: this.form.fontWeight,
@@ -174,6 +180,7 @@ export default {
this.form = {
code: '',
context: '',
+ unit: '',
textFill: '',
fontSize: 14,
fontWeight: 450,