Commit 20041b92 by shj

间接费可以修改

parent 3e339799
......@@ -689,6 +689,34 @@ public class BudgetHandler {
}
@RequestMapping("/Modify/Indirect")
public void modifyIndirect(Integer mode, Indirect indirect, Integer nums, Integer curd, HttpServletRequest request, HttpServletResponse response) throws IOException {
System.out.println("/Modify/Indirect");
if (nums < 0) return;
String sessionID = getSessionID(request.getCookies());
Budget budget = retrieveBudget(sessionID);
if (budget == null) {
response.sendError(444, "budget not exists");
return;
}
Map<Indirect, Integer> items = null;
items = budget.getIndirects();
if (curd.equals(0)) {
items.put(indirect, nums);
} else if (curd.equals(1)) {
items.remove(indirect);
} else {
items.remove(indirect);
items.put(indirect, nums);
}
serializeBudget(budget, getFilePath(sessionID));
}
/**
* 预算修改的善后工作
*
......
......@@ -115,6 +115,16 @@ public class DetailHandler {
object.put("travel",sub);
req_sofar+=req;sum_sofar+=sum;
//燃料动力费
sub=new JSONObject();
req=budget.getRequirement().getPower();
sum=detailService.sumPower(budget.getPowers());
sub.put("req",req);
sub.put("sum",sum);
sub.put("diff",req-sum);
object.put("power",sub);
req_sofar+=req;sum_sofar+=sum;
//国际交流合作费
sub=new JSONObject();
req=budget.getRequirement().getInternational();
......@@ -165,6 +175,26 @@ public class DetailHandler {
object.put("consultation",sub);
req_sofar+=req;sum_sofar+=sum;
//其他费用
sub=new JSONObject();
req=budget.getRequirement().getOthers();
sum=detailService.sumOthers(budget.getOthers());
sub.put("req",req);
sub.put("sum",sum);
sub.put("diff",req-sum);
object.put("others",sub);
req_sofar+=req;sum_sofar+=sum;
//间接费用
sub=new JSONObject();
req=budget.getRequirement().getIndirect();
sum=detailService.sumIndirect(budget.getIndirects());
sub.put("req",req);
sub.put("sum",sum);
sub.put("diff",req-sum);
object.put("indirect",sub);
req_sofar+=req;sum_sofar+=sum;
object.put("req",budget.getRequirement().getTotal());
object.put("sum",sum_sofar);
object.put("diff",budget.getRequirement().getTotal()-sum_sofar);
......
......@@ -23,4 +23,10 @@ public interface IDetailService {
double sumInternational(Map<InternationalCommunication, Integer> internationalCommunications);
double sumTestAndProcess(Map<TestAndProcess, Integer> testAndProcesses);
double sumPower(Map<Power, Integer> powers);
double sumOthers(Map<Others, Integer> others);
double sumIndirect(Map<Indirect, Integer> indirects);
}
......@@ -88,4 +88,31 @@ public class DetailService implements IDetailService {
}
return sum;
}
@Override
public double sumPower(Map<Power, Integer> powers) {
double sum=0.0;
for (Power item : powers.keySet()) {
sum+=(item.computeUnitPrice()*powers.get(item));
}
return sum;
}
@Override
public double sumOthers(Map<Others, Integer> others) {
double sum=0.0;
for (Others item : others.keySet()) {
sum+=(item.computeUnitPrice()*others.get(item));
}
return sum;
}
@Override
public double sumIndirect(Map<Indirect, Integer> indirects) {
double sum=0.0;
for (Indirect item : indirects.keySet()) {
sum+=(item.computeUnitPrice()*indirects.get(item));
}
return sum;
}
}
......@@ -536,14 +536,18 @@
<th>名称</th>
<th>费用</th>
<th>数量</th>
<th>操作</th>
</tr>
</thead>
<tbody id="indirect-body">
<tr v-for="item in items">
<td>{{item.name}}</td>
<td>{{item.price}}</td>
<td><input type="number" v-model="item.price" class="form-control"></td>
<td>{{item.nums}}</td>
<td>
<button class="btn btn-success" @click="update(item)">确认</button>
</td>
</tr>
</tbody>
......@@ -896,15 +900,38 @@
items: []
},
methods: {
update: function (item) {
this.doUpdate(item, 2);
},
del: function (item) {
this.doUpdate(item, 1);
},
add: function (item) {
this.doUpdate(item, 0);
},
showlist: function () {
this.$http.get("${pageContext.request.contextPath}/Budget/Detail/Indirect").then(
function (data) {
this.items = data.body.data;
console.log("indirect-showlist");
updateBudgetPage("indirect")
}, function (error) {
console.log(error)
}
)
},
doUpdate: function (item, curd) {
this.$http.post("${pageContext.request.contextPath}/Budget/Modify/Indirect",
{
name: item.name,
price: item.price,
nums: item.nums,
curd: curd
},
{emulateJSON: true}
).then(function (value) {
this.showlist();
});
}
},
created: function () {
......
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