Commit 260f4ee1 authored by 赵汉亭's avatar 赵汉亭

成本中心完成

parent 86c67565
$(document).ready(function () {
initializateUI();
// loadProcessListGrid();
// bindQueryEvent();
bindEvent();
});
function initializateUI() {
UICtrl.layout("#layout", {leftWidth: 3});
}
function bindQueryEvent() {
$('#productName').searchbox({
type: "product", name: "productCode",
onChange: function (value, data) {
$('#id').val(data.productId);
$('#productName').val(data.productName);
}
});
}
function bindEvent() {
$("#save").click(function () {
saveData("save");
})
$("#submit").click(function () {
saveData("submit");
})
$("#close").click(function () {//关闭
closeDispatchTabItem();
})
}
function getCostCenterDetail(CostCenterAction) {
//采购订单保存时数据不进行必填验证,提交时数据才进行必填验证
var op = {};
var check = true;
if (CostCenterAction == "save") {
check = false;
}
op = {check: check};
var costCenter = $('#submitForm').formToJSON(op);
if (!costCenter) {
return false;
}
return costCenter;
}
function saveData(action) {
debugger
var CostCenterDetail = getCostCenterDetail("submit");
if (!CostCenterDetail) {
return;
}
Public.ajax(web_app.name + '/sapCostCenter/saveCostCenter.ajax?code=' + action,CostCenterDetail,
function (data) {
setId(data.id);
Public.successTip("数据保存成功");
// processGridManager.setParm('id', data.id);
// processGridManager.loadData();
}
);
}
function closeDispatchTabItem() {
UICtrl.closeCurrentTab();
}
function setId(value) {
$('#id').val(value);
}
function getId() {
return $("#id").val();
}
<%--
Created by IntelliJ IDEA.
User: lenovo
Date: 2023/12/13
Time: 16:39
To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=utf-8" %>
<%@taglib uri="/WEB-INF/taglib.tld" prefix="x" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<x:base include="layout,dialog,grid,tree,combox,commonTree,date"/>
<x:script src='/biz/topsun/sap/costCenter/sapCostCenterDetail.js'/>
</head>
<body>
<%--<div class="container-fluid">--%>
<x:billTitle title="成本中心" needStatus="false" needPerson="true"/>
<div class="blank_div clearfix"></div>
<button class="btn btn-default" type="button" id="close" style="left: 200px;float:right;bottom: 10px;">关闭</button>
<button class="btn btn-warning" type="button" id="submit" style="left: 200px;float:right;bottom: 10px;">提交</button>
<button class="btn btn-success" type="button" id="save" style="left: 200px;float:right;bottom: 10px;">保存</button>
<form class="hg-form" method="post" action="" id="submitForm">
<x:hidden name="id"/>
<div class="hg-form-row">
<x:inputC name="KOSTL" required="true" label="成本中心编码" labelCol="2" maxLength="64" fieldCol="4"/>
<x:inputC name="KTEXT" required="true" label="名称" labelCol="2" maxLength="64" fieldCol="4"/>
<x:inputC name="LTEXT" required="true" label="描述" labelCol="2" maxLength="64" fieldCol="4"/>
<x:selectC name="KOSAR" required="false" label="成本中心类型" labelCol="2" dictionary="KOSAR" fieldCol="4"/>
<x:inputC name="DATAB" required="true" label="有限期自" labelCol="2" wrapper="date" fieldCol="4" value="2024-01-01"/>
<x:inputC name="DATBI" required="true" label="有限截止日" labelCol="2" wrapper="date" fieldCol="4" value="9999-12-31"/>
<x:inputC name="VERAK" required="true" label="负责人" labelCol="2" maxLength="64" fieldCol="4"/>
<x:selectC name="PRCTR" required="true" label="利润中心" labelCol="2" dictionary="PRCTR" fieldCol="4"/>
</div>
<div class="blank_div clearfix"></div>
</form>
<%--</div>--%>
</body>
</html>
var gridManager = null;
$(document).ready(function () {
initializateUI();
loadCostCenterListGrid();
});
function initializateUI() {
UICtrl.layout("#layout", {leftWidth: 3});
}
function loadCostCenterListGrid() {
var toolbarOptions = UICtrl.getDefaultToolbarOptions({
addHandler: function () {
addHandler();
},
updateHandler: function () {
updateHandler();
},
deleteHandler: deleteHandler,
});
gridManager = UICtrl.grid("#sapCostCenterListGrid", {
columns: [
{display: "成本中心编码", name: "kostl", width: 120, minWidth: 60, type: "string", align: "left"},
{display: "名称", name: "ktext", width: 140, minWidth: 60, type: "string", align: "left"},
{display: "描述", name: "ltext", width: 140, minWidth: 60, type: "string", align: "left"},
{display: "成本中心类型", name: "kosarTextView", width: 140, minWidth: 60, type: "string", align: "left"},
{display: "有限期自", name: "datab", width: 120, minWidth: 60, type: "string", align: "left"},
{display: "有限截止日", name: "datbi", width: 120, minWidth: 60, type: "string", align: "left"},
{display: "负责人", name: "verak", width: 100, minWidth: 60, type: "string", align: "left"},
{display: "利润中心", name: "prctrTextView", width: 140, minWidth: 60, type: "string", align: "left"},
],
dataAction: "server",
url: web_app.name + '/sapCostCenter/slicedCostCenterList.ajax',
pageSize: 20,
usePager: true,
toolbar: toolbarOptions,
width: "100%",
height: "100%",
heightDiff: -8,
checkbox: true,
fixedCellHeight: true,
selectRowButtonOnly: true,
// 双击执行
onDblClickRow: function (data, rowindex, rowobj) {
updateHandler(data);
}
});
UICtrl.setSearchAreaToggle(gridManager);
}
function query(obj) {
var param = $(obj).formToJSON();
UICtrl.gridSearch(gridManager, param);
}
function reloadGrid() {
gridManager.loadData();
}
function resetForm(obj) {
$(obj).formClean();
}
function addHandler() {
UICtrl.addTabItem({
tabid: 'sapCostCenterDetail',
text: "新增成本中心",
url: web_app.name + '/sapCostCenter/addCostCenterDetail.do'
})
}
function updateHandler(row) {
if (!row) {
row = DataUtil.getUpdateRow(gridManager);
if (!row) {
return;
}
}
UICtrl.addTabItem({
tabid: 'CostCenterDetail',
text: "修改成本中心",
url: web_app.name + '/sapCostCenter/showCostCenterDetail.do?id='+row.id
})
}
//删除按钮
function deleteHandler() {
DataUtil.del({
action: 'sapCostCenter/deleteCostCenterById.ajax',
gridManager: gridManager, idFieldName: 'id',
onSuccess: function () {
reloadGrid();
}
});
}
<%--
Created by IntelliJ IDEA.
User: lenovo
Date: 2023/12/13
Time: 15:51
To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@taglib uri="/WEB-INF/taglib.tld" prefix="x"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
<x:base include="layout,dialog,grid,tree,combox,commonTree" />
<x:script src='/biz/topsun/sap/costCenter/sapCostCenterList.js'/>
</head>
<body>
<div class="container-fluid">
<div class="ui-hide">
<%-- <x:select name="processType" dictionary="processType" />--%>
<%-- <x:select name="yesorno" dictionary="yesorno" />--%>
</div>
<div id="layout">
<div position="center" title="成本中心">
<x:title title="common.button.search" hideTable="queryMainForm" isHide="true" />
<form class="hg-form ui-hide" method="post" action="" id="queryMainForm">
<x:inputC name="ruleKind" required="false" label="成本中心名称" labelCol="1"/>
<x:searchButtons />
</form>
<div class="blank_div clearfix"></div>
<div id="sapCostCenterListGrid" style="margin: 2px;"></div>
</div>
</div>
</div>
</body>
</html>
\ No newline at end of file
package com.huigou.topsun.sap.costCenter.application; package com.huigou.topsun.sap.costCenter.application;
import com.huigou.topsun.sap.costCenter.domain.CostCenter;
import com.huigou.topsun.sap.costCenter.domain.query.CostCenterQueryRequest;
import com.huigou.topsun.sap.costCenter.domain.vo.CostCenterVo;
import java.util.List;
import java.util.Map;
/** /**
* @Auther: xin.lu * @Auther: xin.lu
* @Date: 2023/12/13/11:09 * @Date: 2023/12/13/11:09
* @Description: * @Description:
*/ */
public interface CostCenterApplication { public interface CostCenterApplication {
public static final String QUERY_XML_FILE_PATH = "config/topsun/sap/costCenter/costCenter.xml";
Map<String,Object> getCostCenterList(CostCenterQueryRequest costCenterQueryRequest);
CostCenterVo findCostCenterById(String id);
void deleteCostCenterById(List<String> ids);
void updateCostCenter(CostCenter costCenter);
void saveCostCenter(CostCenter costCenter);
CostCenterVo saveAndUpdate(CostCenter costCenter);
} }
package com.huigou.topsun.sap.costCenter.application.impl; package com.huigou.topsun.sap.costCenter.application.impl;
import com.huigou.cache.DictUtil;
import com.huigou.data.query.model.QueryDescriptor;
import com.huigou.data.query.model.QueryModel;
import com.huigou.topsun.sap.costCenter.application.CostCenterApplication; import com.huigou.topsun.sap.costCenter.application.CostCenterApplication;
import com.huigou.topsun.sap.costCenter.domain.CostCenter;
import com.huigou.topsun.sap.costCenter.domain.query.CostCenterQueryRequest;
import com.huigou.topsun.sap.costCenter.domain.vo.CostCenterVo;
import com.huigou.topsun.sap.costCenter.repository.CostCenterRepository;
import com.huigou.uasp.bmp.common.application.BaseApplication; import com.huigou.uasp.bmp.common.application.BaseApplication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/** /**
* @Auther: xin.lu * @Auther: xin.lu
* @Date: 2023/12/13/11:09 * @Date: 2023/12/13/11:09
* @Description: * @Description:
*/ */
@Service
public class CostCenterApplicationImpl extends BaseApplication implements CostCenterApplication { public class CostCenterApplicationImpl extends BaseApplication implements CostCenterApplication {
@Autowired
private CostCenterRepository costCenterRepository;
@Override
public Map<String, Object> getCostCenterList(CostCenterQueryRequest costCenterQueryRequest) {
QueryDescriptor queryDescriptor = this.sqlExecutorDao.getQuery(QUERY_XML_FILE_PATH, "costCenter");
QueryModel queryModel = this.sqlExecutorDao.getQueryModel(queryDescriptor, costCenterQueryRequest);
queryModel.putDictionary("KOSAR", DictUtil.getDictionary("KOSAR"));
queryModel.putDictionary("PRCTR", DictUtil.getDictionary("PRCTR"));
Map<String, Object> map = this.sqlExecutorDao.executeSlicedQuery(queryModel);
return map;
}
@Override
public CostCenterVo findCostCenterById(String id) {
CostCenter costCenter = costCenterRepository.findOne(id);
return CostCenterVo.getCostCenterVo(costCenter);
}
@Override
public void deleteCostCenterById(List<String> ids) {
for (String id : ids) {
costCenterRepository.delete(id);
}
}
@Override
public void updateCostCenter(CostCenter costCenter) {
costCenterRepository.saveAndFlush(costCenter);
}
@Override
public void saveCostCenter(CostCenter costCenter) {
}
@Override
public CostCenterVo saveAndUpdate(CostCenter costCenter) {
return CostCenterVo.getCostCenterVo(costCenterRepository.saveAndFlush(costCenter));
}
} }
package com.huigou.topsun.sap.costCenter.controller; package com.huigou.topsun.sap.costCenter.controller;
import com.huigou.topsun.sap.costCenter.application.CostCenterApplication;
import com.huigou.topsun.sap.costCenter.domain.CostCenter;
import com.huigou.topsun.sap.costCenter.domain.query.CostCenterQueryRequest;
import com.huigou.topsun.sap.costCenter.domain.vo.CostCenterVo;
import com.huigou.uasp.annotation.ControllerMapping; import com.huigou.uasp.annotation.ControllerMapping;
import com.huigou.uasp.client.CommonController; import com.huigou.uasp.client.CommonController;
import com.huigou.util.SDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import java.util.List;
/** /**
* @Auther: xin.lu * @Auther: xin.lu
* @Date: 2023/12/13/11:36 * @Date: 2023/12/13/11:36
...@@ -13,17 +21,81 @@ import org.springframework.stereotype.Controller; ...@@ -13,17 +21,81 @@ import org.springframework.stereotype.Controller;
@ControllerMapping("/sapCostCenter") @ControllerMapping("/sapCostCenter")
public class CostCenterController extends CommonController { public class CostCenterController extends CommonController {
@Autowired
private CostCenterApplication costCenterApplication;
@Override @Override
protected String getPagePath(){ protected String getPagePath() {
return "/biz/topsun/sap/costCenter"; return "/biz/topsun/sap/costCenter/";
} }
/** /**
* 跳转到成本中心查询列表 * 跳转到成本中心查询列表
*
* @return * @return
*/ */
public String forwardSapCostCenterList(){ public String forwardSapCostCenterList() {
return forward("sapCostCenterList"); return forward("sapCostCenterList");
} }
public String slicedCostCenterList() {
SDO sdo = this.getSDO();
CostCenterQueryRequest costCenterQueryRequest = sdo.toQueryRequest(CostCenterQueryRequest.class);
return toResult(costCenterApplication.getCostCenterList(costCenterQueryRequest));
}
/**
* 跳转到新增页面
*/
public String addCostCenterDetail() {
return forward("sapCostCenterDetail");
}
/**
* 根据id获取成本中心信息
*
* @return
*/
public String showCostCenterDetail() {
SDO sdo = this.getSDO();
String id = sdo.getString("id");
CostCenterVo costCenterVo = costCenterApplication.findCostCenterById(id);
return forward("sapCostCenterDetail", costCenterVo);
}
/**
* 根据id删除成本中心
*
* @return
*/
public String deleteCostCenterById() {
SDO sdo = this.getSDO();
List<String> ids = sdo.getIds();
costCenterApplication.deleteCostCenterById(ids);
return success();
}
/**
* 保存/修改 成本中心
*
* @return
*/
public String saveCostCenter() {
SDO sdo = this.getSDO();
CostCenterVo costCenterVo = sdo.toObject(CostCenterVo.class);
CostCenter costCenter = CostCenterVo.getCostCenter(costCenterVo);
// if (StringUtil.isNotBlank(costCenter.getId()))
// costCenterApplication.updateCostCenter(costCenter);
// else
// costCenterApplication.saveCostCenter(costCenter);
// return "";
costCenterVo = costCenterApplication.saveAndUpdate(costCenter);
return success(costCenterVo);
}
} }
package com.huigou.topsun.sap.costCenter.domain; package com.huigou.topsun.sap.costCenter.domain;
import com.baomidou.mybatisplus.annotation.TableName;
import com.huigou.data.domain.model.AbstractEntity; import com.huigou.data.domain.model.AbstractEntity;
import com.topsunit.query.annotations.Dictionary; import com.topsunit.query.annotations.Dictionary;
import lombok.Data; import lombok.Data;
import javax.persistence.Column; import javax.persistence.*;
import javax.persistence.Entity;
import java.util.Date; import java.util.Date;
/** /**
...@@ -14,10 +12,19 @@ import java.util.Date; ...@@ -14,10 +12,19 @@ import java.util.Date;
* @Date: 2023/12/13/10:42 * @Date: 2023/12/13/10:42
* @Description: * @Description:
*/ */
@TableName("cost_center") @Table(name="cost_center")
@Entity @Entity
@Data @Data
public class CostCenter extends AbstractEntity { public class CostCenter extends AbstractEntity {
/**
* id
*/
// @Id
// @GeneratedValue(generator = "system-uuid")
// @GenericGenerator(name = "system-uuid", strategy = "guid")
// @Column(name = "id")
// private String id;
/** /**
* 成本中心编码 * 成本中心编码
...@@ -57,11 +64,11 @@ public class CostCenter extends AbstractEntity { ...@@ -57,11 +64,11 @@ public class CostCenter extends AbstractEntity {
/** /**
* 成本中心类型 * 成本中心类型
* 管理类 L * 管理类 L
* 销售类 V * 销售类 V
* 研发类 E * 研发类 E
* 间接生产类 G * 间接生产类 G
* 直接生产类 F * 直接生产类 F
*/ */
@Column(name = "KOSAR") @Column(name = "KOSAR")
@Dictionary("KOSAR") @Dictionary("KOSAR")
......
package com.huigou.topsun.sap.costCenter.domain.query;
import com.huigou.data.domain.query.QueryAbstractRequest;
import lombok.Data;
import java.util.Date;
/**
* title:
* author:ZHT
* date:2023/12/14
* description:
*/
@Data
public class CostCenterQueryRequest extends QueryAbstractRequest {
/**
* id
*/
private String id;
/**
* 成本中心编码
*/
private String KOSTL;
/**
* 有效期自 默认当年1月1日
*/
private Date DATAB;
/**
* 有效截至日 默认9999.12.31
*/
private Date DATBI;
/**
* 名称
*/
private String KTEXT;
/**
* 描述
*/
private String LTEXT;
/**
* 负责人
*/
private String VERAK;
/**
* 成本中心类型
* 管理类 L
* 销售类 V
* 研发类 E
* 间接生产类 G
* 直接生产类 F
*/
private String KOSAR;
/**
* 利润中心
* 10001000 广州宝绅科技利润中心
* 10001001 广州宝绅RFID利润中心
*/
private String PRCTR;
}
package com.huigou.topsun.sap.costCenter.domain.vo;
import com.alibaba.fastjson.JSON;
import com.huigou.topsun.sap.costCenter.domain.CostCenter;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* title:
* author:ZHT
* date:2023/12/14
* description:
*/
@Data
public class CostCenterVo implements Serializable {
/**
* id
*/
private String id;
/**
* 成本中心编码
*/
private String KOSTL;
/**
* 有效期自 默认当年1月1日
*/
private Date DATAB;
/**
* 有效截至日 默认9999.12.31
*/
private Date DATBI;
/**
* 名称
*/
private String KTEXT;
/**
* 描述
*/
private String LTEXT;
/**
* 负责人
*/
private String VERAK;
/**
* 成本中心类型
* 管理类 L
* 销售类 V
* 研发类 E
* 间接生产类 G
* 直接生产类 F
*/
private String KOSAR;
/**
* 利润中心
* 10001000 广州宝绅科技利润中心
* 10001001 广州宝绅RFID利润中心
*/
private String PRCTR;
//创建原因 CHAR 100 手工输入
public static CostCenterVo getCostCenterVo(CostCenter costCenter) {
return JSON.parseObject(JSON.toJSONString(costCenter), CostCenterVo.class);
}
public static CostCenter getCostCenter(CostCenterVo costCenterVo) {
return JSON.parseObject(JSON.toJSONString(costCenterVo), CostCenter.class);
}
}
<?xml version="1.0" encoding="UTF-8" ?>
<query-mappings>
<query name="costCenter" label="成本中心表" table="cost_center">
<sql-query>
select t.* from cost_center t
</sql-query>
</query>
</query-mappings>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment