updates
parent
58a60eeeac
commit
b845ec25e7
|
|
@ -57,6 +57,199 @@ namespace Journeys_WantHome.Controllers
|
||||||
this._httpContextAccessor = httpContextAccessor;
|
this._httpContextAccessor = httpContextAccessor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Route("addEditDelItem")]
|
||||||
|
public ActionResult AddEditDelItem(IFormCollection obj) {
|
||||||
|
optionItemResult ret = new optionItemResult();
|
||||||
|
|
||||||
|
authToken token = new authToken(this._httpContextAccessor);
|
||||||
|
if (token.user_isLogin == false)
|
||||||
|
{
|
||||||
|
HttpContext.Response.Cookies.Delete("token_key");
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "99999";
|
||||||
|
ret.message = "非登入狀態!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (token.user_perm != "system")
|
||||||
|
{
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "90001";
|
||||||
|
ret.message = "此帳號無此api使用權限!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
string option_uid = obj["option_uid"].ToString();
|
||||||
|
string optionItem_uid = obj["optionItem_uid"].ToString();
|
||||||
|
string optionItem_name = obj["optionItem_name"].ToString();
|
||||||
|
string method = obj["method"].ToString();
|
||||||
|
|
||||||
|
|
||||||
|
if (option_uid == "")
|
||||||
|
{
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "00001";
|
||||||
|
ret.message = "無option_uid資料!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (method == "") {
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "0002";
|
||||||
|
ret.message = "無method資料!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (method == "get") {
|
||||||
|
optionItem item = conn.QueryFirstOrDefault<optionItem>("select * from optionItem where optionItem_ishide = 'N' and option_uid = @option_uid and optionItem_uid = @optionItem_uid", new { option_uid = option_uid, optionItem_uid = optionItem_uid});
|
||||||
|
|
||||||
|
if (item == null) {
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "0003";
|
||||||
|
ret.message = "無此筆資料!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
ret.ret = "yes";
|
||||||
|
ret.optionItem = item;
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (method == "add") {
|
||||||
|
if (optionItem_name == "") {
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "0004";
|
||||||
|
ret.message = "無項目名稱!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
optionItem item = conn.QueryFirstOrDefault<optionItem>("select * from optionItem where optionItem_ishide = 'N' and option_uid = @option_uid and optionItem_name = @optionItem_name", new { option_uid = option_uid, optionItem_name = optionItem_name});
|
||||||
|
|
||||||
|
if (item != null)
|
||||||
|
{
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "0005";
|
||||||
|
ret.message = "此項目名稱已存在!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<optionItem> itemsList = conn.Query<optionItem>("select * from optionItem where optionItem_ishide = 'N' and option_uid = @option_uid", new { option_uid = option_uid}).ToList();
|
||||||
|
|
||||||
|
optionItem_uid = "item_" + GlobalClass.CreateRandomCode(8);
|
||||||
|
item = new optionItem();
|
||||||
|
|
||||||
|
item.option_uid = option_uid;
|
||||||
|
item.optionItem_uid = optionItem_uid;
|
||||||
|
item.optionItem_name = optionItem_name;
|
||||||
|
item.optionItem_ishide = "N";
|
||||||
|
item.optionItem_userId = token.user_id;
|
||||||
|
item.optionItem_order = itemsList.Count + 1;
|
||||||
|
|
||||||
|
conn.Insert(item);
|
||||||
|
|
||||||
|
ret.ret = "yes";
|
||||||
|
ret.optionItem = item;
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (method == "edit") {
|
||||||
|
if (optionItem_name == "")
|
||||||
|
{
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "0004";
|
||||||
|
ret.message = "無項目名稱!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
optionItem item = conn.QueryFirstOrDefault<optionItem>("select * from optionItem where optionItem_ishide = 'N' and option_uid = @option_uid and optionItem_name = @optionItem_name and optionItem_uid <> @optionItem_uid", new { option_uid = option_uid, optionItem_name = optionItem_name, optionItem_uid = optionItem_uid });
|
||||||
|
|
||||||
|
if (item != null)
|
||||||
|
{
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "0005";
|
||||||
|
ret.message = "此修改後項目名稱已被使用!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
optionItem editItem = conn.QueryFirstOrDefault<optionItem>("select * from optionItem where optionItem_ishide = 'N' and option_uid = @option_uid and optionItem_uid = @optionItem_uid", new { option_uid = option_uid, optionItem_uid = optionItem_uid});
|
||||||
|
|
||||||
|
if (editItem == null) {
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "0003";
|
||||||
|
ret.message = "無此筆資料!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
editItem.optionItem_name = optionItem_name;
|
||||||
|
editItem.optionItem_userId = token.user_id;
|
||||||
|
editItem.optionItem_modifydate = DateTime.Now;
|
||||||
|
|
||||||
|
conn.Update(editItem);
|
||||||
|
ret.ret = "yes";
|
||||||
|
ret.optionItem = editItem;
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (method == "del") {
|
||||||
|
optionItem editItem = conn.QueryFirstOrDefault<optionItem>("select * from optionItem where optionItem_ishide = 'N' and option_uid = @option_uid and optionItem_uid = @optionItem_uid", new { option_uid = option_uid, optionItem_uid = optionItem_uid });
|
||||||
|
|
||||||
|
if (editItem == null)
|
||||||
|
{
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "0003";
|
||||||
|
ret.message = "無此筆資料!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
editItem.optionItem_userId = token.user_id;
|
||||||
|
editItem.optionItem_modifydate = DateTime.Now;
|
||||||
|
editItem.optionItem_ishide = "Y";
|
||||||
|
|
||||||
|
conn.Update(editItem);
|
||||||
|
ret.ret = "yes";
|
||||||
|
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Route("optionItemList")]
|
||||||
|
public ActionResult OptionItemList(IFormCollection obj) {
|
||||||
|
optionListResult ret = new optionListResult();
|
||||||
|
|
||||||
|
authToken token = new authToken(this._httpContextAccessor);
|
||||||
|
if (token.user_isLogin == false)
|
||||||
|
{
|
||||||
|
HttpContext.Response.Cookies.Delete("token_key");
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "99999";
|
||||||
|
ret.message = "非登入狀態!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (token.user_perm != "system")
|
||||||
|
{
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "90001";
|
||||||
|
ret.message = "此帳號無此api使用權限!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
string option_uid = obj["option_uid"].ToString();
|
||||||
|
|
||||||
|
if (option_uid == "") {
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "00001";
|
||||||
|
ret.message = "無option_uid資料!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
ret.optionItems = conn.Query<optionItem>("select * from optionItem where optionItem_ishide = 'N' and option_uid = @option_uid order by optionItem_order ", new { option_uid = option_uid }).ToList();
|
||||||
|
ret.ret = "yes";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
[Route("addEditGetUser")]
|
[Route("addEditGetUser")]
|
||||||
public ActionResult AddEditGetUser(IFormCollection obj) {
|
public ActionResult AddEditGetUser(IFormCollection obj) {
|
||||||
updateUserResult ret = new updateUserResult();
|
updateUserResult ret = new updateUserResult();
|
||||||
|
|
@ -610,5 +803,21 @@ namespace Journeys_WantHome.Controllers
|
||||||
public string message = "";
|
public string message = "";
|
||||||
public user user = new user();
|
public user user = new user();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class optionListResult
|
||||||
|
{
|
||||||
|
public string ret = "no";
|
||||||
|
public string err_code = "0000";
|
||||||
|
public string message = "";
|
||||||
|
public List<optionItem> optionItems = new List<optionItem>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class optionItemResult
|
||||||
|
{
|
||||||
|
public string ret = "no";
|
||||||
|
public string err_code = "0000";
|
||||||
|
public string message = "";
|
||||||
|
public optionItem optionItem = new optionItem();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,22 @@ namespace Journeys_WantHome.Controllers
|
||||||
this._objToken = new authToken(this._httpContextAccessor);
|
this._objToken = new authToken(this._httpContextAccessor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IActionResult OptionList()
|
||||||
|
{
|
||||||
|
if (checkToken() == false)
|
||||||
|
{
|
||||||
|
HttpContext.Response.Cookies.Delete("token_key");
|
||||||
|
return Redirect("~/Root/Login");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this._objToken.user_perm != "system")
|
||||||
|
{
|
||||||
|
return Redirect("~/");
|
||||||
|
}
|
||||||
|
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
public IActionResult UserList()
|
public IActionResult UserList()
|
||||||
{
|
{
|
||||||
if (checkToken() == false)
|
if (checkToken() == false)
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,53 @@ using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
public class DbTableClass
|
public class DbTableClass
|
||||||
{
|
{
|
||||||
|
[Table("optionItem")]
|
||||||
|
public class optionItem
|
||||||
|
{
|
||||||
|
[JsonIgnore]
|
||||||
|
[Key]
|
||||||
|
public int optionItem_sn { get; set; }
|
||||||
|
|
||||||
|
public string option_uid { get; set; } = "";
|
||||||
|
|
||||||
|
public string optionItem_uid { get; set; } = "";
|
||||||
|
|
||||||
|
public string optionItem_name { get; set; } = "";
|
||||||
|
|
||||||
|
public string optionItem_ishide { get; set; } = "N";
|
||||||
|
|
||||||
|
public int optionItem_order { get; set; } = 999;
|
||||||
|
|
||||||
|
public DateTime optionItem_createdate { get; set; } = DateTime.Now;
|
||||||
|
|
||||||
|
public DateTime optionItem_modifydate { get; set; } = DateTime.Now;
|
||||||
|
|
||||||
|
public string optionItem_userId { get; set; } = "";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[Table("option")]
|
||||||
|
public class option
|
||||||
|
{
|
||||||
|
[JsonIgnore]
|
||||||
|
[Key]
|
||||||
|
public int option_sn { get; set; }
|
||||||
|
|
||||||
|
public string option_uid { get; set; } = "";
|
||||||
|
|
||||||
|
public string option_name { get; set; } = "";
|
||||||
|
|
||||||
|
public string option_ishide { get; set; } = "N";
|
||||||
|
|
||||||
|
public DateTime option_createdate { get; set; } = DateTime.Now;
|
||||||
|
|
||||||
|
public DateTime option_modifydate { get; set; } = DateTime.Now;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
[Table("token")]
|
[Table("token")]
|
||||||
public class token
|
public class token
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,157 @@
|
||||||
|
@*
|
||||||
|
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||||
|
*@
|
||||||
|
@{
|
||||||
|
Layout = "_LooperLayout";
|
||||||
|
}
|
||||||
|
|
||||||
|
@section Style {
|
||||||
|
<link rel="stylesheet" href="~/assets/vendor/datatables.net-responsive-bs4/css/responsive.bootstrap4.min.css">
|
||||||
|
}
|
||||||
|
|
||||||
|
@section Script {
|
||||||
|
<script src="~/assets/vendor/sortablejs/Sortable.min.js"></script>
|
||||||
|
<script src="~/assets/vendor/nestable2/jquery.nestable.min.js"></script>
|
||||||
|
<script src="~/assets/javascript/custom/optionlist.js?v=1"></script>
|
||||||
|
}
|
||||||
|
<!-- .page-inner -->
|
||||||
|
<div class="page-inner">
|
||||||
|
<!-- .page-title-bar -->
|
||||||
|
<header class="page-title-bar">
|
||||||
|
<nav aria-label="breadcrumb">
|
||||||
|
<ol class="breadcrumb">
|
||||||
|
<li class="breadcrumb-item active">
|
||||||
|
<a href="#"><i class="breadcrumb-icon fa fa-angle-left mr-2"></i>項目資料維護</a>
|
||||||
|
</li>
|
||||||
|
</ol>
|
||||||
|
</nav>
|
||||||
|
<h1 class="page-title"> 選項項目資料維護 </h1>
|
||||||
|
</header><!-- /.page-title-bar -->
|
||||||
|
<!-- .page-section -->
|
||||||
|
<div class="page-section">
|
||||||
|
<!-- .section-block -->
|
||||||
|
<div class="section-block" style="display: none;">
|
||||||
|
<h2 class="section-title"> Nestable </h2>
|
||||||
|
<p class="text-muted"> Drag & drop hierarchical list with mouse and touch compatibility. </p>
|
||||||
|
</div><!-- /.section-block -->
|
||||||
|
<!-- grid row -->
|
||||||
|
<div class="row">
|
||||||
|
<!-- grid column -->
|
||||||
|
<div class="col-lg-6">
|
||||||
|
<!-- .card -->
|
||||||
|
<div class="card card-fluid">
|
||||||
|
<div class="card-header border-bottom-0"> KOL成員類型 </div><!-- .nestable -->
|
||||||
|
<div id="nestable01" class="dd" data-toggle="sortable" data-max-depth="1" data-type="kolMakeup">
|
||||||
|
<!-- .dd-list -->
|
||||||
|
<ol class="dd-list">
|
||||||
|
|
||||||
|
</ol><!-- /.dd-list -->
|
||||||
|
</div><!-- /.nestable -->
|
||||||
|
<!-- .card-footer -->
|
||||||
|
<div class="card-footer">
|
||||||
|
<a href="javascript: void(0);" onclick="addItem(this)" data-type="kolMakeup" class="card-footer-item justify-content-start"><span><i class="fa fa-plus-circle mr-1"></i> Add Menu Item</span></a>
|
||||||
|
</div><!-- /.card-footer -->
|
||||||
|
</div><!-- /.card -->
|
||||||
|
</div><!-- /grid column -->
|
||||||
|
<!-- grid column -->
|
||||||
|
<div class="col-lg-6">
|
||||||
|
<!-- .card -->
|
||||||
|
<div class="card card-fluid">
|
||||||
|
<div class="card-header border-bottom-0"> KOL類型 </div><!-- .nestable -->
|
||||||
|
<div id="nestable02" class="dd" data-toggle="sortable" data-max-depth="1" data-type="kolStyle">
|
||||||
|
<!-- .dd-list -->
|
||||||
|
<ol class="dd-list">
|
||||||
|
</ol><!-- /.dd-list -->
|
||||||
|
</div><!-- /.nestable -->
|
||||||
|
<!-- .card-footer -->
|
||||||
|
<div class="card-footer">
|
||||||
|
<a href="javascript: void(0);" onclick="addItem(this)" data-type="kolStyle" class="card-footer-item justify-content-start"><span><i class="fa fa-plus-circle mr-1"></i> Add Menu Item</span></a>
|
||||||
|
</div><!-- /.card-footer -->
|
||||||
|
</div><!-- /.card -->
|
||||||
|
</div><!-- /grid column -->
|
||||||
|
<!-- grid column -->
|
||||||
|
<div class="col-lg-6">
|
||||||
|
<!-- .card -->
|
||||||
|
<div class="card card-fluid">
|
||||||
|
<div class="card-header border-bottom-0"> 粉絲輪廓 </div><!-- .nestable -->
|
||||||
|
<div id="nestable03" class="dd" data-toggle="sortable" data-max-depth="1" data-type="fansType">
|
||||||
|
<!-- .dd-list -->
|
||||||
|
<ol class="dd-list">
|
||||||
|
</ol><!-- /.dd-list -->
|
||||||
|
</div><!-- /.nestable -->
|
||||||
|
<!-- .card-footer -->
|
||||||
|
<div class="card-footer">
|
||||||
|
<a href="javascript: void(0);" onclick="addItem(this)" data-type="fansType" class="card-footer-item justify-content-start"><span><i class="fa fa-plus-circle mr-1"></i> Add Menu Item</span></a>
|
||||||
|
</div><!-- /.card-footer -->
|
||||||
|
</div><!-- /.card -->
|
||||||
|
</div><!-- /grid column -->
|
||||||
|
<!-- grid column -->
|
||||||
|
<div class="col-lg-6">
|
||||||
|
<!-- .card -->
|
||||||
|
<div class="card card-fluid">
|
||||||
|
<div class="card-header border-bottom-0"> 合作形式 </div><!-- .nestable -->
|
||||||
|
<div id="nestable04" class="dd" data-toggle="sortable" data-max-depth="1" data-type="cooperateType">
|
||||||
|
<!-- .dd-list -->
|
||||||
|
<ol class="dd-list">
|
||||||
|
</ol><!-- /.dd-list -->
|
||||||
|
</div><!-- /.nestable -->
|
||||||
|
<!-- .card-footer -->
|
||||||
|
<div class="card-footer">
|
||||||
|
<a href="javascript: void(0);" onclick="addItem(this)" data-type="cooperateType" class="card-footer-item justify-content-start"><span><i class="fa fa-plus-circle mr-1"></i> Add Menu Item</span></a>
|
||||||
|
</div><!-- /.card-footer -->
|
||||||
|
</div><!-- /.card -->
|
||||||
|
</div><!-- /grid column -->
|
||||||
|
<!-- grid column -->
|
||||||
|
<div class="col-lg-6">
|
||||||
|
<!-- .card -->
|
||||||
|
<div class="card card-fluid">
|
||||||
|
<div class="card-header border-bottom-0"> 媒體平台 </div><!-- .nestable -->
|
||||||
|
<div id="nestable05" class="dd" data-toggle="sortable" data-max-depth="1" data-type="media">
|
||||||
|
<!-- .dd-list -->
|
||||||
|
<ol class="dd-list">
|
||||||
|
</ol><!-- /.dd-list -->
|
||||||
|
</div><!-- /.nestable -->
|
||||||
|
<!-- .card-footer -->
|
||||||
|
<div class="card-footer">
|
||||||
|
<a href="javascript: void(0);" onclick="addItem(this)" data-type="media" class="card-footer-item justify-content-start"><span><i class="fa fa-plus-circle mr-1"></i> Add Menu Item</span></a>
|
||||||
|
</div><!-- /.card-footer -->
|
||||||
|
</div><!-- /.card -->
|
||||||
|
</div><!-- /grid column -->
|
||||||
|
</div><!-- /grid row -->
|
||||||
|
</div><!-- /.page-section -->
|
||||||
|
</div><!-- /.page-inner -->
|
||||||
|
|
||||||
|
<!-- .modal -->
|
||||||
|
<form id="clientContactEditForm" name="clientContactEditForm">
|
||||||
|
<div class="modal fade" id="optionItemModal" tabindex="-1" role="dialog" aria-labelledby="optionItemModalLabel" aria-hidden="true">
|
||||||
|
<!-- .modal-dialog -->
|
||||||
|
<div class="modal-dialog" role="document">
|
||||||
|
<!-- .modal-content -->
|
||||||
|
<div class="modal-content">
|
||||||
|
<!-- .modal-header -->
|
||||||
|
<div class="modal-header">
|
||||||
|
<h6 id="optionItemModalLabel" class="modal-title inline-editable">
|
||||||
|
<span class="sr-only">項目名稱</span> <input id="option_name" type="text" class="form-control form-control-lg" value="" placeholder="項目名稱" readonly="readonly " required="">
|
||||||
|
</h6>
|
||||||
|
</div><!-- /.modal-header -->
|
||||||
|
<!-- .modal-body -->
|
||||||
|
<div class="modal-body">
|
||||||
|
<input type="hidden" id="method" />
|
||||||
|
<input type="hidden" id="option_uid" />
|
||||||
|
<input type="hidden" id="optionItem_uid" />
|
||||||
|
<!-- .form-group -->
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="form-label-group">
|
||||||
|
<input type="text" id="optionItem_name" class="form-control" value="" placeholder="名稱" maxlength="32" required=""> <label for="optionItem_name">名稱</label>
|
||||||
|
</div>
|
||||||
|
</div><!-- /.form-group -->
|
||||||
|
|
||||||
|
</div><!-- /.modal-body -->
|
||||||
|
<!-- .modal-footer -->
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" id="optionItemDialogSaveBtn" class="btn btn-primary">Save</button> <button type="button" class="btn btn-light" data-dismiss="modal">Close</button>
|
||||||
|
</div><!-- /.modal-footer -->
|
||||||
|
</div><!-- /.modal-content -->
|
||||||
|
</div><!-- /.modal-dialog -->
|
||||||
|
</div>
|
||||||
|
</form><!-- /.modal -->
|
||||||
|
|
@ -133,7 +133,10 @@
|
||||||
<a href="#" class="menu-link"><span class="menu-icon oi oi-wrench"></span> <span class="menu-text">Auth</span></a> <!-- child menu -->
|
<a href="#" class="menu-link"><span class="menu-icon oi oi-wrench"></span> <span class="menu-text">Auth</span></a> <!-- child menu -->
|
||||||
<ul class="menu">
|
<ul class="menu">
|
||||||
<li class="menu-item">
|
<li class="menu-item">
|
||||||
<a href="auth-comingsoon-v1.html" class="menu-link">使用者管理</a>
|
<a href="~/Home/OptionList" class="menu-link">選項資料管理</a>
|
||||||
|
</li>
|
||||||
|
<li class="menu-item">
|
||||||
|
<a href="~/Home/UserList" class="menu-link">使用者管理</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
</ul><!-- /child menu -->
|
</ul><!-- /child menu -->
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,300 @@
|
||||||
|
var tmpNestableObj;
|
||||||
|
|
||||||
|
$(document).ready(function () {
|
||||||
|
loadKolMakeupList();
|
||||||
|
loadKolStyleList();
|
||||||
|
loadFansTypeList();
|
||||||
|
loadCooperateTypeList();
|
||||||
|
loadMediaList();
|
||||||
|
|
||||||
|
$('#optionItemDialogSaveBtn').click(function () {
|
||||||
|
var method = $('#method').val();
|
||||||
|
var option_uid = $('#option_uid').val();
|
||||||
|
var optionItem_uid = $('#optionItem_uid').val();
|
||||||
|
var optionItem_name = $('#optionItem_name').val();
|
||||||
|
|
||||||
|
if (method == 'add') {
|
||||||
|
if (optionItem_name == '') {
|
||||||
|
alert('請輸入項目名稱!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var formData = {
|
||||||
|
option_uid: option_uid,
|
||||||
|
optionItem_name: optionItem_name,
|
||||||
|
method: method
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: "/AuthApi/addEditDelItem",
|
||||||
|
type: "post",
|
||||||
|
data: formData,
|
||||||
|
success: function (data, textStatus, jqXHR) {
|
||||||
|
if (data.ret == "yes") {
|
||||||
|
var obj = data.optionItem;
|
||||||
|
|
||||||
|
tmpNestableObj.children().append(optionItemHtml(obj));
|
||||||
|
|
||||||
|
$('#optionItemModal').modal('toggle');
|
||||||
|
|
||||||
|
} else {
|
||||||
|
alert(data.message);
|
||||||
|
|
||||||
|
if (data.err_code == "99999") {
|
||||||
|
location.href = "/Root/Login";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
|
alert('網路或伺服器發生錯誤,請稍後重試!');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
//$(document).on('theme:init', function () {
|
||||||
|
// //loadKolMakeupList();
|
||||||
|
// //loadKolStyleList();
|
||||||
|
//});
|
||||||
|
function loadMediaList() {
|
||||||
|
var formData = {
|
||||||
|
option_uid: 'media'
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: "/AuthApi/optionItemList",
|
||||||
|
type: "post",
|
||||||
|
data: formData,
|
||||||
|
success: function (data, textStatus, jqXHR) {
|
||||||
|
if (data.ret == "yes") {
|
||||||
|
var obj = data.optionItems;
|
||||||
|
var items = "";
|
||||||
|
$.each(obj, function (index, item) {
|
||||||
|
items += optionItemHtml(item);
|
||||||
|
});
|
||||||
|
|
||||||
|
//items = '<ol class="dd-list">' + items + '</ol >';
|
||||||
|
|
||||||
|
$('#nestable05').children().html(items);
|
||||||
|
|
||||||
|
$('#nestable05').nestable();
|
||||||
|
|
||||||
|
$('#nestable05').on('change', function () {
|
||||||
|
nestableChange(this);
|
||||||
|
});
|
||||||
|
|
||||||
|
} else {
|
||||||
|
alert(data.message);
|
||||||
|
|
||||||
|
if (data.err_code == "99999") {
|
||||||
|
location.href = "/Root/Login";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
|
alert('網路或伺服器發生錯誤,請稍後重試!');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function loadCooperateTypeList() {
|
||||||
|
var formData = {
|
||||||
|
option_uid: 'cooperateType'
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: "/AuthApi/optionItemList",
|
||||||
|
type: "post",
|
||||||
|
data: formData,
|
||||||
|
success: function (data, textStatus, jqXHR) {
|
||||||
|
if (data.ret == "yes") {
|
||||||
|
var obj = data.optionItems;
|
||||||
|
var items = "";
|
||||||
|
$.each(obj, function (index, item) {
|
||||||
|
items += optionItemHtml(item);
|
||||||
|
});
|
||||||
|
|
||||||
|
//items = '<ol class="dd-list">' + items + '</ol >';
|
||||||
|
|
||||||
|
$('#nestable04').children().html(items);
|
||||||
|
|
||||||
|
$('#nestable04').nestable();
|
||||||
|
|
||||||
|
$('#nestable04').on('change', function () {
|
||||||
|
nestableChange(this);
|
||||||
|
});
|
||||||
|
|
||||||
|
} else {
|
||||||
|
alert(data.message);
|
||||||
|
|
||||||
|
if (data.err_code == "99999") {
|
||||||
|
location.href = "/Root/Login";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
|
alert('網路或伺服器發生錯誤,請稍後重試!');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function loadFansTypeList() {
|
||||||
|
var formData = {
|
||||||
|
option_uid: 'fansType'
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: "/AuthApi/optionItemList",
|
||||||
|
type: "post",
|
||||||
|
data: formData,
|
||||||
|
success: function (data, textStatus, jqXHR) {
|
||||||
|
if (data.ret == "yes") {
|
||||||
|
var obj = data.optionItems;
|
||||||
|
var items = "";
|
||||||
|
$.each(obj, function (index, item) {
|
||||||
|
items += optionItemHtml(item);
|
||||||
|
});
|
||||||
|
|
||||||
|
//items = '<ol class="dd-list">' + items + '</ol >';
|
||||||
|
|
||||||
|
$('#nestable03').children().html(items);
|
||||||
|
|
||||||
|
$('#nestable03').nestable();
|
||||||
|
|
||||||
|
$('#nestable03').on('change', function () {
|
||||||
|
nestableChange(this);
|
||||||
|
});
|
||||||
|
|
||||||
|
} else {
|
||||||
|
alert(data.message);
|
||||||
|
|
||||||
|
if (data.err_code == "99999") {
|
||||||
|
location.href = "/Root/Login";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
|
alert('網路或伺服器發生錯誤,請稍後重試!');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function loadKolStyleList() {
|
||||||
|
var formData = {
|
||||||
|
option_uid: 'kolStyle'
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: "/AuthApi/optionItemList",
|
||||||
|
type: "post",
|
||||||
|
data: formData,
|
||||||
|
success: function (data, textStatus, jqXHR) {
|
||||||
|
if (data.ret == "yes") {
|
||||||
|
var obj = data.optionItems;
|
||||||
|
var items = "";
|
||||||
|
$.each(obj, function (index, item) {
|
||||||
|
items += optionItemHtml(item);
|
||||||
|
});
|
||||||
|
|
||||||
|
//items = '<ol class="dd-list">' + items + '</ol >';
|
||||||
|
|
||||||
|
$('#nestable02').children().html(items);
|
||||||
|
|
||||||
|
$('#nestable02').nestable();
|
||||||
|
|
||||||
|
$('#nestable02').on('change', function () {
|
||||||
|
nestableChange(this);
|
||||||
|
});
|
||||||
|
|
||||||
|
} else {
|
||||||
|
alert(data.message);
|
||||||
|
|
||||||
|
if (data.err_code == "99999") {
|
||||||
|
location.href = "/Root/Login";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
|
alert('網路或伺服器發生錯誤,請稍後重試!');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function nestableChange(obj) {
|
||||||
|
alert($(obj).attr("data-type"));
|
||||||
|
alert(window.JSON.stringify($(obj).nestable('serialize')));
|
||||||
|
}
|
||||||
|
function loadKolMakeupList() {
|
||||||
|
var formData = {
|
||||||
|
option_uid: 'kolMakeup'
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: "/AuthApi/optionItemList",
|
||||||
|
type: "post",
|
||||||
|
data: formData,
|
||||||
|
success: function (data, textStatus, jqXHR) {
|
||||||
|
if (data.ret == "yes") {
|
||||||
|
var obj = data.optionItems;
|
||||||
|
var items = "";
|
||||||
|
$.each(obj, function (index, item) {
|
||||||
|
items += optionItemHtml(item);
|
||||||
|
});
|
||||||
|
|
||||||
|
//items = '<ol class="dd-list">' + items + '</ol >';
|
||||||
|
|
||||||
|
$('#nestable01').children().html(items);
|
||||||
|
|
||||||
|
$('#nestable01').nestable();
|
||||||
|
|
||||||
|
$('#nestable01').on('change', function () {
|
||||||
|
nestableChange(this);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
alert(data.message);
|
||||||
|
|
||||||
|
if (data.err_code == "99999") {
|
||||||
|
location.href = "/Root/Login";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
|
alert('網路或伺服器發生錯誤,請稍後重試!');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function optionItemHtml(item) {
|
||||||
|
var html = "<li class=\"dd-item\" data-id=\"".concat(item.optionItem_uid, "\">\n <div class=\"dd-handle\">\n <span class=\"drag-indicator\"></span>\n <div data-name=\"option_name\">").concat(item.optionItem_name, "</div>\n <div class=\"dd-nodrag btn-group ml-auto\">\n <button class=\"btn btn-sm btn-secondary\" data-parent-uid=\"").concat(item.option_uid, "\" data-uid=\"").concat(item.optionItem_uid, "\" onclick=\"editBtnClick(this);\">Edit</button>\n <button class=\"btn btn-sm btn-secondary\" data-parent-uid=\"").concat(item.option_uid, "\" data-uid=\"").concat(item.optionItem_uid, "\" onclick=\"delBtnClick(this);\" ><i class=\"far fa-trash-alt\"></i></button>\n </div>\n </li>");
|
||||||
|
return html;
|
||||||
|
}
|
||||||
|
|
||||||
|
function editBtnClick(obj) {
|
||||||
|
|
||||||
|
var optionItem_name = $(obj).parent().parent().find("[data-name='option_name']").text();
|
||||||
|
var option_name = $(obj).parent().parent().parent().parent().parent().parent().find('.card-header.border-bottom-0').text();
|
||||||
|
|
||||||
|
$('#method').val('edit');
|
||||||
|
$('#option_name').val();
|
||||||
|
$('#option_uid').val($(obj).attr("data-parent-type"));
|
||||||
|
$('#optionItem_uid').val($(obj).attr("data-uid"));
|
||||||
|
$('#optionItemModal').modal('toggle');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$('#optionItem_name').val(optionItem_name).trigger("change");
|
||||||
|
|
||||||
|
$('#optionItemModal').modal('toggle');
|
||||||
|
}
|
||||||
|
|
||||||
|
function delBtnClick(obj) {
|
||||||
|
alert($(obj).attr("data-parent-uid"));
|
||||||
|
}
|
||||||
|
|
||||||
|
function addItem(obj) {
|
||||||
|
//alert($(obj).attr("data-type"));
|
||||||
|
|
||||||
|
$('#option_name').val($(obj).parent().parent().find('.card-header.border-bottom-0').text());
|
||||||
|
$('#method').val('add');
|
||||||
|
$('#option_uid').val($(obj).attr("data-type"));
|
||||||
|
$('#optionItemModal').modal('toggle');
|
||||||
|
|
||||||
|
tmpNestableObj = $(obj).parent().parent().find('.dd');
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue