fl-web-component 0.1.0 → 1.0.0
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 +35 -24
- package/dist/fl-web-component.common.js +27308 -65
- package/dist/fl-web-component.common.js.map +1 -1
- package/dist/fl-web-component.css +1 -1
- package/dist/fl-web-component.umd.js +27308 -65
- package/dist/fl-web-component.umd.js.map +1 -1
- package/dist/fl-web-component.umd.min.js +13 -1
- package/dist/fl-web-component.umd.min.js.map +1 -1
- package/package.json +80 -47
- package/packages/components/button/index.vue +16 -12
- package/packages/components/com-card/card-page.vue +102 -0
- package/packages/components/com-card/index.vue +53 -0
- package/packages/components/com-dialogWrapper/Readme.md +53 -0
- package/packages/components/com-dialogWrapper/index.vue +98 -0
- package/packages/components/com-flcanvas/components/bspline.js +91 -0
- package/packages/components/com-flcanvas/components/entityFormatting.js +503 -0
- package/packages/components/com-flcanvas/components/round10.js +24 -0
- package/packages/components/com-flcanvas/index.vue +259 -0
- package/packages/components/com-formDialog/Readme.md +409 -0
- package/packages/components/com-formDialog/index.vue +471 -0
- package/packages/components/com-graphics/index.vue +1073 -0
- package/packages/components/com-graphics/per-control.vue +109 -0
- package/packages/components/com-graphics/pid.vue +168 -0
- package/packages/components/com-page/index.vue +101 -0
- package/packages/components/com-selectTree/Readme.md +17 -0
- package/packages/components/com-selectTree/index.vue +236 -0
- package/packages/components/com-table/column-default.vue +71 -0
- package/packages/components/com-table/column-dynamic.vue +36 -0
- package/packages/components/com-table/column-menu.vue +71 -0
- package/packages/components/com-table/column-slot.vue +53 -0
- package/packages/components/com-table/column.vue +41 -0
- package/packages/components/com-table/config.js +21 -0
- package/packages/components/com-table/index.vue +281 -0
- package/packages/components/com-table/table-page.vue +106 -0
- package/packages/components/com-tabs/index.vue +50 -0
- package/packages/components/com-treeDynamic/Readme.md +271 -0
- package/packages/components/com-treeDynamic/index.vue +207 -0
- package/packages/components/model/api/index.js +59 -67
- package/packages/components/model/api/mock/detecttree.js +38 -38
- package/packages/components/model/api/mock/getmodel-line.js +15830 -79332
- package/packages/components/model/api/mock/init.js +1 -1
- package/packages/components/model/api/mock/pbstree.js +486 -495
- package/packages/components/model/components/TextOverTooltip/index.vue +3 -3
- package/packages/components/model/components/annotation-toolbar.vue +4 -19
- package/packages/components/model/components/check-proofing-model.vue +26 -29
- package/packages/components/model/components/clipping-type.vue +22 -14
- package/packages/components/model/components/com-dialogWrapper/index.vue +22 -25
- package/packages/components/model/components/detect-panel.vue +38 -26
- package/packages/components/model/components/detect-tree.vue +9 -24
- package/packages/components/model/components/firstPer-panel.vue +23 -25
- package/packages/components/model/components/header-button.vue +31 -107
- package/packages/components/model/components/imageViewer/index.vue +34 -35
- package/packages/components/model/components/import-model.vue +127 -127
- package/packages/components/model/components/location-panel.vue +25 -29
- package/packages/components/model/components/measure-type.vue +15 -15
- package/packages/components/model/components/pbs-tree.vue +139 -144
- package/packages/components/model/components/proof-config.vue +2 -10
- package/packages/components/model/components/proof-for-pc.vue +35 -32
- package/packages/components/model/components/proof-history.vue +136 -154
- package/packages/components/model/components/proof-panel-detail.vue +166 -165
- package/packages/components/model/components/proof-panel.vue +281 -205
- package/packages/components/model/components/proof-project-user.vue +13 -50
- package/packages/components/model/components/proof-publish.vue +130 -130
- package/packages/components/model/components/proof-role.vue +93 -124
- package/packages/components/model/components/props-panel.vue +63 -54
- package/packages/components/model/index.vue +3225 -3213
- package/packages/components/model/utils/annotation-tool.js +75 -82
- package/packages/components/model/utils/cursor.js +15 -10
- package/packages/components/model/utils/detect-v1.js +23 -35
- package/packages/components/model/utils/index.js +25 -25
- package/packages/components/model/utils/threejs/measure-angle.js +180 -180
- package/packages/components/model/utils/threejs/measure-area.js +196 -184
- package/packages/components/model/utils/threejs/measure-distance.js +154 -152
- package/packages/components/model/utils/threejs/measure-volume.js +64 -61
- package/patches/camera-controls+2.9.0.patch +63 -0
- package/src/assets/test.png +0 -0
- package/src/assets/worker.glb +0 -0
- package/src/main.js +27 -0
- package/src/utils/flgltf-parser.js +141 -0
- package/src/utils/instance-parser.js +402 -0
- package/src/utils/mock.js +84746 -0
- package/src/utils/threejs/measure-angle.js +240 -0
- package/src/utils/threejs/measure-area.js +249 -0
- package/src/utils/threejs/measure-distance.js +195 -0
- package/packages/index.js +0 -24
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<div class="key">
|
|
4
|
+
<span>漫游</span>
|
|
5
|
+
<div class="center">
|
|
6
|
+
<div class="top"><span>W</span></div>
|
|
7
|
+
<div class="cen">
|
|
8
|
+
<span>A</span>
|
|
9
|
+
<span>S</span>
|
|
10
|
+
<span>D</span>
|
|
11
|
+
</div>
|
|
12
|
+
<span class="text">W向前移动、S向后移动、A向左移动、D向右移动</span>
|
|
13
|
+
</div>
|
|
14
|
+
</div>
|
|
15
|
+
<div class="line"></div>
|
|
16
|
+
<div class="mouse">
|
|
17
|
+
<span>环视</span>
|
|
18
|
+
<div class="center">
|
|
19
|
+
<i class="iconfont icon-shubiao"></i>
|
|
20
|
+
<span class="text">鼠标控制方向</span>
|
|
21
|
+
</div>
|
|
22
|
+
</div>
|
|
23
|
+
<div class="line"></div>
|
|
24
|
+
<div class="quit">
|
|
25
|
+
<span>退出</span>
|
|
26
|
+
<div class="center">
|
|
27
|
+
<div class="cen"><span>Esc</span></div>
|
|
28
|
+
<span class="text">使用Esc键退出漫游</span>
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
<div class="button">
|
|
32
|
+
<el-button @click="start(false)">好的,知道了</el-button>
|
|
33
|
+
<el-button @click="start(true)" type="primary">不再提示</el-button>
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
</template>
|
|
37
|
+
<script>
|
|
38
|
+
export default {
|
|
39
|
+
name: 'PerControl',
|
|
40
|
+
data() {
|
|
41
|
+
return {};
|
|
42
|
+
},
|
|
43
|
+
created() {},
|
|
44
|
+
methods: {
|
|
45
|
+
start(val) {
|
|
46
|
+
this.$emit('start', val);
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
</script>
|
|
51
|
+
<style lang="scss" scoped>
|
|
52
|
+
span {
|
|
53
|
+
font-weight: bolder;
|
|
54
|
+
}
|
|
55
|
+
.text {
|
|
56
|
+
margin-top: 20px;
|
|
57
|
+
}
|
|
58
|
+
.line {
|
|
59
|
+
border-bottom: 1px solid #dcdfe6;
|
|
60
|
+
margin: 20px 0;
|
|
61
|
+
}
|
|
62
|
+
.center {
|
|
63
|
+
display: flex;
|
|
64
|
+
flex-direction: column;
|
|
65
|
+
align-items: center;
|
|
66
|
+
.top,
|
|
67
|
+
.cen {
|
|
68
|
+
span {
|
|
69
|
+
color: '#53a8ff';
|
|
70
|
+
display: inline-block;
|
|
71
|
+
width: 30px;
|
|
72
|
+
height: 30px;
|
|
73
|
+
text-align: center;
|
|
74
|
+
line-height: 30px;
|
|
75
|
+
border: 1px solid '#53a8ff';
|
|
76
|
+
padding: 5px;
|
|
77
|
+
margin-bottom: 10px;
|
|
78
|
+
background-color: #e9f3ff;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
.cen {
|
|
82
|
+
span {
|
|
83
|
+
margin: 10px;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
.button {
|
|
88
|
+
display: flex;
|
|
89
|
+
justify-content: end;
|
|
90
|
+
margin-top: 20px;
|
|
91
|
+
}
|
|
92
|
+
@font-face {
|
|
93
|
+
font-family: 'iconfont';
|
|
94
|
+
src: url('//at.alicdn.com/t/font_3226805_qqvo3ag3r8.woff2?t=1646635700216') format('woff2'),
|
|
95
|
+
url('//at.alicdn.com/t/font_3226805_qqvo3ag3r8.woff?t=1646635700216') format('woff'),
|
|
96
|
+
url('//at.alicdn.com/t/font_3226805_qqvo3ag3r8.ttf?t=1646635700216') format('truetype');
|
|
97
|
+
}
|
|
98
|
+
.iconfont {
|
|
99
|
+
font-family: 'iconfont' !important;
|
|
100
|
+
font-size: 50px;
|
|
101
|
+
font-style: normal;
|
|
102
|
+
color: '#53a8ff';
|
|
103
|
+
-webkit-font-smoothing: antialiased;
|
|
104
|
+
-moz-osx-font-smoothing: grayscale;
|
|
105
|
+
}
|
|
106
|
+
.icon-shubiao:before {
|
|
107
|
+
content: '\e8a7';
|
|
108
|
+
}
|
|
109
|
+
</style>
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div id="pid-svg">
|
|
3
|
+
<embed type="image/svg+xml" id="svg-tigger" :src="currentSvg" />
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
<script>
|
|
7
|
+
import * as svgPanZoom from 'static/svg-pan-zoom.min.js';
|
|
8
|
+
var svgCon = {},
|
|
9
|
+
svgTigger = {},
|
|
10
|
+
svgEmbed = {};
|
|
11
|
+
var preTargetCon = [],
|
|
12
|
+
preTargetStyle = [];
|
|
13
|
+
var firstTime = 0,
|
|
14
|
+
lastTime = 0;
|
|
15
|
+
var inspectionRect = null,
|
|
16
|
+
pointerRect = null;
|
|
17
|
+
export default {
|
|
18
|
+
name: 'PidSvg',
|
|
19
|
+
data() {
|
|
20
|
+
return {
|
|
21
|
+
currentSvg: null,
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
mounted() {
|
|
25
|
+
svgEmbed = document.getElementById('svg-tigger');
|
|
26
|
+
svgEmbed.addEventListener('resize', () => {
|
|
27
|
+
this.onWindowResize;
|
|
28
|
+
});
|
|
29
|
+
svgEmbed.addEventListener('load', () => {
|
|
30
|
+
svgTigger = svgPanZoom('#svg-tigger', {
|
|
31
|
+
viewportSelector: '.svg-pan-zoom_viewport',
|
|
32
|
+
preventMouseEventsDefault: false,
|
|
33
|
+
});
|
|
34
|
+
svgCon = svgEmbed.getSVGDocument().querySelector('svg');
|
|
35
|
+
svgCon.style = 'cursor: pointer;user-select: none;';
|
|
36
|
+
svgCon.setAttribute('viewBox', '0 0 ' + svgEmbed.offsetWidth + ' ' + svgEmbed.offsetHeight);
|
|
37
|
+
inspectionRect = svgCon.createSVGRect();
|
|
38
|
+
inspectionRect.width = 10;
|
|
39
|
+
inspectionRect.height = 10;
|
|
40
|
+
pointerRect = svgCon.createSVGPoint();
|
|
41
|
+
this.onWindowResize();
|
|
42
|
+
// 禁止右键菜单栏
|
|
43
|
+
svgCon.addEventListener('contextmenu', e => {
|
|
44
|
+
e.preventDefault();
|
|
45
|
+
});
|
|
46
|
+
// 鼠标的按下与抬起事件
|
|
47
|
+
svgCon.addEventListener('mousedown', this.mousedown);
|
|
48
|
+
svgCon.addEventListener('mouseup', this.mouseup);
|
|
49
|
+
// 加载完成后会通知
|
|
50
|
+
this.$emit('loaded');
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
methods: {
|
|
54
|
+
// 改变窗口大小
|
|
55
|
+
onWindowResize() {
|
|
56
|
+
svgCon.removeAttribute('width');
|
|
57
|
+
svgCon.removeAttribute('height');
|
|
58
|
+
},
|
|
59
|
+
// 鼠标按下
|
|
60
|
+
mousedown() {
|
|
61
|
+
firstTime = new Date().getTime();
|
|
62
|
+
},
|
|
63
|
+
// 鼠标抬起
|
|
64
|
+
mouseup(evt) {
|
|
65
|
+
lastTime = new Date().getTime();
|
|
66
|
+
let targetElement = null;
|
|
67
|
+
// 判断鼠标按下到抬起的时间间隔是否超过300ms 没有超过 则判断为点击
|
|
68
|
+
if (lastTime - firstTime <= 300) {
|
|
69
|
+
if (evt.target.nodeName !== 'svg') {
|
|
70
|
+
targetElement = evt.target;
|
|
71
|
+
} else {
|
|
72
|
+
pointerRect.x = evt.clientX;
|
|
73
|
+
pointerRect.y = evt.clientY;
|
|
74
|
+
const tp = pointerRect.matrixTransform(svgCon.getScreenCTM());
|
|
75
|
+
inspectionRect.x = tp.x;
|
|
76
|
+
inspectionRect.y = tp.y;
|
|
77
|
+
const intersectionList = svgCon.getIntersectionList(inspectionRect, null);
|
|
78
|
+
targetElement =
|
|
79
|
+
intersectionList.length > 0 ? intersectionList[intersectionList.length - 1] : null;
|
|
80
|
+
}
|
|
81
|
+
if (evt.button === 0) {
|
|
82
|
+
this.$emit('leftClick', targetElement);
|
|
83
|
+
} else if (event.button === 2) {
|
|
84
|
+
this.$emit('rightClick', targetElement);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
// 高亮目标元素
|
|
89
|
+
/*
|
|
90
|
+
参数:svgIds: [], 需要高亮的id的集合, flag: true / false, 是否要定位目标元素, color: '', 高亮的颜色
|
|
91
|
+
*/
|
|
92
|
+
highLight(svgIds, flag, color) {
|
|
93
|
+
if (svgIds === null || svgIds === undefined) {
|
|
94
|
+
throw new Error('svgIds should be an array');
|
|
95
|
+
} else {
|
|
96
|
+
for (let index = 0; index < svgIds.length; index++) {
|
|
97
|
+
let element = svgIds[index];
|
|
98
|
+
let targetCon = svgCon.getElementById(element);
|
|
99
|
+
if (!targetCon) return;
|
|
100
|
+
this.depthTraversal(targetCon.children, color);
|
|
101
|
+
}
|
|
102
|
+
if (flag) {
|
|
103
|
+
svgTigger.reset();
|
|
104
|
+
let firstCon = svgCon.getElementById(svgIds[0]);
|
|
105
|
+
setTimeout(() => {
|
|
106
|
+
svgTigger.zoomAtPoint(1.5, {
|
|
107
|
+
x: firstCon.getBoundingClientRect().x,
|
|
108
|
+
y: firstCon.getBoundingClientRect().y,
|
|
109
|
+
});
|
|
110
|
+
}, 100);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
// pid组高亮 深度遍历
|
|
115
|
+
depthTraversal(svgCon, color) {
|
|
116
|
+
for (let i = 0; i < svgCon.length; i++) {
|
|
117
|
+
if (svgCon[i].children.length > 0) {
|
|
118
|
+
this.depthTraversal(svgCon[i].children, color);
|
|
119
|
+
} else {
|
|
120
|
+
preTargetCon.push(svgCon[i]);
|
|
121
|
+
preTargetStyle.push({
|
|
122
|
+
fillOpacity: svgCon[i].style.fillOpacity,
|
|
123
|
+
stroke: svgCon[i].style.stroke,
|
|
124
|
+
strokeWidth: svgCon[i].style.strokeWidth,
|
|
125
|
+
});
|
|
126
|
+
svgCon[i].style.fillOpacity = '0';
|
|
127
|
+
svgCon[i].style.stroke = color;
|
|
128
|
+
svgCon[i].style.strokeWidth = 0.5;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
// 清除上一次的高亮
|
|
133
|
+
resetHightLight() {
|
|
134
|
+
for (let i = 0; i < preTargetCon.length; i++) {
|
|
135
|
+
preTargetCon[i].style.fillOpacity = preTargetStyle[i].fillOpacity;
|
|
136
|
+
preTargetCon[i].style.stroke = preTargetStyle[i].stroke;
|
|
137
|
+
preTargetCon[i].style.strokeWidth = preTargetStyle[i].strokeWidth;
|
|
138
|
+
}
|
|
139
|
+
preTargetStyle.splice(0);
|
|
140
|
+
preTargetCon.splice(0);
|
|
141
|
+
},
|
|
142
|
+
// 更新图纸/切换图纸
|
|
143
|
+
/*
|
|
144
|
+
参数:url: 图纸的路径
|
|
145
|
+
*/
|
|
146
|
+
switchSvg(url) {
|
|
147
|
+
this.$set(this, 'currentSvg', url);
|
|
148
|
+
preTargetCon.splice(0);
|
|
149
|
+
preTargetStyle.splice(0);
|
|
150
|
+
inspectionRect = null;
|
|
151
|
+
pointerRect = null;
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
</script>
|
|
156
|
+
<style lang="scss" scoped>
|
|
157
|
+
#pid-svg {
|
|
158
|
+
cursor: pointer;
|
|
159
|
+
height: 100%;
|
|
160
|
+
width: 100%;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
#svg-tigger {
|
|
164
|
+
cursor: pointer;
|
|
165
|
+
height: 100%;
|
|
166
|
+
width: 100%;
|
|
167
|
+
}
|
|
168
|
+
</style>
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-pagination
|
|
3
|
+
:small="comTable.size == 'mini'"
|
|
4
|
+
:disabled="defaultPage.disabled"
|
|
5
|
+
:hide-on-single-page="defaultPage.single"
|
|
6
|
+
:pager-count="defaultPage.pagerCount"
|
|
7
|
+
:current-page.sync="defaultPage.currentPage"
|
|
8
|
+
:background="defaultPage.background"
|
|
9
|
+
:page-size="defaultPage.pageSize"
|
|
10
|
+
:page-sizes="defaultPage.pageSizes"
|
|
11
|
+
@size-change="sizeChange"
|
|
12
|
+
@prev-click="prevClick"
|
|
13
|
+
@next-click="nextClick"
|
|
14
|
+
@current-change="currentChange"
|
|
15
|
+
:layout="defaultPage.layout"
|
|
16
|
+
:total="defaultPage.total"
|
|
17
|
+
></el-pagination>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<script>
|
|
21
|
+
import base from '../../utils/base.js';
|
|
22
|
+
|
|
23
|
+
export default {
|
|
24
|
+
name: 'comTable',
|
|
25
|
+
inject: ['comTable'],
|
|
26
|
+
mixins: [base()],
|
|
27
|
+
data() {
|
|
28
|
+
return {
|
|
29
|
+
defaultPage: {
|
|
30
|
+
single: false,
|
|
31
|
+
total: 0, // 总页数
|
|
32
|
+
pagerCount: 7, //超过多少条隐藏
|
|
33
|
+
currentPage: 1, // 当前页数
|
|
34
|
+
pageSize: 10, // 每页显示多少条
|
|
35
|
+
pageSizes: [10, 20, 30, 40, 50, 100],
|
|
36
|
+
layout: 'total, sizes, prev, pager, next, jumper',
|
|
37
|
+
background: true, // 背景颜色
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
created() {
|
|
42
|
+
this.pageInit();
|
|
43
|
+
this.comTable.$emit('on-load', this.defaultPage);
|
|
44
|
+
},
|
|
45
|
+
watch: {
|
|
46
|
+
'comTable.page': {
|
|
47
|
+
handler() {
|
|
48
|
+
this.pageInit();
|
|
49
|
+
},
|
|
50
|
+
deep: true,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
computed: {
|
|
54
|
+
pageFlag() {
|
|
55
|
+
return this.defaultPage.total != 0;
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
methods: {
|
|
59
|
+
pageInit() {
|
|
60
|
+
this.defaultPage = Object.assign(this.defaultPage, this.comTable.page);
|
|
61
|
+
this.updateValue();
|
|
62
|
+
},
|
|
63
|
+
updateValue() {
|
|
64
|
+
console.log('updateValue defaultPage', this.defaultPage);
|
|
65
|
+
this.comTable.$emit('update:page', this.defaultPage);
|
|
66
|
+
},
|
|
67
|
+
//下一页事件
|
|
68
|
+
nextClick(val) {
|
|
69
|
+
console.log('nextClick', val);
|
|
70
|
+
this.comTable.$emit('next-click', val);
|
|
71
|
+
},
|
|
72
|
+
//上一页事件
|
|
73
|
+
prevClick(val) {
|
|
74
|
+
console.log('prevClick', val);
|
|
75
|
+
this.comTable.$emit('prev-click', val);
|
|
76
|
+
},
|
|
77
|
+
// 页大小回调
|
|
78
|
+
sizeChange(val) {
|
|
79
|
+
this.defaultPage.currentPage = 1;
|
|
80
|
+
this.defaultPage.pageSize = val;
|
|
81
|
+
this.updateValue();
|
|
82
|
+
console.log('sizeChange', val);
|
|
83
|
+
this.comTable.$emit('on-load', this.defaultPage);
|
|
84
|
+
this.comTable.$emit('size-change', val);
|
|
85
|
+
},
|
|
86
|
+
// 页码回调
|
|
87
|
+
currentChange(val) {
|
|
88
|
+
this.updateValue();
|
|
89
|
+
this.comTable.$emit('on-load', this.defaultPage);
|
|
90
|
+
this.comTable.$emit('current-change', val);
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
</script>
|
|
95
|
+
|
|
96
|
+
<style lang="scss" scoped>
|
|
97
|
+
.el-pagination {
|
|
98
|
+
text-align: right;
|
|
99
|
+
padding: 15px 10px 15px 20px !important;
|
|
100
|
+
}
|
|
101
|
+
</style>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<!-- 使用方法 样例 -->
|
|
2
|
+
<SelectTree
|
|
3
|
+
ref="SelectTree"
|
|
4
|
+
:filterable="true"
|
|
5
|
+
:value-key="`deptId`"
|
|
6
|
+
:select-key="`deptId`"
|
|
7
|
+
:value-name="`deptName`"
|
|
8
|
+
:tree-data="item.optionArr"
|
|
9
|
+
:tree-props="{
|
|
10
|
+
id: 'deptId',
|
|
11
|
+
label: 'deptName',
|
|
12
|
+
children: 'children'
|
|
13
|
+
}"
|
|
14
|
+
:tree-node-key="`deptId`"
|
|
15
|
+
:placeholder-title="`请选择${item.label}`"
|
|
16
|
+
@nodeClickTree="nodeClickTree"
|
|
17
|
+
/>
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @Author: fengyang9326@163.com
|
|
3
|
+
* @Date: 2024-05-13 10:36:07
|
|
4
|
+
* @LastEditors: fengyang9326@163.com
|
|
5
|
+
* @LastEditTime: 2024-05-20 09:38:24
|
|
6
|
+
* @FilePath: /web/components/com-selectTree/index.vue
|
|
7
|
+
* @Description: 树结构下拉框
|
|
8
|
+
-->
|
|
9
|
+
<template>
|
|
10
|
+
<el-select
|
|
11
|
+
ref="Select"
|
|
12
|
+
v-model="formData"
|
|
13
|
+
:value-key="selectKey"
|
|
14
|
+
:placeholder="placeholderTitle"
|
|
15
|
+
size="medium"
|
|
16
|
+
:clearable="clearable"
|
|
17
|
+
:disabled="disabled"
|
|
18
|
+
:filterable="filterable"
|
|
19
|
+
:filter-method="filterMethod"
|
|
20
|
+
style="width: 100%"
|
|
21
|
+
@clear="clear"
|
|
22
|
+
@visible-change="visibleChange"
|
|
23
|
+
@focus="setMinWidth"
|
|
24
|
+
>
|
|
25
|
+
<el-option
|
|
26
|
+
ref="option"
|
|
27
|
+
class="select_tree_option"
|
|
28
|
+
:value="formData.id"
|
|
29
|
+
:label="formData.name"
|
|
30
|
+
:style="{ width: minWidth + 2 + 'px' }"
|
|
31
|
+
>
|
|
32
|
+
<el-tree
|
|
33
|
+
ref="Tree"
|
|
34
|
+
class="select_tree_tree"
|
|
35
|
+
:node-key="treeNodeKey"
|
|
36
|
+
:current-node-key="currentSelect"
|
|
37
|
+
:data="treeData"
|
|
38
|
+
:props="treeProps"
|
|
39
|
+
:highlight-current="true"
|
|
40
|
+
:expand-on-click-node="false"
|
|
41
|
+
:default-expanded-keys="parentList"
|
|
42
|
+
:filter-node-method="filterNode"
|
|
43
|
+
@node-click="handleNodeClick"
|
|
44
|
+
>
|
|
45
|
+
<span slot-scope="{ node }" class="custom-tree-node">
|
|
46
|
+
<span :title="node.label" class="title_tree">{{ node.label }}</span>
|
|
47
|
+
</span>
|
|
48
|
+
</el-tree>
|
|
49
|
+
</el-option>
|
|
50
|
+
</el-select>
|
|
51
|
+
</template>
|
|
52
|
+
<script>
|
|
53
|
+
export default {
|
|
54
|
+
name: 'SelectTree',
|
|
55
|
+
props: {
|
|
56
|
+
// v-model绑定
|
|
57
|
+
// 作为 el-select value 唯一标识的键名,绑定值为对象类型时必填
|
|
58
|
+
selectKey: {
|
|
59
|
+
type: String,
|
|
60
|
+
default: 'id',
|
|
61
|
+
},
|
|
62
|
+
valueKey: {
|
|
63
|
+
type: String,
|
|
64
|
+
default: 'id',
|
|
65
|
+
},
|
|
66
|
+
valueName: {
|
|
67
|
+
type: String,
|
|
68
|
+
default: 'name',
|
|
69
|
+
},
|
|
70
|
+
// 树形的数据
|
|
71
|
+
treeData: {
|
|
72
|
+
type: Array,
|
|
73
|
+
default: () => [],
|
|
74
|
+
},
|
|
75
|
+
// 下拉框默认提示
|
|
76
|
+
placeholderTitle: {
|
|
77
|
+
type: String,
|
|
78
|
+
default: '请选择',
|
|
79
|
+
},
|
|
80
|
+
// 每个树节点用来作为唯一标识的属性
|
|
81
|
+
treeNodeKey: {
|
|
82
|
+
type: [String, Number],
|
|
83
|
+
default: 'id',
|
|
84
|
+
},
|
|
85
|
+
// 是否可搜
|
|
86
|
+
filterable: {
|
|
87
|
+
type: Boolean,
|
|
88
|
+
default: false,
|
|
89
|
+
},
|
|
90
|
+
// 是否禁用
|
|
91
|
+
disabled: {
|
|
92
|
+
type: Boolean,
|
|
93
|
+
default: false,
|
|
94
|
+
},
|
|
95
|
+
// 是否可清空input
|
|
96
|
+
clearable: {
|
|
97
|
+
type: Boolean,
|
|
98
|
+
default: false,
|
|
99
|
+
},
|
|
100
|
+
// tree的props配置
|
|
101
|
+
treeProps: {
|
|
102
|
+
type: Object,
|
|
103
|
+
default: () => ({}),
|
|
104
|
+
},
|
|
105
|
+
// 弹窗标题
|
|
106
|
+
title: {
|
|
107
|
+
type: String,
|
|
108
|
+
default: '新建',
|
|
109
|
+
},
|
|
110
|
+
echoData: {
|
|
111
|
+
type: Object,
|
|
112
|
+
default: () => ({}),
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
data() {
|
|
116
|
+
return {
|
|
117
|
+
// 下拉框最小宽度样式
|
|
118
|
+
minWidth: undefined,
|
|
119
|
+
formData: {
|
|
120
|
+
id: '',
|
|
121
|
+
name: '',
|
|
122
|
+
},
|
|
123
|
+
parentList: [], // 树结构默认展开的节点的 key 的数组
|
|
124
|
+
filterFlag: false,
|
|
125
|
+
currentSelect: '', // 当前选中的节点
|
|
126
|
+
};
|
|
127
|
+
},
|
|
128
|
+
computed: {},
|
|
129
|
+
created() {
|
|
130
|
+
if (this.echoData[this.selectKey]) {
|
|
131
|
+
this.parentList.push(this.echoData[this.selectKey]);
|
|
132
|
+
this.$set(this, 'currentSelect', this.echoData[this.selectKey]);
|
|
133
|
+
this.$set(this.formData, 'id', this.echoData[this.selectKey]);
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
mounted() {
|
|
137
|
+
this.$nextTick(() => {
|
|
138
|
+
this.$refs.Tree.setCurrentKey(this.currentSelect);
|
|
139
|
+
const nodeTree = this.$refs.Tree.getCurrentNode();
|
|
140
|
+
if (nodeTree) {
|
|
141
|
+
this.$set(this.formData, 'name', nodeTree[this.valueName]);
|
|
142
|
+
}
|
|
143
|
+
if (!nodeTree) this.$set(this.formData, 'id', '');
|
|
144
|
+
});
|
|
145
|
+
},
|
|
146
|
+
methods: {
|
|
147
|
+
/* 下拉框样式 无数据的情况下,给请选择提示设置最小宽度*/
|
|
148
|
+
setMinWidth(val) {
|
|
149
|
+
this.minWidth = val.srcElement.clientWidth;
|
|
150
|
+
},
|
|
151
|
+
/* 树节点被点击时的回调 */
|
|
152
|
+
handleNodeClick(data) {
|
|
153
|
+
if (!data[this.valueKey]) return;
|
|
154
|
+
const DataId = data[this.valueKey];
|
|
155
|
+
const DataName = data[this.valueName];
|
|
156
|
+
this.$set(this.formData, 'id', DataId);
|
|
157
|
+
this.$set(this.formData, 'name', DataName);
|
|
158
|
+
this.$set(this, 'currentSelect', data[this.valueKey]);
|
|
159
|
+
this.$refs.Select.visible = false;
|
|
160
|
+
// this.$emit('nodeClickTree', this.formData)
|
|
161
|
+
this.$emit('nodeClickTree', data);
|
|
162
|
+
},
|
|
163
|
+
/* 下拉框出现/隐藏时触发 */
|
|
164
|
+
visibleChange(e) {
|
|
165
|
+
if (e) {
|
|
166
|
+
const tree = this.$refs.Tree;
|
|
167
|
+
this.filterFlag && tree.filter('');
|
|
168
|
+
this.filterFlag = false;
|
|
169
|
+
let selectDom = null;
|
|
170
|
+
selectDom = tree.$el.querySelector('.is-current');
|
|
171
|
+
setTimeout(() => {
|
|
172
|
+
this.$refs.Select.scrollToOption({ $el: selectDom });
|
|
173
|
+
}, 0);
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
clear() {
|
|
177
|
+
this.formData = {
|
|
178
|
+
id: '',
|
|
179
|
+
name: '',
|
|
180
|
+
};
|
|
181
|
+
this.$refs.Tree.setCurrentKey(null);
|
|
182
|
+
this.$emit('nodeClickTree', this.formData);
|
|
183
|
+
},
|
|
184
|
+
/* 自定义搜索方法 */
|
|
185
|
+
filterMethod(val) {
|
|
186
|
+
this.filterFlag = true;
|
|
187
|
+
this.$refs.Tree.filter(val);
|
|
188
|
+
},
|
|
189
|
+
/* 对树节点进行筛选时执行的方法 */
|
|
190
|
+
filterNode(value, data) {
|
|
191
|
+
if (!value) return true;
|
|
192
|
+
const label = this.treeProps.label || 'name';
|
|
193
|
+
return data[label].indexOf(value) !== -1;
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
</script>
|
|
198
|
+
<style lang="scss" scope>
|
|
199
|
+
.el-select-dropdown {
|
|
200
|
+
padding: 5px 0;
|
|
201
|
+
}
|
|
202
|
+
.select_tree_option {
|
|
203
|
+
&.el-select-dropdown__item {
|
|
204
|
+
height: auto;
|
|
205
|
+
line-height: 1;
|
|
206
|
+
padding: 0;
|
|
207
|
+
background-color: #fff;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.select_tree_tree {
|
|
212
|
+
padding: 0px 0px;
|
|
213
|
+
font-weight: 400;
|
|
214
|
+
}
|
|
215
|
+
.el-tree--highlight-current .el-tree-node.is-current > .el-tree-node__content {
|
|
216
|
+
background-color: #fff;
|
|
217
|
+
color: #1890ff;
|
|
218
|
+
}
|
|
219
|
+
.el-tree-node__content {
|
|
220
|
+
width: 100% !important;
|
|
221
|
+
height: 34px !important;
|
|
222
|
+
line-height: 34px !important;
|
|
223
|
+
overflow: hidden;
|
|
224
|
+
&:hover {
|
|
225
|
+
background-color: transparent !important;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
::v-deep .select_tree_tree .el-tree-node .el-tree-node__content .custom-tree-node {
|
|
229
|
+
display: inline-block;
|
|
230
|
+
vertical-align: middle;
|
|
231
|
+
width: calc(100% - 50px) !important;
|
|
232
|
+
overflow: hidden;
|
|
233
|
+
white-space: nowrap;
|
|
234
|
+
text-overflow: ellipsis;
|
|
235
|
+
}
|
|
236
|
+
</style>
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<component :is="comTable.tableColumnName" width="1px"></component>
|
|
4
|
+
<!-- 选择框 -->
|
|
5
|
+
<component
|
|
6
|
+
:is="comTable.tableColumnName"
|
|
7
|
+
v-if="comTable.tableOption.selection"
|
|
8
|
+
:fixed="vaildData(comTable.tableOption.selectionFixed, config.selectionFixed)"
|
|
9
|
+
type="selection"
|
|
10
|
+
key="selection"
|
|
11
|
+
:selectable="comTable.tableOption.selectable"
|
|
12
|
+
align="center"
|
|
13
|
+
></component>
|
|
14
|
+
<!-- 序号 -->
|
|
15
|
+
<component
|
|
16
|
+
:is="comTable.tableColumnName"
|
|
17
|
+
v-if="vaildData(comTable.tableOption.index)"
|
|
18
|
+
:fixed="vaildData(comTable.tableOption.indexFixed, config.indexFixed)"
|
|
19
|
+
:label="comTable.tableOption.indexLabel || config.indexLabel"
|
|
20
|
+
type="index"
|
|
21
|
+
key="index"
|
|
22
|
+
:index="indexMethod"
|
|
23
|
+
align="center"
|
|
24
|
+
>
|
|
25
|
+
</component>
|
|
26
|
+
</div>
|
|
27
|
+
</template>
|
|
28
|
+
|
|
29
|
+
<script>
|
|
30
|
+
import config from './config.js';
|
|
31
|
+
import base from '../../utils/base.js';
|
|
32
|
+
|
|
33
|
+
export default {
|
|
34
|
+
name: 'comTable',
|
|
35
|
+
mixins: [base()],
|
|
36
|
+
components: {},
|
|
37
|
+
data() {
|
|
38
|
+
return {
|
|
39
|
+
config: config,
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
inject: ['comTable'],
|
|
43
|
+
mounted() {
|
|
44
|
+
this.setSort();
|
|
45
|
+
},
|
|
46
|
+
methods: {
|
|
47
|
+
indexMethod(index) {
|
|
48
|
+
return (
|
|
49
|
+
index +
|
|
50
|
+
1 +
|
|
51
|
+
((this.comTable.page.currentPage || 1) - 1) * (this.comTable.page.pageSize || 10)
|
|
52
|
+
);
|
|
53
|
+
},
|
|
54
|
+
setSort() {
|
|
55
|
+
this.rowDrop();
|
|
56
|
+
},
|
|
57
|
+
rowDrop() {
|
|
58
|
+
if (!this.comTable.$refs.table) return;
|
|
59
|
+
const el = this.comTable.$refs.table.$el.querySelectorAll(this.config.dropRowClass)[0];
|
|
60
|
+
this.comTable.tableDrop('row', el, (evt) => {
|
|
61
|
+
const oldIndex = evt.oldIndex;
|
|
62
|
+
const newIndex = evt.newIndex;
|
|
63
|
+
const targetRow = this.comTable.list.splice(oldIndex, 1)[0];
|
|
64
|
+
this.comTable.list.splice(newIndex, 0, targetRow);
|
|
65
|
+
this.comTable.$emit('sortable-change', oldIndex, newIndex);
|
|
66
|
+
this.comTable.refreshTable(() => this.rowDrop());
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
</script>
|