Commit eb1f1ccf by shj

优化导出的费用清单和费用说明

parent d7d1d941
......@@ -6,4 +6,8 @@ import java.util.List;
public interface IPowerDao {
List<Power> selectAll();
void insertPower(Power power);
void deletePower(Power power);
}
......@@ -5,4 +5,10 @@
<select id="selectAll" resultType="beans.Power">
select * from power
</select>
<insert id="insertPower" useGeneratedKeys="true" keyProperty="id">
insert into power(name,price) values (#{name},#{price})
</insert>
<delete id="deletePower">
delete from power where id=#{id}
</delete>
</mapper>
\ No newline at end of file
......@@ -10,14 +10,14 @@
</select>
<insert id="insertTravel">
insert into budgetmanagementsystem.travel(name, price, food, traffic, accommodation)
values (#{dest},#{price},#{food},#{traffic},#{accommodation})
values (#{name},#{price},#{food},#{traffic},#{accommodation})
</insert>
<delete id="deleteTravel">
delete from budgetmanagementsystem.travel where id=#{id}
</delete>
<update id="updateTravel">
update budgetmanagementsystem.travel
set name=#{dest},price=#{price},food=#{food},traffic=#{traffic},accommodation=#{accommodation}
set name=#{name},price=#{price},food=#{food},traffic=#{traffic},accommodation=#{accommodation}
where id=#{id}
</update>
</mapper>
\ No newline at end of file
......@@ -144,13 +144,13 @@ public class BudgetHandler {
return experts;
}
/**
/* *//**
* 下载最新报表
*
* @param request
* @param response
* @param session
*/
*//*
@RequestMapping("/Download")
public void downloadBudgetHandler(HttpServletRequest request, HttpServletResponse response, HttpSession session) {
Cookie[] cookies = request.getCookies();
......@@ -178,7 +178,7 @@ public class BudgetHandler {
} catch (Throwable e) {
e.printStackTrace();
}
}
}*/
......@@ -193,7 +193,8 @@ public class BudgetHandler {
response.setHeader("content-disposition", "attachment;filename=Budget" + sessionID + ".csv");
assert budget != null;
//budgetToOutputStream(budget, writer);
budgetToOutputStream(budget, response.getOutputStream());
//budgetToOutputStream(budget, response.getOutputStream());
BudgetExportUtil.toCsv(budget,response.getOutputStream());
System.out.println("Download...............");
} catch (IOException e) {
e.printStackTrace();
......@@ -607,6 +608,45 @@ public class BudgetHandler {
@Autowired
private IPowerDao powerDao;
@RequestMapping("/Modify/Power")
public void modifyPower(Integer mode, Power power, Integer nums, Integer curd, HttpServletRequest request, HttpServletResponse response) throws IOException {
System.out.println("/Modify/Power");
if (nums < 0) return;
String sessionID = getSessionID(request.getCookies());
Budget budget = retrieveBudget(sessionID);
if (budget == null) {
response.sendError(444, "budget not exists");
return;
}
Map<Power, Integer> items = null;
items = budget.getPowers();
//删除
if (curd.equals(1)) {
items.remove(power);
} else {
if (curd.equals(2))//增改
{
items.remove(power);
items.put(power, nums);
} else if(curd.equals(3))
items.put(power, nums);
else if(curd.equals(0)){
items.put(power,nums);
powerDao.insertPower(power);
}else if(curd.equals(4)){
powerDao.deletePower(power);
}
}
afterUpdate(budget);
serializeBudget(budget, getFilePath(sessionID));
}
@Autowired
private IInternationalCommunicationDao internationalCommunicationDao;
/**
......@@ -860,11 +900,16 @@ public class BudgetHandler {
checkService.checkTravel(travel);
if (curd.equals(0)) {
items.put(travel, nums);
travelDao.insertTravel(travel);
} else if (curd.equals(1)) {
items.remove(travel);
} else {
} else if(curd.equals(2)){
items.remove(travel);
items.put(travel, nums);
}else if(curd.equals(3)){
items.put(travel, nums);
}else if(curd.equals(4)){
travelDao.deleteTravel(travel);
}
afterUpdate(budget);
serializeBudget(budget, getFilePath(sessionID));
......@@ -1023,206 +1068,4 @@ public class BudgetHandler {
}
/**
* 将Budget对象以csv文件的形式写入输出流
*
* @param budget
* @param printWriter
*/
private static void budgetToOutputStream(Budget budget, Writer printWriter) {
BufferedWriter writer = new BufferedWriter(printWriter);
try {
writer.write("设备费,名称,单价,数量,小计");
writer.newLine();
Map<Item, Integer> items = (Map) budget.getEquipments();
char comma = ',';
for (Item item : items.keySet()) {
writer.write(comma + item.getName()
+ comma + item.getPrice()
+ comma + items.get(item)
+ comma + item.computeUnitPrice() * items.get(item));
writer.newLine();
}
writer.newLine();
writer.write("材料费,名称,单价,数量,小计");
writer.newLine();
items = (Map) budget.getMaterials();
for (Item item : items.keySet()) {
writer.write(comma + item.getName()
+ comma + item.getPrice()
+ comma + items.get(item)
+ comma + item.computeUnitPrice() * items.get(item));
writer.newLine();
}
writer.newLine();
writer.write("测试化验加工费,名称,单价,数量,小计");
writer.newLine();
items = (Map) budget.getTestAndProcesses();
for (Item item : items.keySet()) {
writer.write(comma + item.getName()
+ comma + item.getPrice()
+ comma + items.get(item)
+ comma + item.computeUnitPrice() * items.get(item));
writer.newLine();
}
writer.newLine();
writer.write("燃料动力费,名称,单价,数量,小计");
writer.newLine();
items = (Map) budget.getPowers();
for (Item item : items.keySet()) {
writer.write(comma + item.getName()
+ comma + item.getPrice()
+ comma + items.get(item)
+ comma + item.computeUnitPrice() * items.get(item));
writer.newLine();
}
writer.newLine();
writer.write("差旅费,目的地,往返价格,伙食费,交通费,住宿费,人数,天数,次数,小计");
writer.newLine();
Map<Travel, Integer> travels = budget.getTravels();
for (Item item : travels.keySet()) {
if (item instanceof Travel) {
writer.write(comma + ((Travel) item).getName()
+ comma + item.getPrice()
+ comma + ((Travel) item).getFood()
+ comma + ((Travel) item).getTraffic()
+ comma + ((Travel) item).getAccommodation()
+ comma + ((Travel) item).getPeople()
+ comma + ((Travel) item).getDays()
+ comma + travels.get(item)
+ comma + item.computeUnitPrice() * travels.get(item));
writer.newLine();
}
}
writer.newLine();
writer.write("会议费,会议内容,费用标准,参会人数,举办天数,会议次数,小计");
writer.newLine();
Map<Conference, Integer> conferences = budget.getConferences();
for (Item item : conferences.keySet()) {
if (item instanceof Conference) {
writer.write(comma + item.getName()
+ comma + item.getPrice()
+ comma + ((Conference) item).getPeople()
+ comma + ((Conference) item).getDays()
+ comma + conferences.get(item)
+ comma + item.computeUnitPrice() * conferences.get(item));
writer.newLine();
}
}
writer.newLine();
writer.write("国际合作交流费,会议内容,市际交通(往返交通),住宿补贴,伙食补贴,公杂费,人数,天数,次数,小计");
writer.newLine();
Map<InternationalCommunication, Integer> internationalCommunications = budget.getInternationalCommunications();
for (InternationalCommunication item : internationalCommunications.keySet()) {
writer.write(comma + item.getName()
+ comma + item.getPrice()
+ comma + item.getAccommodation()
+ comma + item.getFood()
+ comma + item.getTraffic()
+ comma + item.getPeople()
+ comma + item.getDays()
+ comma + items.get(item)
+ comma + item.computeUnitPrice() * internationalCommunications.get(item));
writer.newLine();
}
writer.newLine();
writer.write("出版/文献/信息传播/知识产权事务费,费用名称,费用标准,数量,小计");
writer.newLine();
items = (Map) budget.getProperties();
for (Item item : items.keySet()) {
if (item instanceof Property) {
writer.write(comma + item.getName()
+ comma + item.getPrice()
+ comma + items.get(item)
+ comma + item.computeUnitPrice() * items.get(item));
writer.newLine();
}
}
writer.newLine();
writer.write("劳务费,费用名称,费用标准,数量,小计(五险一金)");
writer.newLine();
items = (Map) budget.getLabour();
for (Item item : items.keySet()) {
if (item instanceof Labour) {
writer.write(comma + item.getName()
+ comma + item.getPrice()
+ comma + items.get(item)
+ comma + item.computeUnitPrice() * items.get(item));
writer.newLine();
}
}
writer.newLine();
if (budget.getConferences() != null && budget.getConferences().size() > 0 && budget.getConsultations() != null) {
writer.write("咨询费,人员类型,费用标准,人数,小计");
writer.newLine();
Map<Consultation, Integer> consultations = budget.getConsultations();
for (Consultation consultation : consultations.keySet()) {
writer.write(comma + consultation.getName()
+ comma + consultation.getPrice()
+ comma + consultations.get(consultation)
+ comma + consultation.getPrice() * consultations.get(consultation));
writer.newLine();
}
}
writer.newLine();
writer.write("其他费用,费用名称,费用标准,数量,小计");
writer.newLine();
items = (Map) budget.getOthers();
for (Item item : items.keySet()) {
if (item instanceof Others) {
writer.write(comma + item.getName()
+ comma + item.getPrice()
+ comma + items.get(item)
+ comma + item.computeUnitPrice() * items.get(item));
writer.newLine();
}
}
writer.newLine();
writer.write("间接费用,费用名称,费用标准,数量,小计");
writer.newLine();
items = (Map) budget.getIndirects();
for (Item item : items.keySet()) {
if (item instanceof Indirect) {
writer.write(comma + item.getName()
+ comma + item.getPrice()
+ comma + items.get(item)
+ comma + item.computeUnitPrice() * items.get(item));
writer.newLine();
}
}
writer.flush();
System.out.println("CSV");
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* GBK格式,解决csv文件中文乱码
*
* @param budget
* @param outputStream
*/
public static void budgetToOutputStream(Budget budget, OutputStream outputStream) {
System.out.println("GBK");
try {
budgetToOutputStream(budget, new PrintWriter(new OutputStreamWriter(outputStream, "GBK")));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
}
......@@ -103,6 +103,32 @@ public class DatabaseQueryHandler {
}
@Autowired
private IPowerDao powerDao;
@RequestMapping("/Power")
public void queryPower(HttpServletRequest request, HttpServletResponse response){
try {
response.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
PrintWriter writer = response.getWriter();
JSONObject object=new JSONObject();
List<Power> powers = powerDao.selectAll();
List<JSONObject> list=new LinkedList<>();
for (Power item : powers) {
JSONObject obj=new JSONObject();
obj.put("id",item.getId());
obj.put("name",item.getName());
obj.put("price",item.getPrice());
obj.put("nums",0);
list.add(obj);
}
object.put("data",list);
writer.write(JSON.toJSONString(object));
} catch (IOException e) {
e.printStackTrace();
}
}
@Autowired
private ILabourDao labourDao;
@RequestMapping("/Labour")
public void queryLabour(HttpServletRequest request, HttpServletResponse response){
......
......@@ -8,10 +8,7 @@ import service.IDetailService;
import service.impl.BudgetService;
import service.impl.DetailService;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.*;
import java.util.List;
import java.util.Map;
......@@ -154,6 +151,37 @@ public class BudgetExportUtil {
run.addTab();
run.setText("燃料动力费:"+detailService.sumPower(budget.getPowers())+"万元。【具体用途自行填写】");
Map<Power, Integer> powers = budget.getPowers();
i = 0;
for (Power item : powers.keySet()) {
i++;
int num = powers.get(item);
double price = item.getPrice();
paragraph = document.createParagraph();
run = paragraph.createRun();
run.addTab();
StringBuilder line = new StringBuilder();
line.append("(").append(i).append(")");
line.append(item.getName())
.append(num).append("次,每次")
.append(price).append("元,共计")
.append(num * price).append("元");
run.setText(line.toString());
line = new StringBuilder();
line.append("用途:【自行填写】,燃料动力费")
.append(num).append("次,")
.append("单价").append(price).append("元,共需").append(num * price).append("元。");
paragraph = document.createParagraph();
run = paragraph.createRun();
run.addTab();
run.setText(line.toString());
}
//差旅费
paragraph = document.createParagraph();
......@@ -418,6 +446,35 @@ public class BudgetExportUtil {
run.setFontSize(18);
run.setBold(true);
Map<Others, Integer> others = budget.getOthers();
i = 0;
for (Others item : others.keySet()) {
i++;
int num = others.get(item);
double price = item.getPrice();
paragraph = document.createParagraph();
run = paragraph.createRun();
run.addTab();
StringBuilder line = new StringBuilder();
line.append("(").append(i).append(")");
line.append(item.getName())
.append(num).append("次,每次")
.append(price).append("元,共计")
.append(num * price).append("元");
run.setText(line.toString());
line = new StringBuilder();
line.append("用途:【自行填写】,购买")
.append(num).append("服务,")
.append("单价").append(price).append("元,共需").append(num * price).append("元。");
paragraph = document.createParagraph();
run = paragraph.createRun();
run.addTab();
run.setText(line.toString());
}
//间接费用
paragraph = document.createParagraph();
......@@ -442,10 +499,207 @@ public class BudgetExportUtil {
run.addTab();
run.setText("间接费用实行总额控制,在与课题牵头单位信用等级挂钩基础上,按照不超过课题经费中直接费用扣除设备购置费后的一定比例核定,根据最新《北京市科技计划项目(课题)经费管理办法》和间接经费计算方法," +
"本课题扣除设备购置费后 "+detailService.sumEquipment(budget.getEquipments())+" 元," +
"间接经费根据上述管理办法计算为 "+indirectSum+" 元,其中绩效费用约 【自行分配】 万元,用于承担单位人员绩效支出。");
"间接经费根据上述管理办法计算为 "+indirectSum+" 元,其中绩效费用约 "+indirectSum*0.2+" 万元,用于承担单位人员绩效支出。");
document.write(outputStream);
}
public static void toCsv(Budget budget,OutputStream outputStream){
System.out.println("GBK");
try {
toCsv(budget, new PrintWriter(new OutputStreamWriter(outputStream, "GBK")));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
private static void toCsv(Budget budget, PrintWriter printWriter){
BufferedWriter writer = new BufferedWriter(printWriter);
try {
writer.write("设备费,名称,规格型号,产地,数量,计量单位,单价,小计");
writer.newLine();
Map<Item, Integer> items = (Map) budget.getEquipments();
char comma = ',';
for (Item item : items.keySet()) {
writer.write(comma + item.getName()
+ comma + item.getComment()
+ comma + "中国"
+ comma + items.get(item)
+ comma + "台(套)"
+ comma + item.getPrice()
+ comma + item.computeUnitPrice() * items.get(item));
writer.newLine();
}
writer.newLine();
writer.write("材料费,支出内容,单位,单价,数量,用途,小计");
writer.newLine();
items = (Map) budget.getMaterials();
for (Item item : items.keySet()) {
writer.write(comma + item.getName()
+ comma + "套(个)"
+ comma + item.getPrice()
+ comma + items.get(item)
+ comma + item.getComment()
+ comma + item.computeUnitPrice() * items.get(item));
writer.newLine();
}
writer.newLine();
writer.write("测试化验加工费,名称,单价,数量,小计");
writer.newLine();
items = (Map) budget.getTestAndProcesses();
for (Item item : items.keySet()) {
writer.write(comma + item.getName()
+ comma + item.getPrice()
+ comma + items.get(item)
+ comma + item.computeUnitPrice() * items.get(item));
writer.newLine();
}
writer.newLine();
writer.write("燃料动力费,名称,单价,数量,小计");
writer.newLine();
items = (Map) budget.getPowers();
for (Item item : items.keySet()) {
writer.write(comma + item.getName()
+ comma + item.getPrice()
+ comma + items.get(item)
+ comma + item.computeUnitPrice() * items.get(item));
writer.newLine();
}
writer.newLine();
writer.write("差旅费,出差城市,交通方式,往返价格,伙食标准补助,交通标准补助,住宿标准,人数,天数,次数,小计");
writer.newLine();
Map<Travel, Integer> travels = budget.getTravels();
for (Item item : travels.keySet()) {
if (item instanceof Travel) {
writer.write(comma + ((Travel) item).getName()
+ comma + "飞机"
+ comma + item.getPrice()
+ comma + ((Travel) item).getFood()
+ comma + ((Travel) item).getTraffic()
+ comma + ((Travel) item).getAccommodation()
+ comma + ((Travel) item).getPeople()
+ comma + ((Travel) item).getDays()
+ comma + travels.get(item)
+ comma + item.computeUnitPrice() * travels.get(item));
writer.newLine();
}
}
writer.newLine();
writer.write("会议费,会议内容,费用标准,会期,参会人数,会议次数,小计");
writer.newLine();
Map<Conference, Integer> conferences = budget.getConferences();
for (Item item : conferences.keySet()) {
if (item instanceof Conference) {
writer.write(comma + item.getName()
+ comma + item.getPrice()
+ comma + ((Conference) item).getDays()
+ comma + ((Conference) item).getPeople()
+ comma + conferences.get(item)
+ comma + item.computeUnitPrice() * conferences.get(item));
writer.newLine();
}
}
writer.newLine();
writer.write("国际合作交流费,会议内容,市际交通(往返交通),住宿补贴,伙食补贴,公杂费,人数,天数,次数,小计");
writer.newLine();
Map<InternationalCommunication, Integer> internationalCommunications = budget.getInternationalCommunications();
for (InternationalCommunication item : internationalCommunications.keySet()) {
writer.write(comma + item.getName()
+ comma + item.getPrice()
+ comma + item.getAccommodation()
+ comma + item.getFood()
+ comma + item.getTraffic()
+ comma + item.getPeople()
+ comma + item.getDays()
+ comma + internationalCommunications.get(item)
+ comma + item.computeUnitPrice() * internationalCommunications.get(item));
writer.newLine();
}
writer.newLine();
writer.write("出版/文献/信息传播/知识产权事务费,出版/文献/信息传播/知识产权事务费内容,单位,单价,数量,小计");
writer.newLine();
items = (Map) budget.getProperties();
for (Item item : items.keySet()) {
if (item instanceof Property) {
writer.write(comma + item.getName()
+ comma + "篇(个)"
+ comma + item.getPrice()
+ comma + items.get(item)
+ comma + item.computeUnitPrice() * items.get(item));
writer.newLine();
}
}
writer.newLine();
writer.write("劳务费,费用名称,费用标准,数量,小计(五险一金)");
writer.newLine();
items = (Map) budget.getLabour();
for (Item item : items.keySet()) {
if (item instanceof Labour) {
writer.write(comma + item.getName()
+ comma + item.getPrice()
+ comma + items.get(item)
+ comma + item.computeUnitPrice() * items.get(item));
writer.newLine();
}
}
writer.newLine();
if (budget.getConferences() != null && budget.getConferences().size() > 0 && budget.getConsultations() != null) {
writer.write("咨询费,人员类型,费用标准,人数,小计");
writer.newLine();
Map<Consultation, Integer> consultations = budget.getConsultations();
for (Consultation consultation : consultations.keySet()) {
writer.write(comma + consultation.getName()
+ comma + consultation.getPrice()
+ comma + consultations.get(consultation)
+ comma + consultation.getPrice() * consultations.get(consultation));
writer.newLine();
}
}
writer.newLine();
writer.write("其他费用,费用名称,费用标准,数量,小计");
writer.newLine();
items = (Map) budget.getOthers();
for (Item item : items.keySet()) {
if (item instanceof Others) {
writer.write(comma + item.getName()
+ comma + item.getPrice()
+ comma + items.get(item)
+ comma + item.computeUnitPrice() * items.get(item));
writer.newLine();
}
}
writer.newLine();
writer.write("间接费用,费用名称,费用标准,数量,小计");
writer.newLine();
items = (Map) budget.getIndirects();
for (Item item : items.keySet()) {
if (item instanceof Indirect) {
writer.write(comma + item.getName()
+ comma + item.getPrice()
+ comma + items.get(item)
+ comma + item.computeUnitPrice() * items.get(item));
writer.newLine();
}
}
writer.flush();
System.out.println("CSV");
} catch (IOException e) {
e.printStackTrace();
}
}
}
......@@ -186,7 +186,7 @@
</li>
<li><a href="#material" data-toggle="tab" onclick="materialVue.showlist()">材料费</a></li>
<li><a href="#test" data-toggle="tab" onclick="testVue.showlist()">测试化验加工费</a></li>
<li><a href="#power" data-toggle="tab">燃料动力费</a></li>
<li><a href="#power" data-toggle="tab" onclick="powerVue.showlist()">燃料动力费</a></li>
<li><a href="#travel" data-toggle="tab" onclick=travelVue.showlist()>差旅费</a></li>
<li><a href="#conference" data-toggle="tab" onclick="conferenceVue.showlist()">会议费</a></li>
<li><a href="#international" data-toggle="tab" onclick="internationalVue.showlist()">国际交流合作费</a></li>
......@@ -222,7 +222,7 @@
<th hidden>编号</th>
<th>名称</th>
<th hidden>分类</th>
<th>描述</th>
<th>配置</th>
<th>单价</th>
<th>数量</th>
<th>操作</th>
......@@ -230,10 +230,11 @@
</thead>
<tbody id="equipment-table">
<tr v-for="item in items">
<tr v-for="item in items" v-bind:title="item.name+'\n'+item.comment">
<td><input type="text" readonly v-model="item.name" class="form-control"></td>
<td hidden><input type="text" v-model="item.type" class="form-control"></td>
<td><input type="text" v-model="item.comment" class="form-control"></td>
<td><%--<input type="text" v-model="item.comment" class="form-control">--%>
<textarea v-model="item.comment" class="form-control"></textarea></td>
<td><input type="number" v-model="item.price" class="form-control"></td>
<td><input type="number" v-model="item.nums" class="form-control"></td>
<td>
......@@ -244,7 +245,7 @@
<tr class="success">
<td><input type="text" v-model="sample.name" class="form-control"></td>
<td hidden><input type="text" v-model="sample.type" class="form-control"></td>
<td><input type="text" v-model="sample.comment" class="form-control"></td>
<td><textarea v-model="sample.comment" class="form-control"></textarea></td>
<td><input type="number" v-model="sample.price" class="form-control"></td>
<td><input type="number" v-model="sample.nums" class="form-control"></td>
<td>
......@@ -260,7 +261,7 @@
</select>
</td>
<td hidden><input type="text" v-model="database[selectedIndex].type" class="form-control"></td>
<td><input type="text" v-model="database[selectedIndex].comment" class="form-control"></td>
<td><textarea v-model="database[selectedIndex].comment" class="form-control"></textarea></td>
<td>
<input type="number" v-model="database[selectedIndex].price" class="form-control">
</td>
......@@ -335,6 +336,7 @@
<th>名称</th>
<th>单价</th>
<th>数量</th>
<th>操作</th>
</tr>
</thead>
......@@ -393,15 +395,44 @@
</thead>
<tbody id="power-table">
<tr v-for="power in items">
<td><input type="text" readonly v-model="power.name"></td>
<td><input type="number" v-model="power.price"></td>
<td><input type="number" v-model="power.nums"></td>
<tr v-for="item in items">
<td><input type="text" readonly v-model="item.name" class="form-control"></td>
<td><input type="number" v-model="item.price" class="form-control"></td>
<td><input type="number" v-model="item.nums" class="form-control"></td>
<td>
<button class="btn btn-success" @click="update(item)">确认</button>
<button class="btn btn-danger" @click="del(item)">删除</button>
</td>
</tr>
<tr class="success">
<td><input type="text" v-model="sample.name" class="form-control"></td>
<td><input type="number" v-model="sample.price" class="form-control"></td>
<td><input type="number" v-model="sample.nums" class="form-control"></td>
<td>
<button class="btn btn-success" @click="add(sample)">添加</button>
</td>
</tr>
<tr class="info" v-if="database.length>0">
<td>
<select v-model="selectedIndex" class="form-control">
<option v-for="(record,i) in database" :value="i">
{{record.name}}
</option>
</select>
</td>
<td>
<button class="btn btn-success" @click="update(power)">确认</button>
<button class="btn btn-danger" @click="del(power)">删除</button>
<input type="number" v-model="database[selectedIndex].price" class="form-control">
</td>
<td><input type="number" v-model="database[selectedIndex].nums" class="form-control"></td>
<td>
<button class="btn btn-success" @click="addFromDatabase(database[selectedIndex])">添加
</button>
<button class="btn btn-danger" @click="deleteFromDatabase(database[selectedIndex])">删除
</button>
</td>
</tr>
</tbody>
</table>
</div>
......@@ -446,6 +477,7 @@
<td><input type="number" v-model="sample.accommodation" class="form-control"></td>
<td><input type="number" v-model="sample.people" class="form-control"></td>
<td><input type="number" v-model="sample.days" class="form-control"></td>
<td><input type="number" v-model="sample.nums" class="form-control"></td>
<td>
<button class="btn btn-success" @click="add(sample)">添加</button>
</td>
......@@ -468,8 +500,10 @@
</td>
<td><input type="number" v-model="database[selectedIndex].people" class="form-control"></td>
<td><input type="number" v-model="database[selectedIndex].days" class="form-control"></td>
<td><input type="number" v-model="database[selectedIndex].nums" class="form-control"></td>
<td>
<button class="btn btn-success" @click="add(database[selectedIndex])">添加</button>
<button class="btn btn-success" @click="addFromDatabase(database[selectedIndex])">添加</button>
<button class="btn btn-danger" @click="deleteFromDatabase(database[selectedIndex])">删除</button>
</td>
</tr>
</tbody>
......@@ -875,7 +909,6 @@
2:修改费用列表中的条目
3:从数据库中添加到费用列表,
4:从数据库中删除条目
*/
function openNav() {
......@@ -933,7 +966,7 @@
this.doUpdate(item, 3);
},
deleteFromDatabase: function (item) {
this.doUpdate(item, 4);
if (confirm("确认从数据库中删除?")) this.doUpdate(item, 4);
},
showlist: function () {
this.$http.get("${pageContext.request.contextPath}/Budget/Detail/Equipment").then(
......@@ -1014,7 +1047,7 @@
this.doUpdate(item, 3);
},
deleteFromDatabase: function (item) {
this.doUpdate(item, 4);
if (confirm("确认从数据库中删除?")) this.doUpdate(item, 4);
},
showlist: function () {
this.$http.get("${pageContext.request.contextPath}/Budget/Detail/Material").then(
......@@ -1091,7 +1124,7 @@
this.doUpdate(item, 3);
},
deleteFromDatabase: function (item) {
if (confirm("确认删除?")) this.doUpdate(item, 4);
if (confirm("确认从数据库中删除?")) this.doUpdate(item, 4);
},
showDatabase: function () {
this.$http.get("${pageContext.request.contextPath}/Database/Query/TestAndProcess").then(
......@@ -1188,7 +1221,7 @@
this.doUpdate(item, 3);
},
deleteFromDatabase: function (item) {
if (confirm("确认删除?")) this.doUpdate(item, 4);
if (confirm("确认从数据库中删除?")) this.doUpdate(item, 4);
},
showlist: function () {
this.$http.get("${pageContext.request.contextPath}/Budget/Detail/International").then(
......@@ -1245,17 +1278,76 @@
var powerVue = new Vue({
el: "#power",
data: {
items: {}
items: [],
sample: {id: 0, name: "sample", price: 0, nums: 0},
database: [{id: 0, name: "sample", price: 0, nums: 0}],
selectedIndex: 0
},
methods: {
update: function (item) {
alert("update")
this.doUpdate(item, 2);
},
del: function (item) {
alert("delete")
if (confirm("确认删除?")) this.doUpdate(item, 1);
},
add: function (item) {
alert("add")
if (inItems(item, this.items)) {
alert("已存在")
} else
this.doUpdate(item, 0);
},
addFromDatabase: function (item) {
this.doUpdate(item, 3);
},
deleteFromDatabase: function (item) {
if (confirm("确认从数据库中删除?")) this.doUpdate(item, 4);
},
showlist: function () {
this.$http.get("${pageContext.request.contextPath}/Budget/Detail/Power").then(
function (data) {
this.items = data.body.data;
console.log("showlist");
updateBudgetPage("power");
this.showDatabase();
}, function (error) {
console.log(error)
}
)
},
showDatabase: function () {
this.$http.get("${pageContext.request.contextPath}/Database/Query/Power").then(
function (data) {
var tmp = data.body.data;
for (var i = 0; i < tmp.length; i++) {
if (inItems(tmp[i], this.items)) {
console.log("inItems:true, " + tmp[i].name);
tmp.splice(i, 1);
i--;
}
}
this.database = tmp;
console.log("show database");
}, function (error) {
console.log(error)
}
)
},
doUpdate: function (item, curd) {
this.$http.post("${pageContext.request.contextPath}/Budget/Modify/Power",
{
id: item.id,
name: item.name,
price: item.price,
nums: item.nums,
curd: curd
},
{emulateJSON: true}
).then(function (value) {
this.showlist();
}, function (error) {
alert(error.bodyText);
this.showlist()
});
}
},
created: function () {
......@@ -1287,7 +1379,7 @@
this.doUpdate(item, 3);
},
deleteFromDatabase: function (item) {
if (confirm("确认删除?")) this.doUpdate(item, 4);
if (confirm("确认从数据库中删除?")) this.doUpdate(item, 4);
},
showDatabase: function () {
this.$http.get("${pageContext.request.contextPath}/Database/Query/Property").then(
......@@ -1342,8 +1434,8 @@
el: "#travel",
data: {
items: [],
sample: {name: "sample", price: 0, food: 0, accommodation: 0, traffic: 0, days: 0, people: 0, nums: 0},
database: [{name: "sample", price: 0, food: 0, accommodation: 0, traffic: 0, days: 0, people: 0, nums: 0}],
sample: {id:0,name: "sample", price: 0, food: 0, accommodation: 0, traffic: 0, days: 0, people: 0, nums: 0},
database: [{id:0,name: "sample", price: 0, food: 0, accommodation: 0, traffic: 0, days: 0, people: 0, nums: 0}],
selectedIndex: 0
},
methods: {
......@@ -1359,6 +1451,12 @@
} else
this.doUpdate(item, 0);
},
addFromDatabase: function (item) {
this.doUpdate(item, 3);
},
deleteFromDatabase: function (item) {
if (confirm("确认从数据库中删除?")) this.doUpdate(item, 4);
},
showlist: function () {
this.$http.get("${pageContext.request.contextPath}/Budget/Detail/Travel").then(
function (data) {
......@@ -1392,6 +1490,7 @@
doUpdate: function (item, curd) {
this.$http.post("${pageContext.request.contextPath}/Budget/Modify/Travel",
{
id:item.id,
name: item.name,
price: item.price,
food: item.food,
......@@ -1484,7 +1583,7 @@
this.doUpdate(item, 3);
},
deleteFromDatabase: function (item) {
if (confirm("确认删除?")) this.doUpdate(item, 4);
if (confirm("确认从数据库中删除?")) this.doUpdate(item, 4);
},
showDatabase: function () {
this.$http.get("${pageContext.request.contextPath}/Database/Query/Conference").then(
......@@ -1705,7 +1804,7 @@
this.doUpdate(item, 3);
},
deleteFromDatabase: function (item) {
if (confirm("确认删除?")) this.doUpdate(item, 4);
if (confirm("确认从数据库中删除?")) this.doUpdate(item, 4);
},
showDatabase: function () {
this.$http.get("${pageContext.request.contextPath}/Database/Query/Others").then(
......
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