quchenming
2018-04-08 3f944716d241088314f012d8ba64d3842b288327
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">' +
e9bbff 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>' +
1326a4 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 + '">' +
3f9447 1728                     '<div  style="width:14px;height:14px;background:url(../../formEngine/resources/css/img/icon/delete.png)"></div></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
52efbc 1774                 var viewer = new Viewer(document.getElementById(potion.id), {
04dc45 1775                     url: 'data-original',
Q 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;
9ba3c7 5313                     var heightqrcode = showCustomItem.tag_Attribute.height;
Z 5314                     if (heightqrcode == 0 || heightqrcode == undefined) {
5315                         heightqrcode = 165;
5316                     }
4d1219 5317                     if (widthQrcode == 0 || widthQrcode == undefined) {
B 5318                         widthQrcode = 165;
5319                     }
9ba3c7 5320                     
4d1219 5321                     var divIcons = document.createElement("input");
B 5322                     divIcons.setAttribute("type", "text");
5323                     divIcons.setAttribute("id", customItems[item].id + "qrcode");
5324                     divIcons.setAttribute("style", "width: " + widthQrcode + "px;height:33px");
5325                     divIcons.setAttribute("class", "qrcodeShowTextClass cfg_contentNone");
5326                     divIcons.setAttribute("value", itemValue);
5327                     divIcons.setAttribute("maxlength", 200);
5328                     $('.' + showClass + " #" + itemId)[0].after(divIcons);
9ba3c7 5329                     $('.' + showClass + " #" + itemId)[0].setAttribute("style", "width: " + widthQrcode + "px;height:" + heightqrcode + "px");
4d1219 5330                     $('.' + showClass + " #" + itemId).addClass("qrcodeShowClass");
B 5331                 }
5332                 //条形码
5333             } else if (customItems[item].type == "barcode") {
5334                 if ("customViewUEditorCss" == showClass) {
5335                     var itemId = customItems[item].id;
5336                     // var itemValue = $('.'+showClass +" #"+itemId)[0].getAttribute("text");
5337                     // var widthBarcode = $("#"+customItems[item].id)[0].width;
5338                     var showCustomItem = customShow.options.customItemShow.item[itemId];
5339                     // var itemValue = $('.'+showClass +" #"+itemId)[0].getAttribute("qrcodeurl");
5340                     // var widthQrcode = $("#"+customItems[item].id)[0].width;
5341                     var itemValue = showCustomItem.tag_Attribute.text;
5342                     var widthBarcode = 165;
5343                     // if(widthBarcode == 0){
5344                     //   widthBarcode = 100;
5345                     // }
5346                     var divIcons = document.createElement("input");
5347                     divIcons.setAttribute("type", "text");
5348                     divIcons.setAttribute("id", customItems[item].id + "barcode");
5349                     divIcons.setAttribute("style", "width: " + widthBarcode + "px;height:33px");
5350                     divIcons.setAttribute("class", "barcodeShowTextClass cfg_contentNone");
5351                     divIcons.setAttribute("value", itemValue);
5352                     divIcons.setAttribute("maxlength", 200);
5353                     $('.' + showClass + " #" + itemId)[0].after(divIcons);
5354                     $('.' + showClass + " #" + itemId).addClass("barcodeShowClass");
5355                 }
5356                 //子表单设定
5357             } else if (customItems[item].type == "subform") {
5358                 var itemId = customItems[item].id;
5359                 var itemTwo = itemId;
5360                 var itemSubform = $('.' + showClass + " #" + itemId + "ActiveId");
5361                 //lym
5362                 //位总div添加id
5363                 $("#" + itemId + "ActiveId").find(".usfile").attr("id", itemTwo + "uld");
5364                 //为a标签添加id
5365                 $("#" + itemId + "ActiveId").find(".usfile a").attr("id", itemTwo + "uis");
5366                 $("#" + itemId + "ActiveId").find(".usfile a").attr("itemId", itemTwo);
5367                 //为inputFile添加id
5368                 $("#" + itemId + "ActiveId").find("#" + itemTwo + "uld form input").attr("itemId", itemTwo);
5369                 $("#" + itemId + "ActiveId").find("#" + itemTwo + "uld form input").attr("id", itemTwo + "btn");
5370                 $("#" + itemId + "ActiveId").find("#" + itemTwo + "uld form").attr("itemId", itemTwo);
5371
5372                 //////////////console.log(item);
5373                 var ulIcon = document.createElement("ul");
5374                 var liIcon = "";
5375                 var m_customItems = customShow.options.customItemShow.item;
5376                 console.log(customBase.options)
5377                 var subItems = [];
5378                 var parentNum = itemId.replace("itemId_", "");
5379                 _.each(m_customItems, opt => {
5380                     if (opt.parentsubFormNum == parentNum) {
5381                         subItems.push(opt);
5382                     }
5383                 })
5384                 console.log(subItems)
5385                 _.remove(subItems, n => {
5386                     return n.tag_Attribute.alias == "DATAROWNUM" || n.tag_Attribute.visible == false;
5387                 });
5388                 //_.sortBy(orderArr, ['fieldOrderNum']);
5389                 subItems = _.sortBy(subItems, ['fieldOrderNum']);
5390                 _.each(subItems, opt => {
5391                     console.log(opt)
5392                     if (opt.tag_Type == "number") {
5393                         liIcon += "<li class='n_totle'><input class='" + opt.tag_Id + "totle textCssDiv defaultHeight' type='text' readonly></li>"
5394                         console.log(1)
5395                     } else {
5396                         liIcon += "<li class='p_totle'></li>"
5397                         console.log(2)
5398                     }
5399                 });
5400                 $(ulIcon).append(liIcon);
5401                 $("#" + itemId + "ActiveId").find(".h_totle").append(ulIcon);
5402                 console.log($("#" + itemId + "ActiveId").find(".h_totle"))
5403                 console.log(ulIcon)
13ec33 5404                 // 单行文本 多行文本 数字  日历
4d1219 5405             } else if (customItems[item].type == "text" || customItems[item].type == "textarea" || customItems[item].type == "number" || customItems[item].type == "calendar") {
B 5406                 var itemId = customItems[item].id;
5407                 var defaultvalue = $("#" + itemId).attr("defaultvalue");
5408                 //  12/4  判断是否存在当前时间
5409                 var calendar = _.filter(customShow.options.customItemShow.item, ['tag_Type', 'calendar'])
5410                 for (var i = 0; i < calendar.length; i++) {
5411                     if (calendar[i].tag_Attribute.currentDate) {
5412                         if (itemId == calendar[i].tag_Id) {
5413                             defaultvalue = customShow.currentDate
5414                         }
5415                     }
5416                 }
5417                 console.log(defaultvalue)
5418                 // 之前表单日历默认值不存在时 12/4
5419                 if (defaultvalue == undefined || defaultvalue == 'undefined') {
5420                     defaultvalue = ''
5421                 }
5422                 customBase.setItemValue(itemId, "text", defaultvalue);
5423                 //数字验证事件追加
5424                 if (customItems[item].type == "number") {
5425                     //数值型控件验证
5426                     $("#" + itemId).unbind('blur');
5427                     $("#" + itemId).on('blur', function (e) {
5428                         var numbertype = $(this)[0].getAttribute("numbertype");
5429                         if (numbertype == "decimal") {
5430                             var decimalplace = $(this)[0].getAttribute("decimalplace");
5431                             decimalplace = parseInt(decimalplace);
5432                             if ($(this)[0].value != "") {
5433                                 $(this)[0].value = Number($(this)[0].value).toFixed(decimalplace);
5434                             }
5435
5436                         }
5437                     });
5438                 }
5439             } else if (customItems[item].type == 'dropdownlist' || customItems[item].type == 'radio' ||
5440                 customItems[item].type == 'checkbox' || customItems[item].type == 'tree') {
5441                 if ('customShow' != showClass) {
5442                     //数据源绑定
5443                     customShow.setDatasourceData(customItems[item]);
5444                 }
5445             } else if (customItems[item].type == 'splitline') {
5446                 //分割线
5447                 var itemId = customItems[item].id;
5448                 $('.' + showClass + " #" + itemId + "ActiveId").addClass("layoutsetting8");
5449             } else if (customItems[item].type == 'tree') {
5450                 var itemId = customItems[item].id;
5451                 var defaultvalue = $("#" + itemId)[0].getAttribute("defaultvalue");
5452
5453                 // 之前表单树形默认值不存在时 12/7
5454                 if (defaultvalue == undefined || defaultvalue == 'undefined') {
5455                     defaultvalue = ''
5456                 }
5457                 customBase.setItemValue(itemId, "text", defaultvalue);
5458             }
5459             //初始属性设定
5460             if (customItems[item].type == 'dropdownlist' || customItems[item].type == 'radio' ||
5461                 customItems[item].type == 'checkbox' || customItems[item].type == 'tree' ||
5462                 customItems[item].type == "text" || customItems[item].type == "textarea" || customItems[item].type == "number"
5463                 || customItems[item].type == "calendar" || customItems[item].type == "fileupload"
5464                 || customItems[item].type == "qrcode" || customItems[item].type == "barcode"
5465                 || customItems[item].type == "htmlediter" || customItems[item].type == "link"
5466                 || customItems[item].type == "subform"
5467             ) {
5468                 console.log(customBase.options.customItems[item])
5469                 customShow.setShowAttribute(customBase.options.customItems[item]);
5470             }
5471             // 12/15
5472             if (customItems[item].type == "link") {
5473                 var linkurl = customShow.costType[customItems[item].id].tag_Attribute.linkurl;
5474                 if(linkurl == ''){
5475                     linkurl = 'javascript:void(0)';
5476                 }
5477                 if(customShow.costType[customItems[item].id].tag_Attribute.editable){//不可编辑控制  李伟民 0124
5478                     $('#'+customItems[item].id).attr('href',linkurl)
5479                 }
5480             }
5481         }
5482     };
5483     //事件追加
5484     customShow.clickBindSubform();
5485
5486 }
5487
5488 //固定事件的绑定
5489 var index_i = 0;
5490 customShow.clickBind = function () {
5491
5492     //子表单事件追加
5493     customShow.clickBindSubform();
5494
5495     //  //保存按钮按下
5496     //  $(".fromSaveCss").on('click', function() {
5497     //     customShow.onclickSave();
5498     //   });
5499
5500     //  //取消按钮按下
5501     //  $(".cancelCss").on('click', function() {
5502     //     customShow.onclickCancel();
5503     //   });
5504
5505
5506     // 子表单添加记录事件
5507
5508     $('.subformAdd').unbind();
5509     function addSubFunc() {
5510         //子表单项目追加
5511         //console.log($(this)[0]);
5512         customShow.addsubformList($(this)[0], "customViewUEditorCss");
5513         //  customShow.setXhSelectListAdd();
5514         //子表单事件追加
5515         customShow.clickBindSubform();
5516         //公式初期化
5517         customLinkageAnalysis.bindLinkage();
5518         customShow.oneTotle();
5519         //console.log($('.subformAdd'));
5520         $('.subformAdd').unbind('click', addSubFunc);
5521         $('.subformAdd').on('click', addSubFunc);
5522         //行程排序初期化
5523         customShow.journeySort();
5524         SC.noBillCheckInit()//无票据行程验证
5525
5526     }
5527     $('.subformAdd').on('click', addSubFunc);
5528
5529     //主数据丢失
5530     //   $('.subformAdd').unbind();
5531     //   $('.subformAdd').on('click', function(){
5532     //       console.log(1)
5533     //     //子表单项目追加
5534     //     customShow.addsubformList($(this)[0],"customViewUEditorCss");
5535     //     //子表单事件追加
5536     //     customShow.clickBindSubform();
5537     //     //公式初期化
5538     //  customLinkageAnalysis.bindLinkage();
5539     //         //行程排序初期化
5540     //          customShow.journeySort();
5541     //   });
5542
5543     //图片文件上传
5544     var uploaderImage = $(".customViewUEditorCss .uploaderImage");
5545     for (var i = 0; i < uploaderImage.length; i++) {
5546
5547         var imageItem = customShow.options.customItemShow.item[uploaderImage[i].id];
5548         var itemList = customBase.options.uploaderItemReady[uploaderImage[i].id];
5549         // 参数设定
5550         var potion = {
5551             id: uploaderImage[i].id,
5552             width: imageItem.tag_Attribute.width,
5553             height: imageItem.tag_Attribute.height,
5554             formid: customShow.options.formid,
5555             imagetype: imageItem.tag_Attribute.dropdowntype, //图片类型
5556             editable: imageItem.tag_Attribute.editable, //是否可编辑
5557             defaultvalueUrl: imageItem.tag_Attribute.defaultvalue, //默认的Url
5558             ItemReady: itemList,
5559             visible:imageItem.tag_Attribute.visible
5560         }
5561         customBase.uploaderShow(potion);
5562         // customBase.uploaderShow("#"+uploaderImage[i].id,{width:0,height:200},true,customShow.options.formid);
5563
5564     };
5565
5566     //lym子表单上传
5567     $('.sonImportFile').unbind();
5568     $(".sonImportFile").click(function () {
5569         console.log("进入点击事件");
5570         //var checkedObj = $("#tbody input[type=checkbox]:checked");
5571         console.log("fdsffddffd");
5572         // //创建文件上传对象
5573         var a = $(this).attr("itemId")
5574         console.log(a)
5575         $("#" + a + "btn").click(
5576
5577         );
5578         $("#" + a + "btn").change(function () {
5579             console.log("uqwhdoqwhdo");
5580             //var objFile = $("#"+itemTwo+"btn");
5581             //改变
5582
5583             let mthis = this;
5584             var tenantId = localStorage.getItem("tenantID");
5585             var formID = localStorage.getItem("newFormID");
5586             var tenant = JSON.parse(tenantId);
5587             var user = localStorage.getItem("userName");
5588             var userName = JSON.parse(user);
5589             var aba = a;
5590             console.log(aba);
13ec33 5591             //结束
4d1219 5592             console.log(tenantId);
B 5593             console.log(formID);
5594             var objFile = $(this);
5595             if (objFile.value == "") {
5596                 return;
5597             } else {
5598                 var f_content = this.value;
5599                 var fileext = f_content.substring(f_content.lastIndexOf("."), f_content.length);
5600                 fileext = fileext.toLowerCase()
5601                 if (fileext != '.xls') {
5602                 } else {
5603                     //改变
5604                     var dataObj = { "formID": formID, "tenantID": tenant.tenantID, "userName": userName.userName, "rowNum": aba }
5605                     //结束
5606
5607                     var options = {
13ec33 5608                         url: url, //上传文件的路径 
4d1219 5609                         type: 'post',
B 5610                         dataObj: dataObj,
5611                         async: false,
5612                         success: function (data) {//异步上传成功之后的操作
5613                             if (data != undefined && data != null) {
5614                                 console.log("返回参数");
5615                             }
5616
5617                         }
5618                     };
5619
5620                     var requestData = window.SonfiledUpload(dataObj, options, "/excel/impSonExcel", $(this).attr("itemId"), fileext);
5621                     var excels = JSON.parse(requestData);
5622                     console.log(requestData);
5623                     //                console.log("最后");
13ec33 5624                     //
4d1219 5625                     //                console.log($(this).attr("itemId"))
B 5626                     //改变
5627                     $(mthis).val("");
5628                     if (excels.data != undefined) {
5629                         customShow.addRow($(this).attr("itemId"), excels.data);
5630                         toastr.info("导入成功");
5631
5632                     } else {
5633                         toastr.error("表格数据格式有误!");
5634                     }
5635                     //结束
5636                     //清除后台返回结果
5637                     window.localStorage.removeItem("seccData");
5638
5639                 }
5640             }
5641         })
5642     });
5643     //文本文件上传
5644     var uploaderFile = $(".customViewUEditorCss .uploaderFile");
5645     console.log(uploaderFile)
5646     for (var i = 0; i < uploaderFile.length; i++) {
5647
5648         var imageItem = customShow.options.customItemShow.item[uploaderFile[i].id];
5649         debugger
5650         var itemList = customBase.options.uploaderItemReady[uploaderFile[i].id];
5651         // 参数设定
5652         var potion = {
5653             id: uploaderFile[i].id,
5654             width: imageItem.tag_Attribute.width,
5655             height: imageItem.tag_Attribute.height,
5656             formid: customShow.options.formid,
5657             imagetype: imageItem.tag_Attribute.dropdowntype, //图片类型
5658             editable: imageItem.tag_Attribute.editable, //是否可编辑
5659             defaultvalueUrl: imageItem.tag_Attribute.defaultvalue, //默认的Url
5660             ItemReady: itemList,
5661             visible:imageItem.tag_Attribute.visible
5662         }
5663         customBase.uploaderFileShow(potion);
5664         // customBase.uploaderShow_Temp("#"+uploaderFile[i].id,{width:0,height:200},false,customShow.options.formid);
5665
5666     };
5667
5668     //必须入力验证
5669     // var mustcheckCss = $(".mustcheckCss");//-----------todo
5670     // for (var i = 0; i < mustcheckCss.length; i++) {
5671     //   ////////////////console.log('#'+$(mustcheckCss)[i].id);
5672     // };
5673
5674     //子表单默认删除项目去掉
5675     //子表单第一行可删除
5676     // $(".iconfontcolor").addClass("cfg_contentNone");
5677     // $(".iconfontcolorTH").addClass("cfg_contentNone");
5678
5679     //金融控件点击事件
5680     $('.amountShowClass').unbind();
5681     $('.amountShowClass').on('click', function () {
5682         var editable = $(this)[0].getAttribute("editable");
5683         //编辑设定
5684         if (editable == "false") {
5685             return;
5686         }
5687
5688
5689         $(this).addClass("cfg_contentNone");
5690         $("#" + $(this)[0].id + "amount").removeClass("cfg_contentNone");
5691         $("#" + $(this)[0].id + "amount").focus();
5692     });
5693
5694     //金融控件点击事件
5695     $('.amountShowTextClass').unbind();
5696     $('.amountShowTextClass').on('blur', function () {
5697         var id = $(this)[0].id;
5698         //表示的控件ID取得
5699         var idTemp = id.replace("amount", "");
5700
5701         var showCustomItem = customShow.options.customItemShow.item[idTemp];
5702         // var widthqrcode = $("#"+idTemp)[0].width;
5703         // var heightqrcode = $("#"+idTemp)[0].height;
5704         var widthqrcode = showCustomItem.tag_Attribute.width;
5705         var heightqrcode = showCustomItem.tag_Attribute.height;
5706         if (heightqrcode == 0 || heightqrcode == undefined) {
5707             heightqrcode = 24;
5708         }
5709         if (widthqrcode == 0 || widthqrcode == undefined) {
5710             widthqrcode = 200;
5711         }
5712
5713         //金额组件
5714         //默认数值
5715         var defaultSize = {
5716             width: widthqrcode,
5717             height: heightqrcode,
5718             defaultvalue: "",
5719             styleclass: ""
5720         };
5721
5722         var decimalplace = $(this)[0].getAttribute("decimalplace");
5723         decimalplace = parseInt(decimalplace);
5724         if ($(this)[0].value != "") {
5725             $(this)[0].value = Number($(this)[0].value).toFixed(decimalplace);
5726         }
5727
5728
5729         defaultSize.defaultvalue = $(this)[0].value.replace(".", "");
5730
5731         var showItem = customBase.getAmountHtml(defaultSize, true);
5732         customBase.amount2Image(showItem, "amount", defaultSize, function (amountHtml) {
5733             // ////////////////console.log(idTemp);
5734             $("#" + idTemp + "amount").addClass("cfg_contentNone");
5735             for (var i = 0; i < $("." + idTemp + "value").length; i++) {
5736                 $("." + idTemp + "value")[i].setAttribute("src", amountHtml);
5737             };
5738             $("#" + idTemp).removeClass("cfg_contentNone");
5739         })
5740     });
5741     var addVal = [];
5742
5743     //申请单控件点击事件
5744     $('.chooseMenu').unbind();
5745     $(".mytext_icon").on("click", function () {
5746         $(this).closest("[type='mytext']").find('.boxBtn').click();
5747         console.log(customShow.options);
5748         console.log(customBase.options);
5749     })
5750     $('.boxBtn').on('click', (obj) => {
5751         console.log(customBase.options)
5752         addVal = [];
5753         //取得父页面变量
5754         var outWindowObj = window.parent;
5755         var $iconId = $(obj)[0].target.getAttribute("myAttr");
5756         var iconAttr = customShow.options.customItemShow.item[$iconId];
5757         console.log(iconAttr);
5758         if ($("#" + $iconId).attr("formhuixian") != undefined) {
5759             var formhuixian = JSON.parse($("#" + $iconId).attr("formhuixian"));
5760         }
5761         //console.log(formhuixian);
5762         let head = "";
5763         if ($(obj)[0].target.previousSibling.getAttribute("chooseForm") != "" || iconAttr.tag_Attribute.relevancesourcetype == "fundata") {
5764             console.log(attrData);
5765             if (iconAttr.tag_Attribute.relevancesourcetype == "fundata") {//函数分支修改 李伟民 12-05
5766                 var titleObj = { "key": JSON.parse(iconAttr.tag_Attribute.fundata)['key'] };
5767                 var requestTitle = window.commonAjax("/datamanagement/getAssociateTitle", titleObj, "POST", true, false);
5768                 requestTitle.done(function (res) {
5769                     var formtitle = [];
5770                     _.each(res.data, function (tdata) {
5771                         formtitle.push({ "fieldKey": tdata.fieldKey, "title": tdata.title });
5772                     });
5773                     head = formtitle;
5774                 });
5775                 var attrData = undefined;
5776             } else {
5777                 var attrData = JSON.parse($(obj)[0].target.previousSibling.getAttribute("chooseForm"));
5778                 head = attrData.huixianObj.chooseData;
5779             }//函数分支修改 李伟民 12-05
5780             // window.localStorage.setItem("bussiness", attrData.formID.bussinessSystem)  //不用了?
5781             //获取id值
5782             //用于验证是否已经存在div
5783             var $divsLength = $('#' + $iconId + 'divIcons').length;
5784             //接收table头请求
5785             var formId = "";
5786             if (attrData && attrData.ScreenCondition != undefined) {
5787                 //下拉框取值
5788                 let getVal = attrData.ScreenCondition.child;
5789                 console.log(getVal);
5790                 _.each(getVal, opts => {
5791                     _.each(customBase.options.customItems, opt => {
5792                         if (opt.fieldKey == opts.fieldKey && opts.side == "thi") {
5793                             opts.value = "";
5794                             if (opt.type == "dropdownlist") {
5795                                 var getVals = customBase.getItemValue(opt.id, "dropdownlistText");
5796                                 console.log(getVals);
5797                                 if (getVals[0][0] != undefined) {
5798                                     opts.value = getVals[0];
5799                                 } else {
5800                                     opts.value = "";
5801                                 }
5802                             } else if (opt.type == "tree") {//树控件 处理  李伟民 12-5
5803                                 var getVals = customBase.getItemValue(opt.id, opt.type);
5804                                 console.log(getVals);
5805                                 if (getVals[0][0] != undefined) {
5806                                     opts.value = getVals[0];
5807                                 } else {
5808                                     opts.value = "";
5809                                 }
5810                             } else {//树控件 处理  李伟民 12-5
5811                                 var getVals = customBase.getItemValue(opt.id, opt.type);
5812                                 console.log(getVals);
5813                                 if (getVals != undefined) {
5814                                     opts.value = getVals;
5815                                 } else {
5816                                     opts.value = "";
5817                                 }
5818                             }
5819                         }
5820                     })
5821                 });
5822                 var sCondition = {};
5823                 //请求数据  筛选条件参数
5824                 let getValue = {};
5825                 getValue.child = getVal;
5826                 getValue.count = attrData.ScreenCondition.count;
5827                 sCondition = getValue;
5828                 let shaixuanData = attrData.ScreenCondition.child;
5829             }
5830             if ((attrData && attrData.huixianObj != undefined) || iconAttr.tag_Attribute.relevancesourcetype == "fundata") {
5831                 if (iconAttr.tag_Attribute.relevancesourcetype == "fundata") {
5832                     formId = undefined;
5833                 } else {
5834                     formId = attrData.formID;
5835                 }
5836                 if ($divsLength == 0) {
5837                     //外层蒙版
5838                     console.log(customShow.options.customItemShow.item)
5839                     console.log($iconId)
5840                     var my_text_title = customShow.options.customItemShow.item[$iconId].tag_Attribute.title;
5841
5842                     var menuContent = document.createElement('div');
5843                     //数据渲染div
5844                     var divIcons = document.createElement('div');
5845                     var pageBox = document.createElement('div');
5846                     var buttonDiv = document.createElement("div");
5847                     var closeBtn = document.createElement("span");
5848                     var requersTable = document.createElement("table");
5849                     var page = document.createElement("div");
5850                     var bigmodule = document.createElement("div");
5851                     var mymodule = document.createElement("div");
5852                     var mymodule2 = document.createElement("div");
5853                     var modal_content = document.createElement("div");
5854                     var mymodulebody = document.createElement("div");
5855                     var mymoduleheader = document.createElement("div");
5856                     var mymodulefooter = document.createElement("div");
5857                     var myinput = document.createElement("input");
5858                     var mybtn = document.createElement("button");
5859                     mybtn.innerHTML = "<i class='fa fa-search'></i>";
5860                     mybtn.setAttribute('class', 'btn btn-default');
5861                     mybtn.setAttribute('onClick', 'showbtn()');
5862                     mybtn.setAttribute('id', 'showserch');
5863                     // 添加搜索
5864                     var serchbox = document.createElement('div');
5865                     var serchpage = document.createElement('div');
5866                     var sersrc = document.createElement('script');
5867                     serchpage.setAttribute('class', 'pagination');
5868                     serchpage.setAttribute('style', 'display:none');
956db4 5869                     sersrc.setAttribute('src', './../../formEngine/resources/js/dataManagement/findmany.js');
4d1219 5870                     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 5871                     var footer = '<div _ngcontent-c12="" class="btn btn-primary btn-info btn-action closeBtn">确定</div>';
5872                     serchbox.setAttribute('class', 'fui-form hides');
5873                     serchbox.setAttribute('id', 'findserch');
5874                     serchbox.setAttribute('style', 'display:none !important;');
5875                     serchbox.innerHTML = '<div class="search_item">' +
5876                         '<div class="search_column ng-scope" id="copyTemp" style="display: none;">' +
5877                         '<div class="ng-binding" style="font-size:10px;font-weight:700;"></div>' +
5878                         '<span style="display: flex;width: 100%;"></span></div>' +
5879
5880                         '<div class="search_column findbox ng-scope" id="copyTempNumber" style="display: none;">' +
5881                         '<div class="ng-binding" style="font-size:10px;font-weight:700;">预算截止时间</div>' +
5882                         '<span style="display: flex;position:relative;width:45%;"><input id = "numberFrom" class=""  type="number"/></span>' +
5883                         '<span> ~ </span>' +
5884                         '<span style="display: flex;position:relative; width:45%;"><input id = "numberTo" class=""  type="number"/></span></div>' +
5885                         '<div class="search_column ng-scope" id="copyTempTime" style="display: none;">' +
5886                         '<div class="ng-binding" style="font-size:10px;font-weight:700;"> 预算截止时间</div>' +
5887                         '<span style="display: flex; position: relative;width:45%;">' +
5888                         '<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>' +
5889                         '</span><span> ~ </span><span style="display: flex;position:relative;width:45%;">' +
5890                         '<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>' +
5891                         '</span></div><div class="search_column_button search_column_button_box">' +
5892                         '<span><button class="btn btn-info btn-action" id="search_condition"><i class="fa fa-search" aria-hidden="true"></i>&nbsp;&nbsp;查询</button></span>' +
5893                         '</div></div>' +
5894                         '<div class="condition_search_footer" style="display:none">' +
5895                         '<label class="first">' +
5896                         '<span><select class="ng-pristine ng-untouched ng-valid ng-not-empty" id="pageSelect">' +
5897                         '<option value="20" selected="selected">20条/页</option>'
5898                     '<option value="50"> 50条/页</option><option value="100">100条/页</option>' +
5899                         '</select></span><span class="ng-binding">共<span id = "showTotalPageLeft"></span>页</span></label>' +
5900                         '<label class="second"> <div class="pagination">' +
5901                         '<span class="skip first">首页</span><span class="skip pre">上一页</span>' +
5902                         '<div class="nums"></div><span class="skip next">下一页</span>' +
5903                         '<span class="skip last">尾页</span></div></label></div>';
5904                     mymoduleheader.innerHTML = header;
5905                     mymodulefooter.innerHTML = footer;
5906                     mymodule.setAttribute('style', 'width:750px;height: 448px;margin:0 auto;');
5907                     menuContent.setAttribute('id', $iconId + 'menuContent');
5908                     menuContent.setAttribute('class', 'menuContent');
5909                     bigmodule.setAttribute('class', 'bigmodule');
5910                     mymodule.setAttribute('class', 'mymodule');
5911                     mymodule2.setAttribute('class', 'mymodule2 mymodule2_box');
5912                     modal_content.setAttribute('class', 'modal-content modal_content_box');
5913                     mymodulebody.setAttribute('class', 'mymodulebody');
5914                     $(mymodulebody).css({ "height": "485px", "overflow-y": "auto" });
5915                     mymoduleheader.setAttribute('class', 'mymoduleheader');
5916                     mymodulefooter.setAttribute('class', 'mymodulefooter');
5917                     myinput.setAttribute('class', 'myipt');
5918                     divIcons.setAttribute('class', 'mytext');
5919                     divIcons.setAttribute('id', $iconId + 'divIcons');
5920                     page.setAttribute('id', $iconId + 'pageF');
5921                     page.setAttribute('class', 'pageF');
5922                     pageBox.setAttribute('id', $iconId + 'pageBox');
5923                     pageBox.setAttribute('class', 'pageBox');
5924                     buttonDiv.setAttribute("class", "buttonDiv");
5925                     requersTable.setAttribute("class", "requestMenu");
5926                     $('#' + $iconId + 'ActiveId').append(menuContent);
5927                     $('#' + $iconId + 'menuContent').append(bigmodule);
5928                     bigmodule.appendChild(mymodule);
5929                     mymodule.appendChild(mymodule2);
5930                     mymodule2.appendChild(modal_content);
5931                     modal_content.appendChild(mymodulebody);
5932                     mymodulebody.appendChild(mymoduleheader);
5933                     mymodulebody.appendChild(serchpage);
5934                     mymodulebody.appendChild(mybtn);
5935                     mymodulebody.appendChild(serchbox);
5936                     mymodulebody.appendChild(divIcons);
5937                     mymodulebody.appendChild(mymodulefooter);
5938                     mymodulebody.appendChild(myinput);
5939                     pageBox.appendChild(page);
5940                     // $('.mytext').append(sersrc);
5941                     //            $('.mytext').append(buttonDiv);
5942                     $('#' + $iconId + 'divIcons').append(requersTable);
5943                     $('#' + $iconId + 'divIcons').append(pageBox);
5944                     var lastPage = "";
5945                     customBase.findmay = {
5946                         "formId": formId,
5947                         "sCondition": sCondition,
5948                         "formhuixian": formhuixian,
5949                         "head": head,
5950                         "iconId": $iconId,
5951                         "addVal": addVal
5952                     }
5953                     var count = fenye("5", "1", formId, sCondition, formhuixian, head, $iconId, addVal, []);
5954
5955                     lastPage = Math.ceil(count / 5);
5956                     //console.log($(".pageF"))
5957                     $(".pageF").paging({
5958                         pageNo: 1,
5959                         totalPage: lastPage,
5960                         totalSize: count,
5961                         callback: function (num) {
5962                             console.log(num);
5963                             fenye("5", num, formId, sCondition, formhuixian, head, $iconId, addVal, []);
5964                         }
5965                     });
5966                 }
5967                 //如果存在就移除
5968             } else {
5969                 $('#' + $iconId + 'menuContent').remove();
5970             }
5971         } else {
5972             alert('未选择表单')
5973         }
5974         // 调用查询方法10/18
5975         findserch();
5976     });
5977     //条形码点击事件
5978     $('.barcodeShowClass').unbind();
5979     $('.barcodeShowClass').on('click', function () {
5980         var editable = $(this)[0].getAttribute("editable");
5981         //编辑设定
5982         if (editable == "false") {
5983             return;
5984         }
5985
5986         $(this).addClass("cfg_contentNone");
5987         $("#" + $(this)[0].id + "barcode").removeClass("cfg_contentNone");
5988         $("#" + $(this)[0].id + "barcode").focus();
5989     });
5990     //条形码焦点离开事件
5991     $('.barcodeShowTextClass').unbind();
5992     $('.barcodeShowTextClass').on('blur', function () {
5993         var id = $(this)[0].id;
5994         //表示的控件ID取得
5995         var idTemp = id.replace("barcode", "");
5996         // //默认数值
5997         // var defaultSize = {
5998         //   width:$("#"+idTemp)[0].width,
5999         //   height:$("#"+idTemp)[0].height,
6000         //   defaultvalue:"",
6001         //   styleclass:""
6002         // };
6003         // var size = $("#"+idTemp)[0].getAttribute("size");
6004         var showCustomItem = customShow.options.customItemShow.item[idTemp];
6005         // var size = $("#"+idTemp)[0].getAttribute("size");
6006         var size = showCustomItem.tag_Attribute.size;
6007         // defaultSize.defaultvalue = $(this)[0].value;
6008         customBase.createbarcode(size, $(this)[0].value, function (text, barWidth, barHeight, sizeWidthHeight) {
6009             $("#canvasbarcode").remove();
6010             $(document.body).append('<div id="canvasbarcode" style="display: none;"></div>');
6011             // //设值 距离左侧距离 margin-left: -2px;
6012             // if(barWidth == 1){
6013             //    $("."+idTemp+"value").addClass("barcodeMarginleft1");
6014             // }else if(barWidth == 2){
6015
6016             // }else if(barWidth == 3){
6017
6018             // }else if(barWidth == 4){
6019
6020             // }else if(barWidth == 5){
6021
6022             // }else if(barWidth == 6){
6023
6024             // }
6025             // $("."+idTemp+"value").addClass("barcodeMarginleft"+barWidth);
6026
6027             jQuery('#canvasbarcode').barcode(text, "code128", { barWidth: barWidth, barHeight: barHeight, showHRI: true });
6028             var canvasbarcode = $("#canvasbarcode")[0].innerHTML;
6029             sizeWidthHeight.width = $("#canvasbarcode")[0].style.width;
6030
6031             customBase.amount2Image(canvasbarcode, "barcode", sizeWidthHeight, function (amountHtml) {
6032                 $("#" + idTemp + "barcode").addClass("cfg_contentNone");
6033                 for (var i = 0; i < $("." + idTemp + "value").length; i++) {
6034                     $("." + idTemp + "value")[i].setAttribute("src", amountHtml);
6035                 };
6036                 $("#" + idTemp).removeClass("cfg_contentNone");
6037             });
6038         });
6039     });
6040     //二维码点击事件
6041     $('.qrcodeShowClass').unbind();
6042     $('.qrcodeShowClass').on('click', function () {
6043         var editable = $(this)[0].getAttribute("editable");
6044         //编辑设定
6045         if (editable == "false") {
6046             return;
6047         }
6048
6049         $(this).addClass("cfg_contentNone");
6050         $("#" + $(this)[0].id + "qrcode").removeClass("cfg_contentNone");
6051         $("#" + $(this)[0].id + "qrcode").focus();
6052     });
6053
6054     //二维码焦点离开事件
6055     $('.qrcodeShowTextClass').unbind();
6056     $('.qrcodeShowTextClass').on('blur', function () {
6057         var id = $(this)[0].id;
6058         //表示的控件ID取得
6059         var idTemp = id.replace("qrcode", "");
6060         var showCustomItem = customShow.options.customItemShow.item[idTemp];
6061         // var widthqrcode = $("#"+idTemp)[0].width;
6062         // var heightqrcode = $("#"+idTemp)[0].height;
6063         var widthqrcode = showCustomItem.tag_Attribute.width;
6064         var heightqrcode = showCustomItem.tag_Attribute.height;
6065         if (heightqrcode == 0 || heightqrcode == undefined) {
6066             heightqrcode = 60;
6067         }
6068         if (widthqrcode == 0 || widthqrcode == undefined) {
6069             widthqrcode = 60;
6070         }
6071         //默认数值
6072         var defaultSize = {
6073             width: widthqrcode,
6074             height: heightqrcode,
6075             defaultvalue: "",
6076             styleclass: ""
6077         };
6078         // var size = $("#"+idTemp)[0].getAttribute("size");
6079
6080         defaultSize.defaultvalue = $(this)[0].value;
6081         $("#canvasqrcode").remove();
6082         $(document.body).append('<div id="canvasqrcode" style="display: none;"></div>');
6083         jQuery('#canvasqrcode').qrcode({ width: defaultSize.width, height: defaultSize.height, text: $(this)[0].value });
6084         var mycanvas = $("#canvasqrcode").find("canvas")[0];
6085         var image = mycanvas.toDataURL("image/png");
6086         $("#" + idTemp + "qrcode").addClass("cfg_contentNone");
6087         for (var i = 0; i < $("." + idTemp + "value").length; i++) {
6088             $("." + idTemp + "value")[i].setAttribute("src", image);
6089         };
6090
6091         $("#" + idTemp).removeClass("cfg_contentNone");
6092     });
6093 }
6094 // 禁用树的父节点   12/9
6095 customShow.setTree = {
6096     disableParentNode: {
6097         set: function (treeObj) {
6098             if (treeObj) {
6099                 var nodes = treeObj.getNodes();
6100                 var level = 0;
6101                 //  获取最底层的层数
6102                 treeObj.getNodesByFilter(function (node) {
6103                     if (level < node.level) {
6104                         level = node.level;
6105                     }
6106                 }); // 查找不是最底层的节点集合
6107                 var nodesFilter = treeObj.getNodesByFilter(function (node) {
6108                     return (node.level != level)
6109                 });
6110                 //父节点禁止勾选
6111                 for (var i = 0; i < nodesFilter.length; i++) {
6112                     treeObj.setChkDisabled(nodesFilter[i], true);
6113                 }
6114             }
6115         }
6116     }
6117 }
6118
6119 customShow.addtree = function (itemId, item) {
6120     console.log(customBase.settingRadioType)
6121     //修改克隆树的实例化 马习同2017-11-21
6122     console.log(customShow.options.customItemShow.item)
6123     var customItem = customShow.options.customItemShow.item;
6124     var ztree = {};
6125     for (let key in customItem) {
6126         if (customItem[key].tag_Type == "tree") {
6127             ztree[key] = customItem[key];
6128         }
6129     }
6130     $('.zTreeDemoBackground').css("display", "none");
6131     $(".search_input").css("display", "none");
6132     var index = 0;
6133     var treeObj;
6134     // var disableparentnode = false;
6135     for (let key in ztree) {
6136         if ($(item).find("#" + key).find('.ztree').parent().attr('disableparentnode') == "true") {
6137             $(item).find("#" + key).find('.ztree').attr("id", key + "tree" + index_i);//修改克隆树的id  马习同2017-11-21
6138             if (ztree[key].tag_Attribute.dropdowntype == "single") {
6139                 $.fn.zTree.init($($(".customViewUEditorCss  #" + key + "tree" + index_i)), customBase.settingRadioType, customShow.listData[key]);
6140                 //  12/2 树展开
6141                 treeObj = $.fn.zTree.getZTreeObj(key + "tree" + index_i);
6142                 customShow.setTree.disableParentNode.set(treeObj)
6143                 if (treeObj) {
6144                     treeObj.expandAll(true);
6145                 }
6146             } else if (ztree[key].tag_Attribute.dropdowntype == "multiple") {
6147                 $.fn.zTree.init($($(".customViewUEditorCss  #" + key + "tree" + index_i)), customBase.settingChkboxType, customShow.listData[key]);
6148                 treeObj = $.fn.zTree.getZTreeObj(key + "tree" + index_i);
6149                 customShow.setTree.disableParentNode.set(treeObj)
6150                 if (treeObj) {
6151                     treeObj.expandAll(true);
6152                 }
6153             }
6154         } else {
6155             $(item).find("#" + key).find('.ztree').attr("id", key + "tree" + index_i);//修改克隆树的id  马习同2017-11-21
6156             if (ztree[key].tag_Attribute.dropdowntype == "single") {
6157                 $.fn.zTree.init($($(".customViewUEditorCss  #" + key + "tree" + index_i)), customBase.settingRadioType, customShow.listData[key]);
6158                 //  12/2 树展开
6159                 treeObj = $.fn.zTree.getZTreeObj(key + "tree" + index_i);
6160                 console.log(treeObj)
6161                 if (treeObj) {
6162                     treeObj.expandAll(true);
6163                 }
6164             } else if (ztree[key].tag_Attribute.dropdowntype == "multiple") {
6165                 $.fn.zTree.init($($(".customViewUEditorCss  #" + key + "tree" + index_i)), customBase.settingChkboxType, customShow.listData[key]);
6166                 treeObj = $.fn.zTree.getZTreeObj(key + "tree" + index_i);
6167                 console.log(treeObj)
6168                 if (treeObj) {
6169                     treeObj.expandAll(true);
6170                 }
6171             }
6172         }
6173         // 克隆后选中节点  12/7 李元杰
6174         if (!_.isNull(treeObj)) {
6175             var treeId = treeObj['setting'].treeId;
6176             var defaultValue = $('#' + treeId).parent().attr('defaultvalue');
6177             // // 12/7  默认值
6178             if (defaultValue != '') {
6179                 console.log(treeObj)
6180                 customShow.treeDefaultSet(treeObj, defaultValue);
6181             }
6182         }
6183
6184     }
6185     console.log(treeObj)
6186     console.log($(item))
6187     //修改克隆树的实例化End  马习同2017-11-21
6188     index_i++;
6189
6190 }
6191
6192 //子表单项目追加
6193 customShow.addsubformList = function (subformAdd, showClass) {
6194     console.log(i)
6195     var allcopy = subformAdd.getAttribute('allcopy');
6196     var itemId = subformAdd.getAttribute('itemId');
6197     //单行记录更新
6198     if (allcopy == "false") {
6199         console.log(customBase.options.customItems);
6200         console.log(customBase.options.customItems[customShow.options.customItemShow.item[itemId].tag_Attribute.alias].cloneDiv);
6201         var item = customBase.options.customItems[customShow.options.customItemShow.item[itemId].tag_Attribute.alias].cloneDiv;
6202         // 子表单隐藏   马习同 11-13
6203         //      var item =$("."+showClass+" #"+itemId+"save").children()[0];
6204         //子表单情况为U情况
6205         if (item == undefined) {// 子表单回显 修改  李伟民 11-10
6206             var tbody = $("." + showClass + " #" + itemId + "ActiveId").find("tbody");
6207             tbody = tbody[0].cloneNode(true);
6208             console.log(tbody)
6209             // 清空input  12/7
6210             console.log($(item))
6211             if ($(item).find('.zTreeDemoBackground').attr('defaultvalue') == '') {
6212                 $(item).find(".citySel").val('');
6213             }
6214             $(tbody).find(".select2").remove();
6215             console.log($(tbody).html());
6216             $(tbody).find(".tdTitleClass").closest("tr").addClass("table_title");
6217             $(tbody).find(".dropdowntypeCss").select2({ theme: "classic" });
6218             //        $(tbody).find(".zTreeDemoBackground").select2({theme: "classic"});
6219             if ($(tbody).find(".table_title").length > 0) {
6220                 //删除头行
6221                 $(tbody).find(".table_title").remove();
6222             }
6223             if ($(tbody).find(".trContentClass").length > 1) {// 去除重复的tr  李伟民 11-14
6224                 $($(tbody).find(".trContentClass")[0]).siblings().remove();
6225             }// 去除重复的tr  李伟民 11-14
6226             //        $(tbody).find(".cfg_contentNone").removeClass("cfg_contentNone");
6227             tbody = customShow.addsubformListInit(itemId, $(tbody).find("tr"));
6228             console.log(tbody);
6229             console.log(itemId);
6230             console.log($(tbody).find("#" + itemId).attr("class"));
6231             $(tbody).find("input").attr("funarr", "");//公式绑定 清空 李伟民 12-11
6232             $(tbody).find("input").attr("checkfunarr", "");
6233             $(tbody).find(".select_get").attr("funarr", "");
6234             $(tbody).find(".select_get").attr("checkfunarr", "");//公式绑定 清空 李伟民 12-11
6235             $($("." + showClass + " #" + itemId + "ActiveId").find("table")[0]).append(tbody);// 子表单回显 修改  李伟民 11-10
6236             customShow.hidesubform();
6237             customShow.setXhSelectList(false);//添加记录 重复问题  李伟民11-14
6238         } else {
6239             item = item[0].cloneNode(true);
6240             // 12/7 清空input
6241             var defaultvalue = $(item).find('.zTreeDemoBackground').attr('defaultvalue');
6242             var itemIdTree = $(item).find('.ztree').attr('id');
6243             var treeObj = $.fn.zTree.getZTreeObj(itemIdTree);
6244             console.log(treeObj)
6245             // 12/7  默认值
6246             if ($(item).find('.zTreeDemoBackground').attr('defaultvalue') == '') {
6247                 $(item).find(".citySel").val('');
6248             }
6249             $(item).find(".select2").remove();
6250             $(item).find(".dropdowntypeCss").select2({ theme: "classic" });
6251             $(item).find(".subformAddiconShow .cfg_contentNone").removeClass("cfg_contentNone");
6252             item = customShow.addsubformListInit(itemId, item);
6253             $(item).find("input").attr("funarr", "");//公式绑定 清空 李伟民 12-11
6254             $(item).find("input").attr("checkfunarr", "");
6255             $(item).find(".select_get").attr("funarr", "");
6256             $(item).find(".select_get").attr("checkfunarr", "");//公式绑定 清空 李伟民 12-11
6257             $($("." + showClass + " #" + itemId + "ActiveId").find("table")[0]).append(item);
6258             customShow.setXhSelectList(true);//添加记录 重复问题  李伟民11-14
6259         }
6260
6261         customShow.addtree(itemId, item);
6262         //子表单事件追加
6263     } else {
6264         //全子表单复制
6265         //    //console.log(1);
6266
6267         var item = $("." + showClass + " #" + itemId + "ActiveId")[0];
6268         // //console.log(item);
6269         item = item.cloneNode(true);
6270         //console.log(item);
6271         var divIcons = document.createElement("div");
6272         divIcons.setAttribute("class", "frm_item_icons allCopyCss");
6273         var divIcon = document.createElement("div");
6274         divIcon.setAttribute("class", "frm_item_icon remove");
6275         var divIconImg = document.createElement("i");
6276         divIconImg.setAttribute("class", "icon iconfont icon-iconfontcolor93 iconfontcolor");
6277         divIconImg.setAttribute("style", "text-align: left;font-size: 18px;color: red;");
6278         // var divIconImg = document.createElement("img");
6279         // divIconImg.setAttribute("src", "./../../css/img/icon/delete.png");
6280         divIcon.appendChild(divIconImg);
6281         divIcons.appendChild(divIcon);
6282         // $(item).find(".icon-jiahao").parent().addClass("cfg_contentNone");
6283         $(item).append(divIcons);
6284         //  清空 树的input
6285         console.log($(item))
6286         if ($(item).find('.zTreeDemoBackground').attr('defaultvalue') != '') {
6287
6288         } else {
6289             $(item).find(".citySel").val('');
6290         }
6291         $(item).find(".select2").remove();
6292         $(item).find(".dropdowntypeCss").select2({ theme: "classic" });
6293         //console.log(item);
6294         item = customShow.addsubformListInit(itemId, item);
6295         // 10/23添加子表单记录
6296         var beforeitem = $("." + showClass + " #" + itemId + "ActiveId");
6297         //console.log(beforeitem);
6298         $(item).find("input").attr("funarr", "");//公式绑定 清空 李伟民 12-11
6299         $(item).find("input").attr("checkfunarr", "");
6300         $(item).find(".select_get").attr("funarr", "");
6301         $(item).find(".select_get").attr("checkfunarr", "");//公式绑定 清空 李伟民 12-11
6302         $("." + showClass + " #" + itemId + "ActiveId").eq(0).after(item);
6303         // _.each(beforeitem,function(bitem){
6304         if (beforeitem.length > 1) {
6305             for (var i = 0; i < beforeitem.length - 1; i++) {
6306                 $(beforeitem[i]).find(".icon-jiahao").parent().addClass("cfg_contentNone");
6307             }
6308         } else {
6309             $(beforeitem[0]).find(".icon-jiahao").parent().addClass("cfg_contentNone");
6310         }
6311         customShow.setXhSelectList();//添加记录 重复问题  李伟民11-14
6312         // });
6313         customShow.addtree(itemId, item);
6314     }
6315 }
6316 //马习同修改  子表单隐藏  11/13
6317 customShow.hidesubform = function () {
6318     // console.log($("[tag_type='subform']"))
6319     _.each($("[tag_type='subform']"), opt => {
6320         console.log(opt)
6321         $($(opt).find(".tdTitleClass")[0]).addClass("cfg_contentNone");
6322         $($(opt).find(".tdContentClass")[0]).addClass("cfg_contentNone");
6323     })
6324     var unvisible = customBase.options.customItems;
6325     var unvisibleArr = [];
6326     _.each(unvisible, opt => {
6327         if (opt.visible == false && opt.parentsubFormNum != 0) {
6328             unvisibleArr.push(opt)
6329         }
6330     })
6331     //  _.remove(unvisibleArr,n => {
6332     //     return n.fieldKey == "DATAROWNUM";
6333     // })
6334     // console.log(unvisibleArr)
6335     _.each(unvisibleArr, opt => {
6336         $("[id='" + opt.id + "']").parent().parent().addClass("cfg_contentNone");
6337         $($(".customShow #itemId_" + opt.parentsubFormNum + " .tdTitleClass")[$("[id='" + opt.id + "']").parent().parent().index()]).addClass("cfg_contentNone");
6338         $($(".customViewUEditorCss #itemId_" + opt.parentsubFormNum + " .tdTitleClass")[$("[id='" + opt.id + "']").parent().parent().index()]).addClass("cfg_contentNone");
6339     })
6340 }
6341 //子表单内数据初始化
6342 customShow.addsubformListInit = function (itemId, tbodys) {
6343     //console.log(tbodys);
6344     var itemList = customShow.options.customItemShow.item;
6345     var item = itemList[itemId];
6346     var parentsubFormNum = item.columnOrderNum + "";
6347
6348     for (itemListId in itemList) {
6349         if (itemList.hasOwnProperty(itemListId)) {
6350             if (itemList[itemListId].parentsubFormNum == parentsubFormNum) {
6351                 //子表单内控件确认
6352                 var type = itemList[itemListId].tag_Type;
6353                 if (type == "text" || type == "textarea" || type == "number") {
6354                     $(tbodys).find("#" + itemListId)[0].value = itemList[itemListId].tag_Attribute.defaultvalue;
6355                 } else if (type == "calendar") {
6356                     $(tbodys).find("#" + itemListId)[0].value = "";
6357                 } else if (type == "radio") {
6358
6359                 } else if (type == "checkbox") {
6360
6361                 } else if (type == "dropdownlist") {
6362                     var itemListIdTemp = itemListId + "_" + customShow.options.dropdownlist_I;
6363                     var item = $(tbodys).find("#" + itemListId);
6364                     ////////console.log($(tbodys));
6365                     // var dropdowntype =  $(item.find('select'))[0].getAttribute("dropdowntype");
6366                     var dropdowntype = customShow.options.customItemShow.item[itemListId].tag_Attribute.dropdowntype;
6367                     if ($("#" + itemListId + " .select3-element")[0] == undefined) {
6368                         var width = $(tbodys).find("#" + itemListId)[0].style.width.replace("px", "");
6369                     } else {
6370                         var width = $("#" + itemListId + " .select3-element")[0].style.width.replace("px", "");
6371                     }
6372
6373                     width = parseInt(width);
6374                     var listData = customBase.options.dropdownlistText[itemListId];
6375                     ////////console.log(customBase.options.dropdownlistText);
6376                     // $("#"+itemId).parent().empty();
6377                     var itemIdClass = "selectClass js-example-basic-single defaultHeight customShowItemClass  dropdowntypeCss " + itemListId + "value " + itemListIdTemp;
6378                     var DropdownlistItem = item.parent();
6379                     //        DropdownlistItem.css("background-color","red");
6380                     // var setDiv = $('<div id="'+itemListId+'" class="selectClass '+itemIdClass+'"></div>');
6381                     var setDiv = $('<div id="' + itemListId + '" class="selectClass lwm' + itemIdClass + '"></div>');
6382                     console.log("11122211")
6383                     DropdownlistItem.empty();
6384                     setDiv.empty();
6385                     console.log(itemListId);
6386                     DropdownlistItem.append(setDiv);
6387                     console.log($(DropdownlistItem).html());
6388                     //////console.log(dropdowntype);
6389
6390                     if (dropdowntype == "multiple") {
6391                         customShow.options.subformDList[itemListIdTemp] = {
6392                             selectId: itemListId,
6393                             multiple: true,
6394                             width: width,
6395                             // listData:listData,
6396                         }
6397                     } else {
6398                         customShow.options.subformDList[itemListIdTemp] = {
6399                             selectId: itemListId,
6400                             multiple: false,
6401                             width: width,
6402                             // listData:listData,
6403                         }
6404                     }
6405                     //  if(dropdowntype == "multiple"){
6406                     //     xhSelect.setXhSelect(
6407                     //         {
6408                     //             selectId:itemListId,
6409                     //             multiple:true,
6410                     //             width: width,
6411                     //             listData:listData,
6412                     //             setDiv:setDiv
6413                     //             // setDiv:itemListIdTemp
6414                     //         }
6415                     //     );
6416                     //  }else{
6417                     //     xhSelect.setXhSelect(
6418                     //         {
6419                     //             selectId:itemListId,
6420                     //             multiple:false,
6421                     //             width: width,
6422                     //             listData:listData,
6423                     //             setDiv:setDiv
6424                     //             // setDiv:itemListIdTemp
6425                     //         }
6426                     //     );
6427                     //  }
6428
6429                 }
6430             }
6431             customShow.options.dropdownlist_I++;
6432         }
6433
6434     }
6435     //console.log(customShow);
6436     //console.log(customBase);
6437
6438     ////////console.log(customShow.options.customItemShow.item);
6439     ////////console.log(itemId);
6440     ////////console.log(item);
6441     ////////console.log(parentsubFormNum);
6442     // customShow.setXhSelectList();
6443     return tbodys;
6444 }
6445 //驳回
6446 customShow.rejectBtn = function () {
6447     var flag = true;//true驳回 false不驳回
6448     over(flag)
6449 }
6450 //提交
6451 customShow.onclickSubmit = function () {
6452     get();
6453 }
6454 //查看票据
6455 customShow.checkbill = function () {
6456     window.open("./../bill_img/bill.html")
6457 }
6458 //审批
6459 customShow.auditableBtn = function () {
6460     auditableBtn();
6461 }
6462 function auditableBtn() {
6463     var processLog = JSON.parse(localStorage.getItem("processLog"));
6464     if (processLog != null && processLog != undefined) {
6465     } else {
6466         alert("请先创建一个流程");
6467         return null;
6468     }
6469     if (processLog[0].processState == 60) {
6470         alert("流程已结束");
6471         return null;
6472     }
6473     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/>"
6474         + "<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>";
6475     $("#liucheng").html(inputs);
6476     $("#auditableBtn")[0].setAttribute('data-toggle', "modal");
6477     $("#auditableBtn")[0].setAttribute('data-target', ".bs-example-modal-sm");
6478 }
6479 customShow.onclickSave1 = function () {
6480     // SC.sendanydata(function(flag){
6481     //     console.log(flag);
6482     // if(!flag){
6483     //     console("if")
6484     //     customShow.onclickSave(1);
6485     // }else{
6486
6487     //    alert("错误");
6488     // }
6489     // });
6490     SC.sendanydata(customShow.onclickSave, 1)
6491
6492
6493 }
6494 customShow.onclickSave2 = function () {
6495     SC.sendanydata(customShow.onclickSave, 2)
6496 }
6497
6498 //清空按钮按下是
6499 customShow.onclickClear = function () {
6500     console.log(customBase);
6501     console.log(customShow);
6502     var itemKey = _.keys(customShow.options.customItemShow.item);
6503     var item = customShow.options.customItemShow.item;
6504     console.log(itemKey);
6505     _.each(itemKey, function (itemId) {
6506         console.log(itemId);
6507         console.log(item[itemId].tag_Type);
6508         customBase.setItemValue(itemId, item[itemId].tag_Type, "", "");
6509     });
6510 }
6511 //保存按钮按下时
6512 customShow.onclickSave = function (clickFlag) {
6513     console.log(clickFlag);
6514     var saveReturn = customShow.initEvent.fromSaveLinkage();
6515
6516     //画面项目取得 --------------------------画面项目取得------
6517     var items = customShow.getItems(true);
6518     console.log(items)
6519     // customShow.queryCost();
6520     try {
6521         if (typeof (eval(eachitem)) == "function") {
6522             eachitem(items);
6523         }
6524     } catch (e) {
6525         console.log("不存在的函数");
6526     }
6527
6528     console.log("遍历数组")
6529     console.log(items);
6530     // 画面check
6531     var returnfromCheck = customShow.initEvent.fromCheck(items); //--------------------
6532     if (returnfromCheck) {
6533         return;
6534     }
6535     // 03检证执行
6536     var check = customShow.initEvent.validationRuleCheck(items); //--------------------
6537     if (!check) {
6538         return;
6539     }
6540     // 检证接口函数
6541     var check = customShow.initEvent.validationRuleCheck3rd(items); //-----------需要对验证进行解析---------
6542     if (!check) {
6543         return;
6544     }
6545     // 提取数据 生成数据json  同customShow.getItems()
6546     //公式保存接口
6547     //  var saveReturn = customShow.initEvent.fromSaveLinkage(items);
6548     //  if(!saveReturn){
6549     //     return;
6550     //  }
6551     // 发送数据到后台服务器,保存data
6552     var saveReturn = customShow.initEvent.fromSave3rd(items);//--------------------
6553     console.log(customShow.options.customShowFlag)
6554     if (saveReturn) {
6555         console.log(1)
6556         if (customShow.options.customShowFlag == "1") {
6557             //保存
6558             customDataBound.fromSave(customShow.options.formid, items, function (rs) {
6559                 if (rs.rspCode == "000000") {
6560                     var strMessage = customBase.getMessage("mesage_ID015");
6561                     customBase.alert("S", strMessage);
6562                     //  return;
6563                 }
6564                 if (rs.rspCode == "100004") {
6565                     var strMessage = customBase.getMessage("mesage_ID007");
6566                     customBase.alert("E", strMessage);
6567                     return;
6568                 }
6569                 if (customShow.options.customShowFlag == "1") {
6570                     window.parent.$('#myModal').modal('hide');
6571                     window.parent.addFormData(rs);
6572                     $(window.parent.document.body).css({ "overflow-x": "auto", "overflow-y": "auto" });
6573                 }
6574                 // //////console.log(rs);
6575             });
6576         } else if (customShow.options.customShowFlag == "2") {
6577             console.log(2)
6578             //保存
6579             customDataBound.fromEdit(customShow.options.formid, items, customShow.options.dataRowNum, function (rs) {
6580                 if (rs.rspCode == "100004") {
6581                     var strMessage = customBase.getMessage("mesage_ID007");
6582                     customBase.alert("E", strMessage);
6583                     return;
6584                 }
6585                 customShow.options.breakFlag = true;
6586                 //预览模式表示
6587                 $("#customViewUEditor")[0].style.display = "none";
6588                 //马习同  2018-1-2  布局修改
6589                 $("#customShow")[0].style.display = "flex";
6590                 // $(".footer")[0].style.display ="none";
6591
6592                 var btns = [
6593                     'printableBtn',
6594                     // 'exportBtn',
6595                     // 'rejectBtn',
6596                     // 'submitBtn',
6597                     // 'auditableBtn',
6598                     // 'queryBtn',
6599                     // 'createBtn',
6600                     // 'clearBtn',
6601                     // 'disposableBtn',
6602                     // 'fromSaveBtn',
6603                     'editableBtn'
6604                 ];
6605                 customShow.showCustom(items, customShow.options.customInit);
6606                 customShow.setToolBtn(btns);
6607                 console.log("关闭")
6608                 customShow.onclickCancel();
6609
6610             });
6611             //   customShow.onclickCancel();
6612         }
6613         else if (customShow.options.customShowFlag == "3") {
6614             // 保存
6615             console.log(3)
6616             if (clickFlag == 2 && customShow.options.dataRowNum != "") {
6617                 //保存
6618                 customDataBound.fromEdit(customShow.options.formid, items, customShow.options.dataRowNum, function (rs) {
6619                     ////console.log(rs);
6620                     if (rs.rspCode == "000000") {
6621                         var strMessage = customBase.getMessage("mesage_ID015");
6622                         customBase.alert("S", strMessage);
6623                         //  return;
6624                     }
6625                     if (rs.rspCode == "100004") {
6626                         var strMessage = customBase.getMessage("mesage_ID007");
6627                         customBase.alert("E", strMessage);
6628                         return;
6629                     }
6630                     // customShow.options.breakFlag = true;
6631                     // //预览模式表示
6632                     // $("#customViewUEditor")[0].style.display ="none";
6633                     // $("#customShow")[0].style.display ="block";
6634                     // // $(".footer")[0].style.display ="none";
6635                     // customShow.showCustom(items,customShow.options.customInit);
6636                 });
6637                 //新建
6638             } else {
6639                 customDataBound.fromSave(customShow.options.formid, items, function (rs) {
6640                     if (rs.rspCode == "000000") {
6641                         var strMessage = customBase.getMessage("mesage_ID015");
6642                         customBase.alert("S", strMessage);
6643                         //  return;
6644                     }
6645                     if (rs.rspCode == "100004") {
6646                         var strMessage = customBase.getMessage("mesage_ID007");
6647                         customBase.alert("E", strMessage);
6648                         return;
6649                     }
6650                     // if(customShow.options.customShowFlag == "1" ){
6651                     //     window.parent.$('#myModal').modal('hide');
6652                     //     window.parent.addFormData(rs);
6653                     //     $(window.parent.document.body).css({"overflow-x": "auto","overflow-y": "auto"});
6654                     // }
6655                     if(customShow.options.customShowFlag != "3" ){//发布差异修改 李伟民 0120
6656                         customShow.options.dataRowNum = rs.data.dataRowNum;
6657                     }
6658                     //////console.log(rs);
6659                 });
6660             }
6661         }
6662     }
6663     // customShow.onclickCancel();
6664     //  window.parent.$('#myModal').modal('hide');
6665     // console.log($('.boxOne'))
6666     // $('.boxOne').css("display","none");
6667 }
6668
6669 //保存按钮按下时(项目预览表示)
6670 customShow.showCustom = function (items, customInit) {
6671     console.log(items);
6672     console.log(customInit);
6673     customShow.options.customItemShow = customInit.customViewItem;
6674     var customItem = customShow.options.customItemShow;
6675     // $(".preview-edit-pane").css("display","block");
6676     // $(".footer")[0].style.display ="block";
6677     // $(".footer .fromSaveCss")[0].style.display ="none";
6678
6679     var divHtml = customItem.formeditor;
6680
6681     $("#customShow").empty();
6682     $("#customShow")[0].innerHTML = divHtml;
6683     var height = customShow.options.customItemShow.height;
6684     //  height = parseInt(height)-50;
6685     //////////console.log(height);
6686     $("#customShow")[0].style.height = height + "px";
6687     $("#customShow")[0].style.width = customShow.options.customItemShow.width;
6688     $("#customShow")[0].style.display = "flex";
6689     var customItems = customBase.options.customItems;
6690
6691     //数据值变换
6692     for (item in customItems) {
6693         if (customItems.hasOwnProperty(item)) {
6694             if (customItems[item] == undefined) {
6695                 delete customItems[item];
6696                 continue;
6697             }
6698             if (customItems[item].type == 'subform') {
6699                 var subformTemp = items[item];
6700                 //////console.log(items);
6701                 ////console.log(item);
6702                 console.log(subformTemp);
6703                 //          console.log(customItems);
6704                 if (subformTemp == undefined) {
6705                     subformTemp = [{}];
6706                 }
6707                 for (subformItem in subformTemp[0]) {
6708                     if (subformTemp[0].hasOwnProperty(subformItem)) {
6709                         items[subformItem] = [];
6710                     }
6711                 }
6712                 for (var i = 0; i < subformTemp.length; i++) {
6713                     if (i != 0) {
6714                         //子表单项目追加
6715                         var subformAdd = $(".customShow #" + customItems[item].id + "ActiveId .subformAdd")[0];
6716                         customShow.addsubformList(subformAdd, "customShow");
6717                     }
6718                     for (subformItem in subformTemp[i]) {
6719                         if (subformTemp[i].hasOwnProperty(subformItem)) {
6720                             items[subformItem][i] = subformTemp[i][subformItem];
6721                         }
6722                     }
6723                 };
6724             }
6725             //选项卡回显
6726             if (customItems[item].type == 'tag') {
6727                 var subformTemp = items[item];
6728                 ////console.log(items);
6729                 ////console.log(item);
6730                 ////console.log(subformTemp);
6731                 ////console.log(customItems);
6732                 if (subformTemp == undefined) {
6733                     subformTemp = [{}];
6734                 }
6735                 for (subformItem in subformTemp[0]) {
6736                     if (subformTemp[0].hasOwnProperty(subformItem)) {
6737                         items[subformItem] = [];
6738                     }
6739                 }
6740                 for (var i = 0; i < subformTemp.length; i++) {
6741                     if (i != 0) {
6742                         //子表单项目追加
6743                         var subformAdd = $(".customShow #" + customItems[item].id + "ActiveId .subformAdd")[0];
6744                         customShow.addsubformList(subformAdd, "customShow");
6745                     }
6746                     for (subformItem in subformTemp[i]) {
6747                         if (subformTemp[i].hasOwnProperty(subformItem)) {
6748                             items[subformItem][i] = subformTemp[i][subformItem];
6749                         }
6750                     }
6751                 };
6752             }
6753         }
6754     }
6755
6756     customShow.options.subformDValue = items;
6757     //表示项目进行变换
6758
6759     //画面项目初期化
6760     customShow.controlInit("customShow");
6761
6762     //删除项目(select2项目删除)
6763     $('.customShow .selection').remove();
6764     //console.log(customItems);
6765     //数据设定
6766     for (item in customItems) {
6767         console.log(items)
6768         if (customItems.hasOwnProperty(item)) {
6769             if (customItems[item] == undefined) {
6770                 delete customItems[item];
6771                 continue;
6772             }
6773
6774             var type = customItems[item].type;
6775             var id = customItems[item].id;
6776             var value = items[item];
6777             // value = [{"tId":"itemId_1tree_2"},{"name":"F066008"},{"tId":"itemId_1tree_3"},{"name":"F066003"}];
6778             // value = [{"name":"F066008"},{"name":"F066003"}];
6779             // value = [{"name":"F066008"},{"name":"F066003"}];
6780
6781             if (customItems[item].type == 'subform') {
6782                 $(".customShow").find("#" + id + "subform").find("td").addClass("");
6783             } else if (customItems[item].type == 'htmlediter') {
6784                 // var htmlediterShow = $(".customShow").find("#"+id)[0];
6785                 var htmlediterShow = $(".customShow #" + id + "Item")[0];
6786                 // var heightShow = $(htmlediterShow)[0].getAttribute("heightShow");
6787                 // var widthShow = $(htmlediterShow)[0].getAttribute("widthShow");
6788                 var heightShow = customShow.options.customItemShow.item[id].tag_Attribute.height;
6789                 var widthShow = customShow.options.customItemShow.item[id].tag_Attribute.width;
6790                 if (widthShow == undefined || heightShow == undefined) {
6791                     widthShow = 200;
6792                     heightShow = 200;
6793                 }
6794                 var oNode = '<div style="word-break:break-all;width:' + widthShow + 'px;height:' +
6795                     heightShow + 'px;" class="customShowItemClass edui-default customShowItemClassTemp">';
6796                 // var oNode ='<div style="word-break:break-all;border-width: 1px;border-style: solid;border-color: rgb(204, 204, 204);class="customShowItemClass edui-default">';
6797                 oNode += value;
6798                 oNode += "</div>";
6799                 $($(".customShow #" + id + "Item")[0]).after(oNode);
6800                 $($(".customShow #" + id + "Item")[0]).remove();
6801                 //标签数据设定
6802             } else if (customItems[item].type == 'textarea') {
6803                 var htmlediterShow = $(".customShow #" + id)[0];
6804                 var heightShow = customShow.options.customItemShow.item[id].tag_Attribute.height;
6805                 var widthShow = customShow.options.customItemShow.item[id].tag_Attribute.width;
6806                 if (widthShow == undefined || heightShow == undefined) {
6807                     widthShow = 300;
6808                     heightShow = 80;
6809                 }
6810                 var oNode = '<div style="word-break:break-all;border-width: 0px;border-style: solid;border-color: rgb(204, 204, 204);width:' + widthShow + 'px;height:' +
6811                     heightShow + 'px;" class="customShowItemClass edui-default customShowItemClassTemp">';
6812                 // var oNode ='<div style="word-break:break-all;border-width: 1px;border-style: solid;border-color: rgb(204, 204, 204);class="customShowItemClass edui-default">';
6813                 oNode += value;
6814                 oNode += "</div>";
6815                 $($(".customShow #" + id)[0]).after(oNode);
6816                 $($(".customShow #" + id)[0]).remove();
6817                 //标签数据设定
6818             } else if (customItems[item].type == 'number') {
6819                 var numberShowItems = $(".customShow #" + id);
6820                 for (var i = 0; i < numberShowItems.length; i++) {
6821                     numberShowItems[i].setAttribute("type", "text");
6822                 }
6823
6824                 //标签数据设定
6825             } else if (customItems[item].type == 'link') {
6826                 var htmlediterShow = $(".customShow").find("#" + id)[0];
6827                 // console.log($(htmlediterShow))
6828                 // $(htmlediterShow)[0].setAttribute("href","javascript:;");
6829                 $(htmlediterShow).css("font-size", "16px;");
6830                 //单选 多选按钮
6831             } else if (type == 'radio' || type == 'checkbox' || type == 'dropdownlist') {
6832
6833                 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">';
6834                 oNode += "</div>";
6835                 // $($(".customShow").find("#"+id)[0]).after(oNode);
6836                 // $($(".customShow").find("#"+id)[0]).remove();
6837                 var showItem = $($(".customShow").find("#" + id));
6838                 console.log(showItem)
6839                 for (var i = 0; i < showItem.length; i++) {
6840                     $($(showItem[i])[0]).after(oNode);
6841                     $($(showItem[i])[0]).remove();
6842                 }
6843                 console.log(value)
6844                 //单选复选回显问题
6845                 customShow.setShowItem(id, type, value, true);
6846             }
6847             else if (customItems[item].type == 'tree') {
96b1bc 6848                 //普通模式树形回显  李伟民  0130
L 6849                 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 6850                 // 2017 /11/7  李元杰  树的回显
B 6851                 //   var   treeShow = $('#customShow').find('div[type=tree]');
6852
6853                 //   if(value !=undefined && value !=""){
6854                 //       console.log(1);
6855                 //     if(typeof value == "string"){
6856                 //     //   value = $.parseJSON(value);
6857                 //     console.log(2);
6858                 //       value =[value];
6859                 //     }
6860                 //     // 2017/11/7  李元杰回显
6861                 //     if(value.length>0){
6862                 //        console.log(value);
6863                 //        for(var i =0;i<value.length;i++){
6864                 //            value[i]
6865                 //        }
6866
6867
6868                 //      console.log(value)
6869
6870                 //        if(typeof value[0] == "string"){
6871                 //            //console.log(value[0]);
6872                 //         //   value[0] = $.parseJSON(value[0]);
6873                 //        }
6874
6875                 //       oNode +=value[0];
6876                 //     }
6877                 //     for (var i = 1; i < value.length; i++) {
6878                 //         console.log(4);
6879                 //       if(typeof value[i] == "string"){
6880                 //         console.log(5);
6881                 //         //   value[i] = $.parseJSON(value[i]);
6882                 //        }
6883                 //        console.log(value)
6884                 //       oNode +=" , "+value[i];
6885                 //       console.log(oNode)
6886                 //     };
6887                 //   }
6888                 //   console.log(oNode)
6889
6890                 //   oNode +="</div>";
6891                 "</div>";
6892                 $($(".customShow").find("#" + id)[0]).after(oNode);
6893                 $($(".customShow").find("#" + id)[0]).remove();
6894                 //              customShow.setShowItem(id, type, value, true);
6895                 console.log($($(".customShow").find("#" + id)[0]))
6896             }
6897             else if (customItems[item].type == 'amount') {
6898                 var id = id + "amount";
6899                 customBase.setItemValue(id, 'text', items[item], 'customShow');
6900                 $("#" + id).blur();
6901
6902             } else if (customItems[item].type == 'qrcode') {
6903                 var id = id + "qrcode";
6904                 customBase.setItemValue(id, 'text', items[item], 'customShow');
6905                 $("#" + id).blur();
6906             } else if (customItems[item].type == 'barcode') {
6907                 var id = id + "barcode";
6908                 customBase.setItemValue(id, 'text', items[item], 'customShow');
6909                 $("#" + id).blur()
6910             } else if (customItems[item].type == 'fileupload') {
6911                 // var $wrap = $(".customShow #" + customItems[item].id);
6912                 var $uploaderItem = $($(".customShow #" + customItems[item].id)[0]);
6913                 $uploaderItem.empty();
6914                 var $uploadimg = $(
6915                     '<div >' +
6916                     '<div id="fileList" class="uploader-list"></div>' +
6917                     '</div>'
6918                 );
6919                 var $list = $uploadimg.find("#fileList");
6920                 if (typeof value != "string") {
6921                     if (_.isArray(value)) {
6922                         // airport = JSON.parse(airport)
6923                         value = value.join(",")
6924                         var value = JSON.parse(value);
6925
6926                     }
6927                     for (i in value) {
bb9424 6928                         var fileDir = value[i].path;
Z 6929                         var suffix = fileDir.substr(fileDir.lastIndexOf(".")+1);
6930                         if(suffix == "mp4"){
6931                             var $li = $(
6932                                 '<div class="">' +
6933                                 '<div><a href="' + value[i].path + '" target="_blank">' + value[i].oldName + ' </a></div>' +
6934                                 '</div>'
6935                             );
6936                         }else{
6937                             var $li = $(
6938                                 '<div class="">' +
6939                                 // '<div class="info"><a href="' + value[i].path + '" >' + value[i].oldName + '</a></div>' +
6940                                 // '<div class="info info-box"><div class="info_box">' + value[i].oldName +
6941                                 // '<span class="x_box" style="display:none;">×</span>' +
6942                                 // '<img class="img_box" style="display:none;" src="' + value[i].path + '">' +
6943     
6944                                 '<div><a href="' + value[i].path + '" >' + value[i].oldName + '</a></div>' +
6945                                 '</div>'
6946                             );
6947                         }
4d1219 6948                         $li.appendTo($list);
B 6949                     };
6950                 }
6951                 $uploadimg.appendTo($uploaderItem);
6952                 //2017-12-17 马习同修改 图片
6953                 // $(".info_box").on("click", function () {
6954                 //     $(".x_box").show();
6955                 //     $(".img_box").show();
6956                 //     $(".x_box").unbind();
6957                 //     $(".x_box").on("click", function () {
6958                 //         console.log(1);
6959                 //         $(".x_box").hide();
6960                 //         $(".img_box").hide();
6961                 //     })
6962                 // })
6963             } else if (customItems[item].type == 'image') {
6964                 // var $wrap = $(".customShow #" + customItems[item].id);
6965                 var $uploaderItem = $($(".customShow #" + customItems[item].id)[0]);
6966                 console.log($('#' + customItems[item].id));
6967                 console.log($uploaderItem)
6968                 $uploaderItem.empty();
6969
6970                 var $uploadimg = $(
6971                     '<div >' +
6972                     '<div id ="fileList" class="uploader-list"></div>' +
6973                     '</div>'
6974                 );
6975                 // var $list = $uploadimg.find("#"+potion.id+"fileList");
6976                 console.log(value)
449a85 6977                 if(customItems[item].defaultvalue != undefined){//详细显示默认值 李伟民 0131
L 6978                     var $list = $uploadimg.find("#fileList");
6979                         var $addLi = $(
6980                             '<div class="file-item thumbnail">' +
6981                             '<img  src="' + customItems[item].defaultvalue + '">' +
6982                             '</div>'
6983                         );
6984
6985                         $list.prepend($addLi);
6986                 }
4d1219 6987                 if (_.isArray(value)) {
B 6988                         // airport = JSON.parse(airport)
6989                     value = value.join(",")
6990                   var value = JSON.parse(value);
13ec33 6991
4d1219 6992                 }
B 6993                 console.log(value)
6994                 if (typeof value != "string") {
6995                     if (typeof value == "string") {
6996                         //   value = $.parseJSON(value);
6997                     }
6998                     for (i in value) {
6999                         var $list = $uploadimg.find("#fileList");
7000                         var $addLi = $(
7001                             '<div class="file-item thumbnail">' +
bd8eb1 7002                             '<img style="width:100px,height:100px" src="' + value[i].path + '">' +
4d1219 7003                             '</div>'
B 7004                         );
7005
7006                         $list.prepend($addLi);
7007                     }
7008                 }
7009                 //  12/18 放大图片
7010
7011                 $uploaderItem.append($uploadimg);
7012                 var particularId = $uploaderItem.attr('id') + '_1'
7013                 $uploaderItem.children().attr('id', particularId);
7014                 // var particularId =  $uploaderItem.find('#uploaderItem').attr('id')
7015                 // 详情页
7016                 var viewer = new Viewer(document.getElementById(particularId), {
7017                     url: 'data-original',
13ec33 7018
4d1219 7019                 });
B 7020                 var imgId = $uploaderItem.attr('id');
7021                 var srcUrl = $uploaderItem.find('img').attr('src');
7022                 $uploaderItem.find('img').attr('alt', ' ');
7023                 // itemId_32uploadimg
7024
7025                 // 编辑页
7026                 // console.log($('#customViewUEditor').find('#'+imgId).children())
7027                 // console.log($('#'+imgId))
7028                 // console.log($uploaderItem)
7029                 // var viewer = new Viewer(document.getElementById(imgId), {
7030                 //     url: 'data-original',
7031                 //     show:function(){
7032                 //         console.log('显示')
7033                 //     }
7034                 // });
7035                 // 12/18
7036
7037
7038             } else if (customItems[item].type == 'mytext') {
7039                 //选择表单编辑回显
7040                 console.log(customItems);
7041                 console.log(customShow);
7042                 var itemAttribute = customShow.options.customItemShow.item[customItems[item].id];
7043                 var $mytext = $("#" + customItems[item].id);
7044                 var item_title = [];
7045                 var itemVal = [];
7046                 if (itemAttribute.tag_Attribute.relevancesourcetype == "fundata") {// 关联数据回显渲染 李伟民 11-30
7047                     var titleObj = { "key": JSON.parse(itemAttribute.tag_Attribute.fundata)["key"] };
7048                     var dataObj = {
7049                         "formID": customShow.options.formid,
7050                         "tenantID": "001",
7051                         "search": [],
7052                         "pageSize": "1000",
7053                         "pageNum": "1",
7054                         "key": JSON.parse(itemAttribute.tag_Attribute.fundata)["key"],
7055                         "formData": {},
7056                         "dataRowNum": items[item]
7057                     };
7058                     var requesTitle = window.commonAjax("/datamanagement/getAssociateTitle", titleObj, "POST", true, false);
7059                     var requesData = window.commonAjax("/datamanagement/getAssociateData", dataObj, "POST", true, false);
7060                     requesTitle.done(function (res) {
7061                         console.log(res);
7062                         item_title = res.data;
7063                     });
7064                     requesData.done(function (res) {
7065                         console.log(res);
7066                         if (!_.isNull(res.data) && res.data != undefined) {
7067                             itemVal = res.data;
7068                         }
7069                     });
7070                 } else {
7071                     var myTitle = JSON.parse(window.localStorage.getItem("title"));
7072                     item_title = myTitle[item];
7073                     itemVal = items[item];
7074                 }
7075                 console.log(itemVal)
7076                 console.log(item_title);
7077                 console.log(itemVal.list);
7078                 createMxtTable(customItems[item].id, item_title, itemVal.list);// 关联数据回显渲染 李伟民 11-30
7079                 //                            var newData = [];
7080                 //                            _.each(itemVal.list,function(opt){
7081                 //                                opt = _.mapKeys(opt,function(value,key){
7082                 //                                    _.each(item_title,function(item){
7083                 //                                        if(key == item.fieldKey){
7084                 //                                            key = item.title;
7085                 //                                        }
7086                 //                                    })
7087                 //                                    return key;
7088                 //                                })
7089                 //                                console.log(_.cloneDeep(opt))
7090                 //                                newData.push(opt);
7091                 //                            })
7092                 //                            console.log(itemVal.list);
7093                 //                            console.log(newData);
7094                 var formhuixian = itemVal.list;
7095
7096                 //console.log(formhuixian);
7097                 var huixianStr = "";
7098                 for (let i in formhuixian) {
7099                     //console.log($mytext.attr("fieldkey"));
7100                     //console.log(i);
7101                     //console.log(formhuixian[i]);
7102                     if (i = $mytext.attr("fieldkey")) {
7103                         huixianStr = formhuixian[i];
7104                     }
7105                 }
7106                 //console.log(huixianStr);
7107                 $mytext.attr("formhuixian", JSON.stringify(itemVal.list));
7108                 //                     if(newData){
7109                 //                         var $value = newData;
7110                 //                         console.log($value)
7111                 //
7112                 //                                    var show = "";
7113                 //                                    var divBox = $("<div></div>");
7114                 //                                    divBox.attr('id',customItems[item].id+'divBox');
7115                 //                                    var sdata_head = "";
7116                 //                                    _.each($value,(opt,j)=>{
7117                 //                                        var ulBox = $("<ul></ul>");
7118                 //                                        for(let i in opt){
7119                 //                                            show = "";
7120                 //                                            sdata_head = '<td class="data1 '+i+'">'+i+'</td>';
7121                 //                                        show += '<li>'+'<span class="data1 '+i+'">'+i+'</span>'+'<span class="data2 '+i+'">'+opt[i]+'</span>'+'</li>';
7122                 //                                        ulBox.attr("class","addUl ulBox"+j);
7123                 //                                        ulBox.attr("id","ulBox"+j);
7124                 //                                        //console.log(show)
7125                 //                                        ulBox.append(show);
7126                 //                                        }
7127                 //                                        divBox.append(ulBox);
7128                 //                                    });
7129                 //                                    console.log(sdata_head);
7130                 //                          $mytext.append(divBox);
7131                 //                      }
7132             }
7133             if (type == 'radio' || type == 'checkbox' || type == 'dropdownlist' || type == 'tree' ||
7134                 type == 'amount' || type == 'barcode' || type == 'qrcode' || type == 'image' ||
7135                 type == 'button' || type == 'fileupload'
7136                 || type == 'subform' || type == 'link'
7137                 || type == 'splitline' || type == 'link'
7138                 || type == 'textarea'
7139             ) {
7140
7141             } else {
7142                 //值设定
7143                 customBase.setItemValue(id, type, value, 'customShow');
7144             }
7145
7146         }
7147     };
7148 }
7149
7150 //画面表示项目取得  -----------------
7151 customShow.getItems = function (saveflag) {
7152     var items = customBase.options.customItems;
7153     console.log(items);
7154     var itemTempS = {};
7155     for (item in items) {
7156         if (items.hasOwnProperty(item)) {
7157             console.log(item);
7158             console.log(items[item].type);
7159             if (items[item].type == "button" || items[item].type == "link") {
7160             } else if (items[item].type == "dropdownlist") {
7161                 // var datasourcetype = $("#"+items[item].id)[0].getAttribute("datasourcetype");
7162                 //  //主数据源
7163                 // if(datasourcetype == "masterdata"){
7164                 //   itemTempS[item] = customBase.getItemValue(items[item].id,"dropdownlistText");
7165                 //   //数据源
7166                 // }else if(datasourcetype == "datasource"){
7167                 //   itemTempS[item] = customBase.getItemValue(items[item].id,"dropdownlistText");
7168                 //   //自定义
7169                 // }else if(datasourcetype == "custom"){
7170                 //   itemTempS[item] = customBase.getItemValue(items[item].id,"dropdownlistText");
7171                 //   //API接口
7172                 // }else if(datasourcetype == "api"){
7173                 //   itemTempS[item] = customBase.getItemValue(items[item].id,"dropdownlistText");
7174                 // }
7175                 itemTempS[item] = customBase.getItemValue(items[item].id, "dropdownlistText");
7176                 console.log(itemTempS[item])
7177                 if (saveflag) {//下拉框 传值 修改  李伟民  11-09
7178                     console.log(itemTempS[item]);
7179                     _.each(itemTempS[item], function (sval, i) {
7180                         if (_.isArray(sval)) {
7181                             itemTempS[item][i] = sval.join();
7182                         }
7183                     })
7184                     //            if(_.isArray(itemTempS[item][0])){
7185                     //                  itemTempS[item][0] = itemTempS[item][0].join(",")
7186                     //              }
7187                     console.log(itemTempS[item]);
7188                 }//下拉框 传值 修改  李伟民  11-09
7189             } else if (items[item].type == "tree") {
7190                 itemTempS[item] = customBase.getItemValue(items[item].id, "tree");
7191                 console.log(itemTempS[item])
7192                 if (saveflag) {//树形传值 修改  李元杰  11-21
7193                     console.log(itemTempS[item]);
7194                     _.each(itemTempS[item], function (sval, i) {
7195                         if (_.isArray(sval)) {
7196                             itemTempS[item][i] = sval.join();
7197                         }
7198                     })
7199                     //            if(_.isArray(itemTempS[item][0])){
7200                     //                  itemTempS[item][0] = itemTempS[item][0].join(",")
7201                     //              }
7202                 }//树形 传值 修改  李元杰  11-21
7203             } else if (items[item].type == "checkbox") {
7204                 itemTempS[item] = customBase.getItemValue(items[item].id, "checkbox");
7205                 console.log(itemTempS[item])
7206                 console.log(saveflag)
7207                 if (saveflag) {//复选框传值 修改  马习同  12-6
7208                     console.log(itemTempS[item]);
7209                     _.each(itemTempS[item], function (sval, i) {
7210                         if (_.isArray(sval)) {
7211                             itemTempS[item][i] = sval.join();
7212                         }
7213                     })
7214                     //            if(_.isArray(itemTempS[item][0])){
7215                     //                  itemTempS[item][0] = itemTempS[item][0].join(",")
7216                     //              }
7217                 }////复选框传值 修改  马习同  12-6
7218             } else if (items[item].type == "radio") {
7219                 itemTempS[item] = customBase.getItemValue(items[item].id, "radio");
7220                 console.log(itemTempS[item])
7221                 console.log(saveflag)
7222                 if (saveflag) {//复选框传值 修改  马习同  12-6
7223                     console.log(itemTempS[item]);
7224                     _.each(itemTempS[item], function (sval, i) {
7225                         if (_.isArray(sval)) {
7226                             itemTempS[item][i] = sval.join();
7227                         }
7228                     })
7229                     //            if(_.isArray(itemTempS[item][0])){
7230                     //                  itemTempS[item][0] = itemTempS[item][0].join(",")
7231                     //              }
7232                 }////复选框传值 修改  马习同  12-6
7233             } else if (items[item].type == "subform" || items[item].type == "tag" || items[item].type == "tab") {
7234
7235             } else if (items[item].type == "auto") {
7236                 var str = window.localStorage.getItem("customItem");
7237                 var prefix = (str != undefined && str != "undefined") ? JSON.parse(str) : null;
7238                 if (prefix != null && (prefix[item] != null || prefix[item] != undefined)) {
7239                     itemTempS[item] = prefix[item];
7240                 } else {
7241                     itemTempS[item] = customBase.getItemValue(items[item].id, items[item].type);
7242                 }
7243             } else {
7244                 itemTempS[item] = customBase.getItemValue(items[item].id, items[item].type);
7245                 console.log(itemTempS[item]);
7246             }
7247         }
7248     };
7249     var itemRetuen = {};
7250
7251     //子表单数据变换
7252     for (item in customBase.options.customItems) {
7253         if (customBase.options.customItems.hasOwnProperty(item)) {
7254             if (customBase.options.customItems[item].type == "subform" || customBase.options.customItems[item].type == "tag" || customBase.options.customItems[item].type == "tab") {
7255                 var id = customBase.options.customItems[item].id.replace("itemId_", "");
7256                 itemRetuen[id] = {};
7257             }
7258         }
7259     }
7260     console.log(_.cloneDeep(itemRetuen));
7261     console.log(_.cloneDeep(itemTempS));
7262     //子表单内数据保存
7263     for (item in itemTempS) {
7264         ////console.log(items);
7265         ////console.log(itemTempS);
7266         ////console.log(item);
7267         if (itemTempS.hasOwnProperty(item)) {
7268             var parentsubFormNum = customBase.options.customItems[item].parentsubFormNum;
7269             ////console.log(customBase.options)
7270             ////console.log(customBase.options.customItems[item]);
7271             ////console.log(parentsubFormNum);
7272             if (parentsubFormNum == "0") {
7273                 if (customBase.options.customItems[item].type == "radio" ||
7274                     customBase.options.customItems[item].type == "checkbox" ||
7275                     customBase.options.customItems[item].type == "dropdownlist" ||
7276                     customBase.options.customItems[item].type == "tree"
7277                 ) {
7278                     itemRetuen[item] = itemTempS[item][0];
7279                 } else {
7280                     itemRetuen[item] = itemTempS[item];
7281                 }
7282             } else {
7283                 ////console.log(item);
7284                 ////console.log(items);
7285                 ////console.log(itemRetuen[parentsubFormNum]);
7286                 ////console.log(itemTempS[item]);
7287                 ////console.log(itemRetuen);
7288                 ////console.log(parentsubFormNum);
7289                 itemRetuen[parentsubFormNum][item] = itemTempS[item];
7290             }
7291         }
7292     }
7293     //子表单内最终数据变换
7294     console.log(_.cloneDeep(itemRetuen));
7295     console.log(customBase.options.customItems);
7296     for (item in customBase.options.customItems) {
7297         if (customBase.options.customItems.hasOwnProperty(item)) {
7298             if (customBase.options.customItems[item].type == "subform" || customBase.options.customItems[item].type == "tag" || customBase.options.customItems[item].type == "tab") {
7299                 var id = customBase.options.customItems[item].id.replace("itemId_", "");
7300                 var tepItem = itemRetuen[id];
7301                 var subformIten = [];
7302                 var i = 0;
7303                 console.log(tepItem);
7304                 for (tem in tepItem) {
7305                     if (tepItem.hasOwnProperty(tem)) {
7306                         if (typeof tepItem[tem] == "string") {
7307                             if (subformIten[0] == undefined) {
7308                                 subformIten[0] = {};
7309                             }
7310                             subformIten[0][tem] = tepItem[tem];
7311                         } else {
7312                             console.log(tepItem[tem]);
7313                             for (var i = 0; i < tepItem[tem].length; i++) {
7314                                 if (subformIten[i] == undefined) {
7315                                     subformIten[i] = {};
7316                                 }
7317                                 subformIten[i][tem] = tepItem[tem][i];
7318                             }
7319                         }
7320                     }
7321                 }
7322                 delete itemRetuen[id];
7323                 console.log(_.cloneDeep(subformIten));
7324                 itemRetuen[customBase.options.customItems[item].fieldKey] = subformIten;
7325             }
7326         }
7327     }
7328     console.log(_.cloneDeep(itemRetuen));
7329     return itemRetuen;
7330 }
7331
7332 //取消事件
7333 customShow.onclickCancel = function () {
7334     // var items = customShow.getItems();
7335     //检证执行
7336     var saveReturn = customShow.initEvent.cancelEventLinkage();
7337     if (!saveReturn) {
7338         return;
7339     }
7340
7341     //取消接口(第三方提供)
7342     var saveReturn = customShow.initEvent.cancelEvent3rd();//--------------------
7343     if (saveReturn) {
7344         // 取消接口
7345         customShow.initEvent.cancelEvent();//--------------------
7346     }
7347     if (customShow.options.customShowFlag == "3") {
7348         // window.close();
7349         window.location.href = "about:blank";
7350         window.close();
7351     } else if (customShow.options.customShowFlag == "0" || customShow.options.customShowFlag == "1" || customShow.options.customShowFlag == "2") {
7352         window.parent.$('#myModal').modal('hide');
7353         if (customShow.options.breakFlag) {
7354             window.parent.addFormData();
7355         }
7356         if (customShow.options.customShowFlag == "1" || customShow.options.customShowFlag == "2") {
7357             $(window.parent.document.body).css({ "overflow-x": "auto", "overflow-y": "auto" });
7358         }
7359         window.parent.$("#myFormDesign").css("display", "");
7360         window.parent.$(".htmlediterClass").css("display", "");
7361     }
7362 }
7363
7364 //印刷事件  打印
7365 customShow.onPrint = function () {
7366     var items = customShow.getItems();
7367     var interfacep = customShow.initEvent.interfaceprint3rd(items);
7368     if (!interfacep) {
7369         return;
7370     }
7371     var removePrintArea = function (id) {
7372         $("iframe#" + id).remove();
7373     };
7374     var customShowFlag = window.localStorage.getItem("customShowFlag");
7375     if (customShowFlag == "0") {
7376         var itemOnPrint = $("#customViewUEditor")[0].cloneNode(true);
7377         $(itemOnPrint).css("overflow", 'visible');
7378         $(itemOnPrint).printArea();
7379     }else{
7380         var itemOnPrint = $("#customShow")[0].cloneNode(true);
7381         $(itemOnPrint).css("overflow", 'visible');
7382         $(itemOnPrint).printArea();
7383     }
7384 }
7385
7386 //编辑按钮按下时
7387 customShow.onEditor = function () {
7388     // $(".preview-edit-pane").css("display", "none");
7389     window.localStorage.setItem("customShowFlag", 3);
7390     var formIDs = customlocalStorage.newFormID;
7391
7392     customDataBound.formsetting(formIDs, function () { });
7393     //console.log("编辑存值");
7394     $("#customShow").empty();
7395     if (customShow.options.customShowFlag != "3") {
7396         //图片文件上传
7397         var uploaderImage = $(".customViewUEditorCss .uploaderImage");
7398         for (var i = 0; i < uploaderImage.length; i++) {
7399             $("#" + uploaderImage[i].id).find('.imgfileLiShow').remove();
7400             var imageItem = customShow.options.customItemShow.item[uploaderImage[i].id];
7401             var itemList = customBase.options.uploaderItemReady[uploaderImage[i].id];
7402             if (customShow.options.customShowFlag == "3") {
7403
7404             }
7405             // 参数设定
7406             var potion = {
7407                 id: uploaderImage[i].id,
7408                 width: imageItem.tag_Attribute.width,
7409                 height: imageItem.tag_Attribute.height,
7410                 formid: customShow.options.formid,
7411                 imagetype: imageItem.tag_Attribute.dropdowntype, //图片类型
7412                 editable: imageItem.tag_Attribute.editable, //是否可编辑
7413                 defaultvalueUrl: imageItem.tag_Attribute.defaultvalue, //默认的Url
7414                 ItemReady: itemList,
7415                 visible:imageItem.tag_Attribute.visible
7416             }
7417             //  12/18
7418             customBase.uploaderShow(potion);
7419
7420             // customBase.uploaderShow("#"+uploaderImage[i].id,{width:0,height:200},true,customShow.options.formid);
7421
7422         };
7423
7424         //文本文件上传
7425         var uploaderFile = $(".customViewUEditorCss .uploaderFile");
7426
7427         for (var i = 0; i < uploaderFile.length; i++) {
7428             $("#" + uploaderFile[i].id + "  .filelist").empty();
7429
7430             var imageItem = customShow.options.customItemShow.item[uploaderFile[i].id];
7431             debugger
7432             var itemList = customBase.options.uploaderItemReady[uploaderFile[i].id];
7433             // 参数设定
7434             var potion = {
7435                 id: uploaderFile[i].id,
7436                 width: imageItem.tag_Attribute.width,
7437                 height: imageItem.tag_Attribute.height,
7438                 formid: customShow.options.formid,
7439                 imagetype: imageItem.tag_Attribute.dropdowntype, //图片类型
7440                 editable: imageItem.tag_Attribute.editable, //是否可编辑
7441                 defaultvalueUrl: imageItem.tag_Attribute.defaultvalue, //默认的Url
7442                 ItemReady: itemList,
7443                 visible:imageItem.tag_Attribute.visible
7444             }
7445             customBase.uploaderFileShow(potion);
7446             // customBase.uploaderShow_Temp("#"+uploaderFile[i].id,{width:0,height:200},false,customShow.options.formid);
7447         };
7448     }
7449     $("#customViewUEditor")[0].style.display = "block";
7450     $("#customShow")[0].style.display = "none";
7451     $("#customShow").css("display", "none");
7452     $("#customShow").removeClass("fui-form");
7453     // $(".footer")[0].style.display ="block";
7454     // $(".preview-edit-pane")[0].style.display ="none";
7455     // $(".footer .fromSaveCss")[0].style.display ="block";
7456
7457     var btns = [
7458         // 'printableBtn',
7459         //12/23'exportBtn',
7460         //12/23 'rejectBtn',
7461         // 12/23 'submitBtn',
7462         //12 /23 'auditableBtn',
7463         // 12/23 'queryBtn',
7464         // 'createBtn',
7465         // 'clearBtn',
7466         //  12/23 'disposableBtn',
7467         // 'fromSaveBtn',
7468         // 'editableBtn'
7469     ];
7470     customShow.setToolBtn(btns);
7471
7472     customShow.setXhSelectList();
7473     //子表单事件调用
7474     customShow.clickBindSubform();
7475     //2017/11/18  马习同修改 隐藏预览模式下  导入数据按钮
7476     $(".sonImportFile").removeClass("cfg_contentNone");
7477     //s_savebtn
7478     $(".s_savebtn").show();
7479     // $(".preview-edit-pane").css("display", "none");
7480     //12/23
7481     // $('#disposableBtn').css('display','none');
7482     // $('#clearBtn').css('display','none');
7483     // $('#queryBtn').css('display','none');
7484     // $('#auditableBtn').css('display','none');
7485     // $('#submitBtn').css('display','none');
7486     // $('#rejectBtn').css('display','none');
7487
7488 }
7489
7490 //画面验证
7491 customShow.onfromCheck = function (items) {
7492     if ($(".errorCheckCss").length > 0) {
7493         return true;
7494     }
7495     if($(".checkErr") > 0){
7496         return true;
7497     }
7498     $(".errorItemCss").removeClass("errorItemCss");
7499     $(".mesageErrDiv").remove();
7500     for (var id in customShow.options.showErrId) {
7501         $($(".customViewUEditorCss  #" + id)[customShow.options.showErrId[id]]).popover('hide');
7502     }
7503
7504     //必须入力验证
7505     mustcheckExe = function (tag_Type, value, ItemId, N) {
7506         if (tag_Type == "text" || tag_Type == "textarea" ||
7507             tag_Type == "number" || tag_Type == "htmlediter" || tag_Type == "fileupload" ||
7508             tag_Type == "calendar") {
7509             if (tag_Type == "fileupload") {
7510                 var count = 0;
7511                 for (var key in value) {
7512                     count++;
7513                 }
7514                 if (count == 0) {
7515                     value = "";
7516                 }
7517
7518             }
7519             if (value == "") {
7520                 customShow.showErrorItem(tag_Type, ItemId, N);
7521                 var message = customBase.getMessage("mesage_ID004");
7522                 customShow.setShowMesageErr(ItemId, message, N);
7523                 mustcheck = true;
7524             }
7525         } else if (tag_Type == "checkbox" || tag_Type == "dropdownlist") {
7526             // //////////console.log(value);
7527             if (value.length == 0) {
7528                 customShow.showErrorItem(tag_Type, ItemId, N);
7529                 var message = customBase.getMessage("mesage_ID004");
7530                 customShow.setShowMesageErr(ItemId, message, N);
7531                 mustcheck = true;
7532             }
7533         }
7534     }
7535
7536     //数值型验证
7537     numberFormatCheck = function (numbertype, value, ItemId, N) {
7538         if (numbertype == "integer") {
7539             if (value.indexOf(".") > -1) {
7540                 var message = customBase.getMessage("mesage_ID019");
7541                 customShow.showErrorItem("number", ItemId, N);
7542                 customShow.setShowMesageErr(ItemId, message, N);
7543                 mustcheck = true;
7544             } else {
7545                 var numberMaxlength = customShow.options.customItemShow.item[ItemId].tag_Attribute.maxlength;
7546                 numberMaxlength = parseInt(numberMaxlength);
7547                 if (value.length > numberMaxlength && numberMaxlength != 0) {
7548                     customShow.showErrorItem("number", ItemId, N);
7549                     var message = customBase.getMessage("mesage_ID020");
7550                     customShow.setShowMesageErr(ItemId, message, N);
7551                     mustcheck = true;
7552                 }
7553             }
7554         } else {
7555             var integerItem;
7556             integerItem = value.split(".");
7557             //整数长度
7558             // var aa = customShow.options.customItemShow.item[subformItemId].tag_Attribute.alias;
7559             var numberMaxlength = customShow.options.customItemShow.item[ItemId].tag_Attribute.maxlength;
7560             numberMaxlength = parseInt(numberMaxlength);
7561             var numberdecimalplace = customShow.options.customItemShow.item[ItemId].tag_Attribute.decimalplace;
7562             numberdecimalplace = parseInt(numberdecimalplace);
7563             if (integerItem[0].length > numberMaxlength && numberMaxlength != 0) {
7564                 customShow.showErrorItem("number", ItemId, N);
7565                 var message = customBase.getMessage("mesage_ID020");
7566                 customShow.setShowMesageErr(ItemId, message, N);
7567                 mustcheck = true;
7568             }
7569             if (integerItem[2] != undefined && integerItem[1].length > numberdecimalplace) {
7570                 customShow.showErrorItem("number", ItemId, N);
7571                 var message = customBase.getMessage("mesage_ID021");
7572                 customShow.setShowMesageErr(ItemId, message, N);
7573                 mustcheck = true;
7574             }
7575             ////////console.log(customShow.options.customItemShow.item[ItemId].tag_Attribute);
7576         }
7577     }
7578
7579     //文本格式验证
7580     maxlengthCheck = function (maxlength, value, ItemId, N) {
7581         if (value.length > maxlength && maxlength != 0) {
7582             customShow.showErrorItem("htmlediter", ItemId, N);
7583             var message = customBase.getMessage("mesage_ID023");
7584             customShow.setShowMesageErr(ItemId, message, N);
7585             mustcheck = true;
7586         }
7587     }
7588     //文本格式验证
7589     textFormatCheck = function (format, value, ItemId, N) {
7590         if (value == "") {
7591             return;
7592         } else if (format == "phone") {
7593             //手机号
7594             var p1 = /^1[3|4|5|7|8][0-9]{9}$/;
7595             var me = false;
7596             if (!p1.test(value)) {
7597                 customShow.showErrorItem("text", ItemId, N);
7598                 var message = customBase.getMessage("mesage_ID009");
7599                 customShow.setShowMesageErr(ItemId, message, N);
7600                 mustcheck = true;
7601             }
7602         } else if (format == "url") {
b81a80 7603             //网址 张吉男修改网址验证
Z 7604             // var strRegex = "^((https|http|ftp|rtsp|mms)?://)"
7605             //     + "?(([0-9a-z_!~*'().&=+$%-]+: )?[0-9a-z_!~*'().&=+$%-]+@)?" //ftp的user@
7606             //     + "(([0-9]{1,3}\.){3}[0-9]{1,3}" // IP形式的URL- 199.194.52.184
7607             //     + "|" // 允许IP和DOMAIN(域名)
7608             //     + "([0-9a-z_!~*'()-]+\.)*" // 域名- www.
7609             //     + "([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\." // 二级域名
7610             //     + "[a-z]{2,6})" // first level domain- .com or .museum
7611             //     + "(:[0-9]{1,4})?" // 端口- :80
7612             //     + "((/?)|" // a slash isn't required if there is no file name
7613             //     + "(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)$";
7614             var strRegex="[a-zA-z]+://[^\s]*";
4d1219 7615             var re = new RegExp(strRegex);
B 7616             if (!re.test(value)) {
7617                 customShow.showErrorItem("text", ItemId, N);
7618                 var message = customBase.getMessage("mesage_ID010");
7619                 customShow.setShowMesageErr(ItemId, message, N);
7620                 mustcheck = true;
7621             }
7622         } else if (format == "cardno") {
7623             //身份证
7624             // 2018.1.25 张吉男修改  身份证验证错误
7625             // 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;
7626             var p1=/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
7627             // alert(1111);
7628             if (!p1.test(value)) {
7629                 customShow.showErrorItem("text", ItemId, N);
7630                 var message = customBase.getMessage("mesage_ID011");
7631                 customShow.setShowMesageErr(ItemId, message, N);
7632                 mustcheck = true;
7633             }
7634         } else if (format == "email") {
7635             //邮箱
7636             var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
7637             if (!myreg.test(value)) {
7638                 customShow.showErrorItem("text", ItemId, N);
7639                 var message = customBase.getMessage("mesage_ID012");
7640                 customShow.setShowMesageErr(ItemId, message, N);
7641                 mustcheck = true;
7642             }
7643         }
7644     }
7645     var customItems = customBase.options.customItems;
7646     //必须入力验证
7647     var mustcheck = false;
7648     for (fieldKey in customItems) {
7649
7650         if (customItems.hasOwnProperty(fieldKey)) {
7651             ////console.log(customItems);
7652             var tag_Type = customItems[fieldKey].type;
7653             var ItemId = customItems[fieldKey].id;
7654             if (customItems[fieldKey].visible) {
7655                 if (customItems[fieldKey].mustcheck) {
7656                     var value = items[fieldKey];
7657                     //子表单的情况
7658                     if (value == undefined) {
7659
7660                         //取得对应子表单ID
7661                         var subformItemId = "itemId_" + customItems[fieldKey].parentsubFormNum;
7662                         if (customShow.options.customItemShow.item[subformItemId] != undefined) {
7663                             var subformItemAlias = customShow.options.customItemShow.item[subformItemId].tag_Attribute.alias;
7664                             var subformItem = items[subformItemAlias];
7665                             for (var i = 0; i < subformItem.length; i++) {
7666                                 mustcheckExe(tag_Type, subformItem[i][fieldKey], ItemId, i);
7667                             }
7668                         }
7669                     } else {
7670                         mustcheckExe(tag_Type, value, ItemId, 0);
7671                     }
7672                 }
7673                 //文本格式验证
7674                 if (customItems[fieldKey].type == "text") {
7675                     var value = items[fieldKey];
7676                     ////console.log(fieldKey);
7677                     ////console.log(customItems);
7678                     ////console.log(value);
7679                     var format = customShow.options.customItemShow.item[ItemId].tag_Attribute.format;
7680                     //子表单的情况
7681                     if (value == undefined) {
7682                         //取得对应子表单ID
7683                         var subformItemId = "itemId_" + customItems[fieldKey].parentsubFormNum;
7684                         var subformItemAlias = customShow.options.customItemShow.item[subformItemId].tag_Attribute.alias;
7685                         var subformItem = items[subformItemAlias];
7686                         ////console.log(items);
7687                         ////console.log(subformItemAlias);
7688                         ////console.log(subformItem);
7689                         for (var i = 0; i < subformItem.length; i++) {
7690                             textFormatCheck(format, subformItem[i][fieldKey], ItemId, i);
7691                         }
7692                     } else {
7693                         textFormatCheck(format, value, ItemId, 0);
7694                     }
7695
7696                 }
7697                 //数值整数验证
7698                 if (customItems[fieldKey].type == "number") {
7699                     var value = items[fieldKey];
7700                     //数值格式
7701                     var numbertype = customShow.options.customItemShow.item[ItemId].tag_Attribute.numbertype;
7702                     //子表单的情况
7703                     if (value == undefined) {
7704                         //取得对应子表单ID
7705                         var subformItemId = "itemId_" + customItems[fieldKey].parentsubFormNum;
7706                         var subformItemAlias = customShow.options.customItemShow.item[subformItemId].tag_Attribute.alias;
7707                         var subformItem = items[subformItemAlias];
7708                         for (var i = 0; i < subformItem.length; i++) {
7709                             numberFormatCheck(numbertype, subformItem[i][fieldKey], ItemId, i);
7710                         }
7711                     } else {
7712                         numberFormatCheck(numbertype, value, ItemId, 0);
7713                     }
7714
7715                 }
7716
7717                 //默认长度检证
7718                 if (customItems[fieldKey].type == "htmlediter") {
7719                     var value = items[fieldKey];
7720                     //数值格式
7721                     var maxlength = customShow.options.customItemShow.item[ItemId].tag_Attribute.maxlength;
7722                     // //子表单的情况
7723                     // if(value ==undefined){
7724                     //   //取得对应子表单ID
7725                     //   var subformItemId = "itemId_"+customItems[fieldKey].parentsubFormNum;
7726                     //   var subformItemAlias = customShow.options.customItemShow.item[subformItemId].tag_Attribute.alias;
7727                     //   var subformItem = items[subformItemAlias];
7728                     //   for(var i=0;i<subformItem.length;i++){
7729                     //      numberFormatCheck(numbertype,subformItem[i][fieldKey],ItemId,i);
7730                     //   }
7731                     // }else{
7732                     maxlengthCheck(maxlength, value, ItemId, 0);
7733                     // }
7734
7735                 }
7736             }
7737         }
7738     }
7739     //焦点事件
7740     // $(".errorItemCss").unbind('focus');
7741     // $(".errorItemCss").on('focus', function() {
7742     //     $(this).removeClass("errorItemCss");
7743     //     ////////////console.log($(this)[0].id);
7744     //     $("#"+$(this)[0].id+"mesageErrDiv").remove();
7745     //     $(".customViewUEditorCss  #"+$(this)[0].id).popover('hide')
7746     // });
7747     // //下拉列表点击事件
7748     // $(".select2-search__field").unbind("focus");
7749     // $(".select2-search__field").bind("focus",function(){
7750     //   var id = this.getAttribute("errorItemId");
7751     //   var N = this.getAttribute("N");
7752     //   $($('.customViewUEditorCss #'+id)[N].parentNode).find(".select2").removeClass("errorItemCss");
7753     //   $("#"+id+"mesageErrDiv").remove();
7754     //   $($(".customViewUEditorCss  #"+id)[N]).popover('hide')
7755     // });
7756
7757     if (mustcheck) { return true; }
7758
7759     //单选按钮长度验证
7760
7761     //焦点事件
7762     // $(".errorItemCss").unbind();
7763     // $(".errorItemCss").on('focus', function() {
7764     //   $(this).removeClass("errorItemCss");
7765     // });
7766     return false;
7767 }
7768
7769 //检证验证
7770 customShow.interfaceCheck = function (items) {//保存前计算费用  李伟民   10 - 31
7771     var flag = true;
7772     _.each(customBase.interfaceData, function (intdata) {
7773         var func = intdata.customInterfacemethod + "()";
5a4f8f 7774         if(intdata.interfacemethod == 'fromSave3rd'){//只执行保存接口事件
L 7775             try {//解决不上传资源文件JS报错 导致无法保存  李伟民 0129
7776                 var thisChheck = eval(func);
7777                 console.log(thisChheck);
7778                 if (thisChheck == false) {
7779                     flag = false;
7780                 }
7781             } catch (error) {
13ec33 7782
5a4f8f 7783             }
4d1219 7784         }
B 7785     });
7786     return flag;
7787 }//保存前计算费用  李伟民   10 - 31
7788
7789 //错误信息
7790 customShow.showErrorItem = function (errorClass, tag_Type, id, N) {
7791     if (tag_Type == "text" || tag_Type == "textarea" || tag_Type == "number" || tag_Type == "calendar"
7792         || tag_Type == "checkbox") {
7793         $($(".customViewUEditorCss  #" + id)[N]).addClass(errorClass);
7794     } else if (tag_Type == "htmlediter") {
7795         // $(".customViewUEditorCss  #"+id+"Item").addClass(errorClass);
7796         UE.getEditor(id + "Item").body.setAttribute("class", errorClass);
7797         if (UE.getEditor(id + "Item").body.getAttribute("heightFlag") == "height") {
7798         } else {
7799             var height = UE.getEditor(id + "Item").body.style.height.replace("px", "");
7800             height = parseInt(height) - 12;
7801             UE.getEditor(id + "Item").body.style.height = height + "px";
7802             UE.getEditor(id + "Item").body.setAttribute("id", id);
7803         }
7804         UE.getEditor(id + "Item").body.setAttribute("heightFlag", height);
7805
7806         // //////////console.log(UE.getEditor(id+"Item").body.style.height = );
7807     } else if (tag_Type == "dropdownlist") {
7808         //  $(".customViewUEditorCss  #"+id).p + ".selection").addClass(errorClass);
7809         // //////////console.log($('.customViewUEditorCss #'+id)[0].parentNode);
7810         $($('.customViewUEditorCss #' + id)[N].parentNode).find(".select2").addClass(errorClass);
7811         //  $(".customViewUEditorCss  #"+id+" .select2-search__field")
7812         if ($($('.customViewUEditorCss #' + id)[N].parentNode).find(".select2-search__field").length > 0) {
7813             $($('.customViewUEditorCss #' + id)[N].parentNode).find(".select2-search__field")[0].setAttribute("errorItemId", id);
7814             $($('.customViewUEditorCss #' + id)[N].parentNode).find(".select2-search__field")[0].setAttribute("N", N);
7815         }
7816     }
7817 }
7818
7819 //画面属性设定(初始值 表示/非表示  只读 必须 审查必须)
7820 customShow.setShowAttribute = function (aliasItem) {
7821     console.log(aliasItem)
7822     //  12/7  不可编辑 可以编辑
7823     id = aliasItem.id;
7824     //表示非表示
7825     if (aliasItem.visible) {
7826         $(".customViewUEditorCss #" + id).removeClass("cfg_contentNone");
7827         $(".customViewUEditorCss #" + id + "ActiveId").removeClass("cfg_contentNone");
7828         $(".customViewUEditorCss ." + id + "IconShow").removeClass("cfg_contentNone");
7829         $(".customViewUEditorCss #" + id + "Item").removeClass("cfg_contentNone");
7830         if (customShow.options.customItemShow.customFlag == "1" && aliasItem.type == "dropdownlist") {
7831             $($(".customViewUEditorCss #" + id)[0].parentNode).removeClass("cfg_contentNone");
7832         }
7833     } else if (!aliasItem.visible) {
7834         $(".customViewUEditorCss #" + id).addClass("cfg_contentNone");
7835         $(".customViewUEditorCss #" + id + "ActiveId").addClass("cfg_contentNone");
7836         $(".customViewUEditorCss ." + id + "IconShow").addClass("cfg_contentNone");
7837         $(".customViewUEditorCss #" + id + "Item").addClass("cfg_contentNone");
7838         if (customShow.options.customItemShow.customFlag == "1" && aliasItem.type == "dropdownlist") {
7839             $($(".customViewUEditorCss #" + id)[0].parentNode).addClass("cfg_contentNone");
7840         }
7841     }
7842     //必须
7843     if (aliasItem.mustcheck) {
7844         $(".customViewUEditorCss ." + id + "IconShow .iconMustcheck").removeClass("cfg_contentNone");
7845     } else if (!aliasItem.mustcheck) {
7846         $(".customViewUEditorCss ." + id + "IconShow .iconMustcheck").addClass("cfg_contentNone");
7847     }
7848     //审查必须
7849     if (aliasItem.approvalmustenter) {
7850         $(".customViewUEditorCss ." + id + "IconShow .iconApprovalmustenter").removeClass("cfg_contentNone");
7851     } else if (!aliasItem.approvalmustenter) {
7852         $(".customViewUEditorCss ." + id + "IconShow .iconApprovalmustenter").addClass("cfg_contentNone");
7853     }
7854
7855     //编辑-非编辑
7856     var itemTemp = $($(".customViewUEditorCss #" + id)[0]);
7857     var tag_Type = aliasItem.type;
7858     if (aliasItem.editable) {
7859         if (tag_Type == "text" || tag_Type == "textarea" || tag_Type == "number" || tag_Type == "calendar") {//--OK
7860             itemTemp.removeAttr('readonly');
7861             //  非编辑情况移除背景颜色  12/7 李元杰
7862             for (var i = 0; i < itemTemp.length; i++) {
7863                 console.log(itemTemp[i]);
7864                 $(itemTemp[i]).removeClass('disableColor')
7865             }
7866             if (tag_Type == "calendar") {
7867                 var calendarItem = customShow.options.customItemShow.item[id];
7868                 // var editable = tag_Attribute['editable'];
7869                 var textformat = calendarItem.tag_Attribute.datatype;
7870                 if (textformat == 'Y') {
7871                     $(itemTemp).addClass('dateFromyyyy');
7872                 } else if (textformat == 'Y-m') {
7873                     $(itemTemp).addClass('dateFromyyyymm');
7874                 } else if (textformat == 'Y-m-d') {
7875                     $(itemTemp).addClass('dateFromyyyymmdd');
7876                 } else if (textformat == 'Y-m-d H:i') {
7877                     $(itemTemp).addClass('dateFromhhmiss');
7878                 }
7879                 customShow.clickBindSubform();
7880
7881             }
7882         } else if (tag_Type == "radio") {//----------------------------------------------------------
7883             itemTemp.find('.custom-radio').removeAttr("readonly");
7884         } else if (tag_Type == "radio") {//----------------------------------------------------------
7885             itemTemp.find('.custom-radio').removeAttr("readonly");
7886         } else if (tag_Type == "checkbox") {//-------------------------------------------------------
7887             itemTemp.find('.custom-check').removeAttr("readonly");
7888         } else if (tag_Type == "dropdownlist") {//---------------------------------------------------OK
7889             // $(itemTemp).removeClass('editableDisabled');
7890             // $(itemTemp).prop("disabled", false);        //设置下拉框不可用
7891             // $(itemTemp).find(".select-container").removeAttr("readonly");
7892             $(itemTemp).removeClass("disableColor");
7893
7894             $(itemTemp).removeClass("readonly");
7895             //          ////console.log($(itemTemp).find(".select-container"));
7896         } else if (tag_Type == "button") {//---------------------------------------------------------OK
7897             $(itemTemp).removeClass('disabled');
7898         } else if (tag_Type == "link") {//-----------------------------------------------------------OK
7899             itemTemp.href = "javascript:void(0);";
7900             itemTemp.removeAttr('disabled', 'disabled');
7901         } else if (tag_Type == "fileupload") {//----------------------------------------------------todo
7902         } else if (tag_Type == "tree") {//----------------------------------------------------------todo
7903             $(itemTemp).parent().find('.citySel').removeClass('disableColor')
7904
7905             //   var itemTemp = $("#customResultFormDiv").find("#"+tag_Id)[0];
7906             itemTemp[0].setAttribute('editable', aliasItem.editable);
7907         }
7908         // else if (tag_Type == "tree" || tag_Type == "tree" || tag_Type == "tree") {
7909         //     //  var itemTemp = $("#customResultFormDiv").find("#"+tag_Id)[0];
7910         //     itemTemp.setAttribute('editable', aliasItem.editable);
7911         // }
7912
7913     } else if (!aliasItem.editable) {
7914         if (tag_Type == "text" || tag_Type == "textarea" || tag_Type == "number" || tag_Type == "calendar") {//--OK
7915             for (var i = 0; i < itemTemp.length; i++) {
7916                 //  12/7 李元杰 添加背景颜色
7917                 console.log(itemTemp[i]);
7918                 itemTemp[i].setAttribute('readonly', '');
7919                 $(itemTemp[i]).addClass('disableColor')
7920             }
7921             if (tag_Type == "calendar") {
7922                 // $('.dateFromyyyy').unbind();
7923                 // $('.dateFromyyyymm').unbind();
7924                 // $('.dateFromyyyymmdd').unbind();
7925                 // $('.dateFromhhmiss').unbind();
7926                 itemTemp.removeClass('dateFromyyyy');
7927                 itemTemp.removeClass('dateFromyyyymm');
7928                 itemTemp.removeClass('dateFromyyyymmdd');
7929                 itemTemp.removeClass('dateFromhhmiss');
7930                 ////////console.log(itemTemp);
7931                 var itemDateFromTemp = itemTemp[0].cloneNode(true);
7932                 var $DateFromTemp = "<div id='itemDateFromTemp'></div>"
7933                 itemTemp.after($DateFromTemp);
7934                 itemTemp.remove();
7935                 var DateFromTemp = $("#itemDateFromTemp")[0];
7936                 DateFromTemp.after(itemDateFromTemp);
7937                 DateFromTemp.remove();
7938                 customShow.clickBindSubform();
7939             }
7940         } else if (tag_Type == "radio") {//----------------------------------------------------------todo
7941
7942             // setTimeout(function(){
7943             itemTemp.find('.custom-radio').addClass("readonly");
7944             // },0)
7945         } else if (tag_Type == "checkbox") {//-------------------------------------------------------todo
7946             itemTemp.find('.custom-check').addClass("readonly");
7947         } else if (tag_Type == "dropdownlist") {//---------------------------------------------------OK
7948             // $(itemTemp).addClass('editableDisabled');
7949             // $(itemTemp).prop("disabled", true);        //设置下拉框不可用
7950             // ////console.log($(itemTemp).find(".select-container"));
7951             // itemTemp = $(itemTemp).find(".select-container");
7952             // for(var i = 0 ;i<itemTemp.length;i++){
7953             //   itemTemp[i].setAttribute('readonly','');
7954             // }
7955             console.log($(itemTemp))
7956             $(itemTemp).find('.select-container_box').addClass('disableColor')
7957             $(itemTemp).addClass("readonly");
7958             ////console.log( $(itemTemp));
7959         } else if (tag_Type == "button") {//---------------------------------------------------------OK
7960             $(itemTemp).addClass('disabled');
7961         } else if (tag_Type == "link") {//-----------------------------------------------------------OK
7962             itemTemp.href = "javascript:void(0);";
7963             debugger
7964             for (var i; i < itemTemp.length; i++) {
7965                 itemTemp[i].setAttribute('disabled', 'disabled');
7966             }
7967         } else if (tag_Type == "fileupload") {//----------------------------------------------------todo
7968             console.log($(itemTemp));
7969             debugger
7970         } else if (tag_Type == "tree") {//----------------------------------------------------------todo
7971             // 禁用背景颜色
7972             console.log($(itemTemp).parents('div[name="TreeWin"]'))
7973             console.log($(itemTemp))
7974
7975             itemTemp[0].setAttribute('editable', aliasItem.editable);
7976         }
7977         // else if (tag_Type == "tree" || tag_Type == "tree" || tag_Type == "tree") {
7978         //     //  var itemTemp = $("#customResultFormDiv").find("#"+tag_Id)[0];
7979         //     console.log($(itemTemp))
7980         //     itemTemp.setAttribute('editable', aliasItem.editable);
7981         // }
7982     }
7983 }
7984 //错误信息显示
7985 customShow.setShowMesageErr = function (id, message, N, type) {
7986     console.log("setShowMesageErr");
7987     console.log(message);
7988     ////console.log(id);
5a4f8f 7989     var mesageHtml = '<div class="' + id + 'Popover"></div>';
4d1219 7990     if (customShow.options.customInit.designMode == "1") {
B 7991         ////console.log(id);
7992         ////console.log(message);
7993         ////console.log(N);
7994         ////console.log($($(".customViewUEditorCss  #"+id)[N]));
7995         // $($(".customViewUEditorCss  #"+id)[N]).popover('hide');
a36c19 7996         // if($($(".customViewUEditorCss  #" + id)[N]).attr('popoverFalg') != undefined){
L 7997         //    $('.' + id + 'Popover').html(message);
7998         // }
4d1219 7999         $($(".customViewUEditorCss  #" + id)[N]).attr('popoverFalg','true');
B 8000         $($(".customViewUEditorCss  #" + id)[N]).popover({
8001             // title:"错误信息",
8002             html: true,
a36c19 8003             content: mesageHtml,
4d1219 8004             trigger: 'manual'
B 8005         });
8006         $($(".customViewUEditorCss  #" + id)[N]).hover(function(){// 普通模式 错误提示修改  李伟民 0125
8007             if($($(".customViewUEditorCss  #" + id)[N]).attr('popoverFalg') != 'false'){
8008                 $($(".customViewUEditorCss  #" + id)[N]).popover('show');
a36c19 8009                 $('.' + id + 'Popover').html(message);
4d1219 8010             }
B 8011         },function(){
8012             $($(".customViewUEditorCss  #" + id)[N]).popover('hide');
8013         })
8014         $($(".customViewUEditorCss  #" + id)[N]).on('focus',function(){
8015             $($(".customViewUEditorCss  #" + id)[N]).attr('popoverFalg','false');
8016             $($(".customViewUEditorCss  #" + id)[N]).popover('hide');
8017         })
8018         $($(".customViewUEditorCss  #" + id)[N]).popover('show');
a36c19 8019         $('.' + id + 'Popover').html(message);
4d1219 8020         setTimeout(function(){
B 8021             $($(".customViewUEditorCss  #" + id)[N]).popover('hide');
8022         },2000)
8023         customShow.options.showErrId[id] = N;
8024         //////console.log($($(".customViewUEditorCss  #"+id+"Item")[N]).length);
13ec33 8025
4d1219 8026         if ($($(".customViewUEditorCss  #" + id + "Item")[N]).length == 1) {
B 8027             $($(".customViewUEditorCss  #" + id + "Item")[N]).attr('popoverFalg','true');
8028             $($(".customViewUEditorCss  #" + id + "Item")[N]).popover({
8029                 // title:"错误信息",
8030                 html: true,
a36c19 8031                 content: mesageHtml,
4d1219 8032                 trigger: 'manual'
B 8033             });
8034             $($(".customViewUEditorCss  #" + id + "Item")[N]).popover('show');
a36c19 8035             $('.' + id + 'Popover').html(message);
4d1219 8036             setTimeout(function(){
B 8037                 $($(".customViewUEditorCss  #" + id + "Item")[N]).popover('hide');
8038             },2000)
8039             customShow.options.showErrId[id + "Item"] = N;
8040             $($(".customViewUEditorCss  #" + id + "Item")[N]).hover(function(){
8041                 if($($(".customViewUEditorCss  #" + id + "Item")[N]).attr('popoverFalg') != 'false'){
8042                     $($(".customViewUEditorCss  #" + id + "Item")[N]).popover('show');
a36c19 8043                     $('.' + id + 'Popover').html(message);
4d1219 8044                 }
B 8045             },function(){
8046                 $($(".customViewUEditorCss  #" + id + "Item")[N]).popover('hide');
8047             })
8048             $($(".customViewUEditorCss  #" + id + "Item")[N]).on('focus',function(){
8049                 $($(".customViewUEditorCss  #" + id + "Item")[N]).attr('popoverFalg','false');
8050                 $($(".customViewUEditorCss  #" + id + "Item")[N]).popover('hide');
8051             })// 普通模式 错误提示修改  李伟民 0125
8052         }
13ec33 8053
4d1219 8054     } else {
B 8055         var mesageErrDiv = document.createElement("div");
8056         mesageErrDiv.setAttribute("class", "mesageErrDiv");
8057         mesageErrDiv.setAttribute("id", id + "mesageErrDiv");
8058         if(type){//验证消息 修改  李伟民
8059             $(mesageErrDiv).addClass("checkErr");
8060         }//验证消息 修改  李伟民
8061         $(mesageErrDiv).append(message);
8062         var tempActiveId = $($(".customViewUEditorCss  #" + id + "ActiveId")[N]).find("#" + id + "mesageErrDiv");
8063         $($(".customViewUEditorCss  #" + id + "ActiveId")[N]).find("#" + id + "mesageErrDiv").remove();
8064         // if(tempActiveId.length == 0){
8065         //          if($($(".customViewUEditorCss  #"+id+"ActiveId")[N]).length !=0){
8066         //2017/10/23  李元杰 必选的提示信息修改
8067         var requiredHint = $($($(".customViewUEditorCss  #" + id + "ActiveId")[N])[0]);
8068         if (requiredHint.find('input').val() === '') {
8069             if ($(".customViewUEditorCss  #" + id + "ActiveId").length == 0) {
8070                 console.log($(".customViewUEditorCss [id='" + id + "']:eq(" + N + ")").closest("td"));
8071                 $(".customViewUEditorCss [id='" + id + "']:eq(" + N + ")").closest("td").append(mesageErrDiv);
8072             } else {
8073                 $($($(".customViewUEditorCss  #" + id + "ActiveId")[N])[0]).append(mesageErrDiv);
8074             }
8075             $(mesageErrDiv).html(requiredHint.children('h8').children('span').html() + "必须输入")
8076         } else {
8077             if ($(".customViewUEditorCss  #" + id + "ActiveId").length == 0) {
8078                 console.log($(".customViewUEditorCss [id='" + id + "']:eq(" + N + ")").closest("td"));
8079                 if ($(".customViewUEditorCss [id='" + id + "']:eq(" + N + ")").closest("td").find(".mesageErrDiv").length == 0) {
8080                     $(".customViewUEditorCss [id='" + id + "']:eq(" + N + ")").closest("td").append(mesageErrDiv);
8081                 }
8082             } else {
8083                 if ($($($(".customViewUEditorCss  #" + id + "ActiveId")[N])[0]).find(".mesageErrDiv").length == 0) {
8084                     $($($(".customViewUEditorCss  #" + id + "ActiveId")[N])[0]).append(mesageErrDiv);
8085                 }
8086             }
8087         }
8088         // $(mesageErrDiv).html(requiredHint.children('h8').children('span').html() + "必须输入")
8089         //            }
8090         // }
8091
8092
8093     }
8094
8095 }
8096
8097 //DB数据to画面表示数据转化
8098 customShow.dbItemToShowItem = function (itemId, type, value, showClass, dropdowntype, parentsubFormNum) {
8099     if (type == "radio" || type == "checkbox") {
8100         var itemL = $("." + showClass + " ." + itemId + "value");
8101         //数值变换
8102         //单选按钮,仅仅有一项情况(无子表单时)
8103         if (type == "radio" && itemL.length == 1) {
8104             if (parentsubFormNum != 0) {
8105                 value = value[0];
8106             }
8107             value = [[value]];
8108         } else if (type == "checkbox" && itemL.length == 1) {
8109             //复选框时,仅仅有一项情况(无子表单时)
8110             //只选择一项
8111             if (parentsubFormNum != 0) {
8112                 value = value[0];
8113             }
8114             if (typeof value == "string") {
8115                 value = [[value]];
8116             } else {
8117                 //复数项选择
8118                 value = [value];
8119             }
8120         } else if (type == "radio" && itemL.length > 1) {
8121             //
8122             var valueTempRadio = [];
8123             for (var i = 0; i < value.length; i++) {
8124                 valueTempRadio[i] = [value[i]];
8125             }
8126             value = valueTempRadio;
8127         } else if (type == "checkbox" && itemL.length > 1) {
8128             var valueTempRadio = [];
8129             for (var i = 0; i < value.length; i++) {
8130                 if (typeof value[i] == "string") {
8131                     valueTempRadio[i] = [value[i]];
8132                 } else {
8133                     valueTempRadio[i] = value[i];
8134                 }
8135             }
8136             value = valueTempRadio;
8137         }
8138     } else if (type == "dropdownlistText") {
8139
8140         //多个下拉菜单
8141         var itemList = $("." + showClass + " ." + itemId + "value");
8142         if (itemList.length == 1) {
8143             if (parentsubFormNum != 0) {
8144                 value = value[0];
8145             }
8146             if (typeof value == "string" && dropdowntype == "single") {
8147                 value = [value];
8148             }
8149             //子表单中,复选情况
8150             if (dropdowntype == "multiple") {
8151                 if (typeof value == "string") {
8152                     value = [value];
8153                 } else {
8154                     // value = value[0];
8155                 }
8156             }
8157             // setelect2Item(itemList[0],value);
8158         } else {
8159             for (var i = 0; i < itemList.length; i++) {
8160                 // var valueTemp;
8161                 //单选时,多文件
8162                 if (dropdowntype == "single") {
8163                     value[i] = [value[i]];
8164                 } else {
8165                     // for (var i = 0; i < value[i].length; i++) {
8166                     if (typeof value[i] == "string") {
8167                         value[i] = [value[i]];
8168                     } else {
8169                         value[i] = value[i];
8170                     }
8171                     // }
8172                 }
8173                 // setelect2Item(itemList[i],valueTemp);
8174             }
8175         }
8176     }
8177     return value;
8178 }
8179
8180 //表示模式下,数据设定(单选 复选 下拉菜单)
8181 customShow.setShowItem = function (itemId, type, value, flag) {
8182     //被选择项目设定
8183     console.log(1)
8184     //  console.log(_.cloneDeep(itemId))
8185     //  console.log(_.cloneDeep(type))
8186     console.log(_.cloneDeep(value))
8187     //  console.log(_.cloneDeep(flag))
8188     checkboxRadioShow = function (showItem, value) {
8189         console.log($(showItem), value)
8190         var listData = customBase.options.dropdownlistText[itemId];
8191         if (listData == undefined) {
8192             return;
8193         }
8194         if (typeof value == "string") {
8195             value = [value];
8196             // value = JSON.parse(value)
8197         }
8198         var temp = [];
8199         var tempStr = "";
8200         console.log(listData);
8201         console.log(value)
8202         for (var i = 0; i < listData.length; i++) {
8203             for (var j = 0; j < value.length; j++) {
8204                 if (value[j] == listData[i].value) {
8205                     console.log(1)
8206                     temp[j] = listData[i].text;
8207                 }
8208             }
8209         }
8210         console.log(temp)
8211         for (var i = 0; i < temp.length; i++) {
8212             if (i == 0) {
8213                 tempStr = temp[i];
8214             } else {
8215                 tempStr += "," + temp[i];
8216             }
8217         }
8218         console.log(tempStr)
8219         $(showItem).empty();
8220         //console.log(tempStr);
8221         $(showItem).append(tempStr);
8222
8223     }
8224     var showItem = $("." + itemId + "_showItem");
8225     console.log(showItem)
8226     //页面返回
8227     if (flag) {
8228         if (type == "checkbox" || type == "radio") {
8229             if (showItem.length == 1) {
8230                 checkboxRadioShow(showItem[0], value);
8231             } else {
8232                 for (var i = 0; i < showItem.length; i++) {
8233                     checkboxRadioShow(showItem[i], value[i]);
8234                 }
8235             }
8236         } else {
8237             if (showItem.length == 1) {
8238                 checkboxRadioShow(showItem[0], value);
8239             } else {
8240                 for (var i = 0; i < showItem.length; i++) {
8241                     checkboxRadioShow(showItem[i], value[i]);
8242                 }
8243             }
8244         }
8245     } else {
8246         if (type == "checkbox" || type == "radio") {
8247             for (var i = 0; i < showItem.length; i++) {
8248                 var valueTemp = value[i];
8249                 checkboxRadioShow(showItem[i], valueTemp);
8250             }
8251         } else {
8252             if (showItem.length == 1) {
8253                 checkboxRadioShow(showItem[0], value);
8254             } else {
8255                 for (var i = 0; i < showItem.length; i++) {
8256                     checkboxRadioShow(showItem[i], value[i]);
8257                 }
8258             }
8259         }
8260     }
8261 }
8262
8263 //工具栏设定button
8264 customShow.setToolBtn = function (btns) {
8265     console.log(btns)
8266     $(".edit-pane").empty();
8267     var $editPaneBtn = $($(".edit-pane")[0]);
8268
8269     console.log($editPaneBtn)
8270     //  //////console.log(btns);
8271     for (var i = 0; i < btns.length; i++) {
8272         if (customShow.button[btns[i]].functionName == "") {
8273             $a = '<a id="' + btns[i] + '" href="javascript:void(0);">' +
8274                 '<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>';
8275         } else {
8276             $a = '<a id="' + btns[i] + '" href="javascript:void(0);" onclick="' + customShow.button[btns[i]].functionName + '()">' +
8277                 '<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>';
8278         }
8279         if (customShow.getFormSetting(btns[i]) != 0) {
8280             $editPaneBtn.prepend($a);
8281         }
8282
8283     }
8284     if (btns.length > 0) {
8285         // $(".preview-edit-pane").css("display", "block");
8286     }
8287 }
8288
8289 customShow.setTextBtn = function () {
8290     var item = customShow.options.customItemShow.item["itemId_1"];
8291     var code = item.tag_Attribute.masterData;
8292     var masterData = $.parseJSON(code);
8293     var defindCode = masterData.defindCode;
8294     var eleCode = masterData.eleCode;
8295     customLinkageAnalysis.getElement("itemId_1", eleCode, function (re) {
8296         ////////console.log(re);
8297     })
8298 }
8299
8300 //主数据重复
8301 customShow.setXhSelectList = function (addflag) {
8302     //    console.log(1)
8303     var subformDList = customShow.options.subformDList;
8304     //console.log(subformDList);
8305     //console.log(85244445)
8306     //console.log(addflag)
8307     var setValueItem = {};
8308     //
8309     //var subArr = [];
8310     //_.each(subformDList,opt=>{
8311     //    subArr.push(opt);
8312     //})
8313     //var subObj = {};
8314     //for(var key in subformDList){
8315     //    if(subformDList[key] == _.last(subArr)){
8316     //        subObj[key] = subformDList[key];
8317     //    }
8318     //}
8319     //console.log(_.cloneDeep(subObj));
8320     for (var id in subformDList) {
8321         console.log(id);
8322         if ($(".customViewUEditorCss ." + id).length == 1) {
8323             var xhSelectTemp = {
8324                 selectId: customShow.options.subformDList[id].selectId,
8325                 multiple: customShow.options.subformDList[id].multiple,
8326                 width: customShow.options.subformDList[id].width,
8327                 listData: customBase.options.dropdownlistText[customShow.options.subformDList[id].selectId],
8328                 setDiv: id
8329             };
8330             console.log(xhSelectTemp);
8331             console.log(1)
8332             xhSelect.setXhSelect(xhSelectTemp);
8333             var item = customShow.options.customItemShow.item[customShow.options.subformDList[id].selectId];
8334             setValueItem[item.tag_Attribute.alias] = customShow.options.subformDList[id].selectId;
8335         }
8336     }
8337     console.log(setValueItem);
8338     console.log(customShow.options);
8339     if (!addflag) {
8340         for (var valueItem in setValueItem) {
8341             var setList = customShow.options.subformDValue[valueItem];
8342             console.log(setList);
8343             if (setList != undefined) {
8344                 for (var i = 0; i < setList.length; i++) {
8345                     xhSelect.setValue(setValueItem[valueItem], setList[i], i);
8346                 }
8347             }
8348         }
8349
8350     }
8351 }
8352 //子表单添加记录  复制下拉框方法   2017/10/06
8353 customShow.setXhSelectListAdd = function () {
8354     // //////console.log(table);
8355     var subformDList = customShow.options.subformDList;
8356     var setValueItem = {};
8357     //10/2/27 马习同修改  下拉框复制重复
8358     var xhSelectTemp = {};
8359     for (var id in subformDList) {
8360         if ($(".customViewUEditorCss ." + id).length == 1) {
8361             var xhSelectTemp = {
8362                 selectId: customShow.options.subformDList[id].selectId,
8363                 multiple: customShow.options.subformDList[id].multiple,
8364                 width: customShow.options.subformDList[id].width,
8365                 listData: customBase.options.dropdownlistText[customShow.options.subformDList[id].selectId],
8366                 setDiv: id
8367             };
8368             // //////console.log($(".customViewUEditorCss ."+id).find('select > option'));
8369             if ($(".customViewUEditorCss ." + id).find('select > option').length == 0) {
8370                 // //////console.log("----------------------------------------------");
8371                 console.log(1)
8372                 xhSelect.setXhSelect(xhSelectTemp);
8373             }
8374         }
8375     }
8376     xhSelect.setXhSelect(xhSelectTemp);
8377     //10/2/27 马习同修改  下拉框复制重复
8378 }
8379
8380
8381 customShow.getFormSetting = function (btnFlag) {
8382     var ren = 1;
8383     if (btnFlag == 'printableBtn') {
8384         ren = customShow.options.formsetting['printable'];
8385     } else if (btnFlag == 'exportBtn') {
8386         ren = customShow.options.formsetting['exportable'];
8387     } else if (btnFlag == 'rejectBtn') {
8388         ren = customShow.options.formsetting['rejectable'];
8389     } else if (btnFlag == 'submitBtn') {
8390         ren = customShow.options.formsetting['submitable'];
8391     } else if (btnFlag == 'auditableBtn') {
8392         ren = customShow.options.formsetting['auditable'];
8393     } else if (btnFlag == 'queryBtn') {
8394         ren = customShow.options.formsetting['queryable'];
8395     } else if (btnFlag == 'createBtn') {
8396         ren = customShow.options.formsetting['createable'];
8397     } else if (btnFlag == 'clearBtn') {
8398         // ren = customShow.options.formsetting['clearable'];
8399         ren = 1;
8400     } else if (btnFlag == 'disposableBtn') {
8401         // ren = customShow.options.formsetting['disposable'];
8402         ren = 1;
0da79f 8403     //} else if (btnFlag == 'fromSaveBtn') {
75eb92 8404     //    if(customShow.options.customShowFlag != '3'){//发布修改  李伟民 0120
Z 8405     //        ren = customShow.options.formsetting['saveable'];
8406     //        console.log(ren)
8407     //    }else{
8408     //        ren = 1;
8409     //    }
4d1219 8410         // ren = 1;
B 8411     } else if (btnFlag == 'editableBtn') {
66b6b8 8412         ren = customShow.options.formsetting['editableBtn'];//编辑按钮受权限控制  李伟民 0204
L 8413         // ren = 1;
4d1219 8414     }
B 8415     return ren;
8416
8417 }
8418 var customLinkageAnalysis = customLinkageAnalysis || {};
8419 //-----------------------------------------------------仲追加内容----------------------------------------------------------
8420 customLinkageAnalysis.options = {};
8421 //取得表单值
8422 /**
8423  * 参数:ItemId 字段ID
8424  * 返回值:值
8425  */
8426 customLinkageAnalysis.getValue = function (itemId) {
8427     var item = customShow.options.customItemShow.item[itemId];
8428     var alias = item.tag_Attribute.alias;
8429     var items = customShow.getItems();
8430     var result = items[alias];
8431
8432     if (item.parentsubFormNum != 0) {
8433         for (var ItemId in customShow.options.customItemShow.item) {
8434             if (customShow.options.customItemShow.item[ItemId].columnOrderNum == item.parentsubFormNum) {
8435                 result = items[customShow.options.customItemShow.item[ItemId].tag_Attribute.alias];
8436             }
8437         }
8438         ////console.log(result);
8439         var resultTemp = "";
8440
8441         for (var i = 0; i < result.length; i++) {
8442             if (i > 0) {
8443                 resultTemp += ",";
8444             }
8445             if (typeof result[i][alias] != "string") {
8446                 resultTemp += result[i][alias].join(',');
8447             } else {
8448                 resultTemp += result[i][alias];
8449             }
8450
8451         }
8452         ////console.log(resultTemp);
8453         return resultTemp;
8454     } else if (typeof result != "string") {
8455         result = result.join(',');
8456     }
8457     ////console.log(customShow);
8458     ////console.log(customLinkageAnalysis);
8459     console.log(result);
8460     return result;
8461 }
8462
8463 //设定表单值--------------------
8464 /**
8465  * 参数:ItemId 字段ID
8466  *      value:设定值
8467  */
8468 customLinkageAnalysis.setValue = function (itemId, value, num) {
8469     console.log(itemId);
8470     console.log(value);
8471     var item = customShow.options.customItemShow.item[itemId];
8472     //数据类型
8473     var type = item.tag_Type;
8474     if (type == "text" || type == "textarea" ||
8475         type == "number" || type == "calendar") {
8476         customBase.setItemValue(itemId, "text", value, "", "", num);
8477     } else if (type == "radio" || type == "checkbox") {
8478         if (value.indexOf(",") != -1) {
8479             value = value.split(",");
8480             value = [value];
8481         }
8482         customBase.setItemValue(itemId, type, value, "customViewUEditorCss");
8483     } else if (type == "dropdownlist") {
8484         var dropdowntype = item.tag_Attribute.dropdowntype;
8485         customBase.setItemValue(itemId, "dropdownlistText", value, "customViewUEditorCss", dropdowntype);
8486     } else if (type == "htmlediter") {
8487         var id = itemId + "Item";
8488         UE.getEditor(id).setContent(value);
8489     } else if (type == "qrcode") {
8490         var id = itemId + "qrcode";
8491         customBase.setItemValue(id, 'text', value, 'customViewUEditorCss');
8492         $("#" + id).blur();
8493     } else if (type == "barcode") {
8494         var id = itemId + "barcode";
8495         customBase.setItemValue(id, 'text', value, 'customViewUEditorCss');
8496         $("#" + id).blur();
8497     } else if (type == "tree") {
8498
8499     } else if (type == "amount") {
8500         var id = itemId + "amount";
8501         customBase.setItemValue(id, 'text', value, 'customViewUEditorCss');
8502         $("#" + id).blur();
8503     }
8504
8505 }
8506
8507 //取得属性
8508 /**
8509  * 参数:ItemId 字段ID
8510  *      attributeName:属性名
8511  *                  visible  //可见                     true:可见  false:不可见
8512                     editable //可编辑                   true:可编辑  false:不可编辑
8513  */
8514 customLinkageAnalysis.getAttribut = function (itemId, attributeName) {
8515     console.log(itemId);
8516     console.log(attributeName)
8517     var item = customShow.options.customItemShow.item[itemId];
8518     // return customLinkageAnalysis.validationEx(item.tag_Attribute.alias);
8519     var alias = item.tag_Attribute.alias;
8520     var ttn = customBase.options.customItems[alias][attributeName];
8521     ////console.log(ttn)
8522     return ttn;
8523 }
8524
8525 //设定属性---------------需要测试-----
8526 /**
8527  * 参数:ItemId 字段ID
8528  *      attributeName:属性名
8529  *                  visible  //可见                     true:可见  false:不可见
8530                     editable //可编辑                   true:可编辑  false:不可编辑
8531  */
8532 customLinkageAnalysis.setAttribut = function (itemId, attributeName, attributeValue) {
8533     var item = customShow.options.customItemShow.item[itemId];
8534     // return customLinkageAnalysis.validationEx(item.tag_Attribute.alias);
8535     var alias = item.tag_Attribute.alias;
8536     console.log(alias)
8537     attributeValue = attributeValue + "";
8538     attributeValue = attributeValue.toLowerCase();
8539     if (attributeValue == "true") {
8540         attributeValue = true;
8541     } else if (attributeValue == "false") {
8542         attributeValue = false;
8543     } else {
8544         //默认值
8545         attributeValue = true;
8546     }
8547     customBase.options.customItems[alias][attributeName] = attributeValue;
8548     customShow.setShowAttribute(customBase.options.customItems[alias]);
8549 }
8550
8551 //设定错误信息
8552 /**
8553  * 参数:ItemId 字段ID
8554  *      message:信息
8555  */
8556 customLinkageAnalysis.setMessage = function (mode, ItemId, message, num) {
8557     var item = customShow.options.customItemShow.item[ItemId];
8558     var type = item.tag_Type;
8559     if (num == undefined) {
8560         num = 0;
8561     }
8562     var errorClass;
8563     if (mode == "0") {//验证消息 修改  李伟民
8564         errorClass = "errorCheckCss"
8565     } else {
8566         errorClass = "errorItemCss";
8567     }//验证消息 修改  李伟民
8568     customShow.showErrorItem(errorClass, type, ItemId, num);
8569     //焦点事件
8570     // $("." + errorClass).unbind('focus');
8571     $("[id='" + ItemId + "']:eq(" + num + ")").unbind("focus");
8572     $("[id='" + ItemId + "']:eq(" + num + ")").on('focus', function () {
8573         console.log("focus");
8574         $(this).removeClass(errorClass);
8575         ////////console.log($(this)[0].id);
8576         $(this).closest("#" + $(this)[0].id + "ActiveId").find("[id='" + $(this)[0].id + "mesageErrDiv']").remove();//修改错误信息删除  李伟民  2017-10-18 14:15
8577         $(this).closest(".tdContentClass").find("[id='" + $(this)[0].id + "mesageErrDiv']").remove();//列表模式
8578         //        $("#"+$(this)[0].id+"mesageErrDiv").remove();
8579         $(".customViewUEditorCss  #" + $(this)[0].id).popover('hide')
8580     });
8581     //下拉列表点击事件
8582     $(".select2-search__field").unbind("focus");
8583     $(".select2-search__field").bind("focus", function () {
8584         var id = this.getAttribute("errorItemId");
8585         var N = this.getAttribute("N");
8586         $($('.customViewUEditorCss #' + id)[N].parentNode).find(".select2").removeClass(errorClass);
8587         $("#" + id + "mesageErrDiv").remove();
8588         $($(".customViewUEditorCss  #" + id)[N]).popover('hide')
8589     });
8590     if (mode == "0") {//验证消息 修改  李伟民
8591         customShow.setShowMesageErr(ItemId, message, num, true);
8592     } else {
8593         customShow.setShowMesageErr(ItemId, message, num);
8594     }//验证消息 修改  李伟民
13ec33 8595
4d1219 8596 }
B 8597
8598 //设定alert信息
8599 //参数:type类型
8600 // E:错误信息
8601 // I:信息
8602 // W:警告
8603 // S:成功
8604 //  message:信息
8605 customLinkageAnalysis.alert = function (type, message) {
8606     customBase.alert(type, message);
8607 }
8608
8609
8610
8611 // 初期调用
8612 customLinkageAnalysis.bindLinkage = function () {
8613     //    ////console.log(window.customBase);
8614     //取得公式的JSON数据
8615     //  ////console.log(customShow);
8616     //  ////console.log(customLinkageAnalysis);
8617     var rules = customShow.options.jsonLinkage;
8618     if (typeof rules == 'string') {
8619         rules = eval(rules);
8620     }
8621     if (rules == null || rules.length == 0) {
8622         return;
8623     }
8624     //初期接口 (false:不继续执行 true:继续执行)
8625     // customShow.initEvent.interfaceInitLinkage;
8626
8627     //取消接口 (false:不继续执行 true:继续执行)
8628     // customShow.initEvent.cancelEventLinkage;
8629
8630     //保存接口 (false:不继续执行 true:继续执行)
8631     // customShow.initEvent.fromSaveLinkage;
8632     for (var i = 0; i < rules.length; i++) {
8633         //console.log(rules[i]);
8634         var dofunction = {};
8635         try {
8636             dofunction = customLinkageAnalysis.makeLinkage(rules[i]);
8637         } catch (e) {
8638             ////console.log(e.message);
8639             continue;
8640         }
8641         var allFunction = customLinkageAnalysis.changeDoFunction(dofunction);
8642         var fieldId = rules[i].event.eventFieldId;
8643         if (fieldId == "_body" && rules[i].event.doEvent == "loading") {
8644             customShow.initEvent.interfaceInitLinkage = customLinkageAnalysis.bindFunctionEvent(allFunction.strFunction);
8645         } else if (fieldId == "_body" && rules[i].event.doEvent == "commit") {
8646             customShow.initEvent.fromSaveLinkage = customLinkageAnalysis.bindFunctionEvent(allFunction.strFunction);
8647         }
8648         var item = customShow.options.customItemShow.item[fieldId];
8649         if (item != undefined) {
8650             var doEvent = rules[i].event.doEvent;
8651             doEvent = doEvent.replace("selectedChange", "change");
8652             if (item.tag_Type == "radio" || item.tag_Type == "checkbox") {
8653                 doEvent = doEvent.replace("change", "click");
8654             }
8655             if (item.tag_Type == "amount" || item.tag_Type == "qrcode" || item.tag_Type == "barcode") {
8656                 fieldId = fieldId + item.tag_Type;
8657             }
8658             if (item.tag_Type == "htmlediter") {
8659                 UE.getEditor(fieldId + "Item").onclick = function (event, ui) {
8660                     // eval(strFunction);
8661                     // ////console.log(UE.getEditor(fieldId+"Item").getContent());
8662                     customLinkageAnalysis.options[fieldId + "Item"] = UE.getEditor(fieldId + "Item").getContent();
8663                 }
8664                 UE.getEditor(fieldId + "Item").onblur = function (event, ui) {
8665                     //////console.log(UE.getEditor(fieldId+"Item").getContent());
8666                     var fieldIdItem = UE.getEditor(fieldId + "Item").getContent();
8667                     if (fieldIdItem != customLinkageAnalysis.options[fieldId + "Item"]) {
8668                         eval(allFunction.strFunction);
8669                     }
8670
8671                 }
8672                 ////console.log(UE.getEditor(fieldId+"Item"));
8673             } else if (item.tag_Type == "tree") {
8674                 customBase.options.zTreeOnClickItems[fieldId + "tree"] = allFunction.strFunction;
8675             } else if (item.tag_Type == "radio" || item.tag_Type == "checkbox") {
8676
8677             } else {
8678                 customLinkageAnalysis.bindEvent(fieldId, doEvent, allFunction);
8679             }
8680
8681         }
8682         _.each(rules[i].results, function (ru) {// 自定义验证 为弹出消息控件绑定验证方法 李伟民 2017-10-18 15:09
8683             if ((ru.mode == "2" || ru.mode == "0") && rules[i].event.eventFieldId != ru.eventFieldId) {//判断是否为验证公式 判断触发控件与弹出消息控件是否为同一控件
8684                 //console.log(ru);
8685                 customLinkageAnalysis.bindEvent(ru.eventFieldId, "blur", allFunction);
8686             }
8687         });// 自定义验证 为弹出消息控件绑定验证方法 李伟民 2017-10-18 15:09 end
8688     }
8689 }
8690
8691
8692 // 子控件事件调用时
8693 customLinkageAnalysis.bindLinkageSubform = function (inType) {
8694     //取得公式的JSON数据
8695     var rules = customShow.options.jsonLinkage;
8696     if (typeof rules == 'string') {
8697         rules = eval(rules);
8698     }
8699     if (rules == null || rules.length == 0) {
8700         return;
8701     }
8702     // if("calendar" == inType){
8703     //     $("#"+fieldId).unbind();
8704     // }
8705     for (var i = 0; i < rules.length; i++) {
8706         var dofuncion = "";
8707         try {
8708             dofuncion = customLinkageAnalysis.makeLinkage(rules[i]);
8709         } catch (e) {
8710             ////console.log(e.message);
8711             continue;
8712         }
8713         var fieldId = rules[i].event.eventFieldId;
8714         var item = customShow.options.customItemShow.item[fieldId];
8715         var strFunction = customLinkageAnalysis.changeDoFunction(dofuncion);
8716         if (item != undefined) {
8717             var doEvent = rules[i].event.doEvent;
8718             doEvent = doEvent.replace("selectedChange", "change");
8719             // if (item.tag_Type == "radio" || item.tag_Type == "checkbox") {
8720             //     // doEvent = doEvent.replace("change", "click");
8721             // }
8722             if (inType == item.tag_Type) {
8723                 if (item.tag_Type == "radio") {
8724                     $("#" + fieldId + ' .custom-radio').on('click', function () {
8725                         // //////console.log(this.className);
8726                         if (this.className.indexOf("readonly") > -1) {
8727                             return;
8728                         }
8729                         eval(strFunction);
8730                     });
8731                 } else if (item.tag_Type == "checkbox") {
8732                     $("#" + fieldId + ' .custom-check').on('click', function () {
8733                         // //////console.log(this.className);
8734                         if (this.className.indexOf("readonly") > -1) {
8735                             return;
8736                         }
8737                         eval(strFunction);
8738                     });
8739                 } else {
8740                     customLinkageAnalysis.bindEvent(fieldId, doEvent, strFunction);
8741                 }
8742
8743             }
8744         }
8745     }
8746 }
8747
8748 customLinkageAnalysis.bindFunctionEvent = function (strFunction) {
8749     //console.log(strFunction);
8750     return function () {
8751         try {
8752             eval(strFunction);
8753         } catch (e) {
8754             ////console.log(e.message);
8755         }
8756     }
8757 }
8758
8759 customLinkageAnalysis.changeDoFunction = function (doFunction) {
8760     var conditionCode = doFunction.conditionCode;
8761     //console.log(doFunction);
8762     var code = "";
8763     var strFunction = "";
8764     var checkFunction = "";// 单独检查校验规则代码  李伟民 2017-10-19 14:33
8765     if (conditionCode != null) {
8766         code = conditionCode.code
8767         var conditionListCode = conditionCode.listCode;
8768
8769         for (var i = 0; i < conditionListCode.length; i++) {
8770             strFunction += "var code" + i + " = " + conditionListCode[i] + ";\r\n";
8771             checkFunction += "var code" + i + " = " + conditionListCode[i] + ";\r\n";// 单独检查校验规则代码  李伟民 2017-10-19 14:33
8772             var reg = new RegExp('\\{' + i + '\\}', "g");
8773             code = code.replace(reg, "\"+customLinkageAnalysis.changeEvalType(eval('code" + i + "'))+\"");
8774         }
8775         for (var i = 0; i < conditionListCode.length; i++) {
8776             var reg = new RegExp('\\{' + i + '\\}', "g");
8777             strFunction = strFunction.replace(reg, "code" + i);
8778             checkFunction = strFunction.replace(reg, "code" + i);// 单独检查校验规则代码  李伟民 2017-10-19 14:33
8779         }
8780         if (conditionCode.clearCode != undefined) {//添加清空错误信息  李伟民 2017-10-18 17:45
8781             _.each(conditionCode.clearCode, function (_clearCode) {
8782                 strFunction += _clearCode;
8783                 checkFunction += _clearCode;// 单独检查校验规则代码  李伟民 2017-10-19 14:33
8784             })
8785         }//添加清空错误信息  李伟民 2017-10-18 17:45 end
8786         if (code != null && code != "") {
8787             if (code.indexOf('Math.floor') != -1) {
8788                 code = eval(code);
8789                 ////console.log(code);
8790             }
8791             code = "customLinkageAnalysis.expeval(\"=" + code + "\")";
8792             strFunction += "if (" + code + " == 'true') { \r\n";
8793             checkFunction += "if (" + code + " == 'true') { \r\n";// 单独检查校验规则代码  李伟民 2017-10-19 14:33
8794         }
8795     }
8796     var results = doFunction.results;
8797     for (var i = 0; i < results.length; i++) {
8798         var resultValue = results[i].resultValue;
8799         var resultJsText = results[i].resultJsText;
8800         if (resultValue != null) {
8801             var listCode = resultValue.listCode;
8802             var resultCode = resultValue.code;
8803             for (var j = 0; j < listCode.length; j++) {
8804                 strFunction += "var resultCode" + j + " = " + listCode[j] + ";\r\n";
8805                 var reg = new RegExp('\\{' + j + '\\}', "g");
8806                 ////console.log(resultCode);
8807                 resultCode = resultCode.replace(reg, "\"+customLinkageAnalysis.changeEvalType(eval('resultCode" + j + "'))+\"");
8808             }
8809             for (var j = 0; j < listCode.length; j++) {
8810                 var reg = new RegExp('\\{' + j + '\\}', "g");
8811                 strFunction = strFunction.replace(reg, "resultCode" + j);
8812             }
8813             //          if(resultCode.indexOf('Math.floor') != -1){
8814             ////console.log(resultCode);
8815             //                  resultCode = eval(resultCode);
8816             //              }
8817             //console.log(resultCode);
8818             resultCode = "customLinkageAnalysis.expeval(\"=" + resultCode + "\")";
8819             strFunction += resultJsText.replace(/\{0\}/g, resultCode);
8820         } else if (results[i].resultJsText.indexOf("setMessage")) {// 判断是否为 规则校验公式
8821             strFunction += resultJsText + "; \r\n";
8822             checkFunction += resultJsText + "; \r\n";// 单独检查校验规则代码  李伟民 2017-10-19 14:33
8823         } else {
8824             strFunction += resultJsText + "; \r\n";
8825         }
8826         //公式联动追加
8827         if (results[i].doEvent != undefined && results[i].resultJsText.indexOf("setValue") != -1) {
8828             strFunction += '$("#' + results[i].targetid + '").trigger("' + results[i].doEvent + '.value");';
8829         }
8830
8831         //公式联动追加结束
8832
8833     }
8834
8835     if (code != null && code != "") {
8836         strFunction += "}";
8837         checkFunction += "}";// 单独检查校验规则代码  李伟民 2017-10-19 14:33
8838     }
8839     ////console.log(strFunction);
8840     var allFunction = { "strFunction": strFunction, "checkFunction": checkFunction };
8841     return allFunction;
8842 }
8843
8844 function funCheck(optarr, allFunction) {//判断是否重复绑定方法
8845     var flag = true;
8846     if (optarr != undefined && optarr != '') {
8847         optarr = JSON.parse(optarr);
8848         console.log(optarr);
8849         console.log(allFunction);
8850         _.each(optarr, function (fn) {
8851             if (fn.strFunction == allFunction.strFunction && fn.checkFunction == allFunction.checkFunction) {
8852                 console.log("falg false");
8853                 flag = false;
8854             }
8855         })
8856     }
8857     return flag;
8858 }
8859
8860 customLinkageAnalysis.bindEvent = function (fieldId, doEvent, allFunction) {//aaaaaa
8861     console.log(allFunction);
8862     var evalstr = "";
8863     var evalchekstr = "";
8864     ////console.log(customShow.options.customItemShow.item[fieldId].tag_Type);
8865     if (customShow.options.customItemShow.item[fieldId].tag_Type == "dropdownlist") {
8866         ////console.log($("[id='" + fieldId+"']"));
8867         ////console.log($("[id='" + fieldId+"']").find(".select_get"));
8868         ////console.log($(".select_get"));
8869         ////console.log(strFunction);
8870         _.each($("[id='" + fieldId + "']").find(".select_get"),function(opt){
8871             var optarr = $(opt).attr("funarr");
8872             if(funCheck(optarr,allFunction)){
8873                 $(opt).on(doEvent + ".value", function () {
8874             if (customShow.options.customItemShow.item[fieldId].parentsubFormNum != 0) {
8875                 // _.each($("[id='" + fieldId + "']").find(".select_get"), (item, i) => {
8876                     if (allFunction.strFunction.indexOf("var i=") == -1) {
8877                         ////console.log(i);
8878                         evalstr = "var i=" + $("[id='" + fieldId + "']").find(".select_get").index(this) + ";" + allFunction.strFunction;
8879                     }
8880                 // })
8881             }else{
8882                 evalstr = allFunction.strFunction;
8883             }
8884             try {
8885                 console.log(evalstr);
8886                 eval(evalstr);
8887             } catch (e) {
8888                 ////console.log(e.message);
8889             }
8890         });
8891                 var funarr;
8892                 if($(opt).attr("funarr") == undefined || $(opt).attr("funarr") == ""){
8893                     funarr = [allFunction];
8894                 }else{
8895                     funarr = JSON.parse($(opt).attr("funarr"));
8896                     funarr.push(allFunction);
8897                 }
8898                 $(opt).attr("funarr",JSON.stringify(funarr));
8899             }
8900             var checkarr = $(opt).attr("checkfunarr");
8901             if(funCheck(checkarr,allFunction)){
8902                 $(opt).on(doEvent + ".check", function () {//单独检验校验规则绑定  李伟民 2017-10-19 15:18
8903             if (customShow.options.customItemShow.item[fieldId].parentsubFormNum != 0) {
8904                 // _.each($("[id='" + fieldId + "']").find(".select_get"), (item, i) => {
8905                     if (allFunction.checkFunction.indexOf("var i=") == -1) {
8906                         evalchekstr = "var i=" +  $("[id='" + fieldId + "']").find(".select_get").index(this) + ";" + allFunction.checkFunction;
8907                     }
8908                 // })
8909             }else{
8910                 evalchekstr = allFunction.checkFunction;
8911             }
8912             try {
8913                 eval(evalchekstr);
8914             } catch (e) {
8915                 //console.log(e.message);
8916             }
8917         });//单独检验校验规则绑定  李伟民 2017-10-19 15:18 end
8918                 var checkfunarr;
8919                 if($(opt).attr("checkfunarr") == undefined || $(opt).attr("checkfunarr") == ""){
8920                     checkfunarr = [allFunction];
8921                 }else{
8922                     checkfunarr = JSON.parse($(opt).attr("checkfunarr"));
8923                     checkfunarr.push(allFunction);
8924                 }
8925                 $(opt).attr("checkfunarr",JSON.stringify(checkfunarr));
8926             }
13ec33 8927
4d1219 8928         });
B 8929         // $("[id='" + fieldId + "']").find(".select_get").on(doEvent + ".value", function () {
8930         //     if (customShow.options.customItemShow.item[fieldId].parentsubFormNum != 0) {
8931         //         // _.each($("[id='" + fieldId + "']").find(".select_get"), (item, i) => {
8932         //             if (allFunction.strFunction.indexOf("var i=") == -1) {
8933         //                 ////console.log(i);
8934         //                 evalstr = "var i=" + $("[id='" + fieldId + "']").find(".select_get").index(this) + ";" + allFunction.strFunction;
8935         //             }
8936         //         // })
8937         //     }else{
8938         //         evalstr = allFunction.strFunction;
8939         //     }
8940         //     try {
8941         //         console.log(evalstr);
8942         //         eval(evalstr);
8943         //     } catch (e) {
8944         //         ////console.log(e.message);
8945         //     }
8946         // });
8947         // $("[id='" + fieldId + "']").find(".select_get").unbind(doEvent + ".check");
8948         // $("[id='" + fieldId + "']").find(".select_get").on(doEvent + ".check", function () {//单独检验校验规则绑定  李伟民 2017-10-19 15:18
8949         //     if (customShow.options.customItemShow.item[fieldId].parentsubFormNum != 0) {
8950         //         // _.each($("[id='" + fieldId + "']").find(".select_get"), (item, i) => {
8951         //             if (allFunction.checkFunction.indexOf("var i=") == -1) {
8952         //                 evalchekstr = "var i=" +  $("[id='" + fieldId + "']").find(".select_get").index(this) + ";" + allFunction.checkFunction;
8953         //             }
8954         //         // })
8955         //     }else{
8956         //         evalchekstr = allFunction.checkFunction;
8957         //     }
8958         //     try {
8959         //         eval(evalchekstr);
8960         //     } catch (e) {
8961         //         //console.log(e.message);
8962         //     }
8963         // });//单独检验校验规则绑定  李伟民 2017-10-19 15:18 end
8964     } else {
8965         // $("[id='" + fieldId + "']").unbind(doEvent + ".value");
8966         _.each($("[id='" + fieldId + "']"),function(opt){
8967             var optarr = $(opt).attr("funarr");
8968                 if(funCheck(optarr,allFunction)){
8969                     $(opt).on(doEvent + ".value", function () {
8970             if (customShow.options.customItemShow.item[fieldId].parentsubFormNum != 0 && allFunction.strFunction.indexOf("getSum") == -1) {
8971                 console.log($("[id='" + fieldId + "']"));
8972                 console.log($(this));
8973                 console.log($("[id='" + fieldId + "']").index(this));
8974                 // _.each($("[id='" + fieldId + "']"), (item, i) => {
8975                     // console.log($(item));
8976                     if (allFunction.strFunction.indexOf("var i=") == -1) {
8977                         ////console.log(i);
8978                         evalstr = "var i=" + $("[id='" + fieldId + "']").index(this) + ";" + allFunction.strFunction;
8979                     }
8980                 // })
8981             }else if(allFunction.strFunction.indexOf("getSum") > 0){
8982                 console.log(allFunction.strFunction);
8983                 console.log("replace");
8984                 evalstr = allFunction.strFunction;
8985                 // allFunction.strFunction = allFunction.strFunction.replace(new RegExp(".split(',')[i]") ,"");
8986                 while(evalstr.indexOf(".split(',')[i]") != -1){
8987                     evalstr = evalstr.replace(".split(',')[i]","");
8988                 }
8989             }else{
8990                 evalstr = allFunction.strFunction;
8991             }
8992             // try {
8993                 console.log(evalstr);
8994                 eval(evalstr);
8995             // } catch (e) {
8996             //     ////console.log(e.message);
8997             // }
8998         });
8999                 var funarr;
9000                 if($(opt).attr("funarr") == undefined || $(opt).attr("funarr") == ""){
9001                     funarr = [allFunction];
9002                 }else{
9003                     funarr = JSON.parse($(opt).attr("funarr"));
9004                     funarr.push(allFunction);
9005                 }
9006                 $(opt).attr("funarr",JSON.stringify(funarr));
13ec33 9007
4d1219 9008             };
B 9009             var checkarr = $(opt).attr("checkfunarr");
9010             if(funCheck(checkarr,allFunction)){
9011                 $(opt).on("blur.check", function () {//单独检验校验规则绑定  李伟民 2017-10-19 15:18
9012             if (customShow.options.customItemShow.item[fieldId].parentsubFormNum != 0) {
9013                         console.log("change.check");
9014                 _.each($("[id='" + fieldId + "']"), (item, i) => {
9015                     if (allFunction.checkFunction.indexOf("var i=") == -1) {
9016                         ////console.log(i);
9017                         evalchekstr = "var i=" + $("[id='" + fieldId + "']").index(this) + ";" + allFunction.checkFunction;
9018                     }
9019                 })
9020             }else{
9021                 evalchekstr = allFunction.checkFunction;
9022             }
9023             try {
9024                 if(evalchekstr.indexOf('alert') == -1){
9025                     eval(evalchekstr);
9026                 }
9027             } catch (e) {
9028                 ////console.log(e.message);
9029             }
9030         });//单独检验校验规则绑定  李伟民 2017-10-19 15:18 end
9031                 var checkfunarr;
9032                 if($(opt).attr("checkfunarr") == undefined || $(opt).attr("checkfunarr") == ""){
9033                     checkfunarr = [allFunction];
9034                 }else{
9035                     checkfunarr = JSON.parse($(opt).attr("checkfunarr"));
9036                     checkfunarr.push(allFunction);
9037     }
9038                 $(opt).attr("checkfunarr",JSON.stringify(checkfunarr));
9039             }
13ec33 9040
4d1219 9041         });
B 9042         // $("[id='" + fieldId + "']").unbind(doEvent + ".check");
9043         // $("[id='" + fieldId + "']").on(doEvent + ".check", function () {//单独检验校验规则绑定  李伟民 2017-10-19 15:18
9044         //     if (customShow.options.customItemShow.item[fieldId].parentsubFormNum != 0) {
9045         //         console.log("change.check");
9046         //         _.each($("[id='" + fieldId + "']"), (item, i) => {
9047         //             if (allFunction.checkFunction.indexOf("var i=") == -1) {
9048         //                 ////console.log(i);
9049         //                 evalchekstr = "var i=" + $("[id='" + fieldId + "']").index(this) + ";" + allFunction.checkFunction;
9050         //             }
9051         //         })
9052         //     }else{
9053         //         evalchekstr = allFunction.checkFunction;
9054         //     }
9055         //     try {
9056         //         eval(evalchekstr);
9057         //     } catch (e) {
9058         //         ////console.log(e.message);
9059         //     }
9060         // });//单独检验校验规则绑定  李伟民 2017-10-19 15:18 end
9061     }
9062 }
9063
9064 customLinkageAnalysis.changeEvalType = function (str) {
9065     console.log(str);
624ff8 9066     if (isNaN(Number(str)) && (str.substring(0, 1) != "\"" || str.substring(str.length - 1, 1) != "\"") && (str.indexOf('||') != -1) && (str.indexOf('&&') != -1)) {//|| && 修改 李伟民 公式不稳定修改 0202 
4d1219 9067         return "'" + str + "'";
B 9068     } else {
9069         ////console.log(str);
9070         return str;
9071     }
9072 }
9073
9074 //事件绑定调用
9075 //事件绑定:字段ID:ItemId 事件名 自定义事件名
9076 //参数
9077 // eventItem=[{
9078 //     ItemId:"Item_1", 控件id
9079 //     event:"click",  事件
9080 //     eventmethod:"XXXXXXXXXXXXXXXXXXXX"   自定义事件名
9081 // }]
9082 customLinkageAnalysis.setEventBind = function (eventItem) {
9083     customShow.setEventBindItem(eventItem);
9084 }
9085 //03检证执行(接口)
9086 customLinkageAnalysis.validationEx = {
9087     get: function (alias) {
9088         var itemTempS;
9089         var item = customBase.options.customItems[alias];
9090         if (item.type == "button" || item.type == "link") {
9091         } else if (item.type == "dropdownlist") {
9092             var datasourcetype = $("#" + item.id)[0].getAttribute("datasourcetype");
9093             //////////console.log(datasourcetype);
9094             //主数据源
9095             if (datasourcetype == "masterdata") {
9096                 itemTempS = customBase.getItemValue(item.id, item.type);
9097                 //数据源
9098             } else if (datasourcetype == "datasource") {
9099                 itemTempS = customBase.getItemValue(item.id, "dropdownlistText");
9100                 //自定义
9101             } else if (datasourcetype == "custom") {
9102                 itemTempS = customBase.getItemValue(item.id, "dropdownlistText");
9103                 //API接口
9104             } else if (datasourcetype == "api") {
9105                 itemTempS = customBase.getItemValue(item.id, item.type);
9106             }
9107         } else if (item.type == "subform") {
9108
9109         } else {
9110             itemTempS = customBase.getItemValue(item.id, item.type);
9111         }
9112         item.value = itemTempS;
9113         ////////console.log(item);
9114         return item;
9115     }
9116 }
9117 //取得主数据
9118 /*
9119 itemId:项目ID
9120 masterCode:执行CODE
9121 返回值:元素的值
9122 */
9123 customLinkageAnalysis.getElement = function (itemId, masterCode, num) {
9124     var item = customShow.options.customItemShow.item[itemId];
9125     var code = item.tag_Attribute.masterData;
9126     var masterData = $.parseJSON(code);
9127     var defindCode = masterData.defindCode;
9128     var eleCode = masterData.eleCode;
9129     var eleValue = customLinkageAnalysis.getValue(itemId);
9130     if(num != undefined && eleValue != undefined && eleValue.indexOf(',') != -1){//子表单中控件处理  李伟民  0106
9131         eleValue = eleValue.split(',')[num];
9132     }
9133     var opt = {
9134         eleCode: eleCode,
9135         defindCode: defindCode,
9136         eleValue: eleValue,
9137         masterCode: masterCode,
9138         itemId: itemId
9139     }
9140     //主数据取得
9141     var result = customDataBound.getElement1(opt);
9142     console.log(result);
9143     console.log(itemId)
9144     if (result.rspCode == "000000") {
9145         if (result.data[itemId].length > 0) {
9146             console.log(result.data[itemId][0].value)
9147             return result.data[itemId][0].value;
9148         } else {
9149             return "";
9150         }
9151     } else {
9152         return "";
9153     }
9154 }
9155
9156 customLinkageAnalysis.clearMessage = function (itemId, num) {//清空错误信息方法  李伟民 2017-10-18 16:36
9157     if (num == undefined) {
9158         num = 0;
9159     }
9160     //console.log($("[id='"+itemId+"']:eq("+num+")"));
9161     //console.log($("[id='"+itemId+"ActiveId']:eq("+num+")"));
9162     $("[id='" + itemId + "']:eq(" + num + ")").removeClass("errorItemCss");
9163     $("[id='" + itemId + "']:eq(" + num + ")").removeClass("errorCheckCss");
9164     $("[id='" + itemId + "ActiveId']:eq(" + num + ")").find("#" + itemId + "mesageErrDiv").remove();
9165 }//清空错误信息方法  李伟民 2017-10-18 16:36 end
9166
9167 customLinkageAnalysis.makeLinkage = function (rule) {
9168     ////console.log(rule);
9169     var result = {};
9170     var conditionCode = {};
9171     conditionCode = customLinkageAnalysis.changeCodeMirror(rule.conditionCode, rule.conditionHistory._history);
9172
9173     if (rule.conditionCode != "" && !_.isNull(rule.conditionCode)) {//清空错误信息  李伟民 2017-10-18 16:36
9174         var clearCode = [];
9175         _.each(rule.results, function (ru) {
9176             if (ru.mode == "2") {
9177                 var ruItem = customShow.options.customItemShow.item[ru.eventFieldId];
9178                 if (ruItem.parentsubFormNum != 0) {
9179                     clearCode.push("customLinkageAnalysis.clearMessage('" + ru.eventFieldId + "',i);");
9180                 } else {
9181                     clearCode.push("customLinkageAnalysis.clearMessage('" + ru.eventFieldId + "');");
9182                 }
9183             }
9184         });
9185         conditionCode["clearCode"] = clearCode;
9186     }//清空错误信息  李伟民 2017-10-18 16:36 end
9187
9188     var results = new Array();
9189     for (var i = 0; i < rule.results.length; i++) {
9190         var resultJs = {};
9191         var textType = rule.results[i].attribute;
9192         var resultJsText = "";
9193         var resultTargrtItem = customShow.options.customItemShow.item[rule.results[i].eventFieldId]; if ("1" == rule.results[i].mode) {
9194             var resultValue = customLinkageAnalysis.changeCodeMirror(rule.results[i].code, rule.results[i].eventHistory._history);
9195             resultJs.resultValue = resultValue;
9196             if (textType == 'value') {
9197                 if (resultTargrtItem.parentsubFormNum != 0) {
9198                     resultJsText += "customLinkageAnalysis.setValue('" + rule.results[i].eventFieldId + "', {0}, i);";
9199                 } else {
9200                     resultJsText += "customLinkageAnalysis.setValue('" + rule.results[i].eventFieldId + "', {0});";
9201                 }
9202             } else if (textType == 'visible' || textType == 'editable') {
9203                 resultJsText += "customLinkageAnalysis.setAttribut('" + rule.results[i].eventFieldId + "','" + textType + "', {0});";
9204             } else {
9205                 // todo
9206             }
9207         } else if ("2" == rule.results[i].mode || "0" == rule.results[i].mode) {
9208             if (resultTargrtItem.parentsubFormNum != 0) {//自定义校验支持子表单中控件  李伟民 2017-10-18 14:34
9209                 //              resultJsText += "customLinkageAnalysis.clearMessage('" + rule.results[i].eventFieldId + "',i);";
9210                 resultJsText += "customLinkageAnalysis.setMessage('" + rule.results[i].mode + "','" + rule.results[i].eventFieldId + "','" + rule.results[i].message + "',i);";
9211             } else {
9212                 //              resultJsText += "customLinkageAnalysis.clearMessage('" + rule.results[i].eventFieldId + "');";
9213                 resultJsText += "customLinkageAnalysis.setMessage('" + rule.results[i].mode + "','" + rule.results[i].eventFieldId + "','" + rule.results[i].message + "');";
9214             }//自定义校验支持子表单中控件  李伟民 2017-10-18 14:34 end
9215
9216         } else if ("3" == rule.results[i].mode) {
9217             resultJsText += "customLinkageAnalysis.alert('" + rule.results[i].messageType + "','" + rule.results[i].message + "');";
9218         } else {
9219             ;
9220         }
9221         resultJs.resultJsText = resultJsText;
9222         resultJs.targetid = rule.results[i].eventFieldId;// 公式联动追加 目标控件
9223         var targetDoEvent = '';
9224         //      ////console.log(customShow.options.jsonLinkage);
9225         var jsonLinkage_add = customShow.options.jsonLinkage;//预览公式联动修改 李伟民 0117
9226         if (_.isString(jsonLinkage_add)) {
9227             jsonLinkage_add = JSON.parse(jsonLinkage_add);
9228         }
9229         _.each(jsonLinkage_add, function (allrule) {// 公式联动追加 目标控件事件
9230             if (allrule.event.eventFieldId == resultJs.targetid) {
9231                 resultJs.doEvent = allrule.event.doEvent;
9232             }
9233         });
9234         results.push(resultJs);
9235     }
9236     result.conditionCode = conditionCode;
9237     result.results = results;
9238     ////console.log(result);
9239     return result;
9240 }
9241
9242 customLinkageAnalysis.reachLeftSpace = function (str, length) {
9243     var result = str;
9244     if (str.length < length) {
9245         var spaceLen = length - str.length;
9246         for (var i = 0; i < spaceLen; i++) {
9247             result = " " + result;
9248         }
9249     }
9250     return result;
9251 }
9252
9253 customLinkageAnalysis.replace = function (str, stringObj, replaceText, from, to) {
9254     var resultBefore = str.substring(0, from);
9255     var text = str.substring(from, to);
9256     var resultAfter = str.substring(to);
9257     text = text.replace(stringObj, customLinkageAnalysis.reachLeftSpace(replaceText, stringObj.length));
9258     return resultBefore + text + resultAfter;
9259 }
9260
9261 customLinkageAnalysis.changeCodeMirror = function (code, history) {
9262     if (code.trim() == "") {
9263         return null;
9264     }
9265     //console.log(code);
9266     //console.log(history);
9267     var result = {};
9268     var conditionCode = "";
9269     var listCode = new Array();
9270     var arrConditionCode = code.split('\r\n');
9271     ////console.log(arrConditionCode);
9272     var resultIndex = 0;
9273
9274     if (history != null && history.length > 0) {
9275         for (var i = 0; i < history.length; i++) {
9276             var line = history[i].from.line;
9277             var fromCh = history[i].from.ch;
9278             var toCh = history[i].to.ch;
9279             var text = history[i].text;
9280             arrConditionCode[line] = customLinkageAnalysis.replace(arrConditionCode[line], text, '{' + resultIndex + '}', fromCh, toCh);
9281             var idText = history[i].idText;
9282             var arrInputText = idText.split('.');
9283             var replaceText = "";
9284             var id = arrInputText[0];
9285             var textType = arrInputText[1];
9286             var idItem = customShow.options.customItemShow.item[id]; if (textType == 'value') {
9287                 if (idItem.parentsubFormNum != 0) {
9288                     replaceText = "customLinkageAnalysis.getValue('" + id + "').split(',')[i]";
9289                 } else {
9290                     replaceText = "customLinkageAnalysis.getValue('" + id + "')";
9291                 }                // ////console.log(replaceText);
9292             } else if (textType == 'visible' || textType == 'editable') {
9293                 replaceText = "customLinkageAnalysis.getAttribut('" + id + "','" + textType + "')";
9294             } else {
9295                 if (idItem.parentsubFormNum != 0) {//主数据关联也需区分子表单中控件  李伟民 0106
9296                     replaceText = "customLinkageAnalysis.getElement('" + id + "','" + textType + "',i)";
9297                 } else {
9298                     replaceText = "customLinkageAnalysis.getElement('" + id + "','" + textType + "')";
9299                 }
9300                 // replaceText = "customLinkageAnalysis.getElement('" + id + "','" + textType + "')";
9301             }
9302             listCode.push(replaceText);
9303             resultIndex++;
9304         }
9305     }
9306     conditionCode = arrConditionCode.join('\r\n').replace(/\(/g, "###(###");
9307     conditionCode = conditionCode.replace(/\)/g, "###)###");
9308     arrConditionCode = conditionCode.split('\r\n');
9309     conditionCode = arrConditionCode.join('\r\n');
9310     conditionCode = conditionCode.replace(/AND/g, '&&');
9311     conditionCode = conditionCode.replace(/OR/g, '||');
9312     while (conditionCode.indexOf('  ') >= 0) {
9313         conditionCode = conditionCode.replace(/  /g, ' ');
9314     }
9315     var conditionCodeResult = customLinkageAnalysis.changeSign(conditionCode, listCode, resultIndex);
9316     conditionCode = conditionCodeResult.conditionCode;
9317     resultIndex = conditionCodeResult.resultIndex;
9318     conditionCode = conditionCode.replace(/###\(###/g, "(");
9319     conditionCode = conditionCode.replace(/###\)###/g, ")");
9320     result.code = conditionCode;
9321     result.listCode = listCode;
9322     //console.log(result);
9323     return result;
9324 }
9325
9326 customLinkageAnalysis.changeCodeSign = function (sign, inner) {
9327     var exp = igame.Expression;
9328     if (sign.indexOf('MAX') >= 0) {
9329         sign = "Max";
9330     } else if (sign.indexOf('MIN') >= 0) {
9331         sign = "Min";
9332     } else if (sign.indexOf('AVG') >= 0) {
9333         sign = "Average";
9334     } else if (sign.indexOf('SUM') >= 0) {
9335         sign = "Sum";
9336     } else if (sign.indexOf('COUNT') >= 0) {
9337         sign = "Count";
624ff8 9338     } else if (sign.indexOf('||') >= 0) {//|| &&修改 李伟民 0202 公式不稳定修改
L 9339         return sign + eval("[" + inner + "]").toString();
4d1219 9340     } else {
B 9341         return "";
9342     }
9343
9344     var arlInner = eval("[" + inner + "]");
9345     return new exp.Formula(sign + "(" + arlInner.join(',') + ")").evaluate().toString();
9346 }
9347
9348 customLinkageAnalysis.expeval = function (str) {
9349     //    console.log(str);
9350     if (str.trim().replace(/=/, "") == "") {
9351         console.log("str  err");
9352         return " ";
9353     }
9354     console.log("str  scc");
9355     var exp = igame.Expression;
9356     //      console.log(exp);
9357     //      console.log(str);
9358     //      console.log(new exp.Formula(str));
9359     //      console.log(new exp.Formula(str).evaluate());
9360     //      console.log(new exp.Formula(str).evaluate().toString());
9361     return new exp.Formula(str).evaluate().toString();
9362 }
9363
9364 customLinkageAnalysis.changeSign = function (conditionCode, listCode, resultIndex) {
9365     ////console.log(conditionCode);
9366     var index = 0;
9367     var indexOf = -1;
9368     var result = {};
9369     while ((indexOf = conditionCode.substring(index).indexOf('MAX')) >= 0
9370         || (indexOf = conditionCode.substring(index).indexOf('MIN')) >= 0
9371         || (indexOf = conditionCode.substring(index).indexOf('AVG')) >= 0
9372         || (indexOf = conditionCode.substring(index).indexOf('SUM')) >= 0
9373         || (indexOf = conditionCode.substring(index).indexOf('COUNT')) >= 0
9374         || (indexOf = conditionCode.substring(index).indexOf('parseInt')) >= 0
9375         || (indexOf = conditionCode.substring(index).indexOf('addtest')) >= 0
9376         || (indexOf = conditionCode.substring(index).indexOf('getDay')) >= 0
9377         || (indexOf = conditionCode.substring(index).indexOf('getSum')) >= 0) {//时间函数  李伟民 2017-10-17 21:49 修改公式
9378         var before = conditionCode.substring(0, indexOf);
9379         var beforeInner = 0;
9380         var afterIndexOf = 0;
9381         var sign;
9382         var after;
9383         if (history != null && history.length > 0) {
9384             beforeInner = conditionCode.substring(indexOf).indexOf('###(###') + 7
9385             // afterIndexOf = conditionCode.substring(indexOf).lastIndexOf('###)###');
9386             afterIndexOf = customLinkageAnalysis.getBackBracketIndex(conditionCode.substring(indexOf), '###(###', '###)###');
9387             sign = conditionCode.substring(indexOf).substring(0, beforeInner - 7);
9388             after = conditionCode.substring(indexOf).substring(afterIndexOf + 7);
9389         } else {
9390             beforeInner = conditionCode.substring(indexOf).indexOf('(') + 1
9391             // afterIndexOf = conditionCode.substring(indexOf).lastIndexOf(')');
9392             afterIndexOf = customLinkageAnalysis.getBackBracketIndex(conditionCode.substring(indexOf), '(', ')');
9393             sign = conditionCode.substring(indexOf).substring(0, beforeInner - 1);
9394             after = conditionCode.substring(indexOf).substring(afterIndexOf + 1);
9395         }
9396         var inner = conditionCode.substring(indexOf).substring(beforeInner, afterIndexOf);
9397         var innerResult = customLinkageAnalysis.changeSign(inner, listCode, resultIndex);
9398         inner = innerResult.conditionCode;
9399         resultIndex = innerResult.resultIndex;
9400         inner = inner.replace(/###\(###/g, "(");
9401         inner = inner.replace(/###\)###/g, ")");
9402         if ((indexOf = conditionCode.substring(index).indexOf('parseInt')) >= 0
9403             || (indexOf = conditionCode.substring(index).indexOf('addtest')) >= 0
9404             || (indexOf = conditionCode.substring(index).indexOf('getDay')) >= 0
9405             || (indexOf = conditionCode.substring(index).indexOf('getSum')) >= 0) {//时间函数  李伟民 2017-10-17 21:49 修改公式
9406             listCode.push(sign + "(" + inner + ")");
9407         } else {
9408             listCode.push("customLinkageAnalysis.changeCodeSign('" + sign + "',\[" + inner + "\])");
9409         }
9410
9411         conditionCode = before + "{" + resultIndex + "}";
9412         resultIndex++;
9413         index = conditionCode.length - 1;
9414         conditionCode += after;
9415     }
9416     result.conditionCode = conditionCode;
9417     result.resultIndex = resultIndex;
9418     ////console.log(result);
9419     return result;
9420 }
9421 addtest = function (arg1, arg2) {
9422     return arg1 + arg2;
9423 }
9424
9425 getDay = function (arg1, arg2) {//时间函数  李伟民 2017-10-17 21:49
9426     var date1 = new Date(arg1)
9427     var date2 = new Date(arg2)
9428     var s1 = date1.getTime(), s2 = date2.getTime();
9429     var total = (s1 - s2) / 1000;
9430     var day = parseInt(total / (24 * 60 * 60));//计算整数天数
9431     //console.log(day);
9432     return day;
9433 }//时间函数  李伟民 2017-10-17 21:49 end
9434
9435 getSum = function () {
9436     console.log(arguments);
9437     var allItem = [];
9438     _.each(arguments, function (arg) {
9439         allItem.push(arg.split(","));
9440     });
9441     console.log(allItem);
9442     var sum = 0;
9443     _.each(allItem, function (item) {
9444         _.each(item, function (cd) {
9445             sum += Number(cd);
9446         })
9447     })
9448     return sum;
9449 }
9450
9451 customLinkageAnalysis.getBackBracketIndex = function (str, strBracket, strBackBracket) {
9452     var beforeIndex = str.indexOf(strBracket);
9453     var backIndex = str.indexOf(strBackBracket);
9454     var layers = 0;
9455     while (beforeIndex < backIndex && beforeIndex >= 0) {
9456         layers++;
9457         beforeIndex = str.indexOf(strBracket, beforeIndex + strBracket.length)
9458     }
9459     while (layers > 1 && backIndex >= 0) {
9460         layers--;
9461         backIndex = str.indexOf(strBackBracket, backIndex + strBackBracket.length);
9462     }
9463     if (backIndex < 0) {
9464         throw Error("括号未闭合");
9465     }
9466     return backIndex;
9467 }
9468 var customDataBound = customDataBound || {};
9469
9470 //根据表单ID取得表单基本信息
9471 customDataBound.getFormbase = function (formid, callback) {
9472     // if(customBase.options.formbaseInfo == ""){
9473     var dataObj = {};
9474     dataObj.formID = formid;
9475     var requestRight = window.commonAjax("/formbase/getFormInfoService", dataObj, "GET", true);
9476     requestRight.done(function (rs) {
9477         callback(rs);
9478     })
9479
9480
9481     // }else{
9482     //     callback(customBase.options.formbaseInfo);
9483     // }
9484 }
9485
9486 //表单保存
9487 customDataBound.savaFormbase = function (formbase, callback) {
9488     ////////////console.log(formbase);
9489     var dataObj = {};
9490     dataObj = formbase;
9491     console.log(formbase);
9492     var requestRight = window.commonAjax("/formbase/saveformService", dataObj, "POST", true);
9493     requestRight.done(function (rs) {
9494
9495         callback(rs);
9496     });
9497 }
9498
9499 //表单数据保存
9500 customDataBound.fromSave = function (formid, formbase, callback) {
9501     // if(window.localStorage.getItem("bussinessSystem")){
9502     //     var flag = window.localStorage.getItem("bussinessSystem");
9503     // }
9504     var dataObj = {};
9505     dataObj.formID = formid;
9506     dataObj.data = formbase;
9507     //     dataObj.tenantID = "001";
9508     // dataObj.flag = flag;
9509     //dataObj.flag = "cloud"
9510     //console.log(dataObj);
9511     if (customShow.exCouldNumber != undefined && customShow.exCouldNumber != '') {//保存时 传云单标号 李伟民 12-22
9512         _.extend(dataObj, { 'orderCode': customShow.exCouldNumber });
9513     }//保存时 传云单标号 李伟民 12-22
9514     //_.extend(dataObj,{'orderCode': '1012000170900005'});//临时修改
9515     var requestRight = window.commonAjax("/datamanagement/addFormDataService", dataObj, "POST", true);
9516     requestRight.done(function (rs) {
9517         callback(rs);
9518     });
9519 }
9520
9521 //表单数据编辑
9522 customDataBound.fromEdit = function (formid, formbase, dataRowNum, callback) {
9523     var dataObj = {};
9524     // if(window.localStorage.getItem("bussinessSystem")){
9525     //     var flag = window.localStorage.getItem("bussinessSystem");
9526     // }
9527     // dataObj.flag = flag;
9528     dataObj.formID = formid;
9529     dataObj.dataRowNum = dataRowNum;
9530     dataObj.data = formbase;
9531     if (customShow.exCouldNumber != undefined && customShow.exCouldNumber != '') {//保存时 传云单标号 李伟民 12-22
9532         _.extend(dataObj, { 'orderCode': customShow.exCouldNumber });
9533     }//保存时 传云单标号 李伟民 12-22
9534     //_.extend(dataObj,{'orderCode': '1012000170900005'});//临时修改
9535     var requestRight = window.commonAjax("/datamanagement/updateFormDataService", dataObj, "POST", true);
9536     requestRight.done(function (rs) {
9537
9538         callback(rs);
9539     });
9540 }
9541
9542 // 获取表单设定数据源信息
9543
9544 // JSON:{"rspCode":"000000","rspDesc":"请求成功","data":[{"测试连接":["actor_id","first_name","last_name","last_update"]}]}
9545 customDataBound.getDatasource = function (formID, callback) {
9546     var dataObj = {};
9547     dataObj.formID = formID;
9548     // dataObj.formID = '8888';
9549     // dataObj.tenantID = "001";
9550     var requestRight = window.commonAjax("/datasource/getDatasourceColumnsNameService", dataObj, "GET", true);
9551
9552     requestRight.done(function (rs) {
9553         if (rs.rspCode == "000000") {
9554             callback(rs.data);
9555         } else {
9556             callback(rs.data);
9557         }
9558     });
9559 }
9560
9561 // 获取当前表单设置字段的数据源信息  数据绑定
9562 // 参数: formID,tenantID
9563 // JSON: {"rspCode":"000000","rspDesc":"请求成功","data":[{"单选按钮组测试":{"datasource":"","textcolumn":"","valuecolumn":""}}]}
9564 customDataBound.getFieldDatasource = function (Datasource, callback) {
9565     url = "/datasource/getDatasourceColumnsValueService?tenantID={tenantID}&databaseName={databaseName}&datasource={datasource}&columnNames={columnNames}&callbackId={callbackId}";
9566     url = url.replace("{databaseName}", Datasource.databaseName);
9567     url = url.replace("{columnNames}", Datasource.columnNames);
9568     url = url.replace("{datasource}", Datasource.datasource);
9569     url = url.replace("{callbackId}", Datasource.callbackId);
9570
9571     window.commonGetJson(url, callback);
9572
9573 }
9574
9575 // 获得主数据
9576 customDataBound.getElement = function (code, callbackId, callback) {
9577     if (code != "") {
9578         var dataObj = {};
9579         dataObj.tenantIDForMaster = 1;
7b0ed4 9580          if(_.isString(code)){
Z 9581             dataObj.code = code;
9582         }else{
9583             dataObj.code = JSON.stringify(code);
9584         }
4d1219 9585         dataObj.callbackId = callbackId;
B 9586         //console.log(dataObj);
9587         let customlocalStorage = window.localStorage.getItem("bussinessSystem");
9588         var reg = new RegExp('"', "g"); // service  修改  李元杰 11-16
9589         customlocalStorage = customlocalStorage.replace(reg, ""); // service  修改  李元杰 11-16
9590         console.log(customlocalStorage);
9591         dataObj.flag = customlocalStorage;
9022c2 9592         var requestRight = window.commonAjax("/te-csc-api/search/base/elementprivate", dataObj, "POST", true);
4d1219 9593
B 9594         requestRight.done(function (rs) {
9595             console.log(rs)
9596             if (rs.rspCode == "000000") {
9597                 console.log(rs)
9598                 callback(rs);
9599                 customShow.addTitle();
9600                 SC.money_cur();
9601                 // 12/13
9602
9603                 console.log(window.localStorage.getItem('customShowFlag'))
9604                 if (window.localStorage.getItem('customShowFlag') == 1) {
9605                     // customShow.businessTypeAutoFun( 'businessTypeAuto','budget_itemCostType');
9606                     SC.autoFieldKey();
9607                 }
9608             } else {
9609                 callback(rs);
9610                 console.log(rs)
9611                 toastr.error(rs.rspDesc.responseJSON);
9612             }
9613         });
9614         requestRight.error(function (rs) {
9615             // console.log(rs)
9616             // toastr.error(rs.responseJSON.rspDesc);
9617
9618         })
9619     } else {
9620         callback([]);
9621     }
9622
9623 }
9624
9625 // 获得主数据
9626 customDataBound.getElement1 = function (opt) {
9627     var dataObj = {};
9628     // dataObj.tenantIDForMaster = 1;
9629     // dataObj.code =opt;
9630     // dataObj.callbackId = callbackId;
9631     var result;
9022c2 9632     var requestRight = window.commonAjax("/te-csc-api/search/base/elementprivate1", opt, "POST", true, false);
4d1219 9633     requestRight.done(function (rs) {
B 9634         if (rs.rspCode == "000000") {
9635             result = rs;
9636         } else {
9637             result = rs;
9638         }
9639     });
9640     return result;
9641 }
9642
9643 // 获取当前表单设置字段的数据源信息  API数据取得
9644 // 参数: formID,tenantID
9645 // JSON: {"rspCode":"000000","rspDesc":"请求成功","data":[{"单选按钮组测试":{"datasource":"","textcolumn":"","valuecolumn":""}}]}
9646 customDataBound.getApiDatasource = function (url, callbackId, callback) {
9647     // console.log(1);
9648     var urls = url;
9649     var url = url + "&callbackId={callbackId}";
9650
9651     url = url.replace("{callbackId}", callbackId);
9652     // var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
9653     // xhr.open("GET", urls, true);
9654     // debugger
9655     // xhr.onreadystatechange = function () {
9656     //     var res = JSON.parse(xhr.responseText);
9657     //     console.log(res);
9658     // }
9659     $.ajax({
9660         type: "get",
9661         url: urls,
9662         async: true,
9663         success: function (rs) {
9664             console.log(url);
9665             console.log(rs);
9666             callback(rs, url);
9667         }
9668     });
9669     // // var url = url + "&callbackId={callbackId}";
9670     // // url = url.replace("{callbackId}", callbackId);
9671     // // //////////console.log(url);
9672     // // window.commonGetApiJson(url, callback);
9673     //     //////////console.log(url);
9674     //     //window.commonGetApiJson(url,callback);
9675 }
9676
9677 customDataBound.bindInterface = function (formid) {//绑定接口注册方法//保存前计算费用  李伟民   10 - 31
9678     var dataObj = {};
9679     dataObj.formID = formid;
9680     var accessToken = JSON.parse(localStorage.getItem("token")).accessToken;
9681     dataObj.access_token = accessToken;
9682     var requestRight = window.commonAjax("/forminterface/getFormInterfaceListService", dataObj, "GET", true, false);
9683     requestRight.done(function (rs) {
9684         //console.log(rs);
9685         customBase.interfaceData = rs.data;
9686
9687     })
9688 }//保存前计算费用  李伟民   10 - 31
9689
9690 customDataBound.formsetting = function (formid, callback) {
9691     // 工具栏自定义10/18
9692     $('.edit_form').html("");
9693     var type = "";
9694     var flag = window.localStorage.getItem("customShowFlag");
9695     switch (flag) {
9696         case "1": type = "TJ"; break;
9697         case "3": type = "XG"; break;
9698         case "2": type = "XX"; break;
9699         case "4": type = "LB"; break;
9700     }
9701
9702     //console.log(type);
9703     var dataObj = {};
9704     dataObj.formID = formid;
9705     dataObj.type = type;
9706     console.log(dataObj)
9707     var dataObjFlag = _.cloneDeep(dataObj);
9708     delete dataObjFlag.type
9709     var request = window.commonAjax("/formbase/getFormInfoService", dataObjFlag, "GET", true);
9710     request.done(function (rs) {
9711         if (rs.data != null) {
9712             window.localStorage.setItem('bussinessSystem', rs.data.bussinesssystem)
9713         }
9714     })
9715
9716
9717
9718     var requestRight = window.commonAjax("/formsetting/getFormsettingInfoService", dataObj, "POST", true);
9719     requestRight.done(function (rs) {
9720         customDataBound.bindInterface(formid);
9721         //          ////console.log(rs);
9722         //console.log(type);
9723         if (rs.data.saveable == "0") {
9724             $(".sure_box").hide();
9725         }
9726         if (!rs.data.subCustomButton) {
9727             $("#doself").remove();
9728
9729         }
9730         if (rs.data.subCustomButton) {
9731             // var dd=document.createElement('span');
9732             var formdata = [];
9733             //console.log("查询类型");
9734             //console.log(type);
9735             switch (type) {
9736                 case "TJ": formdata = rs.data.subCustomButton.addCustomButton; break;
9737                 case "XG": formdata = rs.data.subCustomButton.updateCustomButton; break;
9738                 case "XX": formdata = rs.data.subCustomButton.detailedCustomButton; break;
9739                 case "LB": formdata = rs.data.subCustomButton.listCustomButton; break;
9740             }
9741             //console.log("渲染结果");
9742             var srcd = document.createElement('script');
9743             // var tabledata=rs.data.customButtons;
9744             srcd.type = "text/javascript";
9745             _.each(formdata, function (obt, i) {
9746                 var dd = document.createElement('span');
9747                 dd.id = obt.buttonName + i;
9748                 //btn btn-default
9749                 dd.setAttribute("class", "btn_myself");
9750                 dd.setAttribute("buttonId", obt.buttonId);
9751                 dd.innerHTML = "<i class='icon iconfont icon-kongjian_danhangwenben' style='text-align: left;'></i>" + obt.buttonName;
9752
9753                 $(".edit_form").append(dd);
9754
9755                 //console.log(obt.buttonName);
9756                 if (obt.buttonName == "驳回") {
9757                     //console.log("等于撤回");
9758                     // 定义审批流程定义的方法
9759                     // 撤销流程实例
9760
9761                     $("#" + dd.id).click(function () {
9762                         var process = localStorage.getItem("processid");
9763
9764                         //console.log(process);
9765                         var dd = JSON.parse(process);
9766                         var tent = JSON.parse(localStorage.getItem("tenantID")).tenantID;
9767
9768                         //console.log(dd.data);
9769                         window.queryAjaxs("ubp-api-seache/process/inst/log", { "processInstId": dd.data.processInstId }, "POST", true).done(function (res) {
9770                             //console.log("打印回执");
9771                             //console.log(res);
9772                             if (res != undefined) {
9773                                 //console.log("发送请求");
9774                                 window.queryAjaxs("ubp-api-control/process/inst/drawBack", { "processInstId": res.data[0].processInstId, "activityInstId": res.data[0].activityInstId }, "POST", true).done(function (res) {
9775                                     //console.log("打印回执");
9776                                     //console.log(res);
9777                                     if (res.data == 1) {
9778                                         //console.log("撤销成功");
9779                                         customBase.alert('S',"撤销成功");
9780                                         // localStorage.removeItem('userinfo')
9781                                     }
9782                                 })
9783                             }
9784
9785                         })
9786
9787                     });
9788
9789                     // 结束流程实例
9790                 } else if (obt.buttonName == "结束") {
9791                     $("#" + dd.id)[0].setAttribute('data-toggle', "modal");
9792                     $("#" + dd.id)[0].setAttribute('data-target', ".bs-example-modal-sm");
9793                     $("#" + dd.id).click(function () {
9794                         var processLog = JSON.parse(localStorage.getItem("processLog"));
9795                         if (processLog != null && processLog != undefined) {
9796                         } else {
9797                             $("#liucheng").html("<h3 class='sp_title'>请先创建一个流程<h3>");
9798                             return null;
9799                         }
9800                         if (processLog[0].processState == 60) {
9801                             $("#liucheng").html("<h3 class='sp_title'>流程已结束<h3>");
9802                             return null;
9803                         } else {
9804                             var inputs = "<h3 class='sp_title'>是否确认结束?<h3><br/>"
9805                                 + "<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>";
9806                             $("#liucheng").html(inputs);
9807                             $("#sssd").click();
9808
9809                         }
9810                     });
9811
9812                 } else if (obt.buttonName == "退回") {
9813                     $("#" + dd.id)[0].setAttribute('data-toggle', "modal");
9814                     $("#" + dd.id)[0].setAttribute('data-target', ".bs-example-modal-sm");
9815                     $("#" + dd.id).click(function () {
9816                         var processLog = JSON.parse(localStorage.getItem("processLog"));
9817                         if (processLog[0].processState == 60) {
9818                             customBase.alert('E',"流程已结束");
9819                             return null;
9820                         } else {
9821                             if (processLog != "null" && processLog != undefined) {
9822                                 console.log(processLog.length);
9823                                 if (processLog.length == 1) {
9824                                     customBase.alert('W',"无可退回活动");
9825                                     return null;
9826                                 }
9827                             } else {
9828                                 customBase.alert('W',"请先创建一个流程");
9829                                 return;
9830                             }
9831                             //请求可退回活动项
9832                             var isshow = false;
9833                             var ss = {
9834                                 "processInstId": processLog[0].processInstId
9835                             }
9836                             var requestSingleForm = window.commonAjax("/ubp-api-seache/process/get/back", ss, "POST", true);
9837                             requestSingleForm.done(function (rs) {
9838                                 console.log(rs);
9839                                 var res = rs.data;
9840                                 if (res != undefined & res != null) {
9841
9842                                     if (res.length > 0) {
9843
9844                                         var inputs = "<h3 class='sp_title'>请选择要退回的活动</h3><br/>";
9845                                         for (var i = 0; i < res.length; i++) {
9846                                             if (i == 0) {
9847                                                 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>";
9848                                             } else {
9849                                                 inputs += "<input  type='radio'  onClick='choosebox(" + i + ")' class='act acts' value=" + res[i].activityDefId + " name='task'  />" + res[i].activityDefName + "</br>";
9850                                             }
9851                                         }
9852                                         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 + ")'/>";
9853                                         inputs += "</div>";
9854                                         console.log(inputs);
9855                                         $("#liucheng").html(inputs);
9856
9857
13ec33 9858                                         // callback();
4d1219 9859                                     }
B 9860                                 } else {
9861                                     $("#liucheng").html("<h3 class='sp_title'>无可退回项<h3>");
9862
9863                                     return null;
9864                                 }
9865                             });
9866
9867                         }
9868                     });
9869                 } else if (obt.buttonName == "审批") {
9870                     $("#" + dd.id).click(function () {
9871
9872                         var processLog = JSON.parse(localStorage.getItem("processLog"));
9873                         if (processLog != null && processLog != undefined) {
9874                         } else {
9875                             customBase.alert('W',"请先创建一个流程");
9876                             return null;
9877                         }
9878                         if (processLog[0].processState == 60) {
9879                             customBase.alert('E',"流程已结束");
9880                             return null;
9881                         }
9882                         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/>"
9883                             + "<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>";
9884                         $("#liucheng").html(inputs);
9885                         $("#" + dd.id)[0].setAttribute('data-toggle', "modal");
9886                         $("#" + dd.id)[0].setAttribute('data-target', ".bs-example-modal-sm");
9887                     });
9888
9889                 } else {
9890                     $("#" + dd.id).click(function () {
9891
9892                         var fuc = obt.methodName + "()";
9893                         eval(fuc);
9894                         //console.log(fuc);
9895                         //调用自定义js中的方法
9896                         //console.log("调用自定义方法");
9897                         fuc;
9898
9899                     });
9900                 }
9901             });
9902
9903             srcd.src = rs.data.resourceFilePath;
9904
9905             // $("#customShow").append(srcd);
9906             if(rs.data.resourceFilePath != undefined && flag != 3 && rs.data.resourceFilePath != ''){//自定义JS加载修改  李伟民  0109
9907                 document.getElementsByTagName("head")[0].appendChild(srcd); // 接口注册 初期化事件 李伟民 12-18
9908                 srcd.onload = function () {
9909                     _.each(customBase.interfaceData, function (data) {
9910                         if (data.interfacemethod == "interfaceInit3rd") {
9911                             if (data.customInterfacemethod != undefined && data.customInterfacemethod != '') {
9912                                 var funstr = data.customInterfacemethod + "()";
9913                                 eval(funstr);
9914                             }
9915                         }
9916                     });
9917                     callback(rs);//自定义JS加载修改  李伟民  0109
9918                 }
9919             }else{
9920                 callback(rs);//自定义JS加载修改  李伟民  0109
9921             }
13ec33 9922
4d1219 9923             //  $(".preview-edit-pane").append(dd);
B 9924             //  $("#"+dd.id).click(function(){
9925
9926             //     var fuc=arr[1]+"()";
9927             //     eval(fuc);
9928             //     ////console.log(fuc);
9929
9930             //     ////console.log("调用自定义方法");
9931             //     fuc;
9932
9933             //  });
9934         }else{
9935             callback(rs);//自定义JS加载修改  李伟民  0109
9936         }
9937     });
9938     var dataObjDo = {};
9939     dataObjDo = dataObj;
9940     delete dataObjDo.type
9941     console.log(dataObj)
9942     var requestRight = window.commonAjax("/tabConfiguration/queryTabConfiguration", dataObjDo, "POST", true);
9943     requestRight.done(function (rs) {
13ec33 9944         //2017/10/31 李元杰 附件 流程先洗 选项卡添加
4d1219 9945         console.log(rs)
B 9946         $('.boxTwo').hide();
9947         $('.sTab').find('ul li').eq(1).hide();
9948         $('.boxThr').hide();
9949         $('.sTab').find('ul li').eq(2).hide();
9950         if (rs.data != '') {
9951             if (rs.data[0].appendix == "do") {
9952                 console.log($('.sTab').find('ul li'))
9953                 $('.sTab').find('ul li').eq(1).show();
9954             } else {
9955                 $('.boxTwo').hide();
9956                 $('.sTab').find('ul li').eq(1).hide();
9957             }
9958             if (rs.data[0].processInfo == "do") {
9959                 $('.sTab').find('ul li').eq(2).show();
9960             } else {
9961                 $('.boxThr').hide();
9962                 $('.sTab').find('ul li').eq(2).hide();
9963             }
9964         }
9965     });
9966 }
9967
9968
9969 var xhSelect = xhSelect || {};
9970 xhSelect.scope = {
9971     sel_val_lst: {
9972         // 'F073001':"常规出差"
9973     },
9974     rm_optionFlag: false
9975 };
9976
9977 xhSelect.options = {
9978     selectId: "",
9979     multiple: false,
9980     listData: [],
9981     width: 200,
9982     setDiv: ""
9983 }
9984 xhSelect.setValue = function (itemId, listData) {
9985     xhSelect.setValue(itemId, listData, 0);
9986 }
9987 xhSelect.setValue = function (itemId, listData, N) {
9988     var selectItme = $("#" + itemId + " .selectItme");
9989     var listDataJson = {};
9990     if (_.isString(listData)) {// 下拉款填值  修改  李伟民 11-14
9991         listData = listData.split(",")
9992     }// 下拉款填值  修改  李伟民 11-14
9993     console.log(listData);
9994     for (var i = 0; i < listData.length; i++) {
9995         listDataJson[listData[i]] = "1";
9996     }
9997
9998     var $options = $($("#" + itemId)[0]).find('select > option');
9999     var vals_selected = [];
10000     var j = 0;
10001     $options.each(function () {
10002         for (var jsonstr in listDataJson) {
10003             if ($(this).val() == jsonstr) {
10004                 vals_selected[j] = {};
10005                 vals_selected[j].value = $(this).val();
10006                 vals_selected[j].label = $(this).text();
10007                 j++;
10008             }
10009         }
10010     });
10011     var $el = $($("." + itemId + "value")[N]);
10012     var set_valueleft = function (vals_selected) {
10013         var $divContainer = "";
10014         var selectedItem = {};
10015         for (var i = 0; i < vals_selected.length; i++) {
6f4af7 10016             //张吉男修改 下拉框发布
4d1219 10017             $divContainer += '<div class="val-card ng-binding ng-scope ' + vals_selected[i].value +
B 10018                 '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 10019                 vals_selected[i].label + '<a onclick="xhSelect.rm_option(this,\'' + vals_selected[i].value +
Z 10020                 '\')" ng-href="javascript:void(0);" href="javascript:void(0);">' + '  <i  class="icon iconfont icon-guanbijiantou"  val="' +
4d1219 10021                 vals_selected[i].value + '" style="color:#20b4aa;"></i></li>' + ' </a>' + ' </div>';
B 10022
10023             selectedItem[vals_selected[i].value] = "1";
10024         }
10025         $divContainer += '<div class="suffix">' + '<i class="fa fa-angle-down" aria-hidden="true"></i>' + '</div>';
10026         $el.find(".select-container").empty();
10027         $el.find(".select-container").append($divContainer);
10028         var selectedItemJson = JSON.stringify(selectedItem);
10029         if ($el.find(".selectItme").length != 0) {
10030             $el.find(".selectItme")[0].setAttribute("value", selectedItemJson);
10031         }
10032
10033     };
10034     set_valueleft(vals_selected);
10035 }
10036 xhSelect.getValue = function (itemId) {
10037     var returnItem = [];
10038     var selectItme = $("#" + itemId + " .selectItme");
10039     console.log(selectItme)
10040     for (var i = 0; i < selectItme.length; i++) {
10041         if (selectItme[i].getAttribute("value") == "") {
10042             var selectItmeJson = {};
10043         } else {
10044             ////console.log(selectItme[i].getAttribute("value"));
10045             var selectItmeJson = $.parseJSON(selectItme[i].getAttribute("value"));
10046         }
10047
10048         var jn = 0;
10049         returnItem[i] = [];
10050         for (j in selectItmeJson) {
10051             returnItem[i][jn] = j;
10052             jn++;
10053         }
10054     }
10055     return returnItem;
10056 }
10057 // 下拉框主数据渲染
10058 xhSelect.setXhSelect = function (options) {
10059     ////console.log(options);
10060     ////console.log(_.cloneDeep(xhSelect.options));
10061     //解决主数据重复
10062     var options_xh = _.cloneDeep(xhSelect.options);
10063     options_xh.listData = [];
10064     //解决主数据重复END
10065     options = $.extend(true, options_xh, options);
10066     var optionArr = "";
10067     console.log(options.selectId);
10068     ////console.log(options.listData);
10069     //        ////console.log(options.listData.length);
10070     for (var i = 0; i < options.listData.length; i++) {
10071         optionArr += '<option value="' + options.listData[i].value + '">' + options.listData[i].text + '</option>';
10072     }
10073     console.log(optionArr);
10074     var multiple = "";
10075     if (options.multiple) {
10076         multiple = 'multiple';
10077     }
10078
10079     var $xhSelectDiv = '' +
10080         '<div class="selectClass">' +
10081         '<div ng-transclude="" style="display:none;">' +
10082         '<select class="select_get ng-scope" load-data="" ' + multiple + ' >' +
10083         optionArr +
10084         '</select>' +
10085         '</div>' +
10086         '<div class="selectItme" style="display:none;" value=""></div>' +
10087         '<div class="select3-element" style="width:100%;max-width: ' + options.width + 'px">' +
10088         '            <div  class="select-container select-container_box" gccolname="ex_c11">  ' +
10089         '                    <div class="suffix">' +
10090         '                            <i class="fa fa-angle-down" aria-hidden="true"></i>' +
10091         '                    </div>' +
10092         '            </div>' +
10093         '    </div> ' +
10094         '</div>';
10095     console.log(options);
10096     if (options.setDiv == '') {
10097         var $el = $("#" + options.selectId);
10098     } else {
10099         var $el = $("." + options.setDiv);
10100     }
10101     console.log(optionArr)
10102     console.log($xhSelectDiv)
10103     _.each($el, function (sel) {//添加记录 重复问题  李伟民11-14   主数据丢失  11-29 再次修改
10104         if ($(sel).find(".selectClass").length == 0) {
10105             $(sel).append($xhSelectDiv)
10106         } else {
10107             $(sel).find(".selectClass").find(".select_get").html(optionArr);
10108         }
10109     })//添加记录 重复问题  李伟民11-14   主数据丢失  11-29 再次修改
10110
10111
10112     //添加记录 重复问题  李伟民11-14
10113     //        $("#"+options.selectId).find()
10114
10115     xhSelect.selectContainer(options);
10116     customLinkageAnalysis.bindLinkage();
10117     //行程排序初期化
10118     customShow.journeySort();
10119 }
10120 xhSelect.rm_option = function (val, vals_selected) {
10121     xhSelect.scope.rm_optionFlag = true;
10122     console.log(val);
10123     console.log(vals_selected)
10124     $('div.drop_down_sel').remove();
10125     var selectItmeJson = $($(val).parent().parent().parent().parent()).find(".selectItme")[0].getAttribute("value");
10126
10127     var selectItme = $.parseJSON(selectItmeJson);
10128     delete selectItme[vals_selected];
10129     selectItmeJson = JSON.stringify(selectItme);
10130     $($(val).parent().parent().parent().parent()).find(".selectItme")[0].setAttribute('value', selectItmeJson);
6f4af7 10131
Z 10132     //张吉男修改 下拉框默认值不可以清空
10133     var cla=new RegExp("disableColor");
10134     //console.log(cla.test($(val).parent().parent().attr("class")));
10135     //判断下拉框是否是可编辑
10136     if(!(cla.test($(val).parent().parent().attr("class")))){
10137         $(val).parent().remove();
10138     }
4d1219 10139     setTimeout(function () {
B 10140         xhSelect.scope.rm_optionFlag = false;
10141     }, 500);
10142 }
10143 xhSelect.selectContainer = function (options) {
10144     var itemId = options.selectId;
10145     if (options.setDiv == '') {
10146         var $el = $("#" + itemId);
10147     } else {
10148         var $el = $("." + options.setDiv);
10149     }
10150     $el.find('div.select-container').on('click', function (event) {
10151         var selectedItem = $el.find(".selectItme")[0].getAttribute("value");
10152         //  12/4 李元杰
10153         $('.zTreeDemoBackground').css("display", "none");
10154         $(".search_input").css("display", "none");
10155         console.log(selectedItem);
10156         console.log(event);
10157         console.log($(this))
10158         ////console.log("-------------------this-----------------------------------");
10159         if ($el[0].className.indexOf("readonly") > -1) {
10160             return;
10161         }
10162         if (selectedItem != "") {
10163             selectedItem = $.parseJSON(selectedItem);
10164         }
10165
10166         if (xhSelect.scope.rm_optionFlag) {
10167             return;
10168         }
10169         console.log(2)
10170         $('div.drop_down_sel').remove();
10171         var $select = $el.find('select');
10172         var isMultiple = $select.attr('multiple');
10173         var $options = $el.find('select > option');
10174         ////console.log($el);
10175         ////console.log($options);
10176         var $options_str = '<ul>' + '<li class="sel_query">' + '<input type="text" name="query" >' + '</li>' + '</ul>';
10177
10178         $options_str += '<div class="select "><ul class="line">';
10179
10180         if ($select.attr('multiple')) {
10181             $options_str += '<li class="ui-state-default" style="height:28px"><span class="custom-check "' +
10182                 ' value="All" label="全选" ><i class="label"></i>全选</span></li>';
10183         }
10184         $options.each(function () {
10185             var checked = '';
10186             if (selectedItem[$(this).val()] != undefined) {
10187                 checked = 'cur';
10188             }
10189             $options_str += '<li class="ui-state-default" style="height:28px"><span class="custom-check ' + checked +
10190                 '" value="' + $(this).val() + '" label="' + $(this).text() + '' + '" title="' + $(this).text() + '"><i class="label"></i>' + $(this).text() + '</span></li>'
10191         });
10192
10193         $options_str += '</ul></div>';
10194         console.log($options_str)
10195         console.log(3)
10196         $("div.drop_down_sel").remove();
10197         var $select_obj = $('<div drop-down-selector="" filterlist="searchlist" class="drop_down_sel" style="position: absolute;">' + $options_str + '</div>');
10198         $el.find('div.select3-element').append($select_obj);
10199         $('body').off('click.sel').on('click.sel', function () {
10200             console.log(5);
10201             $('div.drop_down_sel').remove();
10202             $('.zTreeDemoBackground').css("display", "none");
10203             $(".search_input").css("display", "none");
10204         });
10205         $('div.drop_down_sel').off('click.sel').on('click.sel', function (event) {
10206
10207             event.stopPropagation();
10208         });
10209         console.log(6)
10210         $select_obj.find('input[name="query"]').on('keyup',
10211             function () {
10212                 var $el = $(this);
10213                 var inputs = $select_obj.find('.custom-check');
10214                 inputs.each(function () {
10215                     var val = $(this).attr('label');
10216                     var input_val = $el.val();
10217                     if (val.indexOf(input_val) > -1) {
10218                         $(this).closest('li').show();
10219                     } else {
10220                         $(this).closest('li').hide();
10221                     }
10222                 });
10223             });
10224
10225         $select_obj.find('.custom-check').on('click', function () {
10226             if (this.className.indexOf("readonly") > -1) {
10227                 return;
10228             }
10229             $(this).toggleClass('cur');
10230             if ($(this)[0].getAttribute("value") == "All") {
10231                 if (this.className.indexOf("cur") > -1) {
10232                     $($(this).parent().parent()).find(".custom-check").addClass("cur");
10233                 } else {
10234                     $($(this).parent().parent()).find(".cur").removeClass('cur');
10235                 }
10236             }
10237
10238             var set_valueleft = function (vals_selected) {
10239                 var $divContainer = "";
10240                 var selectedItem = {};
10241                 for (var i = 0; i < vals_selected.length; i++) {
10242                     $divContainer += '<div class="val-card ng-binding ng-scope ' + vals_selected[i].value +
10243                         'Class" ng-repeat="sel_val in sel_val_lst track by $index" ng-show="true" multiple="" load-data="" style="height:40px;line-height:25px;">' +
10244                         vals_selected[i].label + '<a onclick="xhSelect.rm_option(this,\'' + vals_selected[i].value +
10245                         '\')" ng-href="javascript:void(0);" href="javascript:void(0);">' + '  <i  class="icon iconfont icon-guanbijiantou"  val="' +
10246                         vals_selected[i].value + '" style="color:#20b4aa;"></i>' + ' </a>' + ' </div>';
10247                     selectedItem[vals_selected[i].value] = "1";
10248                 }
10249                 $divContainer += '<div class="suffix">' + '<i class="fa fa-angle-down" aria-hidden="true"></i>' + '</div>';
10250                 $el.find(".select-container").empty();
10251                 $el.find(".select-container").append($divContainer);
10252                 var selectedItemJson = JSON.stringify(selectedItem);
10253                 $el.find(".selectItme")[0].setAttribute("value", selectedItemJson);
10254                 $el.find(".select_get").trigger("change.value");//下拉框 公式
10255             };
10256             var vals_selected = [];
10257             var vals_selected_item = [];
10258             var checkboxChecked = false;
10259             var checkboxValue = $(this)[0].getAttribute("value");
10260             var checkboxLabel = $(this)[0].getAttribute("label");
10261             if ($(this)[0].className.indexOf('cur') > -1) {
10262                 checkboxChecked = true;
10263             }
10264             if (!isMultiple) {
10265                 vals_selected = [{
10266                     'value': checkboxValue,
10267                     'label': checkboxLabel
10268                 }];
10269                 set_valueleft(vals_selected);
10270                 console.log(7)
10271                 $('div.drop_down_sel').remove();
10272             } else {
10273                 var vls = [];
10274                 var values = $($(this).parent().parent()).find('.cur');
10275                 var j = 0;
10276                 for (var i = 0; i < values.length; i++) {
10277                     if (values[i].getAttribute("value") != "All") {
10278                         vals_selected[j] = {};
10279                         vals_selected[j].value = values[i].getAttribute("value");
10280                         vals_selected[j].label = values[i].getAttribute("label");
10281                         j++;
10282                     }
10283                 }
10284                 set_valueleft(vals_selected);
10285             }
10286         });
10287         event.stopPropagation();
10288     });
10289 }
10290
10291 //customBase.reCharge = function(){//重新记账  李伟民 2017-10-18 21:30
10292 //    //console.log(customBase);
10293 //    //console.log(customShow);
10294 //    var rePostData = {};
10295 //    rePostData['formID'] = customShow.options.formid;
10296 //    rePostData['dataRowNum'] = customShow.options.dataRowNum;
10297 //    var reCharge_request =  window.cloudAjax("epc-tenant/accounting/record",rePostData,"POST",true);
10298 //    reCharge_request.done(function(res){
10299 //        //console.log(res);
10300 //    })
10301 //}//重新记账  李伟民 2017-10-18 21:30 end
10302
10303 //customBase.checkItem = function(){//提交验证 李伟民2017-10-19 15:52
10304 //    //console.log(customBase);
10305 //    //console.log(customShow);
10306 //     //画面项目取得 --------------------------画面项目取得------
10307 //     var items = customShow.getItems();
10308 //         ////console.log(items)
10309 //     // 画面check
10310 //     var returnfromCheck =  customShow.initEvent.fromCheck(items); //--------------------
10311 //     if(returnfromCheck){
10312 ////      return;
10313 //     }
10314 //
10315 //
10316 //         var rules = customShow.options.jsonLinkage;
10317 //        if(!_.isNull(rules) && rules != undefined){
10318 //            rules = JSON.parse(rules);
10319 //            //console.log(rules);
10320 //            var checkId = [];
10321 //            _.each(rules,function(ru){
10322 //                _.each(ru.results,function(res){
10323 //                    if(res.mode == "2" || res.mode == "0"){
10324 //                        checkId.push(ru.event.eventFieldId);
10325 //                        return false;
10326 //                    }
10327 //                })
10328 //            });
10329 //            checkId = _.uniq(checkId);
10330 //            //console.log(checkId);
10331 //            _.each(checkId,function(cid){
10332 //                $("[id='" + cid + "']").trigger("change.check");
10333 //            });
10334 //        }
10335 //}//提交验证 李伟民2017-10-19 15:52 end
10336
10337 // function checkSameDay(day1, day2) {//判断是否为同一天  李伟民 2017-10-20 17:00
10338 //     var seconds;
10339 //     seconds = day1 - day2;
10340 //     //console.log(seconds);
10341 //     if (seconds < 24 * 60 * 60 * 1000 && seconds >= 0) {
10342 //         return true;
10343 //     } else {
10344 //         return false;
10345 //     }
10346 // }//判断是否为同一天  李伟民 2017-10-20 17:00 end
10347
10348 // customBase.checkTimeCross = function () {//跨行程验证时间 李伟民 2017-10-20 11:35
10349 //     //console.log(customBase);
10350 //     //console.log(customShow);
10351 //     var items = customShow.getItems();
10352 //     //console.log(items);
10353 //     var itemKey = _.keys(customBase.options.customItems);
10354 //     var subItem = [];
10355 //     _.each(itemKey, function (keys) {
10356 //         if (customBase.options.customItems[keys].type == "subform") {
10357 //             subItem.push(customBase.options.customItems[keys].fieldKey);
10358 //         }
10359 //     });
10360 //     var FromDateArr = [];
10361 //     var LeaveDateArr = [];
10362 //     //console.log(subItem);
10363 //     _.each(subItem, function (sub) {
10364 //         if (items[sub] != undefined) {
10365 //             _.each(items[sub], function (isub, i) {
10366 //                 if (isub.FromDate != undefined) {
10367 //                     FromDateArr.push({ "value": new Date(isub.FromDate), "num": i, "property": customBase.options.customItems['FromDate'] });
10368 //                 }
10369 //                 if (isub.LeaveDate != undefined) {
10370 //                     LeaveDateArr.push({ "value": new Date(isub.LeaveDate), "num": i, "property": customBase.options.customItems['LeaveDate'] });
10371 //                 }
10372 //             });
10373 //         }
10374 //     });
10375 //     //console.log(FromDateArr);
10376 //     //console.log(LeaveDateArr);
10377 //     if (FromDateArr.length > 1 && LeaveDateArr.length > 1 && FromDateArr.length == LeaveDateArr.length) {
10378 //         _.each(FromDateArr, function (fdate, k) {
10379 //             if (k > 0) {
10380 //                 //console.log(checkSameDay(fdate.value,LeaveDateArr[k-1].value));
10381 //                 if (checkSameDay(fdate.value, LeaveDateArr[k - 1].value) == false) {
10382 //                     var message = customShow.options.customItemShow.item[fdate.property.id].tag_Attribute.title + "与上一行程不连续";
10383 //                     customLinkageAnalysis.setMessage(fdate.property.id, message, k);
10384 //                 }
10385 //             }
10386 //         });
10387 //     }
10388 // }//跨行程验证时间 李伟民 2017-10-20 11:35 end
10389 // customBase.checkLandCross = function () {//跨行程验地点 李伟民 2017-10-20 11:35
10390 //     var items = customShow.getItems();
10391 //     //console.log(items);
10392 //     var itemKey = _.keys(customBase.options.customItems);
10393 //     var subItem = [];
10394 //     _.each(itemKey, function (keys) {
10395 //         if (customBase.options.customItems[keys].type == "subform") {
10396 //             subItem.push(customBase.options.customItems[keys].fieldKey);
10397 //         }
10398 //     });
10399 //     var FromLandeArr = [];
10400 //     var ToLandArr = [];
10401 //     _.each(subItem, function (sub) {
10402 //         if (items[sub] != undefined) {
10403 //             _.each(items[sub], function (isub, i) {
10404 //                 if (isub.From_site != undefined) {
10405 //                     FromLandeArr.push({ "value": isub.From_site[0], "num": i, "property": customBase.options.customItems['From_site'] });
10406 //                 }
10407 //                 if (isub.To_site != undefined) {
10408 //                     ToLandArr.push({ "value": isub.To_site[0], "num": i, "property": customBase.options.customItems['To_site'] });
10409 //                 }
10410 //             });
10411 //         }
10412 //     });
10413 //     if (FromLandeArr.length > 1 && ToLandArr.length > 1 && FromLandeArr.length == ToLandArr.length) {
10414 //         _.each(FromLandeArr, function (fland, k) {
10415 //             if (k > 0) {
10416 //                 customLinkageAnalysis.clearMessage(fland.property.id, k);
10417 //                 //console.log(fland.value != ToLandArr[k-1].value);
10418 //                 if (fland.value != ToLandArr[k - 1].value) {
10419 //                     var message = customShow.options.customItemShow.item[fland.property.id].tag_Attribute.title + "与上一行程不连续";
10420 //                     customLinkageAnalysis.setMessage(fland.property.id, message, k);
10421 //                 }
10422 //             }
10423 //         });
10424 //     }
10425 // }//跨行程验地点 李伟民 2017-10-20 11:35 end
10426 //自定义表单扩展函数 增加行 删除行
10427 customShow.addRow = function (subId, data) {
10428     console.log(data);
10429     console.log(subId);
10430     console.log($("#" + subId));
10431     console.log($("#" + subId).find(".trContentClass"));
10432     $("#" + subId).find(".trContentClass").remove();
10433     // console.log(data[0].length - 1);
10434     for (var i = 0; i < data[0].length; i++) {
10435         var itemId = subId;
10436         var showClass = "customViewUEditorCss";
10437         var item = customBase.options.customItems[customShow.options.customItemShow.item[itemId].tag_Attribute.alias].cloneDiv;
10438         //console.log(customShow.options)
10439         console.log(itemId, item)
10440         console.log(itemId, customBase.options.customItems)
10441         //子表单情况为U情况
10442         if (item == undefined) {// 子表单回显 修改  李伟民 11-10
10443             var tbody = $("." + showClass + " #" + itemId + "ActiveId").find("tbody");
10444             tbody = tbody[0].cloneNode(true);
10445             $(tbody).find(".select2").remove();
10446             console.log($(tbody).html());
10447             $(tbody).find(".tdTitleClass").closest("tr").addClass("table_title");
10448             $(tbody).find(".dropdowntypeCss").select2({ theme: "classic" });
10449             //        $(tbody).find(".zTreeDemoBackground").select2({theme: "classic"});
10450             if ($(tbody).find(".table_title").length > 0) {
10451                 //删除头行
10452                 $(tbody).find(".table_title").remove();
10453             }
10454             if ($(tbody).find(".trContentClass").length > 1) {// 去除重复的tr  李伟民 11-14
10455                 $($(tbody).find(".trContentClass")[0]).siblings().remove();
10456             }// 去除重复的tr  李伟民 11-14
10457             //        $(tbody).find(".cfg_contentNone").removeClass("cfg_contentNone");
10458             tbody = customShow.addsubformListInit(itemId, $(tbody).find("tr"));
10459             console.log(tbody);
10460             console.log(itemId);
10461             console.log($(tbody).find("#" + itemId).attr("class"));
10462             $($("." + showClass + " #" + itemId + "ActiveId").find("table")[0]).append(tbody);// 子表单回显 修改  李伟民 11-10
10463             customShow.hidesubform();
10464             customShow.setXhSelectList(false);//添加记录 重复问题  李伟民11-14
10465         } else {
10466             console.log(item);
10467             item = item[0].cloneNode(true);
10468             console.log(item);
10469             $(item).find(".select2").remove();
10470             $(item).find(".dropdowntypeCss").select2({ theme: "classic" });
10471
10472             $(item).find(".subformAddiconShow .cfg_contentNone").removeClass("cfg_contentNone");
10473             item = customShow.addsubformListInit(itemId, item);
10474             $($("." + showClass + " #" + itemId + "ActiveId").find("table")[0]).append(item);
10475
10476         }
10477         customShow.setXhSelectList(true);//添加记录 重复问题  李伟民11-14
10478         customShow.addtree(itemId, item);
10479         //子表单事件追加
10480         customShow.clickBindSubform();
10481         //公式初期化
10482         customLinkageAnalysis.bindLinkage();
10483         customShow.oneTotle();
10484         $('.iconfontcolor').on('click', function () {
10485             $(this).parent().parent().parent().remove();
10486         });
10487         console.log($(item))
10488         customShow.addtree(itemId, item);
10489     }
10490     var customItems = customBase.options.customItems;
10491     console.log(customItems)
10492     var order = $($("#" + subId + "ActiveId .trContentClass")[0]).find(".tdContentClass");
10493     var orderid = [];
10494     var orderObj = {};
10495     _.each(order, opt => {
10496         if ($(opt).find("div").children().eq(0).attr("id")) {
10497             orderid.push($(opt).find("div").children().eq(0).attr("id"));
10498         } else {
10499             orderid.push($(opt).find("div").children().eq(1).attr("id"));
10500         }
10501     });
10502     console.log(orderid);
10503     orderid.splice(0, 1);
10504     console.log(orderid);
10505     var subArr = [];
10506     console.log(subId)
10507     _.each(customItems, opt => {
10508         if (opt.parentsubFormNum == subId.replace("itemId_", "")) {
10509             subArr.push(opt);
10510         }
10511     });
10512     _.remove(subArr, n => {
10513         return n.fieldKey == "DATAROWNUM";
10514     })
10515     console.log(subArr);
10516     var endArr = [];
10517     _.each(orderid, opt => {
10518         var a = {};
10519         _.each(subArr, o => {
10520             if (opt == o.id) {
10521                 a = o;
10522             }
10523         });
10524         endArr.push(a);
10525     })
10526     console.log(endArr);
10527     console.log(data);
10528     _.each(endArr, (opts, i) => {
10529         console.log(opts.id, opts.type, data[i]);
10530         if (opts.type == "dropdownlist") {// 不可修改  控件type  李伟民  11-17
10531             customBase.setItemValue(opts.id, "dropdownlistText", data[i], "", "");
10532         } else {
10533             customBase.setItemValue(opts.id, opts.type, data[i], "", "");
10534         }
10535     });
10536     console.log(subId)
10537     customShow.subTotle(subId)
10538 };
10539 //关联表单控件  列表渲染
10540 createTable = function (rs, formId, formhuixian, head, $iconId, addVal) {
10541     var showVal = [];
10542     var iconAttr = customShow.options.customItemShow.item[$iconId];//关联数据 函数 数据源 李伟民  11-07
10543     //接收table内容请求
10544     var content = "";
10545     var counts = "";
10546     $(".requestMenu").empty();
10547     //渲染table头部变量;
10548     let headtr = "";
10549     //渲染table内容变量
10550     let contentdata = "";
10551     //表头渲染数据
10552     //console.log(head);
10553     _.remove(head, n => {
10554         return n.fieldKey == "DATAROWNUM";
10555     });
10556     _.each(head, opt => {
10557         headtr += '<td>' + opt.title + '</td>';
10558     });
10559     let head_tr = $("<tr class='headtr'></tr>");
10560     head_tr.append('<td class="td1">选择</td>' + headtr);
10561     $(".requestMenu").append(head_tr);
10562
10563     //console.log(rs)
10564     if (rs.data != undefined && !_.isNull(rs.data) && rs.data.count != undefined) {
10565         counts = rs.data.count;
10566     }
10567     if (rs.data != undefined && !_.isNull(rs.data)) {
10568         content = rs.data.list;
10569     } else {
10570         content = [];
10571     }
10572     // if(iconAttr.tag_Attribute.relevancesourcetype == "fundata"){
10573     //     codeContent = rs.data.list;
10574     // }else{
10575     //     codeContent = rs.data.code;
10576     // }
10577     console.log(content);
10578     if (content.length == 0) {
10579         var div_empty = $("<div><i style='width:20px;height:20px;' class='fa fa-envelope-o' aria-hidden='true'></i><p>您还没有数据显示</p></div>");
10580         $(".requestMenu").append(div_empty);
10581     } else {
10582         _.each(content, (opt) => {
10583             _.each(formhuixian, n => {
10584                 if (opt.DATAROWNUM == n.DATAROWNUM) {
10585                     opt.show = "cur";
10586                 }
10587             });
10588             var contentdata = "";
10589             _.each(head, opts => {
10590                 contentdata += '<td>' + opt[opts.fieldKey] + '</td>';
10591             });
10592             var tr = $("<tr class='bodytr'></tr>");
10593             tr.append('<td class="td1"><li class="checkLine"><span class="custom-check ' + opt.show + '"></span><i class="label"></i></li></td>' + contentdata);
10594             console.log(tr);
10595             $(".requestMenu").append(tr);
10596         });
10597     }
10598     //console.log(formhuixian);
10599
10600
10601     if (formhuixian != undefined) {
10602         addVal = formhuixian;
10603     }
10604     let show = "";
10605     var showObj = {};
10606     //选择方法
10607     head.push({ fieldKey: "DATAROWNUM", title: "DATAROWNUM" });
10608     //判断单选多选
10609     var selItem = customShow.options.customItemShow.item;
10610     console.log(selItem);
10611     var sel = "";
10612     var datarow = "";
10613     var tag_Id = "";
10614     console.log(selItem);
10615     for (let key in selItem) {
10616         if (key == $iconId) {
10617             sel = selItem[key].tag_Attribute.mytextSel;
10618             console.log(selItem[key].tag_Attribute.singleSetValue);
10619             if (selItem[key].tag_Attribute.singleSetValue != "itemId") {
10620                 datarow = JSON.parse(selItem[key].tag_Attribute.singleSetValue).columnOrderNum;
10621                 tag_Id = JSON.parse(selItem[key].tag_Attribute.singleSetValue).tag_Id;
10622             }
10623         }
10624     }
10625     console.log(sel)
10626     if (sel == "single") {
10627         $(".custom-check").on("click", function () {
10628             var addVals = [];
10629             var showVals = [];
10630             $(this).parent().parent().parent().siblings().find(".custom-check").removeClass('cur');
10631             $(this).toggleClass('cur');
10632             console.log($(this));
10633             console.log($(this).siblings());
10634             //            var showObj = {};
10635             let $index = $(this).parent().parent().parent().index() - 1;
10636             var check = $(".custom-check");
10637             console.log(check);
10638             _.each(check, opt => {
10639                 console.log(opt)
10640                 if ($(opt).hasClass('cur')) {
10641                     addVals.push(content[$(opt).parent().parent().parent().index() - 1]);
10642                     // showVals.push(content[$(opt).parent().parent().parent().index() - 1]);
10643                     // addVals.push(codeContent[$(opt).parent().parent().parent().index() - 1]);//填值时使用code  李伟民  12-05
10644                     // console.log(codeContent[$(opt).parent().parent().parent().index() - 1])
10645                 } else {
10646                     _.remove(addVals, n => {
10647                         return n.DATAROWNUM == content[$(opt).parent().parent().parent().index() - 1].DATAROWNUM;
10648                         // return n.DATAROWNUM == codeContent[$(opt).parent().parent().parent().index() - 1].DATAROWNUM;//填值时使用code  李伟民  12-05
10649                     });
10650                     // _.remove(showVals, n => {
10651                     //     return n.DATAROWNUM == content[$(opt).parent().parent().parent().index() - 1].DATAROWNUM;
10652                     // });
10653                 }
10654             });
10655             addVal = addVals;
10656             // showVal = showVals;
10657             console.log(addVal);
10658             console.log(datarow);
10659             customShow.sureonclick(addVal, $iconId, head, sel, iconAttr, datarow, formId);
10660         });
10661         console.log(addVal);
10662
10663     } else if (sel == "multiple") {
10664         $(".custom-check").on("click", function () {
10665             $(this).toggleClass('cur');
10666             //                var showObj = {};
10667             let $index = $(this).parent().parent().parent().index() - 1;
10668             if ($(this).hasClass('cur')) {
10669                 addVal.push(content[$index]);
10670                 // showVal.push(content[$index]);
10671                 // addVal.push(codeContent[$index]);//填值时使用code  李伟民  12-05
10672                 //console.log(content[$index])
10673             } else {
10674                 _.remove(addVal, n => {
10675                     return n.DATAROWNUM == content[$index].DATAROWNUM;
10676                     // return n.DATAROWNUM == codeContent[$index].DATAROWNUM;//填值时使用code  李伟民  12-05
10677                 });
10678                 // _.remove(showVal, n => {
10679                 //     return n.DATAROWNUM == content[$index].DATAROWNUM;
10680                 // });
10681             }
10682             customShow.sureonclick(addVal, $iconId, head, sel, iconAttr, datarow, formId);
10683         });
10684     }
10685     console.log(addVal);
10686     //选择方法END
10687     return counts;
10688 }
10689
10690 function createMxtTable($iconId, head, addVal) {// 关联数据渲染修改  李伟民 11-30
10691     console.log(head);
10692     console.log(addVal);
10693     if (head == "" || addVal == "" || head == undefined || addVal == undefined) {
10694         return false;
10695     }
10696     var tableBox = $("<table class='mxtdatatable table'></table>");
10697     var tableTitle = $("<tr></tr>");
10698     var tableBody = $("<tbody></tbody>");
10699     var tableHead = $("<thead></thead>");
10700     _.each(addVal, function (atd) {
10701         var tableContent = $("<tr></tr>");
10702         _.each(head, function (htd) {
10703             var td = '<td class="mxtdatatabletd">' + (atd[htd.fieldKey] ? atd[htd.fieldKey] : "") + '</td>';
10704             tableContent.append(td);
10705             var th = '<th>' + htd.title + '</th>';
10706             tableTitle.append(th);
10707         });
10708         tableBody.append(tableContent);
10709     });
10710     tableHead.append(tableTitle);
10711     tableBox.append(tableHead);
10712     tableBox.append(tableBody);
10713     $('#' + $iconId).append(tableBox);
10714 }// 关联数据渲染修改  李伟民 11-30
10715
10716 function setValByAnother(iconAttr, addVal, formId, head, typeflag) {//遍历对比别名相同填值 typefalg为true代表关联的是函数
10717     var datarowNum = addVal[0].DATAROWNUM;
10718     var postdata = {};
10719     var getCodeUrl = "";
10720     var ajaxtype = "";
10721     if (typeflag) {
10722         getCodeUrl = "/datamanagement/getAssociateData";
10723         postdata = { "formID": customShow.options.formid, "search": [], "pageSize": "1000", "pageNum": "1", "key": JSON.parse(iconAttr.tag_Attribute.fundata)['key'], "dataRowNum": datarowNum, "type": "code" };
10724         ajaxtype = "POST";
10725     } else {
10726         postdata = {
10727             "datarowNum": datarowNum,
10728             "formID": formId.formID
10729         };
10730         getCodeUrl = "/datamanagement/getSingleFormDataService";
10731         ajaxtype = "GET";
10732     }
10733
10734     console.log(postdata);
10735     var rquest = window.commonAjax(getCodeUrl, postdata, ajaxtype, true);
10736     rquest.done(function (res) {
10737         console.log(res);
10738         var rsdata = "";
10739         if (res.data && res.data.main != undefined) {
10740             if (typeflag) {
10741                 rsdata = res.data.list[0];
10742             } else {
10743                 rsdata = res.data.main;
10744             }
10745             console.log(iconAttr);
10746             console.log(rsdata);
10747             if (rsdata == undefined) {
10748                 return false;
10749             }
10750             _.each(customBase.options.customItems, opt => {
10751                 _.each(head, opts => {
10752                     if (opts.fieldKey == opt.fieldKey) {
10753                         if (opt.type == "dropdownlist") {
10754                             //                                if(customBase.getItemValue(opt.id,"dropdownlistText")[0].length == 0){
10755                             var item = customShow.options.customItemShow.item[opt.id];
10756                             var dropdowntype = item.tag_Attribute.dropdowntype;
10757                             customBase.setItemValue(opt.id, "dropdownlistText", res.data.main[opt.fieldKey], "", "");
10758                             //                            }
10759                         } else {
10760                             //                                if(!customBase.getItemValue(opt.id,opt.type)){
10761                             customBase.setItemValue(opt.id, opt.type, res.data.main[opt.fieldKey], "", "");
10762                             //                            }
10763                         }
10764                     };
10765                 })
10766             });
10767         }
10768
10769     });
10770
10771 }
10772
10773 customShow.sureonclick = function (addVal, $iconId, head, sel, iconAttr, datarow, formId) {
10774     console.log(datarow)
10775     $(".btn-primary").on("click", function () {
10776         var showObj = {};
10777         console.log(addVal);
10778         $('#' + $iconId).empty();
10779         //回显属性
10780         $("#" + $iconId).attr("formhuixian", JSON.stringify(addVal));
10781         var saveval = '';//关联数据空间 存值  李伟民  11-07
10782         var saveArr = [];
10783         _.each(addVal, function (v) {
10784             if (v.DATAROWNUM != undefined) {
10785                 saveArr.push(v.DATAROWNUM);
10786             }
10787         });
10788         saveval = saveArr.join();
10789         customBase.setItemValue($iconId, customShow.options.customItemShow.item[$iconId].tag_Type, saveval);//关联数据空间 存值  李伟民  11-07 end
10790         if (addVal != "" && addVal != undefined) {
10791             $("#" + iconAttr.tag_Id).attr("checkVal", JSON.stringify(addVal));//将选中值存储起来  用于验证
10792             $("#" + iconAttr.tag_Id).attr("checkHead", JSON.stringify(head));
10793         }
10794         var data2 = customShow.columnToRow(head, addVal);
10795         //子表单自动增加行
10796         var subId = $('#' + $iconId + "ActiveId").attr("choosesubform");
10797         console.log(subId);
10798         if (subId == "itemId") {
10799             createMxtTable($iconId, head, addVal);
10800             console.log(addVal);
10801             console.log(head);
10802             setValByAnother(iconAttr, addVal, formId, head);
10803             //遍历对比别名相同填值
10804             // _.each(customBase.options.customItems, opt => {
10805             //     _.each(head, opts => {
10806             //         if (opts.fieldKey == opt.fieldKey) {
10807             //             if (opt.type == "dropdownlist") {
10808             //                 //                                if(customBase.getItemValue(opt.id,"dropdownlistText")[0].length == 0){
10809             //                 var item = customShow.options.customItemShow.item[opt.id];
10810             //                 var dropdowntype = item.tag_Attribute.dropdowntype;
10811             //                 customBase.setItemValue(opt.id, "dropdownlistText", addVal[0][opt.fieldKey], "", "");
10812             //                 //                            }
10813             //             } else {
10814             //                 //                                if(!customBase.getItemValue(opt.id,opt.type)){
10815             //                 customBase.setItemValue(opt.id, opt.type, addVal[0][opt.fieldKey], "", "");
10816             //                 //                            }
10817             //                            }
10818             //         };
10819             //     })
10820             // });
10821         } else {
10822             console.log(addVal)
10823             if (sel == "single" && iconAttr.tag_Attribute.relevancesourcetype != "fundata") {
10824                 setValByAnother(iconAttr, addVal, formId, head)
10825                 //                    _.each(addVal,(opt,j)=>{
10826                 ////                        var ulBox = $("<ul></ul>");
10827                 //                        var ulBox = $("<table></table>");
10828                 //                        var sdata_head = "";
10829                 //                        var sdata_boby = "";
10830                 //                        for(var i = 0;i<head.length;i++){
10831                 //                            show = "";
10832                 //                            sdata_head += '<td class="data1 '+head[i].fieldKey+'">'+head[i].title+'</td>';
10833                 //                            sdata_boby += '<td class="data2 '+head[i].fieldKey+'">'+opt[head[i].fieldKey]+'</td>';
10834                 //                            show += '<li>'+'<span class="data1 '+head[i].fieldKey+'">'+head[i].title+'</span>'+'<span class="data2 '+head[i].fieldKey+'">'+opt[head[i].fieldKey]+'</span>'+'</li>';
10835                 //
10836                 //                            showObj[head[i].fieldKey] = opt[head[i].fieldKey];
10837                 //
10838                 //                            ulBox.attr("class","addUl ulBox"+j);
10839                 //                            ulBox.attr("id","ulBox"+j);
10840                 ////                            ulBox.append(show);
10841                 //                        }
10842                 //                        ulBox.append("<tr>"+sdata_head+"</tr><tr>"+sdata_boby+"</tr>");
10843                 //                        console.log(sdata_head);
10844                 //                        $('#'+$iconId).append(ulBox);
10845                 //                    });
10846                 createMxtTable($iconId, head, addVal);
10847                 var subdata = {};
10848                 console.log(datarow)
10849                 subdata.formdataNum = datarow;
10850                 subdata.datarowNum = addVal[0].DATAROWNUM;
10851                 subdata.formID = formId.formID;
10852                 var subformData = window.commonAjax("/datamanagement/getSubFormDataListService", subdata, "GET", true, false);
10853                 subformData.done(function (rs) {
10854                     console.log(rs.data);
10855                     var c_data = SC.cur_zero(rs.data);
10856                     console.log(c_data)
10857                     var rsArr = [];
10858                     _.each(c_data, opt => {
10859                         var opts = _.omit(opt, ['DATAROWNUM']);
10860                         rsArr.push(opts)
10861                     });
10862                     var rslength = _.keys(rsArr[0]).length;
10863                     console.log(rsArr);
10864                     var subId = $('#' + $iconId + "ActiveId").attr("choosesubform");
10865                     console.log($(".myipt"))
10866                     var formObj = window.localStorage.getItem("netformid");
10867                     var globalFormID = formObj;
10868                     var dataObj = {};
10869                     dataObj.formID = globalFormID;
10870                     var order_id = [];
10871                     //   11/25 李元杰 存flag
10872                     console.log(dataObj)
10873                     var requestRight = window.commonAjax("/datamanagement/getFormFieldListService", dataObj, "GET", true, false);
10874                     requestRight.done(function (rs) {
10875                         console.log(rs)
10876                         order_id = rs.data;
10877                     })
10878
13ec33 10879                     // var tenantID =JSON.parse(window.localStorage.getItem('tenantID'))
4d1219 10880                     // dataObj.tenantID= tenantID.tenantID;
B 10881
10882                     //          var order_ids = JSON.parse($(".myipt").val());
10883                     console.log(order_id);
10884                     //         console.log(order_ids)
10885
10886
10887                     if (customShow.options.customItemShow.item[$iconId].tag_Attribute.singleSetValue) {
10888                         var message = JSON.parse(customShow.options.customItemShow.item[$iconId].tag_Attribute.singleSetValue);
10889                     }
10890                     console.log(message.columnOrderNum)
10891
10892                     console.log(subId);
10893                     var subIds = subId.replace("itemId_", "")
10894                     console.log(subIds);
10895                     var orderArr = []; //存储关联表单内子表单的数组
10896                     _.each(order_id, opt => {
10897                         console.log(opt)
10898                         if (opt.parentsubFormNum == message.columnOrderNum) {
10899                             orderArr.push(opt);
10900                         }
10901                     });
10902                     _.remove(orderArr, n => {
10903                         return n.fieldKey == "DATAROWNUM";
10904                     })
10905                     console.log(orderArr);
10906                     orderArr = _.sortBy(orderArr, ['fieldOrderNum']);
10907                     var resArr = [];
10908                     for (i = 0; i < rslength; i++) {
10909                         resArr.push([])
10910                     }
10911                     console.log(rsArr);
10912                     console.log(orderArr)
10913                     _.each(rsArr, (opt, i) => {
10914                         var j = 0
10915                         _.each(orderArr, n => {
10916                             resArr[j][i] = opt[n.fieldKey]
10917                             j++;
10918                         })
10919                     });
10920                     console.log(resArr);
10921                     if (resArr.length == 0){
10922                         alert("上级预算为0");
10923                     } else {
10924                         customShow.addRow(subId, resArr);
10925                     }
10926                     $(".subformAdd").hide();
10927                     $(".subformAddiconShow").hide();
10928
10929                 });
10930             } else if (sel == "multiple" || iconAttr.tag_Attribute.relevancesourcetype == "fundata") {
10931                 console.log("fundata");
10932                 if (iconAttr.tag_Attribute.relevancesourcetype == "fundata") {//关联函数时 别名相同填值
10933                     setValByAnother(iconAttr, addVal, "", head, true);
10934                 }
10935                 createMxtTable($iconId, head, addVal);
10936                 $("#" + subId + "subformTr").nextAll().remove();
10937                 customShow.addRow(subId, data2);
10938                 $(".subformAdd").hide();
10939                 $(".subformAddiconShow").hide();
10940             }
10941         }
10942         console.log(customShow.customJs(subId))
10943         SC.setSubForm(customShow.customJs(subId), subId);
10944         if (addVal.length != 0) {
10945             SC.Superior_show()
10946         }
10947     });
10948 }
10949
10950 customShow.customJs = function (subId) {
10951     var subArr = [];
10952     console.log(subId)
10953     var customItems = customBase.options.customItems;
10954     console.log(customItems)
10955     _.each(customItems, opt => {
10956         if (opt.parentsubFormNum == subId.replace("itemId_", "")) {
10957             subArr.push(opt);
10958         }
10959     });
10960     _.remove(subArr, n => {
10961         return n.fieldKey == "DATAROWNUM";
10962     })
10963     console.log(subArr);
10964     var aliasArr = [];
10965     _.each(subArr, opt => {
10966         aliasArr.push(opt.fieldKey)
10967     })
10968     console.log(aliasArr);
10969     return aliasArr;
10970 }
10971
10972 //表单引用 扩展 回显子表单功能
10973 fenye = function (pageSize, pageNum, formId, sCondition, formhuixian, head, $iconId, addVal, anydata) {
10974     console.log($iconId);
10975     console.log("findmany");
10976     console.log(anydata);
10977     console.log(head);
10978     var iconAttr = customShow.options.customItemShow.item[$iconId];//关联数据 函数 数据源 李伟民  11-07
10979     console.log(iconAttr);
10980     var dataUrl = "";
10981     var dataObj;
10982     if (anydata) {
10983         //   alert('if');
10984     } else {
10985         //   alert("else");
10986     }
10987     if (iconAttr.tag_Attribute.relevancesourcetype && iconAttr.tag_Attribute.relevancesourcetype == "fundata") {
10988         dataUrl = "/datamanagement/getAssociateData";
10989         dataObj = { "formID": customShow.options.formid, "tenantID": "001", "search": [], "pageSize": pageSize, "pageNum": pageNum, "key": JSON.parse(iconAttr.tag_Attribute.fundata)['key'] };
10990         _.extend(dataObj, { "formData": customShow.getItems() });
10991     } else {
10992         dataUrl = "/datamanagement/getAssociatedFormDataService";
10993         dataObj = { "formID": formId.formID, "tenantID": "001", "screenCondition": sCondition, "pageSize": pageSize, "pageNum": pageNum, "search": anydata };
10994         window.localStorage.setItem("netformid", dataObj.formID);
10995     }
10996     //关联数据 函数 数据源 李伟民  11-07
10997     //    var dataObj = {"formID":formId.formID,"tenantID":"001","screenCondition":sCondition,"pageSize":pageSize,"pageNum":pageNum};
10998     //window.localStorage.setItem("netformid",dataObj.formID);
10999     var requestRight = window.commonAjax(dataUrl, dataObj, "POST", true, false);
11000     var counts = "";
11001     requestRight.done(function (rs) {
11002         if (iconAttr.tag_Attribute.relevancesourcetype && iconAttr.tag_Attribute.relevancesourcetype == "fundata") {
11003             // var titleObj = { "key": JSON.parse(iconAttr.tag_Attribute.fundata)['key'] };
11004             // var requestTitle = window.commonAjax("/datamanagement/getAssociateTitle", titleObj, "POST", true, false);
11005             // requestTitle.done(function (res) {
11006             //     var formtitle = [];
11007             //     _.each(res.data, function (tdata) {
11008             //         formtitle.push({ "fieldKey": tdata.fieldKey, "title": tdata.title });
11009             //     });
11010             counts = createTable(rs, formId, formhuixian, head, $iconId, addVal);
11011             // });
11012
11013         } else {
11014             counts = createTable(rs, formId, formhuixian, head, $iconId, addVal);//关联表单 列表回显
11015         }
11016
11017     });
11018     $('.closeBtn').on('click', () => {
11019         $('#' + $iconId + 'menuContent').remove();
11020         console.log($('.maskLayer'))
11021         $('.maskLayer').css('display', 'none');
11022     })
11023     return counts;
11024 }
11025 customShow.journeySort = function () {//行程排序 初始化 李伟民 2017-10-23 15:56
11026     //console.log(customShow);
11027     var itemKey = _.keys(customShow.options.customItemShow.item);
11028     _.each(itemKey, function (keys) {
11029         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 != "") {
11030             customShow.bindSort(customShow.options.customItemShow.item[keys].tag_Attribute.sorttype, keys);
11031         }
11032     });
11033     //    customShow.bindSort("itemId_6","itemId_3");
11034 }//行程排序 初始化 李伟民 2017-10-23 15:56 end
11035
11036 customShow.bindSort = function (sorttype, sub) {//排序事件绑定
11037     if (customShow.options.customItemShow.item[sorttype] == undefined) {
11038         return false;
11039     }
11040     var tagType = customShow.options.customItemShow.item[sorttype].tag_Type;
11041     if (tagType == "text" || tagType == "number" || tagType == "calendar") { //单行文本  数字 时间
11042         $("[id=" + sorttype + "]").unbind("change.sort", customShow.sortEvent);
11043         $("[id=" + sorttype + "]").on("change.sort", { msg: { "sorttype": sorttype, "type": tagType, "sub": sub } }, customShow.sortEvent);
11044     } else if (tagType == "dropdownlist") { // 下拉框
11045
11046     }
11047
11048 }
11049
11050 customShow.sortEvent = function (event) {//
11051     var sorttype = event.data.msg.sorttype;
11052     var type = event.data.msg.type;
11053     var sub = event.data.msg.sub;
7e9bb9 11054     var subType = customShow.options.customItemShow.item[sub].tag_Attribute.allcopy;
L 11055     console.log(event);
4d1219 11056     var allValue;
B 11057     var allItem = [];
11058     allValue = customBase.getItemValue(sorttype, type);
11059     if(_.isString(allValue)){
11060         allValue = [allValue];
11061     }
11062     //console.log(allValue);
11063     _.each(allValue, function (v, i) {
7e9bb9 11064         var optValue;
L 11065         if(type == "calendar"){
11066             optValue = new Date(v);
11067         }else if(type == "number"){
11068             optValue = Number(v)
11069         }else{
11070             optValue = v;
4d1219 11071         }
7e9bb9 11072         if(subType){
L 11073             allItem.push({ "value": optValue, "index": i, "temp": $("[id='" + sub + "ActiveId']:eq(" + i + ")").clone(true) });
11074         }else{
11075             allItem.push({ "value": optValue, "index": i, "temp": $("[id='" + sub + "subformTr']:eq(" + i + ")").clone(true) });
11076         }
13ec33 11077
4d1219 11078     });
B 11079     //console.log(allItem);
11080     var sortValue = _.sortBy(allItem, function (o) {
11081         return o.value;
11082     });
11083     console.log(sortValue);
7e9bb9 11084     if(subType){
L 11085         _.each($("[id='" + sub + "ActiveId']"), function (subform, k) {
11086             $(subform).replaceWith(sortValue[k].temp);
11087         })
11088     }else{
11089         _.each($("[id='" + sub + "subformTr']"), function (subform, k) {
11090             $(subform).replaceWith(sortValue[k].temp);
11091         })
11092     }
13ec33 11093
4d1219 11094     // customShow.controlInit("customShow");
B 11095     customLinkageAnalysis.bindLinkage();
11096     customShow.journeySort();
11097 }
11098 //马习同 2017/10/25
11099 $(".sTab ul li").on('click', function () {
11100     $(this).css('border-bottom', '2px solid #23b7e5');
11101     $(this).css('box-sizing', 'border-box');
11102     $(this).siblings().css('border', 'none');
11103     //console.log($($(".tabBox>div")[$(this).index()]));
449a85 11104     $($(".tabBox>div")[$(this).index()]).show();
4d1219 11105     $($(".tabBox>div")[$(this).index()]).siblings().hide();
449a85 11106     if($(this).index() == 0){//切换选项卡导致 保存按钮消失修改  李伟民 0201
L 11107         $(".tabBox .sure_box").show();
11108     }
4d1219 11109 });
B 11110 $(".tag_two").on("click", function () {
11111     //    $(".boxTwo iframe").attr("src","http://122.114.176.216:8087/#/IframeExample?token=C3CDE94FE9CBDDDD37312D3331AC091EC737F5555007677E45A390EFEC7147996A49AA4E117EDC02F0D15984E725CA3B5B93DDAF0C989C35642B58B29360D998DDDAC06EB509BE1C22B19D555A1BB75A07A36FD6C4A7E87C9C9EA0070A213BFB44FF8D3B2AD5A33086EAF1F22E978B24951EA806054F94042533CA73EA7901C5E8B13D4DB7DC87308266E769258DEDFF&openId=3dc22baf5d484170&tenantId=13&companyId=17& appId=1&processInstId=1483")
11112 })
11113 //马习同  11/7  行转化列
11114 customShow.columnToRow = function (head, addVal) {
11115     var data = []
11116     _.remove(head, n => {
11117         return n.fieldKey == "DATAROWNUM";
11118     })
11119     _.each(head, opt => {
11120         let data1 = [];
11121         _.each(addVal, opts => {
11122             data1.push(opts[opt.fieldKey]);
11123         });
11124         console.log(data1)
11125         data.push(data1)
11126     });
11127     return data;
11128 }
11129
11130 function submitErrShow(item,num){//审查必须错误提示 李伟民 0119
11131     console.log(item,num);
11132     var itemId = item.tag_Id;
11133     if(num == undefined){
11134         num = 0;
11135     }
11136     var mesageErrDiv = document.createElement("div");
11137     mesageErrDiv.setAttribute("class", "mesageErrDiv");
11138     $(mesageErrDiv).addClass('submitrErr');
8aa132 11139     var mesageErrStr = item.tag_Attribute.title + '不能为空(审查必须)';
4d1219 11140     mesageErrDiv.setAttribute("id", id + "mesageErrDiv");
8aa132 11141     $(mesageErrDiv).append(mesageErrStr);
L 11142     if(customShow.options.customInit.designMode != 1){//快捷模式 李伟民 0126
4d1219 11143         if ($(".customShow  #" + itemId + "ActiveId").length == 0) {
B 11144             console.log($(".customViewUEditorCss [id='" + itemId + "']:eq(" + num + ")").closest("td"));
11145             $(".customShow [id='" + itemId + "']:eq(" + num + ")").closest("td").append(mesageErrDiv);
11146             $(".customShow ." + itemId + "_showItem:eq(" + num + ")").append(mesageErrDiv);
11147         } else {
11148             $($($(".customShow  #" + itemId + "ActiveId")[num])[0]).append(mesageErrDiv);
11149         }
8aa132 11150     }else{//普通模式 李伟民 0126
L 11151         if ($(".customShow  #" + itemId).length == 0) {
11152             $($(".customShow  ." + itemId + "_showItem")[num]).css({
11153                 'height':"20px",
11154                 'display':'inline-block'
11155             })
11156             $($(".customShow  ." + itemId + "_showItem")[num]).popover({
11157                 // title:"错误信息",
11158                 html: true,
11159                 content: mesageErrStr,
11160                 trigger: 'hover'
11161             });
11162             $($(".customShow  ." + itemId + "_showItem")[num]).popover('show');
11163         } else {
11164             $($(".customShow  #" + itemId)[num]).popover({
11165                 // title:"错误信息",
11166                 html: true,
11167                 content: mesageErrStr,
11168                 trigger: 'hover'
11169             });
11170             $($(".customShow  #" + itemId)[num]).popover('show');
11171         }
11172     }
4d1219 11173 }
B 11174
11175 function submitCheck(){//提交前验证审查必须 李伟民 0119
11176     $('.submitrErr').remove();
11177     var checkFlag = true;
11178     var item = localStorage.getItem('customItem');
11179     if(item != undefined && item != ''){
11180         item = JSON.parse(item);
11181     }
11182     console.log(customBase);
13ec33 11183     console.log(customShow);
4d1219 11184     console.log(item);
B 11185     var allItemKey = _.keys(customBase.options.customItems);
11186     var allItemId = _.keys(customShow.options.customItemShow.item);
11187     var allItem = _.cloneDeep(customShow.options.customItemShow.item);
11188     var allItemValue = [];
11189     var childItem = [];
11190     var parentNums = [];
11191     var parentItem = {};
11192     _.each(allItemId,function(id){
11193         if(allItem[id].parentsubFormNum == 0){
11194             allItemValue.push(allItem[id]);
11195         }else{
11196             childItem.push(allItem[id]);
11197             parentNums.push(allItem[id].parentsubFormNum);
11198         }
11199     });
11200     _.each(parentNums,function(num){
11201         _.each(allItemId,function(id){
11202             if(num == allItem[id].columnOrderNum){
11203                 parentItem[num] = allItem[id];
11204             }
11205         });
11206     });
11207     _.each(childItem,function(cd){
11208         _.extend(cd,{'parentId':parentItem[cd.parentsubFormNum].tag_Attribute.alias});
11209     });
11210     allItemValue = _.concat(allItemValue,childItem);
11211     console.log(allItemValue);
11212     console.log(item);
11213     _.each(allItemValue,function(item_value){
11214         if(item_value.parentsubFormNum == 0){
11215             var value = item[item_value.tag_Attribute.alias]
11216             // _.extend(item_value,{'value':item[item_value.tag_Attribute.alias]});
11217             if(item_value.tag_Attribute.approvalmustenter){//审查必须属性
11218                 if(_.isArray(value)){
11219                     if(value.length == 0){
11220                         submitErrShow(item_value);
11221                         checkFlag = false;
11222                     }
11223                 }else if(value == '' || value == undefined){
11224                     submitErrShow(item_value);
11225                     checkFlag = false;
11226                 }
11227             }
11228         }else{
11229             var cd_value = [];
11230             _.each(item[item_value.parentId],function(sub){
11231                 cd_value.push(sub[item_value.tag_Attribute.alias]);
11232             });
11233             // _.extend(item_value,{'value':cd_value});
11234             _.each(cd_value,function(cval,k){
11235                 if(_.isArray(cval)){
11236                     if(cval.length == 0){
11237                         submitErrShow(item_value,k);
11238                         checkFlag = false;
11239                     }
11240                 }else if(cval == '' || cval == undefined){
11241                     submitErrShow(item_value,k);
11242                     checkFlag = false;
11243                 }
11244             })
11245         }
11246     });
11247     return checkFlag;
11248 }
11249
11250 //lym
11251 function get() {
11252         var checkFlag =  submitCheck();
11253         if(checkFlag != true){
11254             return false;
11255         }
11256         console.log(localStorage.getItem("organizationId"));
11257         console.log(localStorage.getItem("datarowNum"));
11258         //从local取出log
11259         var processLog = localStorage.getItem("processLog");
11260         var tenant = JSON.parse(localStorage.getItem("tenantID"));
11261         var cust = JSON.parse(localStorage.getItem("customItem"));
11262         //暂时修改流程lym
11263         // var org = cust.expend_department.trim();
11264         //暂时修改流程lym
11265         console.log(processLog);
11266         console.log(processLog !== null);
11267         //12/11
11268         if (processLog != "null") {
11269             var strMessage = customBase.getMessage("mesage_ID034");
11270             customBase.alert("E", strMessage);
11271             //return null;
11272         } else {
11273             //暂时修改流程lym
11274             // if (org == "" || org == undefined || org == null) {
11275             //     //var strMessage = customBase.getMessage("mesage_ID035");
11276             //     customBase.alert("E", "请选择部门");
11277             //     return null;
11278             // }
11279             //暂时修改流程lym
11280             // 画面check 提交前验证 李伟民 12-26
11281             // var returnfromCheck = customShow.initEvent.fromCheck(items); //--------------------
11282             // if (returnfromCheck) {
11283             // return;
11284             // }
11285             var ss = {
11286                 "tenantID": tenant.tenantID,
11287                 //"organizationId": org,
11288                 "formID": localStorage.getItem("newFormID"),
11289                 "dataRowNum": localStorage.getItem("datarowNum")
11290             }
11291             var requestSingleForm = window.commonAjax("/ubp-api-control/process/inst/create", ss, "POST", true);
11292             requestSingleForm.done(function (rs) {
11293                 console.log(rs);
11294                 if (rs.resCode == 00000) {
13ec33 11295
4d1219 11296                         customBase.alert('S', "提交成功");
B 11297                         $("#sssd").click();
13ec33 11298
4d1219 11299                 } else {
B 11300                     if (rs.data == '3') {
11301                         customBase.alert('E', "请先配置流程定义");
11302                         $("#sssd").click();
11303                     }else if(rs.data == '2'){
11304                         customBase.alert('E', "请不要重复提交");
11305                         $("#sssd").click();
11306                     } else {
11307                     customBase.alert('E', "提交失败");
11308                     $("#sssd").click();
11309                     }
11310                 }
11311             });
11312         }
13ec33 11313
4d1219 11314     }
B 11315 //lym结束后操作
11316 function over(data) {
11317     if (data == true) {
11318         //确定提交后操作
11319         var processLog = JSON.parse(localStorage.getItem("processLog"));
11320         console.log(processLog);
11321         var ss = {
11322             "processInstId": processLog[0].processInstId
11323         }
11324         console.log(ss);
11325         var requestSingleForm = window.commonAjax("/ubp-api-control/process/inst/over", ss, "POST", true);
11326         requestSingleForm.done(function (rs) {
11327             console.log(rs);
11328             if (rs.data == 1) {
449a85 11329                 customBase.alert('S',"结束成功");
4d1219 11330                 $("#sssd").click();
B 11331             } else {
449a85 11332                 customBase.alert("E","结束失败");
4d1219 11333             }
B 11334         });
11335
11336
11337
11338     } else {
11339         $("#sssd").click();
11340     }
11341 }
11342
11343 //lym退回确定后操作
11344 function tui(data, item) {
11345
11346     if (data == true) {
11347         console.log($('.actcur').val());
11348         if ($('.actcur').val() == undefined) {
449a85 11349             customBase.alert("W","请选择退回的活动");
4d1219 11350             return null;
B 11351         }
11352         var processLog = JSON.parse(localStorage.getItem("processLog"));
11353         var ss = {
11354             "activityInstId": processLog[0].activityInstId,
11355             "activityDefId": $('.actcur').val(),
11356             "processInstId": processLog[0].processInstId,
11357             "formID": localStorage.getItem("newFormID"),
11358             "dataRowNum": localStorage.getItem("datarowNum")
11359         }
11360         var requestSingleForm = window.commonAjax("/ubp-api-control/process/inst/bac", ss, "POST", true);
11361         requestSingleForm.done(function (rs) {
11362             console.log(rs);
11363
11364             if (rs.data == 1) {
449a85 11365                 customBase.alert("S","退回成功");
4d1219 11366                 $("#sssd").click();
B 11367             } else {
449a85 11368                 customBase.alert("E","退回失败");
4d1219 11369             }
B 11370         });
11371
11372
11373     } else {
11374         $("#sssd").click();
11375     }
11376 }
11377 //lym 审批确定后方法
11378 function zhixing(data) {
11379     console.log(data);
11380     console.log($("#datas").val());
11381     if (data == false) {
11382         $("#sssd").click();
11383     } else {
11384
11385         var processLog = JSON.parse(localStorage.getItem("processLog"));
11386         console.log(processLog[0].processInstId);
11387         var ss = {
11388             "processInstId": processLog[0].processInstId,
11389             "activityInstId": processLog[0].activityInstId,
11390             "data": $("#datas").val(),
11391             "formID": localStorage.getItem("newFormID"),
11392             "dataRowNum": localStorage.getItem("datarowNum"),
13ec33 11393             "token": localStorage.getItem("testToken"),//差旅token 特殊处理
4d1219 11394             "tenantId": localStorage.getItem("testTenantId"),
B 11395             "companyId": localStorage.getItem("testCompanyId"),
13ec33 11396
4d1219 11397         }
B 11398         console.log("标记token");
11399         var requestSingleForm = window.commonAjax("/ubp-api-control/process/inst/finish", ss, "POST", true);
11400         requestSingleForm.done(function (rs) {
11401             console.log(rs);
11402             if (rs.resCode == "00000") {
11403                 customBase.alert('S',"审批成功");
5a4f8f 11404                 $('#editableBtn').remove();//审批成功后不能编辑 李伟民 0129
4d1219 11405                 $("#sssd").click();
B 11406             } else {
11407                 customBase.alert('W',"审批失败");
11408             }
11409         });
11410     }
11411 }
11412 //2017.11.24  qld 追加预算
11413 customBase.budgetAddmoney = function () {
11414     var id = JSON.parse(localStorage.getItem("tenantID"))
11415     console.log(id.tenantID);
11416     var sub = JSON.parse(localStorage.getItem("customItem"));
11417     var submit_data = {
11418         "formId": localStorage.getItem("newFormID"),
11419         "netformid": localStorage.getItem("netformid"),
11420         "parentDataRowNum": localStorage.getItem("datarowNum"),
11421         "dataRowNum": localStorage.getItem("datarowNum"),
11422         "tenantID": id.tenantID,
11423         "formType": "ZJ"
11424     };
11425
11426     var submit_request = window.commonAjax1("epc-form/extend/budget/money", submit_data, "POST", true);
11427     submit_request.done(function (res) {
11428         if (res.resCode == 'C0000') {
11429             if (res.data == '1') {
11430                 var strMessage = customBase.getMessage("mesage_ID024");
11431                 customBase.alert("E", strMessage);
11432             } else if (res.data == '2') {
11433                 var strMessage = customBase.getMessage("mesage_ID025");
11434                 customBase.alert("E", strMessage);
11435             } else if (res.data == '3') {
11436                 var strMessage = customBase.getMessage("mesage_ID026");
11437                 customBase.alert("E", strMessage);
11438             } else if (res.data == '9') {
11439                 var strMessage = customBase.getMessage("mesage_ID027");
11440                 customBase.alert("S", strMessage);
11441             } else if (res.data == '7') {
11442                 var strMessage = customBase.getMessage("mesage_ID028");
11443                 customBase.alert("E", strMessage);
11444             }
11445
11446         }
11447
11448     })
11449
11450 }
11451
11452 customBase.budgetBackmoney = function () {
11453     var id = JSON.parse(localStorage.getItem("tenantID"))
11454     console.log(id.tenantID);
11455     var sub = JSON.parse(localStorage.getItem("customItem"));
11456     var submit_data = {
11457         "formId": localStorage.getItem("newFormID"),
11458         "netformid": localStorage.getItem("netformid"),
11459         "parentDataRowNum": localStorage.getItem("datarowNum"),
11460         "dataRowNum": localStorage.getItem("datarowNum"),
11461         "formType": "TH",
11462         "tenantID": id.tenantID
11463     };
11464
11465     var submit_request = window.commonAjax1("epc-form/extend/budget/money", submit_data, "POST", true);
11466     submit_request.done(function (res) {
11467         if (res.resCode == 'C0000') {
11468             if (res.data == '1') {
11469                 var strMessage = customBase.getMessage("mesage_ID024");
11470                 customBase.alert("E", strMessage);
11471             } else if (res.data == '2') {
11472                 var strMessage = customBase.getMessage("mesage_ID025");
11473                 customBase.alert("E", strMessage);
11474             } else if (res.data == '3') {
11475                 var strMessage = customBase.getMessage("mesage_ID026");
11476                 customBase.alert("E", strMessage);
11477             } else if (res.data == '9') {
11478                 var strMessage = customBase.getMessage("mesage_ID027");
11479                 customBase.alert("S", strMessage);
11480             } else if (res.data == '7') {
11481                 var strMessage = customBase.getMessage("mesage_ID028");
11482                 customBase.alert("E", strMessage);
11483             }
11484         }
11485
11486     })
11487
11488 }
11489 function repayment() {
11490     var customBase = window.customBase;
11491     customBase.repayment();
11492     return true;
11493 }
11494 customBase.repayment = function () {
11495     var id = JSON.parse(localStorage.getItem("tenantID"))
11496     console.log(id.tenantID);
11497     var sub = JSON.parse(localStorage.getItem("customItem"));
11498     console.log(sub);
11499     var subForm = sub.DATAROWNUM;
11500     console.log("我是" + subForm)
11501     var submit_data = {
11502         "formId": localStorage.getItem("newFormID"),
11503         "netformid": localStorage.getItem("netformid"),
11504         "parentDataRowNum": localStorage.getItem("datarowNum"),
11505         "datarowNum": localStorage.getItem("datarowNum"),
11506         "tenantId": id.tenantID
11507     };
11508
11509     var submit_request = window.commonAjax1("epc-form/repayment/money", submit_data, "POST", true);
11510     submit_request.done(function (res) {
11511         if (res.data == true) {
11512             //    12/7 qld
11513             var strMessage = customBase.getMessage("mesage_ID029");
11514             customBase.alert("S", strMessage);
11515         } else {
11516             var strMessage = customBase.getMessage("mesage_ID030");
11517             customBase.alert("E", strMessage);
11518         }
11519
11520     })
11521
11522 }
11523 //子表单合计方法   马习同   2017-12-06
11524 customShow.subTotle = function (subId) {
11525     var customItems = customBase.options.customItems;
11526     var numArr = [];
11527     var subArr = [];
11528     var numObj = {};
11529     _.each(customItems, opt => {
11530         if (opt.parentsubFormNum == subId.replace("itemId_", "")) {
11531             subArr.push(opt);
11532         }
11533     });
11534     _.remove(subArr, n => {
11535         return n.fieldKey == "DATAROWNUM";
11536     });
11537     _.each(subArr, opt => {
11538         if (opt.type == "number") {
11539             console.log(opt.id);
11540             numObj[opt.id] = customBase.getItemValue(opt.id, opt.type);
11541             numArr.push(Number(customBase.getItemValue(opt.id, opt.type)));
11542         }
11543     })
11544     console.log(numObj);
11545     for (let key in numObj) {
11546         var opts = [];
11547         if (_.isArray(numObj[key])) {
11548             _.each(numObj[key], n => {
11549                 n = Number(n);
11550                 console.log(n);
11551                 opts.push(n);
11552             })
11553             numObj[key] = opts;
11554         }
11555         console.log(numObj[key]);
11556     }
11557     console.log(numObj);
11558     //_.sum   求和
11559     for (let key in numObj) {
11560         $("." + key + "totle").val(_.sum(numObj[key]));
11561     }
11562
11563 }
11564 //子表单合计方法   马习同   2017-12-07
11565 customShow.oneTotle = function () {
11566     var customItems = customShow.options.customItemShow.item;
11567     var totleArr = [];
11568     var numObj = {};
11569     var numArr = [];
11570     _.each(customItems, opt => {
11571         console.log(opt.tag_Attribute.total)
11572         if (opt.tag_Attribute.total == true) {
11573             totleArr.push(opt.tag_Id);
11574             console.log(opt.tag_Id)
11575         }
11576     })
11577     console.log(totleArr);
11578     _.each(totleArr, opt => {
11579         $("#" + opt + " [type='number']").unbind("change.totle");
11580         $("#" + opt + " [type='number']").on("change.totle", function () {
11581             console.log($(this).attr("id"));
11582             numObj[$(this).attr("id")] = customBase.getItemValue($(this).attr("id"), $(this).attr("type"));
11583             console.log(_.cloneDeep(numObj));
11584             console.log(numObj[key])
11585
11586             for (let key in numObj) {
11587                 var opts = [];
11588                 if (_.isArray(numObj[key])) {
11589                     _.each(numObj[key], n => {
11590                         n = Number(n);
11591                         console.log(n);
11592                         opts.push(n);
11593                     })
11594                     numObj[key] = opts;
11595                 }
11596                 console.log(numObj[key]);
11597             }
11598
11599             console.log(numObj);
11600             //_.sum   求和
11601             for (let key in numObj) {
11602                 $("." + key + "totle").val(_.sum(numObj[key]));
11603             }
11604         })
11605     })
11606 }
11607 //子表单内的控件内容超出部分显示title
11608 customShow.addTitle = function () {
11609     _.each($(".customShow .tdContentClass"), opt => {
11610         // $(opt).attr("title", $(opt).children().children().html());
11611         console.log($(opt).html())
11612         if ($(opt).children().children().attr("type") == "text") {
11613             $(opt).attr("title", $(opt).children().children().val());
11614         } else {
11615             console.log(_.cloneDeep($(opt).children().children()))
11616             console.log(opt.innerHTML)
11617             console.log($(opt).children().children()[0].innerHTML)
11618             $(opt).attr("title", $(opt).children().children()[0].innerHTML);
11619         }
11620     })
11621 }
11622 // customShow.businessTypeAutoFun = function(key,fieldKey,cookieOrlocal){
11623 //     if(cookieOrlocal  == 'cookie'){
11624 //         if(customBase.options.customItems[fieldKey].parentsubFormNum == '0'){
11625 //             var businessTypeAuto = getCookie(key);
11626 //             customBase.setItemValue(customBase.options.customItems[fieldKey].id, customBase.options.customItems[fieldKey].type, businessTypeAuto, '', '');
11627 //         }
11628 //     }else{
11629 //         if(customBase.options.customItems[fieldKey].parentsubFormNum == '0'){
11630 //             var businessTypeAuto = window.localStorage.getItem(key);
11631 //             customBase.setItemValue(customBase.options.customItems[fieldKey].id, customBase.options.customItems[fieldKey].type, businessTypeAuto, '', '');
11632 //         }
11633 //     }
11634 // }
11635 // SC.billInfoInit = function(items){//票据信息初始化 李伟民 12-26
11636 //     var itemKey = _.keys(items);
11637 //     var customItems = customBase.options.customItems;
11638 //     customShow.allbillInfo = [];
11639 //     _.each(itemKey,function(key){
11640 //         console.log(key);
11641 //         if(customItems[key] != undefined && customItems[key] != '' && customItems[key].type == "subform"){
11642 //             var billInfos = [];
11643 //             _.each(items[key], function(journey, i){
11644 //                 if(journey.billData != undefined){
11645 //                     billInfos.push(JSON.parse(journey.billData));
11646 //                     $("#" + key + "ActiveId").attr('noBillCheck',JSON.parse(journey.billData));
11647 //                 }else{
11648 //                     billInfos.push({});
11649 //                 }
11650 //             });
11651 //             customShow.allbillInfo.push({
11652 //                 'subFormId':customItems[key].id,
11653 //                 'subFormKey':key,
11654 //                 'billInfos':billInfos
11655 //             })
11656 //         }
11657 //     });
11658 //     billInfobind(customShow.allbillInfo);
11659 //     SC.noBillCheckInit();
11660 // }
b84eca 11661 // SC.noBillCheckInit = function(){
L 11662 //     noBillCheck('journey','reimburseMan');
11663 // }
11664 // function noBillCheck(subFieldKey,reimburseManKey){//无票据行程及票据人员与报销人验证
11665 //     if(customBase.options.customItems[subFieldKey] == undefined){
11666 //         return false;
11667 //     }
11668 //     var subId = customBase.options.customItems[subFieldKey].id;
11669 //     var manId = customBase.options.customItems[reimburseManKey].id;
11670 //     var manType = customBase.options.customItems[reimburseManKey].type;
11671 //     var manTitle = customBase.options.customItems[reimburseManKey].title;
11672 //     var journeySub = $("#" + subId + "ActiveId");
11673 //     _.each(journeySub,function(jour){
11674 //         var checkData = $(jour).attr('noBillCheck');
11675 //         if(checkData != undefined && checkData != ''){
11676 //             checkData = JSON.parse(checkData);
11677 //             var manVal = customBase.getItemValue(manId,manType);
11678 //             if(manVal != undefined && manVal != checkData.PersonalVal){
11679 //                 $(jour).children('h8').append("<span class='billCheck'>" + "票据‘" + checkData.PersonalName + "’与" + manTitle + "不同</span>");
11680 //             }
11681 //         }else{
11682 //             $(jour).children('h8').append("<span class='billCheck'>无票据行程</span>");
11683 //         }
11684 //     });
11685 // }
11686 // function billInfobind(allbillInfo){//票据信息显示 及 实时验证  李伟民 12-26
11687 //     _.each(allbillInfo,function(info,k){
11688 //         var sub_type = customShow.options.customItemShow.item[info.subFormId].tag_Attribute.allcopy;
13ec33 11689
b84eca 11690 //         _.each(info.billInfos,function(binfo, i){
L 11691 //             if(binfo.billCode != undefined){
11692 //                 var itemKey = _.keys(binfo.billHeadMeaningMvCodeMap);
11693 //                 _.each(itemKey,function(key){
11694 //                     if(binfo.billHeadMap[key] != undefined && binfo.billHeadMap[key] != ''){
11695 //                         var bhName = binfo.billHeadMap[key].val;
11696 //                         var bhVal = binfo.billHeadMap[key].code;
11697 //                         billShow(sub_type,itemKey,bhName,bhVal,i);
11698 //                         if(sub_type && key == 'PersonalName'){//储存票据人员信息
11699 //                             var noBillCheckData = {
11700 //                                 "PersonalName":bhName,
11701 //                                 "PersonalVal":bhVal
11702 //                             };
11703 //                             $("#" + info.subFormId + "ActiveId:ep(" + k + ")").attr("noBillCheck",JSON.stringify(noBillCheckData));
11704 //                         }
11705 //                     }
11706 //                 });
13ec33 11707 //             }
b84eca 11708 //         });
L 11709 //     })
11710 // }
11711 // function billShow(sub_type,itemKey,bhName,bhVal,num){//票据信息验证绑定 李伟民 12-26
11712 //     var itemId = customBase.options.customItems[itemKey].id;
11713 //     var type = customBase.options.customItems[itemKey].type;
11714 //     if(sub_type){
11715 //         $("[id='"+itemId+"ActiveId']:eq('" + num + "')").find("h8[name='el_title']").append("<span class='billCheck'>" + bhName + "</span>");
11716 //     }else{
11717 //         customBase.set_p($("[id='"+itemId+"']:eq('" + num + "')"));
11718 //         if(type == 'dropdownlist'){
11719 //             $("[id='"+itemId+"']:eq('" + num + "')").closet("p").append("<span class='billCheck'>" + bhName + "</span>");
11720 //         }else{
11721 //             $("[id='"+itemId+"']:eq('" + num + "')").prev("p").append("<span class='billCheck'>" + bhName + "</span>");
11722 //         }
13ec33 11723
b84eca 11724 //     }
L 11725 //     if(type == 'dropdownlist'){
11726 //         $("[id='"+itemId+"']:eq('" + num + "')").find(".select_get").on('change.billcheck',function(){
11727 //             if(sub_type){
11728 //                 $("[id='"+itemId+"ActiveId']:eq('" + i + "')").find(".billCheck").css("color", "#333");
11729 //                 if($(this).val() != bhVal) {
11730 //                     $("[id='"+base_item_id+"ActiveId']:eq('" + i + "')").find(".billCheck").css("color", "red");
11731 //                 }
11732 //             }else{
11733 //                 $("[id='"+itemId+"']:eq('" + i + "')").closet("p").find(".billCheck").css("color", "#333");
11734 //                 if($(this).val() != bhVal) {
11735 //                     $("[id='"+itemId+"']:eq('" + i + "')").closet("p").find(".billCheck").css("color", "red");
11736 //                 }
11737 //             }
11738 //         });
11739 //     }else{
11740 //         $("[id='"+itemId+"']:eq('" + num + "')").on('change.billcheck',function(){
11741 //             if(sub_type){
11742 //                 $("[id='"+itemId+"ActiveId']:eq('" + i + "')").find(".billCheck").css("color", "#333");
11743 //                 if($(this).val() != bhVal) {
11744 //                     $("[id='"+itemId+"ActiveId']:eq('" + i + "')").find(".billCheck").css("color", "red");
11745 //                 }
11746 //             }else{
11747 //                 $("[id='"+itemId+"']:eq('" + i + "')").prev("p").find(".billCheck").css("color", "#333");
11748 //                 if($(this).val() != bhVal) {
11749 //                     $("[id='"+itemId+"']:eq('" + i + "')").prev("p").find(".billCheck").css("color", "red");
11750 //                 }
11751 //             }
11752 //         })
11753 //     }
624ff8 11754 // }