Browse Source

[fix] 采购管理

修改采购订单列表页面,新增审批相关字段和组件
修改采购订单添加后端接口方法
修改采购订单查询方法,去掉多余字段
修改采购订单列表查询方法
修改采购订单前端各个角色的审批页面
dev
liuxiaoxu 4 months ago
parent
commit
227aedd381
  1. 2
      ruoyi-admin/src/main/java/com/ruoyi/main.java
  2. 6
      ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderController.java
  3. 1
      ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchaseOrderService.java
  4. 71
      ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseOrderServiceImpl.java
  5. 3
      ruoyi-admin/src/main/resources/mapper/purchase/PurchaseOrderMapper.xml
  6. 62
      ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/purchaseOrder.html
  7. 2
      ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/taskCgjlVerify.html
  8. 2
      ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/taskCgzgVerify.html
  9. 2
      ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/taskFzjlVerify.html
  10. 2
      ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/taskModifyApply.html

2
ruoyi-admin/src/main/java/com/ruoyi/main.java

@ -1,7 +1,7 @@
package com.ruoyi;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.manufacture.controller.MaterialRequisitionInfoController;
import java.util.Scanner;

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

@ -168,9 +168,11 @@ public class PurchaseOrderController extends BaseController
purchaseOrder.setAuditStatus("0");
purchaseOrder.setUseStatus("0");
purchaseOrder.setDelFlag("0");
purchaseOrderService.insertPurchaseOrder(purchaseOrder);
purchaseOrderService.addPurchaseOrderPayable(purchaseOrder);
purchaseOrderService.submitApply(purchaseOrder);
// purchaseOrderService.insertPurchaseOrder(purchaseOrder);
// purchaseOrderService.addPurchaseOrderPayable(purchaseOrder);
// 数据校验,确保前端传入数据格式正确
// 执行主表插入操作
return AjaxResult.success(); // 假设toAjax方法处理成功逻辑

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

@ -76,7 +76,6 @@ public interface IPurchaseOrderService
Integer addPurchaseOrderPayable(PurchaseOrder purchaseOrder);
@Transactional(rollbackFor = Exception.class)
ProcessInstance submitApply(PurchaseOrder purchaseOrder);
@Transactional(rollbackFor = Exception.class)

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

