添加物理书架,修改新增、删除接口

master
hansha 2 years ago
parent 304aab5499
commit 1de730aa33

@ -0,0 +1,110 @@
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.page.TableDataInfo;
import com.da.common.enums.BusinessType;
import com.da.common.utils.poi.ExcelUtil;
import com.da.dangan.domain.DaBookshelf;
import com.da.dangan.service.IDaBookshelfService;
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-05-11
*/
@RestController
@RequestMapping("/dangan/bookshelf")
public class DaBookshelfController extends BaseController
{
@Autowired
private IDaBookshelfService daBookshelfService;
/**
*
*/
@PreAuthorize("@ss.hasPermi('dangan:bookshelf:list')")
@GetMapping("/list")
public TableDataInfo list(DaBookshelf daBookshelf)
{
startPage();
List<DaBookshelf> list = daBookshelfService.selectDaBookshelfList(daBookshelf);
return getDataTable(list);
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('dangan:bookshelf:export')")
@Log(title = "物理书架", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DaBookshelf daBookshelf)
{
List<DaBookshelf> list = daBookshelfService.selectDaBookshelfList(daBookshelf);
ExcelUtil<DaBookshelf> util = new ExcelUtil<DaBookshelf>(DaBookshelf.class);
util.exportExcel(response, list, "物理书架数据");
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('dangan:bookshelf:query')")
@GetMapping(value = "/{shelfId}")
public AjaxResult getInfo(@PathVariable("shelfId") Long shelfId)
{
return success(daBookshelfService.selectDaBookshelfByShelfId(shelfId));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('dangan:bookshelf:add')")
@Log(title = "物理书架", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DaBookshelf daBookshelf)
{
daBookshelf.setCreateBy(getUsername());
return toAjax(daBookshelfService.insertDaBookshelf(daBookshelf));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('dangan:bookshelf:edit')")
@Log(title = "物理书架", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DaBookshelf daBookshelf)
{
return toAjax(daBookshelfService.updateDaBookshelf(daBookshelf));
}
/**
*
*/
/* @PreAuthorize("@ss.hasPermi('dangan:bookshelf:remove')")
@Log(title = "物理书架", businessType = BusinessType.DELETE)
@DeleteMapping("/{shelfIds}")
public AjaxResult remove(@PathVariable Long[] shelfIds)
{
return toAjax(daBookshelfService.deleteDaBookshelfByShelfIds(shelfIds));
}*/
/**
*
*/
@PreAuthorize("@ss.hasPermi('dangan:bookshelf:remove')")
@Log(title = "物理书架", businessType = BusinessType.DELETE)
@DeleteMapping("/{shelfId}")
public AjaxResult remove(@PathVariable Long shelfId)
{
return daBookshelfService.deleteDaBookshelfByShelfId(shelfId);
}
}

@ -44,17 +44,19 @@ public class DaCatalogController extends BaseController
@GetMapping("/treeselect")
public AjaxResult treeselect(DaCatalog daCatalog)
{
List<DaCatalog> daCatalogs = daCatalogService.selectAllDaCatalogList(daCatalog, getUserId());
List<DaCatalog> daCatalogs = daCatalogService.selectDaCatalogList(daCatalog);
return success(daCatalogService.buildCatalogTreeSelect(daCatalogs));
}
/**
*
*
*/
@GetMapping(value = "/userMenuTreeselect/{userId}")
public AjaxResult roleMenuTreeselect(@PathVariable("userId") Long userId)
{
List<DaCatalog> catalogs = daCatalogService.selectCatalogList(getUserId());
{ /*
List<DaCatalog> catalogs = daCatalogService.selectCatalogList(getUserId());*/
//查询全部目录列表
List<DaCatalog> catalogs = daCatalogService.selectDaCatalogList(new DaCatalog());
AjaxResult ajax = AjaxResult.success();
ajax.put("checkedKeys", daCatalogService.selectCatalogListByUserId(userId));
ajax.put("catalogs", daCatalogService.buildCatalogTreeSelect(catalogs));
@ -115,10 +117,21 @@ public class DaCatalogController extends BaseController
*
*/
@PreAuthorize("@ss.hasPermi('dangan:catalog:remove')")
@Log(title = "档案目录", businessType = BusinessType.DELETE)
@DeleteMapping("/{id}")
public AjaxResult remove(@PathVariable Long id)
{
return daCatalogService.deleteDaCatalogById(id);
}
/**
*
*/
/*@PreAuthorize("@ss.hasPermi('dangan:catalog:remove')")
@Log(title = "档案目录", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(daCatalogService.deleteDaCatalogByIds(ids));
}
}*/
}

@ -0,0 +1,98 @@
package com.da.dangan.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.da.common.annotation.Excel;
import com.da.common.core.domain.BaseEntity;
/**
* da_bookshelf
*
* @author hs
* @date 2024-05-11
*/
public class DaBookshelf extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 书架id */
private Long shelfId;
/** 名称 */
@Excel(name = "名称")
private String name;
/** 父目录ID */
@Excel(name = "父目录ID")
private Long pid;
/** 祖级列表 */
@Excel(name = "祖级列表")
private String ancestors;
/** 显示顺序 */
@Excel(name = "显示顺序")
private Long orderNum;
public void setShelfId(Long shelfId)
{
this.shelfId = shelfId;
}
public Long getShelfId()
{
return shelfId;
}
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
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 setOrderNum(Long orderNum)
{
this.orderNum = orderNum;
}
public Long getOrderNum()
{
return orderNum;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("shelfId", getShelfId())
.append("name", getName())
.append("pid", getPid())
.append("ancestors", getAncestors())
.append("orderNum", getOrderNum())
.append("remark", getRemark())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
}
}

@ -0,0 +1,62 @@
package com.da.dangan.mapper;
import com.da.dangan.domain.DaBookshelf;
import java.util.List;
/**
* Mapper
*
* @author hs
* @date 2024-05-11
*/
public interface DaBookshelfMapper
{
/**
*
*
* @param shelfId
* @return
*/
public DaBookshelf selectDaBookshelfByShelfId(Long shelfId);
/**
*
*
* @param daBookshelf
* @return
*/
public List<DaBookshelf> selectDaBookshelfList(DaBookshelf daBookshelf);
/**
*
*
* @param daBookshelf
* @return
*/
public int insertDaBookshelf(DaBookshelf daBookshelf);
/**
*
*
* @param daBookshelf
* @return
*/
public int updateDaBookshelf(DaBookshelf daBookshelf);
/**
*
*
* @param shelfId
* @return
*/
public int deleteDaBookshelfByShelfId(Long shelfId);
/**
*
*
* @param shelfIds
* @return
*/
public int deleteDaBookshelfByShelfIds(Long[] shelfIds);
}

@ -0,0 +1,63 @@
package com.da.dangan.service;
import com.da.common.core.domain.AjaxResult;
import com.da.dangan.domain.DaBookshelf;
import java.util.List;
/**
* Service
*
* @author hs
* @date 2024-05-11
*/
public interface IDaBookshelfService
{
/**
*
*
* @param shelfId
* @return
*/
public DaBookshelf selectDaBookshelfByShelfId(Long shelfId);
/**
*
*
* @param daBookshelf
* @return
*/
public List<DaBookshelf> selectDaBookshelfList(DaBookshelf daBookshelf);
/**
*
*
* @param daBookshelf
* @return
*/
public int insertDaBookshelf(DaBookshelf daBookshelf);
/**
*
*
* @param daBookshelf
* @return
*/
public int updateDaBookshelf(DaBookshelf daBookshelf);
/**
*
*
* @param shelfIds
* @return
*/
public int deleteDaBookshelfByShelfIds(Long[] shelfIds);
/**
*
*
* @param shelfId
* @return
*/
public AjaxResult deleteDaBookshelfByShelfId(Long shelfId);
}

@ -1,5 +1,6 @@
package com.da.dangan.service;
import com.da.common.core.domain.AjaxResult;
import com.da.common.core.domain.TreeSelect;
import com.da.common.core.domain.entity.DaCatalog;
@ -67,14 +68,13 @@ public interface IDaCatalogService
* @param id
* @return
*/
public int deleteDaCatalogById(Long id);
public AjaxResult deleteDaCatalogById(Long id);
boolean checkDaCatalogNameUnique(DaCatalog daCatalog);
List<DaCatalog> selectCatalogList(Long userId);
/**
*
*
* @param daCatalogs
* @return
*/

@ -0,0 +1,117 @@
package com.da.dangan.service.impl;
import com.da.common.core.domain.AjaxResult;
import com.da.common.core.domain.entity.DaCatalog;
import com.da.common.utils.DateUtils;
import com.da.dangan.domain.DaBookshelf;
import com.da.dangan.mapper.DaBookshelfMapper;
import com.da.dangan.service.IDaBookshelfService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* Service
*
* @author hs
* @date 2024-05-11
*/
@Service
public class DaBookshelfServiceImpl implements IDaBookshelfService
{
@Autowired
private DaBookshelfMapper daBookshelfMapper;
/**
*
*
* @param shelfId
* @return
*/
@Override
public DaBookshelf selectDaBookshelfByShelfId(Long shelfId)
{
return daBookshelfMapper.selectDaBookshelfByShelfId(shelfId);
}
/**
*
*
* @param daBookshelf
* @return
*/
@Override
public List<DaBookshelf> selectDaBookshelfList(DaBookshelf daBookshelf)
{
return daBookshelfMapper.selectDaBookshelfList(daBookshelf);
}
/**
*
*
* @param daBookshelf
* @return
*/
@Override
public int insertDaBookshelf(DaBookshelf daBookshelf)
{
daBookshelf.setCreateTime(DateUtils.getNowDate());
daBookshelf.setCreateTime(DateUtils.getNowDate());
if(daBookshelf.getPid()==0){ //代表添加的是主目录
daBookshelf.setAncestors(daBookshelf.getPid().toString());
}else{
DaBookshelf info = daBookshelfMapper.selectDaBookshelfByShelfId(daBookshelf.getPid());
daBookshelf.setAncestors(info.getAncestors() + "," + daBookshelf.getPid());
}
return daBookshelfMapper.insertDaBookshelf(daBookshelf);
}
/**
*
*
* @param daBookshelf
* @return
*/
@Override
public int updateDaBookshelf(DaBookshelf daBookshelf)
{
daBookshelf.setUpdateTime(DateUtils.getNowDate());
return daBookshelfMapper.updateDaBookshelf(daBookshelf);
}
/**
*
*
* @param shelfIds
* @return
*/
@Override
public int deleteDaBookshelfByShelfIds(Long[] shelfIds)
{
return daBookshelfMapper.deleteDaBookshelfByShelfIds(shelfIds);
}
/**
*
*
* @param shelfId
* @return
*/
@Override
public AjaxResult deleteDaBookshelfByShelfId(Long shelfId)
{
DaBookshelf daBookshelf = new DaBookshelf();
daBookshelf.setPid(shelfId);
//有子级目录的不能删除
List<DaBookshelf> daBookshelfs = daBookshelfMapper.selectDaBookshelfList(daBookshelf);
if(daBookshelfs!=null&&daBookshelfs.size()>0){
return AjaxResult.error("有子级目录,不能删除");
}
int i= daBookshelfMapper.deleteDaBookshelfByShelfId(shelfId);
if(i>0){
return AjaxResult.success();
}
return AjaxResult.error();
}
}

@ -1,12 +1,13 @@
package com.da.dangan.service.impl;
import com.da.common.constant.UserConstants;
import com.da.common.core.domain.AjaxResult;
import com.da.common.core.domain.TreeSelect;
import com.da.common.core.domain.entity.DaCatalog;
import com.da.common.core.domain.entity.SysUser;
import com.da.common.exception.ServiceException;
import com.da.common.utils.DateUtils;
import com.da.common.utils.StringUtils;
import com.da.common.core.domain.entity.DaCatalog;
import com.da.dangan.mapper.DaCatalogMapper;
import com.da.dangan.service.IDaCatalogService;
import org.springframework.stereotype.Service;
@ -101,13 +102,13 @@ public class DaCatalogServiceImpl implements IDaCatalogService
public List<DaCatalog> selectAllDaCatalogList(DaCatalog daCatalog, Long userId)
{
List<DaCatalog> catalogList = null;
// 管理员显示所有菜单信息
// 管理员显示所有目录信息
if (SysUser.isAdmin(userId))
{
catalogList = daCatalogMapper.selectDaCatalogList(daCatalog);
}
else
{
{ //根据用户权限显示目录信息
daCatalog.getParams().put("userId", userId);
catalogList = daCatalogMapper.selectDaCatalogListByUserId(daCatalog);
}
@ -150,6 +151,29 @@ public class DaCatalogServiceImpl implements IDaCatalogService
return daCatalogMapper.updateDaCatalog(daCatalog);
}
/**
*
*
* @param id
* @return
*/
@Override
public AjaxResult deleteDaCatalogById(Long id)
{
DaCatalog catalog = new DaCatalog();
catalog.setPid(id);
//有子级目录的不能删除
List<DaCatalog> daCatalogs = daCatalogMapper.selectDaCatalogList(catalog);
if(daCatalogs!=null&&daCatalogs.size()>0){
return AjaxResult.error("有子级目录,不能删除");
}
int i= daCatalogMapper.deleteDaCatalogById(id);
if(i>0){
return AjaxResult.success();
}
return AjaxResult.error();
}
/**
*
*
@ -173,17 +197,6 @@ public class DaCatalogServiceImpl implements IDaCatalogService
return UserConstants.UNIQUE;
}
/**
*
*
* @param id
* @return
*/
@Override
public int deleteDaCatalogById(Long id)
{
return daCatalogMapper.deleteDaCatalogById(id);
}
/**
*
*

@ -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.DaBookshelfMapper">
<resultMap type="DaBookshelf" id="DaBookshelfResult">
<result property="shelfId" column="shelf_id" />
<result property="name" column="name" />
<result property="pid" column="pid" />
<result property="ancestors" column="ancestors" />
<result property="orderNum" column="order_num" />
<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="selectDaBookshelfVo">
select shelf_id, name, pid, ancestors, order_num, remark, create_by, create_time, update_by, update_time from da_bookshelf
</sql>
<select id="selectDaBookshelfList" parameterType="DaBookshelf" resultMap="DaBookshelfResult">
<include refid="selectDaBookshelfVo"/>
<where>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="pid != null "> and pid = #{pid}</if>
<if test="ancestors != null and ancestors != ''"> and ancestors = #{ancestors}</if>
<if test="orderNum != null "> and order_num = #{orderNum}</if>
</where>
</select>
<select id="selectDaBookshelfByShelfId" parameterType="Long" resultMap="DaBookshelfResult">
<include refid="selectDaBookshelfVo"/>
where shelf_id = #{shelfId}
</select>
<insert id="insertDaBookshelf" parameterType="DaBookshelf" useGeneratedKeys="true" keyProperty="shelfId">
insert into da_bookshelf
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null and name != ''">name,</if>
<if test="pid != null">pid,</if>
<if test="ancestors != null">ancestors,</if>
<if test="orderNum != null">order_num,</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="name != null and name != ''">#{name},</if>
<if test="pid != null">#{pid},</if>
<if test="ancestors != null">#{ancestors},</if>
<if test="orderNum != null">#{orderNum},</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="updateDaBookshelf" parameterType="DaBookshelf">
update da_bookshelf
<trim prefix="SET" suffixOverrides=",">
<if test="name != null and name != ''">name = #{name},</if>
<if test="pid != null">pid = #{pid},</if>
<if test="ancestors != null">ancestors = #{ancestors},</if>
<if test="orderNum != null">order_num = #{orderNum},</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 shelf_id = #{shelfId}
</update>
<delete id="deleteDaBookshelfByShelfId" parameterType="Long">
delete from da_bookshelf where shelf_id = #{shelfId}
</delete>
<delete id="deleteDaBookshelfByShelfIds" parameterType="String">
delete from da_bookshelf where shelf_id in
<foreach item="shelfId" collection="array" open="(" separator="," close=")">
#{shelfId}
</foreach>
</delete>
</mapper>

@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询物理书架列表
export function listBookshelf(query) {
return request({
url: '/dangan/bookshelf/list',
method: 'get',
params: query
})
}
// 查询物理书架详细
export function getBookshelf(shelfId) {
return request({
url: '/dangan/bookshelf/' + shelfId,
method: 'get'
})
}
// 新增物理书架
export function addBookshelf(data) {
return request({
url: '/dangan/bookshelf',
method: 'post',
data: data
})
}
// 修改物理书架
export function updateBookshelf(data) {
return request({
url: '/dangan/bookshelf',
method: 'put',
data: data
})
}
// 删除物理书架
export function delBookshelf(shelfId) {
return request({
url: '/dangan/bookshelf/' + shelfId,
method: 'delete'
})
}

@ -0,0 +1,296 @@
<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="name">
<el-input
v-model="queryParams.name"
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 label="显示顺序" prop="orderNum">
<el-input
v-model="queryParams.orderNum"
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:bookshelf: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:bookshelf: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:bookshelf: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:bookshelf:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="bookshelfList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="书架id" align="center" prop="shelfId" />
<el-table-column label="名称" align="center" prop="name" />
<el-table-column label="父目录ID" align="center" prop="pid" />
<el-table-column label="祖级列表" align="center" prop="ancestors" />
<el-table-column label="显示顺序" align="center" prop="orderNum" />
<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:bookshelf:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['dangan:bookshelf: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="name">
<el-input v-model="form.name" 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="显示顺序" prop="orderNum">
<el-input v-model="form.orderNum" placeholder="请输入显示顺序" />
</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 { listBookshelf, getBookshelf, delBookshelf, addBookshelf, updateBookshelf } from "@/api/dangan/bookshelf";
export default {
name: "Bookshelf",
data() {
return {
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
bookshelfList: [],
//
title: "",
//
open: false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
name: null,
pid: null,
ancestors: null,
orderNum: null,
},
//
form: {},
//
rules: {
name: [
{ required: true, message: "名称不能为空", trigger: "blur" }
],
}
};
},
created() {
this.getList();
},
methods: {
/** 查询物理书架列表 */
getList() {
this.loading = true;
listBookshelf(this.queryParams).then(response => {
this.bookshelfList = response.rows;
this.total = response.total;
this.loading = false;
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
shelfId: null,
name: null,
pid: null,
ancestors: null,
orderNum: 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.shelfId)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加物理书架";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const shelfId = row.shelfId || this.ids
getBookshelf(shelfId).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改物理书架";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.shelfId != null) {
updateBookshelf(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addBookshelf(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const shelfIds = row.shelfId || this.ids;
this.$modal.confirm('是否确认删除物理书架编号为"' + shelfIds + '"的数据项?').then(function() {
return delBookshelf(shelfIds);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('dangan/bookshelf/export', {
...this.queryParams
}, `bookshelf_${new Date().getTime()}.xlsx`)
}
}
};
</script>
Loading…
Cancel
Save