调整编组内容数字跟着变化

This commit is contained in:
zyy 2020-10-13 16:19:13 +08:00
parent 912af6424d
commit eb87177bae
4 changed files with 52 additions and 5 deletions

View File

@ -33,8 +33,8 @@ class Iscs {
const height = opts.config.height; const height = opts.config.height;
this.isAllowDragging = false; this.isAllowDragging = false;
this.$iscsZr = zrender.init(opts.dom, Object.assign({ renderer, devicePixelRatio, width, height }, opts.config)); this.$iscsZr = zrender.init(opts.dom, Object.assign({ renderer, devicePixelRatio, width, height }, opts.config));
this.$iscsZr.dom.setAttribute('tabIndex', -1); this.$iscsZr.dom.setAttribute('tabIndex', -1);
this.$options = new Options(Object.assign({ scaleRate: 1, offsetX: 0, offsetY: 0 }, opts.options || {})); // 缩放 this.$options = new Options(Object.assign({ scaleRate: 1, offsetX: 0, offsetY: 0 }, opts.options || {})); // 缩放
this.$mouseController = new MouseController(this); this.$mouseController = new MouseController(this);
this.$mouseController.enable(); this.$mouseController.enable();

View File

@ -18,6 +18,10 @@ export default class text extends Group {
id: model.code, id: model.code,
position: [model.point.x, model.point.y] position: [model.point.x, model.point.y]
}); });
let text = model.context;
if (model.unit) {
text = model.context + model.unit;
}
this.textName = new Text({ this.textName = new Text({
zlevel: model.zlevel, zlevel: model.zlevel,
z: model.z, z: model.z,
@ -28,7 +32,7 @@ export default class text extends Group {
fontWeight: model.fontWeight, fontWeight: model.fontWeight,
fontSize: model.fontSize, fontSize: model.fontSize,
fontFamily: 'consolas', fontFamily: 'consolas',
text: model.context, text: text,
textStrokeWidth: model.textStrokeWidth, textStrokeWidth: model.textStrokeWidth,
textFill: model.textFill, textFill: model.textFill,
textAlign: model.textAlign || 'center', textAlign: model.textAlign || 'center',

View File

@ -1,4 +1,5 @@
import elType from './elType'; import elType from './elType';
import iscs from '../iscs';
export default { export default {
[elType.A.lab]: { [elType.A.lab]: {
@ -31,11 +32,46 @@ export default {
defval: 'stateA', defval: 'stateA',
stateMap: { stateMap: {
stateA: { stateA: {
context: '8.3' context: ''
}, },
stateB: { 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;
}

View File

@ -4,6 +4,9 @@
<el-form-item label="文字内容:" prop="context"> <el-form-item label="文字内容:" prop="context">
<el-input v-model="form.context" type="textarea" size="small" /> <el-input v-model="form.context" type="textarea" size="small" />
</el-form-item> </el-form-item>
<el-form-item label="单位:" prop="unit">
<el-input v-model="form.unit" type="text" size="small" />
</el-form-item>
<el-form-item label="文字颜色:" prop="textFill"> <el-form-item label="文字颜色:" prop="textFill">
<el-color-picker v-model="form.textFill" size="small" /> <el-color-picker v-model="form.textFill" size="small" />
</el-form-item> </el-form-item>
@ -58,6 +61,7 @@ export default {
form: { form: {
code: '', code: '',
context: '', context: '',
unit: '',
textFill: '', textFill: '',
fontSize: 14, fontSize: 14,
fontWeight: 450, fontWeight: 450,
@ -108,6 +112,7 @@ export default {
this.isUpdate = true; this.isUpdate = true;
this.form.code = model.code; this.form.code = model.code;
this.form.context = model.context; this.form.context = model.context;
this.form.unit = model.unit || '';
this.form.fontSize = model.fontSize; this.form.fontSize = model.fontSize;
this.form.fontWeight = model.fontWeight; this.form.fontWeight = model.fontWeight;
this.form.textFill = model.textFill; this.form.textFill = model.textFill;
@ -134,6 +139,7 @@ export default {
code: this.isUpdate ? this.form.code : getUID('IscsText', this.iscs.iscsTextList), code: this.isUpdate ? this.form.code : getUID('IscsText', this.iscs.iscsTextList),
_type: 'IscsText', _type: 'IscsText',
context: this.form.context, context: this.form.context,
unit: this.form.unit,
textFill: this.form.textFill, textFill: this.form.textFill,
fontSize: this.form.fontSize, fontSize: this.form.fontSize,
fontWeight: this.form.fontWeight, fontWeight: this.form.fontWeight,
@ -174,6 +180,7 @@ export default {
this.form = { this.form = {
code: '', code: '',
context: '', context: '',
unit: '',
textFill: '', textFill: '',
fontSize: 14, fontSize: 14,
fontWeight: 450, fontWeight: 450,