onBatchRemove: function(data){ var that = this, selecteds = this.selecteds, datas = []; if(!selecteds.length) { showMessage('请选择商品'); return false; } ConfirmBox.confirm('确定要删除所选商品吗?', '提示:', function(){ for(var i = 0; i < selecteds.length; i++){ var item = selecteds[i]; datas.push(item.removeTrigger.data('pid')); } var pids = datas.join(','); self.ajax('/Item/DeleteItem', { SeletedIds: pids }, function(res){ // selids.val(pids); // that.batchRemove(); queryForm.submit(); // selids.val(''); }); }); }
form.on('click', '.j-remove', function(){ var $this = $(this), data = getItemData($this); ConfirmBox.confirm('确定要删除这个订单吗?', '提示:', function(){ ajax('/Order/OrderBatchDelete', {orderCodes: data.pid}, function(res){ if(res.Succeeded){ showMessage('删除成功', false, function(){ window.location.reload(); }); } }); }); });
form.on('click', '.j-cancel', function(){ var $this = $(this), data = getItemData($this); ConfirmBox.confirm('确定要取消这个订单吗?', '提示:', function(){ ajax('/Order/CancelSellerOrder', {orderCode: data.pid}, function(res){ if(res.Succeeded){ showMessage('取消成功', false, function(){ window.location.reload(); }); } }); }); });
onSingleRemove: function(data){ var that = this; ConfirmBox.confirm('确定要删除这个商品吗?', '提示:', function(){ var pid = data.removeTrigger.data('pid'); self.ajax('/Item/DeleteItem', { SeletedIds: pid }, function(res){ if(res.Succeeded){ // selids.val(pid); // that.itemRemove(data.timestamp); queryForm.submit(); // selids.val(''); } }); }); },
onBatchRemove: function(data) { var that = this, selecteds = this.selecteds, datas = []; if (!selecteds.length) { showMessage('请选择要删除的商品!', false); return false; } ConfirmBox.confirm('确定要删除所选商品吗?', '提示', function() { for (var i = 0; i < selecteds.length; i++) { var item = selecteds[i]; datas.push(item.parent.data('pid')); } var pids = datas.join(','); //待删除的商品id $.ajax({ url: '/ItemFollow/BatchDeleteItemFollow', data: { itemFollowIds: pids }, type: 'POST', dataType: 'json' }) .done(function(data) { if (data.Succeeded) { var count = $('.inner-count').text() - selecteds.length; $('.inner-count').text(count); that.batchRemove(); checkHasNull(that.items); showMessage('删除成功!', false); } else { showMessage('删除失败,请稍后再试!', false); } }) .fail(function() { showMessage('网络出错,请稍后再试!', false); }); }); }
onBatchRemove: function(data) { var that = this, selecteds = this.selecteds, datas = []; if (!selecteds.length) { showMessage('请选择要删除的订单', false); return false; } ConfirmBox.confirm('确定要删除所选订单吗?', '提示:', function() { for (var i = 0; i < selecteds.length; i++) { var item = selecteds[i]; datas.push(item.parent.data('pid')); } var pids = datas.join(','); $.ajax({ url: '/Order/OrderBatchDelete', type: 'POST', dataType: 'json', data: { orderCodes: pids }, success: function(data) { if (data.Succeeded) { that.batchRemove(); checkHasNull(that.items); showMessage('删除成功', false, function(){ window.location.reload(); }); } else { showMessage('删除失败,请稍后再试!', false); } }, error: function() { showMessage('网络出错,请稍后再试!', false); } }); }); }
.done(function(data) { loading.hide(); if (data.Succeeded) { if (data.Result.Status == 1) { showMessage('订单付款成功!', false); $('input[name="Status"]').val('1'); setTimeout(function() { form.submit(); }, 2000); } else { var onConfirm = function() { window.location.href = '/Wallet?amount=' + data.Result.RechargeAmount; }; var onCancel = function() { return false; }; ConfirmBox.confirm(('账户余额不足,订单还需支付' + data.Result.RechargeAmount + '元!'), '支付确认', onConfirm, onCancel); } } else { // showMessage('付款失败,请稍后再试!', true); showMessage(data.Message, true); } })
self.ajax('/Item/GetInventoryWarnResult', {Id: pid}, function(res){ var result = res.Result; ConfirmBox.confirm(compileProContent(result), '库存管理:', null, { width: 800, confirmTpl: false, cancelTpl: false, onShow: function(){ var $dialog = this.element, $suggest = $('#J_suggest'), $avgunit = $('#J_avgunit'); $dialog.addClass('pro-dialog'); validItems('.declarePrice', $dialog); // 库存启用 $dialog.on('change', '.checkbox-se', function(){ var sendData = { ProductList: [], Id: pid, OperateType: result.OperateType }; // 获取数据 $dialog.find('.pro-props').each(function(){ var $this = $(this); $table = $this.find('.ui-table'); var productCode = $this.data('code'), itemId = $this.data('itemid'), declarePrice = $this.find('.declarePrice').val(); inventoryList = []; if(!$table.find('.null')[0]){ // 获取InventoryList $table.find('tbody tr').each(function(){ var $checkbox = $(this).find('.ui-checkbox'); if($checkbox.is(':checked')){ inventoryList.push({ Id: $(this).data('id'), ProductCode: productCode, Status: true }); } }); } sendData.ProductList.push({ InventoryList: inventoryList, ItemId: itemId, ProductCode: productCode, DeclaredPrice: declarePrice ? declarePrice : 0 }); }); console.log(sendData); $.ajax({ url:'/Item/GetItemInventoryAvgUnitPrice', type: 'POST', data: sendData, success: function(data){ if(data.Succeeded){ var result = data.Result; $suggest.text(result.SuggestPrice); $avgunit.text(result.AvgUnitPrice); }else{ $suggest.text(0); $avgunit.text(0); } }, error: function(){ console.log(arguments); } }); }); }, onConfirm: function(){ var that = this; var valided = true, $changedPrice = $('#changedPrice'), cpval = $changedPrice.val(), sendData = { ProductList: [], Id: pid, OperateType: result.OperateType, Price: result.Price }; if(!flagPrice(cpval)){ valided = false; $changedPrice.addClass('failed'); return false; }else{ sendData.Price = cpval; } // 获取数据 this.element.find('.pro-props').each(function(){ var $this = $(this), $declarePrice = $(this).find('.declarePrice'), dpval = $declarePrice.val(); if(!flagPrice(dpval)){ valided = false; $declarePrice.addClass('failed'); return false; }else{ var $table = $this.find('.ui-table'); var productCode = $this.data('code'), itemId = $this.data('itemid'), inventoryList = []; if(!$table.find('.null')[0] && result.InventoryType !== 0){ // 获取InventoryList $table.find('tbody tr').each(function(){ var $checkbox = $(this).find('.ui-checkbox'); inventoryList.push({ Id: $(this).data('id'), ProductCode: productCode, Status: $checkbox.is(':checked') }); }); } sendData.ProductList.push({ InventoryList: inventoryList, DeclaredPrice: dpval, ItemId: itemId, ProductCode: productCode }); } }); if(valided){ // debugger self.ajax('/Item/UpdateItemInventoryWarn', sendData, function(res){ // console.log(res); if(res.Succeeded){ that.hide(); showMessage2Reload('修改成功'); }else{ showMessage(res.Message); } }); }else{ console.log('信息有误,请更正后再提交'); } } }); });
}, function(res){ // console.log(res) if(res.length){ var itemGroups = res, i = 0, l = itemGroups.length, datas = [], tpl; for(; i < l; i++){ var item = itemGroups[i]; var isChecked = item.IsInGroup, id = item.Id; if(isChecked){ groupItems.push(id); } datas.push({ id: id, image: item.Images.split(',')[0], checked: isChecked, name: item.Name, link: '' }); } tpl = templatable.compile(self.tpl.operaGroup, {items: datas}); ConfirmBox.confirm(tpl, '商品关联:',null, { width: 562, onShow: function(){ this.element.addClass('relation-dialog'); var operaGroupList = $('.opera-group-list'); // 选商品 $('.opera-group-list').delegate('li.opera-group-item', 'click', function(){ var $this = $(this), $thisId = $this.data('pid'), idx = groupItems.indexOf($thisId); $this.toggleClass('checked'); if($this.hasClass('checked')){ if(idx === -1){ groupItems.push($thisId); } }else{ groupItems.splice(idx, 1); } // console.log(groupItems) }); operaGroupList.find('.m-goods-name a').on('click', function(e){e.stopPropagation()}); }, onConfirm: function(){ var that = this; self.ajax('/Item/AddItemGroups', { Id: pid, ItemGroupIds: groupItems.join(',') }, function(res){ if(res.Succeeded){ that.hide(); showMessage('操作成功'); }else{ showMessage('操作失败'); } }); } }); }else{ showMessage('无关联的商品'); } });