| | |
| | | <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> |
| | |
| | | <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> |
| | |
| | | |
| | | // 定义接口来定义对象的类型 |
| | | interface TableDataRow { |
| | | struct: Array<string>; |
| | | name:string, |
| | | info:string, |
| | | parentId:string, |
| | |
| | | title:string; |
| | | isShowDialog: boolean; |
| | | departmentForm: { |
| | | struct: Array<string>; |
| | | name:string, |
| | | info:string, |
| | | parentId:string |
| | | depName:string, |
| | | depInfo:string, |
| | | parentDepId:string |
| | | }; |
| | | deptData: Array<TableDataRow>; |
| | | } |
| | |
| | | title:'', |
| | | isShowDialog: false, |
| | | departmentForm: { |
| | | name:'', |
| | | parentId:'', |
| | | info:'', |
| | | struct:[] |
| | | depName:'', |
| | | parentDepId:'', |
| | | depInfo:'', |
| | | }, |
| | | deptData: [], // 部门数据 |
| | | }); |
| | |
| | | if(type === '新增'){ |
| | | state.title = '新增部门' |
| | | state.departmentForm = { |
| | | name:'', |
| | | parentId:'', |
| | | info:'', |
| | | struct:[] |
| | | depName:'', |
| | | parentDepId:'', |
| | | depInfo:'', |
| | | } |
| | | }else{ |
| | | state.title = '修改部门' |
| | |
| | | }; |
| | | // 新增 |
| | | 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'){ |