Compare commits
2 Commits
f6a1a8dac6
...
1f8b1b7172
| Author | SHA1 | Date |
|---|---|---|
|
|
1f8b1b7172 | |
|
|
95e3478c01 |
|
|
@ -56,16 +56,138 @@ namespace Journeys_WantHome.Controllers
|
|||
this._httpContextAccessor = httpContextAccessor;
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Route("updateTags")]
|
||||
public ActionResult UpdateTags(IFormCollection obj) {
|
||||
updatTagResult ret = new updatTagResult();
|
||||
|
||||
authToken token = new authToken(this._httpContextAccessor);
|
||||
if (token.user_isLogin == false)
|
||||
{
|
||||
HttpContext.Response.Cookies.Delete("token_key");
|
||||
|
||||
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||
}
|
||||
|
||||
string search = obj["search"].ToString();
|
||||
|
||||
if (search.Length < 2) {
|
||||
ret.ret = "no";
|
||||
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||
}
|
||||
|
||||
tags tag = conn.QueryFirstOrDefault<tags>("select * from tags where tag_text = @tag_text", new { tag_text = search });
|
||||
|
||||
|
||||
|
||||
if (tag == null)
|
||||
{
|
||||
tags newTag = new tags();
|
||||
newTag.tag_uid = "tag_" + GlobalClass.CreateRandomCode(12);
|
||||
newTag.tag_text = search;
|
||||
|
||||
conn.Insert<tags>(newTag);
|
||||
|
||||
ret.data.id = newTag.tag_uid;
|
||||
ret.data.text = search;
|
||||
ret.ret = "yes";
|
||||
}
|
||||
else {
|
||||
ret.data.id = tag.tag_uid;
|
||||
ret.data.text = search;
|
||||
ret.ret = "yes";
|
||||
}
|
||||
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||
}
|
||||
|
||||
[Route("queryTags")]
|
||||
public ActionResult QueryTags(IFormCollection obj) {
|
||||
tagListResult ret = new tagListResult();
|
||||
|
||||
authToken token = new authToken(this._httpContextAccessor);
|
||||
if (token.user_isLogin == false)
|
||||
{
|
||||
HttpContext.Response.Cookies.Delete("token_key");
|
||||
|
||||
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||
}
|
||||
|
||||
string search = obj["search"].ToString();
|
||||
|
||||
search = "%" + search + "%";
|
||||
|
||||
List<tags> tagList = conn.Query<tags>("select * from tags where tag_text like @tag_text", new { tag_text = search }).ToList();
|
||||
|
||||
foreach (tags tag in tagList)
|
||||
{
|
||||
optionData item = new optionData();
|
||||
|
||||
item.id = tag.tag_uid;
|
||||
item.text = tag.tag_text;
|
||||
|
||||
ret.data.Add(item);
|
||||
}
|
||||
|
||||
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||
}
|
||||
|
||||
[Route("queryPrmFile")]
|
||||
public ActionResult QueryPrmFile(IFormCollection obj) {
|
||||
prmFileResult ret = new prmFileResult();
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
string quotation_serial = obj["quotation_serial"].ToString();
|
||||
|
||||
files fil = prmConn.QueryFirstOrDefault<files>("select * from files where file_target_uid = @quotation_serial and file_del = 'N'", new { quotation_serial = quotation_serial});
|
||||
|
||||
if (fil == null)
|
||||
{
|
||||
ret.ret = "yes";
|
||||
ret.hasFile = "N";
|
||||
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||
}
|
||||
else {
|
||||
ret.ret = "yes";
|
||||
ret.hasFile = "Y";
|
||||
ret.fileName = fil.file_filename;
|
||||
ret.fileUrl = "https://prm.bremennetwork.tw/api/fileService4Journeys.ashx?id=" + fil.file_uid;
|
||||
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||
}
|
||||
|
||||
[Route("queryPrm")]
|
||||
public ActionResult QueryPrm(IFormCollection obj) {
|
||||
prmResult ret = new prmResult();
|
||||
|
||||
authToken token = new authToken(this._httpContextAccessor);
|
||||
if (token.user_isLogin == false)
|
||||
{
|
||||
HttpContext.Response.Cookies.Delete("token_key");
|
||||
|
||||
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||
}
|
||||
|
||||
string search = obj["search"].ToString();
|
||||
|
||||
string quotation_serial = search + "%";
|
||||
string quotation_name = "%" + search + "%";
|
||||
|
||||
List<quotation> quotations = prmConn.Query<quotation>("select * from quotation where quotation_del = 'N' and quotation_invalid = 'N' and (quotation_serial like @quotation_serial or quotation_name like @quotation_name) order by quotation_serial desc ", new { quotation_serial = quotation_serial, quotation_name = quotation_name }).ToList();
|
||||
List<quotation> quotations = prmConn.Query<quotation>("select * from quotation where dept_uid in ('bremen', 'journeys') and quotation_del = 'N' and quotation_invalid = 'N' and (quotation_serial like @quotation_serial or quotation_name like @quotation_name) order by quotation_serial desc ", new { quotation_serial = quotation_serial, quotation_name = quotation_name }).ToList();
|
||||
|
||||
foreach (quotation proj in quotations)
|
||||
{
|
||||
|
|
@ -282,6 +404,7 @@ namespace Journeys_WantHome.Controllers
|
|||
conn.Execute("delete kolFansType where kol_uid = @kol_uid", new { kol_uid = kol_uid });
|
||||
conn.Execute("delete kolMedia where kol_uid = @kol_uid", new { kol_uid = kol_uid });
|
||||
conn.Execute("delete kolCooperateType where kol_uid = @kol_uid", new { kol_uid = kol_uid });
|
||||
conn.Execute("delete kolTag where kol_uid = @kol_uid", new { kol_uid = kol_uid });
|
||||
|
||||
ret.ret = "yes";
|
||||
|
||||
|
|
@ -323,6 +446,7 @@ namespace Journeys_WantHome.Controllers
|
|||
string kolMakeupStr = obj["kolMakeupStr"].ToString().TrimEnd(',');
|
||||
string kolStyleStr = obj["kolStyleStr"].ToString().TrimEnd(',');
|
||||
string kolFansTypeStr = obj["kolFansType"].ToString().TrimEnd(',');
|
||||
string kolTagsStr = obj["kolTags"].ToString().TrimEnd(',');
|
||||
string mediaArrayJson = obj["mediaArrayJson"].ToString().TrimEnd(',');
|
||||
|
||||
if (method == "") {
|
||||
|
|
@ -428,6 +552,20 @@ namespace Journeys_WantHome.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
string[] kolTagArr = kolTagsStr.Split(",");
|
||||
List<kolTag> kolTags = new List<kolTag>();
|
||||
foreach (string tag in kolTagArr) {
|
||||
tags tagData = conn.QueryFirstOrDefault<tags>("select * from tags where tag_uid = @tag_uid", new { tag_uid = tag });
|
||||
|
||||
if (tagData != null) {
|
||||
kolTag newKolTag = new kolTag();
|
||||
newKolTag.kolTag_uid = "kt_" + GlobalClass.CreateRandomCode(12);
|
||||
newKolTag.kol_uid = kol_uid;
|
||||
newKolTag.tag_uid = tag;
|
||||
kolTags.Add(newKolTag);
|
||||
}
|
||||
}
|
||||
|
||||
dynamic mediaJsonObj;
|
||||
|
||||
try
|
||||
|
|
@ -464,11 +602,13 @@ namespace Journeys_WantHome.Controllers
|
|||
conn.Execute("delete kolStyle where kol_uid = @kol_uid", new { kol_uid = kol_uid });
|
||||
conn.Execute("delete kolFansType where kol_uid = @kol_uid", new { kol_uid = kol_uid });
|
||||
conn.Execute("delete kolMedia where kol_uid = @kol_uid", new { kol_uid = kol_uid });
|
||||
conn.Execute("delete kolTag where kol_uid = @kol_uid", new { kol_uid = kol_uid });
|
||||
|
||||
conn.Insert(kolMakeups);
|
||||
conn.Insert(kolStyles);
|
||||
conn.Insert(kolFansTypes);
|
||||
conn.Insert(medias);
|
||||
conn.Insert(kolTags);
|
||||
|
||||
try
|
||||
{
|
||||
|
|
@ -584,6 +724,22 @@ namespace Journeys_WantHome.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
string[] kolTagArr = kolTagsStr.Split(",");
|
||||
List<kolTag> kolTags = new List<kolTag>();
|
||||
foreach (string tag in kolTagArr)
|
||||
{
|
||||
tags tagData = conn.QueryFirstOrDefault<tags>("select * from tags where tag_uid = @tag_uid", new { tag_uid = tag });
|
||||
|
||||
if (tagData != null)
|
||||
{
|
||||
kolTag newKolTag = new kolTag();
|
||||
newKolTag.kolTag_uid = "kt_" + GlobalClass.CreateRandomCode(12);
|
||||
newKolTag.kol_uid = kol_uid;
|
||||
newKolTag.tag_uid = tag;
|
||||
kolTags.Add(newKolTag);
|
||||
}
|
||||
}
|
||||
|
||||
dynamic mediaJsonObj;
|
||||
|
||||
try {
|
||||
|
|
@ -617,6 +773,7 @@ namespace Journeys_WantHome.Controllers
|
|||
conn.Insert(kolStyles);
|
||||
conn.Insert(kolFansTypes);
|
||||
conn.Insert(medias);
|
||||
conn.Insert(kolTags);
|
||||
|
||||
try
|
||||
{
|
||||
|
|
@ -756,6 +913,28 @@ namespace Journeys_WantHome.Controllers
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class updatTagResult {
|
||||
public string ret { get; set; } = "no";
|
||||
public string err_code { get; set; } = "0000";
|
||||
public string message { get; set; } = "";
|
||||
|
||||
public optionData data = new optionData();
|
||||
}
|
||||
public class tagListResult {
|
||||
public List<optionData> data = new List<optionData>();
|
||||
}
|
||||
public class prmFileResult {
|
||||
public string ret { get; set; } = "no";
|
||||
public string err_code { get; set; } = "0000";
|
||||
public string message { get; set; } = "";
|
||||
|
||||
public string hasFile { get; set; } = "N";
|
||||
public string fileName { get; set; } = "";
|
||||
public string fileUrl { get; set; } = "";
|
||||
|
||||
}
|
||||
public class prmResult {
|
||||
public List<optionData> data = new List<optionData>();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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")]
|
||||
public ActionResult OptionItemOrder(IFormCollection obj) {
|
||||
signinResult ret = new signinResult();
|
||||
|
|
@ -872,6 +1155,14 @@ namespace Journeys_WantHome.Controllers
|
|||
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 string ret = "no";
|
||||
|
|
@ -918,5 +1209,13 @@ namespace Journeys_WantHome.Controllers
|
|||
public string message = "";
|
||||
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();
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
if (checkToken() == false)
|
||||
|
|
|
|||
|
|
@ -44,13 +44,13 @@
|
|||
</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="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="NPOI" Version="2.6.2" />
|
||||
<PackageReference Include="RestSharp" Version="110.2.0" />
|
||||
<PackageReference Include="System.Data.SqlClient" Version="4.8.5" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="8.0.0" />
|
||||
<PackageReference Include="System.Data.SqlClient" Version="4.8.6" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="8.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -8,6 +8,63 @@ using Newtonsoft.Json.Linq;
|
|||
|
||||
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")]
|
||||
public class kolTag
|
||||
{
|
||||
[JsonIgnore]
|
||||
[Key]
|
||||
public int kolTag_sn { get; set; }
|
||||
public string kolTag_uid { get; set; } = "";
|
||||
public string kol_uid { get; set; } = "";
|
||||
public string tag_uid { get; set; } = "";
|
||||
}
|
||||
|
||||
[Table("tags")]
|
||||
public class tags
|
||||
{
|
||||
[JsonIgnore]
|
||||
[Key]
|
||||
public int tag_sn { get; set; }
|
||||
public string tag_uid { get; set; } = "";
|
||||
public string tag_text { get; set; } = "";
|
||||
}
|
||||
|
||||
|
||||
[Table("files")]
|
||||
public class files
|
||||
{
|
||||
[JsonIgnore]
|
||||
[Key]
|
||||
public int file_sn { get; set; }
|
||||
public string file_uid { get; set; }
|
||||
public string file_target_uid { get; set; }
|
||||
public string file_url { get; set; }
|
||||
public string file_filename { get; set; }
|
||||
public string file_contenttype { get; set; }
|
||||
public string file_del { get; set; }
|
||||
public string file_create_user_uid { get; set; }
|
||||
public string file_modify_user_uid { get; set; }
|
||||
public DateTime file_createdate { get; set; }
|
||||
public DateTime file_modifydate { get; set; }
|
||||
}
|
||||
|
||||
|
||||
[Table("quotation")]
|
||||
public class quotation
|
||||
{
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ public class kolDetial : kol
|
|||
public List<kolMakeupDetail> makeups = new List<kolMakeupDetail>();
|
||||
public List<kolMediaDetail> medias = new List<kolMediaDetail>();
|
||||
public List<kolStyleDetail> styles = new List<kolStyleDetail>();
|
||||
public List<kolTagDetail> tags = new List<kolTagDetail>();
|
||||
public string updateResult { get; set; } = "";
|
||||
private kol _kol;
|
||||
|
||||
|
|
@ -65,12 +66,15 @@ public class kolDetial : kol
|
|||
makeups.Clear();
|
||||
medias.Clear();
|
||||
styles.Clear();
|
||||
tags.Clear();
|
||||
|
||||
List <kolCooperateType> kolCooperateTypes = conn.Query<kolCooperateType>("select A.* from kolCooperateType A, optionItem B where A.option_uid = B.option_uid and A.optionItem_uid = B.optionItem_uid and A.kol_uid = @kol_uid order by B.optionItem_order", new { kol_uid = this.kol_uid} ).ToList();
|
||||
List<kolFansType> kolFansTypes = conn.Query<kolFansType>("select A.* from kolFansType A, optionItem B where A.option_uid = B.option_uid and A.optionItem_uid = B.optionItem_uid and A.kol_uid = @kol_uid order by B.optionItem_order", new { kol_uid = this.kol_uid }).ToList();
|
||||
List<kolMakeup> kolMakeups = conn.Query<kolMakeup>("select A.* from kolMakeup A, optionItem B where A.option_uid = B.option_uid and A.optionItem_uid = B.optionItem_uid and A.kol_uid = @kol_uid order by B.optionItem_order", new { kol_uid = this.kol_uid }).ToList();
|
||||
List<kolMedia> kolMedias = conn.Query<kolMedia>("select A.* from kolMedia A, optionItem B where A.option_uid = B.option_uid and A.optionItem_uid = B.optionItem_uid and A.kol_uid = @kol_uid order by B.optionItem_order", new { kol_uid = this.kol_uid }).ToList();
|
||||
List<kolStyle> kolStyles = conn.Query<kolStyle>("select A.* from kolStyle A, optionItem B where A.option_uid = B.option_uid and A.optionItem_uid = B.optionItem_uid and A.kol_uid = @kol_uid order by B.optionItem_order", new { kol_uid = this.kol_uid }).ToList();
|
||||
List<kolTag> kolTags = conn.Query<kolTag>("select A.* from kolTag A, tags B where A.tag_uid = B.tag_uid and A.kol_uid = @kol_uid", new { kol_uid = kol_uid }).ToList();
|
||||
|
||||
|
||||
foreach (kolCooperateType objItem in kolCooperateTypes)
|
||||
{
|
||||
|
|
@ -100,6 +104,12 @@ public class kolDetial : kol
|
|||
kolStyleDetail objDetail = new kolStyleDetail(objItem);
|
||||
styles.Add(objDetail);
|
||||
}
|
||||
|
||||
foreach (kolTag objItem in kolTags)
|
||||
{
|
||||
kolTagDetail objDetail = new kolTagDetail(objItem);
|
||||
tags.Add(objDetail);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -179,5 +189,10 @@ public class kolDetial : kol
|
|||
{
|
||||
item.dataUpdate();
|
||||
}
|
||||
|
||||
foreach (var item in tags)
|
||||
{
|
||||
item.dataUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ public class kolMediaDetail : kolMedia
|
|||
|
||||
public string updateResult { get; set; } = "";
|
||||
|
||||
public List<mediaItem> mediaSpecItems { get; set; } = new List<mediaItem>();
|
||||
|
||||
private kolMedia _kolMedia;
|
||||
|
||||
public kolMediaDetail()
|
||||
|
|
@ -20,7 +22,7 @@ public class kolMediaDetail : 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 });
|
||||
|
||||
|
|
@ -44,6 +46,8 @@ public class kolMediaDetail : kolMedia
|
|||
this.option_name = result.option_name;
|
||||
this.optionItem_name = result.optionItem_name;
|
||||
}
|
||||
|
||||
loadMediaItem(kolMedia_uid);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -73,6 +77,16 @@ public class kolMediaDetail : kolMedia
|
|||
this.option_name = result.option_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()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,126 @@
|
|||
using Dapper;
|
||||
using Dapper.Contrib.Extensions;
|
||||
using System.Data.SqlClient;
|
||||
using static DbTableClass;
|
||||
|
||||
public class kolTagDetail : kolTag
|
||||
{
|
||||
DbConn dbConn = new DbConn();
|
||||
SqlConnection conn = new SqlConnection(GlobalClass.appsettings("ConnectionStrings:SQLConnectionString"));
|
||||
|
||||
public string tag_text { get; set; } = "";
|
||||
|
||||
kolTag _kolTag;
|
||||
|
||||
public string updateResult { get; set; } = "";
|
||||
|
||||
public kolTagDetail()
|
||||
{
|
||||
_kolTag = new kolTag();
|
||||
}
|
||||
|
||||
public kolTagDetail(string kolTag_uid) {
|
||||
_kolTag = conn.QueryFirstOrDefault<kolTag>("select * from kolTag where kolTag_uid = @kolTag_uid", new { kolTag_uid = kolTag_uid});
|
||||
|
||||
if (_kolTag != null)
|
||||
{
|
||||
Type dataType = _kolTag.GetType();
|
||||
|
||||
foreach (var prop in dataType.GetProperties())
|
||||
{
|
||||
string propName = prop.Name;
|
||||
var valueProperty = dataType.GetProperty(propName);
|
||||
object propValue = valueProperty.GetValue(_kolTag, null);
|
||||
|
||||
this.GetType().GetProperty(propName).SetValue(this, propValue);
|
||||
}
|
||||
|
||||
var result = conn.QueryFirstOrDefault("select * from tags where tag_uid = @tag_uid ", new { tag_uid = tag_uid });
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
this.tag_text = result.tag_text;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_kolTag = new kolTag();
|
||||
}
|
||||
}
|
||||
|
||||
public kolTagDetail(kolTag kolTag) {
|
||||
this._kolTag = kolTag;
|
||||
|
||||
Type dataType = _kolTag.GetType();
|
||||
|
||||
foreach (var prop in dataType.GetProperties())
|
||||
{
|
||||
string propName = prop.Name;
|
||||
var valueProperty = dataType.GetProperty(propName);
|
||||
object propValue = valueProperty.GetValue(_kolTag, null);
|
||||
|
||||
this.GetType().GetProperty(propName).SetValue(this, propValue);
|
||||
}
|
||||
|
||||
var result = conn.QueryFirstOrDefault("select * from tags where tag_uid = @tag_uid ", new { tag_uid = tag_uid });
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
this.tag_text = result.tag_text;
|
||||
}
|
||||
}
|
||||
|
||||
public bool dataUpdate()
|
||||
{
|
||||
if (this._kolTag != null)
|
||||
{
|
||||
Type dataType = _kolTag.GetType();
|
||||
|
||||
foreach (var prop in dataType.GetProperties())
|
||||
{
|
||||
string propName = prop.Name;
|
||||
var valueProperty = dataType.GetProperty(propName);
|
||||
object propValue = valueProperty.GetValue(this, null);
|
||||
|
||||
_kolTag.GetType().GetProperty(propName).SetValue(_kolTag, propValue);
|
||||
}
|
||||
|
||||
if (this._kolTag.kolTag_uid == "")
|
||||
{
|
||||
this._kolTag.kolTag_uid = "KTAG_" + GlobalClass.CreateRandomCode(16);
|
||||
this.kolTag_uid = this._kolTag.kolTag_uid;
|
||||
try
|
||||
{
|
||||
conn.Insert(this._kolTag);
|
||||
updateResult = "success";
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
updateResult = ex.Message;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
conn.Update(this._kolTag);
|
||||
updateResult = "success";
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
updateResult = ex.Message;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
updateResult = "null 物件無法更新";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -216,7 +216,11 @@
|
|||
<a href="javascript: void();" id="socialNewBtn" class="card-footer-item"><i class="fa fa-plus-circle mr-1"></i> 新增社群平台資料</a>
|
||||
</div><!-- /.card-footer -->
|
||||
</div>
|
||||
|
||||
<div class="col-md-12">
|
||||
<div class="form-group">
|
||||
<label for="kol_tags">合作過產品類型</label> <select type="text" id="kol_tags" class="form-control"></select>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- /.form-row -->
|
||||
</div><!-- /.modal-body -->
|
||||
<!-- .modal-footer -->
|
||||
|
|
|
|||
|
|
@ -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 -->
|
||||
|
|
@ -97,7 +97,12 @@
|
|||
<label class="control-label" for="select2-data-remote">PRM專案名稱</label> <select id="select2-data-remote" class="form-control">
|
||||
</select>
|
||||
</div><!-- /.form-group -->
|
||||
<div class="form-group" id="file_div">
|
||||
<label for="project_file">報價單下載 </label>
|
||||
<a href="#" class="btn btn-danger" target="_blank" id="fileUrl">Go somewhere</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-12" id="project_year_month_div">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
|
|
|
|||
|
|
@ -144,6 +144,9 @@
|
|||
<li class="menu-item">
|
||||
<a href="~/Home/OptionList" class="menu-link">選項資料管理</a>
|
||||
</li>
|
||||
<li class="menu-item">
|
||||
<a href="~/Home/MediaItemList" class="menu-link">報價規格管理</a>
|
||||
</li>
|
||||
<li class="menu-item">
|
||||
<a href="~/Home/UserList" class="menu-link">使用者管理</a>
|
||||
</li>
|
||||
|
|
@ -223,7 +226,7 @@
|
|||
<!-- BEGIN SELECT2-->
|
||||
<script src="~/assets/vendor/handlebars/handlebars.min.js"></script>
|
||||
<script src="~/assets/vendor/typeahead.js/typeahead.bundle.min.js"></script>
|
||||
<script src="~/assets/vendor/select2/js/select2.min.js"></script>
|
||||
<script src="~/assets/vendor/select2/js/select2.full.min.js"></script>
|
||||
<script src="~/assets/vendor/tributejs/tribute.min.js"></script>
|
||||
<script src="~/assets/vendor/jquery.caret/jquery.caret.min.js"></script>
|
||||
<script src="~/assets/vendor/at.js/js/jquery.atwho.min.js"></script>
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ var mainRowID;
|
|||
var mainPos;
|
||||
$(document).ready(function () {
|
||||
delMedia = '';
|
||||
|
||||
loadTagsInput();
|
||||
loadMedia();
|
||||
loadKolMakeupCheckboxItem();
|
||||
loadKolStyleCheckboxItem();
|
||||
|
|
@ -33,6 +33,8 @@ $(document).ready(function () {
|
|||
var kolStyleStr = "";
|
||||
var kolFansType = "";
|
||||
var mediaArray = [];
|
||||
var tags = $('#kol_tags').val();
|
||||
var tagsStr = "";
|
||||
|
||||
var src = $('#fileupload-avatar').parent().children('img').prop('src');
|
||||
var origin = location.origin;
|
||||
|
|
@ -52,6 +54,11 @@ $(document).ready(function () {
|
|||
kolFansType = kolFansType + $(this).val() + ",";
|
||||
});
|
||||
|
||||
$.each(tags, function (key, value) {
|
||||
tagsStr = tagsStr + value + ",";
|
||||
|
||||
});
|
||||
|
||||
$('#media_table tbody tr').each(function () {
|
||||
var item = {
|
||||
kolMedia_uid: $(this).find('td').eq(5).children('button').eq(0).attr('data-uid'),
|
||||
|
|
@ -115,6 +122,7 @@ $(document).ready(function () {
|
|||
kolMakeupStr: kolMakeupStr,
|
||||
kolStyleStr: kolStyleStr,
|
||||
kolFansType: kolFansType,
|
||||
kolTags: tagsStr,
|
||||
mediaArrayJson: JSON.stringify(mediaArray)
|
||||
}
|
||||
|
||||
|
|
@ -481,7 +489,83 @@ $(document).ready(function () {
|
|||
}); // File upload using button
|
||||
// =============================================================
|
||||
|
||||
function loadTagsInput() {
|
||||
$('#kol_tags').select2({
|
||||
width: '100%',
|
||||
tags: true,
|
||||
tokenSeparators: [',', ' '],
|
||||
multiple: true,
|
||||
minimumInputLength: 2,
|
||||
placeholder: '輸入Tag用空白或逗號分隔關鍵字',
|
||||
ajax: {
|
||||
url: '/Api/queryTags',
|
||||
dataType: 'json',
|
||||
delay: 500,
|
||||
type: 'post',
|
||||
// 要送出的資料
|
||||
data: function (params) {
|
||||
// 在伺服器會得到一個 POST 'search'
|
||||
return {
|
||||
search: params.term
|
||||
};
|
||||
},
|
||||
processResults: function (data, params) {
|
||||
console.log(data.data)
|
||||
|
||||
// 一定要返回 results 物件
|
||||
return {
|
||||
results: data.data,
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
createTag: function (params) {
|
||||
let term = $.trim(params.term);
|
||||
if (term.length < 2) {
|
||||
return null
|
||||
}
|
||||
|
||||
return {
|
||||
id: term,
|
||||
text: term,
|
||||
// add indicator:
|
||||
isNew: true
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
$('#kol_tags').on('select2:select', function (e) {
|
||||
let tag = e.params.data;
|
||||
var formData = {
|
||||
search: tag.text
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: "/Api/updateTags",
|
||||
type: "post",
|
||||
data: formData,
|
||||
success: function (data, textStatus, jqXHR) {
|
||||
var obj = data.data;
|
||||
if (data.ret == "yes") {
|
||||
$('#kol_tags').find('[value="' + tag.text + '"]').replaceWith('<option selected value="' + obj.id + '">' + obj.text + '</option>');
|
||||
|
||||
|
||||
} else {
|
||||
alert(data.message);
|
||||
|
||||
if (data.err_code == "99999") {
|
||||
location.href = "/Root/Login";
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
alert('網路或伺服器發生錯誤,請稍後重試!');
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
|
@ -589,6 +673,27 @@ function buttonClick2(obj) {
|
|||
//$("input:checkbox[value='" + value.optionItem_uid + "']").prop('checked', true);
|
||||
});
|
||||
|
||||
|
||||
|
||||
var tagArray = [];
|
||||
var tagValArray = [];
|
||||
$.each(obj.tags, function (key, value) {
|
||||
var tagObj = {};
|
||||
tagObj.id = value.tag_uid;
|
||||
tagObj.text = value.tag_text;
|
||||
|
||||
tagArray.push(tagObj);
|
||||
tagValArray.push(value.tag_uid);
|
||||
|
||||
var newOption = new Option(value.tag_text, value.tag_uid, true, true);
|
||||
$('#kol_tags').append(newOption).trigger('change');
|
||||
});
|
||||
//$('#kol_tags').select2('data').push(tagArray);
|
||||
//$('#kol_tags').select2('data', tagArray);
|
||||
|
||||
//$('#kol_tags').val(tagValArray).trigger('change');
|
||||
|
||||
|
||||
$('#clientNewModal').modal('toggle');
|
||||
} else {
|
||||
alert(data.message);
|
||||
|
|
@ -664,8 +769,8 @@ function cleanModalData() {
|
|||
$.each(trList, function (index, item) {
|
||||
$(item).remove();
|
||||
});
|
||||
|
||||
|
||||
$('#kol_tags').empty();
|
||||
$('#kol_tags').val(null).trigger('change');
|
||||
}
|
||||
|
||||
function loadMedia() {
|
||||
|
|
|
|||
|
|
@ -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('網路或伺服器發生錯誤,請稍後重試!');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -15,6 +15,7 @@ $(document).ready(function () {
|
|||
var project_name = $('#project_name').val();
|
||||
var prm_serial = $('#select2-data-remote').val();
|
||||
var prm_name = $('#select2-data-remote').find(':selected').text();
|
||||
var project_uid = $('#project_uid').val();
|
||||
|
||||
if (typeof project_isPrm === "undefined") {
|
||||
alert('請先選擇已執行或僅提案!');
|
||||
|
|
@ -53,8 +54,8 @@ $(document).ready(function () {
|
|||
project_prmSerial: prm_serial,
|
||||
project_name: project_name,
|
||||
project_year: project_year,
|
||||
project_month: project_month
|
||||
|
||||
project_month: project_month,
|
||||
project_uid: project_uid
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
|
|
@ -93,7 +94,7 @@ $(document).ready(function () {
|
|||
//var origin = location.origin;
|
||||
//src = src.replace(origin, '');
|
||||
//alert(src);
|
||||
|
||||
$('#file_div').hide();
|
||||
$("#select2-data-remote").val(null).trigger('change');
|
||||
$('input:radio[name="project_isExec[]"]').prop('checked', false);
|
||||
$('#project_name').val('');
|
||||
|
|
@ -356,7 +357,7 @@ function buttonClick2(obj) {
|
|||
if (confirm('確定刪除此筆資料? 刪除後將無任何方法回復!')) {
|
||||
var formData = {
|
||||
method: "del",
|
||||
poject_uid: uid
|
||||
project_uid: uid
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
|
|
@ -384,6 +385,7 @@ function buttonClick2(obj) {
|
|||
}
|
||||
|
||||
if (type == "edit") {
|
||||
$('#file_div').hide();
|
||||
$('#method').val('edit');
|
||||
$('#project_uid').val(uid);
|
||||
|
||||
|
|
@ -417,6 +419,29 @@ function buttonClick2(obj) {
|
|||
$('#project_year_month_div').hide();
|
||||
$('#project_name_div').hide();
|
||||
|
||||
var fileData = {
|
||||
quotation_serial: obj.project_prmSerial
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: "/Api/queryPrmFile",
|
||||
type: "post",
|
||||
data: fileData,
|
||||
success: function (data, textStatus, jqXHR) {
|
||||
if (data.hasFile == 'Y') {
|
||||
$('#file_div').show();
|
||||
|
||||
$('#fileUrl').text(data.fileName);
|
||||
$('#fileUrl').prop('href', data.fileUrl);
|
||||
} else {
|
||||
$('#file_div').hide();
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
alert('網路或伺服器發生錯誤,請稍後重試!');
|
||||
}
|
||||
});
|
||||
|
||||
var appendName = "(" + obj.project_prmSerial + ") " + obj.project_name;
|
||||
|
||||
var newOption = new Option(appendName, obj.project_prmSerial, true, true);
|
||||
|
|
|
|||
Loading…
Reference in New Issue