master
dk96 2024-12-17 19:09:32 +08:00
parent bd37f4b928
commit 476d347ed3
8 changed files with 451 additions and 2 deletions

View File

@ -0,0 +1 @@
<%@ WebHandler Language="C#" CodeBehind="babyRecList.ashx.cs" Class="abbott_2024_event.BackEnd.api.babyRecList" %>

View File

@ -0,0 +1,81 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Runtime.Serialization.Json;
using System.Web.SessionState;
using Dapper;
using Dapper.Contrib.Extensions;
using System.Data.SqlClient;
using System.IO.Compression;
namespace abbott_2024_event.BackEnd.api
{
/// <summary>
/// babyRec 的摘要描述
/// </summary>
public class babyRecList : IHttpHandler
{
SqlConnection conn = new SqlConnection(globalClass.appsettings("DBConnectionString"));
public authToken authToken;
public void ProcessRequest(HttpContext context)
{
result objRet = new result();
DataContractJsonSerializer json = new DataContractJsonSerializer(objRet.GetType());
context.Response.ContentType = "application/json;charset=utf-8";
context.Response.AddHeader("Access-Control-Allow-Origin", "*");
string acceptEncoding = context.Request.Headers["Accept-Encoding"].ToString().ToUpperInvariant();
if (!String.IsNullOrEmpty(acceptEncoding))
{
if (acceptEncoding.Contains("GZIP"))
{
//输出流头部GZIP压缩
context.Response.AppendHeader("Content-encoding", "gzip");
context.Response.Filter = new GZipStream(context.Response.Filter, CompressionMode.Compress);
}
else if (acceptEncoding.Contains("DEFLATE"))
{
//输出流头部DEFLATE压缩
context.Response.AppendHeader("Content-encoding", "deflate");
context.Response.Filter = new DeflateStream(context.Response.Filter, CompressionMode.Compress);
}
}
authToken objAuth = new authToken();
if (!objAuth.user_isLogin)
{
objRet.ret = "no";
objRet.err_code = "0001";
objRet.message = "尚未登入,請登入後使用";
json.WriteObject(context.Response.OutputStream, objRet);
return;
}
string baby_uid = (context.Request["baby_uid"] == null) ? "" : context.Request["baby_uid"].ToString();
objRet.recs = conn.Query<babyRec>("select * from babyRec where babyData_uid = @babyData_uid order by babyRec_recdate desc, babyRec_months desc", new { babyData_uid = baby_uid }).ToList();
objRet.ret = "yes";
json.WriteObject(context.Response.OutputStream, objRet);
return;
}
public class result
{
public string ret = "no";
public string err_code = "0000";
public string message = "";
public List<babyRec> recs = new List<babyRec>();
}
public bool IsReusable
{
get
{
return false;
}
}
}
}

View File

@ -0,0 +1 @@
<%@ WebHandler Language="C#" CodeBehind="lineData.ashx.cs" Class="abbott_2024_event.BackEnd.api.lineData" %>

View File

@ -0,0 +1,129 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Runtime.Serialization.Json;
using System.Web.SessionState;
using Dapper;
using Dapper.Contrib.Extensions;
using System.Data.SqlClient;
using System.IO.Compression;
namespace abbott_2024_event.BackEnd.api
{
/// <summary>
/// lineData 的摘要描述
/// </summary>
public class lineData : IHttpHandler
{
SqlConnection conn = new SqlConnection(globalClass.appsettings("DBConnectionString"));
public authToken authToken;
public void ProcessRequest(HttpContext context)
{
result objRet = new result();
DataContractJsonSerializer json = new DataContractJsonSerializer(objRet.GetType());
context.Response.ContentType = "application/json;charset=utf-8";
context.Response.AddHeader("Access-Control-Allow-Origin", "*");
string acceptEncoding = context.Request.Headers["Accept-Encoding"].ToString().ToUpperInvariant();
if (!String.IsNullOrEmpty(acceptEncoding))
{
if (acceptEncoding.Contains("GZIP"))
{
//输出流头部GZIP压缩
context.Response.AppendHeader("Content-encoding", "gzip");
context.Response.Filter = new GZipStream(context.Response.Filter, CompressionMode.Compress);
}
else if (acceptEncoding.Contains("DEFLATE"))
{
//输出流头部DEFLATE压缩
context.Response.AppendHeader("Content-encoding", "deflate");
context.Response.Filter = new DeflateStream(context.Response.Filter, CompressionMode.Compress);
}
}
authToken objAuth = new authToken();
if (!objAuth.user_isLogin)
{
objRet.ret = "no";
objRet.err_code = "0001";
objRet.message = "尚未登入,請登入後使用";
json.WriteObject(context.Response.OutputStream, objRet);
return;
}
string line_uid = (context.Request["line_uid"] == null) ? "" : context.Request["line_uid"].ToString();
lineUser lineUser = conn.QueryFirstOrDefault<lineUser>("select * from lineUser where line_uid = @line_uid", new { line_uid = line_uid });
if (lineUser == null)
{
objRet.ret = "no";
objRet.err_code = "0002";
objRet.message = "無此Line Uid資料!";
json.WriteObject(context.Response.OutputStream, objRet);
return;
}
List<babyData> list = conn.Query<babyData>("select * from babyData where line_uid = @line_uid", new { line_uid = line_uid }).ToList();
objRet.user.line_uid = line_uid;
objRet.user.line_displayName = lineUser.line_displayName;
foreach (babyData babyData in list) {
baby objData = new baby();
objData.baby_uid = babyData.babyData_uid;
objData.baby_gender = babyData.babyData_sexual;
objData.baby_birthday = babyData.babyData_birthday.ToString("yyyy/MM/dd");
objData.baby_name = babyData.babyData_name;
objRet.user.babyDatas.Add(objData);
}
objRet.ret = "yes";
json.WriteObject(context.Response.OutputStream, objRet);
return;
}
public class result
{
public string ret = "no";
public string err_code = "0000";
public string message = "";
public userData user = new userData();
}
public class userData
{
public string line_uid { get; set; } = "";
public string line_displayName { get; set; } = "";
public string testdate { get; set; } = "";
public List<baby> babyDatas = new List<baby>();
}
public class baby
{
public string baby_uid { get; set; } = "";
public string baby_name { get; set; } = "";
public string baby_gender { get; set; } = "";
public string baby_birthday { get; set; } = "";
public string baby_age { get; set; } = "";
public string baby_months { get; set; } = "";
public string baby_testdate { get; set; } = "";
public string baby_height { get; set; } = "";
public double baby_percent { get; set; } = 0;
}
public bool IsReusable
{
get
{
return false;
}
}
}
}

View File

@ -56,11 +56,94 @@ $(document).ready(function () {
loadDataTable();
initSubTable();
$('#baby_select').on('change', function () {
loadBabyRec();
});
});
function loadBabyRec() {
var baby_uid = $('#baby_select').val();
var formData = {
baby_uid: baby_uid
}
$.ajax({
url: "api/babyRecList.ashx",
type: "POST",
data: formData,
success: function (data, textStatus, jqXHR) {
if (data.ret == "yes") {
$('#dt-responsive-baby').dataTable().fnClearTable();
if (data.recs.length > 0) {
$('#dt-responsive-baby').dataTable().fnAddData(data.recs);
}
} else {
alert(data.message);
}
},
error: function (jqXHR, textStatus, errorThrown) {
alert('网絡或伺服器发生错误,请稍后重试!');
}
});
}
function buttonClick(obj) {
var uid = obj.getAttribute('data-uid');
var formData = {
line_uid: uid
}
$.ajax({
url: "api/lineData.ashx",
type: "POST",
data: formData,
success: function (data, textStatus, jqXHR) {
if (data.ret == "yes") {
$('#LineTitle').val("Line 名稱:" + data.user.line_displayName + ", Line Uid" + data.user.line_uid);
$("#baby_select option").remove();
$.each(data.user.babyDatas, function (i, item) {
var gender = "";
if (item.baby_gender == "M") {
gender = "男";
} else {
gender = "女";
}
var babyTxt = item.baby_name + " (" + gender + "), 生日:" + item.baby_birthday;
$("#baby_select").append($("<option></option>").attr("value", item.baby_uid).text(babyTxt));
});
loadBabyRec();
$('#clientHistoryListModal').modal('toggle');
} else {
alert(data.message);
}
},
error: function (jqXHR, textStatus, errorThrown) {
alert('网絡或伺服器发生错误,请稍后重试!');
}
});
}
function loadDataTable() {
var dataTables = {
init: function init() {
@ -236,3 +319,78 @@ function loadDataTable() {
dataTables.init();
}
function initSubTable() {
$("#dt-responsive-baby").DataTable({
dom: '<\'text-muted\'Bi>\n <\'table-fixed\'trl>\n <\'mt-4\'p>',
lengthChange: true,
lengthMenu: [[10, 25, 50, -1], [10, 25, 50, "All"]],
pageLength: 25,
buttons: [],
language: {
paginate: {
previous: '<i class="fa fa-lg fa-angle-left"></i>',
next: '<i class="fa fa-lg fa-angle-right"></i>'
},
buttons: {
copyTitle: 'Data copied',
copyKeys: 'Use your keyboard or menu to select the copy command'
}
},
deferRender: true,
rowId: 'babyRec_uid',
deferRender: true,
order: [[0, 'desc']],
columns: [
{ data: 'babyRec_recdate', className: 'align-middle text-left', orderable: true, searchable: false },
{ data: 'babyRec_yearMonthStr', className: 'align-middle text-left', orderable: true, searchable: false },
{ data: 'babyRec_height', className: 'align-middle text-left', orderable: true, searchable: false },
{ data: 'babyRec_inpercent', className: 'align-middle text-left', orderable: true, searchable: false }
],
columnDefs: [
{
targets: 0,
orderable: true,
searchable: false,
render: function render(data, type, row, meta) {
tMonth = row.babyRec_recMonth;
tDay = row.babyRec_recDay;
if (tDay < 10) {
tDay = '0' + tDay;
}
if (tMonth < 10) {
tMonth = '0' + tMonth;
}
return row.babyRec_recYear + "/" + tMonth + "/" + tDay;
}
},
{
targets: 3,
orderable: false,
searchable: false,
render: function render(data, type, row, meta) {
if (row.babyRec_inpercent > 97) {
return "> 97%";
} else {
return row.babyRec_inpercent + "%"
}
}
}
],
initComplete: function () {
},
info: false,
ordering: true,
paging: true
});
}

View File

@ -118,8 +118,79 @@
</div>
<!-- /.page-inner -->
<!-- .modal -->
<form id="clientHistoryListForm" name="clientHistoryListForm">
<div class="modal fade" id="clientHistoryListModal" tabindex="-1" role="dialog" aria-labelledby="clientHistoryListModalLabel" data-backdrop="static"
data-keyboard="false" aria-hidden="true">
<!-- .modal-dialog -->
<div class="modal-dialog modal-lg" role="document">
<!-- .modal-content -->
<div class="modal-content">
<!-- .modal-header -->
<div class="modal-header">
<h6 id="clientNewModalLabel" class="modal-title inline-editable">
<span class="sr-only"></span> <input id="LineTitle" type="text" class="form-control form-control-lg" placeholder="" required="">
</h6>
<button type="button" class="close" data-dismiss="modal">
<span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
</button>
</div><!-- /.modal-header -->
<!-- .modal-body -->
<div class="modal-body">
<!-- .page-section -->
<div class="page-section">
<!-- .card -->
<div class="card card-fluid">
<!-- .card-body -->
<div class="card-body">
<div class="form-row">
<div class="col-md-6" id="prm_project_serial">
<!-- .form-group -->
<div class="form-group">
<select id="baby_select" class="form-control">
</select>
</div><!-- /.form-group -->
</div>
<div class="col-md-6" id="prm_project_serial2">
<button type="button" class="btn btn-primary ml-auto" id="downloadBtn">下載寶寶總數據</button>
</div>
</div>
<!-- .card -->
<div class="card card-fluid">
<!-- .card-body -->
<div class="card-body">
<!-- .table -->
<table id="dt-responsive-baby" class="table dt-responsive nowrap w-100">
<thead>
<tr>
<th> 測驗日期 </th>
<th> 測驗時年齡 </th>
<th> 測驗時身高 </th>
<th> 成長百分比 </th>
</tr>
</thead>
</table><!-- /.table -->
</div>
</div>
</div><!-- /.card-body -->
</div><!-- /.card -->
</div><!-- /.page-section -->
</div><!-- /.modal-body -->
<!-- .modal-footer -->
<div class="modal-footer">
<button id="closeBtn" type="button" class="btn btn-light" data-dismiss="modal">關閉</button>
</div><!-- /.modal-footer -->
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>
</form><!-- /.modal -->
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="head" runat="server">
<script src="assets/javascript/custom/userList.js?v=2"></script>
<script src="assets/javascript/custom/userList.js?v=3"></script>
</asp:Content>

View File

@ -13319,6 +13319,9 @@
<Compile Include="App_Code\authToken.cs" />
<Compile Include="App_Code\globalClass.cs" />
<Compile Include="App_Code\dbClass.cs" />
<Compile Include="BackEnd\api\babyRecList.ashx.cs">
<DependentUpon>babyRecList.ashx</DependentUpon>
</Compile>
<Compile Include="BackEnd\api\chgPassword.ashx.cs">
<DependentUpon>chgPassword.ashx</DependentUpon>
</Compile>
@ -13331,6 +13334,9 @@
<Compile Include="BackEnd\api\ipList.ashx.cs">
<DependentUpon>ipList.ashx</DependentUpon>
</Compile>
<Compile Include="BackEnd\api\lineData.ashx.cs">
<DependentUpon>lineData.ashx</DependentUpon>
</Compile>
<Compile Include="BackEnd\api\signin.ashx.cs">
<DependentUpon>signin.ashx</DependentUpon>
</Compile>
@ -17888,6 +17894,8 @@
<Content Include="BackEnd\assets\vendor\datepicker\css\bootstrap-datepicker3.standalone.min.css.map" />
<Content Include="BackEnd\api\userList.ashx" />
<Content Include="BackEnd\api\exportExcel.ashx" />
<Content Include="BackEnd\api\lineData.ashx" />
<Content Include="BackEnd\api\babyRecList.ashx" />
<None Include="packages.config" />
<None Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>

Binary file not shown.