update new tag function
parent
f6a1a8dac6
commit
95e3478c01
|
|
@ -56,16 +56,136 @@ namespace Journeys_WantHome.Controllers
|
||||||
this._httpContextAccessor = httpContextAccessor;
|
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")]
|
[Route("queryPrm")]
|
||||||
public ActionResult QueryPrm(IFormCollection obj) {
|
public ActionResult QueryPrm(IFormCollection obj) {
|
||||||
prmResult ret = new prmResult();
|
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 search = obj["search"].ToString();
|
||||||
|
|
||||||
string quotation_serial = search + "%";
|
string quotation_serial = search + "%";
|
||||||
string quotation_name = "%" + 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)
|
foreach (quotation proj in quotations)
|
||||||
{
|
{
|
||||||
|
|
@ -282,6 +402,7 @@ namespace Journeys_WantHome.Controllers
|
||||||
conn.Execute("delete kolFansType 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 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 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";
|
ret.ret = "yes";
|
||||||
|
|
||||||
|
|
@ -323,6 +444,7 @@ namespace Journeys_WantHome.Controllers
|
||||||
string kolMakeupStr = obj["kolMakeupStr"].ToString().TrimEnd(',');
|
string kolMakeupStr = obj["kolMakeupStr"].ToString().TrimEnd(',');
|
||||||
string kolStyleStr = obj["kolStyleStr"].ToString().TrimEnd(',');
|
string kolStyleStr = obj["kolStyleStr"].ToString().TrimEnd(',');
|
||||||
string kolFansTypeStr = obj["kolFansType"].ToString().TrimEnd(',');
|
string kolFansTypeStr = obj["kolFansType"].ToString().TrimEnd(',');
|
||||||
|
string kolTagsStr = obj["kolTags"].ToString().TrimEnd(',');
|
||||||
string mediaArrayJson = obj["mediaArrayJson"].ToString().TrimEnd(',');
|
string mediaArrayJson = obj["mediaArrayJson"].ToString().TrimEnd(',');
|
||||||
|
|
||||||
if (method == "") {
|
if (method == "") {
|
||||||
|
|
@ -428,6 +550,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;
|
dynamic mediaJsonObj;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
@ -464,11 +600,13 @@ namespace Journeys_WantHome.Controllers
|
||||||
conn.Execute("delete kolStyle where kol_uid = @kol_uid", new { kol_uid = kol_uid });
|
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 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 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(kolMakeups);
|
||||||
conn.Insert(kolStyles);
|
conn.Insert(kolStyles);
|
||||||
conn.Insert(kolFansTypes);
|
conn.Insert(kolFansTypes);
|
||||||
conn.Insert(medias);
|
conn.Insert(medias);
|
||||||
|
conn.Insert(kolTags);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -584,6 +722,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;
|
dynamic mediaJsonObj;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
@ -617,6 +771,7 @@ namespace Journeys_WantHome.Controllers
|
||||||
conn.Insert(kolStyles);
|
conn.Insert(kolStyles);
|
||||||
conn.Insert(kolFansTypes);
|
conn.Insert(kolFansTypes);
|
||||||
conn.Insert(medias);
|
conn.Insert(medias);
|
||||||
|
conn.Insert(kolTags);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -756,6 +911,26 @@ 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 class prmResult {
|
||||||
public List<optionData> data = new List<optionData>();
|
public List<optionData> data = new List<optionData>();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,47 @@ using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
public class DbTableClass
|
public class DbTableClass
|
||||||
{
|
{
|
||||||
|
[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")]
|
[Table("quotation")]
|
||||||
public class quotation
|
public class quotation
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ public class kolDetial : kol
|
||||||
public List<kolMakeupDetail> makeups = new List<kolMakeupDetail>();
|
public List<kolMakeupDetail> makeups = new List<kolMakeupDetail>();
|
||||||
public List<kolMediaDetail> medias = new List<kolMediaDetail>();
|
public List<kolMediaDetail> medias = new List<kolMediaDetail>();
|
||||||
public List<kolStyleDetail> styles = new List<kolStyleDetail>();
|
public List<kolStyleDetail> styles = new List<kolStyleDetail>();
|
||||||
|
public List<kolTagDetail> tags = new List<kolTagDetail>();
|
||||||
public string updateResult { get; set; } = "";
|
public string updateResult { get; set; } = "";
|
||||||
private kol _kol;
|
private kol _kol;
|
||||||
|
|
||||||
|
|
@ -65,12 +66,15 @@ public class kolDetial : kol
|
||||||
makeups.Clear();
|
makeups.Clear();
|
||||||
medias.Clear();
|
medias.Clear();
|
||||||
styles.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 <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<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<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<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<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)
|
foreach (kolCooperateType objItem in kolCooperateTypes)
|
||||||
{
|
{
|
||||||
|
|
@ -100,6 +104,12 @@ public class kolDetial : kol
|
||||||
kolStyleDetail objDetail = new kolStyleDetail(objItem);
|
kolStyleDetail objDetail = new kolStyleDetail(objItem);
|
||||||
styles.Add(objDetail);
|
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();
|
item.dataUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (var item in tags)
|
||||||
|
{
|
||||||
|
item.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -216,7 +216,11 @@
|
||||||
<a href="javascript: void();" id="socialNewBtn" class="card-footer-item"><i class="fa fa-plus-circle mr-1"></i> 新增社群平台資料</a>
|
<a href="javascript: void();" id="socialNewBtn" class="card-footer-item"><i class="fa fa-plus-circle mr-1"></i> 新增社群平台資料</a>
|
||||||
</div><!-- /.card-footer -->
|
</div><!-- /.card-footer -->
|
||||||
</div>
|
</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><!-- /.form-row -->
|
||||||
</div><!-- /.modal-body -->
|
</div><!-- /.modal-body -->
|
||||||
<!-- .modal-footer -->
|
<!-- .modal-footer -->
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,12 @@
|
||||||
<label class="control-label" for="select2-data-remote">PRM專案名稱</label> <select id="select2-data-remote" class="form-control">
|
<label class="control-label" for="select2-data-remote">PRM專案名稱</label> <select id="select2-data-remote" class="form-control">
|
||||||
</select>
|
</select>
|
||||||
</div><!-- /.form-group -->
|
</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>
|
||||||
|
|
||||||
<div class="col-md-12" id="project_year_month_div">
|
<div class="col-md-12" id="project_year_month_div">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
|
|
|
||||||
|
|
@ -223,7 +223,7 @@
|
||||||
<!-- BEGIN SELECT2-->
|
<!-- BEGIN SELECT2-->
|
||||||
<script src="~/assets/vendor/handlebars/handlebars.min.js"></script>
|
<script src="~/assets/vendor/handlebars/handlebars.min.js"></script>
|
||||||
<script src="~/assets/vendor/typeahead.js/typeahead.bundle.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/tributejs/tribute.min.js"></script>
|
||||||
<script src="~/assets/vendor/jquery.caret/jquery.caret.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>
|
<script src="~/assets/vendor/at.js/js/jquery.atwho.min.js"></script>
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ var mainRowID;
|
||||||
var mainPos;
|
var mainPos;
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
delMedia = '';
|
delMedia = '';
|
||||||
|
loadTagsInput();
|
||||||
loadMedia();
|
loadMedia();
|
||||||
loadKolMakeupCheckboxItem();
|
loadKolMakeupCheckboxItem();
|
||||||
loadKolStyleCheckboxItem();
|
loadKolStyleCheckboxItem();
|
||||||
|
|
@ -33,6 +33,8 @@ $(document).ready(function () {
|
||||||
var kolStyleStr = "";
|
var kolStyleStr = "";
|
||||||
var kolFansType = "";
|
var kolFansType = "";
|
||||||
var mediaArray = [];
|
var mediaArray = [];
|
||||||
|
var tags = $('#kol_tags').val();
|
||||||
|
var tagsStr = "";
|
||||||
|
|
||||||
var src = $('#fileupload-avatar').parent().children('img').prop('src');
|
var src = $('#fileupload-avatar').parent().children('img').prop('src');
|
||||||
var origin = location.origin;
|
var origin = location.origin;
|
||||||
|
|
@ -52,6 +54,11 @@ $(document).ready(function () {
|
||||||
kolFansType = kolFansType + $(this).val() + ",";
|
kolFansType = kolFansType + $(this).val() + ",";
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$.each(tags, function (key, value) {
|
||||||
|
tagsStr = tagsStr + value + ",";
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
$('#media_table tbody tr').each(function () {
|
$('#media_table tbody tr').each(function () {
|
||||||
var item = {
|
var item = {
|
||||||
kolMedia_uid: $(this).find('td').eq(5).children('button').eq(0).attr('data-uid'),
|
kolMedia_uid: $(this).find('td').eq(5).children('button').eq(0).attr('data-uid'),
|
||||||
|
|
@ -115,6 +122,7 @@ $(document).ready(function () {
|
||||||
kolMakeupStr: kolMakeupStr,
|
kolMakeupStr: kolMakeupStr,
|
||||||
kolStyleStr: kolStyleStr,
|
kolStyleStr: kolStyleStr,
|
||||||
kolFansType: kolFansType,
|
kolFansType: kolFansType,
|
||||||
|
kolTags: tagsStr,
|
||||||
mediaArrayJson: JSON.stringify(mediaArray)
|
mediaArrayJson: JSON.stringify(mediaArray)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -481,7 +489,83 @@ $(document).ready(function () {
|
||||||
}); // File upload using button
|
}); // 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);
|
//$("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');
|
$('#clientNewModal').modal('toggle');
|
||||||
} else {
|
} else {
|
||||||
alert(data.message);
|
alert(data.message);
|
||||||
|
|
@ -664,8 +769,8 @@ function cleanModalData() {
|
||||||
$.each(trList, function (index, item) {
|
$.each(trList, function (index, item) {
|
||||||
$(item).remove();
|
$(item).remove();
|
||||||
});
|
});
|
||||||
|
$('#kol_tags').empty();
|
||||||
|
$('#kol_tags').val(null).trigger('change');
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadMedia() {
|
function loadMedia() {
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ $(document).ready(function () {
|
||||||
var project_name = $('#project_name').val();
|
var project_name = $('#project_name').val();
|
||||||
var prm_serial = $('#select2-data-remote').val();
|
var prm_serial = $('#select2-data-remote').val();
|
||||||
var prm_name = $('#select2-data-remote').find(':selected').text();
|
var prm_name = $('#select2-data-remote').find(':selected').text();
|
||||||
|
var project_uid = $('#project_uid').val();
|
||||||
|
|
||||||
if (typeof project_isPrm === "undefined") {
|
if (typeof project_isPrm === "undefined") {
|
||||||
alert('請先選擇已執行或僅提案!');
|
alert('請先選擇已執行或僅提案!');
|
||||||
|
|
@ -53,8 +54,8 @@ $(document).ready(function () {
|
||||||
project_prmSerial: prm_serial,
|
project_prmSerial: prm_serial,
|
||||||
project_name: project_name,
|
project_name: project_name,
|
||||||
project_year: project_year,
|
project_year: project_year,
|
||||||
project_month: project_month
|
project_month: project_month,
|
||||||
|
project_uid: project_uid
|
||||||
}
|
}
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
|
@ -93,7 +94,7 @@ $(document).ready(function () {
|
||||||
//var origin = location.origin;
|
//var origin = location.origin;
|
||||||
//src = src.replace(origin, '');
|
//src = src.replace(origin, '');
|
||||||
//alert(src);
|
//alert(src);
|
||||||
|
$('#file_div').hide();
|
||||||
$("#select2-data-remote").val(null).trigger('change');
|
$("#select2-data-remote").val(null).trigger('change');
|
||||||
$('input:radio[name="project_isExec[]"]').prop('checked', false);
|
$('input:radio[name="project_isExec[]"]').prop('checked', false);
|
||||||
$('#project_name').val('');
|
$('#project_name').val('');
|
||||||
|
|
@ -356,7 +357,7 @@ function buttonClick2(obj) {
|
||||||
if (confirm('確定刪除此筆資料? 刪除後將無任何方法回復!')) {
|
if (confirm('確定刪除此筆資料? 刪除後將無任何方法回復!')) {
|
||||||
var formData = {
|
var formData = {
|
||||||
method: "del",
|
method: "del",
|
||||||
poject_uid: uid
|
project_uid: uid
|
||||||
}
|
}
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
|
@ -384,6 +385,7 @@ function buttonClick2(obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == "edit") {
|
if (type == "edit") {
|
||||||
|
$('#file_div').hide();
|
||||||
$('#method').val('edit');
|
$('#method').val('edit');
|
||||||
$('#project_uid').val(uid);
|
$('#project_uid').val(uid);
|
||||||
|
|
||||||
|
|
@ -417,6 +419,29 @@ function buttonClick2(obj) {
|
||||||
$('#project_year_month_div').hide();
|
$('#project_year_month_div').hide();
|
||||||
$('#project_name_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 appendName = "(" + obj.project_prmSerial + ") " + obj.project_name;
|
||||||
|
|
||||||
var newOption = new Option(appendName, obj.project_prmSerial, true, true);
|
var newOption = new Option(appendName, obj.project_prmSerial, true, true);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue