mirror of
https://github.com/FatttSnake/Pinnacle-OA.git
synced 2026-04-05 15:01:23 +08:00
Added DepartmentManagement
This commit is contained in:
@@ -1,14 +1,14 @@
|
|||||||
package com.cfive.pinnacle.controller;
|
package com.cfive.pinnacle.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.cfive.pinnacle.entity.Department;
|
import com.cfive.pinnacle.entity.Department;
|
||||||
import com.cfive.pinnacle.entity.common.ResponseCode;
|
import com.cfive.pinnacle.entity.common.ResponseCode;
|
||||||
import com.cfive.pinnacle.entity.common.ResponseResult;
|
import com.cfive.pinnacle.entity.common.ResponseResult;
|
||||||
import com.cfive.pinnacle.service.IDepartmentService;
|
import com.cfive.pinnacle.service.IDepartmentService;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -22,13 +22,18 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/department")
|
@RequestMapping("/department")
|
||||||
@CrossOrigin
|
@Tag(name = "部门", description = "部门相关接口")
|
||||||
public class DepartmentController {
|
public class DepartmentController {
|
||||||
|
private IDepartmentService departmentService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
IDepartmentService departmentService;
|
public void setDepartmentService(IDepartmentService departmentService) {
|
||||||
|
this.departmentService = departmentService;
|
||||||
|
}
|
||||||
|
|
||||||
//获取所有部门及其各部门所属成员
|
//获取所有部门及其各部门所属成员
|
||||||
@GetMapping
|
@GetMapping("/user")
|
||||||
|
@Deprecated
|
||||||
public ResponseResult getDepartAndUser() {
|
public ResponseResult getDepartAndUser() {
|
||||||
List<Department> getDepartAndUser = departmentService.getDepartAndUser();
|
List<Department> getDepartAndUser = departmentService.getDepartAndUser();
|
||||||
Integer code = getDepartAndUser != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR;
|
Integer code = getDepartAndUser != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR;
|
||||||
@@ -36,4 +41,39 @@ public class DepartmentController {
|
|||||||
return ResponseResult.build(code, msg, getDepartAndUser);
|
return ResponseResult.build(code, msg, getDepartAndUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
@PreAuthorize("hasAuthority('department:admin:get')")
|
||||||
|
public ResponseResult<IPage<Department>> getAllDepartment(Long currentPage, Long pageSize, Integer searchType, String searchInput) {
|
||||||
|
return ResponseResult.databaseSelectSuccess(departmentService.getAllDepartment(currentPage, pageSize, searchType, searchInput));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping
|
||||||
|
@PreAuthorize("hasAuthority('department:admin:add')")
|
||||||
|
public ResponseResult<?> addDepartment(@RequestBody Department department) {
|
||||||
|
if (departmentService.save(department)) {
|
||||||
|
return ResponseResult.databaseSaveSuccess(null);
|
||||||
|
} else {
|
||||||
|
return ResponseResult.build(ResponseCode.DATABASE_SAVE_ERROR, "error", null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping
|
||||||
|
@PreAuthorize("hasAuthority('department:admin:modify')")
|
||||||
|
public ResponseResult<?> modifyDepartment(@RequestBody Department department) {
|
||||||
|
if (departmentService.updateById(department)) {
|
||||||
|
return ResponseResult.databaseUpdateSuccess(null);
|
||||||
|
} else {
|
||||||
|
return ResponseResult.build(ResponseCode.DATABASE_SAVE_ERROR, "error", null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/{id}")
|
||||||
|
@PreAuthorize("hasAuthority('department:admin:delete')")
|
||||||
|
public ResponseResult<?> deleteDepartment(@PathVariable Long id) {
|
||||||
|
if (departmentService.removeById(id)) {
|
||||||
|
return ResponseResult.databaseDeleteSuccess();
|
||||||
|
} else {
|
||||||
|
return ResponseResult.build(ResponseCode.DATABASE_DELETE_ERROR, "error", null);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import com.cfive.pinnacle.entity.common.ResponseCode;
|
|||||||
import com.cfive.pinnacle.entity.common.ResponseResult;
|
import com.cfive.pinnacle.entity.common.ResponseResult;
|
||||||
import com.cfive.pinnacle.entity.permission.User;
|
import com.cfive.pinnacle.entity.permission.User;
|
||||||
import com.cfive.pinnacle.service.IStaffService;
|
import com.cfive.pinnacle.service.IStaffService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@@ -18,7 +17,6 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
* @author FatttSnake
|
* @author FatttSnake
|
||||||
* @since 2023-04-30
|
* @since 2023-04-30
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/staff")
|
@RequestMapping("/staff")
|
||||||
public class StaffController {
|
public class StaffController {
|
||||||
@@ -38,7 +36,6 @@ public class StaffController {
|
|||||||
@PutMapping
|
@PutMapping
|
||||||
@PreAuthorize("hasAnyAuthority('staff:manege:modify', 'staff:admin:modify')")
|
@PreAuthorize("hasAnyAuthority('staff:manege:modify', 'staff:admin:modify')")
|
||||||
public ResponseResult<?> modifyStaff(@RequestBody User user) {
|
public ResponseResult<?> modifyStaff(@RequestBody User user) {
|
||||||
log.info(user.toString());
|
|
||||||
if (staffService.modifyStaff(user)) {
|
if (staffService.modifyStaff(user)) {
|
||||||
return ResponseResult.databaseUpdateSuccess(null);
|
return ResponseResult.databaseUpdateSuccess(null);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package com.cfive.pinnacle.mapper;
|
package com.cfive.pinnacle.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.cfive.pinnacle.entity.Department;
|
import com.cfive.pinnacle.entity.Department;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -16,5 +18,8 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface DepartmentMapper extends BaseMapper<Department> {
|
public interface DepartmentMapper extends BaseMapper<Department> {
|
||||||
|
@Deprecated
|
||||||
List<Department> getDepartAndUser();
|
List<Department> getDepartAndUser();
|
||||||
|
|
||||||
|
IPage<Department> getAllDepartment(IPage<Department> page, @Param("searchType") Integer searchType, @Param("searchInput") String searchInput);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.cfive.pinnacle.service;
|
package com.cfive.pinnacle.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.cfive.pinnacle.entity.Department;
|
import com.cfive.pinnacle.entity.Department;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
@@ -14,6 +15,8 @@ import java.util.List;
|
|||||||
* @since 2023-04-30
|
* @since 2023-04-30
|
||||||
*/
|
*/
|
||||||
public interface IDepartmentService extends IService<Department> {
|
public interface IDepartmentService extends IService<Department> {
|
||||||
|
@Deprecated
|
||||||
List<Department> getDepartAndUser();
|
List<Department> getDepartAndUser();
|
||||||
|
|
||||||
|
IPage<Department> getAllDepartment(Long currentPage, Long pageSize, Integer searchType, String searchInput);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.cfive.pinnacle.service.impl;
|
package com.cfive.pinnacle.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
|
||||||
import com.cfive.pinnacle.entity.Department;
|
import com.cfive.pinnacle.entity.Department;
|
||||||
import com.cfive.pinnacle.mapper.DepartmentMapper;
|
import com.cfive.pinnacle.mapper.DepartmentMapper;
|
||||||
import com.cfive.pinnacle.service.IDepartmentService;
|
import com.cfive.pinnacle.service.IDepartmentService;
|
||||||
@@ -19,11 +21,28 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Department> implements IDepartmentService {
|
public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Department> implements IDepartmentService {
|
||||||
@Autowired
|
|
||||||
private DepartmentMapper departmentMapper;
|
private DepartmentMapper departmentMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public void setDepartmentMapper(DepartmentMapper departmentMapper) {
|
||||||
|
this.departmentMapper = departmentMapper;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Deprecated
|
||||||
public List<Department> getDepartAndUser() {
|
public List<Department> getDepartAndUser() {
|
||||||
return departmentMapper.getDepartAndUser();
|
return departmentMapper.getDepartAndUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IPage<Department> getAllDepartment(Long currentPage, Long pageSize, Integer searchType, String searchInput) {
|
||||||
|
IPage<Department> departmentIPage;
|
||||||
|
if (currentPage == null || pageSize == null) {
|
||||||
|
departmentIPage = PageDTO.of(0, -1);
|
||||||
|
} else {
|
||||||
|
departmentIPage = PageDTO.of(currentPage, pageSize);
|
||||||
|
}
|
||||||
|
searchInput = searchInput.trim();
|
||||||
|
return departmentMapper.getAllDepartment(departmentIPage, searchType, searchInput);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,32 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.cfive.pinnacle.mapper.DepartmentMapper">
|
<mapper namespace="com.cfive.pinnacle.mapper.DepartmentMapper">
|
||||||
|
|
||||||
|
<select id="getAllDepartment" resultType="department">
|
||||||
|
select id, name, tel, address, deleted, version
|
||||||
|
from t_department where deleted = 0
|
||||||
|
<if test="searchInput != null and searchInput != ''">
|
||||||
|
<choose>
|
||||||
|
<when test="searchType == 0">
|
||||||
|
and (
|
||||||
|
instr(name, #{searchInput}) > 0
|
||||||
|
or instr(tel, #{searchInput}) > 0
|
||||||
|
or instr(address, #{searchInput}) > 0
|
||||||
|
)
|
||||||
|
</when>
|
||||||
|
<when test="searchType == 1">
|
||||||
|
and instr(name, #{searchInput}) > 0
|
||||||
|
</when>
|
||||||
|
<when test="searchType == 2">
|
||||||
|
and instr(tel, #{searchInput}) > 0
|
||||||
|
</when>
|
||||||
|
<when test="searchType == 3">
|
||||||
|
and instr(address, #{searchInput}) > 0
|
||||||
|
</when>
|
||||||
|
</choose>
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="getDepartAndUser" resultMap="department">
|
<select id="getDepartAndUser" resultMap="department">
|
||||||
select d.id did,name,u.id uid,username from t_department d,t_user u where d.id=u.department_id and d.deleted=0 and u.deleted=0
|
select d.id did,name,u.id uid,username from t_department d,t_user u where d.id=u.department_id and d.deleted=0 and u.deleted=0
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
@@ -83,9 +83,10 @@ create table `t_department`
|
|||||||
`id` bigint not null primary key,
|
`id` bigint not null primary key,
|
||||||
`name` varchar(50) not null comment '部门名',
|
`name` varchar(50) not null comment '部门名',
|
||||||
`tel` varchar(20) null comment '部门电话',
|
`tel` varchar(20) null comment '部门电话',
|
||||||
`address` varchar(20) null comment '部门地址',
|
`address` varchar(100) null comment '部门地址',
|
||||||
`deleted` bigint not null default 0,
|
`deleted` bigint not null default 0,
|
||||||
`version` int not null default 0
|
`version` int not null default 0,
|
||||||
|
constraint t_user_unique unique (name, deleted)
|
||||||
) comment '部门';
|
) comment '部门';
|
||||||
|
|
||||||
create table `t_user`
|
create table `t_user`
|
||||||
|
|||||||
324
ui/src/pages/info/DepartmentManagement.vue
Normal file
324
ui/src/pages/info/DepartmentManagement.vue
Normal file
@@ -0,0 +1,324 @@
|
|||||||
|
<template>
|
||||||
|
<el-row gutter="15">
|
||||||
|
<el-col :span="-1">
|
||||||
|
<el-button
|
||||||
|
bg
|
||||||
|
style="background-color: white"
|
||||||
|
:loading="tableLoading"
|
||||||
|
@click="loadDepartmentTable"
|
||||||
|
>
|
||||||
|
<template #icon>
|
||||||
|
<el-icon>
|
||||||
|
<icon-pinnacle-refresh />
|
||||||
|
</el-icon>
|
||||||
|
</template>
|
||||||
|
</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="-1">
|
||||||
|
<el-button type="primary" @click="handleAddBtn">
|
||||||
|
<template #icon>
|
||||||
|
<el-icon>
|
||||||
|
<icon-pinnacle-plus />
|
||||||
|
</el-icon>
|
||||||
|
</template>
|
||||||
|
</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="16">
|
||||||
|
<el-input
|
||||||
|
v-model="inputInput"
|
||||||
|
class="fill-with"
|
||||||
|
placeholder="请输入内容"
|
||||||
|
clearable
|
||||||
|
@keyup.enter="handleQuery"
|
||||||
|
>
|
||||||
|
<template #prepend>
|
||||||
|
<el-select v-model="selectedType" style="width: 100px">
|
||||||
|
<el-option label="综合搜索" :value="0" />
|
||||||
|
<el-option label="名称" :value="1" />
|
||||||
|
<el-option label="电话" :value="2" />
|
||||||
|
<el-option label="地址" :value="3" />
|
||||||
|
</el-select>
|
||||||
|
</template>
|
||||||
|
</el-input>
|
||||||
|
</el-col>
|
||||||
|
<el-col span="-1">
|
||||||
|
<el-button type="primary" @click="handleQuery">查询</el-button>
|
||||||
|
<el-button @click="handleClear">清空</el-button>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-table
|
||||||
|
:data="departmentTable"
|
||||||
|
v-loading="tableLoading"
|
||||||
|
element-loading-text="Loading..."
|
||||||
|
style="margin-top: 10px"
|
||||||
|
>
|
||||||
|
<el-table-column prop="name" label="名称" width="160" align="center" />
|
||||||
|
<el-table-column prop="tel" label="电话" align="center" width="160" />
|
||||||
|
<el-table-column prop="address" label="地址" />
|
||||||
|
<el-table-column label="操作" width="160" align="center">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-button size="small" @click="handleEdit(scope.row)">编辑</el-button>
|
||||||
|
<el-button type="danger" size="small" @click="handleDelete(scope.row)"
|
||||||
|
>删除</el-button
|
||||||
|
>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<div class="pagination">
|
||||||
|
<el-pagination
|
||||||
|
v-model:current-page="currentPage"
|
||||||
|
v-model:page-size="pageSize"
|
||||||
|
:page-sizes="[50, 100, 200, 500, 1000]"
|
||||||
|
layout="total, sizes, prev, pager, next, jumper"
|
||||||
|
:total="totalCount"
|
||||||
|
@size-change="handleSizeChange"
|
||||||
|
@current-change="handleCurrentChange"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<el-dialog
|
||||||
|
:title="dialogTitle"
|
||||||
|
:close-on-click-modal="false"
|
||||||
|
draggable
|
||||||
|
v-model="dialogVisible"
|
||||||
|
@open="handleDialogOpen"
|
||||||
|
>
|
||||||
|
<template #default>
|
||||||
|
<el-form
|
||||||
|
label-width="60px"
|
||||||
|
:rules="rules"
|
||||||
|
ref="formRef"
|
||||||
|
:model="departmentForm"
|
||||||
|
v-loading="dialogLoading"
|
||||||
|
>
|
||||||
|
<el-form-item label="名称" prop="inputName">
|
||||||
|
<el-input v-model="departmentForm.inputName" maxlength="50" show-word-limit />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="电话" prop="inputTel">
|
||||||
|
<el-input v-model="departmentForm.inputTel" maxlength="20" show-word-limit />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="地址" prop="inputAddress">
|
||||||
|
<el-input
|
||||||
|
v-model="departmentForm.inputAddress"
|
||||||
|
type="textarea"
|
||||||
|
resize="none"
|
||||||
|
maxlength="100"
|
||||||
|
show-word-limit
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</template>
|
||||||
|
<template #footer>
|
||||||
|
<el-button type="primary" @click="handleSubmit" :disabled="dialogLoading"
|
||||||
|
>提交
|
||||||
|
</el-button>
|
||||||
|
<el-button @click="handleCancel" :disabled="dialogLoading">取消</el-button>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
import _ from 'lodash'
|
||||||
|
import request from '@/services'
|
||||||
|
import {
|
||||||
|
DATABASE_DELETE_OK,
|
||||||
|
DATABASE_SAVE_OK,
|
||||||
|
DATABASE_SELECT_OK,
|
||||||
|
DATABASE_UPDATE_OK
|
||||||
|
} from '@/constants/Common.constants'
|
||||||
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'DepartmentManagement',
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
dialogTitle: '',
|
||||||
|
dialogVisible: false,
|
||||||
|
tableLoading: true,
|
||||||
|
dialogLoading: false,
|
||||||
|
searchType: 0,
|
||||||
|
selectedType: 0,
|
||||||
|
searchInput: '',
|
||||||
|
inputInput: '',
|
||||||
|
currentPage: 1,
|
||||||
|
pageSize: 50,
|
||||||
|
totalCount: 0,
|
||||||
|
departmentTable: [],
|
||||||
|
editDepartmentId: '',
|
||||||
|
rules: {
|
||||||
|
inputName: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '名称为必填项'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
departmentForm: {
|
||||||
|
inputName: '',
|
||||||
|
inputTel: '',
|
||||||
|
inputAddress: ''
|
||||||
|
},
|
||||||
|
isAddNew: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
loadDepartmentTable() {
|
||||||
|
this.tableLoading = true
|
||||||
|
request
|
||||||
|
.get('/department', {
|
||||||
|
currentPage: this.currentPage,
|
||||||
|
pageSize: this.pageSize,
|
||||||
|
searchType: this.searchType,
|
||||||
|
searchInput: this.searchInput
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
const response = res.data
|
||||||
|
if (response.code === DATABASE_SELECT_OK) {
|
||||||
|
this.departmentTable = response.data.records
|
||||||
|
this.totalCount = response.data.total
|
||||||
|
this.tableLoading = false
|
||||||
|
} else {
|
||||||
|
ElMessage.error({
|
||||||
|
dangerouslyUseHTMLString: true,
|
||||||
|
message: '<strong>查询出错</strong>: ' + response.msg
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
handleEdit(row) {
|
||||||
|
this.editDepartmentId = row.id
|
||||||
|
this.departmentForm.inputName = row.name
|
||||||
|
this.departmentForm.inputTel = row.tel
|
||||||
|
this.departmentForm.inputAddress = row.address
|
||||||
|
this.isAddNew = false
|
||||||
|
this.dialogVisible = true
|
||||||
|
},
|
||||||
|
handleAddBtn() {
|
||||||
|
this.isAddNew = true
|
||||||
|
this.dialogVisible = true
|
||||||
|
},
|
||||||
|
handleDialogOpen() {
|
||||||
|
if (this.isAddNew) {
|
||||||
|
this.departmentForm.inputName = ''
|
||||||
|
this.departmentForm.inputTel = ''
|
||||||
|
this.departmentForm.inputAddress = ''
|
||||||
|
this.dialogTitle = '添加部门'
|
||||||
|
} else {
|
||||||
|
this.dialogTitle = '编辑部门'
|
||||||
|
}
|
||||||
|
this.dialogLoading = false
|
||||||
|
},
|
||||||
|
async handleSubmit() {
|
||||||
|
await this.$refs.formRef.validate((valid) => {
|
||||||
|
if (valid) {
|
||||||
|
this.dialogLoading = true
|
||||||
|
const departmentObject = {
|
||||||
|
id: '',
|
||||||
|
name: this.departmentForm.inputName,
|
||||||
|
tel: this.departmentForm.inputTel,
|
||||||
|
address: this.departmentForm.inputAddress
|
||||||
|
}
|
||||||
|
if (this.isAddNew) {
|
||||||
|
request.post('/department', departmentObject).then((res) => {
|
||||||
|
const response = res.data
|
||||||
|
if (response.code === DATABASE_SAVE_OK) {
|
||||||
|
ElMessage.success({
|
||||||
|
dangerouslyUseHTMLString: true,
|
||||||
|
message: '<strong>添加成功</strong>'
|
||||||
|
})
|
||||||
|
this.dialogVisible = false
|
||||||
|
this.loadDepartmentTable()
|
||||||
|
} else {
|
||||||
|
ElMessage.error({
|
||||||
|
dangerouslyUseHTMLString: true,
|
||||||
|
message: '<strong>添加失败</strong>: ' + response.msg
|
||||||
|
})
|
||||||
|
this.dialogLoading = false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
departmentObject.id = this.editDepartmentId
|
||||||
|
request.put('/department', departmentObject).then((res) => {
|
||||||
|
const response = res.data
|
||||||
|
if (response.code === DATABASE_UPDATE_OK) {
|
||||||
|
ElMessage.success({
|
||||||
|
dangerouslyUseHTMLString: true,
|
||||||
|
message: '<strong>修改成功</strong>'
|
||||||
|
})
|
||||||
|
this.dialogVisible = false
|
||||||
|
this.loadDepartmentTable()
|
||||||
|
} else {
|
||||||
|
ElMessage.error({
|
||||||
|
dangerouslyUseHTMLString: true,
|
||||||
|
message: '<strong>修改失败</strong>: ' + response.msg
|
||||||
|
})
|
||||||
|
this.dialogLoading = false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
handleDelete(row) {
|
||||||
|
ElMessageBox.confirm('确定删除该部门吗?', '删除').then(() => {
|
||||||
|
this.tableLoading = true
|
||||||
|
request
|
||||||
|
.delete('/department/' + row.id)
|
||||||
|
.then((res) => {
|
||||||
|
const response = res.data
|
||||||
|
if (response.code === DATABASE_DELETE_OK) {
|
||||||
|
ElMessage.success({
|
||||||
|
dangerouslyUseHTMLString: true,
|
||||||
|
message: '<strong>删除成功</strong>'
|
||||||
|
})
|
||||||
|
this.loadDepartmentTable()
|
||||||
|
} else {
|
||||||
|
ElMessage.error({
|
||||||
|
dangerouslyUseHTMLString: true,
|
||||||
|
message: '<strong>删除失败</strong>: ' + response.msg
|
||||||
|
})
|
||||||
|
this.tableLoading = false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
this.tableLoading = false
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
handleCancel() {
|
||||||
|
this.dialogVisible = false
|
||||||
|
},
|
||||||
|
handleSizeChange(pageSize) {
|
||||||
|
this.pageSize = pageSize
|
||||||
|
this.loadDepartmentTable()
|
||||||
|
},
|
||||||
|
handleCurrentChange(currentPage) {
|
||||||
|
this.currentPage = currentPage
|
||||||
|
this.loadDepartmentTable()
|
||||||
|
},
|
||||||
|
handleQuery() {
|
||||||
|
this.searchType = _.cloneDeep(this.selectedType)
|
||||||
|
this.searchInput = _.cloneDeep(this.inputInput)
|
||||||
|
this.currentPage = 1
|
||||||
|
this.loadDepartmentTable()
|
||||||
|
},
|
||||||
|
handleClear() {
|
||||||
|
this.selectedType = 0
|
||||||
|
this.inputInput = ''
|
||||||
|
this.handleQuery()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.loadDepartmentTable()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.pagination {
|
||||||
|
display: flex;
|
||||||
|
margin-top: 10px;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -185,7 +185,7 @@ export default {
|
|||||||
inputFirstName: [
|
inputFirstName: [
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
message: '名称为必填项'
|
message: '名字为必填项'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
inputLastName: [
|
inputLastName: [
|
||||||
|
|||||||
@@ -13,6 +13,17 @@ const infoRouter = {
|
|||||||
requiresScrollbar: true,
|
requiresScrollbar: true,
|
||||||
requiresPadding: true
|
requiresPadding: true
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'department',
|
||||||
|
name: 'departmentManagement',
|
||||||
|
component: async () => await import('@/pages/info/DepartmentManagement.vue'),
|
||||||
|
meta: {
|
||||||
|
title: '部门信息管理',
|
||||||
|
requiresMenu: true,
|
||||||
|
requiresScrollbar: true,
|
||||||
|
requiresPadding: true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
meta: {
|
meta: {
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ export const useNoticeStore = defineStore('notice', {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
async selectDepartment() {
|
async selectDepartment() {
|
||||||
await request.get('/department').then((response) => {
|
await request.get('/department/user').then((response) => {
|
||||||
this.departmentList = response.data.data
|
this.departmentList = response.data.data
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user