采购类别动态化
parent
135f28fd03
commit
dadcfc4c52
|
@ -12,8 +12,11 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
|||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/procurement/type")
|
||||
|
@ -37,7 +40,7 @@ public class ProcurementTypeController extends BaseController{
|
|||
Map<String, Object> model) {
|
||||
model.put("keywords",keywords);
|
||||
ConcurrentHashMap<String, String> searchInfo = getSearchInfo(keywords,model);
|
||||
model.put("pager",procurementTypeService.list(searchInfo,pageNumber,pageSize));
|
||||
model.put(PAGER,procurementTypeService.list(searchInfo,pageNumber,pageSize));
|
||||
return "/admin/procurement_type_list";
|
||||
}
|
||||
|
||||
|
@ -134,4 +137,20 @@ public class ProcurementTypeController extends BaseController{
|
|||
ExportUtils.exportToExcel(headers, exportColumns, 1, 10000,
|
||||
httpServletResponse.getOutputStream(), (pN, pS) -> procurementTypeService.list(searchInfo, pN, pS).getList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 类型和类别的映射关系
|
||||
*/
|
||||
@RequestMapping("/map")
|
||||
@ResponseBody
|
||||
public ResponseMsg map() {
|
||||
List<ProcurementType> procurementTypes = procurementTypeService.allProcurementTypeList();
|
||||
Map<Integer, List<ProcurementType>> map = procurementTypes.stream().collect(Collectors.groupingBy(ProcurementType::getType));
|
||||
|
||||
Map<String, Object> objectMap = new HashMap<>();
|
||||
objectMap.put("procurementTypes", procurementTypes);
|
||||
objectMap.put("map", map);
|
||||
return ResponseMsg.buildSuccessData(objectMap);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -64,6 +64,8 @@ public class ProjectController extends BaseController {
|
|||
private ActTaskDefService actTaskDefService;
|
||||
@Autowired
|
||||
private ProjectSettleService projectSettleService;
|
||||
@Autowired
|
||||
private ProcurementTypeService procurementTypeService;
|
||||
|
||||
/**
|
||||
* 项目列表
|
||||
|
@ -176,6 +178,8 @@ public class ProjectController extends BaseController {
|
|||
model.put("incomeDetails", projectBudgetService.getBudgetIncomeDetail(project));
|
||||
//成本明细
|
||||
model.put("costDetails", projectBudgetService.getBudgetCostDetail(project));
|
||||
//采购类型
|
||||
model.put("procurementTypes", procurementTypeService.allProcurementTypeList());
|
||||
//项目管理成本明细
|
||||
model.put("costProjectManageDetails", projectBudgetService.getBudgetCostProjectManageDetail(project));
|
||||
List<ProjectBudgetPlanDetail> projectBudgetPlanDetails = projectBudgetService.getProjectBudgetPlanDetails(project);
|
||||
|
|
|
@ -12,6 +12,9 @@ import java.util.Date;
|
|||
@Table(name = "procurement_type")
|
||||
public class ProcurementType {
|
||||
|
||||
public static final int ENABLED = 1;
|
||||
public static final int DISABLED = 0;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
|
@ -22,7 +25,7 @@ public class ProcurementType {
|
|||
|
||||
private String name;
|
||||
|
||||
private int category;
|
||||
private int type;
|
||||
|
||||
private int enabled;
|
||||
|
||||
|
@ -52,12 +55,12 @@ public class ProcurementType {
|
|||
this.name = name;
|
||||
}
|
||||
|
||||
public int getCategory() {
|
||||
return category;
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setCategory(int category) {
|
||||
this.category = category;
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int getEnabled() {
|
||||
|
|
|
@ -2,7 +2,8 @@ package cn.palmte.work.model;
|
|||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ProcurementTypeRepository extends JpaRepository<ProcurementType,Integer> {
|
||||
|
||||
|
||||
List<ProcurementType> findAllByEnabledEquals(int enable);
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import top.jfunc.common.db.bean.Page;
|
|||
import top.jfunc.common.db.utils.Pagination;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
|
@ -25,8 +26,8 @@ public class ProcurementTypeService {
|
|||
QueryHelper queryHelper = new QueryHelper("SELECT *","procurement_type");
|
||||
queryHelper.addCondition(searchInfo.containsKey("name"), "name like ?", "%" +
|
||||
searchInfo.get("name") + "%");
|
||||
queryHelper.addCondition(searchInfo.containsKey("category") && !"-1".equals(searchInfo.get("category")),
|
||||
"category=" + searchInfo.get("category"));
|
||||
queryHelper.addCondition(searchInfo.containsKey("type") && !"-1".equals(searchInfo.get("type")),
|
||||
"type=" + searchInfo.get("type"));
|
||||
queryHelper.addCondition(searchInfo.containsKey("enabled") && !"-1".equals(searchInfo.get("enabled")),
|
||||
"enabled=" + searchInfo.get("enabled"));
|
||||
queryHelper.addCondition(searchInfo.containsKey("startTime"), "created_time >= ?", searchInfo.get("startTime") + " 00:00:00");
|
||||
|
@ -44,13 +45,13 @@ public class ProcurementTypeService {
|
|||
if(null == obj){
|
||||
obj = new ProcurementType();
|
||||
obj.setName(procurementType.getName());
|
||||
obj.setCategory(procurementType.getCategory());
|
||||
obj.setType(procurementType.getType());
|
||||
obj.setEnabled(procurementType.getEnabled());
|
||||
obj.setCreatedBy(InterfaceUtil.getAdmin().getRealName());
|
||||
obj.setCreatedTime(new Date());
|
||||
}else {
|
||||
obj.setName(procurementType.getName());
|
||||
obj.setCategory(procurementType.getCategory());
|
||||
obj.setType(procurementType.getType());
|
||||
obj.setEnabled(procurementType.getEnabled());
|
||||
}
|
||||
procurementTypeRepository.saveAndFlush(obj);
|
||||
|
@ -75,10 +76,10 @@ public class ProcurementTypeService {
|
|||
one.setEnabled(status);
|
||||
ProcurementType procurementType = procurementTypeRepository.saveAndFlush(one);
|
||||
|
||||
if(null != procurementType){
|
||||
return true;
|
||||
}
|
||||
return null != procurementType;
|
||||
}
|
||||
|
||||
return false;
|
||||
public List<ProcurementType> allProcurementTypeList(){
|
||||
return procurementTypeRepository.findAllByEnabledEquals(ProcurementType.ENABLED);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,68 @@
|
|||
* 一个采购成本详情的字段
|
||||
*/
|
||||
COST_DETAIL_ARR=["type","category","name","unit","amount","price","taxRate","totalTaxInclude","totalTaxExclude"];
|
||||
/*
|
||||
[
|
||||
{"id":"1","name":"xxx1"},{"id":"2","name":"xxx2"}
|
||||
]
|
||||
*/
|
||||
SELECT_TYPE_CATEGORY_DATA=[];
|
||||
/*{
|
||||
"1":[
|
||||
{
|
||||
"id":"1",
|
||||
"name":"华智产品"
|
||||
},
|
||||
{
|
||||
"id":"2",
|
||||
"name":"紫光其他产品"
|
||||
},
|
||||
{
|
||||
"id":"3",
|
||||
"name":"外购产品"
|
||||
}
|
||||
],
|
||||
"2":[
|
||||
{
|
||||
"id":"4",
|
||||
"name":"外购工程"
|
||||
}
|
||||
],
|
||||
"3":[
|
||||
{
|
||||
"id":"5",
|
||||
"name":"华智服务"
|
||||
},
|
||||
{
|
||||
"id":"6",
|
||||
"name":"紫光其他服务"
|
||||
},
|
||||
{
|
||||
"id":"7",
|
||||
"name":"外购服务"
|
||||
}
|
||||
],
|
||||
"4":[
|
||||
{
|
||||
"id":"8",
|
||||
"name":"其他"
|
||||
}
|
||||
]
|
||||
};*/
|
||||
SELECT_TYPE_CATEGORY_MAP_DATA={};
|
||||
/*{
|
||||
"1":"1",
|
||||
"2":"1",
|
||||
"3":"1",
|
||||
"4":"2",
|
||||
"5":"3",
|
||||
"6":"3",
|
||||
"7":"3",
|
||||
"8":"4"
|
||||
};
|
||||
*/
|
||||
SELECT_CATEGORY_TYPE_MAP_DATA={};
|
||||
|
||||
$(function () {
|
||||
$("#cost-detail").click(function () {
|
||||
$('#my-prompt-cost-detail').modal({
|
||||
|
@ -24,11 +86,20 @@ $(function () {
|
|||
bindOtherOtherChangeable();
|
||||
//绑定采购明细中select联动事件
|
||||
bindTypeSelectChange();
|
||||
|
||||
//初始化大类和类别的数据
|
||||
getAjax(base+"/procurement/type/map", null, initTypeCategory);
|
||||
});
|
||||
/**
|
||||
* 采购成本增加一行
|
||||
*/
|
||||
function appendTrCost() {
|
||||
//console.log(SELECT_TYPE_CATEGORY_DATA);
|
||||
var options = '';
|
||||
SELECT_TYPE_CATEGORY_DATA.forEach(function (e) {
|
||||
options+='<option value="'+e.id+'">'+e.name+'</option>\r\n';
|
||||
});
|
||||
|
||||
var template = '<tr><td><select style="width: auto" class="am-modal-prompt-input am-modal-prompt-input-cost am-modal-prompt-input-cost-type">'+
|
||||
'<option value="1">设备</option>'+
|
||||
'<option value="2">施工</option>'+
|
||||
|
@ -38,14 +109,18 @@ function appendTrCost() {
|
|||
'</td>'+
|
||||
'<td>'+
|
||||
'<select style="width: auto" class="am-modal-prompt-input am-modal-prompt-input-cost am-modal-prompt-input-cost-category">'+
|
||||
'<option value="1">华智产品</option>'+
|
||||
|
||||
/*'<option value="1">华智产品</option>'+
|
||||
'<option value="2">紫光其他产品</option>'+
|
||||
'<option value="3">外购产品</option>'+
|
||||
'<option value="4">外购工程</option>'+
|
||||
'<option value="5">华智服务</option>'+
|
||||
'<option value="6">紫光其他服务</option>'+
|
||||
'<option value="7">外购服务</option>'+
|
||||
'<option value="8">其他</option>'+
|
||||
'<option value="8">其他</option>'+*/
|
||||
|
||||
options+
|
||||
|
||||
'</select>'+
|
||||
'</td>'+
|
||||
'<td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-cost"></td>'+
|
||||
|
@ -57,6 +132,7 @@ function appendTrCost() {
|
|||
'<td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-cost input-changeable-total-tax-exclude" readonly></td>'+
|
||||
'<td><button type="button" class="am-btn am-btn-warning am-btn-xs am-round am-modal-line-delete"><span class="am-icon-minus"></span></button></td>'+
|
||||
'</tr>';
|
||||
|
||||
$("#costTable").append(template);
|
||||
//重新绑定删除事件和input修改事件
|
||||
bindDeleteBtn();
|
||||
|
@ -158,60 +234,6 @@ function bindOtherOtherChangeable() {
|
|||
});
|
||||
}
|
||||
|
||||
SELECT_TYPE_CATEGORY_MAP_DATA={
|
||||
"1":[
|
||||
{
|
||||
"value":"1",
|
||||
"name":"华智产品"
|
||||
},
|
||||
{
|
||||
"value":"2",
|
||||
"name":"紫光其他产品"
|
||||
},
|
||||
{
|
||||
"value":"3",
|
||||
"name":"外购产品"
|
||||
}
|
||||
],
|
||||
"2":[
|
||||
{
|
||||
"value":"4",
|
||||
"name":"外购工程"
|
||||
}
|
||||
],
|
||||
"3":[
|
||||
{
|
||||
"value":"5",
|
||||
"name":"华智服务"
|
||||
},
|
||||
{
|
||||
"value":"6",
|
||||
"name":"紫光其他服务"
|
||||
},
|
||||
{
|
||||
"value":"7",
|
||||
"name":"外购服务"
|
||||
}
|
||||
],
|
||||
"4":[
|
||||
{
|
||||
"value":"8",
|
||||
"name":"其他"
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
SELECT_CATEGORY_TYPE_MAP_DATA={
|
||||
"1":"1",
|
||||
"2":"1",
|
||||
"3":"1",
|
||||
"4":"2",
|
||||
"5":"3",
|
||||
"6":"3",
|
||||
"7":"3",
|
||||
"8":"4"
|
||||
};
|
||||
|
||||
/**
|
||||
* 大类类别联动效果
|
||||
*/
|
||||
|
@ -222,16 +244,58 @@ function bindTypeSelectChange() {
|
|||
var type = $(this).val();
|
||||
//删除后重新添加对应的类别
|
||||
categorySelect.empty();
|
||||
SELECT_TYPE_CATEGORY_MAP_DATA[type].forEach(function (d) {
|
||||
categorySelect.append("<option value='"+d.value+"'>"+d.name+"</option>");
|
||||
})
|
||||
|
||||
//console.log(SELECT_TYPE_CATEGORY_MAP_DATA);
|
||||
|
||||
if(SELECT_TYPE_CATEGORY_MAP_DATA[type]){
|
||||
SELECT_TYPE_CATEGORY_MAP_DATA[type].forEach(function (d) {
|
||||
categorySelect.append("<option value='"+d.id+"'>"+d.name+"</option>");
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
//类别变化联动大类
|
||||
$(".am-modal-prompt-input-cost-category").on('change',function () {
|
||||
var typeSelect = $(this).parent().parent().find(".am-modal-prompt-input-cost-type");
|
||||
var category = $(this).val();
|
||||
//设置他选中类别对应的大类
|
||||
|
||||
//console.log(SELECT_CATEGORY_TYPE_MAP_DATA);
|
||||
|
||||
typeSelect.val(SELECT_CATEGORY_TYPE_MAP_DATA[category]);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 初始化数据
|
||||
* SELECT_TYPE_CATEGORY_MAP_DATA
|
||||
* SELECT_CATEGORY_TYPE_MAP_DATA
|
||||
* SELECT_TYPE_CATEGORY_DATA
|
||||
*/
|
||||
function initTypeCategory(params, data) {
|
||||
var d = data.data;
|
||||
var map = d.map;
|
||||
|
||||
Object.keys(map).forEach(function (t, number) {
|
||||
var temp = [];
|
||||
map[t].forEach(function (g) {
|
||||
temp.push({
|
||||
name:g.name,
|
||||
id:g.id+""
|
||||
});
|
||||
});
|
||||
SELECT_TYPE_CATEGORY_MAP_DATA[t]= temp;
|
||||
});
|
||||
|
||||
var procurementTypes = d.procurementTypes;
|
||||
procurementTypes.forEach(function (e) {
|
||||
SELECT_TYPE_CATEGORY_DATA.push({
|
||||
id:e.id+"",
|
||||
name:e.name
|
||||
});
|
||||
SELECT_CATEGORY_TYPE_MAP_DATA[e.id]=e.type;
|
||||
});
|
||||
|
||||
// console.log(SELECT_TYPE_CATEGORY_MAP_DATA);
|
||||
// console.log(SELECT_TYPE_CATEGORY_DATA);
|
||||
// console.log(SELECT_CATEGORY_TYPE_MAP_DATA);
|
||||
}
|
||||
|
|
|
@ -37,11 +37,11 @@
|
|||
<div class="am-u-sm-4 am-u-md-2 am-text-right">
|
||||
<span style="color: red;">*</span>所属大类</div>
|
||||
<div class="am-u-sm-6 am-u-md-6">
|
||||
<select data-am-selected="{btnWidth: '40%', btnSize: 'sm'" id="category" name="category">
|
||||
<option value="1" <#if procurementType.category! ==1>selected</#if> >设备</option>
|
||||
<option value="2" <#if procurementType.category! ==2>selected</#if> >服务</option>
|
||||
<option value="3" <#if procurementType.category! ==3>selected</#if> >施工</option>
|
||||
<option value="4" <#if procurementType.category! ==4>selected</#if> >其他</option>
|
||||
<select data-am-selected="{btnWidth: '40%', btnSize: 'sm'" id="type" name="type">
|
||||
<option value="1" <#if procurementType.type! ==1>selected</#if> >设备</option>
|
||||
<option value="2" <#if procurementType.type! ==2>selected</#if> >服务</option>
|
||||
<option value="3" <#if procurementType.type! ==3>selected</#if> >施工</option>
|
||||
<option value="4" <#if procurementType.type! ==4>selected</#if> >其他</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="am-u-sm-2 am-u-md-4 input-msg"></div>
|
||||
|
|
|
@ -26,12 +26,12 @@
|
|||
<th class="am-text-middle">所属大类</th>
|
||||
<td>
|
||||
<div class="am-u-sm-10">
|
||||
<select data-am-selected="{btnWidth: '40%', btnSize: 'sm'" id="category">
|
||||
<select data-am-selected="{btnWidth: '40%', btnSize: 'sm'" id="type">
|
||||
<option value="-1">全部</option>
|
||||
<option value="1" <#if category! == "1">selected</#if> >设备</option>
|
||||
<option value="2" <#if category! == "2">selected</#if> >服务</option>
|
||||
<option value="3" <#if category! == "3">selected</#if> >施工</option>
|
||||
<option value="4" <#if category! == "4">selected</#if> >其他</option>
|
||||
<option value="1" <#if type! == "1">selected</#if> >设备</option>
|
||||
<option value="2" <#if type! == "2">selected</#if> >服务</option>
|
||||
<option value="3" <#if type! == "3">selected</#if> >施工</option>
|
||||
<option value="4" <#if type! == "4">selected</#if> >其他</option>
|
||||
</select>
|
||||
</div>
|
||||
</td>
|
||||
|
@ -124,13 +124,13 @@
|
|||
<td><input type="checkbox" name="ids" value="${list.id}"/></td>
|
||||
<td>${list.name!}</td>
|
||||
<td>
|
||||
<#if list.category ==1 >
|
||||
<#if list.type ==1 >
|
||||
设备
|
||||
<#elseif list.category ==2>
|
||||
<#elseif list.type ==2>
|
||||
服务
|
||||
<#elseif list.category ==3>
|
||||
<#elseif list.type ==3>
|
||||
施工
|
||||
<#elseif list.category ==4>
|
||||
<#elseif list.type ==4>
|
||||
其他
|
||||
</#if>
|
||||
|
||||
|
@ -196,8 +196,8 @@
|
|||
var keywordsObj = {};
|
||||
if ($("#name").val())
|
||||
keywordsObj.name = $("#name").val();
|
||||
if ($("#category").val())
|
||||
keywordsObj.category = $("#category").val();
|
||||
if ($("#type").val())
|
||||
keywordsObj.type = $("#type").val();
|
||||
if ($("#enabled").val())
|
||||
keywordsObj.enabled = $("#enabled").val();
|
||||
if ($("#startTime").val())
|
||||
|
@ -259,8 +259,8 @@
|
|||
$("#submit-btn").on("click", function () {
|
||||
if ($("#name").val())
|
||||
keywordsObj.name = $("#name").val();
|
||||
if ($("#category").val())
|
||||
keywordsObj.category = $("#category").val();
|
||||
if ($("#type").val())
|
||||
keywordsObj.type = $("#type").val();
|
||||
if ($("#enabled").val())
|
||||
keywordsObj.enabled = $("#enabled").val();
|
||||
if ($("#startTime").val())
|
||||
|
|
|
@ -495,14 +495,17 @@
|
|||
</td>
|
||||
<td>
|
||||
<select style="width: auto" class="am-modal-prompt-input am-modal-prompt-input-cost am-modal-prompt-input-cost-category">
|
||||
<option value="1" <#if costDetail.category == 1>selected</#if>>华智产品</option>
|
||||
<#--<option value="1" <#if costDetail.category == 1>selected</#if>>华智产品</option>
|
||||
<option value="2" <#if costDetail.category == 2>selected</#if>>紫光其他产品</option>
|
||||
<option value="3" <#if costDetail.category == 3>selected</#if>>外购产品</option>
|
||||
<option value="4" <#if costDetail.category == 4>selected</#if>>外购工程</option>
|
||||
<option value="5" <#if costDetail.category == 5>selected</#if>>华智服务</option>
|
||||
<option value="6" <#if costDetail.category == 6>selected</#if>>紫光其他服务</option>
|
||||
<option value="7" <#if costDetail.category == 7>selected</#if>>外购服务</option>
|
||||
<option value="8" <#if costDetail.category == 8>selected</#if>>其他</option>
|
||||
<option value="8" <#if costDetail.category == 8>selected</#if>>其他</option>-->
|
||||
<#list procurementTypes as procurementType>
|
||||
<option value="${procurementType.id}" <#if costDetail.category == procurementType.id>selected</#if>>${procurementType.name}</option>
|
||||
</#list>
|
||||
</select>
|
||||
</td>
|
||||
<td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-cost" value="${costDetail.name!}"></td>
|
||||
|
|
Loading…
Reference in New Issue