parent
df5cacfb0e
commit
2844ce89ba
@ -0,0 +1,112 @@
|
||||
package com.da.common.core.domain.entity;
|
||||
|
||||
import com.da.common.annotation.Excel;
|
||||
import com.da.common.core.domain.BaseEntity;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 档案柜对象 da_cabinet
|
||||
*
|
||||
* @author hs
|
||||
* @date 2024-06-20
|
||||
*/
|
||||
public class DaCabinet extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** id */
|
||||
private Long id;
|
||||
|
||||
/** 位置名称 */
|
||||
@Excel(name = "位置名称")
|
||||
private String posName;
|
||||
|
||||
/** 父目录ID */
|
||||
@Excel(name = "父目录ID")
|
||||
private Long pid;
|
||||
|
||||
/** 祖级列表 */
|
||||
@Excel(name = "祖级列表")
|
||||
private String ancestors;
|
||||
|
||||
/** 内容 */
|
||||
@Excel(name = "内容")
|
||||
private String content;
|
||||
|
||||
/** 子目录 */
|
||||
private List<DaCabinet> children = new ArrayList<DaCabinet>();
|
||||
|
||||
public List<DaCabinet> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<DaCabinet> children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
public void setPosName(String posName)
|
||||
{
|
||||
this.posName = posName;
|
||||
}
|
||||
|
||||
public String getPosName()
|
||||
{
|
||||
return posName;
|
||||
}
|
||||
public void setPid(Long pid)
|
||||
{
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
public Long getPid()
|
||||
{
|
||||
return pid;
|
||||
}
|
||||
public void setAncestors(String ancestors)
|
||||
{
|
||||
this.ancestors = ancestors;
|
||||
}
|
||||
|
||||
public String getAncestors()
|
||||
{
|
||||
return ancestors;
|
||||
}
|
||||
public void setContent(String content)
|
||||
{
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getContent()
|
||||
{
|
||||
return content;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("posName", getPosName())
|
||||
.append("pid", getPid())
|
||||
.append("ancestors", getAncestors())
|
||||
.append("content", getContent())
|
||||
.append("remark", getRemark())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,108 @@
|
||||
package com.da.dangan.controller;
|
||||
|
||||
import com.da.common.annotation.Log;
|
||||
import com.da.common.core.controller.BaseController;
|
||||
import com.da.common.core.domain.AjaxResult;
|
||||
import com.da.common.core.domain.entity.DaCabinet;
|
||||
import com.da.common.core.page.TableDataInfo;
|
||||
import com.da.common.enums.BusinessType;
|
||||
import com.da.common.utils.poi.ExcelUtil;
|
||||
import com.da.dangan.service.IDaCabinetService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 档案柜Controller
|
||||
*
|
||||
* @author hs
|
||||
* @date 2024-06-20
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/dangan/cabinet")
|
||||
public class DaCabinetController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IDaCabinetService daCabinetService;
|
||||
|
||||
/**
|
||||
* 查询档案柜列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('dangan:cabinet:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(DaCabinet daCabinet)
|
||||
{
|
||||
startPage();
|
||||
List<DaCabinet> list = daCabinetService.selectDaCabinetList(daCabinet);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取目录下拉树列表
|
||||
*/
|
||||
@GetMapping("/treeselect")
|
||||
public AjaxResult treeselect(DaCabinet daCabinet)
|
||||
{
|
||||
List<DaCabinet> list = daCabinetService.selectDaCabinetList(daCabinet);
|
||||
return success(daCabinetService.buildCatalogTreeSelect(list));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出档案柜列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('dangan:cabinet:export')")
|
||||
@Log(title = "档案柜", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, DaCabinet daCabinet)
|
||||
{
|
||||
List<DaCabinet> list = daCabinetService.selectDaCabinetList(daCabinet);
|
||||
ExcelUtil<DaCabinet> util = new ExcelUtil<DaCabinet>(DaCabinet.class);
|
||||
util.exportExcel(response, list, "档案柜数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取档案柜详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('dangan:cabinet:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return success(daCabinetService.selectDaCabinetById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增档案柜
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('dangan:cabinet:add')")
|
||||
@Log(title = "档案柜", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody DaCabinet daCabinet)
|
||||
{
|
||||
return toAjax(daCabinetService.insertDaCabinet(daCabinet));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改档案柜
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('dangan:cabinet:edit')")
|
||||
@Log(title = "档案柜", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody DaCabinet daCabinet)
|
||||
{
|
||||
return toAjax(daCabinetService.updateDaCabinet(daCabinet));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除档案柜
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('dangan:cabinet:remove')")
|
||||
@Log(title = "档案柜", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(daCabinetService.deleteDaCabinetByIds(ids));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,63 @@
|
||||
package com.da.dangan.mapper;
|
||||
|
||||
import com.da.common.core.domain.entity.DaCabinet;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 档案柜Mapper接口
|
||||
*
|
||||
* @author hs
|
||||
* @date 2024-06-20
|
||||
*/
|
||||
public interface DaCabinetMapper
|
||||
{
|
||||
/**
|
||||
* 查询档案柜
|
||||
*
|
||||
* @param id 档案柜主键
|
||||
* @return 档案柜
|
||||
*/
|
||||
public DaCabinet selectDaCabinetById(Long id);
|
||||
|
||||
/**
|
||||
* 查询档案柜列表
|
||||
*
|
||||
* @param daCabinet 档案柜
|
||||
* @return 档案柜集合
|
||||
*/
|
||||
public List<DaCabinet> selectDaCabinetList(DaCabinet daCabinet);
|
||||
|
||||
/**
|
||||
* 新增档案柜
|
||||
*
|
||||
* @param daCabinet 档案柜
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertDaCabinet(DaCabinet daCabinet);
|
||||
|
||||
/**
|
||||
* 修改档案柜
|
||||
*
|
||||
* @param daCabinet 档案柜
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateDaCabinet(DaCabinet daCabinet);
|
||||
|
||||
/**
|
||||
* 删除档案柜
|
||||
*
|
||||
* @param id 档案柜主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDaCabinetById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除档案柜
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDaCabinetByIds(Long[] ids);
|
||||
}
|
||||
@ -0,0 +1,76 @@
|
||||
package com.da.dangan.service;
|
||||
|
||||
import com.da.common.core.domain.TreeSelect;
|
||||
import com.da.common.core.domain.entity.DaCabinet;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 档案柜Service接口
|
||||
*
|
||||
* @author hs
|
||||
* @date 2024-06-20
|
||||
*/
|
||||
public interface IDaCabinetService
|
||||
{
|
||||
/**
|
||||
* 查询档案柜
|
||||
*
|
||||
* @param id 档案柜主键
|
||||
* @return 档案柜
|
||||
*/
|
||||
public DaCabinet selectDaCabinetById(Long id);
|
||||
|
||||
/**
|
||||
* 查询档案柜列表
|
||||
*
|
||||
* @param daCabinet 档案柜
|
||||
* @return 档案柜集合
|
||||
*/
|
||||
public List<DaCabinet> selectDaCabinetList(DaCabinet daCabinet);
|
||||
|
||||
/**
|
||||
* 新增档案柜
|
||||
*
|
||||
* @param daCabinet 档案柜
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertDaCabinet(DaCabinet daCabinet);
|
||||
|
||||
/**
|
||||
* 修改档案柜
|
||||
*
|
||||
* @param daCabinet 档案柜
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateDaCabinet(DaCabinet daCabinet);
|
||||
|
||||
/**
|
||||
* 批量删除档案柜
|
||||
*
|
||||
* @param ids 需要删除的档案柜主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDaCabinetByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除档案柜信息
|
||||
*
|
||||
* @param id 档案柜主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDaCabinetById(Long id);
|
||||
/**
|
||||
* 构建前端所需要树结构
|
||||
* @param list 列表
|
||||
* @return 树结构列表
|
||||
*/
|
||||
List<TreeSelect> buildCatalogTreeSelect(List<DaCabinet> list);
|
||||
/**
|
||||
* 构建前端所需要树结构
|
||||
*
|
||||
* @param cabinets 位置名称列表
|
||||
* @return 树结构列表
|
||||
*/
|
||||
public List<DaCabinet> buildCatalogTree(List<DaCabinet> cabinets);
|
||||
}
|
||||
@ -0,0 +1,186 @@
|
||||
package com.da.dangan.service.impl;
|
||||
|
||||
import com.da.common.core.domain.TreeSelect;
|
||||
import com.da.common.core.domain.entity.DaCabinet;
|
||||
import com.da.common.utils.DateUtils;
|
||||
import com.da.dangan.mapper.DaCabinetMapper;
|
||||
import com.da.dangan.service.IDaCabinetService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 档案柜Service业务层处理
|
||||
*
|
||||
* @author hs
|
||||
* @date 2024-06-20
|
||||
*/
|
||||
@Service
|
||||
public class DaCabinetServiceImpl implements IDaCabinetService
|
||||
{
|
||||
@Autowired
|
||||
private DaCabinetMapper daCabinetMapper;
|
||||
|
||||
/**
|
||||
* 查询档案柜
|
||||
*
|
||||
* @param id 档案柜主键
|
||||
* @return 档案柜
|
||||
*/
|
||||
@Override
|
||||
public DaCabinet selectDaCabinetById(Long id)
|
||||
{
|
||||
return daCabinetMapper.selectDaCabinetById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询档案柜列表
|
||||
*
|
||||
* @param daCabinet 档案柜
|
||||
* @return 档案柜
|
||||
*/
|
||||
@Override
|
||||
public List<DaCabinet> selectDaCabinetList(DaCabinet daCabinet)
|
||||
{
|
||||
return daCabinetMapper.selectDaCabinetList(daCabinet);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增档案柜
|
||||
*
|
||||
* @param daCabinet 档案柜
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertDaCabinet(DaCabinet daCabinet)
|
||||
{
|
||||
daCabinet.setCreateTime(DateUtils.getNowDate());
|
||||
if(daCabinet.getPid()==0){ //代表添加的是主目录
|
||||
daCabinet.setAncestors(daCabinet.getPid().toString());
|
||||
}else{
|
||||
DaCabinet info = daCabinetMapper.selectDaCabinetById(daCabinet.getPid());
|
||||
daCabinet.setAncestors(info.getAncestors() + "," + daCabinet.getPid());
|
||||
}
|
||||
return daCabinetMapper.insertDaCabinet(daCabinet);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改档案柜
|
||||
*
|
||||
* @param daCabinet 档案柜
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateDaCabinet(DaCabinet daCabinet)
|
||||
{
|
||||
daCabinet.setUpdateTime(DateUtils.getNowDate());
|
||||
return daCabinetMapper.updateDaCabinet(daCabinet);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除档案柜
|
||||
*
|
||||
* @param ids 需要删除的档案柜主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteDaCabinetByIds(Long[] ids)
|
||||
{
|
||||
return daCabinetMapper.deleteDaCabinetByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除档案柜信息
|
||||
*
|
||||
* @param id 档案柜主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteDaCabinetById(Long id)
|
||||
{
|
||||
return daCabinetMapper.deleteDaCabinetById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TreeSelect> buildCatalogTreeSelect(List<DaCabinet> daCabinets) {
|
||||
List<DaCabinet> daCabinetTrees = buildCatalogTree(daCabinets);
|
||||
return daCabinetTrees.stream().map(TreeSelect::new).collect(Collectors.toList());
|
||||
}
|
||||
/**
|
||||
* 构建前端所需要树结构
|
||||
*
|
||||
* @param cabinets 位置名称列表
|
||||
* @return 树结构列表
|
||||
*/
|
||||
@Override
|
||||
public List<DaCabinet> buildCatalogTree(List<DaCabinet> cabinets)
|
||||
{
|
||||
List<DaCabinet> returnList = new ArrayList<>();
|
||||
List<Long> tempList = cabinets.stream().map(DaCabinet::getId).collect(Collectors.toList());
|
||||
for (Iterator<DaCabinet> iterator = cabinets.iterator(); iterator.hasNext();)
|
||||
{
|
||||
DaCabinet catalog = iterator.next();
|
||||
// 如果是顶级节点, 遍历该父节点的所有子节点
|
||||
if (!tempList.contains(catalog.getPid()))
|
||||
{
|
||||
recursionFn(cabinets, catalog);
|
||||
returnList.add(catalog);
|
||||
}
|
||||
}
|
||||
if (returnList.isEmpty())
|
||||
{
|
||||
returnList = cabinets;
|
||||
}
|
||||
return returnList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归列表
|
||||
*
|
||||
* @param list 分类表
|
||||
* @param t 子节点
|
||||
*/
|
||||
private void recursionFn(List<DaCabinet> list, DaCabinet t)
|
||||
{
|
||||
// 得到子节点列表
|
||||
List<DaCabinet> childList = getChildList(list, t);
|
||||
t.setChildren(childList);
|
||||
for (DaCabinet tChild : childList)
|
||||
{
|
||||
if (hasChild(list, tChild))
|
||||
{
|
||||
recursionFn(list, tChild);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到子节点列表
|
||||
*/
|
||||
private List<DaCabinet> getChildList(List<DaCabinet> list, DaCabinet t)
|
||||
{
|
||||
List<DaCabinet> tlist = new ArrayList<DaCabinet>();
|
||||
Iterator<DaCabinet> it = list.iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
DaCabinet n = (DaCabinet) it.next();
|
||||
if (n.getPid().longValue() == t.getId().longValue())
|
||||
{
|
||||
tlist.add(n);
|
||||
}
|
||||
}
|
||||
return tlist;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否有子节点
|
||||
*/
|
||||
private boolean hasChild(List<DaCabinet> list, DaCabinet t)
|
||||
{
|
||||
return getChildList(list, t).size() > 0;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,91 @@
|
||||
<?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">
|
||||
<mapper namespace="com.da.dangan.mapper.DaCabinetMapper">
|
||||
|
||||
<resultMap type="DaCabinet" id="DaCabinetResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="posName" column="pos_name" />
|
||||
<result property="pid" column="pid" />
|
||||
<result property="ancestors" column="ancestors" />
|
||||
<result property="content" column="content" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectDaCabinetVo">
|
||||
select id, pos_name, pid, ancestors, content, remark, create_by, create_time, update_by, update_time from da_cabinet
|
||||
</sql>
|
||||
|
||||
<select id="selectDaCabinetList" parameterType="DaCabinet" resultMap="DaCabinetResult">
|
||||
<include refid="selectDaCabinetVo"/>
|
||||
<where>
|
||||
<if test="posName != null and posName != ''"> and pos_name like concat('%', #{posName}, '%')</if>
|
||||
<if test="pid != null "> and pid = #{pid}</if>
|
||||
<if test="ancestors != null and ancestors != ''"> and ancestors = #{ancestors}</if>
|
||||
<if test="content != null and content != ''"> and content = #{content}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectDaCabinetById" parameterType="Long" resultMap="DaCabinetResult">
|
||||
<include refid="selectDaCabinetVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertDaCabinet" parameterType="DaCabinet" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into da_cabinet
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="posName != null and posName != ''">pos_name,</if>
|
||||
<if test="pid != null">pid,</if>
|
||||
<if test="ancestors != null">ancestors,</if>
|
||||
<if test="content != null">content,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="posName != null and posName != ''">#{posName},</if>
|
||||
<if test="pid != null">#{pid},</if>
|
||||
<if test="ancestors != null">#{ancestors},</if>
|
||||
<if test="content != null">#{content},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateDaCabinet" parameterType="DaCabinet">
|
||||
update da_cabinet
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="posName != null and posName != ''">pos_name = #{posName},</if>
|
||||
<if test="pid != null">pid = #{pid},</if>
|
||||
<if test="ancestors != null">ancestors = #{ancestors},</if>
|
||||
<if test="content != null">content = #{content},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteDaCabinetById" parameterType="Long">
|
||||
delete from da_cabinet where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteDaCabinetByIds" parameterType="String">
|
||||
delete from da_cabinet where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
@ -0,0 +1,44 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 查询档案柜列表
|
||||
export function listCabinet(query) {
|
||||
return request({
|
||||
url: '/dangan/cabinet/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询档案柜详细
|
||||
export function getCabinet(id) {
|
||||
return request({
|
||||
url: '/dangan/cabinet/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增档案柜
|
||||
export function addCabinet(data) {
|
||||
return request({
|
||||
url: '/dangan/cabinet',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改档案柜
|
||||
export function updateCabinet(data) {
|
||||
return request({
|
||||
url: '/dangan/cabinet',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除档案柜
|
||||
export function delCabinet(id) {
|
||||
return request({
|
||||
url: '/dangan/cabinet/' + id,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
@ -0,0 +1,288 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="位置名称" prop="posName">
|
||||
<el-input
|
||||
v-model="queryParams.posName"
|
||||
placeholder="请输入位置名称"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="父目录ID" prop="pid">
|
||||
<el-input
|
||||
v-model="queryParams.pid"
|
||||
placeholder="请输入父目录ID"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="祖级列表" prop="ancestors">
|
||||
<el-input
|
||||
v-model="queryParams.ancestors"
|
||||
placeholder="请输入祖级列表"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="el-icon-plus"
|
||||
size="mini"
|
||||
@click="handleAdd"
|
||||
v-hasPermi="['dangan:cabinet:add']"
|
||||
>新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
icon="el-icon-edit"
|
||||
size="mini"
|
||||
:disabled="single"
|
||||
@click="handleUpdate"
|
||||
v-hasPermi="['dangan:cabinet:edit']"
|
||||
>修改</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
icon="el-icon-delete"
|
||||
size="mini"
|
||||
:disabled="multiple"
|
||||
@click="handleDelete"
|
||||
v-hasPermi="['dangan:cabinet:remove']"
|
||||
>删除</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
plain
|
||||
icon="el-icon-download"
|
||||
size="mini"
|
||||
@click="handleExport"
|
||||
v-hasPermi="['dangan:cabinet:export']"
|
||||
>导出</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="cabinetList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="id" align="center" prop="id" />
|
||||
<el-table-column label="位置名称" align="center" prop="posName" />
|
||||
<el-table-column label="父目录ID" align="center" prop="pid" />
|
||||
<el-table-column label="祖级列表" align="center" prop="ancestors" />
|
||||
<el-table-column label="内容" align="center" prop="content" />
|
||||
<el-table-column label="备注" align="center" prop="remark" />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-edit"
|
||||
@click="handleUpdate(scope.row)"
|
||||
v-hasPermi="['dangan:cabinet:edit']"
|
||||
>修改</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['dangan:cabinet:remove']"
|
||||
>删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total>0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
<!-- 添加或修改档案柜对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="位置名称" prop="posName">
|
||||
<el-input v-model="form.posName" placeholder="请输入位置名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="父目录ID" prop="pid">
|
||||
<el-input v-model="form.pid" placeholder="请输入父目录ID" />
|
||||
</el-form-item>
|
||||
<el-form-item label="内容">
|
||||
<editor v-model="form.content" :min-height="192"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listCabinet, getCabinet, delCabinet, addCabinet, updateCabinet } from "@/api/dangan/cabinet";
|
||||
|
||||
export default {
|
||||
name: "Cabinet",
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 档案柜表格数据
|
||||
cabinetList: [],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
posName: null,
|
||||
pid: null,
|
||||
ancestors: null,
|
||||
content: null,
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
posName: [
|
||||
{ required: true, message: "位置名称不能为空", trigger: "blur" }
|
||||
],
|
||||
}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
/** 查询档案柜列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listCabinet(this.queryParams).then(response => {
|
||||
this.cabinetList = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
id: null,
|
||||
posName: null,
|
||||
pid: null,
|
||||
ancestors: null,
|
||||
content: null,
|
||||
remark: null,
|
||||
createBy: null,
|
||||
createTime: null,
|
||||
updateBy: null,
|
||||
updateTime: null
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.id)
|
||||
this.single = selection.length!==1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.reset();
|
||||
this.open = true;
|
||||
this.title = "添加档案柜";
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.reset();
|
||||
const id = row.id || this.ids
|
||||
getCabinet(id).then(response => {
|
||||
this.form = response.data;
|
||||
this.open = true;
|
||||
this.title = "修改档案柜";
|
||||
});
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
if (this.form.id != null) {
|
||||
updateCabinet(this.form).then(response => {
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
} else {
|
||||
addCabinet(this.form).then(response => {
|
||||
this.$modal.msgSuccess("新增成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const ids = row.id || this.ids;
|
||||
this.$modal.confirm('是否确认删除档案柜编号为"' + ids + '"的数据项?').then(function() {
|
||||
return delCabinet(ids);
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
}).catch(() => {});
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
this.download('dangan/cabinet/export', {
|
||||
...this.queryParams
|
||||
}, `cabinet_${new Date().getTime()}.xlsx`)
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
Loading…
Reference in new issue