Authored by 姜敏

优惠券查询--基本完结

... ... @@ -95,7 +95,7 @@ var Bll = {
return common.util.__dateFormat(t, "yyyy-MM-dd hh:mm:ss");
},
__render: function (item) {
__render: function (item,type) {
$("#basicForm").html(common.util.__template2($("#couponListAdd-template").html(), item));
e.init();
startTimeObj = $("#startTime").fdatepicker({
... ... @@ -108,6 +108,15 @@ var Bll = {
}).data("datepicker");
new common.dropDown({el: '#filter-couponType'});
new common.dropDown({el: '#filter-department'});
if(type=='update'){
if(couponBean.customType){
var customType=couponBean.customType.split(',');
for(var i=0;i<customType.length;i++){
custom = "custom-" + customType[i];
$("input ." + custom).attr("checked","checked");
}
}
}
},
checkSortNum: function () {
if ($('.sort-wrap').find('.row').size() > 1) {
... ... @@ -122,7 +131,7 @@ var Bll = {
* 根据type判断界面
*/
if (type == 'add') {
Bll.__render(couponBean);
Bll.__render(couponBean,type);
} else {
var id = location.href.substring(location.href.lastIndexOf("/") + 1);
common.util.__ajax({
... ... @@ -132,21 +141,21 @@ if (type == 'add') {
couponBean = res.data.list[0];
couponBean.startTime = Bll.getTime(couponBean.startTime);
couponBean.endTime = Bll.getTime(couponBean.endTime);
Bll.__render(couponBean)
Bll.__render(couponBean,type)
}, true);
}
/**
* 优惠条件
*/
$(document).on("change", "#useLimitType", function () {
Bll.__render(couponBean);
Bll.__render(couponBean,type);
});
/**
* 适用范围
*/
$(document).on("change", "#useRange", function () {
couponBean.useRange = $(this).val();
Bll.__render(couponBean);
Bll.__render(couponBean,type);
});
var tabTreeArr = [];
var tabTree;
... ... @@ -205,17 +214,19 @@ $(document).on('click', '.del-sort-btn', function () {
/**
* 会员身份
*/
var customType = [];
var len = couponBean.customType.length;
if (len > 0) {
customType = couponBean.customType.split(',');
}
//var customType = [];
//customType = couponBean.customType.split(',');
console.log(couponBean.customType);
//if (customType[0] == "") {
// customType=[];
//}
//console.log(customType);
$(document).on("click", "input[name='customType']", function () {
if ($(this).is(':checked')) {
customType.push($(this).val());
} else {
for (var i = 0; i < a.length; i++) {
if ($(this).val() == a[i]) {
for (var i = 0; i < customType.length; i++) {
if ($(this).val() == customType[i]) {
customType.splice(i, 1)
}
}
... ... @@ -231,13 +242,14 @@ $(document).on("keyup", ".number", function () {
* 保存
*/
$(document).on("click", "#save_brand", function () {
console.log(couponBean);
if (e.validate()) {
delete couponBean.useRange;
common.util.__ajax({
url: action,
data: couponBean
}, function (res) {
location.href = "/market/couponList/index";
//location.href = "/market/couponList/index";
});
}
return false;
... ...
... ... @@ -7,7 +7,16 @@ var $ = require('jquery'),
var departments = ["渠道二部", "渠道一部", "零售部", "品牌资源部", "店铺运营部", "类目运营部", "营销部", "市场部", "会员部 ", "客服部", "内容营销部"];
var couponTypes = ["A券", "B券", "公开券", "生日券", "免邮券"];
var startTimeObj;
var endTimeObj;
startTimeObj = $("#filter-startTimeStr").fdatepicker({
format: 'yyyy-mm-dd hh:ii:ss',
pickTime: true
}).data("datepicker");
endTimeObj = $("#filter-endTimeStr").fdatepicker({
format: 'yyyy-mm-dd hh:ii:ss',
pickTime: true
}).data("datepicker");
//下拉框
new common.dropDown({el: '#filter-couponType'});
new common.dropDown({el: '#filter-department'});
... ... @@ -22,25 +31,25 @@ var g = new common.grid({
couponName:common.util.__input("filter-couponName"),
department:common.util.__input("filter-department"),
startTimeStr:common.util.__input("filter-startTimeStr"),
endTimeStr:common.util.__input("filter-endTimeStr"),
endTimeStr:common.util.__input("filter-endTimeStr")
};
},
columns:[
{display:"优惠券ID", name:"id"},
{display:"优惠券名称",name:"couponName"},
{display: '申请部门', render: function(item) {
return '<p class="audit-time">' + departments[item.department] + '</p>';
return '<p class="audit-time">' + departments[item.department-1] + '</p>';
}},
{display: '优惠券类型', render: function(item) {
return '<p class="audit-time">' + couponTypes[item.couponType] + '</p>';
return '<p class="audit-time">' + couponTypes[item.couponType-1] + '</p>';
}},
{display: '数量', name: "couponNum"},
{display: '面额', name: "couponAmount"},
{display: '开始时间', render: function(item) {
return common.util.__dateFormat(new Date(item.startTime), "yyyy-MM-dd hh:mm:ss");;
return Bll.getTime(item.startTime);
}},
{display: '结束时间', render: function(item) {
return common.util.__dateFormat(new Date(item.endTime), "yyyy-MM-dd hh:mm:ss");;
return Bll.getTime(item.endTime);
}},
{display:"操作",name:"operate",render:function(item){
var HtmArr=[];
... ... @@ -55,4 +64,12 @@ g.init("/coupon/querySendCouponList");
$(document).on("click", "#filter-btn", function() {
g.reload(1);
});
\ No newline at end of file
});
var Bll={
getTime: function (time) {
var t = new Date(time * 1000);
return common.util.__dateFormat(t, "yyyy-MM-dd hh:mm:ss");
}
};
\ No newline at end of file
... ...
... ... @@ -39,9 +39,9 @@ var g = new common.grid({
{display:"是否取消过",render: function (item) {
var isCancel = "";
if(item.isCancel == "Y") {
isCancel = "取消过";
isCancel = "已取消";
} else if(item.isCancel == "N") {
isCancel = "未曾取消过";
isCancel = "未取消";
}
return '<p class="audit-time">' + isCancel + '</p>';
}},
... ...
... ... @@ -22,6 +22,7 @@ var Bll = {
data: {couponId:couponId},
async: false
}, function (res) {
console.log("res",res);
$("#list-content").html(common.util.__template2($("#template-list").html(), res));
},true);
}
... ... @@ -38,7 +39,7 @@ $(document).on("click", "#sendCoupon", function() {
uids:uids
}
}, function () {
location.href = location.href;
//location.href = location.href;
});
} else {
common.util.__tip("请输入UID", "warning");
... ... @@ -47,12 +48,29 @@ $(document).on("click", "#sendCoupon", function() {
//批量导入
$(document).on("click", "#batch-import", function() {
$("#importFile").click();
$("#picfile").click();
common.edit.ajaxfileupload(".picfile", {
params: {
__type: "import-txt",
couponId:parseInt(couponId)
},
valid_extensions: ['txt'],
onComplete: function (response) {
console.log("response",response);
if (response.status && response.code == 200) {
//todo
//进一步操作
}
else {
common.util.__tip(response.message, 'warning');
}
}
});
});
//重新发放
$(document).on("click", ".reSend", function() {
var id = $(this).data("id");
var id = $(this).data("index");
common.util.__ajax({
url: "/couponSendInfo/sendAgainById",
data: {id: id}
... ... @@ -61,18 +79,18 @@ $(document).on("click", ".reSend", function() {
});
});
//导入
common.edit.ajaxfileupload("#importFile",{
params: {
type: "drawlineUserQueue",
__type: "batch-import"
},
onComplete:function(res){
if(res.code == 200) {
common.util.__tip(res.message, 'success');
Bll.getListByCouponId();
} else {
common.util.__tip(res.message);
}
}
});
\ No newline at end of file
////导入
//common.edit.ajaxfileupload("#importFile",{
// params: {
// type: "drawlineUserQueue",
// __type: "batch-import"
// },
// onComplete:function(res){
// if(res.code == 200) {
// common.util.__tip(res.message, 'success');
// Bll.getListByCouponId();
// } else {
// common.util.__tip(res.message);
// }
// }
//});
\ No newline at end of file
... ...
... ... @@ -7,7 +7,6 @@ var $ = require('jquery'),
common=require('../common/common');
var couponId = location.href.substring(location.href.lastIndexOf("/") + 1);
$("#filter-couponId").val(couponId);
//下拉框
new common.dropDown({el: '#filter-status'});
... ... @@ -19,7 +18,8 @@ var g = new common.grid({
async:false,
parms:function(){
return {
couponId: common.util.__input("filter-couponId")
couponId: couponId
//status:common.util.__input("filter-status")
};
},
columns:[
... ...
... ... @@ -622,7 +622,7 @@ exports.res = [
type: 'Number'
}]
},
/**********************************发券管理*************************/
/**********************************发券管理--庞洁*************************/
{
//发券管理列表页渲染
route: "/market/couponSend/index",
... ... @@ -711,6 +711,7 @@ exports.res = [
view: "pages/market/useHistory",
src: "/market/useHistory"
},
/*******************************优惠券查询--李建*******************************/
{
//优惠券查询页面渲染
route: "/market/queryCoupon/index",
... ... @@ -737,7 +738,7 @@ exports.res = [
{name: "id", type: "number"}
]
},
/****************************************优惠券管理********************/
/****************************************优惠券管理--庞洁********************/
{
//优惠券管理页面渲染
route: "/market/couponList/index",
... ...
... ... @@ -20,7 +20,7 @@ var errBackMsg = {
function getHeader(req,res){
var headers = {};
if (req.session && req.session.user) {
var ipObject = ipaddr.process(req.ip).octets
var ipObject = ipaddr.process(req.ip).octets;
var ip = ipObject ? ipObject.join('.') : req.ip;
headers = {
... ... @@ -46,9 +46,6 @@ exports.uploadFile = function (req, res) {
for (var key in req.body) {
url.push(key + "=" + req.body[key]);
}
console.log("req.body",req.body);
//req.body.file = fs.createReadStream(req.files[req.body.filename].path);
if (req.body.__type == "batch-import") {
req.body.file = fs.createReadStream(req.files[req.body.filename].path);
request.post({
... ... @@ -67,7 +64,34 @@ exports.uploadFile = function (req, res) {
res.json(errBackMsg);
}
});
} else {
}
//上传txt文本文件
else if(req.body.__type == "import-txt"){
req.body.file = fs.createReadStream(req.files[req.body.filename].path);
//var data={
// couponId:req.body.couponId,
// file:req.body.file
//};
//console.log("上传的数据",data);
request.post({
url: "http://172.16.6.250:2081/platform/couponSendFile/upload",
formData: req.body,
headers: headers
}, function optionalCallback(error, httpResponse, body) {
if (error) {
return console.error('upload failed:', error);
}
if (!error && httpResponse.statusCode == 200) {
var json = JSON.parse(body);
json.status = true;
console.info("请求结果json",json);
res.json(json);
} else {
res.json(errBackMsg);
}
});
}
else {
var files = req.files[req.body.filename];
//判断是单张传还是多张传
var flag = Object.prototype.toString.call(files) === '[object Array]';
... ...
... ... @@ -223,19 +223,19 @@
<div class="col-sm-10">
<label class="checkbox-inline">
<input type="checkbox" value="1" name="customType"> 新客户 (注册未购买)
<input type="checkbox" value="1" name="customType" class="custom-1"> 新客户 (注册未购买)
</label>
<label class="checkbox-inline">
<input type="checkbox" value="5" name="customType"> 普通会员 (不包含新客户)
<input type="checkbox" value="5" name="customType" class="custom-5"> 普通会员 (不包含新客户)
</label>
<label class="checkbox-inline">
<input type="checkbox" value="2" name="customType"> 银卡会员
<input type="checkbox" value="2" name="customType" class="custom-2"> 银卡会员
</label>
<label class="checkbox-inline">
<input type="checkbox" value="3" name="customType"> 金卡会员
<input type="checkbox" value="3" name="customType" class="custom-3"> 金卡会员
</label>
<label class="checkbox-inline">
<input type="checkbox" value="4" name="customType"> 白金会员
<input type="checkbox" value="4" name="customType" class="custom-4"> 白金会员
</label>
</div>
... ...
... ... @@ -35,9 +35,9 @@
</div>
<div class="form-group">
<h4>批导发放</h4>
<a class="btn btn-primary btn-xs" id="batch-import">批量上传</a>
<input type="file" id="importFile" style="z-index: -999999" name="file" hidden>
<h4>批量发放</h4>
<a class="btn btn-primary" href="javascript:void(0);" id="batch-import">上传文件</a>
<input type="file" class="picfile" name="picfile" required="required" id="picfile">
</div><br>
<div id="list-content">
... ...
... ... @@ -23,15 +23,14 @@
<div class="panel panel-default" style="margin-bottom:10px;">
<div class="panel-body">
<div class="row">
<!--<div class="panel-col">-->
<!--<select id="filter-status" tabindex="-1" class="select2-offscreen brandBtn-group">-->
<!--<option value="-1">状态</option>-->
<!--<option value="1">已使用</option>-->
<!--<option value="0">未使用</option>-->
<!--</select>-->
<input type="hidden" id="filter-couponId" value="">
<!--</div>-->
<!--<a id="filter-btn" href="javascript:;" class="btn btn-info">筛选</a>-->
<div class="panel-col">
<select id="filter-status" tabindex="-1" class="select2-offscreen brandBtn-group">
<option value="-1">状态</option>
<option value="1">已使用</option>
<option value="0">未使用</option>
</select>
</div>
<a id="filter-btn" href="javascript:;" class="btn btn-info">筛选</a>
<a id="export-btn" href="" class="btn btn-info">导出</a>
</div>
</div>
... ...