Authored by 姜敏

优惠券查询--基本完结

@@ -95,7 +95,7 @@ var Bll = { @@ -95,7 +95,7 @@ var Bll = {
95 return common.util.__dateFormat(t, "yyyy-MM-dd hh:mm:ss"); 95 return common.util.__dateFormat(t, "yyyy-MM-dd hh:mm:ss");
96 96
97 }, 97 },
98 - __render: function (item) { 98 + __render: function (item,type) {
99 $("#basicForm").html(common.util.__template2($("#couponListAdd-template").html(), item)); 99 $("#basicForm").html(common.util.__template2($("#couponListAdd-template").html(), item));
100 e.init(); 100 e.init();
101 startTimeObj = $("#startTime").fdatepicker({ 101 startTimeObj = $("#startTime").fdatepicker({
@@ -108,6 +108,15 @@ var Bll = { @@ -108,6 +108,15 @@ var Bll = {
108 }).data("datepicker"); 108 }).data("datepicker");
109 new common.dropDown({el: '#filter-couponType'}); 109 new common.dropDown({el: '#filter-couponType'});
110 new common.dropDown({el: '#filter-department'}); 110 new common.dropDown({el: '#filter-department'});
  111 + if(type=='update'){
  112 + if(couponBean.customType){
  113 + var customType=couponBean.customType.split(',');
  114 + for(var i=0;i<customType.length;i++){
  115 + custom = "custom-" + customType[i];
  116 + $("input ." + custom).attr("checked","checked");
  117 + }
  118 + }
  119 + }
111 }, 120 },
112 checkSortNum: function () { 121 checkSortNum: function () {
113 if ($('.sort-wrap').find('.row').size() > 1) { 122 if ($('.sort-wrap').find('.row').size() > 1) {
@@ -122,7 +131,7 @@ var Bll = { @@ -122,7 +131,7 @@ var Bll = {
122 * 根据type判断界面 131 * 根据type判断界面
123 */ 132 */
124 if (type == 'add') { 133 if (type == 'add') {
125 - Bll.__render(couponBean); 134 + Bll.__render(couponBean,type);
126 } else { 135 } else {
127 var id = location.href.substring(location.href.lastIndexOf("/") + 1); 136 var id = location.href.substring(location.href.lastIndexOf("/") + 1);
128 common.util.__ajax({ 137 common.util.__ajax({
@@ -132,21 +141,21 @@ if (type == 'add') { @@ -132,21 +141,21 @@ if (type == 'add') {
132 couponBean = res.data.list[0]; 141 couponBean = res.data.list[0];
133 couponBean.startTime = Bll.getTime(couponBean.startTime); 142 couponBean.startTime = Bll.getTime(couponBean.startTime);
134 couponBean.endTime = Bll.getTime(couponBean.endTime); 143 couponBean.endTime = Bll.getTime(couponBean.endTime);
135 - Bll.__render(couponBean) 144 + Bll.__render(couponBean,type)
136 }, true); 145 }, true);
137 } 146 }
138 /** 147 /**
139 * 优惠条件 148 * 优惠条件
140 */ 149 */
141 $(document).on("change", "#useLimitType", function () { 150 $(document).on("change", "#useLimitType", function () {
142 - Bll.__render(couponBean); 151 + Bll.__render(couponBean,type);
143 }); 152 });
144 /** 153 /**
145 * 适用范围 154 * 适用范围
146 */ 155 */
147 $(document).on("change", "#useRange", function () { 156 $(document).on("change", "#useRange", function () {
148 couponBean.useRange = $(this).val(); 157 couponBean.useRange = $(this).val();
149 - Bll.__render(couponBean); 158 + Bll.__render(couponBean,type);
150 }); 159 });
151 var tabTreeArr = []; 160 var tabTreeArr = [];
152 var tabTree; 161 var tabTree;
@@ -205,17 +214,19 @@ $(document).on('click', '.del-sort-btn', function () { @@ -205,17 +214,19 @@ $(document).on('click', '.del-sort-btn', function () {
205 /** 214 /**
206 * 会员身份 215 * 会员身份
207 */ 216 */
208 -var customType = [];  
209 -var len = couponBean.customType.length;  
210 -if (len > 0) {  
211 - customType = couponBean.customType.split(',');  
212 -} 217 +//var customType = [];
  218 +//customType = couponBean.customType.split(',');
  219 +console.log(couponBean.customType);
  220 +//if (customType[0] == "") {
  221 +// customType=[];
  222 +//}
  223 +//console.log(customType);
213 $(document).on("click", "input[name='customType']", function () { 224 $(document).on("click", "input[name='customType']", function () {
214 if ($(this).is(':checked')) { 225 if ($(this).is(':checked')) {
215 customType.push($(this).val()); 226 customType.push($(this).val());
216 } else { 227 } else {
217 - for (var i = 0; i < a.length; i++) {  
218 - if ($(this).val() == a[i]) { 228 + for (var i = 0; i < customType.length; i++) {
  229 + if ($(this).val() == customType[i]) {
219 customType.splice(i, 1) 230 customType.splice(i, 1)
220 } 231 }
221 } 232 }
@@ -231,13 +242,14 @@ $(document).on("keyup", ".number", function () { @@ -231,13 +242,14 @@ $(document).on("keyup", ".number", function () {
231 * 保存 242 * 保存
232 */ 243 */
233 $(document).on("click", "#save_brand", function () { 244 $(document).on("click", "#save_brand", function () {
  245 + console.log(couponBean);
234 if (e.validate()) { 246 if (e.validate()) {
235 delete couponBean.useRange; 247 delete couponBean.useRange;
236 common.util.__ajax({ 248 common.util.__ajax({
237 url: action, 249 url: action,
238 data: couponBean 250 data: couponBean
239 }, function (res) { 251 }, function (res) {
240 - location.href = "/market/couponList/index"; 252 + //location.href = "/market/couponList/index";
241 }); 253 });
242 } 254 }
243 return false; 255 return false;
@@ -7,7 +7,16 @@ var $ = require('jquery'), @@ -7,7 +7,16 @@ var $ = require('jquery'),
7 7
8 var departments = ["渠道二部", "渠道一部", "零售部", "品牌资源部", "店铺运营部", "类目运营部", "营销部", "市场部", "会员部 ", "客服部", "内容营销部"]; 8 var departments = ["渠道二部", "渠道一部", "零售部", "品牌资源部", "店铺运营部", "类目运营部", "营销部", "市场部", "会员部 ", "客服部", "内容营销部"];
9 var couponTypes = ["A券", "B券", "公开券", "生日券", "免邮券"]; 9 var couponTypes = ["A券", "B券", "公开券", "生日券", "免邮券"];
10 - 10 +var startTimeObj;
  11 +var endTimeObj;
  12 +startTimeObj = $("#filter-startTimeStr").fdatepicker({
  13 + format: 'yyyy-mm-dd hh:ii:ss',
  14 + pickTime: true
  15 +}).data("datepicker");
  16 +endTimeObj = $("#filter-endTimeStr").fdatepicker({
  17 + format: 'yyyy-mm-dd hh:ii:ss',
  18 + pickTime: true
  19 +}).data("datepicker");
11 //下拉框 20 //下拉框
12 new common.dropDown({el: '#filter-couponType'}); 21 new common.dropDown({el: '#filter-couponType'});
13 new common.dropDown({el: '#filter-department'}); 22 new common.dropDown({el: '#filter-department'});
@@ -22,25 +31,25 @@ var g = new common.grid({ @@ -22,25 +31,25 @@ var g = new common.grid({
22 couponName:common.util.__input("filter-couponName"), 31 couponName:common.util.__input("filter-couponName"),
23 department:common.util.__input("filter-department"), 32 department:common.util.__input("filter-department"),
24 startTimeStr:common.util.__input("filter-startTimeStr"), 33 startTimeStr:common.util.__input("filter-startTimeStr"),
25 - endTimeStr:common.util.__input("filter-endTimeStr"), 34 + endTimeStr:common.util.__input("filter-endTimeStr")
26 }; 35 };
27 }, 36 },
28 columns:[ 37 columns:[
29 {display:"优惠券ID", name:"id"}, 38 {display:"优惠券ID", name:"id"},
30 {display:"优惠券名称",name:"couponName"}, 39 {display:"优惠券名称",name:"couponName"},
31 {display: '申请部门', render: function(item) { 40 {display: '申请部门', render: function(item) {
32 - return '<p class="audit-time">' + departments[item.department] + '</p>'; 41 + return '<p class="audit-time">' + departments[item.department-1] + '</p>';
33 }}, 42 }},
34 {display: '优惠券类型', render: function(item) { 43 {display: '优惠券类型', render: function(item) {
35 - return '<p class="audit-time">' + couponTypes[item.couponType] + '</p>'; 44 + return '<p class="audit-time">' + couponTypes[item.couponType-1] + '</p>';
36 }}, 45 }},
37 {display: '数量', name: "couponNum"}, 46 {display: '数量', name: "couponNum"},
38 {display: '面额', name: "couponAmount"}, 47 {display: '面额', name: "couponAmount"},
39 {display: '开始时间', render: function(item) { 48 {display: '开始时间', render: function(item) {
40 - return common.util.__dateFormat(new Date(item.startTime), "yyyy-MM-dd hh:mm:ss");; 49 + return Bll.getTime(item.startTime);
41 }}, 50 }},
42 {display: '结束时间', render: function(item) { 51 {display: '结束时间', render: function(item) {
43 - return common.util.__dateFormat(new Date(item.endTime), "yyyy-MM-dd hh:mm:ss");; 52 + return Bll.getTime(item.endTime);
44 }}, 53 }},
45 {display:"操作",name:"operate",render:function(item){ 54 {display:"操作",name:"operate",render:function(item){
46 var HtmArr=[]; 55 var HtmArr=[];
@@ -56,3 +65,11 @@ g.init("/coupon/querySendCouponList"); @@ -56,3 +65,11 @@ g.init("/coupon/querySendCouponList");
56 $(document).on("click", "#filter-btn", function() { 65 $(document).on("click", "#filter-btn", function() {
57 g.reload(1); 66 g.reload(1);
58 }); 67 });
  68 +
  69 +var Bll={
  70 + getTime: function (time) {
  71 + var t = new Date(time * 1000);
  72 + return common.util.__dateFormat(t, "yyyy-MM-dd hh:mm:ss");
  73 +
  74 + }
  75 +};
@@ -39,9 +39,9 @@ var g = new common.grid({ @@ -39,9 +39,9 @@ var g = new common.grid({
39 {display:"是否取消过",render: function (item) { 39 {display:"是否取消过",render: function (item) {
40 var isCancel = ""; 40 var isCancel = "";
41 if(item.isCancel == "Y") { 41 if(item.isCancel == "Y") {
42 - isCancel = "取消过"; 42 + isCancel = "已取消";
43 } else if(item.isCancel == "N") { 43 } else if(item.isCancel == "N") {
44 - isCancel = "未曾取消过"; 44 + isCancel = "未取消";
45 } 45 }
46 return '<p class="audit-time">' + isCancel + '</p>'; 46 return '<p class="audit-time">' + isCancel + '</p>';
47 }}, 47 }},
@@ -22,6 +22,7 @@ var Bll = { @@ -22,6 +22,7 @@ var Bll = {
22 data: {couponId:couponId}, 22 data: {couponId:couponId},
23 async: false 23 async: false
24 }, function (res) { 24 }, function (res) {
  25 + console.log("res",res);
25 $("#list-content").html(common.util.__template2($("#template-list").html(), res)); 26 $("#list-content").html(common.util.__template2($("#template-list").html(), res));
26 },true); 27 },true);
27 } 28 }
@@ -38,7 +39,7 @@ $(document).on("click", "#sendCoupon", function() { @@ -38,7 +39,7 @@ $(document).on("click", "#sendCoupon", function() {
38 uids:uids 39 uids:uids
39 } 40 }
40 }, function () { 41 }, function () {
41 - location.href = location.href; 42 + //location.href = location.href;
42 }); 43 });
43 } else { 44 } else {
44 common.util.__tip("请输入UID", "warning"); 45 common.util.__tip("请输入UID", "warning");
@@ -47,12 +48,29 @@ $(document).on("click", "#sendCoupon", function() { @@ -47,12 +48,29 @@ $(document).on("click", "#sendCoupon", function() {
47 48
48 //批量导入 49 //批量导入
49 $(document).on("click", "#batch-import", function() { 50 $(document).on("click", "#batch-import", function() {
50 - $("#importFile").click(); 51 + $("#picfile").click();
  52 + common.edit.ajaxfileupload(".picfile", {
  53 + params: {
  54 + __type: "import-txt",
  55 + couponId:parseInt(couponId)
  56 + },
  57 + valid_extensions: ['txt'],
  58 + onComplete: function (response) {
  59 + console.log("response",response);
  60 + if (response.status && response.code == 200) {
  61 + //todo
  62 + //进一步操作
  63 + }
  64 + else {
  65 + common.util.__tip(response.message, 'warning');
  66 + }
  67 + }
  68 + });
51 }); 69 });
52 70
53 //重新发放 71 //重新发放
54 $(document).on("click", ".reSend", function() { 72 $(document).on("click", ".reSend", function() {
55 - var id = $(this).data("id"); 73 + var id = $(this).data("index");
56 common.util.__ajax({ 74 common.util.__ajax({
57 url: "/couponSendInfo/sendAgainById", 75 url: "/couponSendInfo/sendAgainById",
58 data: {id: id} 76 data: {id: id}
@@ -61,18 +79,18 @@ $(document).on("click", ".reSend", function() { @@ -61,18 +79,18 @@ $(document).on("click", ".reSend", function() {
61 }); 79 });
62 }); 80 });
63 81
64 -//导入  
65 -common.edit.ajaxfileupload("#importFile",{  
66 - params: {  
67 - type: "drawlineUserQueue",  
68 - __type: "batch-import"  
69 - },  
70 - onComplete:function(res){  
71 - if(res.code == 200) {  
72 - common.util.__tip(res.message, 'success');  
73 - Bll.getListByCouponId();  
74 - } else {  
75 - common.util.__tip(res.message);  
76 - }  
77 - }  
78 -});  
  82 +////导入
  83 +//common.edit.ajaxfileupload("#importFile",{
  84 +// params: {
  85 +// type: "drawlineUserQueue",
  86 +// __type: "batch-import"
  87 +// },
  88 +// onComplete:function(res){
  89 +// if(res.code == 200) {
  90 +// common.util.__tip(res.message, 'success');
  91 +// Bll.getListByCouponId();
  92 +// } else {
  93 +// common.util.__tip(res.message);
  94 +// }
  95 +// }
  96 +//});
@@ -7,7 +7,6 @@ var $ = require('jquery'), @@ -7,7 +7,6 @@ var $ = require('jquery'),
7 common=require('../common/common'); 7 common=require('../common/common');
8 8
9 var couponId = location.href.substring(location.href.lastIndexOf("/") + 1); 9 var couponId = location.href.substring(location.href.lastIndexOf("/") + 1);
10 -$("#filter-couponId").val(couponId);  
11 10
12 //下拉框 11 //下拉框
13 new common.dropDown({el: '#filter-status'}); 12 new common.dropDown({el: '#filter-status'});
@@ -19,7 +18,8 @@ var g = new common.grid({ @@ -19,7 +18,8 @@ var g = new common.grid({
19 async:false, 18 async:false,
20 parms:function(){ 19 parms:function(){
21 return { 20 return {
22 - couponId: common.util.__input("filter-couponId") 21 + couponId: couponId
  22 + //status:common.util.__input("filter-status")
23 }; 23 };
24 }, 24 },
25 columns:[ 25 columns:[
@@ -622,7 +622,7 @@ exports.res = [ @@ -622,7 +622,7 @@ exports.res = [
622 type: 'Number' 622 type: 'Number'
623 }] 623 }]
624 }, 624 },
625 - /**********************************发券管理*************************/ 625 + /**********************************发券管理--庞洁*************************/
626 { 626 {
627 //发券管理列表页渲染 627 //发券管理列表页渲染
628 route: "/market/couponSend/index", 628 route: "/market/couponSend/index",
@@ -711,6 +711,7 @@ exports.res = [ @@ -711,6 +711,7 @@ exports.res = [
711 view: "pages/market/useHistory", 711 view: "pages/market/useHistory",
712 src: "/market/useHistory" 712 src: "/market/useHistory"
713 }, 713 },
  714 + /*******************************优惠券查询--李建*******************************/
714 { 715 {
715 //优惠券查询页面渲染 716 //优惠券查询页面渲染
716 route: "/market/queryCoupon/index", 717 route: "/market/queryCoupon/index",
@@ -737,7 +738,7 @@ exports.res = [ @@ -737,7 +738,7 @@ exports.res = [
737 {name: "id", type: "number"} 738 {name: "id", type: "number"}
738 ] 739 ]
739 }, 740 },
740 -/****************************************优惠券管理********************/ 741 +/****************************************优惠券管理--庞洁********************/
741 { 742 {
742 //优惠券管理页面渲染 743 //优惠券管理页面渲染
743 route: "/market/couponList/index", 744 route: "/market/couponList/index",
@@ -20,7 +20,7 @@ var errBackMsg = { @@ -20,7 +20,7 @@ var errBackMsg = {
20 function getHeader(req,res){ 20 function getHeader(req,res){
21 var headers = {}; 21 var headers = {};
22 if (req.session && req.session.user) { 22 if (req.session && req.session.user) {
23 - var ipObject = ipaddr.process(req.ip).octets 23 + var ipObject = ipaddr.process(req.ip).octets;
24 var ip = ipObject ? ipObject.join('.') : req.ip; 24 var ip = ipObject ? ipObject.join('.') : req.ip;
25 25
26 headers = { 26 headers = {
@@ -46,9 +46,6 @@ exports.uploadFile = function (req, res) { @@ -46,9 +46,6 @@ exports.uploadFile = function (req, res) {
46 for (var key in req.body) { 46 for (var key in req.body) {
47 url.push(key + "=" + req.body[key]); 47 url.push(key + "=" + req.body[key]);
48 } 48 }
49 - console.log("req.body",req.body);  
50 - //req.body.file = fs.createReadStream(req.files[req.body.filename].path);  
51 -  
52 if (req.body.__type == "batch-import") { 49 if (req.body.__type == "batch-import") {
53 req.body.file = fs.createReadStream(req.files[req.body.filename].path); 50 req.body.file = fs.createReadStream(req.files[req.body.filename].path);
54 request.post({ 51 request.post({
@@ -67,7 +64,34 @@ exports.uploadFile = function (req, res) { @@ -67,7 +64,34 @@ exports.uploadFile = function (req, res) {
67 res.json(errBackMsg); 64 res.json(errBackMsg);
68 } 65 }
69 }); 66 });
  67 + }
  68 + //上传txt文本文件
  69 + else if(req.body.__type == "import-txt"){
  70 + req.body.file = fs.createReadStream(req.files[req.body.filename].path);
  71 + //var data={
  72 + // couponId:req.body.couponId,
  73 + // file:req.body.file
  74 + //};
  75 + //console.log("上传的数据",data);
  76 + request.post({
  77 + url: "http://172.16.6.250:2081/platform/couponSendFile/upload",
  78 + formData: req.body,
  79 + headers: headers
  80 + }, function optionalCallback(error, httpResponse, body) {
  81 + if (error) {
  82 + return console.error('upload failed:', error);
  83 + }
  84 + if (!error && httpResponse.statusCode == 200) {
  85 + var json = JSON.parse(body);
  86 + json.status = true;
  87 + console.info("请求结果json",json);
  88 + res.json(json);
70 } else { 89 } else {
  90 + res.json(errBackMsg);
  91 + }
  92 + });
  93 + }
  94 + else {
71 var files = req.files[req.body.filename]; 95 var files = req.files[req.body.filename];
72 //判断是单张传还是多张传 96 //判断是单张传还是多张传
73 var flag = Object.prototype.toString.call(files) === '[object Array]'; 97 var flag = Object.prototype.toString.call(files) === '[object Array]';
@@ -223,19 +223,19 @@ @@ -223,19 +223,19 @@
223 223
224 <div class="col-sm-10"> 224 <div class="col-sm-10">
225 <label class="checkbox-inline"> 225 <label class="checkbox-inline">
226 - <input type="checkbox" value="1" name="customType"> 新客户 (注册未购买) 226 + <input type="checkbox" value="1" name="customType" class="custom-1"> 新客户 (注册未购买)
227 </label> 227 </label>
228 <label class="checkbox-inline"> 228 <label class="checkbox-inline">
229 - <input type="checkbox" value="5" name="customType"> 普通会员 (不包含新客户) 229 + <input type="checkbox" value="5" name="customType" class="custom-5"> 普通会员 (不包含新客户)
230 </label> 230 </label>
231 <label class="checkbox-inline"> 231 <label class="checkbox-inline">
232 - <input type="checkbox" value="2" name="customType"> 银卡会员 232 + <input type="checkbox" value="2" name="customType" class="custom-2"> 银卡会员
233 </label> 233 </label>
234 <label class="checkbox-inline"> 234 <label class="checkbox-inline">
235 - <input type="checkbox" value="3" name="customType"> 金卡会员 235 + <input type="checkbox" value="3" name="customType" class="custom-3"> 金卡会员
236 </label> 236 </label>
237 <label class="checkbox-inline"> 237 <label class="checkbox-inline">
238 - <input type="checkbox" value="4" name="customType"> 白金会员 238 + <input type="checkbox" value="4" name="customType" class="custom-4"> 白金会员
239 </label> 239 </label>
240 </div> 240 </div>
241 241
@@ -35,9 +35,9 @@ @@ -35,9 +35,9 @@
35 </div> 35 </div>
36 36
37 <div class="form-group"> 37 <div class="form-group">
38 - <h4>批导发放</h4>  
39 - <a class="btn btn-primary btn-xs" id="batch-import">批量上传</a>  
40 - <input type="file" id="importFile" style="z-index: -999999" name="file" hidden> 38 + <h4>批量发放</h4>
  39 + <a class="btn btn-primary" href="javascript:void(0);" id="batch-import">上传文件</a>
  40 + <input type="file" class="picfile" name="picfile" required="required" id="picfile">
41 </div><br> 41 </div><br>
42 <div id="list-content"> 42 <div id="list-content">
43 43
@@ -23,15 +23,14 @@ @@ -23,15 +23,14 @@
23 <div class="panel panel-default" style="margin-bottom:10px;"> 23 <div class="panel panel-default" style="margin-bottom:10px;">
24 <div class="panel-body"> 24 <div class="panel-body">
25 <div class="row"> 25 <div class="row">
26 - <!--<div class="panel-col">-->  
27 - <!--<select id="filter-status" tabindex="-1" class="select2-offscreen brandBtn-group">-->  
28 - <!--<option value="-1">状态</option>-->  
29 - <!--<option value="1">已使用</option>-->  
30 - <!--<option value="0">未使用</option>-->  
31 - <!--</select>-->  
32 - <input type="hidden" id="filter-couponId" value="">  
33 - <!--</div>-->  
34 - <!--<a id="filter-btn" href="javascript:;" class="btn btn-info">筛选</a>--> 26 + <div class="panel-col">
  27 + <select id="filter-status" tabindex="-1" class="select2-offscreen brandBtn-group">
  28 + <option value="-1">状态</option>
  29 + <option value="1">已使用</option>
  30 + <option value="0">未使用</option>
  31 + </select>
  32 + </div>
  33 + <a id="filter-btn" href="javascript:;" class="btn btn-info">筛选</a>
35 <a id="export-btn" href="" class="btn btn-info">导出</a> 34 <a id="export-btn" href="" class="btn btn-info">导出</a>
36 </div> 35 </div>
37 </div> 36 </div>