收入明细表保存流程基本,下一步进行动态添加
parent
378ef3e760
commit
96fe2a4779
|
@ -148,6 +148,9 @@ public class ProjectController extends BaseController{
|
|||
model.put("project", project);
|
||||
BudgetBean budgetBean = projectBudgetService.getBudget(project);
|
||||
model.put("budgetBean", budgetBean);
|
||||
model.put("incomeDetails", projectBudgetService.getBudgetIncomeDetail(project));
|
||||
model.put("costDetails", projectBudgetService.getBudgetCostDetail(project));
|
||||
model.put("costProjectManageDetails", projectBudgetService.getBudgetCostProjectManageDetail(project));
|
||||
return "admin/project_budget_edit";
|
||||
}
|
||||
|
||||
|
|
|
@ -114,6 +114,7 @@ public class ProjectBudgetIncomeDetail {
|
|||
}
|
||||
|
||||
//不含税总金额=含税总金额/(1+税率)
|
||||
return totalTaxInclude.divide(taxRate.divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP), 2, BigDecimal.ROUND_HALF_UP);
|
||||
BigDecimal bigDecimal = taxRate.divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP).add(new BigDecimal(1));
|
||||
return totalTaxInclude.divide(bigDecimal, 2, BigDecimal.ROUND_HALF_UP);
|
||||
}
|
||||
}
|
|
@ -223,6 +223,13 @@ public class ProjectBudgetService {
|
|||
projectBudgetIncomeDetailRepository.save(detailList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取项目的收入明细
|
||||
*/
|
||||
public List<ProjectBudgetIncomeDetail> getBudgetIncomeDetail(Project project){
|
||||
return projectBudgetIncomeDetailRepository.findAllByProjectIdEquals(project.getId());
|
||||
}
|
||||
/**
|
||||
* 清空项目的成本明细
|
||||
*/
|
||||
|
@ -244,6 +251,13 @@ public class ProjectBudgetService {
|
|||
projectBudgetCostDetailRepository.save(detailList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取项目的成本明细
|
||||
*/
|
||||
public List<ProjectBudgetCostDetail> getBudgetCostDetail(Project project){
|
||||
return projectBudgetCostDetailRepository.findAllByProjectIdEquals(project.getId());
|
||||
}
|
||||
/**
|
||||
* 清空项目的项目管理成本明细
|
||||
*/
|
||||
|
@ -265,4 +279,7 @@ public class ProjectBudgetService {
|
|||
projectBudgetCostProjectManageDetailRepository.save(detailList);
|
||||
}
|
||||
}
|
||||
public List<ProjectBudgetCostProjectManageDetail> getBudgetCostProjectManageDetail(Project project){
|
||||
return projectBudgetCostProjectManageDetailRepository.findAllByProjectIdEquals(project.getId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
/**
|
||||
* 一维数组变二维数组
|
||||
* @param list
|
||||
* @param elementsPerSubArray
|
||||
* @returns {Array}
|
||||
*/
|
||||
function arrayToMatrix(list, elementsPerSubArray) {
|
||||
var matrix = [], i, k;
|
||||
|
||||
for (i = 0, k = -1; i < list.length; i++) {
|
||||
if (i % elementsPerSubArray === 0) {
|
||||
k++;
|
||||
matrix[k] = [];
|
||||
}
|
||||
|
||||
matrix[k].push(list[i]);
|
||||
}
|
||||
|
||||
return matrix;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据映射关系将数组变为对象
|
||||
*/
|
||||
function arr2Object(arr, mapArr) {
|
||||
var obj = {};
|
||||
for (var i = 0; i < mapArr.length; i++) {
|
||||
obj[mapArr[i]]=arr[i];
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* 一个收入详情的字段
|
||||
*/
|
||||
INCOME_DETAIL_ARR=["type","name","unit","amount","price","taxRate"];
|
||||
INCOME_DETAIL_PROP_LENGTH=8;
|
||||
|
||||
function saveIncome(url, data, projectId) {
|
||||
if(Array.isArray(data) && data.length != 0){
|
||||
var arr = arrayToMatrix(data,INCOME_DETAIL_PROP_LENGTH);
|
||||
console.log(arr);
|
||||
var incomeDetails = [];
|
||||
for (var i=0;i<arr.length;i++){
|
||||
incomeDetails.push(arr2Object(arr[i], INCOME_DETAIL_ARR));
|
||||
|
||||
}
|
||||
var da = {
|
||||
"incomeDetails":incomeDetails,
|
||||
"projectId":projectId
|
||||
};
|
||||
$.ajax({
|
||||
url: url,
|
||||
data: JSON.stringify(da),
|
||||
type: "post",
|
||||
dataType: "json",
|
||||
contentType:"application/json",
|
||||
async: false,
|
||||
success: function (d) {
|
||||
console.log(d);
|
||||
//TODO 进行计算
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -2,6 +2,19 @@
|
|||
<#import "../common/defaultLayout.ftl" as defaultLayout>
|
||||
<@defaultLayout.layout>
|
||||
|
||||
|
||||
<style type="text/css">
|
||||
/**让所有的模态对话框都居中*/
|
||||
|
||||
.am-modal.am-modal-prompt.am-modal-active {
|
||||
transform: translate(-50%, -50%) scale(1);
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
margin-left: 0;
|
||||
margin-top: 0!important;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="admin-content">
|
||||
<div class="admin-content-body">
|
||||
<div class="am-cf am-padding">
|
||||
|
@ -393,9 +406,7 @@
|
|||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="am-modal am-modal-prompt" style="width: 1000px;" tabindex="-1" id="my-prompt-income-detail">
|
||||
<div class="am-modal am-modal-prompt" style="width: 1000px;max-height:600px;overflow-y:auto;" tabindex="-1" id="my-prompt-income-detail">
|
||||
<div class="am-modal-dialog">
|
||||
<div class="am-modal-hd">新增销售收入明细表——${project.name}</div>
|
||||
<div class="am-modal-bd">
|
||||
|
@ -411,9 +422,32 @@
|
|||
<td>含税总金额(元)</td>
|
||||
<td>不含税金额(元)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
<#if incomeDetails??>
|
||||
<#list incomeDetails as incomeDetail>
|
||||
<tr>
|
||||
<td>
|
||||
<select data-am-selected class="am-modal-prompt-input">
|
||||
<option value="1" <#if incomeDetail.type == 1>selected</#if>>设备类</option>
|
||||
<option value="2" <#if incomeDetail.type == 2>selected</#if>>工程类</option>
|
||||
<option value="3" <#if incomeDetail.type == 3>selected</#if>>服务类</option>
|
||||
</select>
|
||||
</td>
|
||||
<td><input type="text" class="am-modal-prompt-input" value="${incomeDetail.name!}"></td>
|
||||
<td><input type="text" class="am-modal-prompt-input" value="${incomeDetail.unit!}"></td>
|
||||
<td><input type="text" class="am-modal-prompt-input" value="${incomeDetail.amount!}"></td>
|
||||
<td><input type="text" class="am-modal-prompt-input" value="${incomeDetail.price!}"></td>
|
||||
<td><input type="text" class="am-modal-prompt-input" value="${incomeDetail.taxRate!}"></td>
|
||||
<td><input type="text" class="am-modal-prompt-input" value="${incomeDetail.totalTaxInclude!}" readonly></td>
|
||||
<td><input type="text" class="am-modal-prompt-input" value="${incomeDetail.totalTaxExclude!}" readonly></td>
|
||||
</tr>
|
||||
</#list>
|
||||
</#if>
|
||||
|
||||
|
||||
<#--<tr>
|
||||
<td>
|
||||
<select data-am-selected>
|
||||
<select data-am-selected class="am-modal-prompt-input">
|
||||
<option value="1">设备类</option>
|
||||
<option value="2">工程类</option>
|
||||
<option value="3">服务类</option>
|
||||
|
@ -426,32 +460,13 @@
|
|||
<td><input type="text" class="am-modal-prompt-input"></td>
|
||||
<td><input type="text" class="am-modal-prompt-input" readonly></td>
|
||||
<td><input type="text" class="am-modal-prompt-input" readonly></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<select data-am-selected>
|
||||
<option value="1">设备类</option>
|
||||
<option value="2">工程类</option>
|
||||
<option value="3">服务类</option>
|
||||
</select>
|
||||
</td>
|
||||
<td><input type="text" class="am-modal-prompt-input"></td>
|
||||
<td><input type="text" class="am-modal-prompt-input"></td>
|
||||
<td><input type="text" class="am-modal-prompt-input"></td>
|
||||
<td><input type="text" class="am-modal-prompt-input"></td>
|
||||
<td><input type="text" class="am-modal-prompt-input"></td>
|
||||
<td><input type="text" class="am-modal-prompt-input" readonly></td>
|
||||
<td><input type="text" class="am-modal-prompt-input" readonly></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
</tr>
|
||||
</tr>-->
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="am-modal-footer">
|
||||
<span class="am-modal-btn" data-am-modal-cancel>取消</span>
|
||||
<span class="am-modal-btn" data-am-modal-confirm>提交</span>
|
||||
<span class="am-modal-btn" data-am-modal-confirm>保存</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -485,8 +500,7 @@
|
|||
$('#my-prompt-income-detail').modal({
|
||||
relatedTarget: this,
|
||||
onConfirm: function(e) {
|
||||
console.log(e);
|
||||
alert('你输入的是:' + e.data || '')
|
||||
saveIncome("${base}/project/budgetEditSaveIncomeDetail", e.data, $("#id").val());
|
||||
},
|
||||
onCancel: function(e) {
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue