Browse Source

[feat]基础资料模块:请购单功能,数据传输添加子表数据判空处理。

dev
zhangsiqi 6 months ago
parent
commit
42981e0f60
  1. 49
      ruoyi-admin/src/main/java/com/ruoyi/system/controller/BaseRequisitioningOrderController.java
  2. 7
      ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/BaseRequisitioningOrderServiceImpl.java
  3. 113
      ruoyi-admin/src/main/resources/templates/system/requisitioning/add.html

49
ruoyi-admin/src/main/java/com/ruoyi/system/controller/BaseRequisitioningOrderController.java

@ -1,8 +1,22 @@
package com.ruoyi.system.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.exception.base.BaseException;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.mapper.SysDeptMapper;
import com.ruoyi.system.mapper.SysPostMapper;
import com.ruoyi.system.mapper.SysUserPostMapper;
import com.ruoyi.system.service.IBaseRequisitioningOrderChildService;
import com.ruoyi.system.service.ISysRoleService;
import com.ruoyi.system.service.ISysUserService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@ -14,13 +28,14 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BaseRequisitioningOrder;
import com.ruoyi.system.service.IBaseRequisitioningOrderService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import javax.management.relation.Role;
/**
* 请购单Controller
*
@ -39,6 +54,19 @@ public class BaseRequisitioningOrderController extends BaseController
@Autowired
private IBaseRequisitioningOrderChildService baseRequisitioningOrderChildService;
@Autowired
private ISysUserService sysUserService;
@Autowired
private ISysRoleService sysRoleService;
@Autowired
private SysPostMapper sysPostMapper;
@Autowired
private SysDeptMapper sysDeptMapper;
@RequiresPermissions("system:requisitioning:view")
@GetMapping()
public String requisitioning()
@ -156,5 +184,20 @@ public class BaseRequisitioningOrderController extends BaseController
return toAjax(baseRequisitioningOrderService.restoreBaseRequisitioningOrderById(id));
}
@GetMapping("/getEmpUserName")
@ResponseBody
public Map<String, Object> child(ModelMap mmap) throws Exception{
Map<String, Object> result = new HashMap<>();
SysUser curUser = ShiroUtils.getSysUser();
String loginName = curUser.getLoginName();
Long userId = curUser.getUserId();
List<SysPost> sysPostList = sysPostMapper.selectPostsByUserId(userId);
SysDept dept = sysDeptMapper.selectDeptById(curUser.getDeptId());
String postName = sysPostList.get(0).getPostName();
String deptName = dept.getDeptName();
result.put("userName",loginName);
result.put("deptName",deptName);
result.put("postName",postName);
return result;
}
}

7
ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/BaseRequisitioningOrderServiceImpl.java

@ -94,10 +94,13 @@ public class BaseRequisitioningOrderServiceImpl implements IBaseRequisitioningOr
baseRequisitioningOrder.setUpdateTime(DateUtils.getNowDate());
String requisitioningCode = baseRequisitioningOrder.getRequisitioningCode();
baseRequisitioningOrderChildMapper.deleteBaseRequisitioningOrderChildByQuoteId(baseRequisitioningOrder.getRequisitioningCode());
if (baseRequisitioningOrder.getBaseRequisitioningOrderChildList() != null) {
List<BaseRequisitioningOrderChild> childList = baseRequisitioningOrder.getBaseRequisitioningOrderChildList();
List<BaseRequisitioningOrderChild> childList = baseRequisitioningOrder.getBaseRequisitioningOrderChildList();
int childSize = childList.size();
if (childSize > 0) {
for (BaseRequisitioningOrderChild child: childList) {
child.setQuoteId(requisitioningCode);
child.setCreateBy(loginName);
child.setCreateTime(DateUtils.getNowDate());
child.setUpdateBy(loginName);
child.setUpdateTime(DateUtils.getNowDate());
baseRequisitioningOrderChildMapper.insertBaseRequisitioningOrderChild(child);

113
ruoyi-admin/src/main/resources/templates/system/requisitioning/add.html

@ -2,30 +2,32 @@
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('新增请购单')" />
<th:block th:include="include :: select2-css" />
<th:block th:include="include :: bootstrap-editable-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-requisitioning-add">
<div class="form-group">
<label class="col-sm-3 control-label">部门:</label>
<label class="col-sm-3 control-label is-required">部门:</label>
<div class="col-sm-8">
<select name="dept" class="form-control"></select>
<select name="dept" class="form-control" required></select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">岗位:</label>
<label class="col-sm-3 control-label is-required" >岗位:</label>
<div class="col-sm-8">
<select name="post" class="form-control"></select>
<select name="post" class="form-control" required></select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">姓名:</label>
<label class="col-sm-3 control-label is-required">姓名:</label>
<div class="col-sm-8">
<select name="userName" class="form-control"></select>
<select name="userName" class="form-control" required></select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">关联单号:</label>
<label class="col-sm-3 control-label ">关联单号:</label>
<div class="col-sm-8">
<input name="correlationCode" class="form-control" type="text">
</div>
@ -48,11 +50,14 @@
</div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: select2-js" />
<th:block th:include="include :: bootstrap-table-editable-js" />
<script th:inline="javascript">
var materialTypeDatas = [[${@category.getChildByCode('materialType')}]];
var auditStatusDatas = [[${@dict.getType('auditStatus')}]];
var sysUnitClassDatas = [[${@dict.getType('sys_unit_class')}]];
var processMethodDatas = [[${@dict.getType('processMethod')}]];
var user = [[${user}]];
var prefix = ctx + "system/requisitioning";
$("#form-requisitioning-add").validate({focusCleanup: true});
//获取子表信息
@ -97,9 +102,52 @@
return $.table.selectDictLabel(processMethodDatas, value);
}
},
{title: '物料的数量', field: 'materialNum',align: 'center',editable: true,},
{title: '物料的不含税单价(RMB)',field: 'materialNoRmb',align: 'center',},
{title: '物料的含税单价(RMB)',field: 'materialRmb',align: 'center',},
{title: '物料的数量', field: 'materialNum',align: 'center',
editable : {
type : 'text',
mode:'inline',
title : '物料的数量',
validate : function(value) {
if (!value) {
return '用量不能为空';
}
if (isNaN(value)) {
return '用量必须为数字';
}else if(value < 0){
return "输入数值不能小于0";
}
}
}},
{title: '物料的不含税单价(RMB)',field: 'materialNoRmb',align: 'center',editable : {
type : 'text',
mode:'inline',
title : '不含税单价',
validate : function(value) {
if (!value) {
return '用量不能为空';
}
if (isNaN(value)) {
return '用量必须为数字';
}else if(value < 0){
return "输入数值不能小于0";
}
}
}},
{title: '物料的含税单价(RMB)', field: 'materialRmb', align: 'center',editable : {
type : 'text',
mode:'inline',
title : '含税单价',
validate : function(value) {
if (!value) {
return '用量不能为空';
}
if (isNaN(value)) {
return '用量必须为数字';
}else if(value < 0){
return "输入数值不能小于0";
}
}
}},
{title: '物料的含税总价(RMB)',field: 'materialNoRmbSum',align: 'center',},
{title: '物料的不含税总价(RMB)',field: 'materialRmbSum',align: 'center',},
{title: '录入人',field: 'createBy',align: 'center',visible: false},
@ -115,12 +163,13 @@
}
}
],
onEditableSave:function(field, row, oldValue, $el){
row.materialNoRmbSum = Number(row.materialNum * Number(row.materialNoRmb)).toFixed(2);
row.materialRmbSum = Number(row.materialRmb * row.materialNum).toFixed(2);
},
onEditableSave: function (field, row, oldValue, $el) {
row.materialNoRmbSum = row.materialNum * row.materialNoRmb;
row.materialRmbSum = row.materialNum * row.materialRmb;
}
};
$.table.init(options);
getSelections();
});
function doSubmit(index, layero,uniqueId){
console.log(uniqueId);
@ -139,11 +188,11 @@
unit: rowData.unit,
processMethod: rowData.processMethod,
photoUrl: rowData.photoUrl,
materialNum: "",
materialRmb: "",
materialNoRmb: "",
materialNoRmbSum: "",
materialRmbSum: "",
materialNum: 1,
materialRmb: rowData.materialRmb,
materialNoRmb: rowData.materialNoRmb,
materialNoRmbSum: rowData.materialNoRmbSum,
materialRmbSum: rowData.materialRmbSum,
remark: ""
}
})
@ -167,9 +216,33 @@
}
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/add", $('#form-requisitioning-add').serialize());
var formData = $("#form-requisitionChild-add").serializeArray();
console.log("formData",formData);
var tableData = $("#bootstrap-sub-table-requisitionChild").bootstrapTable('getData');
let rows = tableData.length;
if(rows==0){
$.modal.msgError("子表数据不能为空!");
}else{
formData.push({"name": "baseRequisitioningOrderChildList", "value": tableData});
var jsonData = $.common.formDataToJson(formData);
$.operate.saveJson(prefix + "/add", jsonData);
}
}
}
function getSelections(){
$.ajax({
url: ctx + "system/requisitioning/getEmpUserName",
type: "get",
dataType: "json",
success: function (data) {
console.log(data);
$("select[name='dept']").append($('<option></option>').val(data.deptName).html(data.deptName));
$("select[name='userName']").append($('<option></option>').val(data.userName).html(data.userName));
$("select[name='post']").append($('<option></option>').val(data.postName).html(data.postName));
}
});
}
</script>
</body>
</html>
Loading…
Cancel
Save