From efb4569338df5aeeba8317921bb5ee164dc03ed9 Mon Sep 17 00:00:00 2001 From: Your Name <123456> Date: 星期一, 11 七月 2022 17:49:19 +0800 Subject: [PATCH] 基础模块 --- src/views/system/department/component/deptDialog.vue | 47 ++++++++++++++++++++--------------------------- 1 files changed, 20 insertions(+), 27 deletions(-) diff --git a/src/views/system/department/component/deptDialog.vue b/src/views/system/department/component/deptDialog.vue index 0477317..e3757f2 100644 --- a/src/views/system/department/component/deptDialog.vue +++ b/src/views/system/department/component/deptDialog.vue @@ -7,23 +7,23 @@ <el-form-item label="上级部门"> <el-cascader :options="deptData" - :props="{ checkStrictly: true, value: 'id', label: 'name' }" + :props="{ emitPath: false, checkStrictly: true, value: 'depId', label: 'depName' }" placeholder="请选择部门" clearable class="w100" - v-model="departmentForm.struct" + v-model="departmentForm.parentDepId" > </el-cascader> </el-form-item> </el-col> <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20"> <el-form-item label="部门名称"> - <el-input v-model="departmentForm.name" placeholder="请输入部门名称" clearable></el-input> + <el-input v-model="departmentForm.depName" placeholder="请输入部门名称" clearable></el-input> </el-form-item> </el-col> <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20"> <el-form-item label="部门描述"> - <el-input v-model="departmentForm.info" type="textarea" placeholder="请输入部门描述" maxlength="150"></el-input> + <el-input v-model="departmentForm.depInfo" type="textarea" placeholder="请输入部门描述" maxlength="150"></el-input> </el-form-item> </el-col> </el-row> @@ -31,7 +31,7 @@ <template #footer> <span class="dialog-footer"> <el-button @click="onCancel" size="default">取 消</el-button> - <el-button type="primary" @click="onSubmit" size="default">新 增</el-button> + <el-button type="primary" @click="onSubmit" size="default">确 定</el-button> </span> </template> </el-dialog> @@ -45,7 +45,6 @@ // 定义接口来定义对象的类型 interface TableDataRow { - struct: Array<string>; name:string, info:string, parentId:string, @@ -55,10 +54,9 @@ title:string; isShowDialog: boolean; departmentForm: { - struct: Array<string>; - name:string, - info:string, - parentId:string + depName:string, + depInfo:string, + parentDepId:string }; deptData: Array<TableDataRow>; } @@ -70,10 +68,9 @@ title:'', isShowDialog: false, departmentForm: { - name:'', - parentId:'', - info:'', - struct:[] + depName:'', + parentDepId:'', + depInfo:'', }, deptData: [], // 部门数据 }); @@ -84,13 +81,13 @@ if(type === '新增'){ state.title = '新增部门' state.departmentForm = { - name:'', - parentId:'', - info:'', - struct:[] + depName:'', + parentDepId:'', + depInfo:'', } }else{ - state.title = '编辑部门' + state.title = '修改部门' + state.departmentForm = JSON.parse(JSON.stringify(value)) } }; // 关闭弹窗 @@ -103,20 +100,16 @@ }; // 新增 const onSubmit = async () => { - if(state.departmentForm.struct && state.departmentForm.struct !== []){ - let departmentId = JSON.parse(JSON.stringify(state.departmentForm.struct)) - state.departmentForm.parentId = departmentId[departmentId.length - 1] - } if(state.title === '新增部门'){ let res = await departmentApi().addDepartment(state.departmentForm) if(res.data.code === '200'){ ElMessage({ type:'success', - message:'菜单新增成功', + message:'部门新增成功', duration:2000 }) closeDialog(); - context.emit('getMenuList') + context.emit('getDepartmentList') }else{ ElMessage({ type:'warning', @@ -128,11 +121,11 @@ if(res.data.code === '200'){ ElMessage({ type:'success', - message:'菜单修改成功', + message:'部门修改成功', duration:2000 }) closeDialog(); - context.emit('getMenuList') + context.emit('getDepartmentList') }else{ ElMessage({ type:'warning', -- Gitblit v1.9.2