Authored by 马力

Merge branch 'dev_优惠券优化'

@@ -55,4 +55,6 @@ module.exports = function (app) { @@ -55,4 +55,6 @@ module.exports = function (app) {
55 //作废 55 //作废
56 app.post("/coupon/invalid", "CouponList_invalid"); 56 app.post("/coupon/invalid", "CouponList_invalid");
57 57
  58 + // 查询优惠券操作记录
  59 + app.post("/coupon/getOperationRecords", "CouponList_getOperationRecords");
58 }; 60 };
@@ -74,6 +74,13 @@ module.exports = { @@ -74,6 +74,13 @@ module.exports = {
74 couponId: {type: Number}, 74 couponId: {type: Number},
75 invalidReason: {type: String} 75 invalidReason: {type: String}
76 } 76 }
  77 + },
  78 + getOperationRecords: {
  79 + title: "查询优惠券操作记录",
  80 + url: "/coupon/queryOperationRecord",
  81 + params: {
  82 + couponsId: {type: Number}
  83 + }
77 } 84 }
78 } 85 }
79 }; 86 };
@@ -91,7 +91,7 @@ @@ -91,7 +91,7 @@
91 </div> 91 </div>
92 92
93 <div class="form-group"> 93 <div class="form-group">
94 - <label class="col-sm-2 control-label">申请部门<i class="red">*</i></label> 94 + <label class="col-sm-2 control-label">费用承担部门<i class="red">*</i></label>
95 95
96 <div class="col-sm-8" id="departments"> 96 <div class="col-sm-8" id="departments">
97 97
@@ -207,6 +207,32 @@ @@ -207,6 +207,32 @@
207 207
208 </div> 208 </div>
209 </script> 209 </script>
  210 +<script type="text/template" id="operation-record-template">
  211 + <div class="historyList">
  212 + <table class="table table-striped table-bordered">
  213 + <thead>
  214 + <tr>
  215 + <th>操作类型</th>
  216 + <th>操作人</th>
  217 + <th>执行时间</th>
  218 + </tr>
  219 + </thead>
  220 + <tbody>
  221 + [[if list.length > 0]]
  222 + [[each list as item index]]
  223 + <tr>
  224 + <td>[[item.operationType]]</td>
  225 + <td>[[item.operator]]</td>
  226 + <td>[[item.createTime]]</td>
  227 + </tr>
  228 + [[/each]]
  229 + [[else]]
  230 + <tr><td colspan="7">没有操作记录!</td></tr>
  231 + [[/if]]
  232 + </tbody>
  233 + </table>
  234 + </div>
  235 +</script>
210 <%include '../../../common/views/__ui/footer'%> 236 <%include '../../../common/views/__ui/footer'%>
211 237
212 238
@@ -60,29 +60,29 @@ var t = new common.tab({ @@ -60,29 +60,29 @@ var t = new common.tab({
60 el: "#basicTab", 60 el: "#basicTab",
61 click: function () { 61 click: function () {
62 columnname = $(this).find('a').attr('columnname'); 62 columnname = $(this).find('a').attr('columnname');
  63 + g.options.columns[5].hidden = true;
63 g.options.columns[6].hidden = true; 64 g.options.columns[6].hidden = true;
64 - g.options.columns[7].hidden = true;  
65 switch (columnname) { 65 switch (columnname) {
66 case "1": 66 case "1":
67 { 67 {
68 - g.options.columns[8].hidden = true; 68 + g.options.columns[7].hidden = true;
69 } 69 }
70 break; 70 break;
71 case "2": 71 case "2":
72 { 72 {
73 - g.options.columns[6].hidden = false;  
74 - g.options.columns[8].hidden = true; 73 + g.options.columns[5].hidden = false;
  74 + g.options.columns[7].hidden = true;
75 } 75 }
76 break; 76 break;
77 case "3": 77 case "3":
78 { 78 {
79 - g.options.columns[7].hidden = false;  
80 - g.options.columns[8].hidden = true; 79 + g.options.columns[6].hidden = false;
  80 + g.options.columns[7].hidden = true;
81 } 81 }
82 break; 82 break;
83 case "all": 83 case "all":
84 { 84 {
85 - g.options.columns[8].hidden = false; 85 + g.options.columns[7].hidden = false;
86 } 86 }
87 break; 87 break;
88 } 88 }
@@ -143,7 +143,6 @@ var g = new common.grid({ @@ -143,7 +143,6 @@ var g = new common.grid({
143 } 143 }
144 }, 144 },
145 {display: "优惠券说明", name: "explains"}, 145 {display: "优惠券说明", name: "explains"},
146 - {display: "申请人", name: "proposer"},  
147 { 146 {
148 display: "驳回理由", hidden: true, name: "rejectReason", render: function (item) { 147 display: "驳回理由", hidden: true, name: "rejectReason", render: function (item) {
149 return "<p style='color: red'>" + item.rejectReason + "</p>" 148 return "<p style='color: red'>" + item.rejectReason + "</p>"
@@ -236,6 +235,9 @@ var Bll = { @@ -236,6 +235,9 @@ var Bll = {
236 for (var i = 0; i < array.length; i++) { 235 for (var i = 0; i < array.length; i++) {
237 btns.push(buttons[array[i]]) 236 btns.push(buttons[array[i]])
238 } 237 }
  238 +
  239 + // 增加查看操作记录按钮
  240 + btns.push('<a class="btn btn-primary btn-xs operation-records" data-coupon-id="' + id + '">操作记录</a>');
239 return btns; 241 return btns;
240 } 242 }
241 }; 243 };
@@ -358,4 +360,42 @@ $(document).on('click', '.coupon-info', function () { @@ -358,4 +360,42 @@ $(document).on('click', '.coupon-info', function () {
358 Bll.toastInfo(item1, '优惠券详情'); 360 Bll.toastInfo(item1, '优惠券详情');
359 }); 361 });
360 362
  363 +// 查看操作记录
  364 +$(document).on('click', '.operation-records', function() {
  365 + var couponId = $(this).data('coupon-id');
  366 + var option = {
  367 + title:'操作记录详情',
  368 + content:"<div class='historyDetail'>加载操作记录...</div>",
  369 + width:'70%',
  370 + button:[{value:"关闭", css:"btn-primary"}]
  371 + };
  372 + new common.dialog(option);
  373 +
  374 + getOperationRecords(couponId);
  375 +});
  376 +
  377 +function getOperationRecords(couponId) {
  378 + common.util.__ajax({
  379 + url: '/coupon/getOperationRecords',
  380 + data: {
  381 + couponsId: couponId
  382 + }
  383 + }, function(resp) {
  384 + if(resp.code == 200) {
  385 + var data = resp.data;
  386 + covertOperationRecord(data)
  387 + $('.historyDetail').html(common.util.__template2($('#operation-record-template').html(), {list: data}));
  388 + }
  389 + }, true);
  390 +}
361 391
  392 +// 转化操作类型,操作时间
  393 +function covertOperationRecord(data) {
  394 + var TYPE = {0: "新增", 1: "修改", 2: "作废"}
  395 + if(data && data.length > 0) {
  396 + $.each(data, function(index, item) {
  397 + item.operationType = TYPE[item.operationType];
  398 + item.createTime = Bll.getTime(item.createTime);
  399 + })
  400 + }
  401 +}