Commit 7d6bc4b4 authored by houyu's avatar houyu

表格添加

parent 6ede9641
...@@ -63,6 +63,10 @@ ...@@ -63,6 +63,10 @@
border: none !important; border: none !important;
} }
.ta-tb tbody{
display: inherit;
width: 100%;
}
</style> </style>
<script> <script>
var index4Sf = 1; var index4Sf = 1;
...@@ -78,7 +82,7 @@ ...@@ -78,7 +82,7 @@
<div class="page_dialog"> <div class="page_dialog">
<div class="inner6px"> <div class="inner6px">
<div class="cell" style="width: 100%"> <div class="cell" style="width: 100%">
<table width="100%" border="0"> <table width="100%" border="0" class="ta-tb">
<tr class="table-line-td"> <tr class="table-line-td">
<th width="15%">建设单位</th> <th width="15%">建设单位</th>
...@@ -213,10 +217,10 @@ ...@@ -213,10 +217,10 @@
<tbody class="add-tr"> <tbody class="add-tr">
<tr class=""> <tr class="">
<td class="line-one line-xh">1</td> <td class="line-one line-xh">1</td>
<td class="line-input"><span class="db-num"></span><input class="db-input" type="text" /></td> <td class=" line-input"><span class="db-num db-num-text"></span><input class="db-input line-input-text" type="text" /></td>
<td class="line-one"></td> <td class="line-one"></td>
<td class="line-one"></td> <td class="line-one">150</td>
<td class="line-one"></td> <td class="line-one line-yjmj"></td>
<td class="line-input"><span class="db-num db-nums"></span><input class="db-input db-money" <td class="line-input"><span class="db-num db-nums"></span><input class="db-input db-money"
type="text" /></td> type="text" /></td>
<td><span class="delOneRow"><img src="${ctx}/images/img/edit_remove.png" alt=""></span></td> <td><span class="delOneRow"><img src="${ctx}/images/img/edit_remove.png" alt=""></span></td>
...@@ -238,7 +242,7 @@ ...@@ -238,7 +242,7 @@
<tr > <tr >
<td width="0%" style="width: 0%"><div class="add-title">复核意见</div></td> <td width="0%" style="width: 0%"><div class="add-title">复核意见</div></td>
<td width="35%"> <td width="100%">
<textarea id="" name="fstzsXm.jsdwmc" style="width:96%;margin-top: 6px;" value="${fstzsXm.jsdwmc}" disabled></textarea> <textarea id="" name="fstzsXm.jsdwmc" style="width:96%;margin-top: 6px;" value="${fstzsXm.jsdwmc}" disabled></textarea>
</td> </td>
...@@ -257,18 +261,23 @@ ...@@ -257,18 +261,23 @@
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
var money = 0; //合计总钱数 var money = 0; //合计总钱数
var numf = 0 var numf = 0;
var numb = 0 var numb = 0;
var flag = false var flag = false;
var objNums = {
jkr : [],// 缴款人
yjmj :[],//应缴面积
yjje :[]//应缴金额
}
//添加一行 //添加一行
$("#addOneRow").click(function () { $("#addOneRow").click(function () {
var index = 1; var index = 1;
var str = '<tr class="">' var str = '<tr class="">'
+ '<td class="line-one line-xh"></td>' + '<td class="line-one line-xh"></td>'
+ '<td class="line-input"><span class="db-num"></span><input class="db-input" type="text" /></td>' + '<td class=" line-input"><span class="db-num db-num-text"></span><input class="db-input line-input-text" type="text" /></td>'
+ '<td class="line-one"></td>' + '<td class="line-one"></td>'
+ '<td class="line-one"></td>' + '<td class="line-one">150</td>'
+ '<td class="line-one"></td>' + '<td class="line-one line-yjmj"></td>'
+ '<td class="line-input"><span class="db-num db-nums"></span><input class="db-input db-money" type="text" /></td>' + '<td class="line-input"><span class="db-num db-nums"></span><input class="db-input db-money" type="text" /></td>'
+ '<td><span class="delOneRow"><img src="${ctx}/images/img/edit_remove.png" alt=""></span></td>' + '<td><span class="delOneRow"><img src="${ctx}/images/img/edit_remove.png" alt=""></span></td>'
+ '</tr > ' + '</tr > '
...@@ -285,17 +294,52 @@ ...@@ -285,17 +294,52 @@
} else { } else {
$.messager.confirm("删除","确定要删除吗?",function(result){ $.messager.confirm("删除","确定要删除吗?",function(result){
if (result) { if (result) {
money = money - Number($(this).parent().prev().children().eq(0).text()) money = money - Number($(that).parent().prev().children().eq(0).text())
$(".line-all").text('') $(".line-all").text('')
$(".line-all").append(money) $(".line-all").append(money)
$(that).parent().parent().remove(); $(that).parent().parent().remove();
addJkr();
addyjmj();
addyjje();
} }
}) })
} }
}) })
//添加缴款人
function addJkr(){
var texts = document.getElementsByClassName('db-num-text')
objNums.jkr =[]
for(var i=0;i<texts.length;i++){
if($(texts[i]).text()!==''){
objNums.jkr.push($(texts[i]).text())
}
}
}
function addyjmj(){
var yjmjArr = document.getElementsByClassName('line-yjmj')
objNums.yjmj=[]
//添加应缴面积
for (var i = 0; i < yjmjArr.length; i++) {
if($(yjmjArr[i]).text()!==''){
objNums.yjmj.push($(yjmjArr[i]).text())
}
}
}
function addyjje(){
var nums = document.getElementsByClassName('db-nums')
objNums.yjje = []
//添加应缴金额
for (var i = 0; i < nums.length; i++) {
if($(nums[i]).text()!==''){
objNums.yjje.push($(nums[i]).text())
}
}
}
//点击表格显示输入框 //点击表格显示输入框
$(document).on('click', '.line-input', function () { $(document).on('click', '.line-input', function () {
$(this).children().eq(1).show() $(this).children().eq(1).show()
...@@ -303,16 +347,12 @@ ...@@ -303,16 +347,12 @@
$(this).children().eq(0).hide() $(this).children().eq(0).hide()
}) })
//失去焦点隐藏输入框 //失去焦点隐藏输入框
$(document).on('blur', '.db-input', function () { $(document).on('blur', '.line-input-text', function () {
var num = Number($(this).val()) var num = $(this).val()
if(Number.isNaN(num)){
$.messager.alert('提示','请输入正确的数字!');
}else{
$(this).prev().text(num) $(this).prev().text(num)
$(this).hide() $(this).hide()
$(this).prev().show() $(this).prev().show()
} addJkr();
}) })
...@@ -321,13 +361,31 @@ ...@@ -321,13 +361,31 @@
numb = Number($(this).val()) numb = Number($(this).val())
var nums = document.getElementsByClassName('db-nums') var nums = document.getElementsByClassName('db-nums')
var num = Number($(this).val())
if(Number.isNaN(num) ){
$.messager.alert('提示','请输入正确的数字!');
}else{
$(this).prev().text(num===0?'':num)
$(this).hide()
$(this).prev().show()
//计算应缴面积
var yjmjNums = numb/150
$(this).parent().prev().text((yjmjNums % 1 !== 0)?(yjmjNums).toFixed(2):yjmjNums)
}
if (numb == numf) { if (numb == numf) {
return return
} else { } else {
var ss = 0 var ss = 0
objNums.yjje = []
//添加应缴金额
for (var i = 0; i < nums.length; i++) { for (var i = 0; i < nums.length; i++) {
ss += Number($(nums[i]).text()) ss += Number($(nums[i]).text())
if($(nums[i]).text()!==''){
objNums.yjje.push($(nums[i]).text())
} }
}
addyjmj()
money = ss money = ss
} }
$(".line-all").text('') $(".line-all").text('')
......
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