优化代码

This commit is contained in:
java110 2020-10-28 11:53:44 +08:00
parent 11130ca8c4
commit 01e86dd31e
6 changed files with 255 additions and 4 deletions

View File

@ -0,0 +1,62 @@
<div id="chooseLabelProductModel" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="chooseLabelProductModelLabel"
aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title" id="chooseLabelProductModelLabel">选择商品信息</h3>
<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">
<div class="col-lg-12">
<div class="ibox ">
<div class="row">
<div class="col-sm-7 m-b-xs">
</div>
<div class="col-sm-5">
<div class="input-group">
<input placeholder="输入商品信息名称" type="text"
v-model="chooseLabelProductInfo._currentProductName"
class="form-control form-control-sm">
<span class="input-group-append">
<button type="button" class="btn btn-sm btn-primary"
v-on:click="queryProducts()">查询</button>
</span>
</div>
</div>
</div>
<div class="table-responsive" style="margin-top:15px">
<table class="table table-striped">
<thead>
<tr>
<th class="text-center">商品ID</th>
<th class="text-center">商品大类</th>
<th class="text-center">商品名称</th>
<th class="text-right">操作</th>
</tr>
</thead>
<tbody>
<tr v-for="product in chooseLabelProductInfo.products">
<td class="text-center">{{product.productId}}</td>
<td class="text-center">{{product.categoryName}}</td>
<td class="text-center">{{product.prodName}}</td>
<td class="text-right">
<button class="btn btn-primary btn-xs"
v-on:click="chooseLabelProduct(product)">选择</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,66 @@
(function (vc) {
vc.extends({
propTypes: {
emitChooseProduct: vc.propTypes.string,
emitLoadData: vc.propTypes.string
},
data: {
chooseLabelProductInfo: {
products: [],
_currentProductName: '',
labelCd: ''
}
},
_initMethod: function () {
},
_initEvent: function () {
vc.on('chooseLabelProduct', 'openChooseProductModel', function (_param) {
$('#chooseLabelProductModel').modal('show');
vc.component._refreshChooseProductInfo();
$that.chooseLabelProductInfo.labelCd = _param.labelCd;
vc.component._loadAllProductInfo(1, 10, '');
});
},
methods: {
_loadAllProductInfo: function (_page, _row, _name) {
var param = {
params: {
page: _page,
row: _row,
labelCd: $that.chooseLabelProductInfo.labelCd,
hasProduct: 'N'
}
};
//发送get请求
vc.http.apiGet('/product/queryProductLabel',
param,
function (json) {
var _productInfo = JSON.parse(json);
vc.component.chooseLabelProductInfo.products = _productInfo.data;
}, function () {
console.log('请求失败处理');
}
);
},
chooseLabelProduct: function (_product) {
if (_product.hasOwnProperty('name')) {
_product.productName = _product.name;
}
vc.emit($props.emitChooseProduct, 'chooseLabelProduct', _product);
vc.emit($props.emitLoadData, 'listProductData', {
productId: _product.productId
});
$('#chooseLabelProductModel').modal('hide');
},
queryProducts: function () {
vc.component._loadAllProductInfo(1, 10, vc.component.chooseLabelProductInfo._currentProductName);
},
_refreshChooseProductInfo: function () {
vc.component.chooseLabelProductInfo._currentProductName = "";
vc.component.chooseLabelProductInfo.labelCd = "";
}
}
});
})(window.vc);

View File

