首页 > 其他分享 >泛微案例:明细控制当前行字段必填,只读

泛微案例:明细控制当前行字段必填,只读

时间:2023-02-23 16:22:12浏览次数:45  
标签:jQuery val 必填 needCheck 行字段 field fieldid 泛微

<script type="text/javascript">
jQuery(document).ready(function() {
addField('oTable0', 'field5876', '28093_', '28094_');
$("#indexnum0").bindPropertyChange(function(dom) {
return false;
addField('oTable0', 'field5876', '28093_', '28094_') ;
changeField('oTable0', 'field5876', '28093_', '28094_');

});
addField('oTable1', 'field5885', '28095_', '28096_');
$("#indexnum1").bindPropertyChange(function(dom) {
addField('oTable1', 'field5885', '28095_', '28096_') ;
changeField('oTable1', 'field5885', '28095_', '28096_');

});
addField('oTable2', 'field6122', '28097_', '28098_');
$("#indexnum2").bindPropertyChange(function(dom) {
addField('oTable2', 'field6122', '28097_', '28098_') ;
changeField('oTable2', 'field6122', '28097_', '28098_');

});
})
/*table:明细表
* fylb:费用类别
* btry:补贴人员
* btbz:补贴标准
*/
//明细表新增
function addField(table, fylb1, btry, btbz) {
jQuery("#"+table).find("tr[_target=datarow]").each(function(index, obj) {
var i = $(obj).attr("_rowindex"); //明细字段的序号
var fylb = jQuery("#" + fylb1 + "_" + index).val();
if(fylb == '8') {
needcheck(btbz + i, 0, 1);
needcheck(btry + i, 1, 1);
} else {
needcheck(btbz + i, 0, 0);
needcheck(btry + i, 1, 0);
}
// addInputCheckField1('field28094_'+i);
});
}
//绑定改变事件
function changeField(table, fylb1, btry, btbz) {
jQuery("#"+table).find("tr[_target=datarow]").each(function(index, obj) {
var i = $(obj).attr("_rowindex"); //明细字段的序号
jQuery("#" + fylb1 + "_" + index).bindPropertyChange(function() {
var fylb = jQuery("#" + fylb1 + "_" + index).val();
if(fylb == '8') {
needcheck(btbz + i, 0, 1);
needcheck(btry + i, 1, 1);
} else {
needcheck(btbz + i, 0, 0);
needcheck(btry + i, 1, 0);
}
})
// addInputCheckField1('field28094_'+i);
});
}

//-------------------字段必填控制----------------
/*
用途:添加字段是否必填 适用于主表字段
输入参数: fieldid 字段id 例如 1000
isBrowser 0:非浏览字段 , 1:浏览字段
option 0:非必输 , 1:必输
*/
function needcheck(fieldid, isBrowser, option) {
var textValue = '<img align="absmiddle" src="/images/BacoError_wev8.gif">';
var needCheck = jQuery("input[name='needcheck']").val();
if(isBrowser == 1) {
if(option == 1) { //添加必填
var val = jQuery("#field" + fieldid).val(); //字段值
if(!val) {
jQuery("#field" + fieldid + "spanimg").html(textValue); //添加必填图标
}
jQuery("#field" + fieldid).attr('viewtype', '1'); //必填字段id
needCheck = needCheck + ",field" + fieldid;
//alert("needCheck="+needCheck);
jQuery("input[name='needcheck']").val(needCheck);

//编辑启用
$("#field" + fieldid + "__").attr("disabled", false);
$("#field" + fieldid + "_browserbtn").attr("disabled", false);
$("#innerContentfield" + fieldid + "div").css("cursor", '');
$("#field" + fieldid + "_browserbtn").css("cursor", '');
$("#field" + fieldid + "span .e8_showNameClass .e8_delClass").html(" x ");

} else if(option == 0) { //取消必填
jQuery("#field" + fieldid + "spanimg").html(""); //添加必填图标
jQuery("#field" + fieldid).attr('viewtype', '0'); //必填字段id
needCheck = needCheck.replace(",field" + fieldid, "");
//alert("needCheck="+needCheck);
jQuery("input[name='needcheck']").val(needCheck);
//禁用编辑
$("#field" + fieldid).val('');
$('#field' + fieldid + "span").html("");
$("#field" + fieldid + "__").attr("disabled", true);
$("#field" + fieldid + "_browserbtn").attr("disabled", true);
$("#innerContentfield" + fieldid + "div").css("cursor", 'not-allowed');
$("#field" + fieldid + "_browserbtn").css("cursor", 'not-allowed');
$("#field" + fieldid + "span .e8_showNameClass .e8_delClass").html("");

}
} else if(isBrowser == 0) {
if(option == 1) { //添加必填
var val = jQuery("#field" + fieldid).val(); //字段值
if(!val) {
jQuery("#field" + fieldid + "span").html(textValue); //添加必填图标
}
jQuery("#field" + fieldid).attr('viewtype', '1'); //必填字段id
needCheck = needCheck + ",field" + fieldid;
//alert("needCheck="+needCheck);
jQuery("input[name='needcheck']").val(needCheck);
//编辑
var fieldStr = $('input[name=needcheck]').val();
$("#field" + fieldid).css("cursor", '');
$("#field" + fieldid).attr("disabled", false);
} else if(option == 0) { //取消必填
jQuery("#field" + fieldid + "span").html(""); //添加必填图标
jQuery("#field" + fieldid).attr('viewtype', '0'); //必填字段id
needCheck = needCheck.replace(",field" + fieldid, "");
//alert("needCheck="+needCheck);
jQuery("input[name='needcheck']").val(needCheck);
//只读置空
$("#field" + fieldid).val('');
$("#field" + fieldid).css("cursor", 'not-allowed');
$("#field" + fieldid).attr("disabled", true);
$("#field" + fieldid + "_browserbtn").attr("disabled", false);
}
}
}
//-------------------字段必填控制结束----------------
</script>

标签:jQuery,val,必填,needCheck,行字段,field,fieldid,泛微
From: https://www.cnblogs.com/yitian-lg/p/17148500.html

相关文章