var grid = mini.get("datagrid1");
var form1 = new mini.Form("#form1");
var saveButton = mini.get("saveButton");
var resetButton = mini.get("resetButton");
var key = mini.get("key");
var code = mini.get("code");
var courseOne = mini.get("courseOne");
var courseTwo = mini.get("courseTwo");
var Genders = [{ id: 1, text: '借方' }, { id: 2, text: '贷方'}];
//监听单元格编辑事件
function checkCourse(e){
if(e.field=="course"){
onCourseRenderer(e);
}
}
//列表科目显示
function onCourseRenderer(e) {
var values;
var row = grid.getSelected();
//var renderer = this;
var grid1 = e.sender;
var record = e.record;
var courseField = record.courseField;
// var course = record.course;
if(courseField==null||courseField==""){
return;
}
if(checkloan(courseField)==false) {
grid.updateRow(row,{courseField:""});
return;
}
$.ajax({
url: "${ctx}/login/loancourse!getCourseByCode.action",
data: { oneCourse: courseField},
type: "post",
success: function (text) {
var datajson = text.datajson;
alert(datajson);
if(datajson == '0'){
alert("该凭证不存在");
grid.updateRow(row,{courseField:""});
return;
}else if(datajson == '1'){
alert("总科目不可用");
grid.updateRow(row,{courseField:""});
return;
}else if(datajson == '2'){
alert("本科目下存在多条数据,只能选择一条");
grid.updateRow(row,{courseField:""});
return;
}
//弹出文本框 弹出科目树页面
function onButtonEdit(e) {
var btnEdit = this;
mini.open({
url: "${ctx}/login/loanaccounts!toloancoursetree.action",
title: "多选树",
width: 350,
height: 350,
onload: function () {
var ifr = this.getIFrameEl();
var data = { action: "tree"};
ifr.contentWindow.SetData(data);
},
ondestroy: function (action) {
if (action == "ok") {
var iframe = this.getIFrameEl();
var data = iframe.contentWindow.GetData();
data = mini.clone(data);
btnEdit.setValue(data.text);
btnEdit.setText(data.id);
}
}
});
}
function addRow() {
//获得行数
var count = grid.getData().length;
if(count>5){
alert("最多添加6行数据");
return;
}
var newRow = {};
grid.addRow(newRow);
grid.beginEditCell(newRow);
grid.updateRow(newRow,{course:"",courseField:""});
}
</script>