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. 87
      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.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
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;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.purchase.domain.PurchaseOrder;
import com.ruoyi.purchase.domain.PurchaseOrderVo;
import com.ruoyi.warehouse.domain.WarehouseStorageOrder;
import org.activiti.engine.runtime.ProcessInstance;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
@ -88,4 +90,9 @@ public interface IPurchaseOrderService
* 导出采购订单供应商合同
* */
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.plugin.table.LoopRowTableRenderPolicy;
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.page.PageDomain;
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.bean.BeanUtils;
import com.ruoyi.common.utils.file.FileDownloadUtils;
import com.ruoyi.common.utils.file.FileUploadUtils;
import com.ruoyi.erp.domain.ErpDevelopModifyorder;
import com.ruoyi.erp.mapper.ErpDevelopModifyorderMapper;
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.PurchasePlanMapper;
import com.ruoyi.purchase.service.IPurchaseOrderService;
import com.ruoyi.system.domain.SysAttachFile;
import com.ruoyi.system.domain.SysCompanyInformation;
import com.ruoyi.system.domain.SysSupplier;
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.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
@ -135,6 +141,11 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
private SysCompanyInformationMapper companyInformationMapper;
@Autowired
private ServerConfig serverConfig;
/**
* 查询采购订单
*
@ -707,6 +718,9 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
return processInstance;
}
/**
* 导出采购订单供应商合同
* */
@Override
public void exportPurchaseOrder(PurchaseOrder purchaseOrder, String supplierCode, HttpServletResponse response) {
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) {
Long materialId = purchaseOrder.getPurchaseOrderId();
String businessKey = materialId.toString(); // 实体类 ID,作为流程的业务 key

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

@ -78,7 +78,7 @@
<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> 导入合同
</a>
@ -136,7 +136,6 @@
</div>
</div>
<!-- 导入合同模态框 -->
<div class="modal inmodal fade" id="importContractModal" tabindex="-1" aria-labelledby="importContractModalLabel" role="dialog" aria-hidden="true">
<div class="modal-dialog">
@ -155,7 +154,6 @@
</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>
@ -382,30 +380,12 @@
$(document).ready(function() {
// 获取导入合同按钮
var importContractButton = $('#importContractButton');
// 将选中的行数据存储到全局变量
var globalSelectedRow = null;
// 添加点击事件处理器
importContractButton.on('click', function(event) {
// 阻止默认行为
event.preventDefault();
// 执行校验逻辑
if (checkConditions()) {
// 如果校验通过,则显示模态框
$('#importContractModal').modal('show');
} else {
// 如果校验失败,则显示提示信息
alert('您不具备导入合同的权限!');
}
});
// 定义校验逻辑函数
function checkConditions() {
// 这里可以根据需要添加校验逻辑
// 例如:检查用户权限、表单状态等
// 返回 true 表示校验通过,false 表示校验失败
// 导入合同
function importContract(){
// 获取选中的行
const selectedRows = $("#bootstrap-table").bootstrapTable('getSelections');
@ -414,36 +394,73 @@
return;
}
const row = selectedRows[0];
// 定义状态码常量
const AUDIT_STATUS_APPROVED = "1"; // 审核通过
const USE_STATUS_DELETED = "2"; // 作废
return true; // 示例:始终返回 true
// 检查是否作废
if (row.useStatus === USE_STATUS_DELETED) {
showWarning("该采购订单已作废");
return;
}
});
// 检查是否审核通过
if (row.auditStatus !== AUDIT_STATUS_APPROVED) {
showWarning("该采购订单未审核通过");
return;
}
if (selectedRows.length ===1) {
// $("#purchaseOrderId").val(data[0].purchaseOrderId)
$("#importContractModal").modal("show");
// 存储选中的行数据
globalSelectedRow = row;
}
}
//导入合同
$(document).ready(function () {
// 单图上传
$("#singleFile").fileinput({
uploadUrl: ctx + "common/uploadSingleFile",
language: 'zh', //设置语言
dropZoneEnabled: true, //是否显示拖拽区域
maxFileSize: 20480, //上传文件最大值,单位kb
allowedFileExtensions: ['jpg', 'png', 'gif', 'jpeg'], //指定上传文件类型
uploadUrl: prefix + "/uploadSingleFile",
language: 'zh', // 设置语言
dropZoneEnabled: true, // 是否显示拖拽区域
maxFileSize: 20480, // 上传文件最大值,单位kb
allowedFileExtensions: ['jpg', 'png', 'gif', 'jpeg'], // 指定上传文件类型
maxFileCount: 1,
initialPreviewAsData: true,
uploadExtraData: {
uploadExtraData: function() {
// 返回额外的数据
return {
img_key: "1000",
img_keywords: "happy, nature",
purchaseOrderCode: globalSelectedRow.purchaseOrderCode
};
}
}).on('fileuploaded', function (event, data, previewId, index) {
var response = data.response;
// var rsp = data.response;
// document.getElementById('attachFileId').value = rsp.attachFileId;
var attachFileId = response.data.id;
if (response.code === web_status.SUCCESS) {
$('#fileIdStr').val(attachFileId);
$.modal.msgSuccess("上传成功");
// 在这里可以处理上传成功后的操作
var selectedRowData = globalSelectedRow;
// 使用 selectedRowData 进行进一步的操作
console.log(selectedRowData);
// 绑定保存按钮的点击事件
$('#saveImport').on('click', function() {
// 这里可以添加保存逻辑
console.log("保存按钮被点击");
console.log("选中行的数据:", selectedRowData);
console.log("附件ID:", attachFileId);
});
} else {
$.modal.alertError(response.msg);
}

Loading…
Cancel
Save