Commit a3de9b40 by shj

预算属性修改:包括预算名称、预算分配等数据,页面的实现与接口

parent 9bff1093
...@@ -13,4 +13,6 @@ public interface IUserBudgetDao { ...@@ -13,4 +13,6 @@ public interface IUserBudgetDao {
void deleteUserBudget(@Param("userid") Integer userid, @Param("budgetid") Long budgetId); void deleteUserBudget(@Param("userid") Integer userid, @Param("budgetid") Long budgetId);
void updateBudgetName(@Param("budgetid") Long id,@Param("budgetname") String budgetName); void updateBudgetName(@Param("budgetid") Long id,@Param("budgetname") String budgetName);
UserBudget selectBudgetByBudgetid(@Param("budgetid") Long budgetId);
} }
...@@ -14,4 +14,7 @@ ...@@ -14,4 +14,7 @@
<update id="updateBudgetName"> <update id="updateBudgetName">
update user_budget set budgetname=#{budgetname} where budgetid=#{budgetid} update user_budget set budgetname=#{budgetname} where budgetid=#{budgetid}
</update> </update>
<select id="selectBudgetByBudgetid" resultType="beans.UserBudget">
select * from user_budget where budgetid=#{budgetid}
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -259,6 +259,78 @@ public class BudgetHandler { ...@@ -259,6 +259,78 @@ public class BudgetHandler {
return modelAndView; return modelAndView;
} }
@RequestMapping("/Setting/{budgetId}")
public ModelAndView budgetSettingById(@PathVariable("budgetId") Long budgetId, HttpServletRequest request, HttpServletResponse response) {
if (budgetId == null) return new ModelAndView("/");
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("/budgetSetting.jsp");
modelAndView.addObject("budget", retrieveBudget(budgetId.toString()));
Cookie sessionID = CookieUtil.getCookieByName(request.getCookies(), "sessionID");
if (sessionID == null) {
sessionID = new Cookie("sessionID", budgetId.toString());
} else {
sessionID.setValue(budgetId.toString());
}
sessionID.setPath("/");
response.addCookie(sessionID);
UserBudget userBudget=userBudgetService.getBudgetByBudgetid(budgetId);
modelAndView.addObject("name",userBudget.getBudgetname());
return modelAndView;
}
@RequestMapping("/Setting.do")
public void doBudgetSettingById(HttpServletRequest request, HttpServletResponse response) throws IOException {
try {
String sessionID = getSessionID(request.getCookies());
if (sessionID == null) return;
Integer totalBudget = Integer.valueOf(request.getParameter("total"));
String[] items = request.getParameterValues("items");
Budget budget = retrieveBudget(sessionID);
if(budget==null) return ;
budget.getRequirement().setTotal(totalBudget);
if (items != null && items.length != 0) {
for (String item : items) {
Double number = Double.valueOf(request.getParameter(item + "-number"));
if (item.contains("equipment")) {
budget.getRequirement().setEquip(number);
} else if (item.contains("material")) {
budget.getRequirement().setMaterial(number);
} else if (item.contains("test")) {
budget.getRequirement().setTest(number);
} else if (item.contains("power")) {
budget.getRequirement().setPower(number);
} else if (item.contains("travel")) {
budget.getRequirement().setTravel(number);
} else if (item.contains("conference")) {
budget.getRequirement().setConference(number);
} else if (item.contains("international")) {
budget.getRequirement().setInternational(number);
} else if (item.contains("property")) {
budget.getRequirement().setProperty(number);
} else if (item.contains("labour")) {
budget.getRequirement().setLabour(number);
} else if (item.contains("consultation")) {
budget.getRequirement().setConsultation(number);
} else if (item.contains("others")) {
budget.getRequirement().setOthers(number);
}
}
}
serializeBudget(budget, getFilePath(sessionID));
String budgetName = request.getParameter("name");
userBudgetService.changeBudgetName(budget.getId(),budgetName);
} catch (Exception e) {
e.printStackTrace();
}
response.sendRedirect(request.getContextPath()+"/Budget/HistoryPage");
}
@RequestMapping("/Delete/{budgetId}") @RequestMapping("/Delete/{budgetId}")
public void deleteBudgetById(@PathVariable("budgetId") Long budgetId, HttpServletRequest request, HttpServletResponse response) { public void deleteBudgetById(@PathVariable("budgetId") Long budgetId, HttpServletRequest request, HttpServletResponse response) {
if (budgetId == null) return; if (budgetId == null) return;
......
...@@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import service.IDetailService; import service.IDetailService;
import service.IUserBudgetService;
import util.SalaryCalculator; import util.SalaryCalculator;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
...@@ -57,6 +58,8 @@ public class DetailHandler { ...@@ -57,6 +58,8 @@ public class DetailHandler {
@Autowired @Autowired
private IDetailService detailService; private IDetailService detailService;
@Autowired
private IUserBudgetService userBudgetService;
@RequestMapping("/Stats") @RequestMapping("/Stats")
public void getStats(HttpServletRequest request,HttpServletResponse response) public void getStats(HttpServletRequest request,HttpServletResponse response)
{ {
...@@ -75,6 +78,7 @@ public class DetailHandler { ...@@ -75,6 +78,7 @@ public class DetailHandler {
double req_sofar=0.0,sum_sofar=0.0,req,sum; double req_sofar=0.0,sum_sofar=0.0,req,sum;
//设备费 //设备费
JSONObject sub=new JSONObject(); JSONObject sub=new JSONObject();
req=budget.getRequirement().getEquip(); req=budget.getRequirement().getEquip();
...@@ -199,6 +203,9 @@ public class DetailHandler { ...@@ -199,6 +203,9 @@ public class DetailHandler {
object.put("sum",sum_sofar); object.put("sum",sum_sofar);
object.put("diff",budget.getRequirement().getTotal()-sum_sofar); object.put("diff",budget.getRequirement().getTotal()-sum_sofar);
UserBudget userBudget = userBudgetService.getBudgetByBudgetid(Long.valueOf(sessionID));
object.put("name",userBudget.getBudgetname());
writer.write(object.toJSONString()); writer.write(object.toJSONString());
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
......
...@@ -15,4 +15,6 @@ public interface IUserBudgetService { ...@@ -15,4 +15,6 @@ public interface IUserBudgetService {
void deleteUserBudget(Integer userid, Long budgetId); void deleteUserBudget(Integer userid, Long budgetId);
void changeBudgetName(Long id, String budgetName); void changeBudgetName(Long id, String budgetName);
UserBudget getBudgetByBudgetid(Long budgetId);
} }
...@@ -34,4 +34,9 @@ public class UserBudgetService implements IUserBudgetService { ...@@ -34,4 +34,9 @@ public class UserBudgetService implements IUserBudgetService {
public void changeBudgetName(Long id, String budgetName) { public void changeBudgetName(Long id, String budgetName) {
userBudgetDao.updateBudgetName(id,budgetName); userBudgetDao.updateBudgetName(id,budgetName);
} }
@Override
public UserBudget getBudgetByBudgetid(Long budgetId) {
return userBudgetDao.selectBudgetByBudgetid(budgetId);
}
} }
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
<li><a href="${pageContext.request.contextPath}/">创建预算</a></li> <li><a href="${pageContext.request.contextPath}/">创建预算</a></li>
<li><a href="${pageContext.request.contextPath}/Budget/HistoryPage">历史预算</a></li> <li><a href="${pageContext.request.contextPath}/Budget/HistoryPage">历史预算</a></li>
<li><a href="${pageContext.request.contextPath}/Rule/">修改规则</a></li> <li><a href="${pageContext.request.contextPath}/Rule/">修改规则</a></li>
<li><a href="${pageContext.request.contextPath}/Budget/Download">导出最新预算</a></li> <%--<li><a href="${pageContext.request.contextPath}/Budget/Download">导出最新预算</a></li>--%>
<li><a href="${pageContext.request.contextPath}/Test">测试</a></li> <li><a href="${pageContext.request.contextPath}/Test">测试</a></li>
<li><a href="${pageContext.request.contextPath}/usercenter.jsp">用户中心</a></li> <li><a href="${pageContext.request.contextPath}/usercenter.jsp">用户中心</a></li>
<li class="active"><a href="${pageContext.request.contextPath}/Budget/Detail">修改预算</a></li> <li class="active"><a href="${pageContext.request.contextPath}/Budget/Detail">修改预算</a></li>
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
<li class="active"><a href="${pageContext.request.contextPath}/Budget/HistoryPage">历史预算</a></li> <li class="active"><a href="${pageContext.request.contextPath}/Budget/HistoryPage">历史预算</a></li>
<%--<li><a href="${pageContext.request.contextPath}/Budget/Detail">修改预算</a></li>--%> <%--<li><a href="${pageContext.request.contextPath}/Budget/Detail">修改预算</a></li>--%>
<li><a href="${pageContext.request.contextPath}/Rule/">修改规则</a></li> <li><a href="${pageContext.request.contextPath}/Rule/">修改规则</a></li>
<li><a href="${pageContext.request.contextPath}/Budget/Download">导出最新预算</a></li> <%--<li><a href="${pageContext.request.contextPath}/Budget/Download">导出最新预算</a></li>--%>
<li><a href="${pageContext.request.contextPath}/Test">测试</a></li> <li><a href="${pageContext.request.contextPath}/Test">测试</a></li>
<li><a href="${pageContext.request.contextPath}/usercenter.jsp">用户中心</a></li> <li><a href="${pageContext.request.contextPath}/usercenter.jsp">用户中心</a></li>
</ul> </ul>
...@@ -80,9 +80,11 @@ ...@@ -80,9 +80,11 @@
<td>{{budget.date}}</td> <td>{{budget.date}}</td>
<td> <td>
<a v-bind:href="'${pageContext.request.contextPath}/Budget/Detail/'+budget.id"> <a v-bind:href="'${pageContext.request.contextPath}/Budget/Detail/'+budget.id">
<button class="btn btn-success">查看详情</button> <button class="btn btn-info">查看详情</button>
</a>
<a v-bind:href="'${pageContext.request.contextPath}/Budget/Setting/'+budget.id">
<button class="btn btn-success">修改预算属性</button>
</a> </a>
<button class="btn btn-info">修改属性</button>
<a v-bind:href="'${pageContext.request.contextPath}/Budget/Download/csv/'+budget.id"> <a v-bind:href="'${pageContext.request.contextPath}/Budget/Download/csv/'+budget.id">
<button class="btn btn-success">下载费用清单</button> <button class="btn btn-success">下载费用清单</button>
</a> </a>
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
<li><a href="${pageContext.request.contextPath}/Budget/HistoryPage">历史预算</a></li> <li><a href="${pageContext.request.contextPath}/Budget/HistoryPage">历史预算</a></li>
<%--<li><a href="${pageContext.request.contextPath}/Budget/Detail" >修改预算</a></li>--%> <%--<li><a href="${pageContext.request.contextPath}/Budget/Detail" >修改预算</a></li>--%>
<li><a href="${pageContext.request.contextPath}/Rule/">修改规则</a></li> <li><a href="${pageContext.request.contextPath}/Rule/">修改规则</a></li>
<li><a href="${pageContext.request.contextPath}/Budget/Download">导出最新预算</a></li> <%--<li><a href="${pageContext.request.contextPath}/Budget/Download">导出最新预算</a></li>--%>
<li><a href="${pageContext.request.contextPath}/Test">测试</a></li> <li><a href="${pageContext.request.contextPath}/Test">测试</a></li>
<li><a href="${pageContext.request.contextPath}/usercenter.jsp">用户中心</a></li> <li><a href="${pageContext.request.contextPath}/usercenter.jsp">用户中心</a></li>
</ul> </ul>
......
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
<li><a href="${pageContext.request.contextPath}/Budget/HistoryPage">历史预算</a></li> <li><a href="${pageContext.request.contextPath}/Budget/HistoryPage">历史预算</a></li>
<%--<li><a href="${pageContext.request.contextPath}/Budget/Detail" >修改预算</a></li>--%> <%--<li><a href="${pageContext.request.contextPath}/Budget/Detail" >修改预算</a></li>--%>
<li class="active"><a href="${pageContext.request.contextPath}/Rule/">修改规则</a></li> <li class="active"><a href="${pageContext.request.contextPath}/Rule/">修改规则</a></li>
<li><a href="${pageContext.request.contextPath}/Budget/Download">导出最新预算</a></li> <%--<li><a href="${pageContext.request.contextPath}/Budget/Download">导出最新预算</a></li>--%>
<li><a href="${pageContext.request.contextPath}/Test">测试</a></li> <li><a href="${pageContext.request.contextPath}/Test">测试</a></li>
<li><a href="${pageContext.request.contextPath}/usercenter.jsp">用户中心</a></li> <li><a href="${pageContext.request.contextPath}/usercenter.jsp">用户中心</a></li>
</ul> </ul>
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
<li><a href="${pageContext.request.contextPath}/Budget/HistoryPage">历史预算</a></li> <li><a href="${pageContext.request.contextPath}/Budget/HistoryPage">历史预算</a></li>
<%--<li><a href="${pageContext.request.contextPath}/Budget/Detail">修改预算</a></li>--%> <%--<li><a href="${pageContext.request.contextPath}/Budget/Detail">修改预算</a></li>--%>
<li><a href="${pageContext.request.contextPath}/Rule/">修改规则</a></li> <li><a href="${pageContext.request.contextPath}/Rule/">修改规则</a></li>
<li><a href="${pageContext.request.contextPath}/Budget/Download">导出最新预算</a></li> <%--<li><a href="${pageContext.request.contextPath}/Budget/Download">导出最新预算</a></li>--%>
<li><a href="${pageContext.request.contextPath}/Test">测试</a></li> <li><a href="${pageContext.request.contextPath}/Test">测试</a></li>
<li class="active"><a href="${pageContext.request.contextPath}/usercenter.jsp">用户中心</a></li> <li class="active"><a href="${pageContext.request.contextPath}/usercenter.jsp">用户中心</a></li>
</ul> </ul>
......
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