ebu_ecology_dev1/javascript/xuanran.wang/schroeder/js/Seal.js

152 lines
4.9 KiB
JavaScript
Raw Normal View History

// 打印盖章
const pritGz = 1;
// 鉴伪盖章
const jwGz = 3;
// 开门盖章
const kmGz = 4;
// 用印方式字段名
const sealTypeId = WfForm.convertFieldNameToId("yyfs");
// 用印方式字段名明细
const detailSealTypeId = WfForm.convertFieldNameToId("yylx","detail_1");
// 是否需要加骑缝章
const detailQfzField = WfForm.convertFieldNameToId("sfjgqfz","detail_1");
// 否
const no = 1;
// 是
const yes = 0;// 组合用印
const zh = 6;
// 取章用印
const qzyy = 7;
// 是否归档
const lastField = WfForm.convertFieldNameToId("sfgd");
// 来源
const source = WfForm.convertFieldNameToId("htspcfyy");
//属于合同
const isht = WfForm.convertFieldNameToId("zyht");
//完成法神
const islaw = WfForm.convertFieldNameToId("wcfs");
// 用印文件字段
const detailFileTypeId = WfForm.convertFieldNameToId("yywj","detail_1");
// 主表
const mainsealtype = WfForm.convertFieldNameToId("yzzl");
// 主表合同专用章次数
const mainht = WfForm.convertFieldNameToId("htzyzcshj");
// 主表公章次数
const maingz = WfForm.convertFieldNameToId("gzcshj");
// 主表法人章次数
const mainfr = WfForm.convertFieldNameToId("frzcshj");
// 必填
const required = 3;
// 只读
const readOnly = 1;
// 可编辑
const edit = 2;
// 默认文件docid
const defaultfile = 85;
// 明细1用印文件
jQuery(document).ready(()=>{
let sourceVal = WfForm.getFieldValue(source);
console.log('sourceVal ', sourceVal)
if(sourceVal == 0){
WfForm.changeSingleField(isht,{value:yes}, {viewAttr:readOnly});
WfForm.changeSingleField(islaw,{value:yes}, {viewAttr:readOnly});
// 明细表用印文件字段做只读
var rowArr = WfForm.getDetailAllRowIndexStr("detail_1").split(",");
for(var i=0; i<rowArr.length; i++){
var rowIndex = rowArr[i];
if(rowIndex !== ""){
WfForm.changeFieldAttr(`${detailFileTypeId}_${rowIndex}`, readOnly);
}
}
// 明细行上+-按钮清除
$('#detail1Btn').empty();
}
WfForm.bindFieldChangeEvent(sealTypeId, function(obj,id,val){ //变更用印方式触发
changeDetailFieldVal();
if(val == qzyy || val == kmGz){
WfForm.delDetailRow("detail_1", "all");
}
if(pritGz == val || jwGz == val || zh == val){
WfForm.changeSingleField(lastField,{value:1}, {viewAttr:readOnly});
} else if (kmGz == val){
WfForm.changeSingleField(lastField,{value:2}, {viewAttr:readOnly});
} else{
WfForm.changeSingleField(lastField,{value:''}, {viewAttr:required});
}
addRow();
});
WfForm.bindFieldChangeEvent(`${mainsealtype}, ${mainfr}, ${maingz}, ${mainht}`, function(obj,id,val){
WfForm.delDetailRow("detail_1", "all");
addRow();
})
WfForm.registerCheckEvent(WfForm.OPER_ADDROW+ "1", function(callback){
callback(); //允许继续添加行调用callback不调用代表阻断添加
let val = WfForm.getFieldValue(sealTypeId);
if(val == zh){
return;
}
changeDetailFieldVal();
});
})
function addRow(){
let val = WfForm.getFieldValue(sealTypeId);
if(val == kmGz || val == qzyy){
// 明细1印章种类
let detail1SealType = WfForm.convertFieldNameToId("yzzl","detail_1");
// 明细1合同专用章次数
let detail1ht = WfForm.convertFieldNameToId("htzyzcs","detail_1");
// 明细1公章次数
let detail1gz = WfForm.convertFieldNameToId("gzcs","detail_1");
// 明细1法人章次数
let detail1fr = WfForm.convertFieldNameToId("frzcs","detail_1");
console.log('detail1SealType ', detail1SealType);
console.log('detail1ht ', detail1SealType);
console.log('detail1SealType ', detail1SealType);
console.log('detail1SealType ', detail1SealType);
let obj = {
detailFileTypeId: {value:defaultfile},
detail1SealType: {value:WfForm.getFieldValue(mainsealtype)},
detail1gz: {value:WfForm.getFieldValue(maingz)},
detail1fr: {value:WfForm.getFieldValue(mainfr)},
detail1ht: {value:WfForm.getFieldValue(mainht)}
};
console.log('obj ', obj)
WfForm.addDetailRow("detail_1",obj);
}
}
function changeDetailFieldVal(){
let val = WfForm.getFieldValue(sealTypeId);
// 必填
let attr = required;
let syqf = '';
if(val == pritGz || val == jwGz){
attr = readOnly;
syqf = no;
}else{
val = '';
}
var rowArr = WfForm.getDetailAllRowIndexStr("detail_1").split(",");
for(var i=0; i<rowArr.length; i++){
var rowIndex = rowArr[i];
if(rowIndex !== ""){
WfForm.changeSingleField(`${detailSealTypeId}_${rowIndex}`,{value:val}, {viewAttr:attr});
WfForm.changeSingleField(`${detailQfzField}_${rowIndex}`,{value:syqf}, {viewAttr:attr});
}
}
}