update new 媒體規格維護
parent
95e3478c01
commit
1f8b1b7172
|
|
@ -56,6 +56,8 @@ namespace Journeys_WantHome.Controllers
|
||||||
this._httpContextAccessor = httpContextAccessor;
|
this._httpContextAccessor = httpContextAccessor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[Route("updateTags")]
|
[Route("updateTags")]
|
||||||
public ActionResult UpdateTags(IFormCollection obj) {
|
public ActionResult UpdateTags(IFormCollection obj) {
|
||||||
updatTagResult ret = new updatTagResult();
|
updatTagResult ret = new updatTagResult();
|
||||||
|
|
@ -911,6 +913,8 @@ namespace Journeys_WantHome.Controllers
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class updatTagResult {
|
public class updatTagResult {
|
||||||
public string ret { get; set; } = "no";
|
public string ret { get; set; } = "no";
|
||||||
public string err_code { get; set; } = "0000";
|
public string err_code { get; set; } = "0000";
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,289 @@ namespace Journeys_WantHome.Controllers
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Route("mediaSpecOrder")]
|
||||||
|
public ActionResult MediaSpecOrder(IFormCollection obj)
|
||||||
|
{
|
||||||
|
signinResult ret = new signinResult();
|
||||||
|
|
||||||
|
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 optionItem_uid = obj["optionItem_uid"].ToString();
|
||||||
|
string orderJson = obj["order_json"].ToString();
|
||||||
|
|
||||||
|
if (optionItem_uid == "")
|
||||||
|
{
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "00001";
|
||||||
|
ret.message = "無option_uid資料!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (orderJson == "")
|
||||||
|
{
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "00002";
|
||||||
|
ret.message = "無order_json資料!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
dynamic orderObj;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
orderObj = JsonConvert.DeserializeObject<dynamic>(orderJson);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "00003";
|
||||||
|
ret.message = "json文字轉成物件失敗 " + ex.Message;
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int intOrder = 1;
|
||||||
|
|
||||||
|
foreach (dynamic tmpObj in orderObj)
|
||||||
|
{
|
||||||
|
if (tmpObj.id != null)
|
||||||
|
{
|
||||||
|
string mediaItem_uid = tmpObj.id;
|
||||||
|
|
||||||
|
mediaItem tmpItem = conn.QueryFirstOrDefault<mediaItem>("select * from mediaItem where mediaItem_uid = @mediaItem_uid and optionItem_uid = @optionItem_uid", new { mediaItem_uid = mediaItem_uid, optionItem_uid = optionItem_uid });
|
||||||
|
|
||||||
|
if (tmpItem != null)
|
||||||
|
{
|
||||||
|
tmpItem.mediaItem_order = intOrder;
|
||||||
|
conn.Update<mediaItem>(tmpItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
intOrder++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ret.ret = "yes";
|
||||||
|
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Route("addEditDelSpec")]
|
||||||
|
public ActionResult AddEditDelSpec(IFormCollection obj)
|
||||||
|
{
|
||||||
|
mediaSpecResult ret = new mediaSpecResult();
|
||||||
|
|
||||||
|
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 mediaItem_uid = obj["mediaItem_uid"].ToString();
|
||||||
|
string optionItem_uid = obj["optionItem_uid"].ToString();
|
||||||
|
string mediaItem_name = obj["mediaItem_name"].ToString();
|
||||||
|
string method = obj["method"].ToString();
|
||||||
|
|
||||||
|
|
||||||
|
if (optionItem_uid == "")
|
||||||
|
{
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "00001";
|
||||||
|
ret.message = "無optionItem_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")
|
||||||
|
{
|
||||||
|
mediaItem item = conn.QueryFirstOrDefault<mediaItem>("select * from mediaItem where mediaItem_ishide = 'N' and mediaItem_uid = @mediaItem_uid and optionItem_uid = @optionItem_uid", new { mediaItem_uid = mediaItem_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.mediaItem = item;
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (method == "add")
|
||||||
|
{
|
||||||
|
if (mediaItem_name == "")
|
||||||
|
{
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "0004";
|
||||||
|
ret.message = "無項目名稱!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
mediaItem item = conn.QueryFirstOrDefault<mediaItem>("select * from mediaItem where mediaItem_ishide = 'N' and optionItem_uid = @optionItem_uid and mediaItem_name = @mediaItem_name", new { optionItem_uid = optionItem_uid, mediaItem_name = mediaItem_name });
|
||||||
|
|
||||||
|
if (item != null)
|
||||||
|
{
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "0005";
|
||||||
|
ret.message = "此項目名稱已存在!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<mediaItem> itemsList = conn.Query<mediaItem>("select * from mediaItem where mediaItem_ishide = 'N' and optionItem_uid = @optionItem_uid", new { optionItem_uid = optionItem_uid }).ToList();
|
||||||
|
|
||||||
|
mediaItem_uid = "mitm_" + GlobalClass.CreateRandomCode(8);
|
||||||
|
item = new mediaItem();
|
||||||
|
|
||||||
|
item.mediaItem_uid = mediaItem_uid;
|
||||||
|
item.optionItem_uid = optionItem_uid;
|
||||||
|
item.mediaItem_name = mediaItem_name;
|
||||||
|
item.mediaItem_ishide = "N";
|
||||||
|
item.mediaItem_userId = token.user_id;
|
||||||
|
item.mediaItem_order = itemsList.Count + 1;
|
||||||
|
|
||||||
|
conn.Insert(item);
|
||||||
|
|
||||||
|
ret.ret = "yes";
|
||||||
|
ret.mediaItem = item;
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (method == "edit")
|
||||||
|
{
|
||||||
|
if (mediaItem_name == "")
|
||||||
|
{
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "0004";
|
||||||
|
ret.message = "無項目名稱!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
mediaItem item = conn.QueryFirstOrDefault<mediaItem>("select * from mediaItem where mediaItem_ishide = 'N' and optionItem_uid = @optionItem_uid and mediaItem_name = @mediaItem_name and mediaItem_uid <> @mediaItem_uid", new { optionItem_uid = optionItem_uid, mediaItem_name = mediaItem_name, mediaItem_uid = mediaItem_uid });
|
||||||
|
|
||||||
|
if (item != null)
|
||||||
|
{
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "0005";
|
||||||
|
ret.message = "此修改後項目名稱已被使用!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
mediaItem editItem = conn.QueryFirstOrDefault<mediaItem>("select * from mediaItem where mediaItem_ishide = 'N' and mediaItem_uid = @mediaItem_uid and optionItem_uid = @optionItem_uid", new { mediaItem_uid = mediaItem_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.mediaItem_name = mediaItem_name;
|
||||||
|
editItem.mediaItem_userId = token.user_id;
|
||||||
|
editItem.mediaItem_modifydate = DateTime.Now;
|
||||||
|
|
||||||
|
conn.Update(editItem);
|
||||||
|
ret.ret = "yes";
|
||||||
|
ret.mediaItem = editItem;
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (method == "del")
|
||||||
|
{
|
||||||
|
mediaItem editItem = conn.QueryFirstOrDefault<mediaItem>("select * from mediaItem where mediaItem_ishide = 'N' and mediaItem_uid = @mediaItem_uid and optionItem_uid = @optionItem_uid", new { mediaItem_uid = mediaItem_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.mediaItem_userId = token.user_id;
|
||||||
|
editItem.mediaItem_modifydate = DateTime.Now;
|
||||||
|
editItem.mediaItem_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("queryMediaSpecs")]
|
||||||
|
public ActionResult QueryMediaSpecs(IFormCollection obj)
|
||||||
|
{
|
||||||
|
mediaItemResult ret = new mediaItemResult();
|
||||||
|
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<optionItem> mediaList = conn.Query<optionItem>("select * from optionItem where option_uid = 'media' and optionItem_ishide = 'N' order by optionItem_order").ToList();
|
||||||
|
|
||||||
|
foreach (optionItem item in mediaList)
|
||||||
|
{
|
||||||
|
mediaItemDetail mediaItemDetail = new mediaItemDetail(item);
|
||||||
|
ret.mediaSpecList.Add(mediaItemDetail);
|
||||||
|
}
|
||||||
|
ret.ret = "yes";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
[Route("optionItemOrder")]
|
[Route("optionItemOrder")]
|
||||||
public ActionResult OptionItemOrder(IFormCollection obj) {
|
public ActionResult OptionItemOrder(IFormCollection obj) {
|
||||||
signinResult ret = new signinResult();
|
signinResult ret = new signinResult();
|
||||||
|
|
@ -870,8 +1153,16 @@ namespace Journeys_WantHome.Controllers
|
||||||
|
|
||||||
|
|
||||||
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class mediaItemResult
|
||||||
|
{
|
||||||
|
public string ret { get; set; } = "no";
|
||||||
|
public string err_code { get; set; } = "0000";
|
||||||
|
public string message { get; set; } = "";
|
||||||
|
|
||||||
|
public List<mediaItemDetail> mediaSpecList = new List<mediaItemDetail>();
|
||||||
|
}
|
||||||
public class signinResult
|
public class signinResult
|
||||||
{
|
{
|
||||||
public string ret = "no";
|
public string ret = "no";
|
||||||
|
|
@ -918,5 +1209,13 @@ namespace Journeys_WantHome.Controllers
|
||||||
public string message = "";
|
public string message = "";
|
||||||
public optionItem optionItem = new optionItem();
|
public optionItem optionItem = new optionItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class mediaSpecResult
|
||||||
|
{
|
||||||
|
public string ret = "no";
|
||||||
|
public string err_code = "0000";
|
||||||
|
public string message = "";
|
||||||
|
public mediaItem mediaItem = new mediaItem();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,22 @@ namespace Journeys_WantHome.Controllers
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IActionResult MediaItemList()
|
||||||
|
{
|
||||||
|
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 OptionList()
|
public IActionResult OptionList()
|
||||||
{
|
{
|
||||||
if (checkToken() == false)
|
if (checkToken() == false)
|
||||||
|
|
|
||||||
|
|
@ -44,13 +44,13 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Dapper" Version="2.1.21" />
|
<PackageReference Include="Dapper" Version="2.1.28" />
|
||||||
<PackageReference Include="Dapper.Contrib" Version="2.0.78" />
|
<PackageReference Include="Dapper.Contrib" Version="2.0.78" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
<PackageReference Include="NPOI" Version="2.6.2" />
|
<PackageReference Include="NPOI" Version="2.6.2" />
|
||||||
<PackageReference Include="RestSharp" Version="110.2.0" />
|
<PackageReference Include="RestSharp" Version="110.2.0" />
|
||||||
<PackageReference Include="System.Data.SqlClient" Version="4.8.5" />
|
<PackageReference Include="System.Data.SqlClient" Version="4.8.6" />
|
||||||
<PackageReference Include="System.Drawing.Common" Version="8.0.0" />
|
<PackageReference Include="System.Drawing.Common" Version="8.0.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,22 @@ using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
public class DbTableClass
|
public class DbTableClass
|
||||||
{
|
{
|
||||||
|
[Table("mediaItem")]
|
||||||
|
public class mediaItem
|
||||||
|
{
|
||||||
|
[JsonIgnore]
|
||||||
|
[Key]
|
||||||
|
public int mediaItem_sn { get; set; }
|
||||||
|
public string mediaItem_uid { get; set; } = "";
|
||||||
|
public string optionItem_uid { get; set; } = "";
|
||||||
|
public string mediaItem_name { get; set; } = "";
|
||||||
|
public string mediaItem_ishide { get; set; } = "N";
|
||||||
|
public int mediaItem_order { get; set; } = 999;
|
||||||
|
public DateTime mediaItem_createdate { get; set; } = DateTime.Now;
|
||||||
|
public DateTime mediaItem_modifydate { get; set; } = DateTime.Now;
|
||||||
|
public string mediaItem_userId { get; set; } = "";
|
||||||
|
}
|
||||||
|
|
||||||
[Table("kolTag")]
|
[Table("kolTag")]
|
||||||
public class kolTag
|
public class kolTag
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,8 @@ public class kolMediaDetail : kolMedia
|
||||||
|
|
||||||
public string updateResult { get; set; } = "";
|
public string updateResult { get; set; } = "";
|
||||||
|
|
||||||
|
public List<mediaItem> mediaSpecItems { get; set; } = new List<mediaItem>();
|
||||||
|
|
||||||
private kolMedia _kolMedia;
|
private kolMedia _kolMedia;
|
||||||
|
|
||||||
public kolMediaDetail()
|
public kolMediaDetail()
|
||||||
|
|
@ -20,7 +22,7 @@ public class kolMediaDetail : kolMedia
|
||||||
_kolMedia = new kolMedia();
|
_kolMedia = new kolMedia();
|
||||||
}
|
}
|
||||||
|
|
||||||
public kolMediaDetail(string kolMakeup_uid)
|
public kolMediaDetail(string kolMedia_uid)
|
||||||
{
|
{
|
||||||
_kolMedia = conn.QueryFirstOrDefault<kolMedia>("select * from kolMedia where kolMedia_uid = @kolMedia_uid", new { kolMedia_uid = kolMedia_uid });
|
_kolMedia = conn.QueryFirstOrDefault<kolMedia>("select * from kolMedia where kolMedia_uid = @kolMedia_uid", new { kolMedia_uid = kolMedia_uid });
|
||||||
|
|
||||||
|
|
@ -44,6 +46,8 @@ public class kolMediaDetail : kolMedia
|
||||||
this.option_name = result.option_name;
|
this.option_name = result.option_name;
|
||||||
this.optionItem_name = result.optionItem_name;
|
this.optionItem_name = result.optionItem_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadMediaItem(kolMedia_uid);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -73,6 +77,16 @@ public class kolMediaDetail : kolMedia
|
||||||
this.option_name = result.option_name;
|
this.option_name = result.option_name;
|
||||||
this.optionItem_name = result.optionItem_name;
|
this.optionItem_name = result.optionItem_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadMediaItem(kolMedia.optionItem_uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
void loadMediaItem(string kolMedia_uid) {
|
||||||
|
|
||||||
|
List<mediaItem> mediaItems = conn.Query<mediaItem>("select * from mediaItem where mediaItem_ishide = 'N' and optionItem_uid = @optionItem_uid order by mediaItem_order", new { optionItem_uid = kolMedia_uid}).ToList();
|
||||||
|
|
||||||
|
mediaSpecItems = mediaItems;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool dataUpdate()
|
public bool dataUpdate()
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
using Dapper;
|
||||||
|
using Dapper.Contrib.Extensions;
|
||||||
|
using System.Data.SqlClient;
|
||||||
|
using static DbTableClass;
|
||||||
|
public class mediaItemDetail : optionItem
|
||||||
|
{
|
||||||
|
DbConn dbConn = new DbConn();
|
||||||
|
SqlConnection conn = new SqlConnection(GlobalClass.appsettings("ConnectionStrings:SQLConnectionString"));
|
||||||
|
|
||||||
|
public List<mediaItem> mediaSpecList = new List<mediaItem>();
|
||||||
|
|
||||||
|
private optionItem _optionItem;
|
||||||
|
public mediaItemDetail() {
|
||||||
|
_optionItem = new optionItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
public mediaItemDetail(string _optionItem_uid) {
|
||||||
|
|
||||||
|
_optionItem = conn.QueryFirstOrDefault<optionItem>("select * from optionItem where optionItem_uid = @optionItem_uid", new { optionItem_uid = _optionItem_uid });
|
||||||
|
|
||||||
|
if (_optionItem != null)
|
||||||
|
{
|
||||||
|
Type dataType = _optionItem.GetType();
|
||||||
|
|
||||||
|
foreach (var prop in dataType.GetProperties())
|
||||||
|
{
|
||||||
|
string propName = prop.Name;
|
||||||
|
var valueProperty = dataType.GetProperty(propName);
|
||||||
|
object propValue = valueProperty.GetValue(_optionItem, null);
|
||||||
|
|
||||||
|
this.GetType().GetProperty(propName).SetValue(this, propValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
mediaSpecList = conn.Query<mediaItem>("select * from mediaItem where mediaItem_ishide = 'N' and optionItem_uid = @optionItem_uid order by mediaItem_order", new { optionItem_uid = _optionItem_uid}).ToList();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
_optionItem = new optionItem();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public mediaItemDetail(optionItem _obj) {
|
||||||
|
_optionItem = _obj;
|
||||||
|
|
||||||
|
Type dataType = _optionItem.GetType();
|
||||||
|
|
||||||
|
foreach (var prop in dataType.GetProperties())
|
||||||
|
{
|
||||||
|
string propName = prop.Name;
|
||||||
|
var valueProperty = dataType.GetProperty(propName);
|
||||||
|
object propValue = valueProperty.GetValue(_optionItem, null);
|
||||||
|
|
||||||
|
this.GetType().GetProperty(propName).SetValue(this, propValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
mediaSpecList = conn.Query<mediaItem>("select * from mediaItem where mediaItem_ishide = 'N' and optionItem_uid = @optionItem_uid order by mediaItem_order", new { optionItem_uid = _optionItem.optionItem_uid }).ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,77 @@
|
||||||
|
@*
|
||||||
|
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/mediaItemlist.js" asp-append-version="true"></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" id="card_group">
|
||||||
|
|
||||||
|
</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="optionItem_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="mediaItem_uid" />
|
||||||
|
<input type="hidden" id="optionItem_uid" />
|
||||||
|
<!-- .form-group -->
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="form-label-group">
|
||||||
|
<input type="text" id="mediaItem_name" class="form-control" value="" placeholder="規格名稱" maxlength="32" required=""> <label for="mediaItem_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 -->
|
||||||
|
|
@ -144,6 +144,9 @@
|
||||||
<li class="menu-item">
|
<li class="menu-item">
|
||||||
<a href="~/Home/OptionList" class="menu-link">選項資料管理</a>
|
<a href="~/Home/OptionList" class="menu-link">選項資料管理</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="menu-item">
|
||||||
|
<a href="~/Home/MediaItemList" class="menu-link">報價規格管理</a>
|
||||||
|
</li>
|
||||||
<li class="menu-item">
|
<li class="menu-item">
|
||||||
<a href="~/Home/UserList" class="menu-link">使用者管理</a>
|
<a href="~/Home/UserList" class="menu-link">使用者管理</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,279 @@
|
||||||
|
var tmpNestableObj;
|
||||||
|
var tmpNestableItem;
|
||||||
|
|
||||||
|
$(document).ready(function () {
|
||||||
|
|
||||||
|
loadMediaCard();
|
||||||
|
|
||||||
|
$('#optionItemDialogSaveBtn').click(function () {
|
||||||
|
var method = $('#method').val();
|
||||||
|
var mediaItem_uid = $('#mediaItem_uid').val();
|
||||||
|
var optionItem_uid = $('#optionItem_uid').val();
|
||||||
|
var mediaItem_name = $('#mediaItem_name').val();
|
||||||
|
|
||||||
|
if (method == 'add') {
|
||||||
|
if (mediaItem_name == '') {
|
||||||
|
alert('請輸入項目名稱!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var formData = {
|
||||||
|
optionItem_uid: optionItem_uid,
|
||||||
|
mediaItem_name: mediaItem_name,
|
||||||
|
method: method
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: "/AuthApi/addEditDelSpec",
|
||||||
|
type: "post",
|
||||||
|
data: formData,
|
||||||
|
success: function (data, textStatus, jqXHR) {
|
||||||
|
if (data.ret == "yes") {
|
||||||
|
var obj = data.mediaItem;
|
||||||
|
|
||||||
|
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('網路或伺服器發生錯誤,請稍後重試!');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (method == 'edit') {
|
||||||
|
if (mediaItem_name == '') {
|
||||||
|
alert('請輸入項目名稱!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var formData = {
|
||||||
|
mediaItem_uid: mediaItem_uid,
|
||||||
|
optionItem_uid: optionItem_uid,
|
||||||
|
mediaItem_name: mediaItem_name,
|
||||||
|
method: method
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: "/AuthApi/addEditDelSpec",
|
||||||
|
type: "post",
|
||||||
|
data: formData,
|
||||||
|
success: function (data, textStatus, jqXHR) {
|
||||||
|
if (data.ret == "yes") {
|
||||||
|
var obj = data.mediaItem;
|
||||||
|
|
||||||
|
tmpNestableItem.text(obj.mediaItem_name);
|
||||||
|
|
||||||
|
$('#optionItemModal').modal('toggle');
|
||||||
|
|
||||||
|
} else {
|
||||||
|
alert(data.message);
|
||||||
|
|
||||||
|
if (data.err_code == "99999") {
|
||||||
|
location.href = "/Root/Login";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
|
alert('網路或伺服器發生錯誤,請稍後重試!');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function loadMediaCard() {
|
||||||
|
var formData = {
|
||||||
|
option_uid: 'media'
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: "/AuthApi/queryMediaSpecs",
|
||||||
|
type: "post",
|
||||||
|
data: formData,
|
||||||
|
success: function (data, textStatus, jqXHR) {
|
||||||
|
if (data.ret == "yes") {
|
||||||
|
var obj = data.mediaSpecList;
|
||||||
|
var items = "";
|
||||||
|
$.each(obj, function (index, item) {
|
||||||
|
$('#card_group').append(cardHtml(item));
|
||||||
|
$('#' + item.optionItem_uid).nestable();
|
||||||
|
|
||||||
|
$('#' + item.optionItem_uid).on('change', function () {
|
||||||
|
nestableChange(this);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
//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 cardHtml(mediaOption) {
|
||||||
|
var html = "";
|
||||||
|
html += "<!-- grid column -->";
|
||||||
|
html += "<div class=\"col-lg-6\">";
|
||||||
|
html += " <!-- .card -->";
|
||||||
|
html += " <div class=\"card card-fluid\">";
|
||||||
|
html += " <div class=\"card-header border-bottom-0\"> " + mediaOption.optionItem_name + " </div><!-- .nestable -->";
|
||||||
|
html += " <div id=\"" + mediaOption.optionItem_uid + "\" class=\"dd\" data-toggle=\"sortable\" data-max-depth=\"1\" data-type=\"" + mediaOption.optionItem_uid + "\">";
|
||||||
|
html += " <!-- .dd-list -->";
|
||||||
|
html += " <ol class=\"dd-list\">";
|
||||||
|
html += " <li></li>";
|
||||||
|
|
||||||
|
$.each(mediaOption.mediaSpecList, function (index, item) {
|
||||||
|
html += optionItemHtml(item);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
html += " </ol><!-- /.dd-list -->";
|
||||||
|
html += " </div><!-- /.nestable -->";
|
||||||
|
html += " <!-- .card-footer -->";
|
||||||
|
html += " <div class=\"card-footer\">";
|
||||||
|
html += " <a href=\"javascript: void(0);\" onclick=\"addItem(this)\" data-type=\"" + mediaOption.optionItem_uid + "\" class=\"card-footer-item justify-content-start\"><span><i class=\"fa fa-plus-circle mr-1\"></i> Add Menu Item</span></a>";
|
||||||
|
html += " </div><!-- /.card-footer -->";
|
||||||
|
html += " </div><!-- /.card -->";
|
||||||
|
html += "</div><!-- /grid column -->";
|
||||||
|
|
||||||
|
return html;
|
||||||
|
}
|
||||||
|
|
||||||
|
function optionItemHtml(item) {
|
||||||
|
var html = "<li class=\"dd-item\" data-id=\"".concat(item.mediaItem_uid, "\">\n <div class=\"dd-handle\">\n <span class=\"drag-indicator\"></span>\n <div data-name=\"option_name\">").concat(item.mediaItem_name, "</div>\n <div class=\"dd-nodrag btn-group ml-auto\">\n <button class=\"btn btn-sm btn-secondary\" data-parent-uid=\"").concat(item.optionItem_uid, "\" data-uid=\"").concat(item.mediaItem_uid, "\" onclick=\"editBtnClick(this);\">Edit</button>\n <button class=\"btn btn-sm btn-secondary\" data-parent-uid=\"").concat(item.optionItem_uid, "\" data-uid=\"").concat(item.mediaItem_uid, "\" onclick=\"delBtnClick(this);\" ><i class=\"far fa-trash-alt\"></i></button>\n </div>\n </li>");
|
||||||
|
return html;
|
||||||
|
}
|
||||||
|
|
||||||
|
function addItem(obj) {
|
||||||
|
//alert($(obj).attr("data-type"));
|
||||||
|
|
||||||
|
$('#optionItem_name').val($(obj).parent().parent().find('.card-header.border-bottom-0').text());
|
||||||
|
$('#method').val('add');
|
||||||
|
$('#optionItem_uid').val($(obj).attr("data-type"));
|
||||||
|
$('#optionItemModal').modal('toggle');
|
||||||
|
|
||||||
|
tmpNestableObj = $(obj).parent().parent().find('.dd');
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function editBtnClick(obj) {
|
||||||
|
tmpNestableItem = $(obj).parent().parent().find("[data-name='option_name']");
|
||||||
|
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_name);
|
||||||
|
$('#optionItem_uid').val($(obj).attr("data-parent-uid"));
|
||||||
|
$('#mediaItem_uid').val($(obj).attr("data-uid"));
|
||||||
|
$('#optionItemModal').modal('toggle');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$('#mediaItem_name').val(optionItem_name).trigger("change");
|
||||||
|
|
||||||
|
$('#optionItemModal').modal('toggle');
|
||||||
|
}
|
||||||
|
|
||||||
|
function delBtnClick(obj) {
|
||||||
|
|
||||||
|
|
||||||
|
if (confirm('確定刪除此筆資料? 刪掉後,網紅中有勾選此項目的此項目紀錄會消失,新增一筆相同名稱的項目也無法復原!')) {
|
||||||
|
if (confirm('再次確認要刪除此筆資料?')) {
|
||||||
|
tmpNestableItem = $(obj).parent().parent().find("[data-name='option_name']");
|
||||||
|
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();
|
||||||
|
var optionItem_uid = $(obj).attr("data-parent-uid");
|
||||||
|
var mediaItem_uid = $(obj).attr("data-uid");
|
||||||
|
|
||||||
|
var formData = {
|
||||||
|
mediaItem_uid: mediaItem_uid,
|
||||||
|
optionItem_uid: optionItem_uid,
|
||||||
|
method: 'del'
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: "/AuthApi/addEditDelSpec",
|
||||||
|
type: "post",
|
||||||
|
data: formData,
|
||||||
|
success: function (data, textStatus, jqXHR) {
|
||||||
|
if (data.ret == "yes") {
|
||||||
|
tmpNestableItem.parent().remove();
|
||||||
|
|
||||||
|
} 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')));
|
||||||
|
|
||||||
|
var optionItem_uid = $(obj).attr("data-type");
|
||||||
|
var order_json = window.JSON.stringify($(obj).nestable('serialize'));
|
||||||
|
|
||||||
|
var formData = {
|
||||||
|
optionItem_uid: optionItem_uid,
|
||||||
|
order_json: order_json
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: "/AuthApi/mediaSpecOrder",
|
||||||
|
type: "post",
|
||||||
|
data: formData,
|
||||||
|
success: function (data, textStatus, jqXHR) {
|
||||||
|
if (data.ret == "yes") {
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
//alert(data.message);
|
||||||
|
|
||||||
|
if (data.err_code == "99999") {
|
||||||
|
location.href = "/Root/Login";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
|
alert('網路或伺服器發生錯誤,請稍後重試!');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
@ -405,4 +405,4 @@ function addItem(obj) {
|
||||||
$('#optionItemModal').modal('toggle');
|
$('#optionItemModal').modal('toggle');
|
||||||
|
|
||||||
tmpNestableObj = $(obj).parent().parent().find('.dd');
|
tmpNestableObj = $(obj).parent().parent().find('.dd');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue