1184 行
54 KiB
HTML
可执行文件
1184 行
54 KiB
HTML
可执行文件
<!--[1.8.50]-->
|
||
<style>
|
||
.el-pagination {
|
||
padding: 8px;
|
||
}
|
||
|
||
.el-table__row>td:last-child>.cell {
|
||
white-space: nowrap;
|
||
}
|
||
|
||
|
||
.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%;
|
||
}
|
||
|
||
|
||
.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 id="goodsListApp" v-cloak class="goods-list-container" v-loading="loading" :element-loading-text="loadingText"
|
||
element-loading-spinner="el-icon-loading">
|
||
<!--搜索及操作内容-->
|
||
<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="2" :store-id="store_id" :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.pricing_method">
|
||
<el-option :value="1" label="非称重"></el-option>
|
||
<el-option :value="2" label="称重"></el-option>
|
||
</el-select>
|
||
<el-select clearable placeholder="规格类型" v-model="searchForm.attribute_state">
|
||
<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-select clearable placeholder="销售类型" v-model="searchForm.advance_sale_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="storeAuth.addgoods==1 && storeAuth.showpurch_price==1 && operate.goodsSet"
|
||
@click="setGoods()">新增商品
|
||
</el-button>
|
||
</el-form-item>
|
||
<!--更多操作-->
|
||
<el-form-item>
|
||
<el-button type="primary" plain v-if="storeAuth.synchro_goods==1 && operate.sync_goods"
|
||
@click="syncGoods">同步商户商品
|
||
</el-button>
|
||
|
||
<el-button type="primary" plain v-if="operate.two_sync_goods" @click="twoSyncGoods">更新商品信息
|
||
<el-tooltip class="item" effect="dark" content="当商户更新商品信息时,你可进行此操作直接更新商品信息,无需手动修改"
|
||
placement="top-start">
|
||
<i class="el-icon-question"></i>
|
||
</el-tooltip>
|
||
</el-button>
|
||
<el-button type="primary" plain v-if="operate.simple" @click="goodsSimple">简拼设置</el-button>
|
||
<el-button type="primary" plain @click="resetPluDialogVisible = true">重置PLU码</el-button>
|
||
</el-form-item>
|
||
</div>
|
||
<!--更多操作按钮列表-->
|
||
<div class="more-operate-box">
|
||
<el-form-item class="more-operate" label-width="0">
|
||
<el-button size="mini" v-if="operate.batchOperateGoods" @click="toShowChangeGoods">批量设置
|
||
</el-button>
|
||
<el-button size="mini" v-if="operate.downloadLabel" @click="downloadLabel">下载标签
|
||
</el-button>
|
||
<template v-if="storeAuth.data_export == 1">
|
||
<el-button size="mini" v-if="operate.goods" @click="exportTable(1)">商品导出
|
||
</el-button>
|
||
<el-button size="mini" v-if="operate.goodstwo" @click="exportTable(1,1)">商城商品导出
|
||
</el-button>
|
||
<el-button size="mini" @click="SkuGoodsTable(1,300,1,'',1)">无规格商品导出
|
||
</el-button>
|
||
<el-button size="mini" @click="SkuGoodsTable(1,200,1,'',2)">规格商品导出</el-button>
|
||
</template>
|
||
</el-form-item>
|
||
<el-form-item class="more-operate" label-width="0">
|
||
<el-button v-if="storeAuth.batch_delgoods==1 && operate.delete_goods" size="mini" @click="changeGoods">
|
||
批量删除
|
||
</el-button>
|
||
</el-form-item>
|
||
</div>
|
||
|
||
|
||
</el-form>
|
||
<!--商品列表-->
|
||
<div style="max-width: calc(100vw - 208px);margin-top: 0;">
|
||
<el-table border :header-cell-style="{background:'#F5F7FA',color:'#606266'}" :data="goodsList"
|
||
style="width: 100%" @selection-change="handleSelectionChange" size="small" :stripe="true" max-height="670">
|
||
<el-table-column align="center" fixed type="selection" width="40"></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.purchase_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.goods_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="状态信息" width="270px">
|
||
<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="changeUsual(scope.$index,scope.row.usual_state,scope.row.id)"
|
||
:disabled="!operate.changeusualDemo" v-model="scope.row.usual_state" inactive-value="1"
|
||
active-value="2">
|
||
</el-switch>
|
||
</div>
|
||
<div class="table-cell-long-text">
|
||
<span>商城出售:</span>
|
||
<el-switch
|
||
@change="changeOnline(scope.$index,scope.row.online_state,scope.row.id,scope.row.goods_class_id)"
|
||
:disabled="!operate.changeissellonline" v-model="scope.row.online_state"
|
||
inactive-value="0" active-value="1">
|
||
</el-switch>
|
||
</div>
|
||
<div class="table-cell-long-text">
|
||
<span>店内出售:</span>
|
||
<el-switch
|
||
@change="doChangeRetailState(scope.$index,scope.row.retail_state,scope.row.id,scope.row.goods_class_id)"
|
||
:disabled="!operate.changeRetailState" v-model="scope.row.retail_state"
|
||
inactive-value="0" active-value="1">
|
||
</el-switch>
|
||
</div>
|
||
</div>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="优惠信息" 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.changevip_online_state" 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.changevip_retail_state" v-model="scope.row.vip_retail_state"
|
||
inactive-value="0" active-value="1">
|
||
</el-switch>
|
||
</div>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="其他信息" min-width="160px" show-overflow-tooltip>
|
||
<template slot-scope="scope">
|
||
<div class="table-cell-long-text">类别名称: {{scope.row.cate_name}}</div>
|
||
<div class="table-cell-long-text">商品来源: {{scope.row.source_type_name}}</div>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column align="center" fixed="right" label="操作" width="60px">
|
||
<template slot-scope="scope">
|
||
<div class="table-cell-flex-column">
|
||
<el-button @click.native.prevent="setGoods(scope.row.id)"
|
||
v-if="storeAuth.editgoods==1 && operate.goodsSet" type="text" size="small">编辑
|
||
</el-button>
|
||
<el-button @click.native.prevent="delGoods(scope.row.id)"
|
||
v-if="storeAuth.delgoods==1 && 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, 60, 70, 80, 90, 100]" :page-size="10"
|
||
layout="total, sizes, prev, pager, next, jumper" :total="currentLen">
|
||
</el-pagination>
|
||
</div>
|
||
<el-dialog title="图片详情" :modal-append-to-body="false" :visible.sync="showBigImg" :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="storeAuth.batch_editgoods==1 && operate.updateGoods">
|
||
<el-tab-pane label="商品信息" name="goods_info"></el-tab-pane>
|
||
<el-tab-pane label="商品PLU码" name="goods_plu"></el-tab-pane>
|
||
</template>
|
||
|
||
<el-tab-pane v-if="storeAuth.batch_editgoodsclass==1" 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-tab-pane label="商城发货方式" name="delivery_type"></el-tab-pane>
|
||
<el-tab-pane label="导购员推广提成" name="guide_royalty_state"></el-tab-pane>
|
||
<el-tab-pane label="退款状态" name="refund_state"></el-tab-pane>
|
||
<el-tab-pane label="换货状态" name="exchange_state"></el-tab-pane>
|
||
<el-tab-pane label="虚拟销量" name="fictitious_num"></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>
|
||
<template v-else-if="changeForm.key=='delivery_type'">
|
||
<el-form-item label="配送方式">
|
||
<el-checkbox-group v-model="changeForm.value" style="display: flex;flex-direction: column">
|
||
<el-checkbox :label="1" :value="1">自提</el-checkbox>
|
||
<el-checkbox :label="2" :value="2">同城配送</el-checkbox>
|
||
<el-checkbox :label="3" :value="3">快递配送</el-checkbox>
|
||
</el-checkbox-group>
|
||
</el-form-item>
|
||
<el-form-item label="发货模板" v-if="changeForm.value.indexOf(3)>=0" class="el-form-item-long">
|
||
<el-select v-model="changeForm.delivery_template_id" placeholder="请选择发货模板" clearable
|
||
filterable>
|
||
<el-option v-for="item in deliveryTemplateList" :value-key="item.id" :key="item.id"
|
||
:label="item.title" :value="item.id">
|
||
</el-option>
|
||
</el-select>
|
||
</el-form-item>
|
||
</template>
|
||
<el-form-item v-else-if="changeForm.key=='goods_class_id'" label="">
|
||
<div>请选择修改后的分类信息</div>
|
||
<select-goods-category :user-type="2" :store-id="store_id" :category-id.sync="changeForm.value">
|
||
</select-goods-category>
|
||
</el-form-item>
|
||
<el-form-item v-else-if="['goods_info','goods_plu'].indexOf(changeForm.key)>=0"></el-form-item>
|
||
<el-form-item v-else-if="changeForm.key=='fictitious_num'" label="">
|
||
<el-input style="width: 150px" placeholder="请输入虚拟销量"
|
||
oninput="value=this.value.replace(/^[0]|\D/,'')" v-model="changeForm.value"></el-input>
|
||
</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" size="small" :loading="submitLoading" plain @click="batchOperateGoods(1)">保存并关闭
|
||
</el-button>
|
||
<el-button type="primary" size="small" :loading="submitLoading" @click="batchOperateGoods(0)">保存</el-button>
|
||
</div>
|
||
</el-dialog>
|
||
<el-dialog title="请选择Plu码重置方式" :append-to-body="true" :visible.sync="resetPluDialogVisible" width="500px">
|
||
<el-radio-group v-model="resetPluMethod">
|
||
<el-radio :label="3">全部商品</el-radio>
|
||
<el-radio :label="2">称重商品</el-radio>
|
||
<el-radio :label="1">非称重商品</el-radio>
|
||
</el-radio-group>
|
||
<div slot="footer">
|
||
<el-button @click="resetPluDialogVisible = false">取消</el-button>
|
||
<el-button type="primary" @click="resetPluConfirm">确定</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 goodsListApp = new Vue({
|
||
el: '#goodsListApp',
|
||
data() {
|
||
return {
|
||
platform_type: 1, //商户平台类型 1默认系统 2微礼平台
|
||
submitLoading: false,
|
||
searchForm: {
|
||
keyword_type: 2,
|
||
keyword: '',
|
||
condition_name: '',
|
||
order_type: '',
|
||
pricing_method: '',//是否称重 1不称重 2称重
|
||
advance_sale_status: '', //预售模式
|
||
status: '',//状态:0,正常,1,下架
|
||
attribute_state: '',//1非规格 多规格
|
||
person1: '',
|
||
person2: '',
|
||
person3: '',
|
||
},
|
||
merchant_id: localStorage.merchant_id,
|
||
store_id: localStorage.store_id,
|
||
showMoreSearch: false,//是否显示高级选项
|
||
operate: {},//操作权限
|
||
showBatchOperate: false,//是否显示批量修改商品
|
||
changeForm: {
|
||
key: 'status',
|
||
value: null,
|
||
delivery_template_id: '',
|
||
},//批量修改商品信息
|
||
goodsList: [],
|
||
currentLen: 0,
|
||
currentPage: 1,
|
||
currentLimit: 10,
|
||
checkedList: [],
|
||
table_loading: false,
|
||
loading: false,
|
||
loadingText: '数据获取中',
|
||
showBigImg: false,
|
||
bigImg: '',
|
||
deliveryTemplateList: [],//发货模板列表
|
||
resetPluDialogVisible: false, //重置Plu码弹窗
|
||
resetPluMethod: 3, //Plu码重置方式
|
||
resetPluLoading: '' //Plu码Loading
|
||
}
|
||
},
|
||
methods: {
|
||
//商户平台类型 1默认系统 2微礼平台
|
||
getPlatformType() {
|
||
$.ajax({
|
||
url: '/index.php/Retail/Goods/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;
|
||
}
|
||
},
|
||
//删除商品
|
||
delGoods(id) {
|
||
this.$confirm('您确认要删除该商品吗?', '提示', {
|
||
confirmButtonText: '确定',
|
||
cancelButtonText: '取消',
|
||
type: 'warning'
|
||
}).then(() => {
|
||
$.ajax({
|
||
url: "/index.php/Retail/Goods/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(() => {
|
||
});
|
||
},
|
||
//编辑、新增商品
|
||
setGoods(id) {
|
||
MenuApp.pathData.push({
|
||
name: (id ? '编辑' : '新增') + '商品',
|
||
path: '/index.php/Retail/Goods/goodsSet' + (id ? ('?id=' + id) : ''),
|
||
onClose: () => {
|
||
this.getData();
|
||
}
|
||
})
|
||
},
|
||
//修改商品上下架状态
|
||
changeStatus(index, status, id) {
|
||
//修改商品上下架状态
|
||
$.ajax({
|
||
url: "/index.php/Retail/Goods/changestatus",
|
||
type: 'POST',
|
||
data: {
|
||
status: status,
|
||
id: id
|
||
},
|
||
success: (res) => {
|
||
if (res.status == 1) {
|
||
this.$message.success(res.msg)
|
||
} else {
|
||
this.$message.error(res.msg)
|
||
this.goodsList[index].status = status == 1 ? '0' : '1';
|
||
}
|
||
}
|
||
})
|
||
},
|
||
//修改商城出售状态
|
||
changeOnline(index, status, id, goods_class_id) {
|
||
$.ajax({
|
||
url: "/index.php/Retail/Goods/changeissellonline",
|
||
type: 'POST',
|
||
data: {
|
||
online_state: status,
|
||
id: id,
|
||
goods_class_id: goods_class_id
|
||
},
|
||
success: (res) => {
|
||
if (res.status == 1) {
|
||
this.$message.success(res.msg)
|
||
} else {
|
||
this.$message.error(res.msg)
|
||
this.goodsList[index].online_state = status == 1 ? '0' : '1';
|
||
}
|
||
}
|
||
})
|
||
},
|
||
//修改店内出售状态
|
||
doChangeRetailState(index, status, id, goods_class_id) {
|
||
$.ajax({
|
||
url: "/index.php/Retail/Goods/changeRetailState",
|
||
type: 'POST',
|
||
data: {
|
||
retail_state: status,
|
||
id: id,
|
||
goods_class_id: goods_class_id
|
||
},
|
||
success: (res) => {
|
||
if (res.status == 1) {
|
||
this.$message.success(res.msg)
|
||
} else {
|
||
this.$message.error(res.msg)
|
||
this.goodsList[index].retail_state = status == 1 ? '0' : '1';
|
||
}
|
||
}
|
||
})
|
||
},
|
||
//修改线上打折状态
|
||
changeOnlineDis(index, status, id) {
|
||
$.ajax({
|
||
url: "/index.php/Retail/Goods/changevip_online_state",
|
||
type: 'POST',
|
||
data: {
|
||
vip_online_state: status,
|
||
id: id
|
||
},
|
||
success: (res) => {
|
||
if (res.status == 1) {
|
||
this.$message.success(res.msg)
|
||
} else {
|
||
this.$message.error(res.msg)
|
||
this.goodsList[index].vip_online_state = status == 1 ? '0' : '1';
|
||
}
|
||
}
|
||
})
|
||
},
|
||
//修改线下打折状态
|
||
changeRetailDis(index, status, id) {
|
||
$.ajax({
|
||
url: "/index.php/Retail/Goods/changevip_retail_state",
|
||
type: 'POST',
|
||
data: {
|
||
vip_retail_state: status,
|
||
id: id
|
||
},
|
||
success: (res) => {
|
||
if (res.status == 1) {
|
||
this.$message.success(res.msg)
|
||
} else {
|
||
this.$message.error(res.msg)
|
||
this.goodsList[index].vip_retail_state = status == 1 ? '0' : '1';
|
||
}
|
||
}
|
||
})
|
||
},
|
||
//修改常用状态
|
||
changeUsual(index, status, id) {
|
||
$.ajax({
|
||
url: "/index.php/Retail/Goods/changeusualDemo",
|
||
type: 'POST',
|
||
data: {
|
||
usual_state: status,
|
||
id: id
|
||
},
|
||
success: (res) => {
|
||
if (res.status == 1) {
|
||
this.$message.success(res.msg)
|
||
} else {
|
||
this.$message.error(res.msg)
|
||
this.goodsList[index].usual_state = status == 1 ? '0' : '1';
|
||
}
|
||
}
|
||
})
|
||
},
|
||
//下载标签
|
||
downloadLabel() {
|
||
layer.open({
|
||
type: 2,
|
||
title: "打印商品标签",
|
||
content: "/index.php/Retail/Goods/downloadLabel",
|
||
area: ["calc(100% - 160px)", "calc(100% - 65px)"],
|
||
offset: 'rb',
|
||
resize: false,
|
||
shade: 0,
|
||
move: false
|
||
})
|
||
// MenuApp.pathData.push({
|
||
// name: '下载标签',
|
||
// path: '/index.php/Retail/PriceTag/downloadLabel'
|
||
// })
|
||
},
|
||
//同步商户商品
|
||
syncGoods() {
|
||
layer.open({
|
||
type: 2,
|
||
content: "/index.php/Retail/Goods/sync_goods",
|
||
title: "同步商户商品",
|
||
area: ["calc(100% - 160px)", "calc(100% - 65px)"],
|
||
offset: 'rb',
|
||
shade: 0,
|
||
resize: false,
|
||
move: false,
|
||
end: () => {
|
||
this.getData();
|
||
}
|
||
})
|
||
},
|
||
//更新已同步的商品
|
||
twoSyncGoods() {
|
||
layer.open({
|
||
type: 2,
|
||
content: "/index.php/Retail/Goods/two_sync_goods",
|
||
title: "更新商品",
|
||
area: ["calc(100% - 160px)", "calc(100% - 65px)"],
|
||
offset: 'rb',
|
||
shade: 0,
|
||
resize: false,
|
||
move: false,
|
||
end: () => {
|
||
this.getData();
|
||
}
|
||
})
|
||
},
|
||
//商品、商城商品、无规格商品导出
|
||
exportTable(page = 1, online_state = '', attribute_state = '', type = 1, directory_name) {
|
||
this.loading = true;
|
||
this.loadingText = '文件生成中,请耐心等待';
|
||
if (type == 1) {
|
||
$.ajax({
|
||
url: "/index.php/Retail/Exporttable/goods",
|
||
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,
|
||
pricing_method: this.searchForm.pricing_method,
|
||
person1: this.searchForm.person1,
|
||
person2: this.searchForm.person2,
|
||
person3: this.searchForm.person3,
|
||
online_state: online_state,
|
||
attribute_state: attribute_state,
|
||
status: this.searchForm.status,
|
||
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 = `/index.php/Retail/Exporttable/goods?directory_name=${directory_name}&online_state=${online_state}&attribute_state=${attribute_state}`;
|
||
}
|
||
},
|
||
//规格或非规格商品导出
|
||
SkuGoodsTable(page = 1, limit = 200, type = 1, directory_name = '', attribute_state = 2) {
|
||
//规格导出
|
||
this.loading = true;
|
||
this.loadingText = '文件生成中,请耐心等待';
|
||
if (type == 1) {
|
||
$.ajax({
|
||
url: "{:U('exportGoods')}",
|
||
type: 'POST',
|
||
data: {
|
||
page: page,
|
||
limit: limit,
|
||
type: type,
|
||
directory_name: directory_name,
|
||
attribute_state: attribute_state,
|
||
searchForm: this.searchForm
|
||
},
|
||
success: (res) => {
|
||
this.loading = false;
|
||
if (res.status == 1) {
|
||
this.SkuGoodsTable(++page, limit, res.data.type, res.data.directory_name, attribute_state);
|
||
} else {
|
||
this.$confirm(res.msg, '提示', {
|
||
confirmButtonText: '确定',
|
||
type: 'warning'
|
||
}).then(() => {
|
||
|
||
}).catch(() => {
|
||
});
|
||
}
|
||
},
|
||
});
|
||
} else {
|
||
this.loading = false;
|
||
window.open(`{:U('exportFile')}?file_path=${directory_name}&attribute_state=${attribute_state}`);
|
||
}
|
||
},
|
||
//批量删除商品
|
||
changeGoods() {
|
||
layer.open({
|
||
type: 2,
|
||
title: "批量删除商品",
|
||
content: "/index.php/Retail/Goods/delete_goods",
|
||
area: ["calc(100% - 160px)", "calc(100% - 65px)"],
|
||
offset: 'rb',
|
||
shade: 0,
|
||
resize: false,
|
||
move: false,
|
||
end: () => {
|
||
if (localStorage.isChangeClass == 1) {
|
||
localStorage.isChangeClass = null;
|
||
this.getData();
|
||
}
|
||
}
|
||
})
|
||
},
|
||
handleSelectionChange(data) {
|
||
this.checkedList = [];
|
||
this.checkedList = data;
|
||
},
|
||
handleSizeChange(val) {
|
||
this.currentLimit = val;//切换每页数量
|
||
this.currentPage = 1;
|
||
this.getData();
|
||
},
|
||
handleCurrentChange(val) {
|
||
this.currentPage = val;
|
||
this.getData();//切换页数
|
||
},
|
||
searchGoods() {
|
||
this.currentPage = 1;
|
||
this.getData();
|
||
},
|
||
getData() {
|
||
this.table_loading = true;
|
||
$.ajax({
|
||
url: "/index.php/Retail/Goods/goodsList",
|
||
type: 'POST',
|
||
data: {
|
||
page: this.currentPage,
|
||
limit: this.currentLimit,
|
||
keyword: this.searchForm.keyword,
|
||
keyword_type: this.searchForm.keyword_type,
|
||
condition_name: this.searchForm.condition_name,
|
||
order_type: this.searchForm.order_type,
|
||
person1: this.searchForm.person1,
|
||
person2: this.searchForm.person2,
|
||
person3: this.searchForm.person3,
|
||
pricing_method: this.searchForm.pricing_method,
|
||
advance_sale_status: this.searchForm.advance_sale_status,
|
||
attribute_state: this.searchForm.attribute_state,
|
||
status: this.searchForm.status,
|
||
},
|
||
success: (res) => {
|
||
this.table_loading = false;
|
||
if (res.code == 0) {
|
||
this.goodsList = [];
|
||
this.goodsList = res.data;
|
||
this.$nextTick(() => {
|
||
this.currentLen = parseInt(res.count);
|
||
})
|
||
} else {
|
||
this.$confirm(res.msg, '提示', {
|
||
confirmButtonText: '确定',
|
||
type: 'warning'
|
||
}).then(() => {
|
||
|
||
}).catch(() => {
|
||
});
|
||
}
|
||
},
|
||
error: () => {
|
||
this.table_loading = false;
|
||
}
|
||
});
|
||
},
|
||
//一键设置导购推广
|
||
changeGuideYoyalty(type) {
|
||
var text = '开启';
|
||
if (type == 2) {
|
||
text = '关闭';
|
||
}
|
||
this.$confirm("该操作将会" + text + "所有商品的导购获得提成设置,您确认" + text + "?", "一键" + text + "导购推广提示", {
|
||
confirmButtonText: "继续" + text,
|
||
cancelButtonText: '取消',
|
||
type: 'info'
|
||
}).then(() => {
|
||
this.loading = true;
|
||
this.loadingText = '操作中,请等待';
|
||
$.ajax({
|
||
url: "/index.php/Retail/Goods/changeGuideYoyalty",
|
||
type: 'post',
|
||
data: {
|
||
type: type
|
||
},
|
||
success: (res) => {
|
||
this.loading = false;
|
||
if (res.status == 1) {
|
||
this.$message.success(res.msg)
|
||
} else {
|
||
this.$message.error(res.msg)
|
||
}
|
||
},
|
||
error: () => {
|
||
this.$message.error('请求发生错误')
|
||
this.loading = false;
|
||
}
|
||
})
|
||
}).catch(() => {
|
||
});
|
||
},
|
||
//简拼设置
|
||
goodsSimple() {
|
||
layer.open({
|
||
type: 2,
|
||
content: "/index.php/Retail/Goods/simple",
|
||
title: '简拼设置',
|
||
area: ["calc(100% - 160px)", "calc(100% - 65px)"],
|
||
offset: 'rb',
|
||
shade: 0,
|
||
resize: false,
|
||
move: false,
|
||
end: () => {
|
||
|
||
}
|
||
});
|
||
},
|
||
toShowChangeGoods() {
|
||
if (!this.checkedList.length) {
|
||
return this.$message.info('请先选择需要修改的商品');
|
||
}
|
||
this.changeForm.key = 'status';
|
||
this.submitLoading = false;
|
||
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':
|
||
case 'guide_royalty_state':
|
||
case 'refund_state':
|
||
case 'exchange_state':
|
||
this.changeForm.value = 0;
|
||
break;
|
||
case 'delivery_type':
|
||
this.changeForm.value = [];
|
||
if (!this.deliveryTemplateList.length) {
|
||
this.getDeliveryTemplateList();
|
||
}
|
||
break;
|
||
case 'goods_class_id':
|
||
case 'fictitious_num':
|
||
this.changeForm.value = '';
|
||
break;
|
||
case 'goods_info':
|
||
case 'goods_plu':
|
||
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: 'updateGoods' + "?id=" + id},
|
||
'goods_plu': {title: '批量修改商品PLU', url: 'updateGoodsPLU' + "?id=" + id},
|
||
};
|
||
layer.open({
|
||
type: 2,
|
||
content: "/index.php/Retail/Goods/" + 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:
|
||
}
|
||
this.changeForm.delivery_template_id = '';
|
||
},
|
||
//保存设置
|
||
batchOperateGoods(close) {
|
||
if (this.changeForm.key == '') return this.$message.warning('请选择修改的内容');
|
||
if (this.changeForm.key == 'goods_class_id' && !this.changeForm.value) return this.$message.warning('请完善分类');
|
||
if (this.changeForm.key == 'delivery_type') {
|
||
if (!this.changeForm.value.length) return this.$message.warning('请选择配送方式');
|
||
if (this.changeForm.value.indexOf(3) >= 0 && !this.changeForm.delivery_template_id) 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: 2,
|
||
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/Goods/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);
|
||
}
|
||
},
|
||
})
|
||
},
|
||
//获取配送模板列表供选择
|
||
getDeliveryTemplateList() {
|
||
$.ajax({
|
||
url: "/index.php/Retail/SystemDelivery/getStoreFreightTem",
|
||
data: {},
|
||
type: 'post',
|
||
success: (res) => {
|
||
if (res.code == 0) {
|
||
this.deliveryTemplateList = res.data;
|
||
}
|
||
}
|
||
})
|
||
},
|
||
//获取操作权限
|
||
getOperate() {
|
||
var auth_list = {
|
||
goodsSet: '/index.php/Retail/Goods/goodsSet',
|
||
downloadLabel: '/index.php/Retail/Goods/downloadLabel',
|
||
sync_goods: '/index.php/Retail/Goods/sync_goods',
|
||
two_sync_goods: '/index.php/Retail/Goods/two_sync_goods',
|
||
goods: '/index.php/Retail/Exporttable/goods',
|
||
goodstwo: '/index.php/Retail/Exporttable/goodstwo',
|
||
updateGoods: '/index.php/Retail/Goods/updateGoods',
|
||
move_class: '/index.php/Retail/Goods/move_class',
|
||
delete_goods: '/index.php/Retail/Goods/delete_goods',
|
||
addQuantity: '/index.php/Retail/Goods/addQuantity',
|
||
singleDelete: '/index.php/Retail/Goods/singleDelete',
|
||
changestatus: '/index.php/Retail/Goods/changestatus',
|
||
changeissellonline: '/index.php/Retail/Goods/changeissellonline',
|
||
changeRetailState: '/index.php/Retail/Goods/changeRetailState',
|
||
changevip_online_state: '/index.php/Retail/Goods/changevip_online_state',
|
||
changevip_retail_state: '/index.php/Retail/Goods/changevip_retail_state',
|
||
changeusualDemo: '/index.php/Retail/Goods/changeusualDemo',
|
||
simple: '/index.php/Retail/Goods/simple',
|
||
batchOperateGoods: '/index.php/Retail/Goods/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;
|
||
}
|
||
}
|
||
})
|
||
},
|
||
/**
|
||
* @description 重置Plu码确认
|
||
*/
|
||
resetPluConfirm() {
|
||
this.resetPluDialogVisible = false
|
||
this.$confirm(`<p>您确定要重置Plu码吗?</p><p style="font-size: 12px;">重置后,系统将重新生成商品的Plu码。</p>`, '提示', {
|
||
confirmButtonText: '确定',
|
||
cancelButtonText: '取消',
|
||
dangerouslyUseHTMLString: true,
|
||
type: 'warning'
|
||
}).then(() => {
|
||
this.resetPluLoading = this.$loading()
|
||
this.resetPlu()
|
||
}).catch(() => {});
|
||
},
|
||
/**
|
||
* @description 执行重置Plu码
|
||
*/
|
||
resetPlu(goodId = 0, pluCode = 0) {
|
||
this.sendRequest('Retail/Goods/resetStorePlu', {
|
||
data: {
|
||
pricing_method: this.resetPluMethod,
|
||
plu_code: pluCode,
|
||
goodId: goodId
|
||
},
|
||
success: (response) => {
|
||
if (response.status == 1) {
|
||
const data = response.data
|
||
if (!data) {
|
||
this.resetPluLoading.close()
|
||
this.$message.success('Plu码重置完成')
|
||
} else {
|
||
this.resetPlu(data.goodId, data.pluCode)
|
||
}
|
||
} else {
|
||
this.resetPluLoading.close()
|
||
this.$message.error(response.message)
|
||
}
|
||
}
|
||
});
|
||
}
|
||
},
|
||
created() {
|
||
this.getPlatformType();
|
||
this.getData();
|
||
this.getOperate();
|
||
},
|
||
})
|
||
</script> |