add filiter
parent
be1f244a52
commit
c39e4049a4
|
|
@ -898,7 +898,174 @@ namespace Journeys_WantHome.Controllers
|
|||
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||
}
|
||||
|
||||
List<kol> kols = conn.Query<kol>("select * from kol order by kol_modifydate desc").ToList();
|
||||
string is_filiter = obj["is_filiter"].ToString();
|
||||
string kolMediaJson = obj["kolMediaJson"].ToString();
|
||||
string kolMakeupJson = obj["kolMakeupJson"].ToString();
|
||||
string kolStyleJson = obj["kolStyleJson"].ToString();
|
||||
string kolFansTypeJson = obj["kolFansTypeJson"].ToString();
|
||||
string kolTagsJson = obj["kolTagsJson"].ToString();
|
||||
|
||||
string SQLString = "";
|
||||
|
||||
if (is_filiter == "Y")
|
||||
{
|
||||
string whereString = "";
|
||||
|
||||
SQLString += "SELECT distinct kol.kol_sn, kol.kol_uid, kol.kol_name, kol.kol_photo, kol.kol_descript, kol.kol_men_ratio, ";
|
||||
SQLString += " kol.kol_women_ratio, kol.kol_13_17, kol.kol_18_24, kol.kol_25_34, kol.kol_35_44, ";
|
||||
SQLString += " kol.kol_45_54, kol.kol_55_64, kol.kol_65, kol.kol_contact1, kol.kol_contact2, ";
|
||||
SQLString += " kol.kol_createdate, kol.kol_modifydate, kol.kol_create_userId, kol.kol_modify_userId ";
|
||||
SQLString += "FROM kol LEFT OUTER JOIN ";
|
||||
SQLString += " kolFansType ON kol.kol_uid = kolFansType.kol_uid LEFT OUTER JOIN ";
|
||||
SQLString += " kolMakeup ON kol.kol_uid = kolMakeup.kol_uid LEFT OUTER JOIN ";
|
||||
SQLString += " kolTag ON kol.kol_uid = kolTag.kol_uid LEFT OUTER JOIN ";
|
||||
SQLString += " kolStyle ON kol.kol_uid = kolStyle.kol_uid LEFT OUTER JOIN ";
|
||||
SQLString += " kolMedia ON kol.kol_uid = kolMedia.kol_uid ";
|
||||
|
||||
if (kolMediaJson != "") {
|
||||
dynamic kolMediaObj;
|
||||
|
||||
try
|
||||
{
|
||||
kolMediaObj = JsonConvert.DeserializeObject(kolMediaJson);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ret.ret = "no";
|
||||
ret.err_code = "0003";
|
||||
ret.message = "media json error" + ex.Message;
|
||||
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||
}
|
||||
|
||||
string filiterSql = "";
|
||||
|
||||
foreach (dynamic item in kolMediaObj) {
|
||||
filiterSql += " kolMedia.optionItem_uid = '" + item.optionItem + "' Or";
|
||||
}
|
||||
|
||||
filiterSql = " and (" + filiterSql.TrimEnd('r').TrimEnd('O') + ") ";
|
||||
whereString += filiterSql;
|
||||
}
|
||||
|
||||
if (kolMakeupJson != "")
|
||||
{
|
||||
dynamic kolMakeupObj;
|
||||
|
||||
try
|
||||
{
|
||||
kolMakeupObj = JsonConvert.DeserializeObject(kolMakeupJson);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ret.ret = "no";
|
||||
ret.err_code = "0003";
|
||||
ret.message = "media json error" + ex.Message;
|
||||
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||
}
|
||||
|
||||
string filiterSql = "";
|
||||
|
||||
foreach (dynamic item in kolMakeupObj)
|
||||
{
|
||||
filiterSql += " kolMakeup.optionItem_uid = '" + item.optionItem + "' Or";
|
||||
}
|
||||
|
||||
filiterSql = " and (" + filiterSql.TrimEnd('r').TrimEnd('O') + ") ";
|
||||
whereString += filiterSql;
|
||||
}
|
||||
|
||||
if (kolStyleJson != "")
|
||||
{
|
||||
dynamic kolStyleObj;
|
||||
|
||||
try
|
||||
{
|
||||
kolStyleObj = JsonConvert.DeserializeObject(kolStyleJson);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ret.ret = "no";
|
||||
ret.err_code = "0003";
|
||||
ret.message = "media json error" + ex.Message;
|
||||
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||
}
|
||||
|
||||
string filiterSql = "";
|
||||
|
||||
foreach (dynamic item in kolStyleObj)
|
||||
{
|
||||
filiterSql += " kolStyle.optionItem_uid = '" + item.optionItem + "' Or";
|
||||
}
|
||||
|
||||
filiterSql = " and (" + filiterSql.TrimEnd('r').TrimEnd('O') + ") ";
|
||||
whereString += filiterSql;
|
||||
}
|
||||
|
||||
if (kolFansTypeJson != "")
|
||||
{
|
||||
dynamic kolFansTypeObj;
|
||||
|
||||
try
|
||||
{
|
||||
kolFansTypeObj = JsonConvert.DeserializeObject(kolFansTypeJson);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ret.ret = "no";
|
||||
ret.err_code = "0003";
|
||||
ret.message = "media json error" + ex.Message;
|
||||
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||
}
|
||||
|
||||
string filiterSql = "";
|
||||
|
||||
foreach (dynamic item in kolFansTypeObj)
|
||||
{
|
||||
filiterSql += " kolFansType.optionItem_uid = '" + item.optionItem + "' Or";
|
||||
}
|
||||
|
||||
filiterSql = " and (" + filiterSql.TrimEnd('r').TrimEnd('O') + ") ";
|
||||
whereString += filiterSql;
|
||||
}
|
||||
|
||||
if (kolTagsJson != "")
|
||||
{
|
||||
dynamic kolTagsObj;
|
||||
|
||||
try
|
||||
{
|
||||
kolTagsObj = JsonConvert.DeserializeObject(kolTagsJson);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ret.ret = "no";
|
||||
ret.err_code = "0003";
|
||||
ret.message = "media json error" + ex.Message;
|
||||
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||
}
|
||||
|
||||
string filiterSql = "";
|
||||
|
||||
foreach (dynamic item in kolTagsObj)
|
||||
{
|
||||
filiterSql += " kolTag.tag_uid = '" + item.tag_uid + "' Or";
|
||||
}
|
||||
|
||||
filiterSql = " and (" + filiterSql.TrimEnd('r').TrimEnd('O') + ") ";
|
||||
whereString += filiterSql;
|
||||
}
|
||||
|
||||
if (whereString != "") {
|
||||
SQLString = SQLString + " where 1=1 " + whereString + " order by kol_modifydate desc";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
SQLString = "select * from kol order by kol_modifydate desc";
|
||||
}
|
||||
|
||||
List<kol> kols = conn.Query<kol>(SQLString).ToList();
|
||||
|
||||
foreach (kol kolItem in kols)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -65,6 +65,10 @@
|
|||
<label for="kol_tags2">合作過產品類型</label> <select type="text" id="kol_tags2" class="form-control"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<button type="button" id="filiterBtn" class="btn btn-primary">篩選</button>
|
||||
<button type="button" id="resetBtn" class="btn btn-danger">重設</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -591,6 +591,174 @@ $(document).ready(function () {
|
|||
|
||||
});
|
||||
|
||||
//重設鍵
|
||||
$('#resetBtn').on('click', function () {
|
||||
|
||||
|
||||
$.ajax({
|
||||
url: "/Api/kolList",
|
||||
type: "post",
|
||||
data: null,
|
||||
success: function (data, textStatus, jqXHR) {
|
||||
var obj = data.kolList;
|
||||
if (data.ret == "yes") {
|
||||
$('#adv-search-btn').trigger('click');
|
||||
|
||||
$("#collapseOne1 input[type=checkbox]").each(function (index, checkbox) {
|
||||
checkbox.checked = false;
|
||||
});
|
||||
|
||||
$('#kol_tags2').empty();
|
||||
$('#kol_tags2').val(null).trigger('change');
|
||||
|
||||
$('#dt-responsive').dataTable().fnClearTable();
|
||||
if (data.kolList.length > 0) {
|
||||
|
||||
$('#dt-responsive').dataTable().fnAddData(data.kolList);
|
||||
|
||||
|
||||
}
|
||||
} else {
|
||||
alert(data.message);
|
||||
|
||||
if (data.err_code == "99999") {
|
||||
location.href = "/Root/Login";
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
alert('網路或伺服器發生錯誤,請稍後重試!');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//篩選鍵
|
||||
$('#filiterBtn').on('click', function () {
|
||||
var kolMedia = [];
|
||||
var kolMakeup = [];
|
||||
var kolStyle = [];
|
||||
var kolFansType = [];
|
||||
var kolTags = [];
|
||||
var tags = $('#kol_tags2').val();
|
||||
var kolMediaJson = "";
|
||||
var kolMakeupJson = "";
|
||||
var kolStyleJson = "";
|
||||
var kolFansTypeJson = "";
|
||||
var kolTagsJson = "";
|
||||
|
||||
$.each($('input[name="media2[]"]:checked'), function () {
|
||||
var item = {
|
||||
'optionItem': $(this).val()
|
||||
}
|
||||
|
||||
|
||||
kolMedia.push(item);
|
||||
});
|
||||
|
||||
$.each($('input[name="kolMakeup2[]"]:checked'), function () {
|
||||
var item = {
|
||||
'optionItem': $(this).val()
|
||||
}
|
||||
|
||||
|
||||
kolMakeup.push(item);
|
||||
});
|
||||
|
||||
$.each($('input[name="kolStyle2[]"]:checked'), function () {
|
||||
var item = {
|
||||
'optionItem': $(this).val()
|
||||
}
|
||||
|
||||
|
||||
kolStyle.push(item);
|
||||
});
|
||||
|
||||
$.each($('input[name="fansType2[]"]:checked'), function () {
|
||||
var item = {
|
||||
'optionItem': $(this).val()
|
||||
}
|
||||
|
||||
|
||||
kolFansType.push(item);
|
||||
});
|
||||
|
||||
$.each(tags, function (key, value) {
|
||||
var item = {
|
||||
'tag_uid': value
|
||||
}
|
||||
kolTags.push(item);
|
||||
});
|
||||
|
||||
var hasFiliter = 'N';
|
||||
|
||||
if (kolMedia.length > 0) {
|
||||
kolMediaJson = JSON.stringify(kolMedia);
|
||||
hasFiliter = 'Y';
|
||||
}
|
||||
|
||||
if (kolMakeup.length > 0) {
|
||||
kolMakeupJson = JSON.stringify(kolMakeup);
|
||||
hasFiliter = 'Y';
|
||||
}
|
||||
|
||||
if (kolStyle.length > 0) {
|
||||
kolStyleJson = JSON.stringify(kolStyle);
|
||||
hasFiliter = 'Y';
|
||||
}
|
||||
|
||||
if (kolFansType.length > 0) {
|
||||
kolFansTypeJson = JSON.stringify(kolFansType);
|
||||
hasFiliter = 'Y';
|
||||
}
|
||||
|
||||
if (kolTags.length > 0) {
|
||||
kolTagsJson = JSON.stringify(kolTags);
|
||||
hasFiliter = 'Y';
|
||||
}
|
||||
|
||||
if (hasFiliter == 'N') {
|
||||
alert('請勾選想要篩選的條件!');
|
||||
return;
|
||||
}
|
||||
|
||||
var formData = {
|
||||
is_filiter: 'Y',
|
||||
kolMediaJson: kolMediaJson,
|
||||
kolMakeupJson: kolMakeupJson,
|
||||
kolStyleJson: kolStyleJson,
|
||||
kolFansTypeJson: kolFansTypeJson,
|
||||
kolTagsJson: kolTagsJson
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: "/Api/kolList",
|
||||
type: "post",
|
||||
data: formData,
|
||||
success: function (data, textStatus, jqXHR) {
|
||||
var obj = data.kolList;
|
||||
if (data.ret == "yes") {
|
||||
|
||||
$('#dt-responsive').dataTable().fnClearTable();
|
||||
if (data.kolList.length > 0) {
|
||||
|
||||
$('#dt-responsive').dataTable().fnAddData(data.kolList);
|
||||
|
||||
|
||||
}
|
||||
} else {
|
||||
alert(data.message);
|
||||
|
||||
if (data.err_code == "99999") {
|
||||
location.href = "/Root/Login";
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
alert('網路或伺服器發生錯誤,請稍後重試!');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$("#project_year").on('change', function () {
|
||||
loadprojectList();
|
||||
});
|
||||
|
|
@ -1687,7 +1855,7 @@ function cleanModalData() {
|
|||
$("#kol_uid").val("");
|
||||
$("#kol_name").val("");
|
||||
$("#kol_descript").val("");
|
||||
$("input[type=checkbox]").each(function (index, checkbox) {
|
||||
$("#clientNewModal input[type=checkbox]").each(function (index, checkbox) {
|
||||
checkbox.checked = false;
|
||||
});
|
||||
|
||||
|
|
@ -2004,7 +2172,7 @@ function clearKolProjectTable() {
|
|||
$(item).remove();
|
||||
});
|
||||
|
||||
$("input[type=checkbox]").each(function (index, checkbox) {
|
||||
$("#clientNewKolProjectModal input[type=checkbox]").each(function (index, checkbox) {
|
||||
checkbox.checked = false;
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue