AppPublishDialog.vue
4.55 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
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
<template>
<el-dialog
:visible="publishDialogVisible"
:close-on-click-modal="false"
width="30%"
title="发布应用"
:before-close="beforeClose"
:destroy-on-close="true"
>
<el-form data-vv-scope="publishForm">
<ht-form-item label="应用菜单">
<tree-select
class="tree-select-radio"
v-model="menu.id"
:normalizer="normalizer"
:multiple="false"
:options="menus"
noOptionsText=" "
noChildrenText=" "
placeholder="请选择菜单"
/>
</ht-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="publishDialogVisible = false">取 消</el-button>
<el-button
type="primary"
@click="unPublish(selectedApp)"
v-if="selectedApp.isPublish"
>取消发布</el-button
>
<el-button
type="primary"
@click="changePublish"
v-if="selectedApp.isPublish"
>切换菜单</el-button
>
<el-button
type="primary"
@click="savePublish"
v-if="!selectedApp.isPublish"
>保 存</el-button
>
</div>
</el-dialog>
</template>
<script>
import portal from '../../api/portal'
import _ from 'lodash'
const TreeSelect = () => import('@riophae/vue-treeselect')
export default {
name: 'app-publish-dialog',
components: {
TreeSelect,
},
data() {
return {
publishDialogVisible: false,
menu: {
id: '',
name: '',
},
menus: [],
selectedApp: {},
}
},
methods: {
open(app) {
if (!app.menuName) {
this.$set(this.menu, 'id', null)
this.$set(this.menu, 'name', '')
} else {
this.menu = {id: app.menuId || null, name: app.menuName || ''}
}
this.publishDialogVisible = true
this.loadMenus()
this.selectedApp = {...app}
},
view(app) {
this.selectedApp = {...app}
if (!app.menuName) {
this.$set(this.menu, 'id', null)
this.$set(this.menu, 'name', '')
} else {
this.$set(this.menu, 'id', this.selectedApp.menuId)
}
this.publishDialogVisible = true
this.loadMenus()
},
loadMenus() {
portal.getAppCenterMenu('bpm_platform').then((data) => {
if (data.state && data.value.length > 0) {
this.menus = data.value
this.removeEmptyChildren(this.menus)
} else {
this.menus = []
this.menu = {id: null, name: ''}
}
})
},
removeEmptyChildren(menus) {
menus.forEach((m) => {
if (m.children) {
if (m.children.length < 1) {
delete m.children
} else {
this.removeEmptyChildren(m.children)
}
}
})
},
beforeClose() {
this.publishDialogVisible = false
},
normalizer(node) {
return {
id: node.id,
label: node.name,
children: node.children,
isDefaultExpanded: true,
}
},
savePublish() {
if (!this.menu.id) {
this.$message.warning('请选择应用菜单')
return
}
let param = _.cloneDeep(this.selectedApp)
param.isPublish = 1
param.menuId = this.menu.id
portal.publishApp(param).then((data) => {
if (data.state) {
this.$message({type: 'success', message: data.message})
this.$emit('refresh')
this.publishDialogVisible = false
}
})
},
changePublish() {
this.$confirm(`切换菜单会清空该应用的标签信息,请确认`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
this.savePublish()
})
.catch(() => {})
},
unPublish(app) {
this.$confirm(`取消发布将清空该应用的菜单和标签信息,请确认`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
let param = _.cloneDeep(app)
param.isPublish = 0
param.menuId = null
portal.publishApp(param).then((data) => {
if (data.state) {
this.$message({type: 'success', message: data.message})
this.$emit('refresh')
this.publishDialogVisible = false
}
})
})
.catch(() => {})
},
},
}
</script>
<style lang="scss" scoped>
::v-deep .tree-select-radio .vue-treeselect__control {
border-radius: 2px;
height: 32px;
}
</style>