diff --git a/web/App_Code/Model/Model.cs b/web/App_Code/Model/Model.cs index 9fee5c5..186ab2c 100644 --- a/web/App_Code/Model/Model.cs +++ b/web/App_Code/Model/Model.cs @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // 這個程式碼是由範本產生。 // @@ -187,6 +187,7 @@ namespace Model public string pageSize { get; set; } public string printSize { get; set; } public string defaultStyle { get; set; } + public Nullable sort_order { get; set; } public virtual actItem_kind actItem_kind { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] diff --git a/web/App_Code/Model/Model.edmx b/web/App_Code/Model/Model.edmx index 69cd63b..e012504 100644 --- a/web/App_Code/Model/Model.edmx +++ b/web/App_Code/Model/Model.edmx @@ -1,4 +1,4 @@ - + @@ -94,6 +94,7 @@ + @@ -607,8 +608,8 @@ - - + + @@ -1083,7 +1084,9 @@ - + + + @@ -1203,7 +1206,9 @@ - + + + @@ -1629,7 +1634,9 @@ - + + + @@ -1679,7 +1686,9 @@ - + + + @@ -1691,7 +1700,9 @@ - + + + @@ -3053,8 +3064,8 @@ - - + + diff --git a/web/App_Code/Model/Model.edmx.diagram b/web/App_Code/Model/Model.edmx.diagram index 5493ff5..877866e 100644 --- a/web/App_Code/Model/Model.edmx.diagram +++ b/web/App_Code/Model/Model.edmx.diagram @@ -9,7 +9,7 @@ - + diff --git a/web/App_Code/admin.cs b/web/App_Code/admin.cs index b970cc4..4de3c17 100644 --- a/web/App_Code/admin.cs +++ b/web/App_Code/admin.cs @@ -28,7 +28,7 @@ namespace MyWeb public AdmItem info { get; set; } //定義欄位cookie==================start - public class AdmItem + public class AdmItem { public int num { get; set; } public string u_id { get; set; } diff --git a/web/App_Code/api/FollowerController.cs b/web/App_Code/api/FollowerController.cs index eb581d9..88b228e 100644 --- a/web/App_Code/api/FollowerController.cs +++ b/web/App_Code/api/FollowerController.cs @@ -103,17 +103,18 @@ public class FollowerController : ApiController { foreach (var item in prod) { - foreach (var item2 in item.pro_order_detail1) - item2.from_id = null; //清空訂單明細的陽上報恩者from_id //f_num設定串聯刪除 + //foreach (var item2 in item.pro_order_detail1) + // item2.from_id = null; //清空訂單明細的陽上報恩者from_id //f_num設定串聯刪除 - foreach (var item2 in item.pro_order) - item2.introducer = null; + //foreach (var item2 in item.pro_order) + // item2.introducer = null; - item.leader = null;//清空leader + //item.leader = null;//清空leader + _db.followers.RemoveRange(prod); } - _db.followers.RemoveRange(prod); + //_db.followers.RemoveRange(prod); _db.SaveChanges(); Model.admin_log admin_log = new Model.admin_log(); @@ -150,8 +151,10 @@ public class FollowerController : ApiController qry = qry.Where(o => o.u_name.Contains(q.u_name.Trim())); if (q.birthday.HasValue) qry = qry.Where(o => o.birthday >= q.birthday.Value); - if (q.birthday2.HasValue) - qry = qry.Where(o => o.birthday < Convert.ToDateTime(q.birthday2.Value).AddDays(1)); + if (q.birthday2.HasValue) { + var tmpBirthday2 = Convert.ToDateTime(q.birthday2.Value).AddDays(1); + qry = qry.Where(o => o.birthday < tmpBirthday2); + } if (!string.IsNullOrEmpty(q.address)) qry = qry.Where(o => o.address !=null && o.address.Contains(q.address.Trim())); //if (q.num.HasValue && q.num.Value>0) @@ -173,7 +176,7 @@ public class FollowerController : ApiController } } - + // 電話/證號搜尋 (使用 search_keywords HEX 編碼) if (!string.IsNullOrEmpty(q.phone_idcode) && GlobalVariables.UseSearchKeywords) { @@ -655,8 +658,10 @@ public class FollowerController : ApiController list = orderrecord.Select(x => new { orderno = x.order_no, - startdate = x.reg_time, - endtime = x.up_time, + //startdate = x.reg_time, + //endtime = x.up_time, + startdate = x.activity.startDate_solar, + enddate = x.activity.endDate_solar, pwcount = x.pro_order_detail.Where(a => a.actItem.act_bom.Where(b => b.item_num == a.actItem_num && b.package_num == null).Count() == 0).Count(), amount = x.pro_order_detail.Select(o => (float?)o.price).Sum(), activityname = x.activity.subject, diff --git a/web/App_Code/api/activityController.cs b/web/App_Code/api/activityController.cs index 8a2c8c4..a379a98 100644 --- a/web/App_Code/api/activityController.cs +++ b/web/App_Code/api/activityController.cs @@ -1,14 +1,18 @@ -using System; +using DocumentFormat.OpenXml.Drawing.Spreadsheet; +using Model; +using Newtonsoft.Json; +using Org.BouncyCastle.Crypto; +using PagedList; +using System; +using System.Collections; using System.Collections.Generic; +using System.Data.Entity; using System.Linq; using System.Net; using System.Net.Http; using System.Web.Http; -using PagedList; -using Newtonsoft.Json; -using System.Collections; +using System.Web.Services; using static TreeView; -using System.Data.Entity; // api/activity //[ezAuthorize(Roles = "admin")]//群組:* @@ -126,6 +130,12 @@ public class activityController : ApiController if (prod != null) { ////prod.IsDel = true; ////不確定是否新增欄位? 先註解 + + // 先刪除子項目 + var prod2 = _db.act_bom.Where(q => q.package_num == prod.num).ToList(); + _db.act_bom.RemoveRange(prod2); + + _db.actItems.Remove(prod); _db.SaveChanges(); Model.admin_log admin_log = new Model.admin_log(); MyWeb.admin admin = new MyWeb.admin();//api裡不可以用MyWeb @@ -190,12 +200,18 @@ public class activityController : ApiController if (prod.Count() > 0) { //var prod2 = _db.actItem_files.AsEnumerable().Where(q => ids.Contains(Convert.ToInt32(q.actItem_num))).ToList(); - var prod2 = _db.actItem_files.Where(q => ids.Contains(q.actItem_num)).ToList(); - if (prod2.Count > 0) - { - _db.actItem_files.RemoveRange(prod2); - //_db.SaveChanges(); - } + //var prod2 = _db.actItem_files.Where(q => ids.Contains(q.actItem_num)).ToList(); + //if (prod2.Count > 0) + //{ + // _db.actItem_files.RemoveRange(prod2); + // //_db.SaveChanges(); + //} + + // 先刪除子項目 + var parentBoms = _db.act_bom.Where(q => q.item_num.HasValue && ids.Contains(q.item_num.Value)).ToList(); + var parentIds = parentBoms.Select(x => x.num).ToList(); // 取得母件 id + var childBoms = _db.act_bom.Where(q => q.package_num.HasValue && parentIds.Contains(q.package_num.Value)).ToList(); + _db.act_bom.RemoveRange(childBoms); _db.actItems.RemoveRange(prod); _db.SaveChanges(); @@ -314,6 +330,36 @@ public class activityController : ApiController return Ok(ret); } + public class SortOrderRequest + { + public List ids { get; set; } + } + + [HttpPost] + [Route("api/activity/SaveItemList")] + public IHttpActionResult UpdateSortOrder([FromBody] SortOrderRequest request) + { + if (request == null || request.ids == null) return BadRequest(); + + using (Model.ezEntities _db = new Model.ezEntities()) + { + int totalCount = request.ids.Count; + + for (int i = 0; i < totalCount; i++) + { + int id = request.ids[i]; + var item = _db.actItems.FirstOrDefault(x => x.num == id); + if (item != null) + { + // 改成總數減去索引,這樣第一筆 (i=0) 會拿到最大的數字 + item.sort_order = totalCount - i; + } + } + _db.SaveChanges(); + } + return Ok(); + } + [HttpPost] [Route("api/activity/GetItemList")] public IHttpActionResult GetItemList([FromBody] Model.ViewModel.actItem q, int page, int pageSize = 10, @@ -418,8 +464,14 @@ public class activityController : ApiController else qry = qry.OrderBy(o => o.status); } - else + else if (sortBy.Equals("num")) + { qry = qry.OrderByDescending(o => o.num); + } + else + { + qry = qry.OrderByDescending(o => o.sort_order); + } var tdesc = publicFun.enum_desc(); var count = qry.Count(); //pageSize = count;//一次取回?? @@ -1303,7 +1355,7 @@ public class activityController : ApiController [Route("api/activity/OrderCheckIn")] public IHttpActionResult OrderCheckIn([FromBody] Model.activity_check item) { - if (item.f_num.HasValue && item.activity_num.HasValue && item.qty.HasValue && item.status.HasValue) + if (item.f_num.HasValue && item.activity_num.HasValue && item.status.HasValue) { //同一天不能簽到兩次以上 Model.activity_check check = _db.activity_check diff --git a/web/App_Code/api/orderController.cs b/web/App_Code/api/orderController.cs index 761e939..8788621 100644 --- a/web/App_Code/api/orderController.cs +++ b/web/App_Code/api/orderController.cs @@ -1,17 +1,19 @@ -using System; +using DocumentFormat.OpenXml.Drawing.Charts; +using Model; +using MyWeb; +using Newtonsoft.Json; +using PagedList; +using System; +using System.Activities.Expressions; +using System.Collections; using System.Collections.Generic; +using System.Diagnostics; +using System.IdentityModel.Metadata; using System.Linq; using System.Net; using System.Net.Http; using System.Web.Http; -using PagedList; -using Newtonsoft.Json; -using System.Collections; using static TreeView; -using Model; -using System.IdentityModel.Metadata; -using MyWeb; -using DocumentFormat.OpenXml.Drawing.Charts; // api/order @@ -206,7 +208,7 @@ public class orderController : ApiController string sortBy = "", bool sortDesc = false) { - var qry = _db.pro_order.AsQueryable(); + var qry = _db.pro_order.Include("activity").Include("activity.activity_check").AsQueryable(); //var aIDt = _db.actItems.AsEnumerable().Where(f => f.subject.Contains(q.actItemTxt.Trim())).Select(f => f.num);//品項 @@ -221,7 +223,10 @@ public class orderController : ApiController if (q.up_time1.HasValue) qry = qry.Where(o => o.up_time >= q.up_time1.Value); if (q.up_time2.HasValue) - qry = qry.Where(o => o.up_time < Convert.ToDateTime(q.up_time2.Value).AddDays(1)); + { + var tmp_up_time2 = Convert.ToDateTime(q.up_time2.Value).AddDays(1); + qry = qry.Where(o => o.up_time < tmp_up_time2); + } if (!string.IsNullOrEmpty(q.address)) qry = qry.Where(o => o.address.Contains(q.address.Trim())); if (!string.IsNullOrEmpty(q.subject)) @@ -291,6 +296,13 @@ public class orderController : ApiController else qry = qry.OrderBy(o => o.activity != null ? o.activity.subject : ""); } + else if(sortBy.Equals("status")) + { + if (sortDesc) + qry = qry.OrderByDescending(o => o.activity.activity_check.FirstOrDefault(a => o.activity_num == a.activity_num && o.f_num == a.f_num).status ?? 0); + else + qry = qry.OrderBy(o => o.activity.activity_check.FirstOrDefault(a => o.activity_num == a.activity_num && o.f_num == a.f_num).status ?? 0); + } else qry = qry.OrderByDescending(o => o.reg_time); @@ -307,6 +319,7 @@ public class orderController : ApiController keyin1 = x.keyin1, up_time = x.up_time, keyin1_txt = Model.pro_order.keyin1_value_to_text(x.keyin1), + status = x.activity.activity_check.FirstOrDefault(a => x.activity_num == a.activity_num && x.f_num == a.f_num)?.status ?? 0, }), count = count }; @@ -684,7 +697,7 @@ public class orderController : ApiController .Where(q => q.num == item.num) .FirstOrDefault();//修改 if (order != null) - { + { order.actItem_num = (item.actItem_num.HasValue && item.actItem_num.Value > 0) ? item.actItem_num : null; order.f_num = (item.f_num.HasValue && item.f_num.Value > 0) diff --git a/web/admin/Templates/TBS5ADM001/uc/menu.ascx b/web/admin/Templates/TBS5ADM001/uc/menu.ascx index cd408e4..153319a 100644 --- a/web/admin/Templates/TBS5ADM001/uc/menu.ascx +++ b/web/admin/Templates/TBS5ADM001/uc/menu.ascx @@ -16,6 +16,8 @@ " + onclick="sessionStorage.removeItem('member_list_cache'); sessionStorage.removeItem('member_query_params'); + sessionStorage.removeItem('order_list_cache'); sessionStorage.removeItem('order_query_params');" target="<%#(ValString(Eval("target"))=="B"?"_blank":"_self") %>"> <%#Eval("title") %> diff --git a/web/admin/activity/index2.aspx b/web/admin/activity/index2.aspx index 524c8dc..973af5b 100644 --- a/web/admin/activity/index2.aspx +++ b/web/admin/activity/index2.aspx @@ -7,19 +7,20 @@
<%--
--%> -
+ +
-
- 匯出Excel + 編輯排列順序 + 完成編輯 +
+ + 匯出Excel -
+
- +
- + + + @@ -352,12 +453,12 @@ -
+
\ No newline at end of file diff --git a/web/admin/follower/reg.aspx.cs b/web/admin/follower/reg.aspx.cs index a3be434..d0e2c4d 100644 --- a/web/admin/follower/reg.aspx.cs +++ b/web/admin/follower/reg.aspx.cs @@ -1,34 +1,44 @@ -using System; +using Model; +using Newtonsoft.Json; +using System; using System.Collections; using System.Collections.Generic; +using System.Configuration; using System.Data; +using System.Data.Entity; using System.Data.OleDb; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; -using System.Configuration; -using System.IO; -using System.Linq; -using System.Globalization; -using Model; public partial class admin_follower_reg : MyWeb.config { private Model.ezEntities _db = new Model.ezEntities(); public ArrayList _tmp = new ArrayList(); + public bool isDataChanged = false; + public bool isAutoNumbering = ConfigurationManager.AppSettings["IsAutoNumbering"].ToString() == "true" ? true : false; protected void Page_Load(object sender, EventArgs e) { CallAjax(); if (!IsPostBack) - { + { InitEnumsOptions(identity_type); //身分別 //var qry = _db.followers.AsEnumerable(); - var qry = _db.followers.AsQueryable(); - + var qry = _db.followers.AsQueryable(); + if (isStrNull(Request["num"])) { + if (!isAutoNumbering) + { + f_number.ReadOnly = false; + } + if (!isStrNull(Request["leader"])) { int _num = Val(Request["leader"]); @@ -50,9 +60,14 @@ public partial class admin_follower_reg : MyWeb.config //預設國籍 country.Value = "158"; country_txt.Value = "中華民國(台灣)"; + + // 預設加入日期 + join_date.Text = DateTime.Now.ToString("yyyy-MM-dd"); } else { + f_number.ReadOnly = true; + int _num = Val(Request["num"]); var prod = qry.Where(q => q.num == _num).FirstOrDefault(); if (prod != null) @@ -206,8 +221,11 @@ public partial class admin_follower_reg : MyWeb.config } } } - // 使用新的 generate_f_number 方法,已內建重號檢查和重試機制 - followers.f_number = follower.generate_f_number(sex.SelectedValue); + if (isAutoNumbering) + { + // 使用新的 generate_f_number 方法,已內建重號檢查和重試機制 + followers.f_number = follower.generate_f_number(sex.SelectedValue); + } followers.identity_type = Val(identity_type.SelectedValue); if(!isStrNull(leader.Value)) followers.leader = Val(leader.Value); if (!isStrNull(country.Value)) followers.country = country.Value; @@ -239,7 +257,9 @@ public partial class admin_follower_reg : MyWeb.config Model.admin_log admin_log = new Model.admin_log(); admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Follower, (int)Model.admin_log.Status.Insert, f_number.Text + u_name.Text); - + + Session["LastAddedID"] = followers.f_number; + Response.Redirect("index.aspx"); } else @@ -282,7 +302,7 @@ public partial class admin_follower_reg : MyWeb.config try { foreach (Control obj in cardBodyPanel.Controls) - { + { if (obj is TextBox) { var ObjValue = followers.GetType().GetProperty(obj.ID); @@ -300,7 +320,7 @@ public partial class admin_follower_reg : MyWeb.config ObjValue.SetValue(followers, null); } - + } @@ -310,22 +330,60 @@ public partial class admin_follower_reg : MyWeb.config followers.sex = sex.SelectedValue; followers.blood = blood.SelectedValue; followers.tab = tab.Value.Trim(','); - followers.admin_log = admin.info.u_id + " " + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); + //followers.admin_log = admin.info.u_id + " " + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); followers.follower_hash = encrypt.followerHash(followers.phone, followers.id_code); - + // 如果啟用 search_keywords 功能,生成並更新 search_keywords if (GlobalVariables.UseSearchKeywords) { followers.search_keywords = encrypt.GenerateSearchKeywords(followers); } - - _db.SaveChanges(); - Model.admin_log admin_log = new Model.admin_log(); - admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Follower, (int)Model.admin_log.Status.Update, f_number.Text + u_name.Text); + // 檢查是否有修改資料 + var entry = _db.Entry(followers); + this.isDataChanged = entry.CurrentValues.PropertyNames.Any(name => + { + if (name == "admin_log" || name == "follower_hash") + return false; - Response.Redirect("index.aspx?page=" + Convert.ToString(Request["page"])); + var originalVal = entry.OriginalValues[name]?.ToString(); + var currentVal = entry.CurrentValues[name]?.ToString(); + // 針對加密欄位進行特殊處理 + bool isEncryptedField = (name == "phone" || name == "id_code"); + + if (isEncryptedField) + { + string originalPlain = !string.IsNullOrEmpty(originalVal) ? encrypt.DecryptAutoKey(originalVal) : ""; + string currentPlain = !string.IsNullOrEmpty(currentVal) ? encrypt.DecryptAutoKey(currentVal) : ""; + return originalPlain.Trim() != currentPlain.Trim(); + } + + return !object.Equals(originalVal, currentVal); + }); + + if (this.isDataChanged) + { + followers.admin_log = admin.info.u_id + " " + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); + } + else + { + entry.State = EntityState.Unchanged; + } + + int isDataSaved = _db.SaveChanges(); + if (isDataSaved > 0) + { + //L_msg.Type = alert_type.success; + //L_msg.Text = "修改成功"; + Model.admin_log admin_log = new Model.admin_log(); + admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Follower, (int)Model.admin_log.Status.Update, f_number.Text + u_name.Text); + Response.Redirect("index.aspx?dirty=1&page=" + Convert.ToString(Request["page"])); + } + else + { + Response.Redirect("index.aspx?page=" + Convert.ToString(Request["page"])); + } } catch (Exception ex) { @@ -339,7 +397,7 @@ public partial class admin_follower_reg : MyWeb.config L_msg.Type = alert_type.danger; L_msg.Text = "查無資料"; } - /* + /* if (chk_pro_num(f_number.Text, Val(Request["num"]))) { } @@ -349,7 +407,7 @@ public partial class admin_follower_reg : MyWeb.config L_msg.Text = "信眾編號重複"; } */ - } + } } #endregion diff --git a/web/admin/index.aspx b/web/admin/index.aspx index 54ae257..95fede5 100644 --- a/web/admin/index.aspx +++ b/web/admin/index.aspx @@ -85,7 +85,7 @@
- 登入
+ diff --git a/web/admin/menu.ascx b/web/admin/menu.ascx index b379ba8..8647bdc 100644 --- a/web/admin/menu.ascx +++ b/web/admin/menu.ascx @@ -8,7 +8,7 @@
    -
  • " +
  • " target="<%#(ValString(Eval("target"))=="B"?"_blank":"_self") %>"><%#Eval("title") %>
  • diff --git a/web/admin/order/index.aspx b/web/admin/order/index.aspx index f4e13da..974a16e 100644 --- a/web/admin/order/index.aspx +++ b/web/admin/order/index.aspx @@ -14,17 +14,18 @@ 列印管理報表 - - @@ -39,6 +40,8 @@ vuetify: new Vuetify(vuetify_options), data() { return { + print_error_msg: "", + isSearched: false, this_act : '<%= Request["act_id"]%>', options: { multiSort: false }, search_options: { multiSort: false }, @@ -56,6 +59,7 @@ { text: '報名日期', value: 'up_time' }, { text: '報名活動', value: 'subject', align: 'start' }, { text: '單據狀態', value: 'keyin1_txt' }, + { text: '報到狀態', value: 'status' }, { text: '', value: 'slot_btn', sortable: false, align: 'end' } ], footer:{ @@ -203,6 +207,10 @@ } }, mounted() { + const printResult = document.getElementById('<%= hid_err_msg.ClientID %>').value; + document.getElementById('<%= hid_err_msg.ClientID %>').value = ''; + window._printResult = printResult + this.detalKeyinArray(); this.search_dialog.current = this.search_dialog.controls.search1 ///default if (this.this_act != '') @@ -211,20 +219,63 @@ this.initActivity(); const navEntries = performance.getEntriesByType("navigation"); const isReload = navEntries.length > 0 && navEntries[0].type === "reload"; + if (isReload) { sessionStorage.removeItem("orderpage"); + sessionStorage.removeItem("order_list_cache"); + sessionStorage.removeItem("order_query_params"); + } + else if ("<%=lastAddedNo%>" !== "") { + const newQuery = { order_no: '<%=lastAddedNo%>' }; + sessionStorage.setItem('order_query_params', JSON.stringify(newQuery)); + this.search = newQuery; + this.isSearched = true; } else { const savedPage = parseInt(sessionStorage.getItem('orderpage')); + const savedData = sessionStorage.getItem("order_list_cache"); + const savedQuery = JSON.parse(sessionStorage.getItem("order_query_params")); + if (savedQuery) { + this.search = savedQuery; + this.isSearched = true; + } if (savedPage) { this.options.page = savedPage; } - } + if (savedData && savedData !== "undefined") { + this.data_table = JSON.parse(savedData); + this.isSearched = true; + } + } + + if (printResult === 'nodata' || printResult === 'success') { + + + this.$nextTick(() => { + this.print_dialog.show = true; + if (printResult === 'nodata') { + this.print_error_msg = "查無資料,請重新選擇區間"; + } + }); + } + + this.$nextTick(() => { + setTimeout(() => { + // 清空 URL + const cleanUrl = window.location.protocol + "//" + window.location.host + window.location.pathname; + window.history.replaceState({}, '', cleanUrl); + }, 100); + }); }, watch: { options: { handler() { - this.getDefault() + if (this.isSearched) { + this.getDefault() + } + else { + this.data_table.loading = false; + } }, deep: true, }, @@ -236,6 +287,57 @@ }, }, methods: { + triggerManagementExport(mode) { + this.print_error_msg = ""; + if (this.print_search.year == '') { + msgbox('請輸入年份'); + return; + } + if (!this.print_search.chk_noact && !this.print_search.chk_hasact) { + msgbox('活動/非活動至少勾選一項'); + return; + } + + // 將 Vue 狀態同步至 ASP.NET HiddenField,供後端 PostBack 讀取參數 + document.getElementById('<%= hid_print_mode.ClientID %>').value = this.print_conditions; + document.getElementById('<%= hid_print_year.ClientID %>').value = this.print_search.year; + if (this.print_conditions == 'mm') + document.getElementById('<%= hid_print_month.ClientID %>').value = this.print_search.month; + else if (this.print_conditions == 'ss') + document.getElementById('<%= hid_print_season.ClientID %>').value = this.print_search.season; + document.getElementById('<%= hid_select_act.ClientID %>').value = this.print_search.select_act; + document.getElementById('<%= hid_select_actitem.ClientID %>').value = this.print_search.select_actitem; + document.getElementById('<%= hid_chk_hasact.ClientID %>').value = this.print_search.chk_hasact; + document.getElementById('<%= hid_chk_noact.ClientID %>').value = this.print_search.chk_noact; + + let qry = ""; + Object.keys(this.print_search).forEach(key => { + if (this.print_search[key] != undefined && this.print_search[key] != null && this.print_search[key] != '') { + if (key == 'month' ) { + if (this.print_conditions == 'mm') { + qry += "&month=" + this.print_search.month; + } + } else if ( key == 'season') + { + if (this.print_conditions == 'ss') { + qry += "&season=" + this.print_search.season; + } + } + else { + qry += (qry != '' ? '&' : '?') + (key + '=' + this.print_search[key]); + } + + } + }); + document.getElementById('<%= hid_qry.ClientID %>').value = qry; + + if (mode === 'print') { + document.getElementById('<%= print_management.ClientID %>').click(); + } + else if (mode === "excel") { + document.getElementById('<%= excel_management.ClientID %>').click(); + } + }, search_show(curr) { //console.log("btn_click:", curr, curr.api_url); this.search_dialog.current = curr; @@ -321,19 +423,24 @@ this.data_table.list = response.data.list this.data_table.count = response.data.count; this.data_table.loading = false + + const dataToStore = JSON.stringify(this.data_table); + sessionStorage.setItem("order_list_cache", dataToStore); }) .catch(error => console.log(error)) }, detalKeyinArray() { var getArray = <%=Newtonsoft.Json.JsonConvert.SerializeObject(_keyin1Item, Newtonsoft.Json.Formatting.Indented) %>; - var keys = Object.keys(getArray); - for (let i = 0; i < keys.length; i++) { - //console.log(`${keys[i]}:${getArray[keys[i]]}`); //value : text - var _tmp = { - text: getArray[keys[i]], - val: parseInt(keys[i]), + if (getArray !== null) { + var keys = Object.keys(getArray); + for (let i = 0; i < keys.length; i++) { + //console.log(`${keys[i]}:${getArray[keys[i]]}`); //value : text + var _tmp = { + text: getArray[keys[i]], + val: parseInt(keys[i]), + } + this.keyin1_items.push(_tmp); } - this.keyin1_items.push(_tmp); } }, @@ -368,22 +475,28 @@ //} //this.data_table.selected = []; //this.data_table.count = this.data_table.list.length - location.reload(); + //location.reload(); + this.getDefault(); }) .catch(error => console.log(error)) } }, btn_search() { + this.isSearched = true; + sessionStorage.setItem("order_query_params", JSON.stringify(this.search)); this.this_act = ''; this.search.activity_num = ''; this.getDefault(true) + bootstrap.Offcanvas.getInstance(document.getElementById("offcanvasRight")).hide() }, btn_all() { + this.isSearched = false; this.this_act = ''; this.search.activity_num = ''; clearObjProps(this.search); - this.btn_search() + sessionStorage.setItem("order_query_params", JSON.stringify(this.search)); + //this.btn_search() }, checkInMsg(item) { this.check_data.f_num = item.f_num; @@ -392,39 +505,59 @@ this.check_data.activity_name = item.subject; this.check_dialog.show = true; }, - checkIn() { - if (this.check_data.qty > 0 && this.check_data.status.val > 0) { - var chechdata = - { - f_num: this.check_data.f_num, - activity_num: this.check_data.activity_num, - status: this.check_data.status.val, - qty: this.check_data.qty, - } - axios - .post(HTTP_HOST + 'api/activity/OrderCheckIn', chechdata) - .then(response => { - //清空 - this.check_data.f_num = 0; - this.check_data.u_name = ''; - this.check_data.activity_num = 0; - this.check_data.activity_name = ''; - this.check_data.qty = 1; - this.check_data.status.text = ''; - this.check_data.status.val = 1; - - this.check_dialog.show = false; - msgtop('簽到成功') - }) - .catch( - error => { - console.log(error) - msgtop('簽到失敗', 'error') - } - ) - } else { - msgbox('報到資訊請填寫完整'); + checkIn(item) { + var checkdata = + { + f_num: item.f_num, + activity_num: item.activity_num, + status: 1, + qty: 1, } + console.log(checkdata) + axios + .post(HTTP_HOST + 'api/activity/OrderCheckIn', checkdata) + .then(response => { + msgtop('簽到成功'); + this.getDefault(); + }) + .catch( + error => { + console.log(error) + msgtop('簽到失敗', 'error') + } + ) + //if (this.check_data.qty > 0 && this.check_data.status.val > 0) { + // var chechdata = + // { + // f_num: this.check_data.f_num, + // activity_num: this.check_data.activity_num, + // status: this.check_data.status.val, + // qty: this.check_data.qty, + // } + // axios + // .post(HTTP_HOST + 'api/activity/OrderCheckIn', chechdata) + // .then(response => { + // //清空 + // this.check_data.f_num = 0; + // this.check_data.u_name = ''; + // this.check_data.activity_num = 0; + // this.check_data.activity_name = ''; + // this.check_data.qty = 1; + // this.check_data.status.text = ''; + // this.check_data.status.val = 1; + + // this.check_dialog.show = false; + // msgtop('簽到成功') + // }) + // .catch( + // error => { + // console.log(error) + // msgtop('簽到失敗', 'error') + // } + // ) + //} else { + // msgbox('報到資訊請填寫完整'); + //} }, goPrint() { let _qry = ""; Object.keys(this.search).forEach(key => { @@ -442,6 +575,7 @@ //列印管理報表 print_close() { this.print_dialog.show = false; + this.print_error_msg = ""; } , initPrintSearch() { @@ -504,9 +638,9 @@ } } }); - + console.log(_qry); this.print_dialog.show = false; - window.open("print.aspx" + _qry, '_blank'); + //window.open("print.aspx" + _qry, '_blank'); } else { msgbox('活動/非活動至少勾選一項'); } @@ -537,7 +671,7 @@ initActivity() { axios.get(HTTP_HOST + 'api/activity') .then(response => { - this.select_act_list = response.data + this.select_act_list = response.data }) .catch(error => { console.log(error) @@ -556,10 +690,35 @@ $('#country2').val(''); VueApp.search.country2 = ''; }); + + $(document).ready(function () { + // 判斷是否彈出 search dialog + let hasSearchResult = sessionStorage.getItem("order_list_cache") !== null; + + if (!hasSearchResult && window._printResult === '') { + let $btn = $("a[data-bs-target='#offcanvasRight'][href='#search_panel']"); + $btn.click(); + let el = document.getElementById('offcanvasRight'); + let offcanvas = bootstrap.Offcanvas.getOrCreateInstance(el); + offcanvas.show(); + } + }); + + + + + + + + + + +