diff --git a/web/App_Code/Model/ViewModel/activity.cs b/web/App_Code/Model/ViewModel/activity.cs index 48a7561..8fe28a1 100644 --- a/web/App_Code/Model/ViewModel/activity.cs +++ b/web/App_Code/Model/ViewModel/activity.cs @@ -32,6 +32,8 @@ namespace Model.ViewModel public string subject { get; set; } public int? num { get; set; } public string is_reconcile { get; set; } + public string up_time1 { get; set; } + public string up_time2 { get; set; } } diff --git a/web/App_Code/api/activityController.cs b/web/App_Code/api/activityController.cs index bfbafd7..4d31baa 100644 --- a/web/App_Code/api/activityController.cs +++ b/web/App_Code/api/activityController.cs @@ -235,6 +235,114 @@ public class activityController : ApiController var count = _db.activities.Count(); return count; } + + [HttpPost] + [Route("api/activity/GetListNew")] + public IHttpActionResult GetListNew([FromBody] Model.ViewModel.activity q, int page, int pageSize = 10, + string sortBy = "", bool sortDesc = false) + { + var qry = _db.activities.AsQueryable(); + if (!string.IsNullOrEmpty(q.subject)) + qry = qry.Where(o => o.subject.Contains(q.subject)); + if (q.kind.HasValue && q.kind > 0) + { + var _subKinds = new TreeView().subKinds(_db.activity_kind.Select(o => new TreeItem() + { + num = o.num, + root = o.root, + }).ToList(), q.kind.Value); + + //qry = qry.Where(o => o.kind == q.kind); + qry = qry.Where(o => o.kind == q.kind.Value || _subKinds.Any(s => s == o.kind)); + } + if (!string.IsNullOrEmpty(q.up_time1)) + { + var s = DateTime.Parse(q.up_time1); + qry = qry.Where(o => o.startDate_solar <=s&&o.endDate_solar>=s); + } + + //if (!string.IsNullOrEmpty(q.up_time2)) + //{ + // var end = DateTime.Parse(q.up_time2); + // qry = qry.Where(o => o.endDate_solar<=end); + //} + + if (!string.IsNullOrEmpty(q.kindTxt)) + qry = qry.Where(o => o.activity_kind.kind.Contains(q.kindTxt)); + + if (sortBy.Equals("subject")) + { + if (sortDesc) + qry = qry.OrderByDescending(o => o.subject); + else + qry = qry.OrderBy(o => o.subject); + } + else if (sortBy.Equals("kind")) + { + if (sortDesc) + qry = qry.OrderByDescending(o => o.kind); + else + qry = qry.OrderBy(o => o.kind); + } + else if (sortBy.Equals("startDate_solar")) + { + if (sortDesc) + qry = qry.OrderByDescending(o => o.startDate_solar); + else + qry = qry.OrderBy(o => o.startDate_solar); + } + else if (sortBy.Equals("endDate_solar")) + { + if (sortDesc) + qry = qry.OrderByDescending(o => o.endDate_solar); + else + qry = qry.OrderBy(o => o.endDate_solar); + } + else if (sortBy.Equals("dueDate")) + { + if (sortDesc) + qry = qry.OrderByDescending(o => o.dueDate); + else + qry = qry.OrderBy(o => o.dueDate); + } + else + qry = qry.OrderByDescending(o => o.num); + + var count = qry.Count(); //pageSize = count;//一次取回?? + var qryList = (pageSize > 0) ? qry.ToPagedList(page, pageSize).ToList() : qry.ToList(); + + var ret = new + { + list = qryList.Select(x => new + { + num = x.num, + subject = x.subject, + kind = x.kind, + kindTxt = x.kind.HasValue ? x.activity_kind.kind : "", + kindsTxt = x.kind.HasValue ? new TreeView().kindText(_db.activity_kind.Select(o => new TreeItem() + { + kind = o.kind, + num = o.num, + root = o.root, + }).ToList(), x.kind) : "", + startDate_solar = x.startDate_solar, + endDate_solar = x.endDate_solar, + startDate_lunar = x.startDate_lunar, + endDate_lunar = x.endDate_lunar, + dueDate = x.dueDate, + orderCounts = _db.pro_order.Where(y => y.activity_num == x.num).Count(), + }), + count = count, + + + }; + + + if (ret.list == null) throw new HttpResponseException(HttpStatusCode.NotFound); + return Ok(ret); + } + + [HttpPost] [Route("api/activity/GetList")] public IHttpActionResult GetList([FromBody] Model.ViewModel.activity q, int page, int pageSize = 10, diff --git a/web/admin/activity/item_reg.aspx b/web/admin/activity/item_reg.aspx index 6fd70b9..7e8d4f9 100644 --- a/web/admin/activity/item_reg.aspx +++ b/web/admin/activity/item_reg.aspx @@ -199,19 +199,24 @@ val: 0 }, }, + style_datas: [], + paper_datas: [], + defaultStyle: "", + paperID: "", + printID:"" } }, mounted() { this.search_dialog.current = this.search_dialog.controls.search1 //console.log("mounted"); + this.initialize() }, watch: { options: { handler() { //console.log("watch1", this.search_dialog, this.search_dialog.page); this.search_get() - console.log("watch2", this.search_dialog, this.search_dialog.page); - }, + }, deep: true, }, optionsDetail: { @@ -248,7 +253,6 @@ if (this.this_id == "") search['status'] = "Y";//啟用 } - console.log("search_get", api_url, search, params, this.options); this.search_dialog.loading = true axios.post(api_url, search, { params: params }) .then(response => { @@ -289,7 +293,7 @@ else { } - console.log("search_select", row, editem); + //debugger; target.children("input.search-text").val(curr.selected[curr.text_prop])//text target.children("input:hidden").val(curr.selected[curr.value_prop])//value @@ -336,46 +340,19 @@ ) } - axios - .post(HTTP_HOST + 'api/tablet/GetPaperSize', {}) - .then(response => { - console.log(response); - if (response.status == "200") { - let data = response.data; - if (data.result == "Y") { - data.data.forEach(x => { - this.paperlist.push({ name: x.paperName, id: x.paperID, width: x.width, height: x.height }) - $('#<%= ddlPageSize.ClientID %>').append(``); - $('#<%= ddlPrintSize.ClientID %>').append(``); - }); - - $('#<%= ddlPageSize.ClientID %>').val($("#<%= hidPageSize.ClientID %>").val()) - $('#<%= ddlPrintSize.ClientID %>').val($("#<%= hidPrintSize.ClientID %>").val()) - } - } - }) - .catch( - error => console.log(error) - ) + this.paper_datas.length = 0 + this.style_datas.length = 0 axios .post(HTTP_HOST + 'api/tablet/GetStyleData', {}) .then(response => { - console.log(response); if (response.status == "200") { let data = response.data; if (data.result == "Y") { - data.data.forEach(x => { - if (x.styleID != "000001") { - this.stylelist.push({ styleID: x.styleID, name: x.name }) - $('#<%= ddlDefaultStyle.ClientID %>').append(``); - //$("#defaultStyle").append(``); - } - }); - $('#<%= ddlDefaultStyle.ClientID %>').val($("#<%= hidDefaultStyle.ClientID %>").val()) - } - } - }) + this.style_datas = data.data + this.defaultStyle=$("#<%=hidDefaultStyle.ClientID %>").val() + } + }}) .catch( error => console.log(error) ) @@ -492,7 +469,7 @@ bom_editItem(item) { this.bom_editedIndex = this.bom_list.indexOf(item); this.bom_editedItem = $.extend(true, {}, item); - console.log("bom_editItem:", this.bom_editedIndex, this.bom_editedItem); + //debugger; }, bom_deleteItem(item) { @@ -572,13 +549,13 @@ } }, changeSel(selType) { - if (selType=="ddlPageSize") { - $("#<%= hidPageSize.ClientID %>").val($("#<%= ddlPageSize.ClientID %>").val()) - } else if (selType == "ddlPrintSize") { - $("#<%= hidPrintSize.ClientID %>").val($("#<%=ddlPrintSize.ClientID %>").val()) - } else if (selType == "ddlDefaultStyle") { - $("#<%= hidDefaultStyle.ClientID %>").val($("#<%= ddlDefaultStyle.ClientID %>").val()) - } + let style = this.style_datas.find(x => x.styleID == this.defaultStyle) + this.paperID = style.paperSize + this.printID = style.printSize + $("#<%= hidPageSize.ClientID %>").val(this.paperID) + $("#<%=hidPrintSize.ClientID %>").val(this.printID) + $("#<%=hidDefaultStyle.ClientID %>").val(this.defaultStyle) + } }, computed: { @@ -659,47 +636,43 @@