zhangjinan
2018-04-08 915fe4d9f7d95eefaa8ce626f2bc5a72807d0de6
commit | author | age
4d1219 1 layoutStrings = {
B 2     en: {
3     },
4     zh: {
5         title: "自定义表单设计引擎",
6         saveButton: "保存",
7         shareButton: "预览",
8     }
9
10 }
11 var customBase = customBase || {};
12 customBase.uploaderTemp = 0;
13 toastr.options = {
14     closeButton: false,
15     debug: false,
16     progressBar: false,
17     positionClass: "toast-top-center",
18     onclick: null,
19     showDuration: "300",
20     hideDuration: "1000",
21     timeOut: "2000",
22     extendedTimeOut: "1000",
23     showEasing: "swing",
24     hideEasing: "linear",
25     showMethod: "fadeIn",
26     hideMethod: "fadeOut",
27     }
28
29 //customBase.query_set_value = function(itemId,type,value,num){
30 //
31 //    var itemvalue;
32 //    if(num != undefined){
33 //        itemvalue = customBase.getItemValue(itemId,type)[num];
34 //    }else{
35 //        itemvalue = customBase.getItemValue(itemId,type);
36 //    }
37 //    if(value == 8888){
38 //        ////console.log(itemvalue)
39 //    }
40 //    if(itemvalue == undefined || itemvalue == '' || itemvalue == 0){
41 //        customBase.setItemValue(itemId,type,value,"","",num);
42 //    }
43 //}
44
45 //customBase.submitForm = function(){
46 //    ////console.log(window.customBase);
47 //    ////console.log(window.customShow);
48 //    var submit_data = {
49 //        "formId":customShow.options.formid,
50 //        "dataRowNUm":customShow.options.dataRowNum
51 //    };
52 //
53 //    var submit_request =  window.commonAjax("/datamanagement/getBudget",submit_data,"POST",true);
54 //    submit_request.done(function(res){
55 //
56 //    })
57 //}
58 //   2017/10/17 李元杰  点击计算费用后  msgInfo渲染
59
60 customBase.groupInfo = function (_data) {
61     var groupTitle,
62         groupData
63     var container = $('#itemId_12subform').append('<div class="container"></div>')
64     var subform = $('#itemId_12subform .container');
65     // 点击后先清空在渲染页面数据
66     subform.empty();
67     for (var i = 0; i < _data.msgInfo.length; i++) {
68         subform.append(`<li  style="position: relative;float:left;"></li>`);
69         groupTitle = `<span style="color:${_data.msgInfo[i].groupColor}">${_data.msgInfo[i].groupName}</span>`
70         subform.find("li").eq(i).append(groupTitle);
71         subform.find("li").eq(i).append("<div class='ulContent'></div>");
72         for (var j = 0; j < _data.msgInfo[i].groupData.length; j++) {
73             subform.find("li").eq(i).find('.ulContent').append(`<div  style="color:${_data.msgInfo[i].groupColor}" >${_data.msgInfo[i].groupData[j].data}</div>`)
74         }
75     }
76 }
77 //customBase.listen_check = function(res_data,classname){// 实时验证
78 //    var customBase = window.customBase;
79 //    var customShow = window.customShow;
80 //  //  2017/10/17 李元杰  msgInfo渲染
81 //    customBase.groupInfo(res_data)
82 ////    ////console.log(window.customBase);
83 //    _.each(res_data.data,function(redata){
84 //        var cu_item = customBase.options.customItems[redata.fieldKey];
85 //        ////console.log(cu_item)
86 //        if(cu_item != undefined && cu_item.type != "dropdownlist" && cu_item.type != "subform"){
87 //            customBase.query_set_value(cu_item.id,cu_item.type,redata.value);
88 //        }
89 //
90 //        var base_item = $("[fieldKey='" + redata.fieldKey + "']");
91 //        if(base_item.length > 0){
92 //            var base_item_id = base_item.attr('id');
93 //            var base_item_type = base_item.attr('type');
94 //            if(redata.type != "subform"){
95 //                $("#"+base_item_id+"ActiveId").find("." + classname).remove();
96 //                if(redata.msgInfo){
97 //                    var check_minfo = undefined;
98 //                    _.each(redata.msgInfo.header,function(minfo){
99 //                        if(minfo.validate){
100 //                            //console.log(minfo)
101 //                            $("#"+base_item_id+"ActiveId").find("h8[name='el_title']").append("<span class='" + classname + "'>" + minfo.name + ":" + minfo.value + "</span>");
102 //                            check_minfo = minfo;
103 //                        }else{
104 //                            $("#"+base_item_id+"ActiveId").find("h8[name='el_title']").append("<span class='" + classname + "'>" + minfo.name + ":" + minfo.value + "</span>");
105 //                        }
106 //                    });
107 //                    if(check_minfo != undefined){
108 //                            customBase.bind_check(base_item_id,base_item_type,check_minfo,classname);
109 //                            $("#"+base_item_id).on('change', function(){
110 //                                customBase.bind_check(base_item_id,base_item_type,check_minfo,classname);
111 //                            });
112 //                        }
113 //                }
114 //            }else{
115 //                $("#"+base_item_id+"ActiveId").find("." + classname).remove();
116 //                if(redata.msgInfo){
117 //                    _.each(redata.msgInfo.header,function(minfo){
118 //                        $("#"+base_item_id+"ActiveId").find("h8[name='el_title']").append("<span class='" + classname + "'>" + minfo.name + ":" + minfo.value + "</span>");
119 //                    });
120 //                }
121 //                var sub_type = customShow.options.customItemShow.item[base_item_id].tag_Attribute.allcopy;
122 ////                ////console.log(sub_type);
123 //                _.each(redata.child,function(recd,i){
124 //                    _.each(recd.items,function(recd_item){
125 //                        ////console.log(recd_item);
126 //                        ////console.log(customShow.options.customItemShow);
127 //                        var cu_cd_item = customBase.options.customItems[recd_item.fieldKey];
128 //                        ////console.log(cu_cd_item);
129 //                        if(cu_cd_item != undefined && cu_cd_item.type != "dropdownlist"){
130 //                            customBase.query_set_value(cu_cd_item.id,cu_cd_item.type,recd_item.value,i);
131 //                        }
132 //
133 //                        var base_item_cd = $("[fieldKey='" + recd_item.fieldKey + "']:eq('" + i + "')");
134 //                        var base_item_id_cd = base_item_cd.attr('id');
135 //                        var base_item_type_cd = base_item_cd.attr('type');
136 ////                        ////console.log(base_item_cd);
137 ////                        ////console.log(base_item_id_cd);
138 ////                        ////console.log(base_item_type_cd);
139 ////                        ////console.log(recd_item);
140 //                        if(sub_type){
141 //                            $("[id='"+base_item_id_cd+"ActiveId']:eq('" + i + "')").find("." + classname).remove();
142 //                        }else{
143 //                            $("[id='"+base_item_id_cd+"']:eq('" + i + "')").closest("tr").find("p").remove();
144 //                        }
145 //
146 //                        if(recd_item.msgInfo){
147 //                            var check_minfo_cd = undefined;
148 //                            _.each(recd_item.msgInfo.header,function(minfo_cd){
149 ////                                ////console.log($("#"+base_item_id_cd+"ActiveId"));
150 ////                                ////console.log($("[id='"+base_item_id_cd+"ActiveId']:eq('" + i + "')"));
151 //                                if(minfo_cd.validate){
152 //                                    check_minfo_cd = minfo_cd;
153 //                                    if(sub_type){
154 //                                        $("[id='"+base_item_id_cd+"ActiveId']:eq('" + i + "')").find("h8[name='el_title']").append("<span class='" + classname + "'>" + minfo_cd.name + ":" + minfo_cd.value + "</span>");
155 //                                    }else{
156 //                                        customBase.set_p($("[id='"+base_item_id_cd+"']:eq('" + i + "')"));
157 //                                        $("[id='"+base_item_id_cd+"']:eq('" + i + "')").prev("p").append("<span class='" + classname + "'>" + minfo_cd.name + ":" + minfo_cd.value + "</span>");
158 //                                    }
159 //                                }else{
160 //                                    if(sub_type){
161 //                                        $("[id='"+base_item_id_cd+"ActiveId']:eq('" + i + "')").find("h8[name='el_title']").append("<span class='" + classname + "'>" + minfo_cd.name + ":" + minfo_cd.value + "</span>");
162 //                                    }else{
163 //                                        customBase.set_p($("[id='"+base_item_id_cd+"']:eq('" + i + "')"));
164 //                                        $("[id='"+base_item_id_cd+"']:eq('" + i + "')").prev("p").append("<span class='" + classname + "'>" + minfo_cd.name + ":" + minfo_cd.value + "</span>");
165 //                                    }
166 //                                }
167 //                            });
168 //                            if(check_minfo_cd != undefined){
169 //                                customBase.bind_check(base_item_id_cd,base_item_type_cd,check_minfo_cd,classname,sub_type,i);
170 //                                $("[id='"+base_item_id_cd+"']:eq('" + i + "')").on('change', function(){
171 //                                    customBase.bind_check(base_item_id_cd,base_item_type_cd,check_minfo_cd,classname,sub_type,i);
172 //                                });
173 //                            }
174 //                        }
175 //                    });
176 //                });
177 //            }
178 //        }
179 //
180 //    });
181 //
182 //
183 //
184 //
185 ////        _.each(res_data,function(redata){
186 ////            var base_item = $("[fieldKey='" + redata.fieldKey + "']");
187 ////            if(base_item.length > 0){
188 ////                var base_item_id = base_item.attr('id');
189 ////                var base_item_type = base_item.attr('type');
190 ////                ////console.log(base_item_id);
191 ////                ////console.log($("#"+base_item_id+"ActiveId").find(".listen_check"));
192 ////                if($("#"+base_item_id+"ActiveId").find(".listen_check").length == 0){
193 ////                    $("#"+base_item_id+"ActiveId").find("h8[name='el_title']").append("<span class='listen_check'>" + redata.amount + "</span>");
194 ////                }else{
195 ////                    $("#"+base_item_id+"ActiveId").find(".listen_check").html(redata.amount);
196 ////                }
197 ////                var now_value_s = customBase.getItemValue(base_item_id,base_item_type);
198 ////                    $("#"+base_item_id+"ActiveId").find(".listen_check").css("color","#333");
199 ////                    if(now_value_s != redata.amount){
200 ////                        $("#"+base_item_id+"ActiveId").find(".listen_check").css("color","red");
201 ////                    }
202 ////                $("#"+base_item_id).on('change', function(){
203 ////                    var now_value = customBase.getItemValue(base_item_id,base_item_type);
204 ////                    $("#"+base_item_id+"ActiveId").find(".listen_check").css("color","#333");
205 ////                    if(now_value != redata.amount){
206 ////                        $("#"+base_item_id+"ActiveId").find(".listen_check").css("color","red");
207 ////                    }
208 ////                });
209 ////            }
210 ////        });
211 //}
212
213 //customBase.bind_check = function(base_item_id,base_item_type,minfo,classname,sub_type,i){//验证方法
214 //    if( i != undefined){
215 //        if(i == 0){
216 //            var now_value = customBase.getItemValue(base_item_id, base_item_type);
217 //        }else{
218 //            var now_value = customBase.getItemValue(base_item_id, base_item_type)[i];
219 //        }
220 //        ////console.log(base_item_id);
221 //        ////console.log($("#" + base_item_id + "ActiveId"));
222 //        ////console.log($("[id='"+base_item_id+"ActiveId']:eq('" + i + "')"));
223 //        if(sub_type){
224 //            $("[id='"+base_item_id+"ActiveId']:eq('" + i + "')").find("." + classname).css("color", "#333");
225 //            if(now_value != minfo.value) {
226 //                $("[id='"+base_item_id+"ActiveId']:eq('" + i + "')").find("." + classname).css("color", "red");
227 //            }
228 //        }else{
229 //            $("[id='"+base_item_id+"']:eq('" + i + "')").prev("p").find("." + classname).css("color", "#333");
230 //            if(now_value != minfo.value) {
231 //                $("[id='"+base_item_id+"']:eq('" + i + "')").prev("p").find("." + classname).css("color", "red");
232 //            }
233 //        }
234 //
235 //    }else{
236 //        var now_value = customBase.getItemValue(base_item_id, base_item_type);
237 //        $("#" + base_item_id + "ActiveId").find("." + classname).css("color", "#333");
238 //        if(now_value != minfo.value) {
239 //            $("#" + base_item_id + "ActiveId").find("." + classname).css("color", "red");
240 //        }
241 //    }
242 //}
243
244 //customBase.set_p = function(item){
245 //    var p_height = "19.2px";
246 //    if(item.closest("tr").find("p").length == 0){
247 //        var item_td = item.closest("tr").find("td");
248 //        item_td.each(function(){
249 //            $(this).prepend("<p style='height:" + p_height + "'></p>")
250 //        });
251 //    }
252 //}
253 customBase.options = {
254     customItems: {},
255     uploaderItem: {},
256     uploaderItemReady: {},
257     uploaderFile: {},
258     fileuuid: "",
259     dropdownlistText: {},
260     uploaderFileName: {},
261     formbaseInfo: "",
262     zTreeOnClickItems: {}
263 }
264 //项目编辑(设定及取得值)
265 customBase.itemEdit = {
266     //单行文本
267     text: {
268         getItem: function (itemId) {
269             itemReturn = [];
270             var items = $(itemId);
271             for (var i = 0; i < items.length; i++) {
272                 itemReturn[i] = items[i].value;
273             };
274             if (itemReturn.length == 1) {
275                 return itemReturn[0];
276             } else {
277                 return itemReturn;
278             }
279
280         },
281         setItem: function (itemId, value, showClass) {
282             if (showClass == undefined) {
283                 showClass = 'customViewUEditorCss';
284             }
285             if (value == null) {
286                 value = "";
287             }
288             var itemL = $("." + showClass + " " + itemId).length;
289             if (itemL > value.length) {
290                 itemL = value.length;
291             }
292             if (itemL == 1) {
293                 if ('customShow' == showClass) {
294                     $("." + showClass).find(itemId)[0].setAttribute("readonly", "readonly");
295                 }
296                 $("." + showClass).find(itemId)[0].value = value;
297             } else if (itemL == 0) {
298                 for (var i = 0; i < $("." + showClass + " " + itemId).length; i++) {
299                     if ('customShow' == showClass) {
300                         $("." + showClass + " " + itemId)[i].setAttribute("readonly", "readonly");
301                     }
302                     $("." + showClass + " " + itemId)[i].value = value;
303                 };
304             } else {
305                 for (var i = 0; i < itemL; i++) {
306                     if ('customShow' == showClass) {
307                         $("." + showClass + " " + itemId)[i].setAttribute("readonly", "readonly");
308                     }
309                     $("." + showClass + " " + itemId)[i].value = value[i]
310                 };
311             }
312     
313         },
314     },
315     //单选按钮组
316     checkboxRadio: {
317         getItem: function (itemId, type) {
318             var itemList = $("." + itemId + "value");
319             var itemListReturn = [];
320             // 数组循环取得
321             for (var j = 0; j < itemList.length; j++) {
322
323                 if (type == "radio") {
324                     var items = $(itemList[j]).find(".custom-radio");
325                 } else {
326                     var items = $(itemList[j]).find(".custom-check");
327                 }
328                 var checkItem = [];
329                 var z = 0;
330                 for (var i = 0; i < items.length; i++) {
331                     if (items[i].className.indexOf("cur") > 0) {
332                         checkItem[z] = items[i].getAttribute("value");
333                         z++;
334                     } else {
335                     }
336                 };
337                 itemListReturn[j] = checkItem;
338                 z++;
339             };
340             return itemListReturn;
341         },
342         setItem: function (itemId, type, value, showClass) {
343             //被选择项目设定
344             checkboxRadioItem = function (itemList, value) {
345                 console.log(itemList)
346                 if (typeof value == "string") {
347                     value = [value];
348                 }
349                 for (var i = 0; i < itemList.length; i++) {
350                     for (var j = 0; j < value.length; j++) {
351                         if (value[j] == itemList[i].getAttribute("value")) {
352
353                             $(itemList[i]).addClass('cur');
354                         }
355                     }
356                 }
357             }
358             var itemL = $("." + showClass + " ." + itemId + "value");
359             if (typeof value == "string") {
360                 value = [value];
361             }
362
363             //数据赋值
364             for (var i = 0; i < itemL.length; i++) {
365                 var valueTemp = value[i];
366                 if (type == "radio") {
367                     var items = $(itemL[i]).find(".custom-radio");
368                 } else {
369                     var items = $(itemL[i]).find(".custom-check");
370                 }
371                 items.removeClass('cur');
372                 checkboxRadioItem(items, valueTemp)
373             }
374         },
375     },
376     //复选框组
377     checkbox: {
378         getItem: function (itemId) {
379             var checkItem = "";
380             if ($(itemId)[0] != undefined) {
381                 checkItem = $(itemId)[0].className.replace("custom-check", "");
382             }
383             if (checkItem.indexOf("cur") > 0) {
384                 checkItem = true;
385             } else {
386                 checkItem = false;
387             }
388             return checkItem;
389         },
390         setItem: function (itemId, value) {
391             if (value) {
392                 $(itemId).addClass('cur')
393             } else {
394                 $(itemId).removeClass('cur');
395             }
396         },
397     },
398     // HTML内容
399     htmlediter: {
400         getItem: function (itemId) {
401             itemId = itemId + "Item";
402             return UE.getEditor(itemId).getContent();
403         },
404         setItem: function (itemId, value, showClass) {
405             // itemId = itemId+"Item";
406             // if(showClass ==undefined){
407             //     showClass = 'customViewUEditorCss';
408             // }
409             // UE.getEditor(itemId).ready(function(){
410             //     UE.getEditor(itemId).setContent(value);
411             // });
412
413         },
414     },
415     dropdownlistView: {
416         getItem: function (itemId) {
417             return $(itemId).select2("val");
418         },
419         setItem: function (itemId, value) {
420             if (value) {
421                 $(itemId).select2("val", value);
422             } else {
423                 $('.selectItme').attr('value', "");
424                 $('.val-card').remove();
425             }
426         },
427     },
428     dropdownlist: {
429         getItem: function (itemId) {
430             return $(itemId).select2("val");
431         },
432         setItem: function (itemId, value) {
433             if (value) {
434                 $(itemId).select2("val", value);
435             } else {
436                 $('.selectItme').attr('value', "");
437                 $('.val-card').remove();
438             }
439         },
440     },
441     // 下拉框(文本取得)
442     dropdownlistText: {
443         getItem: function (itemId) {
444             var itemList = $(".customViewUEditorCss ." + itemId + "value");
445             var itemListReturn = [];
446             var select2ItemList = customBase.options.dropdownlistText[itemId];
447             for (var i = 0; i < itemList.length; i++) {
448                 var select2Item = $(itemList[i]).select2("data");
449                 var items = [];
450                 for (var j = 0; j < select2Item.length; j++) {
451                     for (var z = 0; z < select2ItemList.length; z++) {
452                         if (select2ItemList[z].text == select2Item[j].text) {
453                             items[j] = select2ItemList[z].value;
454                         }
455                     }
456                     // items[j] = select2Item[j].text;
457                 };
458                 itemListReturn[i] = items;
459             };
460
461             return itemListReturn;
462         },
463         setItem: function (itemId, value, showClass, dropdowntype) {
464             console.log(value)
465             //              var select2Item = customBase.options.dropdownlistText[itemId];
466             //              //单多选框数据设定
467             //              //2017/10/27 马习同修改
468             //              var customItem = customBase.options.customItems;
469             //              var itemAttr = "";
470             //              for(let key in customItem){
471             //                  if(customItem[key].id == itemId){
472             //                      itemAttr = customItem[key];
473             //                  }
474             //              }
475             //              console.log(_.cloneDeep(customItem))
476             //              console.log(itemAttr);
477             //              //2017/10/27 马习同修改
478             //              setelect2Item = function (itemId,value){
479             //                  if(typeof value == "string"){
480             //                      value = [value];
481             //                  }
482             //                  var itemsTemp = [];
483             //                  for (var i = 0; i < value.length; i++) {
484             //                      for (var j = 0; j < select2Item.length; j++) {
485             //                          if(select2Item[j].value ==  value[i]){
486             //                              var id = select2Item[j].id;
487             //                              itemsTemp[i] = id;
488             //                          }
489             //                      };
490             //                  }
491             //                  $(itemId).val(itemsTemp).trigger("change");
492             //              }
493             //              //多个下拉菜单  马习同
494             //              var itemList = $("."+showClass+" #itemId_"+itemAttr.parentsubFormNum+" ."+itemId+"value");
495             //              var itemList1 = $("."+showClass+" ."+itemId+"value");
496             //                console.log(itemList);
497             //                console.log(itemList1);
498             //              console.log(value)
499             //              if(itemList.length ==1){
500             //                  setelect2Item(itemList[0],value);
501             //              }else{
502             //                    for (var i = 0; i < itemList.length; i++) {
503             //                        console.log(value)
504             //                        console.log(itemList[i],value[i])
505             //                       setelect2Item(itemList1[i],value[i]);
506             //                    }
507             //              }
508             //
509             //原代码
510             //                            var select2Item = customBase.options.dropdownlistText[itemId];
511             //              //单多选框数据设定
512             //              setelect2Item = function (itemId,value){
513             //                  if(typeof value == "string"){
514             //                      value = [value];
515             //                  }
516             //                  var itemsTemp = [];
517             //                  for (var i = 0; i < value.length; i++) {
518             //                      for (var j = 0; j < select2Item.length; j++) {
519             //                          if(select2Item[j].value ==  value[i]){
520             //                              var id = select2Item[j].id;
521             //                              itemsTemp[i] = id;
522             //                          }
523             //                      };
524             //                  }
525             //                  $(itemId).val(itemsTemp).trigger("change");
526             //              }
527             //              //多个下拉菜单
528             //              var itemList = $("."+showClass+" ."+itemId+"value");
529             //              if(itemList.length ==1){
530             //                  setelect2Item(itemList[0],value);
531             //              }else{
532             //
533             //                  for (var i = 0; i < itemList.length; i++) {
534             //                       setelect2Item(itemList[i],value[i]);
535             //                  }
536             //              }
537         },
538     },
539     dropdownlistText2: {
540         getItem: function (itemId) {
541             // var itemList = $(".customViewUEditorCss ."+itemId+"value");
542             // var itemListReturn =[];
543             // var select2ItemList = customBase.options.dropdownlistText[itemId];
544             // for (var i = 0; i < itemList.length; i++) {
545             //     var select2Item = $(itemList[i]).select2("data");
546             //     var items = [];
547             //     for (var j = 0; j < select2Item.length; j++) {
548             //         for(var z=0;z<select2ItemList.length;z++){
549             //             if(select2ItemList[z].text ==  select2Item[j].text){
550             //                 items[j] = select2ItemList[z].value;
551             //             }
552             //         }
553             //         // items[j] = select2Item[j].text;
554             //     };
555             //     itemListReturn[i] = items;
556             // };
557             var itemListReturn = xhSelect.getValue(itemId);
558             return itemListReturn;
559         },
560         setItem: function (itemId, value, showClass, dropdowntype) {
561             //2017/10/27 马习同修改
562             console.log(value);
563             var customItem = customBase.options.customItems;
564             var itemAttr = "";
565             for (let key in customItem) {
566                 if (customItem[key].id == itemId) {
567                     itemAttr = customItem[key];
568                 }
569             }
570             //2017/10/27 马习同修改
571
572             var select2Item = customBase.options.dropdownlistText[itemId];
573             if (itemAttr.parentsubFormNum != 0) {//非子表单中 无需添加parentformnum 李伟民  11-14
574                 var itemList = $("#itemId_" + itemAttr.parentsubFormNum + " #" + itemId);
575             } else {
576                 var itemList = $("#" + itemId);
577             }
578             console.log(itemList);
579             if (itemList.length == 1) {
580                 // setelect2Item(itemId,value,0);
581                 xhSelect.setValue(itemId, value, 0)
582             } else {
583
584                 for (var i = 0; i < itemList.length; i++) {
585                     //  setelect2Item(itemId,value[i],i);
586                     xhSelect.setValue(itemId, value[i], i)
587                 }
588             }
589
590         },
591     },
592     // 下拉框(值取得)
593     dropdownlisVal: {
594         getItem: function (itemId) {
595             var itemList = $("." + itemId + "value");
596             var itemListReturn = [];
597             for (var i = 0; i < itemList.length; i++) {
598                 var select2Item = $(itemList[i]).select2("val");
599                 var items = [];
600                 for (var j = 0; j < select2Item.length; j++) {
601                     items[j] = select2Item[j].text;
602                 };
603                 itemListReturn[i] = items;
604             };
605             return itemListReturn;
606         },
607         setItem: function (itemId, value) {
608             $(itemId).select2("val", value);
609         },
610     },
611     //文件上传 图片
612     fileupload: { //-------------todo------------------
613         getItem: function (itemId) {
614             var fileReturn = {};
615             for (i in customBase.options.uploaderItem[itemId]) {
616                 if (customBase.options.uploaderItem[itemId].hasOwnProperty(i)) {
617                     var timestamp = new Date().getTime();
618                     var idt = i.replace("WU", timestamp);
619                     fileReturn[idt] = customBase.options.uploaderItem[itemId][i];
620                     // fileReturn.push(customBase.options.uploaderItemReady[itemId][i]);
621                 }
622             };
623             //////console.log(fileReturn);
624             return fileReturn;
625         },
626         setItem: function (itemId, value) {
627             //无此情况
628         },
629     },
630     tree: { //-------------todo------------------
631         getItem: function (itemId) {
632
633             var returnItem = [];
634             var treeItem = $('div#' + itemId);
635             var dataItemJSson;
636             for (var i = 0; i < treeItem.length; i++) {
637                 if (treeItem[i].getAttribute("value") == "") {
638                     var treeItem = {};
639                 } else {
640                     ////console.log(selectItme[i].getAttribute("value"));
641                     dataItemJSson = $.parseJSON(treeItem[i].getAttribute("value"));
642                 }
643
644                 var jn = 0;
645                 returnItem[i] = [];
646                 for (j in dataItemJSson) {
647                     returnItem[i][jn] = j;
648                     jn++;
649                 }
650             }
651             return returnItem;
652         },
653         setItem: function (itemId, value) {
654             var treeDiv = $('div#' + itemId);
655             console.log(value)
656             // 判断是否在子表单内
657             var isSubformTree = false;
658             _.forIn(customShow.options.customItemShow.item, function (value, key) {
659                 if (value.tag_Id == itemId && value.parentsubFormNum != 0) {
660                     isSubformTree = true;
661                 }
662             });
663        
664             //  不在子表单内的树
665             if (!isSubformTree) {
666                 var dataObj = {}
667                 var valueData = [];
668                 // 更新数据的时候需要在div上绑定一个存储数据的value
669                 //  单选
670                 if(value)
671                 console.log(value);
672                 // if(value == ' '){
673                 //     if(value == ' '){
674                 //         value =  window.localStorage.getItem('businessTypeAuto');
675                 //     }
676                 // }else{
677                     if (typeof value == "string") {
678                         dataObj[value] = '1'
679                     } else {
680                         for (var j = 0; j < value.length; j++) {
681                             valueData[j] = value[j].split(',')
682                             dataObj[valueData[j]] = '1'
683                         }
684                     }
685                     $('#' + itemId).attr('value', JSON.stringify(dataObj))
686                     console.log(value)
687                     console.log(itemId)
688                     var  b = $('#'+itemId + "tree")
689                     console.log($('#'+itemId + "tree"))
690                     var treeObj = $.fn.zTree.getZTreeObj(itemId + "tree");
691                     console.log(treeObj)
692                     if (treeObj == null) {
693                         return;
694                     }
695                     if (typeof value == "string") {
696                         value = [value];
697                     }
698                     //   2017/11/6 回显的地方
699                     for (var i = 0, l = value.length; i < l; i++) {
700                         if (treeObj.setting.check.chkStyle == "radio") {
701                             //  单选
702                             console.log(value)
703                             var nodes = treeObj.getNodeByParam("id", value[i], null);
704                             console.log(nodes);
705                             if (_.isNull(nodes)) {
706                                 // treeObj.checkAllNodes(false);
707                                 // return false;
708                             } else {
709                                 if (value == nodes.id) {
710                                     value = nodes.name;
711                                 }
712                                 console.log(value)
713                                 if (nodes != null) {
714                                     // 2017 /11/6 选中
715                                     //选择节点设定
716                                     treeObj.checkNode(nodes, true, true);
717                                     treeObj.expandAll(true);
718                                 }
719                             }
720                         } else {
721                             //  多选
722                             for (var j = 0; j < value[i].length; j++) {
723                                 //取得设定节点
724                                 console.log(value[j]);
725                                 var nodes = treeObj.getNodeByParam("id", value[j], null);
726                                 console.log(nodes)
727                                 if (_.isNull(nodes)) {
728                                     // treeObj.checkAllNodes(false);
729                                     // return false;
730                                 } else {
731                                     if (value[j] == nodes.id) {
732                                         value[j] = nodes.name;
733                                     }
734                                     console.log(nodes)
735                                     if (nodes != null) {
736                                         // 2017 /11/6 选中
737                                         //选择节点设定
738                                         treeObj.checkNode(nodes, true, true);
739                                         treeObj.expandAll(true);
740                                     }
741                                 }
742                             }
743                         }
744                     }
745                     //  详细页面的回显
746                     var showTreeDiv = ` <div style="word-break:break-all;border-width: 0px;border-style: solid;border-color: rgb(204, 204, 204);width:200px;" class="customShowItemClass edui-default customShowItemClassTemp">
747                             ${value}
748                                 </div>`
749                     $('#customShow').find(`#${itemId}ActiveId`).children(':nth-child(4)').remove();
750                     $('#customShow').find(`#${itemId}ActiveId`).append(showTreeDiv);
751                     $('#' + itemId).parents('div[type="tree"]').find('.citySel').val(value);
752                 // }
753             } else {
754                 //  子表单里只有一颗树的时候
755                 if (treeDiv.length == 1) {
756                     var dataObj = {}
757                     var valueData = [];
758                     // 更新数据的时候需要在div上绑定一个存储数据的value
759                     //  单选
760                     console.log(value);
761                     // 不在子表单里的树更新时需要的数据
762                     if(value){
763                         if (typeof value[0] == "string" && value[0]!= '') {
764                             dataObj[value[0]] = '1'
765                         } else {
766                             for (var i = 0; i < value[0].length; i++) {
767                                 valueData[i] = value[0][i].split(',')
768                                 dataObj[valueData[i]] = '1'
769                             }
770                         }
771                         $('#' + itemId).attr('value', JSON.stringify(dataObj))
772                         var treeObj = $.fn.zTree.getZTreeObj(itemId + "tree");
773                         if (treeObj == null) {
774                             return;
775                         }
776                         if (typeof value == "string") {
777                             value = [value];
778                         }
779                         //   2017/11/6 回显的地方
780                         for (var i = 0, l = value.length; i < l; i++) {
781                             if (treeObj.setting.check.chkStyle == "radio") {
782                                 // 12/6   因为会触发customShow.addtree()导致ul 的id 变更
783                                 var treeDiv = $('div#' + itemId);
784                                 var ultreeId = $(treeDiv).find('ul').attr('id');
785                                 var treeObj = $.fn.zTree.getZTreeObj(ultreeId);
786                                 // var treeObj = $.fn.zTree.getZTreeObj(itemId + "tree1");
787                                 //  单选
788                                 var nodes = treeObj.getNodeByParam("id", value[i], null);
789                                 console.log(nodes)
790                                 if (_.isNull(nodes)) {
791     
792                                     var  tid = '';
793                                     nodes = treeObj.getCheckedNodes(true);
794                                     for (var i = 0; i < nodes.length; i++) {
795                                         tid = nodes[i].tId
796                                     }
797                                     console.log(tid)
798                                     // 强行制空
799                                     $('#'+tid+'_check').click()
800                                     $('#' + tid + '_check').click()
801                                     $(treeDiv).prev().find('.citySel').val('')
802                                 } else {
803                                     if (value[i] == nodes.id) {
804                                         value[i] = nodes.name;
805                                     }
806                                     if (nodes != null) {
807                                         // 2017 /11/6 选中
808                                         //选择节点设定
809                                         console.log(nodes)
810                                         treeObj.checkNode(nodes, true, true);
811                                         treeObj.expandAll(true);
812                                         console.log(treeObj)
813                                         var  tid = '';
814                                             nodes11 = treeObj.getCheckedNodes(true);
815                                             console.log(nodes11)
816                                         for (var i = 0; i < nodes11.length; i++) {
817                                             tid = nodes11[i].tId
818                                         }
819                                         console.log(tid);
820                                         // console.log($('#'+tid+'_check'))
821                                         // $('#'+tid+'_check').click()
822                                         // $('#'+tid+'_check').click()
823     
824                                     }
825                                 }
826                             } else {
827                                 //  多选
828                                 for (var j = 0; j < value[i].length; j++) {
829                                     //取得设定节点
830                                     console.log(value[i][j]);
831                                     var nodes = treeObj.getNodeByParam("id", value[i][j], null);
832                                     console.log(nodes)
833                                     if (_.isNull(nodes)) {
834                                         // treeObj.checkAllNodes(false);
835                                         // return false;
836                                     } else {
837                                         if (value[i][j] == nodes.id) {
838                                             value[i][j] = nodes.name;
839                                         }
840                                         console.log(nodes)
841                                         if (nodes != null) {
842                                             // 2017 /11/6 选中
843                                             //选择节点设定
844                                             treeObj.checkNode(nodes, true, true);
845                                             treeObj.expandAll(true);
846                                              console.log(treeObj)
847     
848                                         }
849                                     }
850                                 }
851                             }
852                         }
853                         //      回显到table表格里
854                         var showIdTbale = $(`#${itemId}`).parents('.subformCss').attr('id');
855                         $(`#${itemId}`).parent('div[name="TreeWin"]').find('.citySel').val(value);
856                         var deitSubFormsTree = $(`#${showIdTbale}`).find('tbody').find('tr:nth-child(2)').find('td');
857                         for (var i = 1; i < deitSubFormsTree.length - 1; i++) {
858                             //  将编辑页面的树形ipnut 里面的值 放到展示页面里
859                             var value = $(deitSubFormsTree[i]).find('.citySel').val();
860                             $(`#customShow  #${showIdTbale}ActiveId`).find(`#${showIdTbale}`).find('.trContentClass').find(`td:nth-child(${i + 1})`).find('.customShowItemClass').html(value)
861                         }
862                     
863                     }
864
865                 } else {
866                     // 子表单内td里面的div更改
867                     var oNode = '<div style="word-break:break-all;border-width: 0px;border-style: solid;border-color: rgb(204, 204, 204);width:200px;" class="customShowItemClassTemp customShowItemClass ' + id + '_showItem edui-default">';
868                     oNode += "</div>";
869                     var showItem = $($(".customShow").find("#" + itemId));
870                     for (var i = 0; i < showItem.length; i++) {
871                         $($(showItem[i])[0]).after(oNode);
872                         $($(showItem[i])[0]).remove();
873                     }
874                     var treeDiv = $('div#' + itemId);
875                     console.log(treeDiv)
876                     // 插入input里的value
877                     var iptValue = [];
878                     var iptValueObj = {};
879                     // 更新的时候需要的数据
880                     var dataObj = {}
881                     var valueData = [];
882                     for (var j = 0; j < treeDiv.length; j++) {
883                         var ultreeId = $(treeDiv[j]).find('ul').attr('id');
884                         var treeObj = $.fn.zTree.getZTreeObj(ultreeId);
885                         if (treeObj == null) {
886                             return;
887                         }
888                         if (typeof value == "string") {
889                             value = [value];
890                         }
891                         //   2017/11/6 回显的地方
892                         // 单选
893                         if (treeObj.setting.check.chkStyle == "radio") {
894                             console.log($(treeDiv[j]))
895                             console.log(value);
896                             for (var i = 0; i < value.length; i++) {
897                                 if (value[i] == '') {
898                                     console.log(1)
899                                     // dataObj = {}
900                                 } else {
901                                     console.log(2)
902                                     if (i == j) {
903                                         dataObj[value[i]] = '1';
904                                     }
905                                 }
906                             }
907                             $(treeDiv[j]).attr('value', JSON.stringify(dataObj))
908                             dataObj = {}
909                             console.log(j)
910                             console.log(value[j])
911                             var nodes = treeObj.getNodeByParam("id", value[j], null);
912                             console.log(nodes)
913                             console.log(treeObj)
914                             if (_.isNull(nodes)) {
915                                 // treeObj.checkAllNodes(false);
916                                 var  tid = '';
917                                     nodes = treeObj.getCheckedNodes(true);
918                                 for (var i = 0; i < nodes.length; i++) {
919                                     tid = nodes[i].tId
920                                 }
921                                 console.log(tid)
922                                 $('#' + tid + '_check').click()
923                                 $(treeDiv[j]).prev().find('.citySel').val('')
924                             } else {
925                                 if (value[j] == nodes.id) {
926                                     iptValue.push(nodes.name);
927                                 }
928                                 if (nodes != null) {
929                                     // 2017 /11/6 选中
930                                     //选择节点设定
931                                     console.log(treeObj);
932                                     console.log(nodes)
933                                     treeObj.checkNode(nodes, true, true);
934                                     treeObj.expandAll(true);
935                                 }
936                                 for (var k = 0; k < iptValue.length; k++) {
937                                     $(treeDiv[j]).prev().find('.citySel').val(iptValue[k])
938                                 }
939                             }
940
941                         } else {
942                             // 多选
943
944                             console.log(value[j])
945                             if (typeof value[j] == "string") {
946                                 var strValue = value[j].split(',');
947                                 // 导入excel时状态多选为字符串形式
948                                 if (strValue.length > 1) {
949                                     console.log(strValue)
950                                     for (var n = 0; n < strValue.length; n++) {
951                                         var nodes = treeObj.getNodeByParam("id", strValue[n], null);
952                                         console.log(nodes)
953                                         if (strValue[n] == '') {
954
955                                         } else {
956                                             dataObj[strValue[n]] = '1';
957                                         }
958                                         if (_.isNull(nodes)) {
959                                             // treeObj.checkAllNodes(false);
960                                             // return false;
961                                             $(treeDiv[j]).prev().find('.citySel').val('')
962
963                                         } else {
964                                             if (strValue[n] == nodes.id) {
965                                                 iptValue.push(nodes.name);
966                                             }
967                                             if (nodes != null) {
968                                                 // 2017 /11/6 选中
969                                                 //选择节点设定
970                                                 treeObj.checkNode(nodes, true, true);
971                                                 treeObj.expandAll(true);
972                                             }
973                                         }
974                                         $(treeDiv[j]).attr('value', JSON.stringify(dataObj))
975
976                                     }
977                                     $(treeDiv[j]).prev().find('.citySel').val(iptValue.join(','))
978                                     iptValue = [];
979                                     dataObj = {};
980                                 } else {
981                                     var nodes = treeObj.getNodeByParam("id", value[j], null);
982                                     for (var i = 0; i < value.length; i++) {
983                                         if (value[i] == '') {
984
985                                         } else {
986                                             if (i == j) {
987                                                 dataObj[value[i]] = '1';
988                                             }
989                                         }
990                                     }
991                                     $(treeDiv[j]).attr('value', JSON.stringify(dataObj))
992                                     dataObj = {}
993                                     if (_.isNull(nodes)) {
994                                         // treeObj.checkAllNodes(false);
995                                         // return false;
996                                     } else {
997                                         if (value[j] == nodes.id) {
998                                             iptValue.push(nodes.name);
999                                         }
1000                                         if (nodes != null) {
1001                                             // 2017 /11/6 选中
1002                                             //选择节点设定
1003                                             treeObj.checkNode(nodes, true, true);
1004                                             treeObj.expandAll(true);
1005                                         }
1006                                         for (var k = 0; k < iptValue.length; k++) {
1007                                             $(treeDiv[j]).prev().find('.citySel').val(iptValue[k])
1008                                         }
1009                                         iptValue = [];
1010                                     }
1011                                 }
1012                             } else {
1013                                 var dataObj = {}
1014                                 var valueData = [];
1015                                 for (var i = 0; i < value[j].length; i++) {
1016                                     valueData[i] = value[j][i].split(',')
1017                                     dataObj[valueData[i]] = '1'
1018                                 }
1019                                 $(treeDiv[j]).attr('value', JSON.stringify(dataObj))
1020                                 for (var k = 0; k < value[j].length; k++) {
1021                                     //   j是 有几个input框
1022                                     //   k是  value 里面的数据还会有呈现数组的形式
1023                                     dataObj = {}
1024                                     valueData = [];
1025                                     var nodes = treeObj.getNodeByParam("id", value[j][k], null);
1026                                     if (_.isNull(nodes)) {
1027                                       
1028                                     } else {
1029                                         if (value[j][k] == nodes.id) {
1030                                             if (k <= value[j].length) {
1031                                                 iptValue.push(nodes.name);
1032                                             }
1033                                         }
1034                                         iptValueObj[k] = iptValue;
1035                                         // if (nodes != null) {
1036                                             // 2017 /11/6 选中
1037                                             //选择节点设定
1038                                             treeObj.checkNode(nodes, true, true);
1039                                             treeObj.expandAll(true);
1040                                         // }
1041                                     }
1042                                 }
1043                                 for (index in iptValueObj) {
1044                                     $(treeDiv[j]).prev().find('.citySel').val(iptValueObj[index].join(','))
1045                                 }
1046                                 iptValue = [];
1047                                 iptValueObj = {};
1048                             }
1049
1050                         }
1051                         //  获取父级ID
1052                         var showIdTable = $(`#${itemId}`).parents('.subformCss').attr('id');
1053                         // 获取当前树形在整个td的下标
1054                         var subformDataIndex = $(`#${itemId}`).parents('td').index();
1055                         var subformTr = $('#customShow tr#' + showIdTable + "subformTr");
1056                         var subformValue = $($('.tabBox' + ' #' + showIdTable + "subformTr")[j]).find('td').eq(subformDataIndex).find('.citySel').val()
1057                         $(subformTr[j]).children().eq(subformDataIndex).find('.customShowItemClassTemp').html(subformValue);
1058                     }
1059                 }
1060             }
1061             
1062         },
1063     },
1064     //选择表单控件
1065     mytext: {
1066         getItem: function (itemId) {
1067             //                var newmytextObj = $('#'+itemId+' ul');
1068             //                console.log(newmytextObj);
1069             //                var chooseFormData = {};
1070             //                var str = [];
1071             //                _.each(newmytextObj,(opt,i)=>{
1072             //                    var $mytextObj = $('#'+opt.id+' [class="data1 DATAROWNUM"]');
1073             //              var $mytextObj2 = $('#'+opt.id+' [class="data2 DATAROWNUM"]');
1074             ////              console.log($mytextObj);
1075             ////              console.log($mytextObj2);
1076             ////              console.log($mytextObj.html());
1077             ////              console.log($mytextObj2.html());
1078             ////              for(let i = 0;i < $mytextObj.length ;i++){
1079             ////                  var $myText = $mytextObj.eq(i).html();
1080             ////                  console.log($myText)
1081             ////                  console.log($mytextObj2.eq(i).html())
1082             ////                                    chooseFormData[$myText] = $mytextObj2.eq(i).html();
1083             ////
1084             ////              }
1085             ////              dataArr1.push($mytextObj2.html());
1086             //                                console.log(i);
1087             //                                console.log(newmytextObj.length);
1088             //                                if(i<newmytextObj.length-1){
1089             //                                    str += $mytextObj2.html()+",";
1090             //                                }else{
1091             //                                    str += $mytextObj2.html();
1092             //                                }
1093             //                })
1094             //                console.log(str)
1095
1096             var str = $('#' + itemId).attr("mxtVal");//关联数据 取值 11-07  李伟民
1097             return str;
1098
1099
1100         },
1101         setItem: function (itemId, value) {
1102             console.log(value);
1103             if (!_.isString(value)) {
1104                 var new_value = [];
1105                 _.each(value.list, function (v) {
1106                     if (v.DATAROWNUM) {
1107                         new_value.push(v.DATAROWNUM);
1108                     }
1109                 });
1110                 new_value = new_value.join();
1111                 $('#' + itemId).attr("mxtVal", new_value);//关联数据 存值 11-07  李伟民
1112             } else {
1113                 $('#' + itemId).attr("mxtVal", value);//关联数据 存值 11-07  李伟民
1114             }
1115         },
1116     },
1117 };
1118
1119
1120 //画面弹出信息
1121 customBase.alert = function (type, message) {
1122     if (type == "E") {
1123         toastr.error(message);
1124     } else if (type == "I") {
1125         toastr.info(message);
1126     } else if (type == "W") {
1127         toastr.warning(message);
1128     } else if (type == "S") {
1129         toastr.success(message);
1130     } else {
1131         toastr.error(message);
1132     }
1133 }
1134
1135 //根据别名取得字段Id
1136 customBase.getfieldKeyFoItemId = function (fieldKey) {
1137     return customBase.options.customItems[fieldKey].id;
1138 }
1139
1140 //取得message信息
1141 customBase.getMessage = function (messageID) {
1142     // 12/11
1143     var strMessage = "";
1144     switch (messageID) {
1145         case "mesage_ID001":
1146             strMessage = "子表单中无法追加此控件!";
1147             break;
1148         case "mesage_ID002":
1149             strMessage = "表单别名重复,请对别名进行修改!";
1150             break;
1151         case "mesage_ID003":
1152             strMessage = "表单保存成功!";
1153             break;
1154         case "mesage_ID004":
1155             strMessage = '项目必须输入!';
1156             break;
1157         case "mesage_ID005":
1158             strMessage = "上传成功!";
1159             break;
1160         case "mesage_ID006":
1161             strMessage = "操作过于频繁,请稍后再执行!";
1162             break;
1163         case "mesage_ID007":
1164             strMessage = "画面字段数据过多,保存失败!";
1165             break;
1166         case "mesage_ID008":
1167             strMessage = "单行文本的最大长度不能超过150!";
1168             break;
1169         case "mesage_ID009":
1170             strMessage = "'请输入有效的手机号码!";
1171             break;
1172         case "mesage_ID010":
1173             strMessage = "'请输入正确的网址!";
1174             break;
1175         case "mesage_ID011":
1176             strMessage = "'请输入有效的身份证号!";
1177             break;
1178         case "mesage_ID012":
1179             strMessage = "请输入有效的邮箱!";
1180             break;
1181         case "mesage_ID013":
1182             strMessage = "请输入表单名!";
1183             break;
1184         case "mesage_ID014":
1185             strMessage = "表单版本重复,请修改!";
1186             break;
1187         case "mesage_ID015":
1188             strMessage = "保存成功!";
1189             break;
1190         case "mesage_ID016":
1191             strMessage = "表单别名必须输入,请对别名进行修改!";
1192             break;
1193         case "mesage_ID017":
1194             strMessage = "表单的宽高必须输入!";
1195             break;
1196         case "mesage_ID018":
1197             strMessage = "请输入版本信息!";
1198             break;
1199         case "mesage_ID019":
1200             strMessage = "请输入整数!";
1201             break;
1202         case "mesage_ID020":
1203             strMessage = "整数长度超出设定范围!";
1204             break;
1205         case "mesage_ID021":
1206             strMessage = "小数长度超出设定范围!";
1207             break;
1208         case "mesage_ID022":
1209             strMessage = "条形码默认值不能为空!";
1210             break;
1211         case "mesage_ID023":
1212             strMessage = "长度超出设定范围!";
1213             break;
1214         case "mesage_ID024":
1215             strMessage = "请选择正确的部门";
1216             break;
1217         case "mesage_ID025":
1218             strMessage = "预算余额不足,不可退回";
1219             break;
1220         case "mesage_ID026":
1221             strMessage = "上级预算余额不足";
1222             break;
1223         case "mesage_ID027":
1224             strMessage = "操作成功";
1225             break;
1226         case "mesage_ID028":
1227             strMessage = "上级预算无此业务类型";
1228             break;
1229         case "mesage_ID029":
1230             strMessage = "还款成功";
1231             break;
1232         case "mesage_ID030":
1233             strMessage = "还款失败";
1234             break;
1235         case "mesage_ID031":
1236             strMessage = "创建流程实例成功";
1237             break;
1238         case "mesage_ID032":
1239             strMessage = "请创建流程定义";
1240             break;
1241         case "mesage_ID033":
1242             strMessage = "服务器返回错误有";
1243             break;
1244         case "mesage_ID034":
1245             strMessage = "本条数据已创建流程";
1246             break;
1247         case "mesage_ID035":
1248             strMessage = "请先选择流程定义";
1249             break;
1250         default:
1251             strMessage = "错误信息,请与管理员联系!";
1252     }
1253     return strMessage;
1254 }
1255
1256
1257 //取得表单画面项目
1258 customBase.getItemValue = function (itemId, type) {
1259
1260     var item = "";
1261     //单行文本 多行文本 数字 日历  customBase.itemEdit   var prefix =  JSON.parse(window.localStorage.getItem("customItem"));
1262     if (type == 'text' || type == 'textarea' || type == 'number' || type == 'calendar' || type == "auto") {
1263         item = customBase.itemEdit['text'].getItem("." + itemId + "value");
1264     } else if (type == 'radio' || type == 'checkbox') {
1265         item = customBase.itemEdit['checkboxRadio'].getItem(itemId, type);
1266     } else if (type == 'image' || type == 'fileupload') {
1267         item = customBase.itemEdit['fileupload'].getItem(itemId);
1268     } else if (type == 'amount') {
1269         item = customBase.itemEdit['text'].getItem("#" + itemId + "amount");
1270     } else if (type == 'qrcode') {
1271         item = customBase.itemEdit['text'].getItem("#" + itemId + "qrcode");
1272     } else if (type == 'barcode') {
1273         item = customBase.itemEdit['text'].getItem("#" + itemId + "barcode");
1274     } else if (type == 'splitline' || type == 'button') {
1275
1276     } else if (type == 'dropdownlistText') {
1277         // customBase.itemEdit[type].setItem(itemId,value,showClass,dropdowntype);
1278         // item = customBase.itemEdit["dropdownlistText"].getItem(itemId);
1279         item = customBase.itemEdit["dropdownlistText2"].getItem(itemId);
1280     } else if (type == "tree") {
1281         item = customBase.itemEdit["tree"].getItem(itemId);
1282     } else {
1283         item = customBase.itemEdit[type].getItem(itemId);
1284     }
1285     return item;
1286 }
1287 //设定表单画面项目   12/7
1288 customBase.setItemValue = function (itemId, type, value, showClass, dropdowntype, num) {
1289     console.log(type)
1290     console.log(value)
1291     console.log(itemId)
1292     var item;
1293     if (showClass == "") {
1294         showClass = 'customViewUEditorCss';
1295     }
1296     if (type == 'text' || type == 'textarea' || type == 'number' || type == 'calendar' || type == 'auto') {
1297         if (num != undefined) {
1298             customBase.itemEdit['text'].setItem("[id=" + itemId + "]:eq('" + num + "')", value, showClass);
1299         } else {
1300             customBase.itemEdit['text'].setItem("#" + itemId, value, showClass);
1301         }
1302     } else if (type == 'htmlediter') {
1303         customBase.itemEdit['htmlediter'].setItem(itemId, value, showClass);
1304     } else if (type == 'radio' || type == 'checkbox') {
1305         customBase.itemEdit['checkboxRadio'].setItem(itemId, type, value, showClass);
1306     } else if (type == 'tree') {
1307         customBase.itemEdit['tree'].setItem(itemId, value);
1308     } else if (type == 'dropdownlistText') {
1309         //console.log(value);
1310         customBase.itemEdit[type].setItem(itemId, value, showClass, dropdowntype);
1311         //console.log(1);
1312         customBase.itemEdit["dropdownlistText2"].setItem(itemId, value, showClass, dropdowntype);
1313     } else if (type == 'splitline' || type == 'subform' || type == 'tag' || type == 'tab') {
1314     } else if (type == 'image') {
1315         // customBase.itemEdit[type].setItem(itemId,value,showClass);
1316     } else if (type == 'qrcode') {
1317         // customBase.itemEdit[type].setItem(itemId,value,showClass);
1318     } else if (type == 'barcode') {
1319         // customBase.itemEdit[type].setItem(itemId,value,showClass);
1320     } else if (type == 'link') {
1321         // customBase.itemEdit[type].setItem(itemId,value,showClass);
1322     } else if (type == 'button') {
1323         // customBase.itemEdit[type].setItem(itemId,value,showClass);
1324     } else {
1325         customBase.itemEdit[type].setItem(itemId, value, showClass);
1326     }
1327
1328 }
1329
1330
1331 /**
1332  * 获取项目根路径1
1333  * @return {RootPath}
1334  */
1335 customBase.getRootPath = function () {
1336     var strFullPath = window.document.location.href;
1337     var strPath = window.document.location.pathname;
1338     var pos = strFullPath.indexOf(strPath);
1339     var prePath = strFullPath.substring(0, pos);
1340     var postPath = strPath.substring(0, strPath.substr(1).indexOf('/') + 1) + "/";
1341     return (prePath + postPath);
1342 }
1343
1344
1345
1346 //文件上传
1347 customBase.uploaderFileShow = function (potion) {
1348     console.log(potion);
1349     var itemId = potion.id;
1350
1351     customBase.options.uploaderItem[itemId] = {};
1352     var arrItemReady = 0;
1353     if (potion.ItemReady != undefined) {
1354         arrItemReady = Object.keys(potion.ItemReady).length;
1355         customBase.options.uploaderItem[itemId] = potion.ItemReady;
1356     }
1357     var $uploaderItem = $(".customViewUEditorCss #" + potion.id);
1358     $uploaderItem.empty();
1359     var $uploadimg = $(
1360         '<div id="' + potion.id + 'uploadimg">' +
1361         '<div id="' + potion.id + 'fileList" class="uploader-list"></div>' +
1362         '</div>'
1363     );
1364     var $list = $uploadimg.find("#" + potion.id + "fileList");
1365     var $addLi = $(
1366         '<div id="' + potion.id + 'imgPicker" class="file-item ">' +
1367         '<button type="button" class="btn btn-info designbtn right">点击选文件</button>' +
1368         '</div>'
1369     );
1370     $list.after($addLi);
1371
1372     //不可编辑情况下 附件追加按钮隐藏
1373     if (!potion.editable) {
1374         $addLi.addClass("cfg_contentNone");
1375     }
1376
1377     //默认图片追加
1378     if (potion.defaultvalueUrl != "") {
1379         var tmp = potion.defaultvalueUrl.split("/");//按照"/"分割
1380         var pp = tmp[tmp.length - 1];//获取最后一部分,即文件名和参数
1381         var $li = $(
1382             '<div class="thumbnail01">' +
1383             '<div class="info"><a href="' + potion.defaultvalueUrl + '" >' + pp + '</a></div>' +
1384             '</div>'
1385         );
1386         $list.prepend($li);
1387         // //单一图片的情况下 图片追加隐藏
1388         // if(potion.imagetype == "single"){
1389         //     $addLi.addClass("cfg_contentNone");
1390         // }
1391     }
1392     //数据编辑的情况下,数据表示
1393     if (arrItemReady > 0) {
1394         for (fileid in potion.ItemReady) {
1395             if (potion.ItemReady.hasOwnProperty(fileid)) {
1396                 var fileItem = potion.ItemReady[fileid];
1397                 // var $list = $("#"+potion.id+"fileList"),
1398                 // var $list = $uploadimg,
1399                 $li = $(
1400                     '<div id="' + fileid + '" class="thumbnail01">' +
1401                     '<div class="frm_item_icons01">' +
1402                     '<div class="frm_item_icon remove" imgId="' + fileid + '">' +
1403                     '<img  alt=" " style="width:14px;height:14px;" src="./../../css/img/icon/delete.png"></div>' +
1404                     '</div>' +
1405                     // '<img class = "fileQueuedAddItem" src = "'+fileItem.base64+'">' +
1406                     // '<div class="info"><a href="'+customBase.options.uploaderItem[itemId][file.id].path+'" >' + file.name + '</a></div>' +
1407                     '<div class="info"><a href="' + fileItem.path + '" >' + fileItem.oldName + '</a></div>' +
1408                     '</div>'
1409                 );
1410                 // $img = $li.find('.fileQueuedAddItem');
1411
1412                 $li.find(".frm_item_icon").on('click', function (event) {
1413                     var imgId = this.getAttribute("imgId");
1414                     $('#' + imgId).remove();
1415                     if (imgId.indexOf("WU") > -1) {
1416                         uploader.removeFile(imgId, true);
1417                     }
1418                     delete customBase.options.uploaderItem[itemId][imgId];
1419
1420                     event.stopPropagation();
1421                     return false;
1422
1423                 });
1424                 // $list为容器jQuery实例
1425                 $list.prepend($li);
1426             }
1427         }
1428     }
1429
1430     $uploaderItem.append($uploadimg);
1431     customBase.uploaderTemp += 500;
1432     setTimeout(function () {
1433         var uploader;
1434         var webUploaderJson = {
1435             // 选完文件后,是否自动上传。
1436             auto: true,
1437             // pick: '#'+potion.id+"dndArea",
1438             pick: '#' + potion.id + 'imgPicker',
1439             paste: potion.id,
1440             swf: '../../dist/Uploader.swf',
1441             // fileExt: '*.zip,*.doc,*.xls,*.mp3,*.mp4',
1442             // chunked:true,
1443             // chunkSize :true,
fa4e0d 1444             fileSizeLimit: 20 * 1024 * 1024,    // 200 M
M 1445             fileSingleSizeLimit: 20 * 1024 * 1024,    // 50 M
4d1219 1446             accept: {// 只允许选择图片文件格式
B 1447                 title: 'File',
fa4e0d 1448                 extensions: 'zip,rar,mp3,mp4,xls,xlsx,doc,docx,ppt,pptx,rtf',
4d1219 1449                 mimeTypes: ''
B 1450             },
1451
1452         }
1453         var webUploaderJson = $.extend(webUploaderJson, window.commonWebUploaderJson(potion.formid));
1454
1455
1456         // 初始化Web Uploader
1457         uploader = WebUploader.create(webUploaderJson);
1458
1459         // uploader;
1460         uploader.on('ready', function () {
1461             window.uploader = uploader;
1462         });
1463         uploader.on('error', function (type) {
1464             if (type == "Q_TYPE_DENIED") {
fa4e0d 1465                 customBase.alert("myModal", "请上传zip,rar,mp3,mp4,xls,xlsx,doc,docx,ppt,pptx,rtf格式文件", "");
0016c8 1466             } else if (type == "Q_EXCEED_SIZE_LIMIT") {
M 1467                 customBase.alert("", "文件大小不能超过20M");
4d1219 1468             }
B 1469         });
1470         // 当有文件添加进来的时候
1471         uploader.on('fileQueued', function (file) {
1472             // var $list = $("#"+potion.id+"fileList"),
1473             var $list = $(".customViewUEditorCss #" + potion.id + "fileList"),
1474                 $li = $(
1475                     '<div id="' + file.id + '" class="thumbnail01">' +
1476                     '<div class="frm_item_icons01">' +
1477                     '<div class="frm_item_icon remove" imgId="' + file.id + '">' +
1478                     '<img   style="width:14px;height:14px;" src="./../../css/img/icon/delete.png"></div>' +
1479                     '</div>' +
1480                     // '<img class = "fileQueuedAddItem">' +
1481                     '<div class="info"><a href="" >' + file.name + '</a></div>' +
1482                     '</div>'
1483                 ),
1484                 $img = $li.find('.fileQueuedAddItem');
1485
1486             $li.find(".frm_item_icon").on('click', function () {
1487                 var imgId = this.getAttribute("imgId");
1488                 $('#' + imgId).remove();
1489                 if (imgId.indexOf("WU") > -1) {
1490                     uploader.removeFile(imgId, true);
1491                 }
1492                 delete customBase.options.uploaderItem[itemId][imgId];
1493
1494                 event.stopPropagation();
1495                 return false;
1496             });
1497             // $list为容器jQuery实例
1498             $list.prepend($li);
1499         });
1500         // 文件上传过程中创建进度条实时显示。
1501         uploader.on('uploadProgress', function (file, percentage) {
1502         });
1503
1504         // 文件上传成功,给item添加成功class, 用样式标记上传成功。
1505         uploader.on('uploadSuccess', function (file, response) {
1506             //////console.log(file);
1507             //////console.log(response);
1508
1509             $("#" + itemId + "mesageErrDiv").remove();
1510             $(".customViewUEditorCss  #" + itemId).popover('hide')
1511
1512             $('#' + file.id).addClass('upload-state-done');
1513             customBase.options.uploaderItem[itemId][file.id] = response.data;
1514             $('#' + file.id).find("a")[0].setAttribute("href", response.data.path);
1515         });
1516
1517         // 文件上传失败,显示上传出错。
1518         uploader.on('uploadError', function (file) {
1519             var $li = $('#' + file.id),
1520                 $error = $li.find('div.error');
1521
1522             // 避免重复创建
1523             if (!$error.length) {
1524                 $error = $('<div class="error"></div>').appendTo($li);
1525             }
1526
1527             $error.text('上传失败');
1528         });
1529
1530         // 完成上传完了,成功或者失败,先删除进度条。
1531         uploader.on('uploadComplete', function (file) {
1532             $('#' + file.id).find('.progress').remove();
1533         });
1534     }, customBase.uploaderTemp);
1535 }
1536 //图片上传
1537 customBase.uploaderShow = function (potion) {
1538     //////console.log(potion);
1539     var itemId = potion.id;
1540     // var uploader;
1541     customBase.options.uploaderItem[itemId] = {};
1542     var arrItemReady = 0;
1543     if (potion.ItemReady != undefined) {
1544         arrItemReady = Object.keys(potion.ItemReady).length;
1545         customBase.options.uploaderItem[itemId] = potion.ItemReady;
1546     }
1547     var $uploaderItem = $(".customViewUEditorCss #" + potion.id);
1548     $uploaderItem.empty();
1549     var $uploadimg = $(
1550         '<div id="' + potion.id + 'uploadimg">' +
1551         '<div id="' + potion.id + 'fileList" class="uploader-list"></div>' +
1552         '</div>'
1553     );
1554     var $list = $uploadimg.find("#" + potion.id + "fileList");
1555     console.log($('#' + itemId))
1556     var $addLi = $(
1557         '<div id="' + potion.id + 'imgPicker" class="file-item thumbnail">' +
1558         '<div  style="background:url(./../../css/image.png) no-repeat ;width: 100px;height: 100px;>"  </div>' +
1559         '</div>'
1560     );
1561     $list.prepend($addLi);
1562     //不可编辑情况下 图片追加隐藏
1563     if (!potion.editable) {
1564         $addLi.addClass("cfg_contentNone");
1565     }
1566
1567     //默认图片追加
1568     if (potion.defaultvalueUrl != "") {
1569         var $li = $(
1570             '<div class="file-item thumbnail">' +
1571             '<img src="' + potion.defaultvalueUrl + '"' +
1572             '</div>'
1573             // `<div class="file-item thumbnail">
1574             //     <img src="${potion.defaultvalueUrl}" data-original="${otion.defaultvalueUrl}"
1575             // </div>`
1576         );
1577         $list.prepend($li);
1578         //单一图片的情况下 图片追加隐藏
1579         if (potion.imagetype == "single") {
1580             $addLi.addClass("cfg_contentNone");
1581         }
1582     }
1583     //数据编辑的情况下,数据表示
1584     console.log(arrItemReady)
1585     if (arrItemReady > 0) {
1586         console.log(potion.ItemReady)
1587         for (fileid in potion.ItemReady) {
1588             if (potion.ItemReady.hasOwnProperty(fileid)) {
1589                 var fileItem = potion.ItemReady[fileid];
1590                 // var $list = $("#"+potion.id+"fileList"),
1591                 // var $list = $uploadimg,
1592                 var $li = $(
1593                     '<div id="' + fileid + '" class="file-item thumbnail">' +
1594                     '<img alt=" " class = "fileQueuedAddItem" src = "' + fileItem.base64 + '"  data-original ="' + fileItem.base64 + '" >' +
1595                     '<div class="frm_item_icons">' +
1596                     '<div class="frm_item_icon remove" imgId="' + fileid + '">' +
1597                     // '<img  style="width:14px;height:14px;" src="./../../css/img/icon/delete.png"></div>' +
1598                     '<div  style="width:14px;height:14px;background:url(./../../css/img/icon/delete.png);"> </div></div>' +
1599
1600                     '</div>' +
1601                     // '<div class="info">' + file.name + '</div>' +
1602                     '</div>'
1603                 );
1604
1605
1606                 $li.find(".frm_item_icon").on('click', function () {
1607                     var imgId = this.getAttribute("imgId");
1608                     $('#' + imgId).remove();
1609                     if (imgId.indexOf("WU") > -1) {
1610                         uploader.removeFile(imgId, true);
1611                     }
1612                     delete customBase.options.uploaderItem[itemId][imgId];
1613                     //单一图片的情况下 图片追加隐藏
1614                     if (potion.imagetype == "single") {
1615                         $addLi.removeClass("cfg_contentNone");
1616                     }
1617                     console.log($(this))
1618                     event.stopPropagation();
1619                 });
1620                 // $list为容器jQuery实例
1621                 $list.prepend($li);
1622                 console.log($('#customShow').children())
1623
1624             }
1625         }
1626     }
1627     //单一图片的情况下 图片追加隐藏
1628     if (arrItemReady > 0 && potion.imagetype == "single") {
1629         setTimeout(function () {
1630             $addLi.addClass("cfg_contentNone");
1631         }, 10);
1632         console.log($('#customShow').children())
1633
1634     }
1635
1636     $uploaderItem.append($uploadimg);
1637     customBase.uploaderTemp += 500;
1638     setTimeout(function () {
1639         var uploader;
1640         var webUploaderJson = {
1641             // 选完文件后,是否自动上传。
1642             auto: true,
1643             // pick: '#'+potion.id+"dndArea",
1644             pick:{
1645         id: '#' + potion.id + 'imgPicker',
1646         multiple: false
1647         },
1648             paste: potion.id,
1649             swf: '../../dist/Uploader.swf',
1650         }
1651         var webUploaderJson = $.extend(webUploaderJson, window.commonWebUploaderJson(potion.formid));
1652
1653
1654         // 初始化Web Uploader
1655         uploader = WebUploader.create(webUploaderJson);
1656
1657         // uploader;
1658         uploader.on('ready', function () {
1659             window.uploader = uploader;
1660         });
1661         // 当有文件添加进来的时候
1662         uploader.on('fileQueued', function (file) {
1663             // var $list = $("#"+potion.id+"fileList"),
1664             var $list = $(".customViewUEditorCss #" + potion.id + "fileList"),
1665                 $li = $(
1666                     '<div id="' + file.id + '" class="file-item thumbnail">' +
1667                     '<div class="frm_item_icons">' +
1668                     '<div class="frm_item_icon remove" imgId="' + file.id + '">' +
1669                     '<img  style="width:14px;height:14px;" src="./../../css/img/icon/delete.png"></div>' +
1670                     '</div>' +
1671                     '<img  class = "fileQueuedAddItem">' +
1672                     // '<div class="info">' + file.name + '</div>' +
1673                     '</div>'
1674                 ),
1675                 $img = $li.find('.fileQueuedAddItem');
1676
1677             $li.find(".frm_item_icon").on('click', function () {
1678                 var imgId = this.getAttribute("imgId");
1679                 $('#' + imgId).remove();
1680                 if (imgId.indexOf("WU") > -1) {
1681                     uploader.removeFile(imgId, true);
1682                 }
1683                 delete customBase.options.uploaderItem[itemId][imgId];
1684                 //单一图片的情况下 图片追加隐藏
1685                 if (potion.imagetype == "single") {
1686                     $addLi.removeClass("cfg_contentNone");
1687                 }
1688
1689                 event.stopPropagation();
1690
1691             });
1692             // $list为容器jQuery实例
1693             $list.prepend($li);
1694
1695             //单一图片的情况下 图片追加隐藏
1696             if (potion.imagetype == "single") {
1697                 $addLi.addClass("cfg_contentNone");
1698             }
1699
1700             // 创建缩略图
1701             // 如果为非图片文件,可以不用调用此方法。
1702             // thumbnailWidth x thumbnailHeight 为 100 x 100
1703             uploader.makeThumb(file, function (error, src) {
1704                 if (error) {
1705                     $img.replaceWith('<span>不能预览</span>');
1706                     return;
1707                 }
1708                 // //////console.log(customBase.options.uploaderItem[itemId][file.id]);
1709                 // customBase.options.uploaderItem[itemId][file.id]["base64"] = src;
1710                 $img.attr('src', src);
1711                 // 12/21
1712                 console.log($img)
1713                 $img.attr('data-original', src);
1714
1715             }, 100, 100);
1716         });
1717         // 文件上传过程中创建进度条实时显示。
1718         uploader.on('uploadProgress', function (file, percentage) {
1719             var $li = $('#' + file.id),
1720                 $percent = $li.find('.progress span');
1721
1722             // 避免重复创建
1723             if (!$percent.length) {
1724                 $percent = $('<p class="progress"><span></span></p>')
1725                     .appendTo($li)
1726                     .find('span');
1727             }
1728             //////console.log(percentage);
1729             $percent.css('width', percentage * 100 + '%');
1730         });
1731
1732         // 文件上传成功,给item添加成功class, 用样式标记上传成功。
1733         uploader.on('uploadSuccess', function (file, response) {
1734             //////console.log(file);
1735             //////console.log(response);
1736             $('#' + file.id).addClass('upload-state-done');
1737             // customBase.options.uploaderFileName[file.id] = response.data;
1738             customBase.options.uploaderItem[itemId][file.id] = response.data;
1739             // //////console.log(customBase.options.uploaderItem[itemId][file.id]);
1740             customBase.options.uploaderItem[itemId][file.id]["base64"] = $("#" + file.id + " .fileQueuedAddItem")[0].getAttribute("src");
1741         });
1742
1743         // 文件上传失败,显示上传出错。
1744         uploader.on('uploadError', function (file) {
1745             var $li = $('#' + file.id),
1746                 $error = $li.find('div.error');
1747
1748             // 避免重复创建
1749             if (!$error.length) {
1750                 $error = $('<div class="error"></div>').appendTo($li);
1751             }
1752
1753             $error.text('上传失败');
1754         });
1755
1756         // 完成上传完了,成功或者失败,先删除进度条。
1757         uploader.on('uploadComplete', function (file) {
1758             $('#' + file.id).find('.progress').remove();
1759         });
1760     }, customBase.uploaderTemp);
1761     // 12/19
1762     console.log($uploadimg)
1763     console.log($('#customViewUEditor').find('#itemId_1').children())
1764
1765     var $uploaderItems = $($("#customViewUEditor #" + potion.id)[0]);
1766     var imgId = $uploaderItems.attr('id');
1767     var srcUrl = $uploaderItems.find('img').attr('src');
1768     // $uploaderItem.find('img').attr('data-original',srcUrl);
1769     console.log($('#' + imgId).children().children())
1770
1771     console.log($('#' + imgId).find('#itemId_1fileList').find('label'))
1772     $('#' + imgId).find('#itemId_1fileList').find('label').css({
1773         'height': '150px',
1774         'width': '150px'
1775     })
1776     var id = $('#' + imgId).children().children().attr('id')
1777     //编辑
1778     var viewer = new Viewer(document.getElementById(id), {
1779         url: 'data-original',
1780         movable: false
1781     });
1782     console.log($('#customShow').children())
1783     console.log($("[style='opacity: 0; width: 100%; height: 100%; display: block; cursor: pointer; background: rgb(255, 255, 255)']"))
1784 }
1785
1786
1787 //图片上传
1788 customBase.uploaderShow_Temp = function (itemId, chunkSize, imgFlag, formID) {
1789     if (chunkSize.width != 0) {
1790         $(itemId + 'dndArea')[0].style.width = chunkSize.width + 'px';
1791         $(itemId + 'dndArea')[0].style.height = chunkSize.height + 'px';
1792     }
1793
1794     var $wrap = $(itemId),
1795         // 图片容器
1796         $queue = $('<ul class="filelist"></ul>').appendTo($wrap.find('.queueList')),
1797         // 状态栏,包括进度和控制按钮
1798         $statusBar = $wrap.find('.statusBar'),
1799         // 文件总体选择信息。
1800         $info = $statusBar.find('.info'),
1801         // 上传按钮
1802         $upload = $wrap.find('.uploadBtn'),
1803         // 没选择文件之前的内容。
1804         $placeHolder = $wrap.find('.placeholder'),
1805
1806         $progress = $statusBar.find('.progress').hide(),
1807         // 添加的文件数量
1808         fileCount = 0,
1809         // 添加的文件总大小
1810         fileSize = 0,
1811         // 优化retina, 在retina下这个值是2
1812         ratio = window.devicePixelRatio || 1,
1813         // 缩略图大小
1814         thumbnailWidth = 110 * ratio,
1815         thumbnailHeight = 110 * ratio,
1816         // 可能有pedding, ready, uploading, confirm, done.
1817         state = 'pedding',
1818         // 所有文件的进度信息,key为file id
1819         percentages = {},
1820         // 判断浏览器是否支持图片的base64
1821         isSupportBase64 = (function () {
1822             var data = new Image();
1823             var support = true;
1824             data.onload = data.onerror = function () {
1825                 if (this.width != 1 || this.height != 1) {
1826                     support = false;
1827                 }
1828             }
1829             data.src = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";
1830             return support;
1831         })(),
1832         // 检测是否已经安装flash,检测flash的版本
1833         flashVersion = (function () {
1834             var version;
1835
1836             try {
1837                 version = navigator.plugins['Shockwave Flash'];
1838                 version = version.description;
1839             } catch (ex) {
1840                 try {
1841                     version = new ActiveXObject('ShockwaveFlash.ShockwaveFlash')
1842                         .GetVariable('$version');
1843                 } catch (ex2) {
1844                     version = '0.0';
1845                 }
1846             }
1847             version = version.match(/\d+/g);
1848             return parseFloat(version[0] + '.' + version[1], 10);
1849         })(),
1850
1851         supportTransition = (function () {
1852             var s = document.createElement('p').style,
1853                 r = 'transition' in s ||
1854                     'WebkitTransition' in s ||
1855                     'MozTransition' in s ||
1856                     'msTransition' in s ||
1857                     'OTransition' in s;
1858             return r;
1859         })(),
1860         //创建
1861         uploader;
1862
1863     if (!WebUploader.Uploader.support('flash') && WebUploader.browser.ie) {
1864         // flash 安装了但是版本过低。
1865         if (flashVersion) {
1866             (function (container) {
1867                 window['expressinstallcallback'] = function (state) {
1868                     switch (state) {
1869                         case 'Download.Cancelled':
1870                             customBase.alert("M", '您取消了更新!')
1871                             break;
1872
1873                         case 'Download.Failed':
1874                             customBase.alert("M", '安装失败')
1875                             break;
1876
1877                         default:
1878                             customBase.alert("M", '安装已成功,请刷新!');
1879                             break;
1880                     }
1881                     delete window['expressinstallcallback'];
1882                 };
1883
1884                 var swf = './expressInstall.swf';
1885                 // insert flash object
1886                 var html = '<object type="application/' +
1887                     'x-shockwave-flash" data="' + swf + '" ';
1888
1889                 if (WebUploader.browser.ie) {
1890                     html += 'classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
1891                 }
1892
1893                 html += 'width="100%" height="100%" style="outline:0">' +
1894                     '<param name="movie" value="' + swf + '" />' +
1895                     '<param name="wmode" value="transparent" />' +
1896                     '<param name="allowscriptaccess" value="always" />' +
1897                     '</object>';
1898
1899                 container.html(html);
1900
1901             })($wrap);
1902
1903             // 压根就没有安转。
1904         } else { }
1905
1906         return;
1907     } else if (!WebUploader.Uploader.support()) {
1908         customBase.alert("M", 'Web Uploader 不支持您的浏览器!');
1909         return;
1910     }
1911     if (imgFlag) {
1912         labelTemp = '点击选择图片'
1913     } else {
1914         labelTemp = '点击选择文件'
1915     }
1916
1917
1918
1919     ;
1920     var webUploaderJson = {
1921         pick: {
1922             id: itemId + 'filePicker',
1923             label: labelTemp
1924         },
1925         dnd: itemId + 'dndArea',
1926         paste: itemId,
1927         swf: '../../dist/Uploader.swf',
1928         chunked: false,
1929         chunkSize: 512 * 1024,
1930         // 禁掉全局的拖拽功能。这样不会出现图片拖进页面的时候,把图片打开。
1931         disableGlobalDnd: true,
1932         fileNumLimit: 300,
1933         fileSizeLimit: 200 * 1024 * 1024,    // 200 M
1934         fileSingleSizeLimit: 50 * 1024 * 1024    // 50 M
1935     }
1936     var webUploaderJson = $.extend(webUploaderJson, window.commonWebUploaderJson(formID));
1937
1938     // 实例化
1939     uploader = WebUploader.create(webUploaderJson);
1940
1941     // 拖拽时不接受 js, txt 文件。
1942     uploader.on('dndAccept', function (items) {
1943         var denied = false,
1944             len = items.length,
1945             i = 0,
1946             // 修改js类型
1947             unAllowed = 'text/plain;application/javascript ';
1948
1949         for (; i < len; i++) {
1950             // 如果在列表里面
1951             if (~unAllowed.indexOf(items[i].type)) {
1952                 denied = true;
1953                 break;
1954             }
1955         }
1956
1957         return !denied;
1958     });
1959
1960     // 添加“添加文件”的按钮,
1961     uploader.addButton({
1962         id: itemId + 'filePicker2',
1963         label: '继续添加'
1964     });
1965     //文件读取
1966     uploader.on('ready', function () {
1967         window.uploader = uploader;
1968         $queue.empty();
1969         var json = customBase.options.uploaderItemReady[itemId.replace("#", "")];
1970         if (json == undefined) {
1971             json = [];
1972         }
1973         var jsonLen = json.length;
1974         if (jsonLen != 0) {
1975             fileCount = jsonLen;
1976             $placeHolder.addClass('element-invisible');
1977             $statusBar.show();
1978             //显示在页面上
1979             $.each(json, function (i, n) {
1980                 fileSize += n.filelen;
1981                 var obj = {}, statusMap = {}
1982                     , file_id = 'WU_FILE_' + i;
1983                 obj.id = file_id;
1984                 obj.name = n.filebasename;
1985                 obj.filename = n.filename;
1986                 obj.getStatus = function () {
1987                     return '';
1988                 };
1989                 obj.statusText = '';
1990                 obj.size = n.filelen;
1991                 obj.version = WebUploader.Base.version;
1992                 obj.type = n.mimeType;
1993                 obj.filetype = n.filetype;
1994                 obj.source = this;
1995                 obj.path = n.filePath.path;
1996                 obj.setStatus = function (status, text) {
1997
1998                     var prevStatus = statusMap[this.id];
1999
2000                     typeof text !== 'undefined' && (this.statusText = text);
2001
2002                     if (status !== prevStatus) {
2003                         statusMap[this.id] = status;
2004                         /**
2005                          * 文件状态变化
2006                          * @event statuschange
2007                          */
2008                         uploader.trigger('statuschange', status, prevStatus);
2009                     }
2010                 };
2011                 editFile(obj);
2012                 $("#" + file_id).append(inputStr(i, n));
2013             });
2014
2015             WebUploader.Base.idSuffix = jsonLen;
2016
2017             setState('ready');
2018             updateTotalProgress();
2019         }
2020         // },'json');
2021     });
2022
2023     function inputStr(index, json) {
2024         var inputStr = '';
2025         var pre = itemId;
2026         //转化格式后的名称
2027         inputStr += '<input name="' + pre + 'list[' + index + '].filename"   value="' + json.filename + '" style="display:none"/>';
2028         //保存路径
2029         inputStr += '<input name="' + pre + 'list[' + index + '].filepath"   value="' + json.filepath + '" style="display:none"/>';
2030         //文件源名称
2031         inputStr += '<input name="' + pre + 'list[' + index + '].filebasename"   value="' + json.filebasename + '" style="display:none"/>';
2032
2033         //文件类型  doc?xls?
2034         inputStr += '<input name="' + pre + 'list[' + index + '].filetype"   value="' + json.filetype + '" style="display:none"/>';
2035         //文件大小
2036         inputStr += '<input name="' + pre + 'list[' + index + '].filelen"   value="' + json.filelen + '" style="display:none"/>';
2037         //doc转为html
2038         inputStr += '<input name="' + pre + 'list[' + index + '].doc2htmlpath" value="' + json.doc2htmlpath + '"  style="display:none"/>';
2039         //mimeType
2040         inputStr += '<input name="' + pre + 'list[' + index + '].mimeType" value="' + json.mimeType + '"  style="display:none"/>';
2041         return inputStr;
2042     }
2043
2044     function editFile(file) {
2045         if (imgFlag) {
2046             var $li = $('<li id="' + file.id + '" class="imgfileLiShow">' +
2047                 '<p class="title">' + file.name + '</p>' +
2048                 '<p class="imgWrap"></p>' +
2049                 '<p class="progress"><span></span></p>' +
2050                 '</li>'),
2051
2052                 $btns = $('<div class="file-panel">' +
2053                     '<span class="cancel">删除</span>' +
2054                     '<span class="rotateRight">向右旋转</span>' +
2055                     '<span class="rotateLeft">向左旋转</span></div>').appendTo($li),
2056
2057                 $wrap = $li.find('p.imgWrap')
2058
2059         } else {
2060             var $li = $('<li id="' + file.id + '">' +
2061                 '<div class="title" style="word-break:break-all;text-align:left;font-size:16px">' + file.filename + '</div>' +
2062
2063                 '</li>'),
2064                 $btns = $('<div class="file-panel">' +
2065                     '<span class="cancel">删除</span>'
2066
2067                     + '</div>'
2068                 ).appendTo($li),
2069
2070                 $wrap = $li.find('p.imgWrap')
2071         }
2072
2073         if (file.getStatus() === 'invalid') {
2074             showError(file.statusText);
2075         } else {
2076             // @todo lazyload
2077             $wrap.empty();
2078             $wrap.text('不能预览');
2079
2080             var img;
2081             //判断是否是图片
2082             src = file.path;
2083             img = $('<img  src="' + src + '" style="height:100%;">');
2084             $wrap.empty().append(img);
2085
2086             percentages[file.id] = [file.size, 0];
2087             file.rotation = 0;
2088         }
2089
2090
2091
2092         $li.append('<span class="success"></span>');
2093
2094         $li.on('mouseenter', function () {
2095             $btns.stop().animate({ height: 30 });
2096         });
2097
2098         $li.on('mouseleave', function () {
2099             $btns.stop().animate({ height: 0 });
2100         });
2101
2102         $btns.on('click', 'span', function () {
2103             var index = $(this).index(),
2104                 deg;
2105
2106             switch (index) {
2107                 case 0:
2108                     // uploader.removeFile( file );
2109                     return;
2110
2111                 case 1:
2112                     file.rotation += 90;
2113                     break;
2114
2115                 case 2:
2116                     file.rotation -= 90;
2117                     break;
2118             }
2119
2120             if (supportTransition) {
2121                 deg = 'rotate(' + file.rotation + 'deg)';
2122                 $wrap.css({
2123                     '-webkit-transform': deg,
2124                     '-mos-transform': deg,
2125                     '-o-transform': deg,
2126                     'transform': deg
2127                 });
2128             } else {
2129                 $wrap.css('filter', 'progid:DXImageTransform.Microsoft.BasicImage(rotation=' + (~~((file.rotation / 90) % 4 + 4) % 4) + ')');
2130             }
2131
2132
2133         });
2134
2135         $li.appendTo($queue);
2136     }
2137
2138
2139     // 当有文件添加进来时执行,负责view的创建
2140     if (imgFlag) { }
2141     function addFile(file) {
2142         if (imgFlag) {
2143             var $li = $('<li id="' + file.id + '" class="imgfileLiShow">' +
2144                 '<p class="title">' + file.name + '</p>' +
2145                 '<p class="imgWrap"></p>' +
2146                 '<p class="progress"><span></span></p>' +
2147                 '</li>'),
2148
2149                 $btns = $('<div class="file-panel">' +
2150                     '<span class="cancel">删除</span>' +
2151                     '<span class="rotateRight">向右旋转</span>' +
2152                     '<span class="rotateLeft">向左旋转</span></div>').appendTo($li),
2153                 $prgress = $li.find('p.progress span'),
2154                 $wrap = $li.find('p.imgWrap'),
2155                 $info = $('<p class="error"></p>')
2156         } else {
2157             var $li = $('<li id="' + file.id + '">' +
2158                 '<div class="title" style="word-break:break-all;text-align:left;font-size:16px">' + file.name + '</div>' +
2159                 '</li>'),
2160
2161                 $btns = $('<div class="file-panel">' +
2162                     '<span class="cancel">删除</span>' +
2163                     '</div>'
2164                 ).appendTo($li),
2165                 $prgress = $li.find('p.progress span'),
2166                 $wrap = $li.find('p.imgWrap'),
2167                 $info = $('<p class="error"></p>')
2168         }
2169
2170
2171         showError = function (code) {
2172             switch (code) {
2173                 case 'exceed_size':
2174                     text = '文件大小超出';
2175                     break;
2176
2177                 case 'interrupt':
2178                     text = '上传暂停';
2179                     break;
2180
2181                 default:
2182                     text = '上传失败,请重试';
2183                     break;
2184             }
2185
2186             $info.text(text).appendTo($li);
2187         };
2188
2189         if (file.getStatus() === 'invalid') {
2190             showError(file.statusText);
2191         } else {
2192             // @todo lazyload
2193             $wrap.text('预览中');
2194             uploader.makeThumb(file, function (error, src) {
2195                 var img;
2196
2197                 if (error) {
2198                     $wrap.text('不能预览');
2199                     return;
2200                 }
2201                 if (isSupportBase64) {
2202                     img = $('<img src="' + src + '">');
2203                     $wrap.empty().append(img);
2204                 } else {
2205
2206                 }
2207             }, thumbnailWidth, thumbnailHeight);
2208
2209             percentages[file.id] = [file.size, 0];
2210             file.rotation = 0;
2211         }
2212
2213         file.on('statuschange', function (cur, prev) {
2214             if (prev === 'progress') {
2215                 $prgress.hide().width(0);
2216             } else if (prev === 'queued') {
2217                 $li.off('mouseenter mouseleave');
2218                 $btns.remove();
2219             }
2220
2221             // 成功
2222             if (cur === 'error' || cur === 'invalid') {
2223                 //////////console.log( file.statusText );
2224                 showError(file.statusText);
2225                 percentages[file.id][1] = 1;
2226             } else if (cur === 'interrupt') {
2227                 showError('interrupt');
2228             } else if (cur === 'queued') {
2229                 percentages[file.id][1] = 0;
2230             } else if (cur === 'progress') {
2231                 $info.remove();
2232                 $prgress.css('display', 'block');
2233             } else if (cur === 'complete') {
2234                 $li.append('<span class="success"></span>');
2235             }
2236
2237             $li.removeClass('state-' + prev).addClass('state-' + cur);
2238         });
2239
2240         $li.on('mouseenter', function () {
2241             $btns.stop().animate({ height: 30 });
2242         });
2243
2244         $li.on('mouseleave', function () {
2245             $btns.stop().animate({ height: 0 });
2246         });
2247
2248         $btns.on('click', 'span', function () {
2249             var index = $(this).index(),
2250                 deg;
2251
2252             switch (index) {
2253                 case 0:
2254                     uploader.removeFile(file);
2255                     return;
2256
2257                 case 1:
2258                     file.rotation += 90;
2259                     break;
2260
2261                 case 2:
2262                     file.rotation -= 90;
2263                     break;
2264             }
2265
2266             if (supportTransition) {
2267                 deg = 'rotate(' + file.rotation + 'deg)';
2268                 $wrap.css({
2269                     '-webkit-transform': deg,
2270                     '-mos-transform': deg,
2271                     '-o-transform': deg,
2272                     'transform': deg
2273                 });
2274             } else {
2275                 $wrap.css('filter', 'progid:DXImageTransform.Microsoft.BasicImage(rotation=' + (~~((file.rotation / 90) % 4 + 4) % 4) + ')');
2276             }
2277
2278
2279         });
2280
2281         $li.appendTo($queue);
2282     }
2283
2284     // 负责view的销毁
2285     function removeFile(file) {
2286         var $li = $('#' + file.id);
2287
2288         delete percentages[file.id];
2289         updateTotalProgress();
2290         $li.off().find('.file-panel').off().end().remove();
2291     }
2292
2293     function updateTotalProgress() {
2294         var loaded = 0,
2295             total = 0,
2296             spans = $progress.children(),
2297             percent;
2298
2299         $.each(percentages, function (k, v) {
2300             total += v[0];
2301             loaded += v[0] * v[1];
2302         });
2303
2304         percent = total ? loaded / total : 0;
2305
2306
2307         spans.eq(0).text(Math.round(percent * 100) + '%');
2308         spans.eq(1).css('width', Math.round(percent * 100) + '%');
2309         updateStatus();
2310     }
2311
2312     function updateStatus() {
2313         var text = '', stats;
2314
2315         if (state === 'ready') {
2316             if (imgFlag) {
2317                 text = '选中' + fileCount + '张图片,共' + WebUploader.formatSize(fileSize) + '。';
2318             } else {
2319                 text = '选中' + fileCount + '个文件,共' + WebUploader.formatSize(fileSize) + '。';
2320             }
2321
2322         } else if (state === 'confirm') {
2323             stats = uploader.getStats();
2324             if (stats.uploadFailNum) {
2325                 if (imgFlag) {
2326                     text = '已成功上传' + stats.successNum + '张照片至XX相册,' +
2327                         stats.uploadFailNum + '张照片上传失败,<a class="retry" href="#">重新上传</a>失败图片或<a class="ignore" href="#">忽略</a>'
2328                 } else {
2329                     text = '已成功上传' + stats.successNum + '个文件至XX文件夹,' +
2330                         stats.uploadFailNum + '个文件上传失败,<a class="retry" href="#">重新上传</a>失败文件或<a class="ignore" href="#">忽略</a>'
2331                 }
2332             }
2333
2334         } else {
2335             stats = uploader.getStats();
2336             if (imgFlag) {
2337                 text = '共' + fileCount + '张(' +
2338                     WebUploader.formatSize(fileSize) +
2339                     '),已上传' + stats.successNum + '张';
2340
2341                 if (stats.uploadFailNum) {
2342                     text += ',失败' + stats.uploadFailNum + '张';
2343                 }
2344             } else {
2345                 text = '共' + fileCount + '个文件(' +
2346                     WebUploader.formatSize(fileSize) +
2347                     '),已上传' + stats.successNum + '个文件';
2348
2349                 if (stats.uploadFailNum) {
2350                     text += ',失败' + stats.uploadFailNum + '个文件';
2351                 }
2352             }
2353
2354         }
2355
2356         $info.html(text);
2357     }
2358
2359     function setState(val) {
2360         var file, stats;
2361
2362         if (val === state) {
2363             return;
2364         }
2365
2366         $upload.removeClass('state-' + state);
2367         $upload.addClass('state-' + val);
2368         state = val;
2369
2370         switch (state) {
2371             case 'pedding':
2372                 $placeHolder.removeClass('element-invisible');
2373                 $queue.hide();
2374                 $statusBar.addClass('element-invisible');
2375                 uploader.refresh();
2376                 break;
2377
2378             case 'ready':
2379                 $placeHolder.addClass('element-invisible');
2380                 $('#filePicker2').removeClass('element-invisible');
2381                 $queue.show();
2382                 $statusBar.removeClass('element-invisible');
2383                 uploader.refresh();
2384                 break;
2385
2386             case 'uploading':
2387                 $('#filePicker2').addClass('element-invisible');
2388                 $progress.show();
2389                 $upload.text('暂停上传');
2390                 break;
2391
2392             case 'paused':
2393                 $progress.show();
2394                 $upload.text('继续上传');
2395                 break;
2396
2397             case 'confirm':
2398                 $progress.hide();
2399                 $('#filePicker2').removeClass('element-invisible');
2400                 $upload.text('开始上传');
2401
2402                 stats = uploader.getStats();
2403                 if (stats.successNum && !stats.uploadFailNum) {
2404                     setState('finish');
2405                     return;
2406                 }
2407                 break;
2408             case 'finish':
2409                 stats = uploader.getStats();
2410                 if (stats.successNum) {
2411                     var strMessage = customBase.getMessage("mesage_ID005");
2412                     customBase.alert("S", strMessage);
2413                     // alert( '上传成功' );
2414                 } else {
2415                     // 没有成功的图片,重设
2416                     state = 'done';
2417                     location.reload();
2418                 }
2419                 break;
2420         }
2421
2422         updateStatus();
2423     }
2424
2425     uploader.onUploadProgress = function (file, percentage) {
2426         var $li = $('#' + file.id),
2427             $percent = $li.find('.progress span');
2428
2429         $percent.css('width', percentage * 100 + '%');
2430         percentages[file.id][1] = percentage;
2431         updateTotalProgress();
2432         customBase.options.uploaderItem[itemId] = uploader.getFiles();
2433     };
2434
2435     uploader.onFileQueued = function (file) {
2436         fileCount++;
2437         fileSize += file.size;
2438
2439         if (fileCount === 1) {
2440             $placeHolder.addClass('element-invisible');
2441             $statusBar.show();
2442         }
2443
2444         addFile(file);
2445         setState('ready');
2446         updateTotalProgress();
2447     };
2448
2449     uploader.onFileDequeued = function (file) {
2450         fileCount--;
2451         fileSize -= file.size;
2452
2453         if (!fileCount) {
2454             setState('pedding');
2455         }
2456
2457         removeFile(file);
2458         updateTotalProgress();
2459
2460     };
2461
2462     uploader.on('all', function (type) {
2463         var stats;
2464         switch (type) {
2465             case 'uploadFinished':
2466                 setState('confirm');
2467                 break;
2468
2469             case 'startUpload':
2470                 setState('uploading');
2471                 break;
2472
2473             case 'stopUpload':
2474                 setState('paused');
2475                 break;
2476
2477         }
2478     });
2479
2480     uploader.onError = function (code) {
2481         customBase.alert("M", 'Eroor: ' + code);
2482     };
2483
2484     $upload.on('click', function () {
2485         if ($(this).hasClass('disabled')) {
2486             return false;
2487         }
2488         if (state === 'ready') {
2489             uploader.upload();
2490             uploader.on('uploadSuccess', function (file, response) {
2491                 customBase.options.uploaderFileName[response.data.oldName] = response.data;
2492             })
2493         } else if (state === 'paused') {
2494             uploader.upload();
2495         } else if (state === 'uploading') {
2496             uploader.stop();
2497         }
2498     });
2499
2500     $info.on('click', '.retry', function () {
2501         uploader.retry();
2502     });
2503
2504     $info.on('click', '.ignore', function () {
2505         customBase.alert("M", 'todo');
2506     });
2507
2508     $upload.addClass('state-' + state);
2509     updateTotalProgress();
2510 }
2511
2512 //得到金融控件的HTMLL
2513 customBase.getAmountHtml = function (sizeWidthHeight, flag) {
2514     var width = sizeWidthHeight.width;
2515     var linewidth = (width - 10) / 11;
2516     var item = sizeWidthHeight.defaultvalue;
2517     var height = sizeWidthHeight.height;
2518     var lineheight = parseInt(height) + 20;
2519     var margin_top = '-20';
2520     var itemTemp = item.split("");
2521     var items = [];
2522     var nbsp = '';
2523
2524     if (flag) {
2525         nbsp = 'nbsp';
2526     } else {
2527         nbsp = '&nbsp;';
2528         margin_top = '10';
2529     }
2530     for (var i = 0; i < 11; i++) {
2531         items[i] = nbsp;
2532     };
2533     for (var i = 0; i < itemTemp.length; i++) {
2534         items[11 - i - 1] = itemTemp[itemTemp.length - i - 1];
2535     };
2536
2537     var oNode = '<div style="width:' + (width) + 'px;">';
2538     oNode += '<hr style="float:left;width: 1px;height:' + lineheight + 'px;margin-top:' + margin_top + 'px;border: #fff;"/>';
2539     if (items[0] == "nbsp") {
2540         // items[0] = " ";
2541         oNode += '<span style="width:' + (linewidth) + ';float:left;line-height:' + height + 'px;color:#fff;">' + '&#160;' + '</span>';
2542     } else {
2543         oNode += '<span style="width:' + (linewidth) + ';float:left;line-height:' + height + 'px;">' + items[0] + '</span>';
2544     }
2545
2546     var hrcolor = "";
2547     for (var i = 0; i < 10; i++) {
2548         if (i == 2 || i == 5) {
2549             hrcolor = '#31b0d5';
2550         } else if (i == 8) {
2551             hrcolor = '#D53137';
2552         } else {
2553             hrcolor = '#eee';
2554         }
2555         oNode += '<hr style="border:0px;background-color:' + hrcolor + ';color:' + hrcolor + ';float: left;width: 1px;height:' + lineheight + 'px;margin-top:' + margin_top + 'px;"/>';
2556         // oNode += '<span style="width:'+linewidth+'px;float:left;line-height:'+height+'px;">'+items[i+1]+'</span>';
2557         ////////////console.log(items[i+1]);
2558         if (items[i + 1] == "nbsp") {
2559             // items[0] = "0";
2560             oNode += '<span style="width:' + linewidth + 'px;float:left;line-height:' + height + 'px;color:#fff;">' + '&#160;' + '</span>';
2561         } else {
2562             oNode += '<span style="width:' + linewidth + 'px;float:left;line-height:' + height + 'px;">' + items[i + 1] + '</span>';
2563         }
2564
2565     };
2566     oNode += "</div>";
2567     return oNode;
2568 }
2569
2570 //条码设定
2571 customBase.createbarcode = function (val, text, callback) {
2572
2573     var sizeWidthHeight = { width: 88, height: 40, styleclass: "" };
2574     var barWidth = 1;
2575     var barHeight = 5;
2576     val = parseInt(val);
2577     val = val;
2578     if (val == 1) {
2579         barWidth = 1;
2580         barHeight = 30;
2581         sizeWidthHeight = { width: 88, height: 40, styleclass: "" };
2582     } else if (val == 2) {
2583         barWidth = 2;
2584         barHeight = 40;
2585         sizeWidthHeight = { width: 176, height: 50, styleclass: "" };
2586     } else if (val == 3) {
2587         barWidth = 3;
2588         barHeight = 50;
2589         sizeWidthHeight = { width: 264, height: 60, styleclass: "" };
2590     } else if (val == 4) {
2591         barWidth = 4;
2592         barHeight = 60;
2593         sizeWidthHeight = { width: 352, height: 70, styleclass: "" };
2594     } else if (val == 5) {
2595         barWidth = 5;
2596         barHeight = 70;
2597         sizeWidthHeight = { width: 440, height: 80, styleclass: "" };
2598     } else if (val == 6) {
2599         barWidth = 6;
2600         barHeight = 80;
2601         sizeWidthHeight = { width: 528, height: 90, styleclass: "" };
2602     }
2603
2604     //条形码数据回调
2605     callback(text, barWidth, barHeight, sizeWidthHeight);
2606 }
2607 customBase.zTreeOnClick = function (event, treeId, treeNode) {
2608     console.log(this);
2609     console.log(event);
2610     console.log(treeId);
2611     console.log(treeNode);
2612
2613     if (treeNode.checked) {
2614         // 单击事件 by kill
2615         if ($('#span_' + treeNode.id).val() == undefined || $('#span_' + treeNode.id).val() == "") {
2616             var i = $('#' + treeId).children(':first').children(':nth-child(2)').attr('class').indexOf('radio');
2617             if (i != -1) {
2618                 ////console.log(i)
2619                 ////console.log('span_'+treeId)
2620                 $('.span_' + treeId).remove();
2621                 $('#' + treeId.replace("tree", ""))
2622                     .parent().parent().children(':first').children(':nth-child(4)').remove();
2623             }
2624             //$('#'+treeId.replace("tree","")).parent().parent().children(':first')
2625             // .append('<span id="span_'+treeNode.id+'">|'+treeNode.name+'&nbsp</sapn>')
2626         }
2627     } else {
2628         $('#span_' + treeNode.id).remove();
2629     }
2630     var dofuncion = customBase.options.zTreeOnClickItems[treeId];
2631     if (dofuncion != undefined) {
2632         eval(dofuncion);
2633     }
2634 };
2635 //  2017/11/2  李元杰 单选树选中事件
2636 customBase.zTreeOncheckRadio = function (e, treeId, treeNode) {
2637     //console.log($('#citySel').parents('div[name=treeWinTitle]').next().attr('id'));
2638
2639     var zTree = $.fn.zTree.getZTreeObj(treeId);
2640     //console.log(zTree)
2641     var nodes = zTree.getCheckedNodes(true);
2642     var v = "";
2643     var dataObj = {}
2644     for (var i = 0, l = nodes.length; i < l; i++) {
2645         v += nodes[i].name + ",";
2646         console.log(nodes)
2647         dataObj[nodes[i].id] = '1'
2648     }
2649     if (v.length > 0) v = v.substring(0, v.length - 1)
2650     // 2017/11/6  李元杰  单选树
2651
2652     // console.log($('#'+treeId).parents('div[name="TreeWin"]').find('.citySel'))
2653     // console.log(   )
2654
2655     $(e.currentTarget).parent().attr('value', JSON.stringify(dataObj))
2656     $(e.currentTarget).parents('div[name="TreeWin"]').find('.citySel').val(v);
2657     // // cityObj.attr("value", v);
2658     // console.log(e);
2659     // console.log(treeId);
2660     // console.log(treeNode);
2661     // // $('#'+treeId).parents('div[type="tree"]').find('h8').children(':nth-child(4)').remove();
2662     // console.log(  $('#'+treeId).parents('div[type="tree"]').find('h8'));
2663     // console.log( $('#'+treeId).parents('div[type="tree"]').find('h8').children(':nth-child(3)'))
2664
2665     // if(treeNode.checked){
2666     //     // 单击事件 by kill
2667     //     if($('#span_'+treeNode.id).val()==undefined||$('#span_'+treeNode.id).val()==""){
2668     //         //console.log($('#'+treeId))
2669     //       var i=$('#'+treeId).children(':first').children(':nth-child(2)').attr('class').indexOf('radio');
2670     //       if(i!=-1){
2671     //           //console.log(i)
2672     //           //console.log('span_'+treeId)
2673     //           $('.span_'+treeId).remove();
2674     //             $('#'+treeId.replace("tree",""))
2675     //             .parent().parent().children(':first').children(':nth-child(4)').remove();
2676     //       }
2677     //     }
2678     // }else{
2679     //           $('#span_'+treeNode.id).remove();
2680     // }
2681     var pitchon = `
2682             <span id="spanDiv'+${treeId}+'">
2683                  <span>|${v}</span>
2684             </span>
2685         `
2686     // $('#'+treeId).parents('div[type="tree"]').find('h8').children(':nth-child(4)').remove();
2687     // $('#'+treeId).parents('div[type="tree"]').find('h8').append(pitchon);
2688     var dofuncion = customBase.options.zTreeOnClickItems[treeId];
2689     if (dofuncion != undefined) {
2690         eval(dofuncion);
2691     }
2692 }
2693 customBase.settingChkboxType = {
2694     check: {
2695         autoCheckTrigger: false,
2696         chkboxType: { "Y": "", "N": "" },
2697         chkStyle: "checkbox",
2698         enable: true,
2699         nocheckInherit: false,
2700         radioType: "level"
2701     },
2702     view: {
2703         showIcon: false,
2704         showLine: false,
2705         txtSelectedEnable: true,
2706     },
2707     data: {
2708         simpleData: {
2709             enable: true,
2710             idKey: "id",
2711             pIdKey: "pId",
2712             rootPId: 0
2713         }
2714     },
2715     callback: {
2716         onClick: customBase.zTreeOnClick,
2717         onCheck: customBase.zTreeOncheckRadio,
2718     }
2719 }
2720
2721 customBase.settingRadioType = {
2722     check: {
2723         enable: true,
2724         chkStyle: "radio",
2725         radioType: "all",
2726     },
2727     view: {
2728         showIcon: false,
2729         showLine: false,
2730         txtSelectedEnable: true,
2731     },
2732     data: {
2733         simpleData: {
2734             enable: true,
2735             idKey: "id",
2736             pIdKey: "pId",
2737             rootPId: 0
2738         }
2739     },
2740     callback: {
2741         onClick: customBase.zTreeOnClick,
2742         onCheck: customBase.zTreeOncheckRadio,
2743     }
2744 }
2745
2746
2747
2748 customBase.zNodes = [{ name: "树控件", isParent: true }];
2749 var customShow = customShow || {};
2750
2751 customShow.button = {
2752     //基础字段
2753     printableBtn: { name: "打印", cssName: 'icon iconfont icon-dayin1 ', functionName: "customShow.onPrint" },
2754     exportBtn: { name: "导出", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "" },
2755     rejectBtn: { name: "驳回", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "customShow.rejectBtn" },
2756     submitBtn: { name: "提交", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "customShow.onclickSubmit" },
2757     auditableBtn: { name: "审批", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "customShow.auditableBtn" },
2758     queryBtn: { name: "查询", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "" },
2759     createBtn: { name: "新建", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "customShow.onclickSave1" },
2760     clearBtn: { name: "清空", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "customShow.onclickClear" },
2761     disposableBtn: { name: "取消", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: 'customShow.onclickCancel' },
2762     fromSaveBtn: { name: "保存", cssName: 'icon iconfont icon-bianji ', functionName: "customShow.onclickSave2" },
2763     editableBtn: { name: "编辑", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "customShow.onEditor" },
2764     //添加权限按钮  马习同  2017-12-14
2765     billuploadingBtn: { name: "票据上传", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "customShow.billuploading" },
2766     reuploadBtn: { name: "重新上传票据", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "customShow.reupload" },
2767     checkbillBtn: { name: "查看票据", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "customShow.checkbill" },
2768 }
2769 console.log(Flatpickr)
2770 Flatpickr.localize(Flatpickr.l10ns.zh); // 设置为中文
2771 customShow.options = {
2772     customItem: {},
2773     customViewDiv: "",
2774     customInit: {},
2775     htmlediterShow: {},
2776     attributeList: {}, //属性一览
2777     // editorFlag:true,
2778     formID: "",        //表单ID
2779     customShowFlag: "",//调用标识
2780     dataRowNum: "",    //更新行番号
2781     breakFlag: false,  //父画面刷新
2782     datasource: {},
2783     customItemShow: {},
2784     initTempDatas: {},  //临时初始化数据
2785     itemFormbase: "",
2786     jsonLinkage: {}, //公式用
2787     btnFlag: { editable: "1", printable: "1", auditable: "0", disposable: "0" }, //按钮表示
2788     subformList: {}, //子表单List
2789     subformDList: {},
2790     dropdownlist_I: 0,
2791     subformDValue: {},
2792     formsetting: {},
2793     showErrId: {},
2794     // LinkageAnalysisSetValueFlag:false
2795 }
2796
2797 customShow.initEvent = {
2798     //--------------------保存Button事件------------------------
2799     //画面check
2800     fromCheck: function (items, callback) {
2801         return customShow.onfromCheck(items);
2802         ////console.log(1)
2803     },
2804     //03检证执行
2805     validationRuleCheck: function (items, callback) { return true },
2806     //检证接口函数(第三口)
2807     validationRuleCheck3rd: function (items, callback) { return customShow.interfaceCheck(items) },//保存前计算费用  李伟民   10 - 31
2808     //发送数据到后台服务器,保存data
2809     fromSave: function (items, callback) {
2810
2811     },
2812     //发送数据到后台服务器,保存data
2813     fromSave3rd: function (items, callback) { return true },
2814     fromSaveLinkage: function (items, callback) { return true },
2815     //--------------------保存Button事件------------------------
2816     //--------------------初期化事件----------------------------
2817     //01接口绑定:接口名 接口变量名 自定义函数
2818     interfaceBind: [],
2819     //02事件绑定:字段别名 字段类型 事件名 自定义事件名
2820     // eventBind:[{fieldKey:"项目1",tag:"text",eventName:"click",functionName:"customShow.clickBindBase001"}],
2821     eventBind: [],
2822     //初期化接口
2823     interfaceInit: function (customShowFlag) {
2824         //表示模式
2825         console.log(customShowFlag)
2826         if (customShowFlag == 2) {
2827             customShow.controlInit("customViewUEditorCss");
2828             //控件初始化
2829             customShow.controlInit("customShow");
2830         } else {
2831             //控件初始化
2832             customShow.controlInit("customViewUEditorCss");
2833         }
2834         //事件初始化
2835         customShow.clickBind();
2836         //  12/14
2837         if (customShowFlag == 1) {
2838             // customShow.businessTypeAutoFun( 'businessTypeAuto','budget_itemCostType','cookie');
2839             SC.autoFieldKey();
2840         }
2841     },
2842     interfaceInit3rd: function (customShowFlag) { return true },
2843     //验证初期公式
2844     interfaceInitLinkage: function (customShowFlag) { return true },
2845     //密码输入
2846     passwordInputFlag: function (items, callback) { },
2847     //--------------------初期化事件----------------------------
2848     //--------------------取消事件----------------------------
2849     //取消接口
2850     cancelEvent: function (items, callback) { },
2851     //取消接口(第三方提供)
2852     cancelEvent3rd: function (items, callback) { return true },
2853     //取消接口
2854     cancelEventLinkage: function () { return true },
2855     //--------------------取消事件----------------------------
2856     //--------------------印刷事件----------------------------
2857     interfaceprint: function (items, callback) { },
2858     interfaceprint3rd: function (items, callback) { return true },
2859     //--------------------印刷事件----------------------------
2860 }
2861
2862 function getProcessLog() {//获得流程信息 李雁鸣  12-25
2863     localStorage.setItem("processLog", null);
2864     if (localStorage.getItem("customItem") != undefined && localStorage.getItem("customItem") != "undefined" && localStorage.getItem("customItem") != null && localStorage.getItem("customItem") != "" && localStorage.getItem("customItem") != null) {
2865         var ss = { "formID": JSON.parse(localStorage.getItem("customForm")).newFormID, "dataRowNum": JSON.parse(localStorage.getItem("customItem")).DATAROWNUM };
2866         var requestSingleForm = window.commonAjax("/ubp-api-seache/process/inst/log", ss, "POST", true, false);
2867         requestSingleForm.done(function (rs) {
2868             console.log(rs.data);
2869             console.log("新改的");
2870             if (rs.data != undefined) {
2871                 localStorage.setItem("processLog", JSON.stringify(rs.data.data));
2872             } else {
2873
2874             }
2875         });
2876     }
2877 };//获得流程信息 李雁鸣  12-25
2878
2879 customShow.Init = function () {
2880     getProcessLog() //获得流程信息 李雁鸣  12-25
2881     customShow.exCouldNumber = undefined;//初始化 云单编号 李伟民  12-22
2882     customShow.orderStatus = undefined;//初始化 表单状态 李伟民 12-26
2883     //数据源
2884
2885     //数据源信息取得
2886     var datasource = $.parseJSON(window.localStorage.getItem("datasource"));
2887     customShow.options.datasource = {};
2888     if (datasource != null) {
2889
2890         for (var i = 0; i < datasource.length; i++) {
2891             customShow.options.datasource[datasource[i].dataSourceName] = datasource[i];
2892         };
2893     }
2894
2895     // 0:预览 1:数据管理中新建 2:数据管理中展示(数据表示) 3:发布 4:模板中心
2896     var customShowFlag = window.localStorage.getItem("customShowFlag");
2897     customShow.options.customShowFlag = customShowFlag;
2898     //  12/13 测试模拟用
2899
2900     if (customShowFlag == "0" || customShowFlag == "1") {// 新建 预览  隐藏 详情页 李伟民  11-17
2901         console.log(customShowFlag);
2902         //   12/4 李元杰 日历当前时间
2903         // var dataObj = {
2904         //     "time":"yyyy-MM-dd HH:mm:ss"
2905         // }
2906         // var requestRight = window.commonAjax('/epc/getTime', dataObj, 'POST', true);
2907         // requestRight.done(function (res) {
2908         //     // if (res.rspCode == "000000") {
2909         //     console.log(res)
2910         //     // }
2911         // })
2912         var myDate = new Date();
2913         myDate.getFullYear();    //获取完整的年份(4位,1970-????)
2914         myDate.getMonth();       //获取当前月份(0-11,0代表1月)
2915         myDate.getDate();
2916         customShow.currentDate = myDate.getFullYear() + '-' + (myDate.getMonth() + 1) + '-' + myDate.getDate();
2917         console.log(new Date())
2918         console.log(customShow.currentDate)
2919         $("#customShow").removeClass("fui-form");
2920         console.log(customBase.options.customItemShow)
2921         // $(".preview-edit-pane").css("display", "none");
2922         // 12/23
2923
2924
2925
2926
2927     }// 新建 预览  隐藏 详情页 李伟民  11-17
2928     if (customShowFlag == "2") {
2929         console.log(customShowFlag);
2930         //12/23
2931         $(".preview-edit-pane").css("display", "block");
2932         // $("#editableBtn").on("click",() => {
2933         //     console.log($(".preview-edit-pane"));
2934
2935         // })
2936     }
2937     if (customShowFlag == "0") {
2938         //表单ID
2939         var customlocalStorage = window.localStorage.getItem("customForm");
2940         customlocalStorage = $.parseJSON(customlocalStorage);
2941         customShow.options.formid = customlocalStorage.newFormID;
2942         var customViewItem = window.localStorage.getItem("customViewItem");
2943
2944         customShow.InitShow({
2945             //绑定DIV
2946             showDiv: "customViewUEditor",
2947             //数据来源
2948             customShowFlag: customShowFlag,
2949             //表示模式
2950             designMode: customlocalStorage.mode,
2951             //画面表示基础数据
2952             customViewItem: $.parseJSON(customViewItem),
2953             //画面表示数据
2954             formbase: "",
2955         });
2956         $(".s_savebtn").hide();
2957         // $(".customShow .fa-calendar").addClass();
2958     } else {
2959         customShow.options.formid = window.localStorage.getItem("newFormID");
2960         //初期数据取得
2961         customDataBound.getFormbase(customShow.options.formid, function (rs) {
2962             if (rs.rspCode == "000000" && rs.data != null) {
2963                 //控件属性JSON对象
2964                 var field = JSON.parse(rs.data.fieldset);
2965                 //转换成数组
2966                 var fields = _.keysIn(field);
2967                 console.log(rs.data.fieldset)
2968
2969                 //循环读取tag_Type是否含有‘auto’
2970                 for (var i = 0; i < fields.length; i++) {
2971                     var attrib = field[fields[i]];
2972                     if (attrib.tag_Type != null && attrib.tag_Type == 'auto') {
2973                         //如果有那么就发送请求
2974                         var dataObj = {};
2975                         dataObj.prefix = attrib.tag_Attribute.prefixs["0"].itemtext_1 + '$in{' + attrib.tag_Attribute.prefixs["0"].itemtext_2 + '}';
2976                         dataObj.FormID = formid;
2977                         var requestRight = window.commonAjax('/datamanagement/getGenerateRandomNumService', dataObj, 'POST', true);
2978                         requestRight.done(function (res) {
2979                             if (res.rspCode == "000000") {
2980                                 var alisN = _.keysIn(customBase.options.customItems);
2981                                 for (var i = 0; i < alisN.length; i++) {
2982                                     var item = customBase.options.customItems[alisN[i]];
2983                                     if (item.type == "auto") {
2984                                         var itemID = item.id;
2985                                         customBase.setItemValue(itemID, 'text', res.data, '', '');
2986                                     }
2987                                 }
2988                             }
2989                         })
2990
2991                     }
2992                 }
2993
2994                 var formbase = window.localStorage.getItem("customItem");
2995                 //console.log(formbase)
2996                 //////////////console.log(formbase);
2997                 // //console.log(formbase);
2998                 var customItem = {
2999                     formeditor: rs.data.resultForm,
3000                     item: $.parseJSON(rs.data.fieldset),
3001                     //表单宽度
3002                     fromwidth: rs.data.formWidth,
3003                     //表单高度
3004                     fromheigh: rs.data.formHeight,
3005                     //表单名
3006                     formName: rs.data.formName,
3007                     customFlag: rs.data.designMode,
3008                     Linkage: rs.data.linkage
3009                 }
3010                 //console.log(customItem);
3011                 //console.log(formbase)
3012                 customShow.InitShow({
3013                     //绑定DIV
3014                     showDiv: "customViewUEditor",
3015                     //数据来源
3016                     customShowFlag: customShowFlag,
3017                     //表示模式
3018                     designMode: rs.data.designMode,
3019                     //画面表示基础数据
3020                     customViewItem: customItem,
3021                     //画面表示数据
3022                     formbase: formbase,
3023                 });
3024             } else {
3025
3026             }
3027         });
3028     }
3029
3030 }
3031 // 12/4 李元杰 当前时间
3032 customShow.currentDate = '';
3033 function changeOrderStatus(orderStatus){//修改表单状态  李伟民  01-04
3034     if(orderStatus == undefined){
3035         return false;
3036     }
3037     switch(orderStatus){
3038         case '10':
3039             $('#stateText').html('自动审单中');
3040             break
3041         case '15':
3042             $('#stateText').html('自动审单成功');
3043             break
3044         case '19':
3045             $('#stateText').html('自动审单失败');
3046             break
3047         case '20':
3048             $('#stateText').html('未上传单据');
3049             break
3050         case '40':
3051             $('#stateText').html('记账处理中');
3052             break
3053         case '45':
3054             $('#stateText').html('记账处理完成');
3055             break
3056         case '49':
3057             $('#stateText').html('记账处理失败');
3058             break
3059         case undefined:
3060             $('#stateText').html('test');
3061             break
3062
3063     }
3064 }
3065 //画面初期化
3066 customShow.InitShow = function (customInit) {
3067     //画面初期迁移源属性取得
3068     // 0:预览 1:数据管理中新建 2:数据管理中展示 3:发布 4:模板中心
3069     //console.log(customInit)
3070     if (customInit.customViewItem != null && customInit.customViewItem != undefined) {
3071         customShow.costType = customInit.customViewItem.item;
3072     }
3073     var customShowFlag = customInit.customShowFlag;
3074     var customViewDiv = "#" + customInit.showDiv;
3075     customShow.options.customInit = customInit;
3076     customShow.options.customViewDiv = customInit.showDiv;
3077     //画面初期化(画面表示基础数据)
3078     customShow.options.customItemShow = customInit.customViewItem;
3079     customShow.options.jsonLinkage = customShow.options.customItemShow.Linkage;
3080     var customItem = customShow.options.customItemShow;
3081     setTimeout(function () {
3082         if (customShowFlag == "4") {
3083             $(".customViewUEditorCss").css("height", window.innerHeight);
3084             $(".customShow").css("height", window.innerHeight - 200);
3085         } else {
3086             $(".customViewUEditorCss").css("height", window.innerHeight - 200);
3087             $(".customShow").css("height", window.innerHeight - 200);
3088         }
3089     }, 10);
3090     var btns = [];
3091     //展示数据表示
3092
3093     if (customShowFlag == "0" || customShowFlag == "6") {
3094         //2017-12-27 马习同   专家模式打印
3095         var print_btnFlag = window.localStorage.getItem("print_btnFlag");
3096         if (customShowFlag == "0" && print_btnFlag == "1"){
3097             var btns = [
3098                 "printableBtn"
3099             ];
3100             customShow.setToolBtn(btns);
3101         }
3102         ////console.log(window.customBase);
3103         //标题头表示
3104         $('#childclick').css("display", "none");
3105         $(".header")[0].style.display = "block";
3106         //标题设定
3107         $(".modal-title")[0].innerHTML = customItem.formName;
3108
3109         //画面内容的初始化设定
3110         customShow.setContentHtml(customItem, customViewDiv);
3111         //编辑模式下表示
3112         $(customViewDiv)[0].style.display = "block";
3113
3114         //1:数据管理中新建  3:发布 4:模板中心
3115     } else if (customShowFlag == "1" || customShowFlag == "3") {
3116         //标题头表示
3117         console.log("显示X");
3118         console.log($('#childclick'));
3119         $('#childclick').css("display", "block");
3120         $('#childclick').click(() => {
3121             customShow.onclickCancel();
3122             console.log("点击父元素关闭");
3123         });
3124
3125         $(".header")[0].style.display = "block";
3126         //标题设定
3127         $(".modal-title")[0].innerHTML = customItem.formName;
3128         //画面内容的初始化设定
3129         customShow.setContentHtml(customItem, customViewDiv);
3130
3131         // $(".footer")[0].style.display ="block";
3132         //编辑模式下表示
3133         $(customViewDiv)[0].style.display = "block";
3134         //2:数据管理中展示
3135         //第三方事件绑定
3136         // customShow.setEventBind();
3137         if (customShowFlag == "1") {
3138             var btns = [
3139                 'rejectBtn',
3140                 'submitBtn',
3141                 'auditableBtn',
3142                 'queryBtn',
3143                 'clearBtn',
3144                 'disposableBtn',
3145                 //  'fromSaveBtn',
3146             ];
3147         } else {
3148             var btns = [
3149                 'rejectBtn',
3150                 'submitBtn',
3151                 'auditableBtn',
3152                 'queryBtn',
3153                 'createBtn',
3154                 'clearBtn',
3155                 'disposableBtn',
3156                 'fromSaveBtn',
3157             ];
3158         }
3159     }
3160     else if (customShowFlag == "4") {
3161         //标题头表示
3162         $(".header")[0].style.display = "none";
3163         //标题设定
3164         // $(".modal-title")[0].innerHTML=customItem.formName;
3165         //画面内容的初始化设定
3166         customShow.setContentHtml(customItem, customViewDiv);
3167         //编辑模式下表示
3168         $(customViewDiv)[0].style.display = "block";
3169         // $(".footer")[0].style.display ="none";
3170         //编辑模式下表示
3171         // $(customViewDiv)[0].style.display ="block";
3172         //第三方事件绑定
3173         // customShow.setEventBind();
3174     } else if (customShowFlag == "2") {
3175         console.log("显示X");
3176         console.log($('#childclick'));
3177         $('#childclick').css("display", "block");
3178         if (JSON.parse(window.localStorage.getItem('allow')) == true) {
3179             $('#childclick').css("display", "none");
3180         } else {
3181             $('#childclick').css("display", "block");
3182         }
3183         $('#childclick').click(() => {
3184             customShow.onclickCancel();
3185             console.log("点击父元素关闭");
3186
3187         });
3188         //按钮修改 马习同 2017-12-13
3189         // var btnshowFlag = {
3190         //     a = true,
3191         //     b = flase,
3192         // };
3193         // if(btnshowFlag.a == true){
3194         //     btns.push();
3195         // }
3196         var btns = [
3197             // 'checkbillBtn',//查看票据
3198             'rejectBtn',//驳回
3199             'submitBtn',//提交
3200             'auditableBtn',//审批
3201             'editableBtn',
3202             'printableBtn',//打印
3203         ];
3204         //画面内容的初始化设定
3205         console.log(customItem);
3206         console.log(customViewDiv);
3207         customShow.setContentHtml(customItem, customViewDiv);
3208         var items = {};
3209         //数据变换
3210         //console.log(customInit);
3211         //console.log(customInit.formbase)
3212         var formbase = $.parseJSON(customInit.formbase);
3213         //console.log(formbase);
3214         customShow.options.dataRowNum = formbase['DATAROWNUM'];
3215         customShow.exCouldNumber = formbase['orderCode'];//获取云单编号 李伟民 12-26
3216         if(customShow.exCouldNumber){
3217             $('#exCloudNumberText').html('云单编号:' + customShow.exCouldNumber);
3218         }
3219         customShow.orderStatus = formbase['orderStatus'];// 获取表单状态 李伟民  12-26
3220         changeOrderStatus(customShow.orderStatus);
3221         items = formbase;
3222         customShow.options.itemFormbase = formbase;
3223         console.log(_.cloneDeep(items));
3224         delete items['DATAROWNUM'];
3225         console.log(_.cloneDeep(items));
3226         //初期化后,数据赋值(编辑模式)
3227         console.log(_.cloneDeep(items));
3228         customShow.showCustom(items, customShow.options.customInit);
3229         //初期化后,数据赋值(预览)
3230         console.log(_.cloneDeep(items));
3231         customShow.setShowCustomItem(items);
3232         //初期化后,票据信息追加  李伟民  12-26
3233         SC.billInfoInit(items);
3234
3235
3236         //数据源再次追加
3237         // var customItems = customShow.options.customItemShow.item;
3238         var customItems = customBase.options.customItems;
3239         console.log(customItems);
3240         for (item in customItems) {
3241             if (customItems.hasOwnProperty(item)) {
3242                 if (customItems[item].type == 'dropdownlist' || customItems[item].type == 'radio' ||
3243                     customItems[item].type == 'checkbox' || customItems[item].type == 'tree') {
3244                     var datasourcetype = customShow.options.customItemShow.item[customItems[item].id].tag_Attribute.datasourcetype;
3245                     console.log(datasourcetype);
3246                     if (datasourcetype == "custom") {
3247                         //数据源绑定(自定义数据)
3248                         customShow.setDatasourceData(customItems[item]);
3249                     }
3250                 }
3251             }
3252         }
3253         //标题头表示
3254         $(".header")[0].style.display = "block";
3255         //标题设定
3256         $(".modal-title")[0].innerHTML = customItem.formName;
3257         //  12/19
3258         $("#customViewUEditor")[0].style.display = "none";
3259         //2017/11/18  马习同修改 隐藏预览模式下  导入数据按钮
3260         $(".sonImportFile").addClass("cfg_contentNone");
3261         $(".s_savebtn").hide();
3262         $(".customShow .fa-calendar").addClass("cfg_contentNone");
3263
3264         console.log($(".customShow .tdContentClass"))
3265         // _.each($(".customShow .tdContentClass"),opt=>{
3266         //     // $(opt).attr("title", $(opt).children().children().html());
3267         //     console.log($(opt).html())
3268         //     if ($(opt).children().children().attr("type") == "text"){
3269         //         $(opt).attr("title", $(opt).children().children().val());
3270         //     }else{
3271         //         console.log(_.cloneDeep($(opt).children().children()))
3272         //         console.log(opt.innerHTML)
3273         //         console.log($(opt).children().children()[0].innerHTML)
3274         //         $(opt).attr("title", $(opt).children().children()[0].innerHTML);
3275         //     }
3276         // })
3277
3278     }
3279     //第三方事件绑定
3280     var token = localStorage.getItem('token');//页面事件绑定 李伟民 12-22
3281     if (token != '' && token != undefined) {
3282         token = JSON.parse(token);
3283     }
3284     var postdata = { 'formID': customShow.options.formid };
3285     _.extend(postdata, token);
3286     var eventBindRquest = window.commonAjax('/formevent/getFormEventListService', postdata, 'GET', true, false);
3287     eventBindRquest.done(function (res) {
3288         if (res.data != undefined) {
3289             // var eventBindData = [];
3290             // _.each(res.data,function(data){
3291             //     eventBindData.push({'fieldName':data.fieldName,'tag':data.fieldType,'eventName':data.event,'functionName':data.eventmethod});
3292             // });
3293             customShow.initEvent.eventBind = res.data;
3294         }
3295         customShow.setEventBind();
3296     });//页面事件绑定 李伟民 12-22
3297
3298     // SC.showUser()//报销人根据当前登录人自动带出  李伟民  0108
3299
3300     customShow.setToolBtn(btns);
3301     $(".select2-selection").remove();
3302     customShow.hidesubform();
3303     var unvisible = customBase.options.customItems;
3304     for (item in unvisible) {
3305         if (unvisible[item].type == "subform") {
3306             var itemId = unvisible[item].id;
3307             //          var itemTwo = itemId;
3308             //          var itemSubform = $('.'+"customViewUEditorCss" +" #"+itemId+"ActiveId");
3309             ////////////console.log(item);
3310             //子表单删除第一条可添加  2017/10/26 马习同
3311             //          var divIcon = $('<div id="'+itemId+'save" class="cfg_contentNone"></div>');
3312             var cloneE = $('#' + itemId + 'subformTr').clone();
3313             //          divIcon.append(cloneE);
3314             console.log(cloneE);
3315             //          itemSubform.append(divIcon);
3316             customBase.options.customItems[item]['cloneDiv'] = cloneE;
3317         }
3318     }
3319     //2017-12-12  马习同隐藏
3320     SC.Superior_hide();
3321     if (customShowFlag == "1" || customShowFlag == "0") {
3322         // window.localStorage.setItem('businessTypeAuto','240');
3323         $(".preview-edit-pane").find('#disposableBtn').css('display', 'none');
3324         $(".preview-edit-pane").find('#clearBtn').css('display', 'none');
3325         $(".preview-edit-pane").find('#queryBtn').css('display', 'none');
3326         $(".preview-edit-pane").find('#auditableBtn').css('display', 'none');
3327         $(".preview-edit-pane").find('#submitBtn').css('display', 'none');
3328         $(".preview-edit-pane").find('#rejectBtn').css('display', 'none');
3329     }
3330 }
3331 //   2017/10/20   李元杰  抽出了 李伟民的计算费用的方法 最后将数据return出去了
3332 //计算费用
3333 //customShow.queryCostAllData = function(){
3334 //    var post_data = [];
3335 //    var items = customShow.getItems();
3336 //    var items_key = _.keysIn(items);
3337 //    var all_data = {};
3338 //    //console.log(items);
3339 //    _.each(items_key,function(item){
3340 //        var control = {};
3341 //        var item_attr = customBase.options.customItems[item];
3342 //        if(_.isArray(items[item]) && _.isObject(items[item][0])){//判断是否为子表单
3343 //            _.extend(control,{'fieldKey':item,'mdCode':'','value':'','type':item_attr.type,'child':[]});
3344 //            _.each(items[item],function(cd){
3345 //                var cd_key = _.keysIn(cd);
3346 //                var item_cd = {
3347 //                    "items":[],
3348 //                    "cid":""
3349 //                };
3350 //                _.each(cd_key,function(cdk){
3351 //                    var control_cd = {};
3352 //                    var item_attr_cd = customBase.options.customItems[cdk];
3353 //                    _.extend(control_cd,{'fieldKey':cdk,'mdCode':customShow.getmasterdataById(item_attr_cd.id),'value':cd[cdk],'type':item_attr_cd.type});
3354 //                    item_cd.items.push(control_cd);
3355 //                    if(cdk == "dataRowNum"){
3356 //                        item_cd.cid = cd[cdk];
3357 //                    }
3358 //                });
3359 //                control.child.push(item_cd);
3360 //            });
3361 //            //行程ID 预留
3362 //        }else{
3363 //            _.extend(control,{'fieldKey':item,'mdCode':customShow.getmasterdataById(item_attr.id),'value':items[item],'type':item_attr.type});
3364 //        }
3365 //        post_data.push(control);
3366 //    });
3367 //    var customShowFlag = window.localStorage.getItem("customShowFlag");
3368 //    var customForm = window.localStorage.getItem("customForm");
3369 //    if(customForm && customForm != ""){
3370 //        customForm = JSON.parse(customForm);
3371 //    }
3372 //    if(customShowFlag == 2){//详情
3373 //        var customItem = window.localStorage.getItem("customItem");
3374 //        if(customItem && customItem != ""){
3375 //            customItem = JSON.parse(customItem);
3376 //            //console.log(customItem);
3377 //        }
3378 //        _.extend(all_data,{"data":post_data,"formId":customForm.newFormID,"id":customItem.DATAROWNUM});
3379 //    }else{//新建或预览
3380 //        _.extend(all_data,{'data':post_data,"formId":customForm.newFormID,"id":""});
3381 //    }
3382 //    _.extend(all_data,{'orderCode':""});
3383 //    _.extend(all_data,{'ctId':"240"});// 费用类型 假
3384 //  return all_data;
3385 //}
3386 //计算费用
3387 //customShow.queryCost = function(){
3388 //  // 2017/10/20 李元杰 queryCostAllData 抽出来存这里了
3389 //  //   var post_data = [];
3390 //  //   var items = customShow.getItems();
3391 //  //   var items_key = _.keysIn(items);
3392 //  //   var all_data = {};
3393 //  //   //console.log(items);
3394 //  //   //console.log(items_key)
3395 //  //   _.each(items_key,function(item){
3396 //  //       var control = {};
3397 //  //       //console.log(item);
3398 //  //       var item_attr = customBase.options.customItems[item];
3399 //  //       //console.log(item_attr)
3400 //  //       if(_.isArray(items[item]) && _.isObject(items[item][0])){//判断是否为子表单
3401 //  //           _.extend(control,{'fieldKey':item,'mdCode':'','value':'','type':item_attr.type,'child':[]});
3402 //  //           _.each(items[item],function(cd){
3403 //  //               //console.log(cd)
3404 //  //               var cd_key = _.keysIn(cd);
3405 //  //               //console.log(cd_key)
3406 //  //               var item_cd = {
3407 //  //                   "items":[],
3408 //  //                   "cid":""
3409 //  //               };
3410 //  //               _.each(cd_key,function(cdk){
3411 //  //                   var control_cd = {};
3412 //  //                   var item_attr_cd = customBase.options.customItems[cdk];
3413 //  //                   //console.log(item_attr_cd);
3414 //  //                   _.extend(control_cd,{'fieldKey':cdk,'mdCode':customShow.getmasterdataById(item_attr_cd.id),'value':cd[cdk],'type':item_attr_cd.type});
3415 //  //                   item_cd.items.push(control_cd);
3416 //    //                 if(cdk == "dataRowNum"){
3417 //    //                     item_cd.cid = cd[cdk];
3418 //    //                 }
3419 //  //               });
3420 //  //               control.child.push(item_cd);
3421 //  //           });
3422 //  //           //行程ID 预留
3423 //  //       }else{
3424 //  //           _.extend(control,{'fieldKey':item,'mdCode':customShow.getmasterdataById(item_attr.id),'value':items[item],'type':item_attr.type});
3425 //  //       }
3426 //  //       post_data.push(control);
3427 //  //   });
3428 //  //   var customShowFlag = window.localStorage.getItem("customShowFlag");
3429 //  //   var customForm = window.localStorage.getItem("customForm");
3430 //  //   if(customForm && customForm != ""){
3431 //  //       customForm = JSON.parse(customForm);
3432 //  //   }
3433 //  //   if(customShowFlag == 2){//详情
3434 //  //       var customItem = window.localStorage.getItem("customItem");
3435 //  //       if(customItem && customItem != ""){
3436 //  //           customItem = JSON.parse(customItem);
3437 //    //         //console.log(customItem);
3438 //  //       }
3439 //  //       _.extend(all_data,{"data":post_data,"formId":customForm.newFormID,"id":customItem.DATAROWNUM});
3440 //  //   }else{//新建或预览
3441 //  //       _.extend(all_data,{'data':post_data,"formId":customForm.newFormID,"id":""});
3442 //  //   }
3443 //  //   _.extend(all_data,{'orderCode':""});
3444 //  //   _.extend(all_data,{'ctId':"240"});// 费用类型 假
3445 //  //   //console.log(all_data);
3446 //  //   //console.log(JSON.stringify(all_data))
3447 //    var all_data = customShow.queryCostAllData();
3448 //    // 2017/10/20 李元杰 queryCostAllData 抽出来存这里了  end
3449 //    var query_request =  window.queryAjax("epc-count/countCost",all_data,"POST",true,false);
3450 //    ////console.log(query_request);
3451 //    query_request.done(function(res){
3452 //        ////console.log("6531289");
3453 //        customBase.listen_check(res.data,"query_check");
3454 //    })
3455 //
3456 //    return all_data;
3457 //}
3458 // 12/12  模态框
3459 $('.closeBtn').on('click', () => {
3460     $('.maskLayer').css('display', 'none');
3461     customShow.clean();
3462 })
3463 //扩展费用自定义方法,yuezhw 2017-11-13
3464 customShow.extended_budget = function (where) {
3465     var obj = {};
3466     obj.formId = localStorage.getItem("newFormID");
3467     obj.dataId = JSON.parse(localStorage.getItem("customItem")).DATAROWNUM;
3468     obj.tenantID = JSON.parse(localStorage.getItem("tenantID")).tenantID;
3469     var query_request;
3470     flatpickr("#budget_time", {
3471         dateFormat: "Y-m-d"
3472     })
3473
3474     var budgetNumber = $('#customShow').find('div[type="auto"]').find('input').val();
3475     var budgetDate = $($('#customShow').find('div[type="calendar"]')[1]).find('input').val();
3476     $('#budget_number').val(budgetNumber)
3477     $('#budget_date').val(budgetDate)
3478     $('#extended_someThing').css("display", "block");
3479     $('#budget_time').css("display", "block");
3480     $('.maskLayer').css('display', 'block');
3481     $('#budget_todo').on('click', () => {
3482         obj.department = $('#budget_department').val();
3483         obj.info = $('#budget_time').val();
3484         var nowTime = new Date(Date.parse(obj.info));
3485         var endTime = new Date(Date.parse(JSON.parse(localStorage.getItem("customItem")).budgetEndDate));
3486         console.log(obj.info);
3487         console.log(nowTime);
3488         console.log(endTime);
3489         if (obj.info.length < 1) {
3490             alert("请输入增加时间");
3491         } else if (nowTime < endTime) {
3492             alert("扩展时间不可小于当前结束时间!");
3493         } else {
3494             var query_request = window.queryAjaxQQ("epc-form/extend/budget/time", obj, "POST", true, false);
3495             query_request.done(function (res) {
3496                 console.log(typeof res.data)
3497                 console.log(res.data)
3498                 if (res.data === true) {
3499                     alert("扩展时间成功!");
3500                     customShow.clean();
3501                     $('.maskLayer').css('display', 'none');
3502                 } else {
3503                     alert("服务器通信失败");
3504                 }
3505             })
3506             query_request.error(function (rs) {
3507                 // console.log(rs)
3508                 toastr.error(rs.responseJSON.rspDesc);
3509
3510             })
3511         }
3512
3513     })
3514     $('#budget_undo,.closeModal').on('click', () => {
3515         customShow.clean();
3516     })
3517 }
3518 //关闭页面
3519 customShow.clean = function () {
3520     $('#extended_someThing').css("display", "none");
3521     $('#budget_whrere').val('');
3522     $('#budget_money').val('');
3523     $('#budget_time').val('');
3524 }
3525 //根据别名获取主数据
3526 customShow.getmasterdataById = function (itemid) {
3527     var mdata = undefined;
3528     ////console.log(itemid);
3529     if (customShow.options.customItemShow.item[itemid] != undefined) {
3530         if (customShow.options.customItemShow.item[itemid].tag_Attribute.masterData != undefined && customShow.options.customItemShow.item[itemid].tag_Attribute.masterData != '') {
3531             mdata = JSON.parse(customShow.options.customItemShow.item[itemid].tag_Attribute.masterData);
3532         }
3533     }
3534     if (mdata != undefined) {
3535         return mdata.defindCode;
3536     } else {
3537         return "";
3538     }
3539 }
3540
3541 //数据赋值 ----编辑项目赋值
3542 customShow.setShowCustomItem = function (items) {
3543     //   2017/10/19  李元杰  在费用明细里插入一些信息
3544     // 需要传给后端的对象
3545     //console.log(items);
3546     // var objData =  customShow.queryCostAllData();
3547     //  获取orderCode的值
3548
3549     // if(objData.orderCode){
3550     // var  orderCode =  customBase.getItemValue(customBase.options.customItems.orderCode.id,customBase.options.customItems.orderCode.type)
3551     // objData.orderCode = orderCode[1];
3552     // var requestInsert  = window.commonAjax("/datamanagement/getAssociatedFormDataService", objData, "POST", true);
3553     // requestInsert.done(function (res) {
3554     //     for(var i = 0 ; i <res.data.data.length;i++){
3555     //         if(res.data.data[i].child){
3556     //             for(var j = 0;j<res.data.data[i].child.length;j++){
3557     //                 // 循环子表单里拥有dataRowNum的数量
3558     //                     $(`[id= ${customBase.options.customItems.dataRowNum.id}]`).each( (index,ipt)=>{
3559     //                         // 获取返回值里的value和子表单里的dataRowNum的值是否相同
3560     //                             if(  res.data.data[i].child[j].msgInfo.header[0].value == $(ipt).val()){
3561     //                                 // 寻找当前子表单的父节点里的H8标签插入数据
3562     //                                 $($(`[id= ${customBase.options.customItems.dataRowNum.id}]`)[index].closest('[type=subform]')).children('h8').find('.text')
3563     //                                 .append(` <span>${res.data.data[i].child[j].msgInfo.header[0].name}</span>`)
3564     //                             }
3565     //                     })
3566     //             }
3567     //         }
3568     //     }
3569     // });
3570     // }
3571     //delete items['DATAROWNUM']; // 子表单中  不删除datarownum  李伟民  11-16
3572     var items = _.cloneDeep(items);
3573     var customItems = customBase.options.customItems;
3574     //console.log(customItems);
3575     //数据值变换
3576     for (item in items) {
3577         if (items.hasOwnProperty(item)) {
3578             if (customItems[item] == undefined) {
3579                 delete customItems[item];
3580                 continue;
3581             }
3582             if (customItems[item].type == 'subform' || customItems[item].type == 'tag' || customItems[item].type == 'tab') {
3583                 var subformTemp = items[item];
3584                 console.log(subformTemp)
3585                 if (subformTemp == undefined) {
3586                     subformTemp = [{}];
3587                 }
3588                 for (subformItem in subformTemp[0]) {
3589                     if (subformTemp[0].hasOwnProperty(subformItem)) {
3590                         items[subformItem] = [];
3591                     }
3592                 }
3593                 console.log(subformTemp.length);//主数据丢失
3594                 for (var i = 0; i < subformTemp.length; i++) {
3595                     if (i != 0) {
3596                         //子表单项目追加
3597                         var subformAdd = $(".customViewUEditorCss #" + customItems[item].id + "ActiveId .subformAdd")[0];
3598                         customShow.addsubformList(subformAdd, "customViewUEditorCss");
3599                     }
3600                     for (subformItem in subformTemp[i]) {
3601                         if (subformTemp[i].hasOwnProperty(subformItem)) {
3602                             items[subformItem][i] = subformTemp[i][subformItem];
3603                         }
3604                     }
3605                 };
3606             }
3607         }
3608     }
3609
3610     //delete items['DATAROWNUM']; // 子表单中  不删除datarownum  李伟民  11-16
3611     console.log(_.cloneDeep(items))
3612     console.log(customItems);
3613     //数据赋值
3614     for (item in items) {
3615         console.log(item);
3616         if (items.hasOwnProperty(item)) {
3617             if (customItems[item] == undefined) {
3618                 delete customItems[item];
3619                 continue;
3620             }
3621             var type = customItems[item].type;
3622             var id = customItems[item].id;
3623             console.log(id);
3624             console.log(items[item]);
3625             if (
3626                 // type == 'radio' || type == 'checkbox' ||
3627                 // type == 'dropdownlist'||
3628                 // type == 'tree'||
3629                 // type == 'amount'||
3630                 // type == 'barcode'||
3631                 // type == 'qrcode' ||
3632                 // type == 'image'||
3633                 type == 'button'
3634                 // || type == 'fileupload'
3635                 || type == 'subform' || type == 'link'
3636                 || type == 'splitline' || type == 'link' || type == 'tag' || type == 'tab'
3637             ) {
3638
3639             } else if (customItems[item].type == "image" || customItems[item].type == "fileupload") {
3640                 var itemId = customItems[item].id;
3641                 if (items[item] != "") {
3642                     customBase.options.uploaderItemReady[itemId] = $.parseJSON(items[item]);
3643                 } else {
3644                     customBase.options.uploaderItemReady[itemId] = [];
3645                 }
3646             } else if (type == 'amount') {
3647                 var id = id + "amount";
3648                 customBase.setItemValue(id, 'text', items[item], 'customViewUEditorCss');
3649                 $("#" + id).blur();
3650             } else if (type == 'qrcode') {
3651                 var id = id + "qrcode";
3652                 customBase.setItemValue(id, 'text', items[item], 'customViewUEditorCss');
3653                 $("#" + id).blur();
3654             } else if (type == 'barcode') {
3655                 var id = id + "barcode";
3656                 customBase.setItemValue(id, 'text', items[item], 'customViewUEditorCss');
3657                 $("#" + id).blur();
3658             } else if (type == 'dropdownlist' || type == 'radio' || type == 'checkbox' || type == 'tree') {
3659                 //异步加载时数据临时保存
3660                 customShow.options.initTempDatas[id] = items[item];
3661                 // var datasourcetype = $("#"+id)[0].getAttribute("datasourcetype");
3662                 // //主数据源
3663                 // if(datasourcetype == "masterdata"){
3664                 //   customBase.setItemValue(id,type,items[item],'customViewUEditorCss');
3665                 //   //数据源
3666                 // }else if(datasourcetype == "datasource"){
3667                 //   customBase.setItemValue(id,type,items[item],'customViewUEditorCss');
3668                 //   //自定义
3669                 // }else if(datasourcetype == "custom"){
3670                 //   customBase.setItemValue(id,'dropdownlistText',items[item],'customViewUEditorCss');
3671                 //   //API接口
3672                 // }else if(datasourcetype == "api"){
3673                 //   customBase.setItemValue(id,type,items[item],'customViewUEditorCss');
3674                 // }
3675
3676             } else if (customItems[item].type == 'mytext') {
3677                 //选择表单预览回显
3678                 var itemAttribute = customShow.options.customItemShow.item[customItems[item].id];
3679                 var item_title = [];
3680                 var itemVal = [];
3681                 var $mytext = $("#customShow " + "#" + customItems[item].id + "ActiveId");
3682                 if (itemAttribute.tag_Attribute.relevancesourcetype == "fundata") {// 关联数据回显渲染 李伟民 11-30
3683                     var titleObj = { "key": JSON.parse(itemAttribute.tag_Attribute.fundata)["key"] };
3684                     var dataObj = {
3685                         "formID": customShow.options.formid,
3686                         "tenantID": "001",
3687                         "search": [],
3688                         "pageSize": "1000",
3689                         "pageNum": "1",
3690                         "key": JSON.parse(itemAttribute.tag_Attribute.fundata)["key"],
3691                         "formData": {},
3692                         "dataRowNum": items[item]
3693                     };
3694                     var requesTitle = window.commonAjax("/datamanagement/getAssociateTitle", titleObj, "POST", true, false);
3695                     var requesData = window.commonAjax("/datamanagement/getAssociateData", dataObj, "POST", true, false);
3696                     requesTitle.done(function (res) {
3697                         console.log(res);
3698                         item_title = res.data;
3699                     });
3700                     requesData.done(function (res) {
3701                         console.log(res);
3702                         if (!_.isNull(res.data) && res.data != undefined) {
3703                             itemVal = res.data;
3704                         }
3705                     });
3706                 } else {
3707                     var myTitle = JSON.parse(window.localStorage.getItem("title"));
3708                     item_title = myTitle[item];
3709                     itemVal = items[item];
3710                 }
3711                 console.log(myTitle);
3712                 console.log(itemVal)
3713                 console.log(item_title);
3714                 console.log(itemVal.list);
3715                 var iconID = "customShow #" + customItems[item].id + "ActiveId";// 关联数据回显渲染 李伟民 11-30
3716                 createMxtTable(iconID, item_title, itemVal.list);// 关联数据回显渲染 李伟民 11-30
3717                 //              var newData = [];
3718                 //              _.each(itemVal.list,function(opt){
3719                 //                  opt = _.mapKeys(opt,function(value,key){
3720                 //                      _.each(item_title,function(item){
3721                 //                          if(key == item.fieldKey){
3722                 //                              key = item.title;
3723                 //                          }
3724                 //                      })
3725                 //                      return key;
3726                 //                  })
3727                 //                  console.log(_.cloneDeep(opt))
3728                 //                  newData.push(opt);
3729                 //              })
3730                 //              console.log(itemVal.list);
3731                 //              console.log(newData);
3732                 ////              var $value = newData;
3733                 //              var show = "";
3734                 //              var divBox = $("<div></div>");
3735                 //              divBox.attr('id',customItems[item].id+'divBox');
3736                 //              //console.log($value)
3737                 //                        var sdata_head = "";
3738                 //              _.each($value,(opt,j)=>{
3739                 //                  //console.log(opt);
3740                 //                  var ulBox = $("<ul></ul>");
3741                 //                  for(let i in opt){
3742                 //                      show = "";
3743                 //                                sdata_head = '<td class="data1 '+i+'">'+i+'</td>';
3744                 //                  show += '<li>'+'<span class="data1 '+i+'">'+i+'</span>'+'<span class="data2 '+i+'">'+opt[i]+'</span>'+'</li>';
3745                 //                  ulBox.attr("class","addUl ulBox"+j);
3746                 //                  ulBox.attr("id","ulBox"+j);
3747                 //                  //console.log(show)
3748                 //                  ulBox.append(show);
3749                 //                  }
3750                 //                            console.log(sdata_head);
3751                 //                  divBox.append(ulBox);
3752                 //              });
3753                 //              $mytext.append(divBox);
3754             } else {
3755                 //值设定
24a275 3756                 console.log(type);
M 3757                 if (type == "text"){
3758                     $("#" + id).attr("title", items[item]);
3759                 }
4d1219 3760                 customBase.setItemValue(id, type, items[item], 'customViewUEditorCss');
B 3761                 //异步加载时数据临时保存
3762                 customShow.options.initTempDatas[id] = items[item];
3763             }
3764         }
3765     };
3766     //赋值后绑定票据信息
3767 }
3768 // 定义云账房方法 10/17
3769 var orderid = "";
3770 function getepc() {
3771     window.queryAjaxsd("epc/epc-form/getOrderCode", {}, "POST", true).done(function (res) {
3772         //console.log("云账房id");
3773         //console.log(res);
3774         if (res.data != undefined) {
3775             orderid = res.data.orderCode;
3776             setepc(orderid);
3777         }
3778
3779     })
3780 }
3781 function setepc(orderid) {
3782     //console.log(orderid);
3783     //console.log(customBase);
3784     //console.log(window.customShow);
3785     if (customBase.options.customItems.orderCode != undefined) {
3786         var id = customBase.options.customItems.orderCode.id;
3787         var type = customBase.options.customItems.orderCode.type;
3788         //console.log(id);
3789         //console.log(type);
3790
3791         customBase.setItemValue(id, type, orderid);
3792     }
3793 }
3794
3795 function getCookie(name) {
3796     var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
3797     if (arr = document.cookie.match(reg))
3798         return unescape(arr[2]);
3799     else
3800         return null;
3801 }
3802
3803 customShow.uploadBill = function () {//票据上传
3804     $('#upload_iframe').show();
3805     var token = localStorage.getItem(token);
3806     if (token != '' && token != undefined) {
3807         token = JSON.parse(token).accessToken;
3808     }
3809     var compid = getCookie('companyId');
3810     var tenantId = localStorage.getItem("tenantID");
3811     // var iframe_src = "http://csza.chfcloud.com/views/order_create_visit.html?token=" + token + "&compid=" + compid +"&tenantId=" + tenantId;
3812     var iframe_src = "http://csza.chfcloud.com/views/order_create_visit.html?token=" + localStorage.getItem("testToken") + "&compid=" + localStorage.getItem("testCompanyId") +"&tenantId=" + localStorage.getItem("testTenantId");
3813     //var iframe_src = "http://csza.chfcloud.com/views/order_create_visit.html?token=a23efb1df2303a914b1139d4e1d1859f&compid=66&tenantId=13";
3814     $("#upload_iframe").append("<iframe id='uploadBill' style='width:100%;overflow: auto;'></iframe>");
3815     ////console.log($("body"));
3816     var thisHeight = $("body").height();
3817     ////console.log(thisHeight);
3818     $('#upload_iframe').height(thisHeight);
3819     $('#uploadBill').height(thisHeight);
3820     $('#uploadBill').attr("src", iframe_src);
3821     window.addEventListener("message", customShow.getExCouldNumber);
3822     $("#upload_iframe .right").on("click", function () {
3823         customShow.uploadBillClose();
3824     });
3825
3826 }
3827
3828 customShow.getExCouldNumber = function (event) {
3829     if (event && event.data && event.data.indexOf('csc_OrderCode=') != -1) {
3830         var exCouldNumber = event.data.split('=')[1];
3831         console.log(exCouldNumber);
3832         customShow.exCouldNumber = exCouldNumber;
3833         if(localStorage.getItem('customShowFlag') == 2){//详情页上传票据需将云单编号传给后台  李伟民  01-04
3834             var orderData = {
3835                 "formId":customShow.options.formid,
3836                 "formDataId":localStorage.getItem("datarowNum"),
3837                 "orderCode":exCouldNumber
3838             }
3839             var orderUpdate = window.cloudAjax("epc-form/formData/updataBillInfoAndForm",orderData,"POST",true);
3840             orderUpdate.done(function(res){
3841                 if(res.rspCode == '000000'){
3842                     changeOrderStatus('10');
3843                     customShow.uploadBillClose();
3844                 }
3845             });
3846         }else{
3847             customShow.uploadBillClose();
3848         }
3849     }
3850 }
3851
3852 customShow.uploadBillClose = function () {
3853     $('#uploadBill').remove();
3854     $('#upload_iframe').hide();
3855     window.removeEventListener("message", customShow.getExCouldNumber);
3856     $('.bill_upload').hide();
3857     // getepc();
3858 }//画面初期编辑内容设定
3859 customShow.setContentHtml = function (customItem, customViewDiv) {
3860
3861     //按钮状态编辑  btnFlag:{editable:"1",printable:"1",auditable:"1",disposable:"1"} //按钮表示
3862     var btnFlag = customShow.options.btnFlag;
3863     if (btnFlag.editable != "0") {
3864         $("#editableBtn").removeClass("cfg_contentNone");
3865     }
3866     if (btnFlag.printable != "0") {
3867         $("#printableBtn").removeClass("cfg_contentNone");
3868     }
3869     if (btnFlag.auditable != "0") {
3870         $("#auditableBtn").removeClass("cfg_contentNone");
3871     }
3872     if (btnFlag.disposable != "0") {
3873         $("#disposableBtn").removeClass("cfg_contentNone");
3874     }
3875
3876     var div = document.createElement("div");
3877     div.innerHTML = customItem.formeditor;
3878     if (customShow.options.customInit.designMode == "1") {
3879         div.setAttribute("class", "divshow divshowEditor");
3880
3881         if (customShow.options.customShowFlag != "4") {
3882             $(div).css("height", customItem.fromheigh);
3883             $(div).css("width", customItem.fromwidth);
3884             // $(customViewDiv).css("height",customItem.fromheigh);
3885             // $(customViewDiv).css("width",customItem.fromwidth);
3886             console.log(1);
3887         }
3888
3889     } else {
3890         div.setAttribute("class", "divshow divshowNoEditor");
3891         //  $(div)[0].style.height = window.innerHeight-140 + "px";
3892         //  if(customShow.options.customShowFlag =="0"){
3893         //     $(div)[0].style.width ='98%';
3894         //  }else{
3895         //     $(div)[0].style.width ='100%';
3896         //  }
3897
3898         //  $(div)[0].style.overflowY ='auto';
3899         $(div)[0].style.width = '100%';
3900         $(div)[0].style.height = '100%';
3901
3902         $(div).css("display", "flex");
3903         $(div).css("justify-content", "flex-start");
3904         $(div).css("flex-wrap", "wrap");
3905     }
3906     $(customViewDiv).prepend(div);
3907
3908     //基本信息List取得
3909     customBase.options.customItems = customShow.getItemsList();
3910     console.log(customShow.getItemsList())
3911     console.log(customShow.options.customItemShow.item)
3912
3913     //接口绑定
3914     interfaceBind = customShow.initEvent.interfaceBind;
3915     for (var i = 0; i < interfaceBind.length; i++) {
3916         customShow.initEvent[interfaceBind[i].interfacemethod] = eval(interfaceBind[i].customInterfacemethod);
3917     };
3918
3919     // //事件绑定
3920     // eventBind = customShow.initEvent.eventBind;
3921     // //02事件绑定:字段别名 字段类型 事件名 自定义事件名
3922     // for (var i = 0; i < eventBind.length; i++) {
3923     //   // 自定义事件名
3924     //   var setfunction = eval(eventBind[i].eventmethod);
3925     //   // 事件名
3926     //   var eventName = eventBind[i].event;
3927     //   // 字段类型
3928     //   // var tag = eventBind.tag;                         //------------类型绑定-------------
3929     //   // 字段别名
3930     //   var fieldKey = eventBind[i].fieldName;
3931     //   // 取得控件ID
3932     //   var itemId = customBase.getfieldKeyFoItemId(fieldKey);  //---------------------------
3933     //   //事件绑定
3934     //   $("#"+itemId).on(eventName, setfunction);
3935     // };
3936     // //-------------------------主数据取得------------------------------
3937     //-------------------------数据源取得------------------------------
3938     //-------------------------API取得data-----------------------------
3939
3940     //画面初期化
3941     customShow.initEvent.interfaceInit(customShow.options.customShowFlag);
3942     console.log(customShow.options.customItemShow.item);
3943     //第三方初始化
3944
3945     customShow.initEvent.interfaceInit3rd();
3946
3947     //密码输入----------------
3948     customShow.initEvent.passwordInputFlag();
3949     //tree控件 by kill
3950     // 2017/11/4  李元杰 在点击预览的时候树的按钮
3951     customShow.treeWinShow();
3952
3953 }
3954 //2017/11/2  李元杰 单选树  树的显示
3955
3956 $('.tabBox').on('click', '.citySel,.menuBtn', function () {
3957     // 树里存在数据时
3958     if ($(this).parents('div[name="TreeWin"]').find('.ztree').children('li').length > 0) {
3959         //  12/16 李元杰 
3960         $('div.drop_down_sel').remove();
3961         var fieldKey = $(this).parents('div[name="TreeWin"]').find('.zTreeDemoBackground').attr('fieldkey');
3962         $('.zTreeDemoBackground').css("display", "none");
3963         $(".search_input").css("display", "none");
3964         if (customBase.options.customItems[fieldKey].editable) {
3965             if (event.target.className == 'defaultHeight  citySel' || event.target.className == 'defaultHeight  citySel') {
3966                 var ztree = $(this).parents('div[name="TreeWin"]').find('.ztree')
3967                 for (var i = 0; i < ztree.length; i++) {
3968                     var treeObj = $.fn.zTree.getZTreeObj($(ztree[i]).attr('id'));
3969                     if (!_.isNull(treeObj)) {
3970                         treeObj.expandAll(true);
3971                     }
3972                 }
3973             }
3974             $(this).parents('div[name="TreeWin"]').find('div[name="treeWinTitle"]').find('.search_input').css("display", "block");
3975             $(this).parents('div[name="TreeWin"]').find('.zTreeDemoBackground').show();
3976             //  12/16 end
3977         }
3978         $('.boxOne').off('click.tree').on('click.tree', function () {
3979             console.log(1);
3980             console.log($('div.drop_down_sel'))
3981             $('div.drop_down_sel').remove();
3982             $('.zTreeDemoBackground').css("display", "none");
3983             $(".search_input").css("display", "none");
3984
3985         });
3986
3987         $('div.TreeWin').off('click.tree').on('click.tree', function (event) {
3988             // 展开树 12/4
3989             console.log($(this))
3990             $('div.drop_down_sel').remove();
3991             var fieldKey = $(this).find('.zTreeDemoBackground').attr('fieldkey');
3992             $('.zTreeDemoBackground').css("display", "none");
3993             $(".search_input").css("display", "none");
3994             if (customBase.options.customItems[fieldKey].editable) {
3995                 if (event.target.className == 'defaultHeight  citySel' || event.target.className == 'defaultHeight  citySel') {
3996                     var ztree = $(this).find('.ztree')
3997                     for (var i = 0; i < ztree.length; i++) {
3998                         var treeObj = $.fn.zTree.getZTreeObj($(ztree[i]).attr('id'));
3999                         if (!_.isNull(treeObj)) {
4000                             treeObj.expandAll(true);
4001                         }
4002                     }
4003                 }
4004
4005                 $(this).find('div[name="treeWinTitle"]').find('.search_input').css("display", "block");
4006                 $(this).find('.zTreeDemoBackground').show();
4007             }
4008             event.stopPropagation();
4009         });
4010
4011     }
4012 })
4013 //this function by kill
4014 customShow.treeWinShow = function () {
4015     // $('body').append('<div id="occlusion"></div>')
4016     //    occlusionCss={
4017     //        background: 'white',
4018     //        filter: 'alpha(opacity=100)',
4019     //        opacity: '1',
4020     //        display: 'none',
4021     //        position: 'absolute',
4022     //        top: '0px',
4023     //        left: '0px',
4024     //        width: '100%',
4025     //        height: '100%',
4026     //        display:'none',
4027     //        "z-index":"99998",
4028     //        display:"none",
4029     //        height:'100%',
4030     //        width:'100%',
4031     //    };
4032     treeButtonDivCss = {
4033         position: "absolute",
4034         top: '85%',
4035         left: '30%',
4036     }
4037     treeDutton2DivCss = {
4038         position: "absolute",
4039         top: '85%',
4040         left: '60%',
4041     }
4042     winCss = {
4043         position: 'relative',
4044         "border-radius": "4px",
4045         width: "100%",
4046         'max-width':"190px",
4047         height: "30px",
4048
4049     }
4050     treeWinTitleCss = {
4051         "margint-top": "3%"
4052     }
4053     subFormTreeCss = {
4054         position: "absolute",
4055
4056         top: '56px',
4057         left: '0px',
4058
4059         'background-color': '#fff',
4060         'z-index': '99999',
4061         // top:"15%",
4062         // "margin-left":"5%",
4063         width: "165px",
4064         border: "1px solid #CCC",
4065         overflow: "hidden",
4066         'overflow-y': "auto",
4067
4068     }
4069     wintreeCss = {
4070         position: "absolute",
4071         top: '56px',
4072         'background-color': '#fff',
4073         'z-index': '99999',
4074         // top:"15%",
4075         // "margin-left":"5%",
4076         width: "165px",
4077         border: "1px solid #CCC",
4078         overflow: "hidden",
4079         'overflow-y': "auto",
4080     }
4081
4082     $(".ztree").parent().parent().attr("name", "TreeWin");
4083     $(".ztree").parent().parent().attr("class", "TreeWin");
4084
4085     $('.ztree').parents('div[name="TreeWin"]').show();
4086     //    2017/11/4 点击预览的时候产生的树样式  李元杰
4087     $('div[type="Tree"]').append('<button class="btn btn-primary" name="treeButton1" style="display:none">选择</button>');
4088     //马习同  下拉树样式修改 11/13
4089     // $('div[name="TreeWin"]').prepend(`
4090     //     <div name="treeWinTitle">
4091     //         <div class="content_wrap">
4092     //             <div>
4093     //                 <ul class="list ulContent">
4094     //                     <div class="input-group"  >
4095     //                         <input   readonly unselectable="on" type="text"  class="defaultHeight  citySel" placeholder="" aria-describedby="basic-addon1">
4096     //                         <button id="" type="button" class="menuBtn btn btn-default"><i class="fa fa-search" aria-hidden="true"></i></button>
4097     //                     </div>
4098
4099     //                     </li>
4100     //                 </ul>
4101     //             </div>
4102     //         </div>
4103     //     </div>
4104     // `);
4105     $('div[name="TreeWin"]').prepend(`
4106             <div name="treeWinTitle">
4107                 <input  id="search_input" type="text" class="defaultHeight search_input" placeholder="" aria-describedby="basic-addon1">
4108                 <div class="content_wrap">
4109                     <div>
4110                         <ul class="list ulContent">
4111                             <div class="input-group"  >
4112                                 <input   readonly unselectable="on" type="text"  class="defaultHeight  citySel" placeholder="" aria-describedby="basic-addon1">
4113                                 <button id="" type="button" class="menuBtn btn btn-default"><i class="fa fa-search" aria-hidden="true"></i></button>
4114                             </div>
4115
4116                             </li>
4117                         </ul>
4118                     </div>
4119                 </div>
4120             </div>
4121         `);
4122     //    $('div[name="TreeWin"]').prepend('<div name="treeWinSearch"><input id="search_input" placeholder="Type to filter"><hr /></div>');
4123     //    $('div[name="TreeWin"]').append('<div name="treeButtonDiv"><button class="btn btn-primary" name="treeButton2">确定</button></div>');
4124     //    $('div[name="TreeWin"]').append('<div name="treeButtonDiv2"><button class="btn btn-danger" name="treeButton3">取消</button></div>');
4125     //    $(".ztree").parent().css(subFormTreeCss);
4126     //    $('.ztree').parents('.fieldOrderNum').attr('typpe');
4127     var ztreeParentCss = $(".ztree").parent();
4128     $(".ztree").parent().css(subFormTreeCss);
4129     for (var i = 0; i < ztreeParentCss.length; i++) {
4130         //  11/16 李元杰  子表单内树形搜索框定位
4131         console.log($(ztreeParentCss[i]).find('ul'))
4132         console.log($(ztreeParentCss[i]).parents('.fieldOrderNum'))
4133         var isAllCopyTreeIs = $(ztreeParentCss[i]).find('ul').attr('id').split('tree')[0];
4134         if (customShow.options.customItemShow.item[isAllCopyTreeIs].parentsubFormNum != 0) {
4135             $(ztreeParentCss[i]).css(subFormTreeCss);
4136             $(ztreeParentCss[i]).parent('div[name="TreeWin"]').find('.search_input').addClass('search_input_subform')
4137         } else {
4138
4139             $(ztreeParentCss[i]).css(wintreeCss);
4140         }
4141         //  树形是否有数据的判断
4142         if ($(ztreeParentCss[i]).children('ul').children('li').length > 0) {
4143
4144         } else {
4145
4146             $(ztreeParentCss[i]).hide();
4147         }
4148     }
4149     //    $("#occlusion").css(occlusionCss);
4150     $('div[name="TreeWin"]').css(winCss);
4151     $('div[name="treeWinTitle"]').css(treeWinTitleCss);
4152     $('.ztree').css("top", "%20");
4153     //    $(".ztree").parent().parent().hide();
4154     //这个换成点击新建
4155     //    $('button[name="treeButton1"]').click(function(){
4156     // 表明只有树组件时才提示是否绑定数据
4157     if ($('button[name="treeButton1"]').length > 0) {
4158         var treeId = $('button[name="treeButton1"]').prev().attr("id");
4159         var treeJson = $('button[name="treeButton1"]').prev().children(':nth-child(2)').attr("masterdata");
4160         //////console.log($(this).prev()[0]);
4161         // console.log(treeJson);
4162         //console.log(treeId);
4163         if (typeof (treeJson) == "undefined" || treeJson == "") {
4164             // alert("该控件没有进行数据绑定!")
4165         } else {
4166             //    $("#occlusion").fadeTo(200);
4167             console.log($('button[name="treeButton1"]'))
4168             $('button[name="treeButton1"]').prev().show();
4169             console.log($('div[name="treeWinTitle"]'))
4170             var treeWinTitle = $('div[name="treeWinTitle"]');
4171             console.log(treeWinTitle[0])
4172             for (var i = 0; i < treeWinTitle.length; i++) {
4173                 console.log($(treeWinTitle[i]));
4174                 $(treeWinTitle[i]).find('input[type="text"]').attr('id', `search_input${i}`)
4175             }
4176         }
4177     }
4178     //  12/7 李元杰 树禁止背景颜色
4179     var editableBgColor = $('.ztree');
4180     for (var i = 0; i < editableBgColor.length; i++) {
4181         var editableFlag = $(editableBgColor[i]).parent().attr('editable')
4182         if (editableFlag == 'true') {
4183             var a = $(editableBgColor[i]).parents('div[name="TreeWin"]').find('.citySel')
4184             $(editableBgColor[i]).parents('div[name="TreeWin"]').find('.citySel').removeClass('disableColor')
4185         } else {
4186             var a = $(editableBgColor[i]).parents('div[name="TreeWin"]').find('.citySel')
4187             $(editableBgColor[i]).parents('div[name="TreeWin"]').find('.citySel').addClass('disableColor')
4188         }
4189     }
4190     //  12/7 end
4191     $('.ztree').addClass('search_list');
4192     // 搜索框获得焦点时 初始化
4193     console.log($('.tabBox'))
4194     $('.tabBox').on('focus', '.search_input', function () {
4195         console.log($(this))
4196         var searchListId = $(this).parents('div[name="TreeWin"]').find('.ztree').attr('id');
4197         console.log($(this).parents('div[name="TreeWin"]').find('.ztree'));
4198         $(this).fastLiveFilter(`#${searchListId}`, {});
4199     })
4200     //    $('button[name="treeButton2"]').click(function(){
4201     //        //确定按钮 by kill
4202     //            var treeId=$(this).parent().parent().children(':nth-child(2)').attr("id")
4203     //            $('#spanDiv'+treeId).remove()
4204     //            $('#'+treeId+"ActiveId").children(':nth-child(1)').append('<span id="spanDiv'+treeId+'"></span>')
4205     //            $('#'+treeId+'tree').children('li').each(function(){
4206     //               var state=$(this).children(':nth-child(2)').attr('class')
4207     //               if(state.indexOf('true')!=-1){
4208     //                    var text=$(this).children(':nth-child(3)').attr('title');
4209     //                    $('#'+treeId+"ActiveId").children(':nth-child(1)').children(':nth-child(4)').append('<span>|'+text+'</span>')
4210     //               }
4211     //            })
4212     //         //    $("#occlusion").fadeOut(200);
4213     //         //    $(this).parent().parent().hide();
4214     //        }
4215     //    )
4216     //    $('button[name="treeButton3"]').click(function(){
4217     //        //取消按钮 by kill
4218     //        var treeId=$(this).parent().parent().children(':nth-child(2)').attr("id")
4219     //        var a = [];
4220     //        var tite=$('#spanDiv'+treeId).children().text();
4221     //        for(var i=0;i<tite.split("|").length;i++){
4222     //           $('#'+treeId+'tree').children('li').each(function(){
4223     //               if(tite.split("|")[i]==$(this).children(':nth-child(3)').attr('title')){
4224     //                   a.push($(this).children(':nth-child(2)').attr('id'))
4225     //               }else{
4226     //                   if($(this).children(':nth-child(2)').attr('class').indexOf('true')!=-1){
4227     //                       $(this).children(':nth-child(2)').click();
4228     //                   }
4229     //               }
4230     //           })
4231     //       }
4232     //           for(var x=0;x<a.length;x++){
4233     //               $('#'+a[x]).click();
4234     //               ////console.log(a[x])
4235     //           }
4236
4237     //         // $("#occlusion").fadeOut(200);
4238     //         // $(this).parent().parent().hide();
4239     //    })
4240     // end by kill
4241
4242
4243 }
4244
4245 //事件绑定 接口绑定
4246 customShow.setEventBind = function () {
4247     // //接口绑定
4248     // interfaceBind = customShow.initEvent.interfaceBind;
4249     // for (var i = 0; i < interfaceBind.length; i++) {
4250     //   customShow.initEvent[interfaceBind[i].interfacemethod] = eval(interfaceBind[i].customInterfacemethod);
4251     // };
4252
4253     //事件绑定
4254     eventBind = customShow.initEvent.eventBind;
4255     //02事件绑定:字段别名 字段类型 事件名 自定义事件名
4256     console.log(eventBind);
4257     for (var i = 0; i < eventBind.length; i++) {
4258         // 自定义事件名
4259         var funstr = eventBind[i].eventmethod + "()";//页面事件绑定 李伟民 12-22
4260         var setfunction = function () {
4261             eval(funstr);
4262         }//页面事件绑定 李伟民 12-22
4263         // 事件名
4264         var eventName = eventBind[i].event;
4265         // 字段类型
4266         // var tag = eventBind.tag;                         //------------类型绑定-------------
4267         // 字段别名
4268         var fieldKey = eventBind[i].fieldName;
4269         // 取得控件ID
4270         var itemId = customBase.getfieldKeyFoItemId(fieldKey);  //---------------------------
4271         //事件绑定
4272         $("#" + itemId).on(eventName, setfunction);
4273     };
4274     //-------------------------主数据取得------------------------------
4275
4276     //公式初期化
4277     setTimeout(function () {
4278         customLinkageAnalysis.bindLinkage();
4279     }, 200);
4280     //行程排序初期化
4281     setTimeout(function () {
4282         customShow.journeySort();
4283     }, 200);
4284     // customShow.options.LinkageAnalysisSetValueFlag = ture;
4285
4286     setTimeout(function () {
4287         //初期化公式接口
4288         customShow.initEvent.interfaceInitLinkage();
4289     }, 200);
4290     //马习同   合计   2017-12-07  公式初期化后
4291     customShow.oneTotle();
4292 }
4293
4294 customShow.setEventBindItem = function (eventItem) {
4295     //事件绑定
4296     eventBind = eventItem;
4297     //02事件绑定:字段别名 字段类型 事件名 自定义事件名
4298     for (var i = 0; i < eventBind.length; i++) {
4299         // 自定义事件名
4300         var setfunction = eval(eventBind[i].eventmethod);
4301         // 事件名
4302         var eventName = eventBind[i].event;
4303         // 字段类型
4304         // var tag = eventBind.tag;                         //------------类型绑定-------------
4305         // 字段别名
4306         var fieldKey = eventBind[i].fieldName;
4307         // 取得控件ID
4308         var itemId = customBase.getfieldKeyFoItemId(fieldKey);  //---------------------------
4309         //事件绑定
4310         $("#" + itemId).on(eventName, setfunction);
4311     };
4312 }
4313 customShow.listData = {};
4314 //  11/21  全局 itemId
4315 customShow.itemId = "";
4316 //数据设定值取得(主数据 API 数据源 自定义)
4317 customShow.setDatasourceData = function (customItem) {
4318     //马习同 获取
4319     customItems = customShow.options.customItemShow.item;
4320
4321     var setDataItem = {
4322         masterdata: function (item, callback) {
4323             setMasterData(item, callback);
4324         },
4325         datasource: function (item, callback) {
4326             setDatasource(item, callback);
4327         },
4328         custom: function (item, callback) {
4329             setCustom(item, callback);
4330         },
4331         api: function (item, callback) {
4332             setApiDatasource(item, callback);
4333         }
4334     }
4335     var setCallbackItem = function (itemId, listData) {
4336         var type = customShow.options.customItemShow.item[itemId].tag_Type;
4337         if (type == "dropdownlist") {
4338             setDropdownlist(itemId, listData);
4339         } else if (type == "radio" || type == "checkbox") {
4340             setCustomradio(itemId, listData);
4341         } else if (type == "tree") {
4342             var dropdowntype = customShow.options.customItemShow.item[itemId].tag_Attribute.dropdowntype;
4343             if (dropdowntype == "multiple") {
4344                 // 多选的树样式
4345                 $('#' + itemId + "tree").parent().hide();
4346                 setTree(itemId, customBase.settingChkboxType, listData);
4347
4348             } else {
4349                 // 2017/11/1  李元杰 树更改成单选
4350                 // 单选的树样式
4351
4352                 $('#' + itemId + "tree").parent().hide();
4353                 setTree(itemId, customBase.settingRadioType, listData);
4354             }
4355             var unvisible = customBase.options.customItems;
4356             for (item in unvisible) {
4357                 if (unvisible[item].type == "subform") {
4358                     var itemId = unvisible[item].id;
4359                     //          var itemTwo = itemId;
4360                     //          var itemSubform = $('.'+"customViewUEditorCss" +" #"+itemId+"ActiveId");
4361                     ////////////console.log(item);
4362                     //子表单删除第一条可添加  2017/10/26 马习同
4363                     //          var divIcon = $('<div id="'+itemId+'save" class="cfg_contentNone"></div>');
4364                     var cloneE = $('#' + itemId + 'subformTr').clone();
4365                     //          divIcon.append(cloneE);
4366                     console.log(cloneE);
4367                     //          itemSubform.append(divIcon);
4368
4369
4370                     customBase.options.customItems[item]['cloneDiv'] = cloneE;
4371                 }
4372             }
4373         }
4374     }
4375
4376     //下拉菜单
4377     setDropdownlist = function (itemId, listData) {
4378
4379
4380         var dropdownlistData;
4381
4382         var item = $('.customViewUEditorCss #' + itemId);
4383         //  $($('.customViewUEditorCss #'+itemId)[0]).empty();
4384         //  $($($('.customViewUEditorCss #'+itemId)[0]).parentNode).find(".select2").remove();
4385         var dropdowntype = customShow.options.customItemShow.item[itemId].tag_Attribute.dropdowntype;
4386         var editable = customShow.options.customItemShow.item[itemId].tag_Attribute.editable;
4387         //        ////console.log(editable);
4388         var readonly = "readonly";
4389         if (editable) {
4390             readonly = "";
4391         }
4392         var width = $(item[0])[0].style.width.replace("px", "");
4393         width = parseInt(width);
4394         console.log(width)
4395         customBase.options.dropdownlistText[itemId] = listData;
4396         // $("#"+itemId).parent().empty();
4397         var itemIdClass = "selectClass js-example-basic-single defaultHeight customShowItemClass  dropdowntypeCss " + itemId + "value " + readonly;
4398         var DropdownlistItem = $("#" + itemId).parent();
4399         DropdownlistItem.empty();
4400         DropdownlistItem.append($('<div id="' + itemId + '" class="selectClass ' + itemIdClass + '"></div>'));
4401         if (dropdowntype == "multiple") {
4402             xhSelect.setXhSelect(
4403                 {
4404                     selectId: itemId,
4405                     multiple: true,
4406                     width: width,
4407                     listData: listData
4408                 }
4409             );
4410         } else {
4411             xhSelect.setXhSelect(
4412                 {
4413                     selectId: itemId,
4414                     multiple: false,
4415                     width: width,
4416                     listData: listData
4417                 }
4418             );
4419         }
4420         //  item.find();
4421         // if(dropdowntype == "multiple"){
4422         //     item.select2({theme: "classic",
4423         //       width: width,
4424         //       data: listData,
4425         //       multiple: true});
4426         //  }else{
4427         //     item.select2({theme: "classic",
4428         //       width: width,
4429         //       data: listData,
4430         //     });
4431         //  }
4432         customShow.clickBindSubform();
4433
4434         //数据加载
4435         var initTempData = customShow.options.initTempDatas[itemId];
4436         if (initTempData != undefined) {
4437             var parentsubFormNum = customShow.options.customItemShow.item[itemId].parentsubFormNum;
4438             initTempData = customShow.dbItemToShowItem(itemId, "dropdownlistText", initTempData, "customViewUEditorCss", dropdowntype, parentsubFormNum);
4439             // customShow.options.initTempDatas[itemId] = initTempData;
4440             customBase.setItemValue(itemId, "dropdownlistText", initTempData, "customViewUEditorCss", dropdowntype);
4441             customShow.setShowItem(itemId, "dropdownlistText", initTempData);
4442         } else {
4443             if (customShow.options.customItemShow.item[itemId].tag_Attribute.datasourcetype == "custom") {
4444                 var customItemsTemp = customShow.options.customItemShow.item[itemId].tag_Attribute.custom;
4445                 ////////console.log(customItemsTemp);
4446                 var initTempDataCustom = []
4447                 var j = 0;
4448
4449                 for (var i = 0; i < customItemsTemp.length; i++) {
4450                     if (customItemsTemp[i].ischecked) {
4451                         initTempDataCustom[j] = customItemsTemp[i].itemtext;
4452                         j++;
4453                         // ////////console.log(customItems[i].itemtext);
4454                         // ////////console.log(customItems[i]);
4455                     }
4456                 }
4457                 ////////console.log(initTempDataCustom);
4458                 if (customShow.options.customItemShow.item[itemId].tag_Attribute.dropdowntype == "single") {
4459                     customBase.setItemValue(itemId, "dropdownlistText", [initTempDataCustom[0]], "customViewUEditorCss", dropdowntype);
4460                 } else {
4461                     customBase.setItemValue(itemId, "dropdownlistText", initTempDataCustom, "customViewUEditorCss", dropdowntype);
4462                 }
4463             }
4464         }
4465     }
4466     setCustomradio = function (itemId, listData) {
4467         var tag_Type = customItems[itemId].tag_Type;
4468         customBase.options.dropdownlistText[itemId] = listData;
4469         $('.customViewUEditorCss #' + itemId).removeClass('select2Maxheight').addClass('select2Maxheight');
4470         var item = $('.customViewUEditorCss #' + itemId + " .line");
4471         var oNodeclass = "custom-check";
4472         if (tag_Type == "radio") {
4473             oNodeclass = "custom-radio";
4474         } else if (tag_Type == "checkbox") {
4475             oNodeclass = "custom-check";
4476         }
4477         var oNode = "";
4478         var customItemsData = customBase.options.customItems;
4479         for (data in customItemsData) {
4480             // console.log(customBase.options.customItems[data]);
4481             // console.log(itemId);
4482             for (var i = 0; i < listData.length; i++) {
4483                 if (customBase.options.customItems[data].id == itemId) {
4484                     //   11/9  李元杰 是否有选中
4485                     console.log(customBase.options.customItems[data])
4486                     if (customBase.options.customItems[data].editable) {
4487                         oNode += '<li class="ui-state-default" style="height:28px"><span class="' + oNodeclass + '" value="' + listData[i].value + '" ><i class="label"></i>' + listData[i].text + '</span></li>';
4488                     } else {
4489                         oNode += '<li class="ui-state-default" style="height:28px"><span class="' + oNodeclass + ' readonly" value="' + listData[i].value + '" ><i class="label"></i>' + listData[i].text + '</span></li>';
4490                     }
4491                     // }else{
4492                     //   oNode += '<li class="ui-state-default" style="height:28px"><span class="'+oNodeclass+'" value="'+listData[i].value+'" ><i class="label"></i>'+listData[i].text+'</span></li>';
4493                 }
4494             };
4495             // if(customBase.options.customItems[data].id == itemId ){
4496             // //    console.log(listData);
4497
4498             // }
4499         }
4500         for (var i = 0; i < $(item).length; i++) {
4501             // item.empty();
4502             $($(item)[i]).empty();
4503             $(item)[i].innerHTML = oNode;
4504         }
4505         customShow.clickBindSubform();
4506         //数据加载
4507         var initTempData = customShow.options.initTempDatas[itemId];
4508         if (initTempData != undefined) {
4509             var parentsubFormNum = customShow.options.customItemShow.item[itemId].parentsubFormNum;
4510             initTempData = customShow.dbItemToShowItem(itemId, tag_Type, initTempData, "customViewUEditorCss", '', parentsubFormNum);
4511             // customShow.options.initTempDatas[itemId] = initTempData;
4512             customBase.setItemValue(itemId, tag_Type, initTempData, "customViewUEditorCss");
4513             customShow.setShowItem(itemId, tag_Type, initTempData);
4514         }
4515         console.log($(item))
4516         //  12/11 禁用背景
4517         var spanDiv = $(item).find('li').find('span');
4518         console.log($(item).parent().attr('editable'))
4519         if (($(item).parent().attr('editable') == "true")) {
4520             $(item).find('li').find('span').addClass("disableUrl");
4521             for (var i = 0; i < spanDiv.length; i++) {
4522                 console.log($(spanDiv[i]))
4523                 if (tag_Type == "radio") {
4524                     $(spanDiv[i]).removeClass("disableRadUrl");
4525                 } else if (tag_Type == "checkbox") {
4526                     $(spanDiv[i]).removeClass("disableChkUrl");
4527                 }
4528             }
4529         } else {
4530             for (var i = 0; i < spanDiv.length; i++) {
4531                 console.log($(spanDiv[i]))
4532                 if (tag_Type == "radio") {
4533                     $(spanDiv[i]).addClass("disableRadUrl");
4534                 } else if (tag_Type == "checkbox") {
4535                     $(spanDiv[i]).addClass("disableChkUrl");
4536                 }
4537
4538             }
4539         }
4540     }
4541     setTree = function (itemId, setting, listData) {
4542         $('.customViewUEditorCss  #' + itemId + "tree").empty();
4543         // 在这里设置 树的id 和 listData
4544         customShow.listData[itemId] = listData;
4545         customShow.itemId = itemId
4546         var treeDiv = $('div#' + itemId);
4547         if (treeDiv.length != 1) {
4548             for (var i = 0; i < treeDiv.length - 1; i++) {
4549                 var ultreeId = $(treeDiv[i]).find('ul').attr('id');
4550                 ultreeId = ultreeId.split('tree')[0] + 'tree';
4551                 $(treeDiv[i]).find('ul').attr('id', ultreeId + i);
4552                 $.fn.zTree.init($($('.customViewUEditorCss  #' + itemId + "tree" + i)), setting, listData);
4553                 // $('#'+itemId).parents('div[name="TreeWin"]').find('.citySel').addClass('disableColor')
4554                 console.log('#' + itemId);
4555                 var treeObj = $.fn.zTree.getZTreeObj(itemId + "tree" + i);
4556                 // customShow.setTree.disableParentNode.set(treeObj);
4557                 if (treeObj) {
4558                     treeObj.expandAll(true);
4559                 }
4560             }
4561         } else {
4562             $.fn.zTree.init($($('.customViewUEditorCss  #' + itemId + "tree")), setting, listData);
4563             var treeObj = $.fn.zTree.getZTreeObj(itemId + "tree");
4564             var treeDefaultSet;
4565             if (treeObj) {
4566                 treeObj.expandAll(true);
4567             }
4568             var defaultValue = $('#' + itemId).attr('defaultvalue');
4569             var dataObj, defaultValue;
4570             var treeDefaultSet = customShow.treeDefaultSet(treeObj, defaultValue)
4571             defaultValue = treeDefaultSet[0]
4572             dataObj = treeDefaultSet[1];
4573             $('#' + itemId).attr('value', JSON.stringify(dataObj))
4574             $('#' + itemId).prev().find('.citySel').val(defaultValue);
4575             //  12/8 禁止选中  李元杰'
4576             console.log(itemId)
4577             var treeArray = _.filter(customShow.options.customItemShow.item, ['tag_Type', 'tree'])
4578             for (var i = 0; i < treeArray.length; i++) {
4579                 if (treeArray[i].tag_Id == itemId) {
4580                     if (treeArray[i].tag_Attribute.disableParentNode) {
4581                         customShow.setTree.disableParentNode.set(treeObj)
4582                     }
4583                 }
4584             }
4585         }
4586         var initTempData = customShow.options.initTempDatas[itemId];
4587
4588         var defaultValue = $('#' + itemId).attr('defaultvalue');
4589         if (initTempData == 'undefined' || initTempData == undefined) {
4590             if (defaultValue != '' && defaultValue != 'undefined' && defaultValue != undefined) {
4591                 initTempData = defaultValue;
4592             } else {
4593                 initTempData = ' '
4594             }
4595         }
4596         // 010110001000010000010000001
4597         if (initTempData != undefined) {
4598             customBase.setItemValue(itemId, "tree", initTempData, "customViewUEditorCss");
4599         }
4600         customShow.clickBindSubform();
4601     }
4602
4603
4604
4605
4606     //API数据
4607     setApiDatasource = function (item, callback) {
4608         console.log(item)
4609         var apiUrl = item.tag_Attribute.apiUrl;
4610         var callbackId = item.tag_Id;
4611         callbackApiData = function (itemData, url) {
4612
4613             console.log(url)
4614             var ItemId = url.split("callbackId=")[1];
4615             console.log(url)
4616             var item = customShow.options.customItemShow.item[ItemId];
4617             var apiIdKey = item.tag_Attribute.apiIdKey;//  表示项
4618             var apiPIdKey = item.tag_Attribute.apiPIdKey;// 表示值
4619             itemData = itemData.data;
4620
4621             things = [];
4622             console.log(itemData);
4623             // var textcolumn = itemData[apiIdKey];
4624
4625             // var valuecolumn = itemData[apiPIdKey];
4626             // //取得数据长度不一致时数据不设定
4627             // if (textcolumn.length != valuecolumn.length) {
4628             //     return;
4629             // }
4630             if (item.tag_Type == 'radio' || item.tag_Type == 'checkbox') {
4631                 for (var i = 0; i < itemData.length; i++) {
4632                     if (i == 0 && item.tag_Type == 'radio') {
4633                         things[i] = { ischecked: true, value: itemData[i][apiPIdKey], text: itemData[i][apiIdKey] };
4634                     } else {
4635                         things[i] = { ischecked: false, value: itemData[i][apiPIdKey], text: itemData[i][apiIdKey] };
4636                     }
4637                 };
4638             } else if (item.tag_Type == 'tree') {
4639                 var apiName = item.tag_Attribute.apiName;
4640                 console.log(apiName)
4641                 // var namecolumn = itemData[apiName];
4642                 // if (textcolumn.length != namecolumn.length) {
4643                 //     return;
4644                 // }
4645                 for (var i = 0; i < itemData.length; i++) {
4646                     things[i] = { id: itemData[i][apiIdKey], pId: itemData[i][apiPIdKey], name: itemData[i][apiName] };
4647                 };
4648             } else {
4649                 console.log(itemData)
4650
4651                 for (var i = 0; i < itemData.length; i++) {
4652                     console.log(itemData[i])
4653                     console.log(apiPIdKey)
4654                     console.log(apiIdKey)
4655                     console.log(itemData[i][apiPIdKey])
4656                     console.log(itemData[i][apiIdKey])
4657                     things[i] = { id: i, value: itemData[i][apiPIdKey], text: itemData[i][apiIdKey] };
4658
4659                 };
4660             }
4661             console.log(things);
4662             callback(ItemId, things);
4663         }
4664
4665         customDataBound.getApiDatasource(apiUrl, callbackId, callbackApiData);
4666     }
4667     //主数据
4668     setMasterData = function (item, callback) {
4669         var callbackId = item.tag_Id;
4670         var code = item.tag_Attribute.masterData;
4671         console.log(code);
4672         //  11/9
4673
4674
4675
4676         console.log(callbackId)
4677         //   if(code == ""){
4678         //     return;
4679         //   }
4680         callbackMasterData = function (itemid, itemData) {
4681             things = [];
4682             console.log('√')
4683             console.log(itemData);
4684             console.log(itemid);
4685             var customItems = customBase.options.customItems;
4686             for (item in customItems) {
4687                 if (customBase.options.customItems[item].id == callbackId) {
4688
4689                 }
4690             }
4691             item = customShow.options.customItemShow.item[itemid];
4692             if (item.tag_Type == 'radio' || item.tag_Type == 'checkbox') {
4693                 for (var i = 0; i < itemData.length; i++) {
4694                     if (i == 0 && item.tag_Type == 'radio') {
4695                         things[i] = { ischecked: true, value: itemData[i].code, text: itemData[i].value };
4696                     } else {
4697                         things[i] = { ischecked: false, value: itemData[i].code, text: itemData[i].value };
4698                     }
4699                 };
4700             } else if (item.tag_Type == 'tree') {
4701                 //-------------------------
4702                 console.log(itemData)
4703                 if (itemData != null) {
4704                     for (var i = 0; i < itemData.length; i++) {
4705                         things[i] = {
4706                             id: itemData[i].code,
4707                             pId: itemData[i].pid,
4708                             name: itemData[i].value
4709                         };
4710                     };
4711                 }
4712                 
4713             } else if (item.tag_Type == 'dropdownlist') {
4714                 if(itemData != undefined && !_.isNull(itemData)){
4715                    for (var i = 0; i < itemData.length; i++) {
4716                         things[i] = { id: i, value: itemData[i].code, text: itemData[i].value };
4717
4718                     }; 
4719                 }
4720             } else {
4721                 //其他控件主数据--
4722             }
4723             callback(itemid, things);
4724         }
4725
4726         //数据源数据取得
4727         customDataBound.getElement(code, callbackId, function (rs) {
4728             // 修改下拉框样式统一
4729             if (rs.data == null) {
4730                 callbackMasterData(callbackId, []);
4731             }
4732             for (itemid in rs.data) {
4733                 if (rs.data.hasOwnProperty(itemid)) {
4734                     callbackMasterData(itemid, rs.data[itemid]);
4735                 }
4736             }
4737
4738
4739         });
4740     }
4741     //数据源
4742     setDatasource = function (item, callback) {
4743         var temp = {};
4744         datasourceName = item.tag_Attribute.datasource;
4745         if (datasourceName == "") {
4746             return;
4747         }
4748         if (customShow.options.datasource[datasourceName] == undefined) {
4749             return;
4750         }
4751         temp.columnNames = item.tag_Attribute.textcolumn + "," + item.tag_Attribute.valuecolumn;
4752         temp.datasource = customShow.options.datasource[datasourceName].datasource;
4753         temp.databaseName = customShow.options.datasource[datasourceName].databaseName;
4754         temp.callbackId = item.tag_Id;
4755         if (item.tag_Type == 'tree') {
4756             temp.columnNames += "," + item.tag_Attribute.namecolumn;
4757         }
4758
4759         callbackDatasource = function (rs) {
4760             console.log(this);
4761             console.log(this.url);
4762             var ItemId = this.url.split("callbackId=")[1];
4763
4764             item = customShow.options.customItemShow.item[ItemId];
4765
4766             datasourceName = rs.data;
4767
4768             things = [];
4769             var textcolumn = datasourceName[item.tag_Attribute.textcolumn];
4770             var valuecolumn = datasourceName[item.tag_Attribute.valuecolumn];
4771             if (item.tag_Type == 'radio' || item.tag_Type == 'checkbox') {
4772                 for (var i = 0; i < textcolumn.length; i++) {
4773                     if (i == 0 && item.tag_Type == 'radio') {
4774                         things[i] = { ischecked: true, value: valuecolumn[i], text: textcolumn[i] };
4775                     } else {
4776                         things[i] = { ischecked: false, value: valuecolumn[i], text: textcolumn[i] };
4777                     }
4778                 };
4779             } else if (item.tag_Type == 'tree') {
4780                 var namecolumn = datasourceName[item.tag_Attribute.namecolumn];
4781                 for (var i = 0; i < valuecolumn.length; i++) {
4782                     things[i] = { id: valuecolumn[i], pId: textcolumn[i], name: namecolumn[i] };
4783                 };
4784
4785             } else {
4786                 for (var i = 0; i < valuecolumn.length; i++) {
4787                     things[i] = { id: i, value: valuecolumn[i], text: textcolumn[i] };
4788
4789                 };
4790             }
4791
4792             callback(ItemId, things);
4793         }
4794
4795         //数据源数据取得
4796         customDataBound.getFieldDatasource(temp, callbackDatasource);
4797     }
4798     //自定义数据 ------1001--------
4799     setCustom = function (item, callback) {
4800         var custom = item.tag_Attribute.custom;
4801         things = [];
4802         if (item.tag_Type == 'radio' || item.tag_Type == 'checkbox') {
4803             for (var i = 0; i < custom.length; i++) {
4804                 things[i] = { ischecked: custom[i].ischecked, value: custom[i].itemtext, text: custom[i].itemtext };
4805             };
4806
4807         } else {
4808             for (var i = 0; i < custom.length; i++) {
4809                 things[i] = { id: i, value: custom[i].itemtext, text: custom[i].itemtext };
4810             };
4811         }
4812         var ItemId = customItem.id;
4813         callback(ItemId, things);
4814     }
4815
4816     //树 单选按钮 多选按钮 下拉菜单
4817     var type = customItems[customItem.id].tag_Type;
4818     if (type == 'dropdownlist' || type == 'radio' || type == 'checkbox' || type == 'tree') {
4819         //数据取得顺序
4820         //按照 选择的情况? 按照主数据?TODO
4821         var item = customShow.options.customItemShow.item[customItem.id];
4822
4823         //数据清空
4824         if (type == 'dropdownlist') {
4825             $($('.customViewUEditorCss #' + customItem.id)[0]).empty();
4826             $($($('.customViewUEditorCss #' + customItem.id)[0]).parentNode).find(".select2").remove();
4827             var visibleTemp = customShow.options.customItemShow.item[customItem.id].tag_Attribute.visible;
4828             if (!visibleTemp) {
4829                 $($($('.customViewUEditorCss #' + customItem.id)[0]).parentNode).remove();
4830                 return;
4831             } else {
4832                 $('.customViewUEditorCss #' + customItem.id).select2({ theme: "classic", width: '240' });
4833             }
4834         } else if (type == 'radio' || type == 'checkbox') {
4835             //  var item = $('.customViewUEditorCss #'+customItem.id +" .line");
4836             $($($('.customViewUEditorCss #' + customItem.id + " .line"))[0]).empty();
4837         }
4838
4839         var datasourcetype = item.tag_Attribute.datasourcetype;
4840         //    ////console.log(datasourcetype);
4841         console.log(item);
4842         console.log(datasourcetype);
4843         setDataItem[datasourcetype](item, setCallbackItem);
4844         // _.each($(".customShow .tdContentClass"), opt => {
4845         //     // $(opt).attr("title", $(opt).children().children().html());
4846         //     console.log($(opt).html())
4847         //     if ($(opt).children().children().attr("type") == "text") {
4848         //         $(opt).attr("title", $(opt).children().children().val());
4849         //     } else {
4850         //         console.log(_.cloneDeep($(opt).children().children()))
4851         //         console.log(opt.innerHTML)
4852         //         console.log($(opt).children().children()[0].innerHTML)
4853         //         $(opt).attr("title", $(opt).children().children()[0].innerHTML);
4854         //     }
4855         // })
4856     }
4857     // return itemData;
4858     // _.each($(".customShow .tdContentClass"), opt => {
4859     //     // $(opt).attr("title", $(opt).children().children().html());
4860     //     console.log($(opt).html())
4861     //     if ($(opt).children().children().attr("type") == "text") {
4862     //         $(opt).attr("title", $(opt).children().children().val());
4863     //     } else {
4864     //         console.log(_.cloneDeep($(opt).children().children()))
4865     //         console.log(opt.innerHTML)
4866     //         console.log($(opt).children().children()[0].innerHTML)
4867     //         $(opt).attr("title", $(opt).children().children()[0].innerHTML);
4868     //     }
4869     // })
4870 }
4871 //  12/7  设置默认值
4872 customShow.treeDefaultSet = function (treeObj, defaultValue) {
4873     var objValue = {};
4874     var defaultValueArray = [];
4875     var valueData;
4876     var dataObj = {};
4877     var dataObjArray = []
4878     //  12/7 树的默认值 
4879     //  判断单选多选
4880     // if(defaultValue.indexOf(',') == -1){
4881     if(defaultValue){  
4882         //  单选
4883         if (defaultValue.indexOf(',') == -1) {  
4884             var nodes = treeObj.getNodeByParam("id", defaultValue, null);
4885             if (!_.isNull(nodes)) {
4886                 // 2017 /11/6 选中
4887                 //选择节点设定
4888                 treeObj.checkNode(nodes, true, true);
4889                 treeObj.expandAll(true);
4890                 dataObj[defaultValue] = '1';
4891                 if (defaultValue == nodes.id) {
4892                     defaultValue = nodes.name;
4893                 }
4894             }
4895         } else {   //多选
4896             defaultValueArray = defaultValue.split(',');
4897             for (var i = 0; i < defaultValueArray.length; i++) {
4898                 valueData = defaultValueArray[i]
4899                 dataObj[valueData] = '1'
4900             }
4901             for (var i = 0; i < defaultValueArray.length; i++) {
4902                 var nodes = treeObj.getNodeByParam("id", defaultValueArray[i], null);
4903                 if (!_.isNull(nodes)) {
4904                     // 2017 /11/6 选中
4905                     //选择节点设定
4906                     treeObj.checkNode(nodes, true, true);
4907                     treeObj.expandAll(true);
4908                     if (defaultValueArray[i] == nodes.id) {
4909                         defaultValueArray[i] = nodes.name;
4910                     }
4911                 }
4912             }
4913             defaultValue = defaultValueArray.join(',')
4914         }
4915         console.log(dataObj)
4916         objValue[0] = defaultValue;
4917         objValue[1] = dataObj;
4918     }
4919     return objValue;
4920     // }
4921 }
4922
4923 //画面表示项目一览取得
4924 customShow.getItemsList = function () {
4925
4926     var items = customShow.options.customItemShow.item;
4927     var itemsList = {};
4928
4929     for (i in items) {
4930         if (items.hasOwnProperty(i)) {
4931             var item = items[i];
4932             itemsList[item.tag_Attribute.alias] = {
4933                 fieldKey: item.tag_Attribute.alias,
4934                 id: item.tag_Id,
4935                 type: item.tag_Type,
4936                 parentsubFormNum: item.parentsubFormNum,
4937                 visible: item.tag_Attribute.visible,  //可见
4938                 editable: item.tag_Attribute.editable, //可编辑
4939                 mustcheck: item.tag_Attribute.mustcheck, //必填
4940                 approvalmustenter: item.tag_Attribute.approvalmustenter,//审查必须
4941                 defaultvalue: item.tag_Attribute.defaultvalue,
4942                 // field:"",
4943             }
4944             console.log(item.tag_Attribute.defaultvalue)
4945         }
4946     };
4947     return itemsList;
4948 }
4949
4950 // 子表单事件调用
4951 customShow.clickBindSubform = function () {
4952     // 单选框
4953     $('.select .custom-radio').unbind();
4954     $('.select .custom-radio').on('click', function () {
4955         // //////////console.log(this.className);
4956         if (this.className.indexOf("readonly") > -1) {
4957             return;
4958         }
4959         $($(this).parent().parent()).find(".cur").removeClass('cur');
4960         $(this).addClass('cur').siblings().removeClass('cur');
4961     });
4962     customLinkageAnalysis.bindLinkageSubform("radio");
4963     // 多选框
4964     $('.select .custom-check').unbind();
4965     $('.select .custom-check').on('click', function () {
4966         if (this.className.indexOf("readonly") > -1) {
4967             return;
4968         }
4969         $(this).toggleClass('cur');
4970         // $($(this).parent().parent().parent().parent()).find(".errorItemCss").removeClass('errorItemCss');
4971         // //////////console.log($($(this).parent().parent().parent())[0].id);
4972         // var id = $($(this).parent().parent().parent())[0].id;
4973         // $("#"+id+"mesageErrDiv").remove();
4974         // $(".customViewUEditorCss  #"+id).popover('hide')
4975     });
4976     customLinkageAnalysis.bindLinkageSubform("checkbox");
4977     //删除子表单项目
4978     $('.divshowEditor .iconfontcolorTH').unbind();
4979     $('.divshowEditor .iconfontcolorTH').on('click', function () {
4980         ////////////////console.log($(this).parent().parent().parent());
4981         $(this).parent().parent().parent().parent().parent().remove();
4982     });
4983     $('.iconfontcolor').unbind();
4984     $('.iconfontcolor').on('click', function () {
4985         $(this).parent().parent().parent().remove();
4986     });
4987
4988     //-----------------日期类型------------------------
4989     // $('.dateFromyyyy').unbind();
4990     // $('.dateFromyyyymm').unbind();
4991     // $('.dateFromyyyymmdd').unbind();
4992     // $('.dateFromhhmiss').unbind();
4993     // Flatpickr.localize(Flatpickr.l10ns.zh); // 设置为中文
4994     flatpickr('.customViewUEditorCss .dateFromyyyy', {
4995         dateFormat: "Y",
4996     });
4997     flatpickr('.customViewUEditorCss .dateFromyyyymm', {
4998         dateFormat: "Y-m",
4999     });
5000     flatpickr('.customViewUEditorCss .dateFromyyyymmdd', {
5001         dateFormat: "Y-m-d",
5002     });
5003     flatpickr('.customViewUEditorCss .dateFromhhmiss', {
5004         dateFormat: "Y-m-d H:i",
5005         time_24hr: true,
5006         enableTime: true
5007     });
5008     // customLinkageAnalysis.bindLinkageSubform("calendar");
5009 }
5010
5011 //各控件初期
5012 customShow.controlInit = function (showClass) {
5013
5014     var customItems = customBase.options.customItems;
5015     console.log(customItems)
5016     if ('customShow' != showClass) {
5017         //HTML内容控件初期化
5018         var htmlediterShow = $(".customViewUEditorCss .htmlediterShowClass");
5019
5020         for (var i = 0; i < htmlediterShow.length; i++) {
5021             var itemId = htmlediterShow[i].id;
5022             var htmlediterShowItemId = itemId.replace("Item", "");
5023             // var heightShow = htmlediterShow[i].getAttribute("heightShow");
5024             // var widthShow = htmlediterShow[i].getAttribute("widthShow");
5025             // ////////console.log(customShow.options.customItemShow.item[htmlediterShowItemId].tag_Attribute.alias);
5026             var heightShow = customShow.options.customItemShow.item[htmlediterShowItemId].tag_Attribute.height;
5027             var widthShow = customShow.options.customItemShow.item[htmlediterShowItemId].tag_Attribute.width;
5028             // customShow.options.customItemShow.item[itemId].tag_Attribute.alias;
5029             if (widthShow == undefined || heightShow == undefined) {
5030                 widthShow = 200;
5031                 heightShow = 200;
5032             }
5033
5034             customShow.options.htmlediterShow[itemId] = {};
5035             customShow.options.htmlediterShow[itemId].widthShow = widthShow;
5036             customShow.options.htmlediterShow[itemId].heightShow = heightShow;
5037
5038
5039             UE.getEditor(itemId, {
5040                 // serverUrl :url,
5041                 //allowDivTransToP: false,//阻止转换div 为p
5042                 toolleipi: true,//是否显示,设计器的 toolbars
5043                 textarea: 'design_content',
5044                 //这里可以选择自己需要的工具按钮名称,此处仅选择如下五个
5045                 toolbars: [[
5046                     'source', '|', 'bold', 'underline', 'strikethrough', 'forecolor', 'backcolor']],
5047                 //关闭字数统计
5048                 wordCount: false,
5049                 //关闭elementPath
5050                 elementPathEnabled: false,
5051                 //默认的编辑区域高度
5052                 initialFrameHeight: heightShow,
5053                 scaleEnabled: true,
5054                 //高度
5055                 // initialFrameHeight:heightShow,
5056                 // readonly:true,
5057                 //,iframeCssUrl:"css/bootstrap/css/bootstrap.css" //引入自身 css使编辑器兼容你网站css
5058                 //更多其他参数,请参考ueditor.config.js中的配置项
5059             }).ready(function () {
5060                 ////////////console.log(customBase.options.customItems);
5061                 id = this.key;
5062                 for (i in customBase.options.customItems) {
5063                     if (customBase.options.customItems.hasOwnProperty(i)) {
5064                         var idItem = id.replace("Item", "");
5065                         if (customBase.options.customItems[i].id == idItem) {
5066                             if (customShow.options.itemFormbase == "") {
5067                                 UE.getEditor(id).setContent(customBase.options.customItems[i].defaultvalue);
5068                             } else {
5069                                 var defaultvalue = customShow.options.itemFormbase[i];
5070                                 //  ////////console.log(defaultvalue);
5071                                 //  defaultvalue=defaultvalue+" ";
5072                                 UE.getEditor(id).setContent(defaultvalue);
5073                                 //  setTimeout(function() {
5074                                 //       // this.body.focus();
5075                                 //       ////////console.log(UE.getEditor(id));
5076                                 //       UE.getEditor(id).options.scaleEnabled =false;
5077                                 //   }, 1000);
5078                             }
5079                         }
5080                         //非表示
5081                         //  if(!customBase.options.customItems[i].visible){
5082                         //     $(".customViewUEditorCss #"+id).addClass("cfg_contentNone");
5083                         //  }
5084                     }
5085                 }
5086                 $(".edui-editor-bottomContainer").addClass("cfg_contentNone");
5087                 this.body.onclick = function (event, ui) {
5088                     //////////console.log(this);
5089                     //////////console.log(this.getAttribute("id"));
5090                     // $(this).removeClass("errorItemCss");
5091                     // $("#"+this.getAttribute("id")+"mesageErrDiv").remove();
5092                 }
5093             })
5094         };
5095     }
5096     //-----------------日期类型------------------------
5097
5098     flatpickr('.customViewUEditorCss .dateFromyyyy', {
5099         dateFormat: "Y",
5100     });
5101     flatpickr('.customViewUEditorCss .dateFromyyyymm', {
5102         dateFormat: "Y-m",
5103     });
5104     flatpickr('.customViewUEditorCss .dateFromyyyymmdd', {
5105         dateFormat: "Y-m-d",
5106     });
5107     flatpickr('.customViewUEditorCss .dateFromhhmiss', {
5108         dateFormat: "Y-m-d H:i",
5109         time_24hr: true,
5110         enableTime: true
5111     });
5112
5113     if ('customShow' != showClass) {
5114         //删除项目(select2项目删除)
5115         $('.selection').remove();
5116         $(".ztree").empty();
5117     }
5118     //下拉列表初期化
5119
5120     // $(".dropdowntypeCss").select2({theme: "classic",width: '240'});
5121     // //下拉列表不可用
5122     $('.' + showClass + " .editableDisabled").prop("disabled", true);
5123
5124     // 金融控件
5125     for (item in customItems) {
5126         if (customItems.hasOwnProperty(item)) {
5127             //金融控件
5128             if (customItems[item].type == "amount") {
5129                 if ("customViewUEditorCss" == showClass) {
5130                     var itemId = customItems[item].id;
5131                     // var itemValue = $('.'+showClass +" #"+itemId)[0].getAttribute("defaultvalue");
5132                     var showCustomItem = customShow.options.customItemShow.item[itemId];
5133                     // var itemValue = $('.'+showClass +" #"+itemId)[0].getAttribute("qrcodeurl");
5134                     // var widthQrcode = $("#"+customItems[item].id)[0].width;
5135                     var itemValue = showCustomItem.tag_Attribute.defaultvalue;
5136                     var widthQrcode = showCustomItem.tag_Attribute.width;
5137                     if (widthQrcode == 0 || widthQrcode == undefined) {
5138                         widthQrcode = 60;
5139                     }
5140                     var divIcons = document.createElement("input");
5141                     divIcons.setAttribute("type", "text");
5142                     divIcons.setAttribute("id", customItems[item].id + "amount");
5143                     divIcons.setAttribute("style", "width: " + widthQrcode + "px; height:33px");
5144                     divIcons.setAttribute("class", "amountShowTextClass cfg_contentNone");
5145                     divIcons.setAttribute("value", itemValue);
5146                     $('.' + showClass + " #" + itemId)[0].after(divIcons);
5147                     $('.' + showClass + " #" + itemId).addClass("amountShowClass");
5148                 }
5149                 //申请单
5150             }
5151             else if (customItems[item].type == "mytext") {
5152                 if ("customViewUEditorCss" == showClass) {
5153                     var itemId = customItems[item].id;
5154                     ////console.log(itemId);
5155                     var showCustomItem = customShow.options.customItemShow.item[itemId];
5156                     // var itemValue = $('.'+showClass +" #"+itemId)[0].getAttribute("qrcodeurl");
5157                     // var widthQrcode = $("#"+customItems[item].id)[0].width;
5158                     var itemValue = showCustomItem.tag_Attribute.qrcodeurl;
5159                     var widthQrcode = showCustomItem.tag_Attribute.width;
5160                     if (widthQrcode == 0 || widthQrcode == undefined) {
5161                         widthQrcode = 60;
5162                     }
5163                     var divIcons = document.createElement("div");
5164                     var div = document.createElement("div");
5165                     divIcons.setAttribute("id", customItems[item].id + "qrcode");
5166                     divIcons.setAttribute("class", "boxBtn");
5167                     divIcons.setAttribute("myAttr", itemId);
5168                     divIcons.innerHTML = '选择数据';
5169                     divIcons.setAttribute("maxlength", 200);
5170                     $('.' + showClass + " #" + itemId).eq(0).after(divIcons);
5171                     //        $(" #"+itemId+"divid")[0].after(divIcons);
5172                 }
5173                 //二维码
5174             } else if (customItems[item].type == "qrcode") {
5175                 if ("customViewUEditorCss" == showClass) {
5176                     var itemId = customItems[item].id;
5177                     var showCustomItem = customShow.options.customItemShow.item[itemId];
5178                     // var itemValue = $('.'+showClass +" #"+itemId)[0].getAttribute("qrcodeurl");
5179                     // var widthQrcode = $("#"+customItems[item].id)[0].width;
5180                     var itemValue = showCustomItem.tag_Attribute.qrcodeurl;
5181                     var widthQrcode = showCustomItem.tag_Attribute.width;
5182                     if (widthQrcode == 0 || widthQrcode == undefined) {
5183                         widthQrcode = 165;
5184                     }
5185                     var divIcons = document.createElement("input");
5186                     divIcons.setAttribute("type", "text");
5187                     divIcons.setAttribute("id", customItems[item].id + "qrcode");
5188                     divIcons.setAttribute("style", "width: " + widthQrcode + "px;height:33px");
5189                     divIcons.setAttribute("class", "qrcodeShowTextClass cfg_contentNone");
5190                     divIcons.setAttribute("value", itemValue);
5191                     divIcons.setAttribute("maxlength", 200);
5192                     $('.' + showClass + " #" + itemId)[0].after(divIcons);
5193                     $('.' + showClass + " #" + itemId).addClass("qrcodeShowClass");
5194                 }
5195                 //条形码
5196             } else if (customItems[item].type == "barcode") {
5197                 if ("customViewUEditorCss" == showClass) {
5198                     var itemId = customItems[item].id;
5199                     // var itemValue = $('.'+showClass +" #"+itemId)[0].getAttribute("text");
5200                     // var widthBarcode = $("#"+customItems[item].id)[0].width;
5201                     var showCustomItem = customShow.options.customItemShow.item[itemId];
5202                     // var itemValue = $('.'+showClass +" #"+itemId)[0].getAttribute("qrcodeurl");
5203                     // var widthQrcode = $("#"+customItems[item].id)[0].width;
5204                     var itemValue = showCustomItem.tag_Attribute.text;
5205                     var widthBarcode = 165;
5206                     // if(widthBarcode == 0){
5207                     //   widthBarcode = 100;
5208                     // }
5209                     var divIcons = document.createElement("input");
5210                     divIcons.setAttribute("type", "text");
5211                     divIcons.setAttribute("id", customItems[item].id + "barcode");
5212                     divIcons.setAttribute("style", "width: " + widthBarcode + "px;height:33px");
5213                     divIcons.setAttribute("class", "barcodeShowTextClass cfg_contentNone");
5214                     divIcons.setAttribute("value", itemValue);
5215                     divIcons.setAttribute("maxlength", 200);
5216                     $('.' + showClass + " #" + itemId)[0].after(divIcons);
5217                     $('.' + showClass + " #" + itemId).addClass("barcodeShowClass");
5218                 }
5219                 //子表单设定
5220             } else if (customItems[item].type == "subform") {
5221                 var itemId = customItems[item].id;
5222                 var itemTwo = itemId;
5223                 var itemSubform = $('.' + showClass + " #" + itemId + "ActiveId");
5224                 //lym
5225                 //位总div添加id
5226                 $("#" + itemId + "ActiveId").find(".usfile").attr("id", itemTwo + "uld");
5227                 //为a标签添加id
5228                 $("#" + itemId + "ActiveId").find(".usfile a").attr("id", itemTwo + "uis");
5229                 $("#" + itemId + "ActiveId").find(".usfile a").attr("itemId", itemTwo);
5230                 //为inputFile添加id
5231                 $("#" + itemId + "ActiveId").find("#" + itemTwo + "uld form input").attr("itemId", itemTwo);
5232                 $("#" + itemId + "ActiveId").find("#" + itemTwo + "uld form input").attr("id", itemTwo + "btn");
5233                 $("#" + itemId + "ActiveId").find("#" + itemTwo + "uld form").attr("itemId", itemTwo);
5234
5235                 //////////////console.log(item);
5236                 var ulIcon = document.createElement("ul");
5237                 var liIcon = "";
5238                 var m_customItems = customShow.options.customItemShow.item;
5239                 console.log(customBase.options)
5240                 var subItems = [];
5241                 var parentNum = itemId.replace("itemId_", "");
5242                 _.each(m_customItems, opt => {
5243                     if (opt.parentsubFormNum == parentNum) {
5244                         subItems.push(opt);
5245                     }
5246                 })
5247                 console.log(subItems)
5248                 _.remove(subItems, n => {
5249                     return n.tag_Attribute.alias == "DATAROWNUM" || n.tag_Attribute.visible == false;
5250                 });
5251                 //_.sortBy(orderArr, ['fieldOrderNum']);
5252                 subItems = _.sortBy(subItems, ['fieldOrderNum']);
5253                 _.each(subItems, opt => {
5254                     console.log(opt)
5255                     if (opt.tag_Type == "number") {
5256                         liIcon += "<li class='n_totle'><input class='" + opt.tag_Id + "totle textCssDiv defaultHeight' type='text' readonly></li>"
5257                         console.log(1)
5258                     } else {
5259                         liIcon += "<li class='p_totle'></li>"
5260                         console.log(2)
5261                     }
5262                 });
5263                 $(ulIcon).append(liIcon);
5264                 $("#" + itemId + "ActiveId").find(".h_totle").append(ulIcon);
5265                 console.log($("#" + itemId + "ActiveId").find(".h_totle"))
5266                 console.log(ulIcon)
5267                 // 单行文本 多行文本 数字  日历 
5268             } else if (customItems[item].type == "text" || customItems[item].type == "textarea" || customItems[item].type == "number" || customItems[item].type == "calendar") {
5269                 var itemId = customItems[item].id;
5270                 var defaultvalue = $("#" + itemId).attr("defaultvalue");
5271                 //  12/4  判断是否存在当前时间
5272                 var calendar = _.filter(customShow.options.customItemShow.item, ['tag_Type', 'calendar'])
5273                 for (var i = 0; i < calendar.length; i++) {
5274                     if (calendar[i].tag_Attribute.currentDate) {
5275                         if (itemId == calendar[i].tag_Id) {
5276                             defaultvalue = customShow.currentDate
5277                         }
5278                     }
5279                 }
5280                 console.log(defaultvalue)
5281                 // 之前表单日历默认值不存在时 12/4
5282                 if (defaultvalue == undefined || defaultvalue == 'undefined') {
5283                     defaultvalue = ''
5284                 }
5285                 customBase.setItemValue(itemId, "text", defaultvalue);
5286                 //数字验证事件追加
5287                 if (customItems[item].type == "number") {
5288                     //数值型控件验证
5289                     $("#" + itemId).unbind('blur');
5290                     $("#" + itemId).on('blur', function (e) {
5291                         var numbertype = $(this)[0].getAttribute("numbertype");
5292                         if (numbertype == "decimal") {
5293                             var decimalplace = $(this)[0].getAttribute("decimalplace");
5294                             decimalplace = parseInt(decimalplace);
5295                             if ($(this)[0].value != "") {
5296                                 $(this)[0].value = Number($(this)[0].value).toFixed(decimalplace);
5297                             }
5298
5299                         }
5300                     });
5301                 }
5302             } else if (customItems[item].type == 'dropdownlist' || customItems[item].type == 'radio' ||
5303                 customItems[item].type == 'checkbox' || customItems[item].type == 'tree') {
5304                 if ('customShow' != showClass) {
5305                     //数据源绑定
5306                     customShow.setDatasourceData(customItems[item]);
5307                 }
5308             } else if (customItems[item].type == 'splitline') {
5309                 //分割线
5310                 var itemId = customItems[item].id;
5311                 $('.' + showClass + " #" + itemId + "ActiveId").addClass("layoutsetting8");
5312             } else if (customItems[item].type == 'tree') {
5313                 var itemId = customItems[item].id;
5314                 var defaultvalue = $("#" + itemId)[0].getAttribute("defaultvalue");
5315
5316                 // 之前表单树形默认值不存在时 12/7
5317                 if (defaultvalue == undefined || defaultvalue == 'undefined') {
5318                     defaultvalue = ''
5319                 }
5320                 customBase.setItemValue(itemId, "text", defaultvalue);
5321             }
5322             //初始属性设定
5323             if (customItems[item].type == 'dropdownlist' || customItems[item].type == 'radio' ||
5324                 customItems[item].type == 'checkbox' || customItems[item].type == 'tree' ||
5325                 customItems[item].type == "text" || customItems[item].type == "textarea" || customItems[item].type == "number"
5326                 || customItems[item].type == "calendar" || customItems[item].type == "fileupload"
5327                 || customItems[item].type == "qrcode" || customItems[item].type == "barcode"
5328                 || customItems[item].type == "htmlediter" || customItems[item].type == "link"
5329                 || customItems[item].type == "subform"
5330             ) {
5331                 console.log(customBase.options.customItems[item])
5332                 customShow.setShowAttribute(customBase.options.customItems[item]);
5333             }
5334             // 12/15
5335             if (customItems[item].type == "link") {
5336                 var linkurl = customShow.costType[customItems[item].id].tag_Attribute.linkurl;
5337                 if(linkurl == ''){
5338                     linkurl = 'javascript:void(0)';
5339                 }
5340                 $('#'+customItems[item].id).attr('href',linkurl)
5341             }
5342         }
5343     };
5344     //事件追加
5345     customShow.clickBindSubform();
5346
5347 }
5348
5349 //固定事件的绑定
5350 var index_i = 0;
5351 customShow.clickBind = function () {
5352
5353     //子表单事件追加
5354     customShow.clickBindSubform();
5355
5356     //  //保存按钮按下
5357     //  $(".fromSaveCss").on('click', function() {
5358     //     customShow.onclickSave();
5359     //   });
5360
5361     //  //取消按钮按下
5362     //  $(".cancelCss").on('click', function() {
5363     //     customShow.onclickCancel();
5364     //   });
5365
5366
5367     // 子表单添加记录事件
5368
5369     $('.subformAdd').unbind();
5370     function addSubFunc() {
5371         //子表单项目追加
5372         //console.log($(this)[0]);
5373         customShow.addsubformList($(this)[0], "customViewUEditorCss");
5374         //  customShow.setXhSelectListAdd();
5375         //子表单事件追加
5376         customShow.clickBindSubform();
5377         //公式初期化
5378         customLinkageAnalysis.bindLinkage();
5379         customShow.oneTotle();
5380         //console.log($('.subformAdd'));
5381         $('.subformAdd').unbind('click', addSubFunc);
5382         $('.subformAdd').on('click', addSubFunc);
5383         //行程排序初期化
5384         customShow.journeySort();
5385         SC.noBillCheckInit()//无票据行程验证
5386
5387     }
5388     $('.subformAdd').on('click', addSubFunc);
5389
5390     //主数据丢失
5391     //   $('.subformAdd').unbind();
5392     //   $('.subformAdd').on('click', function(){
5393     //       console.log(1)
5394     //     //子表单项目追加
5395     //     customShow.addsubformList($(this)[0],"customViewUEditorCss");
5396     //     //子表单事件追加
5397     //     customShow.clickBindSubform();
5398     //     //公式初期化
5399     //  customLinkageAnalysis.bindLinkage();
5400     //         //行程排序初期化
5401     //          customShow.journeySort();
5402     //   });
5403
5404     //图片文件上传
5405     var uploaderImage = $(".customViewUEditorCss .uploaderImage");
5406     for (var i = 0; i < uploaderImage.length; i++) {
5407
5408         var imageItem = customShow.options.customItemShow.item[uploaderImage[i].id];
5409         var itemList = customBase.options.uploaderItemReady[uploaderImage[i].id];
5410         // 参数设定
5411         var potion = {
5412             id: uploaderImage[i].id,
5413             width: imageItem.tag_Attribute.width,
5414             height: imageItem.tag_Attribute.height,
5415             formid: customShow.options.formid,
5416             imagetype: imageItem.tag_Attribute.dropdowntype, //图片类型
5417             editable: imageItem.tag_Attribute.editable, //是否可编辑
5418             defaultvalueUrl: imageItem.tag_Attribute.defaultvalue, //默认的Url
5419             ItemReady: itemList
5420         }
5421         customBase.uploaderShow(potion);
5422         // customBase.uploaderShow("#"+uploaderImage[i].id,{width:0,height:200},true,customShow.options.formid);
5423
5424     };
5425
5426     //lym子表单上传
5427     $('.sonImportFile').unbind();
5428     $(".sonImportFile").click(function () {
5429         console.log("进入点击事件");
5430         //var checkedObj = $("#tbody input[type=checkbox]:checked");
5431         console.log("fdsffddffd");
5432         // //创建文件上传对象
5433         var a = $(this).attr("itemId")
5434         console.log(a)
5435         $("#" + a + "btn").click(
5436
5437         );
5438         $("#" + a + "btn").change(function () {
5439             console.log("uqwhdoqwhdo");
5440             //var objFile = $("#"+itemTwo+"btn");
5441             //改变
5442
5443             let mthis = this;
5444             var tenantId = localStorage.getItem("tenantID");
5445             var formID = localStorage.getItem("newFormID");
5446             var tenant = JSON.parse(tenantId);
5447             var user = localStorage.getItem("userName");
5448             var userName = JSON.parse(user);
5449             var aba = a;
5450             console.log(aba);
5451             //结束    
5452             console.log(tenantId);
5453             console.log(formID);
5454             var objFile = $(this);
5455             if (objFile.value == "") {
5456                 return;
5457             } else {
5458                 var f_content = this.value;
5459                 var fileext = f_content.substring(f_content.lastIndexOf("."), f_content.length);
5460                 fileext = fileext.toLowerCase()
5461                 if (fileext != '.xls') {
5462                 } else {
5463                     //改变
5464                     var dataObj = { "formID": formID, "tenantID": tenant.tenantID, "userName": userName.userName, "rowNum": aba }
5465                     //结束
5466
5467                     var options = {
5468                         url: url, //上传文件的路径  
5469                         type: 'post',
5470                         dataObj: dataObj,
5471                         async: false,
5472                         success: function (data) {//异步上传成功之后的操作
5473                             if (data != undefined && data != null) {
5474                                 console.log("返回参数");
5475                             }
5476
5477                         }
5478                     };
5479
5480                     var requestData = window.SonfiledUpload(dataObj, options, "/excel/impSonExcel", $(this).attr("itemId"), fileext);
5481                     var excels = JSON.parse(requestData);
5482                     console.log(requestData);
5483                     //                console.log("最后");
5484                     //          
5485                     //                console.log($(this).attr("itemId"))
5486                     //改变
5487                     $(mthis).val("");
5488                     if (excels.data != undefined) {
5489                         customShow.addRow($(this).attr("itemId"), excels.data);
13ec33 5490                         //toastr.info("导入成功");
4d1219 5491
B 5492                     } else {
5493                         toastr.error("表格数据格式有误!");
5494                     }
5495                     //结束
5496                     //清除后台返回结果
5497                     window.localStorage.removeItem("seccData");
5498
5499                 }
5500             }
5501         })
5502     });
5503     //文本文件上传
5504     var uploaderFile = $(".customViewUEditorCss .uploaderFile");
5505     console.log(uploaderFile)
5506     for (var i = 0; i < uploaderFile.length; i++) {
5507
5508         var imageItem = customShow.options.customItemShow.item[uploaderFile[i].id];
5509         var itemList = customBase.options.uploaderItemReady[uploaderFile[i].id];
5510         // 参数设定
5511         var potion = {
5512             id: uploaderFile[i].id,
5513             width: imageItem.tag_Attribute.width,
5514             height: imageItem.tag_Attribute.height,
5515             formid: customShow.options.formid,
5516             imagetype: imageItem.tag_Attribute.dropdowntype, //图片类型
5517             editable: imageItem.tag_Attribute.editable, //是否可编辑
5518             defaultvalueUrl: imageItem.tag_Attribute.defaultvalue, //默认的Url
5519             ItemReady: itemList
5520         }
5521         customBase.uploaderFileShow(potion);
5522         // customBase.uploaderShow_Temp("#"+uploaderFile[i].id,{width:0,height:200},false,customShow.options.formid);
5523
5524     };
5525
5526     //必须入力验证
5527     // var mustcheckCss = $(".mustcheckCss");//-----------todo
5528     // for (var i = 0; i < mustcheckCss.length; i++) {
5529     //   ////////////////console.log('#'+$(mustcheckCss)[i].id);
5530     // };
5531
5532     //子表单默认删除项目去掉
5533     //子表单第一行可删除
5534     // $(".iconfontcolor").addClass("cfg_contentNone");
5535     // $(".iconfontcolorTH").addClass("cfg_contentNone");
5536
5537     //金融控件点击事件
5538     $('.amountShowClass').unbind();
5539     $('.amountShowClass').on('click', function () {
5540         var editable = $(this)[0].getAttribute("editable");
5541         //编辑设定
5542         if (editable == "false") {
5543             return;
5544         }
5545
5546
5547         $(this).addClass("cfg_contentNone");
5548         $("#" + $(this)[0].id + "amount").removeClass("cfg_contentNone");
5549         $("#" + $(this)[0].id + "amount").focus();
5550     });
5551
5552     //金融控件点击事件
5553     $('.amountShowTextClass').unbind();
5554     $('.amountShowTextClass').on('blur', function () {
5555         var id = $(this)[0].id;
5556         //表示的控件ID取得
5557         var idTemp = id.replace("amount", "");
5558
5559         var showCustomItem = customShow.options.customItemShow.item[idTemp];
5560         // var widthqrcode = $("#"+idTemp)[0].width;
5561         // var heightqrcode = $("#"+idTemp)[0].height;
5562         var widthqrcode = showCustomItem.tag_Attribute.width;
5563         var heightqrcode = showCustomItem.tag_Attribute.height;
5564         if (heightqrcode == 0 || heightqrcode == undefined) {
5565             heightqrcode = 24;
5566         }
5567         if (widthqrcode == 0 || widthqrcode == undefined) {
5568             widthqrcode = 200;
5569         }
5570
5571         //金额组件
5572         //默认数值
5573         var defaultSize = {
5574             width: widthqrcode,
5575             height: heightqrcode,
5576             defaultvalue: "",
5577             styleclass: ""
5578         };
5579
5580         var decimalplace = $(this)[0].getAttribute("decimalplace");
5581         decimalplace = parseInt(decimalplace);
5582         if ($(this)[0].value != "") {
5583             $(this)[0].value = Number($(this)[0].value).toFixed(decimalplace);
5584         }
5585
5586
5587         defaultSize.defaultvalue = $(this)[0].value.replace(".", "");
5588
5589         var showItem = customBase.getAmountHtml(defaultSize, true);
5590         customBase.amount2Image(showItem, "amount", defaultSize, function (amountHtml) {
5591             // ////////////////console.log(idTemp);
5592             $("#" + idTemp + "amount").addClass("cfg_contentNone");
5593             for (var i = 0; i < $("." + idTemp + "value").length; i++) {
5594                 $("." + idTemp + "value")[i].setAttribute("src", amountHtml);
5595             };
5596             $("#" + idTemp).removeClass("cfg_contentNone");
5597         })
5598     });
5599     var addVal = [];
5600
5601     //申请单控件点击事件
5602     $('.chooseMenu').unbind();
5603     $(".mytext_icon").on("click", function () {
5604         $(this).closest("[type='mytext']").find('.boxBtn').click();
5605         console.log(customShow.options);
5606         console.log(customBase.options);
5607     })
5608     $('.boxBtn').on('click', (obj) => {
5609         console.log(customBase.options)
5610         addVal = [];
5611         //取得父页面变量
5612         var outWindowObj = window.parent;
5613         var $iconId = $(obj)[0].target.getAttribute("myAttr");
5614         var iconAttr = customShow.options.customItemShow.item[$iconId];
5615         console.log(iconAttr);
5616         if ($("#" + $iconId).attr("formhuixian") != undefined) {
5617             var formhuixian = JSON.parse($("#" + $iconId).attr("formhuixian"));
5618         }
5619         //console.log(formhuixian);
5620         let head = "";
5621         if ($(obj)[0].target.previousSibling.getAttribute("chooseForm") != "" || iconAttr.tag_Attribute.relevancesourcetype == "fundata") {
5622             console.log(attrData);
5623             if (iconAttr.tag_Attribute.relevancesourcetype == "fundata") {//函数分支修改 李伟民 12-05
5624                 var titleObj = { "key": JSON.parse(iconAttr.tag_Attribute.fundata)['key'] };
5625                 var requestTitle = window.commonAjax("/datamanagement/getAssociateTitle", titleObj, "POST", true, false);
5626                 requestTitle.done(function (res) {
5627                     var formtitle = [];
5628                     _.each(res.data, function (tdata) {
5629                         formtitle.push({ "fieldKey": tdata.fieldKey, "title": tdata.title });
5630                     });
5631                     head = formtitle;
5632                 });
5633                 var attrData = undefined;
5634             } else {
5635                 var attrData = JSON.parse($(obj)[0].target.previousSibling.getAttribute("chooseForm"));
5636                 head = attrData.huixianObj.chooseData;
5637             }//函数分支修改 李伟民 12-05
5638             // window.localStorage.setItem("bussiness", attrData.formID.bussinessSystem)  //不用了?
5639             //获取id值
5640             //用于验证是否已经存在div
5641             var $divsLength = $('#' + $iconId + 'divIcons').length;
5642             //接收table头请求
5643             var formId = "";
5644             if (attrData && attrData.ScreenCondition != undefined) {
5645                 //下拉框取值
5646                 let getVal = attrData.ScreenCondition.child;
5647                 console.log(getVal);
5648                 _.each(getVal, opts => {
5649                     _.each(customBase.options.customItems, opt => {
5650                         if (opt.fieldKey == opts.fieldKey && opts.side == "thi") {
5651                             opts.value = "";
5652                             if (opt.type == "dropdownlist") {
5653                                 var getVals = customBase.getItemValue(opt.id, "dropdownlistText");
5654                                 console.log(getVals);
5655                                 if (getVals[0][0] != undefined) {
5656                                     opts.value = getVals[0];
5657                                 } else {
5658                                     opts.value = "";
5659                                 }
5660                             } else if (opt.type == "tree") {//树控件 处理  李伟民 12-5
5661                                 var getVals = customBase.getItemValue(opt.id, opt.type);
5662                                 console.log(getVals);
5663                                 if (getVals[0][0] != undefined) {
5664                                     opts.value = getVals[0];
5665                                 } else {
5666                                     opts.value = "";
5667                                 }
5668                             } else {//树控件 处理  李伟民 12-5
5669                                 var getVals = customBase.getItemValue(opt.id, opt.type);
5670                                 console.log(getVals);
5671                                 if (getVals != undefined) {
5672                                     opts.value = getVals;
5673                                 } else {
5674                                     opts.value = "";
5675                                 }
5676                             }
5677                         }
5678                     })
5679                 });
5680                 var sCondition = {};
5681                 //请求数据  筛选条件参数
5682                 let getValue = {};
5683                 getValue.child = getVal;
5684                 getValue.count = attrData.ScreenCondition.count;
5685                 sCondition = getValue;
5686                 let shaixuanData = attrData.ScreenCondition.child;
5687             }
5688             if ((attrData && attrData.huixianObj != undefined) || iconAttr.tag_Attribute.relevancesourcetype == "fundata") {
5689                 if (iconAttr.tag_Attribute.relevancesourcetype == "fundata") {
5690                     formId = undefined;
5691                 } else {
5692                     formId = attrData.formID;
5693                 }
5694                 if ($divsLength == 0) {
5695                     //外层蒙版
5696                     console.log(customShow.options.customItemShow.item)
5697                     console.log($iconId)
5698                     var my_text_title = customShow.options.customItemShow.item[$iconId].tag_Attribute.title;
5699
5700                     var menuContent = document.createElement('div');
5701                     //数据渲染div
5702                     var divIcons = document.createElement('div');
5703                     var pageBox = document.createElement('div');
5704                     var buttonDiv = document.createElement("div");
5705                     var closeBtn = document.createElement("span");
5706                     var requersTable = document.createElement("table");
5707                     var page = document.createElement("div");
5708                     var bigmodule = document.createElement("div");
5709                     var mymodule = document.createElement("div");
5710                     var mymodule2 = document.createElement("div");
5711                     var modal_content = document.createElement("div");
5712                     var mymodulebody = document.createElement("div");
5713                     var mymoduleheader = document.createElement("div");
5714                     var mymodulefooter = document.createElement("div");
5715                     var myinput = document.createElement("input");
5716                     var mybtn = document.createElement("button");
5717                     mybtn.innerHTML = "<i class='fa fa-search'></i>";
5718                     mybtn.setAttribute('class', 'btn btn-default');
5719                     mybtn.setAttribute('onClick', 'showbtn()');
5720                     mybtn.setAttribute('id', 'showserch');
5721                     // 添加搜索
5722                     var serchbox = document.createElement('div');
5723                     var serchpage = document.createElement('div');
5724                     var sersrc = document.createElement('script');
5725                     serchpage.setAttribute('class', 'pagination');
5726                     serchpage.setAttribute('style', 'display:none');
5727                     sersrc.setAttribute('src', './../../js/dataManagement/findmany.js');
5728                     var header = '<div _ngcontent-c12="" aria-label="Close" class="close"><span _ngcontent-c12="" class="closeBtn" aria-hidden="true">×</span></div><h4  class="modal-title modal-title_box" id="myModalLabel">' + my_text_title + '</h4>';
5729                     var footer = '<div _ngcontent-c12="" class="btn btn-primary btn-info btn-action closeBtn">确定</div>';
5730                     serchbox.setAttribute('class', 'fui-form hides');
5731                     serchbox.setAttribute('id', 'findserch');
5732                     serchbox.setAttribute('style', 'display:none !important;');
5733                     serchbox.innerHTML = '<div class="search_item">' +
5734                         '<div class="search_column ng-scope" id="copyTemp" style="display: none;">' +
5735                         '<div class="ng-binding" style="font-size:10px;font-weight:700;"></div>' +
5736                         '<span style="display: flex;width: 100%;"></span></div>' +
5737
5738                         '<div class="search_column findbox ng-scope" id="copyTempNumber" style="display: none;">' +
5739                         '<div class="ng-binding" style="font-size:10px;font-weight:700;">预算截止时间</div>' +
5740                         '<span style="display: flex;position:relative;width:45%;"><input id = "numberFrom" class=""  type="number"/></span>' +
5741                         '<span> ~ </span>' +
5742                         '<span style="display: flex;position:relative; width:45%;"><input id = "numberTo" class=""  type="number"/></span></div>' +
5743                         '<div class="search_column ng-scope" id="copyTempTime" style="display: none;">' +
5744                         '<div class="ng-binding" style="font-size:10px;font-weight:700;"> 预算截止时间</div>' +
5745                         '<span style="display: flex; position: relative;width:45%;">' +
5746                         '<input id = "dateFrom" class=""  type="text"/><i name = "clearFlatPickr" style="position:absolute;padding-left:3px;font-size:16px;top:6px;right:5px;" class="fa fa-calendar" aria-hidden="true"></i>' +
5747                         '</span><span> ~ </span><span style="display: flex;position:relative;width:45%;">' +
5748                         '<input id = "dateTo" class=""  type="text"/><i name = "clearFlatPickr" style="position:absolute;padding-left:3px;font-size:16px;top:6px;right:5px;" class="fa fa-calendar" aria-hidden="true"></i>' +
5749                         '</span></div><div class="search_column_button search_column_button_box">' +
5750                         '<span><button class="btn btn-info btn-action" id="search_condition"><i class="fa fa-search" aria-hidden="true"></i>&nbsp;&nbsp;查询</button></span>' +
5751                         '</div></div>' +
5752                         '<div class="condition_search_footer" style="display:none">' +
5753                         '<label class="first">' +
5754                         '<span><select class="ng-pristine ng-untouched ng-valid ng-not-empty" id="pageSelect">' +
5755                         '<option value="20" selected="selected">20条/页</option>'
5756                     '<option value="50"> 50条/页</option><option value="100">100条/页</option>' +
5757                         '</select></span><span class="ng-binding">共<span id = "showTotalPageLeft"></span>页</span></label>' +
5758                         '<label class="second"> <div class="pagination">' +
5759                         '<span class="skip first">首页</span><span class="skip pre">上一页</span>' +
5760                         '<div class="nums"></div><span class="skip next">下一页</span>' +
5761                         '<span class="skip last">尾页</span></div></label></div>';
5762                     mymoduleheader.innerHTML = header;
5763                     mymodulefooter.innerHTML = footer;
5764                     mymodule.setAttribute('style', 'width:750px;height: 448px;margin:0 auto;');
5765                     menuContent.setAttribute('id', $iconId + 'menuContent');
5766                     menuContent.setAttribute('class', 'menuContent');
5767                     bigmodule.setAttribute('class', 'bigmodule');
5768                     mymodule.setAttribute('class', 'mymodule');
5769                     mymodule2.setAttribute('class', 'mymodule2 mymodule2_box');
5770                     modal_content.setAttribute('class', 'modal-content modal_content_box');
5771                     mymodulebody.setAttribute('class', 'mymodulebody');
5772                     $(mymodulebody).css({ "height": "485px", "overflow-y": "auto" });
5773                     mymoduleheader.setAttribute('class', 'mymoduleheader');
5774                     mymodulefooter.setAttribute('class', 'mymodulefooter');
5775                     myinput.setAttribute('class', 'myipt');
5776                     divIcons.setAttribute('class', 'mytext');
5777                     divIcons.setAttribute('id', $iconId + 'divIcons');
5778                     page.setAttribute('id', $iconId + 'pageF');
5779                     page.setAttribute('class', 'pageF');
5780                     pageBox.setAttribute('id', $iconId + 'pageBox');
5781                     pageBox.setAttribute('class', 'pageBox');
5782                     buttonDiv.setAttribute("class", "buttonDiv");
5783                     requersTable.setAttribute("class", "requestMenu");
5784                     $('#' + $iconId + 'ActiveId').append(menuContent);
5785                     $('#' + $iconId + 'menuContent').append(bigmodule);
5786                     bigmodule.appendChild(mymodule);
5787                     mymodule.appendChild(mymodule2);
5788                     mymodule2.appendChild(modal_content);
5789                     modal_content.appendChild(mymodulebody);
5790                     mymodulebody.appendChild(mymoduleheader);
5791                     mymodulebody.appendChild(serchpage);
5792                     mymodulebody.appendChild(mybtn);
5793                     mymodulebody.appendChild(serchbox);
5794                     mymodulebody.appendChild(divIcons);
5795                     mymodulebody.appendChild(mymodulefooter);
5796                     mymodulebody.appendChild(myinput);
5797                     pageBox.appendChild(page);
5798                     // $('.mytext').append(sersrc);
5799                     //            $('.mytext').append(buttonDiv);
5800                     $('#' + $iconId + 'divIcons').append(requersTable);
5801                     $('#' + $iconId + 'divIcons').append(pageBox);
5802                     var lastPage = "";
5803                     customBase.findmay = {
5804                         "formId": formId,
5805                         "sCondition": sCondition,
5806                         "formhuixian": formhuixian,
5807                         "head": head,
5808                         "iconId": $iconId,
5809                         "addVal": addVal
5810                     }
5811                     var count = fenye("5", "1", formId, sCondition, formhuixian, head, $iconId, addVal, []);
5812
5813                     lastPage = Math.ceil(count / 5);
5814                     //console.log($(".pageF"))
5815                     $(".pageF").paging({
5816                         pageNo: 1,
5817                         totalPage: lastPage,
5818                         totalSize: count,
5819                         callback: function (num) {
5820                             console.log(num);
5821                             fenye("5", num, formId, sCondition, formhuixian, head, $iconId, addVal, []);
5822                         }
5823                     });
5824                 }
5825                 //如果存在就移除
5826             } else {
5827                 $('#' + $iconId + 'menuContent').remove();
5828             }
5829         } else {
5830             alert('未选择表单')
5831         }
5832         // 调用查询方法10/18
5833         findserch();
5834     });
5835     //条形码点击事件
5836     $('.barcodeShowClass').unbind();
5837     $('.barcodeShowClass').on('click', function () {
5838         var editable = $(this)[0].getAttribute("editable");
5839         //编辑设定
5840         if (editable == "false") {
5841             return;
5842         }
5843
5844         $(this).addClass("cfg_contentNone");
5845         $("#" + $(this)[0].id + "barcode").removeClass("cfg_contentNone");
5846         $("#" + $(this)[0].id + "barcode").focus();
5847     });
5848     //条形码焦点离开事件
5849     $('.barcodeShowTextClass').unbind();
5850     $('.barcodeShowTextClass').on('blur', function () {
5851         var id = $(this)[0].id;
5852         //表示的控件ID取得
5853         var idTemp = id.replace("barcode", "");
5854         // //默认数值
5855         // var defaultSize = {
5856         //   width:$("#"+idTemp)[0].width,
5857         //   height:$("#"+idTemp)[0].height,
5858         //   defaultvalue:"",
5859         //   styleclass:""
5860         // };
5861         // var size = $("#"+idTemp)[0].getAttribute("size");
5862         var showCustomItem = customShow.options.customItemShow.item[idTemp];
5863         // var size = $("#"+idTemp)[0].getAttribute("size");
5864         var size = showCustomItem.tag_Attribute.size;
5865         // defaultSize.defaultvalue = $(this)[0].value;
5866         customBase.createbarcode(size, $(this)[0].value, function (text, barWidth, barHeight, sizeWidthHeight) {
5867             $("#canvasbarcode").remove();
5868             $(document.body).append('<div id="canvasbarcode" style="display: none;"></div>');
5869             // //设值 距离左侧距离 margin-left: -2px;
5870             // if(barWidth == 1){
5871             //    $("."+idTemp+"value").addClass("barcodeMarginleft1");
5872             // }else if(barWidth == 2){
5873
5874             // }else if(barWidth == 3){
5875
5876             // }else if(barWidth == 4){
5877
5878             // }else if(barWidth == 5){
5879
5880             // }else if(barWidth == 6){
5881
5882             // }
5883             // $("."+idTemp+"value").addClass("barcodeMarginleft"+barWidth);
5884
5885             jQuery('#canvasbarcode').barcode(text, "code128", { barWidth: barWidth, barHeight: barHeight, showHRI: true });
5886             var canvasbarcode = $("#canvasbarcode")[0].innerHTML;
5887             sizeWidthHeight.width = $("#canvasbarcode")[0].style.width;
5888
5889             customBase.amount2Image(canvasbarcode, "barcode", sizeWidthHeight, function (amountHtml) {
5890                 $("#" + idTemp + "barcode").addClass("cfg_contentNone");
5891                 for (var i = 0; i < $("." + idTemp + "value").length; i++) {
5892                     $("." + idTemp + "value")[i].setAttribute("src", amountHtml);
5893                 };
5894                 $("#" + idTemp).removeClass("cfg_contentNone");
5895             });
5896         });
5897     });
5898     //二维码点击事件
5899     $('.qrcodeShowClass').unbind();
5900     $('.qrcodeShowClass').on('click', function () {
5901         var editable = $(this)[0].getAttribute("editable");
5902         //编辑设定
5903         if (editable == "false") {
5904             return;
5905         }
5906
5907         $(this).addClass("cfg_contentNone");
5908         $("#" + $(this)[0].id + "qrcode").removeClass("cfg_contentNone");
5909         $("#" + $(this)[0].id + "qrcode").focus();
5910     });
5911
5912     //二维码焦点离开事件
5913     $('.qrcodeShowTextClass').unbind();
5914     $('.qrcodeShowTextClass').on('blur', function () {
5915         var id = $(this)[0].id;
5916         //表示的控件ID取得
5917         var idTemp = id.replace("qrcode", "");
5918         var showCustomItem = customShow.options.customItemShow.item[idTemp];
5919         // var widthqrcode = $("#"+idTemp)[0].width;
5920         // var heightqrcode = $("#"+idTemp)[0].height;
5921         var widthqrcode = showCustomItem.tag_Attribute.width;
5922         var heightqrcode = showCustomItem.tag_Attribute.height;
5923         if (heightqrcode == 0 || heightqrcode == undefined) {
5924             heightqrcode = 60;
5925         }
5926         if (widthqrcode == 0 || widthqrcode == undefined) {
5927             widthqrcode = 60;
5928         }
5929         //默认数值
5930         var defaultSize = {
5931             width: widthqrcode,
5932             height: heightqrcode,
5933             defaultvalue: "",
5934             styleclass: ""
5935         };
5936         // var size = $("#"+idTemp)[0].getAttribute("size");
24a275 5937         //0131  马习同   二维码汉字转码
M 5938          function utf16to8(str) {
5939              var out, i, len, c;
5940              out = "";
5941              len = str.length;
5942              for (i = 0; i < len; i++) {
5943                  c = str.charCodeAt(i);
5944                  if ((c >= 0x0001) && (c <= 0x007F)) {
5945                      out += str.charAt(i);
5946                  } else if (c > 0x07FF) {
5947                      out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));
5948                      out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F));
5949                      out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
5950                  } else {
5951                      out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F));
5952                      out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
5953                  }
5954              }
5955              return out;
5956          }
4d1219 5957
B 5958         defaultSize.defaultvalue = $(this)[0].value;
5959         $("#canvasqrcode").remove();
5960         $(document.body).append('<div id="canvasqrcode" style="display: none;"></div>');
24a275 5961         jQuery('#canvasqrcode').qrcode({ width: defaultSize.width, height: defaultSize.height, text: utf16to8($(this)[0].value) });
4d1219 5962         var mycanvas = $("#canvasqrcode").find("canvas")[0];
B 5963         var image = mycanvas.toDataURL("image/png");
5964         $("#" + idTemp + "qrcode").addClass("cfg_contentNone");
5965         for (var i = 0; i < $("." + idTemp + "value").length; i++) {
5966             $("." + idTemp + "value")[i].setAttribute("src", image);
5967         };
5968
5969         $("#" + idTemp).removeClass("cfg_contentNone");
5970     });
5971 }
5972 // 禁用树的父节点   12/9
5973 customShow.setTree = {
5974     disableParentNode: {
5975         set: function (treeObj) {
5976             if (treeObj) {
5977                 var nodes = treeObj.getNodes();
5978                 var level = 0;
5979                 //  获取最底层的层数
5980                 treeObj.getNodesByFilter(function (node) {
5981                     if (level < node.level) {
5982                         level = node.level;
5983                     }
5984                 }); // 查找不是最底层的节点集合
5985                 var nodesFilter = treeObj.getNodesByFilter(function (node) {
5986                     return (node.level != level)
5987                 });
5988                 //父节点禁止勾选
5989                 for (var i = 0; i < nodesFilter.length; i++) {
5990                     treeObj.setChkDisabled(nodesFilter[i], true);
5991                 }
5992             }
5993         }
5994     }
5995 }
5996
5997 customShow.addtree = function (itemId, item) {
5998     console.log(customBase.settingRadioType)
5999     //修改克隆树的实例化 马习同2017-11-21
6000     console.log(customShow.options.customItemShow.item)
6001     var customItem = customShow.options.customItemShow.item;
6002     var ztree = {};
6003     for (let key in customItem) {
6004         if (customItem[key].tag_Type == "tree") {
6005             ztree[key] = customItem[key];
6006         }
6007     }
6008     $('.zTreeDemoBackground').css("display", "none");
6009     $(".search_input").css("display", "none");
6010     var index = 0;
6011     var treeObj;
6012     // var disableparentnode = false;
6013     for (let key in ztree) {
6014         if ($(item).find("#" + key).find('.ztree').parent().attr('disableparentnode') == "true") {
6015             $(item).find("#" + key).find('.ztree').attr("id", key + "tree" + index_i);//修改克隆树的id  马习同2017-11-21
6016             if (ztree[key].tag_Attribute.dropdowntype == "single") {
6017                 $.fn.zTree.init($($(".customViewUEditorCss  #" + key + "tree" + index_i)), customBase.settingRadioType, customShow.listData[key]);
6018                 //  12/2 树展开
6019                 treeObj = $.fn.zTree.getZTreeObj(key + "tree" + index_i);
6020                 customShow.setTree.disableParentNode.set(treeObj)
6021                 if (treeObj) {
6022                     treeObj.expandAll(true);
6023                 }
6024             } else if (ztree[key].tag_Attribute.dropdowntype == "multiple") {
6025                 $.fn.zTree.init($($(".customViewUEditorCss  #" + key + "tree" + index_i)), customBase.settingChkboxType, customShow.listData[key]);
6026                 treeObj = $.fn.zTree.getZTreeObj(key + "tree" + index_i);
6027                 customShow.setTree.disableParentNode.set(treeObj)
6028                 if (treeObj) {
6029                     treeObj.expandAll(true);
6030                 }
6031             }
6032         } else {
6033             $(item).find("#" + key).find('.ztree').attr("id", key + "tree" + index_i);//修改克隆树的id  马习同2017-11-21
6034             if (ztree[key].tag_Attribute.dropdowntype == "single") {
6035                 $.fn.zTree.init($($(".customViewUEditorCss  #" + key + "tree" + index_i)), customBase.settingRadioType, customShow.listData[key]);
6036                 //  12/2 树展开
6037                 treeObj = $.fn.zTree.getZTreeObj(key + "tree" + index_i);
6038                 console.log(treeObj)
6039                 if (treeObj) {
6040                     treeObj.expandAll(true);
6041                 }
6042             } else if (ztree[key].tag_Attribute.dropdowntype == "multiple") {
6043                 $.fn.zTree.init($($(".customViewUEditorCss  #" + key + "tree" + index_i)), customBase.settingChkboxType, customShow.listData[key]);
6044                 treeObj = $.fn.zTree.getZTreeObj(key + "tree" + index_i);
6045                 console.log(treeObj)
6046                 if (treeObj) {
6047                     treeObj.expandAll(true);
6048                 }
6049             }
6050         }
6051         // 克隆后选中节点  12/7 李元杰
6052         if (!_.isNull(treeObj)) {
6053             var treeId = treeObj['setting'].treeId;
6054             var defaultValue = $('#' + treeId).parent().attr('defaultvalue');
6055             // // 12/7  默认值
6056             if (defaultValue != '') {
6057                 console.log(treeObj)
6058                 customShow.treeDefaultSet(treeObj, defaultValue);
6059             }
6060         }
6061
6062     }
6063     console.log(treeObj)
6064     console.log($(item))
6065     //修改克隆树的实例化End  马习同2017-11-21
6066     index_i++;
6067
6068 }
6069
6070 //子表单项目追加
6071 customShow.addsubformList = function (subformAdd, showClass) {
6072     console.log(i)
6073     var allcopy = subformAdd.getAttribute('allcopy');
6074     var itemId = subformAdd.getAttribute('itemId');
6075     //单行记录更新
6076     if (allcopy == "false") {
6077         console.log(customBase.options.customItems);
6078         console.log(customBase.options.customItems[customShow.options.customItemShow.item[itemId].tag_Attribute.alias].cloneDiv);
6079         var item = customBase.options.customItems[customShow.options.customItemShow.item[itemId].tag_Attribute.alias].cloneDiv;
6080         // 子表单隐藏   马习同 11-13
6081         //      var item =$("."+showClass+" #"+itemId+"save").children()[0];
6082         //子表单情况为U情况
6083         if (item == undefined) {// 子表单回显 修改  李伟民 11-10
6084             var tbody = $("." + showClass + " #" + itemId + "ActiveId").find("tbody");
6085             tbody = tbody[0].cloneNode(true);
6086             console.log(tbody)
6087             // 清空input  12/7
6088             console.log($(item))
6089             if ($(item).find('.zTreeDemoBackground').attr('defaultvalue') == '') {
6090                 $(item).find(".citySel").val('');
6091             }
6092             $(tbody).find(".select2").remove();
6093             console.log($(tbody).html());
6094             $(tbody).find(".tdTitleClass").closest("tr").addClass("table_title");
6095             $(tbody).find(".dropdowntypeCss").select2({ theme: "classic" });
6096             //        $(tbody).find(".zTreeDemoBackground").select2({theme: "classic"});
6097             if ($(tbody).find(".table_title").length > 0) {
6098                 //删除头行
6099                 $(tbody).find(".table_title").remove();
6100             }
6101             if ($(tbody).find(".trContentClass").length > 1) {// 去除重复的tr  李伟民 11-14
6102                 $($(tbody).find(".trContentClass")[0]).siblings().remove();
6103             }// 去除重复的tr  李伟民 11-14
6104             //        $(tbody).find(".cfg_contentNone").removeClass("cfg_contentNone");
6105             tbody = customShow.addsubformListInit(itemId, $(tbody).find("tr"));
6106             console.log(tbody);
6107             console.log(itemId);
6108             console.log($(tbody).find("#" + itemId).attr("class"));
6109             $(tbody).find("input").attr("funarr", "");//公式绑定 清空 李伟民 12-11
6110             $(tbody).find("input").attr("checkfunarr", "");
6111             $(tbody).find(".select_get").attr("funarr", "");
6112             $(tbody).find(".select_get").attr("checkfunarr", "");//公式绑定 清空 李伟民 12-11
6113             $($("." + showClass + " #" + itemId + "ActiveId").find("table")[0]).append(tbody);// 子表单回显 修改  李伟民 11-10
6114             customShow.hidesubform();
6115             customShow.setXhSelectList(false);//添加记录 重复问题  李伟民11-14
6116         } else {
6117             item = item[0].cloneNode(true);
6118             // 12/7 清空input
6119             var defaultvalue = $(item).find('.zTreeDemoBackground').attr('defaultvalue');
6120             var itemIdTree = $(item).find('.ztree').attr('id');
6121             var treeObj = $.fn.zTree.getZTreeObj(itemIdTree);
6122             console.log(treeObj)
6123             // 12/7  默认值
6124             if ($(item).find('.zTreeDemoBackground').attr('defaultvalue') == '') {
6125                 $(item).find(".citySel").val('');
6126             }
6127             $(item).find(".select2").remove();
6128             $(item).find(".dropdowntypeCss").select2({ theme: "classic" });
6129             $(item).find(".subformAddiconShow .cfg_contentNone").removeClass("cfg_contentNone");
6130             item = customShow.addsubformListInit(itemId, item);
6131             $(item).find("input").attr("funarr", "");//公式绑定 清空 李伟民 12-11
6132             $(item).find("input").attr("checkfunarr", "");
6133             $(item).find(".select_get").attr("funarr", "");
6134             $(item).find(".select_get").attr("checkfunarr", "");//公式绑定 清空 李伟民 12-11
6135             $($("." + showClass + " #" + itemId + "ActiveId").find("table")[0]).append(item);
6136             customShow.setXhSelectList(true);//添加记录 重复问题  李伟民11-14
6137         }
6138
6139         customShow.addtree(itemId, item);
6140         //子表单事件追加
6141     } else {
6142         //全子表单复制
6143         //    //console.log(1);
6144
6145         var item = $("." + showClass + " #" + itemId + "ActiveId")[0];
6146         // //console.log(item);
6147         item = item.cloneNode(true);
6148         //console.log(item);
6149         var divIcons = document.createElement("div");
6150         divIcons.setAttribute("class", "frm_item_icons allCopyCss");
6151         var divIcon = document.createElement("div");
6152         divIcon.setAttribute("class", "frm_item_icon remove");
6153         var divIconImg = document.createElement("i");
6154         divIconImg.setAttribute("class", "icon iconfont icon-iconfontcolor93 iconfontcolor");
6155         divIconImg.setAttribute("style", "text-align: left;font-size: 18px;color: red;");
6156         // var divIconImg = document.createElement("img");
6157         // divIconImg.setAttribute("src", "./../../css/img/icon/delete.png");
6158         divIcon.appendChild(divIconImg);
6159         divIcons.appendChild(divIcon);
6160         // $(item).find(".icon-jiahao").parent().addClass("cfg_contentNone");
6161         $(item).append(divIcons);
6162         //  清空 树的input
6163         console.log($(item))
6164         if ($(item).find('.zTreeDemoBackground').attr('defaultvalue') != '') {
6165
6166         } else {
6167             $(item).find(".citySel").val('');
6168         }
6169         $(item).find(".select2").remove();
6170         $(item).find(".dropdowntypeCss").select2({ theme: "classic" });
6171         //console.log(item);
6172         item = customShow.addsubformListInit(itemId, item);
6173         // 10/23添加子表单记录
6174         var beforeitem = $("." + showClass + " #" + itemId + "ActiveId");
6175         //console.log(beforeitem);
6176         $(item).find("input").attr("funarr", "");//公式绑定 清空 李伟民 12-11
6177         $(item).find("input").attr("checkfunarr", "");
6178         $(item).find(".select_get").attr("funarr", "");
6179         $(item).find(".select_get").attr("checkfunarr", "");//公式绑定 清空 李伟民 12-11
6180         $("." + showClass + " #" + itemId + "ActiveId").eq(0).after(item);
6181         // _.each(beforeitem,function(bitem){
6182         if (beforeitem.length > 1) {
6183             for (var i = 0; i < beforeitem.length - 1; i++) {
6184                 $(beforeitem[i]).find(".icon-jiahao").parent().addClass("cfg_contentNone");
6185             }
6186         } else {
6187             $(beforeitem[0]).find(".icon-jiahao").parent().addClass("cfg_contentNone");
6188         }
6189         customShow.setXhSelectList();//添加记录 重复问题  李伟民11-14
6190         // });
6191         customShow.addtree(itemId, item);
6192     }
6193 }
6194 //马习同修改  子表单隐藏  11/13
6195 customShow.hidesubform = function () {
6196     // console.log($("[tag_type='subform']"))
6197     _.each($("[tag_type='subform']"), opt => {
6198         console.log(opt)
6199         $($(opt).find(".tdTitleClass")[0]).addClass("cfg_contentNone");
6200         $($(opt).find(".tdContentClass")[0]).addClass("cfg_contentNone");
6201     })
6202     var unvisible = customBase.options.customItems;
6203     var unvisibleArr = [];
6204     _.each(unvisible, opt => {
6205         if (opt.visible == false && opt.parentsubFormNum != 0) {
6206             unvisibleArr.push(opt)
6207         }
6208     })
6209     //  _.remove(unvisibleArr,n => {
6210     //     return n.fieldKey == "DATAROWNUM";
6211     // })
6212     // console.log(unvisibleArr)
6213     _.each(unvisibleArr, opt => {
6214         $("[id='" + opt.id + "']").parent().parent().addClass("cfg_contentNone");
6215         $($(".customShow #itemId_" + opt.parentsubFormNum + " .tdTitleClass")[$("[id='" + opt.id + "']").parent().parent().index()]).addClass("cfg_contentNone");
6216         $($(".customViewUEditorCss #itemId_" + opt.parentsubFormNum + " .tdTitleClass")[$("[id='" + opt.id + "']").parent().parent().index()]).addClass("cfg_contentNone");
6217     })
6218 }
6219 //子表单内数据初始化
6220 customShow.addsubformListInit = function (itemId, tbodys) {
6221     //console.log(tbodys);
6222     var itemList = customShow.options.customItemShow.item;
6223     var item = itemList[itemId];
6224     var parentsubFormNum = item.columnOrderNum + "";
6225
6226     for (itemListId in itemList) {
6227         if (itemList.hasOwnProperty(itemListId)) {
6228             if (itemList[itemListId].parentsubFormNum == parentsubFormNum) {
6229                 //子表单内控件确认
6230                 var type = itemList[itemListId].tag_Type;
6231                 if (type == "text" || type == "textarea" || type == "number") {
6232                     $(tbodys).find("#" + itemListId)[0].value = itemList[itemListId].tag_Attribute.defaultvalue;
6233                 } else if (type == "calendar") {
6234                     $(tbodys).find("#" + itemListId)[0].value = "";
6235                 } else if (type == "radio") {
6236
6237                 } else if (type == "checkbox") {
6238
6239                 } else if (type == "dropdownlist") {
6240                     var itemListIdTemp = itemListId + "_" + customShow.options.dropdownlist_I;
6241                     var item = $(tbodys).find("#" + itemListId);
6242                     ////////console.log($(tbodys));
6243                     // var dropdowntype =  $(item.find('select'))[0].getAttribute("dropdowntype");
6244                     var dropdowntype = customShow.options.customItemShow.item[itemListId].tag_Attribute.dropdowntype;
6245                     if ($("#" + itemListId + " .select3-element")[0] == undefined) {
6246                         var width = $(tbodys).find("#" + itemListId)[0].style.width.replace("px", "");
6247                     } else {
6248                         var width = $("#" + itemListId + " .select3-element")[0].style.width.replace("px", "");
6249                     }
6250
6251                     width = parseInt(width);
6252                     var listData = customBase.options.dropdownlistText[itemListId];
6253                     ////////console.log(customBase.options.dropdownlistText);
6254                     // $("#"+itemId).parent().empty();
6255                     var itemIdClass = "selectClass js-example-basic-single defaultHeight customShowItemClass  dropdowntypeCss " + itemListId + "value " + itemListIdTemp;
6256                     var DropdownlistItem = item.parent();
6257                     //        DropdownlistItem.css("background-color","red");
6258                     // var setDiv = $('<div id="'+itemListId+'" class="selectClass '+itemIdClass+'"></div>');
6259                     var setDiv = $('<div id="' + itemListId + '" class="selectClass lwm' + itemIdClass + '"></div>');
6260                     console.log("11122211")
6261                     DropdownlistItem.empty();
6262                     setDiv.empty();
6263                     console.log(itemListId);
6264                     DropdownlistItem.append(setDiv);
6265                     console.log($(DropdownlistItem).html());
6266                     //////console.log(dropdowntype);
6267
6268                     if (dropdowntype == "multiple") {
6269                         customShow.options.subformDList[itemListIdTemp] = {
6270                             selectId: itemListId,
6271                             multiple: true,
6272                             width: width,
6273                             // listData:listData,
6274                         }
6275                     } else {
6276                         customShow.options.subformDList[itemListIdTemp] = {
6277                             selectId: itemListId,
6278                             multiple: false,
6279                             width: width,
6280                             // listData:listData,
6281                         }
6282                     }
6283                     //  if(dropdowntype == "multiple"){
6284                     //     xhSelect.setXhSelect(
6285                     //         {
6286                     //             selectId:itemListId,
6287                     //             multiple:true,
6288                     //             width: width,
6289                     //             listData:listData,
6290                     //             setDiv:setDiv
6291                     //             // setDiv:itemListIdTemp
6292                     //         }
6293                     //     );
6294                     //  }else{
6295                     //     xhSelect.setXhSelect(
6296                     //         {
6297                     //             selectId:itemListId,
6298                     //             multiple:false,
6299                     //             width: width,
6300                     //             listData:listData,
6301                     //             setDiv:setDiv
6302                     //             // setDiv:itemListIdTemp
6303                     //         }
6304                     //     );
6305                     //  }
6306
6307                 }
6308             }
6309             customShow.options.dropdownlist_I++;
6310         }
6311
6312     }
6313     //console.log(customShow);
6314     //console.log(customBase);
6315
6316     ////////console.log(customShow.options.customItemShow.item);
6317     ////////console.log(itemId);
6318     ////////console.log(item);
6319     ////////console.log(parentsubFormNum);
6320     // customShow.setXhSelectList();
6321     return tbodys;
6322 }
6323 //驳回
6324 customShow.rejectBtn = function () {
6325     var flag = true;//true驳回 false不驳回
6326     over(flag)
6327 }
6328 //提交
6329 customShow.onclickSubmit = function () {
6330     get();
6331 }
6332 //查看票据
6333 customShow.checkbill = function () {
6334     window.open("./../bill_img/bill.html")
6335 }
6336 //审批
6337 customShow.auditableBtn = function () {
6338     auditableBtn();
6339 }
6340 function auditableBtn() {
6341     var processLog = JSON.parse(localStorage.getItem("processLog"));
6342     if (processLog != null && processLog != undefined) {
6343     } else {
6344         alert("请先创建一个流程");
6345         return null;
6346     }
6347     if (processLog[0].processState == 60) {
6348         alert("流程已结束");
6349         return null;
6350     }
6351     var inputs = "<h3 class='sp_title'>请输入审批语</h3><br/>" + "<textarea maxlength='200' onKeyUp='listenword()' class='stexta' type='test' id='datas'></textarea><span class='wordwrap'><var class='word'>0</var>/200</span><br/>"
6352         + "<div class='footerbtn' style='display:flex;justify-content:space-around;'><input class='btn btn-default choosebtn'  type='button' value='取消' onclick='zhixing(false)'/><input class='btn btn-default choosebtn2' type='button' value='确定' onclick='zhixing(true)'/></div>";
6353     $("#liucheng").html(inputs);
6354     $("#auditableBtn")[0].setAttribute('data-toggle', "modal");
6355     $("#auditableBtn")[0].setAttribute('data-target', ".bs-example-modal-sm");
6356 }
6357 customShow.onclickSave1 = function () {
6358     // SC.sendanydata(function(flag){
6359     //     console.log(flag);
6360     // if(!flag){
6361     //     console("if")
6362     //     customShow.onclickSave(1);
6363     // }else{
6364
6365     //    alert("错误");
6366     // }
6367     // });
6368     SC.sendanydata(customShow.onclickSave, 1)
6369
6370
6371 }
6372 customShow.onclickSave2 = function () {
6373     SC.sendanydata(customShow.onclickSave, 2)
6374 }
6375
6376 //清空按钮按下是
6377 customShow.onclickClear = function () {
6378     console.log(customBase);
6379     console.log(customShow);
6380     var itemKey = _.keys(customShow.options.customItemShow.item);
6381     var item = customShow.options.customItemShow.item;
6382     console.log(itemKey);
6383     _.each(itemKey, function (itemId) {
6384         console.log(itemId);
6385         console.log(item[itemId].tag_Type);
6386         customBase.setItemValue(itemId, item[itemId].tag_Type, "", "");
6387     });
6388 }
6389 //保存按钮按下时
6390 customShow.onclickSave = function (clickFlag) {
6391     console.log(clickFlag);
6392     var saveReturn = customShow.initEvent.fromSaveLinkage();
6393
6394     //画面项目取得 --------------------------画面项目取得------
6395     var items = customShow.getItems(true);
6396     console.log(items)
6397     // customShow.queryCost();
6398     try {
6399         if (typeof (eval(eachitem)) == "function") {
6400             eachitem(items);
6401         }
6402     } catch (e) {
6403         console.log("不存在的函数");
6404     }
6405
6406     console.log("遍历数组")
6407     console.log(items);
6408     // 画面check
6409     var returnfromCheck = customShow.initEvent.fromCheck(items); //--------------------
6410     if (returnfromCheck) {
6411         return;
6412     }
6413     // 03检证执行
6414     var check = customShow.initEvent.validationRuleCheck(items); //--------------------
6415     if (!check) {
6416         return;
6417     }
6418     // 检证接口函数
6419     var check = customShow.initEvent.validationRuleCheck3rd(items); //-----------需要对验证进行解析---------
6420     if (!check) {
6421         return;
6422     }
6423     // 提取数据 生成数据json  同customShow.getItems()
6424     //公式保存接口
6425     //  var saveReturn = customShow.initEvent.fromSaveLinkage(items);
6426     //  if(!saveReturn){
6427     //     return;
6428     //  }
6429     // 发送数据到后台服务器,保存data
6430     var saveReturn = customShow.initEvent.fromSave3rd(items);//--------------------
6431     console.log(customShow.options.customShowFlag)
6432     if (saveReturn) {
6433         console.log(1)
6434         if (customShow.options.customShowFlag == "1") {
6435             //保存
6436             customDataBound.fromSave(customShow.options.formid, items, function (rs) {
6437                 if (rs.rspCode == "000000") {
6438                     var strMessage = customBase.getMessage("mesage_ID015");
6439                     customBase.alert("S", strMessage);
6440                     //  return;
6441                 }
6442                 if (rs.rspCode == "100004") {
6443                     var strMessage = customBase.getMessage("mesage_ID007");
6444                     customBase.alert("E", strMessage);
6445                     return;
6446                 }
6447                 if (customShow.options.customShowFlag == "1") {
6448                     window.parent.$('#myModal').modal('hide');
6449                     window.parent.addFormData(rs);
6450                     $(window.parent.document.body).css({ "overflow-x": "auto", "overflow-y": "auto" });
6451                 }
6452                 // //////console.log(rs);
6453             });
6454         } else if (customShow.options.customShowFlag == "2") {
6455             console.log(2)
6456             //保存
6457             customDataBound.fromEdit(customShow.options.formid, items, customShow.options.dataRowNum, function (rs) {
6458                 if (rs.rspCode == "100004") {
6459                     var strMessage = customBase.getMessage("mesage_ID007");
6460                     customBase.alert("E", strMessage);
6461                     return;
6462                 }
6463                 customShow.options.breakFlag = true;
6464                 //预览模式表示
6465                 $("#customViewUEditor")[0].style.display = "none";
6466                 //马习同  2018-1-2  布局修改
6467                 $("#customShow")[0].style.display = "flex";
6468                 // $(".footer")[0].style.display ="none";
6469
6470                 var btns = [
6471                     'printableBtn',
6472                     // 'exportBtn',
6473                     // 'rejectBtn',
6474                     // 'submitBtn',
6475                     // 'auditableBtn',
6476                     // 'queryBtn',
6477                     // 'createBtn',
6478                     // 'clearBtn',
6479                     'disposableBtn',
6480                     // 'fromSaveBtn',
6481                     'editableBtn'
6482                 ];
6483                 customShow.showCustom(items, customShow.options.customInit);
6484                 customShow.setToolBtn(btns);
6485                 console.log("关闭")
6486                 customShow.onclickCancel();
6487
6488             });
6489             //   customShow.onclickCancel();
6490         }
6491         else if (customShow.options.customShowFlag == "3") {
6492             // 保存
6493             console.log(3)
6494             if (clickFlag == 2 && customShow.options.dataRowNum != "") {
6495                 //保存
6496                 customDataBound.fromEdit(customShow.options.formid, items, customShow.options.dataRowNum, function (rs) {
6497                     ////console.log(rs);
6498                     if (rs.rspCode == "000000") {
6499                         var strMessage = customBase.getMessage("mesage_ID015");
6500                         customBase.alert("S", strMessage);
6501                         //  return;
6502                     }
6503                     if (rs.rspCode == "100004") {
6504                         var strMessage = customBase.getMessage("mesage_ID007");
6505                         customBase.alert("E", strMessage);
6506                         return;
6507                     }
6508                     // customShow.options.breakFlag = true;
6509                     // //预览模式表示
6510                     // $("#customViewUEditor")[0].style.display ="none";
6511                     // $("#customShow")[0].style.display ="block";
6512                     // // $(".footer")[0].style.display ="none";
6513                     // customShow.showCustom(items,customShow.options.customInit);
6514                 });
6515                 //新建
6516             } else {
6517                 customDataBound.fromSave(customShow.options.formid, items, function (rs) {
6518                     if (rs.rspCode == "000000") {
6519                         var strMessage = customBase.getMessage("mesage_ID015");
6520                         customBase.alert("S", strMessage);
6521                         //  return;
6522                     }
6523                     if (rs.rspCode == "100004") {
6524                         var strMessage = customBase.getMessage("mesage_ID007");
6525                         customBase.alert("E", strMessage);
6526                         return;
6527                     }
6528                     // if(customShow.options.customShowFlag == "1" ){
6529                     //     window.parent.$('#myModal').modal('hide');
6530                     //     window.parent.addFormData(rs);
6531                     //     $(window.parent.document.body).css({"overflow-x": "auto","overflow-y": "auto"});
6532                     // }
6533                     customShow.options.dataRowNum = rs.data.dataRowNum;
6534                     //////console.log(rs);
6535                 });
6536             }
6537         }
6538     }
6539     // customShow.onclickCancel();
6540     //  window.parent.$('#myModal').modal('hide');
6541     // console.log($('.boxOne'))
6542     // $('.boxOne').css("display","none");
6543 }
6544
6545 //保存按钮按下时(项目预览表示)
6546 customShow.showCustom = function (items, customInit) {
6547     console.log(items);
6548     console.log(customInit);
6549     customShow.options.customItemShow = customInit.customViewItem;
6550     var customItem = customShow.options.customItemShow;
6551     // $(".preview-edit-pane").css("display","block");
6552     // $(".footer")[0].style.display ="block";
6553     // $(".footer .fromSaveCss")[0].style.display ="none";
6554
6555     var divHtml = customItem.formeditor;
6556
6557     $("#customShow").empty();
6558     $("#customShow")[0].innerHTML = divHtml;
6559     var height = customShow.options.customItemShow.height;
6560     //  height = parseInt(height)-50;
6561     //////////console.log(height);
6562     $("#customShow")[0].style.height = height + "px";
6563     $("#customShow")[0].style.width = customShow.options.customItemShow.width;
6564     $("#customShow")[0].style.display = "flex";
6565     var customItems = customBase.options.customItems;
6566
6567     //数据值变换
6568     for (item in customItems) {
6569         if (customItems.hasOwnProperty(item)) {
6570             if (customItems[item] == undefined) {
6571                 delete customItems[item];
6572                 continue;
6573             }
6574             if (customItems[item].type == 'subform') {
6575                 var subformTemp = items[item];
6576                 //////console.log(items);
6577                 ////console.log(item);
6578                 console.log(subformTemp);
6579                 //          console.log(customItems);
6580                 if (subformTemp == undefined) {
6581                     subformTemp = [{}];
6582                 }
6583                 for (subformItem in subformTemp[0]) {
6584                     if (subformTemp[0].hasOwnProperty(subformItem)) {
6585                         items[subformItem] = [];
6586                     }
6587                 }
6588                 for (var i = 0; i < subformTemp.length; i++) {
6589                     if (i != 0) {
6590                         //子表单项目追加
6591                         var subformAdd = $(".customShow #" + customItems[item].id + "ActiveId .subformAdd")[0];
6592                         customShow.addsubformList(subformAdd, "customShow");
6593                     }
6594                     for (subformItem in subformTemp[i]) {
6595                         if (subformTemp[i].hasOwnProperty(subformItem)) {
6596                             items[subformItem][i] = subformTemp[i][subformItem];
6597                         }
6598                     }
6599                 };
6600             }
6601             //选项卡回显
6602             if (customItems[item].type == 'tag') {
6603                 var subformTemp = items[item];
6604                 ////console.log(items);
6605                 ////console.log(item);
6606                 ////console.log(subformTemp);
6607                 ////console.log(customItems);
6608                 if (subformTemp == undefined) {
6609                     subformTemp = [{}];
6610                 }
6611                 for (subformItem in subformTemp[0]) {
6612                     if (subformTemp[0].hasOwnProperty(subformItem)) {
6613                         items[subformItem] = [];
6614                     }
6615                 }
6616                 for (var i = 0; i < subformTemp.length; i++) {
6617                     if (i != 0) {
6618                         //子表单项目追加
6619                         var subformAdd = $(".customShow #" + customItems[item].id + "ActiveId .subformAdd")[0];
6620                         customShow.addsubformList(subformAdd, "customShow");
6621                     }
6622                     for (subformItem in subformTemp[i]) {
6623                         if (subformTemp[i].hasOwnProperty(subformItem)) {
6624                             items[subformItem][i] = subformTemp[i][subformItem];
6625                         }
6626                     }
6627                 };
6628             }
6629         }
6630     }
6631
6632     customShow.options.subformDValue = items;
6633     //表示项目进行变换
6634
6635     //画面项目初期化
6636     customShow.controlInit("customShow");
6637
6638     //删除项目(select2项目删除)
6639     $('.customShow .selection').remove();
6640     //console.log(customItems);
6641     //数据设定
6642     for (item in customItems) {
6643         console.log(items)
6644         if (customItems.hasOwnProperty(item)) {
6645             if (customItems[item] == undefined) {
6646                 delete customItems[item];
6647                 continue;
6648             }
6649
6650             var type = customItems[item].type;
6651             var id = customItems[item].id;
6652             var value = items[item];
6653             // value = [{"tId":"itemId_1tree_2"},{"name":"F066008"},{"tId":"itemId_1tree_3"},{"name":"F066003"}];
6654             // value = [{"name":"F066008"},{"name":"F066003"}];
6655             // value = [{"name":"F066008"},{"name":"F066003"}];
6656
6657             if (customItems[item].type == 'subform') {
6658                 $(".customShow").find("#" + id + "subform").find("td").addClass("");
6659             } else if (customItems[item].type == 'htmlediter') {
6660                 // var htmlediterShow = $(".customShow").find("#"+id)[0];
6661                 var htmlediterShow = $(".customShow #" + id + "Item")[0];
6662                 // var heightShow = $(htmlediterShow)[0].getAttribute("heightShow");
6663                 // var widthShow = $(htmlediterShow)[0].getAttribute("widthShow");
6664                 var heightShow = customShow.options.customItemShow.item[id].tag_Attribute.height;
6665                 var widthShow = customShow.options.customItemShow.item[id].tag_Attribute.width;
6666                 if (widthShow == undefined || heightShow == undefined) {
6667                     widthShow = 200;
6668                     heightShow = 200;
6669                 }
6670                 var oNode = '<div style="word-break:break-all;width:' + widthShow + 'px;height:' +
6671                     heightShow + 'px;" class="customShowItemClass edui-default customShowItemClassTemp">';
6672                 // var oNode ='<div style="word-break:break-all;border-width: 1px;border-style: solid;border-color: rgb(204, 204, 204);class="customShowItemClass edui-default">';
6673                 oNode += value;
6674                 oNode += "</div>";
6675                 $($(".customShow #" + id + "Item")[0]).after(oNode);
6676                 $($(".customShow #" + id + "Item")[0]).remove();
6677                 //标签数据设定
6678             } else if (customItems[item].type == 'textarea') {
6679                 var htmlediterShow = $(".customShow #" + id)[0];
6680                 var heightShow = customShow.options.customItemShow.item[id].tag_Attribute.height;
6681                 var widthShow = customShow.options.customItemShow.item[id].tag_Attribute.width;
6682                 if (widthShow == undefined || heightShow == undefined) {
6683                     widthShow = 300;
6684                     heightShow = 80;
6685                 }
6686                 var oNode = '<div style="word-break:break-all;border-width: 0px;border-style: solid;border-color: rgb(204, 204, 204);width:' + widthShow + 'px;height:' +
6687                     heightShow + 'px;" class="customShowItemClass edui-default customShowItemClassTemp">';
6688                 // var oNode ='<div style="word-break:break-all;border-width: 1px;border-style: solid;border-color: rgb(204, 204, 204);class="customShowItemClass edui-default">';
6689                 oNode += value;
6690                 oNode += "</div>";
6691                 $($(".customShow #" + id)[0]).after(oNode);
6692                 $($(".customShow #" + id)[0]).remove();
6693                 //标签数据设定
6694             } else if (customItems[item].type == 'number') {
6695                 var numberShowItems = $(".customShow #" + id);
6696                 for (var i = 0; i < numberShowItems.length; i++) {
6697                     numberShowItems[i].setAttribute("type", "text");
6698                 }
6699
6700                 //标签数据设定
6701             } else if (customItems[item].type == 'link') {
6702                 var htmlediterShow = $(".customShow").find("#" + id)[0];
6703                 // console.log($(htmlediterShow))
6704                 // $(htmlediterShow)[0].setAttribute("href","javascript:;");
6705                 $(htmlediterShow).css("font-size", "16px;");
6706                 //单选 多选按钮
6707             } else if (type == 'radio' || type == 'checkbox' || type == 'dropdownlist') {
6708
6709                 var oNode = '<div style="word-break:break-all;border-width: 0px;border-style: solid;border-color: rgb(204, 204, 204);width:200px;" class="customShowItemClassTemp customShowItemClass ' + id + '_showItem edui-default">';
6710                 oNode += "</div>";
6711                 // $($(".customShow").find("#"+id)[0]).after(oNode);
6712                 // $($(".customShow").find("#"+id)[0]).remove();
6713                 var showItem = $($(".customShow").find("#" + id));
6714                 console.log(showItem)
6715                 for (var i = 0; i < showItem.length; i++) {
6716                     $($(showItem[i])[0]).after(oNode);
6717                     $($(showItem[i])[0]).remove();
6718                 }
6719                 console.log(value)
6720                 //单选复选回显问题
6721                 customShow.setShowItem(id, type, value, true);
6722             }
6723             else if (customItems[item].type == 'tree') {
6724                 var oNode = '<div style="word-break:break-all;border-width: 0px;border-style: solid;border-color: rgb(204, 204, 204);width:200px;" class="customShowItemClass edui-default customShowItemClassTemp">';
6725                 // 2017 /11/7  李元杰  树的回显
6726                 //   var   treeShow = $('#customShow').find('div[type=tree]');
6727
6728                 //   if(value !=undefined && value !=""){
6729                 //       console.log(1);
6730                 //     if(typeof value == "string"){
6731                 //     //   value = $.parseJSON(value);
6732                 //     console.log(2);
6733                 //       value =[value];
6734                 //     }
6735                 //     // 2017/11/7  李元杰回显
6736                 //     if(value.length>0){
6737                 //        console.log(value);
6738                 //        for(var i =0;i<value.length;i++){
6739                 //            value[i]
6740                 //        }
6741
6742
6743                 //      console.log(value)
6744
6745                 //        if(typeof value[0] == "string"){
6746                 //            //console.log(value[0]);
6747                 //         //   value[0] = $.parseJSON(value[0]);
6748                 //        }
6749
6750                 //       oNode +=value[0];
6751                 //     }
6752                 //     for (var i = 1; i < value.length; i++) {
6753                 //         console.log(4);
6754                 //       if(typeof value[i] == "string"){
6755                 //         console.log(5);
6756                 //         //   value[i] = $.parseJSON(value[i]);
6757                 //        }
6758                 //        console.log(value)
6759                 //       oNode +=" , "+value[i];
6760                 //       console.log(oNode)
6761                 //     };
6762                 //   }
6763                 //   console.log(oNode)
6764
6765                 //   oNode +="</div>";
6766                 "</div>";
6767                 $($(".customShow").find("#" + id)[0]).after(oNode);
6768                 $($(".customShow").find("#" + id)[0]).remove();
6769                 //              customShow.setShowItem(id, type, value, true);
6770                 console.log($($(".customShow").find("#" + id)[0]))
6771             }
6772             else if (customItems[item].type == 'amount') {
6773                 var id = id + "amount";
6774                 customBase.setItemValue(id, 'text', items[item], 'customShow');
6775                 $("#" + id).blur();
6776
6777             } else if (customItems[item].type == 'qrcode') {
6778                 var id = id + "qrcode";
6779                 customBase.setItemValue(id, 'text', items[item], 'customShow');
6780                 $("#" + id).blur();
6781             } else if (customItems[item].type == 'barcode') {
6782                 var id = id + "barcode";
6783                 customBase.setItemValue(id, 'text', items[item], 'customShow');
6784                 $("#" + id).blur()
6785             } else if (customItems[item].type == 'fileupload') {
6786                 // var $wrap = $(".customShow #" + customItems[item].id);
6787                 var $uploaderItem = $($(".customShow #" + customItems[item].id)[0]);
6788                 $uploaderItem.empty();
6789                 var $uploadimg = $(
6790                     '<div >' +
6791                     '<div id="fileList" class="uploader-list"></div>' +
6792                     '</div>'
6793                 );
6794                 var $list = $uploadimg.find("#fileList");
6795                 if (typeof value != "string") {
6796                     if (_.isArray(value)) {
6797                         // airport = JSON.parse(airport)
6798                         value = value.join(",")
6799                         var value = JSON.parse(value);
6800
6801                     }
6802                     for (i in value) {
6803                         var $li = $(
6804                             '<div class="">' +
6805                             // '<div class="info"><a href="' + value[i].path + '" >' + value[i].oldName + '</a></div>' +
6806                             // '<div class="info info-box"><div class="info_box">' + value[i].oldName +
6807                             // '<span class="x_box" style="display:none;">×</span>' +
6808                             // '<img class="img_box" style="display:none;" src="' + value[i].path + '">' +
6809
6810                             '<div><a href="' + value[i].path + '" >' + value[i].oldName + '</a></div>' +
6811                             '</div>'
6812                         );
6813                         $li.appendTo($list);
6814                     };
6815                 }
6816                 $uploadimg.appendTo($uploaderItem);
6817                 //2017-12-17 马习同修改 图片
6818                 // $(".info_box").on("click", function () {
6819                 //     $(".x_box").show();
6820                 //     $(".img_box").show();
6821                 //     $(".x_box").unbind();
6822                 //     $(".x_box").on("click", function () {
6823                 //         console.log(1);
6824                 //         $(".x_box").hide();
6825                 //         $(".img_box").hide();
6826                 //     })
6827                 // })
6828             } else if (customItems[item].type == 'image') {
6829                 // var $wrap = $(".customShow #" + customItems[item].id);
6830                 var $uploaderItem = $($(".customShow #" + customItems[item].id)[0]);
6831                 console.log($('#' + customItems[item].id));
6832                 console.log($uploaderItem)
6833                 $uploaderItem.empty();
6834
6835                 var $uploadimg = $(
6836                     '<div >' +
6837                     '<div id ="fileList" class="uploader-list"></div>' +
6838                     '</div>'
6839                 );
6840                 // var $list = $uploadimg.find("#"+potion.id+"fileList");
6841                 console.log(value)
6842                 
6843                 if (_.isArray(value)) {
6844                         // airport = JSON.parse(airport)
6845                     value = value.join(",")
6846                   var value = JSON.parse(value);
6847                 
6848                 }
6849                 console.log(value)
6850                 if (typeof value != "string") {
6851                     if (typeof value == "string") {
6852                         //   value = $.parseJSON(value);
6853                     }
6854                     for (i in value) {
6855                         var $list = $uploadimg.find("#fileList");
6856                         var $addLi = $(
6857                             '<div class="file-item thumbnail">' +
6858                             '<img  src="' + value[i].base64 + '">' +
6859                             '</div>'
6860                         );
6861
6862                         $list.prepend($addLi);
6863                     }
6864                 }
6865                 //  12/18 放大图片
6866
6867                 $uploaderItem.append($uploadimg);
6868                 var particularId = $uploaderItem.attr('id') + '_1'
6869                 $uploaderItem.children().attr('id', particularId);
6870                 // var particularId =  $uploaderItem.find('#uploaderItem').attr('id')
6871                 // 详情页
6872                 var viewer = new Viewer(document.getElementById(particularId), {
6873                     url: 'data-original',
6874                     
6875                 });
6876                 var imgId = $uploaderItem.attr('id');
6877                 var srcUrl = $uploaderItem.find('img').attr('src');
6878                 $uploaderItem.find('img').attr('alt', ' ');
6879                 // itemId_32uploadimg
6880
6881                 // 编辑页
6882                 // console.log($('#customViewUEditor').find('#'+imgId).children())
6883                 // console.log($('#'+imgId))
6884                 // console.log($uploaderItem)
6885                 // var viewer = new Viewer(document.getElementById(imgId), {
6886                 //     url: 'data-original',
6887                 //     show:function(){
6888                 //         console.log('显示')
6889                 //     }
6890                 // });
6891                 // 12/18
6892
6893
6894             } else if (customItems[item].type == 'mytext') {
6895                 //选择表单编辑回显
6896                 console.log(customItems);
6897                 console.log(customShow);
6898                 var itemAttribute = customShow.options.customItemShow.item[customItems[item].id];
6899                 var $mytext = $("#" + customItems[item].id);
6900                 var item_title = [];
6901                 var itemVal = [];
6902                 if (itemAttribute.tag_Attribute.relevancesourcetype == "fundata") {// 关联数据回显渲染 李伟民 11-30
6903                     var titleObj = { "key": JSON.parse(itemAttribute.tag_Attribute.fundata)["key"] };
6904                     var dataObj = {
6905                         "formID": customShow.options.formid,
6906                         "tenantID": "001",
6907                         "search": [],
6908                         "pageSize": "1000",
6909                         "pageNum": "1",
6910                         "key": JSON.parse(itemAttribute.tag_Attribute.fundata)["key"],
6911                         "formData": {},
6912                         "dataRowNum": items[item]
6913                     };
6914                     var requesTitle = window.commonAjax("/datamanagement/getAssociateTitle", titleObj, "POST", true, false);
6915                     var requesData = window.commonAjax("/datamanagement/getAssociateData", dataObj, "POST", true, false);
6916                     requesTitle.done(function (res) {
6917                         console.log(res);
6918                         item_title = res.data;
6919                     });
6920                     requesData.done(function (res) {
6921                         console.log(res);
6922                         if (!_.isNull(res.data) && res.data != undefined) {
6923                             itemVal = res.data;
6924                         }
6925                     });
6926                 } else {
6927                     var myTitle = JSON.parse(window.localStorage.getItem("title"));
6928                     item_title = myTitle[item];
6929                     itemVal = items[item];
6930                 }
6931                 console.log(itemVal)
6932                 console.log(item_title);
6933                 console.log(itemVal.list);
6934                 createMxtTable(customItems[item].id, item_title, itemVal.list);// 关联数据回显渲染 李伟民 11-30
6935                 //                            var newData = [];
6936                 //                            _.each(itemVal.list,function(opt){
6937                 //                                opt = _.mapKeys(opt,function(value,key){
6938                 //                                    _.each(item_title,function(item){
6939                 //                                        if(key == item.fieldKey){
6940                 //                                            key = item.title;
6941                 //                                        }
6942                 //                                    })
6943                 //                                    return key;
6944                 //                                })
6945                 //                                console.log(_.cloneDeep(opt))
6946                 //                                newData.push(opt);
6947                 //                            })
6948                 //                            console.log(itemVal.list);
6949                 //                            console.log(newData);
6950                 var formhuixian = itemVal.list;
6951
6952                 //console.log(formhuixian);
6953                 var huixianStr = "";
6954                 for (let i in formhuixian) {
6955                     //console.log($mytext.attr("fieldkey"));
6956                     //console.log(i);
6957                     //console.log(formhuixian[i]);
6958                     if (i = $mytext.attr("fieldkey")) {
6959                         huixianStr = formhuixian[i];
6960                     }
6961                 }
6962                 //console.log(huixianStr);
6963                 $mytext.attr("formhuixian", JSON.stringify(itemVal.list));
6964                 //                     if(newData){
6965                 //                         var $value = newData;
6966                 //                         console.log($value)
6967                 //
6968                 //                                    var show = "";
6969                 //                                    var divBox = $("<div></div>");
6970                 //                                    divBox.attr('id',customItems[item].id+'divBox');
6971                 //                                    var sdata_head = "";
6972                 //                                    _.each($value,(opt,j)=>{
6973                 //                                        var ulBox = $("<ul></ul>");
6974                 //                                        for(let i in opt){
6975                 //                                            show = "";
6976                 //                                            sdata_head = '<td class="data1 '+i+'">'+i+'</td>';
6977                 //                                        show += '<li>'+'<span class="data1 '+i+'">'+i+'</span>'+'<span class="data2 '+i+'">'+opt[i]+'</span>'+'</li>';
6978                 //                                        ulBox.attr("class","addUl ulBox"+j);
6979                 //                                        ulBox.attr("id","ulBox"+j);
6980                 //                                        //console.log(show)
6981                 //                                        ulBox.append(show);
6982                 //                                        }
6983                 //                                        divBox.append(ulBox);
6984                 //                                    });
6985                 //                                    console.log(sdata_head);
6986                 //                          $mytext.append(divBox);
6987                 //                      }
6988             }
6989             if (type == 'radio' || type == 'checkbox' || type == 'dropdownlist' || type == 'tree' ||
6990                 type == 'amount' || type == 'barcode' || type == 'qrcode' || type == 'image' ||
6991                 type == 'button' || type == 'fileupload'
6992                 || type == 'subform' || type == 'link'
6993                 || type == 'splitline' || type == 'link'
6994                 || type == 'textarea'
6995             ) {
6996
6997             } else {
6998                 //值设定
6999                 customBase.setItemValue(id, type, value, 'customShow');
7000             }
7001
7002         }
7003     };
7004 }
7005
7006 //画面表示项目取得  -----------------
7007 customShow.getItems = function (saveflag) {
7008     var items = customBase.options.customItems;
7009     console.log(items);
7010     var itemTempS = {};
7011     for (item in items) {
7012         if (items.hasOwnProperty(item)) {
7013             console.log(item);
7014             console.log(items[item].type);
7015             if (items[item].type == "button" || items[item].type == "link") {
7016             } else if (items[item].type == "dropdownlist") {
7017                 // var datasourcetype = $("#"+items[item].id)[0].getAttribute("datasourcetype");
7018                 //  //主数据源
7019                 // if(datasourcetype == "masterdata"){
7020                 //   itemTempS[item] = customBase.getItemValue(items[item].id,"dropdownlistText");
7021                 //   //数据源
7022                 // }else if(datasourcetype == "datasource"){
7023                 //   itemTempS[item] = customBase.getItemValue(items[item].id,"dropdownlistText");
7024                 //   //自定义
7025                 // }else if(datasourcetype == "custom"){
7026                 //   itemTempS[item] = customBase.getItemValue(items[item].id,"dropdownlistText");
7027                 //   //API接口
7028                 // }else if(datasourcetype == "api"){
7029                 //   itemTempS[item] = customBase.getItemValue(items[item].id,"dropdownlistText");
7030                 // }
7031                 itemTempS[item] = customBase.getItemValue(items[item].id, "dropdownlistText");
7032                 console.log(itemTempS[item])
7033                 if (saveflag) {//下拉框 传值 修改  李伟民  11-09
7034                     console.log(itemTempS[item]);
7035                     _.each(itemTempS[item], function (sval, i) {
7036                         if (_.isArray(sval)) {
7037                             itemTempS[item][i] = sval.join();
7038                         }
7039                     })
7040                     //            if(_.isArray(itemTempS[item][0])){
7041                     //                  itemTempS[item][0] = itemTempS[item][0].join(",")
7042                     //              }
7043                     console.log(itemTempS[item]);
7044                 }//下拉框 传值 修改  李伟民  11-09
7045             } else if (items[item].type == "tree") {
7046                 itemTempS[item] = customBase.getItemValue(items[item].id, "tree");
7047                 console.log(itemTempS[item])
7048                 if (saveflag) {//树形传值 修改  李元杰  11-21
7049                     console.log(itemTempS[item]);
7050                     _.each(itemTempS[item], function (sval, i) {
7051                         if (_.isArray(sval)) {
7052                             itemTempS[item][i] = sval.join();
7053                         }
7054                     })
7055                     //            if(_.isArray(itemTempS[item][0])){
7056                     //                  itemTempS[item][0] = itemTempS[item][0].join(",")
7057                     //              }
7058                 }//树形 传值 修改  李元杰  11-21
7059             } else if (items[item].type == "checkbox") {
7060                 itemTempS[item] = customBase.getItemValue(items[item].id, "checkbox");
7061                 console.log(itemTempS[item])
7062                 console.log(saveflag)
7063                 if (saveflag) {//复选框传值 修改  马习同  12-6
7064                     console.log(itemTempS[item]);
7065                     _.each(itemTempS[item], function (sval, i) {
7066                         if (_.isArray(sval)) {
7067                             itemTempS[item][i] = sval.join();
7068                         }
7069                     })
7070                     //            if(_.isArray(itemTempS[item][0])){
7071                     //                  itemTempS[item][0] = itemTempS[item][0].join(",")
7072                     //              }
7073                 }////复选框传值 修改  马习同  12-6
7074             } else if (items[item].type == "radio") {
7075                 itemTempS[item] = customBase.getItemValue(items[item].id, "radio");
7076                 console.log(itemTempS[item])
7077                 console.log(saveflag)
7078                 if (saveflag) {//复选框传值 修改  马习同  12-6
7079                     console.log(itemTempS[item]);
7080                     _.each(itemTempS[item], function (sval, i) {
7081                         if (_.isArray(sval)) {
7082                             itemTempS[item][i] = sval.join();
7083                         }
7084                     })
7085                     //            if(_.isArray(itemTempS[item][0])){
7086                     //                  itemTempS[item][0] = itemTempS[item][0].join(",")
7087                     //              }
7088                 }////复选框传值 修改  马习同  12-6
7089             } else if (items[item].type == "subform" || items[item].type == "tag" || items[item].type == "tab") {
7090
7091             } else if (items[item].type == "auto") {
7092                 var str = window.localStorage.getItem("customItem");
7093                 var prefix = (str != undefined && str != "undefined") ? JSON.parse(str) : null;
7094                 if (prefix != null && (prefix[item] != null || prefix[item] != undefined)) {
7095                     itemTempS[item] = prefix[item];
7096                 } else {
7097                     itemTempS[item] = customBase.getItemValue(items[item].id, items[item].type);
7098                 }
7099             } else {
7100                 itemTempS[item] = customBase.getItemValue(items[item].id, items[item].type);
7101                 console.log(itemTempS[item]);
7102             }
7103         }
7104     };
7105     var itemRetuen = {};
7106
7107     //子表单数据变换
7108     for (item in customBase.options.customItems) {
7109         if (customBase.options.customItems.hasOwnProperty(item)) {
7110             if (customBase.options.customItems[item].type == "subform" || customBase.options.customItems[item].type == "tag" || customBase.options.customItems[item].type == "tab") {
7111                 var id = customBase.options.customItems[item].id.replace("itemId_", "");
7112                 itemRetuen[id] = {};
7113             }
7114         }
7115     }
7116     console.log(_.cloneDeep(itemRetuen));
7117     console.log(_.cloneDeep(itemTempS));
7118     //子表单内数据保存
7119     for (item in itemTempS) {
7120         ////console.log(items);
7121         ////console.log(itemTempS);
7122         ////console.log(item);
7123         if (itemTempS.hasOwnProperty(item)) {
7124             var parentsubFormNum = customBase.options.customItems[item].parentsubFormNum;
7125             ////console.log(customBase.options)
7126             ////console.log(customBase.options.customItems[item]);
7127             ////console.log(parentsubFormNum);
7128             if (parentsubFormNum == "0") {
7129                 if (customBase.options.customItems[item].type == "radio" ||
7130                     customBase.options.customItems[item].type == "checkbox" ||
7131                     customBase.options.customItems[item].type == "dropdownlist" ||
7132                     customBase.options.customItems[item].type == "tree"
7133                 ) {
7134                     itemRetuen[item] = itemTempS[item][0];
7135                 } else {
7136                     itemRetuen[item] = itemTempS[item];
7137                 }
7138             } else {
7139                 ////console.log(item);
7140                 ////console.log(items);
7141                 ////console.log(itemRetuen[parentsubFormNum]);
7142                 ////console.log(itemTempS[item]);
7143                 ////console.log(itemRetuen);
7144                 ////console.log(parentsubFormNum);
7145                 itemRetuen[parentsubFormNum][item] = itemTempS[item];
7146             }
7147         }
7148     }
7149     //子表单内最终数据变换
7150     console.log(_.cloneDeep(itemRetuen));
7151     console.log(customBase.options.customItems);
7152     for (item in customBase.options.customItems) {
7153         if (customBase.options.customItems.hasOwnProperty(item)) {
7154             if (customBase.options.customItems[item].type == "subform" || customBase.options.customItems[item].type == "tag" || customBase.options.customItems[item].type == "tab") {
7155                 var id = customBase.options.customItems[item].id.replace("itemId_", "");
7156                 var tepItem = itemRetuen[id];
7157                 var subformIten = [];
7158                 var i = 0;
7159                 console.log(tepItem);
7160                 for (tem in tepItem) {
7161                     if (tepItem.hasOwnProperty(tem)) {
7162                         if (typeof tepItem[tem] == "string") {
7163                             if (subformIten[0] == undefined) {
7164                                 subformIten[0] = {};
7165                             }
7166                             subformIten[0][tem] = tepItem[tem];
7167                         } else {
7168                             console.log(tepItem[tem]);
7169                             for (var i = 0; i < tepItem[tem].length; i++) {
7170                                 if (subformIten[i] == undefined) {
7171                                     subformIten[i] = {};
7172                                 }
7173                                 subformIten[i][tem] = tepItem[tem][i];
7174                             }
7175                         }
7176                     }
7177                 }
7178                 delete itemRetuen[id];
7179                 console.log(_.cloneDeep(subformIten));
7180                 itemRetuen[customBase.options.customItems[item].fieldKey] = subformIten;
7181             }
7182         }
7183     }
7184     console.log(_.cloneDeep(itemRetuen));
7185     return itemRetuen;
7186 }
7187
7188 //取消事件
7189 customShow.onclickCancel = function () {
7190     // var items = customShow.getItems();
7191     //检证执行
7192     var saveReturn = customShow.initEvent.cancelEventLinkage();
7193     if (!saveReturn) {
7194         return;
7195     }
7196
7197     //取消接口(第三方提供)
7198     var saveReturn = customShow.initEvent.cancelEvent3rd();//--------------------
7199     if (saveReturn) {
7200         // 取消接口
7201         customShow.initEvent.cancelEvent();//--------------------
7202     }
7203     if (customShow.options.customShowFlag == "3") {
7204         // window.close();
7205         window.location.href = "about:blank";
7206         window.close();
7207     } else if (customShow.options.customShowFlag == "0" || customShow.options.customShowFlag == "1" || customShow.options.customShowFlag == "2") {
7208         window.parent.$('#myModal').modal('hide');
7209         if (customShow.options.breakFlag) {
7210             window.parent.addFormData();
7211         }
7212         if (customShow.options.customShowFlag == "1" || customShow.options.customShowFlag == "2") {
7213             $(window.parent.document.body).css({ "overflow-x": "auto", "overflow-y": "auto" });
7214         }
7215         window.parent.$("#myFormDesign").css("display", "");
7216         window.parent.$(".htmlediterClass").css("display", "");
7217     }
7218 }
7219
7220 //印刷事件  打印
7221 customShow.onPrint = function () {
7222     var items = customShow.getItems();
7223     var interfacep = customShow.initEvent.interfaceprint3rd(items);
7224     if (!interfacep) {
7225         return;
7226     }
7227     var removePrintArea = function (id) {
7228         $("iframe#" + id).remove();
7229     };
7230     var customShowFlag = window.localStorage.getItem("customShowFlag");
7231     if (customShowFlag == "0") {
7232         var itemOnPrint = $("#customViewUEditor")[0].cloneNode(true);
7233         $(itemOnPrint).css("overflow", 'visible');
7234         $(itemOnPrint).printArea();
7235     }else{
7236         var itemOnPrint = $("#customShow")[0].cloneNode(true);
7237         $(itemOnPrint).css("overflow", 'visible');
7238         $(itemOnPrint).printArea();
7239     }
7240 }
7241
7242 //编辑按钮按下时
7243 customShow.onEditor = function () {
7244     // $(".preview-edit-pane").css("display", "none");
7245     window.localStorage.setItem("customShowFlag", 3);
7246     var formIDs = customlocalStorage.newFormID;
7247
7248     customDataBound.formsetting(formIDs, function () { });
7249     //console.log("编辑存值");
7250     $("#customShow").empty();
7251     if (customShow.options.customShowFlag != "3") {
7252         //图片文件上传
7253         var uploaderImage = $(".customViewUEditorCss .uploaderImage");
7254         for (var i = 0; i < uploaderImage.length; i++) {
7255             $("#" + uploaderImage[i].id).find('.imgfileLiShow').remove();
7256             var imageItem = customShow.options.customItemShow.item[uploaderImage[i].id];
7257             var itemList = customBase.options.uploaderItemReady[uploaderImage[i].id];
7258             if (customShow.options.customShowFlag == "3") {
7259
7260             }
7261             // 参数设定
7262             var potion = {
7263                 id: uploaderImage[i].id,
7264                 width: imageItem.tag_Attribute.width,
7265                 height: imageItem.tag_Attribute.height,
7266                 formid: customShow.options.formid,
7267                 imagetype: imageItem.tag_Attribute.dropdowntype, //图片类型
7268                 editable: imageItem.tag_Attribute.editable, //是否可编辑
7269                 defaultvalueUrl: imageItem.tag_Attribute.defaultvalue, //默认的Url
7270                 ItemReady: itemList
7271             }
7272             //  12/18
7273             customBase.uploaderShow(potion);
7274
7275             // customBase.uploaderShow("#"+uploaderImage[i].id,{width:0,height:200},true,customShow.options.formid);
7276
7277         };
7278
7279         //文本文件上传
7280         var uploaderFile = $(".customViewUEditorCss .uploaderFile");
7281
7282         for (var i = 0; i < uploaderFile.length; i++) {
7283             $("#" + uploaderFile[i].id + "  .filelist").empty();
7284
7285             var imageItem = customShow.options.customItemShow.item[uploaderFile[i].id];
7286             var itemList = customBase.options.uploaderItemReady[uploaderFile[i].id];
7287             // 参数设定
7288             var potion = {
7289                 id: uploaderFile[i].id,
7290                 width: imageItem.tag_Attribute.width,
7291                 height: imageItem.tag_Attribute.height,
7292                 formid: customShow.options.formid,
7293                 imagetype: imageItem.tag_Attribute.dropdowntype, //图片类型
7294                 editable: imageItem.tag_Attribute.editable, //是否可编辑
7295                 defaultvalueUrl: imageItem.tag_Attribute.defaultvalue, //默认的Url
7296                 ItemReady: itemList
7297             }
7298             customBase.uploaderFileShow(potion);
7299             // customBase.uploaderShow_Temp("#"+uploaderFile[i].id,{width:0,height:200},false,customShow.options.formid);
7300         };
7301     }
7302     $("#customViewUEditor")[0].style.display = "block";
7303     $("#customShow")[0].style.display = "none";
7304     $("#customShow").css("display", "none");
7305     $("#customShow").removeClass("fui-form");
7306     // $(".footer")[0].style.display ="block";
7307     // $(".preview-edit-pane")[0].style.display ="none";
7308     // $(".footer .fromSaveCss")[0].style.display ="block";
7309
7310     var btns = [
7311         // 'printableBtn',
7312         //12/23'exportBtn',
7313         //12/23 'rejectBtn',
7314         // 12/23 'submitBtn',
7315         //12 /23 'auditableBtn',
7316         // 12/23 'queryBtn',
7317         // 'createBtn',
7318         // 'clearBtn',
7319         //  12/23 'disposableBtn',
7320         // 'fromSaveBtn',
7321         // 'editableBtn'
7322     ];
7323     customShow.setToolBtn(btns);
7324
7325     customShow.setXhSelectList();
7326     //子表单事件调用
7327     customShow.clickBindSubform();
7328     //2017/11/18  马习同修改 隐藏预览模式下  导入数据按钮
7329     $(".sonImportFile").removeClass("cfg_contentNone");
7330     //s_savebtn
7331     $(".s_savebtn").show();
7332     // $(".preview-edit-pane").css("display", "none");
7333     //12/23
7334     // $('#disposableBtn').css('display','none');
7335     // $('#clearBtn').css('display','none');
7336     // $('#queryBtn').css('display','none');
7337     // $('#auditableBtn').css('display','none');
7338     // $('#submitBtn').css('display','none');
7339     // $('#rejectBtn').css('display','none');
7340
7341 }
7342
7343 //画面验证
7344 customShow.onfromCheck = function (items) {
7345     if ($(".errorCheckCss").length > 0) {
7346         return true;
7347     }
7348     if($(".checkErr") > 0){
7349         return true;
7350     }
7351     $(".errorItemCss").removeClass("errorItemCss");
7352     $(".mesageErrDiv").remove();
7353     for (var id in customShow.options.showErrId) {
7354         $($(".customViewUEditorCss  #" + id)[customShow.options.showErrId[id]]).popover('hide');
7355     }
7356
7357     //必须入力验证
7358     mustcheckExe = function (tag_Type, value, ItemId, N) {
7359         if (tag_Type == "text" || tag_Type == "textarea" ||
7360             tag_Type == "number" || tag_Type == "htmlediter" || tag_Type == "fileupload" ||
7361             tag_Type == "calendar") {
7362             if (tag_Type == "fileupload") {
7363                 var count = 0;
7364                 for (var key in value) {
7365                     count++;
7366                 }
7367                 if (count == 0) {
7368                     value = "";
7369                 }
7370
7371             }
7372             if (value == "") {
7373                 customShow.showErrorItem(tag_Type, ItemId, N);
7374                 var message = customBase.getMessage("mesage_ID004");
7375                 customShow.setShowMesageErr(ItemId, message, N);
7376                 mustcheck = true;
7377             }
7378         } else if (tag_Type == "checkbox" || tag_Type == "dropdownlist") {
7379             // //////////console.log(value);
7380             if (value.length == 0) {
7381                 customShow.showErrorItem(tag_Type, ItemId, N);
7382                 var message = customBase.getMessage("mesage_ID004");
7383                 customShow.setShowMesageErr(ItemId, message, N);
7384                 mustcheck = true;
7385             }
7386         }
7387     }
7388
7389     //数值型验证
7390     numberFormatCheck = function (numbertype, value, ItemId, N) {
7391         if (numbertype == "integer") {
7392             if (value.indexOf(".") > -1) {
7393                 var message = customBase.getMessage("mesage_ID019");
7394                 customShow.showErrorItem("number", ItemId, N);
7395                 customShow.setShowMesageErr(ItemId, message, N);
7396                 mustcheck = true;
7397             } else {
7398                 var numberMaxlength = customShow.options.customItemShow.item[ItemId].tag_Attribute.maxlength;
7399                 numberMaxlength = parseInt(numberMaxlength);
7400                 if (value.length > numberMaxlength && numberMaxlength != 0) {
7401                     customShow.showErrorItem("number", ItemId, N);
7402                     var message = customBase.getMessage("mesage_ID020");
7403                     customShow.setShowMesageErr(ItemId, message, N);
7404                     mustcheck = true;
7405                 }
7406             }
7407         } else {
7408             var integerItem;
7409             integerItem = value.split(".");
7410             //整数长度
7411             // var aa = customShow.options.customItemShow.item[subformItemId].tag_Attribute.alias;
7412             var numberMaxlength = customShow.options.customItemShow.item[ItemId].tag_Attribute.maxlength;
7413             numberMaxlength = parseInt(numberMaxlength);
7414             var numberdecimalplace = customShow.options.customItemShow.item[ItemId].tag_Attribute.decimalplace;
7415             numberdecimalplace = parseInt(numberdecimalplace);
7416             if (integerItem[0].length > numberMaxlength && numberMaxlength != 0) {
7417                 customShow.showErrorItem("number", ItemId, N);
7418                 var message = customBase.getMessage("mesage_ID020");
7419                 customShow.setShowMesageErr(ItemId, message, N);
7420                 mustcheck = true;
7421             }
7422             if (integerItem[2] != undefined && integerItem[1].length > numberdecimalplace) {
7423                 customShow.showErrorItem("number", ItemId, N);
7424                 var message = customBase.getMessage("mesage_ID021");
7425                 customShow.setShowMesageErr(ItemId, message, N);
7426                 mustcheck = true;
7427             }
7428             ////////console.log(customShow.options.customItemShow.item[ItemId].tag_Attribute);
7429         }
7430     }
7431
7432     //文本格式验证
7433     maxlengthCheck = function (maxlength, value, ItemId, N) {
7434         if (value.length > maxlength && maxlength != 0) {
7435             customShow.showErrorItem("htmlediter", ItemId, N);
7436             var message = customBase.getMessage("mesage_ID023");
7437             customShow.setShowMesageErr(ItemId, message, N);
7438             mustcheck = true;
7439         }
7440     }
7441     //文本格式验证
7442     textFormatCheck = function (format, value, ItemId, N) {
7443         if (value == "") {
7444             return;
7445         } else if (format == "phone") {
7446             //手机号
7447             var p1 = /^1[3|4|5|7|8][0-9]{9}$/;
7448             var me = false;
7449             if (!p1.test(value)) {
7450                 customShow.showErrorItem("text", ItemId, N);
7451                 var message = customBase.getMessage("mesage_ID009");
7452                 customShow.setShowMesageErr(ItemId, message, N);
7453                 mustcheck = true;
7454             }
7455         } else if (format == "url") {
7456             //网址
7457             var strRegex = "^((https|http|ftp|rtsp|mms)?://)"
7458                 + "?(([0-9a-z_!~*'().&=+$%-]+: )?[0-9a-z_!~*'().&=+$%-]+@)?" //ftp的user@
7459                 + "(([0-9]{1,3}\.){3}[0-9]{1,3}" // IP形式的URL- 199.194.52.184
7460                 + "|" // 允许IP和DOMAIN(域名)
7461                 + "([0-9a-z_!~*'()-]+\.)*" // 域名- www.
7462                 + "([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\." // 二级域名
7463                 + "[a-z]{2,6})" // first level domain- .com or .museum
7464                 + "(:[0-9]{1,4})?" // 端口- :80
7465                 + "((/?)|" // a slash isn't required if there is no file name
7466                 + "(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)$";
7467             var re = new RegExp(strRegex);
7468             if (!re.test(value)) {
7469                 customShow.showErrorItem("text", ItemId, N);
7470                 var message = customBase.getMessage("mesage_ID010");
7471                 customShow.setShowMesageErr(ItemId, message, N);
7472                 mustcheck = true;
7473             }
7474         } else if (format == "cardno") {
7475             //身份证
7476             var p1 = /^\d{6}(18|19|20)?\d{2}(0[1-9]|1[12])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i;
7477             if (!p1.test(value)) {
7478                 customShow.showErrorItem("text", ItemId, N);
7479                 var message = customBase.getMessage("mesage_ID011");
7480                 customShow.setShowMesageErr(ItemId, message, N);
7481                 mustcheck = true;
7482             }
7483         } else if (format == "email") {
7484             //邮箱
7485             var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
7486             if (!myreg.test(value)) {
7487                 customShow.showErrorItem("text", ItemId, N);
7488                 var message = customBase.getMessage("mesage_ID012");
7489                 customShow.setShowMesageErr(ItemId, message, N);
7490                 mustcheck = true;
7491             }
7492         }
7493     }
7494     var customItems = customBase.options.customItems;
7495     //必须入力验证
7496     var mustcheck = false;
7497     for (fieldKey in customItems) {
7498
7499         if (customItems.hasOwnProperty(fieldKey)) {
7500             ////console.log(customItems);
7501             var tag_Type = customItems[fieldKey].type;
7502             var ItemId = customItems[fieldKey].id;
7503             if (customItems[fieldKey].visible) {
7504                 if (customItems[fieldKey].mustcheck) {
7505                     var value = items[fieldKey];
7506                     //子表单的情况
7507                     if (value == undefined) {
7508
7509                         //取得对应子表单ID
7510                         var subformItemId = "itemId_" + customItems[fieldKey].parentsubFormNum;
7511                         if (customShow.options.customItemShow.item[subformItemId] != undefined) {
7512                             var subformItemAlias = customShow.options.customItemShow.item[subformItemId].tag_Attribute.alias;
7513                             var subformItem = items[subformItemAlias];
7514                             for (var i = 0; i < subformItem.length; i++) {
7515                                 mustcheckExe(tag_Type, subformItem[i][fieldKey], ItemId, i);
7516                             }
7517                         }
7518                     } else {
7519                         mustcheckExe(tag_Type, value, ItemId, 0);
7520                     }
7521                 }
7522                 //文本格式验证
7523                 if (customItems[fieldKey].type == "text") {
7524                     var value = items[fieldKey];
7525                     ////console.log(fieldKey);
7526                     ////console.log(customItems);
7527                     ////console.log(value);
7528                     var format = customShow.options.customItemShow.item[ItemId].tag_Attribute.format;
7529                     //子表单的情况
7530                     if (value == undefined) {
7531                         //取得对应子表单ID
7532                         var subformItemId = "itemId_" + customItems[fieldKey].parentsubFormNum;
7533                         var subformItemAlias = customShow.options.customItemShow.item[subformItemId].tag_Attribute.alias;
7534                         var subformItem = items[subformItemAlias];
7535                         ////console.log(items);
7536                         ////console.log(subformItemAlias);
7537                         ////console.log(subformItem);
7538                         for (var i = 0; i < subformItem.length; i++) {
7539                             textFormatCheck(format, subformItem[i][fieldKey], ItemId, i);
7540                         }
7541                     } else {
7542                         textFormatCheck(format, value, ItemId, 0);
7543                     }
7544
7545                 }
7546                 //数值整数验证
7547                 if (customItems[fieldKey].type == "number") {
7548                     var value = items[fieldKey];
7549                     //数值格式
7550                     var numbertype = customShow.options.customItemShow.item[ItemId].tag_Attribute.numbertype;
7551                     //子表单的情况
7552                     if (value == undefined) {
7553                         //取得对应子表单ID
7554                         var subformItemId = "itemId_" + customItems[fieldKey].parentsubFormNum;
7555                         var subformItemAlias = customShow.options.customItemShow.item[subformItemId].tag_Attribute.alias;
7556                         var subformItem = items[subformItemAlias];
7557                         for (var i = 0; i < subformItem.length; i++) {
7558                             numberFormatCheck(numbertype, subformItem[i][fieldKey], ItemId, i);
7559                         }
7560                     } else {
7561                         numberFormatCheck(numbertype, value, ItemId, 0);
7562                     }
7563
7564                 }
7565
7566                 //默认长度检证
7567                 if (customItems[fieldKey].type == "htmlediter") {
7568                     var value = items[fieldKey];
7569                     //数值格式
7570                     var maxlength = customShow.options.customItemShow.item[ItemId].tag_Attribute.maxlength;
7571                     // //子表单的情况
7572                     // if(value ==undefined){
7573                     //   //取得对应子表单ID
7574                     //   var subformItemId = "itemId_"+customItems[fieldKey].parentsubFormNum;
7575                     //   var subformItemAlias = customShow.options.customItemShow.item[subformItemId].tag_Attribute.alias;
7576                     //   var subformItem = items[subformItemAlias];
7577                     //   for(var i=0;i<subformItem.length;i++){
7578                     //      numberFormatCheck(numbertype,subformItem[i][fieldKey],ItemId,i);
7579                     //   }
7580                     // }else{
7581                     maxlengthCheck(maxlength, value, ItemId, 0);
7582                     // }
7583
7584                 }
7585             }
7586         }
7587     }
7588     //焦点事件
7589     // $(".errorItemCss").unbind('focus');
7590     // $(".errorItemCss").on('focus', function() {
7591     //     $(this).removeClass("errorItemCss");
7592     //     ////////////console.log($(this)[0].id);
7593     //     $("#"+$(this)[0].id+"mesageErrDiv").remove();
7594     //     $(".customViewUEditorCss  #"+$(this)[0].id).popover('hide')
7595     // });
7596     // //下拉列表点击事件
7597     // $(".select2-search__field").unbind("focus");
7598     // $(".select2-search__field").bind("focus",function(){
7599     //   var id = this.getAttribute("errorItemId");
7600     //   var N = this.getAttribute("N");
7601     //   $($('.customViewUEditorCss #'+id)[N].parentNode).find(".select2").removeClass("errorItemCss");
7602     //   $("#"+id+"mesageErrDiv").remove();
7603     //   $($(".customViewUEditorCss  #"+id)[N]).popover('hide')
7604     // });
7605
7606     if (mustcheck) { return true; }
7607
7608     //单选按钮长度验证
7609
7610     //焦点事件
7611     // $(".errorItemCss").unbind();
7612     // $(".errorItemCss").on('focus', function() {
7613     //   $(this).removeClass("errorItemCss");
7614     // });
7615     return false;
7616 }
7617
7618 //检证验证
7619 customShow.interfaceCheck = function (items) {//保存前计算费用  李伟民   10 - 31
7620     var flag = true;
7621     _.each(customBase.interfaceData, function (intdata) {
7622         var func = intdata.customInterfacemethod + "()";
7623         var thisChheck = eval(func);
7624         console.log(thisChheck);
7625         if (thisChheck == false) {
7626             flag = false;
7627         }
7628     });
7629     return flag;
7630 }//保存前计算费用  李伟民   10 - 31
7631
7632 //错误信息
7633 customShow.showErrorItem = function (errorClass, tag_Type, id, N) {
7634     if (tag_Type == "text" || tag_Type == "textarea" || tag_Type == "number" || tag_Type == "calendar"
7635         || tag_Type == "checkbox") {
7636         $($(".customViewUEditorCss  #" + id)[N]).addClass(errorClass);
7637     } else if (tag_Type == "htmlediter") {
7638         // $(".customViewUEditorCss  #"+id+"Item").addClass(errorClass);
7639         UE.getEditor(id + "Item").body.setAttribute("class", errorClass);
7640         if (UE.getEditor(id + "Item").body.getAttribute("heightFlag") == "height") {
7641         } else {
7642             var height = UE.getEditor(id + "Item").body.style.height.replace("px", "");
7643             height = parseInt(height) - 12;
7644             UE.getEditor(id + "Item").body.style.height = height + "px";
7645             UE.getEditor(id + "Item").body.setAttribute("id", id);
7646         }
7647         UE.getEditor(id + "Item").body.setAttribute("heightFlag", height);
7648
7649         // //////////console.log(UE.getEditor(id+"Item").body.style.height = );
7650     } else if (tag_Type == "dropdownlist") {
7651         //  $(".customViewUEditorCss  #"+id).p + ".selection").addClass(errorClass);
7652         // //////////console.log($('.customViewUEditorCss #'+id)[0].parentNode);
7653         $($('.customViewUEditorCss #' + id)[N].parentNode).find(".select2").addClass(errorClass);
7654         //  $(".customViewUEditorCss  #"+id+" .select2-search__field")
7655         if ($($('.customViewUEditorCss #' + id)[N].parentNode).find(".select2-search__field").length > 0) {
7656             $($('.customViewUEditorCss #' + id)[N].parentNode).find(".select2-search__field")[0].setAttribute("errorItemId", id);
7657             $($('.customViewUEditorCss #' + id)[N].parentNode).find(".select2-search__field")[0].setAttribute("N", N);
7658         }
7659     }
7660 }
7661
7662 //画面属性设定(初始值 表示/非表示  只读 必须 审查必须)
7663 customShow.setShowAttribute = function (aliasItem) {
7664     console.log(aliasItem)
7665     //  12/7  不可编辑 可以编辑
7666     id = aliasItem.id;
7667     //表示非表示
7668     if (aliasItem.visible) {
7669         $(".customViewUEditorCss #" + id).removeClass("cfg_contentNone");
7670         $(".customViewUEditorCss #" + id + "ActiveId").removeClass("cfg_contentNone");
7671         $(".customViewUEditorCss ." + id + "IconShow").removeClass("cfg_contentNone");
7672         $(".customViewUEditorCss #" + id + "Item").removeClass("cfg_contentNone");
7673         if (customShow.options.customItemShow.customFlag == "1" && aliasItem.type == "dropdownlist") {
7674             $($(".customViewUEditorCss #" + id)[0].parentNode).removeClass("cfg_contentNone");
7675         }
7676     } else if (!aliasItem.visible) {
7677         $(".customViewUEditorCss #" + id).addClass("cfg_contentNone");
7678         $(".customViewUEditorCss #" + id + "ActiveId").addClass("cfg_contentNone");
7679         $(".customViewUEditorCss ." + id + "IconShow").addClass("cfg_contentNone");
7680         $(".customViewUEditorCss #" + id + "Item").addClass("cfg_contentNone");
7681         if (customShow.options.customItemShow.customFlag == "1" && aliasItem.type == "dropdownlist") {
7682             $($(".customViewUEditorCss #" + id)[0].parentNode).addClass("cfg_contentNone");
7683         }
7684     }
7685     //必须
7686     if (aliasItem.mustcheck) {
7687         $(".customViewUEditorCss ." + id + "IconShow .iconMustcheck").removeClass("cfg_contentNone");
7688     } else if (!aliasItem.mustcheck) {
7689         $(".customViewUEditorCss ." + id + "IconShow .iconMustcheck").addClass("cfg_contentNone");
7690     }
7691     //审查必须
7692     if (aliasItem.approvalmustenter) {
7693         $(".customViewUEditorCss ." + id + "IconShow .iconApprovalmustenter").removeClass("cfg_contentNone");
7694     } else if (!aliasItem.approvalmustenter) {
7695         $(".customViewUEditorCss ." + id + "IconShow .iconApprovalmustenter").addClass("cfg_contentNone");
7696     }
7697
7698     //编辑-非编辑
7699     var itemTemp = $($(".customViewUEditorCss #" + id)[0]);
7700     var tag_Type = aliasItem.type;
7701     if (aliasItem.editable) {
7702         if (tag_Type == "text" || tag_Type == "textarea" || tag_Type == "number" || tag_Type == "calendar") {//--OK
7703             itemTemp.removeAttr('readonly');
7704             //  非编辑情况移除背景颜色  12/7 李元杰
7705             for (var i = 0; i < itemTemp.length; i++) {
7706                 console.log(itemTemp[i]);
7707                 $(itemTemp[i]).removeClass('disableColor')
7708             }
7709             if (tag_Type == "calendar") {
7710                 var calendarItem = customShow.options.customItemShow.item[id];
7711                 // var editable = tag_Attribute['editable'];
7712                 var textformat = calendarItem.tag_Attribute.datatype;
7713                 if (textformat == 'Y') {
7714                     $(itemTemp).addClass('dateFromyyyy');
7715                 } else if (textformat == 'Y-m') {
7716                     $(itemTemp).addClass('dateFromyyyymm');
7717                 } else if (textformat == 'Y-m-d') {
7718                     $(itemTemp).addClass('dateFromyyyymmdd');
7719                 } else if (textformat == 'Y-m-d H:i') {
7720                     $(itemTemp).addClass('dateFromhhmiss');
7721                 }
7722                 customShow.clickBindSubform();
7723
7724             }
7725         } else if (tag_Type == "radio") {//----------------------------------------------------------
7726             itemTemp.find('.custom-radio').removeAttr("readonly");
7727         } else if (tag_Type == "radio") {//----------------------------------------------------------
7728             itemTemp.find('.custom-radio').removeAttr("readonly");
7729         } else if (tag_Type == "checkbox") {//-------------------------------------------------------
7730             itemTemp.find('.custom-check').removeAttr("readonly");
7731         } else if (tag_Type == "dropdownlist") {//---------------------------------------------------OK
7732             // $(itemTemp).removeClass('editableDisabled');
7733             // $(itemTemp).prop("disabled", false);        //设置下拉框不可用
7734             // $(itemTemp).find(".select-container").removeAttr("readonly");
7735             $(itemTemp).removeClass("disableColor");
7736
7737             $(itemTemp).removeClass("readonly");
7738             //          ////console.log($(itemTemp).find(".select-container"));
7739         } else if (tag_Type == "button") {//---------------------------------------------------------OK
7740             $(itemTemp).removeClass('disabled');
7741         } else if (tag_Type == "link") {//-----------------------------------------------------------OK
7742             itemTemp.href = "javascript:void(0);";
7743             itemTemp.removeAttr('disabled', 'disabled');
7744         } else if (tag_Type == "fileupload") {//----------------------------------------------------todo
7745         } else if (tag_Type == "tree") {//----------------------------------------------------------todo
7746             $(itemTemp).parent().find('.citySel').removeClass('disableColor')
7747
7748             //   var itemTemp = $("#customResultFormDiv").find("#"+tag_Id)[0];
7749             itemTemp[0].setAttribute('editable', aliasItem.editable);
7750         }
7751         // else if (tag_Type == "tree" || tag_Type == "tree" || tag_Type == "tree") {
7752         //     //  var itemTemp = $("#customResultFormDiv").find("#"+tag_Id)[0];
7753         //     itemTemp.setAttribute('editable', aliasItem.editable);
7754         // }
7755
7756     } else if (!aliasItem.editable) {
7757         if (tag_Type == "text" || tag_Type == "textarea" || tag_Type == "number" || tag_Type == "calendar") {//--OK
7758             for (var i = 0; i < itemTemp.length; i++) {
7759                 //  12/7 李元杰 添加背景颜色
7760                 console.log(itemTemp[i]);
7761                 itemTemp[i].setAttribute('readonly', '');
7762                 $(itemTemp[i]).addClass('disableColor')
7763             }
7764             if (tag_Type == "calendar") {
7765                 // $('.dateFromyyyy').unbind();
7766                 // $('.dateFromyyyymm').unbind();
7767                 // $('.dateFromyyyymmdd').unbind();
7768                 // $('.dateFromhhmiss').unbind();
7769                 itemTemp.removeClass('dateFromyyyy');
7770                 itemTemp.removeClass('dateFromyyyymm');
7771                 itemTemp.removeClass('dateFromyyyymmdd');
7772                 itemTemp.removeClass('dateFromhhmiss');
7773                 ////////console.log(itemTemp);
7774                 var itemDateFromTemp = itemTemp[0].cloneNode(true);
7775                 var $DateFromTemp = "<div id='itemDateFromTemp'></div>"
7776                 itemTemp.after($DateFromTemp);
7777                 itemTemp.remove();
7778                 var DateFromTemp = $("#itemDateFromTemp")[0];
7779                 DateFromTemp.after(itemDateFromTemp);
7780                 DateFromTemp.remove();
7781                 customShow.clickBindSubform();
7782             }
7783         } else if (tag_Type == "radio") {//----------------------------------------------------------todo
7784
7785             // setTimeout(function(){
7786             itemTemp.find('.custom-radio').addClass("readonly");
7787             // },0)
7788         } else if (tag_Type == "checkbox") {//-------------------------------------------------------todo
7789             itemTemp.find('.custom-check').addClass("readonly");
7790         } else if (tag_Type == "dropdownlist") {//---------------------------------------------------OK
7791             // $(itemTemp).addClass('editableDisabled');
7792             // $(itemTemp).prop("disabled", true);        //设置下拉框不可用
7793             // ////console.log($(itemTemp).find(".select-container"));
7794             // itemTemp = $(itemTemp).find(".select-container");
7795             // for(var i = 0 ;i<itemTemp.length;i++){
7796             //   itemTemp[i].setAttribute('readonly','');
7797             // }
7798             console.log($(itemTemp))
7799             $(itemTemp).find('.select-container_box').addClass('disableColor')
7800             $(itemTemp).addClass("readonly");
7801             ////console.log( $(itemTemp));
7802         } else if (tag_Type == "button") {//---------------------------------------------------------OK
7803             $(itemTemp).addClass('disabled');
7804         } else if (tag_Type == "link") {//-----------------------------------------------------------OK
7805             itemTemp.href = "javascript:void(0);";
7806             for (var i; i < itemTemp.length; i++) {
7807                 itemTemp[i].setAttribute('disabled', 'disabled');
7808             }
7809         } else if (tag_Type == "fileupload") {//----------------------------------------------------todo
7810         } else if (tag_Type == "tree") {//----------------------------------------------------------todo
7811             // 禁用背景颜色
7812             console.log($(itemTemp).parents('div[name="TreeWin"]'))
7813             console.log($(itemTemp))
7814
7815             itemTemp[0].setAttribute('editable', aliasItem.editable);
7816         }
7817         // else if (tag_Type == "tree" || tag_Type == "tree" || tag_Type == "tree") {
7818         //     //  var itemTemp = $("#customResultFormDiv").find("#"+tag_Id)[0];
7819         //     console.log($(itemTemp))
7820         //     itemTemp.setAttribute('editable', aliasItem.editable);
7821         // }
7822     }
7823 }
7824 //错误信息显示
7825 customShow.setShowMesageErr = function (id, message, N, type) {
7826     console.log("setShowMesageErr");
7827     console.log(message);
7828     ////console.log(id);
7829     if (customShow.options.customInit.designMode == "1") {
7830         ////console.log(id);
7831         ////console.log(message);
7832         ////console.log(N);
7833         ////console.log($($(".customViewUEditorCss  #"+id)[N]));
7834         // $($(".customViewUEditorCss  #"+id)[N]).popover('hide');
7835         $($(".customViewUEditorCss  #" + id)[N]).popover({
7836             // title:"错误信息",
7837             html: true,
7838             content: message,
7839         });
7840         $($(".customViewUEditorCss  #" + id)[N]).popover('show');
7841         customShow.options.showErrId[id] = N;
7842         //////console.log($($(".customViewUEditorCss  #"+id+"Item")[N]).length);
7843         if ($($(".customViewUEditorCss  #" + id + "Item")[N]).length == 1) {
7844             $($(".customViewUEditorCss  #" + id + "Item")[N]).popover({
7845                 // title:"错误信息",
7846                 html: true,
7847                 content: message,
7848             });
7849             $($(".customViewUEditorCss  #" + id + "Item")[N]).popover('show');
7850             customShow.options.showErrId[id + "Item"] = N;
7851         }
7852     } else {
7853         var mesageErrDiv = document.createElement("div");
7854         mesageErrDiv.setAttribute("class", "mesageErrDiv");
7855         mesageErrDiv.setAttribute("id", id + "mesageErrDiv");
7856         if(type){//验证消息 修改  李伟民
7857             $(mesageErrDiv).addClass("checkErr");
7858         }//验证消息 修改  李伟民
7859         $(mesageErrDiv).append(message);
7860         var tempActiveId = $($(".customViewUEditorCss  #" + id + "ActiveId")[N]).find("#" + id + "mesageErrDiv");
7861         $($(".customViewUEditorCss  #" + id + "ActiveId")[N]).find("#" + id + "mesageErrDiv").remove();
7862         // if(tempActiveId.length == 0){
7863         //          if($($(".customViewUEditorCss  #"+id+"ActiveId")[N]).length !=0){
7864         //2017/10/23  李元杰 必选的提示信息修改
7865         var requiredHint = $($($(".customViewUEditorCss  #" + id + "ActiveId")[N])[0]);
7866         if (requiredHint.find('input').val() === '') {
7867             if ($(".customViewUEditorCss  #" + id + "ActiveId").length == 0) {
7868                 console.log($(".customViewUEditorCss [id='" + id + "']:eq(" + N + ")").closest("td"));
7869                 $(".customViewUEditorCss [id='" + id + "']:eq(" + N + ")").closest("td").append(mesageErrDiv);
7870             } else {
7871                 $($($(".customViewUEditorCss  #" + id + "ActiveId")[N])[0]).append(mesageErrDiv);
7872             }
7873             $(mesageErrDiv).html(requiredHint.children('h8').children('span').html() + "必须输入")
7874         } else {
7875             if ($(".customViewUEditorCss  #" + id + "ActiveId").length == 0) {
7876                 console.log($(".customViewUEditorCss [id='" + id + "']:eq(" + N + ")").closest("td"));
7877                 if ($(".customViewUEditorCss [id='" + id + "']:eq(" + N + ")").closest("td").find(".mesageErrDiv").length == 0) {
7878                     $(".customViewUEditorCss [id='" + id + "']:eq(" + N + ")").closest("td").append(mesageErrDiv);
7879                 }
7880             } else {
7881                 if ($($($(".customViewUEditorCss  #" + id + "ActiveId")[N])[0]).find(".mesageErrDiv").length == 0) {
7882                     $($($(".customViewUEditorCss  #" + id + "ActiveId")[N])[0]).append(mesageErrDiv);
7883                 }
7884             }
7885         }
7886         // $(mesageErrDiv).html(requiredHint.children('h8').children('span').html() + "必须输入")
7887         //            }
7888         // }
7889
7890
7891     }
7892
7893 }
7894
7895 //DB数据to画面表示数据转化
7896 customShow.dbItemToShowItem = function (itemId, type, value, showClass, dropdowntype, parentsubFormNum) {
7897     if (type == "radio" || type == "checkbox") {
7898         var itemL = $("." + showClass + " ." + itemId + "value");
7899         //数值变换
7900         //单选按钮,仅仅有一项情况(无子表单时)
7901         if (type == "radio" && itemL.length == 1) {
7902             if (parentsubFormNum != 0) {
7903                 value = value[0];
7904             }
7905             value = [[value]];
7906         } else if (type == "checkbox" && itemL.length == 1) {
7907             //复选框时,仅仅有一项情况(无子表单时)
7908             //只选择一项
7909             if (parentsubFormNum != 0) {
7910                 value = value[0];
7911             }
7912             if (typeof value == "string") {
7913                 value = [[value]];
7914             } else {
7915                 //复数项选择
7916                 value = [value];
7917             }
7918         } else if (type == "radio" && itemL.length > 1) {
7919             //
7920             var valueTempRadio = [];
7921             for (var i = 0; i < value.length; i++) {
7922                 valueTempRadio[i] = [value[i]];
7923             }
7924             value = valueTempRadio;
7925         } else if (type == "checkbox" && itemL.length > 1) {
7926             var valueTempRadio = [];
7927             for (var i = 0; i < value.length; i++) {
7928                 if (typeof value[i] == "string") {
7929                     valueTempRadio[i] = [value[i]];
7930                 } else {
7931                     valueTempRadio[i] = value[i];
7932                 }
7933             }
7934             value = valueTempRadio;
7935         }
7936     } else if (type == "dropdownlistText") {
7937
7938         //多个下拉菜单
7939         var itemList = $("." + showClass + " ." + itemId + "value");
7940         if (itemList.length == 1) {
7941             if (parentsubFormNum != 0) {
7942                 value = value[0];
7943             }
7944             if (typeof value == "string" && dropdowntype == "single") {
7945                 value = [value];
7946             }
7947             //子表单中,复选情况
7948             if (dropdowntype == "multiple") {
7949                 if (typeof value == "string") {
7950                     value = [value];
7951                 } else {
7952                     // value = value[0];
7953                 }
7954             }
7955             // setelect2Item(itemList[0],value);
7956         } else {
7957             for (var i = 0; i < itemList.length; i++) {
7958                 // var valueTemp;
7959                 //单选时,多文件
7960                 if (dropdowntype == "single") {
7961                     value[i] = [value[i]];
7962                 } else {
7963                     // for (var i = 0; i < value[i].length; i++) {
7964                     if (typeof value[i] == "string") {
7965                         value[i] = [value[i]];
7966                     } else {
7967                         value[i] = value[i];
7968                     }
7969                     // }
7970                 }
7971                 // setelect2Item(itemList[i],valueTemp);
7972             }
7973         }
7974     }
7975     return value;
7976 }
7977
7978 //表示模式下,数据设定(单选 复选 下拉菜单)
7979 customShow.setShowItem = function (itemId, type, value, flag) {
7980     //被选择项目设定
7981     console.log(1)
7982     //  console.log(_.cloneDeep(itemId))
7983     //  console.log(_.cloneDeep(type))
7984     console.log(_.cloneDeep(value))
7985     //  console.log(_.cloneDeep(flag))
7986     checkboxRadioShow = function (showItem, value) {
7987         console.log($(showItem), value)
7988         var listData = customBase.options.dropdownlistText[itemId];
7989         if (listData == undefined) {
7990             return;
7991         }
7992         if (typeof value == "string") {
7993             value = [value];
7994             // value = JSON.parse(value)
7995         }
7996         var temp = [];
7997         var tempStr = "";
7998         console.log(listData);
7999         console.log(value)
8000         for (var i = 0; i < listData.length; i++) {
8001             for (var j = 0; j < value.length; j++) {
8002                 if (value[j] == listData[i].value) {
8003                     console.log(1)
8004                     temp[j] = listData[i].text;
8005                 }
8006             }
8007         }
8008         console.log(temp)
8009         for (var i = 0; i < temp.length; i++) {
8010             if (i == 0) {
8011                 tempStr = temp[i];
8012             } else {
8013                 tempStr += "," + temp[i];
8014             }
8015         }
8016         console.log(tempStr)
8017         $(showItem).empty();
8018         //console.log(tempStr);
8019         $(showItem).append(tempStr);
8020
8021     }
8022     var showItem = $("." + itemId + "_showItem");
8023     console.log(showItem)
8024     //页面返回
8025     if (flag) {
8026         if (type == "checkbox" || type == "radio") {
8027             if (showItem.length == 1) {
8028                 checkboxRadioShow(showItem[0], value);
8029             } else {
8030                 for (var i = 0; i < showItem.length; i++) {
8031                     checkboxRadioShow(showItem[i], value[i]);
8032                 }
8033             }
8034         } else {
8035             if (showItem.length == 1) {
8036                 checkboxRadioShow(showItem[0], value);
8037             } else {
8038                 for (var i = 0; i < showItem.length; i++) {
8039                     checkboxRadioShow(showItem[i], value[i]);
8040                 }
8041             }
8042         }
8043     } else {
8044         if (type == "checkbox" || type == "radio") {
8045             for (var i = 0; i < showItem.length; i++) {
8046                 var valueTemp = value[i];
8047                 checkboxRadioShow(showItem[i], valueTemp);
8048             }
8049         } else {
8050             if (showItem.length == 1) {
8051                 checkboxRadioShow(showItem[0], value);
8052             } else {
8053                 for (var i = 0; i < showItem.length; i++) {
8054                     checkboxRadioShow(showItem[i], value[i]);
8055                 }
8056             }
8057         }
8058     }
8059 }
8060
8061 //工具栏设定button
8062 customShow.setToolBtn = function (btns) {
8063     console.log(btns)
8064     $(".edit-pane").empty();
8065     var $editPaneBtn = $($(".edit-pane")[0]);
8066
8067     console.log($editPaneBtn)
8068     //  //////console.log(btns);
8069     for (var i = 0; i < btns.length; i++) {
8070         if (customShow.button[btns[i]].functionName == "") {
8071             $a = '<a id="' + btns[i] + '" href="javascript:void(0);">' +
8072                 '<i class="icon-flow-edit"></i><span style="color:#ff0000"><i class="' + customShow.button[btns[i]].cssName + '" style="text-align: left;color:#ff0000"></i>' + customShow.button[btns[i]].name + '</span></a>';
8073         } else {
8074             $a = '<a id="' + btns[i] + '" href="javascript:void(0);" onclick="' + customShow.button[btns[i]].functionName + '()">' +
8075                 '<i class="icon-flow-edit"></i><span><i class="' + customShow.button[btns[i]].cssName + '" style="text-align: left;"></i>' + customShow.button[btns[i]].name + '</span></a>';
8076         }
8077         if (customShow.getFormSetting(btns[i]) != 0) {
8078             $editPaneBtn.prepend($a);
8079         }
8080
8081     }
8082     if (btns.length > 0) {
8083         // $(".preview-edit-pane").css("display", "block");
8084     }
8085 }
8086
8087 customShow.setTextBtn = function () {
8088     var item = customShow.options.customItemShow.item["itemId_1"];
8089     var code = item.tag_Attribute.masterData;
8090     var masterData = $.parseJSON(code);
8091     var defindCode = masterData.defindCode;
8092     var eleCode = masterData.eleCode;
8093     customLinkageAnalysis.getElement("itemId_1", eleCode, function (re) {
8094         ////////console.log(re);
8095     })
8096 }
8097
8098 //主数据重复
8099 customShow.setXhSelectList = function (addflag) {
8100     //    console.log(1)
8101     var subformDList = customShow.options.subformDList;
8102     //console.log(subformDList);
8103     //console.log(85244445)
8104     //console.log(addflag)
8105     var setValueItem = {};
8106     //
8107     //var subArr = [];
8108     //_.each(subformDList,opt=>{
8109     //    subArr.push(opt);
8110     //})
8111     //var subObj = {};
8112     //for(var key in subformDList){
8113     //    if(subformDList[key] == _.last(subArr)){
8114     //        subObj[key] = subformDList[key];
8115     //    }
8116     //}
8117     //console.log(_.cloneDeep(subObj));
8118     for (var id in subformDList) {
8119         console.log(id);
8120         if ($(".customViewUEditorCss ." + id).length == 1) {
8121             var xhSelectTemp = {
8122                 selectId: customShow.options.subformDList[id].selectId,
8123                 multiple: customShow.options.subformDList[id].multiple,
8124                 width: customShow.options.subformDList[id].width,
8125                 listData: customBase.options.dropdownlistText[customShow.options.subformDList[id].selectId],
8126                 setDiv: id
8127             };
8128             console.log(xhSelectTemp);
8129             console.log(1)
8130             xhSelect.setXhSelect(xhSelectTemp);
8131             var item = customShow.options.customItemShow.item[customShow.options.subformDList[id].selectId];
8132             setValueItem[item.tag_Attribute.alias] = customShow.options.subformDList[id].selectId;
8133         }
8134     }
8135     console.log(setValueItem);
8136     console.log(customShow.options);
8137     if (!addflag) {
8138         for (var valueItem in setValueItem) {
8139             var setList = customShow.options.subformDValue[valueItem];
8140             console.log(setList);
8141             if (setList != undefined) {
8142                 for (var i = 0; i < setList.length; i++) {
8143                     xhSelect.setValue(setValueItem[valueItem], setList[i], i);
8144                 }
8145             }
8146         }
8147
8148     }
8149 }
8150 //子表单添加记录  复制下拉框方法   2017/10/06
8151 customShow.setXhSelectListAdd = function () {
8152     // //////console.log(table);
8153     var subformDList = customShow.options.subformDList;
8154     var setValueItem = {};
8155     //10/2/27 马习同修改  下拉框复制重复
8156     var xhSelectTemp = {};
8157     for (var id in subformDList) {
8158         if ($(".customViewUEditorCss ." + id).length == 1) {
8159             var xhSelectTemp = {
8160                 selectId: customShow.options.subformDList[id].selectId,
8161                 multiple: customShow.options.subformDList[id].multiple,
8162                 width: customShow.options.subformDList[id].width,
8163                 listData: customBase.options.dropdownlistText[customShow.options.subformDList[id].selectId],
8164                 setDiv: id
8165             };
8166             // //////console.log($(".customViewUEditorCss ."+id).find('select > option'));
8167             if ($(".customViewUEditorCss ." + id).find('select > option').length == 0) {
8168                 // //////console.log("----------------------------------------------");
8169                 console.log(1)
8170                 xhSelect.setXhSelect(xhSelectTemp);
8171             }
8172         }
8173     }
8174     xhSelect.setXhSelect(xhSelectTemp);
8175     //10/2/27 马习同修改  下拉框复制重复
8176 }
8177
8178
8179 customShow.getFormSetting = function (btnFlag) {
8180     var ren = 1;
8181     if (btnFlag == 'printableBtn') {
8182         ren = customShow.options.formsetting['printable'];
8183     } else if (btnFlag == 'exportBtn') {
8184         ren = customShow.options.formsetting['exportable'];
8185     } else if (btnFlag == 'rejectBtn') {
8186         ren = customShow.options.formsetting['rejectable'];
8187     } else if (btnFlag == 'submitBtn') {
8188         ren = customShow.options.formsetting['submitable'];
8189     } else if (btnFlag == 'auditableBtn') {
8190         ren = customShow.options.formsetting['auditable'];
8191     } else if (btnFlag == 'queryBtn') {
8192         ren = customShow.options.formsetting['queryable'];
8193     } else if (btnFlag == 'createBtn') {
8194         ren = customShow.options.formsetting['createable'];
8195     } else if (btnFlag == 'clearBtn') {
8196         // ren = customShow.options.formsetting['clearable'];
8197         ren = 1;
8198     } else if (btnFlag == 'disposableBtn') {
8199         // ren = customShow.options.formsetting['disposable'];
8200         ren = 1;
8201     } else if (btnFlag == 'fromSaveBtn') {
8202         ren = customShow.options.formsetting['saveable'];
8203         console.log(ren)
8204         // ren = 1;
8205     } else if (btnFlag == 'editableBtn') {
8206         ren = 1;
8207     }
8208     return ren;
8209
8210 }
8211 var customLinkageAnalysis = customLinkageAnalysis || {};
8212 //-----------------------------------------------------仲追加内容----------------------------------------------------------
8213 customLinkageAnalysis.options = {};
8214 //取得表单值
8215 /**
8216  * 参数:ItemId 字段ID
8217  * 返回值:值
8218  */
8219 customLinkageAnalysis.getValue = function (itemId) {
8220     var item = customShow.options.customItemShow.item[itemId];
8221     var alias = item.tag_Attribute.alias;
8222     var items = customShow.getItems();
8223     var result = items[alias];
8224
8225     if (item.parentsubFormNum != 0) {
8226         for (var ItemId in customShow.options.customItemShow.item) {
8227             if (customShow.options.customItemShow.item[ItemId].columnOrderNum == item.parentsubFormNum) {
8228                 result = items[customShow.options.customItemShow.item[ItemId].tag_Attribute.alias];
8229             }
8230         }
8231         ////console.log(result);
8232         var resultTemp = "";
8233
8234         for (var i = 0; i < result.length; i++) {
8235             if (i > 0) {
8236                 resultTemp += ",";
8237             }
8238             if (typeof result[i][alias] != "string") {
8239                 resultTemp += result[i][alias].join(',');
8240             } else {
8241                 resultTemp += result[i][alias];
8242             }
8243
8244         }
8245         ////console.log(resultTemp);
8246         return resultTemp;
8247     } else if (typeof result != "string") {
8248         result = result.join(',');
8249     }
8250     ////console.log(customShow);
8251     ////console.log(customLinkageAnalysis);
8252     console.log(result);
8253     return result;
8254 }
8255
8256 //设定表单值--------------------
8257 /**
8258  * 参数:ItemId 字段ID
8259  *      value:设定值
8260  */
8261 customLinkageAnalysis.setValue = function (itemId, value, num) {
8262     console.log(itemId);
8263     console.log(value);
8264     var item = customShow.options.customItemShow.item[itemId];
8265     //数据类型
8266     var type = item.tag_Type;
8267     if (type == "text" || type == "textarea" ||
8268         type == "number" || type == "calendar") {
8269         customBase.setItemValue(itemId, "text", value, "", "", num);
8270     } else if (type == "radio" || type == "checkbox") {
8271         if (value.indexOf(",") != -1) {
8272             value = value.split(",");
8273             value = [value];
8274         }
8275         customBase.setItemValue(itemId, type, value, "customViewUEditorCss");
8276     } else if (type == "dropdownlist") {
8277         var dropdowntype = item.tag_Attribute.dropdowntype;
8278         customBase.setItemValue(itemId, "dropdownlistText", value, "customViewUEditorCss", dropdowntype);
8279     } else if (type == "htmlediter") {
8280         var id = itemId + "Item";
8281         UE.getEditor(id).setContent(value);
8282     } else if (type == "qrcode") {
8283         var id = itemId + "qrcode";
8284         customBase.setItemValue(id, 'text', value, 'customViewUEditorCss');
8285         $("#" + id).blur();
8286     } else if (type == "barcode") {
8287         var id = itemId + "barcode";
8288         customBase.setItemValue(id, 'text', value, 'customViewUEditorCss');
8289         $("#" + id).blur();
8290     } else if (type == "tree") {
8291
8292     } else if (type == "amount") {
8293         var id = itemId + "amount";
8294         customBase.setItemValue(id, 'text', value, 'customViewUEditorCss');
8295         $("#" + id).blur();
8296     }
8297
8298 }
8299
8300 //取得属性
8301 /**
8302  * 参数:ItemId 字段ID
8303  *      attributeName:属性名
8304  *                  visible  //可见                     true:可见  false:不可见
8305                     editable //可编辑                   true:可编辑  false:不可编辑
8306  */
8307 customLinkageAnalysis.getAttribut = function (itemId, attributeName) {
8308     console.log(itemId);
8309     console.log(attributeName)
8310     var item = customShow.options.customItemShow.item[itemId];
8311     // return customLinkageAnalysis.validationEx(item.tag_Attribute.alias);
8312     var alias = item.tag_Attribute.alias;
8313     var ttn = customBase.options.customItems[alias][attributeName];
8314     ////console.log(ttn)
8315     return ttn;
8316 }
8317
8318 //设定属性---------------需要测试-----
8319 /**
8320  * 参数:ItemId 字段ID
8321  *      attributeName:属性名
8322  *                  visible  //可见                     true:可见  false:不可见
8323                     editable //可编辑                   true:可编辑  false:不可编辑
8324  */
8325 customLinkageAnalysis.setAttribut = function (itemId, attributeName, attributeValue) {
8326     var item = customShow.options.customItemShow.item[itemId];
8327     // return customLinkageAnalysis.validationEx(item.tag_Attribute.alias);
8328     var alias = item.tag_Attribute.alias;
8329     console.log(alias)
8330     attributeValue = attributeValue + "";
8331     attributeValue = attributeValue.toLowerCase();
8332     if (attributeValue == "true") {
8333         attributeValue = true;
8334     } else if (attributeValue == "false") {
8335         attributeValue = false;
8336     } else {
8337         //默认值
8338         attributeValue = true;
8339     }
8340     customBase.options.customItems[alias][attributeName] = attributeValue;
8341     customShow.setShowAttribute(customBase.options.customItems[alias]);
8342 }
8343
8344 //设定错误信息
8345 /**
8346  * 参数:ItemId 字段ID
8347  *      message:信息
8348  */
8349 customLinkageAnalysis.setMessage = function (mode, ItemId, message, num) {
8350     var item = customShow.options.customItemShow.item[ItemId];
8351     var type = item.tag_Type;
8352     if (num == undefined) {
8353         num = 0;
8354     }
8355     var errorClass;
8356     if (mode == "0") {//验证消息 修改  李伟民
8357         errorClass = "errorCheckCss"
8358     } else {
8359         errorClass = "errorItemCss";
8360     }//验证消息 修改  李伟民
8361     customShow.showErrorItem(errorClass, type, ItemId, num);
8362     //焦点事件
8363     // $("." + errorClass).unbind('focus');
8364     $("[id='" + ItemId + "']:eq(" + num + ")").unbind("focus");
8365     $("[id='" + ItemId + "']:eq(" + num + ")").on('focus', function () {
8366         console.log("focus");
8367         $(this).removeClass(errorClass);
8368         ////////console.log($(this)[0].id);
8369         $(this).closest("#" + $(this)[0].id + "ActiveId").find("[id='" + $(this)[0].id + "mesageErrDiv']").remove();//修改错误信息删除  李伟民  2017-10-18 14:15
8370         $(this).closest(".tdContentClass").find("[id='" + $(this)[0].id + "mesageErrDiv']").remove();//列表模式
8371         //        $("#"+$(this)[0].id+"mesageErrDiv").remove();
8372         $(".customViewUEditorCss  #" + $(this)[0].id).popover('hide')
8373     });
8374     //下拉列表点击事件
8375     $(".select2-search__field").unbind("focus");
8376     $(".select2-search__field").bind("focus", function () {
8377         var id = this.getAttribute("errorItemId");
8378         var N = this.getAttribute("N");
8379         $($('.customViewUEditorCss #' + id)[N].parentNode).find(".select2").removeClass(errorClass);
8380         $("#" + id + "mesageErrDiv").remove();
8381         $($(".customViewUEditorCss  #" + id)[N]).popover('hide')
8382     });
8383     if (mode == "0") {//验证消息 修改  李伟民
8384         customShow.setShowMesageErr(ItemId, message, num, true);
8385     } else {
8386         customShow.setShowMesageErr(ItemId, message, num);
8387     }//验证消息 修改  李伟民
8388     
8389 }
8390
8391 //设定alert信息
8392 //参数:type类型
8393 // E:错误信息
8394 // I:信息
8395 // W:警告
8396 // S:成功
8397 //  message:信息
8398 customLinkageAnalysis.alert = function (type, message) {
8399     customBase.alert(type, message);
8400 }
8401
8402
8403
8404 // 初期调用
8405 customLinkageAnalysis.bindLinkage = function () {
8406     //    ////console.log(window.customBase);
8407     //取得公式的JSON数据
8408     //  ////console.log(customShow);
8409     //  ////console.log(customLinkageAnalysis);
8410     var rules = customShow.options.jsonLinkage;
8411     if (typeof rules == 'string') {
8412         rules = eval(rules);
8413     }
8414     if (rules == null || rules.length == 0) {
8415         return;
8416     }
8417     //初期接口 (false:不继续执行 true:继续执行)
8418     // customShow.initEvent.interfaceInitLinkage;
8419
8420     //取消接口 (false:不继续执行 true:继续执行)
8421     // customShow.initEvent.cancelEventLinkage;
8422
8423     //保存接口 (false:不继续执行 true:继续执行)
8424     // customShow.initEvent.fromSaveLinkage;
8425     for (var i = 0; i < rules.length; i++) {
8426         //console.log(rules[i]);
8427         var dofunction = {};
8428         try {
8429             dofunction = customLinkageAnalysis.makeLinkage(rules[i]);
8430         } catch (e) {
8431             ////console.log(e.message);
8432             continue;
8433         }
8434         var allFunction = customLinkageAnalysis.changeDoFunction(dofunction);
8435         var fieldId = rules[i].event.eventFieldId;
8436         if (fieldId == "_body" && rules[i].event.doEvent == "loading") {
8437             customShow.initEvent.interfaceInitLinkage = customLinkageAnalysis.bindFunctionEvent(allFunction.strFunction);
8438         } else if (fieldId == "_body" && rules[i].event.doEvent == "commit") {
8439             customShow.initEvent.fromSaveLinkage = customLinkageAnalysis.bindFunctionEvent(allFunction.strFunction);
8440         }
8441         var item = customShow.options.customItemShow.item[fieldId];
8442         if (item != undefined) {
8443             var doEvent = rules[i].event.doEvent;
8444             doEvent = doEvent.replace("selectedChange", "change");
8445             if (item.tag_Type == "radio" || item.tag_Type == "checkbox") {
8446                 doEvent = doEvent.replace("change", "click");
8447             }
8448             if (item.tag_Type == "amount" || item.tag_Type == "qrcode" || item.tag_Type == "barcode") {
8449                 fieldId = fieldId + item.tag_Type;
8450             }
8451             if (item.tag_Type == "htmlediter") {
8452                 UE.getEditor(fieldId + "Item").onclick = function (event, ui) {
8453                     // eval(strFunction);
8454                     // ////console.log(UE.getEditor(fieldId+"Item").getContent());
8455                     customLinkageAnalysis.options[fieldId + "Item"] = UE.getEditor(fieldId + "Item").getContent();
8456                 }
8457                 UE.getEditor(fieldId + "Item").onblur = function (event, ui) {
8458                     //////console.log(UE.getEditor(fieldId+"Item").getContent());
8459                     var fieldIdItem = UE.getEditor(fieldId + "Item").getContent();
8460                     if (fieldIdItem != customLinkageAnalysis.options[fieldId + "Item"]) {
8461                         eval(allFunction.strFunction);
8462                     }
8463
8464                 }
8465                 ////console.log(UE.getEditor(fieldId+"Item"));
8466             } else if (item.tag_Type == "tree") {
8467                 customBase.options.zTreeOnClickItems[fieldId + "tree"] = allFunction.strFunction;
8468             } else if (item.tag_Type == "radio" || item.tag_Type == "checkbox") {
8469
8470             } else {
8471                 customLinkageAnalysis.bindEvent(fieldId, doEvent, allFunction);
8472             }
8473
8474         }
8475         _.each(rules[i].results, function (ru) {// 自定义验证 为弹出消息控件绑定验证方法 李伟民 2017-10-18 15:09
8476             if ((ru.mode == "2" || ru.mode == "0") && rules[i].event.eventFieldId != ru.eventFieldId) {//判断是否为验证公式 判断触发控件与弹出消息控件是否为同一控件
8477                 //console.log(ru);
8478                 customLinkageAnalysis.bindEvent(ru.eventFieldId, "blur", allFunction);
8479             }
8480         });// 自定义验证 为弹出消息控件绑定验证方法 李伟民 2017-10-18 15:09 end
8481     }
8482 }
8483
8484
8485 // 子控件事件调用时
8486 customLinkageAnalysis.bindLinkageSubform = function (inType) {
8487     //取得公式的JSON数据
8488     var rules = customShow.options.jsonLinkage;
8489     if (typeof rules == 'string') {
8490         rules = eval(rules);
8491     }
8492     if (rules == null || rules.length == 0) {
8493         return;
8494     }
8495     // if("calendar" == inType){
8496     //     $("#"+fieldId).unbind();
8497     // }
8498     for (var i = 0; i < rules.length; i++) {
8499         var dofuncion = "";
8500         try {
8501             dofuncion = customLinkageAnalysis.makeLinkage(rules[i]);
8502         } catch (e) {
8503             ////console.log(e.message);
8504             continue;
8505         }
8506         var fieldId = rules[i].event.eventFieldId;
8507         var item = customShow.options.customItemShow.item[fieldId];
8508         var strFunction = customLinkageAnalysis.changeDoFunction(dofuncion);
8509         if (item != undefined) {
8510             var doEvent = rules[i].event.doEvent;
8511             doEvent = doEvent.replace("selectedChange", "change");
8512             // if (item.tag_Type == "radio" || item.tag_Type == "checkbox") {
8513             //     // doEvent = doEvent.replace("change", "click");
8514             // }
8515             if (inType == item.tag_Type) {
8516                 if (item.tag_Type == "radio") {
8517                     $("#" + fieldId + ' .custom-radio').on('click', function () {
8518                         // //////console.log(this.className);
8519                         if (this.className.indexOf("readonly") > -1) {
8520                             return;
8521                         }
8522                         eval(strFunction);
8523                     });
8524                 } else if (item.tag_Type == "checkbox") {
8525                     $("#" + fieldId + ' .custom-check').on('click', function () {
8526                         // //////console.log(this.className);
8527                         if (this.className.indexOf("readonly") > -1) {
8528                             return;
8529                         }
8530                         eval(strFunction);
8531                     });
8532                 } else {
8533                     customLinkageAnalysis.bindEvent(fieldId, doEvent, strFunction);
8534                 }
8535
8536             }
8537         }
8538     }
8539 }
8540
8541 customLinkageAnalysis.bindFunctionEvent = function (strFunction) {
8542     //console.log(strFunction);
8543     return function () {
8544         try {
8545             eval(strFunction);
8546         } catch (e) {
8547             ////console.log(e.message);
8548         }
8549     }
8550 }
8551
8552 customLinkageAnalysis.changeDoFunction = function (doFunction) {
8553     var conditionCode = doFunction.conditionCode;
8554     //console.log(doFunction);
8555     var code = "";
8556     var strFunction = "";
8557     var checkFunction = "";// 单独检查校验规则代码  李伟民 2017-10-19 14:33
8558     if (conditionCode != null) {
8559         code = conditionCode.code
8560         var conditionListCode = conditionCode.listCode;
8561
8562         for (var i = 0; i < conditionListCode.length; i++) {
8563             strFunction += "var code" + i + " = " + conditionListCode[i] + ";\r\n";
8564             checkFunction += "var code" + i + " = " + conditionListCode[i] + ";\r\n";// 单独检查校验规则代码  李伟民 2017-10-19 14:33
8565             var reg = new RegExp('\\{' + i + '\\}', "g");
8566             code = code.replace(reg, "\"+customLinkageAnalysis.changeEvalType(eval('code" + i + "'))+\"");
8567         }
8568         for (var i = 0; i < conditionListCode.length; i++) {
8569             var reg = new RegExp('\\{' + i + '\\}', "g");
8570             strFunction = strFunction.replace(reg, "code" + i);
8571             checkFunction = strFunction.replace(reg, "code" + i);// 单独检查校验规则代码  李伟民 2017-10-19 14:33
8572         }
8573         if (conditionCode.clearCode != undefined) {//添加清空错误信息  李伟民 2017-10-18 17:45
8574             _.each(conditionCode.clearCode, function (_clearCode) {
8575                 strFunction += _clearCode;
8576                 checkFunction += _clearCode;// 单独检查校验规则代码  李伟民 2017-10-19 14:33
8577             })
8578         }//添加清空错误信息  李伟民 2017-10-18 17:45 end
8579         if (code != null && code != "") {
8580             if (code.indexOf('Math.floor') != -1) {
8581                 code = eval(code);
8582                 ////console.log(code);
8583             }
8584             code = "customLinkageAnalysis.expeval(\"=" + code + "\")";
8585             strFunction += "if (" + code + " == 'true') { \r\n";
8586             checkFunction += "if (" + code + " == 'true') { \r\n";// 单独检查校验规则代码  李伟民 2017-10-19 14:33
8587         }
8588     }
8589     var results = doFunction.results;
8590     for (var i = 0; i < results.length; i++) {
8591         var resultValue = results[i].resultValue;
8592         var resultJsText = results[i].resultJsText;
8593         if (resultValue != null) {
8594             var listCode = resultValue.listCode;
8595             var resultCode = resultValue.code;
8596             for (var j = 0; j < listCode.length; j++) {
8597                 strFunction += "var resultCode" + j + " = " + listCode[j] + ";\r\n";
8598                 var reg = new RegExp('\\{' + j + '\\}', "g");
8599                 ////console.log(resultCode);
8600                 resultCode = resultCode.replace(reg, "\"+customLinkageAnalysis.changeEvalType(eval('resultCode" + j + "'))+\"");
8601             }
8602             for (var j = 0; j < listCode.length; j++) {
8603                 var reg = new RegExp('\\{' + j + '\\}', "g");
8604                 strFunction = strFunction.replace(reg, "resultCode" + j);
8605             }
8606             //          if(resultCode.indexOf('Math.floor') != -1){
8607             ////console.log(resultCode);
8608             //                  resultCode = eval(resultCode);
8609             //              }
8610             //console.log(resultCode);
8611             resultCode = "customLinkageAnalysis.expeval(\"=" + resultCode + "\")";
8612             strFunction += resultJsText.replace(/\{0\}/g, resultCode);
8613         } else if (results[i].resultJsText.indexOf("setMessage")) {// 判断是否为 规则校验公式
8614             strFunction += resultJsText + "; \r\n";
8615             checkFunction += resultJsText + "; \r\n";// 单独检查校验规则代码  李伟民 2017-10-19 14:33
8616         } else {
8617             strFunction += resultJsText + "; \r\n";
8618         }
8619         //公式联动追加
8620         if (results[i].doEvent != undefined && results[i].resultJsText.indexOf("setValue") != -1) {
8621             strFunction += '$("#' + results[i].targetid + '").trigger("' + results[i].doEvent + '.value");';
8622         }
8623
8624         //公式联动追加结束
8625
8626     }
8627
8628     if (code != null && code != "") {
8629         strFunction += "}";
8630         checkFunction += "}";// 单独检查校验规则代码  李伟民 2017-10-19 14:33
8631     }
8632     ////console.log(strFunction);
8633     var allFunction = { "strFunction": strFunction, "checkFunction": checkFunction };
8634     return allFunction;
8635 }
8636
8637 function funCheck(optarr, allFunction) {//判断是否重复绑定方法
8638     var flag = true;
8639     if (optarr != undefined && optarr != '') {
8640         optarr = JSON.parse(optarr);
8641         console.log(optarr);
8642         console.log(allFunction);
8643         _.each(optarr, function (fn) {
8644             if (fn.strFunction == allFunction.strFunction && fn.checkFunction == allFunction.checkFunction) {
8645                 console.log("falg false");
8646                 flag = false;
8647             }
8648         })
8649     }
8650     return flag;
8651 }
8652
8653 customLinkageAnalysis.bindEvent = function (fieldId, doEvent, allFunction) {//aaaaaa
8654     console.log(allFunction);
8655     var evalstr = "";
8656     var evalchekstr = "";
8657     ////console.log(customShow.options.customItemShow.item[fieldId].tag_Type);
8658     if (customShow.options.customItemShow.item[fieldId].tag_Type == "dropdownlist") {
8659         ////console.log($("[id='" + fieldId+"']"));
8660         ////console.log($("[id='" + fieldId+"']").find(".select_get"));
8661         ////console.log($(".select_get"));
8662         ////console.log(strFunction);
8663         _.each($("[id='" + fieldId + "']").find(".select_get"),function(opt){
8664             var optarr = $(opt).attr("funarr");
8665             if(funCheck(optarr,allFunction)){
8666                 $(opt).on(doEvent + ".value", function () {
8667             if (customShow.options.customItemShow.item[fieldId].parentsubFormNum != 0) {
8668                 // _.each($("[id='" + fieldId + "']").find(".select_get"), (item, i) => {
8669                     if (allFunction.strFunction.indexOf("var i=") == -1) {
8670                         ////console.log(i);
8671                         evalstr = "var i=" + $("[id='" + fieldId + "']").find(".select_get").index(this) + ";" + allFunction.strFunction;
8672                     }
8673                 // })
8674             }else{
8675                 evalstr = allFunction.strFunction;
8676             }
8677             try {
8678                 console.log(evalstr);
8679                 eval(evalstr);
8680             } catch (e) {
8681                 ////console.log(e.message);
8682             }
8683         });
8684                 var funarr;
8685                 if($(opt).attr("funarr") == undefined || $(opt).attr("funarr") == ""){
8686                     funarr = [allFunction];
8687                 }else{
8688                     funarr = JSON.parse($(opt).attr("funarr"));
8689                     funarr.push(allFunction);
8690                 }
8691                 $(opt).attr("funarr",JSON.stringify(funarr));
8692             }
8693             var checkarr = $(opt).attr("checkfunarr");
8694             if(funCheck(checkarr,allFunction)){
8695                 $(opt).on(doEvent + ".check", function () {//单独检验校验规则绑定  李伟民 2017-10-19 15:18
8696             if (customShow.options.customItemShow.item[fieldId].parentsubFormNum != 0) {
8697                 // _.each($("[id='" + fieldId + "']").find(".select_get"), (item, i) => {
8698                     if (allFunction.checkFunction.indexOf("var i=") == -1) {
8699                         evalchekstr = "var i=" +  $("[id='" + fieldId + "']").find(".select_get").index(this) + ";" + allFunction.checkFunction;
8700                     }
8701                 // })
8702             }else{
8703                 evalchekstr = allFunction.checkFunction;
8704             }
8705             try {
8706                 eval(evalchekstr);
8707             } catch (e) {
8708                 //console.log(e.message);
8709             }
8710         });//单独检验校验规则绑定  李伟民 2017-10-19 15:18 end
8711                 var checkfunarr;
8712                 if($(opt).attr("checkfunarr") == undefined || $(opt).attr("checkfunarr") == ""){
8713                     checkfunarr = [allFunction];
8714                 }else{
8715                     checkfunarr = JSON.parse($(opt).attr("checkfunarr"));
8716                     checkfunarr.push(allFunction);
8717                 }
8718                 $(opt).attr("checkfunarr",JSON.stringify(checkfunarr));
8719             }
8720             
8721         });
8722         // $("[id='" + fieldId + "']").find(".select_get").on(doEvent + ".value", function () {
8723         //     if (customShow.options.customItemShow.item[fieldId].parentsubFormNum != 0) {
8724         //         // _.each($("[id='" + fieldId + "']").find(".select_get"), (item, i) => {
8725         //             if (allFunction.strFunction.indexOf("var i=") == -1) {
8726         //                 ////console.log(i);
8727         //                 evalstr = "var i=" + $("[id='" + fieldId + "']").find(".select_get").index(this) + ";" + allFunction.strFunction;
8728         //             }
8729         //         // })
8730         //     }else{
8731         //         evalstr = allFunction.strFunction;
8732         //     }
8733         //     try {
8734         //         console.log(evalstr);
8735         //         eval(evalstr);
8736         //     } catch (e) {
8737         //         ////console.log(e.message);
8738         //     }
8739         // });
8740         // $("[id='" + fieldId + "']").find(".select_get").unbind(doEvent + ".check");
8741         // $("[id='" + fieldId + "']").find(".select_get").on(doEvent + ".check", function () {//单独检验校验规则绑定  李伟民 2017-10-19 15:18
8742         //     if (customShow.options.customItemShow.item[fieldId].parentsubFormNum != 0) {
8743         //         // _.each($("[id='" + fieldId + "']").find(".select_get"), (item, i) => {
8744         //             if (allFunction.checkFunction.indexOf("var i=") == -1) {
8745         //                 evalchekstr = "var i=" +  $("[id='" + fieldId + "']").find(".select_get").index(this) + ";" + allFunction.checkFunction;
8746         //             }
8747         //         // })
8748         //     }else{
8749         //         evalchekstr = allFunction.checkFunction;
8750         //     }
8751         //     try {
8752         //         eval(evalchekstr);
8753         //     } catch (e) {
8754         //         //console.log(e.message);
8755         //     }
8756         // });//单独检验校验规则绑定  李伟民 2017-10-19 15:18 end
8757     } else {
8758         // $("[id='" + fieldId + "']").unbind(doEvent + ".value");
8759         _.each($("[id='" + fieldId + "']"),function(opt){
8760             var optarr = $(opt).attr("funarr");
8761                 if(funCheck(optarr,allFunction)){
8762                     $(opt).on(doEvent + ".value", function () {
8763             if (customShow.options.customItemShow.item[fieldId].parentsubFormNum != 0 && allFunction.strFunction.indexOf("getSum") == -1) {
8764                 console.log($("[id='" + fieldId + "']"));
8765                 console.log($(this));
8766                 console.log($("[id='" + fieldId + "']").index(this));
8767                 // _.each($("[id='" + fieldId + "']"), (item, i) => {
8768                     // console.log($(item));
8769                     if (allFunction.strFunction.indexOf("var i=") == -1) {
8770                         ////console.log(i);
8771                         evalstr = "var i=" + $("[id='" + fieldId + "']").index(this) + ";" + allFunction.strFunction;
8772                     }
8773                 // })
8774             }else if(allFunction.strFunction.indexOf("getSum") > 0){
8775                 console.log(allFunction.strFunction);
8776                 console.log("replace");
8777                 evalstr = allFunction.strFunction;
8778                 // allFunction.strFunction = allFunction.strFunction.replace(new RegExp(".split(',')[i]") ,"");
8779                 while(evalstr.indexOf(".split(',')[i]") != -1){
8780                     evalstr = evalstr.replace(".split(',')[i]","");
8781                 }
8782             }else{
8783                 evalstr = allFunction.strFunction;
8784             }
8785             // try {
8786                 console.log(evalstr);
8787                 eval(evalstr);
8788             // } catch (e) {
8789             //     ////console.log(e.message);
8790             // }
8791         });
8792                 var funarr;
8793                 if($(opt).attr("funarr") == undefined || $(opt).attr("funarr") == ""){
8794                     funarr = [allFunction];
8795                 }else{
8796                     funarr = JSON.parse($(opt).attr("funarr"));
8797                     funarr.push(allFunction);
8798                 }
8799                 $(opt).attr("funarr",JSON.stringify(funarr));
8800                 
8801             };
8802             var checkarr = $(opt).attr("checkfunarr");
8803             if(funCheck(checkarr,allFunction)){
8804                 $(opt).on("blur.check", function () {//单独检验校验规则绑定  李伟民 2017-10-19 15:18
8805             if (customShow.options.customItemShow.item[fieldId].parentsubFormNum != 0) {
8806                         console.log("change.check");
8807                 _.each($("[id='" + fieldId + "']"), (item, i) => {
8808                     if (allFunction.checkFunction.indexOf("var i=") == -1) {
8809                         ////console.log(i);
8810                         evalchekstr = "var i=" + $("[id='" + fieldId + "']").index(this) + ";" + allFunction.checkFunction;
8811                     }
8812                 })
8813             }else{
8814                 evalchekstr = allFunction.checkFunction;
8815             }
8816             try {
8817                 if(evalchekstr.indexOf('alert') == -1){
8818                     eval(evalchekstr);
8819                 }
8820             } catch (e) {
8821                 ////console.log(e.message);
8822             }
8823         });//单独检验校验规则绑定  李伟民 2017-10-19 15:18 end
8824                 var checkfunarr;
8825                 if($(opt).attr("checkfunarr") == undefined || $(opt).attr("checkfunarr") == ""){
8826                     checkfunarr = [allFunction];
8827                 }else{
8828                     checkfunarr = JSON.parse($(opt).attr("checkfunarr"));
8829                     checkfunarr.push(allFunction);
8830     }
8831                 $(opt).attr("checkfunarr",JSON.stringify(checkfunarr));
8832             }
8833             
8834         });
8835         // $("[id='" + fieldId + "']").unbind(doEvent + ".check");
8836         // $("[id='" + fieldId + "']").on(doEvent + ".check", function () {//单独检验校验规则绑定  李伟民 2017-10-19 15:18
8837         //     if (customShow.options.customItemShow.item[fieldId].parentsubFormNum != 0) {
8838         //         console.log("change.check");
8839         //         _.each($("[id='" + fieldId + "']"), (item, i) => {
8840         //             if (allFunction.checkFunction.indexOf("var i=") == -1) {
8841         //                 ////console.log(i);
8842         //                 evalchekstr = "var i=" + $("[id='" + fieldId + "']").index(this) + ";" + allFunction.checkFunction;
8843         //             }
8844         //         })
8845         //     }else{
8846         //         evalchekstr = allFunction.checkFunction;
8847         //     }
8848         //     try {
8849         //         eval(evalchekstr);
8850         //     } catch (e) {
8851         //         ////console.log(e.message);
8852         //     }
8853         // });//单独检验校验规则绑定  李伟民 2017-10-19 15:18 end
8854     }
8855 }
8856
8857 customLinkageAnalysis.changeEvalType = function (str) {
8858     console.log(str);
8859     if (isNaN(Number(str)) && (str.substring(0, 1) != "\"" || str.substring(str.length - 1, 1) != "\"")) {
8860         return "'" + str + "'";
8861     } else {
8862         ////console.log(str);
8863         return str;
8864     }
8865 }
8866
8867 //事件绑定调用
8868 //事件绑定:字段ID:ItemId 事件名 自定义事件名
8869 //参数
8870 // eventItem=[{
8871 //     ItemId:"Item_1", 控件id
8872 //     event:"click",  事件
8873 //     eventmethod:"XXXXXXXXXXXXXXXXXXXX"   自定义事件名
8874 // }]
8875 customLinkageAnalysis.setEventBind = function (eventItem) {
8876     customShow.setEventBindItem(eventItem);
8877 }
8878 //03检证执行(接口)
8879 customLinkageAnalysis.validationEx = {
8880     get: function (alias) {
8881         var itemTempS;
8882         var item = customBase.options.customItems[alias];
8883         if (item.type == "button" || item.type == "link") {
8884         } else if (item.type == "dropdownlist") {
8885             var datasourcetype = $("#" + item.id)[0].getAttribute("datasourcetype");
8886             //////////console.log(datasourcetype);
8887             //主数据源
8888             if (datasourcetype == "masterdata") {
8889                 itemTempS = customBase.getItemValue(item.id, item.type);
8890                 //数据源
8891             } else if (datasourcetype == "datasource") {
8892                 itemTempS = customBase.getItemValue(item.id, "dropdownlistText");
8893                 //自定义
8894             } else if (datasourcetype == "custom") {
8895                 itemTempS = customBase.getItemValue(item.id, "dropdownlistText");
8896                 //API接口
8897             } else if (datasourcetype == "api") {
8898                 itemTempS = customBase.getItemValue(item.id, item.type);
8899             }
8900         } else if (item.type == "subform") {
8901
8902         } else {
8903             itemTempS = customBase.getItemValue(item.id, item.type);
8904         }
8905         item.value = itemTempS;
8906         ////////console.log(item);
8907         return item;
8908     }
8909 }
8910 //取得主数据
8911 /*
8912 itemId:项目ID
8913 masterCode:执行CODE
8914 返回值:元素的值
8915 */
8916 customLinkageAnalysis.getElement = function (itemId, masterCode, num) {
8917     var item = customShow.options.customItemShow.item[itemId];
8918     var code = item.tag_Attribute.masterData;
8919     var masterData = $.parseJSON(code);
8920     var defindCode = masterData.defindCode;
8921     var eleCode = masterData.eleCode;
8922     var eleValue = customLinkageAnalysis.getValue(itemId);
8923     if(num != undefined && eleValue != undefined && eleValue.indexOf(',') != -1){//子表单中控件处理  李伟民  0106
8924         eleValue = eleValue.split(',')[num];
8925     }
8926     var opt = {
8927         eleCode: eleCode,
8928         defindCode: defindCode,
8929         eleValue: eleValue,
8930         masterCode: masterCode,
8931         itemId: itemId
8932     }
8933     //主数据取得
8934     var result = customDataBound.getElement1(opt);
8935     console.log(result);
8936     console.log(itemId)
8937     if (result.rspCode == "000000") {
8938         if (result.data[itemId].length > 0) {
8939             console.log(result.data[itemId][0].value)
8940             return result.data[itemId][0].value;
8941         } else {
8942             return "";
8943         }
8944     } else {
8945         return "";
8946     }
8947 }
8948
8949 customLinkageAnalysis.clearMessage = function (itemId, num) {//清空错误信息方法  李伟民 2017-10-18 16:36
8950     if (num == undefined) {
8951         num = 0;
8952     }
8953     //console.log($("[id='"+itemId+"']:eq("+num+")"));
8954     //console.log($("[id='"+itemId+"ActiveId']:eq("+num+")"));
8955     $("[id='" + itemId + "']:eq(" + num + ")").removeClass("errorItemCss");
8956     $("[id='" + itemId + "']:eq(" + num + ")").removeClass("errorCheckCss");
8957     $("[id='" + itemId + "ActiveId']:eq(" + num + ")").find("#" + itemId + "mesageErrDiv").remove();
8958 }//清空错误信息方法  李伟民 2017-10-18 16:36 end
8959
8960 customLinkageAnalysis.makeLinkage = function (rule) {
8961     ////console.log(rule);
8962     var result = {};
8963     var conditionCode = {};
8964     conditionCode = customLinkageAnalysis.changeCodeMirror(rule.conditionCode, rule.conditionHistory._history);
8965
8966     if (rule.conditionCode != "" && !_.isNull(rule.conditionCode)) {//清空错误信息  李伟民 2017-10-18 16:36
8967         var clearCode = [];
8968         _.each(rule.results, function (ru) {
8969             if (ru.mode == "2") {
8970                 var ruItem = customShow.options.customItemShow.item[ru.eventFieldId];
8971                 if (ruItem.parentsubFormNum != 0) {
8972                     clearCode.push("customLinkageAnalysis.clearMessage('" + ru.eventFieldId + "',i);");
8973                 } else {
8974                     clearCode.push("customLinkageAnalysis.clearMessage('" + ru.eventFieldId + "');");
8975                 }
8976             }
8977         });
8978         conditionCode["clearCode"] = clearCode;
8979     }//清空错误信息  李伟民 2017-10-18 16:36 end
8980
8981     var results = new Array();
8982     for (var i = 0; i < rule.results.length; i++) {
8983         var resultJs = {};
8984         var textType = rule.results[i].attribute;
8985         var resultJsText = "";
8986         var resultTargrtItem = customShow.options.customItemShow.item[rule.results[i].eventFieldId]; if ("1" == rule.results[i].mode) {
8987             var resultValue = customLinkageAnalysis.changeCodeMirror(rule.results[i].code, rule.results[i].eventHistory._history);
8988             resultJs.resultValue = resultValue;
8989             if (textType == 'value') {
8990                 if (resultTargrtItem.parentsubFormNum != 0) {
8991                     resultJsText += "customLinkageAnalysis.setValue('" + rule.results[i].eventFieldId + "', {0}, i);";
8992                 } else {
8993                     resultJsText += "customLinkageAnalysis.setValue('" + rule.results[i].eventFieldId + "', {0});";
8994                 }
8995             } else if (textType == 'visible' || textType == 'editable') {
8996                 resultJsText += "customLinkageAnalysis.setAttribut('" + rule.results[i].eventFieldId + "','" + textType + "', {0});";
8997             } else {
8998                 // todo
8999             }
9000         } else if ("2" == rule.results[i].mode || "0" == rule.results[i].mode) {
9001             if (resultTargrtItem.parentsubFormNum != 0) {//自定义校验支持子表单中控件  李伟民 2017-10-18 14:34
9002                 //              resultJsText += "customLinkageAnalysis.clearMessage('" + rule.results[i].eventFieldId + "',i);";
9003                 resultJsText += "customLinkageAnalysis.setMessage('" + rule.results[i].mode + "','" + rule.results[i].eventFieldId + "','" + rule.results[i].message + "',i);";
9004             } else {
9005                 //              resultJsText += "customLinkageAnalysis.clearMessage('" + rule.results[i].eventFieldId + "');";
9006                 resultJsText += "customLinkageAnalysis.setMessage('" + rule.results[i].mode + "','" + rule.results[i].eventFieldId + "','" + rule.results[i].message + "');";
9007             }//自定义校验支持子表单中控件  李伟民 2017-10-18 14:34 end
9008
9009         } else if ("3" == rule.results[i].mode) {
9010             resultJsText += "customLinkageAnalysis.alert('" + rule.results[i].messageType + "','" + rule.results[i].message + "');";
9011         } else {
9012             ;
9013         }
9014         resultJs.resultJsText = resultJsText;
9015         resultJs.targetid = rule.results[i].eventFieldId;// 公式联动追加 目标控件
9016         var targetDoEvent = '';
9017         //      ////console.log(customShow.options.jsonLinkage);
9018         var jsonLinkage_add = customShow.options.jsonLinkage;//预览公式联动修改 李伟民 0117
9019         if (_.isString(jsonLinkage_add)) {
9020             jsonLinkage_add = JSON.parse(jsonLinkage_add);
9021         }
9022         _.each(jsonLinkage_add, function (allrule) {// 公式联动追加 目标控件事件
9023             if (allrule.event.eventFieldId == resultJs.targetid) {
9024                 resultJs.doEvent = allrule.event.doEvent;
9025             }
9026         });
9027         results.push(resultJs);
9028     }
9029     result.conditionCode = conditionCode;
9030     result.results = results;
9031     ////console.log(result);
9032     return result;
9033 }
9034
9035 customLinkageAnalysis.reachLeftSpace = function (str, length) {
9036     var result = str;
9037     if (str.length < length) {
9038         var spaceLen = length - str.length;
9039         for (var i = 0; i < spaceLen; i++) {
9040             result = " " + result;
9041         }
9042     }
9043     return result;
9044 }
9045
9046 customLinkageAnalysis.replace = function (str, stringObj, replaceText, from, to) {
9047     var resultBefore = str.substring(0, from);
9048     var text = str.substring(from, to);
9049     var resultAfter = str.substring(to);
9050     text = text.replace(stringObj, customLinkageAnalysis.reachLeftSpace(replaceText, stringObj.length));
9051     return resultBefore + text + resultAfter;
9052 }
9053
9054 customLinkageAnalysis.changeCodeMirror = function (code, history) {
9055     if (code.trim() == "") {
9056         return null;
9057     }
9058     //console.log(code);
9059     //console.log(history);
9060     var result = {};
9061     var conditionCode = "";
9062     var listCode = new Array();
9063     var arrConditionCode = code.split('\r\n');
9064     ////console.log(arrConditionCode);
9065     var resultIndex = 0;
9066
9067     if (history != null && history.length > 0) {
9068         for (var i = 0; i < history.length; i++) {
9069             var line = history[i].from.line;
9070             var fromCh = history[i].from.ch;
9071             var toCh = history[i].to.ch;
9072             var text = history[i].text;
9073             arrConditionCode[line] = customLinkageAnalysis.replace(arrConditionCode[line], text, '{' + resultIndex + '}', fromCh, toCh);
9074             var idText = history[i].idText;
9075             var arrInputText = idText.split('.');
9076             var replaceText = "";
9077             var id = arrInputText[0];
9078             var textType = arrInputText[1];
9079             var idItem = customShow.options.customItemShow.item[id]; if (textType == 'value') {
9080                 if (idItem.parentsubFormNum != 0) {
9081                     replaceText = "customLinkageAnalysis.getValue('" + id + "').split(',')[i]";
9082                 } else {
9083                     replaceText = "customLinkageAnalysis.getValue('" + id + "')";
9084                 }                // ////console.log(replaceText);
9085             } else if (textType == 'visible' || textType == 'editable') {
9086                 replaceText = "customLinkageAnalysis.getAttribut('" + id + "','" + textType + "')";
9087             } else {
9088                 if (idItem.parentsubFormNum != 0) {//主数据关联也需区分子表单中控件  李伟民 0106
9089                     replaceText = "customLinkageAnalysis.getElement('" + id + "','" + textType + "',i)";
9090                 } else {
9091                     replaceText = "customLinkageAnalysis.getElement('" + id + "','" + textType + "')";
9092                 }
9093                 // replaceText = "customLinkageAnalysis.getElement('" + id + "','" + textType + "')";
9094             }
9095             listCode.push(replaceText);
9096             resultIndex++;
9097         }
9098     }
9099     conditionCode = arrConditionCode.join('\r\n').replace(/\(/g, "###(###");
9100     conditionCode = conditionCode.replace(/\)/g, "###)###");
9101     arrConditionCode = conditionCode.split('\r\n');
9102     conditionCode = arrConditionCode.join('\r\n');
9103     conditionCode = conditionCode.replace(/AND/g, '&&');
9104     conditionCode = conditionCode.replace(/OR/g, '||');
9105     while (conditionCode.indexOf('  ') >= 0) {
9106         conditionCode = conditionCode.replace(/  /g, ' ');
9107     }
9108     var conditionCodeResult = customLinkageAnalysis.changeSign(conditionCode, listCode, resultIndex);
9109     conditionCode = conditionCodeResult.conditionCode;
9110     resultIndex = conditionCodeResult.resultIndex;
9111     conditionCode = conditionCode.replace(/###\(###/g, "(");
9112     conditionCode = conditionCode.replace(/###\)###/g, ")");
9113     result.code = conditionCode;
9114     result.listCode = listCode;
9115     //console.log(result);
9116     return result;
9117 }
9118
9119 customLinkageAnalysis.changeCodeSign = function (sign, inner) {
9120     var exp = igame.Expression;
9121     if (sign.indexOf('MAX') >= 0) {
9122         sign = "Max";
9123     } else if (sign.indexOf('MIN') >= 0) {
9124         sign = "Min";
9125     } else if (sign.indexOf('AVG') >= 0) {
9126         sign = "Average";
9127     } else if (sign.indexOf('SUM') >= 0) {
9128         sign = "Sum";
9129     } else if (sign.indexOf('COUNT') >= 0) {
9130         sign = "Count";
9131     } else {
9132         return "";
9133     }
9134
9135     var arlInner = eval("[" + inner + "]");
9136     return new exp.Formula(sign + "(" + arlInner.join(',') + ")").evaluate().toString();
9137 }
9138
9139 customLinkageAnalysis.expeval = function (str) {
9140     //    console.log(str);
9141     if (str.trim().replace(/=/, "") == "") {
9142         console.log("str  err");
9143         return " ";
9144     }
9145     console.log("str  scc");
9146     var exp = igame.Expression;
9147     //      console.log(exp);
9148     //      console.log(str);
9149     //      console.log(new exp.Formula(str));
9150     //      console.log(new exp.Formula(str).evaluate());
9151     //      console.log(new exp.Formula(str).evaluate().toString());
9152     return new exp.Formula(str).evaluate().toString();
9153 }
9154
9155 customLinkageAnalysis.changeSign = function (conditionCode, listCode, resultIndex) {
9156     ////console.log(conditionCode);
9157     var index = 0;
9158     var indexOf = -1;
9159     var result = {};
9160     while ((indexOf = conditionCode.substring(index).indexOf('MAX')) >= 0
9161         || (indexOf = conditionCode.substring(index).indexOf('MIN')) >= 0
9162         || (indexOf = conditionCode.substring(index).indexOf('AVG')) >= 0
9163         || (indexOf = conditionCode.substring(index).indexOf('SUM')) >= 0
9164         || (indexOf = conditionCode.substring(index).indexOf('COUNT')) >= 0
9165         || (indexOf = conditionCode.substring(index).indexOf('parseInt')) >= 0
9166         || (indexOf = conditionCode.substring(index).indexOf('addtest')) >= 0
9167         || (indexOf = conditionCode.substring(index).indexOf('getDay')) >= 0
9168         || (indexOf = conditionCode.substring(index).indexOf('getSum')) >= 0) {//时间函数  李伟民 2017-10-17 21:49 修改公式
9169         var before = conditionCode.substring(0, indexOf);
9170         var beforeInner = 0;
9171         var afterIndexOf = 0;
9172         var sign;
9173         var after;
9174         if (history != null && history.length > 0) {
9175             beforeInner = conditionCode.substring(indexOf).indexOf('###(###') + 7
9176             // afterIndexOf = conditionCode.substring(indexOf).lastIndexOf('###)###');
9177             afterIndexOf = customLinkageAnalysis.getBackBracketIndex(conditionCode.substring(indexOf), '###(###', '###)###');
9178             sign = conditionCode.substring(indexOf).substring(0, beforeInner - 7);
9179             after = conditionCode.substring(indexOf).substring(afterIndexOf + 7);
9180         } else {
9181             beforeInner = conditionCode.substring(indexOf).indexOf('(') + 1
9182             // afterIndexOf = conditionCode.substring(indexOf).lastIndexOf(')');
9183             afterIndexOf = customLinkageAnalysis.getBackBracketIndex(conditionCode.substring(indexOf), '(', ')');
9184             sign = conditionCode.substring(indexOf).substring(0, beforeInner - 1);
9185             after = conditionCode.substring(indexOf).substring(afterIndexOf + 1);
9186         }
9187         var inner = conditionCode.substring(indexOf).substring(beforeInner, afterIndexOf);
9188         var innerResult = customLinkageAnalysis.changeSign(inner, listCode, resultIndex);
9189         inner = innerResult.conditionCode;
9190         resultIndex = innerResult.resultIndex;
9191         inner = inner.replace(/###\(###/g, "(");
9192         inner = inner.replace(/###\)###/g, ")");
9193         if ((indexOf = conditionCode.substring(index).indexOf('parseInt')) >= 0
9194             || (indexOf = conditionCode.substring(index).indexOf('addtest')) >= 0
9195             || (indexOf = conditionCode.substring(index).indexOf('getDay')) >= 0
9196             || (indexOf = conditionCode.substring(index).indexOf('getSum')) >= 0) {//时间函数  李伟民 2017-10-17 21:49 修改公式
9197             listCode.push(sign + "(" + inner + ")");
9198         } else {
9199             listCode.push("customLinkageAnalysis.changeCodeSign('" + sign + "',\[" + inner + "\])");
9200         }
9201
9202         conditionCode = before + "{" + resultIndex + "}";
9203         resultIndex++;
9204         index = conditionCode.length - 1;
9205         conditionCode += after;
9206     }
9207     result.conditionCode = conditionCode;
9208     result.resultIndex = resultIndex;
9209     ////console.log(result);
9210     return result;
9211 }
9212 addtest = function (arg1, arg2) {
9213     return arg1 + arg2;
9214 }
9215
9216 getDay = function (arg1, arg2) {//时间函数  李伟民 2017-10-17 21:49
9217     var date1 = new Date(arg1)
9218     var date2 = new Date(arg2)
9219     var s1 = date1.getTime(), s2 = date2.getTime();
9220     var total = (s1 - s2) / 1000;
9221     var day = parseInt(total / (24 * 60 * 60));//计算整数天数
9222     //console.log(day);
9223     return day;
9224 }//时间函数  李伟民 2017-10-17 21:49 end
9225
9226 getSum = function () {
9227     console.log(arguments);
9228     var allItem = [];
9229     _.each(arguments, function (arg) {
9230         allItem.push(arg.split(","));
9231     });
9232     console.log(allItem);
9233     var sum = 0;
9234     _.each(allItem, function (item) {
9235         _.each(item, function (cd) {
9236             sum += Number(cd);
9237         })
9238     })
9239     return sum;
9240 }
9241
9242 customLinkageAnalysis.getBackBracketIndex = function (str, strBracket, strBackBracket) {
9243     var beforeIndex = str.indexOf(strBracket);
9244     var backIndex = str.indexOf(strBackBracket);
9245     var layers = 0;
9246     while (beforeIndex < backIndex && beforeIndex >= 0) {
9247         layers++;
9248         beforeIndex = str.indexOf(strBracket, beforeIndex + strBracket.length)
9249     }
9250     while (layers > 1 && backIndex >= 0) {
9251         layers--;
9252         backIndex = str.indexOf(strBackBracket, backIndex + strBackBracket.length);
9253     }
9254     if (backIndex < 0) {
9255         throw Error("括号未闭合");
9256     }
9257     return backIndex;
9258 }
9259 var customDataBound = customDataBound || {};
9260
9261 //根据表单ID取得表单基本信息
9262 customDataBound.getFormbase = function (formid, callback) {
9263     // if(customBase.options.formbaseInfo == ""){
9264     var dataObj = {};
9265     dataObj.formID = formid;
9266     var requestRight = window.commonAjax("/formbase/getFormInfoService", dataObj, "GET", true);
9267     requestRight.done(function (rs) {
9268         callback(rs);
9269     })
9270
9271
9272     // }else{
9273     //     callback(customBase.options.formbaseInfo);
9274     // }
9275 }
9276
9277 //表单保存
9278 customDataBound.savaFormbase = function (formbase, callback) {
9279     ////////////console.log(formbase);
9280     var dataObj = {};
9281     dataObj = formbase;
9282     console.log(formbase);
9283     var requestRight = window.commonAjax("/formbase/saveformService", dataObj, "POST", true);
9284     requestRight.done(function (rs) {
9285
9286         callback(rs);
9287     });
9288 }
9289
9290 //表单数据保存
9291 customDataBound.fromSave = function (formid, formbase, callback) {
9292     // if(window.localStorage.getItem("bussinessSystem")){
9293     //     var flag = window.localStorage.getItem("bussinessSystem");
9294     // }
9295     var dataObj = {};
9296     dataObj.formID = formid;
9297     dataObj.data = formbase;
9298     //     dataObj.tenantID = "001";
9299     // dataObj.flag = flag;
9300     //dataObj.flag = "cloud"
1326a4 9301     console.log(dataObj);
4d1219 9302     if (customShow.exCouldNumber != undefined && customShow.exCouldNumber != '') {//保存时 传云单标号 李伟民 12-22
B 9303         _.extend(dataObj, { 'orderCode': customShow.exCouldNumber });
9304     }//保存时 传云单标号 李伟民 12-22
9305     //_.extend(dataObj,{'orderCode': '1012000170900005'});//临时修改
9306     var requestRight = window.commonAjax("/datamanagement/addFormDataService", dataObj, "POST", true);
9307     requestRight.done(function (rs) {
9308         callback(rs);
9309     });
9310 }
9311
9312 //表单数据编辑
9313 customDataBound.fromEdit = function (formid, formbase, dataRowNum, callback) {
9314     var dataObj = {};
9315     // if(window.localStorage.getItem("bussinessSystem")){
9316     //     var flag = window.localStorage.getItem("bussinessSystem");
9317     // }
9318     // dataObj.flag = flag;
9319     dataObj.formID = formid;
9320     dataObj.dataRowNum = dataRowNum;
9321     dataObj.data = formbase;
9322     if (customShow.exCouldNumber != undefined && customShow.exCouldNumber != '') {//保存时 传云单标号 李伟民 12-22
9323         _.extend(dataObj, { 'orderCode': customShow.exCouldNumber });
9324     }//保存时 传云单标号 李伟民 12-22
9325     //_.extend(dataObj,{'orderCode': '1012000170900005'});//临时修改
9326     var requestRight = window.commonAjax("/datamanagement/updateFormDataService", dataObj, "POST", true);
9327     requestRight.done(function (rs) {
9328
9329         callback(rs);
9330     });
9331 }
9332
9333 // 获取表单设定数据源信息
9334
9335 // JSON:{"rspCode":"000000","rspDesc":"请求成功","data":[{"测试连接":["actor_id","first_name","last_name","last_update"]}]}
9336 customDataBound.getDatasource = function (formID, callback) {
9337     var dataObj = {};
9338     dataObj.formID = formID;
9339     // dataObj.formID = '8888';
9340     // dataObj.tenantID = "001";
9341     var requestRight = window.commonAjax("/datasource/getDatasourceColumnsNameService", dataObj, "GET", true);
9342
9343     requestRight.done(function (rs) {
9344         if (rs.rspCode == "000000") {
9345             callback(rs.data);
9346         } else {
9347             callback(rs.data);
9348         }
9349     });
9350 }
9351
9352 // 获取当前表单设置字段的数据源信息  数据绑定
9353 // 参数: formID,tenantID
9354 // JSON: {"rspCode":"000000","rspDesc":"请求成功","data":[{"单选按钮组测试":{"datasource":"","textcolumn":"","valuecolumn":""}}]}
9355 customDataBound.getFieldDatasource = function (Datasource, callback) {
9356     url = "/datasource/getDatasourceColumnsValueService?tenantID={tenantID}&databaseName={databaseName}&datasource={datasource}&columnNames={columnNames}&callbackId={callbackId}";
9357     url = url.replace("{databaseName}", Datasource.databaseName);
9358     url = url.replace("{columnNames}", Datasource.columnNames);
9359     url = url.replace("{datasource}", Datasource.datasource);
9360     url = url.replace("{callbackId}", Datasource.callbackId);
9361
9362     window.commonGetJson(url, callback);
9363
9364 }
9365
9366 // 获得主数据
9367 customDataBound.getElement = function (code, callbackId, callback) {
9368     if (code != "") {
9369         var dataObj = {};
9370         dataObj.tenantIDForMaster = 1;
9371         dataObj.code = code;
9372         dataObj.callbackId = callbackId;
9373         //console.log(dataObj);
9374         let customlocalStorage = window.localStorage.getItem("bussinessSystem");
9375         var reg = new RegExp('"', "g"); // service  修改  李元杰 11-16
9376         customlocalStorage = customlocalStorage.replace(reg, ""); // service  修改  李元杰 11-16
9377         console.log(customlocalStorage);
9378         dataObj.flag = customlocalStorage;
9379         var requestRight = window.commonAjax("/te-csc-api/search/base/elementprivate", dataObj, "GET", true);
9380
9381         requestRight.done(function (rs) {
9382             console.log(rs)
9383             if (rs.rspCode == "000000") {
9384                 console.log(rs)
9385                 callback(rs);
9386                 customShow.addTitle();
9387                 SC.money_cur();
9388                 // 12/13
9389
9390                 console.log(window.localStorage.getItem('customShowFlag'))
9391                 if (window.localStorage.getItem('customShowFlag') == 1) {
9392                     // customShow.businessTypeAutoFun( 'businessTypeAuto','budget_itemCostType');
9393                     SC.autoFieldKey();
9394                 }
9395             } else {
9396                 callback(rs);
9397                 console.log(rs)
9398                 toastr.error(rs.rspDesc.responseJSON);
9399             }
9400         });
9401         requestRight.error(function (rs) {
9402             // console.log(rs)
9403             // toastr.error(rs.responseJSON.rspDesc);
9404
9405         })
9406     } else {
9407         callback([]);
9408     }
9409
9410 }
9411
9412 // 获得主数据
9413 customDataBound.getElement1 = function (opt) {
9414     var dataObj = {};
9415     // dataObj.tenantIDForMaster = 1;
9416     // dataObj.code =opt;
9417     // dataObj.callbackId = callbackId;
9418     var result;
9419     var requestRight = window.commonAjax("/te-csc-api/search/base/elementprivate1", opt, "GET", true, false);
9420     requestRight.done(function (rs) {
9421         if (rs.rspCode == "000000") {
9422             result = rs;
9423         } else {
9424             result = rs;
9425         }
9426     });
9427     return result;
9428 }
9429
9430 // 获取当前表单设置字段的数据源信息  API数据取得
9431 // 参数: formID,tenantID
9432 // JSON: {"rspCode":"000000","rspDesc":"请求成功","data":[{"单选按钮组测试":{"datasource":"","textcolumn":"","valuecolumn":""}}]}
9433 customDataBound.getApiDatasource = function (url, callbackId, callback) {
9434     // console.log(1);
9435     var urls = url;
9436     var url = url + "&callbackId={callbackId}";
9437
9438     url = url.replace("{callbackId}", callbackId);
9439     // var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
9440     // xhr.open("GET", urls, true);
9441     // debugger
9442     // xhr.onreadystatechange = function () {
9443     //     var res = JSON.parse(xhr.responseText);
9444     //     console.log(res);
9445     // }
9446     $.ajax({
9447         type: "get",
9448         url: urls,
9449         async: true,
9450         success: function (rs) {
9451             console.log(url);
9452             console.log(rs);
9453             callback(rs, url);
9454         }
9455     });
9456     // // var url = url + "&callbackId={callbackId}";
9457     // // url = url.replace("{callbackId}", callbackId);
9458     // // //////////console.log(url);
9459     // // window.commonGetApiJson(url, callback);
9460     //     //////////console.log(url);
9461     //     //window.commonGetApiJson(url,callback);
9462 }
9463
9464 customDataBound.bindInterface = function (formid) {//绑定接口注册方法//保存前计算费用  李伟民   10 - 31
9465     var dataObj = {};
9466     dataObj.formID = formid;
9467     var accessToken = JSON.parse(localStorage.getItem("token")).accessToken;
9468     dataObj.access_token = accessToken;
9469     var requestRight = window.commonAjax("/forminterface/getFormInterfaceListService", dataObj, "GET", true, false);
9470     requestRight.done(function (rs) {
9471         //console.log(rs);
9472         customBase.interfaceData = rs.data;
9473
9474     })
9475 }//保存前计算费用  李伟民   10 - 31
9476
9477 customDataBound.formsetting = function (formid, callback) {
9478     // 工具栏自定义10/18
9479     $('.edit_form').html("");
9480     var type = "";
9481     var flag = window.localStorage.getItem("customShowFlag");
9482     switch (flag) {
9483         case "1": type = "TJ"; break;
9484         case "3": type = "XG"; break;
9485         case "2": type = "XX"; break;
9486         case "4": type = "LB"; break;
9487     }
9488
9489     //console.log(type);
9490     var dataObj = {};
9491     dataObj.formID = formid;
9492     dataObj.type = type;
9493     console.log(dataObj)
9494     var dataObjFlag = _.cloneDeep(dataObj);
9495     delete dataObjFlag.type
9496     var request = window.commonAjax("/formbase/getFormInfoService", dataObjFlag, "GET", true);
9497     request.done(function (rs) {
9498         if (rs.data != null) {
9499             window.localStorage.setItem('bussinessSystem', rs.data.bussinesssystem)
9500         }
9501     })
9502
9503
9504
9505     var requestRight = window.commonAjax("/formsetting/getFormsettingInfoService", dataObj, "POST", true);
9506     requestRight.done(function (rs) {
9507         customDataBound.bindInterface(formid);
9508         //          ////console.log(rs);
9509         //console.log(type);
9510         if (rs.data.saveable == "0") {
9511             $(".sure_box").hide();
9512         }
9513         if (!rs.data.subCustomButton) {
9514             $("#doself").remove();
9515
9516         }
9517         if (rs.data.subCustomButton) {
9518             // var dd=document.createElement('span');
9519             var formdata = [];
9520             //console.log("查询类型");
9521             //console.log(type);
9522             switch (type) {
9523                 case "TJ": formdata = rs.data.subCustomButton.addCustomButton; break;
9524                 case "XG": formdata = rs.data.subCustomButton.updateCustomButton; break;
9525                 case "XX": formdata = rs.data.subCustomButton.detailedCustomButton; break;
9526                 case "LB": formdata = rs.data.subCustomButton.listCustomButton; break;
9527             }
9528             //console.log("渲染结果");
9529             var srcd = document.createElement('script');
9530             // var tabledata=rs.data.customButtons;
9531             srcd.type = "text/javascript";
9532             _.each(formdata, function (obt, i) {
9533                 var dd = document.createElement('span');
9534                 dd.id = obt.buttonName + i;
9535                 //btn btn-default
9536                 dd.setAttribute("class", "btn_myself");
9537                 dd.setAttribute("buttonId", obt.buttonId);
9538                 dd.innerHTML = "<i class='icon iconfont icon-kongjian_danhangwenben' style='text-align: left;'></i>" + obt.buttonName;
9539
9540                 $(".edit_form").append(dd);
9541
9542                 //console.log(obt.buttonName);
9543                 if (obt.buttonName == "驳回") {
9544                     //console.log("等于撤回");
9545                     // 定义审批流程定义的方法
9546                     // 撤销流程实例
9547
9548                     $("#" + dd.id).click(function () {
9549                         var process = localStorage.getItem("processid");
9550
9551                         //console.log(process);
9552                         var dd = JSON.parse(process);
9553                         var tent = JSON.parse(localStorage.getItem("tenantID")).tenantID;
9554
9555                         //console.log(dd.data);
9556                         window.queryAjaxs("ubp-api-seache/process/inst/log", { "processInstId": dd.data.processInstId }, "POST", true).done(function (res) {
9557                             //console.log("打印回执");
9558                             //console.log(res);
9559                             if (res != undefined) {
9560                                 //console.log("发送请求");
9561                                 window.queryAjaxs("ubp-api-control/process/inst/drawBack", { "processInstId": res.data[0].processInstId, "activityInstId": res.data[0].activityInstId }, "POST", true).done(function (res) {
9562                                     //console.log("打印回执");
9563                                     //console.log(res);
9564                                     if (res.data == 1) {
9565                                         //console.log("撤销成功");
9566                                         customBase.alert('S',"撤销成功");
9567                                         // localStorage.removeItem('userinfo')
9568                                     }
9569                                 })
9570                             }
9571
9572                         })
9573
9574                     });
9575
9576                     // 结束流程实例
9577                 } else if (obt.buttonName == "结束") {
9578                     $("#" + dd.id)[0].setAttribute('data-toggle', "modal");
9579                     $("#" + dd.id)[0].setAttribute('data-target', ".bs-example-modal-sm");
9580                     $("#" + dd.id).click(function () {
9581                         var processLog = JSON.parse(localStorage.getItem("processLog"));
9582                         if (processLog != null && processLog != undefined) {
9583                         } else {
9584                             $("#liucheng").html("<h3 class='sp_title'>请先创建一个流程<h3>");
9585                             return null;
9586                         }
9587                         if (processLog[0].processState == 60) {
9588                             $("#liucheng").html("<h3 class='sp_title'>流程已结束<h3>");
9589                             return null;
9590                         } else {
9591                             var inputs = "<h3 class='sp_title'>是否确认结束?<h3><br/>"
9592                                 + "<div class='footerbtn' style='display:flex;justify-content:space-around;'><input class='btn btn-default choosebtn2' type='button' value='确定' onclick='over(true)'/>&nbsp;&nbsp;<input type='button' class='btn btn-default choosebtn' value='取消' onclick='over(false)'/></div>";
9593                             $("#liucheng").html(inputs);
9594                             $("#sssd").click();
9595
9596                         }
9597                     });
9598
9599                 } else if (obt.buttonName == "退回") {
9600                     $("#" + dd.id)[0].setAttribute('data-toggle', "modal");
9601                     $("#" + dd.id)[0].setAttribute('data-target', ".bs-example-modal-sm");
9602                     $("#" + dd.id).click(function () {
9603                         var processLog = JSON.parse(localStorage.getItem("processLog"));
9604                         if (processLog[0].processState == 60) {
9605                             customBase.alert('E',"流程已结束");
9606                             return null;
9607                         } else {
9608                             if (processLog != "null" && processLog != undefined) {
9609                                 console.log(processLog.length);
9610                                 if (processLog.length == 1) {
9611                                     customBase.alert('W',"无可退回活动");
9612                                     return null;
9613                                 }
9614                             } else {
9615                                 customBase.alert('W',"请先创建一个流程");
9616                                 return;
9617                             }
9618                             //请求可退回活动项
9619                             var isshow = false;
9620                             var ss = {
9621                                 "processInstId": processLog[0].processInstId
9622                             }
9623                             var requestSingleForm = window.commonAjax("/ubp-api-seache/process/get/back", ss, "POST", true);
9624                             requestSingleForm.done(function (rs) {
9625                                 console.log(rs);
9626                                 var res = rs.data;
9627                                 if (res != undefined & res != null) {
9628
9629                                     if (res.length > 0) {
9630
9631                                         var inputs = "<h3 class='sp_title'>请选择要退回的活动</h3><br/>";
9632                                         for (var i = 0; i < res.length; i++) {
9633                                             if (i == 0) {
9634                                                 inputs += "<input style='margin-left:-9px !important;' type='radio' onClick='choosebox(" + i + ")' class='act acts' value=" + res[i].activityDefId + " name='task'   />" + res[i].activityDefName + "</br>";
9635                                             } else {
9636                                                 inputs += "<input  type='radio'  onClick='choosebox(" + i + ")' class='act acts' value=" + res[i].activityDefId + " name='task'  />" + res[i].activityDefName + "</br>";
9637                                             }
9638                                         }
9639                                         inputs += "<div class='footerbtn' style='display:flex;justify-content:space-around;'><input class='btn btn-default choosebtn' type='button' value='取消' onclick='tui(false)'/><input type='button' class='btn btn-default choosebtn2' value='确定' onclick='tui(true," + activeitem + ")'/>";
9640                                         inputs += "</div>";
9641                                         console.log(inputs);
9642                                         $("#liucheng").html(inputs);
9643
9644
9645                                         // callback(); 
9646                                     }
9647                                 } else {
9648                                     $("#liucheng").html("<h3 class='sp_title'>无可退回项<h3>");
9649
9650                                     return null;
9651                                 }
9652                             });
9653
9654                         }
9655                     });
9656                 } else if (obt.buttonName == "审批") {
9657                     $("#" + dd.id).click(function () {
9658
9659                         var processLog = JSON.parse(localStorage.getItem("processLog"));
9660                         if (processLog != null && processLog != undefined) {
9661                         } else {
9662                             customBase.alert('W',"请先创建一个流程");
9663                             return null;
9664                         }
9665                         if (processLog[0].processState == 60) {
9666                             customBase.alert('E',"流程已结束");
9667                             return null;
9668                         }
9669                         var inputs = "<h3 class='sp_title'>请输入审批语</h3><br/>" + "<textarea maxlength='200' onKeyUp='listenword()' class='stexta' type='test' id='datas'></textarea><span class='wordwrap'><var class='word'>0</var>/200</span><br/>"
9670                             + "<div class='footerbtn' style='display:flex;justify-content:space-around;'><input class='btn btn-default choosebtn'  type='button' value='取消' onclick='zhixing(false)'/><input class='btn btn-default choosebtn2' type='button' value='确定' onclick='zhixing(true)'/></div>";
9671                         $("#liucheng").html(inputs);
9672                         $("#" + dd.id)[0].setAttribute('data-toggle', "modal");
9673                         $("#" + dd.id)[0].setAttribute('data-target', ".bs-example-modal-sm");
9674                     });
9675
9676                 } else {
9677                     $("#" + dd.id).click(function () {
9678
9679                         var fuc = obt.methodName + "()";
9680                         eval(fuc);
9681                         //console.log(fuc);
9682                         //调用自定义js中的方法
9683                         //console.log("调用自定义方法");
9684                         fuc;
9685
9686                     });
9687                 }
9688             });
9689
9690             srcd.src = rs.data.resourceFilePath;
9691
9692             // $("#customShow").append(srcd);
9693             if(rs.data.resourceFilePath != undefined && flag != 3 && rs.data.resourceFilePath != ''){//自定义JS加载修改  李伟民  0109
9694                 document.getElementsByTagName("head")[0].appendChild(srcd); // 接口注册 初期化事件 李伟民 12-18
9695                 srcd.onload = function () {
9696                     _.each(customBase.interfaceData, function (data) {
9697                         if (data.interfacemethod == "interfaceInit3rd") {
9698                             if (data.customInterfacemethod != undefined && data.customInterfacemethod != '') {
9699                                 var funstr = data.customInterfacemethod + "()";
9700                                 eval(funstr);
9701                             }
9702                         }
9703                     });
9704                     callback(rs);//自定义JS加载修改  李伟民  0109
9705                 }
9706             }else{
9707                 callback(rs);//自定义JS加载修改  李伟民  0109
9708             }
9709             
9710             //  $(".preview-edit-pane").append(dd);
9711             //  $("#"+dd.id).click(function(){
9712
9713             //     var fuc=arr[1]+"()";
9714             //     eval(fuc);
9715             //     ////console.log(fuc);
9716
9717             //     ////console.log("调用自定义方法");
9718             //     fuc;
9719
9720             //  });
9721         }else{
9722             callback(rs);//自定义JS加载修改  李伟民  0109
9723         }
9724     });
9725     var dataObjDo = {};
9726     dataObjDo = dataObj;
9727     delete dataObjDo.type
9728     console.log(dataObj)
9729     var requestRight = window.commonAjax("/tabConfiguration/queryTabConfiguration", dataObjDo, "POST", true);
9730     requestRight.done(function (rs) {
9731         //2017/10/31 李元杰 附件 流程先洗 选项卡添加    
9732         console.log(rs)
9733         $('.boxTwo').hide();
9734         $('.sTab').find('ul li').eq(1).hide();
9735         $('.boxThr').hide();
9736         $('.sTab').find('ul li').eq(2).hide();
9737         if (rs.data != '') {
9738             if (rs.data[0].appendix == "do") {
9739                 console.log($('.sTab').find('ul li'))
9740                 $('.sTab').find('ul li').eq(1).show();
9741             } else {
9742                 $('.boxTwo').hide();
9743                 $('.sTab').find('ul li').eq(1).hide();
9744             }
9745             if (rs.data[0].processInfo == "do") {
9746                 $('.sTab').find('ul li').eq(2).show();
9747             } else {
9748                 $('.boxThr').hide();
9749                 $('.sTab').find('ul li').eq(2).hide();
9750             }
9751         }
9752     });
9753 }
9754
9755
9756 var xhSelect = xhSelect || {};
9757 xhSelect.scope = {
9758     sel_val_lst: {
9759         // 'F073001':"常规出差"
9760     },
9761     rm_optionFlag: false
9762 };
9763
9764 xhSelect.options = {
9765     selectId: "",
9766     multiple: false,
9767     listData: [],
9768     width: 200,
9769     setDiv: ""
9770 }
9771 xhSelect.setValue = function (itemId, listData) {
9772     xhSelect.setValue(itemId, listData, 0);
9773 }
9774 xhSelect.setValue = function (itemId, listData, N) {
9775     var selectItme = $("#" + itemId + " .selectItme");
9776     var listDataJson = {};
9777     if (_.isString(listData)) {// 下拉款填值  修改  李伟民 11-14
9778         listData = listData.split(",")
9779     }// 下拉款填值  修改  李伟民 11-14
9780     console.log(listData);
9781     for (var i = 0; i < listData.length; i++) {
9782         listDataJson[listData[i]] = "1";
9783     }
9784
9785     var $options = $($("#" + itemId)[0]).find('select > option');
9786     var vals_selected = [];
9787     var j = 0;
9788     $options.each(function () {
9789         for (var jsonstr in listDataJson) {
9790             if ($(this).val() == jsonstr) {
9791                 vals_selected[j] = {};
9792                 vals_selected[j].value = $(this).val();
9793                 vals_selected[j].label = $(this).text();
9794                 j++;
9795             }
9796         }
9797     });
9798     var $el = $($("." + itemId + "value")[N]);
9799     var set_valueleft = function (vals_selected) {
9800         var $divContainer = "";
9801         var selectedItem = {};
9802         for (var i = 0; i < vals_selected.length; i++) {
d14bd1 9803             $divContainer += '<div class="val-card ng-binding ng-scope ' + vals_selected[i].value +
aec305 9804                 'Class" ng-repeat="sel_val in sel_val_lst track by $index" ng-show="true" multiple="" load-data="" style="height:40px;line-height:25px;">' +
Z 9805                 vals_selected[i].label + '<a onclick="xhSelect.rm_option(this,\'' + vals_selected[i].value +
9806                 '\')" ng-href="javascript:void(0);" href="javascript:void(0);">' + '  <i  class="icon iconfont icon-guanbijiantou"  val="' +
9807                 vals_selected[i].value + '" style="color:#20b4aa;"></i></li>' + ' </a>' + ' </div>';
9808
9809
4d1219 9810
B 9811             selectedItem[vals_selected[i].value] = "1";
9812         }
9813         $divContainer += '<div class="suffix">' + '<i class="fa fa-angle-down" aria-hidden="true"></i>' + '</div>';
9814         $el.find(".select-container").empty();
9815         $el.find(".select-container").append($divContainer);
9816         var selectedItemJson = JSON.stringify(selectedItem);
9817         if ($el.find(".selectItme").length != 0) {
9818             $el.find(".selectItme")[0].setAttribute("value", selectedItemJson);
9819         }
9820
9821     };
9822     set_valueleft(vals_selected);
9823 }
9824 xhSelect.getValue = function (itemId) {
9825     var returnItem = [];
9826     var selectItme = $("#" + itemId + " .selectItme");
9827     console.log(selectItme)
9828     for (var i = 0; i < selectItme.length; i++) {
9829         if (selectItme[i].getAttribute("value") == "") {
9830             var selectItmeJson = {};
9831         } else {
9832             ////console.log(selectItme[i].getAttribute("value"));
9833             var selectItmeJson = $.parseJSON(selectItme[i].getAttribute("value"));
9834         }
9835
9836         var jn = 0;
9837         returnItem[i] = [];
9838         for (j in selectItmeJson) {
9839             returnItem[i][jn] = j;
9840             jn++;
9841         }
9842     }
9843     return returnItem;
9844 }
9845 // 下拉框主数据渲染
9846 xhSelect.setXhSelect = function (options) {
9847     ////console.log(options);
9848     ////console.log(_.cloneDeep(xhSelect.options));
9849     //解决主数据重复
9850     var options_xh = _.cloneDeep(xhSelect.options);
9851     options_xh.listData = [];
9852     //解决主数据重复END
9853     options = $.extend(true, options_xh, options);
9854     var optionArr = "";
9855     console.log(options.selectId);
9856     ////console.log(options.listData);
9857     //        ////console.log(options.listData.length);
9858     for (var i = 0; i < options.listData.length; i++) {
9859         optionArr += '<option value="' + options.listData[i].value + '">' + options.listData[i].text + '</option>';
9860     }
9861     console.log(optionArr);
9862     var multiple = "";
9863     if (options.multiple) {
9864         multiple = 'multiple';
9865     }
9866
9867     var $xhSelectDiv = '' +
9868         '<div class="selectClass">' +
9869         '<div ng-transclude="" style="display:none;">' +
9870         '<select class="select_get ng-scope" load-data="" ' + multiple + ' >' +
9871         optionArr +
9872         '</select>' +
9873         '</div>' +
9874         '<div class="selectItme" style="display:none;" value=""></div>' +
9875         '<div class="select3-element" style="width:100%;max-width: ' + options.width + 'px">' +
9876         '            <div  class="select-container select-container_box" gccolname="ex_c11">  ' +
9877         '                    <div class="suffix">' +
9878         '                            <i class="fa fa-angle-down" aria-hidden="true"></i>' +
9879         '                    </div>' +
9880         '            </div>' +
9881         '    </div> ' +
9882         '</div>';
9883     console.log(options);
9884     if (options.setDiv == '') {
9885         var $el = $("#" + options.selectId);
9886     } else {
9887         var $el = $("." + options.setDiv);
9888     }
9889     console.log(optionArr)
9890     console.log($xhSelectDiv)
9891     _.each($el, function (sel) {//添加记录 重复问题  李伟民11-14   主数据丢失  11-29 再次修改
9892         if ($(sel).find(".selectClass").length == 0) {
9893             $(sel).append($xhSelectDiv)
9894         } else {
9895             $(sel).find(".selectClass").find(".select_get").html(optionArr);
9896         }
9897     })//添加记录 重复问题  李伟民11-14   主数据丢失  11-29 再次修改
9898
9899
9900     //添加记录 重复问题  李伟民11-14
9901     //        $("#"+options.selectId).find()
9902
9903     xhSelect.selectContainer(options);
9904     customLinkageAnalysis.bindLinkage();
9905     //行程排序初期化
9906     customShow.journeySort();
9907 }
9908 xhSelect.rm_option = function (val, vals_selected) {
9909     xhSelect.scope.rm_optionFlag = true;
9910     console.log(val);
9911     console.log(vals_selected)
9912     $('div.drop_down_sel').remove();
9913     var selectItmeJson = $($(val).parent().parent().parent().parent()).find(".selectItme")[0].getAttribute("value");
9914
9915     var selectItme = $.parseJSON(selectItmeJson);
9916     delete selectItme[vals_selected];
9917     selectItmeJson = JSON.stringify(selectItme);
9918     $($(val).parent().parent().parent().parent()).find(".selectItme")[0].setAttribute('value', selectItmeJson);
d14bd1 9919
Z 9920     //张吉男修改 下拉框默认值不可以清空
9921     var cla=new RegExp("disableColor");
9922     //console.log(cla.test($(val).parent().parent().attr("class")));
9923     //判断下拉框是否是可编辑
9924     if(!(cla.test($(val).parent().parent().attr("class")))){
9925         $(val).parent().remove();
9926     }
9927
4d1219 9928     setTimeout(function () {
B 9929         xhSelect.scope.rm_optionFlag = false;
9930     }, 500);
9931 }
9932 xhSelect.selectContainer = function (options) {
9933     var itemId = options.selectId;
9934     if (options.setDiv == '') {
9935         var $el = $("#" + itemId);
9936     } else {
9937         var $el = $("." + options.setDiv);
9938     }
9939     $el.find('div.select-container').on('click', function (event) {
9940         var selectedItem = $el.find(".selectItme")[0].getAttribute("value");
9941         //  12/4 李元杰
9942         $('.zTreeDemoBackground').css("display", "none");
9943         $(".search_input").css("display", "none");
9944         console.log(selectedItem);
9945         console.log(event);
9946         console.log($(this))
9947         ////console.log("-------------------this-----------------------------------");
9948         if ($el[0].className.indexOf("readonly") > -1) {
9949             return;
9950         }
9951         if (selectedItem != "") {
9952             selectedItem = $.parseJSON(selectedItem);
9953         }
9954
9955         if (xhSelect.scope.rm_optionFlag) {
9956             return;
9957         }
9958         console.log(2)
9959         $('div.drop_down_sel').remove();
9960         var $select = $el.find('select');
9961         var isMultiple = $select.attr('multiple');
9962         var $options = $el.find('select > option');
9963         ////console.log($el);
9964         ////console.log($options);
9965         var $options_str = '<ul>' + '<li class="sel_query">' + '<input type="text" name="query" >' + '</li>' + '</ul>';
9966
9967         $options_str += '<div class="select "><ul class="line">';
9968
9969         if ($select.attr('multiple')) {
9970             $options_str += '<li class="ui-state-default" style="height:28px"><span class="custom-check "' +
9971                 ' value="All" label="全选" ><i class="label"></i>全选</span></li>';
9972         }
9973         $options.each(function () {
9974             var checked = '';
9975             if (selectedItem[$(this).val()] != undefined) {
9976                 checked = 'cur';
9977             }
9978             $options_str += '<li class="ui-state-default" style="height:28px"><span class="custom-check ' + checked +
9979                 '" value="' + $(this).val() + '" label="' + $(this).text() + '' + '" title="' + $(this).text() + '"><i class="label"></i>' + $(this).text() + '</span></li>'
9980         });
9981
9982         $options_str += '</ul></div>';
9983         console.log($options_str)
9984         console.log(3)
9985         $("div.drop_down_sel").remove();
9986         var $select_obj = $('<div drop-down-selector="" filterlist="searchlist" class="drop_down_sel" style="position: absolute;">' + $options_str + '</div>');
9987         $el.find('div.select3-element').append($select_obj);
9988         $('body').off('click.sel').on('click.sel', function () {
9989             console.log(5);
9990             $('div.drop_down_sel').remove();
9991             $('.zTreeDemoBackground').css("display", "none");
9992             $(".search_input").css("display", "none");
9993         });
9994         $('div.drop_down_sel').off('click.sel').on('click.sel', function (event) {
9995
9996             event.stopPropagation();
9997         });
9998         console.log(6)
9999         $select_obj.find('input[name="query"]').on('keyup',
10000             function () {
10001                 var $el = $(this);
10002                 var inputs = $select_obj.find('.custom-check');
10003                 inputs.each(function () {
10004                     var val = $(this).attr('label');
10005                     var input_val = $el.val();
10006                     if (val.indexOf(input_val) > -1) {
10007                         $(this).closest('li').show();
10008                     } else {
10009                         $(this).closest('li').hide();
10010                     }
10011                 });
10012             });
10013
10014         $select_obj.find('.custom-check').on('click', function () {
10015             if (this.className.indexOf("readonly") > -1) {
10016                 return;
10017             }
10018             $(this).toggleClass('cur');
10019             if ($(this)[0].getAttribute("value") == "All") {
10020                 if (this.className.indexOf("cur") > -1) {
10021                     $($(this).parent().parent()).find(".custom-check").addClass("cur");
10022                 } else {
10023                     $($(this).parent().parent()).find(".cur").removeClass('cur');
10024                 }
10025             }
10026
10027             var set_valueleft = function (vals_selected) {
10028                 var $divContainer = "";
10029                 var selectedItem = {};
10030                 for (var i = 0; i < vals_selected.length; i++) {
10031                     $divContainer += '<div class="val-card ng-binding ng-scope ' + vals_selected[i].value +
10032                         'Class" ng-repeat="sel_val in sel_val_lst track by $index" ng-show="true" multiple="" load-data="" style="height:40px;line-height:25px;">' +
10033                         vals_selected[i].label + '<a onclick="xhSelect.rm_option(this,\'' + vals_selected[i].value +
10034                         '\')" ng-href="javascript:void(0);" href="javascript:void(0);">' + '  <i  class="icon iconfont icon-guanbijiantou"  val="' +
10035                         vals_selected[i].value + '" style="color:#20b4aa;"></i>' + ' </a>' + ' </div>';
10036                     selectedItem[vals_selected[i].value] = "1";
10037                 }
10038                 $divContainer += '<div class="suffix">' + '<i class="fa fa-angle-down" aria-hidden="true"></i>' + '</div>';
10039                 $el.find(".select-container").empty();
10040                 $el.find(".select-container").append($divContainer);
10041                 var selectedItemJson = JSON.stringify(selectedItem);
10042                 $el.find(".selectItme")[0].setAttribute("value", selectedItemJson);
10043                 $el.find(".select_get").trigger("change.value");//下拉框 公式
10044             };
10045             var vals_selected = [];
10046             var vals_selected_item = [];
10047             var checkboxChecked = false;
10048             var checkboxValue = $(this)[0].getAttribute("value");
10049             var checkboxLabel = $(this)[0].getAttribute("label");
10050             if ($(this)[0].className.indexOf('cur') > -1) {
10051                 checkboxChecked = true;
10052             }
10053             if (!isMultiple) {
10054                 vals_selected = [{
10055                     'value': checkboxValue,
10056                     'label': checkboxLabel
10057                 }];
10058                 set_valueleft(vals_selected);
10059                 console.log(7)
10060                 $('div.drop_down_sel').remove();
10061             } else {
10062                 var vls = [];
10063                 var values = $($(this).parent().parent()).find('.cur');
10064                 var j = 0;
10065                 for (var i = 0; i < values.length; i++) {
10066                     if (values[i].getAttribute("value") != "All") {
10067                         vals_selected[j] = {};
10068                         vals_selected[j].value = values[i].getAttribute("value");
10069                         vals_selected[j].label = values[i].getAttribute("label");
10070                         j++;
10071                     }
10072                 }
10073                 set_valueleft(vals_selected);
10074             }
10075         });
10076         event.stopPropagation();
10077     });
10078 }
10079
10080 //customBase.reCharge = function(){//重新记账  李伟民 2017-10-18 21:30
10081 //    //console.log(customBase);
10082 //    //console.log(customShow);
10083 //    var rePostData = {};
10084 //    rePostData['formID'] = customShow.options.formid;
10085 //    rePostData['dataRowNum'] = customShow.options.dataRowNum;
10086 //    var reCharge_request =  window.cloudAjax("epc-tenant/accounting/record",rePostData,"POST",true);
10087 //    reCharge_request.done(function(res){
10088 //        //console.log(res);
10089 //    })
10090 //}//重新记账  李伟民 2017-10-18 21:30 end
10091
10092 //customBase.checkItem = function(){//提交验证 李伟民2017-10-19 15:52
10093 //    //console.log(customBase);
10094 //    //console.log(customShow);
10095 //     //画面项目取得 --------------------------画面项目取得------
10096 //     var items = customShow.getItems();
10097 //         ////console.log(items)
10098 //     // 画面check
10099 //     var returnfromCheck =  customShow.initEvent.fromCheck(items); //--------------------
10100 //     if(returnfromCheck){
10101 ////      return;
10102 //     }
10103 //
10104 //
10105 //         var rules = customShow.options.jsonLinkage;
10106 //        if(!_.isNull(rules) && rules != undefined){
10107 //            rules = JSON.parse(rules);
10108 //            //console.log(rules);
10109 //            var checkId = [];
10110 //            _.each(rules,function(ru){
10111 //                _.each(ru.results,function(res){
10112 //                    if(res.mode == "2" || res.mode == "0"){
10113 //                        checkId.push(ru.event.eventFieldId);
10114 //                        return false;
10115 //                    }
10116 //                })
10117 //            });
10118 //            checkId = _.uniq(checkId);
10119 //            //console.log(checkId);
10120 //            _.each(checkId,function(cid){
10121 //                $("[id='" + cid + "']").trigger("change.check");
10122 //            });
10123 //        }
10124 //}//提交验证 李伟民2017-10-19 15:52 end
10125
10126 // function checkSameDay(day1, day2) {//判断是否为同一天  李伟民 2017-10-20 17:00
10127 //     var seconds;
10128 //     seconds = day1 - day2;
10129 //     //console.log(seconds);
10130 //     if (seconds < 24 * 60 * 60 * 1000 && seconds >= 0) {
10131 //         return true;
10132 //     } else {
10133 //         return false;
10134 //     }
10135 // }//判断是否为同一天  李伟民 2017-10-20 17:00 end
10136
10137 // customBase.checkTimeCross = function () {//跨行程验证时间 李伟民 2017-10-20 11:35
10138 //     //console.log(customBase);
10139 //     //console.log(customShow);
10140 //     var items = customShow.getItems();
10141 //     //console.log(items);
10142 //     var itemKey = _.keys(customBase.options.customItems);
10143 //     var subItem = [];
10144 //     _.each(itemKey, function (keys) {
10145 //         if (customBase.options.customItems[keys].type == "subform") {
10146 //             subItem.push(customBase.options.customItems[keys].fieldKey);
10147 //         }
10148 //     });
10149 //     var FromDateArr = [];
10150 //     var LeaveDateArr = [];
10151 //     //console.log(subItem);
10152 //     _.each(subItem, function (sub) {
10153 //         if (items[sub] != undefined) {
10154 //             _.each(items[sub], function (isub, i) {
10155 //                 if (isub.FromDate != undefined) {
10156 //                     FromDateArr.push({ "value": new Date(isub.FromDate), "num": i, "property": customBase.options.customItems['FromDate'] });
10157 //                 }
10158 //                 if (isub.LeaveDate != undefined) {
10159 //                     LeaveDateArr.push({ "value": new Date(isub.LeaveDate), "num": i, "property": customBase.options.customItems['LeaveDate'] });
10160 //                 }
10161 //             });
10162 //         }
10163 //     });
10164 //     //console.log(FromDateArr);
10165 //     //console.log(LeaveDateArr);
10166 //     if (FromDateArr.length > 1 && LeaveDateArr.length > 1 && FromDateArr.length == LeaveDateArr.length) {
10167 //         _.each(FromDateArr, function (fdate, k) {
10168 //             if (k > 0) {
10169 //                 //console.log(checkSameDay(fdate.value,LeaveDateArr[k-1].value));
10170 //                 if (checkSameDay(fdate.value, LeaveDateArr[k - 1].value) == false) {
10171 //                     var message = customShow.options.customItemShow.item[fdate.property.id].tag_Attribute.title + "与上一行程不连续";
10172 //                     customLinkageAnalysis.setMessage(fdate.property.id, message, k);
10173 //                 }
10174 //             }
10175 //         });
10176 //     }
10177 // }//跨行程验证时间 李伟民 2017-10-20 11:35 end
10178 // customBase.checkLandCross = function () {//跨行程验地点 李伟民 2017-10-20 11:35
10179 //     var items = customShow.getItems();
10180 //     //console.log(items);
10181 //     var itemKey = _.keys(customBase.options.customItems);
10182 //     var subItem = [];
10183 //     _.each(itemKey, function (keys) {
10184 //         if (customBase.options.customItems[keys].type == "subform") {
10185 //             subItem.push(customBase.options.customItems[keys].fieldKey);
10186 //         }
10187 //     });
10188 //     var FromLandeArr = [];
10189 //     var ToLandArr = [];
10190 //     _.each(subItem, function (sub) {
10191 //         if (items[sub] != undefined) {
10192 //             _.each(items[sub], function (isub, i) {
10193 //                 if (isub.From_site != undefined) {
10194 //                     FromLandeArr.push({ "value": isub.From_site[0], "num": i, "property": customBase.options.customItems['From_site'] });
10195 //                 }
10196 //                 if (isub.To_site != undefined) {
10197 //                     ToLandArr.push({ "value": isub.To_site[0], "num": i, "property": customBase.options.customItems['To_site'] });
10198 //                 }
10199 //             });
10200 //         }
10201 //     });
10202 //     if (FromLandeArr.length > 1 && ToLandArr.length > 1 && FromLandeArr.length == ToLandArr.length) {
10203 //         _.each(FromLandeArr, function (fland, k) {
10204 //             if (k > 0) {
10205 //                 customLinkageAnalysis.clearMessage(fland.property.id, k);
10206 //                 //console.log(fland.value != ToLandArr[k-1].value);
10207 //                 if (fland.value != ToLandArr[k - 1].value) {
10208 //                     var message = customShow.options.customItemShow.item[fland.property.id].tag_Attribute.title + "与上一行程不连续";
10209 //                     customLinkageAnalysis.setMessage(fland.property.id, message, k);
10210 //                 }
10211 //             }
10212 //         });
10213 //     }
10214 // }//跨行程验地点 李伟民 2017-10-20 11:35 end
10215 //自定义表单扩展函数 增加行 删除行
10216 customShow.addRow = function (subId, data) {
10217     console.log(data);
10218     console.log(subId);
10219     console.log($("#" + subId));
10220     console.log($("#" + subId).find(".trContentClass"));
10221     $("#" + subId).find(".trContentClass").remove();
10222     // console.log(data[0].length - 1);
10223     for (var i = 0; i < data[0].length; i++) {
10224         var itemId = subId;
10225         var showClass = "customViewUEditorCss";
10226         var item = customBase.options.customItems[customShow.options.customItemShow.item[itemId].tag_Attribute.alias].cloneDiv;
10227         //console.log(customShow.options)
10228         console.log(itemId, item)
10229         console.log(itemId, customBase.options.customItems)
10230         //子表单情况为U情况
10231         if (item == undefined) {// 子表单回显 修改  李伟民 11-10
10232             var tbody = $("." + showClass + " #" + itemId + "ActiveId").find("tbody");
10233             tbody = tbody[0].cloneNode(true);
10234             $(tbody).find(".select2").remove();
10235             console.log($(tbody).html());
10236             $(tbody).find(".tdTitleClass").closest("tr").addClass("table_title");
10237             $(tbody).find(".dropdowntypeCss").select2({ theme: "classic" });
10238             //        $(tbody).find(".zTreeDemoBackground").select2({theme: "classic"});
10239             if ($(tbody).find(".table_title").length > 0) {
10240                 //删除头行
10241                 $(tbody).find(".table_title").remove();
10242             }
10243             if ($(tbody).find(".trContentClass").length > 1) {// 去除重复的tr  李伟民 11-14
10244                 $($(tbody).find(".trContentClass")[0]).siblings().remove();
10245             }// 去除重复的tr  李伟民 11-14
10246             //        $(tbody).find(".cfg_contentNone").removeClass("cfg_contentNone");
10247             tbody = customShow.addsubformListInit(itemId, $(tbody).find("tr"));
10248             console.log(tbody);
10249             console.log(itemId);
10250             console.log($(tbody).find("#" + itemId).attr("class"));
10251             $($("." + showClass + " #" + itemId + "ActiveId").find("table")[0]).append(tbody);// 子表单回显 修改  李伟民 11-10
10252             customShow.hidesubform();
10253             customShow.setXhSelectList(false);//添加记录 重复问题  李伟民11-14
10254         } else {
10255             console.log(item);
10256             item = item[0].cloneNode(true);
10257             console.log(item);
10258             $(item).find(".select2").remove();
10259             $(item).find(".dropdowntypeCss").select2({ theme: "classic" });
10260
10261             $(item).find(".subformAddiconShow .cfg_contentNone").removeClass("cfg_contentNone");
10262             item = customShow.addsubformListInit(itemId, item);
10263             $($("." + showClass + " #" + itemId + "ActiveId").find("table")[0]).append(item);
10264
10265         }
10266         customShow.setXhSelectList(true);//添加记录 重复问题  李伟民11-14
10267         customShow.addtree(itemId, item);
10268         //子表单事件追加
10269         customShow.clickBindSubform();
10270         //公式初期化
10271         customLinkageAnalysis.bindLinkage();
10272         customShow.oneTotle();
10273         $('.iconfontcolor').on('click', function () {
10274             $(this).parent().parent().parent().remove();
10275         });
10276         console.log($(item))
10277         customShow.addtree(itemId, item);
10278     }
10279     var customItems = customBase.options.customItems;
10280     console.log(customItems)
10281     var order = $($("#" + subId + "ActiveId .trContentClass")[0]).find(".tdContentClass");
10282     var orderid = [];
10283     var orderObj = {};
10284     _.each(order, opt => {
10285         if ($(opt).find("div").children().eq(0).attr("id")) {
10286             orderid.push($(opt).find("div").children().eq(0).attr("id"));
10287         } else {
10288             orderid.push($(opt).find("div").children().eq(1).attr("id"));
10289         }
10290     });
10291     console.log(orderid);
10292     orderid.splice(0, 1);
10293     console.log(orderid);
10294     var subArr = [];
10295     console.log(subId)
10296     _.each(customItems, opt => {
10297         if (opt.parentsubFormNum == subId.replace("itemId_", "")) {
10298             subArr.push(opt);
10299         }
10300     });
10301     _.remove(subArr, n => {
10302         return n.fieldKey == "DATAROWNUM";
10303     })
10304     console.log(subArr);
10305     var endArr = [];
10306     _.each(orderid, opt => {
10307         var a = {};
10308         _.each(subArr, o => {
10309             if (opt == o.id) {
10310                 a = o;
10311             }
10312         });
10313         endArr.push(a);
10314     })
10315     console.log(endArr);
10316     console.log(data);
10317     _.each(endArr, (opts, i) => {
10318         console.log(opts.id, opts.type, data[i]);
10319         if (opts.type == "dropdownlist") {// 不可修改  控件type  李伟民  11-17
10320             customBase.setItemValue(opts.id, "dropdownlistText", data[i], "", "");
10321         } else {
10322             customBase.setItemValue(opts.id, opts.type, data[i], "", "");
10323         }
10324     });
10325     console.log(subId)
10326     customShow.subTotle(subId)
10327 };
10328 //关联表单控件  列表渲染
10329 createTable = function (rs, formId, formhuixian, head, $iconId, addVal) {
10330     var showVal = [];
10331     var iconAttr = customShow.options.customItemShow.item[$iconId];//关联数据 函数 数据源 李伟民  11-07
10332     //接收table内容请求
10333     var content = "";
10334     var counts = "";
10335     $(".requestMenu").empty();
10336     //渲染table头部变量;
10337     let headtr = "";
10338     //渲染table内容变量
10339     let contentdata = "";
10340     //表头渲染数据
10341     //console.log(head);
10342     _.remove(head, n => {
10343         return n.fieldKey == "DATAROWNUM";
10344     });
10345     _.each(head, opt => {
10346         headtr += '<td>' + opt.title + '</td>';
10347     });
10348     let head_tr = $("<tr class='headtr'></tr>");
10349     head_tr.append('<td class="td1">选择</td>' + headtr);
10350     $(".requestMenu").append(head_tr);
10351
10352     //console.log(rs)
10353     if (rs.data != undefined && !_.isNull(rs.data) && rs.data.count != undefined) {
10354         counts = rs.data.count;
10355     }
10356     if (rs.data != undefined && !_.isNull(rs.data)) {
10357         content = rs.data.list;
10358     } else {
10359         content = [];
10360     }
10361     // if(iconAttr.tag_Attribute.relevancesourcetype == "fundata"){
10362     //     codeContent = rs.data.list;
10363     // }else{
10364     //     codeContent = rs.data.code;
10365     // }
10366     console.log(content);
10367     if (content.length == 0) {
10368         var div_empty = $("<div><i style='width:20px;height:20px;' class='fa fa-envelope-o' aria-hidden='true'></i><p>您还没有数据显示</p></div>");
10369         $(".requestMenu").append(div_empty);
10370     } else {
10371         _.each(content, (opt) => {
10372             _.each(formhuixian, n => {
10373                 if (opt.DATAROWNUM == n.DATAROWNUM) {
10374                     opt.show = "cur";
10375                 }
10376             });
10377             var contentdata = "";
10378             _.each(head, opts => {
10379                 contentdata += '<td>' + opt[opts.fieldKey] + '</td>';
10380             });
10381             var tr = $("<tr class='bodytr'></tr>");
10382             tr.append('<td class="td1"><li class="checkLine"><span class="custom-check ' + opt.show + '"></span><i class="label"></i></li></td>' + contentdata);
10383             console.log(tr);
10384             $(".requestMenu").append(tr);
10385         });
10386     }
10387     //console.log(formhuixian);
10388
10389
10390     if (formhuixian != undefined) {
10391         addVal = formhuixian;
10392     }
10393     let show = "";
10394     var showObj = {};
10395     //选择方法
10396     head.push({ fieldKey: "DATAROWNUM", title: "DATAROWNUM" });
10397     //判断单选多选
10398     var selItem = customShow.options.customItemShow.item;
10399     console.log(selItem);
10400     var sel = "";
10401     var datarow = "";
10402     var tag_Id = "";
10403     console.log(selItem);
10404     for (let key in selItem) {
10405         if (key == $iconId) {
10406             sel = selItem[key].tag_Attribute.mytextSel;
10407             console.log(selItem[key].tag_Attribute.singleSetValue);
10408             if (selItem[key].tag_Attribute.singleSetValue != "itemId") {
10409                 datarow = JSON.parse(selItem[key].tag_Attribute.singleSetValue).columnOrderNum;
10410                 tag_Id = JSON.parse(selItem[key].tag_Attribute.singleSetValue).tag_Id;
10411             }
10412         }
10413     }
10414     console.log(sel)
10415     if (sel == "single") {
10416         $(".custom-check").on("click", function () {
10417             var addVals = [];
10418             var showVals = [];
10419             $(this).parent().parent().parent().siblings().find(".custom-check").removeClass('cur');
10420             $(this).toggleClass('cur');
10421             console.log($(this));
10422             console.log($(this).siblings());
10423             //            var showObj = {};
10424             let $index = $(this).parent().parent().parent().index() - 1;
10425             var check = $(".custom-check");
10426             console.log(check);
10427             _.each(check, opt => {
10428                 console.log(opt)
10429                 if ($(opt).hasClass('cur')) {
10430                     addVals.push(content[$(opt).parent().parent().parent().index() - 1]);
10431                     // showVals.push(content[$(opt).parent().parent().parent().index() - 1]);
10432                     // addVals.push(codeContent[$(opt).parent().parent().parent().index() - 1]);//填值时使用code  李伟民  12-05
10433                     // console.log(codeContent[$(opt).parent().parent().parent().index() - 1])
10434                 } else {
10435                     _.remove(addVals, n => {
10436                         return n.DATAROWNUM == content[$(opt).parent().parent().parent().index() - 1].DATAROWNUM;
10437                         // return n.DATAROWNUM == codeContent[$(opt).parent().parent().parent().index() - 1].DATAROWNUM;//填值时使用code  李伟民  12-05
10438                     });
10439                     // _.remove(showVals, n => {
10440                     //     return n.DATAROWNUM == content[$(opt).parent().parent().parent().index() - 1].DATAROWNUM;
10441                     // });
10442                 }
10443             });
10444             addVal = addVals;
10445             // showVal = showVals;
10446             console.log(addVal);
10447             console.log(datarow);
10448             customShow.sureonclick(addVal, $iconId, head, sel, iconAttr, datarow, formId);
10449         });
10450         console.log(addVal);
10451
10452     } else if (sel == "multiple") {
10453         $(".custom-check").on("click", function () {
10454             $(this).toggleClass('cur');
10455             //                var showObj = {};
10456             let $index = $(this).parent().parent().parent().index() - 1;
10457             if ($(this).hasClass('cur')) {
10458                 addVal.push(content[$index]);
10459                 // showVal.push(content[$index]);
10460                 // addVal.push(codeContent[$index]);//填值时使用code  李伟民  12-05
10461                 //console.log(content[$index])
10462             } else {
10463                 _.remove(addVal, n => {
10464                     return n.DATAROWNUM == content[$index].DATAROWNUM;
10465                     // return n.DATAROWNUM == codeContent[$index].DATAROWNUM;//填值时使用code  李伟民  12-05
10466                 });
10467                 // _.remove(showVal, n => {
10468                 //     return n.DATAROWNUM == content[$index].DATAROWNUM;
10469                 // });
10470             }
10471             customShow.sureonclick(addVal, $iconId, head, sel, iconAttr, datarow, formId);
10472         });
10473     }
10474     console.log(addVal);
10475     //选择方法END
10476     return counts;
10477 }
10478
10479 function createMxtTable($iconId, head, addVal) {// 关联数据渲染修改  李伟民 11-30
10480     console.log(head);
10481     console.log(addVal);
10482     if (head == "" || addVal == "" || head == undefined || addVal == undefined) {
10483         return false;
10484     }
10485     var tableBox = $("<table class='mxtdatatable table'></table>");
10486     var tableTitle = $("<tr></tr>");
10487     var tableBody = $("<tbody></tbody>");
10488     var tableHead = $("<thead></thead>");
10489     _.each(addVal, function (atd) {
10490         var tableContent = $("<tr></tr>");
10491         _.each(head, function (htd) {
10492             var td = '<td class="mxtdatatabletd">' + (atd[htd.fieldKey] ? atd[htd.fieldKey] : "") + '</td>';
10493             tableContent.append(td);
10494             var th = '<th>' + htd.title + '</th>';
10495             tableTitle.append(th);
10496         });
10497         tableBody.append(tableContent);
10498     });
10499     tableHead.append(tableTitle);
10500     tableBox.append(tableHead);
10501     tableBox.append(tableBody);
10502     $('#' + $iconId).append(tableBox);
10503 }// 关联数据渲染修改  李伟民 11-30
10504
10505 function setValByAnother(iconAttr, addVal, formId, head, typeflag) {//遍历对比别名相同填值 typefalg为true代表关联的是函数
10506     var datarowNum = addVal[0].DATAROWNUM;
10507     var postdata = {};
10508     var getCodeUrl = "";
10509     var ajaxtype = "";
10510     if (typeflag) {
10511         getCodeUrl = "/datamanagement/getAssociateData";
10512         postdata = { "formID": customShow.options.formid, "search": [], "pageSize": "1000", "pageNum": "1", "key": JSON.parse(iconAttr.tag_Attribute.fundata)['key'], "dataRowNum": datarowNum, "type": "code" };
10513         ajaxtype = "POST";
10514     } else {
10515         postdata = {
10516             "datarowNum": datarowNum,
10517             "formID": formId.formID
10518         };
10519         getCodeUrl = "/datamanagement/getSingleFormDataService";
10520         ajaxtype = "GET";
10521     }
10522
10523     console.log(postdata);
10524     var rquest = window.commonAjax(getCodeUrl, postdata, ajaxtype, true);
10525     rquest.done(function (res) {
10526         console.log(res);
10527         var rsdata = "";
10528         if (res.data && res.data.main != undefined) {
10529             if (typeflag) {
10530                 rsdata = res.data.list[0];
10531             } else {
10532                 rsdata = res.data.main;
10533             }
10534             console.log(iconAttr);
10535             console.log(rsdata);
10536             if (rsdata == undefined) {
10537                 return false;
10538             }
10539             _.each(customBase.options.customItems, opt => {
10540                 _.each(head, opts => {
10541                     if (opts.fieldKey == opt.fieldKey) {
10542                         if (opt.type == "dropdownlist") {
10543                             //                                if(customBase.getItemValue(opt.id,"dropdownlistText")[0].length == 0){
10544                             var item = customShow.options.customItemShow.item[opt.id];
10545                             var dropdowntype = item.tag_Attribute.dropdowntype;
10546                             customBase.setItemValue(opt.id, "dropdownlistText", res.data.main[opt.fieldKey], "", "");
10547                             //                            }
10548                         } else {
10549                             //                                if(!customBase.getItemValue(opt.id,opt.type)){
10550                             customBase.setItemValue(opt.id, opt.type, res.data.main[opt.fieldKey], "", "");
10551                             //                            }
10552                         }
10553                     };
10554                 })
10555             });
10556         }
10557
10558     });
10559
10560 }
10561
10562 customShow.sureonclick = function (addVal, $iconId, head, sel, iconAttr, datarow, formId) {
10563     console.log(datarow)
10564     $(".btn-primary").on("click", function () {
10565         var showObj = {};
10566         console.log(addVal);
10567         $('#' + $iconId).empty();
10568         //回显属性
10569         $("#" + $iconId).attr("formhuixian", JSON.stringify(addVal));
10570         var saveval = '';//关联数据空间 存值  李伟民  11-07
10571         var saveArr = [];
10572         _.each(addVal, function (v) {
10573             if (v.DATAROWNUM != undefined) {
10574                 saveArr.push(v.DATAROWNUM);
10575             }
10576         });
10577         saveval = saveArr.join();
10578         customBase.setItemValue($iconId, customShow.options.customItemShow.item[$iconId].tag_Type, saveval);//关联数据空间 存值  李伟民  11-07 end
10579         if (addVal != "" && addVal != undefined) {
10580             $("#" + iconAttr.tag_Id).attr("checkVal", JSON.stringify(addVal));//将选中值存储起来  用于验证
10581             $("#" + iconAttr.tag_Id).attr("checkHead", JSON.stringify(head));
10582         }
10583         var data2 = customShow.columnToRow(head, addVal);
10584         //子表单自动增加行
10585         var subId = $('#' + $iconId + "ActiveId").attr("choosesubform");
10586         console.log(subId);
10587         if (subId == "itemId") {
10588             createMxtTable($iconId, head, addVal);
10589             console.log(addVal);
10590             console.log(head);
10591             setValByAnother(iconAttr, addVal, formId, head);
10592             //遍历对比别名相同填值
10593             // _.each(customBase.options.customItems, opt => {
10594             //     _.each(head, opts => {
10595             //         if (opts.fieldKey == opt.fieldKey) {
10596             //             if (opt.type == "dropdownlist") {
10597             //                 //                                if(customBase.getItemValue(opt.id,"dropdownlistText")[0].length == 0){
10598             //                 var item = customShow.options.customItemShow.item[opt.id];
10599             //                 var dropdowntype = item.tag_Attribute.dropdowntype;
10600             //                 customBase.setItemValue(opt.id, "dropdownlistText", addVal[0][opt.fieldKey], "", "");
10601             //                 //                            }
10602             //             } else {
10603             //                 //                                if(!customBase.getItemValue(opt.id,opt.type)){
10604             //                 customBase.setItemValue(opt.id, opt.type, addVal[0][opt.fieldKey], "", "");
10605             //                 //                            }
10606             //                            }
10607             //         };
10608             //     })
10609             // });
10610         } else {
10611             console.log(addVal)
10612             if (sel == "single" && iconAttr.tag_Attribute.relevancesourcetype != "fundata") {
10613                 setValByAnother(iconAttr, addVal, formId, head)
10614                 //                    _.each(addVal,(opt,j)=>{
10615                 ////                        var ulBox = $("<ul></ul>");
10616                 //                        var ulBox = $("<table></table>");
10617                 //                        var sdata_head = "";
10618                 //                        var sdata_boby = "";
10619                 //                        for(var i = 0;i<head.length;i++){
10620                 //                            show = "";
10621                 //                            sdata_head += '<td class="data1 '+head[i].fieldKey+'">'+head[i].title+'</td>';
10622                 //                            sdata_boby += '<td class="data2 '+head[i].fieldKey+'">'+opt[head[i].fieldKey]+'</td>';
10623                 //                            show += '<li>'+'<span class="data1 '+head[i].fieldKey+'">'+head[i].title+'</span>'+'<span class="data2 '+head[i].fieldKey+'">'+opt[head[i].fieldKey]+'</span>'+'</li>';
10624                 //
10625                 //                            showObj[head[i].fieldKey] = opt[head[i].fieldKey];
10626                 //
10627                 //                            ulBox.attr("class","addUl ulBox"+j);
10628                 //                            ulBox.attr("id","ulBox"+j);
10629                 ////                            ulBox.append(show);
10630                 //                        }
10631                 //                        ulBox.append("<tr>"+sdata_head+"</tr><tr>"+sdata_boby+"</tr>");
10632                 //                        console.log(sdata_head);
10633                 //                        $('#'+$iconId).append(ulBox);
10634                 //                    });
10635                 createMxtTable($iconId, head, addVal);
10636                 var subdata = {};
10637                 console.log(datarow)
10638                 subdata.formdataNum = datarow;
10639                 subdata.datarowNum = addVal[0].DATAROWNUM;
10640                 subdata.formID = formId.formID;
10641                 var subformData = window.commonAjax("/datamanagement/getSubFormDataListService", subdata, "GET", true, false);
10642                 subformData.done(function (rs) {
10643                     console.log(rs.data);
10644                     var c_data = SC.cur_zero(rs.data);
10645                     console.log(c_data)
10646                     var rsArr = [];
10647                     _.each(c_data, opt => {
10648                         var opts = _.omit(opt, ['DATAROWNUM']);
10649                         rsArr.push(opts)
10650                     });
10651                     var rslength = _.keys(rsArr[0]).length;
10652                     console.log(rsArr);
10653                     var subId = $('#' + $iconId + "ActiveId").attr("choosesubform");
10654                     console.log($(".myipt"))
10655                     var formObj = window.localStorage.getItem("netformid");
10656                     var globalFormID = formObj;
10657                     var dataObj = {};
10658                     dataObj.formID = globalFormID;
10659                     var order_id = [];
10660                     //   11/25 李元杰 存flag
10661                     console.log(dataObj)
10662                     var requestRight = window.commonAjax("/datamanagement/getFormFieldListService", dataObj, "GET", true, false);
10663                     requestRight.done(function (rs) {
10664                         console.log(rs)
10665                         order_id = rs.data;
10666                     })
10667
10668                     // var tenantID =JSON.parse(window.localStorage.getItem('tenantID')) 
10669                     // dataObj.tenantID= tenantID.tenantID;
10670
10671                     //          var order_ids = JSON.parse($(".myipt").val());
10672                     console.log(order_id);
10673                     //         console.log(order_ids)
10674
10675
10676                     if (customShow.options.customItemShow.item[$iconId].tag_Attribute.singleSetValue) {
10677                         var message = JSON.parse(customShow.options.customItemShow.item[$iconId].tag_Attribute.singleSetValue);
10678                     }
10679                     console.log(message.columnOrderNum)
10680
10681                     console.log(subId);
10682                     var subIds = subId.replace("itemId_", "")
10683                     console.log(subIds);
10684                     var orderArr = []; //存储关联表单内子表单的数组
10685                     _.each(order_id, opt => {
10686                         console.log(opt)
10687                         if (opt.parentsubFormNum == message.columnOrderNum) {
10688                             orderArr.push(opt);
10689                         }
10690                     });
10691                     _.remove(orderArr, n => {
10692                         return n.fieldKey == "DATAROWNUM";
10693                     })
10694                     console.log(orderArr);
10695                     orderArr = _.sortBy(orderArr, ['fieldOrderNum']);
10696                     var resArr = [];
10697                     for (i = 0; i < rslength; i++) {
10698                         resArr.push([])
10699                     }
10700                     console.log(rsArr);
10701                     console.log(orderArr)
10702                     _.each(rsArr, (opt, i) => {
10703                         var j = 0
10704                         _.each(orderArr, n => {
10705                             resArr[j][i] = opt[n.fieldKey]
10706                             j++;
10707                         })
10708                     });
10709                     console.log(resArr);
10710                     if (resArr.length == 0){
10711                         alert("上级预算为0");
10712                     } else {
10713                         customShow.addRow(subId, resArr);
10714                     }
10715                     $(".subformAdd").hide();
10716                     $(".subformAddiconShow").hide();
10717
10718                 });
10719             } else if (sel == "multiple" || iconAttr.tag_Attribute.relevancesourcetype == "fundata") {
10720                 console.log("fundata");
10721                 if (iconAttr.tag_Attribute.relevancesourcetype == "fundata") {//关联函数时 别名相同填值
10722                     setValByAnother(iconAttr, addVal, "", head, true);
10723                 }
10724                 createMxtTable($iconId, head, addVal);
10725                 $("#" + subId + "subformTr").nextAll().remove();
10726                 customShow.addRow(subId, data2);
10727                 $(".subformAdd").hide();
10728                 $(".subformAddiconShow").hide();
10729             }
10730         }
10731         console.log(customShow.customJs(subId))
10732         SC.setSubForm(customShow.customJs(subId), subId);
10733         if (addVal.length != 0) {
10734             SC.Superior_show()
10735         }
10736     });
10737 }
10738
10739 customShow.customJs = function (subId) {
10740     var subArr = [];
10741     console.log(subId)
10742     var customItems = customBase.options.customItems;
10743     console.log(customItems)
10744     _.each(customItems, opt => {
10745         if (opt.parentsubFormNum == subId.replace("itemId_", "")) {
10746             subArr.push(opt);
10747         }
10748     });
10749     _.remove(subArr, n => {
10750         return n.fieldKey == "DATAROWNUM";
10751     })
10752     console.log(subArr);
10753     var aliasArr = [];
10754     _.each(subArr, opt => {
10755         aliasArr.push(opt.fieldKey)
10756     })
10757     console.log(aliasArr);
10758     return aliasArr;
10759 }
10760
10761 //表单引用 扩展 回显子表单功能
10762 fenye = function (pageSize, pageNum, formId, sCondition, formhuixian, head, $iconId, addVal, anydata) {
10763     console.log($iconId);
10764     console.log("findmany");
10765     console.log(anydata);
10766     console.log(head);
10767     var iconAttr = customShow.options.customItemShow.item[$iconId];//关联数据 函数 数据源 李伟民  11-07
10768     console.log(iconAttr);
10769     var dataUrl = "";
10770     var dataObj;
10771     if (anydata) {
10772         //   alert('if');
10773     } else {
10774         //   alert("else");
10775     }
10776     if (iconAttr.tag_Attribute.relevancesourcetype && iconAttr.tag_Attribute.relevancesourcetype == "fundata") {
10777         dataUrl = "/datamanagement/getAssociateData";
10778         dataObj = { "formID": customShow.options.formid, "tenantID": "001", "search": [], "pageSize": pageSize, "pageNum": pageNum, "key": JSON.parse(iconAttr.tag_Attribute.fundata)['key'] };
10779         _.extend(dataObj, { "formData": customShow.getItems() });
10780     } else {
10781         dataUrl = "/datamanagement/getAssociatedFormDataService";
10782         dataObj = { "formID": formId.formID, "tenantID": "001", "screenCondition": sCondition, "pageSize": pageSize, "pageNum": pageNum, "search": anydata };
10783         window.localStorage.setItem("netformid", dataObj.formID);
10784     }
10785     //关联数据 函数 数据源 李伟民  11-07
10786     //    var dataObj = {"formID":formId.formID,"tenantID":"001","screenCondition":sCondition,"pageSize":pageSize,"pageNum":pageNum};
10787     //window.localStorage.setItem("netformid",dataObj.formID);
10788     var requestRight = window.commonAjax(dataUrl, dataObj, "POST", true, false);
10789     var counts = "";
10790     requestRight.done(function (rs) {
10791         if (iconAttr.tag_Attribute.relevancesourcetype && iconAttr.tag_Attribute.relevancesourcetype == "fundata") {
10792             // var titleObj = { "key": JSON.parse(iconAttr.tag_Attribute.fundata)['key'] };
10793             // var requestTitle = window.commonAjax("/datamanagement/getAssociateTitle", titleObj, "POST", true, false);
10794             // requestTitle.done(function (res) {
10795             //     var formtitle = [];
10796             //     _.each(res.data, function (tdata) {
10797             //         formtitle.push({ "fieldKey": tdata.fieldKey, "title": tdata.title });
10798             //     });
10799             counts = createTable(rs, formId, formhuixian, head, $iconId, addVal);
10800             // });
10801
10802         } else {
10803             counts = createTable(rs, formId, formhuixian, head, $iconId, addVal);//关联表单 列表回显
10804         }
10805
10806     });
10807     $('.closeBtn').on('click', () => {
10808         $('#' + $iconId + 'menuContent').remove();
10809         console.log($('.maskLayer'))
10810         $('.maskLayer').css('display', 'none');
10811     })
10812     return counts;
10813 }
10814 customShow.journeySort = function () {//行程排序 初始化 李伟民 2017-10-23 15:56
10815     //console.log(customShow);
10816     var itemKey = _.keys(customShow.options.customItemShow.item);
10817     _.each(itemKey, function (keys) {
10818         if (customShow.options.customItemShow.item[keys].tag_Type == "subform" && customShow.options.customItemShow.item[keys].tag_Attribute.sorttype != undefined && customShow.options.customItemShow.item[keys].tag_Attribute.sorttype != "") {
10819             customShow.bindSort(customShow.options.customItemShow.item[keys].tag_Attribute.sorttype, keys);
10820         }
10821     });
10822     //    customShow.bindSort("itemId_6","itemId_3");
10823 }//行程排序 初始化 李伟民 2017-10-23 15:56 end
10824
10825 customShow.bindSort = function (sorttype, sub) {//排序事件绑定
10826     if (customShow.options.customItemShow.item[sorttype] == undefined) {
10827         return false;
10828     }
10829     var tagType = customShow.options.customItemShow.item[sorttype].tag_Type;
10830     if (tagType == "text" || tagType == "number" || tagType == "calendar") { //单行文本  数字 时间
10831         $("[id=" + sorttype + "]").unbind("change.sort", customShow.sortEvent);
10832         $("[id=" + sorttype + "]").on("change.sort", { msg: { "sorttype": sorttype, "type": tagType, "sub": sub } }, customShow.sortEvent);
10833     } else if (tagType == "dropdownlist") { // 下拉框
10834
10835     }
10836
10837 }
10838
10839 customShow.sortEvent = function (event) {//
10840     var sorttype = event.data.msg.sorttype;
10841     var type = event.data.msg.type;
10842     var sub = event.data.msg.sub;
10843     //console.log(event);
10844     var allValue;
10845     var allItem = [];
10846     allValue = customBase.getItemValue(sorttype, type);
10847     if(_.isString(allValue)){
10848         allValue = [allValue];
10849     }
10850     //console.log(allValue);
10851     _.each(allValue, function (v, i) {
10852         if (type == "calendar") {
10853             allItem.push({ "value": new Date(v), "index": i, "temp": $("[id='" + sub + "ActiveId']:eq(" + i + ")").clone(true) });
10854         } else {
10855             allItem.push({ "value": v, "index": i, "temp": $("[id='" + sub + "ActiveId']:eq(" + i + ")").clone(true) });
10856         }
10857     });
10858     //console.log(allItem);
10859     var sortValue = _.sortBy(allItem, function (o) {
10860         return o.value;
10861     });
10862     console.log(sortValue);
10863     _.each($("[id='" + sub + "ActiveId']"), function (subform, k) {
10864         $(subform).replaceWith(sortValue[k].temp);
10865     })
10866     // customShow.controlInit("customShow");
10867     customLinkageAnalysis.bindLinkage();
10868     customShow.journeySort();
10869 }
10870 //马习同 2017/10/25
10871 $(".sTab ul li").on('click', function () {
10872     $(this).css('border-bottom', '2px solid #23b7e5');
10873     $(this).css('box-sizing', 'border-box');
10874     $(this).siblings().css('border', 'none');
10875     //console.log($($(".tabBox>div")[$(this).index()]));
10876     $($(".tabBox>div")[$(this).index()]).css("display", "block");
10877     $($(".tabBox>div")[$(this).index()]).siblings().hide();
10878 });
10879 $(".tag_two").on("click", function () {
10880     //    $(".boxTwo iframe").attr("src","http://122.114.176.216:8087/#/IframeExample?token=C3CDE94FE9CBDDDD37312D3331AC091EC737F5555007677E45A390EFEC7147996A49AA4E117EDC02F0D15984E725CA3B5B93DDAF0C989C35642B58B29360D998DDDAC06EB509BE1C22B19D555A1BB75A07A36FD6C4A7E87C9C9EA0070A213BFB44FF8D3B2AD5A33086EAF1F22E978B24951EA806054F94042533CA73EA7901C5E8B13D4DB7DC87308266E769258DEDFF&openId=3dc22baf5d484170&tenantId=13&companyId=17& appId=1&processInstId=1483")
10881 })
10882 //马习同  11/7  行转化列
10883 customShow.columnToRow = function (head, addVal) {
10884     var data = []
10885     _.remove(head, n => {
10886         return n.fieldKey == "DATAROWNUM";
10887     })
10888     _.each(head, opt => {
10889         let data1 = [];
10890         _.each(addVal, opts => {
10891             data1.push(opts[opt.fieldKey]);
10892         });
10893         console.log(data1)
10894         data.push(data1)
10895     });
10896     return data;
10897 }
10898
10899 //lym
10900 function get() {
10901     
10902         console.log(localStorage.getItem("organizationId"));
10903         console.log(localStorage.getItem("datarowNum"));
10904         //从local取出log
10905         var processLog = localStorage.getItem("processLog");
10906         var tenant = JSON.parse(localStorage.getItem("tenantID"));
10907         var cust = JSON.parse(localStorage.getItem("customItem"));
10908         //暂时修改流程lym
10909         // var org = cust.expend_department.trim();
10910         //暂时修改流程lym
10911         console.log(processLog);
10912         console.log(processLog !== null);
10913         //12/11
10914         if (processLog != "null") {
10915             var strMessage = customBase.getMessage("mesage_ID034");
10916             customBase.alert("E", strMessage);
10917             //return null;
10918         } else {
10919             //暂时修改流程lym
10920             // if (org == "" || org == undefined || org == null) {
10921             //     //var strMessage = customBase.getMessage("mesage_ID035");
10922             //     customBase.alert("E", "请选择部门");
10923             //     return null;
10924             // }
10925             //暂时修改流程lym
10926             // 画面check 提交前验证 李伟民 12-26
10927             // var returnfromCheck = customShow.initEvent.fromCheck(items); //--------------------
10928             // if (returnfromCheck) {
10929             // return;
10930             // }
10931             var ss = {
10932                 "tenantID": tenant.tenantID,
10933                 //"organizationId": org,
10934                 "formID": localStorage.getItem("newFormID"),
10935                 "dataRowNum": localStorage.getItem("datarowNum")
10936             }
10937             var requestSingleForm = window.commonAjax("/ubp-api-control/process/inst/create", ss, "POST", true);
10938             requestSingleForm.done(function (rs) {
10939                 console.log(rs);
10940                 if (rs.resCode == 00000) {
10941                     
10942                         customBase.alert('S', "提交成功");
10943                         $("#sssd").click();
10944                     
10945                 } else {
10946                     if (rs.data == '3') {
10947                         customBase.alert('E', "请先配置流程定义");
10948                         $("#sssd").click();
10949                     }else if(rs.data == '2'){
10950                         customBase.alert('E', "请不要重复提交");
10951                         $("#sssd").click();
10952                     } else {
10953                     customBase.alert('E', "提交失败");
10954                     $("#sssd").click();
10955                     }
10956                 }
10957             });
10958         }
10959     
10960     }
10961 //lym结束后操作
10962 function over(data) {
10963     if (data == true) {
10964         //确定提交后操作
10965         var processLog = JSON.parse(localStorage.getItem("processLog"));
10966         console.log(processLog);
10967         var ss = {
10968             "processInstId": processLog[0].processInstId
10969         }
10970         console.log(ss);
10971         var requestSingleForm = window.commonAjax("/ubp-api-control/process/inst/over", ss, "POST", true);
10972         requestSingleForm.done(function (rs) {
10973             console.log(rs);
10974             if (rs.data == 1) {
10975                 alert("结束成功");
10976                 $("#sssd").click();
10977             } else {
10978                 alert("结束失败");
10979             }
10980         });
10981
10982
10983
10984     } else {
10985         $("#sssd").click();
10986     }
10987 }
10988
10989 //lym退回确定后操作
10990 function tui(data, item) {
10991
10992     if (data == true) {
10993         console.log($('.actcur').val());
10994         if ($('.actcur').val() == undefined) {
10995             alert("请选择退回的活动");
10996             return null;
10997         }
10998         var processLog = JSON.parse(localStorage.getItem("processLog"));
10999         var ss = {
11000             "activityInstId": processLog[0].activityInstId,
11001             "activityDefId": $('.actcur').val(),
11002             "processInstId": processLog[0].processInstId,
11003             "formID": localStorage.getItem("newFormID"),
11004             "dataRowNum": localStorage.getItem("datarowNum")
11005         }
11006         var requestSingleForm = window.commonAjax("/ubp-api-control/process/inst/bac", ss, "POST", true);
11007         requestSingleForm.done(function (rs) {
11008             console.log(rs);
11009
11010             if (rs.data == 1) {
11011                 alert("退回成功");
11012                 $("#sssd").click();
11013             } else {
11014                 alert("退回失败");
11015             }
11016         });
11017
11018
11019     } else {
11020         $("#sssd").click();
11021     }
11022 }
11023 //lym 审批确定后方法
11024 function zhixing(data) {
11025     console.log(data);
11026     console.log($("#datas").val());
11027     if (data == false) {
11028         $("#sssd").click();
11029     } else {
11030
11031         var processLog = JSON.parse(localStorage.getItem("processLog"));
11032         console.log(processLog[0].processInstId);
11033         var ss = {
11034             "processInstId": processLog[0].processInstId,
11035             "activityInstId": processLog[0].activityInstId,
11036             "data": $("#datas").val(),
11037             "formID": localStorage.getItem("newFormID"),
11038             "dataRowNum": localStorage.getItem("datarowNum"),
11039             "token": localStorage.getItem("testToken"),//差旅token 特殊处理 
11040             "tenantId": localStorage.getItem("testTenantId"),
11041             "companyId": localStorage.getItem("testCompanyId"),
11042         
11043         }
11044         console.log("标记token");
11045         var requestSingleForm = window.commonAjax("/ubp-api-control/process/inst/finish", ss, "POST", true);
11046         requestSingleForm.done(function (rs) {
11047             console.log(rs);
11048             if (rs.resCode == "00000") {
11049                 customBase.alert('S',"审批成功");
11050                 $("#sssd").click();
11051             } else {
11052                 customBase.alert('W',"审批失败");
11053             }
11054         });
11055     }
11056 }
11057 //2017.11.24  qld 追加预算
11058 customBase.budgetAddmoney = function () {
11059     var id = JSON.parse(localStorage.getItem("tenantID"))
11060     console.log(id.tenantID);
11061     var sub = JSON.parse(localStorage.getItem("customItem"));
11062     var submit_data = {
11063         "formId": localStorage.getItem("newFormID"),
11064         "netformid": localStorage.getItem("netformid"),
11065         "parentDataRowNum": localStorage.getItem("datarowNum"),
11066         "dataRowNum": localStorage.getItem("datarowNum"),
11067         "tenantID": id.tenantID,
11068         "formType": "ZJ"
11069     };
11070
11071     var submit_request = window.commonAjax1("epc-form/extend/budget/money", submit_data, "POST", true);
11072     submit_request.done(function (res) {
11073         if (res.resCode == 'C0000') {
11074             if (res.data == '1') {
11075                 var strMessage = customBase.getMessage("mesage_ID024");
11076                 customBase.alert("E", strMessage);
11077             } else if (res.data == '2') {
11078                 var strMessage = customBase.getMessage("mesage_ID025");
11079                 customBase.alert("E", strMessage);
11080             } else if (res.data == '3') {
11081                 var strMessage = customBase.getMessage("mesage_ID026");
11082                 customBase.alert("E", strMessage);
11083             } else if (res.data == '9') {
11084                 var strMessage = customBase.getMessage("mesage_ID027");
11085                 customBase.alert("S", strMessage);
11086             } else if (res.data == '7') {
11087                 var strMessage = customBase.getMessage("mesage_ID028");
11088                 customBase.alert("E", strMessage);
11089             }
11090
11091         }
11092
11093     })
11094
11095 }
11096
11097 customBase.budgetBackmoney = function () {
11098     var id = JSON.parse(localStorage.getItem("tenantID"))
11099     console.log(id.tenantID);
11100     var sub = JSON.parse(localStorage.getItem("customItem"));
11101     var submit_data = {
11102         "formId": localStorage.getItem("newFormID"),
11103         "netformid": localStorage.getItem("netformid"),
11104         "parentDataRowNum": localStorage.getItem("datarowNum"),
11105         "dataRowNum": localStorage.getItem("datarowNum"),
11106         "formType": "TH",
11107         "tenantID": id.tenantID
11108     };
11109
11110     var submit_request = window.commonAjax1("epc-form/extend/budget/money", submit_data, "POST", true);
11111     submit_request.done(function (res) {
11112         if (res.resCode == 'C0000') {
11113             if (res.data == '1') {
11114                 var strMessage = customBase.getMessage("mesage_ID024");
11115                 customBase.alert("E", strMessage);
11116             } else if (res.data == '2') {
11117                 var strMessage = customBase.getMessage("mesage_ID025");
11118                 customBase.alert("E", strMessage);
11119             } else if (res.data == '3') {
11120                 var strMessage = customBase.getMessage("mesage_ID026");
11121                 customBase.alert("E", strMessage);
11122             } else if (res.data == '9') {
11123                 var strMessage = customBase.getMessage("mesage_ID027");
11124                 customBase.alert("S", strMessage);
11125             } else if (res.data == '7') {
11126                 var strMessage = customBase.getMessage("mesage_ID028");
11127                 customBase.alert("E", strMessage);
11128             }
11129         }
11130
11131     })
11132
11133 }
11134 function repayment() {
11135     var customBase = window.customBase;
11136     customBase.repayment();
11137     return true;
11138 }
11139 customBase.repayment = function () {
11140     var id = JSON.parse(localStorage.getItem("tenantID"))
11141     console.log(id.tenantID);
11142     var sub = JSON.parse(localStorage.getItem("customItem"));
11143     console.log(sub);
11144     var subForm = sub.DATAROWNUM;
11145     console.log("我是" + subForm)
11146     var submit_data = {
11147         "formId": localStorage.getItem("newFormID"),
11148         "netformid": localStorage.getItem("netformid"),
11149         "parentDataRowNum": localStorage.getItem("datarowNum"),
11150         "datarowNum": localStorage.getItem("datarowNum"),
11151         "tenantId": id.tenantID
11152     };
11153
11154     var submit_request = window.commonAjax1("epc-form/repayment/money", submit_data, "POST", true);
11155     submit_request.done(function (res) {
11156         if (res.data == true) {
11157             //    12/7 qld
11158             var strMessage = customBase.getMessage("mesage_ID029");
11159             customBase.alert("S", strMessage);
11160         } else {
11161             var strMessage = customBase.getMessage("mesage_ID030");
11162             customBase.alert("E", strMessage);
11163         }
11164
11165     })
11166
11167 }
11168 //子表单合计方法   马习同   2017-12-06
11169 customShow.subTotle = function (subId) {
11170     var customItems = customBase.options.customItems;
11171     var numArr = [];
11172     var subArr = [];
11173     var numObj = {};
11174     _.each(customItems, opt => {
11175         if (opt.parentsubFormNum == subId.replace("itemId_", "")) {
11176             subArr.push(opt);
11177         }
11178     });
11179     _.remove(subArr, n => {
11180         return n.fieldKey == "DATAROWNUM";
11181     });
11182     _.each(subArr, opt => {
11183         if (opt.type == "number") {
11184             console.log(opt.id);
11185             numObj[opt.id] = customBase.getItemValue(opt.id, opt.type);
11186             numArr.push(Number(customBase.getItemValue(opt.id, opt.type)));
11187         }
11188     })
11189     console.log(numObj);
11190     for (let key in numObj) {
11191         var opts = [];
11192         if (_.isArray(numObj[key])) {
11193             _.each(numObj[key], n => {
11194                 n = Number(n);
11195                 console.log(n);
11196                 opts.push(n);
11197             })
11198             numObj[key] = opts;
11199         }
11200         console.log(numObj[key]);
11201     }
11202     console.log(numObj);
11203     //_.sum   求和
11204     for (let key in numObj) {
11205         $("." + key + "totle").val(_.sum(numObj[key]));
11206     }
11207
11208 }
11209 //子表单合计方法   马习同   2017-12-07
11210 customShow.oneTotle = function () {
11211     var customItems = customShow.options.customItemShow.item;
11212     var totleArr = [];
11213     var numObj = {};
11214     var numArr = [];
11215     _.each(customItems, opt => {
11216         console.log(opt.tag_Attribute.total)
11217         if (opt.tag_Attribute.total == true) {
11218             totleArr.push(opt.tag_Id);
11219             console.log(opt.tag_Id)
11220         }
11221     })
11222     console.log(totleArr);
11223     _.each(totleArr, opt => {
11224         $("#" + opt + " [type='number']").unbind("change.totle");
11225         $("#" + opt + " [type='number']").on("change.totle", function () {
11226             console.log($(this).attr("id"));
11227             numObj[$(this).attr("id")] = customBase.getItemValue($(this).attr("id"), $(this).attr("type"));
11228             console.log(_.cloneDeep(numObj));
11229             console.log(numObj[key])
11230
11231             for (let key in numObj) {
11232                 var opts = [];
11233                 if (_.isArray(numObj[key])) {
11234                     _.each(numObj[key], n => {
11235                         n = Number(n);
11236                         console.log(n);
11237                         opts.push(n);
11238                     })
11239                     numObj[key] = opts;
11240                 }
11241                 console.log(numObj[key]);
11242             }
11243
11244             console.log(numObj);
11245             //_.sum   求和
11246             for (let key in numObj) {
11247                 $("." + key + "totle").val(_.sum(numObj[key]));
11248             }
11249         })
11250     })
11251 }
11252 //子表单内的控件内容超出部分显示title
11253 customShow.addTitle = function () {
11254     _.each($(".customShow .tdContentClass"), opt => {
11255         // $(opt).attr("title", $(opt).children().children().html());
11256         console.log($(opt).html())
11257         if ($(opt).children().children().attr("type") == "text") {
11258             $(opt).attr("title", $(opt).children().children().val());
11259         } else {
11260             console.log(_.cloneDeep($(opt).children().children()))
11261             console.log(opt.innerHTML)
11262             console.log($(opt).children().children()[0].innerHTML)
11263             $(opt).attr("title", $(opt).children().children()[0].innerHTML);
11264         }
11265     })
11266 }
11267 // customShow.businessTypeAutoFun = function(key,fieldKey,cookieOrlocal){
11268 //     if(cookieOrlocal  == 'cookie'){
11269 //         if(customBase.options.customItems[fieldKey].parentsubFormNum == '0'){
11270 //             var businessTypeAuto = getCookie(key);
11271 //             customBase.setItemValue(customBase.options.customItems[fieldKey].id, customBase.options.customItems[fieldKey].type, businessTypeAuto, '', '');
11272 //         }
11273 //     }else{
11274 //         if(customBase.options.customItems[fieldKey].parentsubFormNum == '0'){
11275 //             var businessTypeAuto = window.localStorage.getItem(key);
11276 //             customBase.setItemValue(customBase.options.customItems[fieldKey].id, customBase.options.customItems[fieldKey].type, businessTypeAuto, '', '');
11277 //         }
11278 //     }
11279 // }
11280 // SC.billInfoInit = function(items){//票据信息初始化 李伟民 12-26
11281 //     var itemKey = _.keys(items);
11282 //     var customItems = customBase.options.customItems;
11283 //     customShow.allbillInfo = [];
11284 //     _.each(itemKey,function(key){
11285 //         console.log(key);
11286 //         if(customItems[key] != undefined && customItems[key] != '' && customItems[key].type == "subform"){
11287 //             var billInfos = [];
11288 //             _.each(items[key], function(journey, i){
11289 //                 if(journey.billData != undefined){
11290 //                     billInfos.push(JSON.parse(journey.billData));
11291 //                     $("#" + key + "ActiveId").attr('noBillCheck',JSON.parse(journey.billData));
11292 //                 }else{
11293 //                     billInfos.push({});
11294 //                 }
11295 //             });
11296 //             customShow.allbillInfo.push({
11297 //                 'subFormId':customItems[key].id,
11298 //                 'subFormKey':key,
11299 //                 'billInfos':billInfos
11300 //             })
11301 //         }
11302 //     });
11303 //     billInfobind(customShow.allbillInfo);
11304 //     SC.noBillCheckInit();
11305 // }
11306 // SC.noBillCheckInit = function(){
11307 //     noBillCheck('journey','reimburseMan');
11308 // }
11309 function noBillCheck(subFieldKey,reimburseManKey){//无票据行程及票据人员与报销人验证
11310     if(customBase.options.customItems[subFieldKey] == undefined){
11311         return false;
11312     }
11313     var subId = customBase.options.customItems[subFieldKey].id;
11314     var manId = customBase.options.customItems[reimburseManKey].id;
11315     var manType = customBase.options.customItems[reimburseManKey].type;
11316     var manTitle = customBase.options.customItems[reimburseManKey].title;
11317     var journeySub = $("#" + subId + "ActiveId");
11318     _.each(journeySub,function(jour){
11319         var checkData = $(jour).attr('noBillCheck');
11320         if(checkData != undefined && checkData != ''){
11321             checkData = JSON.parse(checkData);
11322             var manVal = customBase.getItemValue(manId,manType);
11323             if(manVal != undefined && manVal != checkData.PersonalVal){
11324                 $(jour).children('h8').append("<span class='billCheck'>" + "票据‘" + checkData.PersonalName + "’与" + manTitle + "不同</span>");
11325             }
11326         }else{
11327             $(jour).children('h8').append("<span class='billCheck'>无票据行程</span>");
11328         }
11329     });
11330 }
11331 function billInfobind(allbillInfo){//票据信息显示 及 实时验证  李伟民 12-26
11332     _.each(allbillInfo,function(info,k){
11333         var sub_type = customShow.options.customItemShow.item[info.subFormId].tag_Attribute.allcopy;
11334         
11335         _.each(info.billInfos,function(binfo, i){
11336             if(binfo.billCode != undefined){
11337                 var itemKey = _.keys(binfo.billHeadMeaningMvCodeMap);
11338                 _.each(itemKey,function(key){
11339                     if(binfo.billHeadMap[key] != undefined && binfo.billHeadMap[key] != ''){
11340                         var bhName = binfo.billHeadMap[key].val;
11341                         var bhVal = binfo.billHeadMap[key].code;
11342                         billShow(sub_type,itemKey,bhName,bhVal,i);
11343                         if(sub_type && key == 'PersonalName'){//储存票据人员信息
11344                             var noBillCheckData = {
11345                                 "PersonalName":bhName,
11346                                 "PersonalVal":bhVal
11347                             };
11348                             $("#" + info.subFormId + "ActiveId:ep(" + k + ")").attr("noBillCheck",JSON.stringify(noBillCheckData));
11349                         }
11350                     }
11351                 });
11352             }    
11353         });
11354     })
11355 }
11356 function billShow(sub_type,itemKey,bhName,bhVal,num){//票据信息验证绑定 李伟民 12-26
11357     var itemId = customBase.options.customItems[itemKey].id;
11358     var type = customBase.options.customItems[itemKey].type;
11359     if(sub_type){
11360         $("[id='"+itemId+"ActiveId']:eq('" + num + "')").find("h8[name='el_title']").append("<span class='billCheck'>" + bhName + "</span>");
11361     }else{
11362         customBase.set_p($("[id='"+itemId+"']:eq('" + num + "')"));
11363         if(type == 'dropdownlist'){
11364             $("[id='"+itemId+"']:eq('" + num + "')").closet("p").append("<span class='billCheck'>" + bhName + "</span>");
11365         }else{
11366             $("[id='"+itemId+"']:eq('" + num + "')").prev("p").append("<span class='billCheck'>" + bhName + "</span>");
11367         }
11368         
11369     }
11370     if(type == 'dropdownlist'){
11371         $("[id='"+itemId+"']:eq('" + num + "')").find(".select_get").on('change.billcheck',function(){
11372             if(sub_type){
11373                 $("[id='"+itemId+"ActiveId']:eq('" + i + "')").find(".billCheck").css("color", "#333");
11374                 if($(this).val() != bhVal) {
11375                     $("[id='"+base_item_id+"ActiveId']:eq('" + i + "')").find(".billCheck").css("color", "red");
11376                 }
11377             }else{
11378                 $("[id='"+itemId+"']:eq('" + i + "')").closet("p").find(".billCheck").css("color", "#333");
11379                 if($(this).val() != bhVal) {
11380                     $("[id='"+itemId+"']:eq('" + i + "')").closet("p").find(".billCheck").css("color", "red");
11381                 }
11382             }
11383         });
11384     }else{
11385         $("[id='"+itemId+"']:eq('" + num + "')").on('change.billcheck',function(){
11386             if(sub_type){
11387                 $("[id='"+itemId+"ActiveId']:eq('" + i + "')").find(".billCheck").css("color", "#333");
11388                 if($(this).val() != bhVal) {
11389                     $("[id='"+itemId+"ActiveId']:eq('" + i + "')").find(".billCheck").css("color", "red");
11390                 }
11391             }else{
11392                 $("[id='"+itemId+"']:eq('" + i + "')").prev("p").find(".billCheck").css("color", "#333");
11393                 if($(this).val() != bhVal) {
11394                     $("[id='"+itemId+"']:eq('" + i + "')").prev("p").find(".billCheck").css("color", "red");
11395                 }
11396             }
11397         })
11398     }
11399 }