Prechádzať zdrojové kódy

新增资产借用功能模块

LinWuTai 1 rok pred
rodič
commit
b0a300e743

+ 50 - 0
ruoyi-admin/src/main/java/com/ruoyi/asset/domain/enums/ManageStatus.java

@@ -0,0 +1,50 @@
+package com.ruoyi.asset.domain.enums;
+
+/**
+ * 资产管理状态
+ */
+public enum ManageStatus {
+    NORMAL(0L, "正常"),
+    ADJUSTMENT(1L, "调整"),
+    ALLOT(2L, "调拨"),
+    BORROW(3L, "借出"),
+    SPLIT(4L, "拆分"),
+    LEAVE_UNUSED(5L, "闲置"),
+    START_USING(6L, "启用"),
+    SCRAP(7L, "报废"),
+    SALE(8L, "变卖");
+
+    /** 特定代码 */
+    private final Long code;
+
+    /** 名称 */
+    private final String name;
+
+    ManageStatus(Long code, String name) {
+        this.code = code;
+        this.name = name;
+    }
+
+    public Long getCode() {
+        return code;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * 根据特定代码返回名称
+     *
+     * @param code 特定代码
+     * @return 名称/null
+     */
+    public static String getName(Integer code) {
+        for (ManageStatus value : ManageStatus.values()) {
+            if (value.code.equals(code)) {
+                return value.getName();
+            }
+        }
+        return null;
+    }
+}

+ 118 - 0
ruoyi-admin/src/main/java/com/ruoyi/borrow/controller/TbAssetBorrowRecordController.java

@@ -0,0 +1,118 @@
+package com.ruoyi.borrow.controller;
+
+import java.util.List;
+import javax.servlet.http.HttpServletResponse;
+
+import cn.hutool.core.util.StrUtil;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.borrow.domain.TbAssetBorrowRecord;
+import com.ruoyi.borrow.service.ITbAssetBorrowRecordService;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.common.core.page.TableDataInfo;
+
+/**
+ * 资产借用Controller
+ * 
+ * @author ruoyi
+ * @date 2024-01-11
+ */
+@RestController
+@RequestMapping("/asset/borrow")
+public class TbAssetBorrowRecordController extends BaseController
+{
+    @Autowired
+    private ITbAssetBorrowRecordService tbAssetBorrowRecordService;
+
+    /**
+     * 快速归还
+     */
+    @PostMapping("/fastReturn/{assetNumber}")
+    public AjaxResult fastReturn(@PathVariable("assetNumber") String assetNumber) {
+        String errMessage = tbAssetBorrowRecordService.fastReturnByAssetNumber(assetNumber);
+        if (StrUtil.isNotBlank(errMessage)) {
+            return success(errMessage);
+        }
+        return success("归还成功");
+    }
+
+    /**
+     * 查询资产借用列表
+     */
+    @PreAuthorize("@ss.hasPermi('asset:borrow:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(TbAssetBorrowRecord tbAssetBorrowRecord)
+    {
+        startPage();
+        List<TbAssetBorrowRecord> list = tbAssetBorrowRecordService.selectTbAssetBorrowRecordList(tbAssetBorrowRecord);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出资产借用列表
+     */
+    @PreAuthorize("@ss.hasPermi('asset:borrow:export')")
+    @Log(title = "资产借用", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, TbAssetBorrowRecord tbAssetBorrowRecord)
+    {
+        List<TbAssetBorrowRecord> list = tbAssetBorrowRecordService.selectTbAssetBorrowRecordList(tbAssetBorrowRecord);
+        ExcelUtil<TbAssetBorrowRecord> util = new ExcelUtil<TbAssetBorrowRecord>(TbAssetBorrowRecord.class);
+        util.exportExcel(response, list, "资产借用数据");
+    }
+
+    /**
+     * 获取资产借用详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('asset:borrow:query')")
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") Long id)
+    {
+        return success(tbAssetBorrowRecordService.selectTbAssetBorrowRecordById(id));
+    }
+
+    /**
+     * 新增资产借用
+     */
+    @PreAuthorize("@ss.hasPermi('asset:borrow:add')")
+    @Log(title = "资产借用", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody TbAssetBorrowRecord tbAssetBorrowRecord)
+    {
+        return toAjax(tbAssetBorrowRecordService.insertTbAssetBorrowRecord(tbAssetBorrowRecord));
+    }
+
+    /**
+     * 修改资产借用
+     */
+    @PreAuthorize("@ss.hasPermi('asset:borrow:edit')")
+    @Log(title = "资产借用", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody TbAssetBorrowRecord tbAssetBorrowRecord)
+    {
+        return toAjax(tbAssetBorrowRecordService.updateTbAssetBorrowRecord(tbAssetBorrowRecord));
+    }
+
+    /**
+     * 删除资产借用
+     */
+    @PreAuthorize("@ss.hasPermi('asset:borrow:remove')")
+    @Log(title = "资产借用", businessType = BusinessType.DELETE)
+	@DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids)
+    {
+        return toAjax(tbAssetBorrowRecordService.deleteTbAssetBorrowRecordByIds(ids));
+    }
+}

+ 206 - 0
ruoyi-admin/src/main/java/com/ruoyi/borrow/domain/TbAssetBorrowRecord.java

@@ -0,0 +1,206 @@
+package com.ruoyi.borrow.domain;
+
+import java.util.Date;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.ruoyi.common.annotation.Excel;
+import com.ruoyi.common.core.domain.BaseEntity;
+
+/**
+ * 资产借用对象 tb_asset_borrow_record
+ * 
+ * @author ruoyi
+ * @date 2024-01-11
+ */
+public class TbAssetBorrowRecord extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 编号 */
+    private Long id;
+
+    /** 借出资产ID */
+    @Excel(name = "借出资产ID")
+    private Long assetId;
+
+    /** 借出资产名称 */
+    @Excel(name = "借出资产名称")
+    private String assetName;
+
+    /** 借出资产编码 */
+    @Excel(name = "借出资产编码")
+    private String assetNumber;
+
+    /** 借出人用户名 */
+    @Excel(name = "借出人用户名")
+    private String userName;
+
+    /** 借出时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "借出时间", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date borrowTime;
+
+    /** 借出位置 */
+    @Excel(name = "借出位置编码")
+    private String borrowLocationNumber;
+
+    /** 借出位置 */
+    @Excel(name = "借出位置(导出)")
+    private String borrowLocationName;
+
+    /** 预计归还时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "预计归还时间", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date expectedReturnTime;
+
+    /** 是否归还,0:否,1:是 */
+    @Excel(name = "是否归还,0:否,1:是")
+    private Long isReturn;
+
+    /** 归还时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "归还时间", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date returnTime;
+
+    /** 归还位置 */
+    @Excel(name = "归还位置编码")
+    private String returnLocationNumber;
+
+    /** 归还位置 */
+    @Excel(name = "归还位置(导出)")
+    private String returnLocationName;
+
+    public void setId(Long id) 
+    {
+        this.id = id;
+    }
+
+    public Long getId() 
+    {
+        return id;
+    }
+    public void setAssetId(Long assetId) 
+    {
+        this.assetId = assetId;
+    }
+
+    public Long getAssetId() 
+    {
+        return assetId;
+    }
+    public void setUserName(String userName) 
+    {
+        this.userName = userName;
+    }
+
+    public String getUserName() 
+    {
+        return userName;
+    }
+    public void setBorrowTime(Date borrowTime) 
+    {
+        this.borrowTime = borrowTime;
+    }
+
+    public Date getBorrowTime() 
+    {
+        return borrowTime;
+    }
+    public void setBorrowLocationNumber(String borrowLocationNumber) 
+    {
+        this.borrowLocationNumber = borrowLocationNumber;
+    }
+
+    public String getBorrowLocationNumber() 
+    {
+        return borrowLocationNumber;
+    }
+    public void setExpectedReturnTime(Date expectedReturnTime) 
+    {
+        this.expectedReturnTime = expectedReturnTime;
+    }
+
+    public Date getExpectedReturnTime() 
+    {
+        return expectedReturnTime;
+    }
+    public void setIsReturn(Long isReturn) 
+    {
+        this.isReturn = isReturn;
+    }
+
+    public Long getIsReturn() 
+    {
+        return isReturn;
+    }
+    public void setReturnTime(Date returnTime) 
+    {
+        this.returnTime = returnTime;
+    }
+
+    public Date getReturnTime() 
+    {
+        return returnTime;
+    }
+    public void setReturnLocationNumber(String returnLocationNumber) 
+    {
+        this.returnLocationNumber = returnLocationNumber;
+    }
+
+    public String getReturnLocationNumber() 
+    {
+        return returnLocationNumber;
+    }
+
+    public String getAssetName() {
+        return assetName;
+    }
+
+    public void setAssetName(String assetName) {
+        this.assetName = assetName;
+    }
+
+    public String getAssetNumber() {
+        return assetNumber;
+    }
+
+    public void setAssetNumber(String assetNumber) {
+        this.assetNumber = assetNumber;
+    }
+
+    public String getBorrowLocationName() {
+        return borrowLocationName;
+    }
+
+    public void setBorrowLocationName(String borrowLocationName) {
+        this.borrowLocationName = borrowLocationName;
+    }
+
+    public String getReturnLocationName() {
+        return returnLocationName;
+    }
+
+    public void setReturnLocationName(String returnLocationName) {
+        this.returnLocationName = returnLocationName;
+    }
+
+    @Override
+    public String toString() {
+        return "TbAssetBorrowRecord{" +
+                "id=" + id +
+                ", assetId=" + assetId +
+                ", assetName='" + assetName + '\'' +
+                ", assetNumber='" + assetNumber + '\'' +
+                ", userName='" + userName + '\'' +
+                ", borrowTime=" + borrowTime +
+                ", borrowLocationNumber='" + borrowLocationNumber + '\'' +
+                ", borrowLocationName='" + borrowLocationName + '\'' +
+                ", expectedReturnTime=" + expectedReturnTime +
+                ", isReturn=" + isReturn +
+                ", returnTime=" + returnTime +
+                ", returnLocationNumber='" + returnLocationNumber + '\'' +
+                ", returnLocationName='" + returnLocationName + '\'' +
+                '}';
+    }
+}

+ 78 - 0
ruoyi-admin/src/main/java/com/ruoyi/borrow/mapper/TbAssetBorrowRecordMapper.java

@@ -0,0 +1,78 @@
+package com.ruoyi.borrow.mapper;
+
+import java.util.List;
+import com.ruoyi.borrow.domain.TbAssetBorrowRecord;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * 资产借用Mapper接口
+ * 
+ * @author ruoyi
+ * @date 2024-01-11
+ */
+public interface TbAssetBorrowRecordMapper 
+{
+    /**
+     * 查询资产借用
+     * 
+     * @param id 资产借用主键
+     * @return 资产借用
+     */
+    public TbAssetBorrowRecord selectTbAssetBorrowRecordById(Long id);
+
+    /**
+     * 根据资产Id查询借出信息
+     *
+     * @param assetId 资产Id
+     * @return 资产借用
+     */
+    public TbAssetBorrowRecord selectLentRecordByAssetId(@Param("assetId") Long assetId);
+
+    /**
+     * 查询资产借用列表
+     * 
+     * @param tbAssetBorrowRecord 资产借用
+     * @return 资产借用集合
+     */
+    public List<TbAssetBorrowRecord> selectTbAssetBorrowRecordList(TbAssetBorrowRecord tbAssetBorrowRecord);
+
+    /**
+     * 新增资产借用
+     * 
+     * @param tbAssetBorrowRecord 资产借用
+     * @return 结果
+     */
+    public int insertTbAssetBorrowRecord(TbAssetBorrowRecord tbAssetBorrowRecord);
+
+    /**
+     * 修改资产借用
+     * 
+     * @param tbAssetBorrowRecord 资产借用
+     * @return 结果
+     */
+    public int updateTbAssetBorrowRecord(TbAssetBorrowRecord tbAssetBorrowRecord);
+
+    /**
+     * 修改是否归还
+     *
+     * @param tbAssetBorrowRecord 包含值:id, is_return, return_location_number
+     * @return 结果
+     */
+    int updateIsReturn(TbAssetBorrowRecord tbAssetBorrowRecord);
+
+    /**
+     * 删除资产借用
+     * 
+     * @param id 资产借用主键
+     * @return 结果
+     */
+    public int deleteTbAssetBorrowRecordById(Long id);
+
+    /**
+     * 批量删除资产借用
+     * 
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteTbAssetBorrowRecordByIds(Long[] ids);
+}

+ 69 - 0
ruoyi-admin/src/main/java/com/ruoyi/borrow/service/ITbAssetBorrowRecordService.java

@@ -0,0 +1,69 @@
+package com.ruoyi.borrow.service;
+
+import java.util.List;
+import com.ruoyi.borrow.domain.TbAssetBorrowRecord;
+
+/**
+ * 资产借用Service接口
+ * 
+ * @author ruoyi
+ * @date 2024-01-11
+ */
+public interface ITbAssetBorrowRecordService
+{
+    /**
+     * 快速归还
+     *
+     * @param assetNumber 资产编码
+     * @return null/错误消息
+     */
+    public String fastReturnByAssetNumber(String assetNumber);
+
+    /**
+     * 查询资产借用
+     * 
+     * @param id 资产借用主键
+     * @return 资产借用
+     */
+    public TbAssetBorrowRecord selectTbAssetBorrowRecordById(Long id);
+
+    /**
+     * 查询资产借用列表
+     * 
+     * @param tbAssetBorrowRecord 资产借用
+     * @return 资产借用集合
+     */
+    public List<TbAssetBorrowRecord> selectTbAssetBorrowRecordList(TbAssetBorrowRecord tbAssetBorrowRecord);
+
+    /**
+     * 新增资产借用
+     * 
+     * @param tbAssetBorrowRecord 资产借用
+     * @return 结果
+     */
+    public int insertTbAssetBorrowRecord(TbAssetBorrowRecord tbAssetBorrowRecord);
+
+    /**
+     * 修改资产借用
+     * 
+     * @param tbAssetBorrowRecord 资产借用
+     * @return 结果
+     */
+    public int updateTbAssetBorrowRecord(TbAssetBorrowRecord tbAssetBorrowRecord);
+
+    /**
+     * 批量删除资产借用
+     * 
+     * @param ids 需要删除的资产借用主键集合
+     * @return 结果
+     */
+    public int deleteTbAssetBorrowRecordByIds(Long[] ids);
+
+    /**
+     * 删除资产借用信息
+     * 
+     * @param id 资产借用主键
+     * @return 结果
+     */
+    public int deleteTbAssetBorrowRecordById(Long id);
+}

+ 219 - 0
ruoyi-admin/src/main/java/com/ruoyi/borrow/service/impl/TbAssetBorrowRecordServiceImpl.java

@@ -0,0 +1,219 @@
+package com.ruoyi.borrow.service.impl;
+
+import java.util.Date;
+import java.util.List;
+
+import cn.hutool.core.util.StrUtil;
+import com.ruoyi.asset.domain.TbAssetInformation;
+import com.ruoyi.asset.domain.enums.ManageStatus;
+import com.ruoyi.asset.mapper.TbAssetInformationMapper;
+import com.ruoyi.common.utils.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.ruoyi.borrow.mapper.TbAssetBorrowRecordMapper;
+import com.ruoyi.borrow.domain.TbAssetBorrowRecord;
+import com.ruoyi.borrow.service.ITbAssetBorrowRecordService;
+
+/**
+ * 资产借用Service业务层处理
+ * 
+ * @author ruoyi
+ * @date 2024-01-11
+ */
+@Service
+public class TbAssetBorrowRecordServiceImpl implements ITbAssetBorrowRecordService 
+{
+    @Autowired
+    private TbAssetBorrowRecordMapper tbAssetBorrowRecordMapper;
+
+    @Autowired
+    private TbAssetInformationMapper assetInformationMapper;
+
+    @Override
+    public String fastReturnByAssetNumber(String assetNumber) {
+        // 根据资产编码查询资产
+        TbAssetInformation tbAssetInformation = assetInformationMapper.selectTbAssetInformationByAssetNumber(assetNumber);
+        // 判断资产是否存在
+        if (tbAssetInformation == null) {
+            return "资产不存在";
+        }
+
+        // 获取资产Id
+        Long assetId = tbAssetInformation.getId();
+
+        // 判断资产是否已借出
+        TbAssetBorrowRecord isLentRecord = tbAssetBorrowRecordMapper.selectLentRecordByAssetId(assetId);
+        if (isLentRecord == null) {
+            return "资产已归还";
+        }
+
+        // 设置已归还
+        isLentRecord.setIsReturn(1L);
+        // 设置归还时间
+        isLentRecord.setReturnTime(new Date());
+        // 设置归还地点:原借出位置
+        isLentRecord.setReturnLocationNumber(isLentRecord.getBorrowLocationNumber());
+        // 设置备注
+        isLentRecord.setRemark("快速归还");
+        // 设置更新时间
+        isLentRecord.setUpdateTime(DateUtils.getNowDate());
+
+        int updateResult = tbAssetBorrowRecordMapper.updateTbAssetBorrowRecord(isLentRecord);
+        if (updateResult > 0) {
+            TbAssetInformation assetInformation = new TbAssetInformation();
+            assetInformation.setId(isLentRecord.getAssetId());
+            assetInformation.setManageStatus(ManageStatus.NORMAL.getCode());
+            assetInformationMapper.updateTbAssetInformation(assetInformation);
+        }
+
+        return updateResult > 0 ? null : "归还失败";
+    }
+
+    /**
+     * 查询资产借用
+     * 
+     * @param id 资产借用主键
+     * @return 资产借用
+     */
+    @Override
+    public TbAssetBorrowRecord selectTbAssetBorrowRecordById(Long id)
+    {
+        return tbAssetBorrowRecordMapper.selectTbAssetBorrowRecordById(id);
+    }
+
+    /**
+     * 查询资产借用列表
+     * 
+     * @param tbAssetBorrowRecord 资产借用
+     * @return 资产借用
+     */
+    @Override
+    public List<TbAssetBorrowRecord> selectTbAssetBorrowRecordList(TbAssetBorrowRecord tbAssetBorrowRecord)
+    {
+        return tbAssetBorrowRecordMapper.selectTbAssetBorrowRecordList(tbAssetBorrowRecord);
+    }
+
+    /**
+     * 新增资产借用
+     * 
+     * @param tbAssetBorrowRecord 资产借用
+     * @return 结果
+     */
+    @Override
+    public int insertTbAssetBorrowRecord(TbAssetBorrowRecord tbAssetBorrowRecord)
+    {
+        Long assetId = tbAssetBorrowRecord.getAssetId();
+
+        // 判断是否已借出
+        TbAssetBorrowRecord isLentRecord = tbAssetBorrowRecordMapper.selectLentRecordByAssetId(assetId);
+        if (isLentRecord != null) {
+            return 0;
+        }
+
+        TbAssetInformation tbAssetInformation;
+        if (assetId != null) {
+            tbAssetInformation = assetInformationMapper.selectTbAssetInformationById(assetId);
+            if (tbAssetInformation == null) {
+                return 0;
+            }
+        } else {
+            String assetNumber = tbAssetBorrowRecord.getAssetNumber();
+            tbAssetInformation = assetInformationMapper.selectTbAssetInformationByAssetNumber(assetNumber);
+
+            if (tbAssetInformation == null) {
+                return 0;
+            }
+            tbAssetBorrowRecord.setAssetId(tbAssetInformation.getId());
+        }
+        tbAssetBorrowRecord.setBorrowLocationNumber(tbAssetInformation.getLocationNumber());
+
+        tbAssetBorrowRecord.setCreateTime(DateUtils.getNowDate());
+        int insertResult = tbAssetBorrowRecordMapper.insertTbAssetBorrowRecord(tbAssetBorrowRecord);
+        if (insertResult > 0) {
+            TbAssetInformation assetInformation = new TbAssetInformation();
+            assetInformation.setId(tbAssetBorrowRecord.getAssetId());
+            assetInformation.setManageStatus(ManageStatus.BORROW.getCode());
+            assetInformationMapper.updateTbAssetInformation(assetInformation);
+        }
+        return insertResult;
+    }
+
+    /**
+     * 修改资产借用
+     * 
+     * @param tbAssetBorrowRecord 资产借用
+     * @return 结果
+     */
+    @Override
+    public int updateTbAssetBorrowRecord(TbAssetBorrowRecord tbAssetBorrowRecord)
+    {
+        Long isReturn = tbAssetBorrowRecord.getIsReturn();
+        Date returnTime = tbAssetBorrowRecord.getReturnTime();
+        String returnLocationNumber = tbAssetBorrowRecord.getReturnLocationNumber();
+
+        if (isReturn > 0) { // 已归还
+            // 未设置归还时间
+            if (returnTime == null) {
+                tbAssetBorrowRecord.setReturnTime(new Date());
+            }
+        } else { // 未归还
+            // 根据资产Id判断是否已借出
+            TbAssetBorrowRecord isLentRecord = tbAssetBorrowRecordMapper.selectLentRecordByAssetId(tbAssetBorrowRecord.getAssetId());
+            // 判断是否非同一个
+            if (!tbAssetBorrowRecord.getId().equals(isLentRecord.getId())) {
+                return 0;
+            }
+
+            // 已设置归还时间
+            if (returnTime != null) {
+                tbAssetBorrowRecord.setReturnTime(null);
+            }
+            // 已设置归还位置
+            if (StrUtil.isNotBlank(returnLocationNumber)) {
+                tbAssetBorrowRecord.setReturnLocationNumber(null);
+            }
+        }
+
+        tbAssetBorrowRecord.setUpdateTime(DateUtils.getNowDate());
+        int updateResult = tbAssetBorrowRecordMapper.updateTbAssetBorrowRecord(tbAssetBorrowRecord);
+        if (updateResult > 0) {
+            if (isReturn < 1) {
+                tbAssetBorrowRecordMapper.updateIsReturn(tbAssetBorrowRecord);
+            }
+
+            TbAssetInformation assetInformation = new TbAssetInformation();
+            assetInformation.setId(tbAssetBorrowRecord.getAssetId());
+            if (isReturn > 0) {
+                assetInformation.setManageStatus(ManageStatus.NORMAL.getCode());
+            } else {
+                assetInformation.setManageStatus(ManageStatus.BORROW.getCode());
+            }
+            assetInformationMapper.updateTbAssetInformation(assetInformation);
+        }
+        return 1;
+    }
+
+    /**
+     * 批量删除资产借用
+     * 
+     * @param ids 需要删除的资产借用主键
+     * @return 结果
+     */
+    @Override
+    public int deleteTbAssetBorrowRecordByIds(Long[] ids)
+    {
+        return tbAssetBorrowRecordMapper.deleteTbAssetBorrowRecordByIds(ids);
+    }
+
+    /**
+     * 删除资产借用信息
+     * 
+     * @param id 资产借用主键
+     * @return 结果
+     */
+    @Override
+    public int deleteTbAssetBorrowRecordById(Long id)
+    {
+        return tbAssetBorrowRecordMapper.deleteTbAssetBorrowRecordById(id);
+    }
+}

+ 6 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java

@@ -74,6 +74,12 @@ public class SysUserController extends BaseController
         return success(list);
     }
 
+    @GetMapping("/exists/{userName}")
+    public AjaxResult existsUserName(@PathVariable("userName") String userName) {
+        SysUser sysUser = userService.selectUserByUserName(userName);
+        return AjaxResult.success(sysUser != null);
+    }
+
     /**
      * 获取用户列表
      */

+ 154 - 0
ruoyi-admin/src/main/resources/mapper/borrow/TbAssetBorrowRecordMapper.xml

@@ -0,0 +1,154 @@
+<?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.ruoyi.borrow.mapper.TbAssetBorrowRecordMapper">
+    
+    <resultMap type="TbAssetBorrowRecord" id="TbAssetBorrowRecordResult">
+        <result property="id"    column="id"    />
+        <result property="assetId"    column="asset_id"    />
+        <result property="userName"    column="user_name"    />
+        <result property="borrowTime"    column="borrow_time"    />
+        <result property="borrowLocationNumber"    column="borrow_location_number"    />
+        <result property="expectedReturnTime"    column="expected_return_time"    />
+        <result property="isReturn"    column="is_return"    />
+        <result property="returnTime"    column="return_time"    />
+        <result property="returnLocationNumber"    column="return_location_number"    />
+        <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="remark"    column="remark"    />
+    </resultMap>
+
+    <sql id="selectTbAssetBorrowRecordVo">
+        select id, asset_id, user_name, borrow_time, borrow_location_number, expected_return_time, is_return, return_time, return_location_number, create_by, create_time, update_by, update_time, remark from tb_asset_borrow_record
+    </sql>
+
+    <sql id="selectTbAssetBorrowRecord">
+        select
+            a.id,
+            a.asset_id assetId,
+            b.name assetName,
+            b.number assetNumber,
+            a.user_name userName,
+            a.borrow_time borrowTime,
+            a.borrow_location_number borrowLocationNumber,
+            concat_ws('-',IFNULL(NULL,e.name),IFNULL(NULL,d.name),c.name) borrowLocationName,
+            a.expected_return_time expectedReturnTime,
+            a.is_return isReturn,
+            a.return_time returnTime,
+            a.return_location_number returnLocationNumber,
+            concat_ws('-',IFNULL(NULL,h.name),IFNULL(NULL,g.name),f.name) returnLocationName,
+            a.create_by createBy,
+            a.create_time createTime,
+            a.update_by updateBy,
+            a.update_time updateTime,
+            a.remark
+        from tb_asset_borrow_record a
+         LEFT JOIN tb_asset_information b ON b.id = a.asset_id
+         LEFT JOIN tb_location c ON c.number = a.borrow_location_number
+         LEFT JOIN tb_location d ON c.parent_id = d.id
+         LEFT JOIN tb_location e ON d.parent_id = e.id
+         LEFT JOIN tb_location f ON f.number = a.return_location_number
+         LEFT JOIN tb_location g ON f.parent_id = g.id
+         LEFT JOIN tb_location h ON g.parent_id = h.id
+    </sql>
+
+    <select id="selectTbAssetBorrowRecordList" parameterType="TbAssetBorrowRecord" resultType="TbAssetBorrowRecord">
+        <include refid="selectTbAssetBorrowRecord"/>
+        <where>  
+            <if test="assetNumber != null and assetNumber != ''"> and b.number = #{assetNumber} or b.number like concat('%', #{assetNumber}, '%')</if>
+            <if test="assetName != null and assetName != ''"> and b.name = #{assetName} or b.name like concat('%', #{assetName}, '%')</if>
+            <if test="userName != null  and userName != ''"> and a.user_name like concat('%', #{userName}, '%')</if>
+            <if test="borrowTime != null "> and a.borrow_time = #{borrowTime}</if>
+            <if test="borrowLocationNumber != null  and borrowLocationNumber != ''"> and a.borrow_location_number = #{borrowLocationNumber}</if>
+            <if test="expectedReturnTime != null "> and a.expected_return_time = #{expectedReturnTime}</if>
+            <if test="isReturn != null "> and a.is_return = #{isReturn}</if>
+            <if test="returnTime != null "> and a.return_time = #{returnTime}</if>
+            <if test="returnLocationNumber != null  and returnLocationNumber != ''"> and a.return_location_number = #{returnLocationNumber}</if>
+        </where>
+        ORDER BY a.is_return ASC
+    </select>
+    
+    <select id="selectTbAssetBorrowRecordById" parameterType="Long" resultType="TbAssetBorrowRecord">
+        <include refid="selectTbAssetBorrowRecord"/>
+        where a.id = #{id}
+    </select>
+    
+    <select id="selectLentRecordByAssetId" parameterType="Long" resultType="TbAssetBorrowRecord">
+        <include refid="selectTbAssetBorrowRecord"/>
+        where a.asset_id = #{assetId} and is_return = 0
+    </select>
+        
+    <insert id="insertTbAssetBorrowRecord" parameterType="TbAssetBorrowRecord" useGeneratedKeys="true" keyProperty="id">
+        insert into tb_asset_borrow_record
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="assetId != null">asset_id,</if>
+            <if test="userName != null and userName != ''">user_name,</if>
+            <if test="borrowTime != null">borrow_time,</if>
+            <if test="borrowLocationNumber != null and borrowLocationNumber != ''">borrow_location_number,</if>
+            <if test="expectedReturnTime != null">expected_return_time,</if>
+            <if test="isReturn != null">is_return,</if>
+            <if test="returnTime != null">return_time,</if>
+            <if test="returnLocationNumber != null and returnLocationNumber != ''">return_location_number,</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>
+            <if test="remark != null">remark,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="assetId != null">#{assetId},</if>
+            <if test="userName != null and userName != ''">#{userName},</if>
+            <if test="borrowTime != null">#{borrowTime},</if>
+            <if test="borrowLocationNumber != null and borrowLocationNumber != ''">#{borrowLocationNumber},</if>
+            <if test="expectedReturnTime != null">#{expectedReturnTime},</if>
+            <if test="isReturn != null">#{isReturn},</if>
+            <if test="returnTime != null">#{returnTime},</if>
+            <if test="returnLocationNumber != null and returnLocationNumber != ''">#{returnLocationNumber},</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>
+            <if test="remark != null">#{remark},</if>
+         </trim>
+    </insert>
+
+    <update id="updateTbAssetBorrowRecord" parameterType="TbAssetBorrowRecord">
+        update tb_asset_borrow_record
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="assetId != null">asset_id = #{assetId},</if>
+            <if test="userName != null and userName != ''">user_name = #{userName},</if>
+            <if test="borrowTime != null">borrow_time = #{borrowTime},</if>
+            <if test="borrowLocationNumber != null and borrowLocationNumber != ''">borrow_location_number = #{borrowLocationNumber},</if>
+            <if test="expectedReturnTime != null">expected_return_time = #{expectedReturnTime},</if>
+            <if test="isReturn != null">is_return = #{isReturn},</if>
+            <if test="returnTime != null">return_time = #{returnTime},</if>
+            <if test="returnLocationNumber != null and returnLocationNumber != ''">return_location_number = #{returnLocationNumber},</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>
+            <if test="remark != null">remark = #{remark},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <update id="updateIsReturn" parameterType="TbAssetBorrowRecord">
+        update tb_asset_borrow_record
+        set is_return = #{isReturn}, return_time = #{returnTime}, return_location_number = #{returnLocationNumber}
+        where id = #{id}
+    </update>
+
+    <delete id="deleteTbAssetBorrowRecordById" parameterType="Long">
+        delete from tb_asset_borrow_record where id = #{id} and is_return = 1
+    </delete>
+
+    <delete id="deleteTbAssetBorrowRecordByIds" parameterType="String">
+        delete from tb_asset_borrow_record where is_return = 1 and id in
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+</mapper>

+ 44 - 0
ruoyi-ui/src/api/asset/borrow.js

@@ -0,0 +1,44 @@
+import request from '@/utils/request'
+
+// 查询资产借用列表
+export function listBorrow(query) {
+  return request({
+    url: '/asset/borrow/list',
+    method: 'get',
+    params: query
+  })
+}
+
+// 查询资产借用详细
+export function getBorrow(id) {
+  return request({
+    url: '/asset/borrow/' + id,
+    method: 'get'
+  })
+}
+
+// 新增资产借用
+export function addBorrow(data) {
+  return request({
+    url: '/asset/borrow',
+    method: 'post',
+    data: data
+  })
+}
+
+// 修改资产借用
+export function updateBorrow(data) {
+  return request({
+    url: '/asset/borrow',
+    method: 'put',
+    data: data
+  })
+}
+
+// 删除资产借用
+export function delBorrow(id) {
+  return request({
+    url: '/asset/borrow/' + id,
+    method: 'delete'
+  })
+}

+ 8 - 0
ruoyi-ui/src/api/system/user.js

@@ -142,3 +142,11 @@ export function deptTreeSelect() {
     method: 'get'
   })
 }
