Commit 30822b4a by yuwei

2.0.0项目初始化

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