| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795 |
- <?php
- use common\helpers\AddonHelper;
- use common\helpers\ComponentHelper;
- ComponentHelper::loadComponentView('component/com-add-cat', __DIR__);
- ComponentHelper::loadComponentView('component/com-select-goods-cat', __DIR__);
- ComponentHelper::loadComponentView('com-export-dialog');
- if (!empty($pay_success_jump_component)) {
- ComponentHelper::loadComponentView(
- 'pay-success-select-jump-url',
- AddonHelper::getAddonRootPath('PaySuccessJump') . 'backend/views/components'
- );
- }
- ?>
- <style>
- </style>
- <div id="app" v-cloak>
- <el-card shadow="never" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
- <div slot="header">
- <span>商品列表</span>
- <div style="float: right; margin: -5px 0">
- <el-button type="primary" size="small" @click="handle('edit')">添加商品</el-button>
- <el-button v-if="synchronize_goods_dialog > 0" type="primary" size="small" @click="syncGoods">同步商品</el-button>
- <el-button class="all_button" type="primary" size="small" @click="importGoods" >批量导入</el-button>
- <com-export-dialog
- style="float: right;margin-left: 10px;"
- :field_list='export_list'
- :action_url="export_url"
- :params="search_data">
- </com-export-dialog>
- <!-- <com-export-dialog-->
- <!-- style="float: right;margin-left: 10px;"-->
- <!-- :field_list='export_list'-->
- <!-- :action_url="export_url"-->
- <!-- :params="search_data">-->
- <!-- </com-export-dialog>-->
- </div>
- </div>
- <div class="table-body">
- <el-tabs v-model="activeName" @tab-click="handleClick">
- <el-tab-pane v-for="item in tabs" :key="item.value" :label="item.name" :name="item.value">
- <el-form :inline="true" :model="search_data" size="small" class="demo-form-inline">
- <el-form-item>
- <el-button size="small" @click="$refs.cats.openDialog()">分类筛选</el-button>
- <el-button size="small" v-if="search_data.cats && search_data.cats.length > 0" type="danger" @click="clearCat">清除分类</el-button>
- </el-form-item>
- <el-form-item>
- <el-date-picker style="margin-top: 1px;" size="small" @change="changeTime" v-model="datetime" type="datetimerange" value-format="yyyy-MM-dd HH:mm:ss" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']"></el-date-picker>
- </el-form-item>
- <el-form-item label="">
- <el-input size="small" placeholder="请输入商品名称" v-model="search_data.goods_name"></el-input>
- </el-form-item>
- <el-form-item label="">
- <el-input size="small" placeholder="请输入商品ID精准搜索" v-model="search_data.goods_id"></el-input>
- </el-form-item>
- <el-form-item label="">
- <el-select size="small" v-model="search_data.goods_type" placeholder="请选择商品类型" style="width: 100%;" clearable>
- <el-option label="实体商品" :value="1"></el-option>
- <el-option label="虚拟商品" :value="2"></el-option>
- <el-option label="预约商品" :value="3"></el-option>
- </el-select>
- </el-form-item>
- <el-form-item>
- <el-button type="primary" @click="search">搜索</el-button>
- <el-button type="primary" @click="multipleOff">批量下架</el-button>
- <el-button type="primary" @click="multipleOn">批量上架</el-button>
- <el-button type="danger" @click="clearSearch" v-if="show_clear_search_btn">清除条件</el-button>
- </el-form-item>
- </el-form>
- <el-table v-loading="listLoading" :data="list" stripe style="width: 100%" @sort-change="sortChange" @selection-change="handleSelectionChange">
- <el-table-column type="selection" align="center" width="60" :selectable="checkSelectable"></el-table-column>
- <el-table-column label="ID" prop="id" align="center"></el-table-column>
- <el-table-column prop="sort" label="排序" width="150">
- <template slot-scope="scope">
- <div v-if="sort_id != scope.row.id">
- <el-tooltip class="item" effect="dark" content="排序" placement="top">
- <span>{{scope.row.sort}}</span>
- </el-tooltip>
- <el-button class="edit-sort" type="text" @click="edit(scope.row,'sort')">
- <img src="resources/img/mall/order/edit.png" alt="">
- </el-button>
- </div>
- <div style="display: flex;align-items: center" v-else>
- <el-input style="min-width: 70px" type="number" size="mini" class="change" v-model="sort" autocomplete="off"></el-input>
- <el-button class="change-quit" type="text" style="color: #F56C6C;padding: 0 5px" icon="el-icon-error" circle @click="cancelEdit('sort')"></el-button>
- <el-button class="change-success" type="text" style="margin-left: 0;color: #67C23A;padding: 0 5px" icon="el-icon-success" circle @click="handle('sort',scope.row)">
- </el-button>
- </div>
- </template>
- </el-table-column>
- <el-table-column label="分类" align="center">
- <template slot-scope="scope">
- <div class="goods-cat">
- <el-tag v-if="scope.row.cats && scope.row.cats.length > 0" size="mini">
- {{scope.row.cats[0].name}}
- </el-tag>
- <el-tooltip v-if="scope.row.cats && scope.row.cats.length > 1" placement="top">
- <div slot="content">
- <span v-for="item in scope.row.cats" :key="item.id">{{item.name}} </span>
- </div>
- <span>...</span>
- </el-tooltip>
- </div>
- </template>
- </el-table-column>
- <el-table-column label="商品名称" min-width="200" prop="goods_name" align="center">
- <template slot-scope="scope">
- <div flex="cross:center">
- <div style="margin-right: 10px;">
- <el-image style="width: 50px; height: 50px;border-radius: 5px;" :src="scope.row.cover_pic"></el-image>
- </div>
- <div v-if="goods_name_id != scope.row.id">
- <el-tooltip class="item" effect="dark" content="商品名称" placement="top">
- <span>{{scope.row.goods_name}}</span>
- </el-tooltip>
- <el-button class="edit-sort" type="text" @click="edit(scope.row,'goods_name')">
- <img src="resources/img/mall/order/edit.png" alt="">
- </el-button>
- </div>
- <div style="display: flex;align-items: center" v-else>
- <el-input style="min-width: 70px" size="mini" class="change" v-model="goods_name" autocomplete="off"></el-input>
- <el-button class="change-quit" type="text" style="color: #F56C6C;padding: 0 5px" icon="el-icon-error" circle @click="cancelEdit('goods_name')"></el-button>
- <el-button class="change-success" type="text" style="margin-left: 0;color: #67C23A;padding: 0 5px" icon="el-icon-success" circle @click="handle('goods_name',scope.row)">
- </el-button>
- </div>
- </div>
- </template>
- </el-table-column>
- <el-table-column label="售价" prop="price" align="center" sortable="false">
- <template slot-scope="scope">
- <div size="small">{{scope.row.price}}</div>
- </template>
- </el-table-column>
- <el-table-column label="库存" prop="stock" align="center" sortable="false">
- <template slot-scope="scope">
- <div size="small" style="color: red;" v-if="scope.row.stock<=scope.row.stock_warning">{{scope.row.stock}}</div>
- <div size="small" v-else>{{scope.row.stock}}</div>
- </template>
- </el-table-column>
- <el-table-column label="审核状态" prop="check_status" align="center">
- <template slot-scope="scope">
- <div size="small" v-if="scope.row.check_status == 1">已通过</div>
- <div size="small" v-if="scope.row.check_status == 2">不通过</div>
- <div size="small" v-if="scope.row.check_status == 0">审核中</div>
- </template>
- </el-table-column>
- <el-table-column label="审核备注" prop="check_remark" align="center">
- <template slot-scope="scope">
- <div size="small" v-if="scope.row.check_status == 2">{{scope.row.check_remark}}</div>
- </template>
- </el-table-column>
- <el-table-column label="状态" prop="is_on_sale" align="center">
- <template slot-scope="scope">
- <div size="small" v-if="scope.row.is_on_sale == 1">上架</div>
- <div size="small" v-if="scope.row.is_on_sale == 0">下架</div>
- </template>
- </el-table-column>
- <el-table-column label="销量数量" prop="sales" align="center">
- <template slot-scope="scope">
- <div size="small">{{scope.row.sales_num}}</div>
- </template>
- </template>
- </el-table-column>
- <el-table-column label="类型" prop="goods_type" align="center">
- <template slot-scope="scope">
- <div size="small" v-if="scope.row.goods_type == 1">实体商品</div>
- <div size="small" v-if="scope.row.goods_type == 2">虚拟商品</div>
- <div size="small" v-if="scope.row.goods_type == 3">预约商品</div>
- </template>
- </el-table-column>
- <el-table-column label="创建时间" width="160" prop="created_at" align="center">
- <template slot-scope="scope">
- <div size="small">{{scope.row.created_at|dateTimeFormat('Y-m-d H:i:s')}}</div>
- </template>
- </el-table-column>
- <el-table-column label="店铺推荐" width="160" prop="is_recommend" align="center">
- <template slot-scope="scope">
- <div size="small" v-if="scope.row.is_recommend == 0">否</div>
- <div size="small" v-if="scope.row.is_recommend == 1">是</div>
- </template>
- </el-table-column>
- <el-table-column label="操作" min-width="300" align="center">
- <template slot-scope="scope">
- <div>
- <template v-if="scope.row.addons_name!=''">
- <el-tooltip class="item" effect="dark" content="该商品正在参与营销活动,暂不可操作" placement="left-start">
- <el-tag size="small" type="warning">{{scope.row.addons_name}}</el-tag>
- </el-tooltip>
- </template>
- <template v-else="group_buy_active_arr[scope.row.id]">
- <el-button v-if="scope.row.show_sync_goods == 0 && scope.row.option_limit == 0" type="text" @click="handle('edit',scope.row)">编辑</el-button>
- <el-button v-if="scope.row.show_sync_goods == 0" type="text" @click="handle('destroy',scope.row)">删除</el-button>
- <el-button v-if="scope.row.show_sync_goods == 0 && scope.row.option_limit == 0" type="text" @click="handle('is_on_sale',scope.row)">
- <span size="small" v-if="scope.row.is_on_sale == 0">上架</span>
- <span size="small" v-if="scope.row.is_on_sale == 1">下架</span>
- </el-button>
- <el-button type="text" @click="handle('model',scope.row)" v-if="scope.row.option_limit == 0">模式</el-button>
- </template>
- <el-dropdown style="margin-left: 10px" v-if="scope.row.addons_name == '' || pay_success_jump > 0">
- <el-button type="text" class="el-dropdown-link">
- 更多<i class="el-icon-arrow-down el-icon--right"></i>
- </el-button>
- <el-dropdown-menu slot="dropdown">
- <el-dropdown-item v-if="scope.row.addons_name == ''">
- <el-button type="text" @click="handle('is_recommend',scope.row)">
- <span size="small" v-if="scope.row.is_recommend == 0">推荐商品</span>
- <span size="small" v-if="scope.row.is_recommend == 1">取消推荐</span>
- </el-button>
- </el-dropdown-item>
- <el-dropdown-item v-if="pay_success_jump > 0">
- <el-button type="text" @click="onChangeJumpUrl(scope.row)">支付后跳转设置</el-button>
- </el-dropdown-item>
- </el-dropdown-menu>
- </el-dropdown>
- </div>
- </template>
- </el-table-column>
- </el-table>
- <div style="text-align: right;margin: 20px 0;">
- <el-pagination @current-change="pagination" background layout="prev, pager, next" :page-count="pageCount"></el-pagination>
- </div>
- </el-tab-pane>
- </el-tabs>
- </div>
- </el-card>
- <!-- 分类筛选 -->
- <com-add-cat ref="cats" :new-cats="search_data.cats" @select="selectCat" :mch_id="mch_id"></com-add-cat>
- <!-- 绑定跳转链接 -->
- <pay-success-select-jump-url addons="Store" :goods="currentItem" :show="paySuccessSelectJumpUrlDialogVisible" @hide="hidePaySuccessSelectJumpUrlDialogVisible"></pay-success-select-jump-url>
- <template>
- <?= ComponentHelper::loadComponentView('sync-goods', __DIR__) ?>
- <!-- 分类筛选 -->
- <com-select-goods-cat ref="mallCats" :new-cats="mchGoodsSearch.cats" @select="selectMallCat" :mall_id="mchGoodsSearch.mall_id"></com-select-goods-cat>
- </template>
- </div>
- <script>
- const app = new Vue({
- el: '#app',
- props:{
- import_store_goods_url: {
- type: String,
- default: 'store/client/goods/import-store-goods'
- },
- },
- data() {
- return {
- goods_name: '',
- goods_id: '',
- tabs: [{
- name: '全部',
- value: 'all'
- },
- {
- name: '审核中',
- value: 'checking'
- },
- {
- name: '销售中',
- value: 'onsale'
- },
- {
- name: '下架中',
- value: 'offline'
- },
- {
- name: '售罄',
- value: 'sell-out'
- },
- ],
- activeName: 'all',
- list: [],
- listLoading: false,
- page: 1,
- pageCount: 0,
- mch_id: 0, // 这个地方不知道要怎么获取
- searchCats: [],
- datetime: [],
- search_data: { // 筛选条件
- type: null,
- cats: [],
- start: null,
- end: null,
- goods_id: null,
- goods_name: null,
- goods_type: null,
- choose_list: [],
- },
- sort: 0,
- sort_id: 0,
- goods_name_id: 0,
- export_url: 'store/client/goods/export-excel',
- export_list: {},
- group_buy_active_arr: {},
- selectedGoodIds: [],
- pay_success_jump: 0,
- paySuccessSelectJumpUrlDialogVisible: false,
- currentItem: {},
- synchronize_goods_dialog: 0,
- syncGoods2Store: false,
- syncGoods2StoreLoading: false,
- mchGoodsList: [],
- mchGoodsPageCount: 0,
- mchGoodsPage: 1,
- selectedRowIds: [],
- mchGoodsSearch: {
- name: '',
- goods_id: '',
- mch_id: '',
- mall_id: '',
- cats: []
- },
- btnLoading: false,
- mchList: [],
- mallList: [],
- sign:'',
- };
- },
- mounted: function() {
- this.getList();
- },
- computed: {
- show_clear_search_btn: function() {
- return !isEmpty(this.search_data.cats) || !isEmpty(this.search_data.start) ||
- !isEmpty(this.search_data.end) || !isEmpty(this.search_data.goods_id) ||
- !isEmpty(this.search_data.goods_name);
- }
- },
- created() {
- this.sign = getQuery('sign')
- },
- methods: {
- importGoods() { //数据导入
- navigateTo({
- r: this.import_store_goods_url,
- page: this.page
- });
- },
- selectCat(arr) {
- this.search_data.cats = [];
- arr.forEach(it => this.search_data.cats.push(it.id))
- this.getList()
- },
- clearCat() { // 清除分类
- this.search_data.cats = []
- this.getList()
- },
- changeTime(e) {
- // console.log(e)
- this.search_data.start = e[0]
- this.search_data.end = e[1]
- },
- handleClick(res) { //标签页切换
- if (this.search_data.status == this.activeName) return;
- this.search_data.type = this.activeName;
- this.getList();
- },
- sortChange(row) {
- if (row.prop) {
- this.search_data.sort_field = row.prop;
- this.search_data.sort_type = row.order == "descending" ? 'desc' : 'asc';
- } else {
- this.search_data.sort_prop = null;
- this.search_data.sort_type = null;
- }
- this.getList();
- },
- search() {
- this.page = 1;
- this.getList();
- },
- clearSearch() {
- this.search_data.cats = [];
- this.search_data.start = null;
- this.search_data.end = null;
- this.search_data.goods_id = null;
- this.search_data.goods_name = null;
- this.datetime = [];
- this.getList();
- },
- handle(type, data = null) {
- let id = data ? parseInt(data.id) : '';
- switch (type) {
- case 'edit':
- let params = {
- r: 'store/client/goods/edit'
- };
- if (id) params = Object.assign(params, {
- id: id,
- sign:this.sign
- });
- navigateTo(params);
- break;
- case 'model': // 模式跳转
- param = {
- r: 'store/client/goods/goods-model'
- };
- if (id) param = Object.assign(param, {
- id: id,
- sign:this.sign
- });
- navigateTo(param);
- break;
- case 'destroy':
- param = {
- id: data.id,
- type
- };
- this.$confirm('删除该条数据后不可以恢复, 是否继续?', '警告', {
- type: 'warning'
- }).then(() => {
- this.send(param)
- })
- break;
- case 'sort':
- param = {
- id: id,
- sort: this.sort,
- type
- };
- this.send(param);
- break;
- case 'goods_name':
- param = {
- id: id,
- goods_name: this.goods_name,
- type
- };
- this.send(param);
- break;
- case 'is_on_sale':
- param = {
- id: id,
- is_on_sale: data.is_on_sale == 0 ? 1 : 0,
- type
- };
- operate_type = data.is_on_sale == 0 ? '上架' : '下架';
- this.$confirm('是否' + operate_type + '该商品?', '警告', {
- type: 'warning'
- }).then(() => {
- this.send(param)
- })
- break;
- case 'is_recommend':
- param = {
- id: id,
- is_recommend: data.is_recommend == 0 ? 1 : 0,
- type
- };
- operate_type = data.is_recommend == 0 ? '推荐' : '取消推荐';
- this.$confirm('是否' + operate_type + '该商品?', '警告', {
- type: 'warning'
- }).then(() => {
- request({
- params: {
- r: 'store/client/goods/is-recommend',
- },
- method: 'post',
- data: param
- }).then(e => {
- if (e.data.code == 0) {
- this.$message.success(e.data.msg);
- this.getList();
- } else {
- this.$message.error(e.data.msg);
- }
- }).catch(e => {
- console.log(e);
- });
- });
- break;
- }
- this.cancelEdit(type);
- },
- send(params) {
- let self = this;
- request({
- params: {
- r: 'store/client/goods/index',
- },
- method: 'post',
- data: params
- }).then(e => {
- if (e.data.code == 0) {
- self.$message.success(e.data.msg);
- self.getList();
- } else {
- self.$message.error(e.data.msg);
- }
- }).catch(e => {
- console.log(e);
- });
- },
- edit(row, type) {
- switch (type) {
- case 'sort':
- this.sort = row.sort;
- this.sort_id = row.id;
- break;
- case 'goods_name':
- this.goods_name_id = row.id;
- this.goods_name = row.goods_name;
- break;
- }
- },
- cancelEdit(type) {
- switch (type) {
- case 'sort':
- this.sort = 0;
- this.sort_id = 0;
- break;
- case 'goods_name':
- this.goods_name = '';
- this.goods_name_id = 0;
- break;
- }
- },
- searchClick() {
- this.page = 1;
- this.getList();
- },
- pagination(currentPage) {
- let self = this;
- self.page = currentPage;
- self.getList();
- },
- // 获取商品列表
- getList() {
- let self = this;
- let basic_params = {
- r: 'store/client/goods/index',
- page: self.page,
- };
- params = Object.assign(basic_params, this.search_data);
- if (self.listLoading == false) {
- self.listLoading = true;
- request({
- params: params,
- method: 'get',
- }).then(e => {
- self.listLoading = false;
- if (e.data.code == 0) {
- self.list = e.data.data.list;
- self.group_buy_active_arr = e.data.data.group_buy_active_arr;
- self.pageCount = e.data.data.page_count;
- self.pay_success_jump = e.data.data.pay_success_jump;
- this.export_list = e.data.data.export_list;
- this.synchronize_goods_dialog = e.data.data.synchronize_goods_dialog
- } else {
- self.$message.error(e.data.msg);
- }
- }).catch(e => {
- self.$message.error(e.data.msg);
- self.listLoading = false;
- });
- }
- },
- // 批量下架商品
- multipleOff() {
- let self = this;
- if (!self.selectedGoodIds.length) {
- self.$message.error('请先选择要下架的商品');
- return false;
- }
- self.listLoading = true;
- self.$confirm('是否确认下架所选中商品', '警告', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- request({
- params: {
- r: 'store/client/goods/mutiple-off',
- },
- method: 'post',
- data: {
- good_ids: self.selectedGoodIds,
- }
- }).then(e => {
- self.listLoading = false;
- if (e.data.code == 0) {
- self.$message.success('操作成功');
- self.getList();
- } else {
- self.$message.error(e.data.msg);
- return false;
- }
- }).catch(e => {
- self.listLoading = false;
- console.log(e);
- self.$message.error('网络错误');
- return false;
- });
- }).catch(() => {
- self.listLoading = false;
- console.log('已取消操作');
- return false;
- });
- },
- multipleOn() {
- let self = this;
- if (!self.selectedGoodIds.length) {
- self.$message.error('请先选择要上架的商品');
- return false;
- }
- self.listLoading = true;
- self.$confirm('是否确认上架所选中商品', '警告', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- request({
- params: {
- r: 'store/client/goods/mutiple-on',
- },
- method: 'post',
- data: {
- good_ids: self.selectedGoodIds,
- }
- }).then(e => {
- self.listLoading = false;
- if (e.data.code == 0) {
- self.$message.success('操作成功');
- self.getList();
- } else {
- self.$message.error(e.data.msg);
- return false;
- }
- }).catch(e => {
- self.listLoading = false;
- console.log(e);
- self.$message.error('网络错误');
- return false;
- });
- }).catch(() => {
- self.listLoading = false;
- console.log('已取消操作');
- return false;
- });
- },
- // 批量下架选中
- handleSelectionChange(val) {
- if (val.length) {
- this.selectedGoodIds = val.map((e) => {
- return e.id;
- });
- } else {
- this.selectedGoodIds = [];
- }
- this.search_data.choose_list = this.selectedGoodIds;
- },
- hidePaySuccessSelectJumpUrlDialogVisible() {
- this.paySuccessSelectJumpUrlDialogVisible = false
- },
- onChangeJumpUrl(goods) {
- this.currentItem = goods
- this.paySuccessSelectJumpUrlDialogVisible = true
- },
- syncGoods() {
- this.syncGoods2Store = true;
- this.getMallList()
- this.getMchGoodsList();
- },
- getMallList() {
- let _this = this;
- let basic_params = {
- r: 'store/client/goods/get-mall-list',
- };
- params = Object.assign(basic_params, {});
- request({
- params: params,
- method: 'get',
- }).then(e => {
- if (e.data.code == 0) {
- _this.mallList = e.data.data;
- } else {
- _this.$message.error(e.data.data.msg);
- }
- }).catch(e => {
- _this.$message.error(e.data.data.msg);
- _this.syncGoods2StoreLoading = false;
- });
- },
- getMchGoodsList() {
- let _this = this;
- let basic_params = {
- r: 'store/client/goods/sync-goods-list',
- page: this.mchGoodsPage,
- limit: 15,
- ..._this.mchGoodsSearch
- };
- params = Object.assign(basic_params, {});
- if (_this.syncGoods2StoreLoading == false) {
- _this.syncGoods2StoreLoading = true;
- request({
- params: params,
- method: 'get',
- }).then(e => {
- _this.syncGoods2StoreLoading = false;
- if (e.data.code == 0) {
- _this.mchGoodsList = e.data.data.list;
- _this.mchGoodsPageCount = e.data.data.page_count;
- } else {
- _this.$message.error(e.data.data.msg);
- }
- }).catch(e => {
- _this.$message.error(e.data.data.msg);
- _this.syncGoods2StoreLoading = false;
- });
- }
- },
- searchMchGoods() {
- this.mchGoodsPage = 1
- this.getMchGoodsList()
- },
- getRowKey(row) {
- return row.id;
- },
- handleSelectAll() {
- let _this = this
- _this.mchGoodsList.map(function(item, index) {
- _this.selectedRowIds.push(item.id)
- })
- },
- handleSyncSelect(selection, row) {
- this.selectedRowIds.push(row.id)
- },
- mchGoodsPagination(currentPage) {
- this.mchGoodsPage = currentPage;
- this.getMchGoodsList();
- },
- confirmSyncGoods() {
- let _this = this
- if (_this.selectedRowIds.length <= 0) {
- _this.$message.error('请选择需要同步的商品');
- return
- }
- _this.$confirm('确定要同步这些商品到门店?', '警告', {
- type: 'warning'
- }).then(() => {
- this.btnLoading = true;
- request({
- params: {
- r: 'store/client/goods/sync-goods-store'
- },
- method: 'post',
- data: {
- selected_goods_ids: this.selectedRowIds,
- }
- }).then(res => {
- if (res.data.code == 0) {
- _this.$message.success(res.data.msg);
- _this.syncGoods2Store = false;
- _this.btnLoading = false;
- } else {
- _this.$message.error(res.data.msg);
- }
- }).catch(err => {
- console.info(err);
- _this.syncGoods2Store = false;
- _this.btnLoading = false;
- })
- })
- },
- selectMallCat(arr) {
- this.mchGoodsSearch.cats = [];
- arr.forEach(it => this.mchGoodsSearch.cats.push(it.id))
- this.getMchGoodsList()
- },
- clearMallCat() { // 清除分类
- this.mchGoodsSearch.cats = []
- this.getMchGoodsList()
- },
- checkSelectable(row) {
- if (row.option_limit == 0) {
- return true;
- } else {
- return false;
- }
- },
- }
- });
- </script>
|