1001 行
42 KiB
HTML
可执行文件
1001 行
42 KiB
HTML
可执行文件
<!--[1.8.50]-->
|
||
<style>
|
||
.el-pagination {
|
||
padding: 8px;
|
||
}
|
||
|
||
.center-content > .el-input {
|
||
width: 200px;
|
||
margin-bottom: 10px;
|
||
}
|
||
|
||
.el-table__row > td:last-child > .cell {
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.center-content {
|
||
margin: 0 0 10px;
|
||
}
|
||
|
||
.center-content .el-input__inner {
|
||
padding: 0 15px;
|
||
text-align: left;
|
||
}
|
||
|
||
.table-cell-flex-row {
|
||
display: flex;
|
||
align-items: center;
|
||
}
|
||
|
||
.table-cell-img {
|
||
width: 40px;
|
||
max-height: 40px;
|
||
max-width: 40px;
|
||
cursor: pointer;
|
||
margin-right: 10px;
|
||
}
|
||
|
||
.table-cell-long-text {
|
||
flex: 1;
|
||
overflow: hidden;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.table-cell-long-text > div {
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
line-height: 20px;
|
||
}
|
||
|
||
.table-cell-flex-column {
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
|
||
.table-cell-flex-column .el-button {
|
||
margin-left: 0;
|
||
}
|
||
|
||
.big-img {
|
||
max-height: 50vh;
|
||
max-width: 100%;
|
||
}
|
||
|
||
.center-content .el-button {
|
||
margin: 5px;
|
||
}
|
||
|
||
.state-box {
|
||
display: flex;
|
||
align-items: center;
|
||
flex-wrap: wrap;
|
||
}
|
||
|
||
.state-box > .table-cell-long-text {
|
||
flex: none;
|
||
margin-right: 20px;
|
||
}
|
||
|
||
.more-operate-box {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
background: #ecf5ff;
|
||
padding-top: 8px;
|
||
padding-left: 10px;
|
||
margin-bottom: 10px;
|
||
}
|
||
|
||
.more-operate-box .el-button {
|
||
font-weight: normal;
|
||
}
|
||
|
||
.more-operate {
|
||
margin-bottom: 0 !important;
|
||
}
|
||
|
||
.more-operate .el-button + .el-button {
|
||
margin-left: 0;
|
||
}
|
||
|
||
.more-operate .el-button {
|
||
margin-right: 8px;
|
||
margin-bottom: 8px;
|
||
}
|
||
|
||
.normal-text {
|
||
color: #666;
|
||
font-weight: normal;
|
||
}
|
||
|
||
.goods-list-popover {
|
||
width: 90px;
|
||
min-width: 90px;
|
||
}
|
||
|
||
.goods-list-popover .el-cascader-panel .el-cascader-menu {
|
||
min-width: 80px;
|
||
}
|
||
|
||
.goods-list-popover .el-cascader-panel .el-cascader-menu__wrap {
|
||
height: auto;
|
||
}
|
||
|
||
.goods-list-popover .el-cascader-panel {
|
||
min-width: 90px;
|
||
border: none;
|
||
height: auto;
|
||
}
|
||
|
||
.batchEdit {
|
||
display: flex;
|
||
align-items: flex-start;
|
||
}
|
||
|
||
.batchEdit .el-tabs--left .el-tabs__item.is-left {
|
||
text-align: center;
|
||
line-height: 36px;
|
||
height: 36px;
|
||
}
|
||
</style>
|
||
|
||
<div class="goodsBox" id="mGoodsListApp">
|
||
<!--搜索及操作内容-->
|
||
<el-form label-width="90px" size="small">
|
||
<el-form-item label="关键词搜索">
|
||
<el-input :placeholder="'请输入'+(searchForm.keyword_type==1?'货号':(searchForm.keyword_type==2?'条码':'名称'))"
|
||
v-model="searchForm.keyword"
|
||
oninput="value=this.value.trim(' ')"
|
||
type="text"
|
||
clearable
|
||
style="width: 300px"
|
||
@keydown.enter.exact.native.prevent="searchGoods"
|
||
class="input-with-select">
|
||
<el-select v-model="searchForm.keyword_type"
|
||
style="width: 80px"
|
||
background slot="prepend">
|
||
<el-option label="货号" :value="1"></el-option>
|
||
<el-option label="条码" :value="2"></el-option>
|
||
<el-option label="名称" :value="3"></el-option>
|
||
</el-select>
|
||
</el-input>
|
||
|
||
<!--设置默认的搜索关键词类型-->
|
||
<default-search-goods-type @change-type="changeKeywordType"></default-search-goods-type>
|
||
|
||
</el-form-item>
|
||
<el-form-item label="商品分类">
|
||
<select-goods-category :user-type="1"
|
||
:category-id1.sync="searchForm.person1"
|
||
:category-id2.sync="searchForm.person2"
|
||
:category-id3.sync="searchForm.person3"></select-goods-category>
|
||
</el-form-item>
|
||
<template v-if="showMoreSearch">
|
||
<el-form-item label="排序规则">
|
||
<el-select clearable placeholder="排序关键字" v-model="searchForm.condition_name">
|
||
<el-option :value="1" label="添加时间"></el-option>
|
||
<el-option :value="2" label="货号"></el-option>
|
||
<el-option :value="4" label="商品名称"></el-option>
|
||
</el-select>
|
||
<el-select clearable placeholder="排序方式" filterable v-model="searchForm.order_type">
|
||
<el-option :value="1" label="升序"></el-option>
|
||
<el-option :value="2" label="降序"></el-option>
|
||
</el-select>
|
||
</el-form-item>
|
||
<el-form-item label="其他选项">
|
||
<el-select clearable placeholder="商品计量类型" v-model="searchForm.can_exchange_weigh">
|
||
<el-option :value="1" label="非称重"></el-option>
|
||
<el-option :value="2" label="称重"></el-option>
|
||
</el-select>
|
||
<el-select clearable placeholder="规格类型" v-model="searchForm.attribute">
|
||
<el-option :value="1" label="非规格"></el-option>
|
||
<el-option :value="2" label="多规格"></el-option>
|
||
</el-select>
|
||
<el-select clearable placeholder="商品状态" v-model="searchForm.status">
|
||
<el-option value="0" label="上架"></el-option>
|
||
<el-option value="1" label="下架"></el-option>
|
||
</el-select>
|
||
</el-form-item>
|
||
</template>
|
||
<el-form-item label="" class="more-operate">
|
||
<el-button type="text"
|
||
@click="showMoreSearch=!showMoreSearch">{{showMoreSearch?'隐藏':'显示'}}高级选项
|
||
</el-button>
|
||
</el-form-item>
|
||
<!--搜索-->
|
||
<div style="display: flex;justify-content: space-between">
|
||
<el-form-item label="">
|
||
<el-button type="primary" @click="searchGoods">搜索</el-button>
|
||
<el-button type="primary" plain
|
||
v-if="operate.goodsSet"
|
||
@click="setGoods()">新增商品
|
||
</el-button>
|
||
</el-form-item>
|
||
<!--新增、更多操作按钮-->
|
||
<el-form-item>
|
||
<el-button type="primary" plain
|
||
v-if="operate.simpleSet"
|
||
@click="simpleSet" size="small">简拼设置
|
||
</el-button>
|
||
</el-form-item>
|
||
</div>
|
||
<!--更多操作按钮列表-->
|
||
<div class="more-operate-box">
|
||
<el-form-item class="more-operate" label-width="0" v-if="operate.mGoods">
|
||
<el-button v-if="operate.batchOperateGoods" @click="toShowChangeGoods">批量设置</el-button>
|
||
<el-button @click="exportTable(1)">商品导出</el-button>
|
||
<el-button @click="SkuExportTable(1,500,1,'',1)">无规格商品导出</el-button>
|
||
<el-button @click="SkuExportTable(1,200,1,'',2)">规格商品导出</el-button>
|
||
</el-form-item>
|
||
|
||
<el-form-item class="more-operate">
|
||
<el-button v-if="operate.batch_del"
|
||
@click="batchDelGoods">批量删除
|
||
</el-button>
|
||
</el-form-item>
|
||
</div>
|
||
|
||
</el-form>
|
||
|
||
<!--商品列表-->
|
||
<div style="max-width: calc(100vw - 208px);">
|
||
<el-table
|
||
v-loading="loading"
|
||
:data="goodsList"
|
||
size="mini"
|
||
border :header-cell-style="{background:'#F5F7FA',color:'#606266'}"
|
||
style="width: 100%"
|
||
@selection-change="handleSelectionChange">
|
||
<el-table-column align="center" fixed type="selection" width="50"
|
||
@selection-change="handleSelectionChange"></el-table-column>
|
||
<el-table-column align="center" fixed type="index" label="序号" width="50"></el-table-column>
|
||
<el-table-column label="商品信息" fixed min-width="160px" show-overflow-tooltip>
|
||
<template slot-scope="scope" slot="header">
|
||
<el-tooltip class="item"
|
||
effect="dark"
|
||
placement="top-start">
|
||
<div slot="content">
|
||
<p>库存:供给仓当前的商品数量</p>
|
||
<p>成本价:移动加权平均值(当前供给仓的商品总入库价除以总数量的平均值)</p>
|
||
</div>
|
||
<div>商品信息<i class="el-icon-warning-outline"></i></div>
|
||
</el-tooltip>
|
||
</template>
|
||
<template slot-scope="scope">
|
||
<div class="table-cell-flex-row">
|
||
<el-image class="table-cell-img"
|
||
@click="seeBig(scope.row.goods_img)"
|
||
:src="scope.row.goods_img">
|
||
<div slot="error" class="image-slot">
|
||
<i class="el-icon-picture-outline"></i>
|
||
</div>
|
||
</el-image>
|
||
<div class="table-cell-long-text">
|
||
<div>名称:{{scope.row.goods_name}}</div>
|
||
<div v-if="scope.row.subheading">副标题:{{scope.row.subheading}}</div>
|
||
<div>库存:{{scope.row.goods_num}}</div>
|
||
<div>成本价:{{scope.row.purch_price}}</div>
|
||
</div>
|
||
</div>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="编号信息" min-width="160px">
|
||
<template slot-scope="scope">
|
||
<div>ID:<strong style="font-size: 14px">{{scope.row.id}}</strong></div>
|
||
<div class="table-cell-long-text">货号:{{scope.row.good_number}}</div>
|
||
<div class="table-cell-long-text">条码:{{scope.row.goods_code}}</div>
|
||
<div class="table-cell-long-text" v-if="platform_type == 2">Q3编码:{{scope.row.third_goods_code}}</div>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="价格信息(元)" min-width="160px">
|
||
<template slot-scope="scope">
|
||
<div class="table-cell-long-text">零售价:{{scope.row.retail_price}}</div>
|
||
<div class="table-cell-long-text">商城价:{{scope.row.online_price}}</div>
|
||
<div class="table-cell-long-text">店内会员价:{{scope.row.store_mem_price}}</div>
|
||
<div class="table-cell-long-text">商城会员价:{{scope.row.shop_mem_price}}</div>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="状态信息" min-width="140px">
|
||
<template slot-scope="scope">
|
||
<div class="state-box">
|
||
<div class="table-cell-long-text">
|
||
<span>是否上架:</span>
|
||
<el-switch @change="changeStatus(scope.$index,scope.row.status,scope.row.id)"
|
||
:disabled="!operate.changeStatus"
|
||
v-model="scope.row.status"
|
||
inactive-value="1"
|
||
active-value="0">
|
||
</el-switch>
|
||
</div>
|
||
<div class="table-cell-long-text">
|
||
<span>店内出售:</span>
|
||
<el-switch
|
||
@change="changeStoreState(scope.$index,scope.row.retail_state,scope.row.id)"
|
||
:disabled="!operate.changeOnlineState"
|
||
v-model="scope.row.retail_state"
|
||
inactive-value="0"
|
||
active-value="1">
|
||
</el-switch>
|
||
</div>
|
||
<div class="table-cell-long-text">
|
||
<span>商城出售:</span>
|
||
<el-switch
|
||
@change="changeOnline(scope.$index,scope.row.issellonline,scope.row.id,scope.row.goods_class_id)"
|
||
:disabled="!operate.changeOnlineState"
|
||
v-model="scope.row.issellonline"
|
||
inactive-value="0"
|
||
active-value="1">
|
||
</el-switch>
|
||
</div>
|
||
</div>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="优惠信息" min-width="140px">
|
||
<template slot-scope="scope">
|
||
<div class="table-cell-long-text">
|
||
<span>线上打折:</span>
|
||
<el-switch @change="changeOnlineDis(scope.$index,scope.row.vip_online_state,scope.row.id)"
|
||
:disabled="!operate.changeVipOnlineState"
|
||
v-model="scope.row.vip_online_state"
|
||
inactive-value="0"
|
||
active-value="1">
|
||
</el-switch>
|
||
</div>
|
||
<div class="table-cell-long-text">
|
||
<span>线下打折:</span>
|
||
<el-switch @change="changeRetailDis(scope.$index,scope.row.vip_retail_state,scope.row.id)"
|
||
:disabled="!operate.changeVipRetailState"
|
||
v-model="scope.row.vip_retail_state"
|
||
inactive-value="0"
|
||
active-value="1">
|
||
</el-switch>
|
||
</div>
|
||
</template>
|
||
</el-table-column>
|
||
|
||
<el-table-column prop="cate_name" label="类别名称" min-width="140px" show-overflow-tooltip></el-table-column>
|
||
<el-table-column fixed="right" align="center" label="操作" width='60px'>
|
||
<template slot-scope="scope">
|
||
<div class="table-cell-flex-column">
|
||
<el-button @click.native.prevent="setGoods(scope.row.id)"
|
||
v-if="operate.goodsSet"
|
||
type="text" size="small">编辑
|
||
</el-button>
|
||
|
||
<el-button @click.native.prevent="delGoods(scope.row.id)"
|
||
v-if="operate.singleDelete"
|
||
style="color: #999" type="text"
|
||
size="small">删除
|
||
</el-button>
|
||
</div>
|
||
</template>
|
||
</el-table-column>
|
||
</el-table>
|
||
<el-pagination
|
||
@size-change="handleSizeChange"
|
||
@current-change="handleCurrentChange"
|
||
:current-page="currentPage"
|
||
:page-sizes="[10, 15, 20, 25, 30, 35, 40, 45, 50]"
|
||
:page-size="100"
|
||
layout="total, sizes, prev, pager, next, jumper"
|
||
:total="currentLen">
|
||
</el-pagination>
|
||
</div>
|
||
<el-dialog title="图片详情"
|
||
:visible.sync="showBigImg"
|
||
:modal-append-to-body="false"
|
||
:append-to-body="false"
|
||
custom-class="small-dialog-content">
|
||
<div style="padding: 0 20px;text-align: center">
|
||
<a :href="bigImg" target="_blank">
|
||
<img class="big-img" :src="bigImg">
|
||
</a>
|
||
</div>
|
||
</el-dialog>
|
||
|
||
<el-dialog title="批量设置" :append-to-body="true"
|
||
:visible.sync="showBatchOperate" width="550px"
|
||
:before-close="closeBatchEdit"
|
||
custom-class="small-dialog-content">
|
||
<div class="batchEdit">
|
||
<el-tabs :tab-position="'left'"
|
||
style="height: 400px;"
|
||
v-model="changeForm.key"
|
||
@tab-click="selectedChangeKey(changeForm.key)">
|
||
<template v-if="operate.updateMGoods">
|
||
<el-tab-pane label="商品信息" name="goods_info"></el-tab-pane>
|
||
</template>
|
||
|
||
<el-tab-pane label="商品分类" name="goods_class_id"></el-tab-pane>
|
||
<el-tab-pane label="上下架状态" name="status"></el-tab-pane>
|
||
<el-tab-pane label="店内出售状态" name="retail_state"></el-tab-pane>
|
||
<el-tab-pane label="商城出售状态" name="online_state"></el-tab-pane>
|
||
<el-tab-pane label="会员店内打折状态" name="vip_retail_state"></el-tab-pane>
|
||
<el-tab-pane label="会员商城打折状态" name="vip_online_state"></el-tab-pane>
|
||
</el-tabs>
|
||
<el-form style="flex: 1" label-width="80px">
|
||
<template v-if="changeForm.key!=''">
|
||
<el-form-item v-if="changeForm.key=='status'" label="是否上架">
|
||
<el-switch v-model="changeForm.value"
|
||
:inactive-value="1"
|
||
:active-value="0">
|
||
</el-switch>
|
||
</el-form-item>
|
||
<el-form-item v-else-if="changeForm.key=='goods_class_id'" label="">
|
||
<div>请选择修改后的分类信息</div>
|
||
<select-goods-category :user-type="1"
|
||
:category-id.sync="changeForm.value"></select-goods-category>
|
||
</el-form-item>
|
||
<el-form-item v-else-if="'goods_info'==changeForm.key"></el-form-item>
|
||
<el-form-item v-else label="是否开启">
|
||
<el-switch v-model="changeForm.value"
|
||
:inactive-value="0"
|
||
:active-value="1">
|
||
</el-switch>
|
||
</el-form-item>
|
||
</template>
|
||
</el-form>
|
||
</div>
|
||
|
||
<div style="text-align: center;margin-top: 20px">
|
||
<el-button type="primary" :loading="submitLoading" size="small" plain @click="batchOperateGoods(1)">保存并关闭</el-button>
|
||
<el-button type="primary" :loading="submitLoading" size="small" @click="batchOperateGoods(0)">保存</el-button>
|
||
</div>
|
||
</el-dialog>
|
||
</div>
|
||
<script src="/Public/Retail/common/js/select-goods-category.js"></script>
|
||
<script src="/Public/Retail/js/default-search-goods-type.js"></script>
|
||
<script type="text/javascript">
|
||
var mGoodsListApp = new Vue({
|
||
el: '#mGoodsListApp',
|
||
data() {
|
||
return {
|
||
platform_type:1,
|
||
submitLoading: false,
|
||
merchant_id: localStorage.merchant_id,
|
||
showMoreSearch: false,//是否显示更多选项
|
||
operate: {},//操作权限
|
||
currentPage: 1,
|
||
currentLimit: 10,
|
||
currentLen: 0,
|
||
goodsList: [],
|
||
loading: true,
|
||
searchForm: {
|
||
keyword_type: 2,
|
||
keyword: '',
|
||
condition_name: '',
|
||
order_type: '',
|
||
can_exchange_weigh: '',
|
||
attribute: '',
|
||
status: '',
|
||
person1: '',
|
||
person2: '',
|
||
person3: '',
|
||
},
|
||
showBatchOperate: false,//是否显示批量修改商品
|
||
changeForm: {
|
||
key: 'status',
|
||
value: null,
|
||
},//批量修改商品信息
|
||
checkedList: [],
|
||
showBigImg: false,
|
||
bigImg: '',
|
||
}
|
||
},
|
||
methods: {
|
||
//商户平台类型 1默认系统 2微礼平台
|
||
getPlatformType(){
|
||
$.ajax({
|
||
url:'/index.php/Retail/Mgoods/getPlatformType',
|
||
type:"post",
|
||
data:{},
|
||
success:(res)=>{
|
||
this.platform_type = res.platform_type
|
||
}
|
||
})
|
||
},
|
||
//修改默认关键词类型
|
||
changeKeywordType(val) {
|
||
this.searchForm.keyword_type = val;
|
||
},
|
||
seeBig(img) {
|
||
if (img != '') {
|
||
this.showBigImg = true;
|
||
this.bigImg = img;
|
||
}
|
||
},
|
||
searchGoods() {
|
||
this.currentPage = 1;
|
||
this.getData();
|
||
},
|
||
getData() {
|
||
$.ajax({
|
||
url: "{:U(goodsList)}",
|
||
type: 'POST',
|
||
data: {
|
||
...this.searchForm,
|
||
page: this.currentPage,
|
||
limit: this.currentLimit,
|
||
},
|
||
success: (res) => {
|
||
if (res.code == 0) {
|
||
this.loading = false;
|
||
this.goodsList = [];
|
||
this.goodsList = res.data;
|
||
this.$nextTick(() => {
|
||
this.currentLen = parseInt(res.count);
|
||
})
|
||
} else {
|
||
this.$confirm(res.msg, '提示', {
|
||
confirmButtonText: '确定',
|
||
type: 'warning'
|
||
}).then(() => {
|
||
|
||
}).catch(() => {
|
||
});
|
||
}
|
||
}
|
||
});
|
||
},
|
||
handleSizeChange(val) {
|
||
this.currentLimit = val;//切换每页数量
|
||
this.currentPage = 1;
|
||
this.getData();
|
||
},
|
||
handleCurrentChange(val) {
|
||
this.currentPage = val;
|
||
this.getData();//切换页数
|
||
},
|
||
setGoods(id) {
|
||
MenuApp.pathData.push({
|
||
name: (id ? '编辑' : '新增') + '商品',
|
||
path: '/index.php/Retail/Mgoods/goodsSet' + (id ? ('?id=' + id) : ''),
|
||
onClose: () => {
|
||
this.getData();
|
||
}
|
||
})
|
||
},
|
||
delGoods(id) {
|
||
this.$confirm('您确认要删除该商品吗?', '提示', {
|
||
confirmButtonText: '确定',
|
||
cancelButtonText: '取消',
|
||
type: 'warning'
|
||
}).then(() => {
|
||
$.ajax({
|
||
url: "{:U('singleDelete')}",
|
||
type: "POST",
|
||
data: {id: id},
|
||
success: (res) => {
|
||
if (res.status == 1) {
|
||
this.getData();
|
||
this.$message.success(res.msg);
|
||
} else {
|
||
this.$message.error(res.msg);
|
||
}
|
||
}
|
||
})
|
||
}).catch(() => {
|
||
});
|
||
},
|
||
//商品、商城商品、无规格商品导出
|
||
exportTable(page = 1, online_state = '', attribute_state = '', type = 1, directory_name) {
|
||
this.loading = true;
|
||
this.loadingText = '文件生成中,请耐心等待';
|
||
if (type == 1) {
|
||
$.ajax({
|
||
url: "{:U('Exporttable/mGoods')}",
|
||
type: 'POST',
|
||
data: {
|
||
page: page,
|
||
keyword: this.searchForm.keyword,
|
||
keyword_type: this.searchForm.keyword_type,
|
||
condition_name: this.searchForm.condition_name,
|
||
order_type: this.searchForm.order_type,
|
||
can_exchange_weigh: this.searchForm.can_exchange_weigh,
|
||
person1: this.searchForm.person1,
|
||
person2: this.searchForm.person2,
|
||
person3: this.searchForm.person3,
|
||
issellonline: online_state,
|
||
attribute: attribute_state,
|
||
type: type,
|
||
directory_name: directory_name
|
||
},
|
||
success: (res) => {
|
||
if (res.status == 1) {
|
||
if (type == 1) {
|
||
this.exportTable(++page, online_state, attribute_state, res.type, res.directory_name);
|
||
} else {
|
||
this.loading = false;
|
||
}
|
||
} else {
|
||
this.loading = false;
|
||
this.$confirm(res.msg, '提示', {
|
||
confirmButtonText: '确定',
|
||
type: 'warning'
|
||
}).then(() => {
|
||
|
||
}).catch(() => {
|
||
});
|
||
}
|
||
},
|
||
error: (res) => {
|
||
this.loading = false;
|
||
}
|
||
});
|
||
} else {
|
||
this.loading = false;
|
||
window.location.href = `{:U('Exporttable/mGoods')}?directory_name=${directory_name}&issellonline=${online_state}&attribute=${attribute_state}`;
|
||
}
|
||
},
|
||
|
||
//规格商品导出
|
||
SkuExportTable(page = 1, limit = 200, type = 1, directory_name = '', attribute_state = 2) {
|
||
this.loading = true;
|
||
this.loadingText = '文件生成中,请耐心等待';
|
||
if (type == 1) {
|
||
$.ajax({
|
||
url: "{:U('SkuMGoodsExport')}",
|
||
type: 'POST',
|
||
data: {
|
||
page: page,
|
||
limit: limit,
|
||
type: type,
|
||
directory_name: directory_name,
|
||
attribute_state: attribute_state,
|
||
...this.searchForm,
|
||
},
|
||
success: (res) => {
|
||
this.loading = false;
|
||
if (res.status == 1) {
|
||
this.SkuExportTable(++page, limit, res.data.type, res.data.directory_name, attribute_state);
|
||
} else {
|
||
this.$confirm(res.message, '提示', {
|
||
confirmButtonText: '确定',
|
||
type: 'warning'
|
||
}).then(() => {
|
||
|
||
}).catch(() => {
|
||
});
|
||
}
|
||
},
|
||
});
|
||
} else {
|
||
this.loading = false;
|
||
window.open(`{:U('exportFile')}?file_path=${directory_name}&attribute_state=${attribute_state}`);
|
||
}
|
||
},
|
||
changeClass() {
|
||
layer.open({
|
||
type: 2,
|
||
title: "批量修改分类",
|
||
content: "{:U('move_class')}",
|
||
area: ["calc(100% - 160px)", "calc(100% - 65px)"],
|
||
offset: 'rb',
|
||
resize: false,
|
||
shade: 0,
|
||
move: false,
|
||
end: () => {
|
||
if (localStorage.isChangeClass == 1) {
|
||
localStorage.isChangeClass = null;
|
||
this.getData();
|
||
}
|
||
}
|
||
})
|
||
},
|
||
batchDelGoods() {
|
||
if (this.checkedList.length == 0) {
|
||
return this.$message.warning('请选择需要删除的商品');
|
||
}
|
||
$.ajax({
|
||
url: "{:U('batch_del')}",
|
||
type: "POST",
|
||
data: {del_data: this.checkedList},
|
||
success: (res) => {
|
||
if (res.status == 1) {
|
||
this.$message.success(res.msg);
|
||
this.getData();
|
||
} else {
|
||
this.$message.error(res.msg);
|
||
}
|
||
}
|
||
})
|
||
},
|
||
handleSelectionChange(data) {
|
||
this.checkedList = [];
|
||
this.checkedList = data;
|
||
},
|
||
updateMGoods() {
|
||
if (this.checkedList.length == 0) {
|
||
return this.$message.warning('请选择需要修改的商品');
|
||
}
|
||
var id = '';
|
||
for (var i = 0; i < this.checkedList.length; i++) {
|
||
id += this.checkedList[i]['id'] + ",";
|
||
}
|
||
layer.open({
|
||
type: 2,
|
||
title: "批量修改商品",
|
||
content: "{:U('Mgoods/updateMGoods')}?id=" + id,
|
||
area: ["calc(100% - 160px)", "calc(100% - 65px)"],
|
||
offset: 'rb',
|
||
shade: 0,
|
||
resize: false,
|
||
move: false,
|
||
end: () => {
|
||
this.getData();
|
||
}
|
||
})
|
||
},
|
||
//简拼设置
|
||
simpleSet() {
|
||
layer.open({
|
||
type: 2,
|
||
title: "简拼设置",
|
||
content: "{:U('simple')}",
|
||
area: ["calc(100% - 160px)", "calc(100% - 65px)"],
|
||
offset: 'rb',
|
||
shade: 0,
|
||
resize: false,
|
||
move: false,
|
||
end: () => {
|
||
this.getData();
|
||
}
|
||
})
|
||
},
|
||
changeStoreState(index, status, id) {
|
||
$.ajax({
|
||
url: "{:U('changeStoreState')}",
|
||
type: 'POST',
|
||
data: {
|
||
status: status,
|
||
id: id
|
||
},
|
||
success: (res) => {
|
||
if (res.status == 1) {
|
||
this.$message.success('修改成功')
|
||
} else {
|
||
this.$message.error('修改失败')
|
||
this.goodsList[index].retail_state = status == 1 ? '0' : '1';
|
||
}
|
||
}
|
||
})
|
||
},
|
||
changeOnline(index, status, id) {
|
||
$.ajax({
|
||
url: "{:U('changeOnlineState')}",
|
||
type: 'POST',
|
||
data: {
|
||
issellonline: status,
|
||
id: id
|
||
},
|
||
success: (res) => {
|
||
if (res.status == 1) {
|
||
this.$message.success('修改成功')
|
||
} else {
|
||
this.$message.error('修改失败')
|
||
this.goodsList[index].online_state = status == 1 ? '0' : '1';
|
||
}
|
||
}
|
||
})
|
||
},
|
||
changeStatus(index, status, id) {
|
||
//修改商品上下架状态
|
||
$.ajax({
|
||
url: "{:U('changeStatus')}",
|
||
type: 'POST',
|
||
data: {
|
||
status: status,
|
||
id: id
|
||
},
|
||
success: (res) => {
|
||
if (res.status == 1) {
|
||
this.$message.success('修改成功')
|
||
} else {
|
||
this.$message.error('修改失败')
|
||
this.goodsList[index].status = status == 1 ? '0' : '1';
|
||
}
|
||
}
|
||
})
|
||
},
|
||
changeOnlineDis(index, status, id) {
|
||
$.ajax({
|
||
url: "{:U('changeVipOnlineState')}",
|
||
type: 'POST',
|
||
data: {
|
||
vip_online_state: status,
|
||
id: id
|
||
},
|
||
success: (res) => {
|
||
if (res.status == 1) {
|
||
this.$message.success('修改成功')
|
||
} else {
|
||
this.$message.error('修改失败')
|
||
this.goodsList[index].vip_online_state = status == 1 ? '0' : '1';
|
||
}
|
||
}
|
||
})
|
||
},
|
||
changeRetailDis(index, status, id) {
|
||
$.ajax({
|
||
url: "{:U('changeVipRetailState')}",
|
||
type: 'POST',
|
||
data: {
|
||
vip_retail_state: status,
|
||
id: id
|
||
},
|
||
success: (res) => {
|
||
if (res.status == 1) {
|
||
this.$message.success('修改成功')
|
||
} else {
|
||
this.$message.error('修改失败')
|
||
this.goodsList[index].vip_retail_state = status == 1 ? '0' : '1';
|
||
}
|
||
}
|
||
})
|
||
},
|
||
|
||
//显示批量设置
|
||
toShowChangeGoods() {
|
||
if (!this.checkedList.length) {
|
||
return this.$message.info('请先选择需要修改的商品');
|
||
}
|
||
this.changeForm.key = 'status';
|
||
this.showBatchOperate = true;
|
||
},
|
||
closeBatchEdit() {
|
||
this.showBatchOperate = false;
|
||
this.getData();
|
||
},
|
||
//选择批量修改的字段
|
||
selectedChangeKey(val) {
|
||
//重置value值
|
||
console.log(val);
|
||
switch (val) {
|
||
case 'status':
|
||
this.changeForm.value = 1;
|
||
break;
|
||
case 'retail_state':
|
||
case 'online_state':
|
||
case 'vip_retail_state':
|
||
case 'vip_online_state':
|
||
this.changeForm.value = 0;
|
||
break;
|
||
case 'goods_class_id':
|
||
this.changeForm.value = '';
|
||
break;
|
||
case 'goods_info':
|
||
var id = [];
|
||
for (var i = 0; i < this.checkedList.length; i++) {
|
||
id.push(this.checkedList[i]['id']);
|
||
}
|
||
id = id.join(',');
|
||
let urlArr = {
|
||
'goods_info': {title: '批量修改商品', url: 'updateMGoods' + "?id=" + id},
|
||
};
|
||
layer.open({
|
||
type: 2,
|
||
content: "/index.php/Retail/Mgoods/" + urlArr[val].url,
|
||
title: urlArr[val].title,
|
||
area: ["calc(100% - 160px)", "calc(100% - 65px)"],
|
||
offset: 'rb',
|
||
shade: 0,
|
||
resize: false,
|
||
move: false,
|
||
end: () => {
|
||
this.getData();
|
||
}
|
||
});
|
||
this.showBatchOperate = false;
|
||
break;
|
||
default:
|
||
}
|
||
},
|
||
//保存设置
|
||
batchOperateGoods(close) {
|
||
if (this.changeForm.key == '') return this.$message.warning('请选择修改的内容');
|
||
if (this.changeForm.key == 'goods_class_id' && !this.changeForm.value) return this.$message.warning('请完善分类');
|
||
|
||
let goodsList = [];
|
||
for (let i = 0; i < this.checkedList.length; i++) {
|
||
if (this.changeForm.key == 'retail_state' && !parseFloat(this.checkedList[i].retail_price)) {
|
||
return this.$message.warning('第' + (i + 1) + '个商品未设置店内零售价,不可开启店内出售');
|
||
}
|
||
if (this.changeForm.key == 'online_state' && !parseFloat(this.checkedList[i].online_price)) {
|
||
return this.$message.warning('第' + (i + 1) + '个商品未设置商城零售价,不可开启商城出售');
|
||
}
|
||
goodsList.push(this.checkedList[i].id);
|
||
}
|
||
this.submitLoading = true;
|
||
let goodsIds = goodsList.join(',');
|
||
if (this.changeForm.key == 'goods_class_id') {
|
||
this.sendRequest('Retail/LabelInventory/verifyGoodsChangeClass', {
|
||
data: {
|
||
class_id: this.changeForm.value,
|
||
operate_type: 1,
|
||
goods_ids: goodsIds,
|
||
},
|
||
success: (res) => {
|
||
if (res.status == 1) {
|
||
this.submitChangeGoods(goodsIds, close);
|
||
} else {
|
||
this.submitLoading = false;
|
||
if (res.data && res.data.length) {
|
||
if (res.data && res.data.length > 0) {
|
||
let str = `<div><p class="danger">${res.message}</p>`;
|
||
res.data.forEach((item, index) => {
|
||
str += `<p>
|
||
<span>${index + 1}. </span>
|
||
<span>${item.goods_name}</span>
|
||
</p>`;
|
||
});
|
||
str += `</div>`;
|
||
this.$alert(str, '错误提示', {
|
||
dangerouslyUseHTMLString: true,
|
||
type: 'danger',
|
||
}).catch(() => {
|
||
});
|
||
}
|
||
} else {
|
||
this.$message.error(res.message);
|
||
}
|
||
}
|
||
},
|
||
})
|
||
} else {
|
||
this.submitChangeGoods(goodsIds, close);
|
||
}
|
||
},
|
||
submitChangeGoods(goodsIds, close) {
|
||
this.sendRequest('Retail/Mgoods/batchOperateGoods', {
|
||
data: {
|
||
...this.changeForm,
|
||
goodsIds: goodsIds,
|
||
},
|
||
success: (res) => {
|
||
this.submitLoading = false;
|
||
if (res.status == 1) {
|
||
if (close) this.showBatchOperate = false, this.checkedList = [], this.getData();
|
||
this.$message.success(res.message);
|
||
} else {
|
||
this.$message.error(res.message);
|
||
}
|
||
},
|
||
})
|
||
},
|
||
//获取操作权限
|
||
getOperate() {
|
||
var auth_list = {
|
||
goodsSet: '/index.php/Retail/Mgoods/goodsSet',
|
||
mGoods: '/index.php/Retail/Exporttable/mGoods',
|
||
batch_del: '/index.php/Retail/Mgoods/batch_del',
|
||
updateMGoods: '/index.php/Retail/Mgoods/updateMGoods',
|
||
singleDelete: '/index.php/Retail/Mgoods/singleDelete',
|
||
changeOnlineState: '/index.php/Retail/Mgoods/changeOnlineState',
|
||
changeStatus: '/index.php/Retail/Mgoods/changeStatus',
|
||
changeVipOnlineState: '/index.php/Retail/Mgoods/changeVipOnlineState',
|
||
changeVipRetailState: '/index.php/Retail/Mgoods/changeVipRetailState',
|
||
simpleSet: '/index.php/Retail/Mgoods/simple',
|
||
batchOperateGoods: '/index.php/Retail/Mgoods/batchOperateGoods',
|
||
};
|
||
$.ajax({
|
||
url: '/index.php/Retail/Component/checkOperateAuth',
|
||
type: "post",
|
||
data: {
|
||
auth_list: JSON.stringify(auth_list),
|
||
},
|
||
success: (res) => {
|
||
if (res.status == 1) {
|
||
this.operate = res.data;
|
||
}
|
||
}
|
||
})
|
||
},
|
||
},
|
||
created() {
|
||
this.getPlatformType();
|
||
this.getData();
|
||
this.getOperate();
|
||
},
|
||
})
|
||
</script> |