kd-lane-container 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +79 -78
- package/dist/cjs/index.js +241 -315
- package/dist/umd/index.min.js +1 -1
- package/package.json +2 -5
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
#
|
|
1
|
+
# KdLaneContainer 组件使用文档
|
|
2
2
|
|
|
3
3
|
## 1. 组件概述
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
KdLaneContainer 是一个基于 Vue 开发的泳道图容器组件,用于展示和管理泳道模板、线条配置等。
|
|
6
6
|
|
|
7
7
|
### 1.1 设计思路
|
|
8
8
|
|
|
@@ -13,6 +13,21 @@ KdLaneChartContainer 是一个基于 Vue 开发的泳道图容器组件,用于
|
|
|
13
13
|
- 适合合作单位使用,提供灵活的数据接入方式
|
|
14
14
|
- **技术栈无关**:不限制绘制区技术栈,绘制逻辑完全由外部实现,只需要监听组件事件即可动态调整绘制内容
|
|
15
15
|
|
|
16
|
+
### 1.2 组件更名说明
|
|
17
|
+
|
|
18
|
+
**重要通知:从版本 0.0.8 开始,组件名称正式从 `KdLaneChartContainer` 更名为 `KdLaneContainer`**
|
|
19
|
+
|
|
20
|
+
#### 更名必要性:
|
|
21
|
+
|
|
22
|
+
1. **更准确的功能定位**:原名称包含 "Chart"(图表),但组件实际上是一个通用的泳道容器,不直接负责图表绘制,更名后更符合其实际功能定位
|
|
23
|
+
2. **简化命名**:去掉冗余的 "Chart" 后缀,使组件名称更简洁易记
|
|
24
|
+
3. **避免语义混淆**:澄清了组件职责边界,明确表示这是一个容器组件而非图表组件,避免与其他图表组件混淆,和包名保持一致
|
|
25
|
+
|
|
26
|
+
#### 版本兼容性:
|
|
27
|
+
|
|
28
|
+
- 版本 0.0.8 及以后:统一使用 `KdLaneContainer`
|
|
29
|
+
- 版本 0.0.7 及之前:使用旧名称 `KdLaneChartContainer`
|
|
30
|
+
|
|
16
31
|
## 2. 组件功能
|
|
17
32
|
|
|
18
33
|
- 加载和展示泳道模板
|
|
@@ -31,11 +46,11 @@ KdLaneChartContainer 是一个基于 Vue 开发的泳道图容器组件,用于
|
|
|
31
46
|
// npm install kd-lane-container --save
|
|
32
47
|
|
|
33
48
|
// 引入组件
|
|
34
|
-
import
|
|
49
|
+
import KdLaneContainer from "kd-lane-container";
|
|
35
50
|
import Vue from "vue";
|
|
36
51
|
|
|
37
52
|
// 注册组件
|
|
38
|
-
Vue.use(
|
|
53
|
+
Vue.use(KdLaneContainer);
|
|
39
54
|
```
|
|
40
55
|
|
|
41
56
|
### 3.2 在组件中使用
|
|
@@ -53,43 +68,43 @@ export default {
|
|
|
53
68
|
### 4.1 基本使用
|
|
54
69
|
|
|
55
70
|
```vue
|
|
56
|
-
<
|
|
71
|
+
<KdLaneContainer class="container" :config="config" :customMenuList="customMenuList" @onCustomMenuClicked="onCustomMenuClicked">
|
|
57
72
|
<!-- 自定义插槽内容 -->
|
|
58
|
-
</
|
|
73
|
+
</KdLaneContainer>
|
|
59
74
|
```
|
|
60
75
|
|
|
61
76
|
### 4.2 场景与版本控制
|
|
62
77
|
|
|
63
|
-
#### 4.
|
|
78
|
+
#### 4.2.1 场景唯一标识规则
|
|
64
79
|
|
|
65
80
|
- **caseId (场景 ID)**:用于唯一标识不同的应用场景或业务模块。
|
|
66
81
|
- 必须确保在同一应用中唯一,否则会导致数据混淆。
|
|
67
82
|
- 建议使用业务模块名称或唯一的 UUID。
|
|
68
83
|
- 所有数据操作都将与该场景 ID 绑定,确保数据隔离。
|
|
69
84
|
|
|
70
|
-
#### 4.
|
|
85
|
+
#### 4.2.2 版本号管理
|
|
71
86
|
|
|
72
87
|
- **versionCode (版本号)**:用于管理不同版本的初始配置。
|
|
73
88
|
- 当业务需求发生重大变更时,可以通过升级版本号来重置数据。
|
|
74
89
|
- 版本号升级后,系统会自动清理旧版本数据并重新初始化。
|
|
75
90
|
- 版本号必须为整数,建议从 1 开始递增。
|
|
76
91
|
|
|
77
|
-
#### 4.
|
|
92
|
+
#### 4.2.3 数据初始化策略
|
|
78
93
|
|
|
79
94
|
- 首次初始化:系统会将传入的`dataSource`保存为当前版本的初始配置。
|
|
80
95
|
- 版本冲突:当检测到版本号变更时,系统会自动重置数据并使用新版本的配置。
|
|
81
96
|
- 异常恢复:如果初始化过程中出现错误,系统会自动执行重置操作。
|
|
82
97
|
|
|
83
|
-
### 4.
|
|
98
|
+
### 4.3 配置参数
|
|
84
99
|
|
|
85
|
-
#### 4.
|
|
100
|
+
#### 4.3.1 数据源类型选择说明
|
|
86
101
|
|
|
87
|
-
|
|
102
|
+
KdLaneContainer 支持两种数据源类型:
|
|
88
103
|
|
|
89
104
|
- **local**:无后台配置接口,仅需前端单方面维护配置时使用
|
|
90
105
|
- **custom**:需要本组件 + 后台实时曲线配置接口组合使用时使用
|
|
91
106
|
|
|
92
|
-
#### 4.
|
|
107
|
+
#### 4.3.2 本地数据源 (Local)
|
|
93
108
|
|
|
94
109
|
```javascript
|
|
95
110
|
config: {
|
|
@@ -159,7 +174,7 @@ config: {
|
|
|
159
174
|
}
|
|
160
175
|
```
|
|
161
176
|
|
|
162
|
-
#### 4.
|
|
177
|
+
#### 4.3.3 自定义数据源 (Custom)
|
|
163
178
|
|
|
164
179
|
```javascript
|
|
165
180
|
config: {
|
|
@@ -230,11 +245,11 @@ config: {
|
|
|
230
245
|
8. `restoreSetting()` (可选)
|
|
231
246
|
- 返回值:`Promise<void>` - 恢复默认设置的 Promise
|
|
232
247
|
|
|
233
|
-
### 4.
|
|
248
|
+
### 4.4 自定义菜单
|
|
234
249
|
|
|
235
250
|
customMenuList 用于在上下文菜单中添加自定义操作选项。当用户在泳道头部或线条上右键点击时,这些自定义选项会出现在上下文菜单中。
|
|
236
251
|
|
|
237
|
-
#### 4.
|
|
252
|
+
#### 4.4.1 菜单结构
|
|
238
253
|
|
|
239
254
|
```javascript
|
|
240
255
|
customMenuList: [
|
|
@@ -249,7 +264,7 @@ customMenuList: [
|
|
|
249
264
|
];
|
|
250
265
|
```
|
|
251
266
|
|
|
252
|
-
#### 4.
|
|
267
|
+
#### 4.4.2 点击事件
|
|
253
268
|
|
|
254
269
|
当用户点击自定义菜单项时,会触发 `onCustomMenuClicked` 事件,并传递以下参数:
|
|
255
270
|
|
|
@@ -257,13 +272,13 @@ customMenuList: [
|
|
|
257
272
|
- `option`: 被点击的菜单项配置
|
|
258
273
|
- `item`: 右键点击时的目标对象(可能是泳道或线条)
|
|
259
274
|
|
|
260
|
-
#### 4.
|
|
275
|
+
#### 4.4.3 使用示例
|
|
261
276
|
|
|
262
|
-
```
|
|
263
|
-
<
|
|
264
|
-
:customMenuList
|
|
265
|
-
@onCustomMenuClicked
|
|
266
|
-
</
|
|
277
|
+
```vue
|
|
278
|
+
<KdLaneContainer
|
|
279
|
+
:customMenuList="[{ name: '单屏时长', key: 'timeRange' }]"
|
|
280
|
+
@onCustomMenuClicked="handleCustomMenuClick">
|
|
281
|
+
</KdLaneContainer>
|
|
267
282
|
```
|
|
268
283
|
|
|
269
284
|
```javascript
|
|
@@ -345,7 +360,7 @@ handleCustomMenuClick(event) {
|
|
|
345
360
|
组件支持根据泳道 ID 动态生成的插槽,用于自定义泳道头部:
|
|
346
361
|
|
|
347
362
|
```vue
|
|
348
|
-
<
|
|
363
|
+
<KdLaneContainer ...>
|
|
349
364
|
<!-- 动态slot名称 -->
|
|
350
365
|
<template v-if="slotName">
|
|
351
366
|
<div :slot="slotName" class="demo-slot">
|
|
@@ -357,26 +372,26 @@ handleCustomMenuClick(event) {
|
|
|
357
372
|
<template v-if="slotName2" :slot="slotName2" slot-scope="slotData">
|
|
358
373
|
<div class="demo-slot">{{ typeof slotData }}</div>
|
|
359
374
|
</template>
|
|
360
|
-
</
|
|
375
|
+
</KdLaneContainer>
|
|
361
376
|
```
|
|
362
377
|
|
|
363
378
|
插槽名称格式为 `lane${laneId}`,例如:`lane1556bdbfd0f24c11948b14999947c556`。
|
|
364
379
|
|
|
365
|
-
### 6.
|
|
380
|
+
### 6.1 draw-slot 画布插槽
|
|
366
381
|
|
|
367
382
|
组件提供 `draw-slot` 插槽用于自定义绘制内容,该插槽占据泳道下方的整个绘制区域:
|
|
368
383
|
|
|
369
384
|
```vue
|
|
370
|
-
<
|
|
385
|
+
<KdLaneContainer ...>
|
|
371
386
|
<template slot="draw-slot">
|
|
372
387
|
<div style="height: 100%; width: 100%; padding: 10px">
|
|
373
388
|
<!-- 自定义绘制内容 -->
|
|
374
389
|
</div>
|
|
375
390
|
</template>
|
|
376
|
-
</
|
|
391
|
+
</KdLaneContainer>
|
|
377
392
|
```
|
|
378
393
|
|
|
379
|
-
### 6.
|
|
394
|
+
### 6.2 插槽布局与尺寸注意事项
|
|
380
395
|
|
|
381
396
|
1. **布局方式**:
|
|
382
397
|
|
|
@@ -404,21 +419,45 @@ handleCustomMenuClick(event) {
|
|
|
404
419
|
</template>
|
|
405
420
|
```
|
|
406
421
|
|
|
407
|
-
## 7.
|
|
422
|
+
## 7. 主题与样式定制
|
|
423
|
+
|
|
424
|
+
### 7.1 组件级 CSS 变量
|
|
425
|
+
|
|
426
|
+
可以通过 CSS 变量或直接覆盖样式来自定义组件外观:
|
|
427
|
+
|
|
428
|
+
组件提供了以下 CSS 变量用于主题适配:
|
|
408
429
|
|
|
409
|
-
|
|
430
|
+
| 变量名 | 默认值 | 说明 |
|
|
431
|
+
| ---------------------------------------------------- | --------- | ---------------------- |
|
|
432
|
+
| `--kd-lane-container-border-color` | `#333` | 组件边框颜色 |
|
|
433
|
+
| `--kd-lane-container-header-item-color` | `#333` | 头部线条项文字颜色 |
|
|
434
|
+
| `--kd-lane-container-context-background-color` | `#ecf0f1` | 上下文菜单背景色 |
|
|
435
|
+
| `--kd-lane-container-context-item-color` | `#333` | 上下文菜单文字颜色 |
|
|
436
|
+
| `--kd-lane-container-context-hover-background-color` | `#007aff` | 上下文菜单悬停背景色 |
|
|
437
|
+
| `--kd-lane-container-context-hover-item-color` | `#fff` | 上下文菜单悬停文字颜色 |
|
|
438
|
+
| `--kd-lane-container-context-divider-color` | `#595a5a` | 上下文菜单分割线颜色 |
|
|
410
439
|
|
|
411
|
-
|
|
440
|
+
### 7.2 CSS 变量使用示例
|
|
441
|
+
|
|
442
|
+
```css
|
|
443
|
+
.kd-lane-chart-container {
|
|
444
|
+
--kd-lane-container-border-color: white;
|
|
445
|
+
--kd-lane-container-context-background-color: darkgray;
|
|
446
|
+
--kd-lane-container-header-item-color: white;
|
|
447
|
+
}
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
### 7.3 线条级别主题配置
|
|
451
|
+
|
|
452
|
+
组件支持通过 `themeName` 属性设置当前主题,配合 line 的 themeConfig 来实现表头线条和图表线条颜色主题适配。
|
|
412
453
|
|
|
413
454
|
```vue
|
|
414
|
-
<
|
|
455
|
+
<KdLaneContainer
|
|
415
456
|
:themeName="themeName"
|
|
416
457
|
...
|
|
417
458
|
>
|
|
418
459
|
```
|
|
419
460
|
|
|
420
|
-
### 7.2 线条级别主题配置
|
|
421
|
-
|
|
422
461
|
每个线条对象可以通过 `themeConfig` 属性配置不同主题下的颜色,格式为:
|
|
423
462
|
|
|
424
463
|
```javascript
|
|
@@ -446,51 +485,12 @@ lines: [
|
|
|
446
485
|
|
|
447
486
|
当组件的 `themeName` 变化时,线条会自动应用对应主题的颜色。如果未配置 `themeConfig`,则使用默认的 `lineColor`。
|
|
448
487
|
|
|
449
|
-
### 7.3 主题切换示例
|
|
450
|
-
|
|
451
|
-
````vue
|
|
452
|
-
<template>
|
|
453
|
-
<div id="app">
|
|
454
|
-
<KdLaneChartContainer class="container" :config="config" :themeName="themeName" ...>
|
|
455
|
-
<!-- 插槽内容 -->
|
|
456
|
-
</KdLaneChartContainer>
|
|
457
|
-
<div style="display: flex">
|
|
458
|
-
<button @click="changeCheme('white')">white</button>
|
|
459
|
-
<button @click="changeCheme('dark')">dark</button>
|
|
460
|
-
<button @click="changeCheme('gray')">gray</button>
|
|
461
|
-
</div>
|
|
462
|
-
</div>
|
|
463
|
-
</template>
|
|
464
|
-
|
|
465
|
-
<script>
|
|
466
|
-
export default {
|
|
467
|
-
data() {
|
|
468
|
-
return {
|
|
469
|
-
themeName: "white", // 默认主题
|
|
470
|
-
// ...其他配置
|
|
471
|
-
};
|
|
472
|
-
},
|
|
473
|
-
methods: {
|
|
474
|
-
changeCheme(themeName) {
|
|
475
|
-
this.themeName = themeName;
|
|
476
|
-
// 可选:给body设置data-theme属性,用于全局样式切换
|
|
477
|
-
document.body.setAttribute("data-theme", themeName);
|
|
478
|
-
},
|
|
479
|
-
},
|
|
480
|
-
};
|
|
481
|
-
</script>
|
|
482
|
-
|
|
483
|
-
## 8. 样式定制 可以通过 CSS 变量或直接覆盖样式来自定义组件外观: ```css .kd-lane-chart-container { --kd-lane-container-border-color: white;
|
|
484
|
-
--kd-lane-container-context-background-color: darkgray; --kd-lane-container-context-hover-color: darkgray;
|
|
485
|
-
--kd-lane-container-header-item-color: white; --app-background-color: gray; }
|
|
486
|
-
````
|
|
487
|
-
|
|
488
488
|
## 8. 使用示例
|
|
489
489
|
|
|
490
490
|
```vue
|
|
491
491
|
<template>
|
|
492
492
|
<div id="app">
|
|
493
|
-
<
|
|
493
|
+
<KdLaneContainer class="container" :config="config" :customMenuList="customMenuList" @onCustomMenuClicked="onCustomMenuClicked">
|
|
494
494
|
<!-- 动态slot名称,这里全部使用的是旧语法 -->
|
|
495
495
|
<template v-if="slotName">
|
|
496
496
|
<div :slot="slotName" class="demo-slot">
|
|
@@ -500,14 +500,14 @@ export default {
|
|
|
500
500
|
<template v-if="slotName2" :slot="slotName2" slot-scope="slotData">
|
|
501
501
|
<div class="demo-slot">{{ typeof slotData }}</div>
|
|
502
502
|
</template>
|
|
503
|
-
</
|
|
503
|
+
</KdLaneContainer>
|
|
504
504
|
</div>
|
|
505
505
|
</template>
|
|
506
506
|
|
|
507
507
|
<script>
|
|
508
508
|
import Vue from "vue";
|
|
509
|
-
import
|
|
510
|
-
Vue.use(
|
|
509
|
+
import KdLaneContainer from "kd-lane-container";
|
|
510
|
+
Vue.use(KdLaneContainer);
|
|
511
511
|
import { data } from "./mock/mockData.js";
|
|
512
512
|
export default {
|
|
513
513
|
name: "App",
|
|
@@ -572,3 +572,4 @@ export default {
|
|
|
572
572
|
}
|
|
573
573
|
</style>
|
|
574
574
|
```
|
|
575
|
+
````
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,276 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var vClickOutside = require('v-click-outside');
|
|
4
3
|
var Vue = require('vue');
|
|
4
|
+
var vClickOutside = require('v-click-outside');
|
|
5
5
|
|
|
6
6
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
7
7
|
|
|
8
|
-
var vClickOutside__default = /*#__PURE__*/_interopDefaultLegacy(vClickOutside);
|
|
9
8
|
var Vue__default = /*#__PURE__*/_interopDefaultLegacy(Vue);
|
|
10
|
-
|
|
11
|
-
function styleInject(css, ref) {
|
|
12
|
-
if ( ref === void 0 ) ref = {};
|
|
13
|
-
var insertAt = ref.insertAt;
|
|
14
|
-
|
|
15
|
-
if (!css || typeof document === 'undefined') { return; }
|
|
16
|
-
|
|
17
|
-
var head = document.head || document.getElementsByTagName('head')[0];
|
|
18
|
-
var style = document.createElement('style');
|
|
19
|
-
style.type = 'text/css';
|
|
20
|
-
|
|
21
|
-
if (insertAt === 'top') {
|
|
22
|
-
if (head.firstChild) {
|
|
23
|
-
head.insertBefore(style, head.firstChild);
|
|
24
|
-
} else {
|
|
25
|
-
head.appendChild(style);
|
|
26
|
-
}
|
|
27
|
-
} else {
|
|
28
|
-
head.appendChild(style);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (style.styleSheet) {
|
|
32
|
-
style.styleSheet.cssText = css;
|
|
33
|
-
} else {
|
|
34
|
-
style.appendChild(document.createTextNode(css));
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
var css_248z$6 = ".vue-simple-context-menu {\n top: 0;\n left: 0;\n margin: 0;\n padding: 0;\n display: none;\n list-style: none;\n position: absolute;\n z-index: 1000000;\n background-color: #ecf0f1;\n border-bottom-width: 0px;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", \"Roboto\", \"Oxygen\", \"Ubuntu\", \"Cantarell\", \"Fira Sans\", \"Droid Sans\", \"Helvetica Neue\", sans-serif;\n box-shadow: 0 3px 6px 0 rgba(51, 51, 51, 0.2);\n border-radius: 4px;\n}\n.vue-simple-context-menu--active {\n display: block;\n}\n.vue-simple-context-menu__item {\n display: flex;\n color: #333;\n cursor: pointer;\n padding: 5px 15px;\n align-items: center;\n}\n.vue-simple-context-menu__item:hover {\n background-color: #007aff;\n color: #fff;\n}\n.vue-simple-context-menu__divider {\n box-sizing: content-box;\n height: 2px;\n background-color: #c0cdd1;\n padding: 4px 0;\n background-clip: content-box;\n pointer-events: none;\n}\n.vue-simple-context-menu li:first-of-type {\n margin-top: 4px;\n}\n.vue-simple-context-menu li:last-of-type {\n margin-bottom: 4px;\n}";
|
|
39
|
-
styleInject(css_248z$6);
|
|
40
|
-
|
|
41
|
-
//
|
|
42
|
-
Vue__default["default"].use(vClickOutside__default["default"]);
|
|
43
|
-
var script$6 = {
|
|
44
|
-
name: "VueSimpleContextMenu",
|
|
45
|
-
props: {
|
|
46
|
-
elementId: {
|
|
47
|
-
type: String,
|
|
48
|
-
required: true
|
|
49
|
-
},
|
|
50
|
-
options: {
|
|
51
|
-
type: Array,
|
|
52
|
-
required: true
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
data: function data() {
|
|
56
|
-
return {
|
|
57
|
-
item: null,
|
|
58
|
-
menuWidth: null,
|
|
59
|
-
menuHeight: null
|
|
60
|
-
};
|
|
61
|
-
},
|
|
62
|
-
methods: {
|
|
63
|
-
showMenu: function showMenu(event, item) {
|
|
64
|
-
this.item = item;
|
|
65
|
-
var menu = document.getElementById(this.elementId);
|
|
66
|
-
if (!menu) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
if (!this.menuWidth || !this.menuHeight) {
|
|
70
|
-
menu.style.visibility = "hidden";
|
|
71
|
-
menu.style.display = "block";
|
|
72
|
-
this.menuWidth = menu.offsetWidth;
|
|
73
|
-
this.menuHeight = menu.offsetHeight;
|
|
74
|
-
menu.removeAttribute("style");
|
|
75
|
-
}
|
|
76
|
-
if (this.menuWidth + event.pageX >= window.innerWidth) {
|
|
77
|
-
menu.style.left = event.pageX - this.menuWidth + 2 + "px";
|
|
78
|
-
} else {
|
|
79
|
-
menu.style.left = event.pageX - 2 + "px";
|
|
80
|
-
}
|
|
81
|
-
if (this.menuHeight + event.pageY >= window.innerHeight) {
|
|
82
|
-
menu.style.top = event.pageY - this.menuHeight + 2 + "px";
|
|
83
|
-
} else {
|
|
84
|
-
menu.style.top = event.pageY - 2 + "px";
|
|
85
|
-
}
|
|
86
|
-
menu.classList.add("vue-simple-context-menu--active");
|
|
87
|
-
},
|
|
88
|
-
hideContextMenu: function hideContextMenu() {
|
|
89
|
-
var element = document.getElementById(this.elementId);
|
|
90
|
-
if (element) {
|
|
91
|
-
element.classList.remove("vue-simple-context-menu--active");
|
|
92
|
-
this.$emit("menu-closed");
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
onClickOutside: function onClickOutside() {
|
|
96
|
-
this.hideContextMenu();
|
|
97
|
-
},
|
|
98
|
-
optionClicked: function optionClicked(option) {
|
|
99
|
-
this.hideContextMenu();
|
|
100
|
-
this.$emit("option-clicked", {
|
|
101
|
-
item: this.item,
|
|
102
|
-
option: option
|
|
103
|
-
});
|
|
104
|
-
},
|
|
105
|
-
onEscKeyRelease: function onEscKeyRelease(event) {
|
|
106
|
-
if (event.keyCode === 27) {
|
|
107
|
-
this.hideContextMenu();
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
mounted: function mounted() {
|
|
112
|
-
document.body.addEventListener("keyup", this.onEscKeyRelease);
|
|
113
|
-
},
|
|
114
|
-
beforeDestroy: function beforeDestroy() {
|
|
115
|
-
document.removeEventListener("keyup", this.onEscKeyRelease);
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
function normalizeComponent$1(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier /* server only */, shadowMode, createInjector, createInjectorSSR, createInjectorShadow) {
|
|
119
|
-
if (typeof shadowMode !== 'boolean') {
|
|
120
|
-
createInjectorSSR = createInjector;
|
|
121
|
-
createInjector = shadowMode;
|
|
122
|
-
shadowMode = false;
|
|
123
|
-
}
|
|
124
|
-
// Vue.extend constructor export interop.
|
|
125
|
-
var options = typeof script === 'function' ? script.options : script;
|
|
126
|
-
// render functions
|
|
127
|
-
if (template && template.render) {
|
|
128
|
-
options.render = template.render;
|
|
129
|
-
options.staticRenderFns = template.staticRenderFns;
|
|
130
|
-
options._compiled = true;
|
|
131
|
-
// functional template
|
|
132
|
-
if (isFunctionalTemplate) {
|
|
133
|
-
options.functional = true;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
// scopedId
|
|
137
|
-
if (scopeId) {
|
|
138
|
-
options._scopeId = scopeId;
|
|
139
|
-
}
|
|
140
|
-
var hook;
|
|
141
|
-
if (moduleIdentifier) {
|
|
142
|
-
// server build
|
|
143
|
-
hook = function (context) {
|
|
144
|
-
// 2.3 injection
|
|
145
|
-
context = context ||
|
|
146
|
-
// cached call
|
|
147
|
-
this.$vnode && this.$vnode.ssrContext ||
|
|
148
|
-
// stateful
|
|
149
|
-
this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext; // functional
|
|
150
|
-
// 2.2 with runInNewContext: true
|
|
151
|
-
if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
|
|
152
|
-
context = __VUE_SSR_CONTEXT__;
|
|
153
|
-
}
|
|
154
|
-
// inject component styles
|
|
155
|
-
if (style) {
|
|
156
|
-
style.call(this, createInjectorSSR(context));
|
|
157
|
-
}
|
|
158
|
-
// register component module identifier for async chunk inference
|
|
159
|
-
if (context && context._registeredComponents) {
|
|
160
|
-
context._registeredComponents.add(moduleIdentifier);
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
// used by ssr in case component is cached and beforeCreate
|
|
164
|
-
// never gets called
|
|
165
|
-
options._ssrRegister = hook;
|
|
166
|
-
} else if (style) {
|
|
167
|
-
hook = shadowMode ? function (context) {
|
|
168
|
-
style.call(this, createInjectorShadow(context, this.$root.$options.shadowRoot));
|
|
169
|
-
} : function (context) {
|
|
170
|
-
style.call(this, createInjector(context));
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
if (hook) {
|
|
174
|
-
if (options.functional) {
|
|
175
|
-
// register for functional component in vue file
|
|
176
|
-
var originalRender = options.render;
|
|
177
|
-
options.render = function renderWithStyleInjection(h, context) {
|
|
178
|
-
hook.call(context);
|
|
179
|
-
return originalRender(h, context);
|
|
180
|
-
};
|
|
181
|
-
} else {
|
|
182
|
-
// inject component registration as beforeCreate hook
|
|
183
|
-
var existing = options.beforeCreate;
|
|
184
|
-
options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
return script;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/* script */
|
|
191
|
-
var __vue_script__$6 = script$6;
|
|
192
|
-
/* template */
|
|
193
|
-
var __vue_render__$6 = function () {
|
|
194
|
-
var _vm = this;
|
|
195
|
-
var _h = _vm.$createElement;
|
|
196
|
-
var _c = _vm._self._c || _h;
|
|
197
|
-
return _c("div", [_c("ul", {
|
|
198
|
-
directives: [{
|
|
199
|
-
name: "click-outside",
|
|
200
|
-
rawName: "v-click-outside",
|
|
201
|
-
value: _vm.onClickOutside,
|
|
202
|
-
expression: "onClickOutside"
|
|
203
|
-
}],
|
|
204
|
-
staticClass: "vue-simple-context-menu",
|
|
205
|
-
attrs: {
|
|
206
|
-
id: _vm.elementId
|
|
207
|
-
}
|
|
208
|
-
}, _vm._l(_vm.options, function (option, index) {
|
|
209
|
-
return _c("li", {
|
|
210
|
-
key: index,
|
|
211
|
-
staticClass: "vue-simple-context-menu__item",
|
|
212
|
-
class: [option.class, option.type === "divider" ? "vue-simple-context-menu__divider" : ""],
|
|
213
|
-
on: {
|
|
214
|
-
click: function ($event) {
|
|
215
|
-
$event.stopPropagation();
|
|
216
|
-
return _vm.optionClicked(option);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}, [_c("span", {
|
|
220
|
-
domProps: {
|
|
221
|
-
innerHTML: _vm._s(option.name)
|
|
222
|
-
}
|
|
223
|
-
})]);
|
|
224
|
-
}), 0)]);
|
|
225
|
-
};
|
|
226
|
-
var __vue_staticRenderFns__$6 = [];
|
|
227
|
-
__vue_render__$6._withStripped = true;
|
|
228
|
-
|
|
229
|
-
/* style */
|
|
230
|
-
var __vue_inject_styles__$6 = undefined;
|
|
231
|
-
/* scoped */
|
|
232
|
-
var __vue_scope_id__$6 = undefined;
|
|
233
|
-
/* module identifier */
|
|
234
|
-
var __vue_module_identifier__$6 = undefined;
|
|
235
|
-
/* functional template */
|
|
236
|
-
var __vue_is_functional_template__$6 = false;
|
|
237
|
-
/* style inject */
|
|
238
|
-
|
|
239
|
-
/* style inject SSR */
|
|
240
|
-
|
|
241
|
-
/* style inject shadow dom */
|
|
242
|
-
|
|
243
|
-
var __vue_component__$6 = /*#__PURE__*/normalizeComponent$1({
|
|
244
|
-
render: __vue_render__$6,
|
|
245
|
-
staticRenderFns: __vue_staticRenderFns__$6
|
|
246
|
-
}, __vue_inject_styles__$6, __vue_script__$6, __vue_scope_id__$6, __vue_is_functional_template__$6, __vue_module_identifier__$6, false, undefined, undefined, undefined);
|
|
247
|
-
|
|
248
|
-
// Import vue component
|
|
249
|
-
|
|
250
|
-
// install function executed by Vue.use()
|
|
251
|
-
function install$1(Vue) {
|
|
252
|
-
if (install$1.installed) {
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
255
|
-
install$1.installed = true;
|
|
256
|
-
Vue.component('VueSimpleContextMenu', __vue_component__$6);
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
// Create module definition for Vue.use()
|
|
260
|
-
var plugin = {
|
|
261
|
-
install: install$1
|
|
262
|
-
};
|
|
263
|
-
|
|
264
|
-
// To auto-install when vue is found
|
|
265
|
-
var GlobalVue = null;
|
|
266
|
-
if (typeof window !== 'undefined') {
|
|
267
|
-
GlobalVue = window.Vue;
|
|
268
|
-
} else if (typeof global !== 'undefined') {
|
|
269
|
-
GlobalVue = global.Vue;
|
|
270
|
-
}
|
|
271
|
-
if (GlobalVue) {
|
|
272
|
-
GlobalVue.use(plugin);
|
|
273
|
-
}
|
|
9
|
+
var vClickOutside__default = /*#__PURE__*/_interopDefaultLegacy(vClickOutside);
|
|
274
10
|
|
|
275
11
|
class CustomStrategy {
|
|
276
12
|
constructor(strategy) {
|
|
@@ -1712,7 +1448,7 @@ class StrategyFactory {
|
|
|
1712
1448
|
//
|
|
1713
1449
|
//
|
|
1714
1450
|
|
|
1715
|
-
var script$
|
|
1451
|
+
var script$6 = {
|
|
1716
1452
|
inject: ["upsertTemplate", "setTargetData", "setExpanded"],
|
|
1717
1453
|
props: {
|
|
1718
1454
|
currentTemplate: {
|
|
@@ -1804,8 +1540,35 @@ var script$5 = {
|
|
|
1804
1540
|
},
|
|
1805
1541
|
};
|
|
1806
1542
|
|
|
1807
|
-
|
|
1808
|
-
|
|
1543
|
+
function styleInject(css, ref) {
|
|
1544
|
+
if ( ref === void 0 ) ref = {};
|
|
1545
|
+
var insertAt = ref.insertAt;
|
|
1546
|
+
|
|
1547
|
+
if (!css || typeof document === 'undefined') { return; }
|
|
1548
|
+
|
|
1549
|
+
var head = document.head || document.getElementsByTagName('head')[0];
|
|
1550
|
+
var style = document.createElement('style');
|
|
1551
|
+
style.type = 'text/css';
|
|
1552
|
+
|
|
1553
|
+
if (insertAt === 'top') {
|
|
1554
|
+
if (head.firstChild) {
|
|
1555
|
+
head.insertBefore(style, head.firstChild);
|
|
1556
|
+
} else {
|
|
1557
|
+
head.appendChild(style);
|
|
1558
|
+
}
|
|
1559
|
+
} else {
|
|
1560
|
+
head.appendChild(style);
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1563
|
+
if (style.styleSheet) {
|
|
1564
|
+
style.styleSheet.cssText = css;
|
|
1565
|
+
} else {
|
|
1566
|
+
style.appendChild(document.createTextNode(css));
|
|
1567
|
+
}
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1570
|
+
var css_248z$6 = ".kd-lane-template-content {\n display: flex;\n flex-direction: column;\n align-content: center;\n}\n.kd-lane-template-content .template-buttons {\n text-align: center;\n}";
|
|
1571
|
+
styleInject(css_248z$6);
|
|
1809
1572
|
|
|
1810
1573
|
function normalizeComponent(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier /* server only */, shadowMode, createInjector, createInjectorSSR, createInjectorShadow) {
|
|
1811
1574
|
if (typeof shadowMode !== 'boolean') {
|
|
@@ -1883,9 +1646,9 @@ function normalizeComponent(template, style, script, scopeId, isFunctionalTempla
|
|
|
1883
1646
|
}
|
|
1884
1647
|
|
|
1885
1648
|
/* script */
|
|
1886
|
-
const __vue_script__$
|
|
1649
|
+
const __vue_script__$6 = script$6;
|
|
1887
1650
|
/* template */
|
|
1888
|
-
var __vue_render__$
|
|
1651
|
+
var __vue_render__$6 = function () {
|
|
1889
1652
|
var _vm = this;
|
|
1890
1653
|
var _h = _vm.$createElement;
|
|
1891
1654
|
var _c = _vm._self._c || _h;
|
|
@@ -2080,17 +1843,17 @@ var __vue_render__$5 = function () {
|
|
|
2080
1843
|
1
|
|
2081
1844
|
)
|
|
2082
1845
|
};
|
|
2083
|
-
var __vue_staticRenderFns__$
|
|
2084
|
-
__vue_render__$
|
|
1846
|
+
var __vue_staticRenderFns__$6 = [];
|
|
1847
|
+
__vue_render__$6._withStripped = true;
|
|
2085
1848
|
|
|
2086
1849
|
/* style */
|
|
2087
|
-
const __vue_inject_styles__$
|
|
1850
|
+
const __vue_inject_styles__$6 = undefined;
|
|
2088
1851
|
/* scoped */
|
|
2089
|
-
const __vue_scope_id__$
|
|
1852
|
+
const __vue_scope_id__$6 = undefined;
|
|
2090
1853
|
/* module identifier */
|
|
2091
|
-
const __vue_module_identifier__$
|
|
1854
|
+
const __vue_module_identifier__$6 = undefined;
|
|
2092
1855
|
/* functional template */
|
|
2093
|
-
const __vue_is_functional_template__$
|
|
1856
|
+
const __vue_is_functional_template__$6 = false;
|
|
2094
1857
|
/* style inject */
|
|
2095
1858
|
|
|
2096
1859
|
/* style inject SSR */
|
|
@@ -2099,13 +1862,13 @@ __vue_render__$5._withStripped = true;
|
|
|
2099
1862
|
|
|
2100
1863
|
|
|
2101
1864
|
|
|
2102
|
-
const __vue_component__$
|
|
2103
|
-
{ render: __vue_render__$
|
|
2104
|
-
__vue_inject_styles__$
|
|
2105
|
-
__vue_script__$
|
|
2106
|
-
__vue_scope_id__$
|
|
2107
|
-
__vue_is_functional_template__$
|
|
2108
|
-
__vue_module_identifier__$
|
|
1865
|
+
const __vue_component__$6 = /*#__PURE__*/normalizeComponent(
|
|
1866
|
+
{ render: __vue_render__$6, staticRenderFns: __vue_staticRenderFns__$6 },
|
|
1867
|
+
__vue_inject_styles__$6,
|
|
1868
|
+
__vue_script__$6,
|
|
1869
|
+
__vue_scope_id__$6,
|
|
1870
|
+
__vue_is_functional_template__$6,
|
|
1871
|
+
__vue_module_identifier__$6,
|
|
2109
1872
|
false,
|
|
2110
1873
|
undefined,
|
|
2111
1874
|
undefined,
|
|
@@ -2127,7 +1890,7 @@ __vue_render__$5._withStripped = true;
|
|
|
2127
1890
|
//
|
|
2128
1891
|
//
|
|
2129
1892
|
|
|
2130
|
-
var script$
|
|
1893
|
+
var script$5 = {
|
|
2131
1894
|
inject: ["upsertLane", "setTargetData", "setExpanded"],
|
|
2132
1895
|
props: {
|
|
2133
1896
|
laneInfo: {
|
|
@@ -2200,13 +1963,13 @@ var script$4 = {
|
|
|
2200
1963
|
},
|
|
2201
1964
|
};
|
|
2202
1965
|
|
|
2203
|
-
var css_248z$
|
|
2204
|
-
styleInject(css_248z$
|
|
1966
|
+
var css_248z$5 = ".kd-lane-lane-content {\n display: flex;\n flex-direction: column;\n align-content: center;\n}\n.kd-lane-lane-content .template-buttons {\n text-align: center;\n}";
|
|
1967
|
+
styleInject(css_248z$5);
|
|
2205
1968
|
|
|
2206
1969
|
/* script */
|
|
2207
|
-
const __vue_script__$
|
|
1970
|
+
const __vue_script__$5 = script$5;
|
|
2208
1971
|
/* template */
|
|
2209
|
-
var __vue_render__$
|
|
1972
|
+
var __vue_render__$5 = function () {
|
|
2210
1973
|
var _vm = this;
|
|
2211
1974
|
var _h = _vm.$createElement;
|
|
2212
1975
|
var _c = _vm._self._c || _h;
|
|
@@ -2275,17 +2038,17 @@ var __vue_render__$4 = function () {
|
|
|
2275
2038
|
1
|
|
2276
2039
|
)
|
|
2277
2040
|
};
|
|
2278
|
-
var __vue_staticRenderFns__$
|
|
2279
|
-
__vue_render__$
|
|
2041
|
+
var __vue_staticRenderFns__$5 = [];
|
|
2042
|
+
__vue_render__$5._withStripped = true;
|
|
2280
2043
|
|
|
2281
2044
|
/* style */
|
|
2282
|
-
const __vue_inject_styles__$
|
|
2045
|
+
const __vue_inject_styles__$5 = undefined;
|
|
2283
2046
|
/* scoped */
|
|
2284
|
-
const __vue_scope_id__$
|
|
2047
|
+
const __vue_scope_id__$5 = undefined;
|
|
2285
2048
|
/* module identifier */
|
|
2286
|
-
const __vue_module_identifier__$
|
|
2049
|
+
const __vue_module_identifier__$5 = undefined;
|
|
2287
2050
|
/* functional template */
|
|
2288
|
-
const __vue_is_functional_template__$
|
|
2051
|
+
const __vue_is_functional_template__$5 = false;
|
|
2289
2052
|
/* style inject */
|
|
2290
2053
|
|
|
2291
2054
|
/* style inject SSR */
|
|
@@ -2294,13 +2057,13 @@ __vue_render__$4._withStripped = true;
|
|
|
2294
2057
|
|
|
2295
2058
|
|
|
2296
2059
|
|
|
2297
|
-
const __vue_component__$
|
|
2298
|
-
{ render: __vue_render__$
|
|
2299
|
-
__vue_inject_styles__$
|
|
2300
|
-
__vue_script__$
|
|
2301
|
-
__vue_scope_id__$
|
|
2302
|
-
__vue_is_functional_template__$
|
|
2303
|
-
__vue_module_identifier__$
|
|
2060
|
+
const __vue_component__$5 = /*#__PURE__*/normalizeComponent(
|
|
2061
|
+
{ render: __vue_render__$5, staticRenderFns: __vue_staticRenderFns__$5 },
|
|
2062
|
+
__vue_inject_styles__$5,
|
|
2063
|
+
__vue_script__$5,
|
|
2064
|
+
__vue_scope_id__$5,
|
|
2065
|
+
__vue_is_functional_template__$5,
|
|
2066
|
+
__vue_module_identifier__$5,
|
|
2304
2067
|
false,
|
|
2305
2068
|
undefined,
|
|
2306
2069
|
undefined,
|
|
@@ -2350,7 +2113,7 @@ __vue_render__$4._withStripped = true;
|
|
|
2350
2113
|
//
|
|
2351
2114
|
//
|
|
2352
2115
|
|
|
2353
|
-
var script$
|
|
2116
|
+
var script$4 = {
|
|
2354
2117
|
inject: ["upsertLine", "setTargetData", "setExpanded"],
|
|
2355
2118
|
props: {
|
|
2356
2119
|
template: {
|
|
@@ -2469,13 +2232,13 @@ var script$3 = {
|
|
|
2469
2232
|
},
|
|
2470
2233
|
};
|
|
2471
2234
|
|
|
2472
|
-
var css_248z$
|
|
2473
|
-
styleInject(css_248z$
|
|
2235
|
+
var css_248z$4 = ".kd-lane-line-content {\n width: 95%;\n display: flex;\n flex-direction: column;\n align-content: center;\n}\n.kd-lane-line-content .template-buttons {\n text-align: center;\n}";
|
|
2236
|
+
styleInject(css_248z$4);
|
|
2474
2237
|
|
|
2475
2238
|
/* script */
|
|
2476
|
-
const __vue_script__$
|
|
2239
|
+
const __vue_script__$4 = script$4;
|
|
2477
2240
|
/* template */
|
|
2478
|
-
var __vue_render__$
|
|
2241
|
+
var __vue_render__$4 = function () {
|
|
2479
2242
|
var _vm = this;
|
|
2480
2243
|
var _h = _vm.$createElement;
|
|
2481
2244
|
var _c = _vm._self._c || _h;
|
|
@@ -2710,6 +2473,173 @@ var __vue_render__$3 = function () {
|
|
|
2710
2473
|
1
|
|
2711
2474
|
)
|
|
2712
2475
|
};
|
|
2476
|
+
var __vue_staticRenderFns__$4 = [];
|
|
2477
|
+
__vue_render__$4._withStripped = true;
|
|
2478
|
+
|
|
2479
|
+
/* style */
|
|
2480
|
+
const __vue_inject_styles__$4 = undefined;
|
|
2481
|
+
/* scoped */
|
|
2482
|
+
const __vue_scope_id__$4 = undefined;
|
|
2483
|
+
/* module identifier */
|
|
2484
|
+
const __vue_module_identifier__$4 = undefined;
|
|
2485
|
+
/* functional template */
|
|
2486
|
+
const __vue_is_functional_template__$4 = false;
|
|
2487
|
+
/* style inject */
|
|
2488
|
+
|
|
2489
|
+
/* style inject SSR */
|
|
2490
|
+
|
|
2491
|
+
/* style inject shadow dom */
|
|
2492
|
+
|
|
2493
|
+
|
|
2494
|
+
|
|
2495
|
+
const __vue_component__$4 = /*#__PURE__*/normalizeComponent(
|
|
2496
|
+
{ render: __vue_render__$4, staticRenderFns: __vue_staticRenderFns__$4 },
|
|
2497
|
+
__vue_inject_styles__$4,
|
|
2498
|
+
__vue_script__$4,
|
|
2499
|
+
__vue_scope_id__$4,
|
|
2500
|
+
__vue_is_functional_template__$4,
|
|
2501
|
+
__vue_module_identifier__$4,
|
|
2502
|
+
false,
|
|
2503
|
+
undefined,
|
|
2504
|
+
undefined,
|
|
2505
|
+
undefined
|
|
2506
|
+
);
|
|
2507
|
+
|
|
2508
|
+
//
|
|
2509
|
+
Vue__default["default"].use(vClickOutside__default["default"]);
|
|
2510
|
+
|
|
2511
|
+
var script$3 = {
|
|
2512
|
+
name: "VueSimpleContextMenu",
|
|
2513
|
+
props: {
|
|
2514
|
+
elementId: {
|
|
2515
|
+
type: String,
|
|
2516
|
+
required: true,
|
|
2517
|
+
},
|
|
2518
|
+
options: {
|
|
2519
|
+
type: Array,
|
|
2520
|
+
required: true,
|
|
2521
|
+
},
|
|
2522
|
+
},
|
|
2523
|
+
data() {
|
|
2524
|
+
return {
|
|
2525
|
+
item: null,
|
|
2526
|
+
menuWidth: null,
|
|
2527
|
+
menuHeight: null,
|
|
2528
|
+
};
|
|
2529
|
+
},
|
|
2530
|
+
methods: {
|
|
2531
|
+
showMenu(event, item) {
|
|
2532
|
+
this.item = item;
|
|
2533
|
+
|
|
2534
|
+
var menu = document.getElementById(this.elementId);
|
|
2535
|
+
if (!menu) {
|
|
2536
|
+
return;
|
|
2537
|
+
}
|
|
2538
|
+
|
|
2539
|
+
if (!this.menuWidth || !this.menuHeight) {
|
|
2540
|
+
menu.style.visibility = "hidden";
|
|
2541
|
+
menu.style.display = "block";
|
|
2542
|
+
this.menuWidth = menu.offsetWidth;
|
|
2543
|
+
this.menuHeight = menu.offsetHeight;
|
|
2544
|
+
menu.removeAttribute("style");
|
|
2545
|
+
}
|
|
2546
|
+
|
|
2547
|
+
if (this.menuWidth + event.pageX >= window.innerWidth) {
|
|
2548
|
+
menu.style.left = event.pageX - this.menuWidth + 2 + "px";
|
|
2549
|
+
} else {
|
|
2550
|
+
menu.style.left = event.pageX - 2 + "px";
|
|
2551
|
+
}
|
|
2552
|
+
|
|
2553
|
+
if (this.menuHeight + event.pageY >= window.innerHeight) {
|
|
2554
|
+
menu.style.top = event.pageY - this.menuHeight + 2 + "px";
|
|
2555
|
+
} else {
|
|
2556
|
+
menu.style.top = event.pageY - 2 + "px";
|
|
2557
|
+
}
|
|
2558
|
+
|
|
2559
|
+
menu.classList.add("vue-simple-context-menu--active");
|
|
2560
|
+
},
|
|
2561
|
+
hideContextMenu() {
|
|
2562
|
+
const element = document.getElementById(this.elementId);
|
|
2563
|
+
if (element) {
|
|
2564
|
+
element.classList.remove("vue-simple-context-menu--active");
|
|
2565
|
+
this.$emit("menu-closed");
|
|
2566
|
+
}
|
|
2567
|
+
},
|
|
2568
|
+
onClickOutside() {
|
|
2569
|
+
this.hideContextMenu();
|
|
2570
|
+
},
|
|
2571
|
+
optionClicked(option) {
|
|
2572
|
+
this.hideContextMenu();
|
|
2573
|
+
this.$emit("option-clicked", {
|
|
2574
|
+
item: this.item,
|
|
2575
|
+
option: option,
|
|
2576
|
+
});
|
|
2577
|
+
},
|
|
2578
|
+
onEscKeyRelease(event) {
|
|
2579
|
+
if (event.keyCode === 27) {
|
|
2580
|
+
this.hideContextMenu();
|
|
2581
|
+
}
|
|
2582
|
+
},
|
|
2583
|
+
},
|
|
2584
|
+
mounted() {
|
|
2585
|
+
document.body.addEventListener("keyup", this.onEscKeyRelease);
|
|
2586
|
+
},
|
|
2587
|
+
beforeDestroy() {
|
|
2588
|
+
document.removeEventListener("keyup", this.onEscKeyRelease);
|
|
2589
|
+
},
|
|
2590
|
+
};
|
|
2591
|
+
|
|
2592
|
+
var css_248z$3 = ".vue-simple-context-menu {\n top: 0;\n left: 0;\n margin: 0;\n padding: 0;\n display: none;\n list-style: none;\n position: fixed;\n z-index: 1000000;\n background-color: var(--kd-lane-container-context-background-color, #ecf0f1);\n border-bottom-width: 0px;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", \"Roboto\", \"Oxygen\", \"Ubuntu\", \"Cantarell\", \"Fira Sans\", \"Droid Sans\", \"Helvetica Neue\", sans-serif;\n box-shadow: 0 3px 6px 0 rgba(var(--kd-lane-container-context-item-color, #333), 0.2);\n border-radius: 4px;\n}\n.vue-simple-context-menu--active {\n display: block;\n}\n.vue-simple-context-menu__item {\n display: flex;\n color: var(--kd-lane-container-context-item-color, #333);\n cursor: pointer;\n padding: 5px 15px;\n align-items: center;\n}\n.vue-simple-context-menu__item:hover {\n background-color: var(--kd-lane-container-context-hover-background-color, #007aff);\n color: var(--kd-lane-container-context-hover-item-color, #fff);\n}\n.vue-simple-context-menu__divider {\n box-sizing: content-box;\n height: 2px;\n background-color: var(--kd-lane-container-context-divider-color, #595a5a);\n padding: 4px 0;\n background-clip: content-box;\n pointer-events: none;\n}\n.vue-simple-context-menu li:first-of-type {\n margin-top: 4px;\n}\n.vue-simple-context-menu li:last-of-type {\n margin-bottom: 4px;\n}";
|
|
2593
|
+
styleInject(css_248z$3);
|
|
2594
|
+
|
|
2595
|
+
/* script */
|
|
2596
|
+
const __vue_script__$3 = script$3;
|
|
2597
|
+
/* template */
|
|
2598
|
+
var __vue_render__$3 = function () {
|
|
2599
|
+
var _vm = this;
|
|
2600
|
+
var _h = _vm.$createElement;
|
|
2601
|
+
var _c = _vm._self._c || _h;
|
|
2602
|
+
return _c("div", [
|
|
2603
|
+
_c(
|
|
2604
|
+
"ul",
|
|
2605
|
+
{
|
|
2606
|
+
directives: [
|
|
2607
|
+
{
|
|
2608
|
+
name: "click-outside",
|
|
2609
|
+
rawName: "v-click-outside",
|
|
2610
|
+
value: _vm.onClickOutside,
|
|
2611
|
+
expression: "onClickOutside",
|
|
2612
|
+
},
|
|
2613
|
+
],
|
|
2614
|
+
staticClass: "vue-simple-context-menu",
|
|
2615
|
+
attrs: { id: _vm.elementId },
|
|
2616
|
+
},
|
|
2617
|
+
_vm._l(_vm.options, function (option, index) {
|
|
2618
|
+
return _c(
|
|
2619
|
+
"li",
|
|
2620
|
+
{
|
|
2621
|
+
key: index,
|
|
2622
|
+
staticClass: "vue-simple-context-menu__item",
|
|
2623
|
+
class: [
|
|
2624
|
+
option.class,
|
|
2625
|
+
option.type === "divider"
|
|
2626
|
+
? "vue-simple-context-menu__divider"
|
|
2627
|
+
: "",
|
|
2628
|
+
],
|
|
2629
|
+
on: {
|
|
2630
|
+
click: function ($event) {
|
|
2631
|
+
$event.stopPropagation();
|
|
2632
|
+
return _vm.optionClicked(option)
|
|
2633
|
+
},
|
|
2634
|
+
},
|
|
2635
|
+
},
|
|
2636
|
+
[_c("span", { domProps: { innerHTML: _vm._s(option.name) } })]
|
|
2637
|
+
)
|
|
2638
|
+
}),
|
|
2639
|
+
0
|
|
2640
|
+
),
|
|
2641
|
+
])
|
|
2642
|
+
};
|
|
2713
2643
|
var __vue_staticRenderFns__$3 = [];
|
|
2714
2644
|
__vue_render__$3._withStripped = true;
|
|
2715
2645
|
|
|
@@ -2752,7 +2682,7 @@ var script$2 = {
|
|
|
2752
2682
|
setExpanded: this.setExpanded,
|
|
2753
2683
|
};
|
|
2754
2684
|
},
|
|
2755
|
-
components: { LineEdit: __vue_component__$
|
|
2685
|
+
components: { LineEdit: __vue_component__$4, TemplateEdit: __vue_component__$6, LaneEdit: __vue_component__$5, VueSimpleContextMenu: __vue_component__$3 },
|
|
2756
2686
|
props: {
|
|
2757
2687
|
contextItem: {
|
|
2758
2688
|
type: Object,
|
|
@@ -3489,7 +3419,7 @@ __vue_render__$1._withStripped = true;
|
|
|
3489
3419
|
//
|
|
3490
3420
|
|
|
3491
3421
|
var script = {
|
|
3492
|
-
name: "
|
|
3422
|
+
name: "KdLaneContainer",
|
|
3493
3423
|
provide() {
|
|
3494
3424
|
return {
|
|
3495
3425
|
upsertTemplate: this.upsertTemplate,
|
|
@@ -3503,6 +3433,7 @@ var script = {
|
|
|
3503
3433
|
components: {
|
|
3504
3434
|
HeaderItem: __vue_component__$1,
|
|
3505
3435
|
RealTimeCurveConfig: __vue_component__$2,
|
|
3436
|
+
VueSimpleContextMenu: __vue_component__$3,
|
|
3506
3437
|
},
|
|
3507
3438
|
props: {
|
|
3508
3439
|
// {type:"local",dataSource:{},caseId:"",versionCode:"",load, save}
|
|
@@ -3882,7 +3813,7 @@ var script = {
|
|
|
3882
3813
|
},
|
|
3883
3814
|
};
|
|
3884
3815
|
|
|
3885
|
-
var css_248z = ".kd-lane-chart-container {\n
|
|
3816
|
+
var css_248z = ".kd-lane-chart-container {\n height: 100%;\n width: 100%;\n overflow: hidden;\n position: relative;\n border: 1px solid var(--kd-lane-container-border-color, #333);\n display: flex;\n}\n.kd-lane-chart-container .kd-lane-chart-lane-slot-container, .kd-lane-chart-container .kd-lane-chart-lane-container {\n height: 100%;\n min-width: 0;\n overflow: hidden;\n z-index: 1;\n}\n.kd-lane-chart-container .kd-lane-chart-lane-slot-container .kd-lane-chart-lane-header, .kd-lane-chart-container .kd-lane-chart-lane-container .kd-lane-chart-lane-header {\n max-height: 40%;\n border-bottom: 1px solid var(--kd-lane-container-border-color, #333);\n overflow: hidden;\n z-index: 2;\n display: flex;\n flex-direction: column;\n justify-content: center;\n}\n.kd-lane-chart-container .kd-lane-chart-lane-container {\n flex: 1;\n}\n.kd-lane-chart-container .kd-lane-chart-lane-slot-container {\n width: auto;\n}\n.kd-lane-chart-container .border-left {\n border-left: 1px solid var(--kd-lane-container-border-color, #333);\n}\n.kd-lane-chart-container .kd-lane-chart-container-draw-area {\n position: absolute;\n left: 0;\n right: 0;\n bottom: 0;\n z-index: 3;\n border: none;\n}";
|
|
3886
3817
|
styleInject(css_248z);
|
|
3887
3818
|
|
|
3888
3819
|
/* script */
|
|
@@ -4103,13 +4034,8 @@ __vue_render__._withStripped = true;
|
|
|
4103
4034
|
|
|
4104
4035
|
// 统一注册函数
|
|
4105
4036
|
const install = Vue => {
|
|
4106
|
-
// 先注册指令(确保时机正确)
|
|
4107
|
-
Vue.use(vClickOutside__default["default"]);
|
|
4108
|
-
// 再注册B组件
|
|
4109
|
-
Vue.component(__vue_component__$6.name, __vue_component__$6);
|
|
4110
4037
|
Vue.component(__vue_component__.name, __vue_component__);
|
|
4111
4038
|
};
|
|
4112
|
-
|
|
4113
4039
|
// 自动安装(当以script标签引入时)
|
|
4114
4040
|
if (typeof window !== "undefined" && window.Vue) {
|
|
4115
4041
|
window.Vue.use(install);
|
package/dist/umd/index.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("v-click-outside"),require("vue")):"function"==typeof define&&define.amd?define(["v-click-outside","vue"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).KdLaneChartContainer=t(e.vClickOutside,e.Vue)}(this,function(e,t){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=n(e),r=n(t);function s(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var a=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css","top"===n&&a.firstChild?a.insertBefore(r,a.firstChild):a.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}}function i(e,t,n,a,r,s,i,o,l,d){"boolean"!=typeof i&&(l=o,o=i,i=!1);var c,m="function"==typeof n?n.options:n;if(e&&e.render&&(m.render=e.render,m.staticRenderFns=e.staticRenderFns,m._compiled=!0,r&&(m.functional=!0)),a&&(m._scopeId=a),s?(c=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,l(e)),e&&e._registeredComponents&&e._registeredComponents.add(s)},m._ssrRegister=c):t&&(c=i?function(e){t.call(this,d(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,o(e))}),c)if(m.functional){var h=m.render;m.render=function(e,t){return c.call(t),h(e,t)}}else{var p=m.beforeCreate;m.beforeCreate=p?[].concat(p,c):[c]}return n}s('.vue-simple-context-menu {\n top: 0;\n left: 0;\n margin: 0;\n padding: 0;\n display: none;\n list-style: none;\n position: absolute;\n z-index: 1000000;\n background-color: #ecf0f1;\n border-bottom-width: 0px;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;\n box-shadow: 0 3px 6px 0 rgba(51, 51, 51, 0.2);\n border-radius: 4px;\n}\n.vue-simple-context-menu--active {\n display: block;\n}\n.vue-simple-context-menu__item {\n display: flex;\n color: #333;\n cursor: pointer;\n padding: 5px 15px;\n align-items: center;\n}\n.vue-simple-context-menu__item:hover {\n background-color: #007aff;\n color: #fff;\n}\n.vue-simple-context-menu__divider {\n box-sizing: content-box;\n height: 2px;\n background-color: #c0cdd1;\n padding: 4px 0;\n background-clip: content-box;\n pointer-events: none;\n}\n.vue-simple-context-menu li:first-of-type {\n margin-top: 4px;\n}\n.vue-simple-context-menu li:last-of-type {\n margin-bottom: 4px;\n}'),r.default.use(a.default);var o={name:"VueSimpleContextMenu",props:{elementId:{type:String,required:!0},options:{type:Array,required:!0}},data:function(){return{item:null,menuWidth:null,menuHeight:null}},methods:{showMenu:function(e,t){this.item=t;var n=document.getElementById(this.elementId);n&&(this.menuWidth&&this.menuHeight||(n.style.visibility="hidden",n.style.display="block",this.menuWidth=n.offsetWidth,this.menuHeight=n.offsetHeight,n.removeAttribute("style")),this.menuWidth+e.pageX>=window.innerWidth?n.style.left=e.pageX-this.menuWidth+2+"px":n.style.left=e.pageX-2+"px",this.menuHeight+e.pageY>=window.innerHeight?n.style.top=e.pageY-this.menuHeight+2+"px":n.style.top=e.pageY-2+"px",n.classList.add("vue-simple-context-menu--active"))},hideContextMenu:function(){var e=document.getElementById(this.elementId);e&&(e.classList.remove("vue-simple-context-menu--active"),this.$emit("menu-closed"))},onClickOutside:function(){this.hideContextMenu()},optionClicked:function(e){this.hideContextMenu(),this.$emit("option-clicked",{item:this.item,option:e})},onEscKeyRelease:function(e){27===e.keyCode&&this.hideContextMenu()}},mounted:function(){document.body.addEventListener("keyup",this.onEscKeyRelease)},beforeDestroy:function(){document.removeEventListener("keyup",this.onEscKeyRelease)}},l=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",[n("ul",{directives:[{name:"click-outside",rawName:"v-click-outside",value:e.onClickOutside,expression:"onClickOutside"}],staticClass:"vue-simple-context-menu",attrs:{id:e.elementId}},e._l(e.options,function(t,a){return n("li",{key:a,staticClass:"vue-simple-context-menu__item",class:[t.class,"divider"===t.type?"vue-simple-context-menu__divider":""],on:{click:function(n){return n.stopPropagation(),e.optionClicked(t)}}},[n("span",{domProps:{innerHTML:e._s(t.name)}})])}),0)])};l._withStripped=!0;var d=i({render:l,staticRenderFns:[]},undefined,o,undefined,false,undefined,!1,void 0,void 0,void 0);var c={install:function e(t){e.installed||(e.installed=!0,t.component("VueSimpleContextMenu",d))}},m=null;"undefined"!=typeof window?m=window.Vue:"undefined"!=typeof global&&(m=global.Vue),m&&m.use(c);class h{constructor(e){this.strategy=e}getUserTemplates(){return this.strategy.getUserTemplates()}upsertTemplate(e){return this.strategy.upsertTemplate(e)}delTemplate(e){return this.strategy.deleteTemplate(e)}upsertLane(e){return this.strategy.upsertLane(e)}delLane(e){return this.strategy.deleteLane(e)}upsertLine(e){return this.strategy.upsertLine(e)}delLine(e){return this.strategy.delLine(e)}restoreSetting(){return this.strategy.restoreSetting?this.strategy.restoreSetting():Promise.resolve()}}class p{static DB_NAME="KDLaneChartContainerConfigDB";static MAX_UNICODE_CHAR="";static DB_VERSION=2;static STORE_NAMES={TEMPLATES:"templates",LANES:"lanes",LINES:"lines",PARAMS:"params",CASE_VERSIONS:"case_versions"};_db=null;_openDB(){return new Promise((e,t)=>{if(this._db)return void e(this._db);const n=indexedDB.open(p.DB_NAME,p.DB_VERSION);n.onupgradeneeded=e=>{const t=e.target.result,{STORE_NAMES:n}=p;t.objectStoreNames.contains(n.CASE_VERSIONS)||t.createObjectStore(n.CASE_VERSIONS,{keyPath:"caseId"}),t.objectStoreNames.contains(n.TEMPLATES)||t.createObjectStore(n.TEMPLATES,{keyPath:["caseId","templateId"]}),t.objectStoreNames.contains(n.LANES)||t.createObjectStore(n.LANES,{keyPath:["caseId","laneId"]}),t.objectStoreNames.contains(n.LINES)||t.createObjectStore(n.LINES,{keyPath:["caseId","lineId"]}),t.objectStoreNames.contains(n.PARAMS)||t.createObjectStore(n.PARAMS,{keyPath:["caseId","paramId"]})},n.onsuccess=t=>{this._db=t.target.result,this._db.onclose=()=>{this._db=null},e(this._db)},n.onerror=e=>{t(new Error(`打开数据库失败:${e.target.error.message}`))},n.onblocked=()=>{t(new Error("数据库操作被阻塞,请关闭其他标签页后重试"))}})}closeDB(){return new Promise(e=>{this._db&&(this._db.close(),this._db=null),e()})}_compareVersion(e,t){const n=e=>String(e).split(".").map(Number),a=n(e),r=n(t),s=Math.max(a.length,r.length);for(let e=0;e<s;e++){const t=a[e]||0,n=r[e]||0;if(t>n)return 1;if(t<n)return-1}return 0}_clearSceneData(e){return this._openDB().then(t=>new Promise((n,a)=>{const r=t.transaction([p.STORE_NAMES.CASE_VERSIONS,p.STORE_NAMES.TEMPLATES,p.STORE_NAMES.LANES,p.STORE_NAMES.LINES,p.STORE_NAMES.PARAMS],"readwrite"),s=r.objectStore(p.STORE_NAMES.TEMPLATES),i=r.objectStore(p.STORE_NAMES.LANES),o=r.objectStore(p.STORE_NAMES.LINES),l=r.objectStore(p.STORE_NAMES.CASE_VERSIONS),d=r.objectStore(p.STORE_NAMES.PARAMS),c=IDBKeyRange.bound([e],[e,p.MAX_UNICODE_CHAR]);s.delete(c),i.delete(c),o.delete(c),d.delete(c),l.delete(e),r.oncomplete=()=>n(),r.onerror=e=>a(new Error(`事务失败:${e.target.error.message}`))}))}_promisifyRequest(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}forceInitSceneConfig(e,t,n){return e&&t?this._clearSceneData(e).then(()=>{const a=this.setUpData(e,t,n);return this.batchAddConfig(a)}).catch(e=>{throw new Error(`强制初始化场景配置失败:${e.message}`)}):Promise.reject(new Error("caseId和versionCode为强制初始化的必传参数"))}setUpData(e,t,n){const a=n.templates.map(t=>({...t,caseId:e})),r=n.lanes.map(t=>({...t,caseId:e})),s=n.lines.map(t=>({...t,caseId:e})),i=n.params.map(t=>({...t,caseId:e}));return{caseVersion:{caseId:e,versionCode:t,updateTime:new Date},templates:a,lanes:r,lines:s,params:i}}checkConfigIntegrity(e,t){return this.getCaseVersionByCaseId(e).then(n=>!(!n||n.versionCode!==t)&&this.getTemplatesByCaseId(e).then(t=>{if(0===t.length)return!0;const n=t[0].templateId;return this.getLanesByTemplateId(e,n).then(t=>{if(0===t.length)return!0;const n=t[0].laneId;return this.getLinesByLaneId(e,n).then(e=>0===e.length)})}))}_initSceneConfig(e){const{caseVersion:t}=e,{caseId:n,versionCode:a}=t;return this.getCaseVersionByCaseId(n).then(t=>{if(!t)return this.batchAddConfig(e);const r=this._compareVersion(a,t.versionCode);if(r>0)return this._clearSceneData(n).then(()=>this.batchAddConfig(e));if(0===r)return console.log(`场景${n}已存在版本${a},无需重复创建`),Promise.resolve(t);throw new Error(`场景${n}当前版本${t.versionCode}高于待创建版本${a}。`)})}saveSceneConfig(e,t,n){if(!e||!t)return Promise.reject(new Error("caseId和versionCode为必传参数"));if(!Array.isArray(n.templates)||!Array.isArray(n.lanes)||!Array.isArray(n.lines))return Promise.reject(new Error("templates/lanes/lines必须为数组"));const a=this.setUpData(e,t,n);return this._initSceneConfig(a)}batchAddConfig(e){return this._openDB().then(t=>new Promise((n,a)=>{const r=t.transaction([p.STORE_NAMES.CASE_VERSIONS,p.STORE_NAMES.TEMPLATES,p.STORE_NAMES.LANES,p.STORE_NAMES.LINES,p.STORE_NAMES.PARAMS],"readwrite");r.objectStore(p.STORE_NAMES.CASE_VERSIONS).put(e.caseVersion);const s=r.objectStore(p.STORE_NAMES.TEMPLATES);e.templates.forEach(e=>s.put(e));const i=r.objectStore(p.STORE_NAMES.LANES);e.lanes.forEach(e=>i.put(e));const o=r.objectStore(p.STORE_NAMES.LINES);e.lines.forEach(e=>o.put(e));const l=r.objectStore(p.STORE_NAMES.PARAMS);e.params.forEach(e=>l.put(e)),r.oncomplete=()=>n(e),r.onerror=e=>a(new Error(`批量添加配置失败:${e.target.error.message}`))}))}upsertCaseVersion(e){return this._openDB().then(t=>new Promise((n,a)=>{const r=t.transaction([p.STORE_NAMES.CASE_VERSIONS],"readwrite").objectStore(p.STORE_NAMES.CASE_VERSIONS),s={updateTime:new Date,...e};this._promisifyRequest(r.put(s)).then(()=>n(s)).catch(e=>a(new Error(`更新场景版本失败:${e.message}`)))}))}getCaseVersionByCaseId(e){return this._openDB().then(t=>new Promise((n,a)=>{const r=t.transaction([p.STORE_NAMES.CASE_VERSIONS],"readonly").objectStore(p.STORE_NAMES.CASE_VERSIONS);this._promisifyRequest(r.get(e)).then(e=>n(e||null)).catch(e=>a(new Error(`查询场景版本失败:${e.message}`)))}))}getConfigByCaseId(e){return e?Promise.all([this.getCaseVersionByCaseId(e),this.getTemplatesByCaseId(e),this.getParamsByCaseId(e)]).then(([t,n,a])=>{const r=n.map(t=>this.getLanesByTemplateId(e,t.templateId).then(n=>{const a=n.map(t=>this.getLinesByLaneId(e,t.laneId).then(e=>({...t,lines:e})));return Promise.all(a).then(e=>({...t,lanes:e}))}));return Promise.all(r).then(e=>({caseVersion:t,templates:e,params:a}))}).catch(e=>{throw new Error(`查询场景配置失败:${e.message}`)}):Promise.reject(new Error("caseId为必传参数"))}getConfigByTemplateId(e,t){if(!e||!t)return Promise.reject(new Error("caseId为必传参数"));const n={};return this.getLanesByTemplateId(e,t).then(t=>{const a=t.map(t=>this.getLinesByLaneId(e,t.laneId));return Promise.all(a).then(e=>{e.forEach((e,n)=>{t[n].lines=e}),n.lanes=t})}).then(()=>this.getTemplateById(e,t)).then(e=>(e.lanes=n.lanes,Promise.resolve(e)))}deleteCaseVersion(e){return this._openDB().then(t=>new Promise((n,a)=>{const r=t.transaction([p.STORE_NAMES.CASE_VERSIONS],"readwrite").objectStore(p.STORE_NAMES.CASE_VERSIONS);this._promisifyRequest(r.delete(e)).then(()=>n()).catch(e=>a(new Error(`删除场景版本失败:${e.message}`)))}))}upsertTemplate(e){return this._openDB().then(t=>new Promise((n,a)=>{if(!e.caseId)return void a(new Error("模板数据必须包含caseId"));const r=t.transaction([p.STORE_NAMES.TEMPLATES],"readwrite").objectStore(p.STORE_NAMES.TEMPLATES),s={...e,createDate:e.createDate?new Date(e.createDate):new Date,updateDate:e.updateDate?new Date(e.updateDate):null};return delete s.lanes,this._promisifyRequest(r.put(s)).then(()=>n(s)).catch(e=>a(new Error(`更新模板失败:${e.message}`)))}))}getTemplateById(e,t){return this._openDB().then(n=>new Promise((a,r)=>{const s=n.transaction([p.STORE_NAMES.TEMPLATES],"readonly").objectStore(p.STORE_NAMES.TEMPLATES);this._promisifyRequest(s.get([e,t])).then(e=>a(e||null)).catch(e=>r(new Error(`查询模板失败:${e.message}`)))}))}getTemplatesByCaseId(e){return this._openDB().then(t=>new Promise((n,a)=>{const r=t.transaction([p.STORE_NAMES.TEMPLATES],"readonly").objectStore(p.STORE_NAMES.TEMPLATES),s=IDBKeyRange.bound([e],[e,p.MAX_UNICODE_CHAR]);this._promisifyRequest(r.getAll(s)).then(e=>{n(e||[])}).catch(e=>a(new Error(`查询场景下模板失败:${e.message}`)))}))}deleteTemplate(e,t){return this._openDB().then(n=>new Promise((a,r)=>{const s=n.transaction([p.STORE_NAMES.TEMPLATES],"readwrite").objectStore(p.STORE_NAMES.TEMPLATES);this._promisifyRequest(s.delete([e,t])).then(()=>a()).catch(e=>r(new Error(`删除模板失败:${e.message}`)))}))}upsertLane(e,t){return this._openDB().then(n=>new Promise((a,r)=>{if(!e||!t.templateId)return void r(new Error("泳道数据必须包含caseId和templateId"));const s=n.transaction([p.STORE_NAMES.LANES],"readwrite").objectStore(p.STORE_NAMES.LANES),i={...t,caseId:e,updateDate:t.updateDate?new Date(t.updateDate):new Date};this._promisifyRequest(s.put(i)).then(()=>a(i)).catch(e=>r(new Error(`更新泳道失败:${e.message}`)))}))}getLaneById(e,t){return this._openDB().then(n=>new Promise((a,r)=>{const s=n.transaction([p.STORE_NAMES.LANES],"readonly").objectStore(p.STORE_NAMES.LANES);this._promisifyRequest(s.get([e,t])).then(e=>a(e||null)).catch(e=>r(new Error(`查询泳道失败:${e.message}`)))}))}getLanesByTemplateId(e,t){return this._openDB().then(n=>new Promise((a,r)=>{const s=n.transaction([p.STORE_NAMES.LANES],"readonly").objectStore(p.STORE_NAMES.LANES),i=IDBKeyRange.bound([e],[e,p.MAX_UNICODE_CHAR]);this._promisifyRequest(s.getAll(i)).then(e=>e.filter(e=>e.templateId===t)).then(e=>a(e||[])).catch(e=>r(new Error(`查询模板下泳道失败:${e.message}`)))}))}deleteLaneByLaneIds(e,t){return Array.isArray(t)&&0!==t.length?this._openDB().then(n=>new Promise((a,r)=>{const s=n.transaction([p.STORE_NAMES.LANES],"readwrite"),i=s.objectStore(p.STORE_NAMES.LANES);t.map(t=>this._promisifyRequest(i.delete([e,t]))),s.oncomplete=()=>a(),s.onerror=e=>r(new Error(`删除泳道失败:${e.target.error.message}`))})):Promise.resolve()}upsertLine(e,t){return this._openDB().then(n=>new Promise((a,r)=>{if(!e||!t.laneId)return void r(new Error("线条数据必须包含caseId和laneId"));const s=n.transaction([p.STORE_NAMES.LINES],"readwrite").objectStore(p.STORE_NAMES.LINES),i={...t,caseId:e,updateDate:t.updateDate?new Date(t.updateDate):new Date};this._promisifyRequest(s.put(i)).then(()=>a(i)).catch(e=>r(new Error(`更新线条失败:${e.message}`)))}))}getLineById(e,t){return this._openDB().then(n=>new Promise((a,r)=>{const s=n.transaction([p.STORE_NAMES.LINES],"readonly").objectStore(p.STORE_NAMES.LINES);this._promisifyRequest(s.get([e,t])).then(e=>a(e||null)).catch(e=>r(new Error(`查询线条失败:${e.message}`)))}))}getLinesByLaneId(e,t){return this._openDB().then(n=>new Promise((a,r)=>{const s=n.transaction([p.STORE_NAMES.LINES],"readonly").objectStore(p.STORE_NAMES.LINES),i=IDBKeyRange.bound([e],[e,p.MAX_UNICODE_CHAR]);this._promisifyRequest(s.getAll(i)).then(e=>e.filter(e=>e.laneId===t)).then(e=>a(e||[])).catch(e=>r(new Error(`查询泳道下线条失败:${e.message}`)))}))}deleteLineByIds(e,t){return Array.isArray(t)&&0!==t.length?this._openDB().then(n=>new Promise((a,r)=>{const s=n.transaction([p.STORE_NAMES.LINES],"readwrite"),i=s.objectStore(p.STORE_NAMES.LINES);t.map(t=>this._promisifyRequest(i.delete([e,t]))),s.oncomplete=()=>a(),s.onerror=e=>r(new Error(`批量删除线条失败:${e.target.error.message}`))})):Promise.resolve()}upsertParam(e){return this._openDB().then(t=>new Promise((n,a)=>{if(!e.caseId)return void a(new Error("参数数据必须包含caseId"));const r=t.transaction([p.STORE_NAMES.PARAMS],"readwrite").objectStore(p.STORE_NAMES.PARAMS),s={...e,updateDate:e.updateDate?new Date(e.updateDate):new Date};this._promisifyRequest(r.put(s)).then(()=>n(s)).catch(e=>a(new Error(`更新参数失败:${e.message}`)))}))}getParamById(e,t){return this._openDB().then(n=>new Promise((a,r)=>{const s=n.transaction([p.STORE_NAMES.PARAMS],"readonly").objectStore(p.STORE_NAMES.PARAMS);this._promisifyRequest(s.get([e,t])).then(e=>a(e||null)).catch(e=>r(new Error(`查询参数失败:${e.message}`)))}))}getParamsByCaseId(e){return this._openDB().then(t=>new Promise((n,a)=>{const r=t.transaction([p.STORE_NAMES.PARAMS],"readonly").objectStore(p.STORE_NAMES.PARAMS),s=IDBKeyRange.bound([e],[e,p.MAX_UNICODE_CHAR]);this._promisifyRequest(r.getAll(s)).then(e=>n(e||[])).catch(e=>a(new Error(`查询场景下参数失败:${e.message}`)))}))}deleteParamById(e,t){return this._openDB().then(n=>new Promise((a,r)=>{const s=n.transaction([p.STORE_NAMES.PARAMS],"readwrite").objectStore(p.STORE_NAMES.PARAMS);this._promisifyRequest(s.delete([e,t])).then(()=>a()).catch(e=>r(new Error(`删除参数失败:${e.message}`)))}))}}const u=new p;function f(e){return e&&"string"==typeof e&&parseFloat(e.replace("px",""))||0}function g(e){e&&Array.isArray(e.lines)&&e.lines.sort((e,t)=>(e.lineSort??0)-(t.lineSort??0))}function S(e){Array.isArray(e)&&(e.sort((e,t)=>(e.sort??0)-(t.sort??0)),e.forEach(e=>g(e)))}function y(e){return Array.isArray(e)&&0!==e.length?(e.sort((e,t)=>(e.sort??0)-(t.sort??0)),e.forEach(e=>S(e.lanes)),e):e}function b(e){return e?e.lineId&&e.laneId?"line":e.laneId&&e.templateId&&!e.lineId?"lane":e.templateId?"template":null:null}function v(e=!0){let t="";return t="undefined"!=typeof crypto&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}),e?t.replace(/-/g,""):t}class E{constructor(e,t,n,a=!0){this.caseId=e,this.versionCode=t,this.dataSource=n,this.flatData=a,this.ready=u.saveSceneConfig(e,t,n).catch(a=>(console.warn(`初始化数据库出错,直接重置:${a.message}`),u.forceInitSceneConfig(e,t,n)))}getUserTemplates(){return this.ready.then(()=>u.getConfigByCaseId(this.caseId))}upsertTemplate(e){let t;if(e.templateId)t=u.upsertTemplate(e);else{const n=v();if(e.templateId=n,e.baseTemplate){const a={};t=u.getLanesByTemplateId(this.caseId,e.baseTemplate).then(e=>{a.lanes=e;const t=e.map(e=>u.getLinesByLaneId(this.caseId,e.laneId));return Promise.all(t).then(e=>{const t=[];e.forEach((e,r)=>{const s=v();a.lanes[r].laneId=s,a.lanes[r].templateId=n,a.lanes[r].createUser=void 0,e.forEach(e=>{e.lineId=v(),e.laneId=s,e.createUser=void 0,t.push(e)})}),a.lines=t})}).then(()=>{a.templates=[e]}).then(()=>{a.params=[];const e=u.setUpData(this.caseId,this.versionCode,a);return u.batchAddConfig(e)}).then(()=>u.getTemplateById(this.caseId,n))}else t=u.upsertTemplate(e)}return"1"===e.isPublic?t.then(()=>u.getTemplatesByCaseId(this.caseId).then(t=>t.filter(t=>t.templateId!==e.templateId)).then(e=>{e.forEach(e=>{e.isPublic="0"});const t=e.map(e=>u.upsertTemplate(e));return Promise.all(t)}).then(()=>u.getConfigByTemplateId(this.caseId,e.templateId))):t}deleteTemplate(e){return u.getLanesByTemplateId(this.caseId,e.templateId).then(e=>{const t=e.map(e=>e.laneId);let n=t.map(e=>u.getLinesByLaneId(this.caseId,e));return Promise.all(n).then(e=>{const t=e.reduce((e,t)=>e.concat(t),[]).map(e=>e.lineId);return u.deleteLineByIds(this.caseId,t)}).then(()=>Promise.resolve(t))}).then(e=>u.deleteLaneByLaneIds(this.caseId,e)).then(()=>u.deleteTemplate(this.caseId,e.templateId)).then(()=>Promise.resolve(e))}upsertLane(e){return e.laneId||(e.laneId=v()),e.lines||(e.lines=[]),u.upsertLane(this.caseId,e)}delLane(e){const{lines:t,laneId:n}=e,a=t.map(e=>e.lineId);return u.deleteLineByIds(this.caseId,a).then(()=>u.deleteLaneByLaneIds(this.caseId,[n])).then(()=>Promise.resolve(e))}upsertLine(e){return e.lineId||(e.lineId=v()),e.laneId?u.upsertLine(this.caseId,e):Promise.reject(new Error("更新线条数据的时候,必须laneId不能为空!"))}delLine(e){return e.laneId?u.deleteLineByIds(this.caseId,[e.lineId]):Promise.reject(new Error("更新线条数据的时候,必须laneId不能为空!"))}restoreSetting(){return u.forceInitSceneConfig(this.caseId,this.versionCode,this.dataSource)}getType(){return"local-default"}}class I{static createStrategy(e){if("local"===e.type){let n;if((t=e.dataSource)&&Array.isArray(t.templates)&&Array.isArray(t.lanes)&&Array.isArray(t.lines)&&(0===t.templates.length||!t.templates[0].lanes))n={...e};else{if(!function(e){return Array.isArray(e)?0===e.length||!!e[0]&&Array.isArray(e[0].lanes):!!e&&Array.isArray(e.templates)&&(0===e.templates.length||Array.isArray(e.templates[0].lanes))}(e.dataSource))throw new Error("策略数据源格式不匹配");{const t=function(e){const t=[],n=[],a=[];for(const r of e){const{lanes:e,...s}=r;s.templateId||(s.templateId=v()),t.push(s);for(const t of e||[]){const{lines:e,...r}=t;r.templateId=s.templateId,r.laneId||(r.laneId=v()),n.push(r);for(const t of e||[])t.laneId=r.laneId,t.lineId||(t.lineId=v()),a.push(t)}}return{templates:t,lanes:n,lines:a}}(e.dataSource.templates);n={...e,dataSource:{...t,params:e.dataSource.params}}}}const{caseId:a,versionCode:r,dataSource:s}=n;return new E(a,r,s,!1)}return new h(e);var t}}var _={inject:["upsertTemplate","setTargetData","setExpanded"],props:{currentTemplate:{type:Object},formDisable:{type:Boolean},userTemplate:{type:Array},caseId:{type:String,default:""}},data(){return{formData:Object.assign({sort:void 0},this.currentTemplate),rules:{templateName:[{required:!0,message:"请输入模板名称",trigger:"blur"}]},saving:!1}},methods:{editable(){this.$emit("editable")},submitForm(e){this.$refs[e].validate(e=>{if(!e)return;if("function"!=typeof this.upsertTemplate)return void this.$message({type:"error",message:"没有配置模板管理方法"});this.saving=!0;const t={...this.formData};t.caseId||(t.caseId=this.caseId);const n=this.upsertTemplate(t);n instanceof Promise?n.then(e=>{this.setTargetData(e)}).then(()=>{this.$message({type:"success",message:"保存成功"})}).finally(()=>{this.saving=!1}):this.saving=!1})}},computed:{baseTemplate(){return this.userTemplate?[{name:"空白模板",value:""},...this.userTemplate.map(e=>({name:e.templateName,value:e.templateId}))]:[{name:"空白模板",value:""}]}},watch:{currentTemplate:{deep:!0,handler:function(e){this.formData=Object.assign({},e)}}}};function T(e,t,n,a,r,s,i,o,l,d){"boolean"!=typeof i&&(l=o,o=i,i=!1);const c="function"==typeof n?n.options:n;let m;if(e&&e.render&&(c.render=e.render,c.staticRenderFns=e.staticRenderFns,c._compiled=!0,r&&(c.functional=!0)),a&&(c._scopeId=a),s?(m=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,l(e)),e&&e._registeredComponents&&e._registeredComponents.add(s)},c._ssrRegister=m):t&&(m=i?function(e){t.call(this,d(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,o(e))}),m)if(c.functional){const e=c.render;c.render=function(t,n){return m.call(n),e(t,n)}}else{const e=c.beforeCreate;c.beforeCreate=e?[].concat(e,m):[m]}return n}s(".kd-lane-template-content {\n display: flex;\n flex-direction: column;\n align-content: center;\n}\n.kd-lane-template-content .template-buttons {\n text-align: center;\n}");const x=_;var C=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"kd-lane-template-content"},[n("el-form",{ref:"template",attrs:{rules:e.rules,model:e.formData,"label-width":"120px"}},[n("el-form-item",{attrs:{label:"模板名称",prop:"templateName"}},[n("el-input",{attrs:{disabled:"SYSTEM_USER"==e.currentTemplate.createUser||e.formDisable},model:{value:e.formData.templateName,callback:function(t){e.$set(e.formData,"templateName",t)},expression:"formData.templateName"}})],1),e._v(" "),n("el-form-item",{attrs:{label:"默认模板",prop:"isPublic"}},[n("el-radio-group",{attrs:{disabled:e.formDisable},model:{value:e.formData.isPublic,callback:function(t){e.$set(e.formData,"isPublic",t)},expression:"formData.isPublic"}},[n("el-radio",{attrs:{label:"1"}},[e._v("是")]),e._v(" "),n("el-radio",{attrs:{label:"0"}},[e._v("否")])],1)],1),e._v(" "),n("el-form-item",{attrs:{label:"曲线高度占比",prop:"col1"}},[n("el-select",{attrs:{disabled:e.formDisable},model:{value:e.formData.col1,callback:function(t){e.$set(e.formData,"col1",t)},expression:"formData.col1"}},[n("el-option",{attrs:{value:"0.5",label:"50%"}}),e._v(" "),n("el-option",{attrs:{value:"0.6",label:"60%"}}),e._v(" "),n("el-option",{attrs:{value:"0.7",label:"70%"}}),e._v(" "),n("el-option",{attrs:{value:"0.8",label:"80%"}}),e._v(" "),n("el-option",{attrs:{value:"0.9",label:"90%"}}),e._v(" "),n("el-option",{attrs:{value:"1",label:"全屏"}})],1)],1),e._v(" "),n("el-form-item",{directives:[{name:"show",rawName:"v-show",value:!e.currentTemplate.templateId,expression:"!currentTemplate.templateId"}],attrs:{label:"选择基础模板",prop:"lineType",disabled:e.formDisable}},[n("el-select",{attrs:{placeholder:"请选择"},model:{value:e.formData.baseTemplate,callback:function(t){e.$set(e.formData,"baseTemplate",t)},expression:"formData.baseTemplate"}},e._l(e.baseTemplate,function(e){return n("el-option",{key:e.value,attrs:{label:e.name,value:e.value}})}),1)],1),e._v(" "),n("el-form-item",{attrs:{label:"顺序",prop:"sort","label-width":"120px"}},[n("el-input",{attrs:{disabled:e.formDisable},model:{value:e.formData.sort,callback:function(t){e.$set(e.formData,"sort",e._n(t))},expression:"formData.sort"}})],1)],1),e._v(" "),n("div",{staticClass:"template-buttons"},[n("el-button",{on:{click:e.editable}},[e._v("编辑")]),e._v(" "),n("el-button",{attrs:{type:"primary",disabled:e.formDisable,loading:e.saving},on:{click:function(t){return e.submitForm("template")}}},[e._v("保存")])],1)],1)};C._withStripped=!0;const w=T({render:C,staticRenderFns:[]},undefined,x,undefined,false,undefined,!1,void 0,void 0,void 0);var A={inject:["upsertLane","setTargetData","setExpanded"],props:{laneInfo:{type:Object},caseId:{type:String,default:""},formDisable:{type:Boolean}},data(){return{formData:Object.assign(this.laneInfo),rules:{sort:[{required:!0,message:"请输入泳道顺序",trigger:"blur"}]},saving:!1}},methods:{editable(){this.$emit("editable")},submitForm(e){this.$refs[e].validate(e=>{if(!e)return;if("function"!=typeof this.upsertLane)return void this.$message({type:"error",message:"没有配置泳道管理方法"});this.saving=!0;const t={...this.formData};t.caseId||(t.caseId=this.caseId);const n=this.upsertLane(t);n instanceof Promise?n.then(e=>{this.setTargetData(e)}).then(()=>{this.$message({type:"success",message:"保存成功"})}).finally(()=>{this.saving=!1}):this.saving=!1})}},computed:{},watch:{laneInfo:{deep:!0,handler:function(e){this.formData=Object.assign({},e)}}}};s(".kd-lane-lane-content {\n display: flex;\n flex-direction: column;\n align-content: center;\n}\n.kd-lane-lane-content .template-buttons {\n text-align: center;\n}");const D=A;var N=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"kd-lane-lane-content"},[n("el-form",{ref:"template",attrs:{rules:e.rules,model:e.formData,"label-width":"120px"}},[n("el-form-item",{attrs:{label:"泳道顺序",prop:"sort"}},[n("el-input",{attrs:{disabled:e.formDisable},model:{value:e.formData.sort,callback:function(t){e.$set(e.formData,"sort",t)},expression:"formData.sort"}})],1)],1),e._v(" "),n("div",{staticClass:"template-buttons"},[n("el-button",{on:{click:e.editable}},[e._v("编辑")]),e._v(" "),n("el-button",{attrs:{type:"primary",disabled:e.formDisable,loading:e.saving},on:{click:function(t){return e.submitForm("template")}}},[e._v("保存")])],1)],1)};N._withStripped=!0;const k=T({render:N,staticRenderFns:[]},undefined,D,undefined,false,undefined,!1,void 0,void 0,void 0);var L={inject:["upsertLine","setTargetData","setExpanded"],props:{template:{type:Object},formDisable:{type:Boolean},params:{type:Array}},mounted(){},data(){const e=(e,t,n)=>{isNaN(t)?n(new Error("请输入数字值")):n()};return{formData:Object.assign({},this.template),lines:[{name:"直线",value:"solid"},{name:"虚线",value:"dashed"},{name:"点线",value:"dotted"},{name:"面积",value:"area"}],lineWidthSliderMarks:{1:"1",2:"2",3:"3",4:"4"},rules:{min:[{required:!0,message:"请输入最小值",trigger:"blur"},{validator:e,trigger:"blur"}],lineSort:[{required:!0,message:"请输入曲线顺序(1-10)",trigger:"blur"},{type:"number",message:"顺序必须为数字值"}],max:[{required:!0,message:"请输入最大值",trigger:"blur"},{validator:e,trigger:"blur"}],lineSize:[{required:!0,message:"请选择曲线粗细",trigger:"blur"}],lineColor:[{required:!0,message:"请选择曲线颜色",trigger:"blur"}],lineType:[{required:!0,message:"请选择线型",trigger:"blur"}],paramId:[{required:!0,message:"请选择参数名称",trigger:"blur"}]}}},methods:{editable(){this.$emit("editable")},submitForm(e){this.$refs[e].validate().then(()=>{if(!(this.upsertLine instanceof Function))return Promise.reject(new Error("未配置线条设置函数"));{const e=this.upsertLine(this.formData);e instanceof Promise?e.then(e=>{this.setTargetData(e)}).then(()=>{this.$message({type:"success",message:"保存成功"})}).finally(()=>{this.saving=!1}):this.saving=!1}}).catch(e=>{console.log(e)})}},watch:{template:{immediate:!1,deep:!0,handler(e){this.formData=Object.assign({},e)}}}};s(".kd-lane-line-content {\n width: 95%;\n display: flex;\n flex-direction: column;\n align-content: center;\n}\n.kd-lane-line-content .template-buttons {\n text-align: center;\n}");const M=L;var R=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"kd-lane-line-content"},[n("el-form",{ref:"template",attrs:{rules:e.rules,model:e.formData,disabled:e.formDisable}},[n("el-form-item",{attrs:{label:"参数名称",prop:"paramId","label-width":"120px"}},[n("el-select",{attrs:{filterable:"",placeholder:"请选择"},model:{value:e.formData.paramId,callback:function(t){e.$set(e.formData,"paramId",t)},expression:"formData.paramId"}},e._l(e.params,function(e){return n("el-option",{key:e.paramId,attrs:{label:e.paramName,value:e.paramId}})}),1)],1),e._v(" "),n("el-form-item",{attrs:{label:"最小值",prop:"min","label-width":"120px"}},[n("el-input",{model:{value:e.formData.min,callback:function(t){e.$set(e.formData,"min",t)},expression:"formData.min"}})],1),e._v(" "),n("el-form-item",{attrs:{label:"最大值",prop:"max","label-width":"120px"}},[n("el-input",{model:{value:e.formData.max,callback:function(t){e.$set(e.formData,"max",t)},expression:"formData.max"}})],1),e._v(" "),n("el-form-item",{attrs:{label:"曲线粗细",prop:"lineSize","label-width":"120px"}},[n("el-input",{attrs:{max:4,min:1,type:"number"},model:{value:e.formData.lineSize,callback:function(t){e.$set(e.formData,"lineSize",t)},expression:"formData.lineSize"}})],1),e._v(" "),n("el-form-item",{attrs:{label:"曲线颜色",prop:"lineColor","label-width":"120px"}},[n("el-color-picker",{attrs:{disabled:e.formData.isGradient},model:{value:e.formData.lineColor,callback:function(t){e.$set(e.formData,"lineColor",t)},expression:"formData.lineColor"}})],1),e._v(" "),n("el-form-item",{attrs:{label:"线型",prop:"lineType","label-width":"120px"}},[n("el-select",{attrs:{placeholder:"请选择",disabled:e.formData.isGradient},model:{value:e.formData.lineType,callback:function(t){e.$set(e.formData,"lineType",t)},expression:"formData.lineType"}},e._l(e.lines,function(e){return n("el-option",{key:e.value,attrs:{label:e.name,value:e.value}})}),1)],1),e._v(" "),n("el-form-item",{attrs:{label:"曲线顺序",prop:"lineSort","label-width":"120px"}},[n("el-input",{model:{value:e.formData.lineSort,callback:function(t){e.$set(e.formData,"lineSort",e._n(t))},expression:"formData.lineSort"}})],1),e._v(" "),e._e()],1),e._v(" "),n("div",{directives:[{name:"show",rawName:"v-show",value:"SYSTEM_USER"!=e.template.createUser,expression:"template.createUser != 'SYSTEM_USER'"}],staticClass:"template-buttons"},[n("el-button",{on:{click:e.editable}},[e._v("编辑")]),e._v(" "),n("el-button",{attrs:{type:"primary",disabled:e.formDisable},on:{click:function(t){return e.submitForm("template")}}},[e._v("保存")])],1)],1)};R._withStripped=!0;const P=T({render:R,staticRenderFns:[]},undefined,M,undefined,false,undefined,!1,void 0,void 0,void 0);var $={inject:["delTemplate","delLane","delLine"],provide(){return{setTargetData:this.setTargetData,setExpanded:this.setExpanded}},components:{LineEdit:P,TemplateEdit:w,LaneEdit:k},props:{contextItem:{type:Object,default:()=>{}},expended:{type:Object},caseId:{type:String,default:""},inputTempates:{type:Array,default:()=>[]},params:{type:Array,required:!0,default:()=>[]},paramsNameMap:{type:Object,default:()=>{},required:!0}},data:()=>({templateContentShow:!1,templateDisable:!1,laneContentShow:!1,lineContentShow:!1,templateInfo:{},laneInfo:{},lineInfo:{},dataType:"",curveConfigLoading:!1,expandedKeys:[],currentNodeKey:"",targetData:void 0,treeKey:""}),mounted(){},methods:{getLineDataLabel(e){if(!e)return"";const t=this.paramsNameMap[e.paramId];return t?t.paramName:e.paramId},setTargetData(e){this.targetData=e,this.setExpanded();switch(b(e)){case"template":this.templateContentShow=!0,this.laneContentShow=!1,this.lineContentShow=!1,this.templateDisable=!0,this.templateInfo=e;break;case"lane":this.templateContentShow=!1,this.laneContentShow=!0,this.lineContentShow=!1,this.templateDisable=!0,this.laneInfo=e;break;case"line":this.templateContentShow=!1,this.laneContentShow=!1,this.lineContentShow=!0,this.templateDisable=!0,this.lineInfo=e}},setExpanded(){const e=this.targetData;if(e){switch(b(e)){case"template":this.expandedKeys=[e.templateId],this.currentNodeKey=e.templateId;break;case"lane":this.expandedKeys=[e.laneId],this.currentNodeKey=e.laneId;break;case"line":this.expandedKeys=[e.lineId],this.currentNodeKey=e.lineId;break;default:this.expandedKeys=[],this.currentNodeKey=""}}else this.expandedKeys=[],this.currentNodeKey="";this.$refs.refTree&&this.$refs.refTree.setCurrentKey(this.currentNodeKey),this.treeKey=`treeKey${(new Date).getTime()}`},optionClicked(e){const{option:t={},item:n}=e;switch(t.key){case"delTemplate":this.askForDelTemplate(n);break;case"addLane":this.addLane(n);break;case"delLane":this.askForDelLane(n);break;case"addParam":this.addParam(n);break;case"delParam":this.delParam(n)}},hideContextMenu(){const e=this.$refs.vueSimpleContextMenu;e&&e.hideContextMenu()},showRightWindows(e,t,n){const a=this.judgeDataType(n);this.dataType=a,"SYSTEM_USER"!=t.createUser?this.$refs.vueSimpleContextMenu.showMenu(e,t):this.$message.warning("系统模板不能编辑")},clear(){this.expandedKeys=[],this.templateDisable=!0,this.templateContentShow=!1},editable(){this.templateDisable=!1},handleNodeClick(e){this.setTargetData(e)},judgeDataType(e){const{level:t,data:n={}}=e;return 1==t&&n.templateId?"template":2==t&&n.laneId&&n.templateId?"lane":3==t&&n.lineId?"line":null},addTemplate(){this.templateContentShow=!0,this.laneContentShow=!1,this.lineContentShow=!1,this.templateDisable=!1,this.templateInfo={isPublic:"0",baseTemplate:"",col1:"1"}},addLane(e){this.templateContentShow=!1,this.laneContentShow=!0,this.lineContentShow=!1,this.templateDisable=!1,this.laneInfo={templateId:e.templateId,isUsed:"1",sort:e.lanes.length+1}},addParam(e){this.templateContentShow=!1,this.laneContentShow=!1,this.lineContentShow=!0,this.templateDisable=!1,this.lineInfo={laneId:e.laneId,isUsed:"1",lineSize:2}},askForDelTemplate(e){this.$confirm("此操作将删除该模板, 是否继续?","提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then(()=>(e.bsflag="1",this.curveConfigLoading=!0,this.delTemplate instanceof Function?this.delTemplate(e):Promise.reject(new Error("未配置删除模板函数")))).catch(e=>{this.$message.error(e.message||"删除失败")}).finally(()=>{this.curveConfigLoading=!1})},askForDelLane(e){this.$confirm("此操作将删除该泳道, 是否继续?","提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then(()=>(e.bsflag="1",this.curveConfigLoading=!0,this.delLane instanceof Function?this.delLane(e):Promise.reject(new Error("未配置删除模板函数")))).catch(()=>{this.$message.error("删除失败")}).finally(()=>{this.curveConfigLoading=!1})},delParam(e){this.$confirm("此操作将删除该参数, 是否继续?","提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then(()=>(e.bsflag="1",this.delLine instanceof Function?this.delLine(e):Promise.reject(new Error("未配置删除线条函数")))).catch(e=>{this.$message.error(e.message||"删除失败")})}},computed:{contextMenuOptions(){switch(this.dataType){case"template":return[{name:"新增泳道",key:"addLane"},{name:"删除模板",key:"delTemplate"}];case"lane":return[{name:"新增参数",key:"addParam"},{name:"删除泳道",key:"delLane"}];case"line":return[{name:"删除参数",key:"delParam"}];default:return[]}},treeData(){if(this.inputTempates){const e=[];return this.inputTempates.forEach(t=>{const n={...t,id:t.templateId,label:t.templateName};n.children=[],t.lanes||(t.lanes=[]),t.lanes.forEach((e,t)=>{const a={...e,id:e.laneId,label:`泳道${t+1}`};n.children.push(a),a.lines||(a.lines=[]),a.children=[],e.lines.forEach(e=>{const t={...e,id:e.lineId,label:e.lineName||e.paramId};t.label=this.getLineDataLabel(e),a.children.push(t)})}),e.push(n)}),e}return[]},userTemplate(){return this.treeData?[...this.treeData]:[]}},watch:{contextItem:{immediate:!0,deep:!0,handler(e){this.setTargetData(Object.assign({},e))}}},beforeDestroy(){}};s(".kd-lane-el-container {\n height: 60vh;\n border: 1px solid var(--kd-lane-container-border-color, #333);\n width: 100%;\n}\n@media screen and (max-width: 1024px) {\n.kd-lane-el-container {\n height: 70vh;\n}\n}\n.kd-lane-el-container .rtd-config-side {\n border-right: 1px solid var(--kd-lane-container-border-color, #333);\n}\n.kd-lane-el-container .rtd-config-side-tree {\n height: 90%;\n overflow: auto;\n}\n.kd-lane-el-container .rtd-config-side-option {\n text-align: center;\n}\n.kd-lane-el-container .rtd-config-main {\n display: flex;\n align-content: center;\n justify-content: center;\n width: 100%;\n}");const O=$;var B=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("el-container",{directives:[{name:"loading",rawName:"v-loading",value:e.curveConfigLoading,expression:"curveConfigLoading"}],staticClass:"kd-lane-el-container"},[n("el-aside",{staticClass:"rtd-config-side",attrs:{width:"20%"}},[n("el-tree",{key:e.treeKey,ref:"refTree",staticClass:"rtd-config-side-tree",attrs:{data:e.treeData,"expand-on-click-node":!1,"current-node-key":e.currentNodeKey,"default-expanded-keys":e.expandedKeys,"node-key":"id","highlight-current":""},on:{"node-click":e.handleNodeClick,"node-expand":e.hideContextMenu,"node-collapse":e.hideContextMenu},scopedSlots:e._u([{key:"default",fn:function(t){var a=t.node,r=t.data;return n("span",{staticClass:"custom-tree-node",on:{contextmenu:function(t){return t.preventDefault(),e.showRightWindows(t,r,a)}}},[n("span",[e._v(e._s(a.label))]),e._v(" "),n("span",{directives:[{name:"show",rawName:"v-show",value:"1"==r.isPublic,expression:"data.isPublic == '1'"}],staticStyle:{"padding-left":"5px"}},[n("i",{staticClass:"el-icon-star-on"})])])}}])}),e._v(" "),n("div",{staticClass:"rtd-config-side-option"},[n("el-button",{on:{click:e.addTemplate}},[e._v("新增模板")])],1)],1),e._v(" "),n("el-main",{staticClass:"rtd-config-main"},[n("TemplateEdit",e._g({directives:[{name:"show",rawName:"v-show",value:e.templateContentShow,expression:"templateContentShow"}],attrs:{currentTemplate:e.templateInfo,"form-disable":e.templateDisable,userTemplate:e.userTemplate,caseId:e.caseId},on:{editable:e.editable}},e.$listeners)),e._v(" "),n("LaneEdit",e._g({directives:[{name:"show",rawName:"v-show",value:e.laneContentShow,expression:"laneContentShow"}],attrs:{laneInfo:e.laneInfo,"form-disable":e.templateDisable},on:{editable:e.editable}},e.$listeners)),e._v(" "),n("LineEdit",e._g({directives:[{name:"show",rawName:"v-show",value:e.lineContentShow,expression:"lineContentShow"}],attrs:{template:e.lineInfo,params:e.params,"form-disable":e.templateDisable},on:{editable:e.editable}},e.$listeners))],1),e._v(" "),n("VueSimpleContextMenu",{ref:"vueSimpleContextMenu",attrs:{"element-id":"kd-lane-chart-context-menu-2",options:e.contextMenuOptions},on:{"option-clicked":e.optionClicked}})],1)};B._withStripped=!0;const j=T({render:B,staticRenderFns:[]},undefined,O,undefined,false,undefined,!1,void 0,void 0,void 0);var U={props:{itemHeight:{type:Number,default:20},line:{type:Object,default:()=>{}},paramsNameMap:{type:Object,default:()=>{},required:!0},themeName:{type:String,default:void 0}},methods:{getParamName(e){if(!e)return"";const t=this.paramsNameMap[e.paramId];return t?`${t.paramName}${t.paramUnit}`:""},toggleIsUsed(){const e={...this.line};"1"==e.isUsed||1==e.isUsed?e.isUsed="0":e.isUsed="1",this.$emit("updateLine",e)}},computed:{gradientDisplay(){let e,t;return this.themeName&&this.line.themeConfig&&(e=this.line.themeConfig[this.themeName]?.lineColor),t=this.line.isGradient?{background:`${e||this.line.lineColor}`}:{},t},textColor(){let e;return this.themeName&&this.line.themeConfig&&!this.line.isGradient&&(e=this.line.themeConfig[this.themeName]?.lineColor),{color:e||this.line.lineColor}},headerItemStyle(){let e,t;return this.themeName&&this.line.themeConfig&&(e=this.line.themeConfig[this.themeName]?.lineColor),t="area"==this.line.lineType?this.line.isGradient?{}:{"box-shadow":`inset 0 0 8px 0px ${e||this.line.lineColor}`}:{"border-bottom":`2px ${this.line.lineType} ${e||this.line.lineColor}`},{height:`${this.itemHeight}px`,opacity:"1"==this.line.isUsed?1:.5,...t}}},watch:{}};s('@charset "UTF-8";\n.kd-lane-chart-container-header-item {\n color: var(--kd-lane-container-header-item-color, #333);\n border: unset;\n position: relative;\n cursor: pointer;\n}\n.kd-lane-chart-container-header-item .kd-lane-chart-container-text-container {\n height: 100%;\n width: 100%;\n font-size: 10px;\n font-weight: bold;\n position: relative;\n}\n.kd-lane-chart-container-header-item .kd-lane-chart-container-text-container .left {\n position: absolute;\n left: 0;\n bottom: 2px;\n}\n.kd-lane-chart-container-header-item .kd-lane-chart-container-text-container .center {\n position: absolute;\n left: 50%;\n bottom: 2px;\n transform: translateX(-50%);\n /* 文字不换行,超出显示省略号 */\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.kd-lane-chart-container-header-item .kd-lane-chart-container-text-container .right {\n position: absolute;\n right: 0;\n bottom: 2px;\n}\n.kd-lane-chart-container-header-item .kd-lane-chart-container-text-container .gradient-display {\n position: absolute;\n height: 2px;\n left: 0;\n bottom: 0;\n right: 0;\n}');const V=U;var q=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"kd-lane-chart-container-header-item",style:e.headerItemStyle,on:{click:e.toggleIsUsed}},[n("div",{staticClass:"kd-lane-chart-container-text-container"},[n("span",{staticClass:"left",style:e.textColor},[e._v(e._s(e.line.min))]),e._v(" "),n("span",{staticClass:"center"},[e._v(e._s(e.getParamName(e.line)))]),e._v(" "),n("span",{staticClass:"right",style:e.textColor},[e._v(e._s(e.line.max))]),e._v(" "),n("div",{staticClass:"gradient-display",style:e.gradientDisplay})])])};q._withStripped=!0;const K=T({render:q,staticRenderFns:[]},undefined,V,undefined,false,undefined,!1,void 0,void 0,void 0);var F={name:"KdLaneChartContainer",provide(){return{upsertTemplate:this.upsertTemplate,delTemplate:this.delTemplate,upsertLane:this.upsertLane,delLane:this.delLane,upsertLine:this.upsertLine,delLine:this.delLine}},components:{HeaderItem:K,RealTimeCurveConfig:j},props:{config:{type:Object,required:!0,validator:function(e){if("object"!=typeof e||null===e)throw new Error("配置必须是一个对象");if(!("type"in e))throw new Error("配置必须包含 type 属性");if(!("caseId"in e)||!("versionCode"in e))throw new Error("配置必须包含 caseId, versionCode 属性");const{type:t}=e;if("local"===t){if(!("dataSource"in e)||null==e.dataSource)throw new Error("local 类型的配置必须包含 dataSource 属性");if(!("params"in e.dataSource))throw new Error("local 类型的配置 dataSource 必须包含 params 属性")}else{if("custom"!==t)throw new Error('type 必须是 "local" 或 "custom"');{const t=["getUserTemplates","upsertTemplate","delTemplate","upsertLane","delLane","upsertLine","delLine"];for(const n of t)if("function"!=typeof e[n])throw new Error(`${n} 必须是一个函数`)}}return!0}},headerPadding:{type:Number,default:4},headerItemHeight:{type:Number,default:20},itemGap:{type:Number,default:2},customMenuList:{type:Array,default:()=>[]},themeName:{type:String,default:void 0}},data:()=>({treeTemplates:null,isLoading:!1,strategy:null,currentTemplate:{},curveConfigVisible:!1,params:[],contextItem:void 0}),created(){this.strategy=I.createStrategy(this.$props.config),this.loadConfig()},mounted(){},methods:{setExpanded(){this.$refs.curveConfig.setExpanded()},delLine(e){return this.strategy.delLine(e).then(()=>{const t=this.currentTemplate.lanes,n=t.findIndex(t=>t.laneId==e.laneId);if(n<0)for(const t of this.treeTemplates){const{lanes:n}=t;for(const t of n)if(t.laneId==e.laneId){const{lines:n}=t,a=n.findIndex(t=>t.lineId==e.lineId);a<0?console.warn("要删除的线条在当前泳道中不存在?"):n.splice(a,1);break}}else{const a=t[n].lines.findIndex(t=>t.lineId==e.lineId);a<0?console.warn("要删除的线条在当前泳道中不存在?"):t[n].lines.splice(a,1),this.onLineChange(e)}})},upsertLine(e){return this.strategy.upsertLine(e).then(e=>{const t=this.currentTemplate.lanes,n=t.findIndex(t=>t.laneId==e.laneId);if(!(n<0)){const a=t[n],r=a.lines,s=r.findIndex(t=>t.lineId==e.lineId);return s<0?r.push(e):this.$set(r,s,e),this.$set(t,n,a),g(a),this.onLineChange(e),e}for(const t of this.treeTemplates){const{lanes:n}=t;for(const t of n)if(t.laneId==e.laneId){const{lines:n}=t,a=n.findIndex(t=>t.lineId==e.lineId);a<0?n.push(e):this.$set(n,a,e),g(t);break}}})},delLane(e){return this.strategy.delLane(e).then(e=>{const{templateId:t}=e,n=this.treeTemplates.findIndex(e=>e.templateId==t);if(n<0)return void console.warn(`template_id not found: '${t}'`);const a=this.treeTemplates[n],r=a.lanes.findIndex(t=>t.laneId==e.laneId);a.lanes.splice(r,1),this.currentTemplate.templateId==t&&this.setDefaultAndNotify()})},upsertLane(e){return this.strategy.upsertLane(e).then(e=>{const t=this.treeTemplates.findIndex(t=>t.templateId==e.templateId);if(t<0)console.warn("template not found");else{const n=this.treeTemplates[t],a=n.lanes||[],r=a.findIndex(t=>t.laneId==e.laneId);r<0?a.push(e):this.$set(a,r,e),S(n.lanes),n.templateId===this.currentTemplate.templateId&&this.setDefaultAndNotify()}return e})},delTemplate(e){return this.strategy.deleteTemplate(e).then(()=>{const t=this.treeTemplates.findIndex(t=>t.templateId===e.templateId);this.treeTemplates.splice(t,1),e.templateId==this.currentTemplate.templateId&&this.setDefaultAndNotify()})},upsertTemplate(e){return this.strategy.upsertTemplate(e).then(e=>{"1"==e.isPublic&&this.treeTemplates.forEach(e=>{e.isPublic="0"});const t=this.treeTemplates.findIndex(t=>t.templateId===e.templateId);if(t>=0){const n=this.treeTemplates[t],a=Object.assign({},n,e);this.$set(this.treeTemplates,t,a)}else this.treeTemplates.push(e);return y(this.treeTemplates),this.setDefaultAndNotify(),e})},onParentContextMenu(e){const t=".kd-lane-chart-lane-header";if(!(e.target&&(e.target.classList.contains(t)||e.target.closest(t)))){e.preventDefault();const t=this.$refs.vueSimpleContextMenu;t&&t.hideContextMenu()}},showContextMenu(e,t){e.stopPropagation(),this.$refs.vueSimpleContextMenu.showMenu(e,t)},optionClicked(e){const{option:t,item:n}=e;this.contextItem=n;const a=this.customMenuList.findIndex(e=>e.key==t.key);if(a<0){if("editTemplate"==t.key)this.curveConfigVisible=!0;else if("restoreSetting"==t.key)return this.restoreSetting()}else this.$emit("onCustomMenuClicked",e)},restoreSetting(){return this.strategy.restoreSetting().then(()=>{this.loadConfig()})},loadConfig(){this.isLoading=!0,this.strategy.getUserTemplates().then(e=>{const{templates:t=[],params:n=[]}=e;this.params=n,y(t),this.treeTemplates=t,this.setDefaultAndNotify()}).catch(e=>{console.error(`加载配置失败: ${this.$props.strategy.caseId},${this.$props.strategy.versionCode},${e.message}`)}).finally(()=>{this.isLoading=!1})},onLineChange(e){console.log("notify line change",e),this.$emit("line-change",e)},setDefaultAndNotify(){const e=this.treeTemplates.find(e=>"1"===e.isPublic);if(e)this.currentTemplate=e;else{const e=this.treeTemplates.find(e=>"SYSTEM_USER"==e.createUser);e?(e.isPublic="1",this.currentTemplate=e,this.strategy.upsertTemplate(e)):(this.treeTemplates[0].isPublic="1",this.currentTemplate=this.treeTemplates[0],this.strategy.upsertTemplate(this.currentTemplate))}this.$emit("template-change",this.currentTemplate)}},computed:{contextMenuOptions(){return"local"==this.config.type?[{name:"编辑模板",key:"editTemplate"},{name:"恢复默认",key:"restoreSetting"},...this.customMenuList]:[{name:"编辑模板",key:"template"},...this.customMenuList]},paramsNameMap(){const e={};for(const t of this.params)e[t.paramId]={paramName:t.paramName,paramUnit:t.paramUnit};return e},lineCount(){const{lanes:e=[]}=this.currentTemplate||{};return Math.max(...e.map(e=>e.lines?.length||0))},headerStyle(){const e={gap:`${this.itemGap}px`,padding:`${this.headerPadding}px`};if(this.currentTemplate){const{lanes:t=[]}=this.currentTemplate;if(t&&0!=t.length){const t=Math.max(0,this.lineCount-1);return{...e,height:this.lineCount*this.headerItemHeight+2*this.headerPadding+t*this.itemGap+"px","min-height":"60px"}}return{...e,height:"30%","min-height":"60px"}}return{...e,height:"30%","min-height":"60px"}},slotHeaderStyle(){if(this.currentTemplate){const{lanes:e=[]}=this.currentTemplate;if(e&&0!=e.length){const e=Math.max(0,this.lineCount-1);return{height:this.lineCount*this.headerItemHeight+2*this.headerPadding+e*this.itemGap+"px","min-height":"60px"}}return{height:"30%","min-height":"60px"}}return{height:"30%","min-height":"60px"}},darwAreaStyle(){const e=this.headerStyle,t=f(e.height),n=f(e["min-height"]);return{top:`${Math.max(t,n)}px`}}}};s(".kd-lane-chart-container {\n --border-color: var(--kd-lane-container-border-color, #333);\n --context-background-color: var(--kd-lane-container-context-background-color, #ecf0f1);\n --context-hover-color: var(--kd-lane-container-context-hover-color, #007aff);\n height: 100%;\n width: 100%;\n overflow: hidden;\n position: relative;\n border: 1px solid var(--border-color);\n display: flex;\n}\n.kd-lane-chart-container .kd-lane-chart-lane-slot-container, .kd-lane-chart-container .kd-lane-chart-lane-container {\n height: 100%;\n min-width: 0;\n overflow: hidden;\n z-index: 1;\n}\n.kd-lane-chart-container .kd-lane-chart-lane-slot-container .kd-lane-chart-lane-header, .kd-lane-chart-container .kd-lane-chart-lane-container .kd-lane-chart-lane-header {\n max-height: 40%;\n border-bottom: 1px solid var(--border-color);\n overflow: hidden;\n z-index: 2;\n display: flex;\n flex-direction: column;\n justify-content: center;\n}\n.kd-lane-chart-container .kd-lane-chart-lane-container {\n flex: 1;\n}\n.kd-lane-chart-container .kd-lane-chart-lane-slot-container {\n width: auto;\n}\n.kd-lane-chart-container .border-left {\n border-left: 1px solid var(--border-color);\n}\n.kd-lane-chart-container .kd-lane-chart-container-draw-area {\n position: absolute;\n left: 0;\n right: 0;\n bottom: 0;\n z-index: 3;\n border: none;\n}\n.vue-simple-context-menu {\n background-color: var(--context-background-color);\n position: fixed;\n}\n.vue-simple-context-menu .vue-simple-context-menu__item:hover {\n background: var(--context-hover-color);\n}");const H=F;var X=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{directives:[{name:"loading",rawName:"v-loading",value:e.isLoading,expression:"isLoading"}],staticClass:"kd-lane-chart-container",on:{contextmenu:e.onParentContextMenu}},[e.currentTemplate&&e.currentTemplate.lanes&&e.currentTemplate.lanes.length>0?[e._l(e.currentTemplate.lanes||[],function(t,a){return[e.$scopedSlots["lane"+t.laneId]?n("div",{key:t.laneId,staticClass:"kd-lane-chart-lane-slot-container",class:{"border-left":0!=a}},[n("div",{staticClass:"kd-lane-chart-lane-header",style:e.slotHeaderStyle},[e._t("lane"+t.laneId,null,{lane:t})],2)]):e.$slots["lane"+t.laneId]?n("div",{key:""+t.laneId,staticClass:"kd-lane-chart-lane-slot-container",class:{"border-left":0!=a}},[n("div",{staticClass:"kd-lane-chart-lane-header",style:e.slotHeaderStyle},[e._t("lane"+t.laneId,null,{lane:t})],2)]):[n("div",{key:t.laneId,staticClass:"kd-lane-chart-lane-container",class:{"border-left":0!=a}},[n("div",{staticClass:"kd-lane-chart-lane-header",style:e.headerStyle,on:{contextmenu:function(n){return n.preventDefault(),e.showContextMenu(n,t)}}},e._l(t.lines||[],function(t){return n("HeaderItem",{key:t.lineId,attrs:{itemHeight:e.headerItemHeight,line:t,paramsNameMap:e.paramsNameMap,themeName:e.themeName},on:{updateLine:e.upsertLine},nativeOn:{contextmenu:function(n){return n.preventDefault(),e.showContextMenu(n,t)}}})}),1)])]]})]:[n("div",{staticClass:"kd-lane-chart-lane-container"},[n("div",{staticClass:"kd-lane-chart-lane-header",style:e.headerStyle,on:{contextmenu:function(t){return t.preventDefault(),e.showContextMenu.apply(null,arguments)}}})])],e._v(" "),n("div",{staticClass:"kd-lane-chart-container-draw-area",style:e.darwAreaStyle},[e._t("draw-slot")],2),e._v(" "),n("VueSimpleContextMenu",{ref:"vueSimpleContextMenu",attrs:{"element-id":"kd-lane-chart-context-menu",options:e.contextMenuOptions},on:{"option-clicked":e.optionClicked}}),e._v(" "),n("el-dialog",{attrs:{title:"泳道模板设置",visible:e.curveConfigVisible},on:{"update:visible":function(t){e.curveConfigVisible=t},opened:e.setExpanded}},[n("RealTimeCurveConfig",e._g({ref:"curveConfig",attrs:{inputTempates:e.treeTemplates,caseId:e.strategy.caseId,params:e.params,paramsNameMap:e.paramsNameMap,contextItem:e.contextItem}},e.$listeners))],1)],2)};X._withStripped=!0;const z=T({render:X,staticRenderFns:[]},undefined,H,undefined,false,undefined,!1,void 0,void 0,void 0),W=e=>{e.use(a.default),e.component(d.name,d),e.component(z.name,z)};return"undefined"!=typeof window&&window.Vue&&window.Vue.use(W),{install:W}});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("vue"),require("v-click-outside")):"function"==typeof define&&define.amd?define(["vue","v-click-outside"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).KdLaneChartContainer=t(e.Vue,e.vClickOutside)}(this,function(e,t){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=n(e),r=n(t);class s{constructor(e){this.strategy=e}getUserTemplates(){return this.strategy.getUserTemplates()}upsertTemplate(e){return this.strategy.upsertTemplate(e)}delTemplate(e){return this.strategy.deleteTemplate(e)}upsertLane(e){return this.strategy.upsertLane(e)}delLane(e){return this.strategy.deleteLane(e)}upsertLine(e){return this.strategy.upsertLine(e)}delLine(e){return this.strategy.delLine(e)}restoreSetting(){return this.strategy.restoreSetting?this.strategy.restoreSetting():Promise.resolve()}}class i{static DB_NAME="KDLaneChartContainerConfigDB";static MAX_UNICODE_CHAR="";static DB_VERSION=2;static STORE_NAMES={TEMPLATES:"templates",LANES:"lanes",LINES:"lines",PARAMS:"params",CASE_VERSIONS:"case_versions"};_db=null;_openDB(){return new Promise((e,t)=>{if(this._db)return void e(this._db);const n=indexedDB.open(i.DB_NAME,i.DB_VERSION);n.onupgradeneeded=e=>{const t=e.target.result,{STORE_NAMES:n}=i;t.objectStoreNames.contains(n.CASE_VERSIONS)||t.createObjectStore(n.CASE_VERSIONS,{keyPath:"caseId"}),t.objectStoreNames.contains(n.TEMPLATES)||t.createObjectStore(n.TEMPLATES,{keyPath:["caseId","templateId"]}),t.objectStoreNames.contains(n.LANES)||t.createObjectStore(n.LANES,{keyPath:["caseId","laneId"]}),t.objectStoreNames.contains(n.LINES)||t.createObjectStore(n.LINES,{keyPath:["caseId","lineId"]}),t.objectStoreNames.contains(n.PARAMS)||t.createObjectStore(n.PARAMS,{keyPath:["caseId","paramId"]})},n.onsuccess=t=>{this._db=t.target.result,this._db.onclose=()=>{this._db=null},e(this._db)},n.onerror=e=>{t(new Error(`打开数据库失败:${e.target.error.message}`))},n.onblocked=()=>{t(new Error("数据库操作被阻塞,请关闭其他标签页后重试"))}})}closeDB(){return new Promise(e=>{this._db&&(this._db.close(),this._db=null),e()})}_compareVersion(e,t){const n=e=>String(e).split(".").map(Number),a=n(e),r=n(t),s=Math.max(a.length,r.length);for(let e=0;e<s;e++){const t=a[e]||0,n=r[e]||0;if(t>n)return 1;if(t<n)return-1}return 0}_clearSceneData(e){return this._openDB().then(t=>new Promise((n,a)=>{const r=t.transaction([i.STORE_NAMES.CASE_VERSIONS,i.STORE_NAMES.TEMPLATES,i.STORE_NAMES.LANES,i.STORE_NAMES.LINES,i.STORE_NAMES.PARAMS],"readwrite"),s=r.objectStore(i.STORE_NAMES.TEMPLATES),o=r.objectStore(i.STORE_NAMES.LANES),l=r.objectStore(i.STORE_NAMES.LINES),d=r.objectStore(i.STORE_NAMES.CASE_VERSIONS),c=r.objectStore(i.STORE_NAMES.PARAMS),m=IDBKeyRange.bound([e],[e,i.MAX_UNICODE_CHAR]);s.delete(m),o.delete(m),l.delete(m),c.delete(m),d.delete(e),r.oncomplete=()=>n(),r.onerror=e=>a(new Error(`事务失败:${e.target.error.message}`))}))}_promisifyRequest(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}forceInitSceneConfig(e,t,n){return e&&t?this._clearSceneData(e).then(()=>{const a=this.setUpData(e,t,n);return this.batchAddConfig(a)}).catch(e=>{throw new Error(`强制初始化场景配置失败:${e.message}`)}):Promise.reject(new Error("caseId和versionCode为强制初始化的必传参数"))}setUpData(e,t,n){const a=n.templates.map(t=>({...t,caseId:e})),r=n.lanes.map(t=>({...t,caseId:e})),s=n.lines.map(t=>({...t,caseId:e})),i=n.params.map(t=>({...t,caseId:e}));return{caseVersion:{caseId:e,versionCode:t,updateTime:new Date},templates:a,lanes:r,lines:s,params:i}}checkConfigIntegrity(e,t){return this.getCaseVersionByCaseId(e).then(n=>!(!n||n.versionCode!==t)&&this.getTemplatesByCaseId(e).then(t=>{if(0===t.length)return!0;const n=t[0].templateId;return this.getLanesByTemplateId(e,n).then(t=>{if(0===t.length)return!0;const n=t[0].laneId;return this.getLinesByLaneId(e,n).then(e=>0===e.length)})}))}_initSceneConfig(e){const{caseVersion:t}=e,{caseId:n,versionCode:a}=t;return this.getCaseVersionByCaseId(n).then(t=>{if(!t)return this.batchAddConfig(e);const r=this._compareVersion(a,t.versionCode);if(r>0)return this._clearSceneData(n).then(()=>this.batchAddConfig(e));if(0===r)return console.log(`场景${n}已存在版本${a},无需重复创建`),Promise.resolve(t);throw new Error(`场景${n}当前版本${t.versionCode}高于待创建版本${a}。`)})}saveSceneConfig(e,t,n){if(!e||!t)return Promise.reject(new Error("caseId和versionCode为必传参数"));if(!Array.isArray(n.templates)||!Array.isArray(n.lanes)||!Array.isArray(n.lines))return Promise.reject(new Error("templates/lanes/lines必须为数组"));const a=this.setUpData(e,t,n);return this._initSceneConfig(a)}batchAddConfig(e){return this._openDB().then(t=>new Promise((n,a)=>{const r=t.transaction([i.STORE_NAMES.CASE_VERSIONS,i.STORE_NAMES.TEMPLATES,i.STORE_NAMES.LANES,i.STORE_NAMES.LINES,i.STORE_NAMES.PARAMS],"readwrite");r.objectStore(i.STORE_NAMES.CASE_VERSIONS).put(e.caseVersion);const s=r.objectStore(i.STORE_NAMES.TEMPLATES);e.templates.forEach(e=>s.put(e));const o=r.objectStore(i.STORE_NAMES.LANES);e.lanes.forEach(e=>o.put(e));const l=r.objectStore(i.STORE_NAMES.LINES);e.lines.forEach(e=>l.put(e));const d=r.objectStore(i.STORE_NAMES.PARAMS);e.params.forEach(e=>d.put(e)),r.oncomplete=()=>n(e),r.onerror=e=>a(new Error(`批量添加配置失败:${e.target.error.message}`))}))}upsertCaseVersion(e){return this._openDB().then(t=>new Promise((n,a)=>{const r=t.transaction([i.STORE_NAMES.CASE_VERSIONS],"readwrite").objectStore(i.STORE_NAMES.CASE_VERSIONS),s={updateTime:new Date,...e};this._promisifyRequest(r.put(s)).then(()=>n(s)).catch(e=>a(new Error(`更新场景版本失败:${e.message}`)))}))}getCaseVersionByCaseId(e){return this._openDB().then(t=>new Promise((n,a)=>{const r=t.transaction([i.STORE_NAMES.CASE_VERSIONS],"readonly").objectStore(i.STORE_NAMES.CASE_VERSIONS);this._promisifyRequest(r.get(e)).then(e=>n(e||null)).catch(e=>a(new Error(`查询场景版本失败:${e.message}`)))}))}getConfigByCaseId(e){return e?Promise.all([this.getCaseVersionByCaseId(e),this.getTemplatesByCaseId(e),this.getParamsByCaseId(e)]).then(([t,n,a])=>{const r=n.map(t=>this.getLanesByTemplateId(e,t.templateId).then(n=>{const a=n.map(t=>this.getLinesByLaneId(e,t.laneId).then(e=>({...t,lines:e})));return Promise.all(a).then(e=>({...t,lanes:e}))}));return Promise.all(r).then(e=>({caseVersion:t,templates:e,params:a}))}).catch(e=>{throw new Error(`查询场景配置失败:${e.message}`)}):Promise.reject(new Error("caseId为必传参数"))}getConfigByTemplateId(e,t){if(!e||!t)return Promise.reject(new Error("caseId为必传参数"));const n={};return this.getLanesByTemplateId(e,t).then(t=>{const a=t.map(t=>this.getLinesByLaneId(e,t.laneId));return Promise.all(a).then(e=>{e.forEach((e,n)=>{t[n].lines=e}),n.lanes=t})}).then(()=>this.getTemplateById(e,t)).then(e=>(e.lanes=n.lanes,Promise.resolve(e)))}deleteCaseVersion(e){return this._openDB().then(t=>new Promise((n,a)=>{const r=t.transaction([i.STORE_NAMES.CASE_VERSIONS],"readwrite").objectStore(i.STORE_NAMES.CASE_VERSIONS);this._promisifyRequest(r.delete(e)).then(()=>n()).catch(e=>a(new Error(`删除场景版本失败:${e.message}`)))}))}upsertTemplate(e){return this._openDB().then(t=>new Promise((n,a)=>{if(!e.caseId)return void a(new Error("模板数据必须包含caseId"));const r=t.transaction([i.STORE_NAMES.TEMPLATES],"readwrite").objectStore(i.STORE_NAMES.TEMPLATES),s={...e,createDate:e.createDate?new Date(e.createDate):new Date,updateDate:e.updateDate?new Date(e.updateDate):null};return delete s.lanes,this._promisifyRequest(r.put(s)).then(()=>n(s)).catch(e=>a(new Error(`更新模板失败:${e.message}`)))}))}getTemplateById(e,t){return this._openDB().then(n=>new Promise((a,r)=>{const s=n.transaction([i.STORE_NAMES.TEMPLATES],"readonly").objectStore(i.STORE_NAMES.TEMPLATES);this._promisifyRequest(s.get([e,t])).then(e=>a(e||null)).catch(e=>r(new Error(`查询模板失败:${e.message}`)))}))}getTemplatesByCaseId(e){return this._openDB().then(t=>new Promise((n,a)=>{const r=t.transaction([i.STORE_NAMES.TEMPLATES],"readonly").objectStore(i.STORE_NAMES.TEMPLATES),s=IDBKeyRange.bound([e],[e,i.MAX_UNICODE_CHAR]);this._promisifyRequest(r.getAll(s)).then(e=>{n(e||[])}).catch(e=>a(new Error(`查询场景下模板失败:${e.message}`)))}))}deleteTemplate(e,t){return this._openDB().then(n=>new Promise((a,r)=>{const s=n.transaction([i.STORE_NAMES.TEMPLATES],"readwrite").objectStore(i.STORE_NAMES.TEMPLATES);this._promisifyRequest(s.delete([e,t])).then(()=>a()).catch(e=>r(new Error(`删除模板失败:${e.message}`)))}))}upsertLane(e,t){return this._openDB().then(n=>new Promise((a,r)=>{if(!e||!t.templateId)return void r(new Error("泳道数据必须包含caseId和templateId"));const s=n.transaction([i.STORE_NAMES.LANES],"readwrite").objectStore(i.STORE_NAMES.LANES),o={...t,caseId:e,updateDate:t.updateDate?new Date(t.updateDate):new Date};this._promisifyRequest(s.put(o)).then(()=>a(o)).catch(e=>r(new Error(`更新泳道失败:${e.message}`)))}))}getLaneById(e,t){return this._openDB().then(n=>new Promise((a,r)=>{const s=n.transaction([i.STORE_NAMES.LANES],"readonly").objectStore(i.STORE_NAMES.LANES);this._promisifyRequest(s.get([e,t])).then(e=>a(e||null)).catch(e=>r(new Error(`查询泳道失败:${e.message}`)))}))}getLanesByTemplateId(e,t){return this._openDB().then(n=>new Promise((a,r)=>{const s=n.transaction([i.STORE_NAMES.LANES],"readonly").objectStore(i.STORE_NAMES.LANES),o=IDBKeyRange.bound([e],[e,i.MAX_UNICODE_CHAR]);this._promisifyRequest(s.getAll(o)).then(e=>e.filter(e=>e.templateId===t)).then(e=>a(e||[])).catch(e=>r(new Error(`查询模板下泳道失败:${e.message}`)))}))}deleteLaneByLaneIds(e,t){return Array.isArray(t)&&0!==t.length?this._openDB().then(n=>new Promise((a,r)=>{const s=n.transaction([i.STORE_NAMES.LANES],"readwrite"),o=s.objectStore(i.STORE_NAMES.LANES);t.map(t=>this._promisifyRequest(o.delete([e,t]))),s.oncomplete=()=>a(),s.onerror=e=>r(new Error(`删除泳道失败:${e.target.error.message}`))})):Promise.resolve()}upsertLine(e,t){return this._openDB().then(n=>new Promise((a,r)=>{if(!e||!t.laneId)return void r(new Error("线条数据必须包含caseId和laneId"));const s=n.transaction([i.STORE_NAMES.LINES],"readwrite").objectStore(i.STORE_NAMES.LINES),o={...t,caseId:e,updateDate:t.updateDate?new Date(t.updateDate):new Date};this._promisifyRequest(s.put(o)).then(()=>a(o)).catch(e=>r(new Error(`更新线条失败:${e.message}`)))}))}getLineById(e,t){return this._openDB().then(n=>new Promise((a,r)=>{const s=n.transaction([i.STORE_NAMES.LINES],"readonly").objectStore(i.STORE_NAMES.LINES);this._promisifyRequest(s.get([e,t])).then(e=>a(e||null)).catch(e=>r(new Error(`查询线条失败:${e.message}`)))}))}getLinesByLaneId(e,t){return this._openDB().then(n=>new Promise((a,r)=>{const s=n.transaction([i.STORE_NAMES.LINES],"readonly").objectStore(i.STORE_NAMES.LINES),o=IDBKeyRange.bound([e],[e,i.MAX_UNICODE_CHAR]);this._promisifyRequest(s.getAll(o)).then(e=>e.filter(e=>e.laneId===t)).then(e=>a(e||[])).catch(e=>r(new Error(`查询泳道下线条失败:${e.message}`)))}))}deleteLineByIds(e,t){return Array.isArray(t)&&0!==t.length?this._openDB().then(n=>new Promise((a,r)=>{const s=n.transaction([i.STORE_NAMES.LINES],"readwrite"),o=s.objectStore(i.STORE_NAMES.LINES);t.map(t=>this._promisifyRequest(o.delete([e,t]))),s.oncomplete=()=>a(),s.onerror=e=>r(new Error(`批量删除线条失败:${e.target.error.message}`))})):Promise.resolve()}upsertParam(e){return this._openDB().then(t=>new Promise((n,a)=>{if(!e.caseId)return void a(new Error("参数数据必须包含caseId"));const r=t.transaction([i.STORE_NAMES.PARAMS],"readwrite").objectStore(i.STORE_NAMES.PARAMS),s={...e,updateDate:e.updateDate?new Date(e.updateDate):new Date};this._promisifyRequest(r.put(s)).then(()=>n(s)).catch(e=>a(new Error(`更新参数失败:${e.message}`)))}))}getParamById(e,t){return this._openDB().then(n=>new Promise((a,r)=>{const s=n.transaction([i.STORE_NAMES.PARAMS],"readonly").objectStore(i.STORE_NAMES.PARAMS);this._promisifyRequest(s.get([e,t])).then(e=>a(e||null)).catch(e=>r(new Error(`查询参数失败:${e.message}`)))}))}getParamsByCaseId(e){return this._openDB().then(t=>new Promise((n,a)=>{const r=t.transaction([i.STORE_NAMES.PARAMS],"readonly").objectStore(i.STORE_NAMES.PARAMS),s=IDBKeyRange.bound([e],[e,i.MAX_UNICODE_CHAR]);this._promisifyRequest(r.getAll(s)).then(e=>n(e||[])).catch(e=>a(new Error(`查询场景下参数失败:${e.message}`)))}))}deleteParamById(e,t){return this._openDB().then(n=>new Promise((a,r)=>{const s=n.transaction([i.STORE_NAMES.PARAMS],"readwrite").objectStore(i.STORE_NAMES.PARAMS);this._promisifyRequest(s.delete([e,t])).then(()=>a()).catch(e=>r(new Error(`删除参数失败:${e.message}`)))}))}}const o=new i;function l(e){return e&&"string"==typeof e&&parseFloat(e.replace("px",""))||0}function d(e){e&&Array.isArray(e.lines)&&e.lines.sort((e,t)=>(e.lineSort??0)-(t.lineSort??0))}function c(e){Array.isArray(e)&&(e.sort((e,t)=>(e.sort??0)-(t.sort??0)),e.forEach(e=>d(e)))}function m(e){return Array.isArray(e)&&0!==e.length?(e.sort((e,t)=>(e.sort??0)-(t.sort??0)),e.forEach(e=>c(e.lanes)),e):e}function h(e){return e?e.lineId&&e.laneId?"line":e.laneId&&e.templateId&&!e.lineId?"lane":e.templateId?"template":null:null}function p(e=!0){let t="";return t="undefined"!=typeof crypto&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}),e?t.replace(/-/g,""):t}class u{constructor(e,t,n,a=!0){this.caseId=e,this.versionCode=t,this.dataSource=n,this.flatData=a,this.ready=o.saveSceneConfig(e,t,n).catch(a=>(console.warn(`初始化数据库出错,直接重置:${a.message}`),o.forceInitSceneConfig(e,t,n)))}getUserTemplates(){return this.ready.then(()=>o.getConfigByCaseId(this.caseId))}upsertTemplate(e){let t;if(e.templateId)t=o.upsertTemplate(e);else{const n=p();if(e.templateId=n,e.baseTemplate){const a={};t=o.getLanesByTemplateId(this.caseId,e.baseTemplate).then(e=>{a.lanes=e;const t=e.map(e=>o.getLinesByLaneId(this.caseId,e.laneId));return Promise.all(t).then(e=>{const t=[];e.forEach((e,r)=>{const s=p();a.lanes[r].laneId=s,a.lanes[r].templateId=n,a.lanes[r].createUser=void 0,e.forEach(e=>{e.lineId=p(),e.laneId=s,e.createUser=void 0,t.push(e)})}),a.lines=t})}).then(()=>{a.templates=[e]}).then(()=>{a.params=[];const e=o.setUpData(this.caseId,this.versionCode,a);return o.batchAddConfig(e)}).then(()=>o.getTemplateById(this.caseId,n))}else t=o.upsertTemplate(e)}return"1"===e.isPublic?t.then(()=>o.getTemplatesByCaseId(this.caseId).then(t=>t.filter(t=>t.templateId!==e.templateId)).then(e=>{e.forEach(e=>{e.isPublic="0"});const t=e.map(e=>o.upsertTemplate(e));return Promise.all(t)}).then(()=>o.getConfigByTemplateId(this.caseId,e.templateId))):t}deleteTemplate(e){return o.getLanesByTemplateId(this.caseId,e.templateId).then(e=>{const t=e.map(e=>e.laneId);let n=t.map(e=>o.getLinesByLaneId(this.caseId,e));return Promise.all(n).then(e=>{const t=e.reduce((e,t)=>e.concat(t),[]).map(e=>e.lineId);return o.deleteLineByIds(this.caseId,t)}).then(()=>Promise.resolve(t))}).then(e=>o.deleteLaneByLaneIds(this.caseId,e)).then(()=>o.deleteTemplate(this.caseId,e.templateId)).then(()=>Promise.resolve(e))}upsertLane(e){return e.laneId||(e.laneId=p()),e.lines||(e.lines=[]),o.upsertLane(this.caseId,e)}delLane(e){const{lines:t,laneId:n}=e,a=t.map(e=>e.lineId);return o.deleteLineByIds(this.caseId,a).then(()=>o.deleteLaneByLaneIds(this.caseId,[n])).then(()=>Promise.resolve(e))}upsertLine(e){return e.lineId||(e.lineId=p()),e.laneId?o.upsertLine(this.caseId,e):Promise.reject(new Error("更新线条数据的时候,必须laneId不能为空!"))}delLine(e){return e.laneId?o.deleteLineByIds(this.caseId,[e.lineId]):Promise.reject(new Error("更新线条数据的时候,必须laneId不能为空!"))}restoreSetting(){return o.forceInitSceneConfig(this.caseId,this.versionCode,this.dataSource)}getType(){return"local-default"}}class f{static createStrategy(e){if("local"===e.type){let n;if((t=e.dataSource)&&Array.isArray(t.templates)&&Array.isArray(t.lanes)&&Array.isArray(t.lines)&&(0===t.templates.length||!t.templates[0].lanes))n={...e};else{if(!function(e){return Array.isArray(e)?0===e.length||!!e[0]&&Array.isArray(e[0].lanes):!!e&&Array.isArray(e.templates)&&(0===e.templates.length||Array.isArray(e.templates[0].lanes))}(e.dataSource))throw new Error("策略数据源格式不匹配");{const t=function(e){const t=[],n=[],a=[];for(const r of e){const{lanes:e,...s}=r;s.templateId||(s.templateId=p()),t.push(s);for(const t of e||[]){const{lines:e,...r}=t;r.templateId=s.templateId,r.laneId||(r.laneId=p()),n.push(r);for(const t of e||[])t.laneId=r.laneId,t.lineId||(t.lineId=p()),a.push(t)}}return{templates:t,lanes:n,lines:a}}(e.dataSource.templates);n={...e,dataSource:{...t,params:e.dataSource.params}}}}const{caseId:a,versionCode:r,dataSource:s}=n;return new u(a,r,s,!1)}return new s(e);var t}}var g={inject:["upsertTemplate","setTargetData","setExpanded"],props:{currentTemplate:{type:Object},formDisable:{type:Boolean},userTemplate:{type:Array},caseId:{type:String,default:""}},data(){return{formData:Object.assign({sort:void 0},this.currentTemplate),rules:{templateName:[{required:!0,message:"请输入模板名称",trigger:"blur"}]},saving:!1}},methods:{editable(){this.$emit("editable")},submitForm(e){this.$refs[e].validate(e=>{if(!e)return;if("function"!=typeof this.upsertTemplate)return void this.$message({type:"error",message:"没有配置模板管理方法"});this.saving=!0;const t={...this.formData};t.caseId||(t.caseId=this.caseId);const n=this.upsertTemplate(t);n instanceof Promise?n.then(e=>{this.setTargetData(e)}).then(()=>{this.$message({type:"success",message:"保存成功"})}).finally(()=>{this.saving=!1}):this.saving=!1})}},computed:{baseTemplate(){return this.userTemplate?[{name:"空白模板",value:""},...this.userTemplate.map(e=>({name:e.templateName,value:e.templateId}))]:[{name:"空白模板",value:""}]}},watch:{currentTemplate:{deep:!0,handler:function(e){this.formData=Object.assign({},e)}}}};function S(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var a=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css","top"===n&&a.firstChild?a.insertBefore(r,a.firstChild):a.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}}function y(e,t,n,a,r,s,i,o,l,d){"boolean"!=typeof i&&(l=o,o=i,i=!1);const c="function"==typeof n?n.options:n;let m;if(e&&e.render&&(c.render=e.render,c.staticRenderFns=e.staticRenderFns,c._compiled=!0,r&&(c.functional=!0)),a&&(c._scopeId=a),s?(m=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,l(e)),e&&e._registeredComponents&&e._registeredComponents.add(s)},c._ssrRegister=m):t&&(m=i?function(e){t.call(this,d(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,o(e))}),m)if(c.functional){const e=c.render;c.render=function(t,n){return m.call(n),e(t,n)}}else{const e=c.beforeCreate;c.beforeCreate=e?[].concat(e,m):[m]}return n}S(".kd-lane-template-content {\n display: flex;\n flex-direction: column;\n align-content: center;\n}\n.kd-lane-template-content .template-buttons {\n text-align: center;\n}");const b=g;var v=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"kd-lane-template-content"},[n("el-form",{ref:"template",attrs:{rules:e.rules,model:e.formData,"label-width":"120px"}},[n("el-form-item",{attrs:{label:"模板名称",prop:"templateName"}},[n("el-input",{attrs:{disabled:"SYSTEM_USER"==e.currentTemplate.createUser||e.formDisable},model:{value:e.formData.templateName,callback:function(t){e.$set(e.formData,"templateName",t)},expression:"formData.templateName"}})],1),e._v(" "),n("el-form-item",{attrs:{label:"默认模板",prop:"isPublic"}},[n("el-radio-group",{attrs:{disabled:e.formDisable},model:{value:e.formData.isPublic,callback:function(t){e.$set(e.formData,"isPublic",t)},expression:"formData.isPublic"}},[n("el-radio",{attrs:{label:"1"}},[e._v("是")]),e._v(" "),n("el-radio",{attrs:{label:"0"}},[e._v("否")])],1)],1),e._v(" "),n("el-form-item",{attrs:{label:"曲线高度占比",prop:"col1"}},[n("el-select",{attrs:{disabled:e.formDisable},model:{value:e.formData.col1,callback:function(t){e.$set(e.formData,"col1",t)},expression:"formData.col1"}},[n("el-option",{attrs:{value:"0.5",label:"50%"}}),e._v(" "),n("el-option",{attrs:{value:"0.6",label:"60%"}}),e._v(" "),n("el-option",{attrs:{value:"0.7",label:"70%"}}),e._v(" "),n("el-option",{attrs:{value:"0.8",label:"80%"}}),e._v(" "),n("el-option",{attrs:{value:"0.9",label:"90%"}}),e._v(" "),n("el-option",{attrs:{value:"1",label:"全屏"}})],1)],1),e._v(" "),n("el-form-item",{directives:[{name:"show",rawName:"v-show",value:!e.currentTemplate.templateId,expression:"!currentTemplate.templateId"}],attrs:{label:"选择基础模板",prop:"lineType",disabled:e.formDisable}},[n("el-select",{attrs:{placeholder:"请选择"},model:{value:e.formData.baseTemplate,callback:function(t){e.$set(e.formData,"baseTemplate",t)},expression:"formData.baseTemplate"}},e._l(e.baseTemplate,function(e){return n("el-option",{key:e.value,attrs:{label:e.name,value:e.value}})}),1)],1),e._v(" "),n("el-form-item",{attrs:{label:"顺序",prop:"sort","label-width":"120px"}},[n("el-input",{attrs:{disabled:e.formDisable},model:{value:e.formData.sort,callback:function(t){e.$set(e.formData,"sort",e._n(t))},expression:"formData.sort"}})],1)],1),e._v(" "),n("div",{staticClass:"template-buttons"},[n("el-button",{on:{click:e.editable}},[e._v("编辑")]),e._v(" "),n("el-button",{attrs:{type:"primary",disabled:e.formDisable,loading:e.saving},on:{click:function(t){return e.submitForm("template")}}},[e._v("保存")])],1)],1)};v._withStripped=!0;const I=y({render:v,staticRenderFns:[]},undefined,b,undefined,false,undefined,!1,void 0,void 0,void 0);var E={inject:["upsertLane","setTargetData","setExpanded"],props:{laneInfo:{type:Object},caseId:{type:String,default:""},formDisable:{type:Boolean}},data(){return{formData:Object.assign(this.laneInfo),rules:{sort:[{required:!0,message:"请输入泳道顺序",trigger:"blur"}]},saving:!1}},methods:{editable(){this.$emit("editable")},submitForm(e){this.$refs[e].validate(e=>{if(!e)return;if("function"!=typeof this.upsertLane)return void this.$message({type:"error",message:"没有配置泳道管理方法"});this.saving=!0;const t={...this.formData};t.caseId||(t.caseId=this.caseId);const n=this.upsertLane(t);n instanceof Promise?n.then(e=>{this.setTargetData(e)}).then(()=>{this.$message({type:"success",message:"保存成功"})}).finally(()=>{this.saving=!1}):this.saving=!1})}},computed:{},watch:{laneInfo:{deep:!0,handler:function(e){this.formData=Object.assign({},e)}}}};S(".kd-lane-lane-content {\n display: flex;\n flex-direction: column;\n align-content: center;\n}\n.kd-lane-lane-content .template-buttons {\n text-align: center;\n}");const _=E;var T=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"kd-lane-lane-content"},[n("el-form",{ref:"template",attrs:{rules:e.rules,model:e.formData,"label-width":"120px"}},[n("el-form-item",{attrs:{label:"泳道顺序",prop:"sort"}},[n("el-input",{attrs:{disabled:e.formDisable},model:{value:e.formData.sort,callback:function(t){e.$set(e.formData,"sort",t)},expression:"formData.sort"}})],1)],1),e._v(" "),n("div",{staticClass:"template-buttons"},[n("el-button",{on:{click:e.editable}},[e._v("编辑")]),e._v(" "),n("el-button",{attrs:{type:"primary",disabled:e.formDisable,loading:e.saving},on:{click:function(t){return e.submitForm("template")}}},[e._v("保存")])],1)],1)};T._withStripped=!0;const x=y({render:T,staticRenderFns:[]},undefined,_,undefined,false,undefined,!1,void 0,void 0,void 0);var w={inject:["upsertLine","setTargetData","setExpanded"],props:{template:{type:Object},formDisable:{type:Boolean},params:{type:Array}},mounted(){},data(){const e=(e,t,n)=>{isNaN(t)?n(new Error("请输入数字值")):n()};return{formData:Object.assign({},this.template),lines:[{name:"直线",value:"solid"},{name:"虚线",value:"dashed"},{name:"点线",value:"dotted"},{name:"面积",value:"area"}],lineWidthSliderMarks:{1:"1",2:"2",3:"3",4:"4"},rules:{min:[{required:!0,message:"请输入最小值",trigger:"blur"},{validator:e,trigger:"blur"}],lineSort:[{required:!0,message:"请输入曲线顺序(1-10)",trigger:"blur"},{type:"number",message:"顺序必须为数字值"}],max:[{required:!0,message:"请输入最大值",trigger:"blur"},{validator:e,trigger:"blur"}],lineSize:[{required:!0,message:"请选择曲线粗细",trigger:"blur"}],lineColor:[{required:!0,message:"请选择曲线颜色",trigger:"blur"}],lineType:[{required:!0,message:"请选择线型",trigger:"blur"}],paramId:[{required:!0,message:"请选择参数名称",trigger:"blur"}]}}},methods:{editable(){this.$emit("editable")},submitForm(e){this.$refs[e].validate().then(()=>{if(!(this.upsertLine instanceof Function))return Promise.reject(new Error("未配置线条设置函数"));{const e=this.upsertLine(this.formData);e instanceof Promise?e.then(e=>{this.setTargetData(e)}).then(()=>{this.$message({type:"success",message:"保存成功"})}).finally(()=>{this.saving=!1}):this.saving=!1}}).catch(e=>{console.log(e)})}},watch:{template:{immediate:!1,deep:!0,handler(e){this.formData=Object.assign({},e)}}}};S(".kd-lane-line-content {\n width: 95%;\n display: flex;\n flex-direction: column;\n align-content: center;\n}\n.kd-lane-line-content .template-buttons {\n text-align: center;\n}");const C=w;var A=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"kd-lane-line-content"},[n("el-form",{ref:"template",attrs:{rules:e.rules,model:e.formData,disabled:e.formDisable}},[n("el-form-item",{attrs:{label:"参数名称",prop:"paramId","label-width":"120px"}},[n("el-select",{attrs:{filterable:"",placeholder:"请选择"},model:{value:e.formData.paramId,callback:function(t){e.$set(e.formData,"paramId",t)},expression:"formData.paramId"}},e._l(e.params,function(e){return n("el-option",{key:e.paramId,attrs:{label:e.paramName,value:e.paramId}})}),1)],1),e._v(" "),n("el-form-item",{attrs:{label:"最小值",prop:"min","label-width":"120px"}},[n("el-input",{model:{value:e.formData.min,callback:function(t){e.$set(e.formData,"min",t)},expression:"formData.min"}})],1),e._v(" "),n("el-form-item",{attrs:{label:"最大值",prop:"max","label-width":"120px"}},[n("el-input",{model:{value:e.formData.max,callback:function(t){e.$set(e.formData,"max",t)},expression:"formData.max"}})],1),e._v(" "),n("el-form-item",{attrs:{label:"曲线粗细",prop:"lineSize","label-width":"120px"}},[n("el-input",{attrs:{max:4,min:1,type:"number"},model:{value:e.formData.lineSize,callback:function(t){e.$set(e.formData,"lineSize",t)},expression:"formData.lineSize"}})],1),e._v(" "),n("el-form-item",{attrs:{label:"曲线颜色",prop:"lineColor","label-width":"120px"}},[n("el-color-picker",{attrs:{disabled:e.formData.isGradient},model:{value:e.formData.lineColor,callback:function(t){e.$set(e.formData,"lineColor",t)},expression:"formData.lineColor"}})],1),e._v(" "),n("el-form-item",{attrs:{label:"线型",prop:"lineType","label-width":"120px"}},[n("el-select",{attrs:{placeholder:"请选择",disabled:e.formData.isGradient},model:{value:e.formData.lineType,callback:function(t){e.$set(e.formData,"lineType",t)},expression:"formData.lineType"}},e._l(e.lines,function(e){return n("el-option",{key:e.value,attrs:{label:e.name,value:e.value}})}),1)],1),e._v(" "),n("el-form-item",{attrs:{label:"曲线顺序",prop:"lineSort","label-width":"120px"}},[n("el-input",{model:{value:e.formData.lineSort,callback:function(t){e.$set(e.formData,"lineSort",e._n(t))},expression:"formData.lineSort"}})],1),e._v(" "),e._e()],1),e._v(" "),n("div",{directives:[{name:"show",rawName:"v-show",value:"SYSTEM_USER"!=e.template.createUser,expression:"template.createUser != 'SYSTEM_USER'"}],staticClass:"template-buttons"},[n("el-button",{on:{click:e.editable}},[e._v("编辑")]),e._v(" "),n("el-button",{attrs:{type:"primary",disabled:e.formDisable},on:{click:function(t){return e.submitForm("template")}}},[e._v("保存")])],1)],1)};A._withStripped=!0;const D=y({render:A,staticRenderFns:[]},undefined,C,undefined,false,undefined,!1,void 0,void 0,void 0);a.default.use(r.default);var N={name:"VueSimpleContextMenu",props:{elementId:{type:String,required:!0},options:{type:Array,required:!0}},data:()=>({item:null,menuWidth:null,menuHeight:null}),methods:{showMenu(e,t){this.item=t;var n=document.getElementById(this.elementId);n&&(this.menuWidth&&this.menuHeight||(n.style.visibility="hidden",n.style.display="block",this.menuWidth=n.offsetWidth,this.menuHeight=n.offsetHeight,n.removeAttribute("style")),this.menuWidth+e.pageX>=window.innerWidth?n.style.left=e.pageX-this.menuWidth+2+"px":n.style.left=e.pageX-2+"px",this.menuHeight+e.pageY>=window.innerHeight?n.style.top=e.pageY-this.menuHeight+2+"px":n.style.top=e.pageY-2+"px",n.classList.add("vue-simple-context-menu--active"))},hideContextMenu(){const e=document.getElementById(this.elementId);e&&(e.classList.remove("vue-simple-context-menu--active"),this.$emit("menu-closed"))},onClickOutside(){this.hideContextMenu()},optionClicked(e){this.hideContextMenu(),this.$emit("option-clicked",{item:this.item,option:e})},onEscKeyRelease(e){27===e.keyCode&&this.hideContextMenu()}},mounted(){document.body.addEventListener("keyup",this.onEscKeyRelease)},beforeDestroy(){document.removeEventListener("keyup",this.onEscKeyRelease)}};S('.vue-simple-context-menu {\n top: 0;\n left: 0;\n margin: 0;\n padding: 0;\n display: none;\n list-style: none;\n position: fixed;\n z-index: 1000000;\n background-color: var(--kd-lane-container-context-background-color, #ecf0f1);\n border-bottom-width: 0px;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;\n box-shadow: 0 3px 6px 0 rgba(var(--kd-lane-container-context-item-color, #333), 0.2);\n border-radius: 4px;\n}\n.vue-simple-context-menu--active {\n display: block;\n}\n.vue-simple-context-menu__item {\n display: flex;\n color: var(--kd-lane-container-context-item-color, #333);\n cursor: pointer;\n padding: 5px 15px;\n align-items: center;\n}\n.vue-simple-context-menu__item:hover {\n background-color: var(--kd-lane-container-context-hover-background-color, #007aff);\n color: var(--kd-lane-container-context-hover-item-color, #fff);\n}\n.vue-simple-context-menu__divider {\n box-sizing: content-box;\n height: 2px;\n background-color: var(--kd-lane-container-context-divider-color, #595a5a);\n padding: 4px 0;\n background-clip: content-box;\n pointer-events: none;\n}\n.vue-simple-context-menu li:first-of-type {\n margin-top: 4px;\n}\n.vue-simple-context-menu li:last-of-type {\n margin-bottom: 4px;\n}');const k=N;var L=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",[n("ul",{directives:[{name:"click-outside",rawName:"v-click-outside",value:e.onClickOutside,expression:"onClickOutside"}],staticClass:"vue-simple-context-menu",attrs:{id:e.elementId}},e._l(e.options,function(t,a){return n("li",{key:a,staticClass:"vue-simple-context-menu__item",class:[t.class,"divider"===t.type?"vue-simple-context-menu__divider":""],on:{click:function(n){return n.stopPropagation(),e.optionClicked(t)}}},[n("span",{domProps:{innerHTML:e._s(t.name)}})])}),0)])};L._withStripped=!0;const M=y({render:L,staticRenderFns:[]},undefined,k,undefined,false,undefined,!1,void 0,void 0,void 0);var R={inject:["delTemplate","delLane","delLine"],provide(){return{setTargetData:this.setTargetData,setExpanded:this.setExpanded}},components:{LineEdit:D,TemplateEdit:I,LaneEdit:x,VueSimpleContextMenu:M},props:{contextItem:{type:Object,default:()=>{}},expended:{type:Object},caseId:{type:String,default:""},inputTempates:{type:Array,default:()=>[]},params:{type:Array,required:!0,default:()=>[]},paramsNameMap:{type:Object,default:()=>{},required:!0}},data:()=>({templateContentShow:!1,templateDisable:!1,laneContentShow:!1,lineContentShow:!1,templateInfo:{},laneInfo:{},lineInfo:{},dataType:"",curveConfigLoading:!1,expandedKeys:[],currentNodeKey:"",targetData:void 0,treeKey:""}),mounted(){},methods:{getLineDataLabel(e){if(!e)return"";const t=this.paramsNameMap[e.paramId];return t?t.paramName:e.paramId},setTargetData(e){this.targetData=e,this.setExpanded();switch(h(e)){case"template":this.templateContentShow=!0,this.laneContentShow=!1,this.lineContentShow=!1,this.templateDisable=!0,this.templateInfo=e;break;case"lane":this.templateContentShow=!1,this.laneContentShow=!0,this.lineContentShow=!1,this.templateDisable=!0,this.laneInfo=e;break;case"line":this.templateContentShow=!1,this.laneContentShow=!1,this.lineContentShow=!0,this.templateDisable=!0,this.lineInfo=e}},setExpanded(){const e=this.targetData;if(e){switch(h(e)){case"template":this.expandedKeys=[e.templateId],this.currentNodeKey=e.templateId;break;case"lane":this.expandedKeys=[e.laneId],this.currentNodeKey=e.laneId;break;case"line":this.expandedKeys=[e.lineId],this.currentNodeKey=e.lineId;break;default:this.expandedKeys=[],this.currentNodeKey=""}}else this.expandedKeys=[],this.currentNodeKey="";this.$refs.refTree&&this.$refs.refTree.setCurrentKey(this.currentNodeKey),this.treeKey=`treeKey${(new Date).getTime()}`},optionClicked(e){const{option:t={},item:n}=e;switch(t.key){case"delTemplate":this.askForDelTemplate(n);break;case"addLane":this.addLane(n);break;case"delLane":this.askForDelLane(n);break;case"addParam":this.addParam(n);break;case"delParam":this.delParam(n)}},hideContextMenu(){const e=this.$refs.vueSimpleContextMenu;e&&e.hideContextMenu()},showRightWindows(e,t,n){const a=this.judgeDataType(n);this.dataType=a,"SYSTEM_USER"!=t.createUser?this.$refs.vueSimpleContextMenu.showMenu(e,t):this.$message.warning("系统模板不能编辑")},clear(){this.expandedKeys=[],this.templateDisable=!0,this.templateContentShow=!1},editable(){this.templateDisable=!1},handleNodeClick(e){this.setTargetData(e)},judgeDataType(e){const{level:t,data:n={}}=e;return 1==t&&n.templateId?"template":2==t&&n.laneId&&n.templateId?"lane":3==t&&n.lineId?"line":null},addTemplate(){this.templateContentShow=!0,this.laneContentShow=!1,this.lineContentShow=!1,this.templateDisable=!1,this.templateInfo={isPublic:"0",baseTemplate:"",col1:"1"}},addLane(e){this.templateContentShow=!1,this.laneContentShow=!0,this.lineContentShow=!1,this.templateDisable=!1,this.laneInfo={templateId:e.templateId,isUsed:"1",sort:e.lanes.length+1}},addParam(e){this.templateContentShow=!1,this.laneContentShow=!1,this.lineContentShow=!0,this.templateDisable=!1,this.lineInfo={laneId:e.laneId,isUsed:"1",lineSize:2}},askForDelTemplate(e){this.$confirm("此操作将删除该模板, 是否继续?","提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then(()=>(e.bsflag="1",this.curveConfigLoading=!0,this.delTemplate instanceof Function?this.delTemplate(e):Promise.reject(new Error("未配置删除模板函数")))).catch(e=>{this.$message.error(e.message||"删除失败")}).finally(()=>{this.curveConfigLoading=!1})},askForDelLane(e){this.$confirm("此操作将删除该泳道, 是否继续?","提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then(()=>(e.bsflag="1",this.curveConfigLoading=!0,this.delLane instanceof Function?this.delLane(e):Promise.reject(new Error("未配置删除模板函数")))).catch(()=>{this.$message.error("删除失败")}).finally(()=>{this.curveConfigLoading=!1})},delParam(e){this.$confirm("此操作将删除该参数, 是否继续?","提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then(()=>(e.bsflag="1",this.delLine instanceof Function?this.delLine(e):Promise.reject(new Error("未配置删除线条函数")))).catch(e=>{this.$message.error(e.message||"删除失败")})}},computed:{contextMenuOptions(){switch(this.dataType){case"template":return[{name:"新增泳道",key:"addLane"},{name:"删除模板",key:"delTemplate"}];case"lane":return[{name:"新增参数",key:"addParam"},{name:"删除泳道",key:"delLane"}];case"line":return[{name:"删除参数",key:"delParam"}];default:return[]}},treeData(){if(this.inputTempates){const e=[];return this.inputTempates.forEach(t=>{const n={...t,id:t.templateId,label:t.templateName};n.children=[],t.lanes||(t.lanes=[]),t.lanes.forEach((e,t)=>{const a={...e,id:e.laneId,label:`泳道${t+1}`};n.children.push(a),a.lines||(a.lines=[]),a.children=[],e.lines.forEach(e=>{const t={...e,id:e.lineId,label:e.lineName||e.paramId};t.label=this.getLineDataLabel(e),a.children.push(t)})}),e.push(n)}),e}return[]},userTemplate(){return this.treeData?[...this.treeData]:[]}},watch:{contextItem:{immediate:!0,deep:!0,handler(e){this.setTargetData(Object.assign({},e))}}},beforeDestroy(){}};S(".kd-lane-el-container {\n height: 60vh;\n border: 1px solid var(--kd-lane-container-border-color, #333);\n width: 100%;\n}\n@media screen and (max-width: 1024px) {\n.kd-lane-el-container {\n height: 70vh;\n}\n}\n.kd-lane-el-container .rtd-config-side {\n border-right: 1px solid var(--kd-lane-container-border-color, #333);\n}\n.kd-lane-el-container .rtd-config-side-tree {\n height: 90%;\n overflow: auto;\n}\n.kd-lane-el-container .rtd-config-side-option {\n text-align: center;\n}\n.kd-lane-el-container .rtd-config-main {\n display: flex;\n align-content: center;\n justify-content: center;\n width: 100%;\n}");const P=R;var $=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("el-container",{directives:[{name:"loading",rawName:"v-loading",value:e.curveConfigLoading,expression:"curveConfigLoading"}],staticClass:"kd-lane-el-container"},[n("el-aside",{staticClass:"rtd-config-side",attrs:{width:"20%"}},[n("el-tree",{key:e.treeKey,ref:"refTree",staticClass:"rtd-config-side-tree",attrs:{data:e.treeData,"expand-on-click-node":!1,"current-node-key":e.currentNodeKey,"default-expanded-keys":e.expandedKeys,"node-key":"id","highlight-current":""},on:{"node-click":e.handleNodeClick,"node-expand":e.hideContextMenu,"node-collapse":e.hideContextMenu},scopedSlots:e._u([{key:"default",fn:function(t){var a=t.node,r=t.data;return n("span",{staticClass:"custom-tree-node",on:{contextmenu:function(t){return t.preventDefault(),e.showRightWindows(t,r,a)}}},[n("span",[e._v(e._s(a.label))]),e._v(" "),n("span",{directives:[{name:"show",rawName:"v-show",value:"1"==r.isPublic,expression:"data.isPublic == '1'"}],staticStyle:{"padding-left":"5px"}},[n("i",{staticClass:"el-icon-star-on"})])])}}])}),e._v(" "),n("div",{staticClass:"rtd-config-side-option"},[n("el-button",{on:{click:e.addTemplate}},[e._v("新增模板")])],1)],1),e._v(" "),n("el-main",{staticClass:"rtd-config-main"},[n("TemplateEdit",e._g({directives:[{name:"show",rawName:"v-show",value:e.templateContentShow,expression:"templateContentShow"}],attrs:{currentTemplate:e.templateInfo,"form-disable":e.templateDisable,userTemplate:e.userTemplate,caseId:e.caseId},on:{editable:e.editable}},e.$listeners)),e._v(" "),n("LaneEdit",e._g({directives:[{name:"show",rawName:"v-show",value:e.laneContentShow,expression:"laneContentShow"}],attrs:{laneInfo:e.laneInfo,"form-disable":e.templateDisable},on:{editable:e.editable}},e.$listeners)),e._v(" "),n("LineEdit",e._g({directives:[{name:"show",rawName:"v-show",value:e.lineContentShow,expression:"lineContentShow"}],attrs:{template:e.lineInfo,params:e.params,"form-disable":e.templateDisable},on:{editable:e.editable}},e.$listeners))],1),e._v(" "),n("VueSimpleContextMenu",{ref:"vueSimpleContextMenu",attrs:{"element-id":"kd-lane-chart-context-menu-2",options:e.contextMenuOptions},on:{"option-clicked":e.optionClicked}})],1)};$._withStripped=!0;const O=y({render:$,staticRenderFns:[]},undefined,P,undefined,false,undefined,!1,void 0,void 0,void 0);var B={props:{itemHeight:{type:Number,default:20},line:{type:Object,default:()=>{}},paramsNameMap:{type:Object,default:()=>{},required:!0},themeName:{type:String,default:void 0}},methods:{getParamName(e){if(!e)return"";const t=this.paramsNameMap[e.paramId];return t?`${t.paramName}${t.paramUnit}`:""},toggleIsUsed(){const e={...this.line};"1"==e.isUsed||1==e.isUsed?e.isUsed="0":e.isUsed="1",this.$emit("updateLine",e)}},computed:{gradientDisplay(){let e,t;return this.themeName&&this.line.themeConfig&&(e=this.line.themeConfig[this.themeName]?.lineColor),t=this.line.isGradient?{background:`${e||this.line.lineColor}`}:{},t},textColor(){let e;return this.themeName&&this.line.themeConfig&&!this.line.isGradient&&(e=this.line.themeConfig[this.themeName]?.lineColor),{color:e||this.line.lineColor}},headerItemStyle(){let e,t;return this.themeName&&this.line.themeConfig&&(e=this.line.themeConfig[this.themeName]?.lineColor),t="area"==this.line.lineType?this.line.isGradient?{}:{"box-shadow":`inset 0 0 8px 0px ${e||this.line.lineColor}`}:{"border-bottom":`2px ${this.line.lineType} ${e||this.line.lineColor}`},{height:`${this.itemHeight}px`,opacity:"1"==this.line.isUsed?1:.5,...t}}},watch:{}};S('@charset "UTF-8";\n.kd-lane-chart-container-header-item {\n color: var(--kd-lane-container-header-item-color, #333);\n border: unset;\n position: relative;\n cursor: pointer;\n}\n.kd-lane-chart-container-header-item .kd-lane-chart-container-text-container {\n height: 100%;\n width: 100%;\n font-size: 10px;\n font-weight: bold;\n position: relative;\n}\n.kd-lane-chart-container-header-item .kd-lane-chart-container-text-container .left {\n position: absolute;\n left: 0;\n bottom: 2px;\n}\n.kd-lane-chart-container-header-item .kd-lane-chart-container-text-container .center {\n position: absolute;\n left: 50%;\n bottom: 2px;\n transform: translateX(-50%);\n /* 文字不换行,超出显示省略号 */\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.kd-lane-chart-container-header-item .kd-lane-chart-container-text-container .right {\n position: absolute;\n right: 0;\n bottom: 2px;\n}\n.kd-lane-chart-container-header-item .kd-lane-chart-container-text-container .gradient-display {\n position: absolute;\n height: 2px;\n left: 0;\n bottom: 0;\n right: 0;\n}');const j=B;var U=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"kd-lane-chart-container-header-item",style:e.headerItemStyle,on:{click:e.toggleIsUsed}},[n("div",{staticClass:"kd-lane-chart-container-text-container"},[n("span",{staticClass:"left",style:e.textColor},[e._v(e._s(e.line.min))]),e._v(" "),n("span",{staticClass:"center"},[e._v(e._s(e.getParamName(e.line)))]),e._v(" "),n("span",{staticClass:"right",style:e.textColor},[e._v(e._s(e.line.max))]),e._v(" "),n("div",{staticClass:"gradient-display",style:e.gradientDisplay})])])};U._withStripped=!0;const V=y({render:U,staticRenderFns:[]},undefined,j,undefined,false,undefined,!1,void 0,void 0,void 0);var q={name:"KdLaneContainer",provide(){return{upsertTemplate:this.upsertTemplate,delTemplate:this.delTemplate,upsertLane:this.upsertLane,delLane:this.delLane,upsertLine:this.upsertLine,delLine:this.delLine}},components:{HeaderItem:V,RealTimeCurveConfig:O,VueSimpleContextMenu:M},props:{config:{type:Object,required:!0,validator:function(e){if("object"!=typeof e||null===e)throw new Error("配置必须是一个对象");if(!("type"in e))throw new Error("配置必须包含 type 属性");if(!("caseId"in e)||!("versionCode"in e))throw new Error("配置必须包含 caseId, versionCode 属性");const{type:t}=e;if("local"===t){if(!("dataSource"in e)||null==e.dataSource)throw new Error("local 类型的配置必须包含 dataSource 属性");if(!("params"in e.dataSource))throw new Error("local 类型的配置 dataSource 必须包含 params 属性")}else{if("custom"!==t)throw new Error('type 必须是 "local" 或 "custom"');{const t=["getUserTemplates","upsertTemplate","delTemplate","upsertLane","delLane","upsertLine","delLine"];for(const n of t)if("function"!=typeof e[n])throw new Error(`${n} 必须是一个函数`)}}return!0}},headerPadding:{type:Number,default:4},headerItemHeight:{type:Number,default:20},itemGap:{type:Number,default:2},customMenuList:{type:Array,default:()=>[]},themeName:{type:String,default:void 0}},data:()=>({treeTemplates:null,isLoading:!1,strategy:null,currentTemplate:{},curveConfigVisible:!1,params:[],contextItem:void 0}),created(){this.strategy=f.createStrategy(this.$props.config),this.loadConfig()},mounted(){},methods:{setExpanded(){this.$refs.curveConfig.setExpanded()},delLine(e){return this.strategy.delLine(e).then(()=>{const t=this.currentTemplate.lanes,n=t.findIndex(t=>t.laneId==e.laneId);if(n<0)for(const t of this.treeTemplates){const{lanes:n}=t;for(const t of n)if(t.laneId==e.laneId){const{lines:n}=t,a=n.findIndex(t=>t.lineId==e.lineId);a<0?console.warn("要删除的线条在当前泳道中不存在?"):n.splice(a,1);break}}else{const a=t[n].lines.findIndex(t=>t.lineId==e.lineId);a<0?console.warn("要删除的线条在当前泳道中不存在?"):t[n].lines.splice(a,1),this.onLineChange(e)}})},upsertLine(e){return this.strategy.upsertLine(e).then(e=>{const t=this.currentTemplate.lanes,n=t.findIndex(t=>t.laneId==e.laneId);if(!(n<0)){const a=t[n],r=a.lines,s=r.findIndex(t=>t.lineId==e.lineId);return s<0?r.push(e):this.$set(r,s,e),this.$set(t,n,a),d(a),this.onLineChange(e),e}for(const t of this.treeTemplates){const{lanes:n}=t;for(const t of n)if(t.laneId==e.laneId){const{lines:n}=t,a=n.findIndex(t=>t.lineId==e.lineId);a<0?n.push(e):this.$set(n,a,e),d(t);break}}})},delLane(e){return this.strategy.delLane(e).then(e=>{const{templateId:t}=e,n=this.treeTemplates.findIndex(e=>e.templateId==t);if(n<0)return void console.warn(`template_id not found: '${t}'`);const a=this.treeTemplates[n],r=a.lanes.findIndex(t=>t.laneId==e.laneId);a.lanes.splice(r,1),this.currentTemplate.templateId==t&&this.setDefaultAndNotify()})},upsertLane(e){return this.strategy.upsertLane(e).then(e=>{const t=this.treeTemplates.findIndex(t=>t.templateId==e.templateId);if(t<0)console.warn("template not found");else{const n=this.treeTemplates[t],a=n.lanes||[],r=a.findIndex(t=>t.laneId==e.laneId);r<0?a.push(e):this.$set(a,r,e),c(n.lanes),n.templateId===this.currentTemplate.templateId&&this.setDefaultAndNotify()}return e})},delTemplate(e){return this.strategy.deleteTemplate(e).then(()=>{const t=this.treeTemplates.findIndex(t=>t.templateId===e.templateId);this.treeTemplates.splice(t,1),e.templateId==this.currentTemplate.templateId&&this.setDefaultAndNotify()})},upsertTemplate(e){return this.strategy.upsertTemplate(e).then(e=>{"1"==e.isPublic&&this.treeTemplates.forEach(e=>{e.isPublic="0"});const t=this.treeTemplates.findIndex(t=>t.templateId===e.templateId);if(t>=0){const n=this.treeTemplates[t],a=Object.assign({},n,e);this.$set(this.treeTemplates,t,a)}else this.treeTemplates.push(e);return m(this.treeTemplates),this.setDefaultAndNotify(),e})},onParentContextMenu(e){const t=".kd-lane-chart-lane-header";if(!(e.target&&(e.target.classList.contains(t)||e.target.closest(t)))){e.preventDefault();const t=this.$refs.vueSimpleContextMenu;t&&t.hideContextMenu()}},showContextMenu(e,t){e.stopPropagation(),this.$refs.vueSimpleContextMenu.showMenu(e,t)},optionClicked(e){const{option:t,item:n}=e;this.contextItem=n;const a=this.customMenuList.findIndex(e=>e.key==t.key);if(a<0){if("editTemplate"==t.key)this.curveConfigVisible=!0;else if("restoreSetting"==t.key)return this.restoreSetting()}else this.$emit("onCustomMenuClicked",e)},restoreSetting(){return this.strategy.restoreSetting().then(()=>{this.loadConfig()})},loadConfig(){this.isLoading=!0,this.strategy.getUserTemplates().then(e=>{const{templates:t=[],params:n=[]}=e;this.params=n,m(t),this.treeTemplates=t,this.setDefaultAndNotify()}).catch(e=>{console.error(`加载配置失败: ${this.$props.strategy.caseId},${this.$props.strategy.versionCode},${e.message}`)}).finally(()=>{this.isLoading=!1})},onLineChange(e){console.log("notify line change",e),this.$emit("line-change",e)},setDefaultAndNotify(){const e=this.treeTemplates.find(e=>"1"===e.isPublic);if(e)this.currentTemplate=e;else{const e=this.treeTemplates.find(e=>"SYSTEM_USER"==e.createUser);e?(e.isPublic="1",this.currentTemplate=e,this.strategy.upsertTemplate(e)):(this.treeTemplates[0].isPublic="1",this.currentTemplate=this.treeTemplates[0],this.strategy.upsertTemplate(this.currentTemplate))}this.$emit("template-change",this.currentTemplate)}},computed:{contextMenuOptions(){return"local"==this.config.type?[{name:"编辑模板",key:"editTemplate"},{name:"恢复默认",key:"restoreSetting"},...this.customMenuList]:[{name:"编辑模板",key:"template"},...this.customMenuList]},paramsNameMap(){const e={};for(const t of this.params)e[t.paramId]={paramName:t.paramName,paramUnit:t.paramUnit};return e},lineCount(){const{lanes:e=[]}=this.currentTemplate||{};return Math.max(...e.map(e=>e.lines?.length||0))},headerStyle(){const e={gap:`${this.itemGap}px`,padding:`${this.headerPadding}px`};if(this.currentTemplate){const{lanes:t=[]}=this.currentTemplate;if(t&&0!=t.length){const t=Math.max(0,this.lineCount-1);return{...e,height:this.lineCount*this.headerItemHeight+2*this.headerPadding+t*this.itemGap+"px","min-height":"60px"}}return{...e,height:"30%","min-height":"60px"}}return{...e,height:"30%","min-height":"60px"}},slotHeaderStyle(){if(this.currentTemplate){const{lanes:e=[]}=this.currentTemplate;if(e&&0!=e.length){const e=Math.max(0,this.lineCount-1);return{height:this.lineCount*this.headerItemHeight+2*this.headerPadding+e*this.itemGap+"px","min-height":"60px"}}return{height:"30%","min-height":"60px"}}return{height:"30%","min-height":"60px"}},darwAreaStyle(){const e=this.headerStyle,t=l(e.height),n=l(e["min-height"]);return{top:`${Math.max(t,n)}px`}}}};S(".kd-lane-chart-container {\n height: 100%;\n width: 100%;\n overflow: hidden;\n position: relative;\n border: 1px solid var(--kd-lane-container-border-color, #333);\n display: flex;\n}\n.kd-lane-chart-container .kd-lane-chart-lane-slot-container, .kd-lane-chart-container .kd-lane-chart-lane-container {\n height: 100%;\n min-width: 0;\n overflow: hidden;\n z-index: 1;\n}\n.kd-lane-chart-container .kd-lane-chart-lane-slot-container .kd-lane-chart-lane-header, .kd-lane-chart-container .kd-lane-chart-lane-container .kd-lane-chart-lane-header {\n max-height: 40%;\n border-bottom: 1px solid var(--kd-lane-container-border-color, #333);\n overflow: hidden;\n z-index: 2;\n display: flex;\n flex-direction: column;\n justify-content: center;\n}\n.kd-lane-chart-container .kd-lane-chart-lane-container {\n flex: 1;\n}\n.kd-lane-chart-container .kd-lane-chart-lane-slot-container {\n width: auto;\n}\n.kd-lane-chart-container .border-left {\n border-left: 1px solid var(--kd-lane-container-border-color, #333);\n}\n.kd-lane-chart-container .kd-lane-chart-container-draw-area {\n position: absolute;\n left: 0;\n right: 0;\n bottom: 0;\n z-index: 3;\n border: none;\n}");const K=q;var F=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{directives:[{name:"loading",rawName:"v-loading",value:e.isLoading,expression:"isLoading"}],staticClass:"kd-lane-chart-container",on:{contextmenu:e.onParentContextMenu}},[e.currentTemplate&&e.currentTemplate.lanes&&e.currentTemplate.lanes.length>0?[e._l(e.currentTemplate.lanes||[],function(t,a){return[e.$scopedSlots["lane"+t.laneId]?n("div",{key:t.laneId,staticClass:"kd-lane-chart-lane-slot-container",class:{"border-left":0!=a}},[n("div",{staticClass:"kd-lane-chart-lane-header",style:e.slotHeaderStyle},[e._t("lane"+t.laneId,null,{lane:t})],2)]):e.$slots["lane"+t.laneId]?n("div",{key:""+t.laneId,staticClass:"kd-lane-chart-lane-slot-container",class:{"border-left":0!=a}},[n("div",{staticClass:"kd-lane-chart-lane-header",style:e.slotHeaderStyle},[e._t("lane"+t.laneId,null,{lane:t})],2)]):[n("div",{key:t.laneId,staticClass:"kd-lane-chart-lane-container",class:{"border-left":0!=a}},[n("div",{staticClass:"kd-lane-chart-lane-header",style:e.headerStyle,on:{contextmenu:function(n){return n.preventDefault(),e.showContextMenu(n,t)}}},e._l(t.lines||[],function(t){return n("HeaderItem",{key:t.lineId,attrs:{itemHeight:e.headerItemHeight,line:t,paramsNameMap:e.paramsNameMap,themeName:e.themeName},on:{updateLine:e.upsertLine},nativeOn:{contextmenu:function(n){return n.preventDefault(),e.showContextMenu(n,t)}}})}),1)])]]})]:[n("div",{staticClass:"kd-lane-chart-lane-container"},[n("div",{staticClass:"kd-lane-chart-lane-header",style:e.headerStyle,on:{contextmenu:function(t){return t.preventDefault(),e.showContextMenu.apply(null,arguments)}}})])],e._v(" "),n("div",{staticClass:"kd-lane-chart-container-draw-area",style:e.darwAreaStyle},[e._t("draw-slot")],2),e._v(" "),n("VueSimpleContextMenu",{ref:"vueSimpleContextMenu",attrs:{"element-id":"kd-lane-chart-context-menu",options:e.contextMenuOptions},on:{"option-clicked":e.optionClicked}}),e._v(" "),n("el-dialog",{attrs:{title:"泳道模板设置",visible:e.curveConfigVisible},on:{"update:visible":function(t){e.curveConfigVisible=t},opened:e.setExpanded}},[n("RealTimeCurveConfig",e._g({ref:"curveConfig",attrs:{inputTempates:e.treeTemplates,caseId:e.strategy.caseId,params:e.params,paramsNameMap:e.paramsNameMap,contextItem:e.contextItem}},e.$listeners))],1)],2)};F._withStripped=!0;const H=y({render:F,staticRenderFns:[]},undefined,K,undefined,false,undefined,!1,void 0,void 0,void 0),z=e=>{e.component(H.name,H)};return"undefined"!=typeof window&&window.Vue&&window.Vue.use(z),{install:z}});
|
|
2
2
|
//# sourceMappingURL=index.min.js.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kd-lane-container",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "kd-lane-
|
|
3
|
+
"version": "0.0.8",
|
|
4
|
+
"description": "kd-lane-container",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
7
7
|
"browser": "dist/umd/index.min.js",
|
|
@@ -16,9 +16,6 @@
|
|
|
16
16
|
"keywords": [],
|
|
17
17
|
"author": "Fozei",
|
|
18
18
|
"license": "MIT",
|
|
19
|
-
"dependencies": {
|
|
20
|
-
"vue-simple-context-menu": "3.4.2"
|
|
21
|
-
},
|
|
22
19
|
"peerDependencies": {
|
|
23
20
|
"element-ui": "^2.15.14",
|
|
24
21
|
"v-click-outside": "^2.1.3",
|