801 行
39 KiB
HTML
可执行文件
801 行
39 KiB
HTML
可执行文件
<!--[1.8.50]-->
|
||
<style>
|
||
|
||
#promotionGoods .el-input.is-disabled .el-input__inner {
|
||
color: #606266;
|
||
cursor: not-allowed;
|
||
background-color: transparent;
|
||
border-color: transparent;
|
||
}
|
||
|
||
#promotionGoods .el-button--mini {
|
||
line-height: 32px;
|
||
}
|
||
|
||
#addForm .cell {
|
||
line-height: 20px;
|
||
font-size: 13px;
|
||
}
|
||
|
||
#addForm .el-table td, .el-table th {
|
||
padding: 5px 0;
|
||
}
|
||
|
||
.promotion-table .cell {
|
||
font-size: 13px;
|
||
}
|
||
|
||
.promotion-top {
|
||
display: flex;
|
||
align-items: center;
|
||
height: 40px;
|
||
}
|
||
|
||
#promotion-search .el-form-item {
|
||
margin-bottom: 0;
|
||
}
|
||
|
||
.promotion-search {
|
||
display: flex;
|
||
align-items: center;
|
||
flex-wrap: wrap;
|
||
margin-bottom: 10px;
|
||
}
|
||
|
||
.promotion-search > .el-input, .promotion-search > .el-select {
|
||
margin-right: 10px;
|
||
}
|
||
|
||
.promotion-tips {
|
||
color: #999;
|
||
font-size: 12px;
|
||
padding-left: 10px;
|
||
}
|
||
</style>
|
||
<div id="promotionGoods">
|
||
<el-form :inline="true" size="small">
|
||
<el-form-item>
|
||
<if condition="($authArr['addPromotion'] eq true) AND (empty($global_store_jurisdiction['store_goods_promotion']) eq true OR $global_store_jurisdiction['store_goods_promotion'] == 1)">
|
||
<el-button size="small"
|
||
type="primary"
|
||
@click="toShowGoods">新增促销商品
|
||
</el-button>
|
||
</if>
|
||
</el-form-item>
|
||
<el-form-item label="是否开启促销商品">
|
||
<el-switch @change="changePromotion"
|
||
:disabled="promotionDisabled"
|
||
v-model="promotion_status"
|
||
:active-value="1"
|
||
:inactive-value="0"
|
||
:active-text="promotion_status?'开':'关'">
|
||
</el-switch>
|
||
</el-form-item>
|
||
</el-form>
|
||
<div class="promotion-search">
|
||
<el-input size="small" style="width: 210px;" v-model="searchHostKeyword"
|
||
@keydown.enter.exact.native.prevent="searchPromotion"
|
||
placeholder="名称/货号/条码"></el-input>
|
||
<select-goods-category :user-type="2"
|
||
:store-id="store_id"
|
||
:category-id1.sync="goodsClassId1"
|
||
:category-id2.sync="goodsClassId2"
|
||
:category-id3.sync="goodsClassId3"></select-goods-category>
|
||
</div>
|
||
<el-collapse accordion>
|
||
<el-collapse-item>
|
||
<template slot="title">
|
||
<el-button plain size="small">更多搜索条件>></el-button>
|
||
</template>
|
||
<el-form label-width="120px" id="promotion-search">
|
||
<el-form-item label="价格区间">
|
||
<el-select size="small" clearable filterable
|
||
v-model="price_section" placeholder="选择价格区间">
|
||
<el-option value="-50" label="50以下"></el-option>
|
||
<el-option value="50-200" label="50 - 200"></el-option>
|
||
<el-option value="200-500" label="200 - 500"></el-option>
|
||
<el-option value="500-1000" label="500 - 1000"></el-option>
|
||
<el-option value="1000-" label="1000以上"></el-option>
|
||
</el-select>
|
||
</el-form-item>
|
||
<el-form-item label="状态">
|
||
<el-select size="small" clearable filterable
|
||
v-model="act_type" placeholder="选择状态">
|
||
<el-option value="1" label="未开始"></el-option>
|
||
<el-option value="2" label="进行中"></el-option>
|
||
<el-option value="3" label="已结束"></el-option>
|
||
</el-select>
|
||
<span class="promotion-tips">该条件与活动时间范围互斥</span>
|
||
</el-form-item>
|
||
<el-form-item label="活动时间范围">
|
||
<date-picker-range :date-time.sync="promotion_time"></date-picker-range>
|
||
|
||
<span class="promotion-tips">该条件与状态互斥</span>
|
||
</el-form-item>
|
||
</el-form>
|
||
</el-collapse-item>
|
||
</el-collapse>
|
||
<div class="promotion-top" style="margin: 10px 0;">
|
||
<el-button size="small" type="primary" @click="searchPromotion">搜索</el-button>
|
||
<span class="promotion-tips">按商品信息检索,不按规格信息检索</span>
|
||
</div>
|
||
<div class="promotion-table">
|
||
<el-table border :data="promotionList" size="small" :header-cell-style="{background:'#F5F7FA',color:'#606266'}">
|
||
<el-table-column align="center" type="index" label="序号" width="50"></el-table-column>
|
||
<el-table-column align="center" prop="goods_name" label="商品名称" show-overflow-tooltip></el-table-column>
|
||
<el-table-column align="center" prop="goods_number" label="商品货号" show-overflow-tooltip></el-table-column>
|
||
<el-table-column align="center" prop="goods_code" label="商品条码" min-width="120px"
|
||
show-overflow-tooltip></el-table-column>
|
||
<el-table-column align="center" prop="online_price" label="商城价"></el-table-column>
|
||
<el-table-column align="center" prop="act_price" label="促销价"></el-table-column>
|
||
<el-table-column align="center" prop="start_time" label="开始时间" min-width="120px"
|
||
show-overflow-tooltip></el-table-column>
|
||
<el-table-column align="center" prop="end_time" label="结束时间" min-width="120px"
|
||
show-overflow-tooltip></el-table-column>
|
||
<el-table-column align="center" prop="right" label="操作" width="90">
|
||
<template slot-scope="scope">
|
||
<el-button type="text" size="small" @click="toChange(scope.$index)">修改
|
||
</el-button>
|
||
<el-button type="text" size="small" @click="delPromotion(scope.row.id)">删除
|
||
</el-button>
|
||
</template>
|
||
</el-table-column>
|
||
</el-table>
|
||
<el-pagination
|
||
@size-change="handleSizeChange"
|
||
@current-change="handleCurrentChange"
|
||
:pager-count="5"
|
||
:page-sizes="[10,20,30,40,50,60,70,80,90,100]"
|
||
:page-size="10"
|
||
layout="total,sizes, prev, pager, next, jumper"
|
||
:total="currentLen">
|
||
</el-pagination>
|
||
</div>
|
||
<el-dialog title="添加商品" :append-to-body="true" :visible.sync="showAddBox"
|
||
:close-on-click-modal="false" :before-close="cancelAdd"
|
||
width="900px">
|
||
<el-form id="addForm" label-width="120px" :model="addForm" :rules="addRules" ref="addForm">
|
||
<el-form-item label="已选商品" prop="goods">
|
||
<el-table v-if="addForm.goods.length" size="small" border :data="addForm.goods"
|
||
:header-cell-style="{background:'#F5F7FA',color:'#606266'}">
|
||
<el-table-column align="center" prop="goods_name" label="商品名称"
|
||
show-overflow-tooltip></el-table-column>
|
||
<el-table-column align="center" prop="goods_number" label="货号"></el-table-column>
|
||
<el-table-column align="center" prop="goods_code" label="条码"></el-table-column>
|
||
<el-table-column align="center" prop="online_price" label="商城价"
|
||
show-overflow-tooltip></el-table-column>
|
||
<el-table-column align="center" prop="right" label="操作" width="90">
|
||
<template slot-scope="scope">
|
||
<el-button type="text" size="small" @click="delChooseGoods">移除</el-button>
|
||
</template>
|
||
</el-table-column>
|
||
</el-table>
|
||
<span style="color: #aaa;" v-else>未选择商品</span>
|
||
</el-form-item>
|
||
<el-form-item label="已选规格" prop="sku" v-show="addForm.goods.length&&addForm.goods[0].attribute_state==2">
|
||
<el-table v-if="addForm.sku.length" size="small" border :data="addForm.sku"
|
||
:header-cell-style="{background:'#F5F7FA',color:'#606266'}">
|
||
<el-table-column align="center" type="index" label="序号" width="50"></el-table-column>
|
||
<el-table-column align="center" prop="sku_name" label="规格名称"
|
||
show-overflow-tooltip></el-table-column>
|
||
<el-table-column align="center" prop="sku_goods_number" label="规格货号"
|
||
show-overflow-tooltip></el-table-column>
|
||
<el-table-column align="center" prop="sku_code" label="规格条码"
|
||
show-overflow-tooltip></el-table-column>
|
||
<el-table-column align="center" prop="online_price" label="商城价"
|
||
show-overflow-tooltip></el-table-column>
|
||
<el-table-column align="center" v-if="addForm.set_price_type==1" prop="act_price" label="促销价"
|
||
show-overflow-tooltip>
|
||
<template slot-scope="scope">
|
||
<div class="el-input el-input--small">
|
||
<input type="text" autocomplete="off" v-model="scope.row.act_price"
|
||
class="el-input__inner">
|
||
</div>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column align="center" prop="right" label="操作" width="90">
|
||
<template slot-scope="scope">
|
||
<el-button type="text" size="small" @click="delChooseSku(scope.$index)">移除</el-button>
|
||
</template>
|
||
</el-table-column>
|
||
</el-table>
|
||
<span style="color: #aaa;" v-else>未选择规格</span>
|
||
</el-form-item>
|
||
<el-form-item v-if="addForm.sku.length">
|
||
<el-radio v-model="addForm.set_price_type" :label="1">单独设置价格</el-radio>
|
||
<el-radio v-model="addForm.set_price_type" :label="2">统一设置价格</el-radio>
|
||
</el-form-item>
|
||
<el-form-item v-show="addForm.set_price_type==2" label="促销价" prop="act_price">
|
||
<el-input size="small" style="width: 210px" v-model="addForm.act_price"></el-input>
|
||
</el-form-item>
|
||
<el-form-item label="活动时间" prop="time">
|
||
<el-date-picker
|
||
size="small"
|
||
clearable filterable
|
||
v-model="addForm.time"
|
||
type="datetimerange"
|
||
format="yyyy-MM-dd HH:mm:ss"
|
||
value-format="yyyy-MM-dd HH:mm:ss"
|
||
range-separator="至"
|
||
start-placeholder="开始时间"
|
||
end-placeholder="结束时间">
|
||
</el-date-picker>
|
||
</el-form-item>
|
||
<!--选择商品-->
|
||
<el-divider v-if="!addForm.goods.length" content-position="left">选择商品</el-divider>
|
||
<template v-if="!addForm.goods.length">
|
||
<el-form-item label="商品分类">
|
||
<select-goods-category :user-type="2"
|
||
:store-id="store_id"
|
||
:category-id1.sync="addClassId1"
|
||
:category-id2.sync="addClassId2"
|
||
:category-id3.sync="addClassId3"></select-goods-category>
|
||
</el-form-item>
|
||
<el-form-item label="搜索">
|
||
<el-select size="small" clearable filterable
|
||
v-model="attribute_state" placeholder="选择商品类型">
|
||
<el-option value="1" label="非规格商品"></el-option>
|
||
<el-option value="2" label="规格商品"></el-option>
|
||
</el-select>
|
||
<el-input size="small"
|
||
style="width: 214px"
|
||
placeholder="货号/条码"
|
||
v-model="searchGoodsKey"></el-input>
|
||
<el-button type="primary" size="small" @click="searchGoods">搜索</el-button>
|
||
</el-form-item>
|
||
<el-form-item label="商品列表">
|
||
<el-table border size="small" :data="goodsList" style="width: 100%;"
|
||
:header-cell-style="{background:'#F5F7FA',color:'#606266'}">
|
||
<el-table-column align="center" type="index" width="50" label="序号"></el-table-column>
|
||
<el-table-column align="center" prop="goods_name" label="名称"
|
||
show-overflow-tooltip></el-table-column>
|
||
<el-table-column align="center" prop="goods_number" label="货号"
|
||
show-overflow-tooltip></el-table-column>
|
||
<el-table-column align="center" prop="goods_code" label="条码"
|
||
show-overflow-tooltip></el-table-column>
|
||
<el-table-column align="center" prop="online_price" label="商城价" min-width="80px"
|
||
show-overflow-tooltip></el-table-column>
|
||
<el-table-column align="center" prop="attribute_state" label="商品类型">
|
||
<template slot-scope="scope">
|
||
<span v-if="scope.row.attribute_state==2">规格商品</span>
|
||
<span v-else>非规格商品</span>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column align="center" prop="right" label="操作" width="90">
|
||
<template slot-scope="scope">
|
||
<el-button type="text" size="small" @click="chooseGoods(scope.$index)">选择</el-button>
|
||
</template>
|
||
</el-table-column>
|
||
</el-table>
|
||
<el-pagination
|
||
@size-change="goodsHandleSizeChange"
|
||
@current-change="goodsHandleCurrentChange"
|
||
:pager-count="5"
|
||
:page-sizes="[5,10,20,30,40,50,60,70,80,90,100]"
|
||
:page-size="5"
|
||
layout="total,sizes, prev, pager, next, jumper"
|
||
:total="goodsCurrentLen">
|
||
</el-pagination>
|
||
</el-form-item>
|
||
</template>
|
||
<template v-if="addForm.goods[0] && addForm.goods[0].attribute_state==2">
|
||
<!--选择规格-->
|
||
<el-divider content-position="left">选择规格</el-divider>
|
||
<el-form-item label="搜索">
|
||
<el-input size="small"
|
||
style="width: 214px"
|
||
placeholder="名称/货号/条码"
|
||
v-model="searchSkuKey"></el-input>
|
||
<el-button type="primary" size="small" @click="searchSku">搜索</el-button>
|
||
</el-form-item>
|
||
<el-form-item label="规格列表">
|
||
<el-table border :data="skuList" size="small" style="width: 100%;"
|
||
:header-cell-style="{background:'#F5F7FA',color:'#606266'}">
|
||
<el-table-column align="center" type="index" width="50" label="序号"></el-table-column>
|
||
<el-table-column align="center" prop="sku_name" label="规格名称"
|
||
show-overflow-tooltip></el-table-column>
|
||
<el-table-column align="center" prop="sku_goods_number" label="规格货号"
|
||
show-overflow-tooltip></el-table-column>
|
||
<el-table-column align="center" prop="sku_code" label="规格条码"
|
||
show-overflow-tooltip></el-table-column>
|
||
<el-table-column align="center" prop="online_price" label="商城价" min-width="80px"
|
||
show-overflow-tooltip></el-table-column>
|
||
<el-table-column align="center" prop="right" label="操作" width="90">
|
||
<template slot-scope="scope">
|
||
<el-button v-if="chooseSkuIds.indexOf(scope.row.id)==-1" type="text" size="small"
|
||
@click="chooseSku(scope.$index)">选择
|
||
</el-button>
|
||
<el-button v-else type="text" style="color: #999" size="small">已选</el-button>
|
||
</template>
|
||
</el-table-column>
|
||
</el-table>
|
||
<el-pagination
|
||
@size-change="skuHandleSizeChange"
|
||
@current-change="skuHandleCurrentChange"
|
||
:pager-count="5"
|
||
:page-sizes="[5,10,20,30,40,50,60,70,80,90,100]"
|
||
:page-size="5"
|
||
layout="total,sizes, prev, pager, next, jumper"
|
||
:total="skuCurrentLen">
|
||
</el-pagination>
|
||
</el-form-item>
|
||
</template>
|
||
</el-form>
|
||
<div slot="footer" class="dialog-footer">
|
||
<el-button size="small" @click="cancelAdd">取 消</el-button>
|
||
<el-button size="small" type="primary" @click="addPromotion('addForm')">确认添加</el-button>
|
||
</div>
|
||
</el-dialog>
|
||
<el-dialog title="编辑" :append-to-body="true" :visible.sync="showEditBox"
|
||
:close-on-click-modal="false" width="600px">
|
||
<el-form label-width="120px" :model="editForm" :rules="editRules" ref="editForm">
|
||
<el-form-item label="促销价" prop="act_price">
|
||
<el-input size="small" style="width: 210px" type="text" v-model="editForm.act_price"></el-input>
|
||
</el-form-item>
|
||
<el-form-item label="活动时间" prop="time">
|
||
<el-date-picker
|
||
size="small"
|
||
clearable filterable
|
||
v-model="editForm.time"
|
||
type="datetimerange"
|
||
format="yyyy-MM-dd HH:mm:ss"
|
||
value-format="yyyy-MM-dd HH:mm:ss"
|
||
range-separator="至"
|
||
start-placeholder="开始时间"
|
||
end-placeholder="结束时间">
|
||
</el-date-picker>
|
||
</el-form-item>
|
||
</el-form>
|
||
<div slot="footer" class="dialog-footer">
|
||
<el-button size="small" @click="showEditBox = false">取 消</el-button>
|
||
<el-button size="small" type="primary" @click="updatePrice('editForm')">确 定</el-button>
|
||
</div>
|
||
</el-dialog>
|
||
</div>
|
||
|
||
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/Retail/common/js/select-goods-category.js"></script>
|
||
<script>
|
||
var promotionGoods = new Vue({
|
||
el: '#promotionGoods',
|
||
data() {
|
||
return {
|
||
store_id: localStorage.store_id,
|
||
promotionDisabled: "{$authArr['changePromotion']}" == 1 ? false : true,
|
||
promotion_status: {$status},
|
||
promotionList: [],//促销列表
|
||
currentPage: 1,
|
||
currentLimit: 10,
|
||
currentLen: 0,
|
||
searchHostKeyword: '',//促销列表搜索关键词
|
||
price_section: '', //促销列表搜索时间区间关键词
|
||
act_type: '', //活动状态
|
||
promotion_time: '', //活动时间范围
|
||
showAddBox: false,
|
||
showEditBox: false,
|
||
changeIndex: -1,//正在编辑的下标
|
||
goodsList: [],//可选商品列表
|
||
goodsCurrentPage: 1,
|
||
goodsCurrentLimit: 5,
|
||
goodsCurrentLen: 0,
|
||
searchGoodsKey: '',
|
||
skuList: [],//可选商品列表
|
||
skuCurrentPage: 1,
|
||
skuCurrentLimit: 5,
|
||
skuCurrentLen: 0,
|
||
searchSkuKey: '',
|
||
goods_type: 1,
|
||
goodsClassId1: '',
|
||
goodsClassId2: '',
|
||
goodsClassId3: '',
|
||
addClassId1: '',
|
||
addClassId2: '',
|
||
addClassId3: '',
|
||
attribute_state: '',
|
||
editForm: {
|
||
act_price: '',
|
||
time: '',
|
||
},
|
||
editRules: {
|
||
act_price: [{message: '请输入正确的价格', required: true, trigger: 'blur'}, {
|
||
validator: function (rule, value, callback) {
|
||
var reg = /^[+]{0,1}(\d+)$|^[+]{0,1}(\d+\.\d{0,2})$/;
|
||
if (reg.test(value) == false || value < 0) {
|
||
callback(new Error("请输入正确的价格"));
|
||
} else if (value >= parseFloat(promotionGoods.promotionList[promotionGoods.changeIndex].online_price)) {
|
||
callback(new Error("促销价不能大于等于商城价"));
|
||
} else {
|
||
callback();
|
||
}
|
||
}, trigger: 'blur'
|
||
}],
|
||
time: [{message: '请选择促销时间范围', required: true, trigger: 'blur'}],
|
||
},
|
||
chooseSkuIds: [],//已选规格id列表
|
||
addForm: {
|
||
goods: [],
|
||
sku: [],
|
||
act_price: '',
|
||
time: '',
|
||
set_price_type: 2,//1单个自定义 2统一设置价格(针对规格商品)
|
||
},
|
||
addRules: {
|
||
goods: [{message: '请选择商品', required: true, trigger: ['blur', 'change']}],
|
||
sku: [{
|
||
validator: function (rule, value, callback) {
|
||
if (!value.length && promotionGoods.addForm.goods.length && promotionGoods.addForm.goods[0].attribute_state == 2) {
|
||
callback(new Error("请选择商品规格"));
|
||
} else {
|
||
callback();
|
||
}
|
||
}, required: true, trigger: 'blur'
|
||
}],
|
||
act_price: [{message: '请输入正确的价格', required: false, trigger: ['blur', 'change']}, {
|
||
validator: function (rule, value, callback) {
|
||
var reg = /^[+]{0,1}(\d+)$|^[+]{0,1}(\d+\.\d{0,2})$/;
|
||
if ((reg.test(value) == false || value < 0) && promotionGoods.addForm.goods.length && promotionGoods.addForm.set_price_type == 2) {
|
||
callback(new Error("请输入正确的价格"));
|
||
} else if (promotionGoods.addForm.goods[0] && promotionGoods.addForm.goods[0].attribute_state == 1 && value >= parseFloat(promotionGoods.addForm.goods[0].online_price)) {
|
||
callback(new Error("促销价不能大于等于商城价"));
|
||
} else {
|
||
if (promotionGoods.addForm.goods[0] && promotionGoods.addForm.goods[0].attribute_state == 2 && promotionGoods.addForm.goods[0] && promotionGoods.addForm.sku.length && promotionGoods.addForm.set_price_type == 2) {
|
||
var sku = promotionGoods.addForm.sku;
|
||
var msg = '';
|
||
var flag = false;
|
||
for (var i = 0; i < sku.length; i++) {
|
||
if (promotionGoods.addForm.act_price >= parseFloat(sku[i].online_price)) {
|
||
msg = '统一设置的促销价不能大于等于第' + (i + 1) + '个规格的商城价';
|
||
flag = true;
|
||
break;
|
||
}
|
||
}
|
||
if (flag) {
|
||
callback(new Error(msg));
|
||
} else {
|
||
callback();
|
||
}
|
||
} else {
|
||
callback();
|
||
}
|
||
}
|
||
}, trigger: ['blur', 'change']
|
||
}],
|
||
time: [{message: '请选择促销时间范围', required: true, trigger: ['blur', 'change']}, {
|
||
validator: function (rule, value, callback) {
|
||
if (!value.length) {
|
||
callback(new Error("请选择促销时间范围"));
|
||
} else {
|
||
callback();
|
||
}
|
||
}, trigger: ['blur', 'change']
|
||
}],
|
||
},
|
||
}
|
||
},
|
||
methods: {
|
||
//修改促销商品开启关闭状态
|
||
changePromotion(val) {
|
||
this.sendRequest("{:U('changePromotion')}", {
|
||
data: {
|
||
status: val
|
||
},
|
||
success: (res) => {
|
||
if (res.status == 1) {
|
||
this.$message.success(res.message);
|
||
} else {
|
||
this.promotion_status = val == 1 ? 0 : 1;
|
||
this.$message.error(res.message);
|
||
}
|
||
}
|
||
});
|
||
},
|
||
//显示选择商品列表
|
||
toShowGoods() {
|
||
this.showAddBox = true;
|
||
if (!this.goodsList.length) {
|
||
this.getGoodsList();
|
||
}
|
||
},
|
||
//取消添加促销
|
||
cancelAdd() {
|
||
this.showAddBox = false;
|
||
this.addForm = {
|
||
goods: [],
|
||
goods_name: '',
|
||
sku: [],
|
||
act_price: '',
|
||
time: '',
|
||
set_price_type: 2,
|
||
};
|
||
this.chooseSkuIds = [];
|
||
},
|
||
//添加促销时选择商品
|
||
chooseGoods(index) {
|
||
this.addForm.goods = [JSON.parse(JSON.stringify(this.goodsList[index]))];
|
||
this.addForm.set_price_type = 2;
|
||
if (this.goodsList[index].attribute_state == 2) {
|
||
this.getSkuGoodsList();
|
||
}
|
||
this.$refs['addForm'].validate((valid) => {
|
||
});
|
||
},
|
||
//添加促销时移除已选商品
|
||
delChooseGoods() {
|
||
this.addForm.goods = [];
|
||
this.addForm.sku = [];
|
||
this.addForm.set_price_type = 2;
|
||
this.$refs['addForm'].validate((valid) => {
|
||
});
|
||
},
|
||
//添加促销时选择规格
|
||
chooseSku(index) {
|
||
this.addForm.sku.push(JSON.parse(JSON.stringify(this.skuList[index])));
|
||
this.chooseSkuIds.push(this.skuList[index].id);
|
||
this.$refs['addForm'].validate((valid) => {
|
||
});
|
||
},
|
||
//添加促销时移除已选规格
|
||
delChooseSku(index) {
|
||
this.addForm.sku.splice(index, 1);
|
||
this.chooseSkuIds.splice(index, 1);
|
||
this.$refs['addForm'].validate((valid) => {
|
||
});
|
||
},
|
||
//添加促销商品
|
||
addPromotion(addForm) {
|
||
this.$refs[addForm].validate((valid) => {
|
||
if (valid) {
|
||
if (this.addForm.goods[0].attribute_state == 2 && this.addForm.set_price_type == 1) {
|
||
var reg = /^[+]{0,1}(\d+)$|^[+]{0,1}(\d+\.\d{0,2})$/;
|
||
var sku = this.addForm.sku;
|
||
for (var i = 0; i < sku.length; i++) {
|
||
if (reg.test(sku[i].act_price) == false || sku[i].act_price < 0) {
|
||
this.$message({
|
||
message: '请填写第' + (i + 1) + '个规格促销价',
|
||
type: 'warning',
|
||
});
|
||
return;
|
||
}
|
||
if (sku[i].act_price >= parseFloat(sku[i].online_price)) {
|
||
this.$message({
|
||
message: '第' + (i + 1) + '个规格促销价不能大于等于商城价',
|
||
type: 'warning',
|
||
});
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
this.$confirm('确认将该商品添加到促销商品?添加后将立即生效!', '提示', {
|
||
confirmButtonText: '添加',
|
||
cancelButtonText: '取消',
|
||
type: 'warning'
|
||
}).then(() => {
|
||
this.sendRequest("{:U('addPromotion')}", {
|
||
data: {
|
||
goods_id: this.addForm.goods[0].id,
|
||
act_price: this.addForm.act_price,
|
||
sku: JSON.stringify(this.addForm.sku),
|
||
time: this.addForm.time,
|
||
set_price_type: this.addForm.set_price_type,
|
||
},
|
||
success: (res) => {
|
||
if (res.status == 1) {
|
||
this.$message.success(res.message);
|
||
this.cancelAdd();
|
||
this.getData();
|
||
} else {
|
||
if (res.errorData) {
|
||
var err = '';
|
||
for (var j = 0; j < res.errorData.length; j++) {
|
||
err += `<div>${res.errorData[j]}</div>`;
|
||
}
|
||
this.$alert(err, '错误详情', {
|
||
dangerouslyUseHTMLString: true,
|
||
showClose: false,
|
||
confirmButtonText: '关闭',
|
||
});
|
||
}
|
||
}
|
||
}
|
||
})
|
||
}).catch(() => {
|
||
});
|
||
}
|
||
})
|
||
},
|
||
//编辑活动
|
||
toChange(index) {
|
||
this.changeIndex = index;
|
||
this.showEditBox = true;
|
||
var promotionList = JSON.parse(JSON.stringify(this.promotionList[index]));
|
||
this.editForm = {
|
||
act_price: promotionList.act_price,
|
||
time: [promotionList.start_time, promotionList.end_time],
|
||
};
|
||
},
|
||
//修改促销商品价格
|
||
updatePrice(updatePrice) {
|
||
this.$refs[updatePrice].validate((valid) => {
|
||
if (valid) {
|
||
this.$confirm('确认保存改设置?保存成功后将立即生效!', '提示', {
|
||
confirmButtonText: '保存',
|
||
cancelButtonText: '取消',
|
||
type: 'warning'
|
||
}).then(() => {
|
||
this.sendRequest("{:U('updatePrice')}", {
|
||
data: {
|
||
id: this.promotionList[this.changeIndex].id,
|
||
price: this.editForm.act_price,
|
||
time: this.editForm.time,
|
||
},
|
||
success: (res) => {
|
||
if (res.status == 1) {
|
||
this.$message.success(res.message);
|
||
this.showEditBox = false;
|
||
this.getData();
|
||
} else {
|
||
this.$message.error(res.message);
|
||
}
|
||
}
|
||
})
|
||
}).catch(() => {
|
||
});
|
||
}
|
||
});
|
||
},
|
||
//删除促销列表
|
||
delPromotion(id) {
|
||
this.$confirm('确认删除该促销设置?删除后将不能恢复,请谨慎操作!', '提示', {
|
||
confirmButtonText: '删除',
|
||
cancelButtonText: '取消',
|
||
type: 'warning'
|
||
}).then(() => {
|
||
this.sendRequest("{:U('delPromotion')}", {
|
||
data: {
|
||
id: id
|
||
},
|
||
success: (res) => {
|
||
if (res.status == 1) {
|
||
this.$message.success(res.message);
|
||
this.getData();
|
||
} else {
|
||
this.$message.error(res.message);
|
||
}
|
||
}
|
||
})
|
||
}).catch(() => {
|
||
});
|
||
},
|
||
//切换促销列表每页数量
|
||
handleSizeChange(val) {
|
||
this.currentLimit = val;
|
||
this.currentPage = 1;
|
||
this.getData();
|
||
},
|
||
//切换促销列表页数
|
||
handleCurrentChange(val) {
|
||
this.currentPage = val;
|
||
this.getData();
|
||
},
|
||
//搜索促销商品
|
||
searchPromotion() {
|
||
this.currentPage = 1;
|
||
this.getData();
|
||
},
|
||
//获取促销列表
|
||
getData() {
|
||
this.sendRequest("{:U('promotionInfo')}", {
|
||
data: {
|
||
page: this.currentPage,
|
||
limit: this.currentLimit,
|
||
keyword: this.searchHostKeyword,
|
||
price_section: this.price_section,
|
||
class_id1: this.goodsClassId1,
|
||
class_id2: this.goodsClassId2,
|
||
class_id3: this.goodsClassId3,
|
||
act_type: this.act_type,
|
||
promotion_time: this.promotion_time,
|
||
},
|
||
success: (res) => {
|
||
if (res.status == 1) {
|
||
this.promotionList = [];
|
||
this.promotionList = res.data;
|
||
this.currentLen = res.count;
|
||
} else {
|
||
this.promotionList = [];
|
||
}
|
||
}
|
||
})
|
||
},
|
||
//切换商品列表每页数量
|
||
goodsHandleSizeChange(val) {
|
||
this.goodsCurrentLimit = val;
|
||
this.goodsCurrentPage = 1;
|
||
this.getGoodsList();
|
||
},
|
||
//切换商品列表页数
|
||
goodsHandleCurrentChange(val) {
|
||
this.goodsCurrentPage = val;
|
||
this.getGoodsList();
|
||
},
|
||
//搜索商品
|
||
searchGoods() {
|
||
this.goodsCurrentPage = 1;
|
||
this.getGoodsList();
|
||
},
|
||
//获取可添加为促销商品的商品
|
||
getGoodsList() {
|
||
this.sendRequest("{:U('promotionGoodsList')}", {
|
||
data: {
|
||
page: this.goodsCurrentPage,
|
||
limit: this.goodsCurrentLimit,
|
||
class_id1: this.addClassId1,
|
||
class_id2: this.addClassId2,
|
||
class_id3: this.addClassId3,
|
||
keyword: this.searchGoodsKey,
|
||
attribute_state: this.attribute_state,
|
||
},
|
||
success: (res) => {
|
||
if (res.status == 1) {
|
||
this.goodsList = [];
|
||
this.goodsList = res.data;
|
||
this.goodsCurrentLen = res.count;
|
||
} else {
|
||
this.goodsList = [];
|
||
}
|
||
}
|
||
})
|
||
},
|
||
//切换规格列表每页数量
|
||
skuHandleSizeChange(val) {
|
||
this.skuCurrentLimit = val;
|
||
this.skuCurrentPage = 1;
|
||
this.getSkuGoodsList();
|
||
},
|
||
//切换规格列表页数
|
||
skuHandleCurrentChange(val) {
|
||
this.skuCurrentPage = val;
|
||
this.getSkuGoodsList();
|
||
},
|
||
//搜索规格
|
||
searchSku() {
|
||
this.skuCurrentPage = 1;
|
||
this.getSkuGoodsList();
|
||
},
|
||
//获取可添加为促销商品的规格列表
|
||
getSkuGoodsList() {
|
||
this.sendRequest("{:U('getGoodsSkuList')}", {
|
||
data: {
|
||
goods_id: this.addForm.goods[0].id,
|
||
page: this.skuCurrentPage,
|
||
limit: this.skuCurrentLimit,
|
||
keyword: this.searchSkuKey,
|
||
},
|
||
success: (res) => {
|
||
if (res.status == 1) {
|
||
this.skuList = [];
|
||
this.skuList = res.data;
|
||
this.skuCurrentLen = res.count;
|
||
} else {
|
||
this.skuList = [];
|
||
}
|
||
}
|
||
})
|
||
},
|
||
},
|
||
watch: {
|
||
promotion_time(n) {
|
||
if (n) {
|
||
this.act_type = '';
|
||
}
|
||
},
|
||
act_type(n) {
|
||
if (n) {
|
||
this.promotion_time = '';
|
||
}
|
||
}
|
||
},
|
||
created() {
|
||
this.getData();
|
||
},
|
||
})
|
||
</script> |