forked from WeBankFinTech/Scriptis
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.vue
More file actions
110 lines (110 loc) · 3.15 KB
/
Copy pathindex.vue
File metadata and controls
110 lines (110 loc) · 3.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<template>
<Poptip
popper-class="fn-view"
transfer
trigger="hover"
width="540"
placement="right">
<slot></slot>
<div slot="content">
<canvas
:id="`cvs${node.id}`"
class="fn-view-canvas"/>
<Form
v-if="node"
:model="node"
:label-width="100"
size="small">
<FormItem label="函数名称:">
<span
:title="node.name"
class="fn-item">{{ node.name }}</span>
</FormItem>
<FormItem label="创建人/部门:">
<span>{{ node.createUser }}</span>
</FormItem>
<FormItem label="修改时间:">
<span>{{ dateFormatter(node.updateTime) }}</span>
</FormItem>
<!--<FormItem label="注册格式:">
<span>{{node.registerFormat}}</span>
</FormItem>-->
<FormItem label="使用格式:">
<span
:title="node.useFormat"
class="fn-item">{{ node.useFormat }}</span>
</FormItem>
<FormItem label="函数描述:">
<span
:title="node.description"
class="fn-item">{{ node.description }}</span>
</FormItem>
</Form>
</div>
</Poptip>
</template>
<script>
import moment from 'moment';
export default {
props: {
node: {
type: Object,
default: () => {},
},
},
data() {
return {
};
},
mounted() {
this.setXY();
},
methods: {
setXY() {
let type = '';
let x = null;
let y = null;
if (this.node.udfType === 0) {
type = '通用';
x = 86;
y = 106;
} else if (this.node.udfType > 2) {
type = '自定义函数';
x = 60;
y = 106;
} else {
type = 'spark';
x = 80;
y = 106;
}
this.drawWaterMark(type, x, y);
},
drawWaterMark(type, x, y) {
// 由于id是唯一的,所以这里canvas的id使用动态的字符串,让每个元素的id都不一样,否则会出现无法渲染的情况
const cvs = document.getElementById(`cvs${this.node.id}`);
const ctx = cvs.getContext('2d');
cvs.height = 140;
cvs.width = 140;
const drawDashRound = (x, y, radius, step = 5) => {
step = (5 / 180) * Math.PI * 2;
for (let b = 0, e = step / 2; e <= 360; b += step, e += step) {
ctx.beginPath();
ctx.arc(x, y, radius, b, e);
ctx.stroke();
ctx.strokeStyle = '#99d7f7';
}
};
drawDashRound(100, 100, 70);
drawDashRound(100, 100, 50);
ctx.font = '16px microsoft yahei';
ctx.fillStyle = '#99d7f7';
ctx.fillText(type, x, y);
},
dateFormatter(date) {
return moment(date).format('YYYY-MM-DD HH:mm:ss');
},
},
};
</script>
<style lang="scss" src="./index.scss">
</style>