03207d5d
wwk
1
|
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
<template>
<el-aside width="300px" class="right-box">
<div class="cap-wrapper">控件属性</div>
<el-scrollbar class="aside-scrollbar">
<el-form size="small" label-width="80px" labelPosition="left">
<template v-if="activeData">
<el-form-item v-if="activeData.title !== undefined" label="标题">
<el-input v-model="activeData.title" placeholder="请输入标题" />
</el-form-item>
<template v-if="activeData.nccKey === 'commonFunc'">
<el-divider>选项</el-divider>
<div v-for="(item, index) in activeData.list" :key="index" class="select-item">
<NCC-TreeSelect :options="menuList" v-model="item.id" placeholder="请选择菜单" lastLevel
lastLevelKey='type' :lastLevelValue='2' clearable
@change="getSelectValue(arguments,index)">
</NCC-TreeSelect>
<div class="close-btn select-line-icon" @click="delSelectItem(index)">
<i class="el-icon-remove-outline" />
</div>
</div>
<el-button icon="el-icon-circle-plus-outline" type="text" @click="addSelectItem"
v-if="activeData.list.length<10">添加选项</el-button>
</template>
<template v-if="activeData.nccKey === 'dataBoard'">
<div v-for="(item, index) in activeData.list" :key="index" class="dataBoard-item">
<el-divider v-if="index>0"></el-divider>
<p>选项{{index+1}}</p>
<el-form-item label="标题">
<el-input v-model="item.fullName" placeholder="请输入标题" />
</el-form-item>
<el-form-item label="数值">
<el-input v-model="item.num" placeholder="请输入数值" />
</el-form-item>
<el-form-item label="图标">
<el-input v-model="item.icon" placeholder="请输入图标名称">
<el-button slot="append" @click="openIconsDialog(index)">
选择</el-button>
</el-input>
</el-form-item>
</div>
</template>
<template v-if="activeData.nccKey && activeData.nccKey.indexOf('Chart')>-1">
<el-form-item label="数据类型">
<el-radio-group v-model="activeData.dataType" size="small" @change="dataTypeChange">
<el-radio-button label="static">静态数据</el-radio-button>
<el-radio-button label="dynamic">远端数据</el-radio-button>
</el-radio-group>
</el-form-item>
<el-form-item label="数据设置" v-if="activeData.dataType==='static'">
<el-button @click="showData(activeData.option)">查看</el-button>
</el-form-item>
<el-form-item label="数据接口" v-if="activeData.dataType==='dynamic'">
<NCC-TreeSelect :options="dataInterfaceOptions" v-model="activeData.propsApi"
placeholder="请选择数据接口" lastLevel lastLevelKey='categoryId' lastLevelValue='1'
clearable />
</el-form-item>
</template>
</template>
</el-form>
</el-scrollbar>
<JSONArea v-if="areaVisible" ref="JSONArea" @refresh="updataOption" />
<iconBox :visible.sync="iconsVisible" :current="current" @choiceIcon="setIcon" />
</el-aside>
</template>
<script>
import draggable from 'vuedraggable'
import { getSelectorAll } from '@/api/system/menu'
import { getDataInterfaceSelector } from '@/api/systemData/dataInterface'
import iconBox from '@/components/NCC-iconBox'
import JSONArea from './JSONArea'
export default {
props: ['activeData'],
components: { draggable, iconBox, JSONArea },
data() {
return {
iconsVisible: false,
areaVisible: false,
currentIndex: 0,
current: '',
menuList: [],
dataInterfaceOptions: []
}
},
created() {
this.getMenuList()
this.getDataInterfaceSelector()
},
methods: {
getMenuList() {
getSelectorAll({ category: 'Web' }).then(res => {
this.menuList = res.data.list
})
},
getDataInterfaceSelector() {
getDataInterfaceSelector().then(res => {
this.dataInterfaceOptions = res.data
})
},
getSelectValue(data, i) {
if (!data[0]) {
this.$set(this.activeData.list, i, { fullName: '', id: '', urlAddress: '', icon: '', iconBackgroundColor: '' })
} else {
let iconBackgroundColor = ''
if (data[1].propertyJson) {
let propertyJson = JSON.parse(data[1].propertyJson)
iconBackgroundColor = propertyJson.iconBackgroundColor || ''
}
this.$set(this.activeData.list, i, {
fullName: data[1].fullName,
id: data[1].id,
urlAddress: data[1].urlAddress,
icon: data[1].icon,
iconBackgroundColor: iconBackgroundColor
})
}
},
addSelectItem() {
this.activeData.list.push({ fullName: '', id: '', urlAddress: '', icon: '', iconBackgroundColor: '' })
},
delSelectItem(index) {
if (this.activeData.list.length < 3) {
this.$message({
message: '选项最少要保留两项',
type: 'warning'
});
return
}
this.activeData.list.splice(index, 1)
},
openIconsDialog(index) {
this.iconsVisible = true
this.currentIndex = index
this.current = this.activeData.list[this.currentIndex].icon
},
setIcon(val) {
this.activeData.list[this.currentIndex].icon = val
},
showData(option) {
this.areaVisible = true
this.$nextTick(() => {
this.$refs.JSONArea.init(option)
})
},
updataOption(data) {
let option = data ? JSON.parse(data) : {}
this.activeData.option = option
},
dataTypeChange() {
this.activeData.propsApi = ''
}
}
}
</script>
<style lang="scss" scoped>
.right-box {
background: #fff;
border-radius: 4px;
.cap-wrapper {
text-align: center;
}
>>> .el-scrollbar__view {
padding: 15px;
}
.select-item {
display: flex;
border: 1px dashed #fff;
box-sizing: border-box;
& .close-btn {
cursor: pointer;
color: #f56c6c;
}
.el-select {
flex: 1;
}
}
.select-line-icon {
line-height: 32px;
font-size: 22px;
padding: 0 4px;
color: #777;
}
.dataBoard-item {
.el-form-item--small.el-form-item {
margin-bottom: 10px;
}
.el-divider--horizontal {
margin: 14px 0;
}
}
}
</style>
|