根据故障来源新增明细行,并且初始化错误类型
- 1、需求说明
- 2、实现方法
- 3、扩展知识点
- 3.1 批量修改字段值或显示属性
- 3.1.1 格式
- 3.1.2 参数
- 3.1.3 演示
- 3.2 根据字段ID获取字段信息
- 3.2.1 格式
- 3.2.2 参数
- 3.2.3 演示
1、需求说明
用户对出现故障的机器或设备进行判断问题判断,系统根据软硬件故障自动识别相关的故障原因,并且对故障原因进行确认,当存在某个现象时,明细表自动新增行,并初始化错误类型。
-
“硬件故障”
-
“硬件故障”去掉“硬盘存在坏道或损坏”故障原因
-
“软件故障”
2、实现方法
代码块
<script>var gzlxField = WfForm.convertFieldNameToId("gzlypd");var yjgzFieldArr = ["26199","26200","26201","26202","26203","26204","26205"];var rjgzFieldArr = ["26206","26208","26209","26210","26211","26212","26213"];//故障来源判断,清空故障相关值clearData = function(gzlyV){//硬件故障,清空软件故障相关值if(gzlyV == "0"){WfForm.changeMoreField({field26199:{value:""},field26200:{value:""},field26201:{value:""},field26202:{value:""},field26203:{value:""},field26204:{value:""},field26205:{value:""},field26214:{value:""}},{field26199:{viewAttr:3},field26200:{viewAttr:3},field26201:{viewAttr:3},field26202:{viewAttr:3},field26203:{viewAttr:3},field26204:{viewAttr:3},field26205:{viewAttr:3},field26214:{viewAttr:3}});}else if(gzlyV == "1"){ //软件故障,清空硬件故障相关值WfForm.changeMoreField({field26206:{value:""},field26208:{value:""},field26209:{value:""},field26210:{value:""},field26211:{value:""},field26212:{value:""},field26213:{value:""},field26214:{value:""}},{field26206:{viewAttr:3},field26208:{viewAttr:3},field26209:{viewAttr:3},field26210:{viewAttr:3},field26211:{viewAttr:3},field26212:{viewAttr:3},field26213:{viewAttr:3},field26214:{viewAttr:3}});}else{}}operateDetailRow = function(value,fieldLable){//无问题,表示清空该行if(value == "1"){ var rowArr = WfForm.getDetailAllRowIndexStr("detail_1").split(",");for(var i=0; i<rowArr.length; i++){var rowIndex = rowArr[i];if(rowIndex !== ""){var fieldMark = "field25902_"+rowIndex; //遍历明细行字段var fieldValue = WfForm.getFieldValue(fieldMark);if(fieldValue == fieldLable){WfForm.delDetailRow("detail_1",rowIndex.toString());}}}}else if(value == "0"){WfForm.addDetailRow("detail_1",{field25902:{value:fieldLable}});}else{}} jQuery(document).ready(function(){debugger;//故障来源判断 - 值触发WfForm.bindFieldChangeEvent(gzlxField,function(obj,id,value){WfForm.delDetailRow("detail_1","all");clearData(value); });//硬件故障+其他 - 值触发WfForm.bindFieldChangeEvent("field26199,field26200,field26201,field26202,field26203,field26204,field26205,field26214",function(obj,id,value){var gzlxValue = WfForm.getFieldValue(gzlxField);if(gzlxValue == "1"){return;}if(value){var fieldid = id.substring(5,id.length);var fieldInfo = WfForm.getFieldInfo(fieldid);var fieldLable = fieldInfo.fieldlabel;operateDetailRow(value,fieldLable);}});//软件故障+其他 - 值触发WfForm.bindFieldChangeEvent("field26206,field26208,field26209,field26210,field26211,field26212,field26213,field26214",function(obj,id,value){var gzlxValue = WfForm.getFieldValue(gzlxField);if(gzlxValue == "0"){return;}if(value){var fieldid = id.substring(5,id.length);var fieldInfo = WfForm.getFieldInfo(fieldid);var fieldLable = fieldInfo.fieldlabel;operateDetailRow(value,fieldLable);}});})</script>
3、扩展知识点
3.1 批量修改字段值或显示属性
3.1.1 格式
changeMoreField: function(changeDatas, changeVariable)
3.1.2 参数
参数说明
参数 | 参数类型 | 参数类型 | 参数类型 |
---|---|---|---|
changeMoreField | JSON | 是 | 修改的字段值信息集合 |
changeVariable | JSON | 否 | 修改的字段显示属性集合 |
3.1.3 演示
WfForm.changeMoreField({field110:{value:"修改后的值"},field111:{value:"2,3",specialobj:[{id:"2",name:"张三"},{id:"3",name:"李四"}]},...
},{field110:{viewAttr:2},field111:{viewAttr:3},...
});
3.2 根据字段ID获取字段信息
说明:根据字段ID获取字段信息,JSON格式,包括名称、类型、只读必填属性等
3.2.1 格式
getFieldInfo:function(fieldid)
3.2.2 参数
参数说明
参数 | 参数类型 | 参数类型 | 参数类型 |
---|---|---|---|
fieldid | String | 是 | 字段ID,不带任何标示 |
返回值字段信息JSON重要属性说明
参数 | 说明 |
---|---|
htmltype | 字段大类型(文本/多行文本…) |
detailtype | 字段小类型(整数/浮点数…) |
fieldname | 字段数据库名称 |
fieldlabel | 字段显示名 |
viewattr | 字段属性(1:只读;2:可编辑;3:必填) |
3.2.3 演示
WfForm.getFieldInfo("111");