添加档案室密集柜,并添加前端所需树状结构

master
hansha 2 years ago
parent df5cacfb0e
commit 2844ce89ba

@ -1,5 +1,6 @@
package com.da.common.core.domain;
import com.da.common.core.domain.entity.DaCabinet;
import com.da.common.core.domain.entity.DaCatalog;
import com.da.common.core.domain.entity.SysDept;
import com.da.common.core.domain.entity.SysMenu;
@ -27,6 +28,9 @@ public class TreeSelect implements Serializable
/** 业务类型 */
private String ywType;
/** 业务类型 */
private String content;
/** 子节点 */
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<TreeSelect> children;
@ -58,6 +62,22 @@ public class TreeSelect implements Serializable
this.children = catalog.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
}
public TreeSelect(DaCabinet cabinet)
{
this.id = cabinet.getId();
this.label = cabinet.getPosName();
this.content=cabinet.getContent();
this.children = cabinet.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getYwType() {
return ywType;
}

@ -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;
}
}

@ -2,14 +2,16 @@ package com.da.dangan.util;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.http.*;
import com.da.common.utils.SecurityUtils;
import java.io.File;
import java.lang.reflect.Field;
import java.net.HttpCookie;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.da.common.utils.SecurityUtils.getLoginUser;
/**
*
*/
@ -62,7 +64,7 @@ public class CallThirdInterface {
httpRequest.form("files[]",files.toArray(new File[files.size()]));
httpRequest.form("picIds",picIds);
httpRequest.form("fileType",fileType);
httpRequest.form("username", SecurityUtils.getLoginUser().getUser().getUserName()); //添加一个参数做标识 username
httpRequest.form("username", getLoginUser().getUsername()); //添加一个参数做标识 username
//httpRequest.form("singeOrDouble",);
//httpRequest.form("picIds",ids.toArray(new Long[ids.size()]));
@ -106,34 +108,29 @@ public class CallThirdInterface {
}
System.out.println(values);
}
/*public static String callThirdInterface2(){
List<File> files = new ArrayList<>();
File file1 = new File("图片物理路径");
File file2 = new File("图片物理路径");
files.add(file1);
files.add(file2);
String fileType="option1";
String url="http://123.57.142.195:443/upload_api";
List<Long> picIds = new ArrayList<>();
picIds.add(1L);
picIds.add(5L);
HttpRequest httpRequest = new HttpRequest(url);
httpRequest.setMethod(Method.POST);
httpRequest.charset(CharsetUtil.CHARSET_UTF_8);
httpRequest.form("files[]",files.toArray(new File[files.size()]));
httpRequest.form("fileType",fileType);
httpRequest.form("picIds",picIds.toArray(new File[picIds.size()]));
HttpResponse execute = httpRequest.execute();
boolean ok = execute.isOk();
System.out.println(ok);
List<HttpCookie> cookies = execute.getCookies();
cookies.forEach(System.out::println);
String body = execute.body();
System.out.println(body);
return body;
}*/
/**
*javanull
* @param obj
* @param comparison
* @return
* @throws IllegalAccessException
*/
public static boolean allFieldsEqualTo(Object obj, String comparison) throws IllegalAccessException {
if (obj == null) {
return false;
}
Field[] fields = obj.getClass().getDeclaredFields();
for (Field field : fields) {
field.setAccessible(true); // 使私有字段也可以访问
Object fieldValue = field.get(obj);
if (fieldValue == null||field.getName().equals("serialVersionUID")) {
continue; // 忽略null字段
}
if (!fieldValue.equals(comparison)) {
return false; // 一旦发现不等于comparison的字段返回false
}
}
return true; // 所有字段都等于comparison
}
}

@ -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…
Cancel
Save