parent
8b490b31d1
commit
e5d8e3bb85
@ -1,223 +1,229 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<!-- 查询配置 -->
|
<!-- 查询配置 -->
|
||||||
<div style="padding: 0px 20px">
|
<div style="padding: 0px 20px">
|
||||||
<div ref="lxHeader">
|
<div ref="lxHeader">
|
||||||
<LxHeader icon="md-apps" text="菜单管理" style="margin-bottom: 10px; border: 0px; margin-top: 15px">
|
<LxHeader icon="md-apps" text="菜单管理" style="margin-bottom: 10px; border: 0px; margin-top: 15px">
|
||||||
<div slot="content"></div>
|
<div slot="content"></div>
|
||||||
<slot>
|
<slot>
|
||||||
<div>
|
<div>
|
||||||
<Input style="width: 200px; margin-right: 10px" v-model.number="searchFields.Name" placeholder="关键字搜索" />
|
<Input style="width: 200px; margin-right: 10px" v-model.number="searchFields.Name" placeholder="关键字搜索" />
|
||||||
<Button type="primary" @click="load" style="margin-left: 10px">查询</Button>
|
<Button type="primary" @click="load" style="margin-left: 10px">查询</Button>
|
||||||
<Button type="primary" @click="edit()" style="margin-left: 10px">新增菜单</Button>
|
<Button type="primary" @click="edit()" style="margin-left: 10px">新增菜单</Button>
|
||||||
</div>
|
</div>
|
||||||
</slot>
|
</slot>
|
||||||
</LxHeader>
|
</LxHeader>
|
||||||
</div>
|
</div>
|
||||||
<div class="table-tree">
|
<div class="table-tree">
|
||||||
<el-table :data="tableData" :height="tableHeight" class="v-table" style="width: 100%;margin-bottom: 20px;"
|
<el-table :data="tableData" :height="tableHeight" class="v-table" style="width: 100%;margin-bottom: 20px;"
|
||||||
row-key="id" border default-expand-all :tree-props="{children: 'children', hasChildren: 'hasChildren'}">
|
row-key="id" border default-expand-all :tree-props="{children: 'children', hasChildren: 'hasChildren'}">
|
||||||
<el-table-column type="index" align="center">
|
<el-table-column type="index" align="center">
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="name" label="菜单" sortable width="180">
|
<el-table-column prop="name" label="菜单" sortable width="180">
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="url" label="菜单路径" sortable>
|
<el-table-column prop="url" label="菜单路径" sortable>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="icon" label="图标" sortable>
|
<el-table-column prop="path" label="菜单视图" sortable>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="api_prefix" label="API前缀" sortable>
|
<el-table-column prop="icon" label="图标" sortable>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="sortnumber" label="排序" sortable>
|
<el-table-column prop="api_prefix" label="API前缀" sortable>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column fixed="right" label="操作" width="300">
|
<el-table-column prop="sortnumber" label="排序" sortable>
|
||||||
<template slot-scope="scope">
|
</el-table-column>
|
||||||
<Button type="primary" @click="addchildren(scope.row)" size="small" style="margin-left: 10px;"
|
<el-table-column fixed="right" label="操作" width="300">
|
||||||
ghost>子菜单</Button>
|
<template slot-scope="scope">
|
||||||
<Button type="error" @click="del(scope.row)" size="small" style="margin-left: 10px;" ghost>删除</Button>
|
<Button type="primary" @click="addchildren(scope.row)" size="small" style="margin-left: 10px;"
|
||||||
<Button type="primary" @click="edit(scope.row)" size="small" style="margin-left: 10px;" ghost>编辑</Button>
|
ghost>子菜单</Button>
|
||||||
</template>
|
<Button type="error" @click="del(scope.row)" size="small" style="margin-left: 10px;" ghost>删除</Button>
|
||||||
</el-table-column>
|
<Button type="primary" @click="edit(scope.row)" size="small" style="margin-left: 10px;" ghost>编辑</Button>
|
||||||
</el-table>
|
</template>
|
||||||
</div>
|
</el-table-column>
|
||||||
</div>
|
</el-table>
|
||||||
|
</div>
|
||||||
<el-dialog title="菜单编辑" :visible.sync="dialogFormVisible" width="30%">
|
</div>
|
||||||
<el-form :model="form" :rules="rules" ref="form" label-position="right" :label-width="formLabelWidth">
|
|
||||||
<el-form-item label="父菜单">
|
<el-dialog title="菜单编辑" :visible.sync="dialogFormVisible" width="30%">
|
||||||
<el-input v-model="form.pname" disabled autocomplete="off"></el-input>
|
<el-form :model="form" :rules="rules" ref="form" label-position="right" :label-width="formLabelWidth">
|
||||||
</el-form-item>
|
<el-form-item label="父菜单">
|
||||||
<el-form-item label="名称" prop="name">
|
<el-input v-model="form.pname" disabled autocomplete="off"></el-input>
|
||||||
<el-input v-model="form.name" autocomplete="off"></el-input>
|
</el-form-item>
|
||||||
</el-form-item>
|
<el-form-item label="名称" prop="name">
|
||||||
<el-form-item label="菜单路径" prop="url">
|
<el-input v-model="form.name" autocomplete="off"></el-input>
|
||||||
<el-input v-model="form.url" autocomplete="off"></el-input>
|
</el-form-item>
|
||||||
</el-form-item>
|
<el-form-item label="菜单路径" prop="url">
|
||||||
<el-form-item label="是否显示" prop="visible">
|
<el-input v-model="form.url" autocomplete="off"></el-input>
|
||||||
<el-select v-model="form.visible">
|
</el-form-item>
|
||||||
<el-option label="显示" value="1"></el-option>
|
<el-form-item label="菜单视图" prop="url">
|
||||||
<el-option label="不显示" value="0"></el-option>
|
<el-input v-model="form.path" autocomplete="off"></el-input>
|
||||||
</el-select>
|
</el-form-item>
|
||||||
</el-form-item>
|
<el-form-item label="是否显示" prop="visible">
|
||||||
<el-form-item label="API前缀" prop="api_prefix">
|
<el-select v-model="form.visible">
|
||||||
<el-input v-model="form.api_prefix" autocomplete="off"></el-input>
|
<el-option label="显示" value="1"></el-option>
|
||||||
</el-form-item>
|
<el-option label="不显示" value="0"></el-option>
|
||||||
<el-form-item label="图标" prop="icon">
|
</el-select>
|
||||||
<el-input v-model="form.icon" autocomplete="off"></el-input>
|
</el-form-item>
|
||||||
</el-form-item>
|
<el-form-item label="API前缀" prop="api_prefix">
|
||||||
<el-form-item label="排序">
|
<el-input v-model="form.api_prefix" autocomplete="off"></el-input>
|
||||||
<el-input v-model="form.sortnumber" autocomplete="off"></el-input>
|
</el-form-item>
|
||||||
</el-form-item>
|
<el-form-item label="图标" prop="icon">
|
||||||
</el-form>
|
<el-input v-model="form.icon" autocomplete="off"></el-input>
|
||||||
<div slot="footer" class="dialog-footer">
|
</el-form-item>
|
||||||
<el-button @click="resetForm('form')">取 消</el-button>
|
<el-form-item label="排序">
|
||||||
<el-button type="primary" @click="submitForm('form')">确 定</el-button>
|
<el-input v-model="form.sortnumber" autocomplete="off"></el-input>
|
||||||
</div>
|
</el-form-item>
|
||||||
</el-dialog>
|
</el-form>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
</div>
|
<el-button @click="resetForm('form')">取 消</el-button>
|
||||||
</template>
|
<el-button type="primary" @click="submitForm('form')">确 定</el-button>
|
||||||
<script>
|
</div>
|
||||||
import LxHeader from "@/components/LxHeader/index.vue";
|
</el-dialog>
|
||||||
import {
|
|
||||||
save,
|
</div>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
import LxHeader from "@/components/LxHeader/index.vue";
|
||||||
|
import {
|
||||||
|
save,
|
||||||
listmenu,
|
listmenu,
|
||||||
del
|
del
|
||||||
} from "../../api/system/menu.js";
|
} from "../../api/system/menu.js";
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
LxHeader
|
LxHeader
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.initLoad();
|
this.initLoad();
|
||||||
this.load();
|
this.load();
|
||||||
},
|
},
|
||||||
mounted() {},
|
mounted() {},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
dialogFormVisible: false,
|
dialogFormVisible: false,
|
||||||
formLabelWidth: "120px",
|
formLabelWidth: "120px",
|
||||||
form: {
|
form: {
|
||||||
name: "",
|
name: "",
|
||||||
id: "",
|
id: "",
|
||||||
pid: "0",
|
pid: "0",
|
||||||
url: "",
|
url: "",
|
||||||
visible: "1",
|
visible: "1",
|
||||||
sortnumber: 0,
|
sortnumber: 0,
|
||||||
icon: "",
|
icon: "",
|
||||||
pname: "根菜单",
|
pname: "根菜单",
|
||||||
api_prefix:""
|
api_prefix:"",
|
||||||
},
|
path:''
|
||||||
rules: {
|
},
|
||||||
name: [{
|
rules: {
|
||||||
required: true,
|
name: [{
|
||||||
message: '请输入菜单名称',
|
required: true,
|
||||||
trigger: 'blur'
|
message: '请输入菜单名称',
|
||||||
}],
|
trigger: 'blur'
|
||||||
url: [{
|
}],
|
||||||
required: true,
|
url: [{
|
||||||
message: '请输入菜单路径',
|
required: true,
|
||||||
trigger: 'blur'
|
message: '请输入菜单路径',
|
||||||
}],
|
trigger: 'blur'
|
||||||
icon: [{
|
}],
|
||||||
required: true,
|
icon: [{
|
||||||
message: '请输入图标',
|
required: true,
|
||||||
trigger: 'blur'
|
message: '请输入图标',
|
||||||
}],
|
trigger: 'blur'
|
||||||
visible: [{
|
}],
|
||||||
required: true,
|
visible: [{
|
||||||
message: '请选择是否显示',
|
required: true,
|
||||||
trigger: 'blur'
|
message: '请选择是否显示',
|
||||||
}],
|
trigger: 'blur'
|
||||||
},
|
}],
|
||||||
tableHeight: 0,
|
},
|
||||||
//查询条件字段
|
tableHeight: 0,
|
||||||
searchFields: {
|
//查询条件字段
|
||||||
KeyWord: ""
|
searchFields: {
|
||||||
},
|
KeyWord: ""
|
||||||
tableData: []
|
},
|
||||||
}
|
tableData: []
|
||||||
},
|
}
|
||||||
methods: {
|
},
|
||||||
initLoad() {
|
methods: {
|
||||||
var that = this;
|
initLoad() {
|
||||||
var clientHeight = document.documentElement.clientHeight
|
var that = this;
|
||||||
var lxHeader_height = 96.5; //查询 头部
|
var clientHeight = document.documentElement.clientHeight
|
||||||
var paginationHeight = 37; //分页的高度
|
var lxHeader_height = 96.5; //查询 头部
|
||||||
var topHeight = 50; //页面 头部
|
var paginationHeight = 37; //分页的高度
|
||||||
let tableHeight = clientHeight - lxHeader_height - topHeight - paginationHeight - 20;
|
var topHeight = 50; //页面 头部
|
||||||
that.tableHeight = tableHeight;
|
let tableHeight = clientHeight - lxHeader_height - topHeight - paginationHeight - 20;
|
||||||
},
|
that.tableHeight = tableHeight;
|
||||||
load() {
|
},
|
||||||
var that = this;
|
load() {
|
||||||
listmenu().then(response => {
|
var that = this;
|
||||||
that.tableData = response;
|
listmenu().then(response => {
|
||||||
}).catch(error => {
|
that.tableData = response;
|
||||||
//reject(error)
|
}).catch(error => {
|
||||||
})
|
//reject(error)
|
||||||
|
})
|
||||||
},
|
|
||||||
edit(obj) {
|
},
|
||||||
this.form = this.$options.data().form
|
edit(obj) {
|
||||||
if (obj) {
|
this.form = this.$options.data().form
|
||||||
obj.visible = obj.visible.toString();
|
if (obj) {
|
||||||
var result = Object.assign(this.form, obj)
|
obj.visible = obj.visible.toString();
|
||||||
this.form = result;
|
var result = Object.assign(this.form, obj)
|
||||||
}
|
this.form = result;
|
||||||
this.dialogFormVisible = true;
|
}
|
||||||
},
|
this.dialogFormVisible = true;
|
||||||
addchildren(obj) {
|
},
|
||||||
this.form = this.$options.data().form
|
addchildren(obj) {
|
||||||
if (obj) {
|
this.form = this.$options.data().form
|
||||||
this.form.pname = obj.name;
|
if (obj) {
|
||||||
this.form.pid = obj.id;
|
this.form.pname = obj.name;
|
||||||
this.dialogFormVisible = true;
|
this.form.pid = obj.id;
|
||||||
}
|
this.dialogFormVisible = true;
|
||||||
},
|
}
|
||||||
submitForm(formName) {
|
},
|
||||||
var that = this;
|
submitForm(formName) {
|
||||||
this.$refs[formName].validate((valid) => {
|
var that = this;
|
||||||
if (valid) {
|
this.$refs[formName].validate((valid) => {
|
||||||
save(that.form).then(response => {
|
if (valid) {
|
||||||
console.log(response)
|
save(that.form).then(response => {
|
||||||
this.$Message.success('操作成功');
|
console.log(response)
|
||||||
that.dialogFormVisible = false;
|
this.$Message.success('操作成功');
|
||||||
that.load();
|
that.dialogFormVisible = false;
|
||||||
}).catch(error => {
|
that.load();
|
||||||
reject(error)
|
}).catch(error => {
|
||||||
})
|
reject(error)
|
||||||
} else {
|
})
|
||||||
this.$Message.error('数据校验失败');
|
} else {
|
||||||
return false;
|
this.$Message.error('数据校验失败');
|
||||||
}
|
return false;
|
||||||
});
|
}
|
||||||
},
|
});
|
||||||
resetForm(formName) {
|
},
|
||||||
var that = this;
|
resetForm(formName) {
|
||||||
this.$refs[formName].resetFields();
|
var that = this;
|
||||||
that.dialogFormVisible = false;
|
this.$refs[formName].resetFields();
|
||||||
},
|
that.dialogFormVisible = false;
|
||||||
del(obj) {
|
},
|
||||||
var that = this;
|
del(obj) {
|
||||||
if (obj) {
|
var that = this;
|
||||||
this.$Modal.confirm({
|
if (obj) {
|
||||||
title: '确认要删除数据?',
|
this.$Modal.confirm({
|
||||||
onOk: () => {
|
title: '确认要删除数据?',
|
||||||
del({
|
onOk: () => {
|
||||||
id: obj.id
|
del({
|
||||||
}).then(response => {
|
id: obj.id
|
||||||
this.$Message.success('操作成功');
|
}).then(response => {
|
||||||
that.load();
|
this.$Message.success('操作成功');
|
||||||
}).catch(error => {
|
that.load();
|
||||||
console.log(error)
|
}).catch(error => {
|
||||||
reject(error)
|
console.log(error)
|
||||||
})
|
reject(error)
|
||||||
},
|
})
|
||||||
onCancel: () => {
|
},
|
||||||
//this.$Message.info('Clicked cancel');
|
onCancel: () => {
|
||||||
}
|
//this.$Message.info('Clicked cancel');
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
},
|
}
|
||||||
}
|
},
|
||||||
};
|
}
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
Reference in new issue