AppCopyDialog.vue
3.78 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
<template>
<el-dialog
title="复制应用"
:visible.sync="dialogVisible"
width="50%"
:close-on-click-modal="false"
append-to-body
>
<form v-form data-vv-scope="saveCopyForm">
<table class="form-table" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<th>原应用名称:</th>
<td>{{ app.name }}</td>
<th class="is-required">新应用名称</th>
<td>
<ht-input
v-model="newApp.name"
:validate="{required: true}"
:maxlength="50"
/>
</td>
</tr>
<tr>
<th class="is-required">原应用别名:</th>
<td>{{ app.alias }}</td>
<th class="is-required">新应用别名</th>
<td>
<ht-input
v-model="newApp.alias"
v-pinyin="newApp.name"
autocomplete="off"
:validate="{
required: true,
regex: {
exp: '^[a-zA-Z][a-zA-Z0-9_]*$',
message: '只能输入字母、数字、下划线,且以字母开头',
},
isExist: '${form}/form/form/v1/checkKey?key=',
}"
placeholder="请输入别名"
:maxlength="50"
></ht-input>
</td>
</tr>
<tr>
<th class="is-required">原应用分类:</th>
<td>{{ app.menuName }}</td>
<th class="is-required">新应用分类</th>
<td>
<tree-select
style="width: 220px"
:appendToBody="true"
v-model="newApp.menuId"
:normalizer="normalizer"
:multiple="false"
:options="appTypes"
noOptionsText=" "
noChildrenText=" "
z-index="9999"
placeholder="请选择父节点"
:clearable="false"
/>
</td>
</tr>
</tbody>
</table>
</form>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false">{{
$t('eip.common.cancel')
}}</el-button>
<ht-submit-button
url="${portal}/portal/sysApp/v1/copy"
:model="newApp"
scope-name="saveCopyForm"
@after-save-data="afterSaveData"
>{{ $t('eip.common.save') }}</ht-submit-button
>
</div>
</el-dialog>
</template>
<script>
import {mapState} from 'vuex'
import _ from 'lodash'
import utils from '@/hotent-ui-util'
const TreeSelect = () => import('@riophae/vue-treeselect')
export default {
name: 'AppCopyDialog',
components: {
TreeSelect,
},
data() {
return {
dialogVisible: false,
app: {},
newApp: {
alias: '',
name: '',
},
}
},
created() {
this.$store.dispatch('menu/getAppTypes')
},
computed: mapState({
appTypes: (state) => {
let stateAppTypes = _.cloneDeep(state.menu.appTypes)
utils.nestForEach(stateAppTypes, 'children', (item) => {
if (!item.children || item.children.length === 0) {
delete item.children
}
})
return stateAppTypes || []
},
}),
methods: {
open(app) {
this.app = app
this.newApp = {
appId: app.id,
alias: '',
name: '',
}
this.dialogVisible = true
},
normalizer(node) {
return {
id: node.id,
label: node.name,
children: node.children,
isDefaultExpanded: false,
}
},
afterSaveData() {
this.$emit('refresh')
this.dialogVisible = false
},
},
}
</script>
<style lang="scss" scoped>
th {
width: 150px;
}
</style>