Browse Source

[feat] 采购管理

采购订单新增:导入采购订单供应商合同后端接口:新增具体实现类,关联附件表和采购订单表的数据
采购订单前端列表页面新增导入合同按钮和js方法,采用模态框的结构展示导入页面,导入前加上多条数据的判断,订单作废的判断,是否审核通过的判断;新增导入附件的js方法
dev
liuxiaoxu 3 months ago
parent
commit
0da2bcb981
  1. 14
      ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderController.java
  2. 7
      ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchaseOrderService.java
  3. 56
      ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseOrderServiceImpl.java
  4. 139
      ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/purchaseOrder.html

14
ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderController.java

@ -47,6 +47,7 @@ import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -143,6 +144,19 @@ public class PurchaseOrderController extends BaseController
} }
/**
* 导入采购订单合同
*/
@PostMapping("/uploadSingleFile")
@ResponseBody
public AjaxResult uploadSingleFile(@RequestParam("file") MultipartFile file,
@RequestParam(value = "purchaseOrderCode", required = false) String purchaseOrderCode) throws Exception
{
AjaxResult ajaxResult = purchaseOrderService.uploadSingleFile(file,purchaseOrderCode);
return ajaxResult;
}
/** /**
* 新增采购订单 * 新增采购订单
*/ */

7
ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchaseOrderService.java

@ -1,10 +1,12 @@
package com.ruoyi.purchase.service; package com.ruoyi.purchase.service;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.purchase.domain.PurchaseOrder; import com.ruoyi.purchase.domain.PurchaseOrder;
import com.ruoyi.purchase.domain.PurchaseOrderVo; import com.ruoyi.purchase.domain.PurchaseOrderVo;
import com.ruoyi.warehouse.domain.WarehouseStorageOrder; import com.ruoyi.warehouse.domain.WarehouseStorageOrder;
import org.activiti.engine.runtime.ProcessInstance; import org.activiti.engine.runtime.ProcessInstance;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
@ -88,4 +90,9 @@ public interface IPurchaseOrderService
* 导出采购订单供应商合同 * 导出采购订单供应商合同
* */ * */
void exportPurchaseOrder(PurchaseOrder purchaseOrder, String supplierCode ,HttpServletResponse response); void exportPurchaseOrder(PurchaseOrder purchaseOrder, String supplierCode ,HttpServletResponse response);
/**
* 导入采购订单供应商合同
* */
AjaxResult uploadSingleFile(MultipartFile file,String purchaseOrderCode);
} }

56
ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseOrderServiceImpl.java

