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
| <template>
| <div style="height: 100%">
| <button style="width: 100%;height: 100%;border: none" @click="redirect()"
| :style="{background:option.attribute.bgColor,color:option.attribute.textColor,
| borderRadius:option.attribute.radius+'px'}">
| {{cptData.value}}
| </button>
| </div>
| </template>
|
| <script>
| import {getDataJson, pollingRefresh} from "@/utils/refreshCptData";
|
| export default {
| name: "cpt-button",
| props:{option:Object},
| data() {
| return {
| cptData: {},
| uuid: null
| }
| },
| created() {
| this.uuid = require('uuid').v1();
| this.refreshCptData();
| },
| methods:{
| refreshCptData(){
| pollingRefresh(this.uuid, this.option.cptDataForm, this.loadData)
| },
| loadData(){
| getDataJson(this.option.cptDataForm).then(res => {
| this.cptData = res;
| });
| },
| redirect(){
| if (this.option.attribute.url){
| if (this.option.attribute.url.startsWith("view")){
| this.$router.push(this.option.attribute.url)
| this.$emit("reload")
| }else{
| window.open(this.option.attribute.url)
| }
| }
| }
| }
| }
| </script>
|
| <style scoped>
|
| </style>
|
|