de2bd2f9
“wangming”
项目初始化
|
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
|
<template>
<el-dialog :title="!dataForm.id ? '新建按钮' : '编辑按钮'" :close-on-click-modal="false"
:close-on-press-escape="false" :visible.sync="visible" lock-scroll
class="NCC-dialog NCC-dialog_center" width="600px">
<el-form ref="dataForm" :model="dataForm" :rules="dataRule" label-width="80px"
v-loading="formLoading" class="menuForm">
<el-form-item label="上级" prop="parentId">
<NCC-TreeSelect v-model="dataForm.parentId" :options="treeData" placeholder="选择上级菜单" />
</el-form-item>
<el-form-item label="名称" prop="fullName">
<el-input v-model="dataForm.fullName" placeholder="输入名称" />
</el-form-item>
<el-form-item label="编码" prop="enCode">
<el-input v-model="dataForm.enCode" placeholder="输入编码" />
</el-form-item>
<!-- <el-form-item label="图标" prop="icon">
<el-input v-model="dataForm.icon" placeholder="请选择图标" readonly :suffix-icon="dataForm.icon">
<el-button slot="append" @click="openIconBox">选择</el-button>
</el-input>
</el-form-item> -->
<el-form-item label="排序" prop="sortCode">
<el-input-number :min="0" :max="9999" v-model="dataForm.sortCode"
controls-position="right" />
</el-form-item>
<el-form-item label="状态" prop="enabledMark">
<el-switch v-model="dataForm.enabledMark" :active-value="1" :inactive-value="0" />
</el-form-item>
<el-form-item label="说明" prop="description">
<el-input v-model="dataForm.description" type="textarea" :rows="6" />
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="visible = false">{{$t('common.cancelButton')}}</el-button>
<el-button type="primary" :loading="btnLoading" @click="dataFormSubmit()">
{{$t('common.confirmButton')}}</el-button>
</span>
<icon-box :visible.sync="iconBoxVisible" ref="iconBox" :current="dataForm.icon"
@choiceIcon="choiceIcon" />
</el-dialog>
</template>
<script>
import {
getButtonAuthorizeSelector,
createButton,
updateButton,
getButtonInfo
} from '@/api/system/buttonAuthorize'
import iconBox from '@/components/NCC-iconBox'
export default {
components: { iconBox },
data() {
return {
visible: false,
formLoading: false,
btnLoading: false,
treeData: [],
moduleId: '',
dataForm: {
id: '',
parentId: '',
fullName: '',
enCode: '',
sortCode: 0,
icon: '',
enabledMark: 1,
description: ''
},
iconBoxVisible: false,
dataRule: {
parentId: [
{ required: true, message: '上级不能为空', trigger: 'input' }
],
fullName: [
{ required: true, message: '按钮名称不能为空', trigger: 'blur' }
],
enCode: [
{ required: true, message: '按钮编码不能为空', trigger: 'blur' }
]
}
}
},
methods: {
init(moduleId, id) {
this.dataForm.id = id || ''
this.dataForm.moduleId = moduleId
this.visible = true
this.formLoading = true
this.$nextTick(() => {
this.$refs['dataForm'].resetFields()
// 获取上级按钮
getButtonAuthorizeSelector(this.dataForm.moduleId).then(res => {
let topItem = {
fullName: "顶级节点",
hasChildren: true,
id: "-1",
children: res.data.list
}
this.treeData = [topItem]
})
// 获取按钮数据
if (this.dataForm.id) {
getButtonInfo(this.dataForm.id).then(res => {
this.dataForm = res.data
})
}
this.formLoading = false
})
},
dataFormSubmit() {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
this.btnLoading = true
const formMethod = this.dataForm.id ? updateButton : createButton
formMethod(this.dataForm).then(res => {
this.$message({
message: res.msg,
type: 'success',
duration: 1500,
onClose: () => {
this.visible = false
this.btnLoading = false
this.$emit('refreshDataList')
}
})
}).catch(() => {
this.btnLoading = false
})
}
})
},
openIconBox() {
this.iconBoxVisible = true
},
choiceIcon(value) {
this.dataForm.icon = value
}
}
}
</script>
|