init: import production code mss.nahaichuan.com (exclude Runtime/Uploads/backups/logs)
这个提交包含在:
@@ -0,0 +1,865 @@
|
||||
|
||||
<style>
|
||||
[v-cloak] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#giftsPromotion .el-pagination {
|
||||
border: 1px solid #ebeef5;
|
||||
border-top: 0;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.max-dialog-content {
|
||||
margin-left: 160px;
|
||||
height: calc(100vh - 65px);
|
||||
box-sizing: border-box;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.goods_title {
|
||||
padding: 10px 0;
|
||||
}
|
||||
|
||||
.chooseGoods {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
height: calc(100vh - 190px);
|
||||
}
|
||||
|
||||
#giftsPromotion .max-dialog-content .el-dialog__footer, #giftsPromotion .mini-dialog-content .el-dialog__footer {
|
||||
padding: 0 20px 0;
|
||||
}
|
||||
|
||||
#giftsPromotion .max-dialog-content .el-dialog__body, #giftsPromotion .mini-dialog-content .el-dialog__body {
|
||||
padding: 10px 20px;
|
||||
}
|
||||
|
||||
.sku-list-box {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.sku-list-name-box {
|
||||
height: 26px;
|
||||
line-height: 27px;
|
||||
border: 1px solid #ddd;
|
||||
position: relative;
|
||||
padding: 0 20px;
|
||||
margin: 5px 10px;
|
||||
color: #666;
|
||||
cursor: pointer;
|
||||
overflow: hidden;
|
||||
font-size: 12px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.sku-list-name-box::selection {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.check-sku-list {
|
||||
border-color: #4394ff;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.check-sku-list:after {
|
||||
content: '';
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
background-color: #4394ff;
|
||||
position: absolute;
|
||||
top: -7px;
|
||||
right: -7px;
|
||||
transform: rotateZ(45deg);
|
||||
}
|
||||
|
||||
.el-tooltip__popper {
|
||||
max-width: 20%;
|
||||
}
|
||||
|
||||
.el-tooltip__popper,
|
||||
.el-tooltip__popper.is-dark {
|
||||
background: #f5f5f5 !important;
|
||||
color: #303133 !important;
|
||||
}
|
||||
|
||||
.detail_p {
|
||||
padding-top: 8px;
|
||||
}
|
||||
|
||||
.detail_gifts {
|
||||
padding-top: 15px;
|
||||
}
|
||||
</style>
|
||||
<div id="giftsPromotion" v-cloak>
|
||||
<div class="goods_title">
|
||||
<div class="goods_title_inner">
|
||||
赠送促销
|
||||
</div>
|
||||
</div>
|
||||
<el-form :inline="true" size="small">
|
||||
<el-form-item>
|
||||
<el-input v-model="list_keyword" clearable placeholder="请输入商品名称"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-select v-model="value" placeholder="促销状态">
|
||||
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="添加时间">
|
||||
<el-date-picker v-model="addTimeData" type="daterange" value-format="yyyy-MM-dd" range-separator="至"
|
||||
start-placeholder="开始时间" end-placeholder="结束时间">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="促销时间">
|
||||
<el-date-picker v-model="sellTimeData" type="daterange" value-format="yyyy-MM-dd" range-separator="至"
|
||||
start-placeholder="开始时间" end-placeholder="结束时间">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="onSubmit" plain>搜索</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="addActivity" plain v-if="operate.releaseGoodsGiftsActivity">
|
||||
添加活动
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<!-- 表格 -->
|
||||
<template>
|
||||
<el-table :data="tableData" size="small" border style="width: 100%">
|
||||
<el-table-column type="index" label="序号" align="center" width="50"></el-table-column>
|
||||
<el-table-column prop="goods_name" label="商品名称" align="center">
|
||||
</el-table-column>
|
||||
<el-table-column prop="sku_name" label="商品规格" align="center">
|
||||
</el-table-column>
|
||||
<el-table-column prop="created_at" label="添加时间" align="center">
|
||||
</el-table-column>
|
||||
<el-table-column label="促销时间" align="center">
|
||||
<template slot-scope="scope">
|
||||
<p>{{scope.row.start_time}}-<br>{{scope.row.end_time}}</p>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="促销状态" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-switch v-model="scope.row.status"
|
||||
active-color="#13ce66"
|
||||
inactive-color="#999" active-value="1" inactive-value="0"
|
||||
@change="switchChange(scope.row.activity_id)"
|
||||
:disabled="!operate.updateGiftsActivityStatus">
|
||||
</el-switch>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="text" size="mini" @click="goodsDetail(scope.row.activity_id)">查看详情</el-button>
|
||||
<el-button type="text" size="mini" @click="deleteActivity(scope.row.activity_id)"
|
||||
v-if="operate.releaseGoodsGiftsActivity">删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!-- 分页 -->
|
||||
<el-pagination @current-change="CurrentChange"
|
||||
:current-page="currentPage"
|
||||
:page-sizes="[10]"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
:total="total">
|
||||
</el-pagination>
|
||||
</template>
|
||||
<!-- 添加活动弹出框 -->
|
||||
<el-dialog title="添加活动"
|
||||
:visible.sync="addDialog"
|
||||
:modal-append-to-body="false"
|
||||
:append-to-body="false"
|
||||
:top="'65px'"
|
||||
:width="'calc(100vw - 160px)'"
|
||||
:custom-class="'max-dialog-content'"
|
||||
:close-on-press-escape="false"
|
||||
:close-on-click-modal="false">
|
||||
<el-scrollbar class="chooseGoods">
|
||||
<el-form ref="addActivityForm" :model="addActivityForm" size="small" label-width="100px" :rules="rules">
|
||||
<el-form-item label="主商品:">
|
||||
<el-button type="primary" @click="chooseMain" plain>选择商品</el-button>
|
||||
<!-- 表格 -->
|
||||
<template>
|
||||
<el-table :data="mainGoodsData" size="small" border style="margin-top: 10px">
|
||||
<el-table-column prop="goods_name" label="商品名称" align="center">
|
||||
</el-table-column>
|
||||
<el-table-column label="商品规格" align="center" width="150" :show-overflow-tooltip="true">
|
||||
<template slot-scope="scope">
|
||||
<span v-if="scope.row.sku_info">{{ scope.row.sku_info }}</span>
|
||||
<el-button v-else type="text" size="mini"
|
||||
@click="getGoodsSkuAttrActivity(scope.row.id)">选择规格
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="retail_price" label="零售价" align="center">
|
||||
</el-table-column>
|
||||
<el-table-column prop="goods_code" label="商品条码" align="center">
|
||||
</el-table-column>
|
||||
<el-table-column prop="goods_number" label="商品货号" align="center">
|
||||
</el-table-column>
|
||||
<el-table-column prop="goods_num" label="商品库存" align="center">
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</template>
|
||||
</el-form-item>
|
||||
<el-form-item label="赠送门槛:" prop="count">
|
||||
<el-input v-model="addActivityForm.count" @change="giftsCountChange" style="width: 150px;"
|
||||
size="mini"></el-input> 件
|
||||
</el-form-item>
|
||||
<el-form-item label="赠送商品:" prop="gifts_num">
|
||||
<el-button type="primary" size="small" @click="chooseGifts" plain>
|
||||
选择商品 ({{giftsGoodsData.length}}/10)
|
||||
</el-button>
|
||||
<!-- 表格 -->
|
||||
<template>
|
||||
<el-table :data="giftsGoodsData" size="small" border style="margin-top: 10px">
|
||||
<el-table-column type="index" label="序号" align="center" width="50"></el-table-column>
|
||||
<el-table-column prop="goods_name" label="商品名称" align="center">
|
||||
</el-table-column>
|
||||
<el-table-column prop="sku_name" label="商品规格" align="center">
|
||||
</el-table-column>
|
||||
<el-table-column prop="remain_inventory" label="零售价" align="center">
|
||||
</el-table-column>
|
||||
<el-table-column prop="goods_num" label="商品库存" align="center">
|
||||
</el-table-column>
|
||||
<el-table-column label="赠送数量" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model="scope.row.gifts_num" size="small" clearable
|
||||
@change="giftsNumChange(scope.row)"></el-input>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="text" size="mini" @click="deleteGifts(scope.$index,scope.row)">
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</template>
|
||||
</el-form-item>
|
||||
<el-form-item label="促销时间:">
|
||||
<template>
|
||||
<el-radio v-model="addActivityForm.time_limit" label="0">不限时</el-radio>
|
||||
<el-radio v-model="addActivityForm.time_limit" label="1">限时</el-radio>
|
||||
</template>
|
||||
</el-form-item>
|
||||
<el-form-item label="活动时间:" v-if="addActivityForm.time_limit==1">
|
||||
<el-date-picker v-model="addActivityForm.activityTimeData" type="daterange"
|
||||
value-format="yyyy-MM-dd" range-separator="至" start-placeholder="开始时间"
|
||||
end-placeholder="结束时间"
|
||||
size="small">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="线上促销:">
|
||||
<el-switch v-model="addActivityForm.online_promotion"
|
||||
active-value="1"
|
||||
inactive-value="0">
|
||||
</el-switch>
|
||||
</el-form-item>
|
||||
<el-form-item label-width="180px" label="线上单人赠送次数数限制:" v-if="addActivityForm.online_promotion==1">
|
||||
<template>
|
||||
<el-radio v-model="addActivityForm.online_limit" label="0">不限制</el-radio>
|
||||
<el-radio v-model="addActivityForm.online_limit" label="1">限制</el-radio>
|
||||
</template>
|
||||
<template v-if="addActivityForm.online_limit==1">
|
||||
<el-input v-model="addActivityForm.online_buy_limit"
|
||||
@change="onlineChange"
|
||||
style="width: 100px;">
|
||||
</el-input> 次/人
|
||||
</template>
|
||||
</el-form-item>
|
||||
<el-form-item label="线下促销:">
|
||||
<el-switch v-model="addActivityForm.offline_promotion"
|
||||
active-value="1"
|
||||
inactive-value="0">
|
||||
</el-switch>
|
||||
</el-form-item>
|
||||
<el-form-item label-width="180px" label="线下单人赠送次数数限制:" v-if="addActivityForm.offline_promotion==1">
|
||||
<template>
|
||||
<el-radio v-model="addActivityForm.offline_limit" label="0">不限制</el-radio>
|
||||
<el-radio v-model="addActivityForm.offline_limit" label="1">限制</el-radio>
|
||||
</template>
|
||||
<template v-if="addActivityForm.offline_limit==1">
|
||||
<el-input v-model="addActivityForm.offline_buy_limit"
|
||||
@change="offlineChange"
|
||||
style="width: 100px;">
|
||||
</el-input> 次/人
|
||||
</template>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-scrollbar>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button type="primary"
|
||||
@click="addActivityOK('addActivityForm')"
|
||||
size="small">提交</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
<!-- 添加主商品弹框 -->
|
||||
<el-dialog title="选择商品" :visible.sync="mainDialog"
|
||||
width="800px"
|
||||
:modal-append-to-body="false"
|
||||
:custom-class="'mini-dialog-content'"
|
||||
:append-to-body="false"
|
||||
:close-on-click-modal="false">
|
||||
<el-form :inline="true" size="small">
|
||||
<el-form-item>
|
||||
<el-input v-model="search_main_keyword" size="small" clearable placeholder="请输入商品名称"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="search_main" size="small" plain>搜索</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<!-- 表格 -->
|
||||
<template>
|
||||
<el-table :data="mainData" border size="small">
|
||||
<el-table-column type="index" label="序号" align="center" width="50"></el-table-column>
|
||||
<el-table-column prop="goods_name" label="商品名称" show-overflow-tooltip align="center">
|
||||
</el-table-column>
|
||||
<el-table-column prop="retail_price" label="零售价" align="center">
|
||||
</el-table-column>
|
||||
<el-table-column prop="goods_code" label="商品条码" show-overflow-tooltip align="center">
|
||||
</el-table-column>
|
||||
<el-table-column prop="goods_number" label="商品货号" show-overflow-tooltip align="center">
|
||||
</el-table-column>
|
||||
<el-table-column prop="goods_num" label="商品库存" align="center">
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="text" size="mini" @click="chooseMainOK(scope.row)">选择商品
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!-- 分页 -->
|
||||
<el-pagination @current-change="mainCurrentChange"
|
||||
:current-page="mainCurrentPage"
|
||||
:page-sizes="[10]"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
:total="mainTotal">
|
||||
</el-pagination>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<!-- 选择规格 -->
|
||||
<el-dialog title="选择商品规格" :visible.sync="specificationsDialog" width="30%" :close-on-click-modal="false">
|
||||
<div class="sku-list-box">
|
||||
<div class="sku-list-name-box" v-for="(item,i) in skulist" @click="checkSkuList(i)"
|
||||
:class="item.sku_checked?'check-sku-list':''">
|
||||
{{item.name}}
|
||||
</div>
|
||||
</div>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="chooseSkuOK" size="mini">确定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
<!-- 选择赠品 -->
|
||||
<el-dialog title="选择赠品" :visible.sync="giftsDialog" width="60%" :close-on-click-modal="false">
|
||||
<el-form :inline="true" :model="searchGiftsForm" class="demo-form-inline">
|
||||
<el-form-item>
|
||||
<el-input v-model="searchGiftsForm.info" size="small" clearable placeholder="请输入商品名称"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="search_gifts" size="small" plain>搜索
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<!-- 表格 -->
|
||||
<template>
|
||||
<el-table :data="giftsData" style="width: 90%">
|
||||
<el-table-column type="index" label="序号" align="center" width="50"></el-table-column>
|
||||
<el-table-column prop="goods_name" label="商品名称" align="center">
|
||||
</el-table-column>
|
||||
<el-table-column prop="sku_name" label="商品规格" align="center">
|
||||
</el-table-column>
|
||||
<el-table-column prop="goods_code" label="零售价" align="center">
|
||||
</el-table-column>
|
||||
<el-table-column prop="remain_inventory" label="商品库存" align="center">
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="text" size="mini" @click="chooseGiftsOK(scope.$index,scope.row)"
|
||||
v-if="scope.row.checked==false">选择商品
|
||||
</el-button>
|
||||
<el-button type="text" style="color: #666;" size="mini" v-else>已选
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</template>
|
||||
<!-- 分页 -->
|
||||
<el-pagination @current-change="giftsCurrentChange" :current-page="giftsCurrentPage" :page-sizes="[10]"
|
||||
layout="total, sizes, prev, pager, next, jumper" :total="giftsTotal">
|
||||
</el-pagination>
|
||||
</el-dialog>
|
||||
<!-- 查看详情 -->
|
||||
<el-dialog title="查看详情" :visible.sync="detailDialog" width="40%">
|
||||
<p class="detail_p">主商品:</p>
|
||||
<template>
|
||||
<el-table :data="detailInfo.goods_info" style="width: 90%">
|
||||
<el-table-column prop="goods_name" label="商品名称" align="center">
|
||||
</el-table-column>
|
||||
<el-table-column prop="sku_info" label="商品规格" align="center">
|
||||
</el-table-column>
|
||||
<el-table-column prop="retail_price" label="零售价" align="center">
|
||||
</el-table-column>
|
||||
<el-table-column prop="goods_code" label="商品条码" align="center">
|
||||
</el-table-column>
|
||||
<el-table-column prop="goods_number" label="商品货号" align="center">
|
||||
</el-table-column>
|
||||
<el-table-column prop="goods_num" label="商品库存" align="center">
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</template>
|
||||
<p class="detail_p">赠送门槛:购买{{detailInfo.goods_num_min}}件主商品</p>
|
||||
<p class="detail_gifts">赠送商品:</p>
|
||||
<template>
|
||||
<el-table :data="detailInfo.goods_gifts_info" style="width: 90%" max-height="250">
|
||||
<el-table-column type="index" label="序号" align="center" width="50"></el-table-column>
|
||||
<el-table-column prop="goods_name" label="商品名称" align="center">
|
||||
</el-table-column>
|
||||
<el-table-column prop="sku_name" label="商品规格" align="center">
|
||||
</el-table-column>
|
||||
<el-table-column prop="goods_code" label="零售价" align="center">
|
||||
</el-table-column>
|
||||
<el-table-column prop="remain_inventory" label="商品库存" align="center">
|
||||
</el-table-column>
|
||||
<el-table-column prop="gifts_num" label="赠送数量" align="center">
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</template>
|
||||
<p class="detail_p">线上购买限制:<span v-if="detailInfo.online_buy_limit>0">{{detailInfo.offline_buy_limit}}次/人</span><span
|
||||
v-else>无限制</span></p>
|
||||
<p class="detail_p">线下单次购买限制:<span
|
||||
v-if="detailInfo.offline_buy_limit>0">{{detailInfo.offline_buy_limit}}次</span><span v-else>无限制</span>
|
||||
</p>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="detailDialog = false" size="mini">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</div>
|
||||
<script type="text/javaScript">
|
||||
var giftsPromotion = new Vue({
|
||||
el: "#giftsPromotion",
|
||||
data: function () {
|
||||
return {
|
||||
list_keyword: '',
|
||||
addActivityForm: {
|
||||
count: '',
|
||||
activityTimeData: [],
|
||||
online_promotion: 1,
|
||||
online_limit: '0',
|
||||
online_buy_limit: '',
|
||||
offline_promotion: 1,
|
||||
offline_limit: '0',
|
||||
offline_buy_limit: '',
|
||||
time_limit: '0',
|
||||
},
|
||||
search_main_keyword: '',
|
||||
searchGiftsForm: {
|
||||
info: '',
|
||||
},
|
||||
options: [
|
||||
{ // 下拉框
|
||||
value: '1',
|
||||
label: '开启'
|
||||
},
|
||||
{
|
||||
value: '0',
|
||||
label: '关闭'
|
||||
}],
|
||||
value: '', // 下拉框值
|
||||
tableData: [], //活动表格
|
||||
addTimeData: [], //添加时间数组
|
||||
sellTimeData: [], //促销时间数组
|
||||
activityTimeData: [], //添加活动时间
|
||||
giftsGoodsData: [], // 赠品数组
|
||||
mainData: [], // 主商品表格
|
||||
giftsData: [], //选择赠品表格
|
||||
detailInfo: {},
|
||||
currentPage: 1,//当前页
|
||||
mainCurrentPage: 1, //主商品当前页
|
||||
giftsCurrentPage: 1,
|
||||
giftsTotal: 0,
|
||||
total: 0, //总数据
|
||||
mainTotal: 0, //主商品总数据
|
||||
addDialog: false,
|
||||
mainDialog: false,
|
||||
giftsDialog: false,
|
||||
specificationsDialog: false,
|
||||
detailDialog: false,
|
||||
mainGoodsData: [], // 主商品信息
|
||||
operate: {},
|
||||
skulist: [], //规格信息
|
||||
rules: {
|
||||
count: [
|
||||
{required: true, message: '请输入赠送门槛', trigger: 'blur'},
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getGoodsGiftActivityBack()
|
||||
//获取操作权限
|
||||
var auth_list = {
|
||||
releaseGoodsGiftsActivity: '/index.php/Retail/GoodsGifts/releaseGoodsGiftsActivity',
|
||||
updateGiftsActivityStatus: '/index.php/Retail/GoodsGifts/updateGiftsActivityStatus',
|
||||
deleteGiftsActivityRecord: '/index.php/Retail/GoodsGifts/deleteGiftsActivityRecord'
|
||||
};
|
||||
$.ajax({
|
||||
url: "{:U('Retail/Component/checkOperateAuth')}",
|
||||
type: "post",
|
||||
data: {
|
||||
auth_list: JSON.stringify(auth_list),
|
||||
},
|
||||
success: (res) => {
|
||||
if (res.status == 1) {
|
||||
this.operate = res.data;
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
//获取活动详情
|
||||
getGoodsGiftActivityBack() {
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: '/index.php/Retail/GoodsGifts/getGoodsGiftActivityBack',
|
||||
data: {
|
||||
page: this.currentPage,
|
||||
pageSize: 10,
|
||||
goods_name: this.list_keyword,
|
||||
start_time: this.addTimeData[0],
|
||||
end_time: this.addTimeData[1],
|
||||
sales_start_time: this.sellTimeData[0],
|
||||
sales_end_time: this.sellTimeData[1],
|
||||
status: this.value,
|
||||
},
|
||||
success: res => {
|
||||
if (res.status == 1) {
|
||||
console.log(res);
|
||||
this.tableData = res.data.list;
|
||||
this.total = parseInt(res.data.total);
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
// 更改促销状态
|
||||
switchChange(id) {
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: '/index.php/Retail/GoodsGifts/updateGiftsActivityStatus',
|
||||
data: {
|
||||
activity_id: id,
|
||||
},
|
||||
success: res => {
|
||||
if (res.status == 1) {
|
||||
this.$message({
|
||||
message: '促销状态设置成功',
|
||||
type: 'success',
|
||||
});
|
||||
this.getGoodsGiftActivityBack()
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
//主商品门槛
|
||||
giftsCountChange() {
|
||||
if (!/^[1-9]\d*$/.test(this.addActivityForm.count)) {
|
||||
this.addActivityForm.count = ''
|
||||
}
|
||||
},
|
||||
giftsNumChange(x) {
|
||||
if (x.gifts_num > x.goods_num || !/^([1-9]|10)$/.test(x.gifts_num)) {
|
||||
this.$message({
|
||||
message: '库存数量输入错误',
|
||||
type: 'warning',
|
||||
});
|
||||
this.giftsGoodsData.some((item) => {
|
||||
if (item.gifts_id == x.gifts_id) {
|
||||
item.gifts_num = ''
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
offlineChange() {
|
||||
if (!/^[1-9]\d*$/.test(this.addActivityForm.offline_buy_limit)) {
|
||||
this.addActivityForm.offline_buy_limit = ''
|
||||
}
|
||||
},
|
||||
onlineChange() {
|
||||
if (!/^[1-9]\d*$/.test(this.addActivityForm.online_buy_limit)) {
|
||||
this.addActivityForm.online_buy_limit = ''
|
||||
}
|
||||
},
|
||||
|
||||
//获取主商品
|
||||
goodsGiftsActivityMain() {
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: '/index.php/Retail/GoodsGifts/goodsGiftsActivityMain',
|
||||
data: {
|
||||
page: this.mainCurrentPage,
|
||||
limit: 10,
|
||||
keyword: this.search_main_keyword
|
||||
},
|
||||
success: res => {
|
||||
if (res.status == 1) {
|
||||
this.mainData = res.data
|
||||
this.mainTotal = parseInt(res.count)
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
//获取赠品
|
||||
getGoodsGiftBack() {
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: '/index.php/Retail/GoodsGifts/getGoodsGiftBack',
|
||||
data: {
|
||||
page: this.giftsCurrentPage,
|
||||
pageSize: 10,
|
||||
search: this.searchGiftsForm.info,
|
||||
status: 1
|
||||
},
|
||||
success: res => {
|
||||
if (res.status == 1) {
|
||||
this.giftsData = res.data.list
|
||||
this.giftsTotal = parseInt(res.data.total)
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
//获取商品规格
|
||||
getGoodsSkuAttrActivity(id) {
|
||||
this.specificationsDialog = true;
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: '/index.php/Retail/GoodsGifts/getGoodsSkuAttrActivity',
|
||||
data: {
|
||||
id: id
|
||||
},
|
||||
success: res => {
|
||||
this.skulist = res.data.list
|
||||
|
||||
}
|
||||
})
|
||||
},
|
||||
addActivityOK(addActivityForm) {
|
||||
this.$refs[addActivityForm].validate((valid) => {
|
||||
if (valid) {
|
||||
for (var i = 0; i < this.giftsGoodsData.length; i++) {
|
||||
this.giftsGoodsData[i].goods_gifts_id = this.giftsGoodsData[i].gifts_id
|
||||
var item = this.giftsGoodsData[i];
|
||||
if (!item.gifts_num) {
|
||||
this.$message({
|
||||
message: '赠品库存不能为空',
|
||||
type: 'warning',
|
||||
});
|
||||
return
|
||||
}
|
||||
}
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: '/index.php/Retail/GoodsGifts/releaseGoodsGiftsActivity',
|
||||
data: {
|
||||
goods_json: JSON.stringify(this.mainGoodsData),
|
||||
gifts_json: JSON.stringify(this.giftsGoodsData),
|
||||
goods_num_min: this.addActivityForm.count,
|
||||
time_limit: this.addActivityForm.time_limit,
|
||||
start_time: this.addActivityForm.activityTimeData[0],
|
||||
end_time: this.addActivityForm.activityTimeData[1],
|
||||
online_promotion: this.addActivityForm.online_promotion,
|
||||
online_buy_limit: this.addActivityForm.online_buy_limit,
|
||||
offline_promotion: this.addActivityForm.offline_promotion,
|
||||
offline_buy_limit: this.addActivityForm.offline_buy_limit,
|
||||
},
|
||||
success: res => {
|
||||
if (res.status == 1) {
|
||||
this.$message({
|
||||
message: res.msg,
|
||||
type: 'success'
|
||||
});
|
||||
this.mainGoodsData = [];
|
||||
this.giftsGoodsData = [];
|
||||
this.addActivityForm = {
|
||||
count: '',
|
||||
time_limit: '',
|
||||
activityTimeData: [],
|
||||
online_promotion: '',
|
||||
online_buy_limit: '',
|
||||
offline_promotion: '',
|
||||
offline_buy_limit: ''
|
||||
}
|
||||
this.getGoodsGiftActivityBack()
|
||||
} else {
|
||||
this.$message({
|
||||
message: res.msg,
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
this.addDialog = false
|
||||
this.getGoodsGiftActivityBack()
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
},
|
||||
//选择赠品
|
||||
chooseGifts() {
|
||||
this.giftsDialog = true;
|
||||
this.getGoodsGiftBack();
|
||||
},
|
||||
//点击了选择商品
|
||||
chooseGiftsOK(index, x) {
|
||||
if (this.giftsGoodsData.length >= 10) {
|
||||
this.$message({
|
||||
message: '赠品数量最多为10件',
|
||||
type: 'warning',
|
||||
});
|
||||
return
|
||||
}
|
||||
this.giftsData.some((item) => {
|
||||
if (item.gifts_id == x.gifts_id) {
|
||||
item.checked = true
|
||||
}
|
||||
})
|
||||
this.giftsGoodsData.push(x)
|
||||
console.log(this.giftsGoodsData);
|
||||
|
||||
},
|
||||
// 点击删除赠品
|
||||
deleteGifts(index) {
|
||||
this.giftsGoodsData.splice(index, 1)
|
||||
},
|
||||
//搜索
|
||||
onSubmit() {
|
||||
this.getGoodsGiftActivityBack()
|
||||
},
|
||||
|
||||
//添加活动
|
||||
addActivity() {
|
||||
this.addDialog = true;
|
||||
},
|
||||
//删除活动
|
||||
deleteActivity(id) {
|
||||
var id = id
|
||||
|
||||
var that = this
|
||||
this.$confirm('是否删除该活动?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: '/index.php/Retail/GoodsGifts/deleteGiftsActivityRecord',
|
||||
data: {
|
||||
activity_id: id
|
||||
},
|
||||
success: res => {
|
||||
if (res.status == 1) {
|
||||
this.$message({
|
||||
message: '删除成功',
|
||||
type: 'success',
|
||||
});
|
||||
that.getGoodsGiftActivityBack()
|
||||
}
|
||||
}
|
||||
})
|
||||
}).catch(() => {
|
||||
this.$message({
|
||||
type: 'info',
|
||||
message: '已取消删除'
|
||||
});
|
||||
});
|
||||
},
|
||||
//选择主商品
|
||||
chooseMain() {
|
||||
this.mainDialog = true;
|
||||
this.goodsGiftsActivityMain();
|
||||
},
|
||||
//确认选择主商品
|
||||
chooseMainOK(item) {
|
||||
console.log(item);
|
||||
this.mainGoodsData = [];
|
||||
this.mainGoodsData.push(item);
|
||||
this.mainDialog = false;
|
||||
|
||||
console.log(this.mainGoodsData);
|
||||
if (!item.attribute_state == 2) {
|
||||
this.getGoodsSkuAttrActivity(item.id)
|
||||
}
|
||||
},
|
||||
search_main() {
|
||||
this.mainCurrentPage = 1;
|
||||
this.goodsGiftsActivityMain();
|
||||
},
|
||||
search_gifts() {
|
||||
this.getGoodsGiftBack()
|
||||
},
|
||||
//选择规格
|
||||
checkSkuList(i) {
|
||||
var skulist = JSON.parse(JSON.stringify(this.skulist));
|
||||
skulist[i].sku_checked = !skulist[i].sku_checked;
|
||||
this.skulist = skulist
|
||||
},
|
||||
//确定选择规格
|
||||
chooseSkuOK() {
|
||||
var str = '';
|
||||
var arr = [];
|
||||
for (var i = 0; i < this.skulist.length; i++) {
|
||||
var item = this.skulist[i]
|
||||
if (item.sku_checked == true) {
|
||||
str = str + ';' + item.name[0]
|
||||
arr.push(item)
|
||||
}
|
||||
}
|
||||
str = str.substr(1)
|
||||
this.mainGoodsData[0].sku_info = str
|
||||
this.mainGoodsData[0].specifications = arr
|
||||
console.log(this.mainGoodsData);
|
||||
|
||||
this.specificationsDialog = false
|
||||
},
|
||||
//详情
|
||||
goodsDetail(id) {
|
||||
this.detailDialog = true;
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: '/index.php/Retail/GoodsGifts/goodsGiftsActivityDetails',
|
||||
data: {
|
||||
activity_id: id
|
||||
},
|
||||
success: res => {
|
||||
if (res.status == 1) {
|
||||
console.log(1);
|
||||
this.detailDialog = true;
|
||||
this.detailInfo = res.data
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
},
|
||||
//页码改变
|
||||
CurrentChange(val) {
|
||||
this.currentPage = val;
|
||||
this.getGoodsGiftActivityBack()
|
||||
},
|
||||
mainCurrentChange(val) {
|
||||
this.mainCurrentPage = val;
|
||||
this.goodsGiftsActivityMain();
|
||||
},
|
||||
giftsCurrentChange(val) {
|
||||
this.giftsCurrentPage = val;
|
||||
this.getGoodsGiftBack();
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
@@ -0,0 +1,672 @@
|
||||
<!--[1.6.48]-->
|
||||
<style>
|
||||
.chooseGoods {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
height: calc(100vh - 190px);
|
||||
}
|
||||
|
||||
.selected-goods {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.chooseGoodsTables {
|
||||
margin: 0 20px 20px 0;
|
||||
display: inline-block;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.max-dialog-content {
|
||||
margin-left: 160px;
|
||||
height: calc(100vh - 65px);
|
||||
box-sizing: border-box;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.goods-img {
|
||||
max-width: 32px;
|
||||
max-height: 32px;
|
||||
}
|
||||
|
||||
#giftGoods .el-pagination {
|
||||
border: 1px solid #ebeef5;
|
||||
border-top: 0;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
#giftGoods .max-dialog-content .el-dialog__footer {
|
||||
padding: 0 20px 0;
|
||||
}
|
||||
|
||||
#giftGoods .max-dialog-content .el-dialog__body {
|
||||
padding: 10px 20px;
|
||||
}
|
||||
|
||||
#giftGoods .dialog-footer {
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
<div id="giftGoods" v-cloak>
|
||||
<el-form :inline="true" size="small">
|
||||
<el-form-item>
|
||||
<el-input v-model="gift_keyword" clearable placeholder="请输入商品名称"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-select v-model="select_state" clearable placeholder="赠品状态">
|
||||
<el-option v-for="item in stateList" :key="item.value"
|
||||
:label="item.label" :value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-date-picker v-model="timeData"
|
||||
style="margin-top: 1px"
|
||||
type="datetimerange"
|
||||
value-format="yyyy-MM-dd HH:mm:ss"
|
||||
range-separator="至"
|
||||
start-placeholder="开始时间"
|
||||
end-placeholder="结束时间"></el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="searchGifts" size="small" plain>搜索</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button v-if="operate.chooseGoodsJoinGifts"
|
||||
type="primary"
|
||||
@click="addSendGoods"
|
||||
size="small"
|
||||
plain>添加赠品
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<!-- 赠品列表 -->
|
||||
<template>
|
||||
<el-table :data="giftsList" border align="center" size="small" style="width: 100%">
|
||||
<el-table-column align="center" label="序号" type="index" width="50"></el-table-column>
|
||||
<el-table-column align="center" prop="goods_name" label="商品名称" min-width="100px"
|
||||
show-overflow-tooltip></el-table-column>
|
||||
<el-table-column align="center" prop="sku_name" label="商品规格" min-width="100px"
|
||||
show-overflow-tooltip></el-table-column>
|
||||
<el-table-column align="center" prop="remain_inventory" label="赠品库存" min-width="100px"></el-table-column>
|
||||
<el-table-column align="center" prop="goods_num" label="剩余库存" min-width="100px"></el-table-column>
|
||||
<el-table-column align="center" prop="created_at" label="添加时间" min-width="130px"
|
||||
show-overflow-tooltip></el-table-column>
|
||||
<el-table-column align="center" label="赠品状态" min-width="70px">
|
||||
<template slot-scope="scope">
|
||||
<el-switch v-model="scope.row.status"
|
||||
active-value="1"
|
||||
inactive-value="0"
|
||||
:disabled="!operate.updateGiftsStatus"
|
||||
@change="switchChange(scope.$index)">
|
||||
</el-switch>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="操作" width="130px">
|
||||
<template slot-scope="scope">
|
||||
<el-button v-if="operate.updateGiftsInventory"
|
||||
type="text"
|
||||
size="mini" @click="goodsSet(scope.row)">库存设置
|
||||
</el-button>
|
||||
<el-button v-if="operate.deleteGiftsRecord"
|
||||
type="text"
|
||||
size="mini"
|
||||
style="color: #999;"
|
||||
@click="deleteGoods(scope.row.gifts_id)">删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!-- 分页 -->
|
||||
<el-pagination @current-change="CurrentChange"
|
||||
:current-page="currentPage"
|
||||
:page-sizes="[10]"
|
||||
:page-size="pageSize"
|
||||
layout="total, sizes, prev, pager, next, jumper" :total="total">
|
||||
</el-pagination>
|
||||
</template>
|
||||
<!-- 库存设置 -->
|
||||
<el-dialog title="库存设置" :append-to-body="true" :visible.sync="goodsSetDialog" width="30%">
|
||||
<el-form label-width="100px" size="small">
|
||||
<el-form-item label="商品库存:">
|
||||
<span>{{giftsSetForm.goods_num}}</span>
|
||||
<span style="color: #999">该库存不包含赠品库存</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="赠品库存:">
|
||||
<span>{{giftsSetForm.remain_inventory}}</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="操作:">
|
||||
<el-radio v-model="giftsSetForm.operate_type" :label="1">增加库存</el-radio>
|
||||
<el-radio v-model="giftsSetForm.operate_type" :label="0">减少库存</el-radio>
|
||||
</el-form-item>
|
||||
<el-form-item label="数量:">
|
||||
<el-input style="width: 150px"
|
||||
v-model="giftsSetForm.operate_num"
|
||||
oninput="value=this.value.replace(/^[0]|\D/,'')"
|
||||
placeholder="请输入操作数量"></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" size="small" @click="setOK">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
<!-- 选择商品 -->
|
||||
<el-dialog title="选择商品"
|
||||
:visible.sync="chooseGoodsDialog"
|
||||
:modal-append-to-body="false"
|
||||
:append-to-body="false"
|
||||
:top="'65px'"
|
||||
:width="'calc(100vw - 160px)'"
|
||||
:custom-class="'max-dialog-content'"
|
||||
:close-on-press-escape="false"
|
||||
:before-close="closeChild"
|
||||
:close-on-click-modal="false">
|
||||
<el-scrollbar class="chooseGoods">
|
||||
<!-- 商品信息 -->
|
||||
<div class="chooseGoodsTables">
|
||||
<el-form :inline="true">
|
||||
<el-form-item label="商品信息">
|
||||
<el-input v-model="goods_keyword" size="small"
|
||||
@keydown.enter.exact.native.prevent="searchChooseGoods"
|
||||
clearable placeholder="请输入商品名称">
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="searchChooseGoods" size="small" plain>搜索</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<!-- 商品信息表格 -->
|
||||
<template>
|
||||
<el-table :data="chooseGoodsTable" border size="mini">
|
||||
<el-table-column type="index" label="序号" align="center" width="50"></el-table-column>
|
||||
<el-table-column align="center" prop="goods_name" show-overflow-tooltip
|
||||
label="商品名称"></el-table-column>
|
||||
<el-table-column align="center" label="图片" width="60px">
|
||||
<template slot-scope="scope">
|
||||
<el-image class="goods-img" :src="scope.row.goods_img?scope.row.goods_img:''">
|
||||
<div slot="error" class="image-slot">
|
||||
<i class="el-icon-picture-outline"></i>
|
||||
</div>
|
||||
</el-image>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" prop="sku_name" label="商品规格"
|
||||
show-overflow-tooltip></el-table-column>
|
||||
<el-table-column align="center" prop="goods_num" label="库存"></el-table-column>
|
||||
<el-table-column align="center" prop="retail_price" label="零售价"></el-table-column>
|
||||
<el-table-column align="center" label="操作">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="text"
|
||||
size="mini"
|
||||
:disabled="alreadyChoose.length>=max_choose_num?true:false"
|
||||
@click="chooseGoods(scope.row)"
|
||||
v-if="checkGoods(scope.row)">选择
|
||||
</el-button>
|
||||
<el-button v-else type="text" style="color: #666;" size="mini">已选</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</template>
|
||||
<!-- 分页 -->
|
||||
<el-pagination @current-change="chooseGoodsCurrentChange"
|
||||
:current-page="chooseGoodsCurrentPage"
|
||||
:page-sizes="[10]" :page-size="pageSize"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
:total="chooseGoodsTotal">
|
||||
</el-pagination>
|
||||
</div>
|
||||
<!-- 已选商品 -->
|
||||
<div class="chooseGoodsTables">
|
||||
<el-form :inline="true" class="demo-form-inline">
|
||||
<el-form-item label="已选商品">
|
||||
<el-input v-model="select_keyword"
|
||||
size="small"
|
||||
clearable
|
||||
@input="goodsNull"
|
||||
@keydown.enter.exact.native.prevent="searchChooseGoodsTable"
|
||||
placeholder="请输入商品名称"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="searchChooseGoodsTable" size="small" plain>搜索</el-button>
|
||||
<el-button v-if="alreadyChoose.length" @click="toClearChoose" size="small">清空已选</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-scrollbar class="selected-goods">
|
||||
<el-table :data="showAlreadyChoose" border size="mini" height="calc(100vh - 273px)">
|
||||
<el-table-column type="index" label="序号" align="center" 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" label="图片" width="60px">
|
||||
<template slot-scope="scope">
|
||||
<el-image class="goods-img" :src="scope.row.goods_img?scope.row.goods_img:''">
|
||||
<div slot="error" class="image-slot">
|
||||
<i class="el-icon-picture-outline"></i>
|
||||
</div>
|
||||
</el-image>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" prop="sku_name" label="商品规格"
|
||||
show-overflow-tooltip></el-table-column>
|
||||
<el-table-column align="center" prop="goods_num" label="库存"></el-table-column>
|
||||
<el-table-column align="center" prop="retail_price" label="成本价"></el-table-column>
|
||||
<el-table-column align="center" label="赠品库存">
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model="scope.row.remain_inventory"
|
||||
oninput="value=this.value.replace(/^[0]|\D/,'')"
|
||||
size="small" clearable
|
||||
@blur="inventoryOver(scope.row)"></el-input>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="操作">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="text" size="mini" @click="deleteSelected(scope.$index,scope.row)">
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-scrollbar>
|
||||
</div>
|
||||
</el-scrollbar>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary"
|
||||
round
|
||||
@click="chooseAlready"
|
||||
:disabled="alreadyChoose.length==0"
|
||||
size="small">确定选择({{alreadyChoose.length}}/{{max_choose_num}})
|
||||
</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
<script type="text/javaScript">
|
||||
var giftGoods = new Vue({
|
||||
el: "#giftGoods",
|
||||
data: function () {
|
||||
return {
|
||||
gift_keyword: '',//赠品列表搜索关键词
|
||||
goods_keyword: '', //可选商品列表搜索关键词
|
||||
giftsList: [], //赠品库表格
|
||||
stateList: [
|
||||
{ // 下拉框
|
||||
value: '1',
|
||||
label: '开启'
|
||||
},
|
||||
{
|
||||
value: '0',
|
||||
label: '关闭'
|
||||
}
|
||||
],
|
||||
max_choose_num: 100,//最大选择数量
|
||||
select_state: '', // 下拉框值
|
||||
timeData: [], //选择的时间数组
|
||||
chooseGoodsTable: [], //可选商品数组
|
||||
goodsStatus: '', //商品状态
|
||||
goodsChange: '1', // 商品单选
|
||||
goodsNum: '', //商品数量
|
||||
goodsSetDialog: false, //商品库存弹框
|
||||
chooseGoodsDialog: false, //选择商品弹框
|
||||
goodsInfoTable: [], // 商品信息表格
|
||||
currentPage: 1, //当前页
|
||||
chooseGoodsCurrentPage: 1, //可选商品当前页
|
||||
pageSize: 10, //每页展示条信息
|
||||
total: 0, //总计数据
|
||||
chooseGoodsTotal: 0, //可选商品总计
|
||||
giftsSetForm: {
|
||||
gifts_id: 0,//赠品库id
|
||||
goods_num: '',//赠品数量
|
||||
remain_inventory: '',//系统数量
|
||||
operate_num: '',//操作数量
|
||||
operate_type: 1,//操作类型 1增加 2减少
|
||||
},
|
||||
chooseGoodsObj: {},//已选商品id信息
|
||||
operate: {},//操作权限
|
||||
chooseGoodsOK: true, //选择商品
|
||||
alreadyChoose: [], //已选商品列表
|
||||
showAlreadyChoose: [], //展示已选商品列表
|
||||
select_keyword: '', //已选列表搜索关键词
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getGoodsGiftBack();
|
||||
//获取操作权限
|
||||
var auth_list = {
|
||||
updateGiftsStatus: '/index.php/Retail/GoodsGifts/updateGiftsStatus',
|
||||
deleteGiftsRecord: '/index.php/Retail/GoodsGifts/deleteGiftsRecord',
|
||||
chooseGoodsJoinGifts: '/index.php/Retail/GoodsGifts/chooseGoodsJoinGifts',
|
||||
updateGiftsInventory: '/index.php/Retail/GoodsGifts/updateGiftsInventory'
|
||||
};
|
||||
$.ajax({
|
||||
url: "{:U('Retail/Component/checkOperateAuth')}",
|
||||
type: "post",
|
||||
data: {
|
||||
auth_list: JSON.stringify(auth_list),
|
||||
},
|
||||
success: (res) => {
|
||||
if (res.status == 1) {
|
||||
this.operate = res.data;
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
//关闭选择赠品弹框
|
||||
closeChild() {
|
||||
if (this.alreadyChoose.length > 0) {
|
||||
this.$confirm("关闭后所选商品将清空,确认关闭?", "关闭提示", {
|
||||
confirmButtonText: '确认关闭',
|
||||
cancelButtonText: '取消关闭',
|
||||
type: 'info'
|
||||
}).then(() => {
|
||||
this.chooseGoodsDialog = false;
|
||||
this.clearChoose();
|
||||
}).catch(() => {
|
||||
})
|
||||
} else {
|
||||
this.chooseGoodsDialog = false;
|
||||
}
|
||||
},
|
||||
//即将清空已选
|
||||
toClearChoose() {
|
||||
this.$confirm("确认清空已选商品列表?", "关闭提示", {
|
||||
confirmButtonText: '清空',
|
||||
cancelButtonText: '取消',
|
||||
type: 'info'
|
||||
}).then(() => {
|
||||
this.clearChoose();
|
||||
}).catch(() => {
|
||||
})
|
||||
},
|
||||
//清空已选列表
|
||||
clearChoose() {
|
||||
this.alreadyChoose = [];
|
||||
this.showAlreadyChoose = [];
|
||||
this.chooseGoodsObj = {};
|
||||
},
|
||||
//获取赠品库列表
|
||||
getGoodsGiftBack() {
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: '/index.php/Retail/GoodsGifts/getGoodsGiftBack',
|
||||
data: {
|
||||
page: this.currentPage,
|
||||
pageSize: 10,
|
||||
start_time: this.timeData ? this.timeData[0] : '',
|
||||
end_time: this.timeData ? this.timeData[1] : '',
|
||||
status: this.select_state,
|
||||
search: this.gift_keyword,
|
||||
},
|
||||
success: res => {
|
||||
if (res.status == 1) {
|
||||
this.giftsList = res.data.list;
|
||||
this.total = parseInt(res.data.total);
|
||||
}
|
||||
if (res.status == 0) {
|
||||
console.log(res);
|
||||
this.giftsList = [];
|
||||
this.total = 0;
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
//获取可选商品
|
||||
adminCanChooseBySku() {
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: '/index.php/Retail/GoodsGifts/adminCanChooseBySku',
|
||||
data: {
|
||||
keyword: this.goods_keyword,
|
||||
page: this.chooseGoodsCurrentPage,
|
||||
pageSize: 10,
|
||||
},
|
||||
success: res => {
|
||||
if (res.status == 1) {
|
||||
this.chooseGoodsTable = [];
|
||||
this.chooseGoodsTable = res.data;
|
||||
this.chooseGoodsTotal = parseInt(res.total);
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
//搜索赠品
|
||||
searchGifts() {
|
||||
this.currentPage = 1;
|
||||
this.getGoodsGiftBack()
|
||||
},
|
||||
//已选列表搜索
|
||||
searchChooseGoodsTable() {
|
||||
this.showAlreadyChoose = [];
|
||||
if (this.select_keyword == '') {
|
||||
this.showAlreadyChoose = this.alreadyChoose;
|
||||
} else {
|
||||
for (let i = 0; i < this.alreadyChoose.length; i++) {
|
||||
if (this.fuzzySearch(this.alreadyChoose[i].goods_name, this.select_keyword)) {
|
||||
this.showAlreadyChoose.push(this.alreadyChoose[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
//模糊搜索商品名称
|
||||
fuzzySearch(name, keyword) {
|
||||
if (keyword === '' || keyword === undefined) {
|
||||
return true;
|
||||
}
|
||||
let len = 0;
|
||||
let arr = String(keyword).split('');
|
||||
for (let i in arr) {
|
||||
console.log(arr[i]);
|
||||
if (name.indexOf(arr[i]) != -1) {
|
||||
len++;
|
||||
}
|
||||
}
|
||||
if (len == arr.length) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
//清空已选搜索关键词
|
||||
goodsNull(e) {
|
||||
if (!e) {
|
||||
this.showAlreadyChoose = this.alreadyChoose
|
||||
}
|
||||
},
|
||||
//修改赠品状态
|
||||
switchChange(index) {
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: '/index.php/Retail/GoodsGifts/updateGiftsStatus',
|
||||
data: {
|
||||
gifts_id: this.giftsList[index].gifts_id,
|
||||
},
|
||||
success: res => {
|
||||
if (res.status == 1) {
|
||||
console.log(res);
|
||||
this.$message({
|
||||
message: '修改成功',
|
||||
type: 'success'
|
||||
});
|
||||
} else {
|
||||
var giftsList = JSON.parse(JSON.stringify(this.giftsList));
|
||||
giftsList[index].status = giftsList[index].status == 1 ? '0' : '1';
|
||||
this.giftsList = [];
|
||||
this.giftsList = giftsList;
|
||||
this.$message.error(res.msg);
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
},
|
||||
//显示选择赠品
|
||||
addSendGoods() {
|
||||
this.chooseGoodsDialog = true;
|
||||
this.adminCanChooseBySku();
|
||||
},
|
||||
//删除赠品
|
||||
deleteGoods(id) {
|
||||
this.$confirm('是否删除该商品并恢复库存?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: '/index.php/Retail/GoodsGifts/deleteGiftsRecord',
|
||||
data: {
|
||||
gifts_id: id,
|
||||
},
|
||||
success: res => {
|
||||
if (res.status == 1) {
|
||||
console.log(res);
|
||||
this.$message({
|
||||
message: '删除成功',
|
||||
type: 'success'
|
||||
});
|
||||
} else {
|
||||
this.$message.error('删除失败');
|
||||
}
|
||||
}
|
||||
})
|
||||
this.getGoodsGiftBack()
|
||||
}).catch(() => {
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
//显示设置赠品库存
|
||||
goodsSet(item) {
|
||||
this.giftsSetForm = {
|
||||
gifts_id: item.gifts_id,
|
||||
goods_num: item.goods_num * 1,
|
||||
remain_inventory: item.remain_inventory * 1,
|
||||
operate_num: '',
|
||||
operate_type: 1,
|
||||
};
|
||||
this.goodsSetDialog = true;
|
||||
},
|
||||
//搜索待选列表
|
||||
searchChooseGoods() {
|
||||
this.chooseGoodsCurrentPage = 1;
|
||||
this.adminCanChooseBySku();
|
||||
},
|
||||
//判断商品是否可选
|
||||
checkGoods(item) {
|
||||
return !this.chooseGoodsObj[`${item.goods_id},${item.sku_id}`];
|
||||
},
|
||||
//点击了选择商品
|
||||
chooseGoods(item) {
|
||||
item = JSON.parse(JSON.stringify(item));
|
||||
this.chooseGoodsObj[`${item.goods_id},${item.sku_id}`] = true;
|
||||
this.alreadyChoose.unshift(item);
|
||||
if (this.select_keyword) {
|
||||
if (this.fuzzySearch(item.goods_name, this.select_keyword)) {
|
||||
this.showAlreadyChoose.unshift(item);
|
||||
}
|
||||
} else {
|
||||
this.showAlreadyChoose.unshift(item);
|
||||
}
|
||||
var chooseGoodsTable = JSON.parse(JSON.stringify(this.chooseGoodsTable));
|
||||
this.chooseGoodsTable = [];
|
||||
this.chooseGoodsTable = chooseGoodsTable;
|
||||
},
|
||||
//删除已选商品
|
||||
deleteSelected(index, item) {
|
||||
delete this.chooseGoodsObj[`${item.goods_id},${item.sku_id}`];
|
||||
this.alreadyChoose.splice(index, 1);
|
||||
this.showAlreadyChoose.splice(index, 1);
|
||||
var chooseGoodsTable = JSON.parse(JSON.stringify(this.chooseGoodsTable));
|
||||
this.chooseGoodsTable = [];
|
||||
this.chooseGoodsTable = chooseGoodsTable;
|
||||
},
|
||||
// 赠品列表页码改变
|
||||
CurrentChange(val) {
|
||||
this.currentPage = val;
|
||||
this.getGoodsGiftBack();
|
||||
},
|
||||
//可选商品页码改变
|
||||
chooseGoodsCurrentChange(val) {
|
||||
this.chooseGoodsCurrentPage = val;
|
||||
this.adminCanChooseBySku();
|
||||
},
|
||||
//已选列表输入库存失焦判断库存
|
||||
inventoryOver(x) {
|
||||
if (x.remain_inventory > x.goods_num) {
|
||||
this.$message({
|
||||
message: '库存不足',
|
||||
type: 'warning',
|
||||
});
|
||||
this.showAlreadyChoose.some((item) => {
|
||||
if (item.goods_id == x.goods_id) {
|
||||
item.remain_inventory = ''
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
// 提交添加赠品
|
||||
chooseAlready() {
|
||||
this.$confirm("确认将已选商品添加到赠品库?", "提示", {
|
||||
confirmButtonText: '确认添加',
|
||||
cancelButtonText: '取消',
|
||||
type: 'info'
|
||||
}).then(() => {
|
||||
var arr = [];
|
||||
for (var i in this.alreadyChoose) {
|
||||
arr.push({
|
||||
sale_goods_id: this.alreadyChoose[i].sale_goods_id,
|
||||
goods_id: this.alreadyChoose[i].goods_id,
|
||||
sku_id: this.alreadyChoose[i].sku_id,
|
||||
remain_inventory: this.alreadyChoose[i].remain_inventory ? this.alreadyChoose[i].remain_inventory : 0,
|
||||
})
|
||||
}
|
||||
console.log(arr);
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: '/index.php/Retail/GoodsGifts/chooseGoodsJoinGifts',
|
||||
data: {
|
||||
gifts_json: JSON.stringify(arr),
|
||||
},
|
||||
success: res => {
|
||||
if (res.status == 1) {
|
||||
this.$message({
|
||||
message: res.msg,
|
||||
type: 'success',
|
||||
});
|
||||
this.clearChoose();
|
||||
this.chooseGoodsDialog = false;
|
||||
this.getGoodsGiftBack()
|
||||
} else {
|
||||
this.$message({
|
||||
message: res.msg,
|
||||
type: 'error',
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
}).catch(() => {
|
||||
})
|
||||
},
|
||||
//保存修改赠品库存操作
|
||||
setOK() {
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: '/index.php/Retail/GoodsGifts/updateGiftsInventory',
|
||||
data: {
|
||||
gifts_id: this.giftsSetForm.gifts_id,
|
||||
remain_inventory: this.giftsSetForm.operate_num,
|
||||
type: this.giftsSetForm.operate_type,
|
||||
},
|
||||
success: res => {
|
||||
if (res.status == 1) {
|
||||
this.getGoodsGiftBack();
|
||||
this.$message({
|
||||
message: '库存设置成功',
|
||||
type: 'success'
|
||||
});
|
||||
this.goodsSetDialog = false;
|
||||
} else {
|
||||
this.$message.error('库存设置失败');
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
}
|
||||
})
|
||||
</script>
|
||||
在新工单中引用
屏蔽一个用户