@ -1,11 +1,15 @@
package com.ruoyi.purchase.service.impl;
import com.github.pagehelper.Page;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.page.PageDomain;
import com.ruoyi.common.core.page.TableSupport;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.service.ICommonService;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.financial.domain.FinancialAccountsPayable;
import com.ruoyi.financial.service.IFinancialAccountsPayableService;
@ -32,7 +36,9 @@ import com.ruoyi.warehouse.mapper.WarehouseStorageOrderDetailMapper;
import com.ruoyi.warehouse.mapper.WarehouseStorageOrderMapper;
import lombok.extern.slf4j.Slf4j;
import org.activiti.engine.TaskService;
import org.activiti.engine.impl.persistence.entity.TaskEntityImpl;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -128,7 +134,58 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
@Override
public List<PurchaseOrderVo> selectPurchaseOrderList(PurchaseOrder purchaseOrder)
{
return purchaseOrderMapper.selectPurchaseOrderList(purchaseOrder);
PageDomain pageDomain = TableSupport.buildPageRequest();
Integer pageNum = pageDomain.getPageNum();
Integer pageSize = pageDomain.getPageSize();
//PageHelper 仅对第一List分页有效
Page<PurchaseOrderVo> list = (Page<PurchaseOrderVo>) purchaseOrderMapper.selectPurchaseOrderList(purchaseOrder);;
Page<PurchaseOrderVo> returnList = new Page<>();
for(PurchaseOrderVo purchaseOrderVo : list){
SysUser sysUser = userMapper.selectUserByLoginName(purchaseOrderVo.getCreateBy());
if (sysUser != null) {
purchaseOrderVo.setCreateBy(sysUser.getUserName());
}
SysUser sysUser2 = userMapper.selectUserByLoginName(purchaseOrderVo.getApplyUser());
if (sysUser2!=null){
purchaseOrderVo.setApplyUserName(sysUser2.getUserName());
}
String instanceId = purchaseOrderVo.getInstanceId();
// 当前环节
if (StringUtils.isNotBlank(instanceId)) {
List<Task> taskList = taskService.createTaskQuery()
.processInstanceId(instanceId)
// .singleResult();
.list(); // 例如请假会签,会同时拥有多个任务
if (!CollectionUtils.isEmpty(taskList)) {
TaskEntityImpl task = (TaskEntityImpl) taskList.get(0);
String taskId = task.getId();
purchaseOrderVo.setTaskId(taskId);
// 设置待办用户
List<String> todoUserList = todoItemMapper.selectUndealTodoUserList(taskId);
if(!CollectionUtils.isEmpty(taskList)){
purchaseOrderVo.setTodoUserId(String.join(",",todoUserList));
}
if (task.getSuspensionState() == 2) {
purchaseOrderVo.setTaskName("已挂起");
purchaseOrderVo.setSuspendState("2");
} else {
purchaseOrderVo.setTaskName(task.getName());
purchaseOrderVo.setSuspendState("1");
}
} else {
// 已办结或者已撤销
purchaseOrderVo.setTaskName("已结束");
}
} else {
purchaseOrderVo.setTaskName("未启动");
}
returnList.add(purchaseOrderVo);
}
returnList.setTotal(CollectionUtils.isEmpty(list) ? 0 : list.getTotal());
returnList.setPageNum(pageNum);
returnList.setPageSize(pageSize);
return returnList;
}
/**
@ -303,8 +360,6 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
purchaseOrder.setNoRmbSum(materialNoRmbSum);
purchaseOrder.setRmbSum(materialRmbSum);
purchaseOrder.setDelFlag("0");
purchaseOrder.setAuditStatus("1");
purchaseOrder.setUseStatus("1");
purchaseOrder.setEceiptStatus("0");
purchaseOrder.setPaymentStatus("0");
purchaseOrder.setPurchaseBuyer(purchaseOrder.getPurchaseBuyer());
@ -627,7 +682,15 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
private void buildAuthority(SysUser user, Map<String, Object> variables) {
Set<String> roleKeys = roleService.selectRoleKeys(user.getUserId());
// 角色不同审核人不同
if(roleKeys.contains("cgyRole")){
variables.put("authority",1);
}else if(roleKeys.contains("cgjlRole")){
variables.put("authority",2);
}else if(roleKeys.contains("cgzgRole")){
variables.put("authority",3);
}else if(roleKeys.contains("fzjlRole")){
variables.put("authority",4);
}
}
}

3
ruoyi-admin/src/main/resources/mapper/purchase/PurchaseOrderMapper.xml

@ -71,7 +71,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
close_case_no, close_case_name, close_case_time,confirm_no,confirm_time,confirm_name,
del_flag, stock_no, stock_name, stock_address, stock_contact, stock_phone,
approve_time, standby_one, standby_two,create_time, create_by, update_time, update_by,
instance_id, instance_type, instance_type_name, submit_instance_id, cancel_instance_id,
instance_id, instance_type, submit_instance_id, cancel_instance_id,
restore_instance_id, apply_title, apply_user, apply_time
from purchase_order
</sql>
@ -171,7 +171,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="applyTitle != null">apply_title,</if>
<if test="applyUser != null">apply_user,</if>
<if test="applyTime != null">apply_time,</if>
<if test="auditUser != null">audit_user,</if>
<if test="delFlag != null" >del_flag,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">

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

@ -134,12 +134,15 @@
<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js"/>
<th:block th:include="include :: select2-js"/>
<script th:src="@{/js/activiti.js}"></script>
<script th:inline="javascript">
var editFlag = [[${@permission.hasPermi('purchase:purchaseOrder:edit')}]];
var auditStatusDatas = [[${@dict.getType('auditStatus')}]];
var useStatusDatas = [[${@dict.getType('useStatus')}]];
var eceiptStatusDatas = [[${@dict.getType('sys_eceipt_status')}]];
var paymentStatusDatas = [[${@dict.getType('sys_pay_close')}]];
var loginName = [[${@permission.getPrincipalProperty('loginName')}]];
var prefix = ctx + "purchase/purchaseOrder";
$(function() {
var options = {
@ -168,6 +171,29 @@
columns: [
{checkbox: true},
{title: '采购订单id',field: 'purchaseOrderId', visible: false},
{title: '流程实例ID',field: 'instanceId',visible: false},
{ title: '流程提交实例ID',field: 'submitInstanceId',visible: false},
{ title:'流程作废实例ID',field: 'cancelInstanceId',visible: false},
{title: '流程恢复实例ID',field: 'restoreInstanceId', visible: false},
{ title: '流程实例类型', field: 'instanceTypeName',visible: false},
{title: '申请人ID',field: 'applyUser', visible: false},
{
field: 'applyUserName',
title: '<span style="color: red;">申请人</span>',
formatter: function(value, row, index) {
return '<span style="color: red;">' + (value ? value : "-") + '</span>';
}
},
{field: 'applyTime',title: '申请时间'
},
{title: '当前任务ID',field: 'taskId',visible: false},
{ title: '待办用户ID',field: 'todoUserId', visible: false},
{ title: '当前任务名称',field: 'taskName',
align: 'center',
formatter: function(value, row, index) {
return '<span class="badge badge-primary">' + value + '</span>';
}
},
{title:'审核状态',field: 'auditStatus',formatter: function (value, row, index) {
return $.table.selectDictLabel(auditStatusDatas, value);
}},
@ -191,9 +217,41 @@
{title: '操作',align: 'center',
formatter: function(value, row, index) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.purchaseOrderId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.purchaseOrderId + '\')"><i class="fa fa-detail"></i>详情</a>')
// actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.purchaseOrderId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
// actions.push('<a class="btn btn-danger btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.purchaseOrderId + '\')"><i class="fa fa-detail"></i>详情</a>')
actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="$.modal.open(\'添加入库通知检验单\',\'' + prefix+"/addPurchaseOrderStorage/"+row.purchaseOrderCode + '\')">入库通知</a> ');
if(row.auditStatus=="1" && row.useStatus=="1" && !row.cancelInstanceId) {
// 作废
actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="$.operate.cancel(\'' + row.purchaseOrderId + '\')"><i class="fa fa-remove"></i> 作废</a>');
// 编辑
actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.purchaseOrderId + '\')"><i class="fa fa-edit"></i> 编辑</a> ');
// 已作废
}else{
actions.push('<a class="btn btn-default btn-xs" href="javascript:void(0)" disabled><i class="fa fa-edit"></i> 编辑</a> ');
}
// 有流程实例id
if(row.useStatus=="2" && !row.restoreInstanceId){
// 恢复
actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="$.operate.restore(\'' + row.purchaseOrderId + '\')"><i class="fa fa-window-restore"></i> 恢复</a> ');
}
// 有流程实例id
if (row.instanceId) {
// 有待办人展示审批按钮,
if (row.todoUserId) {
var todoUserIdList = row.todoUserId.split(",");
if(todoUserIdList.includes(loginName)){
var nodeName = row.taskName=='驳回调整'?' 调整申请':' 审批';
actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="showVerifyDialog(\'' + prefix + '\',\'' + row.taskId + '\', \'' + row.taskName+"-"+ row.instanceTypeName +"申请" + '\')"><i class="fa fa-edit"></i> '+nodeName+'</a> ');
}
}
// 审批历史
actions.push('<a class="btn btn-warning btn-xs" href="javascript:void(0)" onclick="showHistoryDialog(\'' + row.instanceId + '\')"><i class="fa fa-list"></i> 审批历史</a> ');
// 进度查看
actions.push('<a class="btn btn-info btn-xs" href="javascript:void(0)" onclick="showProcessImgDialog(\'' + row.instanceId + '\')"><i class="fa fa-image"></i> 进度查看</a> ');
}
return actions.join('');
}
}

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

@ -8,7 +8,7 @@
<body class="white-bg">
<div id="app" class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-gcjl-edit" th:object="${formData}">
<input name="id" th:field="*{id}" type="hidden">
<input name="purchaseOrderId" th:field="*{purchaseOrderId}" type="hidden">
<input name="taskId" th:field="*{taskId}" type="hidden">
<input name="taskName" th:field="*{taskName}" type="hidden">
<input name="instanceId" th:field="*{instanceId}" type="hidden">

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

@ -8,7 +8,7 @@
<body class="white-bg">
<div id="app" class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-edit" th:object="${formData}">
<input name="id" th:field="*{id}" type="hidden">
<input name="purchaseOrderId" th:field="*{purchaseOrderId}" type="hidden">
<input name="taskId" th:field="*{taskId}" type="hidden">
<input name="taskName" th:field="*{taskName}" type="hidden">
<input name="instanceId" th:field="*{instanceId}" type="hidden">

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

@ -8,7 +8,7 @@
<body class="white-bg">
<div id="app" class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-edit" th:object="${formData}">
<input name="id" th:field="*{id}" type="hidden">
<input name="purchaseOrderId" th:field="*{purchaseOrderId}" type="hidden">
<input name="taskId" th:field="*{taskId}" type="hidden">
<input name="taskName" th:field="*{taskName}" type="hidden">
<input name="instanceId" th:field="*{instanceId}" type="hidden">

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

@ -8,7 +8,7 @@
<body class="white-bg">
<div id="app" class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-edit" th:object="${formData}">
<input name="id" th:field="*{id}" type="hidden">
<input name="purchaseOrderId" th:field="*{purchaseOrderId}" type="hidden">
<input name="taskId" th:field="*{taskId}" type="hidden">
<input name="taskName" th:field="*{taskName}" type="hidden">
<input name="instanceId" th:field="*{instanceId}" type="hidden">

Loading…
Cancel
Save