Commit 9b6bda81 authored by 李纪文's avatar 李纪文

feat: 组态实时值增加单位设置

parent d4cfd50a
...@@ -1289,10 +1289,10 @@ const ConfigurationView = (props) => { ...@@ -1289,10 +1289,10 @@ const ConfigurationView = (props) => {
const padding = v ? v.split(',') : null; const padding = v ? v.split(',') : null;
return padding return padding
? new go.Margin( ? new go.Margin(
padding[0] * 1 || 0, padding?.[0] * 1 || 0,
padding[1] * 1 || 0, padding?.[1] * 1 || 0,
padding[2] * 1 || 0, padding?.[2] * 1 || 0,
padding[3] * 1 || 0, padding?.[3] * 1 || 0,
) )
: 0; : 0;
}).makeTwoWay(), }).makeTwoWay(),
...@@ -1915,35 +1915,77 @@ const ConfigurationView = (props) => { ...@@ -1915,35 +1915,77 @@ const ConfigurationView = (props) => {
new go.Binding('angle').makeTwoWay(), new go.Binding('angle').makeTwoWay(),
roleVisibleBinding(), // 绑定角色可见 roleVisibleBinding(), // 绑定角色可见
goJS( goJS(
go.Shape, go.Panel,
'RoundedRectanglePlus', 'Horizontal',
{ name: 'SHAPE', strokeWidth: 10, stroke: '#000000', parameter1: 0 }, goJS(
new go.Binding('fill', 'fillColor'), go.Panel,
new go.Binding('stroke'), 'Auto',
new go.Binding('strokeWidth'), goJS(
new go.Binding('parameter1', 'radius').makeTwoWay(), go.Shape,
new go.Binding('desiredSize', 'size', go.Size.parse).makeTwoWay(go.Size.stringify), 'RoundedRectanglePlus',
), { name: 'SHAPE', strokeWidth: 10, stroke: '#000000', parameter1: 0 },
goJS( new go.Binding('fill', 'fillColor'),
go.TextBlock, new go.Binding('stroke'),
textStyle(), new go.Binding('strokeWidth'),
{ new go.Binding('parameter1', 'radius').makeTwoWay(),
maxSize: new go.Size(NaN, NaN), new go.Binding('desiredSize', 'size', go.Size.parse).makeTwoWay(go.Size.stringify),
minSize: new go.Size(NaN, 1), ),
wrap: go.TextBlock.WrapFit, goJS(
textAlign: 'center', go.TextBlock,
editable: true, textStyle(),
font: 'bold 12px Helvetica, Arial, sans-serif', {
stroke: '#454545', maxSize: new go.Size(NaN, NaN),
flip: go.GraphObject.None, minSize: new go.Size(NaN, 1),
}, wrap: go.TextBlock.WrapFit,
new go.Binding('text', 'showVal'), textAlign: 'center',
new go.Binding('font', 'fontStyle'), editable: true,
new go.Binding('stroke', 'fontStroke'), font: 'bold 12px Helvetica, Arial, sans-serif',
new go.Binding('textAlign', 'fontAlign'), stroke: '#454545',
new go.Binding('maxSize', 'textSize'), flip: go.GraphObject.None,
new go.Binding('minSize', 'textSize'), },
new go.Binding('flip', 'flip'), new go.Binding('text', 'showVal'),
new go.Binding('font', 'fontStyle'),
new go.Binding('stroke', 'fontStroke'),
new go.Binding('textAlign', 'fontAlign'),
new go.Binding('maxSize', 'textSize'),
new go.Binding('minSize', 'textSize'),
new go.Binding('flip', 'flip'),
),
),
goJS(
go.TextBlock,
textStyle(),
{
wrap: go.TextBlock.WrapFit,
textAlign: 'center',
editable: false,
font: 'normal 10px Helvetica,Arial,sans-serif',
stroke: '#ffffff',
},
new go.Binding('text', 'unitText'),
new go.Binding('font', '', (v) => {
return `normal ${v?.unitSize || 10}pt ${
v?.unitStyle || 'Helvetica,Arial,sans-serif'
}`;
}),
new go.Binding('stroke', 'unitColor'),
new go.Binding('visible', '', (v) => {
return (v?.unitSwitch && !!v?.unitText) || false;
}),
new go.Binding('margin', '', (v) => {
const unitGap = v?.unitGap || '0,0,0,5';
if (unitGap && isNumber(unitGap)) return unitGap;
const margin = unitGap?.split(',') || null;
return margin
? new go.Margin(
margin?.[0] * 1 || 0,
margin?.[1] * 1 || 0,
margin?.[2] * 1 || 0,
margin?.[3] * 1 || 0,
)
: 0;
}),
),
), ),
{ {
click(e, node) { click(e, node) {
......
...@@ -1856,10 +1856,10 @@ const ConfigurationView = (props) => { ...@@ -1856,10 +1856,10 @@ const ConfigurationView = (props) => {
const padding = v ? v.split(',') : null; const padding = v ? v.split(',') : null;
return padding return padding
? new go.Margin( ? new go.Margin(
padding[0] * 1 || 0, padding?.[0] * 1 || 0,
padding[1] * 1 || 0, padding?.[1] * 1 || 0,
padding[2] * 1 || 0, padding?.[2] * 1 || 0,
padding[3] * 1 || 0, padding?.[3] * 1 || 0,
) )
: 0; : 0;
}).makeTwoWay(), }).makeTwoWay(),
...@@ -2532,35 +2532,77 @@ const ConfigurationView = (props) => { ...@@ -2532,35 +2532,77 @@ const ConfigurationView = (props) => {
new go.Binding('angle').makeTwoWay(), new go.Binding('angle').makeTwoWay(),
roleVisibleBinding(), // 绑定角色可见 roleVisibleBinding(), // 绑定角色可见
goJS( goJS(
go.Shape, go.Panel,
'RoundedRectanglePlus', 'Horizontal',
{ name: 'SHAPE', strokeWidth: 10, stroke: '#000000', parameter1: 0 }, goJS(
new go.Binding('fill', 'fillColor'), go.Panel,
new go.Binding('stroke'), 'Auto',
new go.Binding('strokeWidth'), goJS(
new go.Binding('parameter1', 'radius').makeTwoWay(), go.Shape,
new go.Binding('desiredSize', 'size', go.Size.parse).makeTwoWay(go.Size.stringify), 'RoundedRectanglePlus',
), { name: 'SHAPE', strokeWidth: 10, stroke: '#000000', parameter1: 0 },
goJS( new go.Binding('fill', 'fillColor'),
go.TextBlock, new go.Binding('stroke'),
textStyle(), new go.Binding('strokeWidth'),
{ new go.Binding('parameter1', 'radius').makeTwoWay(),
maxSize: new go.Size(NaN, NaN), new go.Binding('desiredSize', 'size', go.Size.parse).makeTwoWay(go.Size.stringify),
minSize: new go.Size(NaN, 1), ),
wrap: go.TextBlock.WrapFit, goJS(
textAlign: 'center', go.TextBlock,
editable: true, textStyle(),
font: 'bold 12px Helvetica, Arial, sans-serif', {
stroke: '#454545', maxSize: new go.Size(NaN, NaN),
flip: go.GraphObject.None, minSize: new go.Size(NaN, 1),
}, wrap: go.TextBlock.WrapFit,
new go.Binding('text', 'showVal'), textAlign: 'center',
new go.Binding('font', 'fontStyle'), editable: true,
new go.Binding('stroke', 'fontStroke'), font: 'bold 12px Helvetica, Arial, sans-serif',
new go.Binding('textAlign', 'fontAlign'), stroke: '#454545',
new go.Binding('maxSize', 'textSize'), flip: go.GraphObject.None,
new go.Binding('minSize', 'textSize'), },
new go.Binding('flip', 'flip'), new go.Binding('text', 'showVal'),
new go.Binding('font', 'fontStyle'),
new go.Binding('stroke', 'fontStroke'),
new go.Binding('textAlign', 'fontAlign'),
new go.Binding('maxSize', 'textSize'),
new go.Binding('minSize', 'textSize'),
new go.Binding('flip', 'flip'),
),
),
goJS(
go.TextBlock,
textStyle(),
{
wrap: go.TextBlock.WrapFit,
textAlign: 'center',
editable: false,
font: 'normal 10px Helvetica,Arial,sans-serif',
stroke: '#ffffff',
},
new go.Binding('text', 'unitText'),
new go.Binding('font', '', (v) => {
return `normal ${v?.unitSize || 10}pt ${
v?.unitStyle || 'Helvetica,Arial,sans-serif'
}`;
}),
new go.Binding('stroke', 'unitColor'),
new go.Binding('visible', '', (v) => {
return (v?.unitSwitch && !!v?.unitText) || false;
}),
new go.Binding('margin', '', (v) => {
const unitGap = v?.unitGap || '0,0,0,5';
if (unitGap && isNumber(unitGap)) return unitGap;
const margin = unitGap?.split(',') || null;
return margin
? new go.Margin(
margin?.[0] * 1 || 0,
margin?.[1] * 1 || 0,
margin?.[2] * 1 || 0,
margin?.[3] * 1 || 0,
)
: 0;
}),
),
), ),
{ {
click(e, node) { click(e, node) {
......
...@@ -1862,10 +1862,10 @@ const ConfigurationView = (props) => { ...@@ -1862,10 +1862,10 @@ const ConfigurationView = (props) => {
const padding = v ? v.split(',') : null; const padding = v ? v.split(',') : null;
return padding return padding
? new go.Margin( ? new go.Margin(
padding[0] * 1 || 0, padding?.[0] * 1 || 0,
padding[1] * 1 || 0, padding?.[1] * 1 || 0,
padding[2] * 1 || 0, padding?.[2] * 1 || 0,
padding[3] * 1 || 0, padding?.[3] * 1 || 0,
) )
: 0; : 0;
}).makeTwoWay(), }).makeTwoWay(),
...@@ -2538,35 +2538,77 @@ const ConfigurationView = (props) => { ...@@ -2538,35 +2538,77 @@ const ConfigurationView = (props) => {
new go.Binding('angle').makeTwoWay(), new go.Binding('angle').makeTwoWay(),
roleVisibleBinding(), // 绑定角色可见 roleVisibleBinding(), // 绑定角色可见
goJS( goJS(
go.Shape, go.Panel,
'RoundedRectanglePlus', 'Horizontal',
{ name: 'SHAPE', strokeWidth: 10, stroke: '#000000', parameter1: 0 }, goJS(
new go.Binding('fill', 'fillColor'), go.Panel,
new go.Binding('stroke'), 'Auto',
new go.Binding('strokeWidth'), goJS(
new go.Binding('parameter1', 'radius').makeTwoWay(), go.Shape,
new go.Binding('desiredSize', 'size', go.Size.parse).makeTwoWay(go.Size.stringify), 'RoundedRectanglePlus',
), { name: 'SHAPE', strokeWidth: 10, stroke: '#000000', parameter1: 0 },
goJS( new go.Binding('fill', 'fillColor'),
go.TextBlock, new go.Binding('stroke'),
textStyle(), new go.Binding('strokeWidth'),
{ new go.Binding('parameter1', 'radius').makeTwoWay(),
maxSize: new go.Size(NaN, NaN), new go.Binding('desiredSize', 'size', go.Size.parse).makeTwoWay(go.Size.stringify),
minSize: new go.Size(NaN, 1), ),
wrap: go.TextBlock.WrapFit, goJS(
textAlign: 'center', go.TextBlock,
editable: true, textStyle(),
font: 'bold 12px Helvetica, Arial, sans-serif', {
stroke: '#454545', maxSize: new go.Size(NaN, NaN),
flip: go.GraphObject.None, minSize: new go.Size(NaN, 1),
}, wrap: go.TextBlock.WrapFit,
new go.Binding('text', 'showVal'), textAlign: 'center',
new go.Binding('font', 'fontStyle'), editable: true,
new go.Binding('stroke', 'fontStroke'), font: 'bold 12px Helvetica, Arial, sans-serif',
new go.Binding('textAlign', 'fontAlign'), stroke: '#454545',
new go.Binding('maxSize', 'textSize'), flip: go.GraphObject.None,
new go.Binding('minSize', 'textSize'), },
new go.Binding('flip', 'flip'), new go.Binding('text', 'showVal'),
new go.Binding('font', 'fontStyle'),
new go.Binding('stroke', 'fontStroke'),
new go.Binding('textAlign', 'fontAlign'),
new go.Binding('maxSize', 'textSize'),
new go.Binding('minSize', 'textSize'),
new go.Binding('flip', 'flip'),
),
),
goJS(
go.TextBlock,
textStyle(),
{
wrap: go.TextBlock.WrapFit,
textAlign: 'center',
editable: false,
font: 'normal 10px Helvetica,Arial,sans-serif',
stroke: '#ffffff',
},
new go.Binding('text', 'unitText'),
new go.Binding('font', '', (v) => {
return `normal ${v?.unitSize || 10}pt ${
v?.unitStyle || 'Helvetica,Arial,sans-serif'
}`;
}),
new go.Binding('stroke', 'unitColor'),
new go.Binding('visible', '', (v) => {
return (v?.unitSwitch && !!v?.unitText) || false;
}),
new go.Binding('margin', '', (v) => {
const unitGap = v?.unitGap || '0,0,0,5';
if (unitGap && isNumber(unitGap)) return unitGap;
const margin = unitGap?.split(',') || null;
return margin
? new go.Margin(
margin?.[0] * 1 || 0,
margin?.[1] * 1 || 0,
margin?.[2] * 1 || 0,
margin?.[3] * 1 || 0,
)
: 0;
}),
),
), ),
{ {
click(e, node) { click(e, node) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment