Commit 269f2df1 authored by 李纪文's avatar 李纪文

feat: 组态增加动画、画板跳转增加权限

parent 8af1687e
...@@ -29,6 +29,7 @@ import WaterFlowControlView from './js/WaterFlowControlView'; ...@@ -29,6 +29,7 @@ import WaterFlowControlView from './js/WaterFlowControlView';
import ConfigurationDetail from './js/ConfigurationDetail'; import ConfigurationDetail from './js/ConfigurationDetail';
import DragModal from './js/DragModal'; import DragModal from './js/DragModal';
import { import {
authorizationToken,
getSketchPadList, getSketchPadList,
getSketchPadContent, getSketchPadContent,
getPointAddress, getPointAddress,
...@@ -246,9 +247,43 @@ const ConfigurationView = (props) => { ...@@ -246,9 +247,43 @@ const ConfigurationView = (props) => {
break; break;
case 'valCase': // 实时值模型 case 'valCase': // 实时值模型
const division = node.division || false; const division = node.division || false;
// 动画翻转 const animType = node.animType || '';
if (node.effect) // 动画
myDiagram.model.setDataProperty(node, 'flip', go.GraphObject.FlipHorizontal); if (node.effect) {
try {
const nodes = myDiagram.findNodeForKey(node.key);
const textBlocks = nodes.findObject('textBlocks');
let animation = null;
switch (animType) {
case 'flip':
myDiagram.model.setDataProperty(node, 'flip', go.GraphObject.FlipHorizontal);
// 动画还原
myTimeout(() => {
myDiagram.model.setDataProperty(node, 'flip', go.GraphObject.None);
}, 100);
break;
case 'scale':
animation = new go.Animation();
animation.add(textBlocks, 'scale', 0.5, 1);
animation.duration = 100;
animation.start();
break;
case 'opacity':
animation = new go.Animation();
animation.add(textBlocks, 'opacity', 0.5, 1);
animation.duration = 100;
animation.start();
break;
default:
myDiagram.model.setDataProperty(node, 'flip', go.GraphObject.FlipHorizontal);
// 动画还原
myTimeout(() => {
myDiagram.model.setDataProperty(node, 'flip', go.GraphObject.None);
}, 100);
break;
}
} catch (e) {}
}
if (node.shType === '值显示') { if (node.shType === '值显示') {
myDiagram.model.setDataProperty( myDiagram.model.setDataProperty(
node, node,
...@@ -262,10 +297,6 @@ const ConfigurationView = (props) => { ...@@ -262,10 +297,6 @@ const ConfigurationView = (props) => {
division ? realVal.toLocaleString() : realVal, division ? realVal.toLocaleString() : realVal,
); );
} }
// 动画还原
myTimeout(() => {
myDiagram.model.setDataProperty(node, 'flip', go.GraphObject.None);
}, 100);
// 颜色规则 // 颜色规则
if (node.stateName) return false; if (node.stateName) return false;
shRule = ruleOperation(node, realVal); shRule = ruleOperation(node, realVal);
...@@ -1325,7 +1356,7 @@ const ConfigurationView = (props) => { ...@@ -1325,7 +1356,7 @@ const ConfigurationView = (props) => {
}; };
/** **************************************权限控制确认****************************************** */ /** **************************************权限控制确认****************************************** */
const defineAutho = (code, tag, node, guid, value) => { const defineAutho = (code, tag, node, guid, value, type) => {
const { userName, password } = AuthorFrom.current.getFieldsValue(true); const { userName, password } = AuthorFrom.current.getFieldsValue(true);
if (!userName || !password) { if (!userName || !password) {
message.warning('用户名或密码不能为空!'); message.warning('用户名或密码不能为空!');
...@@ -1345,18 +1376,18 @@ const ConfigurationView = (props) => { ...@@ -1345,18 +1376,18 @@ const ConfigurationView = (props) => {
code, code,
tag, tag,
value, value,
flag ? value * 1 : '', type === '输入控制' ? value : flag ? value * 1 : '',
); );
}; };
/** **************************************权限控制方法****************************************** */ /** **************************************权限控制方法****************************************** */
const authoMethod = async (code, tag, node, guid, value) => { const authoMethod = async (code, tag, node, guid, value, type) => {
const { people = '' } = node; const { people = '' } = node;
const userName = const userName =
people === '当前用户' || globalControl ? globalConfig?.userInfo?.loginName || '' : ''; people === '当前用户' || globalControl ? globalConfig?.userInfo?.loginName || '' : '';
setCurrentUser(userName); setCurrentUser(userName);
setIsAuModalVisible(true); setIsAuModalVisible(true);
auModalConfirmFn = () => defineAutho(code, tag, node, guid, value); auModalConfirmFn = () => defineAutho(code, tag, node, guid, value, type);
}; };
// 查看密码 // 查看密码
...@@ -1364,6 +1395,40 @@ const ConfigurationView = (props) => { ...@@ -1364,6 +1395,40 @@ const ConfigurationView = (props) => {
setViewType(!viewType); setViewType(!viewType);
}; };
/** **************************************跳转权限方法****************************************** */
const jumpAuthoMethod = async (people) => {
const userName =
people === '当前用户' || globalControl ? globalConfig?.userInfo?.loginName || '' : '';
setCurrentUser(userName);
setIsAuModalVisible(true);
auModalConfirmFn = () => jumpAuthoConfirm();
};
// 跳转权限确认
const jumpAuthoConfirm = () => {
const { userName, password } = AuthorFrom.current.getFieldsValue(true);
if (!userName || !password) {
message.warning('用户名或密码不能为空!');
return false;
}
authorizationToken({
loginName: userName,
password: encipher(password).toUpperCase(),
type: 'password',
})
.then((res) => {
if (res.code === 0) {
setIsAuModalVisible(false);
setIsJumpModalVisible(true);
} else {
message.warning(res?.msg || '权限认证失败,请重试!');
}
})
.catch((err) => {
message.warning('权限认证失败,请重试!');
});
};
/** **************************************开关控制确定****************************************** */ /** **************************************开关控制确定****************************************** */
const defineSwitch = (code, tag, node) => { const defineSwitch = (code, tag, node) => {
const guid = createGuid(); const guid = createGuid();
...@@ -1422,7 +1487,7 @@ const ConfigurationView = (props) => { ...@@ -1422,7 +1487,7 @@ const ConfigurationView = (props) => {
const guid = createGuid(); const guid = createGuid();
setIsModalVisible(false); setIsModalVisible(false);
if (node.isControl === '') { if (node.isControl === '') {
authoMethod(code, tag, node, guid, value); authoMethod(code, tag, node, guid, isNumber(value * 1) ? value * 1 : value, '输入控制');
return false; return false;
} }
guidAggre[guid] = { tag, code }; guidAggre[guid] = { tag, code };
...@@ -1621,6 +1686,8 @@ const ConfigurationView = (props) => { ...@@ -1621,6 +1686,8 @@ const ConfigurationView = (props) => {
const width = opRule && opRule.width ? opRule.width : ''; const width = opRule && opRule.width ? opRule.width : '';
const height = opRule && opRule.height ? opRule.height : ''; const height = opRule && opRule.height ? opRule.height : '';
const color = opRule && opRule.color ? opRule.color : '#282d3b'; const color = opRule && opRule.color ? opRule.color : '#282d3b';
const auth = opRule && opRule.auth ? opRule.auth : false;
const people = opRule && opRule.people ? opRule.people : '';
if (!name) return false; if (!name) return false;
const deviceArr = []; const deviceArr = [];
device.forEach((item) => { device.forEach((item) => {
...@@ -1637,6 +1704,7 @@ const ConfigurationView = (props) => { ...@@ -1637,6 +1704,7 @@ const ConfigurationView = (props) => {
device: deviceArr, device: deviceArr,
color, color,
}; };
if (auth) return jumpAuthoMethod(people);
setIsJumpModalVisible(true); setIsJumpModalVisible(true);
}; };
...@@ -2553,6 +2621,7 @@ const ConfigurationView = (props) => { ...@@ -2553,6 +2621,7 @@ const ConfigurationView = (props) => {
go.TextBlock, go.TextBlock,
textStyle(), textStyle(),
{ {
name: 'textBlocks',
maxSize: new go.Size(NaN, NaN), maxSize: new go.Size(NaN, NaN),
minSize: new go.Size(NaN, 1), minSize: new go.Size(NaN, 1),
wrap: go.TextBlock.WrapFit, wrap: go.TextBlock.WrapFit,
......
/*
* @Author: ljiwen
* @Date: 2024-09-19 15:42:23
* @Description:
* @FilePath: \wisdom-components\packages\extend-components\EC_ConfigurationView\src\demos\Basic.tsx
*/
import React, { useState } from 'react'; import React, { useState } from 'react';
import { Button } from 'antd'; import { Button } from 'antd';
import PandaConfiguration from '../index'; import PandaConfiguration from '../index';
...@@ -52,8 +58,6 @@ const Demo = () => { ...@@ -52,8 +58,6 @@ const Demo = () => {
export default Demo; export default Demo;
const globalConfig = { const globalConfig = {
mqtt_account: 'panda',
mqtt_password: '6FC08E462A0C87953CD3DB4706462E4B',
token: 'a1372ef0ce7b4e4884d31cfd99fe92f6', token: 'a1372ef0ce7b4e4884d31cfd99fe92f6',
mqtt_iotIP: 'emqttd10.panda-water.cn:443', mqtt_iotIP: 'emqttd10.panda-water.cn:443',
mqtt_path: '/mqtt', mqtt_path: '/mqtt',
......
No preview for this file type
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