@ -6,6 +6,9 @@ import com.deepoove.poi.XWPFTemplate;
import com.deepoove.poi.config.Configure; import com.deepoove.poi.config.Configure;
import com.deepoove.poi.plugin.table.LoopRowTableRenderPolicy; import com.deepoove.poi.plugin.table.LoopRowTableRenderPolicy;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.config.ServerConfig;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.page.PageDomain; import com.ruoyi.common.core.page.PageDomain;
import com.ruoyi.common.core.page.TableSupport; import com.ruoyi.common.core.page.TableSupport;
@ -18,6 +21,7 @@ import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.bean.BeanUtils; import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.common.utils.file.FileDownloadUtils; import com.ruoyi.common.utils.file.FileDownloadUtils;
import com.ruoyi.common.utils.file.FileUploadUtils;
import com.ruoyi.erp.domain.ErpDevelopModifyorder; import com.ruoyi.erp.domain.ErpDevelopModifyorder;
import com.ruoyi.erp.mapper.ErpDevelopModifyorderMapper; import com.ruoyi.erp.mapper.ErpDevelopModifyorderMapper;
import com.ruoyi.financial.domain.FinancialAccountsPayable; import com.ruoyi.financial.domain.FinancialAccountsPayable;
@ -32,6 +36,7 @@ import com.ruoyi.purchase.mapper.PurchaseOrderChildMapper;
import com.ruoyi.purchase.mapper.PurchaseOrderMapper; import com.ruoyi.purchase.mapper.PurchaseOrderMapper;
import com.ruoyi.purchase.mapper.PurchasePlanMapper; import com.ruoyi.purchase.mapper.PurchasePlanMapper;
import com.ruoyi.purchase.service.IPurchaseOrderService; import com.ruoyi.purchase.service.IPurchaseOrderService;
import com.ruoyi.system.domain.SysAttachFile;
import com.ruoyi.system.domain.SysCompanyInformation; import com.ruoyi.system.domain.SysCompanyInformation;
import com.ruoyi.system.domain.SysSupplier; import com.ruoyi.system.domain.SysSupplier;
import com.ruoyi.system.domain.Vo.SysSupplierVo; import com.ruoyi.system.domain.Vo.SysSupplierVo;
@ -55,6 +60,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.ServletOutputStream; import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -135,6 +141,11 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
private SysCompanyInformationMapper companyInformationMapper; private SysCompanyInformationMapper companyInformationMapper;
@Autowired
private ServerConfig serverConfig;
/** /**
* 查询采购订单 * 查询采购订单
* *
@ -707,6 +718,9 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
return processInstance; return processInstance;
} }
/**
* 导出采购订单供应商合同
* */
@Override @Override
public void exportPurchaseOrder(PurchaseOrder purchaseOrder, String supplierCode, HttpServletResponse response) { public void exportPurchaseOrder(PurchaseOrder purchaseOrder, String supplierCode, HttpServletResponse response) {
String fileName = "采购合同.docx"; String fileName = "采购合同.docx";
@ -823,6 +837,48 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
} }
} }
/**
* 导入采购订单供应商合同
* */
@Override
public AjaxResult uploadSingleFile(MultipartFile file,String purchaseOrderCode) {
try {
String loginName = ShiroUtils.getLoginName();
//上传路径
String filePath = RuoYiConfig.getUploadPath();
//上传并返回新文件名称
String fileName = FileUploadUtils.upload(filePath, file);
String url = serverConfig.getUrl() + fileName;
String originalFilename = file.getOriginalFilename();
String fileExt = originalFilename.substring(originalFilename.lastIndexOf(".") + 1);
long fileSize = file.getSize();
if (StringUtils.isEmpty(purchaseOrderCode)){
throw new RuntimeException("采购订单编码为空");
}
PurchaseOrder purchaseOrder = purchaseOrderMapper.selectPurchaseOrderByOrderCode(purchaseOrderCode);
//保存文件信息
SysAttachFile sysAttachFile = new SysAttachFile();
sysAttachFile.setBusinessKey(purchaseOrderCode);
sysAttachFile.setBusinessId(purchaseOrder.getPurchaseOrderId());
sysAttachFile.setName(originalFilename);
sysAttachFile.setExt(fileExt);
sysAttachFile.setPath(fileName);
sysAttachFile.setSize(fileSize);
sysAttachFile.setUrl(url);
sysAttachFile.setCreateBy(loginName);
attachFileService.insertSysAttachFile(sysAttachFile);
AjaxResult ajaxResult = AjaxResult.success(sysAttachFile);
return ajaxResult;
} catch (Exception e) {
return AjaxResult.error(e.getMessage());
}
}
private ProcessInstance startProcessInstance(String applyTitle, String instanceType, PurchaseOrder purchaseOrder, SysUser user) { private ProcessInstance startProcessInstance(String applyTitle, String instanceType, PurchaseOrder purchaseOrder, SysUser user) {
Long materialId = purchaseOrder.getPurchaseOrderId(); Long materialId = purchaseOrder.getPurchaseOrderId();
String businessKey = materialId.toString(); // 实体类 ID,作为流程的业务 key String businessKey = materialId.toString(); // 实体类 ID,作为流程的业务 key

139
ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/purchaseOrder.html

@ -78,7 +78,7 @@
<div class="btn-group-sm" id="toolbar" role="group"> <div class="btn-group-sm" id="toolbar" role="group">
<!-- 导入合同按钮 --> <!-- 导入合同按钮 -->
<a class="btn btn-warning" data-toggle="modal" data-target="#importContractModal"> <a class="btn btn-warning" onclick="importContract()" shiro:hasPermission="purchase:purchaseOrder:importContract">
<i class="fa fa-download"></i> 导入合同 <i class="fa fa-download"></i> 导入合同
</a> </a>
@ -136,30 +136,28 @@
</div> </div>
</div> </div>
<!-- 导入合同模态框 -->
<!-- 导入合同模态框 --> <div class="modal inmodal fade" id="importContractModal" tabindex="-1" aria-labelledby="importContractModalLabel" role="dialog" aria-hidden="true">
<div class="modal inmodal fade" id="importContractModal" tabindex="-1" aria-labelledby="importContractModalLabel" role="dialog" aria-hidden="true"> <div class="modal-dialog">
<div class="modal-dialog"> <div class="modal-content">
<div class="modal-content"> <div class="modal-header">
<div class="modal-header"> <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span> </button>
</button> <h4 class="modal-title">导入合同</h4>
<h4 class="modal-title">导入合同</h4> </div>
</div> <div class="modal-body">
<div class="modal-body"> <div class="file-loading">
<div class="file-loading"> <input id="singleFile" name="file" type="file">
<input id="singleFile" name="file" type="file"> <!-- 添加隐藏的输入框 -->
<!-- 添加隐藏的输入框 --> <input id="fileIdStr" name="fileIdStr" type="text" hidden>
<input id="fileIdStr" name="fileIdStr" type="text" hidden>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
<button type="button" class="btn btn-primary">保存</button>
</div> </div>
</div> </div>
<div class="modal-footer">
<button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
</div>
</div> </div>
</div> </div>
</div>
<th:block th:include="include :: footer" /> <th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js"/> <th:block th:include="include :: datetimepicker-js"/>
@ -382,68 +380,87 @@
$(document).ready(function() { // 将选中的行数据存储到全局变量
// 获取导入合同按钮 var globalSelectedRow = null;
var importContractButton = $('#importContractButton');
// 添加点击事件处理器
importContractButton.on('click', function(event) {
// 阻止默认行为
event.preventDefault();
// 执行校验逻辑 // 导入合同
if (checkConditions()) { function importContract(){
// 如果校验通过,则显示模态框 // 获取选中的行
$('#importContractModal').modal('show'); const selectedRows = $("#bootstrap-table").bootstrapTable('getSelections');
} else {
// 如果校验失败,则显示提示信息
alert('您不具备导入合同的权限!');
}
});
// 定义校验逻辑函数 if (selectedRows.length !== 1) {
function checkConditions() { showWarning("请先选择一条采购订单");
// 这里可以根据需要添加校验逻辑 return;
// 例如:检查用户权限、表单状态等 }
// 返回 true 表示校验通过,false 表示校验失败
// 获取选中的行 const row = selectedRows[0];
const selectedRows = $("#bootstrap-table").bootstrapTable('getSelections');
// 定义状态码常量
if (selectedRows.length !== 1) { const AUDIT_STATUS_APPROVED = "1"; // 审核通过
showWarning("请先选择一条采购订单"); const USE_STATUS_DELETED = "2"; // 作废
return;
}
// 检查是否作废
if (row.useStatus === USE_STATUS_DELETED) {
showWarning("该采购订单已作废");
return;
}
// 检查是否审核通过
if (row.auditStatus !== AUDIT_STATUS_APPROVED) {
showWarning("该采购订单未审核通过");
return;
}
return true; // 示例:始终返回 true if (selectedRows.length ===1) {
// $("#purchaseOrderId").val(data[0].purchaseOrderId)
$("#importContractModal").modal("show");
// 存储选中的行数据
globalSelectedRow = row;
} }
});
}
//导入合同 //导入合同
$(document).ready(function () { $(document).ready(function () {
// 单图上传 // 单图上传
$("#singleFile").fileinput({ $("#singleFile").fileinput({
uploadUrl: ctx + "common/uploadSingleFile", uploadUrl: prefix + "/uploadSingleFile",
language: 'zh', //设置语言 language: 'zh', // 设置语言
dropZoneEnabled: true, //是否显示拖拽区域 dropZoneEnabled: true, // 是否显示拖拽区域
maxFileSize: 20480, //上传文件最大值,单位kb maxFileSize: 20480, // 上传文件最大值,单位kb
allowedFileExtensions: ['jpg', 'png', 'gif', 'jpeg'], //指定上传文件类型 allowedFileExtensions: ['jpg', 'png', 'gif', 'jpeg'], // 指定上传文件类型
maxFileCount: 1, maxFileCount: 1,
initialPreviewAsData: true, initialPreviewAsData: true,
uploadExtraData: { uploadExtraData: function() {
img_key: "1000", // 返回额外的数据
img_keywords: "happy, nature", return {
img_key: "1000",
img_keywords: "happy, nature",
purchaseOrderCode: globalSelectedRow.purchaseOrderCode
};
} }
}).on('fileuploaded', function (event, data, previewId, index) { }).on('fileuploaded', function (event, data, previewId, index) {
var response = data.response; var response = data.response;
// var rsp = data.response;
// document.getElementById('attachFileId').value = rsp.attachFileId;
var attachFileId = response.data.id; var attachFileId = response.data.id;
if (response.code === web_status.SUCCESS) { if (response.code === web_status.SUCCESS) {
$('#fileIdStr').val(attachFileId); $('#fileIdStr').val(attachFileId);
$.modal.msgSuccess("上传成功"); $.modal.msgSuccess("上传成功");
// 在这里可以处理上传成功后的操作
var selectedRowData = globalSelectedRow;
// 使用 selectedRowData 进行进一步的操作
console.log(selectedRowData);
// 绑定保存按钮的点击事件
$('#saveImport').on('click', function() {
// 这里可以添加保存逻辑
console.log("保存按钮被点击");
console.log("选中行的数据:", selectedRowData);
console.log("附件ID:", attachFileId);
});
} else { } else {
$.modal.alertError(response.msg); $.modal.alertError(response.msg);
} }

Loading…
Cancel
Save