Merge branch 'main' of https://github.com/ccnetcore/Yi into main

This commit is contained in:
lzw
2021-10-16 17:57:24 +08:00
16 changed files with 288 additions and 67 deletions

View File

@@ -66,6 +66,13 @@
</summary>
<returns></returns>
</member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.MenuController.AddChildrenMenu(Yi.Framework.DTOModel.ChildrenDto{Yi.Framework.Model.Models.menu})">
<summary>
给一个菜单添加子节点(注意:添加,不是覆盖)
</summary>
<param name="childrenDto"></param>
<returns></returns>
</member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.MouldController.UpdateMould(Yi.Framework.Model.Models.mould)">
<summary>

View File

@@ -47,9 +47,9 @@ namespace Yi.Framework.Service
{
return false;
}
var menuList = _Db.Set<menu>().Where(u => menuIds.Contains(u.id)&&u.is_delete == (short)Common.Enum.DelFlagEnum.Normal).ToListAsync();
var menuList = await _Db.Set<menu>().Where(u => menuIds.Contains(u.id)&&u.is_delete == (short)Common.Enum.DelFlagEnum.Normal).ToListAsync();
role_data.menus = (ICollection<menu>)menuList;
role_data.menus =menuList;
return await AddAsync(role_data);
}
}

View File

@@ -6,4 +6,39 @@ export default {
method: 'get'
})
},
addChildrenMenu(id, data) {
return myaxios({
url: '/Menu/addChildrenMenu',
method: 'post',
data: { parentId: id, data }
})
},
UpdateMenu(data) {
return myaxios({
url: '/Menu/UpdateMenu',
method: 'put',
data: data
})
},
DelListMenu(ids) {
return myaxios({
url: '/Menu/DelListMenu',
method: 'delete',
data: ids
})
},
addMenu(data) {
return myaxios({
url: '/Menu/addMenu',
method: 'post',
data: data
})
},
SetMouldByMenu(menuId, mouldId) {
return myaxios({
url: '/Menu/SetMouldByMenu',
method: 'post',
data: { id1: menuId, id2: mouldId }
})
}
}

View File

@@ -0,0 +1,10 @@
import myaxios from '@/util/myaxios'
export default {
getMould() {
return myaxios({
url: '/Mould/GetMould',
method: 'get'
})
}
}

View File

@@ -5,5 +5,12 @@ export default {
url: '/Role/getRole',
method: 'get'
})
},
setMenuByRole(roleList, menuList) {
return myaxios({
url: '/Role/setMenuByRole',
method: 'post',
data: { ids1: roleList, ids2: menuList }
})
}
}

View File

@@ -26,9 +26,9 @@
<div class="text-body-1 font-weight-light pt-6 pt-md-0 text-center">
&copy; {{ (new Date()).getFullYear() }}, Made by <v-icon>mdi-vuetify</v-icon>
<a
href="https://vuetifyjs.com/en/about/meet-the-team/#company"
href="https://ccnetcore"
class="text-decoration-none"
>Vuetify</a>
>ccnetcore</a>
</div>
</v-col>
</v-row>
@@ -42,21 +42,17 @@
data: () => ({
links: [
{
href: 'https://vuetifyjs.com/',
text: 'Vuetify Docs',
href: '#',
text: 'YiFramework文档',
},
{
href: '#',
text: 'About Us',
text: 'GitHub',
},
{
href: '#',
text: 'Blog',
},
{
href: '#',
text: 'Licenses',
},
text: '论坛',
}
],
}),
}

View File

@@ -1,7 +1,7 @@
<template>
<v-dialog v-model="dialog" persistent max-width="600px">
<template v-slot:activator="{ on, attrs }">
<v-btn color="primary" dark v-bind="attrs" v-on="on">
<v-btn class="ma-2" color="primary" dark v-bind="attrs" v-on="on">
{{ headers }}
</v-btn>
</template>

View File

@@ -74,8 +74,8 @@
<v-btn
v-if="axiosUrls.hasOwnProperty('del')"
color="red"
dark
color="secondary"
class="mb-2"
@click="deleteItem(null)"
>

View File

@@ -1,37 +1,198 @@
<template>
<v-treeview
selectable
:items="items"
:selection-type="selectionType"
v-model="selection"
return-object
open-all
hoverable
item-text="menu_name"
>
<template v-slot:append="{ item }">
<v-btn>编号:{{ item.id }}</v-btn>
<v-btn>图标:{{ item.icon }}</v-btn>
<v-btn>路由:{{ item.router }}</v-btn>
<v-btn>设置接口权限</v-btn>
<v-btn>编辑</v-btn>
<v-btn>删除</v-btn>
<v-btn>添加子菜单</v-btn>
</template>
</v-treeview>
<div>
<app-btn dark class="ma-2" @click="dialog = true"> 添加新项 </app-btn>
<app-btn dark class="ma-2" color="secondary" @click="deleteItem(null)">
删除所选
</app-btn>
<v-dialog v-model="dialog" max-width="500px">
<v-card>
<v-card-title>
<span class="headline">{{ formTitle }}</span>
</v-card-title>
<v-card-text>
<v-container>
<v-row>
<v-col
cols="12"
sm="6"
md="4"
v-for="(value, key, index) in editedItem"
:key="index"
>
<v-text-field
v-model="editedItem[key]"
:label="key"
></v-text-field>
</v-col>
</v-row>
</v-container>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="blue darken-1" text @click="close"> 取消 </v-btn>
<v-btn color="blue darken-1" text @click="save"> 保存 </v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<v-treeview
selectable
:items="desserts"
:selection-type="selectionType"
v-model="selection"
return-object
open-all
hoverable
item-text="menu_name"
>
<template v-slot:append="{ item }">
<v-btn class="mr-2">编号:{{ item.id }}</v-btn>
<v-btn class="mr-2">图标:{{ item.icon }}</v-btn>
<v-btn class="mr-2">路由:{{ item.router }}</v-btn>
<ccCombobox
headers="设置接口权限"
itemText="mould_name"
:items="mouldList"
@select="getSelect"
>
<template v-slot:save>
<v-btn @click="setMould(item)" color="blue darken-1" text>
保存</v-btn
>
</template>
</ccCombobox>
<app-btn
@click="
parentId = item.id;
dialog = true;
"
>添加子菜单</app-btn
>
<app-btn class="mx-2" @click="editItem(item)">编辑</app-btn>
<app-btn color="secondary" class="mr-2" @click="deleteItem(item)">删除</app-btn>
</template>
</v-treeview>
</div>
</template>
<script>
import mouldApi from "../api/mouldApi";
import menuApi from "../api/menuApi";
export default {
name: "ccTreeview",
props: {
items: {
type: Array,
},
},
data: () => ({
mouldSelect: [],
mouldList: [],
desserts: [],
selectionType: "leaf",
selection: [],
dialog: false,
editedItem: {},
editedIndex: -1,
parentId: 0,
defaultItem: {
icon: "mdi-start",
router: "test",
menu_name: "测试",
},
}),
computed: {
formTitle() {
return this.editedIndex === -1 ? "添加数据" : "编辑数据";
},
},
created() {
this.init();
},
methods: {
setMould(item) {
menuApi.SetMouldByMenu(item.id, this.mouldSelect[0].id).then((resp) => {
this.$dialog.notify.info(resp.msg, {
position: "top-right",
timeout: 5000,
});
});
},
getSelect(data) {
this.mouldSelect = data;
},
async deleteItem(item) {
this.editedIndex = this.desserts.indexOf(item);
this.editedItem = Object.assign({}, item);
var p = await this.$dialog.warning({
text: "你确定要删除此条记录吗??",
title: "警告",
actions: {
false: "取消",
true: "确定",
},
});
if (p) {
this.deleteItemConfirm();
}
},
deleteItemConfirm() {
var Ids = [];
if (this.editedIndex > -1) {
Ids.push(this.editedItem.id);
} else {
this.selection.forEach(function (item) {
Ids.push(item.id);
});
}
menuApi.DelListMenu(Ids).then(() => this.init());
},
close() {
this.dialog = false;
this.$nextTick(() => {
this.editedItem = Object.assign({}, this.defaultItem);
this.editedIndex = -1;
});
},
init() {
this.parentId = 0;
mouldApi.getMould().then((resp) => {
this.mouldList = resp.data;
});
menuApi.getMenu().then((resp) => {
this.desserts = resp.data;
});
this.$nextTick(() => {
this.editedItem = Object.assign({}, this.defaultItem);
this.editedIndex = -1;
});
},
editItem(item) {
this.editedIndex = this.desserts.indexOf(item);
this.editedItem = Object.assign({}, item);
this.dialog = true;
},
save() {
if (this.editedIndex > -1) {
menuApi.UpdateMenu(this.editedItem).then(() => this.init());
} else {
if (this.parentId == 0) {
menuApi.addMenu(this.editedItem).then(() => {
this.init();
});
} else {
menuApi.addChildrenMenu(this.parentId, this.editedItem).then(() => {
this.init();
});
}
}
this.close();
},
},
watch: {
selection: {
//深度监听,可监听到对象、数组的变化
@@ -40,7 +201,9 @@ export default {
},
deep: true,
},
dialog(val) {
val || this.close();
},
},
methods: {},
};
</script>

View File

@@ -41,7 +41,7 @@
export default {
data:()=>({
drawer:true,
name:"测试系统"
name:"系统"
}),
name: 'DefaultBar',

View File

@@ -51,7 +51,7 @@
mdi-package-up
</v-icon>
Upgrade to Pro
退出
</app-btn>
</div>
</template>

View File

@@ -9,9 +9,9 @@
<v-list-item-content class="pl-2">
<v-list-item-title class="text-h3">
<strong class="mr-1 font-weight-black">VMD</strong>
<strong class="mr-1 font-weight-black">Yi</strong>
<span class="primary--text">FREE</span>
<span class="primary--text">Framework</span>
</v-list-item-title>
</v-list-item-content>
</v-list-item>

View File

@@ -1,10 +1,10 @@
<template>
<v-text-field
placeholder="Search"
placeholder="全站搜索"
class="mr-16"
color="secondary"
hide-details
style="max-width: 220px"
style="max-width: 400px"
>
<template
v-if="$vuetify.breakpoint.mdAndUp"

View File

@@ -1,29 +1,18 @@
<template>
<v-card class="mx-auto" width="100%">
<v-btn color="primary" dark class="mb-2 mx-2" @click="dialog = true">
添加新项
</v-btn>
<v-btn color="primary" dark class="mb-2 mx-2" @click="dialog = true">
删除所选
</v-btn>
<ccTreeview :items="Menuitems"></ccTreeview>
<ccTreeview></ccTreeview>
</v-card>
</template>
<script>
import menuApi from "../api/MenuApi";
export default {
created() {
this.init();
},
data: () => ({
Menuitems: [],
}),
methods: {
init() {
menuApi.getMenu().then((resp) => {
this.Menuitems = resp.data;
});
},
},
};
</script>

View File

@@ -1,7 +1,7 @@
<template>
<v-row>
<v-col cols="12">
<v-card class="mx-auto" width="100%"><v-btn color="primary">确定分配</v-btn></v-card>
<v-card class="mx-auto" width="100%"><app-btn class="ma-2" @click="setMenu">确定分配</app-btn></v-card>
</v-col>
<v-col cols="12" md="4" lg="4">
<v-card class="mx-auto" width="100%">
@@ -41,12 +41,28 @@
</template>
<script>
import roleApi from "../api/roleApi";
import menuApi from "../api/MenuApi";
import menuApi from "../api/menuApi";
export default {
created() {
this.init();
},
methods: {
setMenu(){
var roleIds=[];
var menuIds=[];
this.selectionRole.forEach((ele)=>{
roleIds.push(ele.id)
})
this.selectionMenu.forEach((ele)=>{
menuIds.push(ele.id)
})
roleApi.setMenuByRole(roleIds,menuIds).then(resp=>{
this.$dialog.notify.info(resp.msg, {
position: "top-right",
timeout: 5000,
});
})
},
init() {
roleApi.getRole().then((resp) => {
this.RoleItems = resp.data;

View File

@@ -1,7 +1,5 @@
<template>
<v-card class="mx-auto" width="100%">
{{ select }}
{{ TableSelect }}
<ccCombobox
headers="设置角色"
:items="roleItems"