+
+// 验证用户名是否存在
+export function isExistsUserName(userName) {
+  return request({
+    url: `/system/user/exists/${userName}`,
+    method: 'get'
+  })
+}

+ 491 - 0
ruoyi-ui/src/views/asset/borrow/index.vue

@@ -0,0 +1,491 @@
+<template>
+  <div class="app-container">
+    <el-form :model="queryParams" ref="queryForm" class="queryForm" size="small" :inline="true" v-show="showSearch" label-width="110px">
+      <el-form-item label="资产编码" prop="assetNumber">
+        <el-input
+          v-model="queryParams.assetNumber"
+          placeholder="请输入资产编码"
+          clearable
+          @keyup.enter.native="handleQuery"
+        />
+      </el-form-item>
+      <el-form-item label="资产名称" prop="assetName">
+        <el-input
+          v-model="queryParams.assetName"
+          placeholder="请输入资产名称"
+          clearable
+          @keyup.enter.native="handleQuery"
+        />
+      </el-form-item>
+      <el-form-item label="借出人" prop="userName">
+        <el-input
+          v-model="queryParams.userName"
+          placeholder="请输入借出人用户名"
+          clearable
+          @keyup.enter.native="handleQuery"
+        />
+      </el-form-item>
+      <el-form-item label="借出时间" prop="borrowTime">
+        <el-date-picker clearable
+          v-model="queryParams.borrowTime"
+          type="date"
+          value-format="yyyy-MM-dd"
+          placeholder="请选择借出时间">
+        </el-date-picker>
+      </el-form-item>
+      <el-form-item label="借出位置" prop="borrowLocationNumber">
+        <treeselect v-model="queryParams.borrowLocationNumber" :options="locationList" :normalizer="tenantIdnormalizer" placeholder="请选择借出位置" />
+      </el-form-item>
+      <el-form-item label="预计归还时间" prop="expectedReturnTime">
+        <el-date-picker clearable
+          v-model="queryParams.expectedReturnTime"
+          type="date"
+          value-format="yyyy-MM-dd"
+          placeholder="请选择预计归还时间">
+        </el-date-picker>
+      </el-form-item>
+      <el-form-item label="是否归还" prop="isReturn">
+        <el-select v-model="queryParams.isReturn" placeholder="请选择是否归还" clearable>
+          <el-option
+            v-for="dict in dict.type.my_yes_no"
+            :key="dict.value"
+            :label="dict.label"
+            :value="dict.value"
+          />
+        </el-select>
+      </el-form-item>
+      <el-form-item label="归还时间" prop="returnTime">
+        <el-date-picker clearable
+          v-model="queryParams.returnTime"
+          type="date"
+          value-format="yyyy-MM-dd"
+          placeholder="请选择归还时间">
+        </el-date-picker>
+      </el-form-item>
+      <el-form-item label="归还位置" prop="returnLocationNumber">
+        <treeselect v-model="queryParams.returnLocationNumber" :options="locationList" :normalizer="tenantIdnormalizer" placeholder="请选择归还位置" />
+      </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="['asset:borrow: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="['asset:borrow: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="['asset:borrow: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="['asset:borrow:export']"
+        >导出</el-button>
+      </el-col>
+      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
+    </el-row>
+
+    <el-table v-loading="loading" :data="borrowList" @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="assetNumber" />
+      <el-table-column label="资产名称" width="200" align="center" prop="assetName" />
+      <el-table-column label="借出人" align="center" prop="userName" />
+      <el-table-column label="借出时间" align="center" prop="borrowTime" width="100">
+        <template slot-scope="scope">
+          <span>{{ parseTime(scope.row.borrowTime, '{y}-{m}-{d}') }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="借出位置" width="200" align="center" prop="borrowLocationName" />
+      <el-table-column label="预计归还时间" align="center" prop="expectedReturnTime" width="100">
+        <template slot-scope="scope">
+          <span>{{ parseTime(scope.row.expectedReturnTime, '{y}-{m}-{d}') }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="是否归还" align="center" prop="isReturn">
+        <template slot-scope="scope">
+          <!-- <dict-tag :options="dict.type.my_yes_no" :value="scope.row.isReturn"/> -->
+          <el-switch
+            v-model="scope.row.isReturn"
+            :active-value="1"
+            active-color="#13ce66"
+            :inactive-value="0"
+            @change="onReturn($event, scope.row)">
+          </el-switch>
+        </template>
+      </el-table-column>
+      <el-table-column label="归还时间" align="center" prop="returnTime" width="100">
+        <template slot-scope="scope">
+          <span>{{ parseTime(scope.row.returnTime, '{y}-{m}-{d}') }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="归还位置" width="200" align="center" prop="returnLocationName" />
+      <el-table-column label="备注" align="center" prop="remark" />
+      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right">
+        <template slot-scope="scope">
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-edit"
+            @click="handleUpdate(scope.row)"
+            v-hasPermi="['asset:borrow:edit']"
+          >修改</el-button>
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-delete"
+            @click="handleDelete(scope.row)"
+            v-hasPermi="['asset:borrow: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="110px">
+        <el-form-item label="借出资产编码" prop="assetNumber">
+          <el-input v-model="form.assetNumber" placeholder="请输入借出资产编码" :disabled="isUpdate"/>
+        </el-form-item>
+        <el-form-item label="借出人用户名" prop="userName">
+          <el-input v-model="form.userName" placeholder="请输入借出人用户名" @change="onCheckUserName">
+            <el-button slot="append" icon="el-icon-search" @click="openUserSearch = true"></el-button>
+          </el-input>
+        </el-form-item>
+        <el-form-item label="借出位置" prop="borrowLocationNumber" v-if="isUpdate">
+          <treeselect v-model="form.borrowLocationNumber" :options="locationList" :normalizer="tenantIdnormalizer" placeholder="请输入借出位置"/>
+        </el-form-item>
+        <el-form-item label="预计归还时间" prop="expectedReturnTime">
+          <el-date-picker clearable
+            v-model="form.expectedReturnTime"
+            type="date"
+            value-format="yyyy-MM-dd"
+            :picker-options="pickerOptions"
+            placeholder="请选择预计归还时间">
+          </el-date-picker>
+        </el-form-item>
+        <el-form-item label="是否归还" prop="isReturn" v-if="isUpdate">
+          <el-switch
+            v-model="form.isReturn"
+            active-text="是"
+            :active-value="1"
+            active-color="#13ce66"
+            inactive-text="否"
+            :inactive-value="0">
+          </el-switch>
+        </el-form-item>
+        <el-form-item label="归还时间" prop="returnTime" v-if="isUpdate && form.isReturn === 1">
+          <el-date-picker clearable
+            v-model="form.returnTime"
+            type="date"
+            value-format="yyyy-MM-dd"
+            placeholder="请选择归还时间">
+          </el-date-picker>
+        </el-form-item>
+        <el-form-item label="归还位置" prop="returnLocationNumber" v-if="isUpdate && form.isReturn === 1">
+          <treeselect v-model="form.returnLocationNumber" :options="locationList" :normalizer="tenantIdnormalizer" placeholder="请输入归还位置" />
+          <el-button type="text" @click="onUseBorrowLocation">归还原位</el-button>
+        </el-form-item>
+        <el-form-item label="备注" prop="remark">
+          <el-input v-model="form.remark" 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>
+
+    <el-dialog :visible.sync="openUserSearch">
+      <UserSearch @submit="onSelectUser" @cancel="() => {openUserSearch = false}" v-if="openUserSearch"></UserSearch>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import { listBorrow, getBorrow, delBorrow, addBorrow, updateBorrow } from "@/api/asset/borrow";
+import { isExistsUserName } from '@/api/system/user'
+import { treeSelect } from '@/api/asset/location'
+import UserSearch from '@/components/SysUserSearch/index.vue'
+import Treeselect from '@riophae/vue-treeselect'
+import '@riophae/vue-treeselect/dist/vue-treeselect.css'
+export default {
+  name: "Borrow",
+  dicts: ['my_yes_no'],
+  components: {
+    Treeselect,
+    UserSearch
+  },
+  data() {
+    return {
+      // 遮罩层
+      loading: true,
+      // 选中数组
+      ids: [],
+      // 非单个禁用
+      single: true,
+      // 非多个禁用
+      multiple: true,
+      // 显示搜索条件
+      showSearch: true,
+      // 总条数
+      total: 0,
+      // 资产借用表格数据
+      borrowList: [],
+      // 所属位置表格数据
+      locationList: [],
+      // 弹出层标题
+      title: "",
+      // 是否显示弹出层
+      open: false,
+      // 查询参数
+      queryParams: {
+        pageNum: 1,
+        pageSize: 10,
+        assetNumber: null,
+        assetName: null,
+        userName: null,
+        borrowTime: null,
+        borrowLocationNumber: null,
+        expectedReturnTime: null,
+        isReturn: null,
+        returnTime: null,
+        returnLocationNumber: null,
+      },
+      // 表单参数
+      form: {},
+      isUpdate: false,
+      openUserSearch: false,
+      pickerOptions: {
+        disabledDate(time) {
+          return time.getTime() < Date.now() - 8.64e7;
+        }
+      },
+      // 表单校验
+      rules: {
+        assetNumber: [
+          { required: true, message: "借出资产编码不能为空", trigger: "blur" }
+        ],
+        userName: [
+          { required: true, message: "借出人用户名不能为空", trigger: "blur" }
+        ],
+        borrowTime: [
+          { required: true, message: "借出时间不能为空", trigger: "blur" }
+        ],
+        borrowLocationNumber: [
+          { required: true, message: "借出位置不能为空", trigger: "blur" }
+        ],
+        expectedReturnTime: [
+          { required: true, message: "预计归还时间不能为空", trigger: "blur" }
+        ],
+        returnLocationNumber: [
+          { required: true, message: "归还位置不能为空", trigger: "blur" }
+        ],
+      }
+    };
+  },
+  created() {
+    this.getList();
+  },
+  methods: {
+    tenantIdnormalizer(node) {
+      return {
+        id: node.number,
+        label: node.label,
+        children: node.children,
+      }
+    },
+    /** 查询资产借用列表 */
+    getList() {
+      this.loading = true;
+      listBorrow(this.queryParams).then(response => {
+        this.borrowList = response.rows;
+        this.total = response.total;
+        this.loading = false;
+      });
+      treeSelect().then((response) => {
+        this.locationList = response.data
+      })
+    },
+    // 取消按钮
+    cancel() {
+      this.open = false;
+      this.reset();
+    },
+    // 表单重置
+    reset() {
+      this.form = {
+        id: null,
+        assetNumber: null,
+        userName: null,
+        borrowTime: null,
+        borrowLocationNumber: null,
+        expectedReturnTime: null,
+        isReturn: null,
+        returnTime: null,
+        returnLocationNumber: null,
+        createBy: null,
+        createTime: null,
+        updateBy: null,
+        updateTime: null,
+        remark: 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
+    },
+    onSelectUser(info) {
+      this.openUserSearch = false
+      this.form.userName = info.userName
+    },
+    onCheckUserName(val) {
+      isExistsUserName(val).then(res => {
+        const isExists = res.data
+        if (!isExists) {
+          this.$modal.msgWarning('用户不存在')
+          this.form.userName = null
+        }
+      })
+    },
+    /** 新增按钮操作 */
+    handleAdd() {
+      this.reset();
+      this.open = true;
+      this.isUpdate = false
+      this.title = "添加资产借用";
+    },
+    /** 修改按钮操作 */
+    handleUpdate(row) {
+      this.reset();
+      const id = row.id || this.ids
+      getBorrow(id).then(response => {
+        this.form = response.data;
+        this.open = true;
+        this.isUpdate = true
+        this.title = "修改资产借用";
+      });
+    },
+    onUseBorrowLocation() {
+      this.form.returnLocationNumber = this.form.borrowLocationNumber
+    },
+    onReturn(e, row) {
+      const form = row
+      let message;
+      if (e === 1) {
+        message = '归还成功'
+        form.returnLocationNumber = row.borrowLocationNumber
+      } else {
+        message = '修改成功'
+        form.returnTime = null
+        form.returnLocationNumber = null
+      }      
+      updateBorrow(form).then(response => {
+        this.$modal.msgSuccess(message);
+        this.getList();
+      })
+    },
+    /** 提交按钮 */
+    submitForm() {
+      this.$refs["form"].validate(valid => {
+        if (valid) {
+          if (this.form.id != null) {
+            updateBorrow(this.form).then(response => {
+              this.$modal.msgSuccess("修改成功");
+              this.open = false;
+              this.getList();
+            });
+          } else {
+            addBorrow(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 delBorrow(ids);
+      }).then(() => {
+        this.getList();
+        this.$modal.msgSuccess("删除成功");
+      }).catch(() => {});
+    },
+    /** 导出按钮操作 */
+    handleExport() {
+      this.download('asset/borrow/export', {
+        ...this.queryParams
+      }, `borrow_${new Date().getTime()}.xlsx`)
+    }
+  }
+};
+</script>
+
+<style lang="less" scoped>
+/deep/ .vue-treeselect {
+  display: inline-block;
+}
+.queryForm {
+  /deep/ .vue-treeselect {
+    width: 205px;
+    height: 32px;
+  }
+}
+</style>

+ 1 - 1
ruoyi-ui/src/views/asset/information/index.vue

@@ -656,8 +656,8 @@ import { treeSelect } from '@/api/asset/location'
 import ImageUploadTemp from '@/components/ImageUploadTemp'
 import { listDept } from '@/api/system/dept'
 import { select } from '@/api/label/labelModel'
-import Treeselect from '@riophae/vue-treeselect'
 import { getToken } from '@/utils/auth'
+import Treeselect from '@riophae/vue-treeselect'
 import '@riophae/vue-treeselect/dist/vue-treeselect.css'
 
 export default {