feat: 菜单初始化提交

This commit is contained in:
fit2cloud-chenyw 2021-02-23 16:21:06 +08:00
parent 6f3f98b1e6
commit 12d0d862b9
3 changed files with 22 additions and 18 deletions

View File

@ -8,8 +8,8 @@ import org.apache.ibatis.annotations.Update;
public interface ExtMenuMapper {
@Update(" update sys_menu set sub_count = sub_count+1 where menu_id = #{menuId} ")
int incrementalSubcount(@Param("deptId") Long menuId);
int incrementalSubcount(@Param("menuId") Long menuId);
@Update(" update sys_menu set sub_count = sub_count-1 where menu_id = #{menuId} and sub_count > 0")
int decreasingSubcount(@Param("deptId") Long menuId);
int decreasingSubcount(@Param("menuId") Long menuId);
}

View File

@ -7,7 +7,7 @@
<el-row>
<el-col>
<span>{{$t('commons.delete_confirm')}}</span>
<span class="delete-tip"> DELETE-{{record.name}}</span>
<span class="delete-tip"> DELETE-{{record.name || record.title}}</span>
<br/>
</el-col>
</el-row>
@ -61,7 +61,7 @@
this.record = record;
},
confirm() {
if (this.value.trim() != 'DELETE-' + this.record.name) {
if (this.value.trim() != 'DELETE-' + (this.record.name || this.record.title) ) {
this.$warning(this.$t('commons.incorrect_input'));
return;
}

View File

@ -16,7 +16,7 @@
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
row-key="menuId">
<el-table-column :show-overflow-tooltip="true" label="菜单标题" width="125px" prop="title" />
<el-table-column :show-overflow-tooltip="true" label="菜单标题" width="150px" prop="title" />
<el-table-column prop="icon" label="图标" align="center" width="60px">
<template slot-scope="scope">
<svg-icon :icon-class="scope.row.icon ? scope.row.icon : ''" />
@ -43,7 +43,7 @@
<span v-else></span>
</template>
</el-table-column>
<el-table-column prop="createTime" label="创建日期" width="135px">
<el-table-column prop="createTime" label="创建日期" width="160px">
<template v-slot:default="scope">
<span>{{ scope.row.createTime | timestampFormatDate }}</span>
</template>
@ -126,7 +126,7 @@
</el-form-item>
<el-form-item label="上级类目" prop="pid">
<treeselect
v-model="form.pid"
v-model="form.pid"
:options="menus"
:load-options="loadMenus"
style="width: 450px;"
@ -180,7 +180,8 @@ export default {
},
data() {
return {
menus: null,
menus: [],
topMunu: { id: 0, label: '顶级类目', children: null },
formType: "add",
queryPath: '/api/menu/childNodes/',
deletePath: '/api/menu/delete',
@ -192,6 +193,7 @@ export default {
tableData: [],
maps: new Map(),
oldPid: null,
defaultForm: { menuId: null, title: null, menuSort: 999, path: null, component: null, componentName: null, iframe: false, pid: 0, icon: null, cache: false, hidden: false, type: 0, permission: null },
form: {},
rule: {
name: [
@ -206,7 +208,8 @@ export default {
}
},
activated() {
this.initTableData();
this.form = Object.assign({}, this.defaultForm)
this.initTableData()
},
methods: {
create() {
@ -219,7 +222,7 @@ export default {
},
edit(row) {
this.dialogOrgAddVisible = true;
this.dialogVisible = true;
this.formType = "modify";
this.oldPid = row.pid;
this.form = Object.assign({}, row);
@ -283,7 +286,8 @@ export default {
if(!row){
data.some(node => node.children = null);
_self.tableData = data;
_self.menus = null;
_self.menus = [];
_self.menus.push(_self.topMunu)
}else{
this.maps.set(row.menuId, {row, treeNode, resolve})
@ -293,11 +297,11 @@ export default {
},
closeFunc() {
this.initTableData();
this.form = {};
this.form = this.defaultForm;
this.oldPid = null;
this.menus = null;
removeGoBackListener(this.closeFunc);
this.dialogOrgAddVisible = false;
this.dialogVisible = false;
},
@ -328,7 +332,7 @@ export default {
}
return {
id: node.menuId,
label:node.name,
label:node.title,
children:node.children
}
},
@ -336,7 +340,7 @@ export default {
return {
id: node.menuId,
pid: node.pid,
label: node.name,
label: node.title,
children: node.children
}
},
@ -353,7 +357,7 @@ export default {
this.initTableData();
this.oldPid && this.reloadByPid(this.oldPid)
this.reloadByPid(this.form['pid'])
this.dialogOrgAddVisible = false;
this.dialogVisible = false;
});
} else {
return false;
@ -370,8 +374,8 @@ export default {
cancelButtonText: this.$t('commons.cancel'),
type: 'warning'
}).then(() => {
let requests = [{menuId: menu.menuId, pid: menu.pid}]
this.$post(this.deletePath, requests, () => {
let request = {menuId: menu.menuId, pid: menu.pid}
this.$post(this.deletePath, request, () => {
this.$success(this.$t('commons.delete_success'));
this.initTableData();
this.reloadByPid(menu.pid)