let tagName = [];
|
let vipLevel = [];
|
let goods = [];
|
let vipChannel = [];
|
let integralTag = [{'tagname': '可用积分数量','valuetype':2},{'tagname': '近3个月兑换的积分商城商品','valuetype':3}, {'tagname': '累计订单数','valuetype':2}, {'tagname': '近3个月订单数','valuetype':2}, {'tagname': '累计消耗积分数','valuetype':2}, {'tagname': '近3个月消耗积分数','valuetype':2}];
|
let tagParameterResult = [];
|
$(function () {
|
getBaseData()
|
|
$('#exportExcel').on('change', function () {
|
let formData = new FormData() //创建一个forData
|
formData.append('file', $('#exportExcel')[0].files[0]) //把file添加进去 name命名为img
|
layer.load(); //上传loading
|
$.ajax({
|
url: Feng.ctxPath + '/exposureCrowd/exportExcel',
|
data: formData,
|
type: "POST",
|
async: true,
|
cache: false,
|
contentType: false,
|
processData: false,
|
success: function(res) {
|
layer.closeAll('loading'); //关闭loading
|
Feng.success("导入成功");
|
$('#exportExcel').val('');
|
}
|
})
|
})
|
queryRow();
|
})
|
|
|
|
function getBaseData() {
|
let ajax = new $ax(Feng.ctxPath + "/exposureCrowd/getTanName", function (res) {
|
if(res.code == 200){
|
tagName = res.data;
|
}else{
|
Feng.error(res.msg);
|
}
|
}, function (data) {
|
Feng.error("获取失败!" + data.responseJSON.message + "!");
|
});
|
ajax.setData();
|
ajax.start();
|
let ajax1 = new $ax(Feng.ctxPath + "/vipLevel/queryVipLevel", function (res) {
|
if(res.code == 200){
|
vipLevel = res.data;
|
}else{
|
Feng.error(res.msg);
|
}
|
}, function (data) {
|
Feng.error("获取失败!" + data.responseJSON.message + "!");
|
});
|
ajax1.setData();
|
ajax1.start();
|
|
let ajax2 = new $ax(Feng.ctxPath + "/goods/getGoodsList", function (res) {
|
if(res.code == 200){
|
goods = res.data;
|
}else{
|
Feng.error(res.msg);
|
}
|
}, function (data) {
|
Feng.error("获取失败!" + data.responseJSON.message + "!");
|
});
|
ajax2.setData();
|
ajax2.start();
|
|
let ajax3 = new $ax(Feng.ctxPath + "/vipChannel/getVipChannelList", function (res) {
|
if(res.code == 200){
|
vipChannel = res.data;
|
}else{
|
Feng.error(res.msg);
|
}
|
}, function (data) {
|
Feng.error("获取失败!" + data.responseJSON.message + "!");
|
});
|
ajax3.setData();
|
ajax3.start();
|
}
|
|
function queryRow() {
|
let exposureCrowd = eval("window.parent." + $('#page').val()).exposureCrowd;
|
let data = typeof exposureCrowd != "undefined" ? JSON.parse(exposureCrowd) : [];
|
let str = '';
|
for(let i in data){
|
let fw = '<option value="">-</option>';
|
str += '<div class="tr" style="height: 40px;" id="' + data[i].id + '">' +
|
'<div style="width: 5%;">' + (parseInt(i) + 1) + '</div>' +
|
'<div>' +
|
' <select class="dataType" onchange="chooseDataType(this)" style="width: 100%;height: 90%;line-height: 90%;border: none;text-indent: 10px;">' +
|
' <option value="1" ' + (data[i].dataType == 1 ? 'selected' : '') + '>用户标签</option>' +
|
' <option value="2" ' + (data[i].dataType == 2 ? 'selected' : '') + '>会员等级</option>' +
|
' <option value="3" ' + (data[i].dataType == 3 ? 'selected' : '') + '>积分订单</option>' +
|
' <option value="4" ' + (data[i].dataType == 4 ? 'selected' : '') + '>入会渠道</option>' +
|
' </select>' +
|
'</div>' +
|
'<div style="width: 14%;">' +
|
' <select class="tagName selectpicker" data-live-search="true" data-style="btn-primary" data-none-selected-text="请选择" onchange="chooseTagName(this)" style="width: 100%;height: 90%;line-height: 90%;border: none;text-indent: 10px;">';
|
if(data[i].dataType == 1){
|
for(let j in tagName){
|
str += '<option value="' + tagName[j].tagname + '" valuetype="' + tagName[j].valuetype + '" v="' + tagName[j].id + '" ' + (data[i].tagName == tagName[j].tagname ? 'selected' : '') + '>' + tagName[j].tagname + '</option>';
|
}
|
}
|
if(data[i].dataType == 2){
|
str += '<option value="会员等级" valuetype="3">会员等级</option>';
|
}
|
if(data[i].dataType == 3){
|
for(let j in integralTag){
|
str += '<option value="' + integralTag[j].tagname + '" valuetype="' + integralTag[j].valuetype + '" ' + (data[i].tagName == integralTag[j].tagname ? 'selected' : '') + '>' + integralTag[j].tagname + '</option>';
|
}
|
}
|
if(data[i].dataType == 4){
|
str += '<option value="入会渠道" valuetype="3">入会渠道</option>';
|
let type = 2;
|
data[i].content = typeof data[i].content == "string" ? JSON.parse(data[i].content) : data[i].content;
|
for(let j in data[i].content){
|
let vs = data[i].content[j].split(";");
|
if(vs[1] == 1){
|
type = 1;
|
break
|
}
|
}
|
if(type == 2){
|
fw = '<option value="">-</option>';
|
}else{
|
fw = '<option value="0" ' + (data[i].membershipSource == 0 ? "selected" : "") + '>站内</option><option value="1" ' + (data[i].membershipSource == 1 ? "selected" : "") + '>站外</option>'
|
}
|
}
|
str += ' </select>' +
|
'</div>' +
|
'<div>' +
|
' <select class="condition" onchange="chooseCondition(this)" style="width: 100%;height: 90%;line-height: 90%;border: none;text-indent: 10px;">' +
|
' <option value="1" ' + (data[i].condition == 1 ? 'selected' : '') + '>包含</option>' +
|
' <option value="2" ' + (data[i].condition == 2 ? 'selected' : '') + '>不包含</option>' +
|
' <option value="3" ' + (data[i].condition == 3 ? 'selected' : '') + '>大于</option>' +
|
' <option value="4" ' + (data[i].condition == 4 ? 'selected' : '') + '>小于</option>' +
|
' <option value="5" ' + (data[i].condition == 5 ? 'selected' : '') + '>在..之间(包含)</option>' +
|
' <option value="6" ' + (data[i].condition == 6 ? 'selected' : '') + '>在..之间(不包含)</option>' +
|
' <option value="7" ' + (data[i].condition == 7 ? 'selected' : '') + '>不在..之间(包含)</option>' +
|
' <option value="8" ' + (data[i].condition == 8 ? 'selected' : '') + '>不在..之间(不包含)</option>' +
|
' <option value="9" ' + (data[i].condition == 9 ? 'selected' : '') + '>不等于</option>' +
|
' <option value="10" ' + (data[i].condition == 10 ? 'selected' : '') + '>大于等于</option>' +
|
' <option value="11" ' + (data[i].condition == 11 ? 'selected' : '') + '>小于等于</option>' +
|
' </select>' +
|
'</div>' +
|
'<div>' +
|
' <select class="tagType" onchange="chooseTagType(this)" style="width: 100%;height: 90%;line-height: 90%;border: none;text-indent: 10px;">' +
|
' <option value="1" ' + (data[i].tagType == "1" ? 'selected' : '') + '>-</option>' +
|
' <option value="2" ' + (data[i].tagType == "2" ? 'selected' : '') + '>数字</option>' +
|
' <option value="3" ' + (data[i].tagType == "3" ? 'selected' : '') + '>时间</option>' +
|
' </select>'+
|
'</div>' +
|
'<div class="content" style="width: 20%;">'+
|
'</div>' +
|
'<div>' +
|
' <select class="membershipSource" style="width: 100%;height: 90%;line-height: 90%;border: none;text-indent: 10px;">' +
|
fw +
|
' </select>'+
|
'</div>' +
|
'<div><a href="#" onclick="delExposureCrowd(this)">删除</a></div>' +
|
'</div>';
|
}
|
$('.body').html(str);
|
$('.tagName').change();
|
|
//赋值
|
let tr = $('.table .body .tr');
|
tr.each(function (i, el) {
|
$(el).find('.condition').val(data[i].condition);
|
$(el).find('.condition').change();
|
let tagType = $(el).find('.tagType').val();
|
if(tagType == 1){//包含/不包含
|
$(el).find('.content .selectpicker').selectpicker('val', typeof data[i].content == "string" ? JSON.parse(data[i].content) : data[i].content);
|
$(el).find('.content .selectpicker').selectpicker('refresh');
|
}
|
if(tagType == 2){//数字
|
$(el).find('.content input').each(function (j, e) {
|
$(e).val(typeof data[i].content == "string" ? JSON.parse(data[i].content)[j] : data[i].content[j]);
|
})
|
}
|
if(tagType == 3){//时间
|
$(el).find('.content input').each(function (j, e) {
|
$(e).val(typeof data[i].content == "string" ? JSON.parse(data[i].content)[j] : data[i].content[j]);
|
})
|
}
|
})
|
}
|
|
function addRow(e) {
|
getBaseData();
|
let tr = $('.table .body .tr');
|
let str = '<div class="tr" style="height: 40px;">' +
|
'<div style="width: 5%;">' + (tr.length + 1) + '</div>' +
|
'<div>' +
|
' <select class="dataType" onchange="chooseDataType(this)" style="width: 100%;height: 90%;line-height: 90%;border: none;text-indent: 10px;">' +
|
' <option value="1">用户标签</option>' +
|
' <option value="2">会员等级</option>' +
|
' <option value="3">积分订单</option>' +
|
' <option value="4">入会渠道</option>' +
|
' </select>' +
|
'</div>' +
|
'<div style="width: 14%;">' +
|
' <select class="tagName selectpicker" data-live-search="true" data-style="btn-primary" data-none-selected-text="请选择" onchange="chooseTagName(this)" style="width: 100%;height: 90%;line-height: 90%;border: none;text-indent: 10px;">';
|
for(let j in tagName){
|
str += '<option value="' + tagName[j].tagname + '" valuetype="' + tagName[j].valuetype + '" v="' + tagName[j].id + '">' + tagName[j].tagname + '</option>';
|
}
|
str += ' </select>' +
|
'</div>' +
|
'<div>' +
|
' <select class="condition" onchange="chooseCondition(this)" style="width: 100%;height: 90%;line-height: 90%;border: none;text-indent: 10px;">' +
|
' <option value="1">包含</option>' +
|
' <option value="2">不包含</option>' +
|
' <option value="3">大于</option>' +
|
' <option value="4">小于</option>' +
|
' <option value="5">在..之间(包含)</option>' +
|
' <option value="6">在..之间(不包含)</option>' +
|
' <option value="7">不在..之间(包含)</option>' +
|
' <option value="8">不在..之间(不包含)</option>' +
|
' <option value="9">不等于</option>' +
|
' <option value="10">大于等于</option>' +
|
' <option value="11">小于等于</option>' +
|
' </select>' +
|
'</div>' +
|
'<div>' +
|
' <select class="tagType" onchange="chooseTagType(this)" style="width: 100%;height: 90%;line-height: 90%;border: none;text-indent: 10px;">' +
|
' <option value="1">-</option>' +
|
' </select>'+
|
'</div>' +
|
'<div class="content" style="width: 20%;">' +
|
' <select name="selectpicker" class="selectpicker form-control" multiple data-style="btn-primary" data-none-selected-text="请选择">' +
|
' ' +
|
' </select>' +
|
'</div>' +
|
'<div>' +
|
' <select class="membershipSource" style="width: 100%;height: 90%;line-height: 90%;border: none;text-indent: 10px;">' +
|
' <option value="">-</option>' +
|
' </select>'+
|
'</div>' +
|
'<div><a href="#" onclick="delExposureCrowd(this)">删除</a></div>' +
|
'</div>';
|
$(e).parents('.table').find(".body").append(str);
|
let trs = $(e).parents('.table').find('.tr');
|
$(trs[trs.length - 1]).find('.dataType').change()
|
}
|
|
function chooseDataType(e) {
|
let dataType = $(e).val();
|
let str = '';
|
if(dataType == 1){
|
for(let j in tagName){
|
str += '<option value="' + tagName[j].tagname + '" valuetype="' + tagName[j].valuetype + '" v="' + tagName[j].id + '">' + tagName[j].tagname + '</option>';
|
}
|
$(e).parents('.tr').find(".tagName .selectpicker").html(str);
|
$(e).parents('.tr').find(".membershipSource").html('<option value="">-</option>');
|
}
|
if(dataType == 2){
|
$(e).parents('.tr').find(".tagName .selectpicker").html('<option value="会员等级" valuetype="3">会员等级</option>');
|
$(e).parents('.tr').find(".membershipSource").html('<option value="">-</option>');
|
}
|
if(dataType == 3){
|
for(let j in integralTag){
|
str += '<option value="' + integralTag[j].tagname + '" valuetype="' + integralTag[j].valuetype + '">' + integralTag[j].tagname + '</option>';
|
}
|
$(e).parents('.tr').find(".tagName .selectpicker").html(str);
|
$(e).parents('.tr').find(".membershipSource").html('<option value="">-</option>');
|
}
|
if(dataType == 4){
|
$(e).parents('.tr').find(".tagName .selectpicker").html('<option value="入会渠道" valuetype="3">入会渠道</option>');
|
$(e).parents('.tr').find(".membershipSource").html('<option value="0">站内</option><option value="1">站外</option>');
|
}
|
$(e).parents('.tr').find(".tagName .selectpicker").selectpicker('refresh');
|
$(e).parents('.tr').find(".tagName").change();
|
}
|
|
|
function chooseTagName(e) {
|
let dataType = $(e).parents('.tr').find(".dataType").val();
|
let valuetype = $(e).find("option:selected").attr('valuetype');
|
if(dataType == 1){
|
let ajax = new $ax(Feng.ctxPath + "/exposureCrowd/getTagParameterResult", function (res) {
|
if(res.code == 200){
|
let data = res.data;
|
tagParameterResult = data;
|
if(data.length > 0 && (valuetype == 1 || valuetype == 2 || valuetype == 3)){
|
$(e).parents('.tr').find(".condition").html('<option value="1">包含</option><option value="2">不包含</option>')
|
}
|
if(data.length == 0 || valuetype == 4){
|
$(e).parents('.tr').find(".condition").html(' <option value="3">大于</option>' +
|
' <option value="4">小于</option>' +
|
' <option value="5">在..之间(包含)</option>' +
|
' <option value="6">在..之间(不包含)</option>' +
|
' <option value="7">不在..之间(包含)</option>' +
|
' <option value="8">不在..之间(不包含)</option>' +
|
' <option value="9">不等于</option>' +
|
' <option value="10">大于等于</option>' +
|
' <option value="11">小于等于</option>')
|
|
}
|
$(e).parents('.tr').find(".condition").change();
|
|
}else{
|
Feng.error(res.msg);
|
}
|
}, function (data) {
|
Feng.error("获取失败!" + data.responseJSON.message + "!");
|
});
|
ajax.setData({
|
tagid: $(e).find("option:selected").attr('v')
|
});
|
ajax.start();
|
}else{
|
if(valuetype == 3){
|
$(e).parents('.tr').find(".condition").html('<option value="1">包含</option><option value="2">不包含</option>')
|
}
|
if(valuetype == 1 || valuetype == 2 || valuetype == 4){
|
$(e).parents('.tr').find(".condition").html(' <option value="3">大于</option>' +
|
' <option value="4">小于</option>' +
|
' <option value="5">在..之间(包含)</option>' +
|
' <option value="6">在..之间(不包含)</option>' +
|
' <option value="7">不在..之间(包含)</option>' +
|
' <option value="8">不在..之间(不包含)</option>' +
|
' <option value="9">不等于</option>' +
|
' <option value="10">大于等于</option>' +
|
' <option value="11">小于等于</option>')
|
|
}
|
$(e).parents('.tr').find(".condition").change();
|
}
|
|
|
}
|
|
|
|
function chooseCondition(e) {
|
let condition = $(e).val();
|
let valuetype = $(e).parents('.tr').find(".tagName").find("option:selected").attr('valuetype');
|
if(condition == 1 || condition == 2){
|
$(e).parents('.tr').find(".tagType").html('<option value="1">-</option>');
|
}else{
|
if(valuetype == 4){
|
$(e).parents('.tr').find(".tagType").html('<option value="3">时间</option>');
|
}else{
|
$(e).parents('.tr').find(".tagType").html('<option value="2">数字</option>');
|
}
|
}
|
$(e).parents('.tr').find(".tagType").change();
|
}
|
|
|
function chooseTagType(e) {
|
let tagType = $(e).val();
|
let condition = $(e).parents('.tr').find(".condition").val();
|
let dataType = $(e).parents('.tr').find(".dataType").val();
|
let str = '';
|
if(tagType == 1){
|
str =
|
'<select name="selectpicker" class="selectpicker form-control" multiple data-style="btn-primary" data-none-selected-text="请选择">';
|
if(dataType == 1){
|
for(let i in tagParameterResult){
|
str += '<option value="' + tagParameterResult[i].value + '">' + tagParameterResult[i].display + '</option>'
|
}
|
}
|
if(dataType == 2){
|
for(let i in vipLevel){
|
str += '<option value="' + vipLevel[i].id + '">' + vipLevel[i].name + '</option>'
|
}
|
}
|
if(dataType == 3){
|
for(let i in goods){
|
str += '<option value="' + goods[i].id + '">' + goods[i].name + '</option>'
|
}
|
}
|
if(dataType == 4){
|
for(let i in vipChannel){
|
str += '<option value="' + vipChannel[i].id + ';' + vipChannel[i].type + '">' + vipChannel[i].name + '</option>'
|
}
|
}
|
str += '</select>';
|
}
|
if(tagType == 2){
|
if(condition == 3 || condition == 4 || condition == 9 || condition == 10 || condition == 11){
|
str = '<input type="number" style="width: 100%;height: 35px;line-height: 35px;border: 1px solid #eee;text-indent: 10px;">'
|
}
|
if(condition == 5 || condition == 6 || condition == 7 || condition == 8){
|
str = '<input type="number" style="width: 40%;height: 35px;line-height: 35px;border: 1px solid #eee;text-indent: 10px;"> - <input type="number" style="width: 40%;height: 35px;line-height: 35px;border: 1px solid #eee;text-indent: 10px;">'
|
}
|
}
|
let t = 1;
|
if(tagType == 3){
|
t = $(e).parents('.body').find(".tr").length;
|
if(condition == 3 || condition == 4 || condition == 9 || condition == 10 || condition == 11){
|
str = '<input id="time_' + t + '_1" style="width: 100%;height: 35px;line-height: 35px;border: none;text-indent: 10px;">'
|
}
|
if(condition == 5 || condition == 6 || condition == 7 || condition == 8){
|
str = '<input id="time_' + t + '_1" style="width: 40%;height: 35px;line-height: 35px;border: none;text-indent: 10px;"> - <input id="time_' + t + '_2" style="width: 40%;height: 35px;line-height: 35px;border: none;text-indent: 10px;">'
|
}
|
}
|
$(e).parents('.tr').find(".content").html(str);
|
if(tagType == 3){
|
if(condition == 3 || condition == 4 || condition == 9 || condition == 10 || condition == 11){
|
layui.use('laydate', function() {
|
var laydate = layui.laydate;
|
laydate.render({
|
elem: '#time_' + t + '_1'
|
, type: 'datetime'
|
});
|
});
|
}
|
if(condition == 5 || condition == 6 || condition == 7 || condition == 8){
|
layui.use('laydate', function() {
|
var laydate = layui.laydate;
|
laydate.render({
|
elem: '#time_' + t + '_1'
|
, type: 'datetime'
|
});
|
laydate.render({
|
elem: '#time_' + t + '_2'
|
, type: 'datetime'
|
});
|
});
|
}
|
}
|
$('.selectpicker').selectpicker();
|
$('.selectpicker').on('hidden.bs.select', function () {
|
let dataType = $('.content').parent('.tr').find('.dataType').val();
|
if(4 == dataType){
|
console.log($('.content .selectpicker').val())
|
let arr = $('.content .selectpicker').val();
|
let type = 2;
|
for(let i in arr){
|
let vs = arr[i].split(";");
|
if(vs[1] == 1){
|
type = 1;
|
break
|
}
|
}
|
if(type == 2){
|
$('.membershipSource').html('<option value="">-</option>')
|
}else{
|
$('.membershipSource').html('<option value="0">站内</option><option value="1">站外</option>')
|
}
|
}
|
});
|
}
|
|
|
function saveData() {
|
let tr = $('.table .body .tr');
|
// if(tr.length == 0){
|
// Feng.error('请填写有效的配置信息');
|
// return
|
// }
|
let obj = [];
|
for(let i = 0; i < tr.length; i++){
|
let id = $(tr[i]).attr('id');
|
if(typeof id == "undefined" || id == "null" || id == "undefined"){
|
id = null;
|
}
|
let objectType = $('#objectType').val();
|
let dataType = $(tr[i]).find('.dataType').val();
|
let tagName = $(tr[i]).find('.selectpicker').val();
|
let condition = $(tr[i]).find('.condition').val();
|
let tagType = $(tr[i]).find('.tagType').val();
|
let membershipSource = $(tr[i]).find('.membershipSource').val();
|
let content = [];
|
if(tagType == 1){//包含/不包含
|
content = $(tr[i]).find('.content .selectpicker').val();
|
}
|
if(tagType == 2){//数字
|
$(tr[i]).find('.content input').each(function (i, e) {
|
let v = $(e).val()
|
if(v != ''){
|
content.push(v);
|
}
|
|
})
|
}
|
if(tagType == 3){//时间
|
$(tr[i]).find('.content input').each(function (i, e) {
|
let v = $(e).val();
|
if(v != ''){
|
content.push(v);
|
}
|
|
})
|
}
|
if(null == content || content.length == 0){
|
Feng.error('请填写有效的配置信息');
|
return
|
}
|
obj.push({
|
id: id,
|
objectType: objectType,
|
dataType: dataType,
|
tagName: tagName,
|
condition: condition,
|
tagType: tagType,
|
content: content,
|
membershipSource: membershipSource
|
})
|
}
|
|
eval("window.parent." + $('#page').val()).exposureCrowd = JSON.stringify(obj);
|
parent.layer.close(eval("window.parent." + $('#page').val() + ".layerIndex"));
|
}
|
|
|
|
function delExposureCrowd(e) {
|
$(e).parents('.tr').remove();
|
}
|
|
function exportExcel() {
|
$('#exportExcel').click();
|
}
|