mirror of
https://gitee.com/java110/MicroCommunityWeb.git
synced 2026-02-25 14:17:54 +08:00
优化代码
This commit is contained in:
parent
0d3f08c80c
commit
9009db741a
@ -126,8 +126,8 @@
|
||||
<div class="col-sm-5">
|
||||
<select class="custom-select" v-model="addGroupBuyProductInfo.state">
|
||||
<option selected disabled value="">选填,请选择状态</option>
|
||||
<option value="1001">关闭</option>
|
||||
<option value="2002">开启</option>
|
||||
<option value="1001">开启</option>
|
||||
<option value="2002">关闭</option>
|
||||
</select>
|
||||
</div>
|
||||
<label class="col-sm-1 col-form-label text-right">拼团人数</label>
|
||||
|
||||
@ -0,0 +1,153 @@
|
||||
<div>
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="ibox">
|
||||
<div class="ibox-title">
|
||||
<h5>拼团信息</h5>
|
||||
<div class="ibox-tools" style="top:10px;">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="ibox-content">
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-1 col-form-label text-right">商品</label>
|
||||
<div class="col-sm-11">
|
||||
<input v-model="editGroupBuyProductInfo.prodName" disabled="disabled" type="text" placeholder="必填,请填写商品名称"
|
||||
class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-1 col-form-label text-right">拼团名称</label>
|
||||
<div class="col-sm-5">
|
||||
<input v-model="editGroupBuyProductInfo.groupProdName" type="text" placeholder="必填,请填写拼团名称"
|
||||
class="form-control">
|
||||
</div>
|
||||
<label class="col-sm-1 col-form-label text-right">拼团排序</label>
|
||||
<div class="col-sm-5">
|
||||
<input v-model="editGroupBuyProductInfo.sort" type="text" placeholder="必填,请填写拼团排序"
|
||||
class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-1 col-form-label text-right">拼团简介</label>
|
||||
<div class="col-sm-11">
|
||||
<textarea v-model="editGroupBuyProductInfo.groupProdDesc" placeholder="必填,请填写拼团简介" maxlength="250"
|
||||
class="form-control"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="ibox">
|
||||
<div class="ibox-title">
|
||||
<h5>商品规格</h5>
|
||||
<div class="ibox-tools" style="top:10px;">
|
||||
</div>
|
||||
</div>
|
||||
<div class="ibox-content">
|
||||
<table class="footable table table-stripped toggle-arrow-tiny" data-page-size="15">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-center">规格名称</th>
|
||||
<th class="text-center">规格值</th>
|
||||
<th class="text-center">库存</th>
|
||||
<th class="text-center">销量</th>
|
||||
<th class="text-center">金额</th>
|
||||
<th class="text-center">成本价</th>
|
||||
<th class="text-center">拼团价</th>
|
||||
<th class="text-center">拼团库存</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="productSpec in editGroupBuyProductInfo.productSpecs">
|
||||
<td class="text-center">{{productSpec.specName}}</td>
|
||||
<td class="text-center">
|
||||
<span v-html="productSpec.specValue"></span>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
{{productSpec.stock}}
|
||||
</td>
|
||||
<td class="text-center">
|
||||
{{productSpec.sales}}
|
||||
</td>
|
||||
<td class="text-center">
|
||||
{{productSpec.price}}
|
||||
</td>
|
||||
<td class="text-center">
|
||||
{{productSpec.costPrice}}
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<input class="form-control" v-model="productSpec.groupPrice" type="number" />
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<input class="form-control" v-model="productSpec.groupStock" type="number" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="7">
|
||||
<ul class="pagination float-right"></ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="ibox">
|
||||
<div class="ibox-title">
|
||||
<h5>商品扩展</h5>
|
||||
<div class="ibox-tools" style="top:10px;">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="ibox-content">
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-1 col-form-label text-right">活动状态</label>
|
||||
<div class="col-sm-5">
|
||||
<select class="custom-select" v-model="editGroupBuyProductInfo.state">
|
||||
<option selected disabled value="">选填,请选择状态</option>
|
||||
<option value="1001">开启</option>
|
||||
<option value="2002">关闭</option>
|
||||
</select>
|
||||
</div>
|
||||
<label class="col-sm-1 col-form-label text-right">拼团人数</label>
|
||||
<div class="col-sm-5">
|
||||
<input v-model="editGroupBuyProductInfo.userCount" type="text" placeholder="必填,请填写拼团人数"
|
||||
class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-1 col-form-label text-right">商品详情</label>
|
||||
<div class="col-sm-11 ">
|
||||
<div class=" no-padding">
|
||||
<div class="editSummernote"></div>
|
||||
</div>
|
||||
<!--<textarea v-model="addNoticeViewInfo.context" cols="3" type="text" placeholder="必填,请填写公告内容" class="form-control"></textarea>-->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ibox-content">
|
||||
<button class="btn btn-primary float-right" type="button" v-on:click="saveProductInfo()"><i
|
||||
class="fa fa-check"></i> 保存</button>
|
||||
<button type="button" class="btn btn-warning float-right" style="margin-right:20px;"
|
||||
v-on:click="_closeAddProduct()">取消</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<vc:create path="goods/chooseProduct" emitChooseProduct="editGroupBuyProduct" emitLoadData=""></vc:create>
|
||||
</div>
|
||||
@ -0,0 +1,266 @@
|
||||
(function (vc) {
|
||||
|
||||
vc.extends({
|
||||
propTypes: {
|
||||
callBackListener: vc.propTypes.string, //父组件名称
|
||||
callBackFunction: vc.propTypes.string //父组件监听方法
|
||||
},
|
||||
data: {
|
||||
editGroupBuyProductInfo: {
|
||||
productId: '',
|
||||
groupProdName: '',
|
||||
prodName: '',
|
||||
groupProdDesc: '',
|
||||
sort: '',
|
||||
content: '',
|
||||
state: '',
|
||||
userCount: '3',
|
||||
productSpecs: []
|
||||
}
|
||||
},
|
||||
_initMethod: function () {
|
||||
|
||||
$that._initEditGroupBuyProduct();
|
||||
},
|
||||
_initEvent: function () {
|
||||
vc.on('editGroupBuyProduct', 'openEditProductModal', function (_product) {
|
||||
//加载数据
|
||||
|
||||
vc.copyObject(_product,$that.editGroupBuyProductInfo);
|
||||
|
||||
$that._loadGroupProductInfo(_product);
|
||||
});
|
||||
vc.on('editGroupBuyProduct', 'chooseProduct', function (_product) {
|
||||
vc.copyObject(_product, $that.editGroupBuyProductInfo);
|
||||
$that.editGroupBuyProductInfo.groupProdDesc = _product.prodDesc;
|
||||
$that.editGroupBuyProductInfo.groupProdName = _product.prodName;
|
||||
$that._loadProductInfo(_product.productId);
|
||||
});
|
||||
vc.on("editGroupBuyProduct", "notifyUploadCoverImage", function (_param) {
|
||||
if (_param.length > 0) {
|
||||
vc.component.editGroupBuyProductInfo.coverPhoto = _param[0];
|
||||
} else {
|
||||
vc.component.editGroupBuyProductInfo.coverPhoto = '';
|
||||
}
|
||||
|
||||
});
|
||||
vc.on("editGroupBuyProduct", "notifyUploadCarouselFigureImage", function (_param) {
|
||||
vc.component.editGroupBuyProductInfo.carouselFigurePhoto = _param;
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
editGroupBuyProductValidate() {
|
||||
return vc.validate.validate({
|
||||
editGroupBuyProductInfo: vc.component.editGroupBuyProductInfo
|
||||
}, {
|
||||
|
||||
'editGroupBuyProductInfo.groupProdName': [
|
||||
{
|
||||
limit: "required",
|
||||
param: "",
|
||||
errInfo: "拼团名称不能为空"
|
||||
},
|
||||
{
|
||||
limit: "maxLength",
|
||||
param: "128",
|
||||
errInfo: "拼团名称不能超过128位"
|
||||
},
|
||||
],
|
||||
'editGroupBuyProductInfo.groupProdDesc': [
|
||||
{
|
||||
limit: "required",
|
||||
param: "",
|
||||
errInfo: "拼团简介不能为空"
|
||||
},
|
||||
{
|
||||
limit: "maxLength",
|
||||
param: "256",
|
||||
errInfo: "拼团简介不能超过256位"
|
||||
},
|
||||
],
|
||||
'editGroupBuyProductInfo.productId': [
|
||||
{
|
||||
limit: "required",
|
||||
param: "",
|
||||
errInfo: "商品不能为空"
|
||||
}
|
||||
],
|
||||
'editGroupBuyProductInfo.state': [
|
||||
{
|
||||
limit: "required",
|
||||
param: "",
|
||||
errInfo: "活动状态不能为空"
|
||||
}
|
||||
],
|
||||
'editGroupBuyProductInfo.sort': [
|
||||
{
|
||||
limit: "num",
|
||||
param: "",
|
||||
errInfo: "排序格式错误"
|
||||
},
|
||||
],
|
||||
'editGroupBuyProductInfo.userCount': [
|
||||
{
|
||||
limit: "required",
|
||||
param: "",
|
||||
errInfo: "拼团人数不能为空"
|
||||
},
|
||||
{
|
||||
limit: "num",
|
||||
param: "",
|
||||
errInfo: "拼团人数必须是数字"
|
||||
}
|
||||
]
|
||||
});
|
||||
},
|
||||
saveProductInfo: function () {
|
||||
if (!vc.component.editGroupBuyProductValidate()) {
|
||||
vc.toast(vc.validate.errInfo);
|
||||
return;
|
||||
}
|
||||
|
||||
vc.http.apiPost(
|
||||
'/groupBuy/saveGroupBuyProduct',
|
||||
JSON.stringify(vc.component.editGroupBuyProductInfo),
|
||||
{
|
||||
emulateJSON: true
|
||||
},
|
||||
function (json, res) {
|
||||
let _json = JSON.parse(json);
|
||||
if (_json.code == 0) {
|
||||
vc.component.clearAddProductInfo();
|
||||
vc.emit('groupBuyProductManage', 'listProduct', {});
|
||||
return;
|
||||
}
|
||||
vc.message(_json.msg);
|
||||
},
|
||||
function (errInfo, error) {
|
||||
console.log('请求失败处理');
|
||||
vc.message(errInfo);
|
||||
|
||||
});
|
||||
},
|
||||
clearAddProductInfo: function () {
|
||||
vc.component.editGroupBuyProductInfo = {
|
||||
productId: '',
|
||||
groupProdName: '',
|
||||
prodName: '',
|
||||
groupProdDesc: '',
|
||||
sort: '',
|
||||
content: '',
|
||||
state: '',
|
||||
userCount: '3',
|
||||
productSpecs: []
|
||||
};
|
||||
},
|
||||
_closeAddProduct: function () {
|
||||
$that.clearAddProductInfo();
|
||||
vc.emit('productManage', 'listProduct', {});
|
||||
},
|
||||
_initEditGroupBuyProduct: function () {
|
||||
let $summernote = $('.editSummernote').summernote({
|
||||
lang: 'zh-CN',
|
||||
height: 300,
|
||||
placeholder: '必填,请输入商品描述',
|
||||
callbacks: {
|
||||
onImageUpload: function (files, editor, $editable) {
|
||||
$that.sendFile($summernote, files);
|
||||
},
|
||||
onChange: function (contents, $editable) {
|
||||
$that.editGroupBuyProductInfo.content = contents;
|
||||
}
|
||||
},
|
||||
toolbar: [
|
||||
['style', ['style']],
|
||||
['font', ['bold', 'italic', 'underline', 'clear']],
|
||||
['fontname', ['fontname']],
|
||||
['color', ['color']],
|
||||
['para', ['ul', 'ol', 'paragraph']],
|
||||
['height', ['height']],
|
||||
['table', ['table']],
|
||||
['insert', ['link', 'picture']],
|
||||
['view', ['fullscreen', 'codeview']],
|
||||
['help', ['help']]
|
||||
],
|
||||
});
|
||||
},
|
||||
sendFile: function ($summernote, files) {
|
||||
console.log('上传图片', files);
|
||||
|
||||
var param = new FormData();
|
||||
param.append("uploadFile", files[0]);
|
||||
param.append('communityId', vc.getCurrentCommunity().communityId);
|
||||
|
||||
vc.http.upload(
|
||||
'addNoticeView',
|
||||
'uploadImage',
|
||||
param,
|
||||
{
|
||||
emulateJSON: true,
|
||||
//添加请求头
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
},
|
||||
function (json, res) {
|
||||
//vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
|
||||
if (res.status == 200) {
|
||||
var data = JSON.parse(json);
|
||||
//关闭model
|
||||
$summernote.summernote('insertImage', "/callComponent/download/getFile/file?fileId=" + data.fileId + "&communityId=" + vc.getCurrentCommunity().communityId);
|
||||
return;
|
||||
}
|
||||
vc.toast(json);
|
||||
},
|
||||
function (errInfo, error) {
|
||||
console.log('请求失败处理');
|
||||
vc.toast(errInfo);
|
||||
});
|
||||
|
||||
},
|
||||
_openChooseProductModal: function () {
|
||||
vc.emit('chooseProduct', 'openChooseProductModel', {});
|
||||
},
|
||||
_loadGroupProductInfo: function (_product) {
|
||||
var param = {
|
||||
params: {
|
||||
page: 1,
|
||||
row: 1,
|
||||
groupId: _product.groupId
|
||||
}
|
||||
};
|
||||
|
||||
//发送get请求
|
||||
vc.http.apiGet('/groupBuy/queryGroupBuyProduct',
|
||||
param,
|
||||
function (json) {
|
||||
let _productInfo = JSON.parse(json);
|
||||
let _product = _productInfo.data[0];
|
||||
|
||||
$that.editGroupBuyProductInfo.productSpecs = _product.productSpecValues;
|
||||
$that.editGroupBuyProductInfo.content = _product.content;
|
||||
$(".editSummernote").summernote('code', _product.content);
|
||||
|
||||
let _productSpecValues = _product.productSpecValues;
|
||||
|
||||
_productSpecValues.forEach(item => {
|
||||
let _productSpecDetails = item.productSpecDetails;
|
||||
let _specValue = '';
|
||||
_productSpecDetails.forEach(detail => {
|
||||
_specValue += (detail.detailValue + "/");
|
||||
});
|
||||
|
||||
item.specValue = _specValue;
|
||||
});
|
||||
|
||||
|
||||
}, function () {
|
||||
console.log('请求失败处理');
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
})(window.vc);
|
||||
@ -80,7 +80,7 @@
|
||||
<td class="text-center">{{product.stock}}</td>
|
||||
<td class="text-center">{{product.groupBuyCount}}</td>
|
||||
<td class="text-center">{{product.sort}}</td>
|
||||
<th class="text-center">{{product.stateName}}</th>
|
||||
<th class="text-center">{{product.state== '1001'?'开启':'关闭'}}</th>
|
||||
<td class="text-right">
|
||||
<div class="btn-group">
|
||||
<button class="btn-white btn btn-xs"
|
||||
@ -112,10 +112,9 @@
|
||||
<div v-bind:class="{no_display:groupBuyProductManageInfo.componentShow != 'addGroupBuyProduct'}">
|
||||
<vc:create path="goods/addGroupBuyProduct" callBackListener="" callBackFunction=""></vc:create>
|
||||
</div>
|
||||
<div v-bind:class="{no_display:groupBuyProductManageInfo.componentShow != 'editGroupProduct'}">
|
||||
<vc:create path="goods/editProduct"></vc:create>
|
||||
<div v-bind:class="{no_display:groupBuyProductManageInfo.componentShow != 'editGroupBuyProduct'}">
|
||||
<vc:create path="goods/editGroupBuyProduct" callBackListener="" callBackFunction=""></vc:create>
|
||||
</div>
|
||||
<vc:create path="goods/deleteProduct"></vc:create>
|
||||
<vc:create path="goods/chooseProductSpec" emitChooseProductSpec="addGroupBuyProduct" emitLoadData="addGroupBuyProduct"></vc:create>
|
||||
|
||||
</div>
|
||||
@ -64,8 +64,8 @@
|
||||
$that.groupBuyProductManageInfo.componentShow = 'addGroupBuyProduct';
|
||||
},
|
||||
_openEditProductModel: function (_product) {
|
||||
$that.groupBuyProductManageInfo.componentShow = 'editProduct';
|
||||
vc.emit('editProduct', 'openEditProductModal', _product);
|
||||
$that.groupBuyProductManageInfo.componentShow = 'editGroupBuyProduct';
|
||||
vc.emit('editGroupBuyProduct', 'openEditProductModal', _product);
|
||||
},
|
||||
_openDeleteProductModel: function (_product) {
|
||||
vc.emit('deleteProduct', 'openDeleteProductModal', _product);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user