Commit 341ac144 by shj

劳务费数据库展示

parent 65a1aeaf
...@@ -3,10 +3,12 @@ package handlers; ...@@ -3,10 +3,12 @@ package handlers;
import beans.Budget; import beans.Budget;
import beans.Consultation; import beans.Consultation;
import beans.Equipment; import beans.Equipment;
import beans.Labour;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import dao.IConsultationDao; import dao.IConsultationDao;
import dao.IEquipmentDao; import dao.IEquipmentDao;
import dao.ILabourDao;
import org.springframework.beans.factory.annotation.Autowired; 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;
...@@ -50,6 +52,34 @@ public class DatabaseQueryHandler { ...@@ -50,6 +52,34 @@ public class DatabaseQueryHandler {
} }
@Autowired @Autowired
private ILabourDao labourDao;
@RequestMapping("/Labour")
public void queryLabour(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<Labour> labours = labourDao.selectAll();
List<JSONObject> list=new LinkedList<>();
for (Labour item : labours) {
JSONObject obj=new JSONObject();
obj.put("id",item.getId());
obj.put("name",item.getName());
obj.put("price",item.getPrice());
obj.put("people",0);
obj.put("months",0);
obj.put("nums",0);
list.add(obj);
}
object.put("data",list);
writer.write(JSON.toJSONString(object));
} catch (IOException e) {
e.printStackTrace();
}
}
@Autowired
private IConsultationDao consultationDao; private IConsultationDao consultationDao;
@RequestMapping("/Consultation") @RequestMapping("/Consultation")
public void queryConsultation(HttpServletRequest request, HttpServletResponse response){ public void queryConsultation(HttpServletRequest request, HttpServletResponse response){
......
...@@ -129,9 +129,6 @@ public class BudgetService implements IBudgetService { ...@@ -129,9 +129,6 @@ public class BudgetService implements IBudgetService {
return (int) diff; return (int) diff;
} }
}); });
for (Equipment equipment : equipments) {
map.put(equipment, 0);
}
Equipment equipment = equipments.get(0); Equipment equipment = equipments.get(0);
double sum = 0.0; double sum = 0.0;
int i = 0; int i = 0;
......
...@@ -134,7 +134,7 @@ ...@@ -134,7 +134,7 @@
<button class="btn btn-success" @click="addToDatabase(sample)">添加到数据库</button> <button class="btn btn-success" @click="addToDatabase(sample)">添加到数据库</button>
</td> </td>
</tr> </tr>
<tr class="success"> <tr class="info">
<td> <td>
<select v-model="selectedIndex" class="form-control"> <select v-model="selectedIndex" class="form-control">
<option v-for="(record,i) in database" :value="i"> <option v-for="(record,i) in database" :value="i">
...@@ -451,6 +451,24 @@ ...@@ -451,6 +451,24 @@
<button class="btn btn-danger" @click="del(item)">删除</button> <button class="btn btn-danger" @click="del(item)">删除</button>
</td> </td>
</tr> </tr>
<tr class="info">
<td>
<select v-model="selectedIndex" class="form-control">
<option v-for="(record,i) in database" :value="i">
{{record.name}}
</option>
</select>
</td>
<td>
<input type="number" v-model="database[selectedIndex].price" class="form-control">
</td>
<td><input type="number" v-model="database[selectedIndex].people" class="form-control"></td>
<td><input type="number" v-model="database[selectedIndex].months" class="form-control"></td>
<td>
<button class="btn btn-success" @click="add(database[selectedIndex])">添加</button>
</td>
</tr>
</tbody> </tbody>
</table> </table>
...@@ -484,7 +502,7 @@ ...@@ -484,7 +502,7 @@
</td> </td>
</tr> </tr>
<tr class="success"> <tr class="info">
<td> <td>
<select v-model="selectedIndex" class="form-control"> <select v-model="selectedIndex" class="form-control">
<option v-for="(record,i) in database" :value="i"> <option v-for="(record,i) in database" :value="i">
...@@ -570,25 +588,28 @@ ...@@ -570,25 +588,28 @@
function (data) { function (data) {
this.items = data.body.data; this.items = data.body.data;
console.log("showlist"); console.log("showlist");
updateBudgetPage("equipment") updateBudgetPage("equipment");
}, function (error) {
console.log(error) this.$http.get("${pageContext.request.contextPath}/Database/Query/Equipment").then(
} function (data) {
); var tmp= data.body.data;
this.$http.get("${pageContext.request.contextPath}/Database/Query/Equipment").then( for(var i=0;i<tmp.length;i++)
function (data) { {
this.database = data.body.data; if(inItems(tmp[i],this.items)){
for(var i=0;i<this.database.length;i++) tmp.splice(i,1);
{ }
if(inItems(this.database[i],this.items)){ }
this.database.splice(i,1); this.database=tmp;
console.log("show database");
}, function (error) {
console.log(error)
} }
} )
console.log("show database");
}, function (error) { }, function (error) {
console.log(error) console.log(error)
} }
) );
}, },
doUpdate: function (item, curd) { doUpdate: function (item, curd) {
this.$http.post("${pageContext.request.contextPath}/Budget/Modify/Equipment", this.$http.post("${pageContext.request.contextPath}/Budget/Modify/Equipment",
...@@ -941,7 +962,9 @@ ...@@ -941,7 +962,9 @@
el: "#labour", el: "#labour",
data: { data: {
items: [], items: [],
sample: {name: "sample", price: 0, nums: 0} sample: {name: "sample", price: 0, nums: 0},
selectedIndex:0,
database:[{name: "sample", price: 0, nums: 0,people:0,months:0}]
}, },
methods: { methods: {
update: function (item) { update: function (item) {
...@@ -951,6 +974,7 @@ ...@@ -951,6 +974,7 @@
this.doUpdate(item, 1); this.doUpdate(item, 1);
}, },
add: function (item) { add: function (item) {
item.nums=1;
this.doUpdate(item, 0); this.doUpdate(item, 0);
}, },
showlist: function () { showlist: function () {
...@@ -962,6 +986,20 @@ ...@@ -962,6 +986,20 @@
}, function (error) { }, function (error) {
console.log(error) console.log(error)
} }
);
this.$http.get("${pageContext.request.contextPath}/Database/Query/Labour").then(
function (data) {
this.database = data.body.data;
for(var i=0;i<this.database.length;i++)
{
if(inItems(this.database[i],this.items)){
this.database.splice(i,1);
}
}
console.log("show database");
}, function (error) {
console.log(error)
}
) )
}, },
doUpdate: function (item, curd) { doUpdate: function (item, curd) {
......
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