|
@ -90,12 +90,15 @@ |
|
|
<script th:inline="javascript"> |
|
|
<script th:inline="javascript"> |
|
|
var prefix = ctx + "system/baseExpense" |
|
|
var prefix = ctx + "system/baseExpense" |
|
|
$("#form-baseExpense-add").validate({focusCleanup: true}); |
|
|
$("#form-baseExpense-add").validate({focusCleanup: true}); |
|
|
$(function(){ |
|
|
var costTypeDatas = [[${@category.getChildByCode('costType')}]]; |
|
|
|
|
|
var $table = $("#bootstrap-sub-table-expense"); |
|
|
|
|
|
var costTypes; |
|
|
|
|
|
$(function() { |
|
|
$.ajax({ |
|
|
$.ajax({ |
|
|
url: prefix + "/getId", |
|
|
url: prefix + "/getId", |
|
|
type: "post", |
|
|
type: "post", |
|
|
dataType: "json", |
|
|
dataType: "json", |
|
|
success: function(result) { |
|
|
success: function (result) { |
|
|
if (result.code == 0) { |
|
|
if (result.code == 0) { |
|
|
$("input[name='expenseCode']").val(result.data); |
|
|
$("input[name='expenseCode']").val(result.data); |
|
|
} else { |
|
|
} else { |
|
@ -103,8 +106,9 @@ |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
}) |
|
|
// 假设此函数返回供应商列表 |
|
|
var $table = $("#bootstrap-sub-table-expense"); |
|
|
|
|
|
|
|
|
}); |
|
|
//获取子表信息 |
|
|
//获取子表信息 |
|
|
$(function() { |
|
|
$(function() { |
|
|
var options = { |
|
|
var options = { |
|
@ -114,15 +118,23 @@ |
|
|
model: "报销单数据", |
|
|
model: "报销单数据", |
|
|
columns: [ |
|
|
columns: [ |
|
|
{checkbox: true}, |
|
|
{checkbox: true}, |
|
|
{title: '主键',field: '',visible: false, |
|
|
{title: '主键',field: 'index',align: 'center',visible: false, |
|
|
formatter: function (value, row, index) { |
|
|
formatter: function (value, row, index) { |
|
|
return index; |
|
|
return index; |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
{title: '报销单分项子表',field: 'expenseChildId',visible: false}, |
|
|
{title: '报销单分项子表',field: 'expenseChildId',visible: false}, |
|
|
{title: '关联报销单号',field: 'quoteId',visible: false}, |
|
|
{title: '关联报销单号',field: 'quoteId',visible: false}, |
|
|
{title: '成本类型',field: 'costType',}, |
|
|
{title: '成本类型',field: 'costType', |
|
|
{title: '成本小类',field: 'costSmallType',}, |
|
|
formatter:function (value, row, index) { |
|
|
|
|
|
return costTypeFormatter(value,row,index); |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
{title: '成本小类',field:'costSmallType', |
|
|
|
|
|
formatter:function(value, row, index){ |
|
|
|
|
|
return getCostSmallType(value,row,index) |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
{title: '用途',field: 'purpose',editable:{type:'text',options:{maxlength:100}}}, |
|
|
{title: '用途',field: 'purpose',editable:{type:'text',options:{maxlength:100}}}, |
|
|
{title: '金额',field: 'amounts',editable: {type:'text',options:{maxlength:100}}}, |
|
|
{title: '金额',field: 'amounts',editable: {type:'text',options:{maxlength:100}}}, |
|
|
{title: '报销时间',field: 'expenseTime',editable:{type:'date'}}, |
|
|
{title: '报销时间',field: 'expenseTime',editable:{type:'date'}}, |
|
@ -132,7 +144,7 @@ |
|
|
{title: '操作', align: 'center', |
|
|
{title: '操作', align: 'center', |
|
|
formatter: function (value, row, index) { |
|
|
formatter: function (value, row, index) { |
|
|
var actions = []; |
|
|
var actions = []; |
|
|
actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="removeRow(\'' + row.index + '\')"><i class="fa fa-remove"></i>删除</a> '); |
|
|
actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="removeRow(\'' + index + '\')"><i class="fa fa-remove"></i>删除</a> '); |
|
|
return actions.join(''); |
|
|
return actions.join(''); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -145,31 +157,87 @@ |
|
|
index:1, |
|
|
index:1, |
|
|
row: { |
|
|
row: { |
|
|
expenseChildId:'', |
|
|
expenseChildId:'', |
|
|
costType: "<select name='costType' class='form-control'>"+ "<option value=''>所有</option>" + "</select>", |
|
|
costType: "", |
|
|
costSmallType:"<select name='costSmallType' class='form-control'>"+ "\"<option value=''>所有</option>\"" +"</select>", |
|
|
costSmallType:"", |
|
|
purpose:'<input name="purpose" class="form-control" type="text">' , |
|
|
purpose:'' , |
|
|
amounts: '<input name="amounts" class="form-control" type="text">', |
|
|
amounts: '', |
|
|
expenseTime: '<div class="input-group date">\n' + |
|
|
expenseTime: '', |
|
|
'<input name="expenseTime" class="form-control" placeholder="yyyy-MM-dd" type="date"></div>', |
|
|
evectionCode:'' , |
|
|
evectionCode:'<input name="evectionCode" class="form-control" type="text">' , |
|
|
purcahseCode:'', |
|
|
purcahseCode:'<input name="purcahseCode" class="form-control" type="text">', |
|
|
outsourceCode: '', |
|
|
outsourceCode: '<input name="outsourceCode" class="form-control" type="text">', |
|
|
|
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
layer.close(index); |
|
|
|
|
|
} |
|
|
} |
|
|
/* 删除指定表格行 */ |
|
|
/* 删除指定表格行 */ |
|
|
function removeRow(id){ |
|
|
function removeRow(index){$table.bootstrapTable('remove', {field: 'index',values: index})}; |
|
|
$table.bootstrapTable('remove', { |
|
|
|
|
|
field: 'id', |
|
|
|
|
|
values: id |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
function submitHandler() { |
|
|
function submitHandler() { |
|
|
if ($.validate.form()) { |
|
|
if ($.validate.form()) { |
|
|
$.operate.save(prefix + "/add", $('#form-baseExpense-add').serialize()); |
|
|
var formData = $('#form-baseExpense-add').serializeArray(); |
|
|
|
|
|
var tableData = $table.bootstrapTable('getData'); |
|
|
|
|
|
var rows = tableData.length; |
|
|
|
|
|
if(rows==0){ |
|
|
|
|
|
$.modal.alertWarning("子表数据不能为空!"); |
|
|
|
|
|
}else{ |
|
|
|
|
|
formData.push({"name": "expenseAccountChildList", "value": tableData}); |
|
|
|
|
|
var jsonData = $.common.formDataToJson(formData); |
|
|
|
|
|
$.operate.saveJson(prefix + "/add", jsonData); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
// 列中获取成本类型的下拉改变数据 |
|
|
|
|
|
function onCostTypeChange(selectElement, rowIndex) { |
|
|
|
|
|
var newSupplierId = $(selectElement).val(); |
|
|
|
|
|
var tableData = $table.bootstrapTable('getData'); |
|
|
|
|
|
var newRow = tableData[rowIndex]; // 获取当前行数据 |
|
|
|
|
|
newRow.costType = newSupplierId; // 更新供应商ID |
|
|
|
|
|
// 重新渲染成本小类的设备名称列 |
|
|
|
|
|
// 更新行数据 |
|
|
|
|
|
$table.bootstrapTable('updateRow', {index: rowIndex, row: newRow}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 自定义供应商名称列的格式化函数 |
|
|
|
|
|
function costTypeFormatter(value, row, index) { |
|
|
|
|
|
var selectHtml = '<select class="form-control" onchange="onCostTypeChange(this, ' + index + ')">'; |
|
|
|
|
|
costTypeDatas.forEach(function (child) { |
|
|
|
|
|
selectHtml += '<option value="' + child.code + '"' + (value === child.code ? ' selected' : '') + '>' + child.name + '</option>'; |
|
|
|
|
|
}); |
|
|
|
|
|
selectHtml += '</select>'; |
|
|
|
|
|
return selectHtml; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 自定义设备名称列的格式化函数,依赖于供应商列的选择 |
|
|
|
|
|
function getCostSmallType(value, row, index) { |
|
|
|
|
|
var selectHtml = '<select class="form-control" onchange="onCostSmallTypeChange(this, ' + index + ')">'; |
|
|
|
|
|
// 假设此函数根据供应商ID返回设备列表 |
|
|
|
|
|
var costSamllTypes = []; |
|
|
|
|
|
$.ajax({ |
|
|
|
|
|
url: ctx + 'system/category/getChildCode', |
|
|
|
|
|
type: 'post', |
|
|
|
|
|
data: {code: row.costType}, |
|
|
|
|
|
async: false, |
|
|
|
|
|
success: function (result) { |
|
|
|
|
|
console.log(result); |
|
|
|
|
|
costSamllTypes = result; |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
if (costSamllTypes) { |
|
|
|
|
|
costSamllTypes.forEach(function (child) { |
|
|
|
|
|
selectHtml += '<option value="' + child.code + '"' + (value === child.code ? ' selected' : '') + '>' + child.name + '</option>'; |
|
|
|
|
|
}); |
|
|
|
|
|
selectHtml += '</select>'; |
|
|
|
|
|
return selectHtml; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function onCostSmallTypeChange(selectElement, rowIndex) { |
|
|
|
|
|
var newCostSmallType = $(selectElement).val(); |
|
|
|
|
|
var tableData = $table.bootstrapTable('getData'); |
|
|
|
|
|
var newRow = tableData[rowIndex]; // 获取当前行数据 |
|
|
|
|
|
newRow.costSmallType = newCostSmallType; |
|
|
|
|
|
// 重新渲染当前行的设备名称列 |
|
|
|
|
|
// 更新行数据 |
|
|
|
|
|
$table.bootstrapTable('updateRow', {index: rowIndex, row: newRow}); |
|
|
|
|
|
} |
|
|
</script> |
|
|
</script> |
|
|
</body> |
|
|
</body> |
|
|
</html> |
|
|
</html> |