zhangjinan
2018-03-28 4532880bf845372d92ea027d791a00f8c66b4d40
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             }
13ec33 312
4d1219 313         },
B 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) {
449a85 405             itemId = itemId+"Item";
L 406             console.log(value)
407             var rValue = value.join(",");//html回显bug修改  李伟民  0201
408             if(showClass ==undefined){
409                 showClass = 'customViewUEditorCss';
410             }
411             UE.getEditor(itemId).ready(function(){
412                 UE.getEditor(itemId).setContent(rValue);
413             });
4d1219 414
B 415         },
416     },
417     dropdownlistView: {
418         getItem: function (itemId) {
419             return $(itemId).select2("val");
420         },
421         setItem: function (itemId, value) {
422             if (value) {
423                 $(itemId).select2("val", value);
424             } else {
425                 $('.selectItme').attr('value', "");
426                 $('.val-card').remove();
427             }
428         },
429     },
430     dropdownlist: {
431         getItem: function (itemId) {
432             return $(itemId).select2("val");
433         },
434         setItem: function (itemId, value) {
435             if (value) {
436                 $(itemId).select2("val", value);
437             } else {
438                 $('.selectItme').attr('value', "");
439                 $('.val-card').remove();
440             }
441         },
442     },
443     // 下拉框(文本取得)
444     dropdownlistText: {
445         getItem: function (itemId) {
446             var itemList = $(".customViewUEditorCss ." + itemId + "value");
447             var itemListReturn = [];
448             var select2ItemList = customBase.options.dropdownlistText[itemId];
449             for (var i = 0; i < itemList.length; i++) {
450                 var select2Item = $(itemList[i]).select2("data");
451                 var items = [];
452                 for (var j = 0; j < select2Item.length; j++) {
453                     for (var z = 0; z < select2ItemList.length; z++) {
454                         if (select2ItemList[z].text == select2Item[j].text) {
455                             items[j] = select2ItemList[z].value;
456                         }
457                     }
458                     // items[j] = select2Item[j].text;
459                 };
460                 itemListReturn[i] = items;
461             };
462
463             return itemListReturn;
464         },
465         setItem: function (itemId, value, showClass, dropdowntype) {
466             console.log(value)
467             //              var select2Item = customBase.options.dropdownlistText[itemId];
468             //              //单多选框数据设定
469             //              //2017/10/27 马习同修改
470             //              var customItem = customBase.options.customItems;
471             //              var itemAttr = "";
472             //              for(let key in customItem){
473             //                  if(customItem[key].id == itemId){
474             //                      itemAttr = customItem[key];
475             //                  }
476             //              }
477             //              console.log(_.cloneDeep(customItem))
478             //              console.log(itemAttr);
479             //              //2017/10/27 马习同修改
480             //              setelect2Item = function (itemId,value){
481             //                  if(typeof value == "string"){
482             //                      value = [value];
483             //                  }
484             //                  var itemsTemp = [];
485             //                  for (var i = 0; i < value.length; i++) {
486             //                      for (var j = 0; j < select2Item.length; j++) {
487             //                          if(select2Item[j].value ==  value[i]){
488             //                              var id = select2Item[j].id;
489             //                              itemsTemp[i] = id;
490             //                          }
491             //                      };
492             //                  }
493             //                  $(itemId).val(itemsTemp).trigger("change");
494             //              }
495             //              //多个下拉菜单  马习同
496             //              var itemList = $("."+showClass+" #itemId_"+itemAttr.parentsubFormNum+" ."+itemId+"value");
497             //              var itemList1 = $("."+showClass+" ."+itemId+"value");
498             //                console.log(itemList);
499             //                console.log(itemList1);
500             //              console.log(value)
501             //              if(itemList.length ==1){
502             //                  setelect2Item(itemList[0],value);
503             //              }else{
504             //                    for (var i = 0; i < itemList.length; i++) {
505             //                        console.log(value)
506             //                        console.log(itemList[i],value[i])
507             //                       setelect2Item(itemList1[i],value[i]);
508             //                    }
509             //              }
510             //
511             //原代码
512             //                            var select2Item = customBase.options.dropdownlistText[itemId];
513             //              //单多选框数据设定
514             //              setelect2Item = function (itemId,value){
515             //                  if(typeof value == "string"){
516             //                      value = [value];
517             //                  }
518             //                  var itemsTemp = [];
519             //                  for (var i = 0; i < value.length; i++) {
520             //                      for (var j = 0; j < select2Item.length; j++) {
521             //                          if(select2Item[j].value ==  value[i]){
522             //                              var id = select2Item[j].id;
523             //                              itemsTemp[i] = id;
524             //                          }
525             //                      };
526             //                  }
527             //                  $(itemId).val(itemsTemp).trigger("change");
528             //              }
529             //              //多个下拉菜单
530             //              var itemList = $("."+showClass+" ."+itemId+"value");
531             //              if(itemList.length ==1){
532             //                  setelect2Item(itemList[0],value);
533             //              }else{
534             //
535             //                  for (var i = 0; i < itemList.length; i++) {
536             //                       setelect2Item(itemList[i],value[i]);
537             //                  }
538             //              }
539         },
540     },
541     dropdownlistText2: {
542         getItem: function (itemId) {
543             // var itemList = $(".customViewUEditorCss ."+itemId+"value");
544             // var itemListReturn =[];
545             // var select2ItemList = customBase.options.dropdownlistText[itemId];
546             // for (var i = 0; i < itemList.length; i++) {
547             //     var select2Item = $(itemList[i]).select2("data");
548             //     var items = [];
549             //     for (var j = 0; j < select2Item.length; j++) {
550             //         for(var z=0;z<select2ItemList.length;z++){
551             //             if(select2ItemList[z].text ==  select2Item[j].text){
552             //                 items[j] = select2ItemList[z].value;
553             //             }
554             //         }
555             //         // items[j] = select2Item[j].text;
556             //     };
557             //     itemListReturn[i] = items;
558             // };
559             var itemListReturn = xhSelect.getValue(itemId);
560             return itemListReturn;
561         },
562         setItem: function (itemId, value, showClass, dropdowntype) {
563             //2017/10/27 马习同修改
564             console.log(value);
565             var customItem = customBase.options.customItems;
566             var itemAttr = "";
567             for (let key in customItem) {
568                 if (customItem[key].id == itemId) {
569                     itemAttr = customItem[key];
570                 }
571             }
572             //2017/10/27 马习同修改
573
574             var select2Item = customBase.options.dropdownlistText[itemId];
575             if (itemAttr.parentsubFormNum != 0) {//非子表单中 无需添加parentformnum 李伟民  11-14
576                 var itemList = $("#itemId_" + itemAttr.parentsubFormNum + " #" + itemId);
577             } else {
578                 var itemList = $("#" + itemId);
579             }
580             console.log(itemList);
581             if (itemList.length == 1) {
582                 // setelect2Item(itemId,value,0);
583                 xhSelect.setValue(itemId, value, 0)
584             } else {
585
586                 for (var i = 0; i < itemList.length; i++) {
587                     //  setelect2Item(itemId,value[i],i);
588                     xhSelect.setValue(itemId, value[i], i)
589                 }
590             }
591
592         },
593     },
594     // 下拉框(值取得)
595     dropdownlisVal: {
596         getItem: function (itemId) {
597             var itemList = $("." + itemId + "value");
598             var itemListReturn = [];
599             for (var i = 0; i < itemList.length; i++) {
600                 var select2Item = $(itemList[i]).select2("val");
601                 var items = [];
602                 for (var j = 0; j < select2Item.length; j++) {
603                     items[j] = select2Item[j].text;
604                 };
605                 itemListReturn[i] = items;
606             };
607             return itemListReturn;
608         },
609         setItem: function (itemId, value) {
610             $(itemId).select2("val", value);
611         },
612     },
613     //文件上传 图片
614     fileupload: { //-------------todo------------------
615         getItem: function (itemId) {
616             var fileReturn = {};
617             for (i in customBase.options.uploaderItem[itemId]) {
618                 if (customBase.options.uploaderItem[itemId].hasOwnProperty(i)) {
619                     var timestamp = new Date().getTime();
620                     var idt = i.replace("WU", timestamp);
621                     fileReturn[idt] = customBase.options.uploaderItem[itemId][i];
622                     // fileReturn.push(customBase.options.uploaderItemReady[itemId][i]);
623                 }
624             };
625             //////console.log(fileReturn);
626             return fileReturn;
627         },
628         setItem: function (itemId, value) {
629             //无此情况
630         },
631     },
632     tree: { //-------------todo------------------
633         getItem: function (itemId) {
634
635             var returnItem = [];
636             var treeItem = $('div#' + itemId);
637             var dataItemJSson;
638             for (var i = 0; i < treeItem.length; i++) {
639                 if (treeItem[i].getAttribute("value") == "") {
640                     var treeItem = {};
641                 } else {
642                     ////console.log(selectItme[i].getAttribute("value"));
643                     dataItemJSson = $.parseJSON(treeItem[i].getAttribute("value"));
644                 }
645
646                 var jn = 0;
647                 returnItem[i] = [];
648                 for (j in dataItemJSson) {
649                     returnItem[i][jn] = j;
650                     jn++;
651                 }
652             }
653             return returnItem;
654         },
655         setItem: function (itemId, value) {
656             var treeDiv = $('div#' + itemId);
657             console.log(value)
658             // 判断是否在子表单内
659             var isSubformTree = false;
660             _.forIn(customShow.options.customItemShow.item, function (value, key) {
661                 if (value.tag_Id == itemId && value.parentsubFormNum != 0) {
662                     isSubformTree = true;
663                 }
664             });
13ec33 665
4d1219 666             //  不在子表单内的树
B 667             if (!isSubformTree) {
668                 var dataObj = {}
669                 var valueData = [];
670                 // 更新数据的时候需要在div上绑定一个存储数据的value
671                 //  单选
672                 if(value)
673                 console.log(value);
674                 // if(value == ' '){
675                 //     if(value == ' '){
676                 //         value =  window.localStorage.getItem('businessTypeAuto');
677                 //     }
678                 // }else{
679                     if (typeof value == "string") {
680                         dataObj[value] = '1'
681                     } else {
682                         for (var j = 0; j < value.length; j++) {
683                             valueData[j] = value[j].split(',')
684                             dataObj[valueData[j]] = '1'
685                         }
686                     }
687                     $('#' + itemId).attr('value', JSON.stringify(dataObj))
688                     console.log(value)
689                     console.log(itemId)
690                     var  b = $('#'+itemId + "tree")
691                     console.log($('#'+itemId + "tree"))
692                     var treeObj = $.fn.zTree.getZTreeObj(itemId + "tree");
693                     console.log(treeObj)
694                     if (treeObj == null) {
695                         return;
696                     }
697                     if (typeof value == "string") {
698                         value = [value];
699                     }
700                     //   2017/11/6 回显的地方
701                     for (var i = 0, l = value.length; i < l; i++) {
702                         if (treeObj.setting.check.chkStyle == "radio") {
703                             //  单选
704                             console.log(value)
705                             var nodes = treeObj.getNodeByParam("id", value[i], null);
706                             console.log(nodes);
707                             if (_.isNull(nodes)) {
708                                 // treeObj.checkAllNodes(false);
709                                 // return false;
710                             } else {
711                                 if (value == nodes.id) {
712                                     value = nodes.name;
713                                 }
714                                 console.log(value)
715                                 if (nodes != null) {
716                                     // 2017 /11/6 选中
717                                     //选择节点设定
718                                     treeObj.checkNode(nodes, true, true);
719                                     treeObj.expandAll(true);
720                                 }
721                             }
722                         } else {
723                             //  多选
724                             for (var j = 0; j < value[i].length; j++) {
725                                 //取得设定节点
726                                 console.log(value[j]);
727                                 var nodes = treeObj.getNodeByParam("id", value[j], null);
728                                 console.log(nodes)
729                                 if (_.isNull(nodes)) {
730                                     // treeObj.checkAllNodes(false);
731                                     // return false;
732                                 } else {
733                                     if (value[j] == nodes.id) {
734                                         value[j] = nodes.name;
735                                     }
736                                     console.log(nodes)
737                                     if (nodes != null) {
738                                         // 2017 /11/6 选中
739                                         //选择节点设定
740                                         treeObj.checkNode(nodes, true, true);
741                                         treeObj.expandAll(true);
742                                     }
743                                 }
744                             }
745                         }
746                     }
747                     //  详细页面的回显
96b1bc 748                     // 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">
L 749                     //         ${value}
750                     //             </div>`
751                     // $('#customShow').find(`#${itemId}ActiveId`).children(':nth-child(4)').remove();
752                     $('#customShow').find(`[treeitemid=${itemId}]`).html(value);//普通模式树形回显  李伟民  0130
753                     // $('#customShow').find(`#${itemId}ActiveId`).append(showTreeDiv);
754                     $('#' + itemId).parents('div[name="TreeWin"]').find('.citySel').val(value);
4d1219 755                 // }
B 756             } else {
757                 //  子表单里只有一颗树的时候
758                 if (treeDiv.length == 1) {
759                     var dataObj = {}
760                     var valueData = [];
761                     // 更新数据的时候需要在div上绑定一个存储数据的value
762                     //  单选
763                     console.log(value);
764                     // 不在子表单里的树更新时需要的数据
765                     if(value){
766                         if (typeof value[0] == "string" && value[0]!= '') {
767                             dataObj[value[0]] = '1'
768                         } else {
769                             for (var i = 0; i < value[0].length; i++) {
770                                 valueData[i] = value[0][i].split(',')
771                                 dataObj[valueData[i]] = '1'
772                             }
773                         }
774                         $('#' + itemId).attr('value', JSON.stringify(dataObj))
775                         var treeObj = $.fn.zTree.getZTreeObj(itemId + "tree");
776                         if (treeObj == null) {
777                             return;
778                         }
779                         if (typeof value == "string") {
780                             value = [value];
781                         }
782                         //   2017/11/6 回显的地方
783                         for (var i = 0, l = value.length; i < l; i++) {
784                             if (treeObj.setting.check.chkStyle == "radio") {
785                                 // 12/6   因为会触发customShow.addtree()导致ul 的id 变更
786                                 var treeDiv = $('div#' + itemId);
787                                 var ultreeId = $(treeDiv).find('ul').attr('id');
788                                 var treeObj = $.fn.zTree.getZTreeObj(ultreeId);
789                                 // var treeObj = $.fn.zTree.getZTreeObj(itemId + "tree1");
790                                 //  单选
791                                 var nodes = treeObj.getNodeByParam("id", value[i], null);
792                                 console.log(nodes)
793                                 if (_.isNull(nodes)) {
13ec33 794
4d1219 795                                     var  tid = '';
B 796                                     nodes = treeObj.getCheckedNodes(true);
797                                     for (var i = 0; i < nodes.length; i++) {
798                                         tid = nodes[i].tId
799                                     }
800                                     console.log(tid)
801                                     // 强行制空
802                                     $('#'+tid+'_check').click()
803                                     $('#' + tid + '_check').click()
804                                     $(treeDiv).prev().find('.citySel').val('')
805                                 } else {
806                                     if (value[i] == nodes.id) {
807                                         value[i] = nodes.name;
808                                     }
809                                     if (nodes != null) {
810                                         // 2017 /11/6 选中
811                                         //选择节点设定
812                                         console.log(nodes)
813                                         treeObj.checkNode(nodes, true, true);
814                                         treeObj.expandAll(true);
815                                         console.log(treeObj)
816                                         var  tid = '';
817                                             nodes11 = treeObj.getCheckedNodes(true);
818                                             console.log(nodes11)
819                                         for (var i = 0; i < nodes11.length; i++) {
820                                             tid = nodes11[i].tId
821                                         }
822                                         console.log(tid);
823                                         // console.log($('#'+tid+'_check'))
824                                         // $('#'+tid+'_check').click()
825                                         // $('#'+tid+'_check').click()
13ec33 826
4d1219 827                                     }
B 828                                 }
829                             } else {
830                                 //  多选
831                                 for (var j = 0; j < value[i].length; j++) {
832                                     //取得设定节点
833                                     console.log(value[i][j]);
834                                     var nodes = treeObj.getNodeByParam("id", value[i][j], null);
835                                     console.log(nodes)
836                                     if (_.isNull(nodes)) {
837                                         // treeObj.checkAllNodes(false);
838                                         // return false;
839                                     } else {
840                                         if (value[i][j] == nodes.id) {
841                                             value[i][j] = nodes.name;
842                                         }
843                                         console.log(nodes)
844                                         if (nodes != null) {
845                                             // 2017 /11/6 选中
846                                             //选择节点设定
847                                             treeObj.checkNode(nodes, true, true);
848                                             treeObj.expandAll(true);
849                                              console.log(treeObj)
13ec33 850
4d1219 851                                         }
B 852                                     }
853                                 }
854                             }
855                         }
856                         //      回显到table表格里
857                         var showIdTbale = $(`#${itemId}`).parents('.subformCss').attr('id');
858                         $(`#${itemId}`).parent('div[name="TreeWin"]').find('.citySel').val(value);
859                         var deitSubFormsTree = $(`#${showIdTbale}`).find('tbody').find('tr:nth-child(2)').find('td');
860                         for (var i = 1; i < deitSubFormsTree.length - 1; i++) {
861                             //  将编辑页面的树形ipnut 里面的值 放到展示页面里
862                             var value = $(deitSubFormsTree[i]).find('.citySel').val();
863                             $(`#customShow  #${showIdTbale}ActiveId`).find(`#${showIdTbale}`).find('.trContentClass').find(`td:nth-child(${i + 1})`).find('.customShowItemClass').html(value)
864                         }
13ec33 865
4d1219 866                     }
B 867
868                 } else {
869                     // 子表单内td里面的div更改
870                     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">';
871                     oNode += "</div>";
872                     var showItem = $($(".customShow").find("#" + itemId));
873                     for (var i = 0; i < showItem.length; i++) {
874                         $($(showItem[i])[0]).after(oNode);
875                         $($(showItem[i])[0]).remove();
876                     }
877                     var treeDiv = $('div#' + itemId);
878                     console.log(treeDiv)
879                     // 插入input里的value
880                     var iptValue = [];
881                     var iptValueObj = {};
882                     // 更新的时候需要的数据
883                     var dataObj = {}
884                     var valueData = [];
885                     for (var j = 0; j < treeDiv.length; j++) {
886                         var ultreeId = $(treeDiv[j]).find('ul').attr('id');
887                         var treeObj = $.fn.zTree.getZTreeObj(ultreeId);
888                         if (treeObj == null) {
889                             return;
890                         }
891                         if (typeof value == "string") {
892                             value = [value];
893                         }
894                         //   2017/11/6 回显的地方
895                         // 单选
896                         if (treeObj.setting.check.chkStyle == "radio") {
897                             console.log($(treeDiv[j]))
898                             console.log(value);
899                             for (var i = 0; i < value.length; i++) {
900                                 if (value[i] == '') {
901                                     console.log(1)
902                                     // dataObj = {}
903                                 } else {
904                                     console.log(2)
905                                     if (i == j) {
906                                         dataObj[value[i]] = '1';
907                                     }
908                                 }
909                             }
910                             $(treeDiv[j]).attr('value', JSON.stringify(dataObj))
911                             dataObj = {}
912                             console.log(j)
913                             console.log(value[j])
914                             var nodes = treeObj.getNodeByParam("id", value[j], null);
915                             console.log(nodes)
916                             console.log(treeObj)
917                             if (_.isNull(nodes)) {
918                                 // treeObj.checkAllNodes(false);
919                                 var  tid = '';
920                                     nodes = treeObj.getCheckedNodes(true);
921                                 for (var i = 0; i < nodes.length; i++) {
922                                     tid = nodes[i].tId
923                                 }
924                                 console.log(tid)
925                                 $('#' + tid + '_check').click()
926                                 $(treeDiv[j]).prev().find('.citySel').val('')
927                             } else {
928                                 if (value[j] == nodes.id) {
929                                     iptValue.push(nodes.name);
930                                 }
931                                 if (nodes != null) {
932                                     // 2017 /11/6 选中
933                                     //选择节点设定
934                                     console.log(treeObj);
935                                     console.log(nodes)
936                                     treeObj.checkNode(nodes, true, true);
937                                     treeObj.expandAll(true);
938                                 }
939                                 for (var k = 0; k < iptValue.length; k++) {
940                                     $(treeDiv[j]).prev().find('.citySel').val(iptValue[k])
941                                 }
942                             }
943
944                         } else {
945                             // 多选
946
947                             console.log(value[j])
948                             if (typeof value[j] == "string") {
949                                 var strValue = value[j].split(',');
950                                 // 导入excel时状态多选为字符串形式
951                                 if (strValue.length > 1) {
952                                     console.log(strValue)
953                                     for (var n = 0; n < strValue.length; n++) {
954                                         var nodes = treeObj.getNodeByParam("id", strValue[n], null);
955                                         console.log(nodes)
956                                         if (strValue[n] == '') {
957
958                                         } else {
959                                             dataObj[strValue[n]] = '1';
960                                         }
961                                         if (_.isNull(nodes)) {
962                                             // treeObj.checkAllNodes(false);
963                                             // return false;
964                                             $(treeDiv[j]).prev().find('.citySel').val('')
965
966                                         } else {
967                                             if (strValue[n] == nodes.id) {
968                                                 iptValue.push(nodes.name);
969                                             }
970                                             if (nodes != null) {
971                                                 // 2017 /11/6 选中
972                                                 //选择节点设定
973                                                 treeObj.checkNode(nodes, true, true);
974                                                 treeObj.expandAll(true);
975                                             }
976                                         }
977                                         $(treeDiv[j]).attr('value', JSON.stringify(dataObj))
978
979                                     }
980                                     $(treeDiv[j]).prev().find('.citySel').val(iptValue.join(','))
981                                     iptValue = [];
982                                     dataObj = {};
983                                 } else {
984                                     var nodes = treeObj.getNodeByParam("id", value[j], null);
985                                     for (var i = 0; i < value.length; i++) {
986                                         if (value[i] == '') {
987
988                                         } else {
989                                             if (i == j) {
990                                                 dataObj[value[i]] = '1';
991                                             }
992                                         }
993                                     }
994                                     $(treeDiv[j]).attr('value', JSON.stringify(dataObj))
995                                     dataObj = {}
996                                     if (_.isNull(nodes)) {
997                                         // treeObj.checkAllNodes(false);
998                                         // return false;
999                                     } else {
1000                                         if (value[j] == nodes.id) {
1001                                             iptValue.push(nodes.name);
1002                                         }
1003                                         if (nodes != null) {
1004                                             // 2017 /11/6 选中
1005                                             //选择节点设定
1006                                             treeObj.checkNode(nodes, true, true);
1007                                             treeObj.expandAll(true);
1008                                         }
1009                                         for (var k = 0; k < iptValue.length; k++) {
1010                                             $(treeDiv[j]).prev().find('.citySel').val(iptValue[k])
1011                                         }
1012                                         iptValue = [];
1013                                     }
1014                                 }
1015                             } else {
1016                                 var dataObj = {}
1017                                 var valueData = [];
1018                                 for (var i = 0; i < value[j].length; i++) {
1019                                     valueData[i] = value[j][i].split(',')
1020                                     dataObj[valueData[i]] = '1'
1021                                 }
1022                                 $(treeDiv[j]).attr('value', JSON.stringify(dataObj))
1023                                 for (var k = 0; k < value[j].length; k++) {
1024                                     //   j是 有几个input框
1025                                     //   k是  value 里面的数据还会有呈现数组的形式
1026                                     dataObj = {}
1027                                     valueData = [];
1028                                     var nodes = treeObj.getNodeByParam("id", value[j][k], null);
1029                                     if (_.isNull(nodes)) {
13ec33 1030
4d1219 1031                                     } else {
B 1032                                         if (value[j][k] == nodes.id) {
1033                                             if (k <= value[j].length) {
1034                                                 iptValue.push(nodes.name);
1035                                             }
1036                                         }
1037                                         iptValueObj[k] = iptValue;
1038                                         // if (nodes != null) {
1039                                             // 2017 /11/6 选中
1040                                             //选择节点设定
1041                                             treeObj.checkNode(nodes, true, true);
1042                                             treeObj.expandAll(true);
1043                                         // }
1044                                     }
1045                                 }
1046                                 for (index in iptValueObj) {
1047                                     $(treeDiv[j]).prev().find('.citySel').val(iptValueObj[index].join(','))
1048                                 }
1049                                 iptValue = [];
1050                                 iptValueObj = {};
1051                             }
1052
1053                         }
1054                         //  获取父级ID
1055                         var showIdTable = $(`#${itemId}`).parents('.subformCss').attr('id');
1056                         // 获取当前树形在整个td的下标
1057                         var subformDataIndex = $(`#${itemId}`).parents('td').index();
1058                         var subformTr = $('#customShow tr#' + showIdTable + "subformTr");
1059                         var subformValue = $($('.tabBox' + ' #' + showIdTable + "subformTr")[j]).find('td').eq(subformDataIndex).find('.citySel').val()
1060                         $(subformTr[j]).children().eq(subformDataIndex).find('.customShowItemClassTemp').html(subformValue);
1061                     }
1062                 }
1063             }
13ec33 1064
4d1219 1065         },
B 1066     },
1067     //选择表单控件
1068     mytext: {
1069         getItem: function (itemId) {
1070             //                var newmytextObj = $('#'+itemId+' ul');
1071             //                console.log(newmytextObj);
1072             //                var chooseFormData = {};
1073             //                var str = [];
1074             //                _.each(newmytextObj,(opt,i)=>{
1075             //                    var $mytextObj = $('#'+opt.id+' [class="data1 DATAROWNUM"]');
1076             //              var $mytextObj2 = $('#'+opt.id+' [class="data2 DATAROWNUM"]');
1077             ////              console.log($mytextObj);
1078             ////              console.log($mytextObj2);
1079             ////              console.log($mytextObj.html());
1080             ////              console.log($mytextObj2.html());
1081             ////              for(let i = 0;i < $mytextObj.length ;i++){
1082             ////                  var $myText = $mytextObj.eq(i).html();
1083             ////                  console.log($myText)
1084             ////                  console.log($mytextObj2.eq(i).html())
1085             ////                                    chooseFormData[$myText] = $mytextObj2.eq(i).html();
1086             ////
1087             ////              }
1088             ////              dataArr1.push($mytextObj2.html());
1089             //                                console.log(i);
1090             //                                console.log(newmytextObj.length);
1091             //                                if(i<newmytextObj.length-1){
1092             //                                    str += $mytextObj2.html()+",";
1093             //                                }else{
1094             //                                    str += $mytextObj2.html();
1095             //                                }
1096             //                })
1097             //                console.log(str)
1098
1099             var str = $('#' + itemId).attr("mxtVal");//关联数据 取值 11-07  李伟民
1100             return str;
1101
1102
1103         },
1104         setItem: function (itemId, value) {
1105             console.log(value);
1106             if (!_.isString(value)) {
1107                 var new_value = [];
1108                 _.each(value.list, function (v) {
1109                     if (v.DATAROWNUM) {
1110                         new_value.push(v.DATAROWNUM);
1111                     }
1112                 });
1113                 new_value = new_value.join();
1114                 $('#' + itemId).attr("mxtVal", new_value);//关联数据 存值 11-07  李伟民
1115             } else {
1116                 $('#' + itemId).attr("mxtVal", value);//关联数据 存值 11-07  李伟民
1117             }
1118         },
1119     },
1120 };
1121
1122
1123 //画面弹出信息
1124 customBase.alert = function (type, message) {
1125     if (type == "E") {
1126         toastr.error(message);
1127     } else if (type == "I") {
1128         toastr.info(message);
1129     } else if (type == "W") {
1130         toastr.warning(message);
1131     } else if (type == "S") {
1132         toastr.success(message);
1133     } else {
1134         toastr.error(message);
1135     }
1136 }
1137
1138 //根据别名取得字段Id
1139 customBase.getfieldKeyFoItemId = function (fieldKey) {
1140     return customBase.options.customItems[fieldKey].id;
1141 }
1142
1143 //取得message信息
1144 customBase.getMessage = function (messageID) {
1145     // 12/11
1146     var strMessage = "";
1147     switch (messageID) {
1148         case "mesage_ID001":
1149             strMessage = "子表单中无法追加此控件!";
1150             break;
1151         case "mesage_ID002":
1152             strMessage = "表单别名重复,请对别名进行修改!";
1153             break;
1154         case "mesage_ID003":
1155             strMessage = "表单保存成功!";
1156             break;
1157         case "mesage_ID004":
1158             strMessage = '项目必须输入!';
1159             break;
1160         case "mesage_ID005":
1161             strMessage = "上传成功!";
1162             break;
1163         case "mesage_ID006":
1164             strMessage = "操作过于频繁,请稍后再执行!";
1165             break;
1166         case "mesage_ID007":
1167             strMessage = "画面字段数据过多,保存失败!";
1168             break;
1169         case "mesage_ID008":
1170             strMessage = "单行文本的最大长度不能超过150!";
1171             break;
1172         case "mesage_ID009":
1173             strMessage = "'请输入有效的手机号码!";
1174             break;
1175         case "mesage_ID010":
1176             strMessage = "'请输入正确的网址!";
1177             break;
1178         case "mesage_ID011":
1179             strMessage = "'请输入有效的身份证号!";
1180             break;
1181         case "mesage_ID012":
1182             strMessage = "请输入有效的邮箱!";
1183             break;
1184         case "mesage_ID013":
1185             strMessage = "请输入表单名!";
1186             break;
1187         case "mesage_ID014":
1188             strMessage = "表单版本重复,请修改!";
1189             break;
1190         case "mesage_ID015":
1191             strMessage = "保存成功!";
1192             break;
1193         case "mesage_ID016":
1194             strMessage = "表单别名必须输入,请对别名进行修改!";
1195             break;
1196         case "mesage_ID017":
1197             strMessage = "表单的宽高必须输入!";
1198             break;
1199         case "mesage_ID018":
1200             strMessage = "请输入版本信息!";
1201             break;
1202         case "mesage_ID019":
1203             strMessage = "请输入整数!";
1204             break;
1205         case "mesage_ID020":
1206             strMessage = "整数长度超出设定范围!";
1207             break;
1208         case "mesage_ID021":
1209             strMessage = "小数长度超出设定范围!";
1210             break;
1211         case "mesage_ID022":
1212             strMessage = "条形码默认值不能为空!";
1213             break;
1214         case "mesage_ID023":
1215             strMessage = "长度超出设定范围!";
1216             break;
1217         case "mesage_ID024":
1218             strMessage = "请选择正确的部门";
1219             break;
1220         case "mesage_ID025":
1221             strMessage = "预算余额不足,不可退回";
1222             break;
1223         case "mesage_ID026":
1224             strMessage = "上级预算余额不足";
1225             break;
1226         case "mesage_ID027":
1227             strMessage = "操作成功";
1228             break;
1229         case "mesage_ID028":
1230             strMessage = "上级预算无此业务类型";
1231             break;
1232         case "mesage_ID029":
1233             strMessage = "还款成功";
1234             break;
1235         case "mesage_ID030":
1236             strMessage = "还款失败";
1237             break;
1238         case "mesage_ID031":
1239             strMessage = "创建流程实例成功";
1240             break;
1241         case "mesage_ID032":
1242             strMessage = "请创建流程定义";
1243             break;
1244         case "mesage_ID033":
1245             strMessage = "服务器返回错误有";
1246             break;
1247         case "mesage_ID034":
1248             strMessage = "本条数据已创建流程";
1249             break;
1250         case "mesage_ID035":
1251             strMessage = "请先选择流程定义";
1252             break;
1253         default:
1254             strMessage = "错误信息,请与管理员联系!";
1255     }
1256     return strMessage;
1257 }
1258
1259
1260 //取得表单画面项目
1261 customBase.getItemValue = function (itemId, type) {
1262
1263     var item = "";
1264     //单行文本 多行文本 数字 日历  customBase.itemEdit   var prefix =  JSON.parse(window.localStorage.getItem("customItem"));
1265     if (type == 'text' || type == 'textarea' || type == 'number' || type == 'calendar' || type == "auto") {
1266         item = customBase.itemEdit['text'].getItem("." + itemId + "value");
1267     } else if (type == 'radio' || type == 'checkbox') {
1268         item = customBase.itemEdit['checkboxRadio'].getItem(itemId, type);
1269     } else if (type == 'image' || type == 'fileupload') {
1270         item = customBase.itemEdit['fileupload'].getItem(itemId);
1271     } else if (type == 'amount') {
1272         item = customBase.itemEdit['text'].getItem("#" + itemId + "amount");
1273     } else if (type == 'qrcode') {
1274         item = customBase.itemEdit['text'].getItem("#" + itemId + "qrcode");
1275     } else if (type == 'barcode') {
1276         item = customBase.itemEdit['text'].getItem("#" + itemId + "barcode");
1277     } else if (type == 'splitline' || type == 'button') {
1278
1279     } else if (type == 'dropdownlistText') {
1280         // customBase.itemEdit[type].setItem(itemId,value,showClass,dropdowntype);
1281         // item = customBase.itemEdit["dropdownlistText"].getItem(itemId);
1282         item = customBase.itemEdit["dropdownlistText2"].getItem(itemId);
1283     } else if (type == "tree") {
1284         item = customBase.itemEdit["tree"].getItem(itemId);
1285     } else {
1286         item = customBase.itemEdit[type].getItem(itemId);
1287     }
1288     return item;
1289 }
1290 //设定表单画面项目   12/7
1291 customBase.setItemValue = function (itemId, type, value, showClass, dropdowntype, num) {
1292     console.log(type)
1293     console.log(value)
1294     console.log(itemId)
1295     var item;
1296     if (showClass == "") {
1297         showClass = 'customViewUEditorCss';
1298     }
1299     if (type == 'text' || type == 'textarea' || type == 'number' || type == 'calendar' || type == 'auto') {
1300         if (num != undefined) {
1301             customBase.itemEdit['text'].setItem("[id=" + itemId + "]:eq('" + num + "')", value, showClass);
1302         } else {
1303             customBase.itemEdit['text'].setItem("#" + itemId, value, showClass);
1304         }
1305     } else if (type == 'htmlediter') {
1306         customBase.itemEdit['htmlediter'].setItem(itemId, value, showClass);
1307     } else if (type == 'radio' || type == 'checkbox') {
1308         customBase.itemEdit['checkboxRadio'].setItem(itemId, type, value, showClass);
1309     } else if (type == 'tree') {
1310         customBase.itemEdit['tree'].setItem(itemId, value);
1311     } else if (type == 'dropdownlistText') {
1312         //console.log(value);
1313         customBase.itemEdit[type].setItem(itemId, value, showClass, dropdowntype);
1314         //console.log(1);
1315         customBase.itemEdit["dropdownlistText2"].setItem(itemId, value, showClass, dropdowntype);
1316     } else if (type == 'splitline' || type == 'subform' || type == 'tag' || type == 'tab') {
1317     } else if (type == 'image') {
1318         // customBase.itemEdit[type].setItem(itemId,value,showClass);
1319     } else if (type == 'qrcode') {
1320         // customBase.itemEdit[type].setItem(itemId,value,showClass);
1321     } else if (type == 'barcode') {
1322         // customBase.itemEdit[type].setItem(itemId,value,showClass);
1323     } else if (type == 'link') {
1324         // customBase.itemEdit[type].setItem(itemId,value,showClass);
1325     } else if (type == 'button') {
1326         // customBase.itemEdit[type].setItem(itemId,value,showClass);
1327     } else {
1328         customBase.itemEdit[type].setItem(itemId, value, showClass);
1329     }
1330
1331 }
1332
1333
1334 /**
1335  * 获取项目根路径1
1336  * @return {RootPath}
1337  */
1338 customBase.getRootPath = function () {
1339     var strFullPath = window.document.location.href;
1340     var strPath = window.document.location.pathname;
1341     var pos = strFullPath.indexOf(strPath);
1342     var prePath = strFullPath.substring(0, pos);
1343     var postPath = strPath.substring(0, strPath.substr(1).indexOf('/') + 1) + "/";
1344     return (prePath + postPath);
1345 }
1346
1347
1348
1349 //文件上传
1350 customBase.uploaderFileShow = function (potion) {
1351     console.log(potion);
1352     var itemId = potion.id;
1353
1354     customBase.options.uploaderItem[itemId] = {};
1355     var arrItemReady = 0;
1356     if (potion.ItemReady != undefined) {
1357         arrItemReady = Object.keys(potion.ItemReady).length;
1358         customBase.options.uploaderItem[itemId] = potion.ItemReady;
1359     }
1360     var $uploaderItem = $(".customViewUEditorCss #" + potion.id);
1361     $uploaderItem.empty();
1362     var $uploadimg = $(
1363         '<div id="' + potion.id + 'uploadimg">' +
1364         '<div id="' + potion.id + 'fileList" class="uploader-list"></div>' +
1365         '</div>'
1366     );
1367     var $list = $uploadimg.find("#" + potion.id + "fileList");
1368     var $addLi = $(
1369         '<div id="' + potion.id + 'imgPicker" class="file-item ">' +
1370         '<button type="button" class="btn btn-info designbtn right">点击选文件</button>' +
1371         '</div>'
1372     );
1373     $list.after($addLi);
1374
1375     //不可见辑情况下 附件追加按钮隐藏 李伟民 0123
1376     if (!potion.visible) {
1377         $addLi.addClass("cfg_contentNone");
1378     }
1379     if (!potion.editable) {//不可编辑 附件追加按钮样式修改 李伟民 0123
1380         $addLi.find('button').addClass("disabled");
1381     }
1382     //默认图片追加
1383     if (potion.defaultvalueUrl != "") {
1384         var tmp = potion.defaultvalueUrl.split("/");//按照"/"分割
1385         var pp = tmp[tmp.length - 1];//获取最后一部分,即文件名和参数
1386         var $li = $(
1387             '<div class="thumbnail01">' +
1388             '<div class="info"><a href="' + potion.defaultvalueUrl + '" >' + pp + '</a></div>' +
1389             '</div>'
1390         );
1391         $list.prepend($li);
1392         // //单一图片的情况下 图片追加隐藏
1393         // if(potion.imagetype == "single"){
1394         //     $addLi.addClass("cfg_contentNone");
1395         // }
1396     }
1397     //数据编辑的情况下,数据表示
1398     if (arrItemReady > 0) {
1399         for (fileid in potion.ItemReady) {
1400             if (potion.ItemReady.hasOwnProperty(fileid)) {
1401                 var fileItem = potion.ItemReady[fileid];
1402                 // var $list = $("#"+potion.id+"fileList"),
1403                 // var $list = $uploadimg,
764ba6 1404                 var fileDir = fileid.path;
Z 1405                 var suffix = fileDir.substr(fileDir.lastIndexOf(".")+1);
1406                 console.log(fileItem.path)
1407                 if(suffix == "mp4"){
1408                     $li = $(
1409                         '<div id="' + fileid + '" class="thumbnail01">' +
1410                         '<div class="frm_item_icons01">' +
1411                         '<div class="frm_item_icon remove" imgId="' + fileid + '">' +
1412                         '<img  alt=" " style="width:14px;height:14px;" src="./../../css/img/icon/delete.png"></div>' +
1413                         '</div>' +
1414                         // '<img class = "fileQueuedAddItem" src = "'+fileItem.base64+'">' +
1415                         // '<div class="info"><a href="'+customBase.options.uploaderItem[itemId][file.id].path+'" >' + file.name + '</a></div>' +
1416                         '<div class="info"><a href="' + fileItem.path + '" " target="_blank">' + fileItem.oldName + '</a></div>' +
1417                         '</div>'
1418                     );
1419                 }else{
1420                     $li = $(
1421                         '<div id="' + fileid + '" class="thumbnail01">' +
1422                         '<div class="frm_item_icons01">' +
1423                         '<div class="frm_item_icon remove" imgId="' + fileid + '">' +
1424                         '<img  alt=" " style="width:14px;height:14px;" src="./../../css/img/icon/delete.png"></div>' +
1425                         '</div>' +
1426                         // '<img class = "fileQueuedAddItem" src = "'+fileItem.base64+'">' +
1427                         // '<div class="info"><a href="'+customBase.options.uploaderItem[itemId][file.id].path+'" >' + file.name + '</a></div>' +
1428                         '<div class="info"><a href="' + fileItem.path + '" >' + fileItem.oldName + '</a></div>' +
1429                         '</div>'
1430                     );
1431                 }
4d1219 1432                 // $img = $li.find('.fileQueuedAddItem');
B 1433
1434                 $li.find(".frm_item_icon").on('click', function (event) {
1435                     var imgId = this.getAttribute("imgId");
1436                     $('#' + imgId).remove();
1437                     if (imgId.indexOf("WU") > -1) {
1438                         uploader.removeFile(imgId, true);
1439                     }
1440                     delete customBase.options.uploaderItem[itemId][imgId];
1441
1442                     event.stopPropagation();
1443                     return false;
1444
1445                 });
1446                 // $list为容器jQuery实例
1447                 $list.prepend($li);
1448             }
1449         }
1450     }
1451
1452     $uploaderItem.append($uploadimg);
1453     customBase.uploaderTemp += 500;
1454     setTimeout(function () {
1455         if (!potion.editable) {//不可编辑 点击无效果  李伟民 0123
1456            return false;
1457         }
1458         var uploader;
1459         var webUploaderJson = {
1460             // 选完文件后,是否自动上传。
1461             auto: true,
1462             // pick: '#'+potion.id+"dndArea",
1463             pick: '#' + potion.id + 'imgPicker',
1464             paste: potion.id,
1465             swf: '../../dist/Uploader.swf',
1466             // fileExt: '*.zip,*.doc,*.xls,*.mp3,*.mp4',
1467             // chunked:true,
1468             // chunkSize :true,
694e42 1469             fileSizeLimit: 20 * 1024 * 1024,    // 200 M
M 1470             fileSingleSizeLimit: 20 * 1024 * 1024,    // 50 M
4d1219 1471             accept: {// 只允许选择图片文件格式
B 1472                 title: 'File',
bb9424 1473                 extensions: 'zip,rar,mp3,mp4,xls,xlsx,doc,docx,ppt,pptx,rtf',
4d1219 1474                 mimeTypes: ''
B 1475             },
1476
1477         }
1478         var webUploaderJson = $.extend(webUploaderJson, window.commonWebUploaderJson(potion.formid));
1479
1480
1481         // 初始化Web Uploader
1482         uploader = WebUploader.create(webUploaderJson);
1483
1484         // uploader;
1485         uploader.on('ready', function () {
1486             debugger
1487             window.uploader = uploader;
1488         });
1489         uploader.on('error', function (type) {
1490             if (type == "Q_TYPE_DENIED") {
bb9424 1491                 customBase.alert("myModal", "请上传zip,rar,mp3,mp4,xls,xlsx,doc,docx,ppt,pptx,rtf格式文件", "");
4d1219 1492             }
B 1493         });
1494         // 当有文件添加进来的时候
1495         uploader.on('fileQueued', function (file) {
1496             // var $list = $("#"+potion.id+"fileList"),
1497             var $list = $(".customViewUEditorCss #" + potion.id + "fileList"),
1498                 $li = $(
1499                     '<div id="' + file.id + '" class="thumbnail01">' +
1500                     '<div class="frm_item_icons01">' +
1501                     '<div class="frm_item_icon remove" imgId="' + file.id + '">' +
764ba6 1502                     '<img   style="width:14px;height:14px;" src="./../../css/img/icon/delete.png"></div>' +
4d1219 1503                     '</div>' +
B 1504                     // '<img class = "fileQueuedAddItem">' +
764ba6 1505                     '<div class="info"><a  target="_blank" onclick=toastr.warning("加载中");>' + file.name + '</a>'+
Z 1506                     '<span style="color:red">&nbsp;&nbsp;&nbsp;&nbsp;*加载中请勿保存</span></div>' +
4d1219 1507                     '</div>'
764ba6 1508                 );
4d1219 1509                 $img = $li.find('.fileQueuedAddItem');
B 1510
1511             $li.find(".frm_item_icon").on('click', function () {
1512                 var imgId = this.getAttribute("imgId");
1513                 $('#' + imgId).remove();
1514                 if (imgId.indexOf("WU") > -1) {
1515                     uploader.removeFile(imgId, true);
1516                 }
1517                 delete customBase.options.uploaderItem[itemId][imgId];
1518
1519                 event.stopPropagation();
1520                 return false;
1521             });
1522             // $list为容器jQuery实例
1523             $list.prepend($li);
1524         });
1525         // 文件上传过程中创建进度条实时显示。
1526         uploader.on('uploadProgress', function (file, percentage) {
1527         });
1528
1529         // 文件上传成功,给item添加成功class, 用样式标记上传成功。
1530         uploader.on('uploadSuccess', function (file, response) {
1531             //////console.log(file);
1532             //////console.log(response);
1533
1534             $("#" + itemId + "mesageErrDiv").remove();
1535             $(".customViewUEditorCss  #" + itemId).popover('hide')
1536
1537             $('#' + file.id).addClass('upload-state-done');
1538             customBase.options.uploaderItem[itemId][file.id] = response.data;
1539             $('#' + file.id).find("a")[0].setAttribute("href", response.data.path);
764ba6 1540              $('#' + file.id).find("a")[0].onclick=null;
Z 1541             customBase.alert("S","上传成功");
1542             $('#' + file.id).find("span")[0].remove();
1543             // .attr("href",response.data.path);
4d1219 1544         });
B 1545
1546         // 文件上传失败,显示上传出错。
1547         uploader.on('uploadError', function (file) {
1548             var $li = $('#' + file.id),
1549                 $error = $li.find('div.error');
1550
1551             // 避免重复创建
1552             if (!$error.length) {
1553                 $error = $('<div class="error"></div>').appendTo($li);
1554             }
764ba6 1555             $('#' + file.id).find("a")[0].onclick=null;
Z 1556             $('#' + file.id).find("span")[0].remove();
4d1219 1557             $error.text('上传失败');
B 1558         });
1559
1560         // 完成上传完了,成功或者失败,先删除进度条。
1561         uploader.on('uploadComplete', function (file) {
1562             $('#' + file.id).find('.progress').remove();
1563         });
1564     }, customBase.uploaderTemp);
1565 }
1566 //图片上传
1567 customBase.uploaderShow = function (potion) {
1568     var customShowFlag = window.localStorage.getItem("customShowFlag")
1569     console.log(customShowFlag);
1570     console.log(customBase.options);
1571     console.log(customShow.options.customItemShow.item);
1572     var customItem = customShow.options.customItemShow.item;
1573     //////console.log(potion);
1574     var itemId = potion.id;
1575     // var uploader;
1576     customBase.options.uploaderItem[itemId] = {};
1577     var arrItemReady = 0;
1578     if (potion.ItemReady != undefined) {
1579         arrItemReady = Object.keys(potion.ItemReady).length;
1580         customBase.options.uploaderItem[itemId] = potion.ItemReady;
1581     }
1582     var $uploaderItem = $(".customViewUEditorCss #" + potion.id);
1583     $uploaderItem.empty();
1584     var $uploadimg = $(
1585         '<div id="' + potion.id + 'uploadimg">' +
1586         '<div id="' + potion.id + 'fileList" class="uploader-list"></div>' +
1587         '</div>'
1588     );
1589     var $list = $uploadimg.find("#" + potion.id + "fileList");
1590     console.log($('#' + itemId))
1591     var $addLi = $(
1592         '<div id="' + potion.id + 'imgPicker" class="file-item thumbnail">' +
956db4 1593         '<div  style="background:url(./../../formEngine/resources/css/image.png) no-repeat ;width: 100px;height: 100px;>"  </div>' +
4d1219 1594         '</div>'
B 1595     );
1596     $list.prepend($addLi);
1597     // //不可编辑情况下 图片追加隐藏
1598     // if (!potion.editable) {
1599     //     $addLi.addClass("cfg_contentNone");
1600     // }
1601     //不可见辑情况下 图片追加按钮隐藏 李伟民 0123
1602     if (!potion.visible) {
1603         $addLi.addClass("cfg_contentNone");
1604     }
1605     if (!potion.editable) {//不可编辑 图片追加样式修改 李伟民 0123
1606         $addLi.css("cursor","not-allowed")
1607     }
1608     //默认图片追加
1609     if (potion.defaultvalueUrl != "") {
1610         var $li = $(
1611             '<div class="file-item thumbnail">' +
1612             '<img src="' + potion.defaultvalueUrl + '"' +
1613             '</div>'
1614             // `<div class="file-item thumbnail">
1615             //     <img src="${potion.defaultvalueUrl}" data-original="${otion.defaultvalueUrl}"
1616             // </div>`
1617         );
1618         $list.prepend($li);
1619         //单一图片的情况下 图片追加隐藏
1620         if (potion.imagetype == "single") {
1621             $addLi.addClass("cfg_contentNone");
1622         }
1623     }
1624     //数据编辑的情况下,数据表示
1625     console.log(arrItemReady)
1626     if (arrItemReady > 0) {
1627         console.log(potion.ItemReady)
1628         for (fileid in potion.ItemReady) {
1629             if (potion.ItemReady.hasOwnProperty(fileid)) {
1630                 var fileItem = potion.ItemReady[fileid];
1631                 // var $list = $("#"+potion.id+"fileList"),
1632                 // var $list = $uploadimg,
1633                 var $li = $(
1634                     '<div id="' + fileid + '" class="file-item thumbnail">' +
04dc45 1635                     '<img alt=" " class = "fileQueuedAddItem" src = "' + fileItem.path + '"  data-original ="' + fileItem.path + '" >' +
4d1219 1636                     '<div class="frm_item_icons">' +
B 1637                     '<div class="frm_item_icon remove" imgId="' + fileid + '">' +
1638                     // '<img  style="width:14px;height:14px;" src="./../../css/img/icon/delete.png"></div>' +
956db4 1639                     '<div  style="width:14px;height:14px;background:url(./../../formEngine/resources/css/img/icon/delete.png);"> </div></div>' +
4d1219 1640
B 1641                     '</div>' +
1642                     // '<div class="info">' + file.name + '</div>' +
1643                     '</div>'
1644                 );
1645
1646
1647                 $li.find(".frm_item_icon").on('click', function () {
1648                     var imgId = this.getAttribute("imgId");
1649                     $('#' + imgId).remove();
1650                     if (imgId.indexOf("WU") > -1) {
1651                         uploader.removeFile(imgId, true);
1652                     }
1653                     delete customBase.options.uploaderItem[itemId][imgId];
1654                     //单一图片的情况下 图片追加隐藏
1655                     if (potion.imagetype == "single") {
1656                         $addLi.removeClass("cfg_contentNone");
1657                     }
1658                     console.log($(this))
1659                     event.stopPropagation();
1660                 });
1661                 // $list为容器jQuery实例
1662                 $list.prepend($li);
1663                 console.log($('#customShow').children())
1664
1665             }
1666         }
1667     }
1668     //单一图片的情况下 图片追加隐藏
1669     if (arrItemReady > 0 && potion.imagetype == "single") {
1670         setTimeout(function () {
1671             $addLi.addClass("cfg_contentNone");
1672         }, 10);
1673         console.log($('#customShow').children())
1674
1675     }
1676
1677     $uploaderItem.append($uploadimg);
1678     customBase.uploaderTemp += 500;
1679     setTimeout(function () {
1680         if (!potion.editable) {//不可编辑 取消点击事件 李伟民 0123
1681            return false;
1682         }
1683         var uploader;
04dc45 1684         //发布页面 多选图片 曲辰明 3-27
Q 1685         if (potion.imagetype == "single") {
1686             var webUploaderJson = {
1687                 // 选完文件后,是否自动上传。
1688                 auto: true,
1689                 // pick: '#'+potion.id+"dndArea",
1690                 pick: {
1691                     id: '#' + potion.id + 'imgPicker',
1692                     multiple: false//禁止多选
1693                 },
1694                 paste: potion.id,
1695                 swf: '../../dist/Uploader.swf',
1696             }
1697         }else{
1698             var webUploaderJson = {
1699                 // 选完文件后,是否自动上传。
1700                 auto: true,
1701                 // pick: '#'+potion.id+"dndArea",
1702                 pick: {
1703                     id: '#' + potion.id + 'imgPicker',
1704                     multiple: true//多选
1705                 },
1706                 paste: potion.id,
1707                 swf: '../../dist/Uploader.swf',
1708             }
4d1219 1709         }
B 1710         var webUploaderJson = $.extend(webUploaderJson, window.commonWebUploaderJson(potion.formid));
1711
1712
1713         // 初始化Web Uploader
1714         uploader = WebUploader.create(webUploaderJson);
1715
1716         // uploader;
1717         uploader.on('ready', function () {
1718             window.uploader = uploader;
1719         });
1720         // 当有文件添加进来的时候
1721         uploader.on('fileQueued', function (file) {
1722             // var $list = $("#"+potion.id+"fileList"),
1723             var $list = $(".customViewUEditorCss #" + potion.id + "fileList"),
1724                 $li = $(
1725                     '<div id="' + file.id + '" class="file-item thumbnail">' +
1726                     '<div class="frm_item_icons">' +
1727                     '<div class="frm_item_icon remove" imgId="' + file.id + '">' +
956db4 1728                     '<img  style="width:14px;height:14px;" src="./../../formEngine/resources/css/img/icon/delete.png"></div>' +
4d1219 1729                     '</div>' +
B 1730                     '<img  class = "fileQueuedAddItem">' +
1731                     // '<div class="info">' + file.name + '</div>' +
1732                     '</div>'
1733                 ),
1734                 $img = $li.find('.fileQueuedAddItem');
1735
1736             $li.find(".frm_item_icon").on('click', function () {
1737                 var imgId = this.getAttribute("imgId");
1738                 $('#' + imgId).remove();
1739                 if (imgId.indexOf("WU") > -1) {
1740                     uploader.removeFile(imgId, true);
1741                 }
1742                 delete customBase.options.uploaderItem[itemId][imgId];
1743                 //单一图片的情况下 图片追加隐藏
1744                 if (potion.imagetype == "single") {
1745                     $addLi.removeClass("cfg_contentNone");
1746                 }
1747
1748                 event.stopPropagation();
1749
1750             });
1751             // $list为容器jQuery实例
1752             $list.prepend($li);
1753
1754             //单一图片的情况下 图片追加隐藏
1755             if (potion.imagetype == "single") {
1756                 $addLi.addClass("cfg_contentNone");
1757             }
1758
1759             // 创建缩略图
1760             // 如果为非图片文件,可以不用调用此方法。
1761             // thumbnailWidth x thumbnailHeight 为 100 x 100
1762             uploader.makeThumb(file, function (error, src) {
1763                 if (error) {
1764                     $img.replaceWith('<span>不能预览</span>');
1765                     return;
1766                 }
1767                 // //////console.log(customBase.options.uploaderItem[itemId][file.id]);
1768                 // customBase.options.uploaderItem[itemId][file.id]["base64"] = src;
1769                 $img.attr('src', src);
1770                 // 12/21
1771                 console.log($img)
1772                 $img.attr('data-original', src);
04dc45 1773                 // 发布页面查看大图  曲辰明 3-27
Q 1774                 var viewer = new Viewer(document.getElementById(file.id), {
1775                     url: 'data-original',
1776                     movable: false
1777                 });
1778             }, 400, 400);
4d1219 1779         });
B 1780         // 文件上传过程中创建进度条实时显示。
1781         uploader.on('uploadProgress', function (file, percentage) {
1782             var $li = $('#' + file.id),
1783                 $percent = $li.find('.progress span');
1784
1785             // 避免重复创建
1786             if (!$percent.length) {
1787                 $percent = $('<p class="progress"><span></span></p>')
1788                     .appendTo($li)
1789                     .find('span');
1790             }
1791             //////console.log(percentage);
1792             $percent.css('width', percentage * 100 + '%');
1793         });
1794
1795         // 文件上传成功,给item添加成功class, 用样式标记上传成功。
1796         uploader.on('uploadSuccess', function (file, response) {
1797             //////console.log(file);
1798             //////console.log(response);
1799             $('#' + file.id).addClass('upload-state-done');
1800             // customBase.options.uploaderFileName[file.id] = response.data;
1801             customBase.options.uploaderItem[itemId][file.id] = response.data;
1802             // //////console.log(customBase.options.uploaderItem[itemId][file.id]);
1803             customBase.options.uploaderItem[itemId][file.id]["base64"] = $("#" + file.id + " .fileQueuedAddItem")[0].getAttribute("src");
1804         });
1805
1806         // 文件上传失败,显示上传出错。
1807         uploader.on('uploadError', function (file) {
1808             var $li = $('#' + file.id),
1809                 $error = $li.find('div.error');
1810
1811             // 避免重复创建
1812             if (!$error.length) {
1813                 $error = $('<div class="error"></div>').appendTo($li);
1814             }
1815
1816             $error.text('上传失败');
1817         });
1818
1819         // 完成上传完了,成功或者失败,先删除进度条。
1820         uploader.on('uploadComplete', function (file) {
1821             $('#' + file.id).find('.progress').remove();
1822         });
1823     }, customBase.uploaderTemp);
1824     // 12/19
1825     console.log($uploadimg)
1826     console.log($('#customViewUEditor').find('#itemId_1').children())
1827
1828     var $uploaderItems = $($("#customViewUEditor #" + potion.id)[0]);
1829     var imgId = $uploaderItems.attr('id');
1830     var srcUrl = $uploaderItems.find('img').attr('src');
1831     // $uploaderItem.find('img').attr('data-original',srcUrl);
1832     console.log($('#' + imgId).children().children())
1833
1834     console.log($('#' + imgId).find('#itemId_1fileList').find('label'))
1835     $('#' + imgId).find('#itemId_1fileList').find('label').css({
1836         'height': '150px',
1837         'width': '150px'
1838     })
1839     var id = $('#' + imgId).children().children().attr('id')
1840     //编辑
1841     var viewer = new Viewer(document.getElementById(id), {
1842         url: 'data-original',
1843         movable: false
1844     });
1845     console.log($('#customShow').children())
1846     console.log($("[style='opacity: 0; width: 100%; height: 100%; display: block; cursor: pointer; background: rgb(255, 255, 255)']"))
1847 }
1848
1849
1850 //图片上传
1851 customBase.uploaderShow_Temp = function (itemId, chunkSize, imgFlag, formID) {
1852     if (chunkSize.width != 0) {
1853         $(itemId + 'dndArea')[0].style.width = chunkSize.width + 'px';
1854         $(itemId + 'dndArea')[0].style.height = chunkSize.height + 'px';
1855     }
1856
1857     var $wrap = $(itemId),
1858         // 图片容器
1859         $queue = $('<ul class="filelist"></ul>').appendTo($wrap.find('.queueList')),
1860         // 状态栏,包括进度和控制按钮
1861         $statusBar = $wrap.find('.statusBar'),
1862         // 文件总体选择信息。
1863         $info = $statusBar.find('.info'),
1864         // 上传按钮
1865         $upload = $wrap.find('.uploadBtn'),
1866         // 没选择文件之前的内容。
1867         $placeHolder = $wrap.find('.placeholder'),
1868
1869         $progress = $statusBar.find('.progress').hide(),
1870         // 添加的文件数量
1871         fileCount = 0,
1872         // 添加的文件总大小
1873         fileSize = 0,
1874         // 优化retina, 在retina下这个值是2
1875         ratio = window.devicePixelRatio || 1,
1876         // 缩略图大小
1877         thumbnailWidth = 110 * ratio,
1878         thumbnailHeight = 110 * ratio,
1879         // 可能有pedding, ready, uploading, confirm, done.
1880         state = 'pedding',
1881         // 所有文件的进度信息,key为file id
1882         percentages = {},
1883         // 判断浏览器是否支持图片的base64
1884         isSupportBase64 = (function () {
1885             var data = new Image();
1886             var support = true;
1887             data.onload = data.onerror = function () {
1888                 if (this.width != 1 || this.height != 1) {
1889                     support = false;
1890                 }
1891             }
1892             data.src = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";
1893             return support;
1894         })(),
1895         // 检测是否已经安装flash,检测flash的版本
1896         flashVersion = (function () {
1897             var version;
1898
1899             try {
1900                 version = navigator.plugins['Shockwave Flash'];
1901                 version = version.description;
1902             } catch (ex) {
1903                 try {
1904                     version = new ActiveXObject('ShockwaveFlash.ShockwaveFlash')
1905                         .GetVariable('$version');
1906                 } catch (ex2) {
1907                     version = '0.0';
1908                 }
1909             }
1910             version = version.match(/\d+/g);
1911             return parseFloat(version[0] + '.' + version[1], 10);
1912         })(),
1913
1914         supportTransition = (function () {
1915             var s = document.createElement('p').style,
1916                 r = 'transition' in s ||
1917                     'WebkitTransition' in s ||
1918                     'MozTransition' in s ||
1919                     'msTransition' in s ||
1920                     'OTransition' in s;
1921             return r;
1922         })(),
1923         //创建
1924         uploader;
1925
1926     if (!WebUploader.Uploader.support('flash') && WebUploader.browser.ie) {
1927         // flash 安装了但是版本过低。
1928         if (flashVersion) {
1929             (function (container) {
1930                 window['expressinstallcallback'] = function (state) {
1931                     switch (state) {
1932                         case 'Download.Cancelled':
1933                             customBase.alert("M", '您取消了更新!')
1934                             break;
1935
1936                         case 'Download.Failed':
1937                             customBase.alert("M", '安装失败')
1938                             break;
1939
1940                         default:
1941                             customBase.alert("M", '安装已成功,请刷新!');
1942                             break;
1943                     }
1944                     delete window['expressinstallcallback'];
1945                 };
1946
1947                 var swf = './expressInstall.swf';
1948                 // insert flash object
1949                 var html = '<object type="application/' +
1950                     'x-shockwave-flash" data="' + swf + '" ';
1951
1952                 if (WebUploader.browser.ie) {
1953                     html += 'classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
1954                 }
1955
1956                 html += 'width="100%" height="100%" style="outline:0">' +
1957                     '<param name="movie" value="' + swf + '" />' +
1958                     '<param name="wmode" value="transparent" />' +
1959                     '<param name="allowscriptaccess" value="always" />' +
1960                     '</object>';
1961
1962                 container.html(html);
1963
1964             })($wrap);
1965
1966             // 压根就没有安转。
1967         } else { }
1968
1969         return;
1970     } else if (!WebUploader.Uploader.support()) {
1971         customBase.alert("M", 'Web Uploader 不支持您的浏览器!');
1972         return;
1973     }
1974     if (imgFlag) {
1975         labelTemp = '点击选择图片'
1976     } else {
1977         labelTemp = '点击选择文件'
1978     }
1979
1980
1981
1982     ;
1983     var webUploaderJson = {
1984         pick: {
1985             id: itemId + 'filePicker',
1986             label: labelTemp
1987         },
1988         dnd: itemId + 'dndArea',
1989         paste: itemId,
1990         swf: '../../dist/Uploader.swf',
1991         chunked: false,
1992         chunkSize: 512 * 1024,
1993         // 禁掉全局的拖拽功能。这样不会出现图片拖进页面的时候,把图片打开。
1994         disableGlobalDnd: true,
1995         fileNumLimit: 300,
1996         fileSizeLimit: 200 * 1024 * 1024,    // 200 M
1997         fileSingleSizeLimit: 50 * 1024 * 1024    // 50 M
1998     }
1999     var webUploaderJson = $.extend(webUploaderJson, window.commonWebUploaderJson(formID));
2000
2001     // 实例化
2002     uploader = WebUploader.create(webUploaderJson);
2003
2004     // 拖拽时不接受 js, txt 文件。
2005     uploader.on('dndAccept', function (items) {
2006         var denied = false,
2007             len = items.length,
2008             i = 0,
2009             // 修改js类型
2010             unAllowed = 'text/plain;application/javascript ';
2011
2012         for (; i < len; i++) {
2013             // 如果在列表里面
2014             if (~unAllowed.indexOf(items[i].type)) {
2015                 denied = true;
2016                 break;
2017             }
2018         }
2019
2020         return !denied;
2021     });
2022
2023     // 添加“添加文件”的按钮,
2024     uploader.addButton({
2025         id: itemId + 'filePicker2',
2026         label: '继续添加'
2027     });
2028     //文件读取
2029     uploader.on('ready', function () {
2030         window.uploader = uploader;
2031         $queue.empty();
2032         var json = customBase.options.uploaderItemReady[itemId.replace("#", "")];
2033         if (json == undefined) {
2034             json = [];
2035         }
2036         var jsonLen = json.length;
2037         if (jsonLen != 0) {
2038             fileCount = jsonLen;
2039             $placeHolder.addClass('element-invisible');
2040             $statusBar.show();
2041             //显示在页面上
2042             $.each(json, function (i, n) {
2043                 fileSize += n.filelen;
2044                 var obj = {}, statusMap = {}
2045                     , file_id = 'WU_FILE_' + i;
2046                 obj.id = file_id;
2047                 obj.name = n.filebasename;
2048                 obj.filename = n.filename;
2049                 obj.getStatus = function () {
2050                     return '';
2051                 };
2052                 obj.statusText = '';
2053                 obj.size = n.filelen;
2054                 obj.version = WebUploader.Base.version;
2055                 obj.type = n.mimeType;
2056                 obj.filetype = n.filetype;
2057                 obj.source = this;
2058                 obj.path = n.filePath.path;
2059                 obj.setStatus = function (status, text) {
2060
2061                     var prevStatus = statusMap[this.id];
2062
2063                     typeof text !== 'undefined' && (this.statusText = text);
2064
2065                     if (status !== prevStatus) {
2066                         statusMap[this.id] = status;
2067                         /**
2068                          * 文件状态变化
2069                          * @event statuschange
2070                          */
2071                         uploader.trigger('statuschange', status, prevStatus);
2072                     }
2073                 };
2074                 editFile(obj);
2075                 $("#" + file_id).append(inputStr(i, n));
2076             });
2077
2078             WebUploader.Base.idSuffix = jsonLen;
2079
2080             setState('ready');
2081             updateTotalProgress();
2082         }
2083         // },'json');
2084     });
2085
2086     function inputStr(index, json) {
2087         var inputStr = '';
2088         var pre = itemId;
2089         //转化格式后的名称
2090         inputStr += '<input name="' + pre + 'list[' + index + '].filename"   value="' + json.filename + '" style="display:none"/>';
2091         //保存路径
2092         inputStr += '<input name="' + pre + 'list[' + index + '].filepath"   value="' + json.filepath + '" style="display:none"/>';
2093         //文件源名称
2094         inputStr += '<input name="' + pre + 'list[' + index + '].filebasename"   value="' + json.filebasename + '" style="display:none"/>';
2095
2096         //文件类型  doc?xls?
2097         inputStr += '<input name="' + pre + 'list[' + index + '].filetype"   value="' + json.filetype + '" style="display:none"/>';
2098         //文件大小
2099         inputStr += '<input name="' + pre + 'list[' + index + '].filelen"   value="' + json.filelen + '" style="display:none"/>';
2100         //doc转为html
2101         inputStr += '<input name="' + pre + 'list[' + index + '].doc2htmlpath" value="' + json.doc2htmlpath + '"  style="display:none"/>';
2102         //mimeType
2103         inputStr += '<input name="' + pre + 'list[' + index + '].mimeType" value="' + json.mimeType + '"  style="display:none"/>';
2104         return inputStr;
2105     }
2106
2107     function editFile(file) {
2108         if (imgFlag) {
2109             var $li = $('<li id="' + file.id + '" class="imgfileLiShow">' +
2110                 '<p class="title">' + file.name + '</p>' +
2111                 '<p class="imgWrap"></p>' +
2112                 '<p class="progress"><span></span></p>' +
2113                 '</li>'),
2114
2115                 $btns = $('<div class="file-panel">' +
2116                     '<span class="cancel">删除</span>' +
2117                     '<span class="rotateRight">向右旋转</span>' +
2118                     '<span class="rotateLeft">向左旋转</span></div>').appendTo($li),
2119
2120                 $wrap = $li.find('p.imgWrap')
2121
2122         } else {
2123             var $li = $('<li id="' + file.id + '">' +
2124                 '<div class="title" style="word-break:break-all;text-align:left;font-size:16px">' + file.filename + '</div>' +
2125
2126                 '</li>'),
2127                 $btns = $('<div class="file-panel">' +
2128                     '<span class="cancel">删除</span>'
2129
2130                     + '</div>'
2131                 ).appendTo($li),
2132
2133                 $wrap = $li.find('p.imgWrap')
2134         }
2135
2136         if (file.getStatus() === 'invalid') {
2137             showError(file.statusText);
2138         } else {
2139             // @todo lazyload
2140             $wrap.empty();
2141             $wrap.text('不能预览');
2142
2143             var img;
2144             //判断是否是图片
2145             src = file.path;
2146             img = $('<img  src="' + src + '" style="height:100%;">');
2147             $wrap.empty().append(img);
2148
2149             percentages[file.id] = [file.size, 0];
2150             file.rotation = 0;
2151         }
2152
2153
2154
2155         $li.append('<span class="success"></span>');
2156
2157         $li.on('mouseenter', function () {
2158             $btns.stop().animate({ height: 30 });
2159         });
2160
2161         $li.on('mouseleave', function () {
2162             $btns.stop().animate({ height: 0 });
2163         });
2164
2165         $btns.on('click', 'span', function () {
2166             var index = $(this).index(),
2167                 deg;
2168
2169             switch (index) {
2170                 case 0:
2171                     // uploader.removeFile( file );
2172                     return;
2173
2174                 case 1:
2175                     file.rotation += 90;
2176                     break;
2177
2178                 case 2:
2179                     file.rotation -= 90;
2180                     break;
2181             }
2182
2183             if (supportTransition) {
2184                 deg = 'rotate(' + file.rotation + 'deg)';
2185                 $wrap.css({
2186                     '-webkit-transform': deg,
2187                     '-mos-transform': deg,
2188                     '-o-transform': deg,
2189                     'transform': deg
2190                 });
2191             } else {
2192                 $wrap.css('filter', 'progid:DXImageTransform.Microsoft.BasicImage(rotation=' + (~~((file.rotation / 90) % 4 + 4) % 4) + ')');
2193             }
2194
2195
2196         });
2197
2198         $li.appendTo($queue);
2199     }
2200
2201
2202     // 当有文件添加进来时执行,负责view的创建
2203     if (imgFlag) { }
2204     function addFile(file) {
2205         if (imgFlag) {
2206             var $li = $('<li id="' + file.id + '" class="imgfileLiShow">' +
2207                 '<p class="title">' + file.name + '</p>' +
2208                 '<p class="imgWrap"></p>' +
2209                 '<p class="progress"><span></span></p>' +
2210                 '</li>'),
2211
2212                 $btns = $('<div class="file-panel">' +
2213                     '<span class="cancel">删除</span>' +
2214                     '<span class="rotateRight">向右旋转</span>' +
2215                     '<span class="rotateLeft">向左旋转</span></div>').appendTo($li),
2216                 $prgress = $li.find('p.progress span'),
2217                 $wrap = $li.find('p.imgWrap'),
2218                 $info = $('<p class="error"></p>')
2219         } else {
2220             var $li = $('<li id="' + file.id + '">' +
2221                 '<div class="title" style="word-break:break-all;text-align:left;font-size:16px">' + file.name + '</div>' +
2222                 '</li>'),
2223
2224                 $btns = $('<div class="file-panel">' +
2225                     '<span class="cancel">删除</span>' +
2226                     '</div>'
2227                 ).appendTo($li),
2228                 $prgress = $li.find('p.progress span'),
2229                 $wrap = $li.find('p.imgWrap'),
2230                 $info = $('<p class="error"></p>')
2231         }
2232
2233
2234         showError = function (code) {
2235             switch (code) {
2236                 case 'exceed_size':
2237                     text = '文件大小超出';
2238                     break;
2239
2240                 case 'interrupt':
2241                     text = '上传暂停';
2242                     break;
2243
2244                 default:
2245                     text = '上传失败,请重试';
2246                     break;
2247             }
2248
2249             $info.text(text).appendTo($li);
2250         };
2251
2252         if (file.getStatus() === 'invalid') {
2253             showError(file.statusText);
2254         } else {
2255             // @todo lazyload
2256             $wrap.text('预览中');
2257             uploader.makeThumb(file, function (error, src) {
2258                 var img;
2259
2260                 if (error) {
2261                     $wrap.text('不能预览');
2262                     return;
2263                 }
2264                 if (isSupportBase64) {
2265                     img = $('<img src="' + src + '">');
2266                     $wrap.empty().append(img);
2267                 } else {
2268
2269                 }
2270             }, thumbnailWidth, thumbnailHeight);
2271
2272             percentages[file.id] = [file.size, 0];
2273             file.rotation = 0;
2274         }
2275
2276         file.on('statuschange', function (cur, prev) {
2277             if (prev === 'progress') {
2278                 $prgress.hide().width(0);
2279             } else if (prev === 'queued') {
2280                 $li.off('mouseenter mouseleave');
2281                 $btns.remove();
2282             }
2283
2284             // 成功
2285             if (cur === 'error' || cur === 'invalid') {
2286                 //////////console.log( file.statusText );
2287                 showError(file.statusText);
2288                 percentages[file.id][1] = 1;
2289             } else if (cur === 'interrupt') {
2290                 showError('interrupt');
2291             } else if (cur === 'queued') {
2292                 percentages[file.id][1] = 0;
2293             } else if (cur === 'progress') {
2294                 $info.remove();
2295                 $prgress.css('display', 'block');
2296             } else if (cur === 'complete') {
2297                 $li.append('<span class="success"></span>');
2298             }
2299
2300             $li.removeClass('state-' + prev).addClass('state-' + cur);
2301         });
2302
2303         $li.on('mouseenter', function () {
2304             $btns.stop().animate({ height: 30 });
2305         });
2306
2307         $li.on('mouseleave', function () {
2308             $btns.stop().animate({ height: 0 });
2309         });
2310
2311         $btns.on('click', 'span', function () {
2312             var index = $(this).index(),
2313                 deg;
2314
2315             switch (index) {
2316                 case 0:
2317                     uploader.removeFile(file);
2318                     return;
2319
2320                 case 1:
2321                     file.rotation += 90;
2322                     break;
2323
2324                 case 2:
2325                     file.rotation -= 90;
2326                     break;
2327             }
2328
2329             if (supportTransition) {
2330                 deg = 'rotate(' + file.rotation + 'deg)';
2331                 $wrap.css({
2332                     '-webkit-transform': deg,
2333                     '-mos-transform': deg,
2334                     '-o-transform': deg,
2335                     'transform': deg
2336                 });
2337             } else {
2338                 $wrap.css('filter', 'progid:DXImageTransform.Microsoft.BasicImage(rotation=' + (~~((file.rotation / 90) % 4 + 4) % 4) + ')');
2339             }
2340
2341
2342         });
2343
2344         $li.appendTo($queue);
2345     }
2346
2347     // 负责view的销毁
2348     function removeFile(file) {
2349         var $li = $('#' + file.id);
2350
2351         delete percentages[file.id];
2352         updateTotalProgress();
2353         $li.off().find('.file-panel').off().end().remove();
2354     }
2355
2356     function updateTotalProgress() {
2357         var loaded = 0,
2358             total = 0,
2359             spans = $progress.children(),
2360             percent;
2361
2362         $.each(percentages, function (k, v) {
2363             total += v[0];
2364             loaded += v[0] * v[1];
2365         });
2366
2367         percent = total ? loaded / total : 0;
2368
2369
2370         spans.eq(0).text(Math.round(percent * 100) + '%');
2371         spans.eq(1).css('width', Math.round(percent * 100) + '%');
2372         updateStatus();
2373     }
2374
2375     function updateStatus() {
2376         var text = '', stats;
2377
2378         if (state === 'ready') {
2379             if (imgFlag) {
2380                 text = '选中' + fileCount + '张图片,共' + WebUploader.formatSize(fileSize) + '。';
2381             } else {
2382                 text = '选中' + fileCount + '个文件,共' + WebUploader.formatSize(fileSize) + '。';
2383             }
2384
2385         } else if (state === 'confirm') {
2386             stats = uploader.getStats();
2387             if (stats.uploadFailNum) {
2388                 if (imgFlag) {
2389                     text = '已成功上传' + stats.successNum + '张照片至XX相册,' +
2390                         stats.uploadFailNum + '张照片上传失败,<a class="retry" href="#">重新上传</a>失败图片或<a class="ignore" href="#">忽略</a>'
2391                 } else {
2392                     text = '已成功上传' + stats.successNum + '个文件至XX文件夹,' +
2393                         stats.uploadFailNum + '个文件上传失败,<a class="retry" href="#">重新上传</a>失败文件或<a class="ignore" href="#">忽略</a>'
2394                 }
2395             }
2396
2397         } else {
2398             stats = uploader.getStats();
2399             if (imgFlag) {
2400                 text = '共' + fileCount + '张(' +
2401                     WebUploader.formatSize(fileSize) +
2402                     '),已上传' + stats.successNum + '张';
2403
2404                 if (stats.uploadFailNum) {
2405                     text += ',失败' + stats.uploadFailNum + '张';
2406                 }
2407             } else {
2408                 text = '共' + fileCount + '个文件(' +
2409                     WebUploader.formatSize(fileSize) +
2410                     '),已上传' + stats.successNum + '个文件';
2411
2412                 if (stats.uploadFailNum) {
2413                     text += ',失败' + stats.uploadFailNum + '个文件';
2414                 }
2415             }
2416
2417         }
2418
2419         $info.html(text);
2420     }
2421
2422     function setState(val) {
2423         var file, stats;
2424
2425         if (val === state) {
2426             return;
2427         }
2428
2429         $upload.removeClass('state-' + state);
2430         $upload.addClass('state-' + val);
2431         state = val;
2432
2433         switch (state) {
2434             case 'pedding':
2435                 $placeHolder.removeClass('element-invisible');
2436                 $queue.hide();
2437                 $statusBar.addClass('element-invisible');
2438                 uploader.refresh();
2439                 break;
2440
2441             case 'ready':
2442                 $placeHolder.addClass('element-invisible');
2443                 $('#filePicker2').removeClass('element-invisible');
2444                 $queue.show();
2445                 $statusBar.removeClass('element-invisible');
2446                 uploader.refresh();
2447                 break;
2448
2449             case 'uploading':
2450                 $('#filePicker2').addClass('element-invisible');
2451                 $progress.show();
2452                 $upload.text('暂停上传');
2453                 break;
2454
2455             case 'paused':
2456                 $progress.show();
2457                 $upload.text('继续上传');
2458                 break;
2459
2460             case 'confirm':
2461                 $progress.hide();
2462                 $('#filePicker2').removeClass('element-invisible');
2463                 $upload.text('开始上传');
2464
2465                 stats = uploader.getStats();
2466                 if (stats.successNum && !stats.uploadFailNum) {
2467                     setState('finish');
2468                     return;
2469                 }
2470                 break;
2471             case 'finish':
2472                 stats = uploader.getStats();
2473                 if (stats.successNum) {
2474                     var strMessage = customBase.getMessage("mesage_ID005");
2475                     customBase.alert("S", strMessage);
2476                     // alert( '上传成功' );
2477                 } else {
2478                     // 没有成功的图片,重设
2479                     state = 'done';
2480                     location.reload();
2481                 }
2482                 break;
2483         }
2484
2485         updateStatus();
2486     }
2487
2488     uploader.onUploadProgress = function (file, percentage) {
2489         var $li = $('#' + file.id),
2490             $percent = $li.find('.progress span');
2491
2492         $percent.css('width', percentage * 100 + '%');
2493         percentages[file.id][1] = percentage;
2494         updateTotalProgress();
2495         customBase.options.uploaderItem[itemId] = uploader.getFiles();
2496     };
2497
2498     uploader.onFileQueued = function (file) {
2499         fileCount++;
2500         fileSize += file.size;
2501
2502         if (fileCount === 1) {
2503             $placeHolder.addClass('element-invisible');
2504             $statusBar.show();
2505         }
2506
2507         addFile(file);
2508         setState('ready');
2509         updateTotalProgress();
2510     };
2511
2512     uploader.onFileDequeued = function (file) {
2513         fileCount--;
2514         fileSize -= file.size;
2515
2516         if (!fileCount) {
2517             setState('pedding');
2518         }
2519
2520         removeFile(file);
2521         updateTotalProgress();
2522
2523     };
2524
2525     uploader.on('all', function (type) {
2526         var stats;
2527         switch (type) {
2528             case 'uploadFinished':
2529                 setState('confirm');
2530                 break;
2531
2532             case 'startUpload':
2533                 setState('uploading');
2534                 break;
2535
2536             case 'stopUpload':
2537                 setState('paused');
2538                 break;
2539
2540         }
2541     });
2542
2543     uploader.onError = function (code) {
2544         customBase.alert("M", 'Eroor: ' + code);
2545     };
2546
2547     $upload.on('click', function () {
2548         if ($(this).hasClass('disabled')) {
2549             return false;
2550         }
2551         if (state === 'ready') {
2552             uploader.upload();
2553             uploader.on('uploadSuccess', function (file, response) {
2554                 customBase.options.uploaderFileName[response.data.oldName] = response.data;
2555             })
2556         } else if (state === 'paused') {
2557             uploader.upload();
2558         } else if (state === 'uploading') {
2559             uploader.stop();
2560         }
2561     });
2562
2563     $info.on('click', '.retry', function () {
2564         uploader.retry();
2565     });
2566
2567     $info.on('click', '.ignore', function () {
2568         customBase.alert("M", 'todo');
2569     });
2570
2571     $upload.addClass('state-' + state);
2572     updateTotalProgress();
2573 }
2574
2575 //得到金融控件的HTMLL
2576 customBase.getAmountHtml = function (sizeWidthHeight, flag) {
2577     var width = sizeWidthHeight.width;
2578     var linewidth = (width - 10) / 11;
2579     var item = sizeWidthHeight.defaultvalue;
2580     var height = sizeWidthHeight.height;
2581     var lineheight = parseInt(height) + 20;
2582     var margin_top = '-20';
2583     var itemTemp = item.split("");
2584     var items = [];
2585     var nbsp = '';
2586
2587     if (flag) {
2588         nbsp = 'nbsp';
2589     } else {
2590         nbsp = '&nbsp;';
2591         margin_top = '10';
2592     }
2593     for (var i = 0; i < 11; i++) {
2594         items[i] = nbsp;
2595     };
2596     for (var i = 0; i < itemTemp.length; i++) {
2597         items[11 - i - 1] = itemTemp[itemTemp.length - i - 1];
2598     };
2599
2600     var oNode = '<div style="width:' + (width) + 'px;">';
2601     oNode += '<hr style="float:left;width: 1px;height:' + lineheight + 'px;margin-top:' + margin_top + 'px;border: #fff;"/>';
2602     if (items[0] == "nbsp") {
2603         // items[0] = " ";
2604         oNode += '<span style="width:' + (linewidth) + ';float:left;line-height:' + height + 'px;color:#fff;">' + '&#160;' + '</span>';
2605     } else {
2606         oNode += '<span style="width:' + (linewidth) + ';float:left;line-height:' + height + 'px;">' + items[0] + '</span>';
2607     }
2608
2609     var hrcolor = "";
2610     for (var i = 0; i < 10; i++) {
2611         if (i == 2 || i == 5) {
2612             hrcolor = '#31b0d5';
2613         } else if (i == 8) {
2614             hrcolor = '#D53137';
2615         } else {
2616             hrcolor = '#eee';
2617         }
2618         oNode += '<hr style="border:0px;background-color:' + hrcolor + ';color:' + hrcolor + ';float: left;width: 1px;height:' + lineheight + 'px;margin-top:' + margin_top + 'px;"/>';
2619         // oNode += '<span style="width:'+linewidth+'px;float:left;line-height:'+height+'px;">'+items[i+1]+'</span>';
2620         ////////////console.log(items[i+1]);
2621         if (items[i + 1] == "nbsp") {
2622             // items[0] = "0";
2623             oNode += '<span style="width:' + linewidth + 'px;float:left;line-height:' + height + 'px;color:#fff;">' + '&#160;' + '</span>';
2624         } else {
2625             oNode += '<span style="width:' + linewidth + 'px;float:left;line-height:' + height + 'px;">' + items[i + 1] + '</span>';
2626         }
2627
2628     };
2629     oNode += "</div>";
2630     return oNode;
2631 }
2632
2633 //条码设定
2634 customBase.createbarcode = function (val, text, callback) {
2635
2636     var sizeWidthHeight = { width: 88, height: 40, styleclass: "" };
2637     var barWidth = 1;
2638     var barHeight = 5;
2639     val = parseInt(val);
2640     val = val;
2641     if (val == 1) {
2642         barWidth = 1;
2643         barHeight = 30;
2644         sizeWidthHeight = { width: 88, height: 40, styleclass: "" };
2645     } else if (val == 2) {
2646         barWidth = 2;
2647         barHeight = 40;
2648         sizeWidthHeight = { width: 176, height: 50, styleclass: "" };
2649     } else if (val == 3) {
2650         barWidth = 3;
2651         barHeight = 50;
2652         sizeWidthHeight = { width: 264, height: 60, styleclass: "" };
2653     } else if (val == 4) {
2654         barWidth = 4;
2655         barHeight = 60;
2656         sizeWidthHeight = { width: 352, height: 70, styleclass: "" };
2657     } else if (val == 5) {
2658         barWidth = 5;
2659         barHeight = 70;
2660         sizeWidthHeight = { width: 440, height: 80, styleclass: "" };
2661     } else if (val == 6) {
2662         barWidth = 6;
2663         barHeight = 80;
2664         sizeWidthHeight = { width: 528, height: 90, styleclass: "" };
2665     }
2666
2667     //条形码数据回调
2668     callback(text, barWidth, barHeight, sizeWidthHeight);
2669 }
2670 customBase.zTreeOnClick = function (event, treeId, treeNode) {
2671     console.log(this);
2672     console.log(event);
2673     console.log(treeId);
2674     console.log(treeNode);
2675
2676     if (treeNode.checked) {
2677         // 单击事件 by kill
2678         if ($('#span_' + treeNode.id).val() == undefined || $('#span_' + treeNode.id).val() == "") {
2679             var i = $('#' + treeId).children(':first').children(':nth-child(2)').attr('class').indexOf('radio');
2680             if (i != -1) {
2681                 ////console.log(i)
2682                 ////console.log('span_'+treeId)
2683                 $('.span_' + treeId).remove();
2684                 $('#' + treeId.replace("tree", ""))
2685                     .parent().parent().children(':first').children(':nth-child(4)').remove();
2686             }
2687             //$('#'+treeId.replace("tree","")).parent().parent().children(':first')
2688             // .append('<span id="span_'+treeNode.id+'">|'+treeNode.name+'&nbsp</sapn>')
2689         }
2690     } else {
2691         $('#span_' + treeNode.id).remove();
2692     }
2693     var dofuncion = customBase.options.zTreeOnClickItems[treeId];
2694     if (dofuncion != undefined) {
2695         eval(dofuncion);
2696     }
2697 };
2698 //  2017/11/2  李元杰 单选树选中事件
2699 customBase.zTreeOncheckRadio = function (e, treeId, treeNode) {
2700     //console.log($('#citySel').parents('div[name=treeWinTitle]').next().attr('id'));
2701
2702     var zTree = $.fn.zTree.getZTreeObj(treeId);
2703     //console.log(zTree)
2704     var nodes = zTree.getCheckedNodes(true);
2705     var v = "";
2706     var dataObj = {}
2707     for (var i = 0, l = nodes.length; i < l; i++) {
2708         v += nodes[i].name + ",";
2709         console.log(nodes)
2710         dataObj[nodes[i].id] = '1'
2711     }
2712     if (v.length > 0) v = v.substring(0, v.length - 1)
2713     // 2017/11/6  李元杰  单选树
2714
2715     // console.log($('#'+treeId).parents('div[name="TreeWin"]').find('.citySel'))
2716     // console.log(   )
2717
2718     $(e.currentTarget).parent().attr('value', JSON.stringify(dataObj))
2719     $(e.currentTarget).parents('div[name="TreeWin"]').find('.citySel').val(v);
2720     // // cityObj.attr("value", v);
2721     // console.log(e);
2722     // console.log(treeId);
2723     // console.log(treeNode);
2724     // // $('#'+treeId).parents('div[type="tree"]').find('h8').children(':nth-child(4)').remove();
2725     // console.log(  $('#'+treeId).parents('div[type="tree"]').find('h8'));
2726     // console.log( $('#'+treeId).parents('div[type="tree"]').find('h8').children(':nth-child(3)'))
2727
2728     // if(treeNode.checked){
2729     //     // 单击事件 by kill
2730     //     if($('#span_'+treeNode.id).val()==undefined||$('#span_'+treeNode.id).val()==""){
2731     //         //console.log($('#'+treeId))
2732     //       var i=$('#'+treeId).children(':first').children(':nth-child(2)').attr('class').indexOf('radio');
2733     //       if(i!=-1){
2734     //           //console.log(i)
2735     //           //console.log('span_'+treeId)
2736     //           $('.span_'+treeId).remove();
2737     //             $('#'+treeId.replace("tree",""))
2738     //             .parent().parent().children(':first').children(':nth-child(4)').remove();
2739     //       }
2740     //     }
2741     // }else{
2742     //           $('#span_'+treeNode.id).remove();
2743     // }
2744     var pitchon = `
2745             <span id="spanDiv'+${treeId}+'">
2746                  <span>|${v}</span>
2747             </span>
2748         `
2749     // $('#'+treeId).parents('div[type="tree"]').find('h8').children(':nth-child(4)').remove();
2750     // $('#'+treeId).parents('div[type="tree"]').find('h8').append(pitchon);
2751     var dofuncion = customBase.options.zTreeOnClickItems[treeId];
2752     if (dofuncion != undefined) {
2753         eval(dofuncion);
2754     }
2755 }
2756 customBase.settingChkboxType = {
2757     check: {
2758         autoCheckTrigger: false,
2759         chkboxType: { "Y": "", "N": "" },
2760         chkStyle: "checkbox",
2761         enable: true,
2762         nocheckInherit: false,
2763         radioType: "level"
2764     },
2765     view: {
2766         showIcon: false,
2767         showLine: false,
2768         txtSelectedEnable: true,
2769     },
2770     data: {
2771         simpleData: {
2772             enable: true,
2773             idKey: "id",
2774             pIdKey: "pId",
2775             rootPId: 0
2776         }
2777     },
2778     callback: {
2779         onClick: customBase.zTreeOnClick,
2780         onCheck: customBase.zTreeOncheckRadio,
2781     }
2782 }
2783
2784 customBase.settingRadioType = {
2785     check: {
2786         enable: true,
2787         chkStyle: "radio",
2788         radioType: "all",
2789     },
2790     view: {
2791         showIcon: false,
2792         showLine: false,
2793         txtSelectedEnable: true,
2794     },
2795     data: {
2796         simpleData: {
2797             enable: true,
2798             idKey: "id",
2799             pIdKey: "pId",
2800             rootPId: 0
2801         }
2802     },
2803     callback: {
2804         onClick: customBase.zTreeOnClick,
2805         onCheck: customBase.zTreeOncheckRadio,
2806     }
2807 }
2808
2809
2810
2811 customBase.zNodes = [{ name: "树控件", isParent: true }];
2812 var customShow = customShow || {};
2813
2814 customShow.button = {
2815     //基础字段
2816     printableBtn: { name: "打印", cssName: 'icon iconfont icon-dayin1 ', functionName: "customShow.onPrint" },
2817     exportBtn: { name: "导出", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "" },
2818     rejectBtn: { name: "驳回", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "customShow.rejectBtn" },
2819     submitBtn: { name: "提交", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "customShow.onclickSubmit" },
2820     auditableBtn: { name: "审批", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "customShow.auditableBtn" },
2821     queryBtn: { name: "查询", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "" },
2822     createBtn: { name: "新建", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "customShow.onclickSave1" },
2823     clearBtn: { name: "清空", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "customShow.onclickClear" },
2824     disposableBtn: { name: "取消", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: 'customShow.onclickCancel' },
75eb92 2825     //fromSaveBtn: { name: "保存", cssName: 'icon iconfont icon-bianji ', functionName: "customShow.onclickSave2" },
4d1219 2826     editableBtn: { name: "编辑", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "customShow.onEditor" },
B 2827     //添加权限按钮  马习同  2017-12-14
2828     billuploadingBtn: { name: "票据上传", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "customShow.billuploading" },
2829     reuploadBtn: { name: "重新上传票据", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "customShow.reupload" },
2830     checkbillBtn: { name: "查看票据", cssName: 'icon iconfont icon-kongjian_danhangwenben', functionName: "customShow.checkbill" },
2831 }
2832 console.log(Flatpickr)
2833 Flatpickr.localize(Flatpickr.l10ns.zh); // 设置为中文
2834 customShow.options = {
2835     customItem: {},
2836     customViewDiv: "",
2837     customInit: {},
2838     htmlediterShow: {},
2839     attributeList: {}, //属性一览
2840     // editorFlag:true,
2841     formID: "",        //表单ID
2842     customShowFlag: "",//调用标识
2843     dataRowNum: "",    //更新行番号
2844     breakFlag: false,  //父画面刷新
2845     datasource: {},
2846     customItemShow: {},
2847     initTempDatas: {},  //临时初始化数据
2848     itemFormbase: "",
2849     jsonLinkage: {}, //公式用
2850     btnFlag: { editable: "1", printable: "1", auditable: "0", disposable: "0" }, //按钮表示
2851     subformList: {}, //子表单List
2852     subformDList: {},
2853     dropdownlist_I: 0,
2854     subformDValue: {},
2855     formsetting: {},
2856     showErrId: {},
2857     // LinkageAnalysisSetValueFlag:false
2858 }
2859
2860 customShow.initEvent = {
2861     //--------------------保存Button事件------------------------
2862     //画面check
2863     fromCheck: function (items, callback) {
2864         return customShow.onfromCheck(items);
2865         ////console.log(1)
2866     },
2867     //03检证执行
2868     validationRuleCheck: function (items, callback) { return true },
2869     //检证接口函数(第三口)
2870     validationRuleCheck3rd: function (items, callback) { return customShow.interfaceCheck(items) },//保存前计算费用  李伟民   10 - 31
2871     //发送数据到后台服务器,保存data
2872     fromSave: function (items, callback) {
2873
2874     },
2875     //发送数据到后台服务器,保存data
2876     fromSave3rd: function (items, callback) { return true },
2877     fromSaveLinkage: function (items, callback) { return true },
2878     //--------------------保存Button事件------------------------
2879     //--------------------初期化事件----------------------------
2880     //01接口绑定:接口名 接口变量名 自定义函数
2881     interfaceBind: [],
2882     //02事件绑定:字段别名 字段类型 事件名 自定义事件名
2883     // eventBind:[{fieldKey:"项目1",tag:"text",eventName:"click",functionName:"customShow.clickBindBase001"}],
2884     eventBind: [],
2885     //初期化接口
2886     interfaceInit: function (customShowFlag) {
2887         //表示模式
2888         console.log(customShowFlag)
2889         if (customShowFlag == 2) {
2890             customShow.controlInit("customViewUEditorCss");
2891             //控件初始化
2892             customShow.controlInit("customShow");
2893         } else {
2894             //控件初始化
2895             customShow.controlInit("customViewUEditorCss");
2896         }
2897         //事件初始化
2898         customShow.clickBind();
2899         //  12/14
2900         if (customShowFlag == 1) {
2901             // customShow.businessTypeAutoFun( 'businessTypeAuto','budget_itemCostType','cookie');
2902             SC.autoFieldKey();
2903         }
2904     },
2905     interfaceInit3rd: function (customShowFlag) { return true },
2906     //验证初期公式
2907     interfaceInitLinkage: function (customShowFlag) { return true },
2908     //密码输入
2909     passwordInputFlag: function (items, callback) { },
2910     //--------------------初期化事件----------------------------
2911     //--------------------取消事件----------------------------
2912     //取消接口
2913     cancelEvent: function (items, callback) { },
2914     //取消接口(第三方提供)
2915     cancelEvent3rd: function (items, callback) { return true },
2916     //取消接口
2917     cancelEventLinkage: function () { return true },
2918     //--------------------取消事件----------------------------
2919     //--------------------印刷事件----------------------------
2920     interfaceprint: function (items, callback) { },
2921     interfaceprint3rd: function (items, callback) { return true },
2922     //--------------------印刷事件----------------------------
2923 }
2924
2925 function getProcessLog() {//获得流程信息 李雁鸣  12-25
2926     localStorage.setItem("processLog", null);
2927     if (localStorage.getItem("customItem") != undefined && localStorage.getItem("customItem") != "undefined" && localStorage.getItem("customItem") != null && localStorage.getItem("customItem") != "" && localStorage.getItem("customItem") != null) {
2928         var ss = { "formID": JSON.parse(localStorage.getItem("customForm")).newFormID, "dataRowNum": JSON.parse(localStorage.getItem("customItem")).DATAROWNUM };
2929         var requestSingleForm = window.commonAjax("/ubp-api-seache/process/inst/log", ss, "POST", true, false);
2930         requestSingleForm.done(function (rs) {
2931             console.log(rs.data);
2932             console.log("新改的");
2933             if (rs.data != undefined) {
2934                 localStorage.setItem("processLog", JSON.stringify(rs.data.data));
2935             } else {
2936
2937             }
2938         });
2939     }
2940 };//获得流程信息 李雁鸣  12-25
2941
2942 customShow.Init = function () {
2943     getProcessLog() //获得流程信息 李雁鸣  12-25
2944     customShow.exCouldNumber = undefined;//初始化 云单编号 李伟民  12-22
2945     customShow.orderStatus = undefined;//初始化 表单状态 李伟民 12-26
2946     //数据源
2947
2948     //数据源信息取得
2949     var datasource = $.parseJSON(window.localStorage.getItem("datasource"));
2950     customShow.options.datasource = {};
2951     if (datasource != null) {
2952
2953         for (var i = 0; i < datasource.length; i++) {
2954             customShow.options.datasource[datasource[i].dataSourceName] = datasource[i];
2955         };
2956     }
2957
2958     // 0:预览 1:数据管理中新建 2:数据管理中展示(数据表示) 3:发布 4:模板中心
2959     var customShowFlag = window.localStorage.getItem("customShowFlag");
2960     customShow.options.customShowFlag = customShowFlag;
2961     //  12/13 测试模拟用
2962
2963     if (customShowFlag == "0" || customShowFlag == "1") {// 新建 预览  隐藏 详情页 李伟民  11-17
2964         console.log(customShowFlag);
2965         //   12/4 李元杰 日历当前时间
2966         // var dataObj = {
2967         //     "time":"yyyy-MM-dd HH:mm:ss"
2968         // }
2969         // var requestRight = window.commonAjax('/epc/getTime', dataObj, 'POST', true);
2970         // requestRight.done(function (res) {
2971         //     // if (res.rspCode == "000000") {
2972         //     console.log(res)
2973         //     // }
2974         // })
2975         var myDate = new Date();
2976         myDate.getFullYear();    //获取完整的年份(4位,1970-????)
2977         myDate.getMonth();       //获取当前月份(0-11,0代表1月)
2978         myDate.getDate();
2979         customShow.currentDate = myDate.getFullYear() + '-' + (myDate.getMonth() + 1) + '-' + myDate.getDate();
2980         console.log(new Date())
2981         console.log(customShow.currentDate)
2982         $("#customShow").removeClass("fui-form");
2983         console.log(customBase.options.customItemShow)
2984         // $(".preview-edit-pane").css("display", "none");
2985         // 12/23
2986
2987
2988
2989
2990     }// 新建 预览  隐藏 详情页 李伟民  11-17
2991     if (customShowFlag == "2") {
2992         console.log(customShowFlag);
2993         //12/23
2994         $(".preview-edit-pane").css("display", "block");
2995         // $("#editableBtn").on("click",() => {
2996         //     console.log($(".preview-edit-pane"));
2997
2998         // })
2999     }
3000     if(customShowFlag == '3'){
3001         $(".preview-edit-pane").css("display", "block");
3002     }
3003     if (customShowFlag == "0") {
3004         //表单ID
3005         var customlocalStorage = window.localStorage.getItem("customForm");
3006         customlocalStorage = $.parseJSON(customlocalStorage);
3007         customShow.options.formid = customlocalStorage.newFormID;
3008         var customViewItem = window.localStorage.getItem("customViewItem");
3009
3010         customShow.InitShow({
3011             //绑定DIV
3012             showDiv: "customViewUEditor",
3013             //数据来源
3014             customShowFlag: customShowFlag,
3015             //表示模式
3016             designMode: customlocalStorage.mode,
3017             //画面表示基础数据
3018             customViewItem: $.parseJSON(customViewItem),
3019             //画面表示数据
3020             formbase: "",
3021         });
3022         $(".s_savebtn").hide();
3023         // $(".customShow .fa-calendar").addClass();
3024     } else {
3025         customShow.options.formid = window.localStorage.getItem("newFormID");
3026         //初期数据取得
3027         customDataBound.getFormbase(customShow.options.formid, function (rs) {
3028             if (rs.rspCode == "000000" && rs.data != null) {
3029                 //控件属性JSON对象
3030                 var field = JSON.parse(rs.data.fieldset);
3031                 //转换成数组
3032                 var fields = _.keysIn(field);
3033                 console.log(rs.data.fieldset)
3034
3035                 //循环读取tag_Type是否含有‘auto’
3036                 for (var i = 0; i < fields.length; i++) {
3037                     var attrib = field[fields[i]];
3038                     if (attrib.tag_Type != null && attrib.tag_Type == 'auto') {
3039                         //如果有那么就发送请求
3040                         var dataObj = {};
3041                         dataObj.prefix = attrib.tag_Attribute.prefixs["0"].itemtext_1 + '$in{' + attrib.tag_Attribute.prefixs["0"].itemtext_2 + '}';
3042                         dataObj.FormID = formid;
3043                         var requestRight = window.commonAjax('/datamanagement/getGenerateRandomNumService', dataObj, 'POST', true);
3044                         requestRight.done(function (res) {
3045                             if (res.rspCode == "000000") {
3046                                 var alisN = _.keysIn(customBase.options.customItems);
3047                                 for (var i = 0; i < alisN.length; i++) {
3048                                     var item = customBase.options.customItems[alisN[i]];
3049                                     if (item.type == "auto") {
3050                                         var itemID = item.id;
3051                                         customBase.setItemValue(itemID, 'text', res.data, '', '');
3052                                     }
3053                                 }
3054                             }
3055                         })
3056
3057                     }
3058                 }
3059
3060                 var formbase = window.localStorage.getItem("customItem");
3061                 //console.log(formbase)
3062                 //////////////console.log(formbase);
3063                 // //console.log(formbase);
3064                 var customItem = {
3065                     formeditor: rs.data.resultForm,
3066                     item: $.parseJSON(rs.data.fieldset),
3067                     //表单宽度
3068                     fromwidth: rs.data.formWidth,
3069                     //表单高度
3070                     fromheigh: rs.data.formHeight,
3071                     //表单名
3072                     formName: rs.data.formName,
3073                     customFlag: rs.data.designMode,
3074                     Linkage: rs.data.linkage
3075                 }
3076                 //console.log(customItem);
3077                 //console.log(formbase)
3078                 customShow.InitShow({
3079                     //绑定DIV
3080                     showDiv: "customViewUEditor",
3081                     //数据来源
3082                     customShowFlag: customShowFlag,
3083                     //表示模式
3084                     designMode: rs.data.designMode,
3085                     //画面表示基础数据
3086                     customViewItem: customItem,
3087                     //画面表示数据
3088                     formbase: formbase,
3089                 });
3090             } else {
3091
3092             }
3093         });
3094     }
7480eb 3095     //隐藏保存
M 3096     if (publishShowflag==1){
3097         $(".preview-edit-pane").hide();
3098     }
4d1219 3099 }
B 3100 // 12/4 李元杰 当前时间
3101 customShow.currentDate = '';
3102 function changeOrderStatus(orderStatus){//修改表单状态  李伟民  01-04
3103     if(orderStatus == undefined){
3104         return false;
3105     }
3106     switch(orderStatus){
3107         case '10':
3108             $('#stateText').html('自动审单中');
3109             break
3110         case '15':
3111             $('#stateText').html('自动审单成功');
3112             break
3113         case '19':
3114             $('#stateText').html('自动审单失败');
3115             break
3116         case '20':
3117             $('#stateText').html('未上传单据');
3118             break
3119         case '40':
3120             $('#stateText').html('记账处理中');
3121             break
3122         case '45':
3123             $('#stateText').html('记账处理完成');
3124             break
3125         case '49':
3126             $('#stateText').html('记账处理失败');
3127             break
3128         case undefined:
3129             $('#stateText').html('test');
3130             break
3131
3132     }
3133 }
3134 //画面初期化
3135 customShow.InitShow = function (customInit) {
3136     customBase.customInit = customInit;
3137     //画面初期迁移源属性取得
3138     // 0:预览 1:数据管理中新建 2:数据管理中展示 3:发布 4:模板中心
3139     //console.log(customInit)
3140     if (customInit.customViewItem != null && customInit.customViewItem != undefined) {
3141         customShow.costType = customInit.customViewItem.item;
3142     }
3143     var customShowFlag = customInit.customShowFlag;
3144     var customViewDiv = "#" + customInit.showDiv;
3145     customShow.options.customInit = customInit;
3146     customShow.options.customViewDiv = customInit.showDiv;
3147     //画面初期化(画面表示基础数据)
3148     customShow.options.customItemShow = customInit.customViewItem;
3149     customShow.options.jsonLinkage = customShow.options.customItemShow.Linkage;
3150     var customItem = customShow.options.customItemShow;
3151     setTimeout(function () {
3152         if (customShowFlag == "4") {
3153             $(".customViewUEditorCss").css("height", window.innerHeight);
3154             $(".customShow").css("height", window.innerHeight - 200);
3155         } else {
3156             $(".customViewUEditorCss").css("height", window.innerHeight - 200);
3157             $(".customShow").css("height", window.innerHeight - 200);
3158         }
3159     }, 10);
3160     var btns = [];
3161     //展示数据表示
3162
3163     if (customShowFlag == "0" || customShowFlag == "6") {
3164         //2017-12-27 马习同   专家模式打印
3165         var print_btnFlag = window.localStorage.getItem("print_btnFlag");
3166         if (customShowFlag == "0" && print_btnFlag == "1"){
3167             var btns = [
3168                 "printableBtn"
3169             ];
3170             customShow.setToolBtn(btns);
3171         }
3172         ////console.log(window.customBase);
3173         //标题头表示
3174         $('#childclick').css("display", "none");
3175         $(".header")[0].style.display = "block";
3176         //标题设定
3177         $(".modal-title")[0].innerHTML = customItem.formName;
3178
3179         //画面内容的初始化设定
3180         customShow.setContentHtml(customItem, customViewDiv);
3181         //编辑模式下表示
3182         $(customViewDiv)[0].style.display = "block";
3183
3184         //1:数据管理中新建  3:发布 4:模板中心
3185     } else if (customShowFlag == "1" || customShowFlag == "3") {
3186         //标题头表示
3187         console.log("显示X");
3188         console.log($('#childclick'));
3189         $('#childclick').css("display", "block");
3190         $('#childclick').click(() => {
3191             customShow.onclickCancel();
3192             console.log("点击父元素关闭");
3193         });
3194
3195         $(".header")[0].style.display = "block";
8c6e10 3196         $("title")[0].innerHTML = customItem.formName;
4d1219 3197         //标题设定
8c6e10 3198         $(".modal-title")[0].innerHTML = customItem.formName;$(".modal-title")[0].innerHTML = customItem.formName;
4d1219 3199         //画面内容的初始化设定
B 3200         customShow.setContentHtml(customItem, customViewDiv);
3201
3202         // $(".footer")[0].style.display ="block";
3203         //编辑模式下表示
3204         $(customViewDiv)[0].style.display = "block";
3205         //2:数据管理中展示
3206         //第三方事件绑定
3207         // customShow.setEventBind();
3208         if (customShowFlag == "1") {
3209             var btns = [
3210                 'rejectBtn',
3211                 'submitBtn',
3212                 'auditableBtn',
3213                 'queryBtn',
3214                 'clearBtn',
3215                 // 'disposableBtn',
3216                 //  'fromSaveBtn',
3217             ];
3218         } else {
3219             var btns = [
3220                 'rejectBtn',
3221                 'submitBtn',
3222                 'auditableBtn',
3223                 'queryBtn',
3224                 'createBtn',
3225                 // 'clearBtn',
3226                 // 'disposableBtn',
75eb92 3227                 //'fromSaveBtn',
4d1219 3228             ];
B 3229         }
3230     }
3231     else if (customShowFlag == "4") {
3232         //标题头表示
3233         $(".header")[0].style.display = "none";
3234         //标题设定
3235         // $(".modal-title")[0].innerHTML=customItem.formName;
3236         //画面内容的初始化设定
3237         customShow.setContentHtml(customItem, customViewDiv);
3238         //编辑模式下表示
3239         $(customViewDiv)[0].style.display = "block";
3240         // $(".footer")[0].style.display ="none";
3241         //编辑模式下表示
3242         // $(customViewDiv)[0].style.display ="block";
3243         //第三方事件绑定
3244         // customShow.setEventBind();
3245     } else if (customShowFlag == "2") {
3246         console.log("显示X");
3247         console.log($('#childclick'));
3248         $('#childclick').css("display", "block");
3249         if (JSON.parse(window.localStorage.getItem('allow')) == true) {
3250             $('#childclick').css("display", "none");
3251         } else {
3252             $('#childclick').css("display", "block");
3253         }
3254         $('#childclick').click(() => {
3255             customShow.onclickCancel();
3256             console.log("点击父元素关闭");
3257
3258         });
3259         //按钮修改 马习同 2017-12-13
3260         // var btnshowFlag = {
3261         //     a = true,
3262         //     b = flase,
3263         // };
3264         // if(btnshowFlag.a == true){
3265         //     btns.push();
3266         // }
3267         var btns = [
3268             // 'checkbillBtn',//查看票据
3269             'rejectBtn',//驳回
3270             'submitBtn',//提交
3271             'auditableBtn',//审批
3272             'editableBtn',
3273             'printableBtn',//打印
3274         ];
3275         //画面内容的初始化设定
3276         console.log(customItem);
3277         console.log(customViewDiv);
3278         customShow.setContentHtml(customItem, customViewDiv);
3279         var items = {};
3280         //数据变换
3281         //console.log(customInit);
3282         //console.log(customInit.formbase)
3283         var formbase = $.parseJSON(customInit.formbase);
3284         //console.log(formbase);
3285         customShow.options.dataRowNum = formbase['DATAROWNUM'];
3286         customShow.exCouldNumber = formbase['orderCode'];//获取云单编号 李伟民 12-26
3287         if(customShow.exCouldNumber){
3288             $('#exCloudNumberText').html('云单编号:' + customShow.exCouldNumber);
3289         }
3290         customShow.orderStatus = formbase['orderStatus'];// 获取表单状态 李伟民  12-26
3291         changeOrderStatus(customShow.orderStatus);
3292         items = formbase;
3293         customShow.options.itemFormbase = formbase;
3294         console.log(_.cloneDeep(items));
3295         delete items['DATAROWNUM'];
3296         console.log(_.cloneDeep(items));
3297         //初期化后,数据赋值(编辑模式)
3298         console.log(_.cloneDeep(items));
3299         customShow.showCustom(items, customShow.options.customInit);
3300         //初期化后,数据赋值(预览)
3301         console.log(_.cloneDeep(items));
3302         customShow.setShowCustomItem(items);
3303         //初期化后,票据信息追加  李伟民  12-26
3304         SC.billInfoInit(items);
3305
3306
3307         //数据源再次追加
3308         // var customItems = customShow.options.customItemShow.item;
3309         var customItems = customBase.options.customItems;
3310         console.log(customItems);
3311         for (item in customItems) {
3312             if (customItems.hasOwnProperty(item)) {
3313                 if (customItems[item].type == 'dropdownlist' || customItems[item].type == 'radio' ||
3314                     customItems[item].type == 'checkbox' || customItems[item].type == 'tree') {
3315                     var datasourcetype = customShow.options.customItemShow.item[customItems[item].id].tag_Attribute.datasourcetype;
3316                     console.log(datasourcetype);
3317                     if (datasourcetype == "custom") {
3318                         //数据源绑定(自定义数据)
3319                         customShow.setDatasourceData(customItems[item]);
3320                     }
3321                 }
3322             }
3323         }
3324         //标题头表示
3325         $(".header")[0].style.display = "block";
3326         //标题设定
3327         $(".modal-title")[0].innerHTML = customItem.formName;
3328         //  12/19
3329         $("#customViewUEditor")[0].style.display = "none";
3330         //2017/11/18  马习同修改 隐藏预览模式下  导入数据按钮
3331         $(".sonImportFile").addClass("cfg_contentNone");
3332         $(".s_savebtn").hide();
3333         $(".customShow .fa-calendar").addClass("cfg_contentNone");
3334
3335         console.log($(".customShow .tdContentClass"))
3336         // _.each($(".customShow .tdContentClass"),opt=>{
3337         //     // $(opt).attr("title", $(opt).children().children().html());
3338         //     console.log($(opt).html())
3339         //     if ($(opt).children().children().attr("type") == "text"){
3340         //         $(opt).attr("title", $(opt).children().children().val());
3341         //     }else{
3342         //         console.log(_.cloneDeep($(opt).children().children()))
3343         //         console.log(opt.innerHTML)
3344         //         console.log($(opt).children().children()[0].innerHTML)
3345         //         $(opt).attr("title", $(opt).children().children()[0].innerHTML);
3346         //     }
3347         // })
3348
3349     }
3350     //第三方事件绑定
3351     var token = localStorage.getItem('token');//页面事件绑定 李伟民 12-22
3352     if (token != '' && token != undefined) {
3353         token = JSON.parse(token);
3354     }
3355     var postdata = { 'formID': customShow.options.formid };
3356     _.extend(postdata, token);
3357     var eventBindRquest = window.commonAjax('/formevent/getFormEventListService', postdata, 'GET', true, false);
3358     eventBindRquest.done(function (res) {
3359         if (res.data != undefined) {
3360             // var eventBindData = [];
3361             // _.each(res.data,function(data){
3362             //     eventBindData.push({'fieldName':data.fieldName,'tag':data.fieldType,'eventName':data.event,'functionName':data.eventmethod});
3363             // });
3364             customShow.initEvent.eventBind = res.data;
3365         }
3366         customShow.setEventBind();
3367     });//页面事件绑定 李伟民 12-22
3368
3369     SC.showUser()//报销人根据当前登录人自动带出  李伟民  0108
3370
3371     customShow.setToolBtn(btns);
3372     $(".select2-selection").remove();
3373     customShow.hidesubform();
3374     var unvisible = customBase.options.customItems;
3375     for (item in unvisible) {
3376         if (unvisible[item].type == "subform") {
3377             var itemId = unvisible[item].id;
3378             //          var itemTwo = itemId;
3379             //          var itemSubform = $('.'+"customViewUEditorCss" +" #"+itemId+"ActiveId");
3380             ////////////console.log(item);
3381             //子表单删除第一条可添加  2017/10/26 马习同
3382             //          var divIcon = $('<div id="'+itemId+'save" class="cfg_contentNone"></div>');
3383             var cloneE = $('#' + itemId + 'subformTr').clone();
3384             //          divIcon.append(cloneE);
3385             console.log(cloneE);
3386             //          itemSubform.append(divIcon);
3387             customBase.options.customItems[item]['cloneDiv'] = cloneE;
3388         }
3389     }
3390     //2017-12-12  马习同隐藏
3391     SC.Superior_hide();
3392     if (customShowFlag == "1" || customShowFlag == "0") {
3393         // window.localStorage.setItem('businessTypeAuto','240');
3394         $(".preview-edit-pane").find('#disposableBtn').css('display', 'none');
3395         $(".preview-edit-pane").find('#clearBtn').css('display', 'none');
3396         $(".preview-edit-pane").find('#queryBtn').css('display', 'none');
3397         $(".preview-edit-pane").find('#auditableBtn').css('display', 'none');
3398         $(".preview-edit-pane").find('#submitBtn').css('display', 'none');
3399         $(".preview-edit-pane").find('#rejectBtn').css('display', 'none');
3400     }
3401 }
3402 //   2017/10/20   李元杰  抽出了 李伟民的计算费用的方法 最后将数据return出去了
3403 //计算费用
3404 //customShow.queryCostAllData = function(){
3405 //    var post_data = [];
3406 //    var items = customShow.getItems();
3407 //    var items_key = _.keysIn(items);
3408 //    var all_data = {};
3409 //    //console.log(items);
3410 //    _.each(items_key,function(item){
3411 //        var control = {};
3412 //        var item_attr = customBase.options.customItems[item];
3413 //        if(_.isArray(items[item]) && _.isObject(items[item][0])){//判断是否为子表单
3414 //            _.extend(control,{'fieldKey':item,'mdCode':'','value':'','type':item_attr.type,'child':[]});
3415 //            _.each(items[item],function(cd){
3416 //                var cd_key = _.keysIn(cd);
3417 //                var item_cd = {
3418 //                    "items":[],
3419 //                    "cid":""
3420 //                };
3421 //                _.each(cd_key,function(cdk){
3422 //                    var control_cd = {};
3423 //                    var item_attr_cd = customBase.options.customItems[cdk];
3424 //                    _.extend(control_cd,{'fieldKey':cdk,'mdCode':customShow.getmasterdataById(item_attr_cd.id),'value':cd[cdk],'type':item_attr_cd.type});
3425 //                    item_cd.items.push(control_cd);
3426 //                    if(cdk == "dataRowNum"){
3427 //                        item_cd.cid = cd[cdk];
3428 //                    }
3429 //                });
3430 //                control.child.push(item_cd);
3431 //            });
3432 //            //行程ID 预留
3433 //        }else{
3434 //            _.extend(control,{'fieldKey':item,'mdCode':customShow.getmasterdataById(item_attr.id),'value':items[item],'type':item_attr.type});
3435 //        }
3436 //        post_data.push(control);
3437 //    });
3438 //    var customShowFlag = window.localStorage.getItem("customShowFlag");
3439 //    var customForm = window.localStorage.getItem("customForm");
3440 //    if(customForm && customForm != ""){
3441 //        customForm = JSON.parse(customForm);
3442 //    }
3443 //    if(customShowFlag == 2){//详情
3444 //        var customItem = window.localStorage.getItem("customItem");
3445 //        if(customItem && customItem != ""){
3446 //            customItem = JSON.parse(customItem);
3447 //            //console.log(customItem);
3448 //        }
3449 //        _.extend(all_data,{"data":post_data,"formId":customForm.newFormID,"id":customItem.DATAROWNUM});
3450 //    }else{//新建或预览
3451 //        _.extend(all_data,{'data':post_data,"formId":customForm.newFormID,"id":""});
3452 //    }
3453 //    _.extend(all_data,{'orderCode':""});
3454 //    _.extend(all_data,{'ctId':"240"});// 费用类型 假
3455 //  return all_data;
3456 //}
3457 //计算费用
3458 //customShow.queryCost = function(){
3459 //  // 2017/10/20 李元杰 queryCostAllData 抽出来存这里了
3460 //  //   var post_data = [];
3461 //  //   var items = customShow.getItems();
3462 //  //   var items_key = _.keysIn(items);
3463 //  //   var all_data = {};
3464 //  //   //console.log(items);
3465 //  //   //console.log(items_key)
3466 //  //   _.each(items_key,function(item){
3467 //  //       var control = {};
3468 //  //       //console.log(item);
3469 //  //       var item_attr = customBase.options.customItems[item];
3470 //  //       //console.log(item_attr)
3471 //  //       if(_.isArray(items[item]) && _.isObject(items[item][0])){//判断是否为子表单
3472 //  //           _.extend(control,{'fieldKey':item,'mdCode':'','value':'','type':item_attr.type,'child':[]});
3473 //  //           _.each(items[item],function(cd){
3474 //  //               //console.log(cd)
3475 //  //               var cd_key = _.keysIn(cd);
3476 //  //               //console.log(cd_key)
3477 //  //               var item_cd = {
3478 //  //                   "items":[],
3479 //  //                   "cid":""
3480 //  //               };
3481 //  //               _.each(cd_key,function(cdk){
3482 //  //                   var control_cd = {};
3483 //  //                   var item_attr_cd = customBase.options.customItems[cdk];
3484 //  //                   //console.log(item_attr_cd);
3485 //  //                   _.extend(control_cd,{'fieldKey':cdk,'mdCode':customShow.getmasterdataById(item_attr_cd.id),'value':cd[cdk],'type':item_attr_cd.type});
3486 //  //                   item_cd.items.push(control_cd);
3487 //    //                 if(cdk == "dataRowNum"){
3488 //    //                     item_cd.cid = cd[cdk];
3489 //    //                 }
3490 //  //               });
3491 //  //               control.child.push(item_cd);
3492 //  //           });
3493 //  //           //行程ID 预留
3494 //  //       }else{
3495 //  //           _.extend(control,{'fieldKey':item,'mdCode':customShow.getmasterdataById(item_attr.id),'value':items[item],'type':item_attr.type});
3496 //  //       }
3497 //  //       post_data.push(control);
3498 //  //   });
3499 //  //   var customShowFlag = window.localStorage.getItem("customShowFlag");
3500 //  //   var customForm = window.localStorage.getItem("customForm");
3501 //  //   if(customForm && customForm != ""){
3502 //  //       customForm = JSON.parse(customForm);
3503 //  //   }
3504 //  //   if(customShowFlag == 2){//详情
3505 //  //       var customItem = window.localStorage.getItem("customItem");
3506 //  //       if(customItem && customItem != ""){
3507 //  //           customItem = JSON.parse(customItem);
3508 //    //         //console.log(customItem);
3509 //  //       }
3510 //  //       _.extend(all_data,{"data":post_data,"formId":customForm.newFormID,"id":customItem.DATAROWNUM});
3511 //  //   }else{//新建或预览
3512 //  //       _.extend(all_data,{'data':post_data,"formId":customForm.newFormID,"id":""});
3513 //  //   }
3514 //  //   _.extend(all_data,{'orderCode':""});
3515 //  //   _.extend(all_data,{'ctId':"240"});// 费用类型 假
3516 //  //   //console.log(all_data);
3517 //  //   //console.log(JSON.stringify(all_data))
3518 //    var all_data = customShow.queryCostAllData();
3519 //    // 2017/10/20 李元杰 queryCostAllData 抽出来存这里了  end
3520 //    var query_request =  window.queryAjax("epc-count/countCost",all_data,"POST",true,false);
3521 //    ////console.log(query_request);
3522 //    query_request.done(function(res){
3523 //        ////console.log("6531289");
3524 //        customBase.listen_check(res.data,"query_check");
3525 //    })
3526 //
3527 //    return all_data;
3528 //}
3529 // 12/12  模态框
3530 $('.closeBtn').on('click', () => {
3531     $('.maskLayer').css('display', 'none');
3532     customShow.clean();
3533 })
3534 //扩展费用自定义方法,yuezhw 2017-11-13
3535 customShow.extended_budget = function (where) {
3536     var obj = {};
3537     obj.formId = localStorage.getItem("newFormID");
3538     obj.dataId = JSON.parse(localStorage.getItem("customItem")).DATAROWNUM;
3539     obj.tenantID = JSON.parse(localStorage.getItem("tenantID")).tenantID;
3540     var query_request;
3541     flatpickr("#budget_time", {
3542         dateFormat: "Y-m-d"
3543     })
3544
3545     var budgetNumber = $('#customShow').find('div[type="auto"]').find('input').val();
3546     var budgetDate = $($('#customShow').find('div[type="calendar"]')[1]).find('input').val();
3547     $('#budget_number').val(budgetNumber)
3548     $('#budget_date').val(budgetDate)
3549     $('#extended_someThing').css("display", "block");
3550     $('#budget_time').css("display", "block");
3551     $('.maskLayer').css('display', 'block');
3552     $('#budget_todo').on('click', () => {
3553         obj.department = $('#budget_department').val();
3554         obj.info = $('#budget_time').val();
3555         var nowTime = new Date(Date.parse(obj.info));
3556         var endTime = new Date(Date.parse(JSON.parse(localStorage.getItem("customItem")).budgetEndDate));
3557         console.log(obj.info);
3558         console.log(nowTime);
3559         console.log(endTime);
3560         if (obj.info.length < 1) {
3561             alert("请输入增加时间");
3562         } else if (nowTime < endTime) {
3563             alert("扩展时间不可小于当前结束时间!");
3564         } else {
3565             var query_request = window.queryAjaxQQ("epc-form/extend/budget/time", obj, "POST", true, false);
3566             query_request.done(function (res) {
3567                 console.log(typeof res.data)
3568                 console.log(res.data)
3569                 if (res.data === true) {
3570                     alert("扩展时间成功!");
3571                     customShow.clean();
3572                     $('.maskLayer').css('display', 'none');
3573                 } else {
3574                     alert("服务器通信失败");
3575                 }
3576             })
3577             query_request.error(function (rs) {
3578                 // console.log(rs)
3579                 toastr.error(rs.responseJSON.rspDesc);
3580
3581             })
3582         }
3583
3584     })
3585     $('#budget_undo,.closeModal').on('click', () => {
3586         customShow.clean();
3587     })
3588 }
3589 //关闭页面
3590 customShow.clean = function () {
3591     $('#extended_someThing').css("display", "none");
3592     $('#budget_whrere').val('');
3593     $('#budget_money').val('');
3594     $('#budget_time').val('');
3595 }
3596 //根据别名获取主数据
3597 customShow.getmasterdataById = function (itemid) {
3598     var mdata = undefined;
3599     ////console.log(itemid);
3600     if (customShow.options.customItemShow.item[itemid] != undefined) {
3601         if (customShow.options.customItemShow.item[itemid].tag_Attribute.masterData != undefined && customShow.options.customItemShow.item[itemid].tag_Attribute.masterData != '') {
3602             mdata = JSON.parse(customShow.options.customItemShow.item[itemid].tag_Attribute.masterData);
3603         }
3604     }
3605     if (mdata != undefined) {
3606         return mdata.defindCode;
3607     } else {
3608         return "";
3609     }
3610 }
3611
3612 //数据赋值 ----编辑项目赋值
3613 customShow.setShowCustomItem = function (items) {
3614     //   2017/10/19  李元杰  在费用明细里插入一些信息
3615     // 需要传给后端的对象
3616     //console.log(items);
3617     // var objData =  customShow.queryCostAllData();
3618     //  获取orderCode的值
3619
3620     // if(objData.orderCode){
3621     // var  orderCode =  customBase.getItemValue(customBase.options.customItems.orderCode.id,customBase.options.customItems.orderCode.type)
3622     // objData.orderCode = orderCode[1];
3623     // var requestInsert  = window.commonAjax("/datamanagement/getAssociatedFormDataService", objData, "POST", true);
3624     // requestInsert.done(function (res) {
3625     //     for(var i = 0 ; i <res.data.data.length;i++){
3626     //         if(res.data.data[i].child){
3627     //             for(var j = 0;j<res.data.data[i].child.length;j++){
3628     //                 // 循环子表单里拥有dataRowNum的数量
3629     //                     $(`[id= ${customBase.options.customItems.dataRowNum.id}]`).each( (index,ipt)=>{
3630     //                         // 获取返回值里的value和子表单里的dataRowNum的值是否相同
3631     //                             if(  res.data.data[i].child[j].msgInfo.header[0].value == $(ipt).val()){
3632     //                                 // 寻找当前子表单的父节点里的H8标签插入数据
3633     //                                 $($(`[id= ${customBase.options.customItems.dataRowNum.id}]`)[index].closest('[type=subform]')).children('h8').find('.text')
3634     //                                 .append(` <span>${res.data.data[i].child[j].msgInfo.header[0].name}</span>`)
3635     //                             }
3636     //                     })
3637     //             }
3638     //         }
3639     //     }
3640     // });
3641     // }
3642     //delete items['DATAROWNUM']; // 子表单中  不删除datarownum  李伟民  11-16
3643     var items = _.cloneDeep(items);
3644     var customItems = customBase.options.customItems;
3645     //console.log(customItems);
3646     //数据值变换
3647     for (item in items) {
3648         if (items.hasOwnProperty(item)) {
3649             if (customItems[item] == undefined) {
3650                 delete customItems[item];
3651                 continue;
3652             }
3653             if (customItems[item].type == 'subform' || customItems[item].type == 'tag' || customItems[item].type == 'tab') {
3654                 var subformTemp = items[item];
3655                 console.log(subformTemp)
3656                 if (subformTemp == undefined) {
3657                     subformTemp = [{}];
3658                 }
3659                 for (subformItem in subformTemp[0]) {
3660                     if (subformTemp[0].hasOwnProperty(subformItem)) {
3661                         items[subformItem] = [];
3662                     }
3663                 }
3664                 console.log(subformTemp.length);//主数据丢失
3665                 for (var i = 0; i < subformTemp.length; i++) {
3666                     if (i != 0) {
3667                         //子表单项目追加
3668                         var subformAdd = $(".customViewUEditorCss #" + customItems[item].id + "ActiveId .subformAdd")[0];
3669                         customShow.addsubformList(subformAdd, "customViewUEditorCss");
3670                     }
3671                     for (subformItem in subformTemp[i]) {
3672                         if (subformTemp[i].hasOwnProperty(subformItem)) {
3673                             items[subformItem][i] = subformTemp[i][subformItem];
3674                         }
3675                     }
3676                 };
3677             }
3678         }
3679     }
3680
3681     //delete items['DATAROWNUM']; // 子表单中  不删除datarownum  李伟民  11-16
3682     console.log(_.cloneDeep(items))
3683     console.log(customItems);
3684     //数据赋值
3685     for (item in items) {
3686         console.log(item);
3687         if (items.hasOwnProperty(item)) {
3688             if (customItems[item] == undefined) {
3689                 delete customItems[item];
3690                 continue;
3691             }
3692             var type = customItems[item].type;
3693             var id = customItems[item].id;
3694             console.log(id);
3695             console.log(items[item]);
3696             if (
3697                 // type == 'radio' || type == 'checkbox' ||
3698                 // type == 'dropdownlist'||
3699                 // type == 'tree'||
3700                 // type == 'amount'||
3701                 // type == 'barcode'||
3702                 // type == 'qrcode' ||
3703                 // type == 'image'||
3704                 type == 'button'
3705                 // || type == 'fileupload'
3706                 || type == 'subform' || type == 'link'
3707                 || type == 'splitline' || type == 'link' || type == 'tag' || type == 'tab'
3708             ) {
3709
3710             } else if (customItems[item].type == "image" || customItems[item].type == "fileupload") {
3711                 var itemId = customItems[item].id;
3712                 if (items[item] != "") {
3713                     customBase.options.uploaderItemReady[itemId] = $.parseJSON(items[item]);
3714                 } else {
3715                     customBase.options.uploaderItemReady[itemId] = [];
3716                 }
3717             } else if (type == 'amount') {
3718                 var id = id + "amount";
3719                 customBase.setItemValue(id, 'text', items[item], 'customViewUEditorCss');
3720                 $("#" + id).blur();
3721             } else if (type == 'qrcode') {
3722                 var id = id + "qrcode";
3723                 customBase.setItemValue(id, 'text', items[item], 'customViewUEditorCss');
3724                 $("#" + id).blur();
3725             } else if (type == 'barcode') {
3726                 var id = id + "barcode";
3727                 customBase.setItemValue(id, 'text', items[item], 'customViewUEditorCss');
3728                 $("#" + id).blur();
3729             } else if (type == 'dropdownlist' || type == 'radio' || type == 'checkbox' || type == 'tree') {
3730                 //异步加载时数据临时保存
3731                 customShow.options.initTempDatas[id] = items[item];
3732                 // var datasourcetype = $("#"+id)[0].getAttribute("datasourcetype");
3733                 // //主数据源
3734                 // if(datasourcetype == "masterdata"){
3735                 //   customBase.setItemValue(id,type,items[item],'customViewUEditorCss');
3736                 //   //数据源
3737                 // }else if(datasourcetype == "datasource"){
3738                 //   customBase.setItemValue(id,type,items[item],'customViewUEditorCss');
3739                 //   //自定义
3740                 // }else if(datasourcetype == "custom"){
3741                 //   customBase.setItemValue(id,'dropdownlistText',items[item],'customViewUEditorCss');
3742                 //   //API接口
3743                 // }else if(datasourcetype == "api"){
3744                 //   customBase.setItemValue(id,type,items[item],'customViewUEditorCss');
3745                 // }
3746
3747             } else if (customItems[item].type == 'mytext') {
3748                 //选择表单预览回显
3749                 var itemAttribute = customShow.options.customItemShow.item[customItems[item].id];
3750                 var item_title = [];
3751                 var itemVal = [];
3752                 var $mytext = $("#customShow " + "#" + customItems[item].id + "ActiveId");
3753                 if (itemAttribute.tag_Attribute.relevancesourcetype == "fundata") {// 关联数据回显渲染 李伟民 11-30
3754                     var titleObj = { "key": JSON.parse(itemAttribute.tag_Attribute.fundata)["key"] };
3755                     var dataObj = {
3756                         "formID": customShow.options.formid,
3757                         "tenantID": "001",
3758                         "search": [],
3759                         "pageSize": "1000",
3760                         "pageNum": "1",
3761                         "key": JSON.parse(itemAttribute.tag_Attribute.fundata)["key"],
3762                         "formData": {},
3763                         "dataRowNum": items[item]
3764                     };
3765                     var requesTitle = window.commonAjax("/datamanagement/getAssociateTitle", titleObj, "POST", true, false);
3766                     var requesData = window.commonAjax("/datamanagement/getAssociateData", dataObj, "POST", true, false);
3767                     requesTitle.done(function (res) {
3768                         console.log(res);
3769                         item_title = res.data;
3770                     });
3771                     requesData.done(function (res) {
3772                         console.log(res);
3773                         if (!_.isNull(res.data) && res.data != undefined) {
3774                             itemVal = res.data;
3775                         }
3776                     });
3777                 } else {
3778                     var myTitle = JSON.parse(window.localStorage.getItem("title"));
3779                     item_title = myTitle[item];
3780                     itemVal = items[item];
3781                 }
3782                 console.log(myTitle);
3783                 console.log(itemVal)
3784                 console.log(item_title);
3785                 console.log(itemVal.list);
3786                 var iconID = "customShow #" + customItems[item].id + "ActiveId";// 关联数据回显渲染 李伟民 11-30
3787                 createMxtTable(iconID, item_title, itemVal.list);// 关联数据回显渲染 李伟民 11-30
3788                 //              var newData = [];
3789                 //              _.each(itemVal.list,function(opt){
3790                 //                  opt = _.mapKeys(opt,function(value,key){
3791                 //                      _.each(item_title,function(item){
3792                 //                          if(key == item.fieldKey){
3793                 //                              key = item.title;
3794                 //                          }
3795                 //                      })
3796                 //                      return key;
3797                 //                  })
3798                 //                  console.log(_.cloneDeep(opt))
3799                 //                  newData.push(opt);
3800                 //              })
3801                 //              console.log(itemVal.list);
3802                 //              console.log(newData);
3803                 ////              var $value = newData;
3804                 //              var show = "";
3805                 //              var divBox = $("<div></div>");
3806                 //              divBox.attr('id',customItems[item].id+'divBox');
3807                 //              //console.log($value)
3808                 //                        var sdata_head = "";
3809                 //              _.each($value,(opt,j)=>{
3810                 //                  //console.log(opt);
3811                 //                  var ulBox = $("<ul></ul>");
3812                 //                  for(let i in opt){
3813                 //                      show = "";
3814                 //                                sdata_head = '<td class="data1 '+i+'">'+i+'</td>';
3815                 //                  show += '<li>'+'<span class="data1 '+i+'">'+i+'</span>'+'<span class="data2 '+i+'">'+opt[i]+'</span>'+'</li>';
3816                 //                  ulBox.attr("class","addUl ulBox"+j);
3817                 //                  ulBox.attr("id","ulBox"+j);
3818                 //                  //console.log(show)
3819                 //                  ulBox.append(show);
3820                 //                  }
3821                 //                            console.log(sdata_head);
3822                 //                  divBox.append(ulBox);
3823                 //              });
3824                 //              $mytext.append(divBox);
3825             } else {
3826                 //值设定
3827                 customBase.setItemValue(id, type, items[item], 'customViewUEditorCss');
3828                 //异步加载时数据临时保存
3829                 customShow.options.initTempDatas[id] = items[item];
3830             }
3831         }
3832     };
3833     //赋值后绑定票据信息
3834 }
3835 // 定义云账房方法 10/17
3836 var orderid = "";
3837 function getepc() {
3838     window.queryAjaxsd("epc/epc-form/getOrderCode", {}, "POST", true).done(function (res) {
3839         //console.log("云账房id");
3840         //console.log(res);
3841         if (res.data != undefined) {
3842             orderid = res.data.orderCode;
3843             setepc(orderid);
3844         }
3845
3846     })
3847 }
3848 function setepc(orderid) {
3849     //console.log(orderid);
3850     //console.log(customBase);
3851     //console.log(window.customShow);
3852     if (customBase.options.customItems.orderCode != undefined) {
3853         var id = customBase.options.customItems.orderCode.id;
3854         var type = customBase.options.customItems.orderCode.type;
3855         //console.log(id);
3856         //console.log(type);
3857
3858         customBase.setItemValue(id, type, orderid);
3859     }
3860 }
3861
3862 function getCookie(name) {
3863     var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
3864     if (arr = document.cookie.match(reg))
3865         return unescape(arr[2]);
3866     else
3867         return null;
3868 }
3869
3870 customShow.uploadBill = function () {//票据上传
3871     $('#upload_iframe').show();
3872     var token = localStorage.getItem(token);
3873     if (token != '' && token != undefined) {
3874         token = JSON.parse(token).accessToken;
3875     }
3876     var compid = getCookie('companyId');
3877     var tenantId = localStorage.getItem("tenantID");
3878     // var iframe_src = "http://csza.chfcloud.com/views/order_create_visit.html?token=" + token + "&compid=" + compid +"&tenantId=" + tenantId;
3879     var iframe_src = "http://csza.chfcloud.com/views/order_create_visit.html?token=" + localStorage.getItem("testToken") + "&compid=" + localStorage.getItem("testCompanyId") +"&tenantId=" + localStorage.getItem("testTenantId");
3880     //var iframe_src = "http://csza.chfcloud.com/views/order_create_visit.html?token=a23efb1df2303a914b1139d4e1d1859f&compid=66&tenantId=13";
3881     $("#upload_iframe").append("<iframe id='uploadBill' style='width:100%;overflow: auto;'></iframe>");
3882     ////console.log($("body"));
3883     var thisHeight = $("body").height();
3884     ////console.log(thisHeight);
3885     $('#upload_iframe').height(thisHeight);
3886     $('#uploadBill').height(thisHeight);
3887     $('#uploadBill').attr("src", iframe_src);
3888     window.addEventListener("message", customShow.getExCouldNumber);
3889     $("#upload_iframe .right").on("click", function () {
3890         customShow.uploadBillClose();
3891     });
3892
3893 }
3894
3895 customShow.getExCouldNumber = function (event) {
3896     if (event && event.data && event.data.indexOf('csc_OrderCode=') != -1) {
3897         var exCouldNumber = event.data.split('=')[1];
3898         console.log(exCouldNumber);
3899         customShow.exCouldNumber = exCouldNumber;
3900         if(localStorage.getItem('customShowFlag') == 2){//详情页上传票据需将云单编号传给后台  李伟民  01-04
3901             var orderData = {
3902                 "formId":customShow.options.formid,
3903                 "formDataId":localStorage.getItem("datarowNum"),
3904                 "orderCode":exCouldNumber
3905             }
3906             var orderUpdate = window.cloudAjax("epc-form/formData/updataBillInfoAndForm",orderData,"POST",true);
3907             orderUpdate.done(function(res){
3908                 if(res.rspCode == '000000'){
3909                     changeOrderStatus('10');
3910                     customShow.uploadBillClose();
3911                 }
3912             });
3913         }else{
3914             customShow.uploadBillClose();
3915         }
3916     }
3917 }
3918
3919 customShow.uploadBillClose = function () {
3920     $('#uploadBill').remove();
3921     $('#upload_iframe').hide();
3922     window.removeEventListener("message", customShow.getExCouldNumber);
3923     $('.bill_upload').hide();
3924     // getepc();
3925 }//画面初期编辑内容设定
3926 customShow.setContentHtml = function (customItem, customViewDiv) {
3927
3928     //按钮状态编辑  btnFlag:{editable:"1",printable:"1",auditable:"1",disposable:"1"} //按钮表示
3929     var btnFlag = customShow.options.btnFlag;
3930     if (btnFlag.editable != "0") {
3931         $("#editableBtn").removeClass("cfg_contentNone");
3932     }
3933     if (btnFlag.printable != "0") {
3934         $("#printableBtn").removeClass("cfg_contentNone");
3935     }
3936     if (btnFlag.auditable != "0") {
3937         $("#auditableBtn").removeClass("cfg_contentNone");
3938     }
3939     if (btnFlag.disposable != "0") {
3940         $("#disposableBtn").removeClass("cfg_contentNone");
3941     }
3942
3943     var div = document.createElement("div");
3944     div.innerHTML = customItem.formeditor;
3945     if (customShow.options.customInit.designMode == "1") {
04dc45 3946         //发布页面查看大图排版问题  曲辰明 3-27
Q 3947         //div.setAttribute("class", "divshow divshowEditor");
4d1219 3948
B 3949         if (customShow.options.customShowFlag != "4") {
3950             $(div).css("height", customItem.fromheigh);
13ec33 3951             $(div).css("width", "100%");
4d1219 3952             // $(customViewDiv).css("height",customItem.fromheigh);
B 3953             // $(customViewDiv).css("width",customItem.fromwidth);
3954             console.log(1);
3955         }
3956
3957     } else {
3958         div.setAttribute("class", "divshow divshowNoEditor");
3959         //  $(div)[0].style.height = window.innerHeight-140 + "px";
3960         //  if(customShow.options.customShowFlag =="0"){
3961         //     $(div)[0].style.width ='98%';
3962         //  }else{
3963         //     $(div)[0].style.width ='100%';
3964         //  }
3965
3966         //  $(div)[0].style.overflowY ='auto';
3967         $(div)[0].style.width = '100%';
3968         $(div)[0].style.height = '100%';
3969
3970         $(div).css("display", "flex");
3971         $(div).css("justify-content", "flex-start");
3972         $(div).css("flex-wrap", "wrap");
3973     }
3974     $(customViewDiv).prepend(div);
3975
3976     //基本信息List取得
3977     customBase.options.customItems = customShow.getItemsList();
3978     console.log(customShow.getItemsList())
3979     console.log(customShow.options.customItemShow.item)
3980
3981     //接口绑定
3982     interfaceBind = customShow.initEvent.interfaceBind;
3983     for (var i = 0; i < interfaceBind.length; i++) {
746465 3984         if(window[interfaceBind[i].customInterfacemethod] != undefined){
L 3985             customShow.initEvent[interfaceBind[i].interfacemethod] = eval(interfaceBind[i].customInterfacemethod);
3986         }
4d1219 3987     };
B 3988
3989     // //事件绑定
3990     // eventBind = customShow.initEvent.eventBind;
3991     // //02事件绑定:字段别名 字段类型 事件名 自定义事件名
3992     // for (var i = 0; i < eventBind.length; i++) {
3993     //   // 自定义事件名
3994     //   var setfunction = eval(eventBind[i].eventmethod);
3995     //   // 事件名
3996     //   var eventName = eventBind[i].event;
3997     //   // 字段类型
3998     //   // var tag = eventBind.tag;                         //------------类型绑定-------------
3999     //   // 字段别名
4000     //   var fieldKey = eventBind[i].fieldName;
4001     //   // 取得控件ID
4002     //   var itemId = customBase.getfieldKeyFoItemId(fieldKey);  //---------------------------
4003     //   //事件绑定
4004     //   $("#"+itemId).on(eventName, setfunction);
4005     // };
4006     // //-------------------------主数据取得------------------------------
4007     //-------------------------数据源取得------------------------------
4008     //-------------------------API取得data-----------------------------
4009
4010     //画面初期化
4011     customShow.initEvent.interfaceInit(customShow.options.customShowFlag);
4012     console.log(customShow.options.customItemShow.item);
4013     //第三方初始化
4014
4015     customShow.initEvent.interfaceInit3rd();
4016
4017     //密码输入----------------
4018     customShow.initEvent.passwordInputFlag();
4019     //tree控件 by kill
4020     // 2017/11/4  李元杰 在点击预览的时候树的按钮
4021     customShow.treeWinShow();
4022
4023 }
4024 //2017/11/2  李元杰 单选树  树的显示
4025
b84eca 4026 $('.customViewUEditorCss').on('click', '.citySel,.menuBtn', function () {
4d1219 4027     debugger
B 4028     // 树里存在数据时
4029     if ($(this).parents('div[name="TreeWin"]').find('.ztree').children('li').length > 0) {
13ec33 4030         //  12/16 李元杰
4d1219 4031         $('div.drop_down_sel').remove();
B 4032         var fieldKey = $(this).parents('div[name="TreeWin"]').find('.zTreeDemoBackground').attr('fieldkey');
4033         $('.zTreeDemoBackground').css("display", "none");
4034         $(".search_input").css("display", "none");
4035         if (customBase.options.customItems[fieldKey].editable) {
4036             if (event.target.className == 'defaultHeight  citySel' || event.target.className == 'defaultHeight  citySel') {
4037                 var ztree = $(this).parents('div[name="TreeWin"]').find('.ztree')
4038                 for (var i = 0; i < ztree.length; i++) {
4039                     var treeObj = $.fn.zTree.getZTreeObj($(ztree[i]).attr('id'));
4040                     if (!_.isNull(treeObj)) {
4041                         treeObj.expandAll(true);
4042                     }
4043                 }
4044             }
4045             $(this).parents('div[name="TreeWin"]').find('div[name="treeWinTitle"]').find('.search_input').css("display", "block");
4046             $(this).parents('div[name="TreeWin"]').find('.zTreeDemoBackground').show();
4047             //  12/16 end
4048         }
70c562 4049         $('.customViewUEditorCss').off('click.tree').on('click.tree', function () {
4d1219 4050             console.log(1);
B 4051             console.log($('div.drop_down_sel'))
4052             $('div.drop_down_sel').remove();
4053             $('.zTreeDemoBackground').css("display", "none");
4054             $(".search_input").css("display", "none");
4055
4056         });
4057
4058         $('div.TreeWin').off('click.tree').on('click.tree', function (event) {
4059             // 展开树 12/4
4060             console.log($(this))
4061             $('div.drop_down_sel').remove();
4062             var fieldKey = $(this).find('.zTreeDemoBackground').attr('fieldkey');
4063             $('.zTreeDemoBackground').css("display", "none");
4064             $(".search_input").css("display", "none");
4065             if (customBase.options.customItems[fieldKey].editable) {
4066                 if (event.target.className == 'defaultHeight  citySel' || event.target.className == 'defaultHeight  citySel') {
4067                     var ztree = $(this).find('.ztree')
4068                     for (var i = 0; i < ztree.length; i++) {
4069                         var treeObj = $.fn.zTree.getZTreeObj($(ztree[i]).attr('id'));
4070                         if (!_.isNull(treeObj)) {
4071                             treeObj.expandAll(true);
4072                         }
4073                     }
4074                 }
4075
4076                 $(this).find('div[name="treeWinTitle"]').find('.search_input').css("display", "block");
4077                 $(this).find('.zTreeDemoBackground').show();
4078             }
4079             event.stopPropagation();
4080         });
4081
4082     }
4083 })
4084 //this function by kill
4085 customShow.treeWinShow = function () {
4086     // $('body').append('<div id="occlusion"></div>')
4087     //    occlusionCss={
4088     //        background: 'white',
4089     //        filter: 'alpha(opacity=100)',
4090     //        opacity: '1',
4091     //        display: 'none',
4092     //        position: 'absolute',
4093     //        top: '0px',
4094     //        left: '0px',
4095     //        width: '100%',
4096     //        height: '100%',
4097     //        display:'none',
4098     //        "z-index":"99998",
4099     //        display:"none",
4100     //        height:'100%',
4101     //        width:'100%',
4102     //    };
4103     treeButtonDivCss = {
4104         position: "absolute",
4105         top: '85%',
4106         left: '30%',
4107     }
4108     treeDutton2DivCss = {
4109         position: "absolute",
4110         top: '85%',
4111         left: '60%',
4112     }
4113     winCss = {
4114         position: 'relative',
4115         "border-radius": "4px",
4116         width: "100%",
4117         'max-width':"190px",
4118         height: "30px",
4119
4120     }
4121     treeWinTitleCss = {
4122         "margint-top": "3%"
4123     }
4124     subFormTreeCss = {
4125         position: "absolute",
4126
4127         top: '56px',
4128         left: '0px',
4129
4130         'background-color': '#fff',
4131         'z-index': '99999',
4132         // top:"15%",
4133         // "margin-left":"5%",
4134         width: "165px",
4135         border: "1px solid #CCC",
4136         overflow: "hidden",
4137         'overflow-y': "auto",
4138
4139     }
4140     wintreeCss = {
4141         position: "absolute",
4142         top: '56px',
4143         'background-color': '#fff',
4144         'z-index': '99999',
4145         // top:"15%",
4146         // "margin-left":"5%",
4147         width: "165px",
4148         border: "1px solid #CCC",
4149         overflow: "hidden",
4150         'overflow-y': "auto",
4151     }
8aa132 4152     if(customShow.options.customInit.designMode == 2){//快捷模式处理  李伟民  0123
4d1219 4153         $(".ztree").parent().parent().attr("name", "TreeWin");
B 4154         $(".ztree").parent().parent().attr("class", "TreeWin");
4155     }else{
4156         $(".ztree").parent().wrapAll('<div name="TreeWin" class="TreeWin"></div>');
4157     }
13ec33 4158
4d1219 4159
B 4160     $('.ztree').parents('div[name="TreeWin"]').show();
4161     //    2017/11/4 点击预览的时候产生的树样式  李元杰
4162     $('div[type="Tree"]').append('<button class="btn btn-primary" name="treeButton1" style="display:none">选择</button>');
4163     //马习同  下拉树样式修改 11/13
4164     // $('div[name="TreeWin"]').prepend(`
4165     //     <div name="treeWinTitle">
4166     //         <div class="content_wrap">
4167     //             <div>
4168     //                 <ul class="list ulContent">
4169     //                     <div class="input-group"  >
4170     //                         <input   readonly unselectable="on" type="text"  class="defaultHeight  citySel" placeholder="" aria-describedby="basic-addon1">
4171     //                         <button id="" type="button" class="menuBtn btn btn-default"><i class="fa fa-search" aria-hidden="true"></i></button>
4172     //                     </div>
4173
4174     //                     </li>
4175     //                 </ul>
4176     //             </div>
4177     //         </div>
4178     //     </div>
4179     // `);
8aa132 4180     if(customShow.options.customInit.designMode == 2){
4d1219 4181         $('div[name="TreeWin"]').prepend(`
B 4182             <div name="treeWinTitle">
4183                 <input  id="search_input" type="text" class="defaultHeight search_input" placeholder="" aria-describedby="basic-addon1">
4184                 <div class="content_wrap">
4185                     <div>
4186                         <ul class="list ulContent">
4187                             <div class="input-group"  >
4188                                 <input   readonly unselectable="on" type="text"  class="defaultHeight  citySel" placeholder="" aria-describedby="basic-addon1">
4189                                 <button id="" type="button" class="menuBtn btn btn-default"><i class="fa fa-search" aria-hidden="true"></i></button>
4190                             </div>
4191
4192                             </li>
4193                         </ul>
4194                     </div>
4195                 </div>
4196             </div>
4197         `);
8aa132 4198     }else{
L 4199         _.each($('.ztree'),function(tree){
4200             if($(tree).parent().attr('class').indexOf('cfg_contentNone') != -1){
4201                 $(tree).closest('div[name="TreeWin"]').prepend(`
4202                 <div name="treeWinTitle" class="cfg_contentNone">
4203                     <input  id="search_input" type="text" class="defaultHeight search_input" placeholder="" aria-describedby="basic-addon1">
4204                     <div class="content_wrap">
4205                         <div>
4206                             <ul class="list ulContent">
4207                                 <div class="input-group"  >
4208                                     <input   readonly unselectable="on" type="text"  class="defaultHeight  citySel" placeholder="" aria-describedby="basic-addon1">
4209                                     <button id="" type="button" class="menuBtn btn btn-default"><i class="fa fa-search" aria-hidden="true"></i></button>
4210                                 </div>
13ec33 4211
8aa132 4212                                 </li>
L 4213                             </ul>
4214                         </div>
4215                     </div>
4216                 </div>
4217             `);
4218             }else{
4219                 $(tree).closest('div[name="TreeWin"]').prepend(`
4220                 <div name="treeWinTitle">
4221                     <input  id="search_input" type="text" class="defaultHeight search_input" placeholder="" aria-describedby="basic-addon1">
4222                     <div class="content_wrap">
4223                         <div>
4224                             <ul class="list ulContent">
4225                                 <div class="input-group"  >
4226                                     <input   readonly unselectable="on" type="text"  class="defaultHeight  citySel" placeholder="" aria-describedby="basic-addon1">
4227                                     <button id="" type="button" class="menuBtn btn btn-default"><i class="fa fa-search" aria-hidden="true"></i></button>
4228                                 </div>
13ec33 4229
8aa132 4230                                 </li>
L 4231                             </ul>
4232                         </div>
4233                     </div>
4234                 </div>
4235             `);
4236             }
4237         })
13ec33 4238
8aa132 4239     }
13ec33 4240
4d1219 4241     //    $('div[name="TreeWin"]').prepend('<div name="treeWinSearch"><input id="search_input" placeholder="Type to filter"><hr /></div>');
B 4242     //    $('div[name="TreeWin"]').append('<div name="treeButtonDiv"><button class="btn btn-primary" name="treeButton2">确定</button></div>');
4243     //    $('div[name="TreeWin"]').append('<div name="treeButtonDiv2"><button class="btn btn-danger" name="treeButton3">取消</button></div>');
4244     //    $(".ztree").parent().css(subFormTreeCss);
4245     //    $('.ztree').parents('.fieldOrderNum').attr('typpe');
4246     var ztreeParentCss = $(".ztree").parent();
4247     $(".ztree").parent().css(subFormTreeCss);
4248     for (var i = 0; i < ztreeParentCss.length; i++) {
4249         //  11/16 李元杰  子表单内树形搜索框定位
4250         console.log($(ztreeParentCss[i]).find('ul'))
4251         console.log($(ztreeParentCss[i]).parents('.fieldOrderNum'))
4252         var isAllCopyTreeIs = $(ztreeParentCss[i]).find('ul').attr('id').split('tree')[0];
4253         if (customShow.options.customItemShow.item[isAllCopyTreeIs].parentsubFormNum != 0) {
4254             $(ztreeParentCss[i]).css(subFormTreeCss);
4255             $(ztreeParentCss[i]).parent('div[name="TreeWin"]').find('.search_input').addClass('search_input_subform')
4256         } else {
4257
4258             $(ztreeParentCss[i]).css(wintreeCss);
4259         }
4260         //  树形是否有数据的判断
4261         if ($(ztreeParentCss[i]).children('ul').children('li').length > 0) {
4262
4263         } else {
4264
4265             $(ztreeParentCss[i]).hide();
4266         }
4267     }
4268     //    $("#occlusion").css(occlusionCss);
4269     $('div[name="TreeWin"]').css(winCss);
8aa132 4270     if(customShow.options.customInit.designMode == 1){
4d1219 4271         $('div[name="TreeWin"]').css('width','unset');
B 4272     }
4273     $('div[name="treeWinTitle"]').css(treeWinTitleCss);
4274     $('.ztree').css("top", "%20");
4275     //    $(".ztree").parent().parent().hide();
4276     //这个换成点击新建
4277     //    $('button[name="treeButton1"]').click(function(){
4278     // 表明只有树组件时才提示是否绑定数据
4279     if ($('button[name="treeButton1"]').length > 0) {
4280         var treeId = $('button[name="treeButton1"]').prev().attr("id");
4281         var treeJson = $('button[name="treeButton1"]').prev().children(':nth-child(2)').attr("masterdata");
4282         //////console.log($(this).prev()[0]);
4283         // console.log(treeJson);
4284         //console.log(treeId);
4285         if (typeof (treeJson) == "undefined" || treeJson == "") {
4286             // alert("该控件没有进行数据绑定!")
4287         } else {
4288             //    $("#occlusion").fadeTo(200);
4289             console.log($('button[name="treeButton1"]'))
4290             $('button[name="treeButton1"]').prev().show();
4291             console.log($('div[name="treeWinTitle"]'))
4292             var treeWinTitle = $('div[name="treeWinTitle"]');
4293             console.log(treeWinTitle[0])
4294             for (var i = 0; i < treeWinTitle.length; i++) {
4295                 console.log($(treeWinTitle[i]));
4296                 $(treeWinTitle[i]).find('input[type="text"]').attr('id', `search_input${i}`)
4297             }
4298         }
4299     }
4300     //  12/7 李元杰 树禁止背景颜色
4301     var editableBgColor = $('.ztree');
4302     for (var i = 0; i < editableBgColor.length; i++) {
4303         var editableFlag = $(editableBgColor[i]).parent().attr('editable')
4304         if (editableFlag == 'true') {
4305             var a = $(editableBgColor[i]).parents('div[name="TreeWin"]').find('.citySel')
4306             $(editableBgColor[i]).parents('div[name="TreeWin"]').find('.citySel').removeClass('disableColor')
4307         } else {
4308             var a = $(editableBgColor[i]).parents('div[name="TreeWin"]').find('.citySel')
4309             $(editableBgColor[i]).parents('div[name="TreeWin"]').find('.citySel').addClass('disableColor')
4310         }
4311     }
4312     //  12/7 end
4313     $('.ztree').addClass('search_list');
4314     // 搜索框获得焦点时 初始化
4315     console.log($('.tabBox'))
4316     $('.tabBox').on('focus', '.search_input', function () {
4317         console.log($(this))
4318         var searchListId = $(this).parents('div[name="TreeWin"]').find('.ztree').attr('id');
4319         console.log($(this).parents('div[name="TreeWin"]').find('.ztree'));
4320         $(this).fastLiveFilter(`#${searchListId}`, {});
4321     })
4322     //    $('button[name="treeButton2"]').click(function(){
4323     //        //确定按钮 by kill
4324     //            var treeId=$(this).parent().parent().children(':nth-child(2)').attr("id")
4325     //            $('#spanDiv'+treeId).remove()
4326     //            $('#'+treeId+"ActiveId").children(':nth-child(1)').append('<span id="spanDiv'+treeId+'"></span>')
4327     //            $('#'+treeId+'tree').children('li').each(function(){
4328     //               var state=$(this).children(':nth-child(2)').attr('class')
4329     //               if(state.indexOf('true')!=-1){
4330     //                    var text=$(this).children(':nth-child(3)').attr('title');
4331     //                    $('#'+treeId+"ActiveId").children(':nth-child(1)').children(':nth-child(4)').append('<span>|'+text+'</span>')
4332     //               }
4333     //            })
4334     //         //    $("#occlusion").fadeOut(200);
4335     //         //    $(this).parent().parent().hide();
4336     //        }
4337     //    )
4338     //    $('button[name="treeButton3"]').click(function(){
4339     //        //取消按钮 by kill
4340     //        var treeId=$(this).parent().parent().children(':nth-child(2)').attr("id")
4341     //        var a = [];
4342     //        var tite=$('#spanDiv'+treeId).children().text();
4343     //        for(var i=0;i<tite.split("|").length;i++){
4344     //           $('#'+treeId+'tree').children('li').each(function(){
4345     //               if(tite.split("|")[i]==$(this).children(':nth-child(3)').attr('title')){
4346     //                   a.push($(this).children(':nth-child(2)').attr('id'))
4347     //               }else{
4348     //                   if($(this).children(':nth-child(2)').attr('class').indexOf('true')!=-1){
4349     //                       $(this).children(':nth-child(2)').click();
4350     //                   }
4351     //               }
4352     //           })
4353     //       }
4354     //           for(var x=0;x<a.length;x++){
4355     //               $('#'+a[x]).click();
4356     //               ////console.log(a[x])
4357     //           }
4358
4359     //         // $("#occlusion").fadeOut(200);
4360     //         // $(this).parent().parent().hide();
4361     //    })
4362     // end by kill
4363
4364
4365 }
4366
4367 //事件绑定 接口绑定
4368 customShow.setEventBind = function () {
4369     // //接口绑定
4370     // interfaceBind = customShow.initEvent.interfaceBind;
4371     // for (var i = 0; i < interfaceBind.length; i++) {
4372     //   customShow.initEvent[interfaceBind[i].interfacemethod] = eval(interfaceBind[i].customInterfacemethod);
4373     // };
4374
4375     //事件绑定
4376     eventBind = customShow.initEvent.eventBind;
4377     //02事件绑定:字段别名 字段类型 事件名 自定义事件名
4378     console.log(eventBind);
4379     for (var i = 0; i < eventBind.length; i++) {
4380         // 自定义事件名
4381         var funstr = eventBind[i].eventmethod + "()";//页面事件绑定 李伟民 12-22
f7134f 4382         //页面事件绑定 李伟民 12-22
4d1219 4383         // 事件名
B 4384         var eventName = eventBind[i].event;
4385         // 字段类型
4386         // var tag = eventBind.tag;                         //------------类型绑定-------------
4387         // 字段别名
4388         var fieldKey = eventBind[i].fieldName;
4389         // 取得控件ID
4390         var itemId = customBase.getfieldKeyFoItemId(fieldKey);  //---------------------------
f7134f 4391         $("#" + itemId).attr('funstr',funstr)
4d1219 4392         //事件绑定
f7134f 4393         $("#" + itemId).on(eventName, function () {
449a85 4394             try {//页面事件 无资源文件 JS报错解决 李伟民 0131
L 4395                 eval($(this).attr('funstr'));
4396             } catch (error) {
4397                 console.log('资源文件中无此方法')
4398             }
f7134f 4399         });
4d1219 4400     };
B 4401     //-------------------------主数据取得------------------------------
4402
4403     //公式初期化
4404     setTimeout(function () {
4405         customLinkageAnalysis.bindLinkage();
4406     }, 200);
4407     //行程排序初期化
4408     setTimeout(function () {
4409         customShow.journeySort();
4410     }, 200);
4411     // customShow.options.LinkageAnalysisSetValueFlag = ture;
4412
4413     setTimeout(function () {
4414         //初期化公式接口
4415         customShow.initEvent.interfaceInitLinkage();
4416     }, 200);
4417     //马习同   合计   2017-12-07  公式初期化后
4418     customShow.oneTotle();
4419 }
4420
4421 customShow.setEventBindItem = function (eventItem) {
4422     //事件绑定
4423     eventBind = eventItem;
4424     //02事件绑定:字段别名 字段类型 事件名 自定义事件名
4425     for (var i = 0; i < eventBind.length; i++) {
4426         // 自定义事件名
4427         var setfunction = eval(eventBind[i].eventmethod);
4428         // 事件名
4429         var eventName = eventBind[i].event;
4430         // 字段类型
4431         // var tag = eventBind.tag;                         //------------类型绑定-------------
4432         // 字段别名
4433         var fieldKey = eventBind[i].fieldName;
4434         // 取得控件ID
4435         var itemId = customBase.getfieldKeyFoItemId(fieldKey);  //---------------------------
4436         //事件绑定
4437         $("#" + itemId).on(eventName, setfunction);
4438     };
4439 }
4440 customShow.listData = {};
4441 //  11/21  全局 itemId
4442 customShow.itemId = "";
4443 //数据设定值取得(主数据 API 数据源 自定义)
4444 customShow.setDatasourceData = function (customItem) {
4445     //马习同 获取
4446     customItems = customShow.options.customItemShow.item;
4447
4448     var setDataItem = {
4449         masterdata: function (item, callback) {
4450             setMasterData(item, callback);
4451         },
4452         datasource: function (item, callback) {
4453             setDatasource(item, callback);
4454         },
4455         custom: function (item, callback) {
4456             setCustom(item, callback);
4457         },
4458         api: function (item, callback) {
4459             setApiDatasource(item, callback);
4460         }
4461     }
4462     var setCallbackItem = function (itemId, listData) {
4463         var type = customShow.options.customItemShow.item[itemId].tag_Type;
4464         if (type == "dropdownlist") {
4465             setDropdownlist(itemId, listData);
4466         } else if (type == "radio" || type == "checkbox") {
4467             setCustomradio(itemId, listData);
4468         } else if (type == "tree") {
4469             var dropdowntype = customShow.options.customItemShow.item[itemId].tag_Attribute.dropdowntype;
4470             if (dropdowntype == "multiple") {
4471                 // 多选的树样式
4472                 $('#' + itemId + "tree").parent().hide();
4473                 setTree(itemId, customBase.settingChkboxType, listData);
4474
4475             } else {
4476                 // 2017/11/1  李元杰 树更改成单选
4477                 // 单选的树样式
4478
4479                 $('#' + itemId + "tree").parent().hide();
4480                 setTree(itemId, customBase.settingRadioType, listData);
4481             }
4482             var unvisible = customBase.options.customItems;
4483             for (item in unvisible) {
4484                 if (unvisible[item].type == "subform") {
4485                     var itemId = unvisible[item].id;
4486                     //          var itemTwo = itemId;
4487                     //          var itemSubform = $('.'+"customViewUEditorCss" +" #"+itemId+"ActiveId");
4488                     ////////////console.log(item);
4489                     //子表单删除第一条可添加  2017/10/26 马习同
4490                     //          var divIcon = $('<div id="'+itemId+'save" class="cfg_contentNone"></div>');
4491                     var cloneE = $('#' + itemId + 'subformTr').clone();
4492                     //          divIcon.append(cloneE);
4493                     console.log(cloneE);
4494                     //          itemSubform.append(divIcon);
4495
4496
4497                     customBase.options.customItems[item]['cloneDiv'] = cloneE;
4498                 }
4499             }
4500         }
4501     }
4502
4503     //下拉菜单
4504     setDropdownlist = function (itemId, listData) {
4505
4506
4507         var dropdownlistData;
4508
4509         var item = $('.customViewUEditorCss #' + itemId);
4510         //  $($('.customViewUEditorCss #'+itemId)[0]).empty();
4511         //  $($($('.customViewUEditorCss #'+itemId)[0]).parentNode).find(".select2").remove();
4512         var dropdowntype = customShow.options.customItemShow.item[itemId].tag_Attribute.dropdowntype;
4513         var editable = customShow.options.customItemShow.item[itemId].tag_Attribute.editable;
4514         //        ////console.log(editable);
4515         var readonly = "readonly";
4516         if (editable) {
4517             readonly = "";
4518         }
4519         var width = $(item[0])[0].style.width.replace("px", "");
4520         width = parseInt(width);
4521         console.log(width)
4522         customBase.options.dropdownlistText[itemId] = listData;
4523         // $("#"+itemId).parent().empty();
4524         var itemIdClass = "selectClass js-example-basic-single defaultHeight customShowItemClass  dropdowntypeCss " + itemId + "value " + readonly;
4525         var DropdownlistItem = $("#" + itemId).parent();
4526         DropdownlistItem.empty();
4527         DropdownlistItem.append($('<div id="' + itemId + '" class="selectClass ' + itemIdClass + '"></div>'));
4528         if (dropdowntype == "multiple") {
4529             xhSelect.setXhSelect(
4530                 {
4531                     selectId: itemId,
4532                     multiple: true,
4533                     width: width,
4534                     listData: listData
4535                 }
4536             );
4537         } else {
4538             xhSelect.setXhSelect(
4539                 {
4540                     selectId: itemId,
4541                     multiple: false,
4542                     width: width,
4543                     listData: listData
4544                 }
4545             );
4546         }
4547         //  item.find();
4548         // if(dropdowntype == "multiple"){
4549         //     item.select2({theme: "classic",
4550         //       width: width,
4551         //       data: listData,
4552         //       multiple: true});
4553         //  }else{
4554         //     item.select2({theme: "classic",
4555         //       width: width,
4556         //       data: listData,
4557         //     });
4558         //  }
4559         customShow.clickBindSubform();
4560
4561         //数据加载
4562         var initTempData = customShow.options.initTempDatas[itemId];
4563         if (initTempData != undefined) {
4564             var parentsubFormNum = customShow.options.customItemShow.item[itemId].parentsubFormNum;
4565             initTempData = customShow.dbItemToShowItem(itemId, "dropdownlistText", initTempData, "customViewUEditorCss", dropdowntype, parentsubFormNum);
4566             // customShow.options.initTempDatas[itemId] = initTempData;
4567             customBase.setItemValue(itemId, "dropdownlistText", initTempData, "customViewUEditorCss", dropdowntype);
4568             customShow.setShowItem(itemId, "dropdownlistText", initTempData);
4569         } else {
4570             if (customShow.options.customItemShow.item[itemId].tag_Attribute.datasourcetype == "custom") {
4571                 var customItemsTemp = customShow.options.customItemShow.item[itemId].tag_Attribute.custom;
4572                 ////////console.log(customItemsTemp);
4573                 var initTempDataCustom = []
4574                 var j = 0;
4575
4576                 for (var i = 0; i < customItemsTemp.length; i++) {
4577                     if (customItemsTemp[i].ischecked) {
4578                         initTempDataCustom[j] = customItemsTemp[i].itemtext;
4579                         j++;
4580                         // ////////console.log(customItems[i].itemtext);
4581                         // ////////console.log(customItems[i]);
4582                     }
4583                 }
4584                 ////////console.log(initTempDataCustom);
4585                 if (customShow.options.customItemShow.item[itemId].tag_Attribute.dropdowntype == "single") {
4586                     customBase.setItemValue(itemId, "dropdownlistText", [initTempDataCustom[0]], "customViewUEditorCss", dropdowntype);
4587                 } else {
4588                     customBase.setItemValue(itemId, "dropdownlistText", initTempDataCustom, "customViewUEditorCss", dropdowntype);
4589                 }
4590             }
4591         }
4592     }
4593     setCustomradio = function (itemId, listData) {
4594         var tag_Type = customItems[itemId].tag_Type;
4595         customBase.options.dropdownlistText[itemId] = listData;
4596         $('.customViewUEditorCss #' + itemId).removeClass('select2Maxheight').addClass('select2Maxheight');
4597         var item = $('.customViewUEditorCss #' + itemId + " .line");
4598         var oNodeclass = "custom-check";
4599         if (tag_Type == "radio") {
4600             oNodeclass = "custom-radio";
4601         } else if (tag_Type == "checkbox") {
4602             oNodeclass = "custom-check";
4603         }
4604         var oNode = "";
4605         var customItemsData = customBase.options.customItems;
4606         for (data in customItemsData) {
4607             // console.log(customBase.options.customItems[data]);
4608             // console.log(itemId);
4609             for (var i = 0; i < listData.length; i++) {
4610                 if (customBase.options.customItems[data].id == itemId) {
4611                     //   11/9  李元杰 是否有选中
4612                     console.log(customBase.options.customItems[data])
4613                     var curFlag = '';
4614                     if(listData[i].ischecked){
4615                         curFlag = 'cur'
4616                     }
4617                     if (customBase.options.customItems[data].editable) {
4618                         oNode += '<li class="ui-state-default" style="height:28px"><span class="' + oNodeclass + ' ' + curFlag +' " value="' + listData[i].value + '" ><i class="label"></i>' + listData[i].text + '</span></li>';
4619                     } else {
4620                         oNode += '<li class="ui-state-default" style="height:28px"><span class="' + oNodeclass + ' ' + curFlag +' readonly" value="' + listData[i].value + '" ><i class="label"></i>' + listData[i].text + '</span></li>';
4621                     }
4622                     // }else{
4623                     //   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>';
4624                 }
4625             };
4626             // if(customBase.options.customItems[data].id == itemId ){
4627             // //    console.log(listData);
4628
4629             // }
4630         }
4631         for (var i = 0; i < $(item).length; i++) {
4632             // item.empty();
4633             $($(item)[i]).empty();
4634             $(item)[i].innerHTML = oNode;
4635         }
4636         customShow.clickBindSubform();
4637         //数据加载
4638         var initTempData = customShow.options.initTempDatas[itemId];
4639         if (initTempData != undefined) {
4640             var parentsubFormNum = customShow.options.customItemShow.item[itemId].parentsubFormNum;
4641             initTempData = customShow.dbItemToShowItem(itemId, tag_Type, initTempData, "customViewUEditorCss", '', parentsubFormNum);
4642             // customShow.options.initTempDatas[itemId] = initTempData;
4643             customBase.setItemValue(itemId, tag_Type, initTempData, "customViewUEditorCss");
4644             customShow.setShowItem(itemId, tag_Type, initTempData);
4645         }
4646         console.log($(item))
4647         //  12/11 禁用背景
4648         var spanDiv = $(item).find('li').find('span');
4649         console.log($(item).parent().attr('editable'))
4650         if (($(item).parent().attr('editable') == "true")) {
4651             $(item).find('li').find('span').addClass("disableUrl");
4652             for (var i = 0; i < spanDiv.length; i++) {
4653                 console.log($(spanDiv[i]))
4654                 if (tag_Type == "radio") {
4655                     $(spanDiv[i]).removeClass("disableRadUrl");
4656                 } else if (tag_Type == "checkbox") {
4657                     $(spanDiv[i]).removeClass("disableChkUrl");
4658                 }
4659             }
4660         } else {
4661             for (var i = 0; i < spanDiv.length; i++) {
4662                 console.log($(spanDiv[i]))
4663                 if (tag_Type == "radio") {
4664                     $(spanDiv[i]).addClass("disableRadUrl");
4665                 } else if (tag_Type == "checkbox") {
4666                     $(spanDiv[i]).addClass("disableChkUrl");
4667                 }
4668
4669             }
4670         }
4671     }
4672     setTree = function (itemId, setting, listData) {
4673         $('.customViewUEditorCss  #' + itemId + "tree").empty();
4674         // 在这里设置 树的id 和 listData
4675         customShow.listData[itemId] = listData;
4676         customShow.itemId = itemId
4677         var treeDiv = $('div#' + itemId);
4678         if (treeDiv.length != 1) {
4679             for (var i = 0; i < treeDiv.length - 1; i++) {
4680                 var ultreeId = $(treeDiv[i]).find('ul').attr('id');
4681                 ultreeId = ultreeId.split('tree')[0] + 'tree';
4682                 $(treeDiv[i]).find('ul').attr('id', ultreeId + i);
4683                 $.fn.zTree.init($($('.customViewUEditorCss  #' + itemId + "tree" + i)), setting, listData);
4684                 // $('#'+itemId).parents('div[name="TreeWin"]').find('.citySel').addClass('disableColor')
4685                 console.log('#' + itemId);
4686                 var treeObj = $.fn.zTree.getZTreeObj(itemId + "tree" + i);
4687                 // customShow.setTree.disableParentNode.set(treeObj);
4688                 if (treeObj) {
4689                     treeObj.expandAll(true);
4690                 }
4691             }
4692         } else {
4693             $.fn.zTree.init($($('.customViewUEditorCss  #' + itemId + "tree")), setting, listData);
4694             var treeObj = $.fn.zTree.getZTreeObj(itemId + "tree");
4695             var treeDefaultSet;
4696             if (treeObj) {
4697                 treeObj.expandAll(true);
4698             }
4699             var defaultValue = $('#' + itemId).attr('defaultvalue');
4700             var dataObj, defaultValue;
4701             var treeDefaultSet = customShow.treeDefaultSet(treeObj, defaultValue)
4702             defaultValue = treeDefaultSet[0]
4703             dataObj = treeDefaultSet[1];
4704             $('#' + itemId).attr('value', JSON.stringify(dataObj))
4705             $('#' + itemId).prev().find('.citySel').val(defaultValue);
4706             //  12/8 禁止选中  李元杰'
4707             console.log(itemId)
4708             var treeArray = _.filter(customShow.options.customItemShow.item, ['tag_Type', 'tree'])
4709             for (var i = 0; i < treeArray.length; i++) {
4710                 if (treeArray[i].tag_Id == itemId) {
4711                     if (treeArray[i].tag_Attribute.disableParentNode) {
4712                         customShow.setTree.disableParentNode.set(treeObj)
4713                     }
4714                 }
4715             }
4716         }
4717         var initTempData = customShow.options.initTempDatas[itemId];
4718
4719         var defaultValue = $('#' + itemId).attr('defaultvalue');
4720         if (initTempData == 'undefined' || initTempData == undefined) {
4721             if (defaultValue != '' && defaultValue != 'undefined' && defaultValue != undefined) {
4722                 initTempData = defaultValue;
4723             } else {
4724                 initTempData = ' '
4725             }
4726         }
4727         // 010110001000010000010000001
4728         if (initTempData != undefined) {
4729             customBase.setItemValue(itemId, "tree", initTempData, "customViewUEditorCss");
4730         }
4731         customShow.clickBindSubform();
4732     }
4733
4734
4735
4736
4737     //API数据
4738     setApiDatasource = function (item, callback) {
4739         console.log(item)
4740         var apiUrl = item.tag_Attribute.apiUrl;
4741         var callbackId = item.tag_Id;
4742         callbackApiData = function (itemData, url) {
4743
4744             console.log(url)
4745             var ItemId = url.split("callbackId=")[1];
4746             console.log(url)
4747             var item = customShow.options.customItemShow.item[ItemId];
4748             var apiIdKey = item.tag_Attribute.apiIdKey;//  表示项
4749             var apiPIdKey = item.tag_Attribute.apiPIdKey;// 表示值
4750             itemData = itemData.data;
4751
4752             things = [];
4753             console.log(itemData);
4754             // var textcolumn = itemData[apiIdKey];
4755
4756             // var valuecolumn = itemData[apiPIdKey];
4757             // //取得数据长度不一致时数据不设定
4758             // if (textcolumn.length != valuecolumn.length) {
4759             //     return;
4760             // }
4761             if (item.tag_Type == 'radio' || item.tag_Type == 'checkbox') {
4762                 for (var i = 0; i < itemData.length; i++) {
4763                     if (i == 0 && item.tag_Type == 'radio') {
4764                         things[i] = { ischecked: true, value: itemData[i][apiPIdKey], text: itemData[i][apiIdKey] };
4765                     } else {
4766                         things[i] = { ischecked: false, value: itemData[i][apiPIdKey], text: itemData[i][apiIdKey] };
4767                     }
4768                 };
4769             } else if (item.tag_Type == 'tree') {
4770                 var apiName = item.tag_Attribute.apiName;
4771                 console.log(apiName)
4772                 // var namecolumn = itemData[apiName];
4773                 // if (textcolumn.length != namecolumn.length) {
4774                 //     return;
4775                 // }
4776                 for (var i = 0; i < itemData.length; i++) {
4777                     things[i] = { id: itemData[i][apiIdKey], pId: itemData[i][apiPIdKey], name: itemData[i][apiName] };
4778                 };
4779             } else {
4780                 console.log(itemData)
4781
4782                 for (var i = 0; i < itemData.length; i++) {
4783                     console.log(itemData[i])
4784                     console.log(apiPIdKey)
4785                     console.log(apiIdKey)
4786                     console.log(itemData[i][apiPIdKey])
4787                     console.log(itemData[i][apiIdKey])
4788                     things[i] = { id: i, value: itemData[i][apiPIdKey], text: itemData[i][apiIdKey] };
4789
4790                 };
4791             }
4792             console.log(things);
4793             callback(ItemId, things);
4794         }
4795
4796         customDataBound.getApiDatasource(apiUrl, callbackId, callbackApiData);
4797     }
4798     //主数据
4799     setMasterData = function (item, callback) {
4800         var callbackId = item.tag_Id;
4801         var code = item.tag_Attribute.masterData;
4802         console.log(code);
4803         //  11/9
4804
4805
4806
4807         console.log(callbackId)
4808         //   if(code == ""){
4809         //     return;
4810         //   }
4811         callbackMasterData = function (itemid, itemData) {
4812             things = [];
4813             console.log('√')
4814             console.log(itemData);
4815             console.log(itemid);
4816             var customItems = customBase.options.customItems;
4817             for (item in customItems) {
4818                 if (customBase.options.customItems[item].id == callbackId) {
4819
4820                 }
4821             }
4822             item = customShow.options.customItemShow.item[itemid];
4823             if (item.tag_Type == 'radio' || item.tag_Type == 'checkbox') {
4824                 for (var i = 0; i < itemData.length; i++) {
4825                     if (i == 0 && item.tag_Type == 'radio') {
4826                         things[i] = { ischecked: true, value: itemData[i].code, text: itemData[i].value };
4827                     } else {
4828                         things[i] = { ischecked: false, value: itemData[i].code, text: itemData[i].value };
4829                     }
4830                 };
4831             } else if (item.tag_Type == 'tree') {
4832                 //-------------------------
4833                 console.log(itemData)
4834                 if (itemData != null) {
4835                     for (var i = 0; i < itemData.length; i++) {
4836                         things[i] = {
4837                             id: itemData[i].code,
4838                             pId: itemData[i].pid,
4839                             name: itemData[i].value
4840                         };
4841                     };
4842                 }
13ec33 4843
4d1219 4844             } else if (item.tag_Type == 'dropdownlist') {
B 4845                 if(itemData != undefined && !_.isNull(itemData)){
4846                    for (var i = 0; i < itemData.length; i++) {
4847                         things[i] = { id: i, value: itemData[i].code, text: itemData[i].value };
4848
13ec33 4849                     };
4d1219 4850                 }
B 4851             } else {
4852                 //其他控件主数据--
4853             }
4854             callback(itemid, things);
4855         }
4856
4857         //数据源数据取得
4858         customDataBound.getElement(code, callbackId, function (rs) {
4859             // 修改下拉框样式统一
4860             if (rs.data == null) {
4861                 callbackMasterData(callbackId, []);
4862             }
4863             for (itemid in rs.data) {
4864                 if (rs.data.hasOwnProperty(itemid)) {
4865                     callbackMasterData(itemid, rs.data[itemid]);
4866                 }
4867             }
4868
4869
4870         });
4871     }
4872     //数据源
4873     setDatasource = function (item, callback) {
4874         var temp = {};
4875         datasourceName = item.tag_Attribute.datasource;
4876         if (datasourceName == "") {
4877             return;
4878         }
4879         if (customShow.options.datasource[datasourceName] == undefined) {
4880             return;
4881         }
4882         temp.columnNames = item.tag_Attribute.textcolumn + "," + item.tag_Attribute.valuecolumn;
4883         temp.datasource = customShow.options.datasource[datasourceName].datasource;
4884         temp.databaseName = customShow.options.datasource[datasourceName].databaseName;
4885         temp.callbackId = item.tag_Id;
4886         if (item.tag_Type == 'tree') {
4887             temp.columnNames += "," + item.tag_Attribute.namecolumn;
4888         }
4889
4890         callbackDatasource = function (rs) {
4891             console.log(this);
4892             console.log(this.url);
4893             var ItemId = this.url.split("callbackId=")[1];
4894
4895             item = customShow.options.customItemShow.item[ItemId];
4896
4897             datasourceName = rs.data;
4898
4899             things = [];
4900             var textcolumn = datasourceName[item.tag_Attribute.textcolumn];
4901             var valuecolumn = datasourceName[item.tag_Attribute.valuecolumn];
4902             if (item.tag_Type == 'radio' || item.tag_Type == 'checkbox') {
4903                 for (var i = 0; i < textcolumn.length; i++) {
4904                     if (i == 0 && item.tag_Type == 'radio') {
4905                         things[i] = { ischecked: true, value: valuecolumn[i], text: textcolumn[i] };
4906                     } else {
4907                         things[i] = { ischecked: false, value: valuecolumn[i], text: textcolumn[i] };
4908                     }
4909                 };
4910             } else if (item.tag_Type == 'tree') {
4911                 var namecolumn = datasourceName[item.tag_Attribute.namecolumn];
4912                 for (var i = 0; i < valuecolumn.length; i++) {
4913                     things[i] = { id: valuecolumn[i], pId: textcolumn[i], name: namecolumn[i] };
4914                 };
4915
4916             } else {
4917                 for (var i = 0; i < valuecolumn.length; i++) {
4918                     things[i] = { id: i, value: valuecolumn[i], text: textcolumn[i] };
4919
4920                 };
4921             }
4922
4923             callback(ItemId, things);
4924         }
4925
4926         //数据源数据取得
4927         customDataBound.getFieldDatasource(temp, callbackDatasource);
4928     }
4929     //自定义数据 ------1001--------
4930     setCustom = function (item, callback) {
4931         var custom = item.tag_Attribute.custom;
4932         things = [];
4933         if (item.tag_Type == 'radio' || item.tag_Type == 'checkbox') {
4934             for (var i = 0; i < custom.length; i++) {
4935                 things[i] = { ischecked: custom[i].ischecked, value: custom[i].itemtext, text: custom[i].itemtext };
4936             };
4937
4938         } else {
4939             for (var i = 0; i < custom.length; i++) {
4940                 things[i] = { id: i, value: custom[i].itemtext, text: custom[i].itemtext };
4941             };
4942         }
4943         var ItemId = customItem.id;
4944         callback(ItemId, things);
4945     }
4946
4947     //树 单选按钮 多选按钮 下拉菜单
4948     var type = customItems[customItem.id].tag_Type;
4949     if (type == 'dropdownlist' || type == 'radio' || type == 'checkbox' || type == 'tree') {
4950         //数据取得顺序
4951         //按照 选择的情况? 按照主数据?TODO
4952         var item = customShow.options.customItemShow.item[customItem.id];
4953
4954         //数据清空
4955         if (type == 'dropdownlist') {
4956             $($('.customViewUEditorCss #' + customItem.id)[0]).empty();
4957             $($($('.customViewUEditorCss #' + customItem.id)[0]).parentNode).find(".select2").remove();
4958             var visibleTemp = customShow.options.customItemShow.item[customItem.id].tag_Attribute.visible;
4959             if (!visibleTemp) {
4960                 $($($('.customViewUEditorCss #' + customItem.id)[0]).parentNode).remove();
4961                 return;
4962             } else {
4963                 $('.customViewUEditorCss #' + customItem.id).select2({ theme: "classic", width: '240' });
4964             }
4965         } else if (type == 'radio' || type == 'checkbox') {
4966             //  var item = $('.customViewUEditorCss #'+customItem.id +" .line");
4967             $($($('.customViewUEditorCss #' + customItem.id + " .line"))[0]).empty();
4968         }
4969
4970         var datasourcetype = item.tag_Attribute.datasourcetype;
4971         //    ////console.log(datasourcetype);
4972         console.log(item);
4973         console.log(datasourcetype);
4974         setDataItem[datasourcetype](item, setCallbackItem);
4975         // _.each($(".customShow .tdContentClass"), opt => {
4976         //     // $(opt).attr("title", $(opt).children().children().html());
4977         //     console.log($(opt).html())
4978         //     if ($(opt).children().children().attr("type") == "text") {
4979         //         $(opt).attr("title", $(opt).children().children().val());
4980         //     } else {
4981         //         console.log(_.cloneDeep($(opt).children().children()))
4982         //         console.log(opt.innerHTML)
4983         //         console.log($(opt).children().children()[0].innerHTML)
4984         //         $(opt).attr("title", $(opt).children().children()[0].innerHTML);
4985         //     }
4986         // })
4987     }
4988     // return itemData;
4989     // _.each($(".customShow .tdContentClass"), opt => {
4990     //     // $(opt).attr("title", $(opt).children().children().html());
4991     //     console.log($(opt).html())
4992     //     if ($(opt).children().children().attr("type") == "text") {
4993     //         $(opt).attr("title", $(opt).children().children().val());
4994     //     } else {
4995     //         console.log(_.cloneDeep($(opt).children().children()))
4996     //         console.log(opt.innerHTML)
4997     //         console.log($(opt).children().children()[0].innerHTML)
4998     //         $(opt).attr("title", $(opt).children().children()[0].innerHTML);
4999     //     }
5000     // })
5001 }
5002 //  12/7  设置默认值
5003 customShow.treeDefaultSet = function (treeObj, defaultValue) {
5004     var objValue = {};
5005     var defaultValueArray = [];
5006     var valueData;
5007     var dataObj = {};
5008     var dataObjArray = []
13ec33 5009     //  12/7 树的默认值
4d1219 5010     //  判断单选多选
B 5011     // if(defaultValue.indexOf(',') == -1){
13ec33 5012     if(defaultValue){
4d1219 5013         //  单选
13ec33 5014         if (defaultValue.indexOf(',') == -1) {
4d1219 5015             var nodes = treeObj.getNodeByParam("id", defaultValue, null);
B 5016             if (!_.isNull(nodes)) {
5017                 // 2017 /11/6 选中
5018                 //选择节点设定
5019                 treeObj.checkNode(nodes, true, true);
5020                 treeObj.expandAll(true);
5021                 dataObj[defaultValue] = '1';
5022                 if (defaultValue == nodes.id) {
5023                     defaultValue = nodes.name;
5024                 }
5025             }
5026         } else {   //多选
5027             defaultValueArray = defaultValue.split(',');
5028             for (var i = 0; i < defaultValueArray.length; i++) {
5029                 valueData = defaultValueArray[i]
5030                 dataObj[valueData] = '1'
5031             }
5032             for (var i = 0; i < defaultValueArray.length; i++) {
5033                 var nodes = treeObj.getNodeByParam("id", defaultValueArray[i], null);
5034                 if (!_.isNull(nodes)) {
5035                     // 2017 /11/6 选中
5036                     //选择节点设定
5037                     treeObj.checkNode(nodes, true, true);
5038                     treeObj.expandAll(true);
5039                     if (defaultValueArray[i] == nodes.id) {
5040                         defaultValueArray[i] = nodes.name;
5041                     }
5042                 }
5043             }
5044             defaultValue = defaultValueArray.join(',')
5045         }
5046         console.log(dataObj)
5047         objValue[0] = defaultValue;
5048         objValue[1] = dataObj;
5049     }
5050     return objValue;
5051     // }
5052 }
5053
5054 //画面表示项目一览取得
5055 customShow.getItemsList = function () {
5056
5057     var items = customShow.options.customItemShow.item;
5058     var itemsList = {};
5059
5060     for (i in items) {
5061         if (items.hasOwnProperty(i)) {
5062             var item = items[i];
5063             itemsList[item.tag_Attribute.alias] = {
5064                 fieldKey: item.tag_Attribute.alias,
5065                 id: item.tag_Id,
5066                 type: item.tag_Type,
5067                 parentsubFormNum: item.parentsubFormNum,
5068                 visible: item.tag_Attribute.visible,  //可见
5069                 editable: item.tag_Attribute.editable, //可编辑
5070                 mustcheck: item.tag_Attribute.mustcheck, //必填
5071                 approvalmustenter: item.tag_Attribute.approvalmustenter,//审查必须
5072                 defaultvalue: item.tag_Attribute.defaultvalue,
5073                 // field:"",
5074             }
5075             console.log(item.tag_Attribute.defaultvalue)
5076         }
5077     };
5078     return itemsList;
5079 }
5080
5081 // 子表单事件调用
5082 customShow.clickBindSubform = function () {
5083     // 单选框
5084     $('.select .custom-radio').unbind();
5085     $('.select .custom-radio').on('click', function () {
5086         // //////////console.log(this.className);
5087         if (this.className.indexOf("readonly") > -1) {
5088             return;
5089         }
5090         $($(this).parent().parent()).find(".cur").removeClass('cur');
5091         $(this).addClass('cur').siblings().removeClass('cur');
5092     });
5093     customLinkageAnalysis.bindLinkageSubform("radio");
5094     // 多选框
5095     $('.select .custom-check').unbind();
5096     $('.select .custom-check').on('click', function () {
5097         if (this.className.indexOf("readonly") > -1) {
5098             return;
5099         }
5100         $(this).toggleClass('cur');
5101         // $($(this).parent().parent().parent().parent()).find(".errorItemCss").removeClass('errorItemCss');
5102         // //////////console.log($($(this).parent().parent().parent())[0].id);
5103         // var id = $($(this).parent().parent().parent())[0].id;
5104         // $("#"+id+"mesageErrDiv").remove();
5105         // $(".customViewUEditorCss  #"+id).popover('hide')
5106     });
5107     customLinkageAnalysis.bindLinkageSubform("checkbox");
5108     //删除子表单项目
5109     $('.divshowEditor .iconfontcolorTH').unbind();
5110     $('.divshowEditor .iconfontcolorTH').on('click', function () {
5111         ////////////////console.log($(this).parent().parent().parent());
5112         $(this).parent().parent().parent().parent().parent().remove();
5113     });
5114     $('.iconfontcolor').unbind();
5115     $('.iconfontcolor').on('click', function () {
5116         $(this).parent().parent().parent().remove();
5117     });
5118
5119     //-----------------日期类型------------------------
5120     // $('.dateFromyyyy').unbind();
5121     // $('.dateFromyyyymm').unbind();
5122     // $('.dateFromyyyymmdd').unbind();
5123     // $('.dateFromhhmiss').unbind();
5124     // Flatpickr.localize(Flatpickr.l10ns.zh); // 设置为中文
5125     flatpickr('.customViewUEditorCss .dateFromyyyy', {
5126         dateFormat: "Y",
5127     });
5128     flatpickr('.customViewUEditorCss .dateFromyyyymm', {
5129         dateFormat: "Y-m",
5130     });
5131     flatpickr('.customViewUEditorCss .dateFromyyyymmdd', {
5132         dateFormat: "Y-m-d",
5133     });
5134     flatpickr('.customViewUEditorCss .dateFromhhmiss', {
5135         dateFormat: "Y-m-d H:i",
5136         time_24hr: true,
5137         enableTime: true
5138     });
5139     // customLinkageAnalysis.bindLinkageSubform("calendar");
5140 }
5141
5142 //各控件初期
5143 customShow.controlInit = function (showClass) {
5144
5145     var customItems = customBase.options.customItems;
5146     console.log(customItems)
5147     if ('customShow' != showClass) {
5148         //HTML内容控件初期化
5149         var htmlediterShow = $(".customViewUEditorCss .htmlediterShowClass");
5150
5151         for (var i = 0; i < htmlediterShow.length; i++) {
5152             var itemId = htmlediterShow[i].id;
5153             var htmlediterShowItemId = itemId.replace("Item", "");
5154             // var heightShow = htmlediterShow[i].getAttribute("heightShow");
5155             // var widthShow = htmlediterShow[i].getAttribute("widthShow");
5156             // ////////console.log(customShow.options.customItemShow.item[htmlediterShowItemId].tag_Attribute.alias);
5157             var heightShow = customShow.options.customItemShow.item[htmlediterShowItemId].tag_Attribute.height;
5158             var widthShow = customShow.options.customItemShow.item[htmlediterShowItemId].tag_Attribute.width;
5159             // customShow.options.customItemShow.item[itemId].tag_Attribute.alias;
5160             if (widthShow == undefined || heightShow == undefined) {
5161                 widthShow = 200;
5162                 heightShow = 200;
5163             }
5164
5165             customShow.options.htmlediterShow[itemId] = {};
5166             customShow.options.htmlediterShow[itemId].widthShow = widthShow;
5167             customShow.options.htmlediterShow[itemId].heightShow = heightShow;
5168
5169
5170             UE.getEditor(itemId, {
5171                 // serverUrl :url,
5172                 //allowDivTransToP: false,//阻止转换div 为p
5173                 toolleipi: true,//是否显示,设计器的 toolbars
5174                 textarea: 'design_content',
5175                 //这里可以选择自己需要的工具按钮名称,此处仅选择如下五个
5176                 toolbars: [[
5177                     'source', '|', 'bold', 'underline', 'strikethrough', 'forecolor', 'backcolor','removeformat']],
5178                 //关闭字数统计
5179                 wordCount: false,
5180                 //关闭elementPath
5181                 elementPathEnabled: false,
5182                 //默认的编辑区域高度
5183                 initialFrameHeight: heightShow,
5184                 scaleEnabled: true,
5185                 //高度
5186                 // initialFrameHeight:heightShow,
5187                 // readonly:true,
5188                 //,iframeCssUrl:"css/bootstrap/css/bootstrap.css" //引入自身 css使编辑器兼容你网站css
5189                 //更多其他参数,请参考ueditor.config.js中的配置项
5190             }).ready(function () {
5191                 ////////////console.log(customBase.options.customItems);
5192                 id = this.key;
5193                 for (i in customBase.options.customItems) {
5194                     if (customBase.options.customItems.hasOwnProperty(i)) {
5195                         var idItem = id.replace("Item", "");
5196                         if (customBase.options.customItems[i].id == idItem) {
5197                             if (customShow.options.itemFormbase == "") {
5198                                 UE.getEditor(id).setContent(customBase.options.customItems[i].defaultvalue);
5199                             } else {
5200                                 var defaultvalue = customShow.options.itemFormbase[i];
5201                                 //  ////////console.log(defaultvalue);
5202                                 //  defaultvalue=defaultvalue+" ";
5203                                 UE.getEditor(id).setContent(defaultvalue);
5204                                 //  setTimeout(function() {
5205                                 //       // this.body.focus();
5206                                 //       ////////console.log(UE.getEditor(id));
5207                                 //       UE.getEditor(id).options.scaleEnabled =false;
5208                                 //   }, 1000);
5209                             }
5210                         }
5211                         //非表示
5212                         //  if(!customBase.options.customItems[i].visible){
5213                         //     $(".customViewUEditorCss #"+id).addClass("cfg_contentNone");
5214                         //  }
5215                     }
5216                 }
5217                 $(".edui-editor-bottomContainer").addClass("cfg_contentNone");
5218                 this.body.onclick = function (event, ui) {
5219                     //////////console.log(this);
5220                     //////////console.log(this.getAttribute("id"));
5221                     // $(this).removeClass("errorItemCss");
5222                     // $("#"+this.getAttribute("id")+"mesageErrDiv").remove();
5223                 }
5224             })
5225         };
5226     }
5227     //-----------------日期类型------------------------
5228
5229     flatpickr('.customViewUEditorCss .dateFromyyyy', {
5230         dateFormat: "Y",
5231     });
5232     flatpickr('.customViewUEditorCss .dateFromyyyymm', {
5233         dateFormat: "Y-m",
5234     });
5235     flatpickr('.customViewUEditorCss .dateFromyyyymmdd', {
5236         dateFormat: "Y-m-d",
5237     });
5238     flatpickr('.customViewUEditorCss .dateFromhhmiss', {
5239         dateFormat: "Y-m-d H:i",
5240         time_24hr: true,
5241         enableTime: true
5242     });
5243
5244     if ('customShow' != showClass) {
5245         //删除项目(select2项目删除)
5246         $('.selection').remove();
5247         $(".ztree").empty();
5248     }
5249     //下拉列表初期化
5250
5251     // $(".dropdowntypeCss").select2({theme: "classic",width: '240'});
5252     // //下拉列表不可用
5253     $('.' + showClass + " .editableDisabled").prop("disabled", true);
5254
5255     // 金融控件
5256     for (item in customItems) {
5257         if (customItems.hasOwnProperty(item)) {
5258             //金融控件
5259             if (customItems[item].type == "amount") {
5260                 if ("customViewUEditorCss" == showClass) {
5261                     var itemId = customItems[item].id;
5262                     // var itemValue = $('.'+showClass +" #"+itemId)[0].getAttribute("defaultvalue");
5263                     var showCustomItem = customShow.options.customItemShow.item[itemId];
5264                     // var itemValue = $('.'+showClass +" #"+itemId)[0].getAttribute("qrcodeurl");
5265                     // var widthQrcode = $("#"+customItems[item].id)[0].width;
5266                     var itemValue = showCustomItem.tag_Attribute.defaultvalue;
5267                     var widthQrcode = showCustomItem.tag_Attribute.width;
5268                     if (widthQrcode == 0 || widthQrcode == undefined) {
5269                         widthQrcode = 60;
5270                     }
5271                     var divIcons = document.createElement("input");
5272                     divIcons.setAttribute("type", "text");
5273                     divIcons.setAttribute("id", customItems[item].id + "amount");
5274                     divIcons.setAttribute("style", "width: " + widthQrcode + "px; height:33px");
5275                     divIcons.setAttribute("class", "amountShowTextClass cfg_contentNone");
5276                     divIcons.setAttribute("value", itemValue);
5277                     $('.' + showClass + " #" + itemId)[0].after(divIcons);
5278                     $('.' + showClass + " #" + itemId).addClass("amountShowClass");
5279                 }
5280                 //申请单
5281             }
5282             else if (customItems[item].type == "mytext") {
5283                 if ("customViewUEditorCss" == showClass) {
5284                     var itemId = customItems[item].id;
5285                     ////console.log(itemId);
5286                     var showCustomItem = customShow.options.customItemShow.item[itemId];
5287                     // var itemValue = $('.'+showClass +" #"+itemId)[0].getAttribute("qrcodeurl");
5288                     // var widthQrcode = $("#"+customItems[item].id)[0].width;
5289                     var itemValue = showCustomItem.tag_Attribute.qrcodeurl;
5290                     var widthQrcode = showCustomItem.tag_Attribute.width;
5291                     if (widthQrcode == 0 || widthQrcode == undefined) {
5292                         widthQrcode = 60;
5293                     }
5294                     var divIcons = document.createElement("div");
5295                     var div = document.createElement("div");
5296                     divIcons.setAttribute("id", customItems[item].id + "qrcode");
5297                     divIcons.setAttribute("class", "boxBtn");
5298                     divIcons.setAttribute("myAttr", itemId);
5299                     divIcons.innerHTML = '选择数据';
5300                     divIcons.setAttribute("maxlength", 200);
5301                     $('.' + showClass + " #" + itemId).eq(0).after(divIcons);
5302                     //        $(" #"+itemId+"divid")[0].after(divIcons);
5303                 }
5304                 //二维码
5305             } else if (customItems[item].type == "qrcode") {
5306                 if ("customViewUEditorCss" == showClass) {
5307                     var itemId = customItems[item].id;
5308                     var showCustomItem = customShow.options.customItemShow.item[itemId];
5309                     // var itemValue = $('.'+showClass +" #"+itemId)[0].getAttribute("qrcodeurl");
5310                     // var widthQrcode = $("#"+customItems[item].id)[0].width;
5311                     var itemValue = showCustomItem.tag_Attribute.qrcodeurl;
5312                     var widthQrcode = showCustomItem.tag_Attribute.width;
5313                     if (widthQrcode == 0 || widthQrcode == undefined) {
5314                         widthQrcode = 165;
5315                     }
5316                     var divIcons = document.createElement("input");
5317                     divIcons.setAttribute("type", "text");
5318                     divIcons.setAttribute("id", customItems[item].id + "qrcode");
5319                     divIcons.setAttribute("style", "width: " + widthQrcode + "px;height:33px");
5320                     divIcons.setAttribute("class", "qrcodeShowTextClass cfg_contentNone");
5321                     divIcons.setAttribute("value", itemValue);
5322                     divIcons.setAttribute("maxlength", 200);
5323                     $('.' + showClass + " #" + itemId)[0].after(divIcons);
5324                     $('.' + showClass + " #" + itemId).addClass("qrcodeShowClass");
5325                 }
5326                 //条形码
5327             } else if (customItems[item].type == "barcode") {
5328                 if ("customViewUEditorCss" == showClass) {
5329                     var itemId = customItems[item].id;
5330                     // var itemValue = $('.'+showClass +" #"+itemId)[0].getAttribute("text");
5331                     // var widthBarcode = $("#"+customItems[item].id)[0].width;
5332                     var showCustomItem = customShow.options.customItemShow.item[itemId];
5333                     // var itemValue = $('.'+showClass +" #"+itemId)[0].getAttribute("qrcodeurl");
5334                     // var widthQrcode = $("#"+customItems[item].id)[0].width;
5335                     var itemValue = showCustomItem.tag_Attribute.text;
5336                     var widthBarcode = 165;
5337                     // if(widthBarcode == 0){
5338                     //   widthBarcode = 100;
5339                     // }
5340                     var divIcons = document.createElement("input");
5341                     divIcons.setAttribute("type", "text");
5342                     divIcons.setAttribute("id", customItems[item].id + "barcode");
5343                     divIcons.setAttribute("style", "width: " + widthBarcode + "px;height:33px");
5344                     divIcons.setAttribute("class", "barcodeShowTextClass cfg_contentNone");
5345                     divIcons.setAttribute("value", itemValue);
5346                     divIcons.setAttribute("maxlength", 200);
5347                     $('.' + showClass + " #" + itemId)[0].after(divIcons);
5348                     $('.' + showClass + " #" + itemId).addClass("barcodeShowClass");
5349                 }
5350                 //子表单设定
5351             } else if (customItems[item].type == "subform") {
5352                 var itemId = customItems[item].id;
5353                 var itemTwo = itemId;
5354                 var itemSubform = $('.' + showClass + " #" + itemId + "ActiveId");
5355                 //lym
5356                 //位总div添加id
5357                 $("#" + itemId + "ActiveId").find(".usfile").attr("id", itemTwo + "uld");
5358                 //为a标签添加id
5359                 $("#" + itemId + "ActiveId").find(".usfile a").attr("id", itemTwo + "uis");
5360                 $("#" + itemId + "ActiveId").find(".usfile a").attr("itemId", itemTwo);
5361                 //为inputFile添加id
5362                 $("#" + itemId + "ActiveId").find("#" + itemTwo + "uld form input").attr("itemId", itemTwo);
5363                 $("#" + itemId + "ActiveId").find("#" + itemTwo + "uld form input").attr("id", itemTwo + "btn");
5364                 $("#" + itemId + "ActiveId").find("#" + itemTwo + "uld form").attr("itemId", itemTwo);
5365
5366                 //////////////console.log(item);
5367                 var ulIcon = document.createElement("ul");
5368                 var liIcon = "";
5369                 var m_customItems = customShow.options.customItemShow.item;
5370                 console.log(customBase.options)
5371                 var subItems = [];
5372                 var parentNum = itemId.replace("itemId_", "");
5373                 _.each(m_customItems, opt => {
5374                     if (opt.parentsubFormNum == parentNum) {
5375                         subItems.push(opt);
5376                     }
5377                 })
5378                 console.log(subItems)
5379                 _.remove(subItems, n => {
5380                     return n.tag_Attribute.alias == "DATAROWNUM" || n.tag_Attribute.visible == false;
5381                 });
5382                 //_.sortBy(orderArr, ['fieldOrderNum']);
5383                 subItems = _.sortBy(subItems, ['fieldOrderNum']);
5384                 _.each(subItems, opt => {
5385                     console.log(opt)
5386                     if (opt.tag_Type == "number") {
5387                         liIcon += "<li class='n_totle'><input class='" + opt.tag_Id + "totle textCssDiv defaultHeight' type='text' readonly></li>"
5388                         console.log(1)
5389                     } else {
5390                         liIcon += "<li class='p_totle'></li>"
5391                         console.log(2)
5392                     }
5393                 });
5394                 $(ulIcon).append(liIcon);
5395                 $("#" + itemId + "ActiveId").find(".h_totle").append(ulIcon);
5396                 console.log($("#" + itemId + "ActiveId").find(".h_totle"))
5397                 console.log(ulIcon)
13ec33 5398                 // 单行文本 多行文本 数字  日历
4d1219 5399             } else if (customItems[item].type == "text" || customItems[item].type == "textarea" || customItems[item].type == "number" || customItems[item].type == "calendar") {
B 5400                 var itemId = customItems[item].id;
5401                 var defaultvalue = $("#" + itemId).attr("defaultvalue");
5402                 //  12/4  判断是否存在当前时间
5403                 var calendar = _.filter(customShow.options.customItemShow.item, ['tag_Type', 'calendar'])
5404                 for (var i = 0; i < calendar.length; i++) {
5405                     if (calendar[i].tag_Attribute.currentDate) {
5406                         if (itemId == calendar[i].tag_Id) {
5407                             defaultvalue = customShow.currentDate
5408                         }
5409                     }
5410                 }
5411                 console.log(defaultvalue)
5412                 // 之前表单日历默认值不存在时 12/4
5413                 if (defaultvalue == undefined || defaultvalue == 'undefined') {
5414                     defaultvalue = ''
5415                 }
5416                 customBase.setItemValue(itemId, "text", defaultvalue);
5417                 //数字验证事件追加
5418                 if (customItems[item].type == "number") {
5419                     //数值型控件验证
5420                     $("#" + itemId).unbind('blur');
5421                     $("#" + itemId).on('blur', function (e) {
5422                         var numbertype = $(this)[0].getAttribute("numbertype");
5423                         if (numbertype == "decimal") {
5424                             var decimalplace = $(this)[0].getAttribute("decimalplace");
5425                             decimalplace = parseInt(decimalplace);
5426                             if ($(this)[0].value != "") {
5427                                 $(this)[0].value = Number($(this)[0].value).toFixed(decimalplace);
5428                             }
5429
5430                         }
5431                     });
5432                 }
5433             } else if (customItems[item].type == 'dropdownlist' || customItems[item].type == 'radio' ||
5434                 customItems[item].type == 'checkbox' || customItems[item].type == 'tree') {
5435                 if ('customShow' != showClass) {
5436                     //数据源绑定
5437                     customShow.setDatasourceData(customItems[item]);
5438                 }
5439             } else if (customItems[item].type == 'splitline') {
5440                 //分割线
5441                 var itemId = customItems[item].id;
5442                 $('.' + showClass + " #" + itemId + "ActiveId").addClass("layoutsetting8");
5443             } else if (customItems[item].type == 'tree') {
5444                 var itemId = customItems[item].id;
5445                 var defaultvalue = $("#" + itemId)[0].getAttribute("defaultvalue");
5446
5447                 // 之前表单树形默认值不存在时 12/7
5448                 if (defaultvalue == undefined || defaultvalue == 'undefined') {
5449                     defaultvalue = ''
5450                 }
5451                 customBase.setItemValue(itemId, "text", defaultvalue);
5452             }
5453             //初始属性设定
5454             if (customItems[item].type == 'dropdownlist' || customItems[item].type == 'radio' ||
5455                 customItems[item].type == 'checkbox' || customItems[item].type == 'tree' ||
5456                 customItems[item].type == "text" || customItems[item].type == "textarea" || customItems[item].type == "number"
5457                 || customItems[item].type == "calendar" || customItems[item].type == "fileupload"
5458                 || customItems[item].type == "qrcode" || customItems[item].type == "barcode"
5459                 || customItems[item].type == "htmlediter" || customItems[item].type == "link"
5460                 || customItems[item].type == "subform"
5461             ) {
5462                 console.log(customBase.options.customItems[item])
5463                 customShow.setShowAttribute(customBase.options.customItems[item]);
5464             }
5465             // 12/15
5466             if (customItems[item].type == "link") {
5467                 var linkurl = customShow.costType[customItems[item].id].tag_Attribute.linkurl;
5468                 if(linkurl == ''){
5469                     linkurl = 'javascript:void(0)';
5470                 }
5471                 if(customShow.costType[customItems[item].id].tag_Attribute.editable){//不可编辑控制  李伟民 0124
5472                     $('#'+customItems[item].id).attr('href',linkurl)
5473                 }
5474             }
5475         }
5476     };
5477     //事件追加
5478     customShow.clickBindSubform();
5479
5480 }
5481
5482 //固定事件的绑定
5483 var index_i = 0;
5484 customShow.clickBind = function () {
5485
5486     //子表单事件追加
5487     customShow.clickBindSubform();
5488
5489     //  //保存按钮按下
5490     //  $(".fromSaveCss").on('click', function() {
5491     //     customShow.onclickSave();
5492     //   });
5493
5494     //  //取消按钮按下
5495     //  $(".cancelCss").on('click', function() {
5496     //     customShow.onclickCancel();
5497     //   });
5498
5499
5500     // 子表单添加记录事件
5501
5502     $('.subformAdd').unbind();
5503     function addSubFunc() {
5504         //子表单项目追加
5505         //console.log($(this)[0]);
5506         customShow.addsubformList($(this)[0], "customViewUEditorCss");
5507         //  customShow.setXhSelectListAdd();
5508         //子表单事件追加
5509         customShow.clickBindSubform();
5510         //公式初期化
5511         customLinkageAnalysis.bindLinkage();
5512         customShow.oneTotle();
5513         //console.log($('.subformAdd'));
5514         $('.subformAdd').unbind('click', addSubFunc);
5515         $('.subformAdd').on('click', addSubFunc);
5516         //行程排序初期化
5517         customShow.journeySort();
5518         SC.noBillCheckInit()//无票据行程验证
5519
5520     }
5521     $('.subformAdd').on('click', addSubFunc);
5522
5523     //主数据丢失
5524     //   $('.subformAdd').unbind();
5525     //   $('.subformAdd').on('click', function(){
5526     //       console.log(1)
5527     //     //子表单项目追加
5528     //     customShow.addsubformList($(this)[0],"customViewUEditorCss");
5529     //     //子表单事件追加
5530     //     customShow.clickBindSubform();
5531     //     //公式初期化
5532     //  customLinkageAnalysis.bindLinkage();
5533     //         //行程排序初期化
5534     //          customShow.journeySort();
5535     //   });
5536
5537     //图片文件上传
5538     var uploaderImage = $(".customViewUEditorCss .uploaderImage");
5539     for (var i = 0; i < uploaderImage.length; i++) {
5540
5541         var imageItem = customShow.options.customItemShow.item[uploaderImage[i].id];
5542         var itemList = customBase.options.uploaderItemReady[uploaderImage[i].id];
5543         // 参数设定
5544         var potion = {
5545             id: uploaderImage[i].id,
5546             width: imageItem.tag_Attribute.width,
5547             height: imageItem.tag_Attribute.height,
5548             formid: customShow.options.formid,
5549             imagetype: imageItem.tag_Attribute.dropdowntype, //图片类型
5550             editable: imageItem.tag_Attribute.editable, //是否可编辑
5551             defaultvalueUrl: imageItem.tag_Attribute.defaultvalue, //默认的Url
5552             ItemReady: itemList,
5553             visible:imageItem.tag_Attribute.visible
5554         }
5555         customBase.uploaderShow(potion);
5556         // customBase.uploaderShow("#"+uploaderImage[i].id,{width:0,height:200},true,customShow.options.formid);
5557
5558     };
5559
5560     //lym子表单上传
5561     $('.sonImportFile').unbind();
5562     $(".sonImportFile").click(function () {
5563         console.log("进入点击事件");
5564         //var checkedObj = $("#tbody input[type=checkbox]:checked");
5565         console.log("fdsffddffd");
5566         // //创建文件上传对象
5567         var a = $(this).attr("itemId")
5568         console.log(a)
5569         $("#" + a + "btn").click(
5570
5571         );
5572         $("#" + a + "btn").change(function () {
5573             console.log("uqwhdoqwhdo");
5574             //var objFile = $("#"+itemTwo+"btn");
5575             //改变
5576
5577             let mthis = this;
5578             var tenantId = localStorage.getItem("tenantID");
5579             var formID = localStorage.getItem("newFormID");
5580             var tenant = JSON.parse(tenantId);
5581             var user = localStorage.getItem("userName");
5582             var userName = JSON.parse(user);
5583             var aba = a;
5584             console.log(aba);
13ec33 5585             //结束
4d1219 5586             console.log(tenantId);
B 5587             console.log(formID);
5588             var objFile = $(this);
5589             if (objFile.value == "") {
5590                 return;
5591             } else {
5592                 var f_content = this.value;
5593                 var fileext = f_content.substring(f_content.lastIndexOf("."), f_content.length);
5594                 fileext = fileext.toLowerCase()
5595                 if (fileext != '.xls') {
5596                 } else {
5597                     //改变
5598                     var dataObj = { "formID": formID, "tenantID": tenant.tenantID, "userName": userName.userName, "rowNum": aba }
5599                     //结束
5600
5601                     var options = {
13ec33 5602                         url: url, //上传文件的路径 
4d1219 5603                         type: 'post',
B 5604                         dataObj: dataObj,
5605                         async: false,
5606                         success: function (data) {//异步上传成功之后的操作
5607                             if (data != undefined && data != null) {
5608                                 console.log("返回参数");
5609                             }
5610
5611                         }
5612                     };
5613
5614                     var requestData = window.SonfiledUpload(dataObj, options, "/excel/impSonExcel", $(this).attr("itemId"), fileext);
5615                     var excels = JSON.parse(requestData);
5616                     console.log(requestData);
5617                     //                console.log("最后");
13ec33 5618                     //
4d1219 5619                     //                console.log($(this).attr("itemId"))
B 5620                     //改变
5621                     $(mthis).val("");
5622                     if (excels.data != undefined) {
5623                         customShow.addRow($(this).attr("itemId"), excels.data);
5624                         toastr.info("导入成功");
5625
5626                     } else {
5627                         toastr.error("表格数据格式有误!");
5628                     }
5629                     //结束
5630                     //清除后台返回结果
5631                     window.localStorage.removeItem("seccData");
5632
5633                 }
5634             }
5635         })
5636     });
5637     //文本文件上传
5638     var uploaderFile = $(".customViewUEditorCss .uploaderFile");
5639     console.log(uploaderFile)
5640     for (var i = 0; i < uploaderFile.length; i++) {
5641
5642         var imageItem = customShow.options.customItemShow.item[uploaderFile[i].id];
5643         debugger
5644         var itemList = customBase.options.uploaderItemReady[uploaderFile[i].id];
5645         // 参数设定
5646         var potion = {
5647             id: uploaderFile[i].id,
5648             width: imageItem.tag_Attribute.width,
5649             height: imageItem.tag_Attribute.height,
5650             formid: customShow.options.formid,
5651             imagetype: imageItem.tag_Attribute.dropdowntype, //图片类型
5652             editable: imageItem.tag_Attribute.editable, //是否可编辑
5653             defaultvalueUrl: imageItem.tag_Attribute.defaultvalue, //默认的Url
5654             ItemReady: itemList,
5655             visible:imageItem.tag_Attribute.visible
5656         }
5657         customBase.uploaderFileShow(potion);
5658         // customBase.uploaderShow_Temp("#"+uploaderFile[i].id,{width:0,height:200},false,customShow.options.formid);
5659
5660     };
5661
5662     //必须入力验证
5663     // var mustcheckCss = $(".mustcheckCss");//-----------todo
5664     // for (var i = 0; i < mustcheckCss.length; i++) {
5665     //   ////////////////console.log('#'+$(mustcheckCss)[i].id);
5666     // };
5667
5668     //子表单默认删除项目去掉
5669     //子表单第一行可删除
5670     // $(".iconfontcolor").addClass("cfg_contentNone");
5671     // $(".iconfontcolorTH").addClass("cfg_contentNone");
5672
5673     //金融控件点击事件
5674     $('.amountShowClass').unbind();
5675     $('.amountShowClass').on('click', function () {
5676         var editable = $(this)[0].getAttribute("editable");
5677         //编辑设定
5678         if (editable == "false") {
5679             return;
5680         }
5681
5682
5683         $(this).addClass("cfg_contentNone");
5684         $("#" + $(this)[0].id + "amount").removeClass("cfg_contentNone");
5685         $("#" + $(this)[0].id + "amount").focus();
5686     });
5687
5688     //金融控件点击事件
5689     $('.amountShowTextClass').unbind();
5690     $('.amountShowTextClass').on('blur', function () {
5691         var id = $(this)[0].id;
5692         //表示的控件ID取得
5693         var idTemp = id.replace("amount", "");
5694
5695         var showCustomItem = customShow.options.customItemShow.item[idTemp];
5696         // var widthqrcode = $("#"+idTemp)[0].width;
5697         // var heightqrcode = $("#"+idTemp)[0].height;
5698         var widthqrcode = showCustomItem.tag_Attribute.width;
5699         var heightqrcode = showCustomItem.tag_Attribute.height;
5700         if (heightqrcode == 0 || heightqrcode == undefined) {
5701             heightqrcode = 24;
5702         }
5703         if (widthqrcode == 0 || widthqrcode == undefined) {
5704             widthqrcode = 200;
5705         }
5706
5707         //金额组件
5708         //默认数值
5709         var defaultSize = {
5710             width: widthqrcode,
5711             height: heightqrcode,
5712             defaultvalue: "",
5713             styleclass: ""
5714         };
5715
5716         var decimalplace = $(this)[0].getAttribute("decimalplace");
5717         decimalplace = parseInt(decimalplace);
5718         if ($(this)[0].value != "") {
5719             $(this)[0].value = Number($(this)[0].value).toFixed(decimalplace);
5720         }
5721
5722
5723         defaultSize.defaultvalue = $(this)[0].value.replace(".", "");
5724
5725         var showItem = customBase.getAmountHtml(defaultSize, true);
5726         customBase.amount2Image(showItem, "amount", defaultSize, function (amountHtml) {
5727             // ////////////////console.log(idTemp);
5728             $("#" + idTemp + "amount").addClass("cfg_contentNone");
5729             for (var i = 0; i < $("." + idTemp + "value").length; i++) {
5730                 $("." + idTemp + "value")[i].setAttribute("src", amountHtml);
5731             };
5732             $("#" + idTemp).removeClass("cfg_contentNone");
5733         })
5734     });
5735     var addVal = [];
5736
5737     //申请单控件点击事件
5738     $('.chooseMenu').unbind();
5739     $(".mytext_icon").on("click", function () {
5740         $(this).closest("[type='mytext']").find('.boxBtn').click();
5741         console.log(customShow.options);
5742         console.log(customBase.options);
5743     })
5744     $('.boxBtn').on('click', (obj) => {
5745         console.log(customBase.options)
5746         addVal = [];
5747         //取得父页面变量
5748         var outWindowObj = window.parent;
5749         var $iconId = $(obj)[0].target.getAttribute("myAttr");
5750         var iconAttr = customShow.options.customItemShow.item[$iconId];
5751         console.log(iconAttr);
5752         if ($("#" + $iconId).attr("formhuixian") != undefined) {
5753             var formhuixian = JSON.parse($("#" + $iconId).attr("formhuixian"));
5754         }
5755         //console.log(formhuixian);
5756         let head = "";
5757         if ($(obj)[0].target.previousSibling.getAttribute("chooseForm") != "" || iconAttr.tag_Attribute.relevancesourcetype == "fundata") {
5758             console.log(attrData);
5759             if (iconAttr.tag_Attribute.relevancesourcetype == "fundata") {//函数分支修改 李伟民 12-05
5760                 var titleObj = { "key": JSON.parse(iconAttr.tag_Attribute.fundata)['key'] };
5761                 var requestTitle = window.commonAjax("/datamanagement/getAssociateTitle", titleObj, "POST", true, false);
5762                 requestTitle.done(function (res) {
5763                     var formtitle = [];
5764                     _.each(res.data, function (tdata) {
5765                         formtitle.push({ "fieldKey": tdata.fieldKey, "title": tdata.title });
5766                     });
5767                     head = formtitle;
5768                 });
5769                 var attrData = undefined;
5770             } else {
5771                 var attrData = JSON.parse($(obj)[0].target.previousSibling.getAttribute("chooseForm"));
5772                 head = attrData.huixianObj.chooseData;
5773             }//函数分支修改 李伟民 12-05
5774             // window.localStorage.setItem("bussiness", attrData.formID.bussinessSystem)  //不用了?
5775             //获取id值
5776             //用于验证是否已经存在div
5777             var $divsLength = $('#' + $iconId + 'divIcons').length;
5778             //接收table头请求
5779             var formId = "";
5780             if (attrData && attrData.ScreenCondition != undefined) {
5781                 //下拉框取值
5782                 let getVal = attrData.ScreenCondition.child;
5783                 console.log(getVal);
5784                 _.each(getVal, opts => {
5785                     _.each(customBase.options.customItems, opt => {
5786                         if (opt.fieldKey == opts.fieldKey && opts.side == "thi") {
5787                             opts.value = "";
5788                             if (opt.type == "dropdownlist") {
5789                                 var getVals = customBase.getItemValue(opt.id, "dropdownlistText");
5790                                 console.log(getVals);
5791                                 if (getVals[0][0] != undefined) {
5792                                     opts.value = getVals[0];
5793                                 } else {
5794                                     opts.value = "";
5795                                 }
5796                             } else if (opt.type == "tree") {//树控件 处理  李伟民 12-5
5797                                 var getVals = customBase.getItemValue(opt.id, opt.type);
5798                                 console.log(getVals);
5799                                 if (getVals[0][0] != undefined) {
5800                                     opts.value = getVals[0];
5801                                 } else {
5802                                     opts.value = "";
5803                                 }
5804                             } else {//树控件 处理  李伟民 12-5
5805                                 var getVals = customBase.getItemValue(opt.id, opt.type);
5806                                 console.log(getVals);
5807                                 if (getVals != undefined) {
5808                                     opts.value = getVals;
5809                                 } else {
5810                                     opts.value = "";
5811                                 }
5812                             }
5813                         }
5814                     })
5815                 });
5816                 var sCondition = {};
5817                 //请求数据  筛选条件参数
5818                 let getValue = {};
5819                 getValue.child = getVal;
5820                 getValue.count = attrData.ScreenCondition.count;
5821                 sCondition = getValue;
5822                 let shaixuanData = attrData.ScreenCondition.child;
5823             }
5824             if ((attrData && attrData.huixianObj != undefined) || iconAttr.tag_Attribute.relevancesourcetype == "fundata") {
5825                 if (iconAttr.tag_Attribute.relevancesourcetype == "fundata") {
5826                     formId = undefined;
5827                 } else {
5828                     formId = attrData.formID;
5829                 }
5830                 if ($divsLength == 0) {
5831                     //外层蒙版
5832                     console.log(customShow.options.customItemShow.item)
5833                     console.log($iconId)
5834                     var my_text_title = customShow.options.customItemShow.item[$iconId].tag_Attribute.title;
5835
5836                     var menuContent = document.createElement('div');
5837                     //数据渲染div
5838                     var divIcons = document.createElement('div');
5839                     var pageBox = document.createElement('div');
5840                     var buttonDiv = document.createElement("div");
5841                     var closeBtn = document.createElement("span");
5842                     var requersTable = document.createElement("table");
5843                     var page = document.createElement("div");
5844                     var bigmodule = document.createElement("div");
5845                     var mymodule = document.createElement("div");
5846                     var mymodule2 = document.createElement("div");
5847                     var modal_content = document.createElement("div");
5848                     var mymodulebody = document.createElement("div");
5849                     var mymoduleheader = document.createElement("div");
5850                     var mymodulefooter = document.createElement("div");
5851                     var myinput = document.createElement("input");
5852                     var mybtn = document.createElement("button");
5853                     mybtn.innerHTML = "<i class='fa fa-search'></i>";
5854                     mybtn.setAttribute('class', 'btn btn-default');
5855                     mybtn.setAttribute('onClick', 'showbtn()');
5856                     mybtn.setAttribute('id', 'showserch');
5857                     // 添加搜索
5858                     var serchbox = document.createElement('div');
5859                     var serchpage = document.createElement('div');
5860                     var sersrc = document.createElement('script');
5861                     serchpage.setAttribute('class', 'pagination');
5862                     serchpage.setAttribute('style', 'display:none');
956db4 5863                     sersrc.setAttribute('src', './../../formEngine/resources/js/dataManagement/findmany.js');
4d1219 5864                     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>';
B 5865                     var footer = '<div _ngcontent-c12="" class="btn btn-primary btn-info btn-action closeBtn">确定</div>';
5866                     serchbox.setAttribute('class', 'fui-form hides');
5867                     serchbox.setAttribute('id', 'findserch');
5868                     serchbox.setAttribute('style', 'display:none !important;');
5869                     serchbox.innerHTML = '<div class="search_item">' +
5870                         '<div class="search_column ng-scope" id="copyTemp" style="display: none;">' +
5871                         '<div class="ng-binding" style="font-size:10px;font-weight:700;"></div>' +
5872                         '<span style="display: flex;width: 100%;"></span></div>' +
5873
5874                         '<div class="search_column findbox ng-scope" id="copyTempNumber" style="display: none;">' +
5875                         '<div class="ng-binding" style="font-size:10px;font-weight:700;">预算截止时间</div>' +
5876                         '<span style="display: flex;position:relative;width:45%;"><input id = "numberFrom" class=""  type="number"/></span>' +
5877                         '<span> ~ </span>' +
5878                         '<span style="display: flex;position:relative; width:45%;"><input id = "numberTo" class=""  type="number"/></span></div>' +
5879                         '<div class="search_column ng-scope" id="copyTempTime" style="display: none;">' +
5880                         '<div class="ng-binding" style="font-size:10px;font-weight:700;"> 预算截止时间</div>' +
5881                         '<span style="display: flex; position: relative;width:45%;">' +
5882                         '<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>' +
5883                         '</span><span> ~ </span><span style="display: flex;position:relative;width:45%;">' +
5884                         '<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>' +
5885                         '</span></div><div class="search_column_button search_column_button_box">' +
5886                         '<span><button class="btn btn-info btn-action" id="search_condition"><i class="fa fa-search" aria-hidden="true"></i>&nbsp;&nbsp;查询</button></span>' +
5887                         '</div></div>' +
5888                         '<div class="condition_search_footer" style="display:none">' +
5889                         '<label class="first">' +
5890                         '<span><select class="ng-pristine ng-untouched ng-valid ng-not-empty" id="pageSelect">' +
5891                         '<option value="20" selected="selected">20条/页</option>'
5892                     '<option value="50"> 50条/页</option><option value="100">100条/页</option>' +
5893                         '</select></span><span class="ng-binding">共<span id = "showTotalPageLeft"></span>页</span></label>' +
5894                         '<label class="second"> <div class="pagination">' +
5895                         '<span class="skip first">首页</span><span class="skip pre">上一页</span>' +
5896                         '<div class="nums"></div><span class="skip next">下一页</span>' +
5897                         '<span class="skip last">尾页</span></div></label></div>';
5898                     mymoduleheader.innerHTML = header;
5899                     mymodulefooter.innerHTML = footer;
5900                     mymodule.setAttribute('style', 'width:750px;height: 448px;margin:0 auto;');
5901                     menuContent.setAttribute('id', $iconId + 'menuContent');
5902                     menuContent.setAttribute('class', 'menuContent');
5903                     bigmodule.setAttribute('class', 'bigmodule');
5904                     mymodule.setAttribute('class', 'mymodule');
5905                     mymodule2.setAttribute('class', 'mymodule2 mymodule2_box');
5906                     modal_content.setAttribute('class', 'modal-content modal_content_box');
5907                     mymodulebody.setAttribute('class', 'mymodulebody');
5908                     $(mymodulebody).css({ "height": "485px", "overflow-y": "auto" });
5909                     mymoduleheader.setAttribute('class', 'mymoduleheader');
5910                     mymodulefooter.setAttribute('class', 'mymodulefooter');
5911                     myinput.setAttribute('class', 'myipt');
5912                     divIcons.setAttribute('class', 'mytext');
5913                     divIcons.setAttribute('id', $iconId + 'divIcons');
5914                     page.setAttribute('id', $iconId + 'pageF');
5915                     page.setAttribute('class', 'pageF');
5916                     pageBox.setAttribute('id', $iconId + 'pageBox');
5917                     pageBox.setAttribute('class', 'pageBox');
5918                     buttonDiv.setAttribute("class", "buttonDiv");
5919                     requersTable.setAttribute("class", "requestMenu");
5920                     $('#' + $iconId + 'ActiveId').append(menuContent);
5921                     $('#' + $iconId + 'menuContent').append(bigmodule);
5922                     bigmodule.appendChild(mymodule);
5923                     mymodule.appendChild(mymodule2);
5924                     mymodule2.appendChild(modal_content);
5925                     modal_content.appendChild(mymodulebody);
5926                     mymodulebody.appendChild(mymoduleheader);
5927                     mymodulebody.appendChild(serchpage);
5928                     mymodulebody.appendChild(mybtn);
5929                     mymodulebody.appendChild(serchbox);
5930                     mymodulebody.appendChild(divIcons);
5931                     mymodulebody.appendChild(mymodulefooter);
5932                     mymodulebody.appendChild(myinput);
5933                     pageBox.appendChild(page);
5934                     // $('.mytext').append(sersrc);
5935                     //            $('.mytext').append(buttonDiv);
5936                     $('#' + $iconId + 'divIcons').append(requersTable);
5937                     $('#' + $iconId + 'divIcons').append(pageBox);
5938                     var lastPage = "";
5939                     customBase.findmay = {
5940                         "formId": formId,
5941                         "sCondition": sCondition,
5942                         "formhuixian": formhuixian,
5943                         "head": head,
5944                         "iconId": $iconId,
5945                         "addVal": addVal
5946                     }
5947                     var count = fenye("5", "1", formId, sCondition, formhuixian, head, $iconId, addVal, []);
5948
5949                     lastPage = Math.ceil(count / 5);
5950                     //console.log($(".pageF"))
5951                     $(".pageF").paging({
5952                         pageNo: 1,
5953                         totalPage: lastPage,
5954                         totalSize: count,
5955                         callback: function (num) {
5956                             console.log(num);
5957                             fenye("5", num, formId, sCondition, formhuixian, head, $iconId, addVal, []);
5958                         }
5959                     });
5960                 }
5961                 //如果存在就移除
5962             } else {
5963                 $('#' + $iconId + 'menuContent').remove();
5964             }
5965         } else {
5966             alert('未选择表单')
5967         }
5968         // 调用查询方法10/18
5969         findserch();
5970     });
5971     //条形码点击事件
5972     $('.barcodeShowClass').unbind();
5973     $('.barcodeShowClass').on('click', function () {
5974         var editable = $(this)[0].getAttribute("editable");
5975         //编辑设定
5976         if (editable == "false") {
5977             return;
5978         }
5979
5980         $(this).addClass("cfg_contentNone");
5981         $("#" + $(this)[0].id + "barcode").removeClass("cfg_contentNone");
5982         $("#" + $(this)[0].id + "barcode").focus();
5983     });
5984     //条形码焦点离开事件
5985     $('.barcodeShowTextClass').unbind();
5986     $('.barcodeShowTextClass').on('blur', function () {
5987         var id = $(this)[0].id;
5988         //表示的控件ID取得
5989         var idTemp = id.replace("barcode", "");
5990         // //默认数值
5991         // var defaultSize = {
5992         //   width:$("#"+idTemp)[0].width,
5993         //   height:$("#"+idTemp)[0].height,
5994         //   defaultvalue:"",
5995         //   styleclass:""
5996         // };
5997         // var size = $("#"+idTemp)[0].getAttribute("size");
5998         var showCustomItem = customShow.options.customItemShow.item[idTemp];
5999         // var size = $("#"+idTemp)[0].getAttribute("size");
6000         var size = showCustomItem.tag_Attribute.size;
6001         // defaultSize.defaultvalue = $(this)[0].value;
6002         customBase.createbarcode(size, $(this)[0].value, function (text, barWidth, barHeight, sizeWidthHeight) {
6003             $("#canvasbarcode").remove();
6004             $(document.body).append('<div id="canvasbarcode" style="display: none;"></div>');
6005             // //设值 距离左侧距离 margin-left: -2px;
6006             // if(barWidth == 1){
6007             //    $("."+idTemp+"value").addClass("barcodeMarginleft1");
6008             // }else if(barWidth == 2){
6009
6010             // }else if(barWidth == 3){
6011
6012             // }else if(barWidth == 4){
6013
6014             // }else if(barWidth == 5){
6015
6016             // }else if(barWidth == 6){
6017
6018             // }
6019             // $("."+idTemp+"value").addClass("barcodeMarginleft"+barWidth);
6020
6021             jQuery('#canvasbarcode').barcode(text, "code128", { barWidth: barWidth, barHeight: barHeight, showHRI: true });
6022             var canvasbarcode = $("#canvasbarcode")[0].innerHTML;
6023             sizeWidthHeight.width = $("#canvasbarcode")[0].style.width;
6024
6025             customBase.amount2Image(canvasbarcode, "barcode", sizeWidthHeight, function (amountHtml) {
6026                 $("#" + idTemp + "barcode").addClass("cfg_contentNone");
6027                 for (var i = 0; i < $("." + idTemp + "value").length; i++) {
6028                     $("." + idTemp + "value")[i].setAttribute("src", amountHtml);
6029                 };
6030                 $("#" + idTemp).removeClass("cfg_contentNone");
6031             });
6032         });
6033     });
6034     //二维码点击事件
6035     $('.qrcodeShowClass').unbind();
6036     $('.qrcodeShowClass').on('click', function () {
6037         var editable = $(this)[0].getAttribute("editable");
6038         //编辑设定
6039         if (editable == "false") {
6040             return;
6041         }
6042
6043         $(this).addClass("cfg_contentNone");
6044         $("#" + $(this)[0].id + "qrcode").removeClass("cfg_contentNone");
6045         $("#" + $(this)[0].id + "qrcode").focus();
6046     });
6047
6048     //二维码焦点离开事件
6049     $('.qrcodeShowTextClass').unbind();
6050     $('.qrcodeShowTextClass').on('blur', function () {
6051         var id = $(this)[0].id;
6052         //表示的控件ID取得
6053         var idTemp = id.replace("qrcode", "");
6054         var showCustomItem = customShow.options.customItemShow.item[idTemp];
6055         // var widthqrcode = $("#"+idTemp)[0].width;
6056         // var heightqrcode = $("#"+idTemp)[0].height;
6057         var widthqrcode = showCustomItem.tag_Attribute.width;
6058         var heightqrcode = showCustomItem.tag_Attribute.height;
6059         if (heightqrcode == 0 || heightqrcode == undefined) {
6060             heightqrcode = 60;
6061         }
6062         if (widthqrcode == 0 || widthqrcode == undefined) {
6063             widthqrcode = 60;
6064         }
6065         //默认数值
6066         var defaultSize = {
6067             width: widthqrcode,
6068             height: heightqrcode,
6069             defaultvalue: "",
6070             styleclass: ""
6071         };
6072         // var size = $("#"+idTemp)[0].getAttribute("size");
6073
6074         defaultSize.defaultvalue = $(this)[0].value;
6075         $("#canvasqrcode").remove();
6076         $(document.body).append('<div id="canvasqrcode" style="display: none;"></div>');
6077         jQuery('#canvasqrcode').qrcode({ width: defaultSize.width, height: defaultSize.height, text: $(this)[0].value });
6078         var mycanvas = $("#canvasqrcode").find("canvas")[0];
6079         var image = mycanvas.toDataURL("image/png");
6080         $("#" + idTemp + "qrcode").addClass("cfg_contentNone");
6081         for (var i = 0; i < $("." + idTemp + "value").length; i++) {
6082             $("." + idTemp + "value")[i].setAttribute("src", image);
6083         };
6084
6085         $("#" + idTemp).removeClass("cfg_contentNone");
6086     });
6087 }
6088 // 禁用树的父节点   12/9
6089 customShow.setTree = {
6090     disableParentNode: {
6091         set: function (treeObj) {
6092             if (treeObj) {
6093                 var nodes = treeObj.getNodes();
6094                 var level = 0;
6095                 //  获取最底层的层数
6096                 treeObj.getNodesByFilter(function (node) {
6097                     if (level < node.level) {
6098                         level = node.level;
6099                     }
6100                 }); // 查找不是最底层的节点集合
6101                 var nodesFilter = treeObj.getNodesByFilter(function (node) {
6102                     return (node.level != level)
6103                 });
6104                 //父节点禁止勾选
6105                 for (var i = 0; i < nodesFilter.length; i++) {
6106                     treeObj.setChkDisabled(nodesFilter[i], true);
6107                 }
6108             }
6109         }
6110     }
6111 }
6112
6113 customShow.addtree = function (itemId, item) {
6114     console.log(customBase.settingRadioType)
6115     //修改克隆树的实例化 马习同2017-11-21
6116     console.log(customShow.options.customItemShow.item)
6117     var customItem = customShow.options.customItemShow.item;
6118     var ztree = {};
6119     for (let key in customItem) {
6120         if (customItem[key].tag_Type == "tree") {
6121             ztree[key] = customItem[key];
6122         }
6123     }
6124     $('.zTreeDemoBackground').css("display", "none");
6125     $(".search_input").css("display", "none");
6126     var index = 0;
6127     var treeObj;
6128     // var disableparentnode = false;
6129     for (let key in ztree) {
6130         if ($(item).find("#" + key).find('.ztree').parent().attr('disableparentnode') == "true") {
6131             $(item).find("#" + key).find('.ztree').attr("id", key + "tree" + index_i);//修改克隆树的id  马习同2017-11-21
6132             if (ztree[key].tag_Attribute.dropdowntype == "single") {
6133                 $.fn.zTree.init($($(".customViewUEditorCss  #" + key + "tree" + index_i)), customBase.settingRadioType, customShow.listData[key]);
6134                 //  12/2 树展开
6135                 treeObj = $.fn.zTree.getZTreeObj(key + "tree" + index_i);
6136                 customShow.setTree.disableParentNode.set(treeObj)
6137                 if (treeObj) {
6138                     treeObj.expandAll(true);
6139                 }
6140             } else if (ztree[key].tag_Attribute.dropdowntype == "multiple") {
6141                 $.fn.zTree.init($($(".customViewUEditorCss  #" + key + "tree" + index_i)), customBase.settingChkboxType, customShow.listData[key]);
6142                 treeObj = $.fn.zTree.getZTreeObj(key + "tree" + index_i);
6143                 customShow.setTree.disableParentNode.set(treeObj)
6144                 if (treeObj) {
6145                     treeObj.expandAll(true);
6146                 }
6147             }
6148         } else {
6149             $(item).find("#" + key).find('.ztree').attr("id", key + "tree" + index_i);//修改克隆树的id  马习同2017-11-21
6150             if (ztree[key].tag_Attribute.dropdowntype == "single") {
6151                 $.fn.zTree.init($($(".customViewUEditorCss  #" + key + "tree" + index_i)), customBase.settingRadioType, customShow.listData[key]);
6152                 //  12/2 树展开
6153                 treeObj = $.fn.zTree.getZTreeObj(key + "tree" + index_i);
6154                 console.log(treeObj)
6155                 if (treeObj) {
6156                     treeObj.expandAll(true);
6157                 }
6158             } else if (ztree[key].tag_Attribute.dropdowntype == "multiple") {
6159                 $.fn.zTree.init($($(".customViewUEditorCss  #" + key + "tree" + index_i)), customBase.settingChkboxType, customShow.listData[key]);
6160                 treeObj = $.fn.zTree.getZTreeObj(key + "tree" + index_i);
6161                 console.log(treeObj)
6162                 if (treeObj) {
6163                     treeObj.expandAll(true);
6164                 }
6165             }
6166         }
6167         // 克隆后选中节点  12/7 李元杰
6168         if (!_.isNull(treeObj)) {
6169             var treeId = treeObj['setting'].treeId;
6170             var defaultValue = $('#' + treeId).parent().attr('defaultvalue');
6171             // // 12/7  默认值
6172             if (defaultValue != '') {
6173                 console.log(treeObj)
6174                 customShow.treeDefaultSet(treeObj, defaultValue);
6175             }
6176         }
6177
6178     }
6179     console.log(treeObj)
6180     console.log($(item))
6181     //修改克隆树的实例化End  马习同2017-11-21
6182     index_i++;
6183
6184 }
6185
6186 //子表单项目追加
6187 customShow.addsubformList = function (subformAdd, showClass) {
6188     console.log(i)
6189     var allcopy = subformAdd.getAttribute('allcopy');
6190     var itemId = subformAdd.getAttribute('itemId');
6191     //单行记录更新
6192     if (allcopy == "false") {
6193         console.log(customBase.options.customItems);
6194         console.log(customBase.options.customItems[customShow.options.customItemShow.item[itemId].tag_Attribute.alias].cloneDiv);
6195         var item = customBase.options.customItems[customShow.options.customItemShow.item[itemId].tag_Attribute.alias].cloneDiv;
6196         // 子表单隐藏   马习同 11-13
6197         //      var item =$("."+showClass+" #"+itemId+"save").children()[0];
6198         //子表单情况为U情况
6199         if (item == undefined) {// 子表单回显 修改  李伟民 11-10
6200             var tbody = $("." + showClass + " #" + itemId + "ActiveId").find("tbody");
6201             tbody = tbody[0].cloneNode(true);
6202             console.log(tbody)
6203             // 清空input  12/7
6204             console.log($(item))
6205             if ($(item).find('.zTreeDemoBackground').attr('defaultvalue') == '') {
6206                 $(item).find(".citySel").val('');
6207             }
6208             $(tbody).find(".select2").remove();
6209             console.log($(tbody).html());
6210             $(tbody).find(".tdTitleClass").closest("tr").addClass("table_title");
6211             $(tbody).find(".dropdowntypeCss").select2({ theme: "classic" });
6212             //        $(tbody).find(".zTreeDemoBackground").select2({theme: "classic"});
6213             if ($(tbody).find(".table_title").length > 0) {
6214                 //删除头行
6215                 $(tbody).find(".table_title").remove();
6216             }
6217             if ($(tbody).find(".trContentClass").length > 1) {// 去除重复的tr  李伟民 11-14
6218                 $($(tbody).find(".trContentClass")[0]).siblings().remove();
6219             }// 去除重复的tr  李伟民 11-14
6220             //        $(tbody).find(".cfg_contentNone").removeClass("cfg_contentNone");
6221             tbody = customShow.addsubformListInit(itemId, $(tbody).find("tr"));
6222             console.log(tbody);
6223             console.log(itemId);
6224             console.log($(tbody).find("#" + itemId).attr("class"));
6225             $(tbody).find("input").attr("funarr", "");//公式绑定 清空 李伟民 12-11
6226             $(tbody).find("input").attr("checkfunarr", "");
6227             $(tbody).find(".select_get").attr("funarr", "");
6228             $(tbody).find(".select_get").attr("checkfunarr", "");//公式绑定 清空 李伟民 12-11
6229             $($("." + showClass + " #" + itemId + "ActiveId").find("table")[0]).append(tbody);// 子表单回显 修改  李伟民 11-10
6230             customShow.hidesubform();
6231             customShow.setXhSelectList(false);//添加记录 重复问题  李伟民11-14
6232         } else {
6233             item = item[0].cloneNode(true);
6234             // 12/7 清空input
6235             var defaultvalue = $(item).find('.zTreeDemoBackground').attr('defaultvalue');
6236             var itemIdTree = $(item).find('.ztree').attr('id');
6237             var treeObj = $.fn.zTree.getZTreeObj(itemIdTree);
6238             console.log(treeObj)
6239             // 12/7  默认值
6240             if ($(item).find('.zTreeDemoBackground').attr('defaultvalue') == '') {
6241                 $(item).find(".citySel").val('');
6242             }
6243             $(item).find(".select2").remove();
6244             $(item).find(".dropdowntypeCss").select2({ theme: "classic" });
6245             $(item).find(".subformAddiconShow .cfg_contentNone").removeClass("cfg_contentNone");
6246             item = customShow.addsubformListInit(itemId, item);
6247             $(item).find("input").attr("funarr", "");//公式绑定 清空 李伟民 12-11
6248             $(item).find("input").attr("checkfunarr", "");
6249             $(item).find(".select_get").attr("funarr", "");
6250             $(item).find(".select_get").attr("checkfunarr", "");//公式绑定 清空 李伟民 12-11
6251             $($("." + showClass + " #" + itemId + "ActiveId").find("table")[0]).append(item);
6252             customShow.setXhSelectList(true);//添加记录 重复问题  李伟民11-14
6253         }
6254
6255         customShow.addtree(itemId, item);
6256         //子表单事件追加
6257     } else {
6258         //全子表单复制
6259         //    //console.log(1);
6260
6261         var item = $("." + showClass + " #" + itemId + "ActiveId")[0];
6262         // //console.log(item);
6263         item = item.cloneNode(true);
6264         //console.log(item);
6265         var divIcons = document.createElement("div");
6266         divIcons.setAttribute("class", "frm_item_icons allCopyCss");
6267         var divIcon = document.createElement("div");
6268         divIcon.setAttribute("class", "frm_item_icon remove");
6269         var divIconImg = document.createElement("i");
6270         divIconImg.setAttribute("class", "icon iconfont icon-iconfontcolor93 iconfontcolor");
6271         divIconImg.setAttribute("style", "text-align: left;font-size: 18px;color: red;");
6272         // var divIconImg = document.createElement("img");
6273         // divIconImg.setAttribute("src", "./../../css/img/icon/delete.png");
6274         divIcon.appendChild(divIconImg);
6275         divIcons.appendChild(divIcon);
6276         // $(item).find(".icon-jiahao").parent().addClass("cfg_contentNone");
6277         $(item).append(divIcons);
6278         //  清空 树的input
6279         console.log($(item))
6280         if ($(item).find('.zTreeDemoBackground').attr('defaultvalue') != '') {
6281
6282         } else {
6283             $(item).find(".citySel").val('');
6284         }
6285         $(item).find(".select2").remove();
6286         $(item).find(".dropdowntypeCss").select2({ theme: "classic" });
6287         //console.log(item);
6288         item = customShow.addsubformListInit(itemId, item);
6289         // 10/23添加子表单记录
6290         var beforeitem = $("." + showClass + " #" + itemId + "ActiveId");
6291         //console.log(beforeitem);
6292         $(item).find("input").attr("funarr", "");//公式绑定 清空 李伟民 12-11
6293         $(item).find("input").attr("checkfunarr", "");
6294         $(item).find(".select_get").attr("funarr", "");
6295         $(item).find(".select_get").attr("checkfunarr", "");//公式绑定 清空 李伟民 12-11
6296         $("." + showClass + " #" + itemId + "ActiveId").eq(0).after(item);
6297         // _.each(beforeitem,function(bitem){
6298         if (beforeitem.length > 1) {
6299             for (var i = 0; i < beforeitem.length - 1; i++) {
6300                 $(beforeitem[i]).find(".icon-jiahao").parent().addClass("cfg_contentNone");
6301             }
6302         } else {
6303             $(beforeitem[0]).find(".icon-jiahao").parent().addClass("cfg_contentNone");
6304         }
6305         customShow.setXhSelectList();//添加记录 重复问题  李伟民11-14
6306         // });
6307         customShow.addtree(itemId, item);
6308     }
6309 }
6310 //马习同修改  子表单隐藏  11/13
6311 customShow.hidesubform = function () {
6312     // console.log($("[tag_type='subform']"))
6313     _.each($("[tag_type='subform']"), opt => {
6314         console.log(opt)
6315         $($(opt).find(".tdTitleClass")[0]).addClass("cfg_contentNone");
6316         $($(opt).find(".tdContentClass")[0]).addClass("cfg_contentNone");
6317     })
6318     var unvisible = customBase.options.customItems;
6319     var unvisibleArr = [];
6320     _.each(unvisible, opt => {
6321         if (opt.visible == false && opt.parentsubFormNum != 0) {
6322             unvisibleArr.push(opt)
6323         }
6324     })
6325     //  _.remove(unvisibleArr,n => {
6326     //     return n.fieldKey == "DATAROWNUM";
6327     // })
6328     // console.log(unvisibleArr)
6329     _.each(unvisibleArr, opt => {
6330         $("[id='" + opt.id + "']").parent().parent().addClass("cfg_contentNone");
6331         $($(".customShow #itemId_" + opt.parentsubFormNum + " .tdTitleClass")[$("[id='" + opt.id + "']").parent().parent().index()]).addClass("cfg_contentNone");
6332         $($(".customViewUEditorCss #itemId_" + opt.parentsubFormNum + " .tdTitleClass")[$("[id='" + opt.id + "']").parent().parent().index()]).addClass("cfg_contentNone");
6333     })
6334 }
6335 //子表单内数据初始化
6336 customShow.addsubformListInit = function (itemId, tbodys) {
6337     //console.log(tbodys);
6338     var itemList = customShow.options.customItemShow.item;
6339     var item = itemList[itemId];
6340     var parentsubFormNum = item.columnOrderNum + "";
6341
6342     for (itemListId in itemList) {
6343         if (itemList.hasOwnProperty(itemListId)) {
6344             if (itemList[itemListId].parentsubFormNum == parentsubFormNum) {
6345                 //子表单内控件确认
6346                 var type = itemList[itemListId].tag_Type;
6347                 if (type == "text" || type == "textarea" || type == "number") {
6348                     $(tbodys).find("#" + itemListId)[0].value = itemList[itemListId].tag_Attribute.defaultvalue;
6349                 } else if (type == "calendar") {
6350                     $(tbodys).find("#" + itemListId)[0].value = "";
6351                 } else if (type == "radio") {
6352
6353                 } else if (type == "checkbox") {
6354
6355                 } else if (type == "dropdownlist") {
6356                     var itemListIdTemp = itemListId + "_" + customShow.options.dropdownlist_I;
6357                     var item = $(tbodys).find("#" + itemListId);
6358                     ////////console.log($(tbodys));
6359                     // var dropdowntype =  $(item.find('select'))[0].getAttribute("dropdowntype");
6360                     var dropdowntype = customShow.options.customItemShow.item[itemListId].tag_Attribute.dropdowntype;
6361                     if ($("#" + itemListId + " .select3-element")[0] == undefined) {
6362                         var width = $(tbodys).find("#" + itemListId)[0].style.width.replace("px", "");
6363                     } else {
6364                         var width = $("#" + itemListId + " .select3-element")[0].style.width.replace("px", "");
6365                     }
6366
6367                     width = parseInt(width);
6368                     var listData = customBase.options.dropdownlistText[itemListId];
6369                     ////////console.log(customBase.options.dropdownlistText);
6370                     // $("#"+itemId).parent().empty();
6371                     var itemIdClass = "selectClass js-example-basic-single defaultHeight customShowItemClass  dropdowntypeCss " + itemListId + "value " + itemListIdTemp;
6372                     var DropdownlistItem = item.parent();
6373                     //        DropdownlistItem.css("background-color","red");
6374                     // var setDiv = $('<div id="'+itemListId+'" class="selectClass '+itemIdClass+'"></div>');
6375                     var setDiv = $('<div id="' + itemListId + '" class="selectClass lwm' + itemIdClass + '"></div>');
6376                     console.log("11122211")
6377                     DropdownlistItem.empty();
6378                     setDiv.empty();
6379                     console.log(itemListId);
6380                     DropdownlistItem.append(setDiv);
6381                     console.log($(DropdownlistItem).html());
6382                     //////console.log(dropdowntype);
6383
6384                     if (dropdowntype == "multiple") {
6385                         customShow.options.subformDList[itemListIdTemp] = {
6386                             selectId: itemListId,
6387                             multiple: true,
6388                             width: width,
6389                             // listData:listData,
6390                         }
6391                     } else {
6392                         customShow.options.subformDList[itemListIdTemp] = {
6393                             selectId: itemListId,
6394                             multiple: false,
6395                             width: width,
6396                             // listData:listData,
6397                         }
6398                     }
6399                     //  if(dropdowntype == "multiple"){
6400                     //     xhSelect.setXhSelect(
6401                     //         {
6402                     //             selectId:itemListId,
6403                     //             multiple:true,
6404                     //             width: width,
6405                     //             listData:listData,
6406                     //             setDiv:setDiv
6407                     //             // setDiv:itemListIdTemp
6408                     //         }
6409                     //     );
6410                     //  }else{
6411                     //     xhSelect.setXhSelect(
6412                     //         {
6413                     //             selectId:itemListId,
6414                     //             multiple:false,
6415                     //             width: width,
6416                     //             listData:listData,
6417                     //             setDiv:setDiv
6418                     //             // setDiv:itemListIdTemp
6419                     //         }
6420                     //     );
6421                     //  }
6422
6423                 }
6424             }
6425             customShow.options.dropdownlist_I++;
6426         }
6427
6428     }
6429     //console.log(customShow);
6430     //console.log(customBase);
6431
6432     ////////console.log(customShow.options.customItemShow.item);
6433     ////////console.log(itemId);
6434     ////////console.log(item);
6435     ////////console.log(parentsubFormNum);
6436     // customShow.setXhSelectList();
6437     return tbodys;
6438 }
6439 //驳回
6440 customShow.rejectBtn = function () {
6441     var flag = true;//true驳回 false不驳回
6442     over(flag)
6443 }
6444 //提交
6445 customShow.onclickSubmit = function () {
6446     get();
6447 }
6448 //查看票据
6449 customShow.checkbill = function () {
6450     window.open("./../bill_img/bill.html")
6451 }
6452 //审批
6453 customShow.auditableBtn = function () {
6454     auditableBtn();
6455 }
6456 function auditableBtn() {
6457     var processLog = JSON.parse(localStorage.getItem("processLog"));
6458     if (processLog != null && processLog != undefined) {
6459     } else {
6460         alert("请先创建一个流程");
6461         return null;
6462     }
6463     if (processLog[0].processState == 60) {
6464         alert("流程已结束");
6465         return null;
6466     }
6467     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/>"
6468         + "<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>";
6469     $("#liucheng").html(inputs);
6470     $("#auditableBtn")[0].setAttribute('data-toggle', "modal");
6471     $("#auditableBtn")[0].setAttribute('data-target', ".bs-example-modal-sm");
6472 }
6473 customShow.onclickSave1 = function () {
6474     // SC.sendanydata(function(flag){
6475     //     console.log(flag);
6476     // if(!flag){
6477     //     console("if")
6478     //     customShow.onclickSave(1);
6479     // }else{
6480
6481     //    alert("错误");
6482     // }
6483     // });
6484     SC.sendanydata(customShow.onclickSave, 1)
6485
6486
6487 }
6488 customShow.onclickSave2 = function () {
6489     SC.sendanydata(customShow.onclickSave, 2)
6490 }
6491
6492 //清空按钮按下是
6493 customShow.onclickClear = function () {
6494     console.log(customBase);
6495     console.log(customShow);
6496     var itemKey = _.keys(customShow.options.customItemShow.item);
6497     var item = customShow.options.customItemShow.item;
6498     console.log(itemKey);
6499     _.each(itemKey, function (itemId) {
6500         console.log(itemId);
6501         console.log(item[itemId].tag_Type);
6502         customBase.setItemValue(itemId, item[itemId].tag_Type, "", "");
6503     });
6504 }
6505 //保存按钮按下时
6506 customShow.onclickSave = function (clickFlag) {
6507     console.log(clickFlag);
6508     var saveReturn = customShow.initEvent.fromSaveLinkage();
6509
6510     //画面项目取得 --------------------------画面项目取得------
6511     var items = customShow.getItems(true);
6512     console.log(items)
6513     // customShow.queryCost();
6514     try {
6515         if (typeof (eval(eachitem)) == "function") {
6516             eachitem(items);
6517         }
6518     } catch (e) {
6519         console.log("不存在的函数");
6520     }
6521
6522     console.log("遍历数组")
6523     console.log(items);
6524     // 画面check
6525     var returnfromCheck = customShow.initEvent.fromCheck(items); //--------------------
6526     if (returnfromCheck) {
6527         return;
6528     }
6529     // 03检证执行
6530     var check = customShow.initEvent.validationRuleCheck(items); //--------------------
6531     if (!check) {
6532         return;
6533     }
6534     // 检证接口函数
6535     var check = customShow.initEvent.validationRuleCheck3rd(items); //-----------需要对验证进行解析---------
6536     if (!check) {
6537         return;
6538     }
6539     // 提取数据 生成数据json  同customShow.getItems()
6540     //公式保存接口
6541     //  var saveReturn = customShow.initEvent.fromSaveLinkage(items);
6542     //  if(!saveReturn){
6543     //     return;
6544     //  }
6545     // 发送数据到后台服务器,保存data
6546     var saveReturn = customShow.initEvent.fromSave3rd(items);//--------------------
6547     console.log(customShow.options.customShowFlag)
6548     if (saveReturn) {
6549         console.log(1)
6550         if (customShow.options.customShowFlag == "1") {
6551             //保存
6552             customDataBound.fromSave(customShow.options.formid, items, function (rs) {
6553                 if (rs.rspCode == "000000") {
6554                     var strMessage = customBase.getMessage("mesage_ID015");
6555                     customBase.alert("S", strMessage);
6556                     //  return;
6557                 }
6558                 if (rs.rspCode == "100004") {
6559                     var strMessage = customBase.getMessage("mesage_ID007");
6560                     customBase.alert("E", strMessage);
6561                     return;
6562                 }
6563                 if (customShow.options.customShowFlag == "1") {
6564                     window.parent.$('#myModal').modal('hide');
6565                     window.parent.addFormData(rs);
6566                     $(window.parent.document.body).css({ "overflow-x": "auto", "overflow-y": "auto" });
6567                 }
6568                 // //////console.log(rs);
6569             });
6570         } else if (customShow.options.customShowFlag == "2") {
6571             console.log(2)
6572             //保存
6573             customDataBound.fromEdit(customShow.options.formid, items, customShow.options.dataRowNum, function (rs) {
6574                 if (rs.rspCode == "100004") {
6575                     var strMessage = customBase.getMessage("mesage_ID007");
6576                     customBase.alert("E", strMessage);
6577                     return;
6578                 }
6579                 customShow.options.breakFlag = true;
6580                 //预览模式表示
6581                 $("#customViewUEditor")[0].style.display = "none";
6582                 //马习同  2018-1-2  布局修改
6583                 $("#customShow")[0].style.display = "flex";
6584                 // $(".footer")[0].style.display ="none";
6585
6586                 var btns = [
6587                     'printableBtn',
6588                     // 'exportBtn',
6589                     // 'rejectBtn',
6590                     // 'submitBtn',
6591                     // 'auditableBtn',
6592                     // 'queryBtn',
6593                     // 'createBtn',
6594                     // 'clearBtn',
6595                     // 'disposableBtn',
6596                     // 'fromSaveBtn',
6597                     'editableBtn'
6598                 ];
6599                 customShow.showCustom(items, customShow.options.customInit);
6600                 customShow.setToolBtn(btns);
6601                 console.log("关闭")
6602                 customShow.onclickCancel();
6603
6604             });
6605             //   customShow.onclickCancel();
6606         }
6607         else if (customShow.options.customShowFlag == "3") {
6608             // 保存
6609             console.log(3)
6610             if (clickFlag == 2 && customShow.options.dataRowNum != "") {
6611                 //保存
6612                 customDataBound.fromEdit(customShow.options.formid, items, customShow.options.dataRowNum, function (rs) {
6613                     ////console.log(rs);
6614                     if (rs.rspCode == "000000") {
6615                         var strMessage = customBase.getMessage("mesage_ID015");
6616                         customBase.alert("S", strMessage);
6617                         //  return;
6618                     }
6619                     if (rs.rspCode == "100004") {
6620                         var strMessage = customBase.getMessage("mesage_ID007");
6621                         customBase.alert("E", strMessage);
6622                         return;
6623                     }
6624                     // customShow.options.breakFlag = true;
6625                     // //预览模式表示
6626                     // $("#customViewUEditor")[0].style.display ="none";
6627                     // $("#customShow")[0].style.display ="block";
6628                     // // $(".footer")[0].style.display ="none";
6629                     // customShow.showCustom(items,customShow.options.customInit);
6630                 });
6631                 //新建
6632             } else {
6633                 customDataBound.fromSave(customShow.options.formid, items, function (rs) {
6634                     if (rs.rspCode == "000000") {
6635                         var strMessage = customBase.getMessage("mesage_ID015");
6636                         customBase.alert("S", strMessage);
6637                         //  return;
6638                     }
6639                     if (rs.rspCode == "100004") {
6640                         var strMessage = customBase.getMessage("mesage_ID007");
6641                         customBase.alert("E", strMessage);
6642                         return;
6643                     }
6644                     // if(customShow.options.customShowFlag == "1" ){
6645                     //     window.parent.$('#myModal').modal('hide');
6646                     //     window.parent.addFormData(rs);
6647                     //     $(window.parent.document.body).css({"overflow-x": "auto","overflow-y": "auto"});
6648                     // }
6649                     if(customShow.options.customShowFlag != "3" ){//发布差异修改 李伟民 0120
6650                         customShow.options.dataRowNum = rs.data.dataRowNum;
6651                     }
6652                     //////console.log(rs);
6653                 });
6654             }
6655         }
6656     }
6657     // customShow.onclickCancel();
6658     //  window.parent.$('#myModal').modal('hide');
6659     // console.log($('.boxOne'))
6660     // $('.boxOne').css("display","none");
6661 }
6662
6663 //保存按钮按下时(项目预览表示)
6664 customShow.showCustom = function (items, customInit) {
6665     console.log(items);
6666     console.log(customInit);
6667     customShow.options.customItemShow = customInit.customViewItem;
6668     var customItem = customShow.options.customItemShow;
6669     // $(".preview-edit-pane").css("display","block");
6670     // $(".footer")[0].style.display ="block";
6671     // $(".footer .fromSaveCss")[0].style.display ="none";
6672
6673     var divHtml = customItem.formeditor;
6674
6675     $("#customShow").empty();
6676     $("#customShow")[0].innerHTML = divHtml;
6677     var height = customShow.options.customItemShow.height;
6678     //  height = parseInt(height)-50;
6679     //////////console.log(height);
6680     $("#customShow")[0].style.height = height + "px";
6681     $("#customShow")[0].style.width = customShow.options.customItemShow.width;
6682     $("#customShow")[0].style.display = "flex";
6683     var customItems = customBase.options.customItems;
6684
6685     //数据值变换
6686     for (item in customItems) {
6687         if (customItems.hasOwnProperty(item)) {
6688             if (customItems[item] == undefined) {
6689                 delete customItems[item];
6690                 continue;
6691             }
6692             if (customItems[item].type == 'subform') {
6693                 var subformTemp = items[item];
6694                 //////console.log(items);
6695                 ////console.log(item);
6696                 console.log(subformTemp);
6697                 //          console.log(customItems);
6698                 if (subformTemp == undefined) {
6699                     subformTemp = [{}];
6700                 }
6701                 for (subformItem in subformTemp[0]) {
6702                     if (subformTemp[0].hasOwnProperty(subformItem)) {
6703                         items[subformItem] = [];
6704                     }
6705                 }
6706                 for (var i = 0; i < subformTemp.length; i++) {
6707                     if (i != 0) {
6708                         //子表单项目追加
6709                         var subformAdd = $(".customShow #" + customItems[item].id + "ActiveId .subformAdd")[0];
6710                         customShow.addsubformList(subformAdd, "customShow");
6711                     }
6712                     for (subformItem in subformTemp[i]) {
6713                         if (subformTemp[i].hasOwnProperty(subformItem)) {
6714                             items[subformItem][i] = subformTemp[i][subformItem];
6715                         }
6716                     }
6717                 };
6718             }
6719             //选项卡回显
6720             if (customItems[item].type == 'tag') {
6721                 var subformTemp = items[item];
6722                 ////console.log(items);
6723                 ////console.log(item);
6724                 ////console.log(subformTemp);
6725                 ////console.log(customItems);
6726                 if (subformTemp == undefined) {
6727                     subformTemp = [{}];
6728                 }
6729                 for (subformItem in subformTemp[0]) {
6730                     if (subformTemp[0].hasOwnProperty(subformItem)) {
6731                         items[subformItem] = [];
6732                     }
6733                 }
6734                 for (var i = 0; i < subformTemp.length; i++) {
6735                     if (i != 0) {
6736                         //子表单项目追加
6737                         var subformAdd = $(".customShow #" + customItems[item].id + "ActiveId .subformAdd")[0];
6738                         customShow.addsubformList(subformAdd, "customShow");
6739                     }
6740                     for (subformItem in subformTemp[i]) {
6741                         if (subformTemp[i].hasOwnProperty(subformItem)) {
6742                             items[subformItem][i] = subformTemp[i][subformItem];
6743                         }
6744                     }
6745                 };
6746             }
6747         }
6748     }
6749
6750     customShow.options.subformDValue = items;
6751     //表示项目进行变换
6752
6753     //画面项目初期化
6754     customShow.controlInit("customShow");
6755
6756     //删除项目(select2项目删除)
6757     $('.customShow .selection').remove();
6758     //console.log(customItems);
6759     //数据设定
6760     for (item in customItems) {
6761         console.log(items)
6762         if (customItems.hasOwnProperty(item)) {
6763             if (customItems[item] == undefined) {
6764                 delete customItems[item];
6765                 continue;
6766             }
6767
6768             var type = customItems[item].type;
6769             var id = customItems[item].id;
6770             var value = items[item];
6771             // value = [{"tId":"itemId_1tree_2"},{"name":"F066008"},{"tId":"itemId_1tree_3"},{"name":"F066003"}];
6772             // value = [{"name":"F066008"},{"name":"F066003"}];
6773             // value = [{"name":"F066008"},{"name":"F066003"}];
6774
6775             if (customItems[item].type == 'subform') {
6776                 $(".customShow").find("#" + id + "subform").find("td").addClass("");
6777             } else if (customItems[item].type == 'htmlediter') {
6778                 // var htmlediterShow = $(".customShow").find("#"+id)[0];
6779                 var htmlediterShow = $(".customShow #" + id + "Item")[0];
6780                 // var heightShow = $(htmlediterShow)[0].getAttribute("heightShow");
6781                 // var widthShow = $(htmlediterShow)[0].getAttribute("widthShow");
6782                 var heightShow = customShow.options.customItemShow.item[id].tag_Attribute.height;
6783                 var widthShow = customShow.options.customItemShow.item[id].tag_Attribute.width;
6784                 if (widthShow == undefined || heightShow == undefined) {
6785                     widthShow = 200;
6786                     heightShow = 200;
6787                 }
6788                 var oNode = '<div style="word-break:break-all;width:' + widthShow + 'px;height:' +
6789                     heightShow + 'px;" class="customShowItemClass edui-default customShowItemClassTemp">';
6790                 // var oNode ='<div style="word-break:break-all;border-width: 1px;border-style: solid;border-color: rgb(204, 204, 204);class="customShowItemClass edui-default">';
6791                 oNode += value;
6792                 oNode += "</div>";
6793                 $($(".customShow #" + id + "Item")[0]).after(oNode);
6794                 $($(".customShow #" + id + "Item")[0]).remove();
6795                 //标签数据设定
6796             } else if (customItems[item].type == 'textarea') {
6797                 var htmlediterShow = $(".customShow #" + id)[0];
6798                 var heightShow = customShow.options.customItemShow.item[id].tag_Attribute.height;
6799                 var widthShow = customShow.options.customItemShow.item[id].tag_Attribute.width;
6800                 if (widthShow == undefined || heightShow == undefined) {
6801                     widthShow = 300;
6802                     heightShow = 80;
6803                 }
6804                 var oNode = '<div style="word-break:break-all;border-width: 0px;border-style: solid;border-color: rgb(204, 204, 204);width:' + widthShow + 'px;height:' +
6805                     heightShow + 'px;" class="customShowItemClass edui-default customShowItemClassTemp">';
6806                 // var oNode ='<div style="word-break:break-all;border-width: 1px;border-style: solid;border-color: rgb(204, 204, 204);class="customShowItemClass edui-default">';
6807                 oNode += value;
6808                 oNode += "</div>";
6809                 $($(".customShow #" + id)[0]).after(oNode);
6810                 $($(".customShow #" + id)[0]).remove();
6811                 //标签数据设定
6812             } else if (customItems[item].type == 'number') {
6813                 var numberShowItems = $(".customShow #" + id);
6814                 for (var i = 0; i < numberShowItems.length; i++) {
6815                     numberShowItems[i].setAttribute("type", "text");
6816                 }
6817
6818                 //标签数据设定
6819             } else if (customItems[item].type == 'link') {
6820                 var htmlediterShow = $(".customShow").find("#" + id)[0];
6821                 // console.log($(htmlediterShow))
6822                 // $(htmlediterShow)[0].setAttribute("href","javascript:;");
6823                 $(htmlediterShow).css("font-size", "16px;");
6824                 //单选 多选按钮
6825             } else if (type == 'radio' || type == 'checkbox' || type == 'dropdownlist') {
6826
6827                 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">';
6828                 oNode += "</div>";
6829                 // $($(".customShow").find("#"+id)[0]).after(oNode);
6830                 // $($(".customShow").find("#"+id)[0]).remove();
6831                 var showItem = $($(".customShow").find("#" + id));
6832                 console.log(showItem)
6833                 for (var i = 0; i < showItem.length; i++) {
6834                     $($(showItem[i])[0]).after(oNode);
6835                     $($(showItem[i])[0]).remove();
6836                 }
6837                 console.log(value)
6838                 //单选复选回显问题
6839                 customShow.setShowItem(id, type, value, true);
6840             }
6841             else if (customItems[item].type == 'tree') {
96b1bc 6842                 //普通模式树形回显  李伟民  0130
L 6843                 var oNode = '<div treeitemid=' + id + ' style="word-break:break-all;border-width: 0px;border-style: solid;border-color: rgb(204, 204, 204);width:200px;" class="customShowItemClass edui-default customShowItemClassTemp">';
4d1219 6844                 // 2017 /11/7  李元杰  树的回显
B 6845                 //   var   treeShow = $('#customShow').find('div[type=tree]');
6846
6847                 //   if(value !=undefined && value !=""){
6848                 //       console.log(1);
6849                 //     if(typeof value == "string"){
6850                 //     //   value = $.parseJSON(value);
6851                 //     console.log(2);
6852                 //       value =[value];
6853                 //     }
6854                 //     // 2017/11/7  李元杰回显
6855                 //     if(value.length>0){
6856                 //        console.log(value);
6857                 //        for(var i =0;i<value.length;i++){
6858                 //            value[i]
6859                 //        }
6860
6861
6862                 //      console.log(value)
6863
6864                 //        if(typeof value[0] == "string"){
6865                 //            //console.log(value[0]);
6866                 //         //   value[0] = $.parseJSON(value[0]);
6867                 //        }
6868
6869                 //       oNode +=value[0];
6870                 //     }
6871                 //     for (var i = 1; i < value.length; i++) {
6872                 //         console.log(4);
6873                 //       if(typeof value[i] == "string"){
6874                 //         console.log(5);
6875                 //         //   value[i] = $.parseJSON(value[i]);
6876                 //        }
6877                 //        console.log(value)
6878                 //       oNode +=" , "+value[i];
6879                 //       console.log(oNode)
6880                 //     };
6881                 //   }
6882                 //   console.log(oNode)
6883
6884                 //   oNode +="</div>";
6885                 "</div>";
6886                 $($(".customShow").find("#" + id)[0]).after(oNode);
6887                 $($(".customShow").find("#" + id)[0]).remove();
6888                 //              customShow.setShowItem(id, type, value, true);
6889                 console.log($($(".customShow").find("#" + id)[0]))
6890             }
6891             else if (customItems[item].type == 'amount') {
6892                 var id = id + "amount";
6893                 customBase.setItemValue(id, 'text', items[item], 'customShow');
6894                 $("#" + id).blur();
6895
6896             } else if (customItems[item].type == 'qrcode') {
6897                 var id = id + "qrcode";
6898                 customBase.setItemValue(id, 'text', items[item], 'customShow');
6899                 $("#" + id).blur();
6900             } else if (customItems[item].type == 'barcode') {
6901                 var id = id + "barcode";
6902                 customBase.setItemValue(id, 'text', items[item], 'customShow');
6903                 $("#" + id).blur()
6904             } else if (customItems[item].type == 'fileupload') {
6905                 // var $wrap = $(".customShow #" + customItems[item].id);
6906                 var $uploaderItem = $($(".customShow #" + customItems[item].id)[0]);
6907                 $uploaderItem.empty();
6908                 var $uploadimg = $(
6909                     '<div >' +
6910                     '<div id="fileList" class="uploader-list"></div>' +
6911                     '</div>'
6912                 );
6913                 var $list = $uploadimg.find("#fileList");
6914                 if (typeof value != "string") {
6915                     if (_.isArray(value)) {
6916                         // airport = JSON.parse(airport)
6917                         value = value.join(",")
6918                         var value = JSON.parse(value);
6919
6920                     }
6921                     for (i in value) {
bb9424 6922                         var fileDir = value[i].path;
Z 6923                         var suffix = fileDir.substr(fileDir.lastIndexOf(".")+1);
6924                         if(suffix == "mp4"){
6925                             var $li = $(
6926                                 '<div class="">' +
6927                                 '<div><a href="' + value[i].path + '" target="_blank">' + value[i].oldName + ' </a></div>' +
6928                                 '</div>'
6929                             );
6930                         }else{
6931                             var $li = $(
6932                                 '<div class="">' +
6933                                 // '<div class="info"><a href="' + value[i].path + '" >' + value[i].oldName + '</a></div>' +
6934                                 // '<div class="info info-box"><div class="info_box">' + value[i].oldName +
6935                                 // '<span class="x_box" style="display:none;">×</span>' +
6936                                 // '<img class="img_box" style="display:none;" src="' + value[i].path + '">' +
6937     
6938                                 '<div><a href="' + value[i].path + '" >' + value[i].oldName + '</a></div>' +
6939                                 '</div>'
6940                             );
6941                         }
4d1219 6942                         $li.appendTo($list);
B 6943                     };
6944                 }
6945                 $uploadimg.appendTo($uploaderItem);
6946                 //2017-12-17 马习同修改 图片
6947                 // $(".info_box").on("click", function () {
6948                 //     $(".x_box").show();
6949                 //     $(".img_box").show();
6950                 //     $(".x_box").unbind();
6951                 //     $(".x_box").on("click", function () {
6952                 //         console.log(1);
6953                 //         $(".x_box").hide();
6954                 //         $(".img_box").hide();
6955                 //     })
6956                 // })
6957             } else if (customItems[item].type == 'image') {
6958                 // var $wrap = $(".customShow #" + customItems[item].id);
6959                 var $uploaderItem = $($(".customShow #" + customItems[item].id)[0]);
6960                 console.log($('#' + customItems[item].id));
6961                 console.log($uploaderItem)
6962                 $uploaderItem.empty();
6963
6964                 var $uploadimg = $(
6965                     '<div >' +
6966                     '<div id ="fileList" class="uploader-list"></div>' +
6967                     '</div>'
6968                 );
6969                 // var $list = $uploadimg.find("#"+potion.id+"fileList");
6970                 console.log(value)
449a85 6971                 if(customItems[item].defaultvalue != undefined){//详细显示默认值 李伟民 0131
L 6972                     var $list = $uploadimg.find("#fileList");
6973                         var $addLi = $(
6974                             '<div class="file-item thumbnail">' +
6975                             '<img  src="' + customItems[item].defaultvalue + '">' +
6976                             '</div>'
6977                         );
6978
6979                         $list.prepend($addLi);
6980                 }
4d1219 6981                 if (_.isArray(value)) {
B 6982                         // airport = JSON.parse(airport)
6983                     value = value.join(",")
6984                   var value = JSON.parse(value);
13ec33 6985
4d1219 6986                 }
B 6987                 console.log(value)
6988                 if (typeof value != "string") {
6989                     if (typeof value == "string") {
6990                         //   value = $.parseJSON(value);
6991                     }
6992                     for (i in value) {
6993                         var $list = $uploadimg.find("#fileList");
6994                         var $addLi = $(
6995                             '<div class="file-item thumbnail">' +
bd8eb1 6996                             '<img style="width:100px,height:100px" src="' + value[i].path + '">' +
4d1219 6997                             '</div>'
B 6998                         );
6999
7000                         $list.prepend($addLi);
7001                     }
7002                 }
7003                 //  12/18 放大图片
7004
7005                 $uploaderItem.append($uploadimg);
7006                 var particularId = $uploaderItem.attr('id') + '_1'
7007                 $uploaderItem.children().attr('id', particularId);
7008                 // var particularId =  $uploaderItem.find('#uploaderItem').attr('id')
7009                 // 详情页
7010                 var viewer = new Viewer(document.getElementById(particularId), {
7011                     url: 'data-original',
13ec33 7012
4d1219 7013                 });
B 7014                 var imgId = $uploaderItem.attr('id');
7015                 var srcUrl = $uploaderItem.find('img').attr('src');
7016                 $uploaderItem.find('img').attr('alt', ' ');
7017                 // itemId_32uploadimg
7018
7019                 // 编辑页
7020                 // console.log($('#customViewUEditor').find('#'+imgId).children())
7021                 // console.log($('#'+imgId))
7022                 // console.log($uploaderItem)
7023                 // var viewer = new Viewer(document.getElementById(imgId), {
7024                 //     url: 'data-original',
7025                 //     show:function(){
7026                 //         console.log('显示')
7027                 //     }
7028                 // });
7029                 // 12/18
7030
7031
7032             } else if (customItems[item].type == 'mytext') {
7033                 //选择表单编辑回显
7034                 console.log(customItems);
7035                 console.log(customShow);
7036                 var itemAttribute = customShow.options.customItemShow.item[customItems[item].id];
7037                 var $mytext = $("#" + customItems[item].id);
7038                 var item_title = [];
7039                 var itemVal = [];
7040                 if (itemAttribute.tag_Attribute.relevancesourcetype == "fundata") {// 关联数据回显渲染 李伟民 11-30
7041                     var titleObj = { "key": JSON.parse(itemAttribute.tag_Attribute.fundata)["key"] };
7042                     var dataObj = {
7043                         "formID": customShow.options.formid,
7044                         "tenantID": "001",
7045                         "search": [],
7046                         "pageSize": "1000",
7047                         "pageNum": "1",
7048                         "key": JSON.parse(itemAttribute.tag_Attribute.fundata)["key"],
7049                         "formData": {},
7050                         "dataRowNum": items[item]
7051                     };
7052                     var requesTitle = window.commonAjax("/datamanagement/getAssociateTitle", titleObj, "POST", true, false);
7053                     var requesData = window.commonAjax("/datamanagement/getAssociateData", dataObj, "POST", true, false);
7054                     requesTitle.done(function (res) {
7055                         console.log(res);
7056                         item_title = res.data;
7057                     });
7058                     requesData.done(function (res) {
7059                         console.log(res);
7060                         if (!_.isNull(res.data) && res.data != undefined) {
7061                             itemVal = res.data;
7062                         }
7063                     });
7064                 } else {
7065                     var myTitle = JSON.parse(window.localStorage.getItem("title"));
7066                     item_title = myTitle[item];
7067                     itemVal = items[item];
7068                 }
7069                 console.log(itemVal)
7070                 console.log(item_title);
7071                 console.log(itemVal.list);
7072                 createMxtTable(customItems[item].id, item_title, itemVal.list);// 关联数据回显渲染 李伟民 11-30
7073                 //                            var newData = [];
7074                 //                            _.each(itemVal.list,function(opt){
7075                 //                                opt = _.mapKeys(opt,function(value,key){
7076                 //                                    _.each(item_title,function(item){
7077                 //                                        if(key == item.fieldKey){
7078                 //                                            key = item.title;
7079                 //                                        }
7080                 //                                    })
7081                 //                                    return key;
7082                 //                                })
7083                 //                                console.log(_.cloneDeep(opt))
7084                 //                                newData.push(opt);
7085                 //                            })
7086                 //                            console.log(itemVal.list);
7087                 //                            console.log(newData);
7088                 var formhuixian = itemVal.list;
7089
7090                 //console.log(formhuixian);
7091                 var huixianStr = "";
7092                 for (let i in formhuixian) {
7093                     //console.log($mytext.attr("fieldkey"));
7094                     //console.log(i);
7095                     //console.log(formhuixian[i]);
7096                     if (i = $mytext.attr("fieldkey")) {
7097                         huixianStr = formhuixian[i];
7098                     }
7099                 }
7100                 //console.log(huixianStr);
7101                 $mytext.attr("formhuixian", JSON.stringify(itemVal.list));
7102                 //                     if(newData){
7103                 //                         var $value = newData;
7104                 //                         console.log($value)
7105                 //
7106                 //                                    var show = "";
7107                 //                                    var divBox = $("<div></div>");
7108                 //                                    divBox.attr('id',customItems[item].id+'divBox');
7109                 //                                    var sdata_head = "";
7110                 //                                    _.each($value,(opt,j)=>{
7111                 //                                        var ulBox = $("<ul></ul>");
7112                 //                                        for(let i in opt){
7113                 //                                            show = "";
7114                 //                                            sdata_head = '<td class="data1 '+i+'">'+i+'</td>';
7115                 //                                        show += '<li>'+'<span class="data1 '+i+'">'+i+'</span>'+'<span class="data2 '+i+'">'+opt[i]+'</span>'+'</li>';
7116                 //                                        ulBox.attr("class","addUl ulBox"+j);
7117                 //                                        ulBox.attr("id","ulBox"+j);
7118                 //                                        //console.log(show)
7119                 //                                        ulBox.append(show);
7120                 //                                        }
7121                 //                                        divBox.append(ulBox);
7122                 //                                    });
7123                 //                                    console.log(sdata_head);
7124                 //                          $mytext.append(divBox);
7125                 //                      }
7126             }
7127             if (type == 'radio' || type == 'checkbox' || type == 'dropdownlist' || type == 'tree' ||
7128                 type == 'amount' || type == 'barcode' || type == 'qrcode' || type == 'image' ||
7129                 type == 'button' || type == 'fileupload'
7130                 || type == 'subform' || type == 'link'
7131                 || type == 'splitline' || type == 'link'
7132                 || type == 'textarea'
7133             ) {
7134
7135             } else {
7136                 //值设定
7137                 customBase.setItemValue(id, type, value, 'customShow');
7138             }
7139
7140         }
7141     };
7142 }
7143
7144 //画面表示项目取得  -----------------
7145 customShow.getItems = function (saveflag) {
7146     var items = customBase.options.customItems;
7147     console.log(items);
7148     var itemTempS = {};
7149     for (item in items) {
7150         if (items.hasOwnProperty(item)) {
7151             console.log(item);
7152             console.log(items[item].type);
7153             if (items[item].type == "button" || items[item].type == "link") {
7154             } else if (items[item].type == "dropdownlist") {
7155                 // var datasourcetype = $("#"+items[item].id)[0].getAttribute("datasourcetype");
7156                 //  //主数据源
7157                 // if(datasourcetype == "masterdata"){
7158                 //   itemTempS[item] = customBase.getItemValue(items[item].id,"dropdownlistText");
7159                 //   //数据源
7160                 // }else if(datasourcetype == "datasource"){
7161                 //   itemTempS[item] = customBase.getItemValue(items[item].id,"dropdownlistText");
7162                 //   //自定义
7163                 // }else if(datasourcetype == "custom"){
7164                 //   itemTempS[item] = customBase.getItemValue(items[item].id,"dropdownlistText");
7165                 //   //API接口
7166                 // }else if(datasourcetype == "api"){
7167                 //   itemTempS[item] = customBase.getItemValue(items[item].id,"dropdownlistText");
7168                 // }
7169                 itemTempS[item] = customBase.getItemValue(items[item].id, "dropdownlistText");
7170                 console.log(itemTempS[item])
7171                 if (saveflag) {//下拉框 传值 修改  李伟民  11-09
7172                     console.log(itemTempS[item]);
7173                     _.each(itemTempS[item], function (sval, i) {
7174                         if (_.isArray(sval)) {
7175                             itemTempS[item][i] = sval.join();
7176                         }
7177                     })
7178                     //            if(_.isArray(itemTempS[item][0])){
7179                     //                  itemTempS[item][0] = itemTempS[item][0].join(",")
7180                     //              }
7181                     console.log(itemTempS[item]);
7182                 }//下拉框 传值 修改  李伟民  11-09
7183             } else if (items[item].type == "tree") {
7184                 itemTempS[item] = customBase.getItemValue(items[item].id, "tree");
7185                 console.log(itemTempS[item])
7186                 if (saveflag) {//树形传值 修改  李元杰  11-21
7187                     console.log(itemTempS[item]);
7188                     _.each(itemTempS[item], function (sval, i) {
7189                         if (_.isArray(sval)) {
7190                             itemTempS[item][i] = sval.join();
7191                         }
7192                     })
7193                     //            if(_.isArray(itemTempS[item][0])){
7194                     //                  itemTempS[item][0] = itemTempS[item][0].join(",")
7195                     //              }
7196                 }//树形 传值 修改  李元杰  11-21
7197             } else if (items[item].type == "checkbox") {
7198                 itemTempS[item] = customBase.getItemValue(items[item].id, "checkbox");
7199                 console.log(itemTempS[item])
7200                 console.log(saveflag)
7201                 if (saveflag) {//复选框传值 修改  马习同  12-6
7202                     console.log(itemTempS[item]);
7203                     _.each(itemTempS[item], function (sval, i) {
7204                         if (_.isArray(sval)) {
7205                             itemTempS[item][i] = sval.join();
7206                         }
7207                     })
7208                     //            if(_.isArray(itemTempS[item][0])){
7209                     //                  itemTempS[item][0] = itemTempS[item][0].join(",")
7210                     //              }
7211                 }////复选框传值 修改  马习同  12-6
7212             } else if (items[item].type == "radio") {
7213                 itemTempS[item] = customBase.getItemValue(items[item].id, "radio");
7214                 console.log(itemTempS[item])
7215                 console.log(saveflag)
7216                 if (saveflag) {//复选框传值 修改  马习同  12-6
7217                     console.log(itemTempS[item]);
7218                     _.each(itemTempS[item], function (sval, i) {
7219                         if (_.isArray(sval)) {
7220                             itemTempS[item][i] = sval.join();
7221                         }
7222                     })
7223                     //            if(_.isArray(itemTempS[item][0])){
7224                     //                  itemTempS[item][0] = itemTempS[item][0].join(",")
7225                     //              }
7226                 }////复选框传值 修改  马习同  12-6
7227             } else if (items[item].type == "subform" || items[item].type == "tag" || items[item].type == "tab") {
7228
7229             } else if (items[item].type == "auto") {
7230                 var str = window.localStorage.getItem("customItem");
7231                 var prefix = (str != undefined && str != "undefined") ? JSON.parse(str) : null;
7232                 if (prefix != null && (prefix[item] != null || prefix[item] != undefined)) {
7233                     itemTempS[item] = prefix[item];
7234                 } else {
7235                     itemTempS[item] = customBase.getItemValue(items[item].id, items[item].type);
7236                 }
7237             } else {
7238                 itemTempS[item] = customBase.getItemValue(items[item].id, items[item].type);
7239                 console.log(itemTempS[item]);
7240             }
7241         }
7242     };
7243     var itemRetuen = {};
7244
7245     //子表单数据变换
7246     for (item in customBase.options.customItems) {
7247         if (customBase.options.customItems.hasOwnProperty(item)) {
7248             if (customBase.options.customItems[item].type == "subform" || customBase.options.customItems[item].type == "tag" || customBase.options.customItems[item].type == "tab") {
7249                 var id = customBase.options.customItems[item].id.replace("itemId_", "");
7250                 itemRetuen[id] = {};
7251             }
7252         }
7253     }
7254     console.log(_.cloneDeep(itemRetuen));
7255     console.log(_.cloneDeep(itemTempS));
7256     //子表单内数据保存
7257     for (item in itemTempS) {
7258         ////console.log(items);
7259         ////console.log(itemTempS);
7260         ////console.log(item);
7261         if (itemTempS.hasOwnProperty(item)) {
7262             var parentsubFormNum = customBase.options.customItems[item].parentsubFormNum;
7263             ////console.log(customBase.options)
7264             ////console.log(customBase.options.customItems[item]);
7265             ////console.log(parentsubFormNum);
7266             if (parentsubFormNum == "0") {
7267                 if (customBase.options.customItems[item].type == "radio" ||
7268                     customBase.options.customItems[item].type == "checkbox" ||
7269                     customBase.options.customItems[item].type == "dropdownlist" ||
7270                     customBase.options.customItems[item].type == "tree"
7271                 ) {
7272                     itemRetuen[item] = itemTempS[item][0];
7273                 } else {
7274                     itemRetuen[item] = itemTempS[item];
7275                 }
7276             } else {
7277                 ////console.log(item);
7278                 ////console.log(items);
7279                 ////console.log(itemRetuen[parentsubFormNum]);
7280                 ////console.log(itemTempS[item]);
7281                 ////console.log(itemRetuen);
7282                 ////console.log(parentsubFormNum);
7283                 itemRetuen[parentsubFormNum][item] = itemTempS[item];
7284             }
7285         }
7286     }
7287     //子表单内最终数据变换
7288     console.log(_.cloneDeep(itemRetuen));
7289     console.log(customBase.options.customItems);
7290     for (item in customBase.options.customItems) {
7291         if (customBase.options.customItems.hasOwnProperty(item)) {
7292             if (customBase.options.customItems[item].type == "subform" || customBase.options.customItems[item].type == "tag" || customBase.options.customItems[item].type == "tab") {
7293                 var id = customBase.options.customItems[item].id.replace("itemId_", "");
7294                 var tepItem = itemRetuen[id];
7295                 var subformIten = [];
7296                 var i = 0;
7297                 console.log(tepItem);
7298                 for (tem in tepItem) {
7299                     if (tepItem.hasOwnProperty(tem)) {
7300                         if (typeof tepItem[tem] == "string") {
7301                             if (subformIten[0] == undefined) {
7302                                 subformIten[0] = {};
7303                             }
7304                             subformIten[0][tem] = tepItem[tem];
7305                         } else {
7306                             console.log(tepItem[tem]);
7307                             for (var i = 0; i < tepItem[tem].length; i++) {
7308                                 if (subformIten[i] == undefined) {
7309                                     subformIten[i] = {};
7310                                 }
7311                                 subformIten[i][tem] = tepItem[tem][i];
7312                             }
7313                         }
7314                     }
7315                 }
7316                 delete itemRetuen[id];
7317                 console.log(_.cloneDeep(subformIten));
7318                 itemRetuen[customBase.options.customItems[item].fieldKey] = subformIten;
7319             }
7320         }
7321     }
7322     console.log(_.cloneDeep(itemRetuen));
7323     return itemRetuen;
7324 }
7325
7326 //取消事件
7327 customShow.onclickCancel = function () {
7328     // var items = customShow.getItems();
7329     //检证执行
7330     var saveReturn = customShow.initEvent.cancelEventLinkage();
7331     if (!saveReturn) {
7332         return;
7333     }
7334
7335     //取消接口(第三方提供)
7336     var saveReturn = customShow.initEvent.cancelEvent3rd();//--------------------
7337     if (saveReturn) {
7338         // 取消接口
7339         customShow.initEvent.cancelEvent();//--------------------
7340     }
7341     if (customShow.options.customShowFlag == "3") {
7342         // window.close();
7343         window.location.href = "about:blank";
7344         window.close();
7345     } else if (customShow.options.customShowFlag == "0" || customShow.options.customShowFlag == "1" || customShow.options.customShowFlag == "2") {
7346         window.parent.$('#myModal').modal('hide');
7347         if (customShow.options.breakFlag) {
7348             window.parent.addFormData();
7349         }
7350         if (customShow.options.customShowFlag == "1" || customShow.options.customShowFlag == "2") {
7351             $(window.parent.document.body).css({ "overflow-x": "auto", "overflow-y": "auto" });
7352         }
7353         window.parent.$("#myFormDesign").css("display", "");
7354         window.parent.$(".htmlediterClass").css("display", "");
7355     }
7356 }
7357
7358 //印刷事件  打印
7359 customShow.onPrint = function () {
7360     var items = customShow.getItems();
7361     var interfacep = customShow.initEvent.interfaceprint3rd(items);
7362     if (!interfacep) {
7363         return;
7364     }
7365     var removePrintArea = function (id) {
7366         $("iframe#" + id).remove();
7367     };
7368     var customShowFlag = window.localStorage.getItem("customShowFlag");
7369     if (customShowFlag == "0") {
7370         var itemOnPrint = $("#customViewUEditor")[0].cloneNode(true);
7371         $(itemOnPrint).css("overflow", 'visible');
7372         $(itemOnPrint).printArea();
7373     }else{
7374         var itemOnPrint = $("#customShow")[0].cloneNode(true);
7375         $(itemOnPrint).css("overflow", 'visible');
7376         $(itemOnPrint).printArea();
7377     }
7378 }
7379
7380 //编辑按钮按下时
7381 customShow.onEditor = function () {
7382     // $(".preview-edit-pane").css("display", "none");
7383     window.localStorage.setItem("customShowFlag", 3);
7384     var formIDs = customlocalStorage.newFormID;
7385
7386     customDataBound.formsetting(formIDs, function () { });
7387     //console.log("编辑存值");
7388     $("#customShow").empty();
7389     if (customShow.options.customShowFlag != "3") {
7390         //图片文件上传
7391         var uploaderImage = $(".customViewUEditorCss .uploaderImage");
7392         for (var i = 0; i < uploaderImage.length; i++) {
7393             $("#" + uploaderImage[i].id).find('.imgfileLiShow').remove();
7394             var imageItem = customShow.options.customItemShow.item[uploaderImage[i].id];
7395             var itemList = customBase.options.uploaderItemReady[uploaderImage[i].id];
7396             if (customShow.options.customShowFlag == "3") {
7397
7398             }
7399             // 参数设定
7400             var potion = {
7401                 id: uploaderImage[i].id,
7402                 width: imageItem.tag_Attribute.width,
7403                 height: imageItem.tag_Attribute.height,
7404                 formid: customShow.options.formid,
7405                 imagetype: imageItem.tag_Attribute.dropdowntype, //图片类型
7406                 editable: imageItem.tag_Attribute.editable, //是否可编辑
7407                 defaultvalueUrl: imageItem.tag_Attribute.defaultvalue, //默认的Url
7408                 ItemReady: itemList,
7409                 visible:imageItem.tag_Attribute.visible
7410             }
7411             //  12/18
7412             customBase.uploaderShow(potion);
7413
7414             // customBase.uploaderShow("#"+uploaderImage[i].id,{width:0,height:200},true,customShow.options.formid);
7415
7416         };
7417
7418         //文本文件上传
7419         var uploaderFile = $(".customViewUEditorCss .uploaderFile");
7420
7421         for (var i = 0; i < uploaderFile.length; i++) {
7422             $("#" + uploaderFile[i].id + "  .filelist").empty();
7423
7424             var imageItem = customShow.options.customItemShow.item[uploaderFile[i].id];
7425             debugger
7426             var itemList = customBase.options.uploaderItemReady[uploaderFile[i].id];
7427             // 参数设定
7428             var potion = {
7429                 id: uploaderFile[i].id,
7430                 width: imageItem.tag_Attribute.width,
7431                 height: imageItem.tag_Attribute.height,
7432                 formid: customShow.options.formid,
7433                 imagetype: imageItem.tag_Attribute.dropdowntype, //图片类型
7434                 editable: imageItem.tag_Attribute.editable, //是否可编辑
7435                 defaultvalueUrl: imageItem.tag_Attribute.defaultvalue, //默认的Url
7436                 ItemReady: itemList,
7437                 visible:imageItem.tag_Attribute.visible
7438             }
7439             customBase.uploaderFileShow(potion);
7440             // customBase.uploaderShow_Temp("#"+uploaderFile[i].id,{width:0,height:200},false,customShow.options.formid);
7441         };
7442     }
7443     $("#customViewUEditor")[0].style.display = "block";
7444     $("#customShow")[0].style.display = "none";
7445     $("#customShow").css("display", "none");
7446     $("#customShow").removeClass("fui-form");
7447     // $(".footer")[0].style.display ="block";
7448     // $(".preview-edit-pane")[0].style.display ="none";
7449     // $(".footer .fromSaveCss")[0].style.display ="block";
7450
7451     var btns = [
7452         // 'printableBtn',
7453         //12/23'exportBtn',
7454         //12/23 'rejectBtn',
7455         // 12/23 'submitBtn',
7456         //12 /23 'auditableBtn',
7457         // 12/23 'queryBtn',
7458         // 'createBtn',
7459         // 'clearBtn',
7460         //  12/23 'disposableBtn',
7461         // 'fromSaveBtn',
7462         // 'editableBtn'
7463     ];
7464     customShow.setToolBtn(btns);
7465
7466     customShow.setXhSelectList();
7467     //子表单事件调用
7468     customShow.clickBindSubform();
7469     //2017/11/18  马习同修改 隐藏预览模式下  导入数据按钮
7470     $(".sonImportFile").removeClass("cfg_contentNone");
7471     //s_savebtn
7472     $(".s_savebtn").show();
7473     // $(".preview-edit-pane").css("display", "none");
7474     //12/23
7475     // $('#disposableBtn').css('display','none');
7476     // $('#clearBtn').css('display','none');
7477     // $('#queryBtn').css('display','none');
7478     // $('#auditableBtn').css('display','none');
7479     // $('#submitBtn').css('display','none');
7480     // $('#rejectBtn').css('display','none');
7481
7482 }
7483
7484 //画面验证
7485 customShow.onfromCheck = function (items) {
7486     if ($(".errorCheckCss").length > 0) {
7487         return true;
7488     }
7489     if($(".checkErr") > 0){
7490         return true;
7491     }
7492     $(".errorItemCss").removeClass("errorItemCss");
7493     $(".mesageErrDiv").remove();
7494     for (var id in customShow.options.showErrId) {
7495         $($(".customViewUEditorCss  #" + id)[customShow.options.showErrId[id]]).popover('hide');
7496     }
7497
7498     //必须入力验证
7499     mustcheckExe = function (tag_Type, value, ItemId, N) {
7500         if (tag_Type == "text" || tag_Type == "textarea" ||
7501             tag_Type == "number" || tag_Type == "htmlediter" || tag_Type == "fileupload" ||
7502             tag_Type == "calendar") {
7503             if (tag_Type == "fileupload") {
7504                 var count = 0;
7505                 for (var key in value) {
7506                     count++;
7507                 }
7508                 if (count == 0) {
7509                     value = "";
7510                 }
7511
7512             }
7513             if (value == "") {
7514                 customShow.showErrorItem(tag_Type, ItemId, N);
7515                 var message = customBase.getMessage("mesage_ID004");
7516                 customShow.setShowMesageErr(ItemId, message, N);
7517                 mustcheck = true;
7518             }
7519         } else if (tag_Type == "checkbox" || tag_Type == "dropdownlist") {
7520             // //////////console.log(value);
7521             if (value.length == 0) {
7522                 customShow.showErrorItem(tag_Type, ItemId, N);
7523                 var message = customBase.getMessage("mesage_ID004");
7524                 customShow.setShowMesageErr(ItemId, message, N);
7525                 mustcheck = true;
7526             }
7527         }
7528     }
7529
7530     //数值型验证
7531     numberFormatCheck = function (numbertype, value, ItemId, N) {
7532         if (numbertype == "integer") {
7533             if (value.indexOf(".") > -1) {
7534                 var message = customBase.getMessage("mesage_ID019");
7535                 customShow.showErrorItem("number", ItemId, N);
7536                 customShow.setShowMesageErr(ItemId, message, N);
7537                 mustcheck = true;
7538             } else {
7539                 var numberMaxlength = customShow.options.customItemShow.item[ItemId].tag_Attribute.maxlength;
7540                 numberMaxlength = parseInt(numberMaxlength);
7541                 if (value.length > numberMaxlength && numberMaxlength != 0) {
7542                     customShow.showErrorItem("number", ItemId, N);
7543                     var message = customBase.getMessage("mesage_ID020");
7544                     customShow.setShowMesageErr(ItemId, message, N);
7545                     mustcheck = true;
7546                 }
7547             }
7548         } else {
7549             var integerItem;
7550             integerItem = value.split(".");
7551             //整数长度
7552             // var aa = customShow.options.customItemShow.item[subformItemId].tag_Attribute.alias;
7553             var numberMaxlength = customShow.options.customItemShow.item[ItemId].tag_Attribute.maxlength;
7554             numberMaxlength = parseInt(numberMaxlength);
7555             var numberdecimalplace = customShow.options.customItemShow.item[ItemId].tag_Attribute.decimalplace;
7556             numberdecimalplace = parseInt(numberdecimalplace);
7557             if (integerItem[0].length > numberMaxlength && numberMaxlength != 0) {
7558                 customShow.showErrorItem("number", ItemId, N);
7559                 var message = customBase.getMessage("mesage_ID020");
7560                 customShow.setShowMesageErr(ItemId, message, N);
7561                 mustcheck = true;
7562             }
7563             if (integerItem[2] != undefined && integerItem[1].length > numberdecimalplace) {
7564                 customShow.showErrorItem("number", ItemId, N);
7565                 var message = customBase.getMessage("mesage_ID021");
7566                 customShow.setShowMesageErr(ItemId, message, N);
7567                 mustcheck = true;
7568             }
7569             ////////console.log(customShow.options.customItemShow.item[ItemId].tag_Attribute);
7570         }
7571     }
7572
7573     //文本格式验证
7574     maxlengthCheck = function (maxlength, value, ItemId, N) {
7575         if (value.length > maxlength && maxlength != 0) {
7576             customShow.showErrorItem("htmlediter", ItemId, N);
7577             var message = customBase.getMessage("mesage_ID023");
7578             customShow.setShowMesageErr(ItemId, message, N);
7579             mustcheck = true;
7580         }
7581     }
7582     //文本格式验证
7583     textFormatCheck = function (format, value, ItemId, N) {
7584         if (value == "") {
7585             return;
7586         } else if (format == "phone") {
7587             //手机号
7588             var p1 = /^1[3|4|5|7|8][0-9]{9}$/;
7589             var me = false;
7590             if (!p1.test(value)) {
7591                 customShow.showErrorItem("text", ItemId, N);
7592                 var message = customBase.getMessage("mesage_ID009");
7593                 customShow.setShowMesageErr(ItemId, message, N);
7594                 mustcheck = true;
7595             }
7596         } else if (format == "url") {
b81a80 7597             //网址 张吉男修改网址验证
Z 7598             // var strRegex = "^((https|http|ftp|rtsp|mms)?://)"
7599             //     + "?(([0-9a-z_!~*'().&=+$%-]+: )?[0-9a-z_!~*'().&=+$%-]+@)?" //ftp的user@
7600             //     + "(([0-9]{1,3}\.){3}[0-9]{1,3}" // IP形式的URL- 199.194.52.184
7601             //     + "|" // 允许IP和DOMAIN(域名)
7602             //     + "([0-9a-z_!~*'()-]+\.)*" // 域名- www.
7603             //     + "([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\." // 二级域名
7604             //     + "[a-z]{2,6})" // first level domain- .com or .museum
7605             //     + "(:[0-9]{1,4})?" // 端口- :80
7606             //     + "((/?)|" // a slash isn't required if there is no file name
7607             //     + "(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)$";
7608             var strRegex="[a-zA-z]+://[^\s]*";
4d1219 7609             var re = new RegExp(strRegex);
B 7610             if (!re.test(value)) {
7611                 customShow.showErrorItem("text", ItemId, N);
7612                 var message = customBase.getMessage("mesage_ID010");
7613                 customShow.setShowMesageErr(ItemId, message, N);
7614                 mustcheck = true;
7615             }
7616         } else if (format == "cardno") {
7617             //身份证
7618             // 2018.1.25 张吉男修改  身份证验证错误
7619             // 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;
7620             var p1=/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
7621             // alert(1111);
7622             if (!p1.test(value)) {
7623                 customShow.showErrorItem("text", ItemId, N);
7624                 var message = customBase.getMessage("mesage_ID011");
7625                 customShow.setShowMesageErr(ItemId, message, N);
7626                 mustcheck = true;
7627             }
7628         } else if (format == "email") {
7629             //邮箱
7630             var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
7631             if (!myreg.test(value)) {
7632                 customShow.showErrorItem("text", ItemId, N);
7633                 var message = customBase.getMessage("mesage_ID012");
7634                 customShow.setShowMesageErr(ItemId, message, N);
7635                 mustcheck = true;
7636             }
7637         }
7638     }
7639     var customItems = customBase.options.customItems;
7640     //必须入力验证
7641     var mustcheck = false;
7642     for (fieldKey in customItems) {
7643
7644         if (customItems.hasOwnProperty(fieldKey)) {
7645             ////console.log(customItems);
7646             var tag_Type = customItems[fieldKey].type;
7647             var ItemId = customItems[fieldKey].id;
7648             if (customItems[fieldKey].visible) {
7649                 if (customItems[fieldKey].mustcheck) {
7650                     var value = items[fieldKey];
7651                     //子表单的情况
7652                     if (value == undefined) {
7653
7654                         //取得对应子表单ID
7655                         var subformItemId = "itemId_" + customItems[fieldKey].parentsubFormNum;
7656                         if (customShow.options.customItemShow.item[subformItemId] != undefined) {
7657                             var subformItemAlias = customShow.options.customItemShow.item[subformItemId].tag_Attribute.alias;
7658                             var subformItem = items[subformItemAlias];
7659                             for (var i = 0; i < subformItem.length; i++) {
7660                                 mustcheckExe(tag_Type, subformItem[i][fieldKey], ItemId, i);
7661                             }
7662                         }
7663                     } else {
7664                         mustcheckExe(tag_Type, value, ItemId, 0);
7665                     }
7666                 }
7667                 //文本格式验证
7668                 if (customItems[fieldKey].type == "text") {
7669                     var value = items[fieldKey];
7670                     ////console.log(fieldKey);
7671                     ////console.log(customItems);
7672                     ////console.log(value);
7673                     var format = customShow.options.customItemShow.item[ItemId].tag_Attribute.format;
7674                     //子表单的情况
7675                     if (value == undefined) {
7676                         //取得对应子表单ID
7677                         var subformItemId = "itemId_" + customItems[fieldKey].parentsubFormNum;
7678                         var subformItemAlias = customShow.options.customItemShow.item[subformItemId].tag_Attribute.alias;
7679                         var subformItem = items[subformItemAlias];
7680                         ////console.log(items);
7681                         ////console.log(subformItemAlias);
7682                         ////console.log(subformItem);
7683                         for (var i = 0; i < subformItem.length; i++) {
7684                             textFormatCheck(format, subformItem[i][fieldKey], ItemId, i);
7685                         }
7686                     } else {
7687                         textFormatCheck(format, value, ItemId, 0);
7688                     }
7689
7690                 }
7691                 //数值整数验证
7692                 if (customItems[fieldKey].type == "number") {
7693                     var value = items[fieldKey];
7694                     //数值格式
7695                     var numbertype = customShow.options.customItemShow.item[ItemId].tag_Attribute.numbertype;
7696                     //子表单的情况
7697                     if (value == undefined) {
7698                         //取得对应子表单ID
7699                         var subformItemId = "itemId_" + customItems[fieldKey].parentsubFormNum;
7700                         var subformItemAlias = customShow.options.customItemShow.item[subformItemId].tag_Attribute.alias;
7701                         var subformItem = items[subformItemAlias];
7702                         for (var i = 0; i < subformItem.length; i++) {
7703                             numberFormatCheck(numbertype, subformItem[i][fieldKey], ItemId, i);
7704                         }
7705                     } else {
7706                         numberFormatCheck(numbertype, value, ItemId, 0);
7707                     }
7708
7709                 }
7710
7711                 //默认长度检证
7712                 if (customItems[fieldKey].type == "htmlediter") {
7713                     var value = items[fieldKey];
7714                     //数值格式
7715                     var maxlength = customShow.options.customItemShow.item[ItemId].tag_Attribute.maxlength;
7716                     // //子表单的情况
7717                     // if(value ==undefined){
7718                     //   //取得对应子表单ID
7719                     //   var subformItemId = "itemId_"+customItems[fieldKey].parentsubFormNum;
7720                     //   var subformItemAlias = customShow.options.customItemShow.item[subformItemId].tag_Attribute.alias;
7721                     //   var subformItem = items[subformItemAlias];
7722                     //   for(var i=0;i<subformItem.length;i++){
7723                     //      numberFormatCheck(numbertype,subformItem[i][fieldKey],ItemId,i);
7724                     //   }
7725                     // }else{
7726                     maxlengthCheck(maxlength, value, ItemId, 0);
7727                     // }
7728
7729                 }
7730             }
7731         }
7732     }
7733     //焦点事件
7734     // $(".errorItemCss").unbind('focus');
7735     // $(".errorItemCss").on('focus', function() {
7736     //     $(this).removeClass("errorItemCss");
7737     //     ////////////console.log($(this)[0].id);
7738     //     $("#"+$(this)[0].id+"mesageErrDiv").remove();
7739     //     $(".customViewUEditorCss  #"+$(this)[0].id).popover('hide')
7740     // });
7741     // //下拉列表点击事件
7742     // $(".select2-search__field").unbind("focus");
7743     // $(".select2-search__field").bind("focus",function(){
7744     //   var id = this.getAttribute("errorItemId");
7745     //   var N = this.getAttribute("N");
7746     //   $($('.customViewUEditorCss #'+id)[N].parentNode).find(".select2").removeClass("errorItemCss");
7747     //   $("#"+id+"mesageErrDiv").remove();
7748     //   $($(".customViewUEditorCss  #"+id)[N]).popover('hide')
7749     // });
7750
7751     if (mustcheck) { return true; }
7752
7753     //单选按钮长度验证
7754
7755     //焦点事件
7756     // $(".errorItemCss").unbind();
7757     // $(".errorItemCss").on('focus', function() {
7758     //   $(this).removeClass("errorItemCss");
7759     // });
7760     return false;
7761 }
7762
7763 //检证验证
7764 customShow.interfaceCheck = function (items) {//保存前计算费用  李伟民   10 - 31
7765     var flag = true;
7766     _.each(customBase.interfaceData, function (intdata) {
7767         var func = intdata.customInterfacemethod + "()";
5a4f8f 7768         if(intdata.interfacemethod == 'fromSave3rd'){//只执行保存接口事件
L 7769             try {//解决不上传资源文件JS报错 导致无法保存  李伟民 0129
7770                 var thisChheck = eval(func);
7771                 console.log(thisChheck);
7772                 if (thisChheck == false) {
7773                     flag = false;
7774                 }
7775             } catch (error) {
13ec33 7776
5a4f8f 7777             }
4d1219 7778         }
B 7779     });
7780     return flag;
7781 }//保存前计算费用  李伟民   10 - 31
7782
7783 //错误信息
7784 customShow.showErrorItem = function (errorClass, tag_Type, id, N) {
7785     if (tag_Type == "text" || tag_Type == "textarea" || tag_Type == "number" || tag_Type == "calendar"
7786         || tag_Type == "checkbox") {
7787         $($(".customViewUEditorCss  #" + id)[N]).addClass(errorClass);
7788     } else if (tag_Type == "htmlediter") {
7789         // $(".customViewUEditorCss  #"+id+"Item").addClass(errorClass);
7790         UE.getEditor(id + "Item").body.setAttribute("class", errorClass);
7791         if (UE.getEditor(id + "Item").body.getAttribute("heightFlag") == "height") {
7792         } else {
7793             var height = UE.getEditor(id + "Item").body.style.height.replace("px", "");
7794             height = parseInt(height) - 12;
7795             UE.getEditor(id + "Item").body.style.height = height + "px";
7796             UE.getEditor(id + "Item").body.setAttribute("id", id);
7797         }
7798         UE.getEditor(id + "Item").body.setAttribute("heightFlag", height);
7799
7800         // //////////console.log(UE.getEditor(id+"Item").body.style.height = );
7801     } else if (tag_Type == "dropdownlist") {
7802         //  $(".customViewUEditorCss  #"+id).p + ".selection").addClass(errorClass);
7803         // //////////console.log($('.customViewUEditorCss #'+id)[0].parentNode);
7804         $($('.customViewUEditorCss #' + id)[N].parentNode).find(".select2").addClass(errorClass);
7805         //  $(".customViewUEditorCss  #"+id+" .select2-search__field")
7806         if ($($('.customViewUEditorCss #' + id)[N].parentNode).find(".select2-search__field").length > 0) {
7807             $($('.customViewUEditorCss #' + id)[N].parentNode).find(".select2-search__field")[0].setAttribute("errorItemId", id);
7808             $($('.customViewUEditorCss #' + id)[N].parentNode).find(".select2-search__field")[0].setAttribute("N", N);
7809         }
7810     }
7811 }
7812
7813 //画面属性设定(初始值 表示/非表示  只读 必须 审查必须)
7814 customShow.setShowAttribute = function (aliasItem) {
7815     console.log(aliasItem)
7816     //  12/7  不可编辑 可以编辑
7817     id = aliasItem.id;
7818     //表示非表示
7819     if (aliasItem.visible) {
7820         $(".customViewUEditorCss #" + id).removeClass("cfg_contentNone");
7821         $(".customViewUEditorCss #" + id + "ActiveId").removeClass("cfg_contentNone");
7822         $(".customViewUEditorCss ." + id + "IconShow").removeClass("cfg_contentNone");
7823         $(".customViewUEditorCss #" + id + "Item").removeClass("cfg_contentNone");
7824         if (customShow.options.customItemShow.customFlag == "1" && aliasItem.type == "dropdownlist") {
7825             $($(".customViewUEditorCss #" + id)[0].parentNode).removeClass("cfg_contentNone");
7826         }
7827     } else if (!aliasItem.visible) {
7828         $(".customViewUEditorCss #" + id).addClass("cfg_contentNone");
7829         $(".customViewUEditorCss #" + id + "ActiveId").addClass("cfg_contentNone");
7830         $(".customViewUEditorCss ." + id + "IconShow").addClass("cfg_contentNone");
7831         $(".customViewUEditorCss #" + id + "Item").addClass("cfg_contentNone");
7832         if (customShow.options.customItemShow.customFlag == "1" && aliasItem.type == "dropdownlist") {
7833             $($(".customViewUEditorCss #" + id)[0].parentNode).addClass("cfg_contentNone");
7834         }
7835     }
7836     //必须
7837     if (aliasItem.mustcheck) {
7838         $(".customViewUEditorCss ." + id + "IconShow .iconMustcheck").removeClass("cfg_contentNone");
7839     } else if (!aliasItem.mustcheck) {
7840         $(".customViewUEditorCss ." + id + "IconShow .iconMustcheck").addClass("cfg_contentNone");
7841     }
7842     //审查必须
7843     if (aliasItem.approvalmustenter) {
7844         $(".customViewUEditorCss ." + id + "IconShow .iconApprovalmustenter").removeClass("cfg_contentNone");
7845     } else if (!aliasItem.approvalmustenter) {
7846         $(".customViewUEditorCss ." + id + "IconShow .iconApprovalmustenter").addClass("cfg_contentNone");
7847     }
7848
7849     //编辑-非编辑
7850     var itemTemp = $($(".customViewUEditorCss #" + id)[0]);
7851     var tag_Type = aliasItem.type;
7852     if (aliasItem.editable) {
7853         if (tag_Type == "text" || tag_Type == "textarea" || tag_Type == "number" || tag_Type == "calendar") {//--OK
7854             itemTemp.removeAttr('readonly');
7855             //  非编辑情况移除背景颜色  12/7 李元杰
7856             for (var i = 0; i < itemTemp.length; i++) {
7857                 console.log(itemTemp[i]);
7858                 $(itemTemp[i]).removeClass('disableColor')
7859             }
7860             if (tag_Type == "calendar") {
7861                 var calendarItem = customShow.options.customItemShow.item[id];
7862                 // var editable = tag_Attribute['editable'];
7863                 var textformat = calendarItem.tag_Attribute.datatype;
7864                 if (textformat == 'Y') {
7865                     $(itemTemp).addClass('dateFromyyyy');
7866                 } else if (textformat == 'Y-m') {
7867                     $(itemTemp).addClass('dateFromyyyymm');
7868                 } else if (textformat == 'Y-m-d') {
7869                     $(itemTemp).addClass('dateFromyyyymmdd');
7870                 } else if (textformat == 'Y-m-d H:i') {
7871                     $(itemTemp).addClass('dateFromhhmiss');
7872                 }
7873                 customShow.clickBindSubform();
7874
7875             }
7876         } else if (tag_Type == "radio") {//----------------------------------------------------------
7877             itemTemp.find('.custom-radio').removeAttr("readonly");
7878         } else if (tag_Type == "radio") {//----------------------------------------------------------
7879             itemTemp.find('.custom-radio').removeAttr("readonly");
7880         } else if (tag_Type == "checkbox") {//-------------------------------------------------------
7881             itemTemp.find('.custom-check').removeAttr("readonly");
7882         } else if (tag_Type == "dropdownlist") {//---------------------------------------------------OK
7883             // $(itemTemp).removeClass('editableDisabled');
7884             // $(itemTemp).prop("disabled", false);        //设置下拉框不可用
7885             // $(itemTemp).find(".select-container").removeAttr("readonly");
7886             $(itemTemp).removeClass("disableColor");
7887
7888             $(itemTemp).removeClass("readonly");
7889             //          ////console.log($(itemTemp).find(".select-container"));
7890         } else if (tag_Type == "button") {//---------------------------------------------------------OK
7891             $(itemTemp).removeClass('disabled');
7892         } else if (tag_Type == "link") {//-----------------------------------------------------------OK
7893             itemTemp.href = "javascript:void(0);";
7894             itemTemp.removeAttr('disabled', 'disabled');
7895         } else if (tag_Type == "fileupload") {//----------------------------------------------------todo
7896         } else if (tag_Type == "tree") {//----------------------------------------------------------todo
7897             $(itemTemp).parent().find('.citySel').removeClass('disableColor')
7898
7899             //   var itemTemp = $("#customResultFormDiv").find("#"+tag_Id)[0];
7900             itemTemp[0].setAttribute('editable', aliasItem.editable);
7901         }
7902         // else if (tag_Type == "tree" || tag_Type == "tree" || tag_Type == "tree") {
7903         //     //  var itemTemp = $("#customResultFormDiv").find("#"+tag_Id)[0];
7904         //     itemTemp.setAttribute('editable', aliasItem.editable);
7905         // }
7906
7907     } else if (!aliasItem.editable) {
7908         if (tag_Type == "text" || tag_Type == "textarea" || tag_Type == "number" || tag_Type == "calendar") {//--OK
7909             for (var i = 0; i < itemTemp.length; i++) {
7910                 //  12/7 李元杰 添加背景颜色
7911                 console.log(itemTemp[i]);
7912                 itemTemp[i].setAttribute('readonly', '');
7913                 $(itemTemp[i]).addClass('disableColor')
7914             }
7915             if (tag_Type == "calendar") {
7916                 // $('.dateFromyyyy').unbind();
7917                 // $('.dateFromyyyymm').unbind();
7918                 // $('.dateFromyyyymmdd').unbind();
7919                 // $('.dateFromhhmiss').unbind();
7920                 itemTemp.removeClass('dateFromyyyy');
7921                 itemTemp.removeClass('dateFromyyyymm');
7922                 itemTemp.removeClass('dateFromyyyymmdd');
7923                 itemTemp.removeClass('dateFromhhmiss');
7924                 ////////console.log(itemTemp);
7925                 var itemDateFromTemp = itemTemp[0].cloneNode(true);
7926                 var $DateFromTemp = "<div id='itemDateFromTemp'></div>"
7927                 itemTemp.after($DateFromTemp);
7928                 itemTemp.remove();
7929                 var DateFromTemp = $("#itemDateFromTemp")[0];
7930                 DateFromTemp.after(itemDateFromTemp);
7931                 DateFromTemp.remove();
7932                 customShow.clickBindSubform();
7933             }
7934         } else if (tag_Type == "radio") {//----------------------------------------------------------todo
7935
7936             // setTimeout(function(){
7937             itemTemp.find('.custom-radio').addClass("readonly");
7938             // },0)
7939         } else if (tag_Type == "checkbox") {//-------------------------------------------------------todo
7940             itemTemp.find('.custom-check').addClass("readonly");
7941         } else if (tag_Type == "dropdownlist") {//---------------------------------------------------OK
7942             // $(itemTemp).addClass('editableDisabled');
7943             // $(itemTemp).prop("disabled", true);        //设置下拉框不可用
7944             // ////console.log($(itemTemp).find(".select-container"));
7945             // itemTemp = $(itemTemp).find(".select-container");
7946             // for(var i = 0 ;i<itemTemp.length;i++){
7947             //   itemTemp[i].setAttribute('readonly','');
7948             // }
7949             console.log($(itemTemp))
7950             $(itemTemp).find('.select-container_box').addClass('disableColor')
7951             $(itemTemp).addClass("readonly");
7952             ////console.log( $(itemTemp));
7953         } else if (tag_Type == "button") {//---------------------------------------------------------OK
7954             $(itemTemp).addClass('disabled');
7955         } else if (tag_Type == "link") {//-----------------------------------------------------------OK
7956             itemTemp.href = "javascript:void(0);";
7957             debugger
7958             for (var i; i < itemTemp.length; i++) {
7959                 itemTemp[i].setAttribute('disabled', 'disabled');
7960             }
7961         } else if (tag_Type == "fileupload") {//----------------------------------------------------todo
7962             console.log($(itemTemp));
7963             debugger
7964         } else if (tag_Type == "tree") {//----------------------------------------------------------todo
7965             // 禁用背景颜色
7966             console.log($(itemTemp).parents('div[name="TreeWin"]'))
7967             console.log($(itemTemp))
7968
7969             itemTemp[0].setAttribute('editable', aliasItem.editable);
7970         }
7971         // else if (tag_Type == "tree" || tag_Type == "tree" || tag_Type == "tree") {
7972         //     //  var itemTemp = $("#customResultFormDiv").find("#"+tag_Id)[0];
7973         //     console.log($(itemTemp))
7974         //     itemTemp.setAttribute('editable', aliasItem.editable);
7975         // }
7976     }
7977 }
7978 //错误信息显示
7979 customShow.setShowMesageErr = function (id, message, N, type) {
7980     console.log("setShowMesageErr");
7981     console.log(message);
7982     ////console.log(id);
5a4f8f 7983     var mesageHtml = '<div class="' + id + 'Popover"></div>';
4d1219 7984     if (customShow.options.customInit.designMode == "1") {
B 7985         ////console.log(id);
7986         ////console.log(message);
7987         ////console.log(N);
7988         ////console.log($($(".customViewUEditorCss  #"+id)[N]));
7989         // $($(".customViewUEditorCss  #"+id)[N]).popover('hide');
a36c19 7990         // if($($(".customViewUEditorCss  #" + id)[N]).attr('popoverFalg') != undefined){
L 7991         //    $('.' + id + 'Popover').html(message);
7992         // }
4d1219 7993         $($(".customViewUEditorCss  #" + id)[N]).attr('popoverFalg','true');
B 7994         $($(".customViewUEditorCss  #" + id)[N]).popover({
7995             // title:"错误信息",
7996             html: true,
a36c19 7997             content: mesageHtml,
4d1219 7998             trigger: 'manual'
B 7999         });
8000         $($(".customViewUEditorCss  #" + id)[N]).hover(function(){// 普通模式 错误提示修改  李伟民 0125
8001             if($($(".customViewUEditorCss  #" + id)[N]).attr('popoverFalg') != 'false'){
8002                 $($(".customViewUEditorCss  #" + id)[N]).popover('show');
a36c19 8003                 $('.' + id + 'Popover').html(message);
4d1219 8004             }
B 8005         },function(){
8006             $($(".customViewUEditorCss  #" + id)[N]).popover('hide');
8007         })
8008         $($(".customViewUEditorCss  #" + id)[N]).on('focus',function(){
8009             $($(".customViewUEditorCss  #" + id)[N]).attr('popoverFalg','false');
8010             $($(".customViewUEditorCss  #" + id)[N]).popover('hide');
8011         })
8012         $($(".customViewUEditorCss  #" + id)[N]).popover('show');
a36c19 8013         $('.' + id + 'Popover').html(message);
4d1219 8014         setTimeout(function(){
B 8015             $($(".customViewUEditorCss  #" + id)[N]).popover('hide');
8016         },2000)
8017         customShow.options.showErrId[id] = N;
8018         //////console.log($($(".customViewUEditorCss  #"+id+"Item")[N]).length);
13ec33 8019
4d1219 8020         if ($($(".customViewUEditorCss  #" + id + "Item")[N]).length == 1) {
B 8021             $($(".customViewUEditorCss  #" + id + "Item")[N]).attr('popoverFalg','true');
8022             $($(".customViewUEditorCss  #" + id + "Item")[N]).popover({
8023                 // title:"错误信息",
8024                 html: true,
a36c19 8025                 content: mesageHtml,
4d1219 8026                 trigger: 'manual'
B 8027             });
8028             $($(".customViewUEditorCss  #" + id + "Item")[N]).popover('show');
a36c19 8029             $('.' + id + 'Popover').html(message);
4d1219 8030             setTimeout(function(){
B 8031                 $($(".customViewUEditorCss  #" + id + "Item")[N]).popover('hide');
8032             },2000)
8033             customShow.options.showErrId[id + "Item"] = N;
8034             $($(".customViewUEditorCss  #" + id + "Item")[N]).hover(function(){
8035                 if($($(".customViewUEditorCss  #" + id + "Item")[N]).attr('popoverFalg') != 'false'){
8036                     $($(".customViewUEditorCss  #" + id + "Item")[N]).popover('show');
a36c19 8037                     $('.' + id + 'Popover').html(message);
4d1219 8038                 }
B 8039             },function(){
8040                 $($(".customViewUEditorCss  #" + id + "Item")[N]).popover('hide');
8041             })
8042             $($(".customViewUEditorCss  #" + id + "Item")[N]).on('focus',function(){
8043                 $($(".customViewUEditorCss  #" + id + "Item")[N]).attr('popoverFalg','false');
8044                 $($(".customViewUEditorCss  #" + id + "Item")[N]).popover('hide');
8045             })// 普通模式 错误提示修改  李伟民 0125
8046         }
13ec33 8047
4d1219 8048     } else {
B 8049         var mesageErrDiv = document.createElement("div");
8050         mesageErrDiv.setAttribute("class", "mesageErrDiv");
8051         mesageErrDiv.setAttribute("id", id + "mesageErrDiv");
8052         if(type){//验证消息 修改  李伟民
8053             $(mesageErrDiv).addClass("checkErr");
8054         }//验证消息 修改  李伟民
8055         $(mesageErrDiv).append(message);
8056         var tempActiveId = $($(".customViewUEditorCss  #" + id + "ActiveId")[N]).find("#" + id + "mesageErrDiv");
8057         $($(".customViewUEditorCss  #" + id + "ActiveId")[N]).find("#" + id + "mesageErrDiv").remove();
8058         // if(tempActiveId.length == 0){
8059         //          if($($(".customViewUEditorCss  #"+id+"ActiveId")[N]).length !=0){
8060         //2017/10/23  李元杰 必选的提示信息修改
8061         var requiredHint = $($($(".customViewUEditorCss  #" + id + "ActiveId")[N])[0]);
8062         if (requiredHint.find('input').val() === '') {
8063             if ($(".customViewUEditorCss  #" + id + "ActiveId").length == 0) {
8064                 console.log($(".customViewUEditorCss [id='" + id + "']:eq(" + N + ")").closest("td"));
8065                 $(".customViewUEditorCss [id='" + id + "']:eq(" + N + ")").closest("td").append(mesageErrDiv);
8066             } else {
8067                 $($($(".customViewUEditorCss  #" + id + "ActiveId")[N])[0]).append(mesageErrDiv);
8068             }
8069             $(mesageErrDiv).html(requiredHint.children('h8').children('span').html() + "必须输入")
8070         } else {
8071             if ($(".customViewUEditorCss  #" + id + "ActiveId").length == 0) {
8072                 console.log($(".customViewUEditorCss [id='" + id + "']:eq(" + N + ")").closest("td"));
8073                 if ($(".customViewUEditorCss [id='" + id + "']:eq(" + N + ")").closest("td").find(".mesageErrDiv").length == 0) {
8074                     $(".customViewUEditorCss [id='" + id + "']:eq(" + N + ")").closest("td").append(mesageErrDiv);
8075                 }
8076             } else {
8077                 if ($($($(".customViewUEditorCss  #" + id + "ActiveId")[N])[0]).find(".mesageErrDiv").length == 0) {
8078                     $($($(".customViewUEditorCss  #" + id + "ActiveId")[N])[0]).append(mesageErrDiv);
8079                 }
8080             }
8081         }
8082         // $(mesageErrDiv).html(requiredHint.children('h8').children('span').html() + "必须输入")
8083         //            }
8084         // }
8085
8086
8087     }
8088
8089 }
8090
8091 //DB数据to画面表示数据转化
8092 customShow.dbItemToShowItem = function (itemId, type, value, showClass, dropdowntype, parentsubFormNum) {
8093     if (type == "radio" || type == "checkbox") {
8094         var itemL = $("." + showClass + " ." + itemId + "value");
8095         //数值变换
8096         //单选按钮,仅仅有一项情况(无子表单时)
8097         if (type == "radio" && itemL.length == 1) {
8098             if (parentsubFormNum != 0) {
8099                 value = value[0];
8100             }
8101             value = [[value]];
8102         } else if (type == "checkbox" && itemL.length == 1) {
8103             //复选框时,仅仅有一项情况(无子表单时)
8104             //只选择一项
8105             if (parentsubFormNum != 0) {
8106                 value = value[0];
8107             }
8108             if (typeof value == "string") {
8109                 value = [[value]];
8110             } else {
8111                 //复数项选择
8112                 value = [value];
8113             }
8114         } else if (type == "radio" && itemL.length > 1) {
8115             //
8116             var valueTempRadio = [];
8117             for (var i = 0; i < value.length; i++) {
8118                 valueTempRadio[i] = [value[i]];
8119             }
8120             value = valueTempRadio;
8121         } else if (type == "checkbox" && itemL.length > 1) {
8122             var valueTempRadio = [];
8123             for (var i = 0; i < value.length; i++) {
8124                 if (typeof value[i] == "string") {
8125                     valueTempRadio[i] = [value[i]];
8126                 } else {
8127                     valueTempRadio[i] = value[i];
8128                 }
8129             }
8130             value = valueTempRadio;
8131         }
8132     } else if (type == "dropdownlistText") {
8133
8134         //多个下拉菜单
8135         var itemList = $("." + showClass + " ." + itemId + "value");
8136         if (itemList.length == 1) {
8137             if (parentsubFormNum != 0) {
8138                 value = value[0];
8139             }
8140             if (typeof value == "string" && dropdowntype == "single") {
8141                 value = [value];
8142             }
8143             //子表单中,复选情况
8144             if (dropdowntype == "multiple") {
8145                 if (typeof value == "string") {
8146                     value = [value];
8147                 } else {
8148                     // value = value[0];
8149                 }
8150             }
8151             // setelect2Item(itemList[0],value);
8152         } else {
8153             for (var i = 0; i < itemList.length; i++) {
8154                 // var valueTemp;
8155                 //单选时,多文件
8156                 if (dropdowntype == "single") {
8157                     value[i] = [value[i]];
8158                 } else {
8159                     // for (var i = 0; i < value[i].length; i++) {
8160                     if (typeof value[i] == "string") {
8161                         value[i] = [value[i]];
8162                     } else {
8163                         value[i] = value[i];
8164                     }
8165                     // }
8166                 }
8167                 // setelect2Item(itemList[i],valueTemp);
8168             }
8169         }
8170     }
8171     return value;
8172 }
8173
8174 //表示模式下,数据设定(单选 复选 下拉菜单)
8175 customShow.setShowItem = function (itemId, type, value, flag) {
8176     //被选择项目设定
8177     console.log(1)
8178     //  console.log(_.cloneDeep(itemId))
8179     //  console.log(_.cloneDeep(type))
8180     console.log(_.cloneDeep(value))
8181     //  console.log(_.cloneDeep(flag))
8182     checkboxRadioShow = function (showItem, value) {
8183         console.log($(showItem), value)
8184         var listData = customBase.options.dropdownlistText[itemId];
8185         if (listData == undefined) {
8186             return;
8187         }
8188         if (typeof value == "string") {
8189             value = [value];
8190             // value = JSON.parse(value)
8191         }
8192         var temp = [];
8193         var tempStr = "";
8194         console.log(listData);
8195         console.log(value)
8196         for (var i = 0; i < listData.length; i++) {
8197             for (var j = 0; j < value.length; j++) {
8198                 if (value[j] == listData[i].value) {
8199                     console.log(1)
8200                     temp[j] = listData[i].text;
8201                 }
8202             }
8203         }
8204         console.log(temp)
8205         for (var i = 0; i < temp.length; i++) {
8206             if (i == 0) {
8207                 tempStr = temp[i];
8208             } else {
8209                 tempStr += "," + temp[i];
8210             }
8211         }
8212         console.log(tempStr)
8213         $(showItem).empty();
8214         //console.log(tempStr);
8215         $(showItem).append(tempStr);
8216
8217     }
8218     var showItem = $("." + itemId + "_showItem");
8219     console.log(showItem)
8220     //页面返回
8221     if (flag) {
8222         if (type == "checkbox" || type == "radio") {
8223             if (showItem.length == 1) {
8224                 checkboxRadioShow(showItem[0], value);
8225             } else {
8226                 for (var i = 0; i < showItem.length; i++) {
8227                     checkboxRadioShow(showItem[i], value[i]);
8228                 }
8229             }
8230         } else {
8231             if (showItem.length == 1) {
8232                 checkboxRadioShow(showItem[0], value);
8233             } else {
8234                 for (var i = 0; i < showItem.length; i++) {
8235                     checkboxRadioShow(showItem[i], value[i]);
8236                 }
8237             }
8238         }
8239     } else {
8240         if (type == "checkbox" || type == "radio") {
8241             for (var i = 0; i < showItem.length; i++) {
8242                 var valueTemp = value[i];
8243                 checkboxRadioShow(showItem[i], valueTemp);
8244             }
8245         } else {
8246             if (showItem.length == 1) {
8247                 checkboxRadioShow(showItem[0], value);
8248             } else {
8249                 for (var i = 0; i < showItem.length; i++) {
8250                     checkboxRadioShow(showItem[i], value[i]);
8251                 }
8252             }
8253         }
8254     }
8255 }
8256
8257 //工具栏设定button
8258 customShow.setToolBtn = function (btns) {
8259     console.log(btns)
8260     $(".edit-pane").empty();
8261     var $editPaneBtn = $($(".edit-pane")[0]);
8262
8263     console.log($editPaneBtn)
8264     //  //////console.log(btns);
8265     for (var i = 0; i < btns.length; i++) {
8266         if (customShow.button[btns[i]].functionName == "") {
8267             $a = '<a id="' + btns[i] + '" href="javascript:void(0);">' +
8268                 '<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>';
8269         } else {
8270             $a = '<a id="' + btns[i] + '" href="javascript:void(0);" onclick="' + customShow.button[btns[i]].functionName + '()">' +
8271                 '<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>';
8272         }
8273         if (customShow.getFormSetting(btns[i]) != 0) {
8274             $editPaneBtn.prepend($a);
8275         }
8276
8277     }
8278     if (btns.length > 0) {
8279         // $(".preview-edit-pane").css("display", "block");
8280     }
8281 }
8282
8283 customShow.setTextBtn = function () {
8284     var item = customShow.options.customItemShow.item["itemId_1"];
8285     var code = item.tag_Attribute.masterData;
8286     var masterData = $.parseJSON(code);
8287     var defindCode = masterData.defindCode;
8288     var eleCode = masterData.eleCode;
8289     customLinkageAnalysis.getElement("itemId_1", eleCode, function (re) {
8290         ////////console.log(re);
8291     })
8292 }
8293
8294 //主数据重复
8295 customShow.setXhSelectList = function (addflag) {
8296     //    console.log(1)
8297     var subformDList = customShow.options.subformDList;
8298     //console.log(subformDList);
8299     //console.log(85244445)
8300     //console.log(addflag)
8301     var setValueItem = {};
8302     //
8303     //var subArr = [];
8304     //_.each(subformDList,opt=>{
8305     //    subArr.push(opt);
8306     //})
8307     //var subObj = {};
8308     //for(var key in subformDList){
8309     //    if(subformDList[key] == _.last(subArr)){
8310     //        subObj[key] = subformDList[key];
8311     //    }
8312     //}
8313     //console.log(_.cloneDeep(subObj));
8314     for (var id in subformDList) {
8315         console.log(id);
8316         if ($(".customViewUEditorCss ." + id).length == 1) {
8317             var xhSelectTemp = {
8318                 selectId: customShow.options.subformDList[id].selectId,
8319                 multiple: customShow.options.subformDList[id].multiple,
8320                 width: customShow.options.subformDList[id].width,
8321                 listData: customBase.options.dropdownlistText[customShow.options.subformDList[id].selectId],
8322                 setDiv: id
8323             };
8324             console.log(xhSelectTemp);
8325             console.log(1)
8326             xhSelect.setXhSelect(xhSelectTemp);
8327             var item = customShow.options.customItemShow.item[customShow.options.subformDList[id].selectId];
8328             setValueItem[item.tag_Attribute.alias] = customShow.options.subformDList[id].selectId;
8329         }
8330     }
8331     console.log(setValueItem);
8332     console.log(customShow.options);
8333     if (!addflag) {
8334         for (var valueItem in setValueItem) {
8335             var setList = customShow.options.subformDValue[valueItem];
8336             console.log(setList);
8337             if (setList != undefined) {
8338                 for (var i = 0; i < setList.length; i++) {
8339                     xhSelect.setValue(setValueItem[valueItem], setList[i], i);
8340                 }
8341             }
8342         }
8343
8344     }
8345 }
8346 //子表单添加记录  复制下拉框方法   2017/10/06
8347 customShow.setXhSelectListAdd = function () {
8348     // //////console.log(table);
8349     var subformDList = customShow.options.subformDList;
8350     var setValueItem = {};
8351     //10/2/27 马习同修改  下拉框复制重复
8352     var xhSelectTemp = {};
8353     for (var id in subformDList) {
8354         if ($(".customViewUEditorCss ." + id).length == 1) {
8355             var xhSelectTemp = {
8356                 selectId: customShow.options.subformDList[id].selectId,
8357                 multiple: customShow.options.subformDList[id].multiple,
8358                 width: customShow.options.subformDList[id].width,
8359                 listData: customBase.options.dropdownlistText[customShow.options.subformDList[id].selectId],
8360                 setDiv: id
8361             };
8362             // //////console.log($(".customViewUEditorCss ."+id).find('select > option'));
8363             if ($(".customViewUEditorCss ." + id).find('select > option').length == 0) {
8364                 // //////console.log("----------------------------------------------");
8365                 console.log(1)
8366                 xhSelect.setXhSelect(xhSelectTemp);
8367             }
8368         }
8369     }
8370     xhSelect.setXhSelect(xhSelectTemp);
8371     //10/2/27 马习同修改  下拉框复制重复
8372 }
8373
8374
8375 customShow.getFormSetting = function (btnFlag) {
8376     var ren = 1;
8377     if (btnFlag == 'printableBtn') {
8378         ren = customShow.options.formsetting['printable'];
8379     } else if (btnFlag == 'exportBtn') {
8380         ren = customShow.options.formsetting['exportable'];
8381     } else if (btnFlag == 'rejectBtn') {
8382         ren = customShow.options.formsetting['rejectable'];
8383     } else if (btnFlag == 'submitBtn') {
8384         ren = customShow.options.formsetting['submitable'];
8385     } else if (btnFlag == 'auditableBtn') {
8386         ren = customShow.options.formsetting['auditable'];
8387     } else if (btnFlag == 'queryBtn') {
8388         ren = customShow.options.formsetting['queryable'];
8389     } else if (btnFlag == 'createBtn') {
8390         ren = customShow.options.formsetting['createable'];
8391     } else if (btnFlag == 'clearBtn') {
8392         // ren = customShow.options.formsetting['clearable'];
8393         ren = 1;
8394     } else if (btnFlag == 'disposableBtn') {
8395         // ren = customShow.options.formsetting['disposable'];
8396         ren = 1;
0da79f 8397     //} else if (btnFlag == 'fromSaveBtn') {
75eb92 8398     //    if(customShow.options.customShowFlag != '3'){//发布修改  李伟民 0120
Z 8399     //        ren = customShow.options.formsetting['saveable'];
8400     //        console.log(ren)
8401     //    }else{
8402     //        ren = 1;
8403     //    }
4d1219 8404         // ren = 1;
B 8405     } else if (btnFlag == 'editableBtn') {
66b6b8 8406         ren = customShow.options.formsetting['editableBtn'];//编辑按钮受权限控制  李伟民 0204
L 8407         // ren = 1;
4d1219 8408     }
B 8409     return ren;
8410
8411 }
8412 var customLinkageAnalysis = customLinkageAnalysis || {};
8413 //-----------------------------------------------------仲追加内容----------------------------------------------------------
8414 customLinkageAnalysis.options = {};
8415 //取得表单值
8416 /**
8417  * 参数:ItemId 字段ID
8418  * 返回值:值
8419  */
8420 customLinkageAnalysis.getValue = function (itemId) {
8421     var item = customShow.options.customItemShow.item[itemId];
8422     var alias = item.tag_Attribute.alias;
8423     var items = customShow.getItems();
8424     var result = items[alias];
8425
8426     if (item.parentsubFormNum != 0) {
8427         for (var ItemId in customShow.options.customItemShow.item) {
8428             if (customShow.options.customItemShow.item[ItemId].columnOrderNum == item.parentsubFormNum) {
8429                 result = items[customShow.options.customItemShow.item[ItemId].tag_Attribute.alias];
8430             }
8431         }
8432         ////console.log(result);
8433         var resultTemp = "";
8434
8435         for (var i = 0; i < result.length; i++) {
8436             if (i > 0) {
8437                 resultTemp += ",";
8438             }
8439             if (typeof result[i][alias] != "string") {
8440                 resultTemp += result[i][alias].join(',');
8441             } else {
8442                 resultTemp += result[i][alias];
8443             }
8444
8445         }
8446         ////console.log(resultTemp);
8447         return resultTemp;
8448     } else if (typeof result != "string") {
8449         result = result.join(',');
8450     }
8451     ////console.log(customShow);
8452     ////console.log(customLinkageAnalysis);
8453     console.log(result);
8454     return result;
8455 }
8456
8457 //设定表单值--------------------
8458 /**
8459  * 参数:ItemId 字段ID
8460  *      value:设定值
8461  */
8462 customLinkageAnalysis.setValue = function (itemId, value, num) {
8463     console.log(itemId);
8464     console.log(value);
8465     var item = customShow.options.customItemShow.item[itemId];
8466     //数据类型
8467     var type = item.tag_Type;
8468     if (type == "text" || type == "textarea" ||
8469         type == "number" || type == "calendar") {
8470         customBase.setItemValue(itemId, "text", value, "", "", num);
8471     } else if (type == "radio" || type == "checkbox") {
8472         if (value.indexOf(",") != -1) {
8473             value = value.split(",");
8474             value = [value];
8475         }
8476         customBase.setItemValue(itemId, type, value, "customViewUEditorCss");
8477     } else if (type == "dropdownlist") {
8478         var dropdowntype = item.tag_Attribute.dropdowntype;
8479         customBase.setItemValue(itemId, "dropdownlistText", value, "customViewUEditorCss", dropdowntype);
8480     } else if (type == "htmlediter") {
8481         var id = itemId + "Item";
8482         UE.getEditor(id).setContent(value);
8483     } else if (type == "qrcode") {
8484         var id = itemId + "qrcode";
8485         customBase.setItemValue(id, 'text', value, 'customViewUEditorCss');
8486         $("#" + id).blur();
8487     } else if (type == "barcode") {
8488         var id = itemId + "barcode";
8489         customBase.setItemValue(id, 'text', value, 'customViewUEditorCss');
8490         $("#" + id).blur();
8491     } else if (type == "tree") {
8492
8493     } else if (type == "amount") {
8494         var id = itemId + "amount";
8495         customBase.setItemValue(id, 'text', value, 'customViewUEditorCss');
8496         $("#" + id).blur();
8497     }
8498
8499 }
8500
8501 //取得属性
8502 /**
8503  * 参数:ItemId 字段ID
8504  *      attributeName:属性名
8505  *                  visible  //可见                     true:可见  false:不可见
8506                     editable //可编辑                   true:可编辑  false:不可编辑
8507  */
8508 customLinkageAnalysis.getAttribut = function (itemId, attributeName) {
8509     console.log(itemId);
8510     console.log(attributeName)
8511     var item = customShow.options.customItemShow.item[itemId];
8512     // return customLinkageAnalysis.validationEx(item.tag_Attribute.alias);
8513     var alias = item.tag_Attribute.alias;
8514     var ttn = customBase.options.customItems[alias][attributeName];
8515     ////console.log(ttn)
8516     return ttn;
8517 }
8518
8519 //设定属性---------------需要测试-----
8520 /**
8521  * 参数:ItemId 字段ID
8522  *      attributeName:属性名
8523  *                  visible  //可见                     true:可见  false:不可见
8524                     editable //可编辑                   true:可编辑  false:不可编辑
8525  */
8526 customLinkageAnalysis.setAttribut = function (itemId, attributeName, attributeValue) {
8527     var item = customShow.options.customItemShow.item[itemId];
8528     // return customLinkageAnalysis.validationEx(item.tag_Attribute.alias);
8529     var alias = item.tag_Attribute.alias;
8530     console.log(alias)
8531     attributeValue = attributeValue + "";
8532     attributeValue = attributeValue.toLowerCase();
8533     if (attributeValue == "true") {
8534         attributeValue = true;
8535     } else if (attributeValue == "false") {
8536         attributeValue = false;
8537     } else {
8538         //默认值
8539         attributeValue = true;
8540     }
8541     customBase.options.customItems[alias][attributeName] = attributeValue;
8542     customShow.setShowAttribute(customBase.options.customItems[alias]);
8543 }
8544
8545 //设定错误信息
8546 /**
8547  * 参数:ItemId 字段ID
8548  *      message:信息
8549  */
8550 customLinkageAnalysis.setMessage = function (mode, ItemId, message, num) {
8551     var item = customShow.options.customItemShow.item[ItemId];
8552     var type = item.tag_Type;
8553     if (num == undefined) {
8554         num = 0;
8555     }
8556     var errorClass;
8557     if (mode == "0") {//验证消息 修改  李伟民
8558         errorClass = "errorCheckCss"
8559     } else {
8560         errorClass = "errorItemCss";
8561     }//验证消息 修改  李伟民
8562     customShow.showErrorItem(errorClass, type, ItemId, num);
8563     //焦点事件
8564     // $("." + errorClass).unbind('focus');
8565     $("[id='" + ItemId + "']:eq(" + num + ")").unbind("focus");
8566     $("[id='" + ItemId + "']:eq(" + num + ")").on('focus', function () {
8567         console.log("focus");
8568         $(this).removeClass(errorClass);
8569         ////////console.log($(this)[0].id);
8570         $(this).closest("#" + $(this)[0].id + "ActiveId").find("[id='" + $(this)[0].id + "mesageErrDiv']").remove();//修改错误信息删除  李伟民  2017-10-18 14:15
8571         $(this).closest(".tdContentClass").find("[id='" + $(this)[0].id + "mesageErrDiv']").remove();//列表模式
8572         //        $("#"+$(this)[0].id+"mesageErrDiv").remove();
8573         $(".customViewUEditorCss  #" + $(this)[0].id).popover('hide')
8574     });
8575     //下拉列表点击事件
8576     $(".select2-search__field").unbind("focus");
8577     $(".select2-search__field").bind("focus", function () {
8578         var id = this.getAttribute("errorItemId");
8579         var N = this.getAttribute("N");
8580         $($('.customViewUEditorCss #' + id)[N].parentNode).find(".select2").removeClass(errorClass);
8581         $("#" + id + "mesageErrDiv").remove();
8582         $($(".customViewUEditorCss  #" + id)[N]).popover('hide')
8583     });
8584     if (mode == "0") {//验证消息 修改  李伟民
8585         customShow.setShowMesageErr(ItemId, message, num, true);
8586     } else {
8587         customShow.setShowMesageErr(ItemId, message, num);
8588     }//验证消息 修改  李伟民
13ec33 8589
4d1219 8590 }
B 8591
8592 //设定alert信息
8593 //参数:type类型
8594 // E:错误信息
8595 // I:信息
8596 // W:警告
8597 // S:成功
8598 //  message:信息
8599 customLinkageAnalysis.alert = function (type, message) {
8600     customBase.alert(type, message);
8601 }
8602
8603
8604
8605 // 初期调用
8606 customLinkageAnalysis.bindLinkage = function () {
8607     //    ////console.log(window.customBase);
8608     //取得公式的JSON数据
8609     //  ////console.log(customShow);
8610     //  ////console.log(customLinkageAnalysis);
8611     var rules = customShow.options.jsonLinkage;
8612     if (typeof rules == 'string') {
8613         rules = eval(rules);
8614     }
8615     if (rules == null || rules.length == 0) {
8616         return;
8617     }
8618     //初期接口 (false:不继续执行 true:继续执行)
8619     // customShow.initEvent.interfaceInitLinkage;
8620
8621     //取消接口 (false:不继续执行 true:继续执行)
8622     // customShow.initEvent.cancelEventLinkage;
8623
8624     //保存接口 (false:不继续执行 true:继续执行)
8625     // customShow.initEvent.fromSaveLinkage;
8626     for (var i = 0; i < rules.length; i++) {
8627         //console.log(rules[i]);
8628         var dofunction = {};
8629         try {
8630             dofunction = customLinkageAnalysis.makeLinkage(rules[i]);
8631         } catch (e) {
8632             ////console.log(e.message);
8633             continue;
8634         }
8635         var allFunction = customLinkageAnalysis.changeDoFunction(dofunction);
8636         var fieldId = rules[i].event.eventFieldId;
8637         if (fieldId == "_body" && rules[i].event.doEvent == "loading") {
8638             customShow.initEvent.interfaceInitLinkage = customLinkageAnalysis.bindFunctionEvent(allFunction.strFunction);
8639         } else if (fieldId == "_body" && rules[i].event.doEvent == "commit") {
8640             customShow.initEvent.fromSaveLinkage = customLinkageAnalysis.bindFunctionEvent(allFunction.strFunction);
8641         }
8642         var item = customShow.options.customItemShow.item[fieldId];
8643         if (item != undefined) {
8644             var doEvent = rules[i].event.doEvent;
8645             doEvent = doEvent.replace("selectedChange", "change");
8646             if (item.tag_Type == "radio" || item.tag_Type == "checkbox") {
8647                 doEvent = doEvent.replace("change", "click");
8648             }
8649             if (item.tag_Type == "amount" || item.tag_Type == "qrcode" || item.tag_Type == "barcode") {
8650                 fieldId = fieldId + item.tag_Type;
8651             }
8652             if (item.tag_Type == "htmlediter") {
8653                 UE.getEditor(fieldId + "Item").onclick = function (event, ui) {
8654                     // eval(strFunction);
8655                     // ////console.log(UE.getEditor(fieldId+"Item").getContent());
8656                     customLinkageAnalysis.options[fieldId + "Item"] = UE.getEditor(fieldId + "Item").getContent();
8657                 }
8658                 UE.getEditor(fieldId + "Item").onblur = function (event, ui) {
8659                     //////console.log(UE.getEditor(fieldId+"Item").getContent());
8660                     var fieldIdItem = UE.getEditor(fieldId + "Item").getContent();
8661                     if (fieldIdItem != customLinkageAnalysis.options[fieldId + "Item"]) {
8662                         eval(allFunction.strFunction);
8663                     }
8664
8665                 }
8666                 ////console.log(UE.getEditor(fieldId+"Item"));
8667             } else if (item.tag_Type == "tree") {
8668                 customBase.options.zTreeOnClickItems[fieldId + "tree"] = allFunction.strFunction;
8669             } else if (item.tag_Type == "radio" || item.tag_Type == "checkbox") {
8670
8671             } else {
8672                 customLinkageAnalysis.bindEvent(fieldId, doEvent, allFunction);
8673             }
8674
8675         }
8676         _.each(rules[i].results, function (ru) {// 自定义验证 为弹出消息控件绑定验证方法 李伟民 2017-10-18 15:09
8677             if ((ru.mode == "2" || ru.mode == "0") && rules[i].event.eventFieldId != ru.eventFieldId) {//判断是否为验证公式 判断触发控件与弹出消息控件是否为同一控件
8678                 //console.log(ru);
8679                 customLinkageAnalysis.bindEvent(ru.eventFieldId, "blur", allFunction);
8680             }
8681         });// 自定义验证 为弹出消息控件绑定验证方法 李伟民 2017-10-18 15:09 end
8682     }
8683 }
8684
8685
8686 // 子控件事件调用时
8687 customLinkageAnalysis.bindLinkageSubform = function (inType) {
8688     //取得公式的JSON数据
8689     var rules = customShow.options.jsonLinkage;
8690     if (typeof rules == 'string') {
8691         rules = eval(rules);
8692     }
8693     if (rules == null || rules.length == 0) {
8694         return;
8695     }
8696     // if("calendar" == inType){
8697     //     $("#"+fieldId).unbind();
8698     // }
8699     for (var i = 0; i < rules.length; i++) {
8700         var dofuncion = "";
8701         try {
8702             dofuncion = customLinkageAnalysis.makeLinkage(rules[i]);
8703         } catch (e) {
8704             ////console.log(e.message);
8705             continue;
8706         }
8707         var fieldId = rules[i].event.eventFieldId;
8708         var item = customShow.options.customItemShow.item[fieldId];
8709         var strFunction = customLinkageAnalysis.changeDoFunction(dofuncion);
8710         if (item != undefined) {
8711             var doEvent = rules[i].event.doEvent;
8712             doEvent = doEvent.replace("selectedChange", "change");
8713             // if (item.tag_Type == "radio" || item.tag_Type == "checkbox") {
8714             //     // doEvent = doEvent.replace("change", "click");
8715             // }
8716             if (inType == item.tag_Type) {
8717                 if (item.tag_Type == "radio") {
8718                     $("#" + fieldId + ' .custom-radio').on('click', function () {
8719                         // //////console.log(this.className);
8720                         if (this.className.indexOf("readonly") > -1) {
8721                             return;
8722                         }
8723                         eval(strFunction);
8724                     });
8725                 } else if (item.tag_Type == "checkbox") {
8726                     $("#" + fieldId + ' .custom-check').on('click', function () {
8727                         // //////console.log(this.className);
8728                         if (this.className.indexOf("readonly") > -1) {
8729                             return;
8730                         }
8731                         eval(strFunction);
8732                     });
8733                 } else {
8734                     customLinkageAnalysis.bindEvent(fieldId, doEvent, strFunction);
8735                 }
8736
8737             }
8738         }
8739     }
8740 }
8741
8742 customLinkageAnalysis.bindFunctionEvent = function (strFunction) {
8743     //console.log(strFunction);
8744     return function () {
8745         try {
8746             eval(strFunction);
8747         } catch (e) {
8748             ////console.log(e.message);
8749         }
8750     }
8751 }
8752
8753 customLinkageAnalysis.changeDoFunction = function (doFunction) {
8754     var conditionCode = doFunction.conditionCode;
8755     //console.log(doFunction);
8756     var code = "";
8757     var strFunction = "";
8758     var checkFunction = "";// 单独检查校验规则代码  李伟民 2017-10-19 14:33
8759     if (conditionCode != null) {
8760         code = conditionCode.code
8761         var conditionListCode = conditionCode.listCode;
8762
8763         for (var i = 0; i < conditionListCode.length; i++) {
8764             strFunction += "var code" + i + " = " + conditionListCode[i] + ";\r\n";
8765             checkFunction += "var code" + i + " = " + conditionListCode[i] + ";\r\n";// 单独检查校验规则代码  李伟民 2017-10-19 14:33
8766             var reg = new RegExp('\\{' + i + '\\}', "g");
8767             code = code.replace(reg, "\"+customLinkageAnalysis.changeEvalType(eval('code" + i + "'))+\"");
8768         }
8769         for (var i = 0; i < conditionListCode.length; i++) {
8770             var reg = new RegExp('\\{' + i + '\\}', "g");
8771             strFunction = strFunction.replace(reg, "code" + i);
8772             checkFunction = strFunction.replace(reg, "code" + i);// 单独检查校验规则代码  李伟民 2017-10-19 14:33
8773         }
8774         if (conditionCode.clearCode != undefined) {//添加清空错误信息  李伟民 2017-10-18 17:45
8775             _.each(conditionCode.clearCode, function (_clearCode) {
8776                 strFunction += _clearCode;
8777                 checkFunction += _clearCode;// 单独检查校验规则代码  李伟民 2017-10-19 14:33
8778             })
8779         }//添加清空错误信息  李伟民 2017-10-18 17:45 end
8780         if (code != null && code != "") {
8781             if (code.indexOf('Math.floor') != -1) {
8782                 code = eval(code);
8783                 ////console.log(code);
8784             }
8785             code = "customLinkageAnalysis.expeval(\"=" + code + "\")";
8786             strFunction += "if (" + code + " == 'true') { \r\n";
8787             checkFunction += "if (" + code + " == 'true') { \r\n";// 单独检查校验规则代码  李伟民 2017-10-19 14:33
8788         }
8789     }
8790     var results = doFunction.results;
8791     for (var i = 0; i < results.length; i++) {
8792         var resultValue = results[i].resultValue;
8793         var resultJsText = results[i].resultJsText;
8794         if (resultValue != null) {
8795             var listCode = resultValue.listCode;
8796             var resultCode = resultValue.code;
8797             for (var j = 0; j < listCode.length; j++) {
8798                 strFunction += "var resultCode" + j + " = " + listCode[j] + ";\r\n";
8799                 var reg = new RegExp('\\{' + j + '\\}', "g");
8800                 ////console.log(resultCode);
8801                 resultCode = resultCode.replace(reg, "\"+customLinkageAnalysis.changeEvalType(eval('resultCode" + j + "'))+\"");
8802             }
8803             for (var j = 0; j < listCode.length; j++) {
8804                 var reg = new RegExp('\\{' + j + '\\}', "g");
8805                 strFunction = strFunction.replace(reg, "resultCode" + j);
8806             }
8807             //          if(resultCode.indexOf('Math.floor') != -1){
8808             ////console.log(resultCode);
8809             //                  resultCode = eval(resultCode);
8810             //              }
8811             //console.log(resultCode);
8812             resultCode = "customLinkageAnalysis.expeval(\"=" + resultCode + "\")";
8813             strFunction += resultJsText.replace(/\{0\}/g, resultCode);
8814         } else if (results[i].resultJsText.indexOf("setMessage")) {// 判断是否为 规则校验公式
8815             strFunction += resultJsText + "; \r\n";
8816             checkFunction += resultJsText + "; \r\n";// 单独检查校验规则代码  李伟民 2017-10-19 14:33
8817         } else {
8818             strFunction += resultJsText + "; \r\n";
8819         }
8820         //公式联动追加
8821         if (results[i].doEvent != undefined && results[i].resultJsText.indexOf("setValue") != -1) {
8822             strFunction += '$("#' + results[i].targetid + '").trigger("' + results[i].doEvent + '.value");';
8823         }
8824
8825         //公式联动追加结束
8826
8827     }
8828
8829     if (code != null && code != "") {
8830         strFunction += "}";
8831         checkFunction += "}";// 单独检查校验规则代码  李伟民 2017-10-19 14:33
8832     }
8833     ////console.log(strFunction);
8834     var allFunction = { "strFunction": strFunction, "checkFunction": checkFunction };
8835     return allFunction;
8836 }
8837
8838 function funCheck(optarr, allFunction) {//判断是否重复绑定方法
8839     var flag = true;
8840     if (optarr != undefined && optarr != '') {
8841         optarr = JSON.parse(optarr);
8842         console.log(optarr);
8843         console.log(allFunction);
8844         _.each(optarr, function (fn) {
8845             if (fn.strFunction == allFunction.strFunction && fn.checkFunction == allFunction.checkFunction) {
8846                 console.log("falg false");
8847                 flag = false;
8848             }
8849         })
8850     }
8851     return flag;
8852 }
8853
8854 customLinkageAnalysis.bindEvent = function (fieldId, doEvent, allFunction) {//aaaaaa
8855     console.log(allFunction);
8856     var evalstr = "";
8857     var evalchekstr = "";
8858     ////console.log(customShow.options.customItemShow.item[fieldId].tag_Type);
8859     if (customShow.options.customItemShow.item[fieldId].tag_Type == "dropdownlist") {
8860         ////console.log($("[id='" + fieldId+"']"));
8861         ////console.log($("[id='" + fieldId+"']").find(".select_get"));
8862         ////console.log($(".select_get"));
8863         ////console.log(strFunction);
8864         _.each($("[id='" + fieldId + "']").find(".select_get"),function(opt){
8865             var optarr = $(opt).attr("funarr");
8866             if(funCheck(optarr,allFunction)){
8867                 $(opt).on(doEvent + ".value", function () {
8868             if (customShow.options.customItemShow.item[fieldId].parentsubFormNum != 0) {
8869                 // _.each($("[id='" + fieldId + "']").find(".select_get"), (item, i) => {
8870                     if (allFunction.strFunction.indexOf("var i=") == -1) {
8871                         ////console.log(i);
8872                         evalstr = "var i=" + $("[id='" + fieldId + "']").find(".select_get").index(this) + ";" + allFunction.strFunction;
8873                     }
8874                 // })
8875             }else{
8876                 evalstr = allFunction.strFunction;
8877             }
8878             try {
8879                 console.log(evalstr);
8880                 eval(evalstr);
8881             } catch (e) {
8882                 ////console.log(e.message);
8883             }
8884         });
8885                 var funarr;
8886                 if($(opt).attr("funarr") == undefined || $(opt).attr("funarr") == ""){
8887                     funarr = [allFunction];
8888                 }else{
8889                     funarr = JSON.parse($(opt).attr("funarr"));
8890                     funarr.push(allFunction);
8891                 }
8892                 $(opt).attr("funarr",JSON.stringify(funarr));
8893             }
8894             var checkarr = $(opt).attr("checkfunarr");
8895             if(funCheck(checkarr,allFunction)){
8896                 $(opt).on(doEvent + ".check", function () {//单独检验校验规则绑定  李伟民 2017-10-19 15:18
8897             if (customShow.options.customItemShow.item[fieldId].parentsubFormNum != 0) {
8898                 // _.each($("[id='" + fieldId + "']").find(".select_get"), (item, i) => {
8899                     if (allFunction.checkFunction.indexOf("var i=") == -1) {
8900                         evalchekstr = "var i=" +  $("[id='" + fieldId + "']").find(".select_get").index(this) + ";" + allFunction.checkFunction;
8901                     }
8902                 // })
8903             }else{
8904                 evalchekstr = allFunction.checkFunction;
8905             }
8906             try {
8907                 eval(evalchekstr);
8908             } catch (e) {
8909                 //console.log(e.message);
8910             }
8911         });//单独检验校验规则绑定  李伟民 2017-10-19 15:18 end
8912                 var checkfunarr;
8913                 if($(opt).attr("checkfunarr") == undefined || $(opt).attr("checkfunarr") == ""){
8914                     checkfunarr = [allFunction];
8915                 }else{
8916                     checkfunarr = JSON.parse($(opt).attr("checkfunarr"));
8917                     checkfunarr.push(allFunction);
8918                 }
8919                 $(opt).attr("checkfunarr",JSON.stringify(checkfunarr));
8920             }
13ec33 8921
4d1219 8922         });
B 8923         // $("[id='" + fieldId + "']").find(".select_get").on(doEvent + ".value", function () {
8924         //     if (customShow.options.customItemShow.item[fieldId].parentsubFormNum != 0) {
8925         //         // _.each($("[id='" + fieldId + "']").find(".select_get"), (item, i) => {
8926         //             if (allFunction.strFunction.indexOf("var i=") == -1) {
8927         //                 ////console.log(i);
8928         //                 evalstr = "var i=" + $("[id='" + fieldId + "']").find(".select_get").index(this) + ";" + allFunction.strFunction;
8929         //             }
8930         //         // })
8931         //     }else{
8932         //         evalstr = allFunction.strFunction;
8933         //     }
8934         //     try {
8935         //         console.log(evalstr);
8936         //         eval(evalstr);
8937         //     } catch (e) {
8938         //         ////console.log(e.message);
8939         //     }
8940         // });
8941         // $("[id='" + fieldId + "']").find(".select_get").unbind(doEvent + ".check");
8942         // $("[id='" + fieldId + "']").find(".select_get").on(doEvent + ".check", function () {//单独检验校验规则绑定  李伟民 2017-10-19 15:18
8943         //     if (customShow.options.customItemShow.item[fieldId].parentsubFormNum != 0) {
8944         //         // _.each($("[id='" + fieldId + "']").find(".select_get"), (item, i) => {
8945         //             if (allFunction.checkFunction.indexOf("var i=") == -1) {
8946         //                 evalchekstr = "var i=" +  $("[id='" + fieldId + "']").find(".select_get").index(this) + ";" + allFunction.checkFunction;
8947         //             }
8948         //         // })
8949         //     }else{
8950         //         evalchekstr = allFunction.checkFunction;
8951         //     }
8952         //     try {
8953         //         eval(evalchekstr);
8954         //     } catch (e) {
8955         //         //console.log(e.message);
8956         //     }
8957         // });//单独检验校验规则绑定  李伟民 2017-10-19 15:18 end
8958     } else {
8959         // $("[id='" + fieldId + "']").unbind(doEvent + ".value");
8960         _.each($("[id='" + fieldId + "']"),function(opt){
8961             var optarr = $(opt).attr("funarr");
8962                 if(funCheck(optarr,allFunction)){
8963                     $(opt).on(doEvent + ".value", function () {
8964             if (customShow.options.customItemShow.item[fieldId].parentsubFormNum != 0 && allFunction.strFunction.indexOf("getSum") == -1) {
8965                 console.log($("[id='" + fieldId + "']"));
8966                 console.log($(this));
8967                 console.log($("[id='" + fieldId + "']").index(this));
8968                 // _.each($("[id='" + fieldId + "']"), (item, i) => {
8969                     // console.log($(item));
8970                     if (allFunction.strFunction.indexOf("var i=") == -1) {
8971                         ////console.log(i);
8972                         evalstr = "var i=" + $("[id='" + fieldId + "']").index(this) + ";" + allFunction.strFunction;
8973                     }
8974                 // })
8975             }else if(allFunction.strFunction.indexOf("getSum") > 0){
8976                 console.log(allFunction.strFunction);
8977                 console.log("replace");
8978                 evalstr = allFunction.strFunction;
8979                 // allFunction.strFunction = allFunction.strFunction.replace(new RegExp(".split(',')[i]") ,"");
8980                 while(evalstr.indexOf(".split(',')[i]") != -1){
8981                     evalstr = evalstr.replace(".split(',')[i]","");
8982                 }
8983             }else{
8984                 evalstr = allFunction.strFunction;
8985             }
8986             // try {
8987                 console.log(evalstr);
8988                 eval(evalstr);
8989             // } catch (e) {
8990             //     ////console.log(e.message);
8991             // }
8992         });
8993                 var funarr;
8994                 if($(opt).attr("funarr") == undefined || $(opt).attr("funarr") == ""){
8995                     funarr = [allFunction];
8996                 }else{
8997                     funarr = JSON.parse($(opt).attr("funarr"));
8998                     funarr.push(allFunction);
8999                 }
9000                 $(opt).attr("funarr",JSON.stringify(funarr));
13ec33 9001
4d1219 9002             };
B 9003             var checkarr = $(opt).attr("checkfunarr");
9004             if(funCheck(checkarr,allFunction)){
9005                 $(opt).on("blur.check", function () {//单独检验校验规则绑定  李伟民 2017-10-19 15:18
9006             if (customShow.options.customItemShow.item[fieldId].parentsubFormNum != 0) {
9007                         console.log("change.check");
9008                 _.each($("[id='" + fieldId + "']"), (item, i) => {
9009                     if (allFunction.checkFunction.indexOf("var i=") == -1) {
9010                         ////console.log(i);
9011                         evalchekstr = "var i=" + $("[id='" + fieldId + "']").index(this) + ";" + allFunction.checkFunction;
9012                     }
9013                 })
9014             }else{
9015                 evalchekstr = allFunction.checkFunction;
9016             }
9017             try {
9018                 if(evalchekstr.indexOf('alert') == -1){
9019                     eval(evalchekstr);
9020                 }
9021             } catch (e) {
9022                 ////console.log(e.message);
9023             }
9024         });//单独检验校验规则绑定  李伟民 2017-10-19 15:18 end
9025                 var checkfunarr;
9026                 if($(opt).attr("checkfunarr") == undefined || $(opt).attr("checkfunarr") == ""){
9027                     checkfunarr = [allFunction];
9028                 }else{
9029                     checkfunarr = JSON.parse($(opt).attr("checkfunarr"));
9030                     checkfunarr.push(allFunction);
9031     }
9032                 $(opt).attr("checkfunarr",JSON.stringify(checkfunarr));
9033             }
13ec33 9034
4d1219 9035         });
B 9036         // $("[id='" + fieldId + "']").unbind(doEvent + ".check");
9037         // $("[id='" + fieldId + "']").on(doEvent + ".check", function () {//单独检验校验规则绑定  李伟民 2017-10-19 15:18
9038         //     if (customShow.options.customItemShow.item[fieldId].parentsubFormNum != 0) {
9039         //         console.log("change.check");
9040         //         _.each($("[id='" + fieldId + "']"), (item, i) => {
9041         //             if (allFunction.checkFunction.indexOf("var i=") == -1) {
9042         //                 ////console.log(i);
9043         //                 evalchekstr = "var i=" + $("[id='" + fieldId + "']").index(this) + ";" + allFunction.checkFunction;
9044         //             }
9045         //         })
9046         //     }else{
9047         //         evalchekstr = allFunction.checkFunction;
9048         //     }
9049         //     try {
9050         //         eval(evalchekstr);
9051         //     } catch (e) {
9052         //         ////console.log(e.message);
9053         //     }
9054         // });//单独检验校验规则绑定  李伟民 2017-10-19 15:18 end
9055     }
9056 }
9057
9058 customLinkageAnalysis.changeEvalType = function (str) {
9059     console.log(str);
624ff8 9060     if (isNaN(Number(str)) && (str.substring(0, 1) != "\"" || str.substring(str.length - 1, 1) != "\"") && (str.indexOf('||') != -1) && (str.indexOf('&&') != -1)) {//|| && 修改 李伟民 公式不稳定修改 0202 
4d1219 9061         return "'" + str + "'";
B 9062     } else {
9063         ////console.log(str);
9064         return str;
9065     }
9066 }
9067
9068 //事件绑定调用
9069 //事件绑定:字段ID:ItemId 事件名 自定义事件名
9070 //参数
9071 // eventItem=[{
9072 //     ItemId:"Item_1", 控件id
9073 //     event:"click",  事件
9074 //     eventmethod:"XXXXXXXXXXXXXXXXXXXX"   自定义事件名
9075 // }]
9076 customLinkageAnalysis.setEventBind = function (eventItem) {
9077     customShow.setEventBindItem(eventItem);
9078 }
9079 //03检证执行(接口)
9080 customLinkageAnalysis.validationEx = {
9081     get: function (alias) {
9082         var itemTempS;
9083         var item = customBase.options.customItems[alias];
9084         if (item.type == "button" || item.type == "link") {
9085         } else if (item.type == "dropdownlist") {
9086             var datasourcetype = $("#" + item.id)[0].getAttribute("datasourcetype");
9087             //////////console.log(datasourcetype);
9088             //主数据源
9089             if (datasourcetype == "masterdata") {
9090                 itemTempS = customBase.getItemValue(item.id, item.type);
9091                 //数据源
9092             } else if (datasourcetype == "datasource") {
9093                 itemTempS = customBase.getItemValue(item.id, "dropdownlistText");
9094                 //自定义
9095             } else if (datasourcetype == "custom") {
9096                 itemTempS = customBase.getItemValue(item.id, "dropdownlistText");
9097                 //API接口
9098             } else if (datasourcetype == "api") {
9099                 itemTempS = customBase.getItemValue(item.id, item.type);
9100             }
9101         } else if (item.type == "subform") {
9102
9103         } else {
9104             itemTempS = customBase.getItemValue(item.id, item.type);
9105         }
9106         item.value = itemTempS;
9107         ////////console.log(item);
9108         return item;
9109     }
9110 }
9111 //取得主数据
9112 /*
9113 itemId:项目ID
9114 masterCode:执行CODE
9115 返回值:元素的值
9116 */
9117 customLinkageAnalysis.getElement = function (itemId, masterCode, num) {
9118     var item = customShow.options.customItemShow.item[itemId];
9119     var code = item.tag_Attribute.masterData;
9120     var masterData = $.parseJSON(code);
9121     var defindCode = masterData.defindCode;
9122     var eleCode = masterData.eleCode;
9123     var eleValue = customLinkageAnalysis.getValue(itemId);
9124     if(num != undefined && eleValue != undefined && eleValue.indexOf(',') != -1){//子表单中控件处理  李伟民  0106
9125         eleValue = eleValue.split(',')[num];
9126     }
9127     var opt = {
9128         eleCode: eleCode,
9129         defindCode: defindCode,
9130         eleValue: eleValue,
9131         masterCode: masterCode,
9132         itemId: itemId
9133     }
9134     //主数据取得
9135     var result = customDataBound.getElement1(opt);
9136     console.log(result);
9137     console.log(itemId)
9138     if (result.rspCode == "000000") {
9139         if (result.data[itemId].length > 0) {
9140             console.log(result.data[itemId][0].value)
9141             return result.data[itemId][0].value;
9142         } else {
9143             return "";
9144         }
9145     } else {
9146         return "";
9147     }
9148 }
9149
9150 customLinkageAnalysis.clearMessage = function (itemId, num) {//清空错误信息方法  李伟民 2017-10-18 16:36
9151     if (num == undefined) {
9152         num = 0;
9153     }
9154     //console.log($("[id='"+itemId+"']:eq("+num+")"));
9155     //console.log($("[id='"+itemId+"ActiveId']:eq("+num+")"));
9156     $("[id='" + itemId + "']:eq(" + num + ")").removeClass("errorItemCss");
9157     $("[id='" + itemId + "']:eq(" + num + ")").removeClass("errorCheckCss");
9158     $("[id='" + itemId + "ActiveId']:eq(" + num + ")").find("#" + itemId + "mesageErrDiv").remove();
9159 }//清空错误信息方法  李伟民 2017-10-18 16:36 end
9160
9161 customLinkageAnalysis.makeLinkage = function (rule) {
9162     ////console.log(rule);
9163     var result = {};
9164     var conditionCode = {};
9165     conditionCode = customLinkageAnalysis.changeCodeMirror(rule.conditionCode, rule.conditionHistory._history);
9166
9167     if (rule.conditionCode != "" && !_.isNull(rule.conditionCode)) {//清空错误信息  李伟民 2017-10-18 16:36
9168         var clearCode = [];
9169         _.each(rule.results, function (ru) {
9170             if (ru.mode == "2") {
9171                 var ruItem = customShow.options.customItemShow.item[ru.eventFieldId];
9172                 if (ruItem.parentsubFormNum != 0) {
9173                     clearCode.push("customLinkageAnalysis.clearMessage('" + ru.eventFieldId + "',i);");
9174                 } else {
9175                     clearCode.push("customLinkageAnalysis.clearMessage('" + ru.eventFieldId + "');");
9176                 }
9177             }
9178         });
9179         conditionCode["clearCode"] = clearCode;
9180     }//清空错误信息  李伟民 2017-10-18 16:36 end
9181
9182     var results = new Array();
9183     for (var i = 0; i < rule.results.length; i++) {
9184         var resultJs = {};
9185         var textType = rule.results[i].attribute;
9186         var resultJsText = "";
9187         var resultTargrtItem = customShow.options.customItemShow.item[rule.results[i].eventFieldId]; if ("1" == rule.results[i].mode) {
9188             var resultValue = customLinkageAnalysis.changeCodeMirror(rule.results[i].code, rule.results[i].eventHistory._history);
9189             resultJs.resultValue = resultValue;
9190             if (textType == 'value') {
9191                 if (resultTargrtItem.parentsubFormNum != 0) {
9192                     resultJsText += "customLinkageAnalysis.setValue('" + rule.results[i].eventFieldId + "', {0}, i);";
9193                 } else {
9194                     resultJsText += "customLinkageAnalysis.setValue('" + rule.results[i].eventFieldId + "', {0});";
9195                 }
9196             } else if (textType == 'visible' || textType == 'editable') {
9197                 resultJsText += "customLinkageAnalysis.setAttribut('" + rule.results[i].eventFieldId + "','" + textType + "', {0});";
9198             } else {
9199                 // todo
9200             }
9201         } else if ("2" == rule.results[i].mode || "0" == rule.results[i].mode) {
9202             if (resultTargrtItem.parentsubFormNum != 0) {//自定义校验支持子表单中控件  李伟民 2017-10-18 14:34
9203                 //              resultJsText += "customLinkageAnalysis.clearMessage('" + rule.results[i].eventFieldId + "',i);";
9204                 resultJsText += "customLinkageAnalysis.setMessage('" + rule.results[i].mode + "','" + rule.results[i].eventFieldId + "','" + rule.results[i].message + "',i);";
9205             } else {
9206                 //              resultJsText += "customLinkageAnalysis.clearMessage('" + rule.results[i].eventFieldId + "');";
9207                 resultJsText += "customLinkageAnalysis.setMessage('" + rule.results[i].mode + "','" + rule.results[i].eventFieldId + "','" + rule.results[i].message + "');";
9208             }//自定义校验支持子表单中控件  李伟民 2017-10-18 14:34 end
9209
9210         } else if ("3" == rule.results[i].mode) {
9211             resultJsText += "customLinkageAnalysis.alert('" + rule.results[i].messageType + "','" + rule.results[i].message + "');";
9212         } else {
9213             ;
9214         }
9215         resultJs.resultJsText = resultJsText;
9216         resultJs.targetid = rule.results[i].eventFieldId;// 公式联动追加 目标控件
9217         var targetDoEvent = '';
9218         //      ////console.log(customShow.options.jsonLinkage);
9219         var jsonLinkage_add = customShow.options.jsonLinkage;//预览公式联动修改 李伟民 0117
9220         if (_.isString(jsonLinkage_add)) {
9221             jsonLinkage_add = JSON.parse(jsonLinkage_add);
9222         }
9223         _.each(jsonLinkage_add, function (allrule) {// 公式联动追加 目标控件事件
9224             if (allrule.event.eventFieldId == resultJs.targetid) {
9225                 resultJs.doEvent = allrule.event.doEvent;
9226             }
9227         });
9228         results.push(resultJs);
9229     }
9230     result.conditionCode = conditionCode;
9231     result.results = results;
9232     ////console.log(result);
9233     return result;
9234 }
9235
9236 customLinkageAnalysis.reachLeftSpace = function (str, length) {
9237     var result = str;
9238     if (str.length < length) {
9239         var spaceLen = length - str.length;
9240         for (var i = 0; i < spaceLen; i++) {
9241             result = " " + result;
9242         }
9243     }
9244     return result;
9245 }
9246
9247 customLinkageAnalysis.replace = function (str, stringObj, replaceText, from, to) {
9248     var resultBefore = str.substring(0, from);
9249     var text = str.substring(from, to);
9250     var resultAfter = str.substring(to);
9251     text = text.replace(stringObj, customLinkageAnalysis.reachLeftSpace(replaceText, stringObj.length));
9252     return resultBefore + text + resultAfter;
9253 }
9254
9255 customLinkageAnalysis.changeCodeMirror = function (code, history) {
9256     if (code.trim() == "") {
9257         return null;
9258     }
9259     //console.log(code);
9260     //console.log(history);
9261     var result = {};
9262     var conditionCode = "";
9263     var listCode = new Array();
9264     var arrConditionCode = code.split('\r\n');
9265     ////console.log(arrConditionCode);
9266     var resultIndex = 0;
9267
9268     if (history != null && history.length > 0) {
9269         for (var i = 0; i < history.length; i++) {
9270             var line = history[i].from.line;
9271             var fromCh = history[i].from.ch;
9272             var toCh = history[i].to.ch;
9273             var text = history[i].text;
9274             arrConditionCode[line] = customLinkageAnalysis.replace(arrConditionCode[line], text, '{' + resultIndex + '}', fromCh, toCh);
9275             var idText = history[i].idText;
9276             var arrInputText = idText.split('.');
9277             var replaceText = "";
9278             var id = arrInputText[0];
9279             var textType = arrInputText[1];
9280             var idItem = customShow.options.customItemShow.item[id]; if (textType == 'value') {
9281                 if (idItem.parentsubFormNum != 0) {
9282                     replaceText = "customLinkageAnalysis.getValue('" + id + "').split(',')[i]";
9283                 } else {
9284                     replaceText = "customLinkageAnalysis.getValue('" + id + "')";
9285                 }                // ////console.log(replaceText);
9286             } else if (textType == 'visible' || textType == 'editable') {
9287                 replaceText = "customLinkageAnalysis.getAttribut('" + id + "','" + textType + "')";
9288             } else {
9289                 if (idItem.parentsubFormNum != 0) {//主数据关联也需区分子表单中控件  李伟民 0106
9290                     replaceText = "customLinkageAnalysis.getElement('" + id + "','" + textType + "',i)";
9291                 } else {
9292                     replaceText = "customLinkageAnalysis.getElement('" + id + "','" + textType + "')";
9293                 }
9294                 // replaceText = "customLinkageAnalysis.getElement('" + id + "','" + textType + "')";
9295             }
9296             listCode.push(replaceText);
9297             resultIndex++;
9298         }
9299     }
9300     conditionCode = arrConditionCode.join('\r\n').replace(/\(/g, "###(###");
9301     conditionCode = conditionCode.replace(/\)/g, "###)###");
9302     arrConditionCode = conditionCode.split('\r\n');
9303     conditionCode = arrConditionCode.join('\r\n');
9304     conditionCode = conditionCode.replace(/AND/g, '&&');
9305     conditionCode = conditionCode.replace(/OR/g, '||');
9306     while (conditionCode.indexOf('  ') >= 0) {
9307         conditionCode = conditionCode.replace(/  /g, ' ');
9308     }
9309     var conditionCodeResult = customLinkageAnalysis.changeSign(conditionCode, listCode, resultIndex);
9310     conditionCode = conditionCodeResult.conditionCode;
9311     resultIndex = conditionCodeResult.resultIndex;
9312     conditionCode = conditionCode.replace(/###\(###/g, "(");
9313     conditionCode = conditionCode.replace(/###\)###/g, ")");
9314     result.code = conditionCode;
9315     result.listCode = listCode;
9316     //console.log(result);
9317     return result;
9318 }
9319
9320 customLinkageAnalysis.changeCodeSign = function (sign, inner) {
9321     var exp = igame.Expression;
9322     if (sign.indexOf('MAX') >= 0) {
9323         sign = "Max";
9324     } else if (sign.indexOf('MIN') >= 0) {
9325         sign = "Min";
9326     } else if (sign.indexOf('AVG') >= 0) {
9327         sign = "Average";
9328     } else if (sign.indexOf('SUM') >= 0) {
9329         sign = "Sum";
9330     } else if (sign.indexOf('COUNT') >= 0) {
9331         sign = "Count";
624ff8 9332     } else if (sign.indexOf('||') >= 0) {//|| &&修改 李伟民 0202 公式不稳定修改
L 9333         return sign + eval("[" + inner + "]").toString();
4d1219 9334     } else {
B 9335         return "";
9336     }
9337
9338     var arlInner = eval("[" + inner + "]");
9339     return new exp.Formula(sign + "(" + arlInner.join(',') + ")").evaluate().toString();
9340 }
9341
9342 customLinkageAnalysis.expeval = function (str) {
9343     //    console.log(str);
9344     if (str.trim().replace(/=/, "") == "") {
9345         console.log("str  err");
9346         return " ";
9347     }
9348     console.log("str  scc");
9349     var exp = igame.Expression;
9350     //      console.log(exp);
9351     //      console.log(str);
9352     //      console.log(new exp.Formula(str));
9353     //      console.log(new exp.Formula(str).evaluate());
9354     //      console.log(new exp.Formula(str).evaluate().toString());
9355     return new exp.Formula(str).evaluate().toString();
9356 }
9357
9358 customLinkageAnalysis.changeSign = function (conditionCode, listCode, resultIndex) {
9359     ////console.log(conditionCode);
9360     var index = 0;
9361     var indexOf = -1;
9362     var result = {};
9363     while ((indexOf = conditionCode.substring(index).indexOf('MAX')) >= 0
9364         || (indexOf = conditionCode.substring(index).indexOf('MIN')) >= 0
9365         || (indexOf = conditionCode.substring(index).indexOf('AVG')) >= 0
9366         || (indexOf = conditionCode.substring(index).indexOf('SUM')) >= 0
9367         || (indexOf = conditionCode.substring(index).indexOf('COUNT')) >= 0
9368         || (indexOf = conditionCode.substring(index).indexOf('parseInt')) >= 0
9369         || (indexOf = conditionCode.substring(index).indexOf('addtest')) >= 0
9370         || (indexOf = conditionCode.substring(index).indexOf('getDay')) >= 0
9371         || (indexOf = conditionCode.substring(index).indexOf('getSum')) >= 0) {//时间函数  李伟民 2017-10-17 21:49 修改公式
9372         var before = conditionCode.substring(0, indexOf);
9373         var beforeInner = 0;
9374         var afterIndexOf = 0;
9375         var sign;
9376         var after;
9377         if (history != null && history.length > 0) {
9378             beforeInner = conditionCode.substring(indexOf).indexOf('###(###') + 7
9379             // afterIndexOf = conditionCode.substring(indexOf).lastIndexOf('###)###');
9380             afterIndexOf = customLinkageAnalysis.getBackBracketIndex(conditionCode.substring(indexOf), '###(###', '###)###');
9381             sign = conditionCode.substring(indexOf).substring(0, beforeInner - 7);
9382             after = conditionCode.substring(indexOf).substring(afterIndexOf + 7);
9383         } else {
9384             beforeInner = conditionCode.substring(indexOf).indexOf('(') + 1
9385             // afterIndexOf = conditionCode.substring(indexOf).lastIndexOf(')');
9386             afterIndexOf = customLinkageAnalysis.getBackBracketIndex(conditionCode.substring(indexOf), '(', ')');
9387             sign = conditionCode.substring(indexOf).substring(0, beforeInner - 1);
9388             after = conditionCode.substring(indexOf).substring(afterIndexOf + 1);
9389         }
9390         var inner = conditionCode.substring(indexOf).substring(beforeInner, afterIndexOf);
9391         var innerResult = customLinkageAnalysis.changeSign(inner, listCode, resultIndex);
9392         inner = innerResult.conditionCode;
9393         resultIndex = innerResult.resultIndex;
9394         inner = inner.replace(/###\(###/g, "(");
9395         inner = inner.replace(/###\)###/g, ")");
9396         if ((indexOf = conditionCode.substring(index).indexOf('parseInt')) >= 0
9397             || (indexOf = conditionCode.substring(index).indexOf('addtest')) >= 0
9398             || (indexOf = conditionCode.substring(index).indexOf('getDay')) >= 0
9399             || (indexOf = conditionCode.substring(index).indexOf('getSum')) >= 0) {//时间函数  李伟民 2017-10-17 21:49 修改公式
9400             listCode.push(sign + "(" + inner + ")");
9401         } else {
9402             listCode.push("customLinkageAnalysis.changeCodeSign('" + sign + "',\[" + inner + "\])");
9403         }
9404
9405         conditionCode = before + "{" + resultIndex + "}";
9406         resultIndex++;
9407         index = conditionCode.length - 1;
9408         conditionCode += after;
9409     }
9410     result.conditionCode = conditionCode;
9411     result.resultIndex = resultIndex;
9412     ////console.log(result);
9413     return result;
9414 }
9415 addtest = function (arg1, arg2) {
9416     return arg1 + arg2;
9417 }
9418
9419 getDay = function (arg1, arg2) {//时间函数  李伟民 2017-10-17 21:49
9420     var date1 = new Date(arg1)
9421     var date2 = new Date(arg2)
9422     var s1 = date1.getTime(), s2 = date2.getTime();
9423     var total = (s1 - s2) / 1000;
9424     var day = parseInt(total / (24 * 60 * 60));//计算整数天数
9425     //console.log(day);
9426     return day;
9427 }//时间函数  李伟民 2017-10-17 21:49 end
9428
9429 getSum = function () {
9430     console.log(arguments);
9431     var allItem = [];
9432     _.each(arguments, function (arg) {
9433         allItem.push(arg.split(","));
9434     });
9435     console.log(allItem);
9436     var sum = 0;
9437     _.each(allItem, function (item) {
9438         _.each(item, function (cd) {
9439             sum += Number(cd);
9440         })
9441     })
9442     return sum;
9443 }
9444
9445 customLinkageAnalysis.getBackBracketIndex = function (str, strBracket, strBackBracket) {
9446     var beforeIndex = str.indexOf(strBracket);
9447     var backIndex = str.indexOf(strBackBracket);
9448     var layers = 0;
9449     while (beforeIndex < backIndex && beforeIndex >= 0) {
9450         layers++;
9451         beforeIndex = str.indexOf(strBracket, beforeIndex + strBracket.length)
9452     }
9453     while (layers > 1 && backIndex >= 0) {
9454         layers--;
9455         backIndex = str.indexOf(strBackBracket, backIndex + strBackBracket.length);
9456     }
9457     if (backIndex < 0) {
9458         throw Error("括号未闭合");
9459     }
9460     return backIndex;
9461 }
9462 var customDataBound = customDataBound || {};
9463
9464 //根据表单ID取得表单基本信息
9465 customDataBound.getFormbase = function (formid, callback) {
9466     // if(customBase.options.formbaseInfo == ""){
9467     var dataObj = {};
9468     dataObj.formID = formid;
9469     var requestRight = window.commonAjax("/formbase/getFormInfoService", dataObj, "GET", true);
9470     requestRight.done(function (rs) {
9471         callback(rs);
9472     })
9473
9474
9475     // }else{
9476     //     callback(customBase.options.formbaseInfo);
9477     // }
9478 }
9479
9480 //表单保存
9481 customDataBound.savaFormbase = function (formbase, callback) {
9482     ////////////console.log(formbase);
9483     var dataObj = {};
9484     dataObj = formbase;
9485     console.log(formbase);
9486     var requestRight = window.commonAjax("/formbase/saveformService", dataObj, "POST", true);
9487     requestRight.done(function (rs) {
9488
9489         callback(rs);
9490     });
9491 }
9492
9493 //表单数据保存
9494 customDataBound.fromSave = function (formid, formbase, callback) {
9495     // if(window.localStorage.getItem("bussinessSystem")){
9496     //     var flag = window.localStorage.getItem("bussinessSystem");
9497     // }
9498     var dataObj = {};
9499     dataObj.formID = formid;
9500     dataObj.data = formbase;
9501     //     dataObj.tenantID = "001";
9502     // dataObj.flag = flag;
9503     //dataObj.flag = "cloud"
9504     //console.log(dataObj);
9505     if (customShow.exCouldNumber != undefined && customShow.exCouldNumber != '') {//保存时 传云单标号 李伟民 12-22
9506         _.extend(dataObj, { 'orderCode': customShow.exCouldNumber });
9507     }//保存时 传云单标号 李伟民 12-22
9508     //_.extend(dataObj,{'orderCode': '1012000170900005'});//临时修改
9509     var requestRight = window.commonAjax("/datamanagement/addFormDataService", dataObj, "POST", true);
9510     requestRight.done(function (rs) {
9511         callback(rs);
9512     });
9513 }
9514
9515 //表单数据编辑
9516 customDataBound.fromEdit = function (formid, formbase, dataRowNum, callback) {
9517     var dataObj = {};
9518     // if(window.localStorage.getItem("bussinessSystem")){
9519     //     var flag = window.localStorage.getItem("bussinessSystem");
9520     // }
9521     // dataObj.flag = flag;
9522     dataObj.formID = formid;
9523     dataObj.dataRowNum = dataRowNum;
9524     dataObj.data = formbase;
9525     if (customShow.exCouldNumber != undefined && customShow.exCouldNumber != '') {//保存时 传云单标号 李伟民 12-22
9526         _.extend(dataObj, { 'orderCode': customShow.exCouldNumber });
9527     }//保存时 传云单标号 李伟民 12-22
9528     //_.extend(dataObj,{'orderCode': '1012000170900005'});//临时修改
9529     var requestRight = window.commonAjax("/datamanagement/updateFormDataService", dataObj, "POST", true);
9530     requestRight.done(function (rs) {
9531
9532         callback(rs);
9533     });
9534 }
9535
9536 // 获取表单设定数据源信息
9537
9538 // JSON:{"rspCode":"000000","rspDesc":"请求成功","data":[{"测试连接":["actor_id","first_name","last_name","last_update"]}]}
9539 customDataBound.getDatasource = function (formID, callback) {
9540     var dataObj = {};
9541     dataObj.formID = formID;
9542     // dataObj.formID = '8888';
9543     // dataObj.tenantID = "001";
9544     var requestRight = window.commonAjax("/datasource/getDatasourceColumnsNameService", dataObj, "GET", true);
9545
9546     requestRight.done(function (rs) {
9547         if (rs.rspCode == "000000") {
9548             callback(rs.data);
9549         } else {
9550             callback(rs.data);
9551         }
9552     });
9553 }
9554
9555 // 获取当前表单设置字段的数据源信息  数据绑定
9556 // 参数: formID,tenantID
9557 // JSON: {"rspCode":"000000","rspDesc":"请求成功","data":[{"单选按钮组测试":{"datasource":"","textcolumn":"","valuecolumn":""}}]}
9558 customDataBound.getFieldDatasource = function (Datasource, callback) {
9559     url = "/datasource/getDatasourceColumnsValueService?tenantID={tenantID}&databaseName={databaseName}&datasource={datasource}&columnNames={columnNames}&callbackId={callbackId}";
9560     url = url.replace("{databaseName}", Datasource.databaseName);
9561     url = url.replace("{columnNames}", Datasource.columnNames);
9562     url = url.replace("{datasource}", Datasource.datasource);
9563     url = url.replace("{callbackId}", Datasource.callbackId);
9564
9565     window.commonGetJson(url, callback);
9566
9567 }
9568
9569 // 获得主数据
9570 customDataBound.getElement = function (code, callbackId, callback) {
9571     if (code != "") {
9572         var dataObj = {};
9573         dataObj.tenantIDForMaster = 1;
7b0ed4 9574          if(_.isString(code)){
Z 9575             dataObj.code = code;
9576         }else{
9577             dataObj.code = JSON.stringify(code);
9578         }
4d1219 9579         dataObj.callbackId = callbackId;
B 9580         //console.log(dataObj);
9581         let customlocalStorage = window.localStorage.getItem("bussinessSystem");
9582         var reg = new RegExp('"', "g"); // service  修改  李元杰 11-16
9583         customlocalStorage = customlocalStorage.replace(reg, ""); // service  修改  李元杰 11-16
9584         console.log(customlocalStorage);
9585         dataObj.flag = customlocalStorage;
9586         var requestRight = window.commonAjax("/te-csc-api/search/base/elementprivate", dataObj, "GET", true);
9587
9588         requestRight.done(function (rs) {
9589             console.log(rs)
9590             if (rs.rspCode == "000000") {
9591                 console.log(rs)
9592                 callback(rs);
9593                 customShow.addTitle();
9594                 SC.money_cur();
9595                 // 12/13
9596
9597                 console.log(window.localStorage.getItem('customShowFlag'))
9598                 if (window.localStorage.getItem('customShowFlag') == 1) {
9599                     // customShow.businessTypeAutoFun( 'businessTypeAuto','budget_itemCostType');
9600                     SC.autoFieldKey();
9601                 }
9602             } else {
9603                 callback(rs);
9604                 console.log(rs)
9605                 toastr.error(rs.rspDesc.responseJSON);
9606             }
9607         });
9608         requestRight.error(function (rs) {
9609             // console.log(rs)
9610             // toastr.error(rs.responseJSON.rspDesc);
9611
9612         })
9613     } else {
9614         callback([]);
9615     }
9616
9617 }
9618
9619 // 获得主数据
9620 customDataBound.getElement1 = function (opt) {
9621     var dataObj = {};
9622     // dataObj.tenantIDForMaster = 1;
9623     // dataObj.code =opt;
9624     // dataObj.callbackId = callbackId;
9625     var result;
9626     var requestRight = window.commonAjax("/te-csc-api/search/base/elementprivate1", opt, "GET", true, false);
9627     requestRight.done(function (rs) {
9628         if (rs.rspCode == "000000") {
9629             result = rs;
9630         } else {
9631             result = rs;
9632         }
9633     });
9634     return result;
9635 }
9636
9637 // 获取当前表单设置字段的数据源信息  API数据取得
9638 // 参数: formID,tenantID
9639 // JSON: {"rspCode":"000000","rspDesc":"请求成功","data":[{"单选按钮组测试":{"datasource":"","textcolumn":"","valuecolumn":""}}]}
9640 customDataBound.getApiDatasource = function (url, callbackId, callback) {
9641     // console.log(1);
9642     var urls = url;
9643     var url = url + "&callbackId={callbackId}";
9644
9645     url = url.replace("{callbackId}", callbackId);
9646     // var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
9647     // xhr.open("GET", urls, true);
9648     // debugger
9649     // xhr.onreadystatechange = function () {
9650     //     var res = JSON.parse(xhr.responseText);
9651     //     console.log(res);
9652     // }
9653     $.ajax({
9654         type: "get",
9655         url: urls,
9656         async: true,
9657         success: function (rs) {
9658             console.log(url);
9659             console.log(rs);
9660             callback(rs, url);
9661         }
9662     });
9663     // // var url = url + "&callbackId={callbackId}";
9664     // // url = url.replace("{callbackId}", callbackId);
9665     // // //////////console.log(url);
9666     // // window.commonGetApiJson(url, callback);
9667     //     //////////console.log(url);
9668     //     //window.commonGetApiJson(url,callback);
9669 }
9670
9671 customDataBound.bindInterface = function (formid) {//绑定接口注册方法//保存前计算费用  李伟民   10 - 31
9672     var dataObj = {};
9673     dataObj.formID = formid;
9674     var accessToken = JSON.parse(localStorage.getItem("token")).accessToken;
9675     dataObj.access_token = accessToken;
9676     var requestRight = window.commonAjax("/forminterface/getFormInterfaceListService", dataObj, "GET", true, false);
9677     requestRight.done(function (rs) {
9678         //console.log(rs);
9679         customBase.interfaceData = rs.data;
9680
9681     })
9682 }//保存前计算费用  李伟民   10 - 31
9683
9684 customDataBound.formsetting = function (formid, callback) {
9685     // 工具栏自定义10/18
9686     $('.edit_form').html("");
9687     var type = "";
9688     var flag = window.localStorage.getItem("customShowFlag");
9689     switch (flag) {
9690         case "1": type = "TJ"; break;
9691         case "3": type = "XG"; break;
9692         case "2": type = "XX"; break;
9693         case "4": type = "LB"; break;
9694     }
9695
9696     //console.log(type);
9697     var dataObj = {};
9698     dataObj.formID = formid;
9699     dataObj.type = type;
9700     console.log(dataObj)
9701     var dataObjFlag = _.cloneDeep(dataObj);
9702     delete dataObjFlag.type
9703     var request = window.commonAjax("/formbase/getFormInfoService", dataObjFlag, "GET", true);
9704     request.done(function (rs) {
9705         if (rs.data != null) {
9706             window.localStorage.setItem('bussinessSystem', rs.data.bussinesssystem)
9707         }
9708     })
9709
9710
9711
9712     var requestRight = window.commonAjax("/formsetting/getFormsettingInfoService", dataObj, "POST", true);
9713     requestRight.done(function (rs) {
9714         customDataBound.bindInterface(formid);
9715         //          ////console.log(rs);
9716         //console.log(type);
9717         if (rs.data.saveable == "0") {
9718             $(".sure_box").hide();
9719         }
9720         if (!rs.data.subCustomButton) {
9721             $("#doself").remove();
9722
9723         }
9724         if (rs.data.subCustomButton) {
9725             // var dd=document.createElement('span');
9726             var formdata = [];
9727             //console.log("查询类型");
9728             //console.log(type);
9729             switch (type) {
9730                 case "TJ": formdata = rs.data.subCustomButton.addCustomButton; break;
9731                 case "XG": formdata = rs.data.subCustomButton.updateCustomButton; break;
9732                 case "XX": formdata = rs.data.subCustomButton.detailedCustomButton; break;
9733                 case "LB": formdata = rs.data.subCustomButton.listCustomButton; break;
9734             }
9735             //console.log("渲染结果");
9736             var srcd = document.createElement('script');
9737             // var tabledata=rs.data.customButtons;
9738             srcd.type = "text/javascript";
9739             _.each(formdata, function (obt, i) {
9740                 var dd = document.createElement('span');
9741                 dd.id = obt.buttonName + i;
9742                 //btn btn-default
9743                 dd.setAttribute("class", "btn_myself");
9744                 dd.setAttribute("buttonId", obt.buttonId);
9745                 dd.innerHTML = "<i class='icon iconfont icon-kongjian_danhangwenben' style='text-align: left;'></i>" + obt.buttonName;
9746
9747                 $(".edit_form").append(dd);
9748
9749                 //console.log(obt.buttonName);
9750                 if (obt.buttonName == "驳回") {
9751                     //console.log("等于撤回");
9752                     // 定义审批流程定义的方法
9753                     // 撤销流程实例
9754
9755                     $("#" + dd.id).click(function () {
9756                         var process = localStorage.getItem("processid");
9757
9758                         //console.log(process);
9759                         var dd = JSON.parse(process);
9760                         var tent = JSON.parse(localStorage.getItem("tenantID")).tenantID;
9761
9762                         //console.log(dd.data);
9763                         window.queryAjaxs("ubp-api-seache/process/inst/log", { "processInstId": dd.data.processInstId }, "POST", true).done(function (res) {
9764                             //console.log("打印回执");
9765                             //console.log(res);
9766                             if (res != undefined) {
9767                                 //console.log("发送请求");
9768                                 window.queryAjaxs("ubp-api-control/process/inst/drawBack", { "processInstId": res.data[0].processInstId, "activityInstId": res.data[0].activityInstId }, "POST", true).done(function (res) {
9769                                     //console.log("打印回执");
9770                                     //console.log(res);
9771                                     if (res.data == 1) {
9772                                         //console.log("撤销成功");
9773                                         customBase.alert('S',"撤销成功");
9774                                         // localStorage.removeItem('userinfo')
9775                                     }
9776                                 })
9777                             }
9778
9779                         })
9780
9781                     });
9782
9783                     // 结束流程实例
9784                 } else if (obt.buttonName == "结束") {
9785                     $("#" + dd.id)[0].setAttribute('data-toggle', "modal");
9786                     $("#" + dd.id)[0].setAttribute('data-target', ".bs-example-modal-sm");
9787                     $("#" + dd.id).click(function () {
9788                         var processLog = JSON.parse(localStorage.getItem("processLog"));
9789                         if (processLog != null && processLog != undefined) {
9790                         } else {
9791                             $("#liucheng").html("<h3 class='sp_title'>请先创建一个流程<h3>");
9792                             return null;
9793                         }
9794                         if (processLog[0].processState == 60) {
9795                             $("#liucheng").html("<h3 class='sp_title'>流程已结束<h3>");
9796                             return null;
9797                         } else {
9798                             var inputs = "<h3 class='sp_title'>是否确认结束?<h3><br/>"
9799                                 + "<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>";
9800                             $("#liucheng").html(inputs);
9801                             $("#sssd").click();
9802
9803                         }
9804                     });
9805
9806                 } else if (obt.buttonName == "退回") {
9807                     $("#" + dd.id)[0].setAttribute('data-toggle', "modal");
9808                     $("#" + dd.id)[0].setAttribute('data-target', ".bs-example-modal-sm");
9809                     $("#" + dd.id).click(function () {
9810                         var processLog = JSON.parse(localStorage.getItem("processLog"));
9811                         if (processLog[0].processState == 60) {
9812                             customBase.alert('E',"流程已结束");
9813                             return null;
9814                         } else {
9815                             if (processLog != "null" && processLog != undefined) {
9816                                 console.log(processLog.length);
9817                                 if (processLog.length == 1) {
9818                                     customBase.alert('W',"无可退回活动");
9819                                     return null;
9820                                 }
9821                             } else {
9822                                 customBase.alert('W',"请先创建一个流程");
9823                                 return;
9824                             }
9825                             //请求可退回活动项
9826                             var isshow = false;
9827                             var ss = {
9828                                 "processInstId": processLog[0].processInstId
9829                             }
9830                             var requestSingleForm = window.commonAjax("/ubp-api-seache/process/get/back", ss, "POST", true);
9831                             requestSingleForm.done(function (rs) {
9832                                 console.log(rs);
9833                                 var res = rs.data;
9834                                 if (res != undefined & res != null) {
9835
9836                                     if (res.length > 0) {
9837
9838                                         var inputs = "<h3 class='sp_title'>请选择要退回的活动</h3><br/>";
9839                                         for (var i = 0; i < res.length; i++) {
9840                                             if (i == 0) {
9841                                                 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>";
9842                                             } else {
9843                                                 inputs += "<input  type='radio'  onClick='choosebox(" + i + ")' class='act acts' value=" + res[i].activityDefId + " name='task'  />" + res[i].activityDefName + "</br>";
9844                                             }
9845                                         }
9846                                         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 + ")'/>";
9847                                         inputs += "</div>";
9848                                         console.log(inputs);
9849                                         $("#liucheng").html(inputs);
9850
9851
13ec33 9852                                         // callback();
4d1219 9853                                     }
B 9854                                 } else {
9855                                     $("#liucheng").html("<h3 class='sp_title'>无可退回项<h3>");
9856
9857                                     return null;
9858                                 }
9859                             });
9860
9861                         }
9862                     });
9863                 } else if (obt.buttonName == "审批") {
9864                     $("#" + dd.id).click(function () {
9865
9866                         var processLog = JSON.parse(localStorage.getItem("processLog"));
9867                         if (processLog != null && processLog != undefined) {
9868                         } else {
9869                             customBase.alert('W',"请先创建一个流程");
9870                             return null;
9871                         }
9872                         if (processLog[0].processState == 60) {
9873                             customBase.alert('E',"流程已结束");
9874                             return null;
9875                         }
9876                         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/>"
9877                             + "<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>";
9878                         $("#liucheng").html(inputs);
9879                         $("#" + dd.id)[0].setAttribute('data-toggle', "modal");
9880                         $("#" + dd.id)[0].setAttribute('data-target', ".bs-example-modal-sm");
9881                     });
9882
9883                 } else {
9884                     $("#" + dd.id).click(function () {
9885
9886                         var fuc = obt.methodName + "()";
9887                         eval(fuc);
9888                         //console.log(fuc);
9889                         //调用自定义js中的方法
9890                         //console.log("调用自定义方法");
9891                         fuc;
9892
9893                     });
9894                 }
9895             });
9896
9897             srcd.src = rs.data.resourceFilePath;
9898
9899             // $("#customShow").append(srcd);
9900             if(rs.data.resourceFilePath != undefined && flag != 3 && rs.data.resourceFilePath != ''){//自定义JS加载修改  李伟民  0109
9901                 document.getElementsByTagName("head")[0].appendChild(srcd); // 接口注册 初期化事件 李伟民 12-18
9902                 srcd.onload = function () {
9903                     _.each(customBase.interfaceData, function (data) {
9904                         if (data.interfacemethod == "interfaceInit3rd") {
9905                             if (data.customInterfacemethod != undefined && data.customInterfacemethod != '') {
9906                                 var funstr = data.customInterfacemethod + "()";
9907                                 eval(funstr);
9908                             }
9909                         }
9910                     });
9911                     callback(rs);//自定义JS加载修改  李伟民  0109
9912                 }
9913             }else{
9914                 callback(rs);//自定义JS加载修改  李伟民  0109
9915             }
13ec33 9916
4d1219 9917             //  $(".preview-edit-pane").append(dd);
B 9918             //  $("#"+dd.id).click(function(){
9919
9920             //     var fuc=arr[1]+"()";
9921             //     eval(fuc);
9922             //     ////console.log(fuc);
9923
9924             //     ////console.log("调用自定义方法");
9925             //     fuc;
9926
9927             //  });
9928         }else{
9929             callback(rs);//自定义JS加载修改  李伟民  0109
9930         }
9931     });
9932     var dataObjDo = {};
9933     dataObjDo = dataObj;
9934     delete dataObjDo.type
9935     console.log(dataObj)
9936     var requestRight = window.commonAjax("/tabConfiguration/queryTabConfiguration", dataObjDo, "POST", true);
9937     requestRight.done(function (rs) {
13ec33 9938         //2017/10/31 李元杰 附件 流程先洗 选项卡添加
4d1219 9939         console.log(rs)
B 9940         $('.boxTwo').hide();
9941         $('.sTab').find('ul li').eq(1).hide();
9942         $('.boxThr').hide();
9943         $('.sTab').find('ul li').eq(2).hide();
9944         if (rs.data != '') {
9945             if (rs.data[0].appendix == "do") {
9946                 console.log($('.sTab').find('ul li'))
9947                 $('.sTab').find('ul li').eq(1).show();
9948             } else {
9949                 $('.boxTwo').hide();
9950                 $('.sTab').find('ul li').eq(1).hide();
9951             }
9952             if (rs.data[0].processInfo == "do") {
9953                 $('.sTab').find('ul li').eq(2).show();
9954             } else {
9955                 $('.boxThr').hide();
9956                 $('.sTab').find('ul li').eq(2).hide();
9957             }
9958         }
9959     });
9960 }
9961
9962
9963 var xhSelect = xhSelect || {};
9964 xhSelect.scope = {
9965     sel_val_lst: {
9966         // 'F073001':"常规出差"
9967     },
9968     rm_optionFlag: false
9969 };
9970
9971 xhSelect.options = {
9972     selectId: "",
9973     multiple: false,
9974     listData: [],
9975     width: 200,
9976     setDiv: ""
9977 }
9978 xhSelect.setValue = function (itemId, listData) {
9979     xhSelect.setValue(itemId, listData, 0);
9980 }
9981 xhSelect.setValue = function (itemId, listData, N) {
9982     var selectItme = $("#" + itemId + " .selectItme");
9983     var listDataJson = {};
9984     if (_.isString(listData)) {// 下拉款填值  修改  李伟民 11-14
9985         listData = listData.split(",")
9986     }// 下拉款填值  修改  李伟民 11-14
9987     console.log(listData);
9988     for (var i = 0; i < listData.length; i++) {
9989         listDataJson[listData[i]] = "1";
9990     }
9991
9992     var $options = $($("#" + itemId)[0]).find('select > option');
9993     var vals_selected = [];
9994     var j = 0;
9995     $options.each(function () {
9996         for (var jsonstr in listDataJson) {
9997             if ($(this).val() == jsonstr) {
9998                 vals_selected[j] = {};
9999                 vals_selected[j].value = $(this).val();
10000                 vals_selected[j].label = $(this).text();
10001                 j++;
10002             }
10003         }
10004     });
10005     var $el = $($("." + itemId + "value")[N]);
10006     var set_valueleft = function (vals_selected) {
10007         var $divContainer = "";
10008         var selectedItem = {};
10009         for (var i = 0; i < vals_selected.length; i++) {
6f4af7 10010             //张吉男修改 下拉框发布
4d1219 10011             $divContainer += '<div class="val-card ng-binding ng-scope ' + vals_selected[i].value +
B 10012                 'Class" ng-repeat="sel_val in sel_val_lst track by $index" ng-show="true" multiple="" load-data="" style="height:40px;line-height:25px;">' +
6f4af7 10013                 vals_selected[i].label + '<a onclick="xhSelect.rm_option(this,\'' + vals_selected[i].value +
Z 10014                 '\')" ng-href="javascript:void(0);" href="javascript:void(0);">' + '  <i  class="icon iconfont icon-guanbijiantou"  val="' +
4d1219 10015                 vals_selected[i].value + '" style="color:#20b4aa;"></i></li>' + ' </a>' + ' </div>';
B 10016
10017             selectedItem[vals_selected[i].value] = "1";
10018         }
10019         $divContainer += '<div class="suffix">' + '<i class="fa fa-angle-down" aria-hidden="true"></i>' + '</div>';
10020         $el.find(".select-container").empty();
10021         $el.find(".select-container").append($divContainer);
10022         var selectedItemJson = JSON.stringify(selectedItem);
10023         if ($el.find(".selectItme").length != 0) {
10024             $el.find(".selectItme")[0].setAttribute("value", selectedItemJson);
10025         }
10026
10027     };
10028     set_valueleft(vals_selected);
10029 }
10030 xhSelect.getValue = function (itemId) {
10031     var returnItem = [];
10032     var selectItme = $("#" + itemId + " .selectItme");
10033     console.log(selectItme)
10034     for (var i = 0; i < selectItme.length; i++) {
10035         if (selectItme[i].getAttribute("value") == "") {
10036             var selectItmeJson = {};
10037         } else {
10038             ////console.log(selectItme[i].getAttribute("value"));
10039             var selectItmeJson = $.parseJSON(selectItme[i].getAttribute("value"));
10040         }
10041
10042         var jn = 0;
10043         returnItem[i] = [];
10044         for (j in selectItmeJson) {
10045             returnItem[i][jn] = j;
10046             jn++;
10047         }
10048     }
10049     return returnItem;
10050 }
10051 // 下拉框主数据渲染
10052 xhSelect.setXhSelect = function (options) {
10053     ////console.log(options);
10054     ////console.log(_.cloneDeep(xhSelect.options));
10055     //解决主数据重复
10056     var options_xh = _.cloneDeep(xhSelect.options);
10057     options_xh.listData = [];
10058     //解决主数据重复END
10059     options = $.extend(true, options_xh, options);
10060     var optionArr = "";
10061     console.log(options.selectId);
10062     ////console.log(options.listData);
10063     //        ////console.log(options.listData.length);
10064     for (var i = 0; i < options.listData.length; i++) {
10065         optionArr += '<option value="' + options.listData[i].value + '">' + options.listData[i].text + '</option>';
10066     }
10067     console.log(optionArr);
10068     var multiple = "";
10069     if (options.multiple) {
10070         multiple = 'multiple';
10071     }
10072
10073     var $xhSelectDiv = '' +
10074         '<div class="selectClass">' +
10075         '<div ng-transclude="" style="display:none;">' +
10076         '<select class="select_get ng-scope" load-data="" ' + multiple + ' >' +
10077         optionArr +
10078         '</select>' +
10079         '</div>' +
10080         '<div class="selectItme" style="display:none;" value=""></div>' +
10081         '<div class="select3-element" style="width:100%;max-width: ' + options.width + 'px">' +
10082         '            <div  class="select-container select-container_box" gccolname="ex_c11">  ' +
10083         '                    <div class="suffix">' +
10084         '                            <i class="fa fa-angle-down" aria-hidden="true"></i>' +
10085         '                    </div>' +
10086         '            </div>' +
10087         '    </div> ' +
10088         '</div>';
10089     console.log(options);
10090     if (options.setDiv == '') {
10091         var $el = $("#" + options.selectId);
10092     } else {
10093         var $el = $("." + options.setDiv);
10094     }
10095     console.log(optionArr)
10096     console.log($xhSelectDiv)
10097     _.each($el, function (sel) {//添加记录 重复问题  李伟民11-14   主数据丢失  11-29 再次修改
10098         if ($(sel).find(".selectClass").length == 0) {
10099             $(sel).append($xhSelectDiv)
10100         } else {
10101             $(sel).find(".selectClass").find(".select_get").html(optionArr);
10102         }
10103     })//添加记录 重复问题  李伟民11-14   主数据丢失  11-29 再次修改
10104
10105
10106     //添加记录 重复问题  李伟民11-14
10107     //        $("#"+options.selectId).find()
10108
10109     xhSelect.selectContainer(options);
10110     customLinkageAnalysis.bindLinkage();
10111     //行程排序初期化
10112     customShow.journeySort();
10113 }
10114 xhSelect.rm_option = function (val, vals_selected) {
10115     xhSelect.scope.rm_optionFlag = true;
10116     console.log(val);
10117     console.log(vals_selected)
10118     $('div.drop_down_sel').remove();
10119     var selectItmeJson = $($(val).parent().parent().parent().parent()).find(".selectItme")[0].getAttribute("value");
10120
10121     var selectItme = $.parseJSON(selectItmeJson);
10122     delete selectItme[vals_selected];
10123     selectItmeJson = JSON.stringify(selectItme);
10124     $($(val).parent().parent().parent().parent()).find(".selectItme")[0].setAttribute('value', selectItmeJson);
6f4af7 10125
Z 10126     //张吉男修改 下拉框默认值不可以清空
10127     var cla=new RegExp("disableColor");
10128     //console.log(cla.test($(val).parent().parent().attr("class")));
10129     //判断下拉框是否是可编辑
10130     if(!(cla.test($(val).parent().parent().attr("class")))){
10131         $(val).parent().remove();
10132     }
4d1219 10133     setTimeout(function () {
B 10134         xhSelect.scope.rm_optionFlag = false;
10135     }, 500);
10136 }
10137 xhSelect.selectContainer = function (options) {
10138     var itemId = options.selectId;
10139     if (options.setDiv == '') {
10140         var $el = $("#" + itemId);
10141     } else {
10142         var $el = $("." + options.setDiv);
10143     }
10144     $el.find('div.select-container').on('click', function (event) {
10145         var selectedItem = $el.find(".selectItme")[0].getAttribute("value");
10146         //  12/4 李元杰
10147         $('.zTreeDemoBackground').css("display", "none");
10148         $(".search_input").css("display", "none");
10149         console.log(selectedItem);
10150         console.log(event);
10151         console.log($(this))
10152         ////console.log("-------------------this-----------------------------------");
10153         if ($el[0].className.indexOf("readonly") > -1) {
10154             return;
10155         }
10156         if (selectedItem != "") {
10157             selectedItem = $.parseJSON(selectedItem);
10158         }
10159
10160         if (xhSelect.scope.rm_optionFlag) {
10161             return;
10162         }
10163         console.log(2)
10164         $('div.drop_down_sel').remove();
10165         var $select = $el.find('select');
10166         var isMultiple = $select.attr('multiple');
10167         var $options = $el.find('select > option');
10168         ////console.log($el);
10169         ////console.log($options);
10170         var $options_str = '<ul>' + '<li class="sel_query">' + '<input type="text" name="query" >' + '</li>' + '</ul>';
10171
10172         $options_str += '<div class="select "><ul class="line">';
10173
10174         if ($select.attr('multiple')) {
10175             $options_str += '<li class="ui-state-default" style="height:28px"><span class="custom-check "' +
10176                 ' value="All" label="全选" ><i class="label"></i>全选</span></li>';
10177         }
10178         $options.each(function () {
10179             var checked = '';
10180             if (selectedItem[$(this).val()] != undefined) {
10181                 checked = 'cur';
10182             }
10183             $options_str += '<li class="ui-state-default" style="height:28px"><span class="custom-check ' + checked +
10184                 '" value="' + $(this).val() + '" label="' + $(this).text() + '' + '" title="' + $(this).text() + '"><i class="label"></i>' + $(this).text() + '</span></li>'
10185         });
10186
10187         $options_str += '</ul></div>';
10188         console.log($options_str)
10189         console.log(3)
10190         $("div.drop_down_sel").remove();
10191         var $select_obj = $('<div drop-down-selector="" filterlist="searchlist" class="drop_down_sel" style="position: absolute;">' + $options_str + '</div>');
10192         $el.find('div.select3-element').append($select_obj);
10193         $('body').off('click.sel').on('click.sel', function () {
10194             console.log(5);
10195             $('div.drop_down_sel').remove();
10196             $('.zTreeDemoBackground').css("display", "none");
10197             $(".search_input").css("display", "none");
10198         });
10199         $('div.drop_down_sel').off('click.sel').on('click.sel', function (event) {
10200
10201             event.stopPropagation();
10202         });
10203         console.log(6)
10204         $select_obj.find('input[name="query"]').on('keyup',
10205             function () {
10206                 var $el = $(this);
10207                 var inputs = $select_obj.find('.custom-check');
10208                 inputs.each(function () {
10209                     var val = $(this).attr('label');
10210                     var input_val = $el.val();
10211                     if (val.indexOf(input_val) > -1) {
10212                         $(this).closest('li').show();
10213                     } else {
10214                         $(this).closest('li').hide();
10215                     }
10216                 });
10217             });
10218
10219         $select_obj.find('.custom-check').on('click', function () {
10220             if (this.className.indexOf("readonly") > -1) {
10221                 return;
10222             }
10223             $(this).toggleClass('cur');
10224             if ($(this)[0].getAttribute("value") == "All") {
10225                 if (this.className.indexOf("cur") > -1) {
10226                     $($(this).parent().parent()).find(".custom-check").addClass("cur");
10227                 } else {
10228                     $($(this).parent().parent()).find(".cur").removeClass('cur');
10229                 }
10230             }
10231
10232             var set_valueleft = function (vals_selected) {
10233                 var $divContainer = "";
10234                 var selectedItem = {};
10235                 for (var i = 0; i < vals_selected.length; i++) {
10236                     $divContainer += '<div class="val-card ng-binding ng-scope ' + vals_selected[i].value +
10237                         'Class" ng-repeat="sel_val in sel_val_lst track by $index" ng-show="true" multiple="" load-data="" style="height:40px;line-height:25px;">' +
10238                         vals_selected[i].label + '<a onclick="xhSelect.rm_option(this,\'' + vals_selected[i].value +
10239                         '\')" ng-href="javascript:void(0);" href="javascript:void(0);">' + '  <i  class="icon iconfont icon-guanbijiantou"  val="' +
10240                         vals_selected[i].value + '" style="color:#20b4aa;"></i>' + ' </a>' + ' </div>';
10241                     selectedItem[vals_selected[i].value] = "1";
10242                 }
10243                 $divContainer += '<div class="suffix">' + '<i class="fa fa-angle-down" aria-hidden="true"></i>' + '</div>';
10244                 $el.find(".select-container").empty();
10245                 $el.find(".select-container").append($divContainer);
10246                 var selectedItemJson = JSON.stringify(selectedItem);
10247                 $el.find(".selectItme")[0].setAttribute("value", selectedItemJson);
10248                 $el.find(".select_get").trigger("change.value");//下拉框 公式
10249             };
10250             var vals_selected = [];
10251             var vals_selected_item = [];
10252             var checkboxChecked = false;
10253             var checkboxValue = $(this)[0].getAttribute("value");
10254             var checkboxLabel = $(this)[0].getAttribute("label");
10255             if ($(this)[0].className.indexOf('cur') > -1) {
10256                 checkboxChecked = true;
10257             }
10258             if (!isMultiple) {
10259                 vals_selected = [{
10260                     'value': checkboxValue,
10261                     'label': checkboxLabel
10262                 }];
10263                 set_valueleft(vals_selected);
10264                 console.log(7)
10265                 $('div.drop_down_sel').remove();
10266             } else {
10267                 var vls = [];
10268                 var values = $($(this).parent().parent()).find('.cur');
10269                 var j = 0;
10270                 for (var i = 0; i < values.length; i++) {
10271                     if (values[i].getAttribute("value") != "All") {
10272                         vals_selected[j] = {};
10273                         vals_selected[j].value = values[i].getAttribute("value");
10274                         vals_selected[j].label = values[i].getAttribute("label");
10275                         j++;
10276                     }
10277                 }
10278                 set_valueleft(vals_selected);
10279             }
10280         });
10281         event.stopPropagation();
10282     });
10283 }
10284
10285 //customBase.reCharge = function(){//重新记账  李伟民 2017-10-18 21:30
10286 //    //console.log(customBase);
10287 //    //console.log(customShow);
10288 //    var rePostData = {};
10289 //    rePostData['formID'] = customShow.options.formid;
10290 //    rePostData['dataRowNum'] = customShow.options.dataRowNum;
10291 //    var reCharge_request =  window.cloudAjax("epc-tenant/accounting/record",rePostData,"POST",true);
10292 //    reCharge_request.done(function(res){
10293 //        //console.log(res);
10294 //    })
10295 //}//重新记账  李伟民 2017-10-18 21:30 end
10296
10297 //customBase.checkItem = function(){//提交验证 李伟民2017-10-19 15:52
10298 //    //console.log(customBase);
10299 //    //console.log(customShow);
10300 //     //画面项目取得 --------------------------画面项目取得------
10301 //     var items = customShow.getItems();
10302 //         ////console.log(items)
10303 //     // 画面check
10304 //     var returnfromCheck =  customShow.initEvent.fromCheck(items); //--------------------
10305 //     if(returnfromCheck){
10306 ////      return;
10307 //     }
10308 //
10309 //
10310 //         var rules = customShow.options.jsonLinkage;
10311 //        if(!_.isNull(rules) && rules != undefined){
10312 //            rules = JSON.parse(rules);
10313 //            //console.log(rules);
10314 //            var checkId = [];
10315 //            _.each(rules,function(ru){
10316 //                _.each(ru.results,function(res){
10317 //                    if(res.mode == "2" || res.mode == "0"){
10318 //                        checkId.push(ru.event.eventFieldId);
10319 //                        return false;
10320 //                    }
10321 //                })
10322 //            });
10323 //            checkId = _.uniq(checkId);
10324 //            //console.log(checkId);
10325 //            _.each(checkId,function(cid){
10326 //                $("[id='" + cid + "']").trigger("change.check");
10327 //            });
10328 //        }
10329 //}//提交验证 李伟民2017-10-19 15:52 end
10330
10331 // function checkSameDay(day1, day2) {//判断是否为同一天  李伟民 2017-10-20 17:00
10332 //     var seconds;
10333 //     seconds = day1 - day2;
10334 //     //console.log(seconds);
10335 //     if (seconds < 24 * 60 * 60 * 1000 && seconds >= 0) {
10336 //         return true;
10337 //     } else {
10338 //         return false;
10339 //     }
10340 // }//判断是否为同一天  李伟民 2017-10-20 17:00 end
10341
10342 // customBase.checkTimeCross = function () {//跨行程验证时间 李伟民 2017-10-20 11:35
10343 //     //console.log(customBase);
10344 //     //console.log(customShow);
10345 //     var items = customShow.getItems();
10346 //     //console.log(items);
10347 //     var itemKey = _.keys(customBase.options.customItems);
10348 //     var subItem = [];
10349 //     _.each(itemKey, function (keys) {
10350 //         if (customBase.options.customItems[keys].type == "subform") {
10351 //             subItem.push(customBase.options.customItems[keys].fieldKey);
10352 //         }
10353 //     });
10354 //     var FromDateArr = [];
10355 //     var LeaveDateArr = [];
10356 //     //console.log(subItem);
10357 //     _.each(subItem, function (sub) {
10358 //         if (items[sub] != undefined) {
10359 //             _.each(items[sub], function (isub, i) {
10360 //                 if (isub.FromDate != undefined) {
10361 //                     FromDateArr.push({ "value": new Date(isub.FromDate), "num": i, "property": customBase.options.customItems['FromDate'] });
10362 //                 }
10363 //                 if (isub.LeaveDate != undefined) {
10364 //                     LeaveDateArr.push({ "value": new Date(isub.LeaveDate), "num": i, "property": customBase.options.customItems['LeaveDate'] });
10365 //                 }
10366 //             });
10367 //         }
10368 //     });
10369 //     //console.log(FromDateArr);
10370 //     //console.log(LeaveDateArr);
10371 //     if (FromDateArr.length > 1 && LeaveDateArr.length > 1 && FromDateArr.length == LeaveDateArr.length) {
10372 //         _.each(FromDateArr, function (fdate, k) {
10373 //             if (k > 0) {
10374 //                 //console.log(checkSameDay(fdate.value,LeaveDateArr[k-1].value));
10375 //                 if (checkSameDay(fdate.value, LeaveDateArr[k - 1].value) == false) {
10376 //                     var message = customShow.options.customItemShow.item[fdate.property.id].tag_Attribute.title + "与上一行程不连续";
10377 //                     customLinkageAnalysis.setMessage(fdate.property.id, message, k);
10378 //                 }
10379 //             }
10380 //         });
10381 //     }
10382 // }//跨行程验证时间 李伟民 2017-10-20 11:35 end
10383 // customBase.checkLandCross = function () {//跨行程验地点 李伟民 2017-10-20 11:35
10384 //     var items = customShow.getItems();
10385 //     //console.log(items);
10386 //     var itemKey = _.keys(customBase.options.customItems);
10387 //     var subItem = [];
10388 //     _.each(itemKey, function (keys) {
10389 //         if (customBase.options.customItems[keys].type == "subform") {
10390 //             subItem.push(customBase.options.customItems[keys].fieldKey);
10391 //         }
10392 //     });
10393 //     var FromLandeArr = [];
10394 //     var ToLandArr = [];
10395 //     _.each(subItem, function (sub) {
10396 //         if (items[sub] != undefined) {
10397 //             _.each(items[sub], function (isub, i) {
10398 //                 if (isub.From_site != undefined) {
10399 //                     FromLandeArr.push({ "value": isub.From_site[0], "num": i, "property": customBase.options.customItems['From_site'] });
10400 //                 }
10401 //                 if (isub.To_site != undefined) {
10402 //                     ToLandArr.push({ "value": isub.To_site[0], "num": i, "property": customBase.options.customItems['To_site'] });
10403 //                 }
10404 //             });
10405 //         }
10406 //     });
10407 //     if (FromLandeArr.length > 1 && ToLandArr.length > 1 && FromLandeArr.length == ToLandArr.length) {
10408 //         _.each(FromLandeArr, function (fland, k) {
10409 //             if (k > 0) {
10410 //                 customLinkageAnalysis.clearMessage(fland.property.id, k);
10411 //                 //console.log(fland.value != ToLandArr[k-1].value);
10412 //                 if (fland.value != ToLandArr[k - 1].value) {
10413 //                     var message = customShow.options.customItemShow.item[fland.property.id].tag_Attribute.title + "与上一行程不连续";
10414 //                     customLinkageAnalysis.setMessage(fland.property.id, message, k);
10415 //                 }
10416 //             }
10417 //         });
10418 //     }
10419 // }//跨行程验地点 李伟民 2017-10-20 11:35 end
10420 //自定义表单扩展函数 增加行 删除行
10421 customShow.addRow = function (subId, data) {
10422     console.log(data);
10423     console.log(subId);
10424     console.log($("#" + subId));
10425     console.log($("#" + subId).find(".trContentClass"));
10426     $("#" + subId).find(".trContentClass").remove();
10427     // console.log(data[0].length - 1);
10428     for (var i = 0; i < data[0].length; i++) {
10429         var itemId = subId;
10430         var showClass = "customViewUEditorCss";
10431         var item = customBase.options.customItems[customShow.options.customItemShow.item[itemId].tag_Attribute.alias].cloneDiv;
10432         //console.log(customShow.options)
10433         console.log(itemId, item)
10434         console.log(itemId, customBase.options.customItems)
10435         //子表单情况为U情况
10436         if (item == undefined) {// 子表单回显 修改  李伟民 11-10
10437             var tbody = $("." + showClass + " #" + itemId + "ActiveId").find("tbody");
10438             tbody = tbody[0].cloneNode(true);
10439             $(tbody).find(".select2").remove();
10440             console.log($(tbody).html());
10441             $(tbody).find(".tdTitleClass").closest("tr").addClass("table_title");
10442             $(tbody).find(".dropdowntypeCss").select2({ theme: "classic" });
10443             //        $(tbody).find(".zTreeDemoBackground").select2({theme: "classic"});
10444             if ($(tbody).find(".table_title").length > 0) {
10445                 //删除头行
10446                 $(tbody).find(".table_title").remove();
10447             }
10448             if ($(tbody).find(".trContentClass").length > 1) {// 去除重复的tr  李伟民 11-14
10449                 $($(tbody).find(".trContentClass")[0]).siblings().remove();
10450             }// 去除重复的tr  李伟民 11-14
10451             //        $(tbody).find(".cfg_contentNone").removeClass("cfg_contentNone");
10452             tbody = customShow.addsubformListInit(itemId, $(tbody).find("tr"));
10453             console.log(tbody);
10454             console.log(itemId);
10455             console.log($(tbody).find("#" + itemId).attr("class"));
10456             $($("." + showClass + " #" + itemId + "ActiveId").find("table")[0]).append(tbody);// 子表单回显 修改  李伟民 11-10
10457             customShow.hidesubform();
10458             customShow.setXhSelectList(false);//添加记录 重复问题  李伟民11-14
10459         } else {
10460             console.log(item);
10461             item = item[0].cloneNode(true);
10462             console.log(item);
10463             $(item).find(".select2").remove();
10464             $(item).find(".dropdowntypeCss").select2({ theme: "classic" });
10465
10466             $(item).find(".subformAddiconShow .cfg_contentNone").removeClass("cfg_contentNone");
10467             item = customShow.addsubformListInit(itemId, item);
10468             $($("." + showClass + " #" + itemId + "ActiveId").find("table")[0]).append(item);
10469
10470         }
10471         customShow.setXhSelectList(true);//添加记录 重复问题  李伟民11-14
10472         customShow.addtree(itemId, item);
10473         //子表单事件追加
10474         customShow.clickBindSubform();
10475         //公式初期化
10476         customLinkageAnalysis.bindLinkage();
10477         customShow.oneTotle();
10478         $('.iconfontcolor').on('click', function () {
10479             $(this).parent().parent().parent().remove();
10480         });
10481         console.log($(item))
10482         customShow.addtree(itemId, item);
10483     }
10484     var customItems = customBase.options.customItems;
10485     console.log(customItems)
10486     var order = $($("#" + subId + "ActiveId .trContentClass")[0]).find(".tdContentClass");
10487     var orderid = [];
10488     var orderObj = {};
10489     _.each(order, opt => {
10490         if ($(opt).find("div").children().eq(0).attr("id")) {
10491             orderid.push($(opt).find("div").children().eq(0).attr("id"));
10492         } else {
10493             orderid.push($(opt).find("div").children().eq(1).attr("id"));
10494         }
10495     });
10496     console.log(orderid);
10497     orderid.splice(0, 1);
10498     console.log(orderid);
10499     var subArr = [];
10500     console.log(subId)
10501     _.each(customItems, opt => {
10502         if (opt.parentsubFormNum == subId.replace("itemId_", "")) {
10503             subArr.push(opt);
10504         }
10505     });
10506     _.remove(subArr, n => {
10507         return n.fieldKey == "DATAROWNUM";
10508     })
10509     console.log(subArr);
10510     var endArr = [];
10511     _.each(orderid, opt => {
10512         var a = {};
10513         _.each(subArr, o => {
10514             if (opt == o.id) {
10515                 a = o;
10516             }
10517         });
10518         endArr.push(a);
10519     })
10520     console.log(endArr);
10521     console.log(data);
10522     _.each(endArr, (opts, i) => {
10523         console.log(opts.id, opts.type, data[i]);
10524         if (opts.type == "dropdownlist") {// 不可修改  控件type  李伟民  11-17
10525             customBase.setItemValue(opts.id, "dropdownlistText", data[i], "", "");
10526         } else {
10527             customBase.setItemValue(opts.id, opts.type, data[i], "", "");
10528         }
10529     });
10530     console.log(subId)
10531     customShow.subTotle(subId)
10532 };
10533 //关联表单控件  列表渲染
10534 createTable = function (rs, formId, formhuixian, head, $iconId, addVal) {
10535     var showVal = [];
10536     var iconAttr = customShow.options.customItemShow.item[$iconId];//关联数据 函数 数据源 李伟民  11-07
10537     //接收table内容请求
10538     var content = "";
10539     var counts = "";
10540     $(".requestMenu").empty();
10541     //渲染table头部变量;
10542     let headtr = "";
10543     //渲染table内容变量
10544     let contentdata = "";
10545     //表头渲染数据
10546     //console.log(head);
10547     _.remove(head, n => {
10548         return n.fieldKey == "DATAROWNUM";
10549     });
10550     _.each(head, opt => {
10551         headtr += '<td>' + opt.title + '</td>';
10552     });
10553     let head_tr = $("<tr class='headtr'></tr>");
10554     head_tr.append('<td class="td1">选择</td>' + headtr);
10555     $(".requestMenu").append(head_tr);
10556
10557     //console.log(rs)
10558     if (rs.data != undefined && !_.isNull(rs.data) && rs.data.count != undefined) {
10559         counts = rs.data.count;
10560     }
10561     if (rs.data != undefined && !_.isNull(rs.data)) {
10562         content = rs.data.list;
10563     } else {
10564         content = [];
10565     }
10566     // if(iconAttr.tag_Attribute.relevancesourcetype == "fundata"){
10567     //     codeContent = rs.data.list;
10568     // }else{
10569     //     codeContent = rs.data.code;
10570     // }
10571     console.log(content);
10572     if (content.length == 0) {
10573         var div_empty = $("<div><i style='width:20px;height:20px;' class='fa fa-envelope-o' aria-hidden='true'></i><p>您还没有数据显示</p></div>");
10574         $(".requestMenu").append(div_empty);
10575     } else {
10576         _.each(content, (opt) => {
10577             _.each(formhuixian, n => {
10578                 if (opt.DATAROWNUM == n.DATAROWNUM) {
10579                     opt.show = "cur";
10580                 }
10581             });
10582             var contentdata = "";
10583             _.each(head, opts => {
10584                 contentdata += '<td>' + opt[opts.fieldKey] + '</td>';
10585             });
10586             var tr = $("<tr class='bodytr'></tr>");
10587             tr.append('<td class="td1"><li class="checkLine"><span class="custom-check ' + opt.show + '"></span><i class="label"></i></li></td>' + contentdata);
10588             console.log(tr);
10589             $(".requestMenu").append(tr);
10590         });
10591     }
10592     //console.log(formhuixian);
10593
10594
10595     if (formhuixian != undefined) {
10596         addVal = formhuixian;
10597     }
10598     let show = "";
10599     var showObj = {};
10600     //选择方法
10601     head.push({ fieldKey: "DATAROWNUM", title: "DATAROWNUM" });
10602     //判断单选多选
10603     var selItem = customShow.options.customItemShow.item;
10604     console.log(selItem);
10605     var sel = "";
10606     var datarow = "";
10607     var tag_Id = "";
10608     console.log(selItem);
10609     for (let key in selItem) {
10610         if (key == $iconId) {
10611             sel = selItem[key].tag_Attribute.mytextSel;
10612             console.log(selItem[key].tag_Attribute.singleSetValue);
10613             if (selItem[key].tag_Attribute.singleSetValue != "itemId") {
10614                 datarow = JSON.parse(selItem[key].tag_Attribute.singleSetValue).columnOrderNum;
10615                 tag_Id = JSON.parse(selItem[key].tag_Attribute.singleSetValue).tag_Id;
10616             }
10617         }
10618     }
10619     console.log(sel)
10620     if (sel == "single") {
10621         $(".custom-check").on("click", function () {
10622             var addVals = [];
10623             var showVals = [];
10624             $(this).parent().parent().parent().siblings().find(".custom-check").removeClass('cur');
10625             $(this).toggleClass('cur');
10626             console.log($(this));
10627             console.log($(this).siblings());
10628             //            var showObj = {};
10629             let $index = $(this).parent().parent().parent().index() - 1;
10630             var check = $(".custom-check");
10631             console.log(check);
10632             _.each(check, opt => {
10633                 console.log(opt)
10634                 if ($(opt).hasClass('cur')) {
10635                     addVals.push(content[$(opt).parent().parent().parent().index() - 1]);
10636                     // showVals.push(content[$(opt).parent().parent().parent().index() - 1]);
10637                     // addVals.push(codeContent[$(opt).parent().parent().parent().index() - 1]);//填值时使用code  李伟民  12-05
10638                     // console.log(codeContent[$(opt).parent().parent().parent().index() - 1])
10639                 } else {
10640                     _.remove(addVals, n => {
10641                         return n.DATAROWNUM == content[$(opt).parent().parent().parent().index() - 1].DATAROWNUM;
10642                         // return n.DATAROWNUM == codeContent[$(opt).parent().parent().parent().index() - 1].DATAROWNUM;//填值时使用code  李伟民  12-05
10643                     });
10644                     // _.remove(showVals, n => {
10645                     //     return n.DATAROWNUM == content[$(opt).parent().parent().parent().index() - 1].DATAROWNUM;
10646                     // });
10647                 }
10648             });
10649             addVal = addVals;
10650             // showVal = showVals;
10651             console.log(addVal);
10652             console.log(datarow);
10653             customShow.sureonclick(addVal, $iconId, head, sel, iconAttr, datarow, formId);
10654         });
10655         console.log(addVal);
10656
10657     } else if (sel == "multiple") {
10658         $(".custom-check").on("click", function () {
10659             $(this).toggleClass('cur');
10660             //                var showObj = {};
10661             let $index = $(this).parent().parent().parent().index() - 1;
10662             if ($(this).hasClass('cur')) {
10663                 addVal.push(content[$index]);
10664                 // showVal.push(content[$index]);
10665                 // addVal.push(codeContent[$index]);//填值时使用code  李伟民  12-05
10666                 //console.log(content[$index])
10667             } else {
10668                 _.remove(addVal, n => {
10669                     return n.DATAROWNUM == content[$index].DATAROWNUM;
10670                     // return n.DATAROWNUM == codeContent[$index].DATAROWNUM;//填值时使用code  李伟民  12-05
10671                 });
10672                 // _.remove(showVal, n => {
10673                 //     return n.DATAROWNUM == content[$index].DATAROWNUM;
10674                 // });
10675             }
10676             customShow.sureonclick(addVal, $iconId, head, sel, iconAttr, datarow, formId);
10677         });
10678     }
10679     console.log(addVal);
10680     //选择方法END
10681     return counts;
10682 }
10683
10684 function createMxtTable($iconId, head, addVal) {// 关联数据渲染修改  李伟民 11-30
10685     console.log(head);
10686     console.log(addVal);
10687     if (head == "" || addVal == "" || head == undefined || addVal == undefined) {
10688         return false;
10689     }
10690     var tableBox = $("<table class='mxtdatatable table'></table>");
10691     var tableTitle = $("<tr></tr>");
10692     var tableBody = $("<tbody></tbody>");
10693     var tableHead = $("<thead></thead>");
10694     _.each(addVal, function (atd) {
10695         var tableContent = $("<tr></tr>");
10696         _.each(head, function (htd) {
10697             var td = '<td class="mxtdatatabletd">' + (atd[htd.fieldKey] ? atd[htd.fieldKey] : "") + '</td>';
10698             tableContent.append(td);
10699             var th = '<th>' + htd.title + '</th>';
10700             tableTitle.append(th);
10701         });
10702         tableBody.append(tableContent);
10703     });
10704     tableHead.append(tableTitle);
10705     tableBox.append(tableHead);
10706     tableBox.append(tableBody);
10707     $('#' + $iconId).append(tableBox);
10708 }// 关联数据渲染修改  李伟民 11-30
10709
10710 function setValByAnother(iconAttr, addVal, formId, head, typeflag) {//遍历对比别名相同填值 typefalg为true代表关联的是函数
10711     var datarowNum = addVal[0].DATAROWNUM;
10712     var postdata = {};
10713     var getCodeUrl = "";
10714     var ajaxtype = "";
10715     if (typeflag) {
10716         getCodeUrl = "/datamanagement/getAssociateData";
10717         postdata = { "formID": customShow.options.formid, "search": [], "pageSize": "1000", "pageNum": "1", "key": JSON.parse(iconAttr.tag_Attribute.fundata)['key'], "dataRowNum": datarowNum, "type": "code" };
10718         ajaxtype = "POST";
10719     } else {
10720         postdata = {
10721             "datarowNum": datarowNum,
10722             "formID": formId.formID
10723         };
10724         getCodeUrl = "/datamanagement/getSingleFormDataService";
10725         ajaxtype = "GET";
10726     }
10727
10728     console.log(postdata);
10729     var rquest = window.commonAjax(getCodeUrl, postdata, ajaxtype, true);
10730     rquest.done(function (res) {
10731         console.log(res);
10732         var rsdata = "";
10733         if (res.data && res.data.main != undefined) {
10734             if (typeflag) {
10735                 rsdata = res.data.list[0];
10736             } else {
10737                 rsdata = res.data.main;
10738             }
10739             console.log(iconAttr);
10740             console.log(rsdata);
10741             if (rsdata == undefined) {
10742                 return false;
10743             }
10744             _.each(customBase.options.customItems, opt => {
10745                 _.each(head, opts => {
10746                     if (opts.fieldKey == opt.fieldKey) {
10747                         if (opt.type == "dropdownlist") {
10748                             //                                if(customBase.getItemValue(opt.id,"dropdownlistText")[0].length == 0){
10749                             var item = customShow.options.customItemShow.item[opt.id];
10750                             var dropdowntype = item.tag_Attribute.dropdowntype;
10751                             customBase.setItemValue(opt.id, "dropdownlistText", res.data.main[opt.fieldKey], "", "");
10752                             //                            }
10753                         } else {
10754                             //                                if(!customBase.getItemValue(opt.id,opt.type)){
10755                             customBase.setItemValue(opt.id, opt.type, res.data.main[opt.fieldKey], "", "");
10756                             //                            }
10757                         }
10758                     };
10759                 })
10760             });
10761         }
10762
10763     });
10764
10765 }
10766
10767 customShow.sureonclick = function (addVal, $iconId, head, sel, iconAttr, datarow, formId) {
10768     console.log(datarow)
10769     $(".btn-primary").on("click", function () {
10770         var showObj = {};
10771         console.log(addVal);
10772         $('#' + $iconId).empty();
10773         //回显属性
10774         $("#" + $iconId).attr("formhuixian", JSON.stringify(addVal));
10775         var saveval = '';//关联数据空间 存值  李伟民  11-07
10776         var saveArr = [];
10777         _.each(addVal, function (v) {
10778             if (v.DATAROWNUM != undefined) {
10779                 saveArr.push(v.DATAROWNUM);
10780             }
10781         });
10782         saveval = saveArr.join();
10783         customBase.setItemValue($iconId, customShow.options.customItemShow.item[$iconId].tag_Type, saveval);//关联数据空间 存值  李伟民  11-07 end
10784         if (addVal != "" && addVal != undefined) {
10785             $("#" + iconAttr.tag_Id).attr("checkVal", JSON.stringify(addVal));//将选中值存储起来  用于验证
10786             $("#" + iconAttr.tag_Id).attr("checkHead", JSON.stringify(head));
10787         }
10788         var data2 = customShow.columnToRow(head, addVal);
10789         //子表单自动增加行
10790         var subId = $('#' + $iconId + "ActiveId").attr("choosesubform");
10791         console.log(subId);
10792         if (subId == "itemId") {
10793             createMxtTable($iconId, head, addVal);
10794             console.log(addVal);
10795             console.log(head);
10796             setValByAnother(iconAttr, addVal, formId, head);
10797             //遍历对比别名相同填值
10798             // _.each(customBase.options.customItems, opt => {
10799             //     _.each(head, opts => {
10800             //         if (opts.fieldKey == opt.fieldKey) {
10801             //             if (opt.type == "dropdownlist") {
10802             //                 //                                if(customBase.getItemValue(opt.id,"dropdownlistText")[0].length == 0){
10803             //                 var item = customShow.options.customItemShow.item[opt.id];
10804             //                 var dropdowntype = item.tag_Attribute.dropdowntype;
10805             //                 customBase.setItemValue(opt.id, "dropdownlistText", addVal[0][opt.fieldKey], "", "");
10806             //                 //                            }
10807             //             } else {
10808             //                 //                                if(!customBase.getItemValue(opt.id,opt.type)){
10809             //                 customBase.setItemValue(opt.id, opt.type, addVal[0][opt.fieldKey], "", "");
10810             //                 //                            }
10811             //                            }
10812             //         };
10813             //     })
10814             // });
10815         } else {
10816             console.log(addVal)
10817             if (sel == "single" && iconAttr.tag_Attribute.relevancesourcetype != "fundata") {
10818                 setValByAnother(iconAttr, addVal, formId, head)
10819                 //                    _.each(addVal,(opt,j)=>{
10820                 ////                        var ulBox = $("<ul></ul>");
10821                 //                        var ulBox = $("<table></table>");
10822                 //                        var sdata_head = "";
10823                 //                        var sdata_boby = "";
10824                 //                        for(var i = 0;i<head.length;i++){
10825                 //                            show = "";
10826                 //                            sdata_head += '<td class="data1 '+head[i].fieldKey+'">'+head[i].title+'</td>';
10827                 //                            sdata_boby += '<td class="data2 '+head[i].fieldKey+'">'+opt[head[i].fieldKey]+'</td>';
10828                 //                            show += '<li>'+'<span class="data1 '+head[i].fieldKey+'">'+head[i].title+'</span>'+'<span class="data2 '+head[i].fieldKey+'">'+opt[head[i].fieldKey]+'</span>'+'</li>';
10829                 //
10830                 //                            showObj[head[i].fieldKey] = opt[head[i].fieldKey];
10831                 //
10832                 //                            ulBox.attr("class","addUl ulBox"+j);
10833                 //                            ulBox.attr("id","ulBox"+j);
10834                 ////                            ulBox.append(show);
10835                 //                        }
10836                 //                        ulBox.append("<tr>"+sdata_head+"</tr><tr>"+sdata_boby+"</tr>");
10837                 //                        console.log(sdata_head);
10838                 //                        $('#'+$iconId).append(ulBox);
10839                 //                    });
10840                 createMxtTable($iconId, head, addVal);
10841                 var subdata = {};
10842                 console.log(datarow)
10843                 subdata.formdataNum = datarow;
10844                 subdata.datarowNum = addVal[0].DATAROWNUM;
10845                 subdata.formID = formId.formID;
10846                 var subformData = window.commonAjax("/datamanagement/getSubFormDataListService", subdata, "GET", true, false);
10847                 subformData.done(function (rs) {
10848                     console.log(rs.data);
10849                     var c_data = SC.cur_zero(rs.data);
10850                     console.log(c_data)
10851                     var rsArr = [];
10852                     _.each(c_data, opt => {
10853                         var opts = _.omit(opt, ['DATAROWNUM']);
10854                         rsArr.push(opts)
10855                     });
10856                     var rslength = _.keys(rsArr[0]).length;
10857                     console.log(rsArr);
10858                     var subId = $('#' + $iconId + "ActiveId").attr("choosesubform");
10859                     console.log($(".myipt"))
10860                     var formObj = window.localStorage.getItem("netformid");
10861                     var globalFormID = formObj;
10862                     var dataObj = {};
10863                     dataObj.formID = globalFormID;
10864                     var order_id = [];
10865                     //   11/25 李元杰 存flag
10866                     console.log(dataObj)
10867                     var requestRight = window.commonAjax("/datamanagement/getFormFieldListService", dataObj, "GET", true, false);
10868                     requestRight.done(function (rs) {
10869                         console.log(rs)
10870                         order_id = rs.data;
10871                     })
10872
13ec33 10873                     // var tenantID =JSON.parse(window.localStorage.getItem('tenantID'))
4d1219 10874                     // dataObj.tenantID= tenantID.tenantID;
B 10875
10876                     //          var order_ids = JSON.parse($(".myipt").val());
10877                     console.log(order_id);
10878                     //         console.log(order_ids)
10879
10880
10881                     if (customShow.options.customItemShow.item[$iconId].tag_Attribute.singleSetValue) {
10882                         var message = JSON.parse(customShow.options.customItemShow.item[$iconId].tag_Attribute.singleSetValue);
10883                     }
10884                     console.log(message.columnOrderNum)
10885
10886                     console.log(subId);
10887                     var subIds = subId.replace("itemId_", "")
10888                     console.log(subIds);
10889                     var orderArr = []; //存储关联表单内子表单的数组
10890                     _.each(order_id, opt => {
10891                         console.log(opt)
10892                         if (opt.parentsubFormNum == message.columnOrderNum) {
10893                             orderArr.push(opt);
10894                         }
10895                     });
10896                     _.remove(orderArr, n => {
10897                         return n.fieldKey == "DATAROWNUM";
10898                     })
10899                     console.log(orderArr);
10900                     orderArr = _.sortBy(orderArr, ['fieldOrderNum']);
10901                     var resArr = [];
10902                     for (i = 0; i < rslength; i++) {
10903                         resArr.push([])
10904                     }
10905                     console.log(rsArr);
10906                     console.log(orderArr)
10907                     _.each(rsArr, (opt, i) => {
10908                         var j = 0
10909                         _.each(orderArr, n => {
10910                             resArr[j][i] = opt[n.fieldKey]
10911                             j++;
10912                         })
10913                     });
10914                     console.log(resArr);
10915                     if (resArr.length == 0){
10916                         alert("上级预算为0");
10917                     } else {
10918                         customShow.addRow(subId, resArr);
10919                     }
10920                     $(".subformAdd").hide();
10921                     $(".subformAddiconShow").hide();
10922
10923                 });
10924             } else if (sel == "multiple" || iconAttr.tag_Attribute.relevancesourcetype == "fundata") {
10925                 console.log("fundata");
10926                 if (iconAttr.tag_Attribute.relevancesourcetype == "fundata") {//关联函数时 别名相同填值
10927                     setValByAnother(iconAttr, addVal, "", head, true);
10928                 }
10929                 createMxtTable($iconId, head, addVal);
10930                 $("#" + subId + "subformTr").nextAll().remove();
10931                 customShow.addRow(subId, data2);
10932                 $(".subformAdd").hide();
10933                 $(".subformAddiconShow").hide();
10934             }
10935         }
10936         console.log(customShow.customJs(subId))
10937         SC.setSubForm(customShow.customJs(subId), subId);
10938         if (addVal.length != 0) {
10939             SC.Superior_show()
10940         }
10941     });
10942 }
10943
10944 customShow.customJs = function (subId) {
10945     var subArr = [];
10946     console.log(subId)
10947     var customItems = customBase.options.customItems;
10948     console.log(customItems)
10949     _.each(customItems, opt => {
10950         if (opt.parentsubFormNum == subId.replace("itemId_", "")) {
10951             subArr.push(opt);
10952         }
10953     });
10954     _.remove(subArr, n => {
10955         return n.fieldKey == "DATAROWNUM";
10956     })
10957     console.log(subArr);
10958     var aliasArr = [];
10959     _.each(subArr, opt => {
10960         aliasArr.push(opt.fieldKey)
10961     })
10962     console.log(aliasArr);
10963     return aliasArr;
10964 }
10965
10966 //表单引用 扩展 回显子表单功能
10967 fenye = function (pageSize, pageNum, formId, sCondition, formhuixian, head, $iconId, addVal, anydata) {
10968     console.log($iconId);
10969     console.log("findmany");
10970     console.log(anydata);
10971     console.log(head);
10972     var iconAttr = customShow.options.customItemShow.item[$iconId];//关联数据 函数 数据源 李伟民  11-07
10973     console.log(iconAttr);
10974     var dataUrl = "";
10975     var dataObj;
10976     if (anydata) {
10977         //   alert('if');
10978     } else {
10979         //   alert("else");
10980     }
10981     if (iconAttr.tag_Attribute.relevancesourcetype && iconAttr.tag_Attribute.relevancesourcetype == "fundata") {
10982         dataUrl = "/datamanagement/getAssociateData";
10983         dataObj = { "formID": customShow.options.formid, "tenantID": "001", "search": [], "pageSize": pageSize, "pageNum": pageNum, "key": JSON.parse(iconAttr.tag_Attribute.fundata)['key'] };
10984         _.extend(dataObj, { "formData": customShow.getItems() });
10985     } else {
10986         dataUrl = "/datamanagement/getAssociatedFormDataService";
10987         dataObj = { "formID": formId.formID, "tenantID": "001", "screenCondition": sCondition, "pageSize": pageSize, "pageNum": pageNum, "search": anydata };
10988         window.localStorage.setItem("netformid", dataObj.formID);
10989     }
10990     //关联数据 函数 数据源 李伟民  11-07
10991     //    var dataObj = {"formID":formId.formID,"tenantID":"001","screenCondition":sCondition,"pageSize":pageSize,"pageNum":pageNum};
10992     //window.localStorage.setItem("netformid",dataObj.formID);
10993     var requestRight = window.commonAjax(dataUrl, dataObj, "POST", true, false);
10994     var counts = "";
10995     requestRight.done(function (rs) {
10996         if (iconAttr.tag_Attribute.relevancesourcetype && iconAttr.tag_Attribute.relevancesourcetype == "fundata") {
10997             // var titleObj = { "key": JSON.parse(iconAttr.tag_Attribute.fundata)['key'] };
10998             // var requestTitle = window.commonAjax("/datamanagement/getAssociateTitle", titleObj, "POST", true, false);
10999             // requestTitle.done(function (res) {
11000             //     var formtitle = [];
11001             //     _.each(res.data, function (tdata) {
11002             //         formtitle.push({ "fieldKey": tdata.fieldKey, "title": tdata.title });
11003             //     });
11004             counts = createTable(rs, formId, formhuixian, head, $iconId, addVal);
11005             // });
11006
11007         } else {
11008             counts = createTable(rs, formId, formhuixian, head, $iconId, addVal);//关联表单 列表回显
11009         }
11010
11011     });
11012     $('.closeBtn').on('click', () => {
11013         $('#' + $iconId + 'menuContent').remove();
11014         console.log($('.maskLayer'))
11015         $('.maskLayer').css('display', 'none');
11016     })
11017     return counts;
11018 }
11019 customShow.journeySort = function () {//行程排序 初始化 李伟民 2017-10-23 15:56
11020     //console.log(customShow);
11021     var itemKey = _.keys(customShow.options.customItemShow.item);
11022     _.each(itemKey, function (keys) {
11023         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 != "") {
11024             customShow.bindSort(customShow.options.customItemShow.item[keys].tag_Attribute.sorttype, keys);
11025         }
11026     });
11027     //    customShow.bindSort("itemId_6","itemId_3");
11028 }//行程排序 初始化 李伟民 2017-10-23 15:56 end
11029
11030 customShow.bindSort = function (sorttype, sub) {//排序事件绑定
11031     if (customShow.options.customItemShow.item[sorttype] == undefined) {
11032         return false;
11033     }
11034     var tagType = customShow.options.customItemShow.item[sorttype].tag_Type;
11035     if (tagType == "text" || tagType == "number" || tagType == "calendar") { //单行文本  数字 时间
11036         $("[id=" + sorttype + "]").unbind("change.sort", customShow.sortEvent);
11037         $("[id=" + sorttype + "]").on("change.sort", { msg: { "sorttype": sorttype, "type": tagType, "sub": sub } }, customShow.sortEvent);
11038     } else if (tagType == "dropdownlist") { // 下拉框
11039
11040     }
11041
11042 }
11043
11044 customShow.sortEvent = function (event) {//
11045     var sorttype = event.data.msg.sorttype;
11046     var type = event.data.msg.type;
11047     var sub = event.data.msg.sub;
7e9bb9 11048     var subType = customShow.options.customItemShow.item[sub].tag_Attribute.allcopy;
L 11049     console.log(event);
4d1219 11050     var allValue;
B 11051     var allItem = [];
11052     allValue = customBase.getItemValue(sorttype, type);
11053     if(_.isString(allValue)){
11054         allValue = [allValue];
11055     }
11056     //console.log(allValue);
11057     _.each(allValue, function (v, i) {
7e9bb9 11058         var optValue;
L 11059         if(type == "calendar"){
11060             optValue = new Date(v);
11061         }else if(type == "number"){
11062             optValue = Number(v)
11063         }else{
11064             optValue = v;
4d1219 11065         }
7e9bb9 11066         if(subType){
L 11067             allItem.push({ "value": optValue, "index": i, "temp": $("[id='" + sub + "ActiveId']:eq(" + i + ")").clone(true) });
11068         }else{
11069             allItem.push({ "value": optValue, "index": i, "temp": $("[id='" + sub + "subformTr']:eq(" + i + ")").clone(true) });
11070         }
13ec33 11071
4d1219 11072     });
B 11073     //console.log(allItem);
11074     var sortValue = _.sortBy(allItem, function (o) {
11075         return o.value;
11076     });
11077     console.log(sortValue);
7e9bb9 11078     if(subType){
L 11079         _.each($("[id='" + sub + "ActiveId']"), function (subform, k) {
11080             $(subform).replaceWith(sortValue[k].temp);
11081         })
11082     }else{
11083         _.each($("[id='" + sub + "subformTr']"), function (subform, k) {
11084             $(subform).replaceWith(sortValue[k].temp);
11085         })
11086     }
13ec33 11087
4d1219 11088     // customShow.controlInit("customShow");
B 11089     customLinkageAnalysis.bindLinkage();
11090     customShow.journeySort();
11091 }
11092 //马习同 2017/10/25
11093 $(".sTab ul li").on('click', function () {
11094     $(this).css('border-bottom', '2px solid #23b7e5');
11095     $(this).css('box-sizing', 'border-box');
11096     $(this).siblings().css('border', 'none');
11097     //console.log($($(".tabBox>div")[$(this).index()]));
449a85 11098     $($(".tabBox>div")[$(this).index()]).show();
4d1219 11099     $($(".tabBox>div")[$(this).index()]).siblings().hide();
449a85 11100     if($(this).index() == 0){//切换选项卡导致 保存按钮消失修改  李伟民 0201
L 11101         $(".tabBox .sure_box").show();
11102     }
4d1219 11103 });
B 11104 $(".tag_two").on("click", function () {
11105     //    $(".boxTwo iframe").attr("src","http://122.114.176.216:8087/#/IframeExample?token=C3CDE94FE9CBDDDD37312D3331AC091EC737F5555007677E45A390EFEC7147996A49AA4E117EDC02F0D15984E725CA3B5B93DDAF0C989C35642B58B29360D998DDDAC06EB509BE1C22B19D555A1BB75A07A36FD6C4A7E87C9C9EA0070A213BFB44FF8D3B2AD5A33086EAF1F22E978B24951EA806054F94042533CA73EA7901C5E8B13D4DB7DC87308266E769258DEDFF&openId=3dc22baf5d484170&tenantId=13&companyId=17& appId=1&processInstId=1483")
11106 })
11107 //马习同  11/7  行转化列
11108 customShow.columnToRow = function (head, addVal) {
11109     var data = []
11110     _.remove(head, n => {
11111         return n.fieldKey == "DATAROWNUM";
11112     })
11113     _.each(head, opt => {
11114         let data1 = [];
11115         _.each(addVal, opts => {
11116             data1.push(opts[opt.fieldKey]);
11117         });
11118         console.log(data1)
11119         data.push(data1)
11120     });
11121     return data;
11122 }
11123
11124 function submitErrShow(item,num){//审查必须错误提示 李伟民 0119
11125     console.log(item,num);
11126     var itemId = item.tag_Id;
11127     if(num == undefined){
11128         num = 0;
11129     }
11130     var mesageErrDiv = document.createElement("div");
11131     mesageErrDiv.setAttribute("class", "mesageErrDiv");
11132     $(mesageErrDiv).addClass('submitrErr');
8aa132 11133     var mesageErrStr = item.tag_Attribute.title + '不能为空(审查必须)';
4d1219 11134     mesageErrDiv.setAttribute("id", id + "mesageErrDiv");
8aa132 11135     $(mesageErrDiv).append(mesageErrStr);
L 11136     if(customShow.options.customInit.designMode != 1){//快捷模式 李伟民 0126
4d1219 11137         if ($(".customShow  #" + itemId + "ActiveId").length == 0) {
B 11138             console.log($(".customViewUEditorCss [id='" + itemId + "']:eq(" + num + ")").closest("td"));
11139             $(".customShow [id='" + itemId + "']:eq(" + num + ")").closest("td").append(mesageErrDiv);
11140             $(".customShow ." + itemId + "_showItem:eq(" + num + ")").append(mesageErrDiv);
11141         } else {
11142             $($($(".customShow  #" + itemId + "ActiveId")[num])[0]).append(mesageErrDiv);
11143         }
8aa132 11144     }else{//普通模式 李伟民 0126
L 11145         if ($(".customShow  #" + itemId).length == 0) {
11146             $($(".customShow  ." + itemId + "_showItem")[num]).css({
11147                 'height':"20px",
11148                 'display':'inline-block'
11149             })
11150             $($(".customShow  ." + itemId + "_showItem")[num]).popover({
11151                 // title:"错误信息",
11152                 html: true,
11153                 content: mesageErrStr,
11154                 trigger: 'hover'
11155             });
11156             $($(".customShow  ." + itemId + "_showItem")[num]).popover('show');
11157         } else {
11158             $($(".customShow  #" + itemId)[num]).popover({
11159                 // title:"错误信息",
11160                 html: true,
11161                 content: mesageErrStr,
11162                 trigger: 'hover'
11163             });
11164             $($(".customShow  #" + itemId)[num]).popover('show');
11165         }
11166     }
4d1219 11167 }
B 11168
11169 function submitCheck(){//提交前验证审查必须 李伟民 0119
11170     $('.submitrErr').remove();
11171     var checkFlag = true;
11172     var item = localStorage.getItem('customItem');
11173     if(item != undefined && item != ''){
11174         item = JSON.parse(item);
11175     }
11176     console.log(customBase);
13ec33 11177     console.log(customShow);
4d1219 11178     console.log(item);
B 11179     var allItemKey = _.keys(customBase.options.customItems);
11180     var allItemId = _.keys(customShow.options.customItemShow.item);
11181     var allItem = _.cloneDeep(customShow.options.customItemShow.item);
11182     var allItemValue = [];
11183     var childItem = [];
11184     var parentNums = [];
11185     var parentItem = {};
11186     _.each(allItemId,function(id){
11187         if(allItem[id].parentsubFormNum == 0){
11188             allItemValue.push(allItem[id]);
11189         }else{
11190             childItem.push(allItem[id]);
11191             parentNums.push(allItem[id].parentsubFormNum);
11192         }
11193     });
11194     _.each(parentNums,function(num){
11195         _.each(allItemId,function(id){
11196             if(num == allItem[id].columnOrderNum){
11197                 parentItem[num] = allItem[id];
11198             }
11199         });
11200     });
11201     _.each(childItem,function(cd){
11202         _.extend(cd,{'parentId':parentItem[cd.parentsubFormNum].tag_Attribute.alias});
11203     });
11204     allItemValue = _.concat(allItemValue,childItem);
11205     console.log(allItemValue);
11206     console.log(item);
11207     _.each(allItemValue,function(item_value){
11208         if(item_value.parentsubFormNum == 0){
11209             var value = item[item_value.tag_Attribute.alias]
11210             // _.extend(item_value,{'value':item[item_value.tag_Attribute.alias]});
11211             if(item_value.tag_Attribute.approvalmustenter){//审查必须属性
11212                 if(_.isArray(value)){
11213                     if(value.length == 0){
11214                         submitErrShow(item_value);
11215                         checkFlag = false;
11216                     }
11217                 }else if(value == '' || value == undefined){
11218                     submitErrShow(item_value);
11219                     checkFlag = false;
11220                 }
11221             }
11222         }else{
11223             var cd_value = [];
11224             _.each(item[item_value.parentId],function(sub){
11225                 cd_value.push(sub[item_value.tag_Attribute.alias]);
11226             });
11227             // _.extend(item_value,{'value':cd_value});
11228             _.each(cd_value,function(cval,k){
11229                 if(_.isArray(cval)){
11230                     if(cval.length == 0){
11231                         submitErrShow(item_value,k);
11232                         checkFlag = false;
11233                     }
11234                 }else if(cval == '' || cval == undefined){
11235                     submitErrShow(item_value,k);
11236                     checkFlag = false;
11237                 }
11238             })
11239         }
11240     });
11241     return checkFlag;
11242 }
11243
11244 //lym
11245 function get() {
11246         var checkFlag =  submitCheck();
11247         if(checkFlag != true){
11248             return false;
11249         }
11250         console.log(localStorage.getItem("organizationId"));
11251         console.log(localStorage.getItem("datarowNum"));
11252         //从local取出log
11253         var processLog = localStorage.getItem("processLog");
11254         var tenant = JSON.parse(localStorage.getItem("tenantID"));
11255         var cust = JSON.parse(localStorage.getItem("customItem"));
11256         //暂时修改流程lym
11257         // var org = cust.expend_department.trim();
11258         //暂时修改流程lym
11259         console.log(processLog);
11260         console.log(processLog !== null);
11261         //12/11
11262         if (processLog != "null") {
11263             var strMessage = customBase.getMessage("mesage_ID034");
11264             customBase.alert("E", strMessage);
11265             //return null;
11266         } else {
11267             //暂时修改流程lym
11268             // if (org == "" || org == undefined || org == null) {
11269             //     //var strMessage = customBase.getMessage("mesage_ID035");
11270             //     customBase.alert("E", "请选择部门");
11271             //     return null;
11272             // }
11273             //暂时修改流程lym
11274             // 画面check 提交前验证 李伟民 12-26
11275             // var returnfromCheck = customShow.initEvent.fromCheck(items); //--------------------
11276             // if (returnfromCheck) {
11277             // return;
11278             // }
11279             var ss = {
11280                 "tenantID": tenant.tenantID,
11281                 //"organizationId": org,
11282                 "formID": localStorage.getItem("newFormID"),
11283                 "dataRowNum": localStorage.getItem("datarowNum")
11284             }
11285             var requestSingleForm = window.commonAjax("/ubp-api-control/process/inst/create", ss, "POST", true);
11286             requestSingleForm.done(function (rs) {
11287                 console.log(rs);
11288                 if (rs.resCode == 00000) {
13ec33 11289
4d1219 11290                         customBase.alert('S', "提交成功");
B 11291                         $("#sssd").click();
13ec33 11292
4d1219 11293                 } else {
B 11294                     if (rs.data == '3') {
11295                         customBase.alert('E', "请先配置流程定义");
11296                         $("#sssd").click();
11297                     }else if(rs.data == '2'){
11298                         customBase.alert('E', "请不要重复提交");
11299                         $("#sssd").click();
11300                     } else {
11301                     customBase.alert('E', "提交失败");
11302                     $("#sssd").click();
11303                     }
11304                 }
11305             });
11306         }
13ec33 11307
4d1219 11308     }
B 11309 //lym结束后操作
11310 function over(data) {
11311     if (data == true) {
11312         //确定提交后操作
11313         var processLog = JSON.parse(localStorage.getItem("processLog"));
11314         console.log(processLog);
11315         var ss = {
11316             "processInstId": processLog[0].processInstId
11317         }
11318         console.log(ss);
11319         var requestSingleForm = window.commonAjax("/ubp-api-control/process/inst/over", ss, "POST", true);
11320         requestSingleForm.done(function (rs) {
11321             console.log(rs);
11322             if (rs.data == 1) {
449a85 11323                 customBase.alert('S',"结束成功");
4d1219 11324                 $("#sssd").click();
B 11325             } else {
449a85 11326                 customBase.alert("E","结束失败");
4d1219 11327             }
B 11328         });
11329
11330
11331
11332     } else {
11333         $("#sssd").click();
11334     }
11335 }
11336
11337 //lym退回确定后操作
11338 function tui(data, item) {
11339
11340     if (data == true) {
11341         console.log($('.actcur').val());
11342         if ($('.actcur').val() == undefined) {
449a85 11343             customBase.alert("W","请选择退回的活动");
4d1219 11344             return null;
B 11345         }
11346         var processLog = JSON.parse(localStorage.getItem("processLog"));
11347         var ss = {
11348             "activityInstId": processLog[0].activityInstId,
11349             "activityDefId": $('.actcur').val(),
11350             "processInstId": processLog[0].processInstId,
11351             "formID": localStorage.getItem("newFormID"),
11352             "dataRowNum": localStorage.getItem("datarowNum")
11353         }
11354         var requestSingleForm = window.commonAjax("/ubp-api-control/process/inst/bac", ss, "POST", true);
11355         requestSingleForm.done(function (rs) {
11356             console.log(rs);
11357
11358             if (rs.data == 1) {
449a85 11359                 customBase.alert("S","退回成功");
4d1219 11360                 $("#sssd").click();
B 11361             } else {
449a85 11362                 customBase.alert("E","退回失败");
4d1219 11363             }
B 11364         });
11365
11366
11367     } else {
11368         $("#sssd").click();
11369     }
11370 }
11371 //lym 审批确定后方法
11372 function zhixing(data) {
11373     console.log(data);
11374     console.log($("#datas").val());
11375     if (data == false) {
11376         $("#sssd").click();
11377     } else {
11378
11379         var processLog = JSON.parse(localStorage.getItem("processLog"));
11380         console.log(processLog[0].processInstId);
11381         var ss = {
11382             "processInstId": processLog[0].processInstId,
11383             "activityInstId": processLog[0].activityInstId,
11384             "data": $("#datas").val(),
11385             "formID": localStorage.getItem("newFormID"),
11386             "dataRowNum": localStorage.getItem("datarowNum"),
13ec33 11387             "token": localStorage.getItem("testToken"),//差旅token 特殊处理
4d1219 11388             "tenantId": localStorage.getItem("testTenantId"),
B 11389             "companyId": localStorage.getItem("testCompanyId"),
13ec33 11390
4d1219 11391         }
B 11392         console.log("标记token");
11393         var requestSingleForm = window.commonAjax("/ubp-api-control/process/inst/finish", ss, "POST", true);
11394         requestSingleForm.done(function (rs) {
11395             console.log(rs);
11396             if (rs.resCode == "00000") {
11397                 customBase.alert('S',"审批成功");
5a4f8f 11398                 $('#editableBtn').remove();//审批成功后不能编辑 李伟民 0129
4d1219 11399                 $("#sssd").click();
B 11400             } else {
11401                 customBase.alert('W',"审批失败");
11402             }
11403         });
11404     }
11405 }
11406 //2017.11.24  qld 追加预算
11407 customBase.budgetAddmoney = function () {
11408     var id = JSON.parse(localStorage.getItem("tenantID"))
11409     console.log(id.tenantID);
11410     var sub = JSON.parse(localStorage.getItem("customItem"));
11411     var submit_data = {
11412         "formId": localStorage.getItem("newFormID"),
11413         "netformid": localStorage.getItem("netformid"),
11414         "parentDataRowNum": localStorage.getItem("datarowNum"),
11415         "dataRowNum": localStorage.getItem("datarowNum"),
11416         "tenantID": id.tenantID,
11417         "formType": "ZJ"
11418     };
11419
11420     var submit_request = window.commonAjax1("epc-form/extend/budget/money", submit_data, "POST", true);
11421     submit_request.done(function (res) {
11422         if (res.resCode == 'C0000') {
11423             if (res.data == '1') {
11424                 var strMessage = customBase.getMessage("mesage_ID024");
11425                 customBase.alert("E", strMessage);
11426             } else if (res.data == '2') {
11427                 var strMessage = customBase.getMessage("mesage_ID025");
11428                 customBase.alert("E", strMessage);
11429             } else if (res.data == '3') {
11430                 var strMessage = customBase.getMessage("mesage_ID026");
11431                 customBase.alert("E", strMessage);
11432             } else if (res.data == '9') {
11433                 var strMessage = customBase.getMessage("mesage_ID027");
11434                 customBase.alert("S", strMessage);
11435             } else if (res.data == '7') {
11436                 var strMessage = customBase.getMessage("mesage_ID028");
11437                 customBase.alert("E", strMessage);
11438             }
11439
11440         }
11441
11442     })
11443
11444 }
11445
11446 customBase.budgetBackmoney = function () {
11447     var id = JSON.parse(localStorage.getItem("tenantID"))
11448     console.log(id.tenantID);
11449     var sub = JSON.parse(localStorage.getItem("customItem"));
11450     var submit_data = {
11451         "formId": localStorage.getItem("newFormID"),
11452         "netformid": localStorage.getItem("netformid"),
11453         "parentDataRowNum": localStorage.getItem("datarowNum"),
11454         "dataRowNum": localStorage.getItem("datarowNum"),
11455         "formType": "TH",
11456         "tenantID": id.tenantID
11457     };
11458
11459     var submit_request = window.commonAjax1("epc-form/extend/budget/money", submit_data, "POST", true);
11460     submit_request.done(function (res) {
11461         if (res.resCode == 'C0000') {
11462             if (res.data == '1') {
11463                 var strMessage = customBase.getMessage("mesage_ID024");
11464                 customBase.alert("E", strMessage);
11465             } else if (res.data == '2') {
11466                 var strMessage = customBase.getMessage("mesage_ID025");
11467                 customBase.alert("E", strMessage);
11468             } else if (res.data == '3') {
11469                 var strMessage = customBase.getMessage("mesage_ID026");
11470                 customBase.alert("E", strMessage);
11471             } else if (res.data == '9') {
11472                 var strMessage = customBase.getMessage("mesage_ID027");
11473                 customBase.alert("S", strMessage);
11474             } else if (res.data == '7') {
11475                 var strMessage = customBase.getMessage("mesage_ID028");
11476                 customBase.alert("E", strMessage);
11477             }
11478         }
11479
11480     })
11481
11482 }
11483 function repayment() {
11484     var customBase = window.customBase;
11485     customBase.repayment();
11486     return true;
11487 }
11488 customBase.repayment = function () {
11489     var id = JSON.parse(localStorage.getItem("tenantID"))
11490     console.log(id.tenantID);
11491     var sub = JSON.parse(localStorage.getItem("customItem"));
11492     console.log(sub);
11493     var subForm = sub.DATAROWNUM;
11494     console.log("我是" + subForm)
11495     var submit_data = {
11496         "formId": localStorage.getItem("newFormID"),
11497         "netformid": localStorage.getItem("netformid"),
11498         "parentDataRowNum": localStorage.getItem("datarowNum"),
11499         "datarowNum": localStorage.getItem("datarowNum"),
11500         "tenantId": id.tenantID
11501     };
11502
11503     var submit_request = window.commonAjax1("epc-form/repayment/money", submit_data, "POST", true);
11504     submit_request.done(function (res) {
11505         if (res.data == true) {
11506             //    12/7 qld
11507             var strMessage = customBase.getMessage("mesage_ID029");
11508             customBase.alert("S", strMessage);
11509         } else {
11510             var strMessage = customBase.getMessage("mesage_ID030");
11511             customBase.alert("E", strMessage);
11512         }
11513
11514     })
11515
11516 }
11517 //子表单合计方法   马习同   2017-12-06
11518 customShow.subTotle = function (subId) {
11519     var customItems = customBase.options.customItems;
11520     var numArr = [];
11521     var subArr = [];
11522     var numObj = {};
11523     _.each(customItems, opt => {
11524         if (opt.parentsubFormNum == subId.replace("itemId_", "")) {
11525             subArr.push(opt);
11526         }
11527     });
11528     _.remove(subArr, n => {
11529         return n.fieldKey == "DATAROWNUM";
11530     });
11531     _.each(subArr, opt => {
11532         if (opt.type == "number") {
11533             console.log(opt.id);
11534             numObj[opt.id] = customBase.getItemValue(opt.id, opt.type);
11535             numArr.push(Number(customBase.getItemValue(opt.id, opt.type)));
11536         }
11537     })
11538     console.log(numObj);
11539     for (let key in numObj) {
11540         var opts = [];
11541         if (_.isArray(numObj[key])) {
11542             _.each(numObj[key], n => {
11543                 n = Number(n);
11544                 console.log(n);
11545                 opts.push(n);
11546             })
11547             numObj[key] = opts;
11548         }
11549         console.log(numObj[key]);
11550     }
11551     console.log(numObj);
11552     //_.sum   求和
11553     for (let key in numObj) {
11554         $("." + key + "totle").val(_.sum(numObj[key]));
11555     }
11556
11557 }
11558 //子表单合计方法   马习同   2017-12-07
11559 customShow.oneTotle = function () {
11560     var customItems = customShow.options.customItemShow.item;
11561     var totleArr = [];
11562     var numObj = {};
11563     var numArr = [];
11564     _.each(customItems, opt => {
11565         console.log(opt.tag_Attribute.total)
11566         if (opt.tag_Attribute.total == true) {
11567             totleArr.push(opt.tag_Id);
11568             console.log(opt.tag_Id)
11569         }
11570     })
11571     console.log(totleArr);
11572     _.each(totleArr, opt => {
11573         $("#" + opt + " [type='number']").unbind("change.totle");
11574         $("#" + opt + " [type='number']").on("change.totle", function () {
11575             console.log($(this).attr("id"));
11576             numObj[$(this).attr("id")] = customBase.getItemValue($(this).attr("id"), $(this).attr("type"));
11577             console.log(_.cloneDeep(numObj));
11578             console.log(numObj[key])
11579
11580             for (let key in numObj) {
11581                 var opts = [];
11582                 if (_.isArray(numObj[key])) {
11583                     _.each(numObj[key], n => {
11584                         n = Number(n);
11585                         console.log(n);
11586                         opts.push(n);
11587                     })
11588                     numObj[key] = opts;
11589                 }
11590                 console.log(numObj[key]);
11591             }
11592
11593             console.log(numObj);
11594             //_.sum   求和
11595             for (let key in numObj) {
11596                 $("." + key + "totle").val(_.sum(numObj[key]));
11597             }
11598         })
11599     })
11600 }
11601 //子表单内的控件内容超出部分显示title
11602 customShow.addTitle = function () {
11603     _.each($(".customShow .tdContentClass"), opt => {
11604         // $(opt).attr("title", $(opt).children().children().html());
11605         console.log($(opt).html())
11606         if ($(opt).children().children().attr("type") == "text") {
11607             $(opt).attr("title", $(opt).children().children().val());
11608         } else {
11609             console.log(_.cloneDeep($(opt).children().children()))
11610             console.log(opt.innerHTML)
11611             console.log($(opt).children().children()[0].innerHTML)
11612             $(opt).attr("title", $(opt).children().children()[0].innerHTML);
11613         }
11614     })
11615 }
11616 // customShow.businessTypeAutoFun = function(key,fieldKey,cookieOrlocal){
11617 //     if(cookieOrlocal  == 'cookie'){
11618 //         if(customBase.options.customItems[fieldKey].parentsubFormNum == '0'){
11619 //             var businessTypeAuto = getCookie(key);
11620 //             customBase.setItemValue(customBase.options.customItems[fieldKey].id, customBase.options.customItems[fieldKey].type, businessTypeAuto, '', '');
11621 //         }
11622 //     }else{
11623 //         if(customBase.options.customItems[fieldKey].parentsubFormNum == '0'){
11624 //             var businessTypeAuto = window.localStorage.getItem(key);
11625 //             customBase.setItemValue(customBase.options.customItems[fieldKey].id, customBase.options.customItems[fieldKey].type, businessTypeAuto, '', '');
11626 //         }
11627 //     }
11628 // }
11629 // SC.billInfoInit = function(items){//票据信息初始化 李伟民 12-26
11630 //     var itemKey = _.keys(items);
11631 //     var customItems = customBase.options.customItems;
11632 //     customShow.allbillInfo = [];
11633 //     _.each(itemKey,function(key){
11634 //         console.log(key);
11635 //         if(customItems[key] != undefined && customItems[key] != '' && customItems[key].type == "subform"){
11636 //             var billInfos = [];
11637 //             _.each(items[key], function(journey, i){
11638 //                 if(journey.billData != undefined){
11639 //                     billInfos.push(JSON.parse(journey.billData));
11640 //                     $("#" + key + "ActiveId").attr('noBillCheck',JSON.parse(journey.billData));
11641 //                 }else{
11642 //                     billInfos.push({});
11643 //                 }
11644 //             });
11645 //             customShow.allbillInfo.push({
11646 //                 'subFormId':customItems[key].id,
11647 //                 'subFormKey':key,
11648 //                 'billInfos':billInfos
11649 //             })
11650 //         }
11651 //     });
11652 //     billInfobind(customShow.allbillInfo);
11653 //     SC.noBillCheckInit();
11654 // }
b84eca 11655 // SC.noBillCheckInit = function(){
L 11656 //     noBillCheck('journey','reimburseMan');
11657 // }
11658 // function noBillCheck(subFieldKey,reimburseManKey){//无票据行程及票据人员与报销人验证
11659 //     if(customBase.options.customItems[subFieldKey] == undefined){
11660 //         return false;
11661 //     }
11662 //     var subId = customBase.options.customItems[subFieldKey].id;
11663 //     var manId = customBase.options.customItems[reimburseManKey].id;
11664 //     var manType = customBase.options.customItems[reimburseManKey].type;
11665 //     var manTitle = customBase.options.customItems[reimburseManKey].title;
11666 //     var journeySub = $("#" + subId + "ActiveId");
11667 //     _.each(journeySub,function(jour){
11668 //         var checkData = $(jour).attr('noBillCheck');
11669 //         if(checkData != undefined && checkData != ''){
11670 //             checkData = JSON.parse(checkData);
11671 //             var manVal = customBase.getItemValue(manId,manType);
11672 //             if(manVal != undefined && manVal != checkData.PersonalVal){
11673 //                 $(jour).children('h8').append("<span class='billCheck'>" + "票据‘" + checkData.PersonalName + "’与" + manTitle + "不同</span>");
11674 //             }
11675 //         }else{
11676 //             $(jour).children('h8').append("<span class='billCheck'>无票据行程</span>");
11677 //         }
11678 //     });
11679 // }
11680 // function billInfobind(allbillInfo){//票据信息显示 及 实时验证  李伟民 12-26
11681 //     _.each(allbillInfo,function(info,k){
11682 //         var sub_type = customShow.options.customItemShow.item[info.subFormId].tag_Attribute.allcopy;
13ec33 11683
b84eca 11684 //         _.each(info.billInfos,function(binfo, i){
L 11685 //             if(binfo.billCode != undefined){
11686 //                 var itemKey = _.keys(binfo.billHeadMeaningMvCodeMap);
11687 //                 _.each(itemKey,function(key){
11688 //                     if(binfo.billHeadMap[key] != undefined && binfo.billHeadMap[key] != ''){
11689 //                         var bhName = binfo.billHeadMap[key].val;
11690 //                         var bhVal = binfo.billHeadMap[key].code;
11691 //                         billShow(sub_type,itemKey,bhName,bhVal,i);
11692 //                         if(sub_type && key == 'PersonalName'){//储存票据人员信息
11693 //                             var noBillCheckData = {
11694 //                                 "PersonalName":bhName,
11695 //                                 "PersonalVal":bhVal
11696 //                             };
11697 //                             $("#" + info.subFormId + "ActiveId:ep(" + k + ")").attr("noBillCheck",JSON.stringify(noBillCheckData));
11698 //                         }
11699 //                     }
11700 //                 });
13ec33 11701 //             }
b84eca 11702 //         });
L 11703 //     })
11704 // }
11705 // function billShow(sub_type,itemKey,bhName,bhVal,num){//票据信息验证绑定 李伟民 12-26
11706 //     var itemId = customBase.options.customItems[itemKey].id;
11707 //     var type = customBase.options.customItems[itemKey].type;
11708 //     if(sub_type){
11709 //         $("[id='"+itemId+"ActiveId']:eq('" + num + "')").find("h8[name='el_title']").append("<span class='billCheck'>" + bhName + "</span>");
11710 //     }else{
11711 //         customBase.set_p($("[id='"+itemId+"']:eq('" + num + "')"));
11712 //         if(type == 'dropdownlist'){
11713 //             $("[id='"+itemId+"']:eq('" + num + "')").closet("p").append("<span class='billCheck'>" + bhName + "</span>");
11714 //         }else{
11715 //             $("[id='"+itemId+"']:eq('" + num + "')").prev("p").append("<span class='billCheck'>" + bhName + "</span>");
11716 //         }
13ec33 11717
b84eca 11718 //     }
L 11719 //     if(type == 'dropdownlist'){
11720 //         $("[id='"+itemId+"']:eq('" + num + "')").find(".select_get").on('change.billcheck',function(){
11721 //             if(sub_type){
11722 //                 $("[id='"+itemId+"ActiveId']:eq('" + i + "')").find(".billCheck").css("color", "#333");
11723 //                 if($(this).val() != bhVal) {
11724 //                     $("[id='"+base_item_id+"ActiveId']:eq('" + i + "')").find(".billCheck").css("color", "red");
11725 //                 }
11726 //             }else{
11727 //                 $("[id='"+itemId+"']:eq('" + i + "')").closet("p").find(".billCheck").css("color", "#333");
11728 //                 if($(this).val() != bhVal) {
11729 //                     $("[id='"+itemId+"']:eq('" + i + "')").closet("p").find(".billCheck").css("color", "red");
11730 //                 }
11731 //             }
11732 //         });
11733 //     }else{
11734 //         $("[id='"+itemId+"']:eq('" + num + "')").on('change.billcheck',function(){
11735 //             if(sub_type){
11736 //                 $("[id='"+itemId+"ActiveId']:eq('" + i + "')").find(".billCheck").css("color", "#333");
11737 //                 if($(this).val() != bhVal) {
11738 //                     $("[id='"+itemId+"ActiveId']:eq('" + i + "')").find(".billCheck").css("color", "red");
11739 //                 }
11740 //             }else{
11741 //                 $("[id='"+itemId+"']:eq('" + i + "')").prev("p").find(".billCheck").css("color", "#333");
11742 //                 if($(this).val() != bhVal) {
11743 //                     $("[id='"+itemId+"']:eq('" + i + "')").prev("p").find(".billCheck").css("color", "red");
11744 //                 }
11745 //             }
11746 //         })
11747 //     }
624ff8 11748 // }