Commit 30822b4a by yuwei

2.0.0项目初始化

parent 9e9d0fd8
......@@ -65,8 +65,8 @@
<script>
import { addMenu, listMenu } from '@/api/system/menu'
import { construct } from '@/utils/json-tree'
import Treeselect from "@riophae/vue-treeselect"
import "@riophae/vue-treeselect/dist/vue-treeselect.css"
import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
export default {
name: 'MenuAdd',
......@@ -74,7 +74,7 @@ export default {
props: {
data: {
type: Object,
default: function() {
default: function () {
return {}
}
}
......@@ -100,13 +100,13 @@ export default {
// 表单校验
rules: {
parentId: [
{ required: true, message: "上级资源不能为空", trigger: "blur" }
{ required: true, message: '上级资源不能为空', trigger: 'blur' }
],
menuName: [
{ required: true, message: "资源名称不能为空", trigger: "blur" }
{ required: true, message: '资源名称不能为空', trigger: 'blur' }
],
menuSort: [
{ required: true, message: "资源排序不能为空", trigger: "blur" }
{ required: true, message: '资源排序不能为空', trigger: 'blur' }
]
},
// 状态数据字典
......@@ -119,12 +119,13 @@ export default {
},
created () {
console.log('data:' + JSON.stringify(this.data))
this.getDicts("sys_common_status").then(response => {
this.form.parentId = this.data.parentId
this.getDicts('sys_common_status').then(response => {
if (response.success) {
this.statusOptions = response.data
}
})
this.getDicts("sys_menu_type").then(response => {
this.getDicts('sys_menu_type').then(response => {
if (response.success) {
this.menuTypeOptions = response.data
}
......@@ -135,7 +136,7 @@ export default {
showCard () {
this.$emit('showCard', this.showOptions)
},
getMenuTreeSelect: function() {
getMenuTreeSelect: function () {
listMenu().then(response => {
if (response.success) {
const { data } = response
......@@ -153,7 +154,7 @@ export default {
/** 转换资源数据结构 */
normalizer (node) {
if (node.children && !node.children.length) {
delete node.children;
delete node.children
}
return {
id: node.id,
......@@ -162,18 +163,18 @@ export default {
}
},
/** 提交按钮 */
submitForm: function() {
this.$refs["form"].validate(valid => {
submitForm: function () {
this.$refs['form'].validate(valid => {
if (valid) {
addMenu(this.form).then(response => {
if (response.success) {
this.$message.success("保存成功")
this.$message.success('保存成功')
setTimeout(() => {
// 2秒后跳转列表页
this.$emit('showCard', this.showOptions)
}, 2000)
} else {
this.$message.error("保存失败")
this.$message.error('保存失败')
}
})
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment