function AddNewForm () { var that = this; this.data = { target_name : "display.AddNew" , trigger_name : "display.AddNew.title" , o_GDD : null , key_list : "Company_SN,name" , dt_data : null , str_confirm_message : "確定新增資料?" , keep_form : 0 /* 新增完是否將表單停留在新增畫面 2008/06/25 by thomas */ , keep_form_clear : true /* 新增停留畫面時,是否清除舊資料 2008/06/25 by thomas */ , detail_dts : [] // added by thomas for detail , pos_left : 200 // added by thomas for detail , pos_top : 50 // added by thomas for detail , master_detail_key_list : "" // added by thomas for detail , active : 0 // added by thomas for detail AddNewForm 是否作用中 , detail_active : 0 // added by thomas for detail Detail 編輯 是否作用中 , detail_rows : [] // added by thomas for detail 編輯中的 detail row number -1 表示不是被編輯 , no_window : 0 // 不以 window 方式呈現 , $detail_default_value_lists : [] // added by thomas for detail default , $detail_editables : [] // detail 是否須編輯, detail default , auto_size : "1" , closing : 0 , delay_init : 1 // 設為1時, 在 form init 時, 不立刻 init, 等 form open 時才 init, 可加快表單開啟速度 , _opened : 0 // 是否被開啟過 , details : [] // 建立的 detail 物件 , details_all : [] // 建立的 detail 物件, 包含 L3 , current_index : 0 , fontsize : "13px" , animation : 1 , width : "" , _height : 800 , detail_search_elements : "" , grid_display_name : "" , flag_error : false , data_source : null , get_iguid : false , iGuid : "" , link_single_form : false , confirm_save : 1 , change_edit : 0 , _change_edit : 0 , initialize : function () { if (is_linkurl_edit) that.data.no_window = 1; if (that.data.no_window == 0) { $("display.AddNew.title").innerHTML = "新增資料"; } if (that.data.no_window == 0 || that.data.link_single_form) { // $j("").insertBefore( $j("[id='display.AddNew.form']")); } for (var i = 0; i < that.data.details.length; i++) { that.data.$detail_editables[i] = 0; if (that.data.details[i].detail_default_key_list != "" ) that.data.$detail_editables[i] = 0; // Detail Default } this.event_setting(); this.init_after(); } ,init_after : function() {} , event_setting : function () { var obj = this; set_element_event("btn.AddNew", "onclick", obj.open); set_element_event("btn.AddNew.cancel", "onclick", function () { that.data.close_action();}); set_element_event("btn.AddNew.save", "onclick", obj.save); // added by thomas for detail try { for (var i=0; i < that.data.details.length; i++) { $j("[name='btn." + that.data.details[i].AddNew_prefix + ".addDetail']").attr("TAG",i); set_element_event("btn." + that.data.details[i].AddNew_prefix + ".addDetail", "onclick", function () { obj.openDetail(-1, $j(this).attr("TAG"))}); $j("[name='btn." + that.data.details[i].AddNew_prefix + ".cancel']").attr("TAG",i); set_element_event("btn." + that.data.details[i].AddNew_prefix + ".cancel", "onclick", function() {obj.closeDetail( $j(this).attr("TAG"))}); $j("[name='btn." + that.data.details[i].AddNew_prefix + ".save']").attr("TAG",i); set_element_event("btn." + that.data.details[i].AddNew_prefix + ".save", "onclick", function() {obj.saveDetail($j(this).attr("TAG"))}); } } catch (e) {}; } , _show_detail : function (_details) { for (var i=0; itable").width(w - 50); $j("[id='" + that.data.target_name + "']").dialog( "option", "position", ['center','top'] ); } , form : { str_form_namespace : "display.AddNew.form" , str_form_name : "CMA001_AddNewForm" , str_template_name : "AddNewForm.htm" , str_template_no_new_line : "" , str_template_with_head : "" , str_template_no_td : "" , str_template_no_head : "" , str_form_template : "" , str_template_heading : "" , str_schema_name : "AddNewForm.xml" , display_name : "display.AddNew.form" , display_detail_name : "display.AddNewDetail.form" // added by thomas for detail , o_dg : new DataGridExp() , o_detail_dgs : [] // added by thomas for detail , o_Form : new clsForm() , dt_schema : new DataTable() , dt_detail_schemas : [] // added by thomas for detail , detail : 0 // added by thomas for detail 是否有 detail 表單 , _created : 0 , create : function () { if (that.data._opened == 0 && that.data.delay_init == 1) return; this.get_template(); this.get_schema(); with (this.o_dg) { flg_show_html = 1; flg_auto_breakline = 0; max_cols = 1000; dt = this.dt_schema; str_template = this.str_form_template; str_template_no_new_line = this.str_template_no_new_line; str_template_with_head = this.str_template_with_head; str_template_no_td = this.str_template_no_td; str_template_no_head = this.str_template_no_head ; str_template_heading = this.str_template_heading ; get_field_list(); $(this.display_name).innerHTML = GetDataGrid(); } if (this.detail == 1) // added by thomas for detail { } with (this.o_Form) { functions = g_functions; dt = this.dt_schema; str_namespace = this.str_form_namespace; str_form_name = this.str_form_name; check_detaildata = that.data.check_detaildata; create_form(); if (this.detail == 1) // added by thomas for detail { this.o_detail_dgs = []; var oldTABS = TABS; TABS = []; for (var i = 0; i < that.data.details_all.length; i++) { var index = that.data.details_all[i].index; if ( that.data.details_all[i].delay_create == 0) { this.o_detail_dgs[index] = new DataGridExp(); with (this.o_detail_dgs[index]) { flg_show_html = 1; flg_auto_breakline = 0; max_cols = 1000; var old_dt = dt; dt = this.dt_detail_schemas[index]; dt_detail = this.dt_detail_schemas[index]; if (that.data.form.str_template_name != that.data.details_all[i].AddNew_template_name) { str_template = o_Page.get_template(that.data.details_all[i].AddNew_template_name); str_template = str_template.ReplaceAll("%namespace%", that.data.form.str_form_namespace); str_template = str_template.ReplaceAll("%FormName%", that.data.form.str_form_name); } else str_template = that.data.form.str_form_template; // str_template = this.str_form_template; str_template_no_new_line = this.str_template_no_new_line; str_template_with_head = this.str_template_with_head; str_template_no_td = this.str_template_no_td; str_template_no_head = this.str_template_no_head ; str_template_heading = this.str_template_heading ; get_field_list(); if ( $(that.data.details_all[i]) != null) { $(that.data.details_all[i].AddNew_display_name).innerHTML = GetDataGrid(); create_form(); that.data.details_all[i].AddNew_form_created = 1 ; } dt = old_dt; } } } TABS = oldTABS; } } this.form_after_create(); that.data.form._created = 1; } ,form_after_create : function() {} , get_schema : function () { // modified for detail this.dt_schema = o_Page.get_schema_byNameSpace(this.str_schema_name,"AddNew"); this.dt_detail_schemas = []; for (var i = 0; i < that.data.details.length; i++) { this.dt_detail_schemas[i] = new DataTable() this.dt_detail_schemas[i] = o_Page.get_schema_byNameSpace(this.str_schema_name,that.data.details[i].AddNew_prefix); // added by thomas for detail for (var o = 0; o < that.data.details[i].child_details.length; o++) { this.dt_detail_schemas[i + "L3" + o] = new DataTable(); this.dt_detail_schemas[i + "L3" + o] = o_Page.get_schema_byNameSpace(this.str_schema_name,that.data.details[i].child_details[o].AddNew_prefix); // added by thomas for detail } } if (this.dt_detail_schemas.length > 0) if (this.dt_detail_schemas[0].MaxRow() > 0) this.detail = 1; // added by thomas for detail } , get_template : function () { this.str_form_template = o_Page.get_template(this.str_template_name); this.str_form_template = this.str_form_template.ReplaceAll("%namespace%", this.str_form_namespace); this.str_form_template = this.str_form_template.ReplaceAll("%FormName%", this.str_form_name); this.str_template_no_head = " %namespace%.%FormName%.%ELE_NAME% " ; this.str_template_no_td = " %namespace%.%FormName%.%ELE_NAME% " this.str_template_no_new_line = " %namespace%.%FormName%.%ELE_NAME% " this.str_template_with_head = " %TITLE% " + this.str_template_no_new_line this.str_template_heading = " %TITLE% " this.str_template_no_td = this.str_template_no_td.ReplaceAll("%namespace%", this.str_form_namespace); this.str_template_no_td = this.str_template_no_td.ReplaceAll("%FormName%", this.str_form_name); this.str_template_no_new_line = this.str_template_no_new_line.ReplaceAll("%namespace%", this.str_form_namespace); this.str_template_no_new_line = this.str_template_no_new_line.ReplaceAll("%FormName%", this.str_form_name); this.str_template_with_head = this.str_template_with_head.ReplaceAll("%namespace%", this.str_form_namespace); this.str_template_with_head = this.str_template_with_head.ReplaceAll("%FormName%", this.str_form_name); this.str_template_no_head = this.str_template_no_head.ReplaceAll("%namespace%", this.str_form_namespace); this.str_template_no_head = this.str_template_no_head.ReplaceAll("%FormName%", this.str_form_name); this.str_template_heading = this.str_template_heading.ReplaceAll("%namespace%", this.str_form_namespace); this.str_template_heading = this.str_template_heading.ReplaceAll("%FormName%", this.str_form_name); } , set_message : function (ele_name, str) { this.o_Form.set_message(ele_name, str); } , refresh_listbox : function(ele_name, row_no) { with (this.o_Form) { is_list_cached = false; dt = this.dt_schema; if (ele_name.indexOf("Detail") > 0) { var e = ele_name.split("."); var i = e[0].substr(e[0].length - 1, 1); var index = (i == "l" ? 0 : parseInt(i, 10)); if (that.data.details[index].master_detail_style == 0) { var old_dt2 = dt; dt = this.dt_detail_schemas[index]; refresh_listbox(ele_name,"Y"); dt = old_dt2; is_list_cached = true; return ; } } if (!refresh_listbox(ele_name,"Y")) { var old_dt2 = dt; var e = ele_name.split("."); var i = e[0].substr(e[0].length - 1, 1); var index = (i == "l" ? 0 : parseInt(i, 10)); is_list_cached = true; dt = this.dt_detail_schemas[index]; refresh_listbox(ele_name, "D", row_no); dt = old_dt2; } is_list_cached = true; } } , set_Tab : function() { if (TABS == "undefined") return; if (TABS.length > 0) { showTab("AddNew." + TABS[0]); } } } } }