优化代码

This commit is contained in:
java110 2020-11-17 10:17:22 +08:00
parent 9b989573a3
commit 081b25aa23
3 changed files with 152 additions and 58 deletions

View File

@ -5,7 +5,6 @@
<div class="ibox-title">
<h5>查询条件</h5>
<div class="ibox-tools" style="top:10px;">
</div>
</div>
<div class="ibox-content">
@ -43,8 +42,6 @@
</button>
</div>
</div>
</div>
</div>
</div>
@ -86,6 +83,9 @@
<td class="text-center">{{order.createTime}}</td>
<td class="text-right">
<div class="btn-group">
<button class="btn-white btn btn-xs"
v-on:click="_openSendOrderCartModel(order)">发货
</button>
<button class="btn-white btn btn-xs"
v-on:click="_openOrderDetailModel(order)">订单详情
</button>
@ -107,5 +107,35 @@
</div>
</div>
</div>
<div id="storeOrderCartModal" class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">发货确认</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="row" >
<label class="col-sm-3 col-form-label">收货人:</label>
<label class="col-sm-8 col-form-label">{{storeOrderCartManageInfo.address.username}}</label>
</div>
<div class="row">
<label class="col-sm-3 col-form-label" >收货时间:</label>
<label class="col-sm-8 col-form-label">{{storeOrderCartManageInfo.address.tel}}</label>
</div>
<div class="row" >
<label class="col-sm-3 col-form-label">收货地点:</label>
<label class="col-sm-8 col-form-label">{{storeOrderCartManageInfo.address.address}}</label>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" @click="_closeStoreOrderCartModal()">关闭</button>
<button type="button" class="btn btn-primary" @click="_sendOrderCart()">确定发货</button>
</div>
</div>
</div>
</div>
</div>

View File

