Commit 66c76dee authored by 李纪文's avatar 李纪文

fix: 修改组态查看组件

parent 0eef04ee
......@@ -120,9 +120,12 @@ export default {
},
proxy: {
'/api': {
target: 'http://192.168.12.71:8080',
target: 'http://192.168.10.150:8669',
changeOrigin: true,
pathRewrite: { '^/api': '' },
},
},
define: {
DUMI_TYPE: 'dumi',
},
};
......@@ -17,6 +17,7 @@ const Demo = (props) => {
<DatePickerCustom onChange={onChange} picker="date" style={{ marginRight: '10px' }} />
<DatePickerCustom onChange={onChange} picker="week" style={{ marginRight: '10px' }} />
<DatePickerCustom onChange={onChange} picker="month" style={{ marginRight: '10px' }} />
<DatePickerCustom onChange={onChange} picker="quarter" style={{ marginRight: '10px' }} />
<DatePickerCustom onChange={onChange} picker="year" style={{ marginRight: '10px' }} />
<div style={{ display: 'flex', marginTop: '10px' }}>
<Input
......
// eslint-disable-next-line no-unused-vars
import React from 'react';
import React, { useContext } from 'react';
import moment from 'moment';
import classNames from 'classnames';
// eslint-disable-next-line no-unused-vars
import { DatePicker } from 'antd';
import { DatePicker, ConfigProvider } from 'antd';
import './index.less';
const FORMATS = {
day: 'YYYY-MM-DD',
week: 'YYYY-wo',
month: 'YYYY-MM',
quarter: 'YYYY-第Q季度',
year: 'YYYY',
};
const STANTFORMAT = 'YYYY-MM-DD 00:00:00';
const ENDFORMAT = 'YYYY-MM-DD 23:59:59';
const DatePickerCustom = (props) => {
const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);
const prefixCls = getPrefixCls('datepicker-custom');
// eslint-disable-next-line no-nested-ternary
const modes = props.picker ? (props.picker !== 'date' ? props.picker : 'day') : 'day';
const selectedDate = props.value ? props.value : new Date();
const onChange = (date, dateString) => {
......@@ -31,6 +38,10 @@ const DatePickerCustom = (props) => {
startTime = moment(dateTime).startOf(modes);
endTime = moment(dateTime).endOf(modes);
break;
case 'quarter':
startTime = moment(dateTime).startOf(modes);
endTime = moment(dateTime).endOf(modes);
break;
case 'year':
startTime = moment(dateTime).startOf(modes);
endTime = moment(dateTime).endOf(modes);
......@@ -50,8 +61,10 @@ const DatePickerCustom = (props) => {
switch (modes) {
case 'day':
name = value.format(FORMATS[modes]);
// eslint-disable-next-line no-use-before-define
if (name === getTime(0, 'days', FORMATS[modes])) {
name = '今天';
// eslint-disable-next-line no-use-before-define
} else if (name === getTime(1, 'days', FORMATS[modes])) {
name = '昨天';
}
......@@ -62,22 +75,37 @@ const DatePickerCustom = (props) => {
// eslint-disable-next-line no-use-before-define
if (value.format('YYYY-wo') === getTime(0, 'week', FORMATS[modes])) {
name = '本周';
// eslint-disable-next-line no-use-before-define
} else if (value.format('YYYY-wo') === getTime(1, 'week', FORMATS[modes])) {
name = '上周';
}
break;
case 'month':
name = value.format(FORMATS[modes]);
// eslint-disable-next-line no-use-before-define
if (name === getTime(0, 'month', FORMATS[modes])) {
name = '本月';
// eslint-disable-next-line no-use-before-define
} else if (name === getTime(1, 'month', FORMATS[modes])) {
name = '上月';
}
break;
case 'quarter':
name = value.format(FORMATS[modes]);
// eslint-disable-next-line no-use-before-define
if (name === getTime(0, 'month', FORMATS[modes])) {
name = '本季度';
// eslint-disable-next-line no-use-before-define
} else if (name === getTime(3, 'month', FORMATS[modes])) {
name = '上季度';
}
break;
case 'year':
name = value.format(FORMATS[modes]);
// eslint-disable-next-line no-use-before-define
if (name === getTime(0, 'year', FORMATS[modes])) {
name = '今年';
// eslint-disable-next-line no-use-before-define
} else if (name === getTime(1, 'year', FORMATS[modes])) {
name = '去年';
}
......@@ -91,25 +119,28 @@ const DatePickerCustom = (props) => {
return moment(new Date()).subtract(num, type).format(format);
};
const getMonthWeek = (value) => {
const a = value.format('YYYY'),
b = value.format('MM'),
c = value.format('DD');
let date = new Date(a, parseInt(b) - 1, c),
w = date.getDay(),
d = date.getDate();
const a = value.format('YYYY');
const b = value.format('MM');
const c = value.format('DD');
// eslint-disable-next-line radix
const date = new Date(a, parseInt(b) - 1, c);
let w = date.getDay();
const d = date.getDate();
if (w == 0) {
w = 7;
}
let config = {
const config = {
getMonth: moment(date).format('MM'),
getYear: date.getFullYear(),
getWeek: Math.ceil((d + 6 - w) / 7),
};
return '第' + config.getWeek + '周(' + config.getYear + '/' + config.getMonth + ')';
return `第${config.getWeek}周(${config.getYear}/${config.getMonth})`;
};
return (
<DatePicker
{...props}
className={modes === 'quarter' ? classNames(`${prefixCls}-quarter-Box`) : ''}
dropdownClassName={modes === 'quarter' ? classNames(`${prefixCls}-quarter`) : ''}
defaultValue={selectedDate ? moment(selectedDate) : ''}
format={customFormat}
onChange={onChange}
......
@root-entry-name: 'default';
@import '~antd/es/style/themes/index.less';
@datepicker-custom-prefix-cls: ~'@{ant-prefix}-datepicker-custom';
.@{datepicker-custom-prefix-cls}-quarter-box {
width: 230px;
}
.@{datepicker-custom-prefix-cls}-quarter {
// :global {
.ant-picker-year-panel,
.ant-picker-quarter-panel {
width: 230px;
}
// 修改选中的年份、季度背景颜⾊
.ant-picker-cell-selected {
.ant-picker-cell-inner {
background: #5788ff;
}
}
// 使⽤CSS改变季度选择器的内容
.ant-picker-quarter-panel {
.ant-picker-content {
// 使季度选择器可以换⾏成两排
tr {
display: flex;
flex-wrap: wrap;
}
// 控制按钮外层宽度,使器溢出换⾏
td {
display: flex;
align-items: center;
justify-content: center;
width: 50%;
height: 50px;
padding: 20px;
}
}
// 使before伪元素和按钮背景颜⾊⼀致
.ant-picker-cell-selected {
&::before {
color: #fff;
background: #5788ff;
}
}
// 控制伪元素所占宽度
.ant-picker-cell {
&::before {
right: auto;
left: auto;
display: flex;
align-items: center;
justify-content: center;
width: 60%;
}
}
// 隐藏季度选择器的按钮,⽤伪元素代替
.ant-picker-cell-inner {
display: none;
}
// 根据title更换相应伪元素的content,使其代替原本的按钮
.ant-picker-cell[title$='-Q1'] {
&::before {
content: '第一季度';
}
}
.ant-picker-cell[title$='-Q2'] {
&::before {
content: '第二季度';
}
}
.ant-picker-cell[title$='-Q3'] {
&::before {
content: '第三季度';
}
}
.ant-picker-cell[title$='-Q4'] {
&::before {
content: '第四季度';
}
}
}
// }
}
......@@ -26,6 +26,6 @@
"dependencies": {
"@babel/runtime": "^7.17.9",
"form-render": "^0.9.12",
"parseForm": "^1.0.0"
"parseForm": "1.0.0"
}
}
......@@ -35,6 +35,7 @@
"@babel/runtime": "^7.17.9",
"@wisdom-components/ec_historyinfo": "1.2.23",
"@wisdom-components/mqttview": "1.3.6",
"@wisdom-components/empty": "1.3.9",
"cross-env": "^7.0.3"
}
}
......@@ -23,15 +23,11 @@ group:
## API
| 参数 | 说明 | 类型 | 默认值 |
| ------------------------------ | -------------------- | ------ | -------- |
| name `必需` | 画板名称 | string | '' |
| devices `必需` | 画板设备 | array | [] |
| pointAddressService `必需` | 获取点表地址信息接口 | func | () => {} |
| sketchPadListService `必需` | 获取画板列表接口 | func | () => {} |
| sketchPadListParams `必需` | 画板列表接口参数 | object | {} |
| sketchPadContentService `必需` | 获取画板 JSON 接口 | func | () => {} |
| historyInfoService `必需` | 获取历史信息接口 | func | () => {} |
| dictionaryService `必需` | 获取数据字典信息接口 | func | () => {} |
| dictionaryParams `必需` | 数据字典信息接口参数 | object | {} |
| globalConfig `必需` | 全局 config | object | {} |
| 参数 | 说明 | 类型 | 默认值 |
| ----------------------- | ------------------------------- | ------- | ------ |
| name `必需` | 画板名称 | string | '' |
| devices `必需` | 画板设备 | array | [] |
| dictionaryParams `必需` | 图标颜色数据字典参数 | object | {} |
| config `必需` | 全局 globalConfig | object | {} |
| isZoom | 是否可缩放(手持上建议设置 true) | boolean | false |
| flowShow | 是否水流效果(无数据表现) | boolean | true |
import { request } from '@wisdom-utils/utils/es';
const REQUEST_METHOD_GET = 'get';
const REQUEST_METHOD_POST = 'post';
// eslint-disable-next-line no-undef
const baseURI = DUMI_TYPE && DUMI_TYPE === 'dumi' ? '/api' : '';
// 获取画板列表接口
export function getSketchPadList(params) {
return request({
url: `${baseURI}/PandaCore/GCK/SketchPad/List`,
method: REQUEST_METHOD_GET,
header: { 'content-type': 'application/x-www-form-urlencoded' },
params,
});
}
// 获取画板JSON
export function getSketchPadContent(params) {
return request({
url: `${baseURI}/PandaCore/GCK/SketchPad/SketchContent`,
method: REQUEST_METHOD_GET,
params,
});
}
// 获取点表地址信息
export function getPointAddress(params) {
return request({
url: `${baseURI}/PandaCore/GCK/PointAddress/GetPointAddress`,
method: REQUEST_METHOD_GET,
params,
});
}
// 获取历史数据
export function getHistoryInfo(params) {
return request({
url: `${baseURI}/PandaCore/GCK/Device/SensorsDataForStation`,
method: REQUEST_METHOD_POST,
data: params,
});
}
// 获取数据字典
export function getDictionaryList(params) {
return request({
url: `${baseURI}/PandaOMS/OMS/DataManger/GetDataDictionaryList`,
method: REQUEST_METHOD_GET,
params,
});
}
// 获取设备实时数据
export function getDeviceRealInfo(data) {
return request({
url: `${baseURI}/PandaCore/GCK/Device/DeviceRealInfo`,
method: REQUEST_METHOD_POST,
data,
});
}
import React from 'react';
import PandaConfigurationView from '../index';
import { service } from '@wisdom-utils/utils';
const REQUEST_HTTP = 'http';
const REQUEST_METHOD_GET = 'get';
const REQUEST_METHOD_POST = 'post';
const GET_SKETCHPAD_LIST =
'https://www.fastmock.site/mock/162c15dca15c4dba9ba51e0a0b76929b/api/PandaCore/GCK/SketchPad/List';
const GET_FILE_SKETCHPAD_CONTENT =
'https://www.fastmock.site/mock/162c15dca15c4dba9ba51e0a0b76929b/api/PandaCore/GCK/SketchPad/SketchContent';
const GET_POINT_ADDRESS =
'https://www.fastmock.site/mock/162c15dca15c4dba9ba51e0a0b76929b/api/PandaCore/GCK/PointAddress/GetPointAddress';
const GET_HISTORY_INFO =
'https://www.fastmock.site/mock/162c15dca15c4dba9ba51e0a0b76929b/api/PandaCore/Monitor/Device/SensorsDataForStation'; //获取历史信息
const GET_DICTIONARY_LIST =
'https://www.fastmock.site/mock/162c15dca15c4dba9ba51e0a0b76929b/api/PandaCore/OMS/Data/GetDataDictionaryList'; //获取数据字典信息
// const GET_SKETCHPAD_LIST = '/api/PandaCore/GCK/SketchPad/List'; //获取画板列表接口
// const GET_FILE_SKETCHPAD_CONTENT = '/api/PandaCore/GCK/SketchPad/SketchContent'; //获取画板JSON
// const GET_POINT_ADDRESS = '/api/PandaCore/GCK/PointAddress/GetPointAddress'; //获取点表地址信息
// const GET_HISTORY_INFO = '/api/PandaCore/GCK/Device/SensorsDataForStation'; //获取历史信息
// const GET_DICTIONARY_LIST = '/api/PandaCore/OMS/DataManger/GetDataDictionaryList'; //获取数据字典信息
const configurationService = {
getSketchPadList: {
url: GET_SKETCHPAD_LIST, // 获取画板列表接口
method: REQUEST_METHOD_GET,
type: REQUEST_HTTP,
},
getSketchPadContent: {
url: GET_FILE_SKETCHPAD_CONTENT, // 获取画板JSON
method: REQUEST_METHOD_GET,
type: REQUEST_HTTP,
},
getPointAddress: {
url: GET_POINT_ADDRESS, // 获取点表地址信息
method: REQUEST_METHOD_GET,
type: REQUEST_HTTP,
},
getHistoryInfo: {
url: GET_HISTORY_INFO,
method: REQUEST_METHOD_POST,
type: REQUEST_HTTP,
},
getDictionaryList: {
url: GET_DICTIONARY_LIST,
method: REQUEST_METHOD_GET,
type: REQUEST_HTTP,
},
};
const cvService = service(configurationService);
const getPointAddress = cvService.getPointAddress;
const getSketchPadContent = cvService.getSketchPadContent;
const getSketchPadList = cvService.getSketchPadList;
const getHistoryInfo = cvService.getHistoryInfo;
const getDictionaryList = cvService.getDictionaryList;
const Demo = () => {
return (
<div style={{ width: '100%', height: '600px', background: '#242835' }}>
<PandaConfigurationView
name={'组态测试'}
devices={['ZTCS00000001', 'ZTCS00000002', 'ZTCS00000003', 'ZTCS00000004']}
pointAddressService={getPointAddress}
sketchPadListService={getSketchPadList}
sketchPadContentService={getSketchPadContent}
sketchPadListParams={{
_site: '',
siteCode: '151_ReactWeb5',
queryInfo: '',
version: '全部',
name: '组态测试',
}}
historyInfoService={getHistoryInfo}
dictionaryService={getDictionaryList}
name={'水厂工艺流程段'}
devices={'EQZT00000008,EQZT00000007,CPDA00000001,JYBZ00000003,JYBZ00000005,JYBZ00000004,SC00000003'.split(
',',
)}
// name={'崇左丽江水厂原水泵房'}
// devices={'EQZT00000007,CPBA00000001,CPAA00000001,EQZT00000008,CPDA00000001,CPAD00000001,LJSC00000002,EQZT00000005,EQZT00000004,EQZT00000002,EQZT00000003'.split(",")}
// name={'丽江水厂原水提升泵D单元'}
// devices={'CPAA00000001, CPAD00000001, LJSC00000002'.split(',')}
dictionaryParams={{ nodeID: 149 }}
globalConfig={globalConfig}
config={globalConfig}
// isZoom={true}
/>
</div>
);
......@@ -87,18 +23,19 @@ const Demo = () => {
export default Demo;
const globalConfig = {
baseURI: 'http://192.168.12.71:8080',
userInfo: {
site: '',
},
token: 'a1372ef0ce7b4e4884d31cfd99fe92f6',
mqtt_iotIP: '192.168.12.9:8083',
mqtt_iotIP: 'emqttd10.panda-water.cn:443',
mqtt_path: '/mqtt',
mqtt_IsSSL: false,
mqtt_IsSSL: true,
mqtt_site_code: 'site_dc8302ni',
mqtt_mess: {
MessageLevel: '1.0',
TcpIP: '192.168.12.9',
TcpPort: 8083,
site_code: '151_ReactWeb5',
TcpIP: 'emqttd10.panda-water.cn',
TcpPort: 443,
site_code: 'site_dc8302ni',
},
userInfo: {
LocalSite: 'site_dc8302ni',
site: '',
},
};
......@@ -22,13 +22,11 @@
display: flex;
align-items: center;
:global {
.anticon.anticon-exclamation-circle {
margin-top: 2px;
margin-right: 10px;
color: #fd5e72;
font-size: 18px;
}
.anticon.anticon-exclamation-circle {
margin-top: 2px;
margin-right: 10px;
color: #fd5e72;
font-size: 18px;
}
}
......@@ -38,6 +36,8 @@
.moreControlList {
display: flex;
align-items: center;
margin-bottom: 20px;
span {
margin-right: 30px;
......@@ -45,17 +45,14 @@
}
div {
margin-bottom: 20px;
padding: 2px 10px;
border: 1px solid #6d7da2;
border-radius: 6px;
}
}
&:last-of-type {
div {
margin-bottom: 0;
}
}
.moreControlList:last-of-type {
margin-bottom: 0;
}
}
......@@ -68,7 +65,6 @@
white-space: nowrap;
}
//:global {
.@{ant-prefix}-input-affix-wrapper {
background: #1c202c;
border: none;
......@@ -99,7 +95,29 @@
.@{ant-prefix}-input-suffix {
color: #646977;
}
//}
}
.adjustControlGroup {
display: flex;
padding-left: 0 5px;
.@{ant-prefix}-btn {
background: transparent;
}
button {
display: flex;
align-items: center;
margin-left: 10px;
background-color: ab;
span {
padding: 5px;
font-size: 14px;
border: 2px solid #1c202c;
border-radius: 5px;
}
}
}
.authorizeControlContent {
......@@ -111,8 +129,6 @@
align-items: center;
margin-bottom: 20px;
//:global {
.@{ant-prefix}-col.@{ant-prefix}-form-item-label {
margin-right: 10px;
......@@ -156,15 +172,13 @@
@{ant-prefix}-input-suffix {
color: #646977;
}
}
&:last-of-type {
margin-bottom: 0;
&:last-of-type {
margin-bottom: 0;
}
}
//}
}
//:global{
.@{ant-prefix}-modal-content {
color: white;
background: #282d3b;
......@@ -179,6 +193,7 @@
}
.@{ant-prefix}-modal-header {
padding-right: 56px;
background: none;
border-color: #1c202c;
......@@ -205,22 +220,20 @@
}
}
}
//}
}
.historyInfoModal {
//:global {
&-historyInfoModal {
.@{ant-prefix}-modal-body {
height: 680px;
}
//}
}
.jumpModal {
&-jumpModal {
display: flex;
align-items: center;
justify-content: center;
color: white;
//:global {
.@{ant-prefix}-modal {
padding-bottom: 0;
}
......@@ -249,6 +262,9 @@
}
.configurationView {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
canvas {
......@@ -256,5 +272,4 @@
outline: none;
}
}
//}
}
/* eslint-disable */
import * as go from './go';
export default class BarLink extends go.Link {
......@@ -55,40 +56,3 @@ export default class BarLink extends go.Link {
}
}
}
// function BarLink() {
// go.Link.call(this);
// }
// go.Diagram.inherit(BarLink, go.Link);
// BarLink.prototype.getLinkPoint = function(node, port, spot, from, ortho, othernode, otherport) {
// if (node.category === "HBar") {
// window.οncοntextmenu = function(event) {
// var e = event || window.event;
// document.getElementById("Menu").style.left = e.clientX + "px";
// document.getElementById("Menu").style.top = e.clientY + "px";
// document.getElementById("Menu").style.display = "block";
// return false;
// }
// var op = go.Link.prototype.getLinkPoint.call(this, othernode, otherport, this.computeSpot(!from), !from, ortho, node, port);
// var r = port.getDocumentBounds();
// // 横向合管
// var r = port.getDocumentBounds();
// var angle = node.angle;
// var spare = (angle / 90) % 2;
// if (!spare) {
// var y = (op.y > r.centerY) ? r.bottom : r.top;
// if (op.x < r.left) return new go.Point(r.left, y);
// if (op.x > r.right) return new go.Point(r.right, y);
// return new go.Point(op.x, y);
// }
// // 纵向合管
// var x = (op.x > r.centerX) ? r.right : r.left;
// if (op.y < r.top) return new go.Point(x, r.top);
// if (op.y > r.bottom) return new go.Point(x, r.bottom);
// // return new go.Point(x, op.y - r.width / 2 + 3);
// return new go.Point(x, op.y);
// } else {
// return go.Link.prototype.getLinkPoint.call(this, node, port, spot, from, ortho, othernode, otherport);
// }
// };
import React from 'react';
import ConfigurationView from '../index';
const ConfigurationDetail = (props) => {
return <ConfigurationView {...props} />;
};
export default ConfigurationDetail;
/* eslint-disable */
import React from 'react';
import { Modal } from 'antd';
class DragModal extends React.Component {
constructor() {
super();
this.simpleClass = Math.random().toString(36).substring(2);
this.init = false;
}
move = (event) => {
const { top, left, right, bottom, width, height } = this.contain.getBoundingClientRect();
const { limit = false } = this.props;
this.contain.style.top = `${top + event.movementY}px`;
this.contain.style.left = `${left + event.movementX}px`;
if (limit) {
if (bottom + event.movementY > window.innerHeight)
this.contain.style.top = `${window.innerHeight - height}px`;
if (top + event.movementY < 0) this.contain.style.top = 0;
if (right + event.movementX > window.innerWidth)
this.contain.style.left = `${window.innerWidth - width}px`;
if (left + event.movementX < 0) this.contain.style.left = 0;
}
};
removeMove = () => {
window.removeEventListener('mousemove', this.move, false);
};
removeUp = () => {
document.body.onselectstart = () => true;
this.removeMove();
};
// eslint-disable-next-line consistent-return
toTop = () => {
const autoIndexArr = document.getElementsByClassName('autoIndex');
if (autoIndexArr.length < 1) return false;
let max = 0;
// eslint-disable-next-line no-plusplus
for (let i = 0; i < autoIndexArr.length; i++) {
// eslint-disable-next-line radix
const zIndex = parseInt(autoIndexArr[i].style.zIndex || 1000);
if (zIndex > max) max = zIndex;
}
this.contain.style.zIndex = max + 1;
};
// eslint-disable-next-line consistent-return
create = (visible) => {
if (this.init) return false;
const { title, dragable = true, autoIndex = true, style = {} } = this.props;
if (title && dragable && visible) {
this.init = true;
setTimeout(() => {
// eslint-disable-next-line prefer-destructuring
this.contain = document.getElementsByClassName(this.simpleClass)[0];
if (!autoIndex) {
// eslint-disable-next-line prefer-destructuring
this.contain = this.contain.getElementsByClassName('ant-modal')[0];
this.contain.style.paddingBottom = 0;
this.contain.style.display = 'inline-block';
} else {
this.contain.style.right = 'auto';
this.contain.style.overflow = 'visible';
this.contain.style.bottom = 'auto';
this.contain.style.left = typeof style.left === 'number' ? `${style.left}px` : style.left;
this.contain.style.top = typeof style.top === 'number' ? `${style.top}px` : style.top;
this.contain.addEventListener('mousedown', this.toTop, false);
this.toTop();
}
// eslint-disable-next-line prefer-destructuring
this.header = this.contain.getElementsByClassName('ant-modal-header')[0];
this.header.style.cursor = 'all-scroll';
this.header.onmousedown = () => {
document.body.onselectstart = () => false;
window.addEventListener('mousemove', this.move, false);
};
window.addEventListener('mouseup', this.removeUp, false);
}, 0);
}
};
componentDidMount() {
this.create(this.props.visible);
}
componentWillReceiveProps({ visible }) {
if (visible && visible !== this.props.visible) {
this.create(visible);
// eslint-disable-next-line no-unused-expressions
this.contain && this.toTop();
}
}
componentWillUnmount() {
this.removeMove();
window.removeEventListener('mouseup', this.removeUp, false);
}
render() {
// eslint-disable-next-line no-unused-vars
const {
children,
wrapClassName = '',
limit = false,
dragable = true,
mask,
autoIndex = false,
style,
...other
} = this.props;
return (
<Modal
{...this.props}
wrapClassName={`${wrapClassName} ${this.simpleClass} ${(autoIndex && 'autoIndex') || ''}`}
mask={autoIndex ? false : mask}
></Modal>
);
}
}
export default DragModal;
/* eslint-disable */
/*
* Copyright (C) 1998-2021 by Northwoods Software Corporation. All Rights Reserved.
*/
......
/* eslint-disable */
'use strict';
/*
* Copyright (C) 1998-2019 by Northwoods Software Corporation. All Rights Reserved.
......
......@@ -18,6 +18,7 @@ import * as go from './go.js';
*
* @category Tool Extension
*/
/* eslint-disable */
export default class GuidedDraggingTool extends go.DraggingTool {
/** Constructs a GuidedDraggingTool and sets up the temporary guideline parts. */
constructor() {
......
/* eslint-disable */
function TopRotatingTool() {
go.RotatingTool.call(this);
}
......
/* eslint-disable */
class WaterFlowControlView {
constructor(options) {
this.linkDataArray = [];
......
/* eslint-disable */
/*
* GoJS v2.0.15 JavaScript Library for HTML Diagrams
* Northwoods Software, https://www.nwoods.com/
// 判断是否是数字
export const isNumber = (val) => {
const regPos = /^\d+(\.\d+)?$/; // 非负浮点数
const regNeg = /^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$/; // 负浮点数
return regPos.test(val) || regNeg.test(val);
};
// 创造guid
export const createGuid = () => {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
.replace(/[xy]/g, (c) => {
// eslint-disable-next-line no-bitwise
const r = (Math.random() * 16) | 0;
// eslint-disable-next-line no-bitwise
const v = c === 'x' ? r : (r & 0x3) | 0x8;
return v.toString(16);
})
.toUpperCase();
};
// 深拷贝
export const deepCopy = (p, c) => {
// eslint-disable-next-line no-param-reassign
c = c || {};
// eslint-disable-next-line no-restricted-syntax
for (const i in p) {
if (typeof p[i] === 'object') {
// eslint-disable-next-line no-param-reassign
c[i] = p[i].constructor === Array ? [] : {};
deepCopy(p[i], c[i]);
} else {
// eslint-disable-next-line no-param-reassign
c[i] = p[i];
}
}
return c;
};
// rgba颜色转换
export const hexToRgba = (hex, opacity) => {
// eslint-disable-next-line no-param-reassign
hex = hex || '#808080';
// eslint-disable-next-line no-param-reassign
opacity = opacity !== undefined ? opacity : 1;
// eslint-disable-next-line radix
return `rgba(${parseInt(`0x${hex.slice(1, 3)}`)}, ${parseInt(`0x${hex.slice(3, 5)}`)}, ${parseInt(
`0x${hex.slice(5, 7)}`,
)}, ${opacity})`;
};
// 加法运算
export const addNumMethod = (num1, num2) => {
let sq1;
let sq2;
let m;
try {
sq1 = num1.toString().split('.')[1].length;
} catch (e) {
sq1 = 0;
}
try {
sq2 = num2.toString().split('.')[1].length;
} catch (e) {
sq2 = 0;
}
// eslint-disable-next-line prefer-const
m = Math.max(sq1, sq2);
return (num1 + num2).toFixed(m);
};
// 进制转换
export const hexSwitch = (num, m, n) => {
const s = `${num}`;
const result = parseInt(s, m).toString(n);
return result;
};
// 文本样式
export const textStyle = () => {
return {
font: 'bold 11pt Helvetica, Arial, sans-serif',
stroke: 'whitesmoke',
};
};
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