@ -0,0 +1,19 @@
<div class="modal fade" id="deleteLabelProductModel" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">请确认您的操作!</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<tr align="center"><th>确定删除商品信息</th></tr>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal" v-on:click="closeDeleteLabelProductModel()">点错了</button>
<button type="button" class="btn btn-primary" v-on:click="deleteLabelProduct()">确认删除</button>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,52 @@
(function(vc,vm){
vc.extends({
data:{
deleteLabelProductInfo:{
}
},
_initMethod:function(){
},
_initEvent:function(){
vc.on('deleteLabelProduct','openDeleteLabelProductModal',function(_params){
vc.component.deleteLabelProductInfo = _params;
$('#deleteLabelProductModel').modal('show');
});
},
methods:{
deleteLabelProduct:function(){
vc.component.deleteLabelProductInfo.communityId=vc.getCurrentCommunity().communityId;
vc.http.apiPost(
'/product/deleteProductLabel',
JSON.stringify(vc.component.deleteLabelProductInfo),
{
emulateJSON:true
},
function(json,res){
//vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
let _json = JSON.parse(json);
if (_json.code == 0) {
//关闭model
$('#deleteLabelProductModel').modal('hide');
vc.emit('recommendGoodsManage', 'listProduct',{});
return ;
}
vc.toast(_json.msg);
},
function(errInfo,error){
console.log('请求失败处理');
vc.toast(errInfo);
});
},
closeDeleteLabelProductModel:function(){
$('#deleteLabelProductModel').modal('hide');
}
}
});
})(window.vc,window.vc.component);

View File

@ -43,6 +43,11 @@
<div class="ibox">
<div class="ibox-title">
<h5>推荐商品</h5>
<div class="ibox-tools" style="top:10px;">
<button type="button" class="btn btn-primary btn-sm" v-on:click="openChooseLabelProductModel()">
<i class="fa fa-search"></i> 选择商品
</button>
</div>
</div>
<div class="ibox-content">
@ -68,7 +73,7 @@
<th class="text-center">
<div class="btn-group">
<button class="btn-white btn btn-xs"
v-on:click="_openDeleteProductModel(product)">删除</button>
v-on:click="openDeleteLabelProductModel(product)">删除</button>
</div>
</th>
</tr>
@ -87,4 +92,7 @@
</div>
</div>
</div>
<vc:create path="goods/chooseLabelProduct" emitChooseProduct = "recommendGoodsManage" emitLoadData="recommendGoodsManage"></vc:create>
<vc:create path="goods/deleteLabelProduct" emitChooseProduct = "recommendGoodsManage" emitLoadData="recommendGoodsManage"></vc:create>
</div>

View File

@ -16,7 +16,8 @@
prodName: '',
productId: '',
barCode: '',
labelCd:'8800012001'
labelCd: '8800012001',
hasProduct:'Y'
}
}
},
@ -25,6 +26,11 @@
},
_initEvent: function () {
vc.on('recommendGoodsManage', 'chooseLabelProduct', function (_param) {
$that._saveProductLabel(_param);
});
vc.on('recommendGoodsManage', 'listProduct', function (_param) {
$that.recommendGoodsManageInfo.componentShow = 'recommendGoodsManage';
vc.component._listProducts(DEFAULT_PAGE, DEFAULT_ROWS);
@ -59,6 +65,38 @@
}
);
},
_saveProductLabel: function (_product) {
let _date = {
productId: _product.productId,
storeId: _product.storeId,
labelCd: '8800012001'
};
vc.http.apiPost(
'/product/saveProductLabel',
JSON.stringify(_date),
{
emulateJSON: true
},
function (json, res) {
//vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
let _json = JSON.parse(json);
if (_json.code == 0) {
//关闭model
vc.emit('recommendGoodsManage', 'listProduct', {});
return;
}
vc.message(_json.msg);
},
function (errInfo, error) {
console.log('请求失败处理');
vc.message(errInfo);
});
},
_queryProductMethod: function () {
vc.component._listProducts(DEFAULT_PAGE, DEFAULT_ROWS);
@ -69,9 +107,15 @@
} else {
vc.component.recommendGoodsManageInfo.moreCondition = true;
}
},
openChooseLabelProductModel: function () {
vc.emit('chooseLabelProduct', 'openChooseProductModel', {
labelCd: '8800012001'
});
},
openDeleteLabelProductModel: function (_product) {
vc.emit('deleteLabelProduct','openDeleteLabelProductModal', _product);
}
}
});
})(window.vc);