基地校优化

This commit is contained in:
paidaxing444
2020-09-04 11:57:14 +08:00
parent d0c0116e6f
commit a295566e3d
7 changed files with 390 additions and 329 deletions

View File

@ -2,6 +2,11 @@ package com.ruoyi.web.controller.jxjs;
import java.util.List;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.jxjs.domain.TsbzJxjsjbxx;
import com.ruoyi.jxjs.service.ITsbzJxjsjbxxService;
import com.ruoyi.system.service.ISysDeptService;
import com.ruoyi.web.controller.common.SchoolCommonController;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
@ -30,20 +35,22 @@ import com.ruoyi.common.core.page.TableDataInfo;
*/
@RestController
@RequestMapping("/jxjs/jdx")
public class TsbzJdxController extends BaseController
{
public class TsbzJdxController extends BaseController {
@Autowired
private ITsbzJdxService tsbzJdxService;
@Autowired
private SchoolCommonController schoolCommonController;
@Autowired
private ITsbzJxjsjbxxService tsbzJxjsjbxxService;
@Autowired
private ISysDeptService deptService;
/**
* 查询基地校列表
*/
@PreAuthorize("@ss.hasPermi('jxjs:jdx:list')")
@GetMapping("/list")
public TableDataInfo list(TsbzJdx tsbzJdx)
{
public TableDataInfo list(TsbzJdx tsbzJdx) {
startPage();
List<TsbzJdx> list = tsbzJdxService.selectTsbzJdxList(tsbzJdx);
return getDataTable(list);
@ -55,8 +62,7 @@ public class TsbzJdxController extends BaseController
@PreAuthorize("@ss.hasPermi('jxjs:jdx:export')")
@Log(title = "基地校", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(TsbzJdx tsbzJdx)
{
public AjaxResult export(TsbzJdx tsbzJdx) {
List<TsbzJdx> list = tsbzJdxService.selectTsbzJdxList(tsbzJdx);
ExcelUtil<TsbzJdx> util = new ExcelUtil<TsbzJdx>(TsbzJdx.class);
return util.exportExcel(list, "jdx");
@ -67,8 +73,7 @@ public class TsbzJdxController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('jxjs:jdx:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") String id)
{
public AjaxResult getInfo(@PathVariable("id") String id) {
return AjaxResult.success(tsbzJdxService.selectTsbzJdxById(id));
}
@ -78,9 +83,18 @@ public class TsbzJdxController extends BaseController
@PreAuthorize("@ss.hasPermi('jxjs:jdx:add')")
@Log(title = "基地校", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody TsbzJdx tsbzJdx)
{
tsbzJdx.setId(schoolCommonController.getUuid());
public AjaxResult add(@RequestBody TsbzJdx tsbzJdx) {
String uuid = schoolCommonController.getUuid();
tsbzJdx.setId(uuid);
//将当前记录插入的dept表
SysDept dept = new SysDept();
dept.setSchoolid(uuid);
dept.setDeptName(tsbzJdx.getJdxmc());
dept.setCreateBy(SecurityUtils.getLoginUser().getUser().getUserName());
dept.setParentId(200L);
dept.setAncestors("0,100,200");
dept.setOrderNum(String.valueOf(tsbzJdxService.selectTsbzJdxList(null).size()));
deptService.insertDept(dept);
return toAjax(tsbzJdxService.insertTsbzJdx(tsbzJdx));
}
@ -90,8 +104,15 @@ public class TsbzJdxController extends BaseController
@PreAuthorize("@ss.hasPermi('jxjs:jdx:edit')")
@Log(title = "基地校", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody TsbzJdx tsbzJdx)
{
public AjaxResult edit(@RequestBody TsbzJdx tsbzJdx) {
//创建dept实例 并且向要添加的dept中设置各个参数
SysDept dept = new SysDept();
//设置schoolID为xxdm
dept.setSchoolid(tsbzJdx.getId());
dept = deptService.selectDeptList(dept).get(0);
dept.setDeptName(tsbzJdx.getJdxmc());
dept.setUpdateBy(SecurityUtils.getLoginUser().getUser().getUserName());
deptService.updateDept(dept);
return toAjax(tsbzJdxService.updateTsbzJdx(tsbzJdx));
}
@ -101,8 +122,17 @@ public class TsbzJdxController extends BaseController
@PreAuthorize("@ss.hasPermi('jxjs:jdx:remove')")
@Log(title = "基地校", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable String[] ids)
{
public AjaxResult remove(@PathVariable String[] ids) {
TsbzJxjsjbxx tsbzJxjsjbxx = null;
//判断当前基地校是否已分配学生
for (int i = 0; i < ids.length; i++) {
tsbzJxjsjbxx = new TsbzJxjsjbxx();
tsbzJxjsjbxx.setJdxid(ids[i]);
List<TsbzJxjsjbxx> list = tsbzJxjsjbxxService.selectTsbzJxjsjbxxList(tsbzJxjsjbxx);
if (list != null && list.size() > 0) {
return AjaxResult.error("当前基地校已分配见习教师,无法删除");
}
}
return toAjax(tsbzJdxService.deleteTsbzJdxByIds(ids));
}
}

View File

@ -5,6 +5,7 @@ import java.util.List;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.domain.BaseEntity;
@ -14,175 +15,187 @@ import com.ruoyi.common.core.domain.BaseEntity;
*
* @author ruoyi
*/
public class SysDept extends BaseEntity
{
public class SysDept extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 部门ID */
/**
* 部门ID
*/
private Long deptId;
/** 父部门ID */
/**
* 父部门ID
*/
private Long parentId;
/** 祖级列表 */
/**
* 祖级列表
*/
private String ancestors;
/** 部门名称 */
/**
* 部门名称
*/
private String deptName;
/** 显示顺序 */
/**
* 显示顺序
*/
private String orderNum;
/** 负责人 */
/**
* 负责人
*/
private String leader;
/** 联系电话 */
/**
* 联系电话
*/
private String phone;
/** 邮箱 */
/**
* 邮箱
*/
private String email;
/** 部门状态:0正常,1停用 */
/**
* 部门状态:0正常,1停用
*/
private String status;
/** 删除标志0代表存在 2代表删除 */
/**
* 删除标志0代表存在 2代表删除
*/
private String delFlag;
/** 父部门名称 */
/**
* 父部门名称
*/
private String parentName;
/** 子部门 */
/**
* 学校id
*/
private String schoolid;
/**
* 子部门
*/
private List<SysDept> children = new ArrayList<SysDept>();
public Long getDeptId()
{
public Long getDeptId() {
return deptId;
}
public void setDeptId(Long deptId)
{
public void setDeptId(Long deptId) {
this.deptId = deptId;
}
public Long getParentId()
{
public Long getParentId() {
return parentId;
}
public void setParentId(Long parentId)
{
public void setParentId(Long parentId) {
this.parentId = parentId;
}
public String getAncestors()
{
public String getAncestors() {
return ancestors;
}
public void setAncestors(String ancestors)
{
public void setAncestors(String ancestors) {
this.ancestors = ancestors;
}
@NotBlank(message = "部门名称不能为空")
@Size(min = 0, max = 30, message = "部门名称长度不能超过30个字符")
public String getDeptName()
{
public String getDeptName() {
return deptName;
}
public void setDeptName(String deptName)
{
public void setDeptName(String deptName) {
this.deptName = deptName;
}
@NotBlank(message = "显示顺序不能为空")
public String getOrderNum()
{
public String getOrderNum() {
return orderNum;
}
public void setOrderNum(String orderNum)
{
public void setOrderNum(String orderNum) {
this.orderNum = orderNum;
}
public String getLeader()
{
public String getLeader() {
return leader;
}
public void setLeader(String leader)
{
public void setLeader(String leader) {
this.leader = leader;
}
@Size(min = 0, max = 11, message = "联系电话长度不能超过11个字符")
public String getPhone()
{
public String getPhone() {
return phone;
}
public void setPhone(String phone)
{
public void setPhone(String phone) {
this.phone = phone;
}
@Email(message = "邮箱格式不正确")
@Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
public String getEmail()
{
public String getEmail() {
return email;
}
public void setEmail(String email)
{
public void setEmail(String email) {
this.email = email;
}
public String getStatus()
{
public String getStatus() {
return status;
}
public void setStatus(String status)
{
public void setStatus(String status) {
this.status = status;
}
public String getDelFlag()
{
public String getDelFlag() {
return delFlag;
}
public void setDelFlag(String delFlag)
{
public void setDelFlag(String delFlag) {
this.delFlag = delFlag;
}
public String getParentName()
{
public String getParentName() {
return parentName;
}
public void setParentName(String parentName)
{
public void setParentName(String parentName) {
this.parentName = parentName;
}
public List<SysDept> getChildren()
{
public List<SysDept> getChildren() {
return children;
}
public void setChildren(List<SysDept> children)
{
public void setChildren(List<SysDept> children) {
this.children = children;
}
public void setSchoolid(String schoolid) {
this.schoolid = schoolid;
}
public String getSchoolid() {
return schoolid;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("deptId", getDeptId())
.append("parentId", getParentId())
.append("ancestors", getAncestors())
@ -197,6 +210,7 @@ public class SysDept extends BaseEntity
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("schoolid", getSchoolid())
.toString();
}
}

View File

@ -1,29 +1,30 @@
<?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">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.SysDeptMapper">
<resultMap type="SysDept" id="SysDeptResult">
<id property="deptId" column="dept_id" />
<result property="parentId" column="parent_id" />
<result property="ancestors" column="ancestors" />
<result property="deptName" column="dept_name" />
<result property="orderNum" column="order_num" />
<result property="leader" column="leader" />
<result property="phone" column="phone" />
<result property="email" column="email" />
<result property="status" column="status" />
<result property="delFlag" column="del_flag" />
<result property="parentName" column="parent_name" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<id property="deptId" column="dept_id"/>
<result property="parentId" column="parent_id"/>
<result property="ancestors" column="ancestors"/>
<result property="deptName" column="dept_name"/>
<result property="orderNum" column="order_num"/>
<result property="leader" column="leader"/>
<result property="phone" column="phone"/>
<result property="email" column="email"/>
<result property="status" column="status"/>
<result property="delFlag" column="del_flag"/>
<result property="parentName" column="parent_name"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="schoolid" column="schoolid"/>
</resultMap>
<sql id="selectDeptVo">
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time , schoolid
from sys_dept d
</sql>
@ -92,6 +93,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="email != null and email != ''">email,</if>
<if test="status != null">status,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="schoolid != null">schoolid,</if>
create_time
)values(
<if test="deptId != null and deptId != 0">#{deptId},</if>
@ -104,6 +106,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="email != null and email != ''">#{email},</if>
<if test="status != null">#{status},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="schoolid != null">#{schoolid},</if>
sysdate()
)
</insert>
@ -120,6 +123,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="email != null">email = #{email},</if>
<if test="status != null and status != ''">status = #{status},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="schoolid != null">schoolid = #{schoolid},</if>
update_time = sysdate()
</set>
where dept_id = #{deptId}

View File

@ -425,7 +425,7 @@ export default {
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$confirm('是否确认删除基地校编号为"' + ids + '"的数据项?', "警告", {
this.$confirm('是否确认删除基地校数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",

View File

@ -1,6 +1,12 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form
:model="queryParams"
ref="queryForm"
:inline="true"
v-show="showSearch"
label-width="68px"
>
<el-form-item label="姓名" prop="name">
<el-input
v-model="queryParams.name"
@ -136,7 +142,7 @@
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item> -->
</el-form-item>-->
<el-form-item>
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
@ -172,22 +178,13 @@
@click="handleDelete"
v-hasPermi="['jxjs:jxjsjbxx:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['jxjs:jxjsjbxx:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="jxjsjbxxList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="编号" align="center" prop="id" />
<!-- <el-table-column label="编号" align="center" prop="id" /> -->
<el-table-column label="姓名" align="center" prop="name" />
<el-table-column label="性别" align="center" prop="xb" :formatter="xbFormat" />
<el-table-column label="政治面貌" align="center" prop="zzmm" :formatter="zzmmFormat" />
@ -256,18 +253,21 @@
</el-select>
</el-form-item>
<el-form-item label="出生日期" prop="csrq">
<el-date-picker clearable size="small" style="width: 200px"
<el-date-picker
clearable
size="small"
style="width: 200px"
v-model="form.csrq"
type="date"
value-format="yyyy-MM-dd"
placeholder="选择出生日期">
</el-date-picker>
placeholder="选择出生日期"
></el-date-picker>
</el-form-item>
<el-form-item label="电子邮件" prop="email">
<el-input v-model="form.email" placeholder="请输入电子邮件" />
</el-form-item>
<el-form-item label="联系电话" prop="phone">
<el-input v-model="form.phone" placeholder="请输入联系电话" maxlength="11"/>
<el-input v-model="form.phone" placeholder="请输入联系电话" maxlength="11" />
</el-form-item>
<el-form-item label="邮编" prop="yzbm">
<el-input v-model="form.yzbm" placeholder="请输入邮编" />
@ -384,7 +384,13 @@
</template>
<script>
import { listJxjsjbxx, getJxjsjbxx, delJxjsjbxx, addJxjsjbxx, updateJxjsjbxx, exportJxjsjbxx } from "@/api/jxjs/jxjsjbxx";
import {
listJxjsjbxx,
getJxjsjbxx,
delJxjsjbxx,
addJxjsjbxx,
updateJxjsjbxx,
} from "@/api/jxjs/jxjsjbxx";
export default {
name: "Jxjsjbxx",
@ -464,49 +470,44 @@ export default {
jxbh: [
{ required: true, message: "进修编号不能为空", trigger: "blur" },
],
xb: [
{ required: true, message: "教师性别不能为空", trigger: "blur" },
],
xb: [{ required: true, message: "教师性别不能为空", trigger: "blur" }],
csrq: [
{ required: true, message: "出生日期不能为空", trigger: "blur" },
],
phone: [
{ required: true, message: "电话不能为空", trigger: "blur" },
],
}
phone: [{ required: true, message: "电话不能为空", trigger: "blur" }],
},
};
},
created() {
this.getList();
this.getDicts("sys_user_sex").then(response => {
this.getDicts("sys_user_sex").then((response) => {
this.xbOptions = response.data;
});
this.getDicts("sys_dm_zzmm").then(response => {
this.getDicts("sys_dm_zzmm").then((response) => {
this.zzmmOptions = response.data;
});
this.getDicts("sys_dm_mz").then(response => {
this.getDicts("sys_dm_mz").then((response) => {
this.mzOptions = response.data;
});
this.getDicts("sys_dm_rjxd").then(response => {
this.getDicts("sys_dm_rjxd").then((response) => {
this.rjxdOptions = response.data;
});
this.getDicts("sys_dm_rjxk").then(response => {
this.getDicts("sys_dm_rjxk").then((response) => {
this.rjxkOptions = response.data;
});
this.getDicts("sys_dm_rjnj").then(response => {
this.getDicts("sys_dm_rjnj").then((response) => {
this.rjnjOptions = response.data;
});
this.getDicts("sys_dm_xl").then(response => {
this.getDicts("sys_dm_xl").then((response) => {
this.xlOptions = response.data;
});
this.getDicts("sys_dm_xw").then(response => {
this.getDicts("sys_dm_xw").then((response) => {
this.xwOptions = response.data;
});
this.getDicts("sys_dm_sfsfs").then(response => {
this.getDicts("sys_dm_sfsfs").then((response) => {
this.sfsfsOptions = response.data;
});
this.getDicts("sys_dm_rxnf").then(response => {
this.getDicts("sys_dm_rxnf").then((response) => {
this.lqnfOptions = response.data;
});
},
@ -514,7 +515,7 @@ export default {
/** 查询见习教师基本信息列表 */
getList() {
this.loading = true;
listJxjsjbxx(this.queryParams).then(response => {
listJxjsjbxx(this.queryParams).then((response) => {
this.jxjsjbxxList = response.rows;
this.total = response.total;
this.loading = false;
@ -590,7 +591,7 @@ export default {
xw: null,
sfsfs: null,
lqnf: null,
createTime: null
createTime: null,
};
this.resetForm("form");
},
@ -606,9 +607,9 @@ export default {
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.multiple = !selection.length
this.ids = selection.map((item) => item.id);
this.single = selection.length !== 1;
this.multiple = !selection.length;
},
/** 新增按钮操作 */
handleAdd() {
@ -619,8 +620,8 @@ export default {
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getJxjsjbxx(id).then(response => {
const id = row.id || this.ids;
getJxjsjbxx(id).then((response) => {
this.form = response.data;
this.open = true;
this.title = "修改见习教师基本信息";
@ -628,10 +629,10 @@ export default {
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
this.$refs["form"].validate((valid) => {
if (valid) {
if (this.form.id != null) {
updateJxjsjbxx(this.form).then(response => {
updateJxjsjbxx(this.form).then((response) => {
if (response.code === 200) {
this.msgSuccess("修改成功");
this.open = false;
@ -639,7 +640,7 @@ export default {
}
});
} else {
addJxjsjbxx(this.form).then(response => {
addJxjsjbxx(this.form).then((response) => {
if (response.code === 200) {
this.msgSuccess("新增成功");
this.open = false;
@ -653,30 +654,24 @@ export default {
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$confirm('是否确认删除见习教师基本信息编号为"' + ids + '"的数据项?', "警告", {
this.$confirm(
'是否确认删除见习教师基本信息数据项?',
"警告",
{
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
type: "warning",
}
)
.then(function () {
return delJxjsjbxx(ids);
}).then(() => {
})
.then(() => {
this.getList();
this.msgSuccess("删除成功");
}).catch(function() {});
})
.catch(function () {});
},
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$confirm('是否确认导出所有见习教师基本信息数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return exportJxjsjbxx(queryParams);
}).then(response => {
this.download(response.msg);
}).catch(function() {});
}
}
};
</script>

View File

@ -293,11 +293,8 @@ export default {
endtime: [
{ required: true, message: "考核结束时间不能为空", trigger: "blur" },
],
filename: [
{ required: true, message: "考核文件名称不能为空", trigger: "blur" },
],
filepath: [
{ required: true, message: "文件路径不能为空", trigger: "blur" },
{ required: true, message: "文件不能为空", trigger: "blur" },
],
khnf: [
{ required: true, message: "考核年份不能为空", trigger: "blur" },

View File

@ -57,6 +57,7 @@
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
v-if="!(scope.row.parentId==200)"
size="mini"
type="text"
icon="el-icon-edit"
@ -64,6 +65,7 @@
v-hasPermi="['system:dept:edit']"
>修改</el-button>
<el-button
v-if="!(scope.row.parentId==200)"
size="mini"
type="text"
icon="el-icon-plus"
@ -71,7 +73,7 @@
v-hasPermi="['system:dept:add']"
>新增</el-button>
<el-button
v-if="scope.row.parentId != 0"
v-if="!(scope.row.parentId == 0)&&!(scope.row.parentId==200)"
size="mini"
type="text"
icon="el-icon-delete"
@ -88,7 +90,12 @@
<el-row>
<el-col :span="24" v-if="form.parentId !== 0">
<el-form-item label="上级部门" prop="parentId">
<treeselect v-model="form.parentId" :options="deptOptions" :normalizer="normalizer" placeholder="选择上级部门" />
<treeselect
v-model="form.parentId"
:options="deptOptions"
:normalizer="normalizer"
placeholder="选择上级部门"
/>
</el-form-item>
</el-col>
<el-col :span="12">
@ -138,7 +145,14 @@
</template>
<script>
import { listDept, getDept, delDept, addDept, updateDept, listDeptExcludeChild } from "@/api/system/dept";
import {
listDept,
getDept,
delDept,
addDept,
updateDept,
listDeptExcludeChild,
} from "@/api/system/dept";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
@ -164,41 +178,41 @@ export default {
// 查询参数
queryParams: {
deptName: undefined,
status: undefined
status: undefined,
},
// 表单参数
form: {},
// 表单校验
rules: {
parentId: [
{ required: true, message: "上级部门不能为空", trigger: "blur" }
{ required: true, message: "上级部门不能为空", trigger: "blur" },
],
deptName: [
{ required: true, message: "部门名称不能为空", trigger: "blur" }
{ required: true, message: "部门名称不能为空", trigger: "blur" },
],
orderNum: [
{ required: true, message: "菜单顺序不能为空", trigger: "blur" }
{ required: true, message: "菜单顺序不能为空", trigger: "blur" },
],
email: [
{
type: "email",
message: "'请输入正确的邮箱地址",
trigger: ["blur", "change"]
}
trigger: ["blur", "change"],
},
],
phone: [
{
pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
message: "请输入正确的手机号码",
trigger: "blur"
}
]
}
trigger: "blur",
},
],
},
};
},
created() {
this.getList();
this.getDicts("sys_normal_disable").then(response => {
this.getDicts("sys_normal_disable").then((response) => {
this.statusOptions = response.data;
});
},
@ -206,7 +220,7 @@ export default {
/** 查询部门列表 */
getList() {
this.loading = true;
listDept(this.queryParams).then(response => {
listDept(this.queryParams).then((response) => {
this.deptList = this.handleTree(response.data, "deptId");
this.loading = false;
});
@ -219,7 +233,7 @@ export default {
return {
id: node.deptId,
label: node.deptName,
children: node.children
children: node.children,
};
},
// 字典状态字典翻译
@ -241,7 +255,7 @@ export default {
leader: undefined,
phone: undefined,
email: undefined,
status: "0"
status: "0",
};
this.resetForm("form");
},
@ -262,28 +276,28 @@ export default {
}
this.open = true;
this.title = "添加部门";
listDept().then(response => {
listDept().then((response) => {
this.deptOptions = this.handleTree(response.data, "deptId");
});
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
getDept(row.deptId).then(response => {
getDept(row.deptId).then((response) => {
this.form = response.data;
this.open = true;
this.title = "修改部门";
});
listDeptExcludeChild(row.deptId).then(response => {
listDeptExcludeChild(row.deptId).then((response) => {
this.deptOptions = this.handleTree(response.data, "deptId");
});
},
/** 提交按钮 */
submitForm: function() {
this.$refs["form"].validate(valid => {
submitForm: function () {
this.$refs["form"].validate((valid) => {
if (valid) {
if (this.form.deptId != undefined) {
updateDept(this.form).then(response => {
updateDept(this.form).then((response) => {
if (response.code === 200) {
this.msgSuccess("修改成功");
this.open = false;
@ -291,7 +305,7 @@ export default {
}
});
} else {
addDept(this.form).then(response => {
addDept(this.form).then((response) => {
if (response.code === 200) {
this.msgSuccess("新增成功");
this.open = false;
@ -304,17 +318,24 @@ export default {
},
/** 删除按钮操作 */
handleDelete(row) {
this.$confirm('是否确认删除名称为"' + row.deptName + '"的数据项?', "警告", {
this.$confirm(
'是否确认删除名称为"' + row.deptName + '"的数据项?',
"警告",
{
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
type: "warning",
}
)
.then(function () {
return delDept(row.deptId);
}).then(() => {
})
.then(() => {
this.getList();
this.msgSuccess("删除成功");
}).catch(function() {});
}
}
})
.catch(function () {});
},
},
};
</script>