Просмотр исходного кода

优化按钮权限和列表权限的编辑更新等

yanglzh 3 лет назад
Родитель
Сommit
3dd4b83e14

+ 5 - 3
src/views/system/menu/component/btn-form.vue

@@ -27,7 +27,7 @@
 </template>
 
 <script lang="ts" setup>
-import { ref, reactive, PropType } from 'vue';
+import { ref, reactive, PropType, nextTick } from 'vue';
 import api from '/@/api/system';
 import { MenuBtnRow } from '/@/api/model/system/menu';
 import { ruleRequired } from '/@/utils/validator';
@@ -44,6 +44,7 @@ const formRef = ref();
 
 const baseForm: MenuBtnRow = {
 	parentId: -1,
+	id: undefined,
 	menuId: 0,
 	name: '',
 	types: '',
@@ -84,9 +85,10 @@ const resetForm = async () => {
 
 const open = async (row: any) => {
 	resetForm();
-	Object.assign(formData, { ...row });
 	showDialog.value = true;
-	// console.log(row);
+	nextTick(() => {
+		Object.assign(formData, { ...row });
+	});
 };
 
 defineExpose({ open });

+ 5 - 0
src/views/system/menu/component/btn.vue

@@ -22,6 +22,7 @@
             <el-dropdown-item command="del-删除">删除</el-dropdown-item>
             <el-dropdown-item command="upload-导入">导入</el-dropdown-item>
             <el-dropdown-item command="dwonload-导出">导出</el-dropdown-item>
+            <el-dropdown-item command="reset-重置">重置</el-dropdown-item>
           </el-dropdown-menu>
         </template>
       </el-dropdown>
@@ -54,6 +55,7 @@ import btnForm from './btn-form.vue';
 import { MenuBtnRow } from '/@/api/model/system/menu';
 import api from '/@/api/system';
 import { ElMessageBox, ElMessage } from 'element-plus';
+import { getBackEndControlRoutes } from '/@/router/backEnd';
 
 const title = ref('按钮权限');
 const drawer = ref(false);
@@ -96,6 +98,7 @@ const addCommonType = async (command: string) => {
 	await api.menu.btn.add(formData);
 	ElMessage.success('操作成功');
 	getList();
+	getBackEndControlRoutes();
 };
 
 // 修改启用停用状态
@@ -109,6 +112,7 @@ const handleStatusChange = (row: MenuBtnRow) => {
 		.then(async function () {
 			await api.menu.btn.setStatus(row.id as number, row.menuId as number, row.status);
 			ElMessage.success('操作成功');
+			getBackEndControlRoutes();
 		})
 		.catch(function () {
 			row.status = row.status === 0 ? 1 : 0;
@@ -124,6 +128,7 @@ const onDel = (row: MenuBtnRow) => {
 		await api.menu.btn.del(row.id as number);
 		ElMessage.success('删除成功');
 		getList();
+		getBackEndControlRoutes();
 	});
 };
 

+ 12 - 8
src/views/system/menu/component/list-form.vue

@@ -1,9 +1,9 @@
 <template>
   <el-dialog v-model="showDialog" :title="`${formData.id?'编辑显示列':'新增显示列'}`" width="500px" :close-on-click-modal="false" :close-on-press-escape="false">
     <el-form ref="formRef" :model="formData" :rules="ruleForm" label-width="80px">
-      <el-form-item label="上级" prop="parentId">
+      <!-- <el-form-item label="上级" prop="parentId">
         <el-cascader :options="parentData" :props="{ label: 'name',value: 'id',checkStrictly: true,emitPath: false }" placeholder="请选择上级菜单" clearable class="w100" v-model="formData.parentId"></el-cascader>
-      </el-form-item>
+      </el-form-item> -->
       <el-form-item label="字段名称" prop="name">
         <el-input v-model="formData.name" placeholder="字段名称" />
       </el-form-item>
@@ -27,15 +27,16 @@
 </template>
 
 <script lang="ts" setup>
-import { ref, reactive, PropType } from 'vue';
+import { ref, reactive, nextTick } from 'vue';
 import api from '/@/api/system';
 import { MenuListRow } from '/@/api/model/system/menu';
 import { ruleRequired } from '/@/utils/validator';
 import { ElMessage } from 'element-plus';
+import { getBackEndControlRoutes } from '/@/router/backEnd';
 
-defineProps({
-	parentData: Array as PropType<MenuListRow[]>,
-});
+// defineProps({
+// 	parentData: Array as PropType<MenuListRow[]>,
+// });
 
 const emit = defineEmits(['getList']);
 
@@ -44,6 +45,7 @@ const formRef = ref();
 
 const baseForm: MenuListRow = {
 	parentId: -1,
+	id: undefined,
 	menuId: 0,
 	name: '',
 	code: '',
@@ -72,6 +74,7 @@ const onSubmit = async () => {
 	await theApi(formData);
 
 	ElMessage.success('操作成功');
+	getBackEndControlRoutes()
 	resetForm();
 	showDialog.value = false;
 	emit('getList');
@@ -84,9 +87,10 @@ const resetForm = async () => {
 
 const open = async (row: any) => {
 	resetForm();
-	Object.assign(formData, { ...row });
 	showDialog.value = true;
-	// console.log(row);
+	nextTick(() => {
+		Object.assign(formData, { ...row });
+	});
 };
 
 defineExpose({ open });

+ 5 - 1
src/views/system/menu/component/list.vue

@@ -27,7 +27,8 @@
       </el-table-column>
     </el-table>
   </el-drawer>
-  <listForm ref="listFormRef" :parent-data="tableData" @getList="getList"></listForm>
+  <!-- <listForm ref="listFormRef" :parent-data="tableData" @getList="getList"></listForm> -->
+  <listForm ref="listFormRef" @getList="getList"></listForm>
 </template>
 
 <script lang="ts" setup>
@@ -36,6 +37,7 @@ import listForm from './list-form.vue';
 import { MenuListRow } from '/@/api/model/system/menu';
 import api from '/@/api/system';
 import { ElMessageBox, ElMessage } from 'element-plus';
+import { getBackEndControlRoutes } from '/@/router/backEnd';
 
 const title = ref('列表权限');
 const drawer = ref(false);
@@ -75,6 +77,7 @@ const handleStatusChange = (row: MenuListRow) => {
 		.then(async function () {
 			await api.menu.list.setStatus(row.id as number, row.menuId as number, row.status);
 			ElMessage.success('操作成功');
+			getBackEndControlRoutes();
 		})
 		.catch(function () {
 			row.status = row.status === 0 ? 1 : 0;
@@ -90,6 +93,7 @@ const onDel = (row: MenuListRow) => {
 		await api.menu.list.del(row.id as number);
 		ElMessage.success('删除成功');
 		getList();
+		getBackEndControlRoutes();
 	});
 };