Authored by yyq

Merge branch 'feature/returnOpt' into release/5.7

@@ -533,7 +533,7 @@ const getOrderExchange = (orderCode, uid) => { @@ -533,7 +533,7 @@ const getOrderExchange = (orderCode, uid) => {
533 skc: value.product_skc, 533 skc: value.product_skc,
534 sku: value.product_sku, 534 sku: value.product_sku,
535 goods_type_id: value.goods_type_id, 535 goods_type_id: value.goods_type_id,
536 - reason: returnReason 536 + reason: _.cloneDeep(returnReason)
537 }; 537 };
538 538
539 // tar note 为每个特殊商品都添加标识 539 // tar note 为每个特殊商品都添加标识
@@ -544,13 +544,13 @@ const getOrderExchange = (orderCode, uid) => { @@ -544,13 +544,13 @@ const getOrderExchange = (orderCode, uid) => {
544 remark2: remarks[1] || '' 544 remark2: remarks[1] || ''
545 }; 545 };
546 546
547 - // tar note 对数组做处理,为不显示的添加 inactive  
548 - if (result.data.special_exchange_reason) {  
549 - let spReason = result.data.special_exchange_reason; 547 + let spReason = _.get(result, 'data.special_exchange_reason', []);
550 548
551 - _.forEach(item.reason, (subVal, subKey) => { // eslint-disable-line  
552 - if (_.indexOf(spReason, subKey)) {  
553 - _.set(item, `reason[${subKey}].inactive`, true); 549 + // tar note 对数组做处理,为不显示的添加 inactive
  550 + if (spReason && spReason.length) {
  551 + _.forEach(item.reason, subVal => { // eslint-disable-line
  552 + if (!_.filter(spReason, ['id', subVal.id]).length) {
  553 + subVal.inactive = true;
554 } 554 }
555 }); 555 });
556 } 556 }
@@ -79,7 +79,7 @@ @@ -79,7 +79,7 @@
79 </p> 79 </p>
80 <p> 80 <p>
81 尺码要换成: 81 尺码要换成:
82 - <select class="exchange-size" {{#if isLimitSkn}}disabled{{/if}}> 82 + <select class="exchange-size" data-sku="{{sku}}" {{#if isLimitSkn}}disabled{{/if}}>
83 <option value="0">请选择尺码</option> 83 <option value="0">请选择尺码</option>
84 </select> 84 </select>
85 </p> 85 </p>
@@ -4,7 +4,8 @@ @@ -4,7 +4,8 @@
4 * @date: 2016/2/29 4 * @date: 2016/2/29
5 */ 5 */
6 var $ = require('yoho-jquery'), 6 var $ = require('yoho-jquery'),
7 - Addr = require('./common-address'); 7 + Addr = require('./common-address'),
  8 + _dialog = require('../common/dialog');
8 9
9 var $goodsTable = $('#goods-table'), 10 var $goodsTable = $('#goods-table'),
10 $checkBox = $goodsTable.find('input[type="checkbox"]'), 11 $checkBox = $goodsTable.find('input[type="checkbox"]'),
@@ -54,7 +55,8 @@ var option = { @@ -54,7 +55,8 @@ var option = {
54 55
55 var refundConfirm = {}; 56 var refundConfirm = {};
56 57
57 -var Dialog = require('../common/dialog').Dialog; 58 +var Dialog = _dialog.Dialog,
  59 + Confirm = _dialog.Confirm;
58 60
59 var resetImg = function($p) { 61 var resetImg = function($p) {
60 $p.removeClass('selected'); 62 $p.removeClass('selected');
@@ -113,6 +115,42 @@ function setBackInput(type) { @@ -113,6 +115,42 @@ function setBackInput(type) {
113 } 115 }
114 } 116 }
115 117
  118 +function formatExchangeOption($dom, type) {
  119 + var sku = $dom.data('sku');
  120 + var $optItem;
  121 + var cd;
  122 +
  123 + if (!$dom || !sku) {
  124 + return;
  125 + }
  126 +
  127 + $dom.children().each(function() {
  128 + if (+sku === +$(this).attr('value')) {
  129 + $optItem = $(this);
  130 + }
  131 + });
  132 +
  133 + if (!$optItem) {
  134 + return;
  135 + }
  136 +
  137 + type = type * 1;
  138 + if (!type || type === 4 || type === 6 || type === 8) {
  139 + $optItem.removeAttr('disabled');
  140 + } else {
  141 + if (+$dom.val() === +sku) {
  142 + $dom.val(0);
  143 + cd = new Confirm({
  144 + content: '无理由换货不可选择换为相同颜色尺码',
  145 + cb: function() {
  146 + cd.close();
  147 + }
  148 + }).show();
  149 + }
  150 + $optItem.attr('disabled', 'disabled');
  151 + }
  152 +}
  153 +
116 if ($refundInfo.length) { 154 if ($refundInfo.length) {
117 pageType = 1; 155 pageType = 1;
118 156
@@ -150,6 +188,8 @@ $reasons.change(function() { @@ -150,6 +188,8 @@ $reasons.change(function() {
150 } else { 188 } else {
151 $par.next().hide(); 189 $par.next().hide();
152 } 190 }
  191 +
  192 + formatExchangeOption($par.find('.exchange-size'), type);
153 }); 193 });
154 194
155 // 切换支行银行信息 195 // 切换支行银行信息
@@ -181,6 +221,7 @@ $checkBox.change(function() { @@ -181,6 +221,7 @@ $checkBox.change(function() {
181 221
182 $goodsTable.on('change', '.exchange-color', function() { 222 $goodsTable.on('change', '.exchange-color', function() {
183 var $warp = $(this).closest('.exchange-choose-wrap'), 223 var $warp = $(this).closest('.exchange-choose-wrap'),
  224 + $warpSize = $warp.find('.exchange-size'),
184 _html = '<option value="0">请选择尺码</option>', 225 _html = '<option value="0">请选择尺码</option>',
185 id = $(this).val(); 226 id = $(this).val();
186 227
@@ -189,7 +230,9 @@ $goodsTable.on('change', '.exchange-color', function() { @@ -189,7 +230,9 @@ $goodsTable.on('change', '.exchange-color', function() {
189 _html += '<option value="' + v.id + '">' + v.name + '</option>'; 230 _html += '<option value="' + v.id + '">' + v.name + '</option>';
190 }); 231 });
191 } 232 }
192 - $warp.find('.exchange-size').html(_html).val(0); 233 + $warpSize.html(_html).val(0);
  234 +
  235 + formatExchangeOption($warpSize, $warp.find('.return-reason').val());
193 }); 236 });
194 237
195 $goodsTable.on('click', '.btn-del', function(e) { 238 $goodsTable.on('click', '.btn-del', function(e) {
@@ -277,6 +320,14 @@ $refundType.change(function() { @@ -277,6 +320,14 @@ $refundType.change(function() {
277 setBackInput(type); 320 setBackInput(type);
278 }); 321 });
279 322
  323 +$('#bank-card').keyup(function() {
  324 + var $this = $(this),
  325 + v = $this.val();
  326 +
  327 + /(\S{5}|\D)/.test(v) && $this.val($.trim(v.replace(/\D/g, '').replace(/(.{4})/g, '$1 ')));
  328 +});
  329 +
  330 +
280 // 打包退换货商品信息 331 // 打包退换货商品信息
281 function packGoogsList() { 332 function packGoogsList() {
282 var goods = [], 333 var goods = [],
@@ -381,7 +432,7 @@ function packRefundInfo(returnMode) { @@ -381,7 +432,7 @@ function packRefundInfo(returnMode) {
381 verifyTip = '请填写收款人姓名'; 432 verifyTip = '请填写收款人姓名';
382 } 433 }
383 434
384 - res.payment.bank_card = $.trim($refundInfo.find('input[name="bank-card"]').val()); 435 + res.payment.bank_card = $refundInfo.find('input[name="bank-card"]').val().replace(/\s/g, '');
385 if (!verifyTip && !res.payment.bank_card) { 436 if (!verifyTip && !res.payment.bank_card) {
386 verifyTip = '请填写收款账户'; 437 verifyTip = '请填写收款账户';
387 } 438 }