@ -1,74 +1,138 @@
//订单查询
(function(vc){
(function (vc) {
var DEFAULT_PAGE = 1;
var DEFAULT_ROWS = 10;
vc.extends({
data:{
storeOrderCartManageInfo:{
orderCarts:[],
total:0,
records:1,
orderDetail:false,
conditions:{
cartId:'',
state:'',
prodName:''
}
data: {
storeOrderCartManageInfo: {
orderCarts: [],
total: 0,
records: 1,
orderDetail: false,
conditions: {
cartId: '',
state: '',
prodName: ''
},
address: {
username: '',
tel: '',
address: ''
},
curOrderCart: {}
}
},
_initMethod:function(){
_initMethod: function () {
vc.component._listOrders(DEFAULT_PAGE, DEFAULT_ROWS);
},
_initEvent:function(){
vc.on('storeOrderCartManage','goBack',function(_param){
_initEvent: function () {
vc.on('storeOrderCartManage', 'goBack', function (_param) {
vc.component.storeOrderCartManageInfo.orderDetail = false;
});
vc.on('pagination','page_event',function(_currentPage){
vc.component._listOrders(_currentPage,DEFAULT_ROWS);
vc.on('storeOrderCartManage', 'list', function () {
vc.component._listOrders(DEFAULT_PAGE,DEFAULT_ROWS);
});
vc.on('pagination', 'page_event', function (_currentPage) {
vc.component._listOrders(_currentPage, DEFAULT_ROWS);
});
},
methods:{
_listOrders:function(_page, _rows){
methods: {
_listOrders: function (_page, _rows) {
vc.component.storeOrderCartManageInfo.conditions.page = _page;
vc.component.storeOrderCartManageInfo.conditions.row = _rows;
var param = {
params:vc.component.storeOrderCartManageInfo.conditions
};
//发送get请求
vc.http.apiGet('/storeOrder/queryStoreOrderCart',
param,
function(json,res){
var _storeOrderCartManageInfo=JSON.parse(json);
vc.component.storeOrderCartManageInfo.total = _storeOrderCartManageInfo.total;
vc.component.storeOrderCartManageInfo.records = _storeOrderCartManageInfo.records;
$that.storeOrderCartManageInfo.orderCarts = _storeOrderCartManageInfo.data;
params: vc.component.storeOrderCartManageInfo.conditions
};
//发送get请求
vc.http.apiGet('/storeOrder/queryStoreOrderCart',
param,
function (json, res) {
var _storeOrderCartManageInfo = JSON.parse(json);
vc.component.storeOrderCartManageInfo.total = _storeOrderCartManageInfo.total;
vc.component.storeOrderCartManageInfo.records = _storeOrderCartManageInfo.records;
$that.storeOrderCartManageInfo.orderCarts = _storeOrderCartManageInfo.data;
let _orderCarts = $that.storeOrderCartManageInfo.orderCarts;
let _orderCarts = $that.storeOrderCartManageInfo.orderCarts;
_orderCarts.forEach(item => {
let _productSpecDetails = item.productSpecDetails;
let _specValue = '';
_productSpecDetails.forEach(detail => {
_specValue += (detail.detailValue+"/");
});
_orderCarts.forEach(item => {
let _productSpecDetails = item.productSpecDetails;
let _specValue = '';
_productSpecDetails.forEach(detail => {
_specValue += (detail.detailValue + "/");
});
item.specValue = _specValue;
});
item.specValue = _specValue;
});
vc.emit('pagination','init',{
total:vc.component.storeOrderCartManageInfo.records,
currentPage:_page
});
},function(errInfo,error){
console.log('请求失败处理');
}
);
vc.emit('pagination', 'init', {
total: vc.component.storeOrderCartManageInfo.records,
currentPage: _page
});
}, function (errInfo, error) {
console.log('请求失败处理');
}
);
},
_queryOrdersMethod:function(){
_queryOrdersMethod: function () {
vc.component._listOrders(DEFAULT_PAGE, DEFAULT_ROWS);
},
_openOrderDetailModel:function(_order){
vc.jumpToPage('/admin.html#/pages/goods/storeOrderCartDetail?orderId='+_order.orderId+'&cartId='+_order.cartId);
_openOrderDetailModel: function (_order) {
vc.jumpToPage('/admin.html#/pages/goods/storeOrderCartDetail?orderId=' + _order.orderId + '&cartId=' + _order.cartId);
},
_openSendOrderCartModel: function (_order) { //发货方法
$that.storeOrderCartManageInfo.curOrderCart = _order;
$that.clearAddress();
$("#storeOrderCartModal").modal('show');
var param = {
params: {
page: 1,
row: 1,
orderId: _order.orderId
}
};
//发送get请求
vc.http.apiGet('/storeOrder/queryStoreOrderAddress',
param,
function (json, res) {
var _storeOrderAddress = JSON.parse(json);
vc.copyObject(_storeOrderAddress.data[0], $that.storeOrderCartManageInfo.address);
}, function (errInfo, error) {
console.log('请求失败处理');
}
);
},
clearAddress: function () {
$that.storeOrderCartManageInfo.address = {
username: '',
tel: '',
address: ''
}
},
_closeStoreOrderCartModal: function () {
$("#storeOrderCartModal").modal('hide');
},
_sendOrderCart: function () {
//发送get请求
vc.http.apiPost('/storeOrder/sendStoreOrderCart',
JSON.stringify($that.storeOrderCartManageInfo.curOrderCart),
{
emulateJSON: true
},
function (json, res) {
let sendResult = JSON.parse(json);
if (sendResult.code == 0) {
$that._closeStoreOrderCartModal();
vc.emit('storeOrderCartManage', 'list',{});
vc.toast('发货成功');
return;
}
vc.toast(sendResult.msg);
return;
}, function (errInfo, error) {
console.log('请求失败处理');
}
);
}
}
});

View File

@ -130,16 +130,16 @@
<table class="table table-stripped">
<thead>
<tr>
<th scope="col">序号</th>
<th scope="col">操作时间</th>
<th scope="col">说明</th>
<th scope="col" class="text-center">序号</th>
<th scope="col" class="text-center">操作时间</th>
<th scope="col" class="text-center">说明</th>
</tr>
</thead>
<tbody>
<tr v-for="(item,index) in storeOrderCartDetailInfo.events">
<th scope="row">{{index+1}}</th>
<td width="80px">{{item.createTime}}</td>
<td>{{item.eventMsg}}</td>
<th scope="row" width="10%" class="text-center">{{index+1}}</th>
<td width="30%" class="text-center">{{item.createTime}}</td>
<td width="60%" class="text-center">{{item.eventMsg}}</td>
</tr>
</tbody>
</table>