diff --git a/.env.development b/.env.development index 5f0e6e6..9c52fe0 100644 --- a/.env.development +++ b/.env.development @@ -2,8 +2,8 @@ ENV = 'development' # base api -VUE_APP_BASE_API = 'http://127.0.0.1:8325' -# VUE_APP_BASE_API = 'https://shop.lihaink.cn' +#VUE_APP_BASE_API = 'http://127.0.0.1:8325' + VUE_APP_BASE_API = 'https://shop.lihaink.cn' # socket 连接地址 #VUE_APP_WS_URL = 'ws://192.168.3.20:8324' VUE_APP_WS_URL = 'wss://shop.lihaink.cn' diff --git a/src/views/product/productList/index.vue b/src/views/product/productList/index.vue index 9af21c5..ebc2429 100644 --- a/src/views/product/productList/index.vue +++ b/src/views/product/productList/index.vue @@ -3,34 +3,80 @@ <el-card class="box-card"> <div slot="header" class="clearfix"> <el-tabs v-model="tableFrom.type" @tab-click="getList(1),getLstFilterApi()"> - <el-tab-pane v-for="(item,index) in headeNum" :key="index" :name="item.type.toString()" :label="item.name +'('+item.count +')' " /> + <el-tab-pane + v-for="(item,index) in headeNum" + :key="index" + :name="item.type.toString()" + :label="item.name +'('+item.count +')' " + /> </el-tabs> <div class="container"> <el-form size="small" label-width="120px" :inline="true"> <el-form-item label="平台商品分类:"> - <el-cascader v-model="tableFrom.cate_id" class="selWidth" :options="categoryList" :props="props" clearable @change="getList(1)" /> + <el-cascader + v-model="tableFrom.cate_id" + class="selWidth" + :options="categoryList" + :props="props" + clearable + @change="getList(1)" + /> </el-form-item> <el-form-item label="商户商品分类:"> - <el-select v-model="tableFrom.mer_cate_id" placeholder="请选择" class="filter-item selWidth" clearable @change="getList(1)"> - <el-option v-for="item in merCateList" :key="item.value" :label="item.label" :value="item.value" /> + <el-select + v-model="tableFrom.mer_cate_id" + placeholder="请选择" + class="filter-item selWidth" + clearable + @change="getList(1)" + > + <el-option + v-for="item in merCateList" + :key="item.value" + :label="item.label" + :value="item.value" + /> </el-select> </el-form-item> <el-form-item label="是否为礼包:"> - <el-select v-model="tableFrom.is_gift_bag" placeholder="请选择" class="selWidth" clearable @change="getList(1)"> + <el-select + v-model="tableFrom.is_gift_bag" + placeholder="请选择" + class="selWidth" + clearable + @change="getList(1)" + > <el-option label="是" value="1" /> <el-option label="否" value="0" /> </el-select> </el-form-item> <el-form-item label="会员价设置:"> - <el-select v-model="tableFrom.svip_price_type" placeholder="请选择" class="selWidth" clearable @change="getList(1)"> + <el-select + v-model="tableFrom.svip_price_type" + placeholder="请选择" + class="selWidth" + clearable + @change="getList(1)" + > <el-option label="未设置" value="0" /> <el-option label="默认设置" value="1" /> <el-option label="自定义设置" value="2" /> </el-select> </el-form-item> <el-form-item label="商品状态:"> - <el-select v-model="tableFrom.us_status" placeholder="请选择" class="filter-item selWidth" clearable @change="getList"> - <el-option v-for="item in productStatusList" :key="item.value" :label="item.label" :value="item.value" /> + <el-select + v-model="tableFrom.us_status" + placeholder="请选择" + class="filter-item selWidth" + clearable + @change="getList" + > + <el-option + v-for="item in productStatusList" + :key="item.value" + :label="item.label" + :value="item.value" + /> </el-select> </el-form-item> <el-form-item label="标签:"> @@ -68,8 +114,18 @@ </el-select> </el-form-item> <el-form-item label="关键字搜索:"> - <el-input v-model="tableFrom.keyword" placeholder="请输入商品名称,关键字" class="selWidth" @keyup.enter.native="getList(1)"> - <el-button slot="append" icon="el-icon-search" class="el-button-solt" @click="getList(1)" /> + <el-input + v-model="tableFrom.keyword" + placeholder="请输入商品名称,关键字" + class="selWidth" + @keyup.enter.native="getList(1)" + > + <el-button + slot="append" + icon="el-icon-search" + class="el-button-solt" + @click="getList(1)" + /> </el-input> </el-form-item> </el-form> @@ -78,27 +134,45 @@ <el-button size="small" type="primary">添加商品</el-button> </router-link> <el-button size="small" type="success" @click="onCopy">商品采集</el-button> - <el-button size="mini" :disabled="tableFrom.type != 1 || multipleSelection.length == 0" @click="batchOff">批量下架</el-button> - <el-button size="mini" :disabled="tableFrom.type != 2 || multipleSelection.length == 0" @click="batchShelf">批量上架</el-button> + <el-button + size="mini" + :disabled="tableFrom.type != 1 || multipleSelection.length == 0" + @click="batchOff" + >批量下架</el-button> + <el-button + size="mini" + :disabled="tableFrom.type != 2 || multipleSelection.length == 0" + @click="batchShelf" + >批量上架</el-button> <el-button size="mini" :disabled="multipleSelection.length == 0" @click="batchLabel">批量设置标签</el-button> - <el-button size="mini" :disabled="multipleSelection.length == 0" @click="batchFreight">批量设置运费</el-button> - <el-button size="mini" :disabled="multipleSelection.length == 0" @click="batchCommision">批量设置佣金</el-button> - <el-button v-if="open_svip == 1" size="mini" :disabled="multipleSelection.length == 0" @click="batchSvip">批量设置会员价</el-button> + <el-button + size="mini" + :disabled="multipleSelection.length == 0" + @click="batchFreight" + >批量设置运费</el-button> + <el-button + size="mini" + :disabled="multipleSelection.length == 0" + @click="batchCommision" + >批量设置佣金</el-button> + <el-button + v-if="open_svip == 1" + size="mini" + :disabled="multipleSelection.length == 0" + @click="batchSvip" + >批量设置会员价</el-button> </div> - <el-table - v-loading="listLoading" - :data="tableData.data" - style="width: 100%" - size="mini" - :row-class-name="tableRowClassName" + <el-table + v-loading="listLoading" + :data="tableData.data" + style="width: 100%" + size="mini" + :row-class-name="tableRowClassName" :row-key="(row) => { return row.product_id }" @selection-change="handleSelectionChange" - @rowclick.stop="closeEdit"> - <el-table-column - type="selection" - :reserve-selection="true" - width="55" - /> + @rowclick.stop="closeEdit" + > + <el-table-column type="selection" :reserve-selection="true" width="55" /> <el-table-column type="expand"> <template slot-scope="props"> <el-form label-position="left" inline class="demo-table-expand demo-table-expand1"> @@ -107,7 +181,11 @@ </el-form-item> <el-form-item label="商品分类:"> <template v-if="props.row.merCateId.length"> - <span v-for="(item, index) in props.row.merCateId" :key="index" class="mr10">{{ item.category.cate_name }}</span> + <span + v-for="(item, index) in props.row.merCateId" + :key="index" + class="mr10" + >{{ item.category.cate_name }}</span> </template> <span v-else>-</span> </el-form-item> @@ -140,7 +218,7 @@ <el-table-column prop="store_name" label="商品名称" min-width="200" /> <el-table-column prop="price" label="商品售价" min-width="90" /> <el-table-column prop="svip_price" label="会员价" min-width="90"> - <template slot-scope="scope"> + <template slot-scope="scope"> <span>{{ scope.row.svip_price || '-' }}</span> </template> </el-table-column> @@ -151,14 +229,34 @@ <el-table-column prop="sort" align="center" label="排序" min-width="80"> <template slot-scope="scope"> <span v-if="scope.row.index === tabClickIndex"> - <el-input v-model.number="scope.row['sort']" type="number" maxlength="300" size="mini" autofocus @blur="inputBlur(scope)" /> + <el-input + v-model.number="scope.row['sort']" + type="number" + maxlength="300" + size="mini" + autofocus + @blur="inputBlur(scope)" + /> </span> <span v-else @dblclick.stop="tabClick(scope.row)">{{ scope.row['sort'] }}</span> </template> </el-table-column> - <el-table-column v-if="Number(tableFrom.type) < 5" key="1" prop="status" label="上/下架" min-width="150"> + <el-table-column + v-if="Number(tableFrom.type) < 5" + key="1" + prop="status" + label="上/下架" + min-width="150" + > <template slot-scope="scope"> - <el-switch v-model="scope.row.is_show" :active-value="1" :inactive-value="0" active-text="上架" inactive-text="下架" @change="onchangeIsShow(scope.row)" /> + <el-switch + v-model="scope.row.is_show" + :active-value="1" + :inactive-value="0" + active-text="上架" + inactive-text="下架" + @change="onchangeIsShow(scope.row)" + /> </template> </el-table-column> <el-table-column prop="stock" label="商品状态" min-width="90"> @@ -168,39 +266,96 @@ </el-table-column> <el-table-column prop="stock" label="标签" min-width="90"> <template slot-scope="scope"> - <div v-for="(item,index) in scope.row.mer_labels" :key="index" class="label-list">{{ item.name }}</div> + <div + v-for="(item,index) in scope.row.mer_labels" + :key="index" + class="label-list" + >{{ item.name }}</div> </template> </el-table-column> <el-table-column prop="create_time" label="创建时间" min-width="150" /> <el-table-column label="操作" min-width="150" fixed="right"> - <template slot-scope="scope"> - <router-link v-if="tableFrom.type != 5" :to="{path: roterPre + '/product/list/addProduct/' + scope.row.product_id}"> + <template slot-scope="scope"> + <router-link + v-if="tableFrom.type != 5" + :to="{path: roterPre + '/product/list/addProduct/' + scope.row.product_id}" + > <el-button type="text" size="small" class="mr10">编辑</el-button> </router-link> - <router-link v-if="tableFrom.type != 5" :to="{path: roterPre + '/product/list/addProduct/' + scope.row.product_id+'?type=copy'}"> + <router-link + v-if="tableFrom.type != 5" + :to="{path: roterPre + '/product/list/addProduct/' + scope.row.product_id+'?type=copy'}" + > <el-button type="text" size="small" class="mr10">复制</el-button> </router-link> - <el-button v-if="tableFrom.type !== '5'" type="text" size="small" @click="handlePreview(scope.row.product_id)">预览</el-button> - <router-link v-if="tableFrom.type != 5" :to="{path: roterPre + '/product/reviews/?product_id=' + scope.row.product_id}"> + <el-button + v-if="tableFrom.type !== '5'" + type="text" + size="small" + @click="handlePreview(scope.row.product_id)" + >预览</el-button> + <router-link + v-if="tableFrom.type != 5" + :to="{path: roterPre + '/product/reviews/?product_id=' + scope.row.product_id}" + > <el-button type="text" size="small" class="mr10">查看评价</el-button> </router-link> - <el-button v-if="tableFrom.type !== '5' && is_audit == '1' " type="text" size="small" @click="onAuditFree(scope.row)">免审编辑</el-button> - <el-button v-if="tableFrom.type !== '5'" type="text" size="small" @click="onEditLabel(scope.row)">编辑标签</el-button> - <el-button v-if="tableFrom.type === '5'" type="text" size="small" @click="handleRestore(scope.row.product_id)">恢复商品</el-button> - <el-button v-if="tableFrom.type !== '1' && tableFrom.type!== '3' && tableFrom.type !=='4' " type="text" size="small" @click="handleDelete(scope.row.product_id, scope.$index)">{{ tableFrom.type === '5' ? '删除' : '加入回收站' }}</el-button> + <el-button + v-if="tableFrom.type !== '5' && is_audit == '1' " + type="text" + size="small" + @click="onAuditFree(scope.row)" + >免审编辑</el-button> + <el-button + v-if="tableFrom.type !== '5'" + type="text" + size="small" + @click="onEditLabel(scope.row)" + >编辑标签</el-button> + <el-button + v-if="tableFrom.type === '5'" + type="text" + size="small" + @click="handleRestore(scope.row.product_id)" + >恢复商品</el-button> + <el-button + v-if="tableFrom.type !== '1' && tableFrom.type!== '3' && tableFrom.type !=='4' " + type="text" + size="small" + @click="handleDelete(scope.row.product_id, scope.$index)" + >{{ tableFrom.type === '5' ? '删除' : '加入回收站' }}</el-button> </template> </el-table-column> </el-table> <div class="block"> - <el-pagination :page-sizes="[20, 40, 60, 80]" :page-size="tableFrom.limit" :current-page="tableFrom.page" layout="total, sizes, prev, pager, next, jumper" :total="tableData.total" @size-change="handleSizeChange" @current-change="pageChange" /> + <el-pagination + :page-sizes="[20, 40, 60, 80]" + :page-size="tableFrom.limit" + :current-page="tableFrom.page" + layout="total, sizes, prev, pager, next, jumper" + :total="tableData.total" + @size-change="handleSizeChange" + @current-change="pageChange" + /> </div> </el-card> <!-- 生成淘宝京东表单--> - <tao-bao ref="taoBao" @getSuccess="getSuccess" :deliveryType="deliveryType" :deliveryList="deliveryList"/> + <tao-bao + ref="taoBao" + @getSuccess="getSuccess" + :deliveryType="deliveryType" + :deliveryList="deliveryList" + /> <!--预览商品--> <div v-if="previewVisible"> <div class="bg" @click.stop="previewVisible = false" /> - <preview-box v-if="previewVisible" ref="previewBox" :goods-id="goodsId" :product-type="0" :preview-key="previewKey" /> + <preview-box + v-if="previewVisible" + ref="previewBox" + :goods-id="goodsId" + :product-type="product" + :preview-key="previewKey" + /> </div> <!--编辑标签--> <el-dialog @@ -212,7 +367,13 @@ > <el-form ref="labelForm" :model="labelForm" @submit.native.prevent> <el-form-item> - <el-select v-model="labelForm.mer_labels" clearable multiple placeholder="请选择" class="selWidth"> + <el-select + v-model="labelForm.mer_labels" + clearable + multiple + placeholder="请选择" + class="selWidth" + > <el-option v-for="item in labelList" :key="item.id" @@ -227,7 +388,7 @@ </span> </el-dialog> <!-- 免审核弹窗--> - <edit-attr ref="editAttr"/> + <edit-attr ref="editAttr" /> <!--运费模板弹窗--> <el-dialog v-if="dialogFreight" @@ -253,18 +414,34 @@ </span> </el-dialog> <!--批量设置佣金弹窗--> - <el-dialog - v-if="dialogCommision" - title="设置佣金" - :visible.sync="dialogCommision" - width="600px" - > - <el-form ref="commisionForm" :model="commisionForm" :rules="commisionRule" @submit.native.prevent> + <el-dialog v-if="dialogCommision" title="设置佣金" :visible.sync="dialogCommision" width="600px"> + <el-form + ref="commisionForm" + :model="commisionForm" + :rules="commisionRule" + @submit.native.prevent + > <el-form-item label="一级佣金比例:" prop="extension_one"> - <el-input-number v-model="commisionForm.extension_one" :precision="2" :step="0.1" :min="0" :max="1" class="priceBox" controls-position="right"/> + <el-input-number + v-model="commisionForm.extension_one" + :precision="2" + :step="0.1" + :min="0" + :max="1" + class="priceBox" + controls-position="right" + /> </el-form-item> <el-form-item label="二级佣金比例:" prop="extension_two"> - <el-input-number v-model="commisionForm.extension_two" :precision="2" :step="0.1" :min="0" :max="1" class="priceBox" controls-position="right"/> + <el-input-number + v-model="commisionForm.extension_two" + :precision="2" + :step="0.1" + :min="0" + :max="1" + class="priceBox" + controls-position="right" + /> </el-form-item> <el-form-item> <span>备注:订单交易成功后给上级返佣的比例,例:0.5 = 返订单金额的50%</span> @@ -275,23 +452,20 @@ </span> </el-dialog> <!--批量设置付费会员价--> - <el-dialog - v-if="dialogSvip" - title="批量设置付费会员价" - :visible.sync="dialogSvip" - width="700px" - > + <el-dialog v-if="dialogSvip" title="批量设置付费会员价" :visible.sync="dialogSvip" width="700px"> <el-form ref="svipForm" :model="svipForm" @submit.native.prevent label-width="80px"> - <el-form-item - label="参与方式:" - > + <el-form-item label="参与方式:"> <el-radio-group v-model="svipForm.svip_price_type"> <el-radio :label="0" class="radio">不设置会员价</el-radio> <el-radio :label="1" class="radio">默认设置会员价</el-radio> </el-radio-group> </el-form-item> <el-form-item> - 备注:默认设置会员价是指商户在 <router-link :to="{path: roterPre + '/systemForm/Basics/svip'}" style="color: #1890ff;"> [设置-付费会员设置] </router-link> 中设置的会员折扣价,选择后每个商品默认展示此处设置的会员折扣价。 + 备注:默认设置会员价是指商户在 + <router-link + :to="{path: roterPre + '/systemForm/Basics/svip'}" + style="color: #1890ff;" + >[设置-付费会员设置]</router-link>中设置的会员折扣价,选择后每个商品默认展示此处设置的会员折扣价。 </el-form-item> </el-form> <span slot="footer" class="dialog-footer"> @@ -329,13 +503,14 @@ import { batchesTempApi, productBathExtApi, productBathSvipApi -} from '@/api/product' -import { roterPre } from '@/settings' -import taoBao from './taoBao' -import editAttr from './editAttr' -import previewBox from '@/components/previewBox/index' +} from "@/api/product"; +import { getBaseInfo } from "@/api/user"; +import { roterPre } from "@/settings"; +import taoBao from "./taoBao"; +import editAttr from "./editAttr"; +import previewBox from "@/components/previewBox/index"; export default { - name: 'ProductList', + name: "ProductList", components: { taoBao, previewBox, editAttr }, data() { return { @@ -354,40 +529,46 @@ export default { tableFrom: { page: 1, limit: 20, - mer_cate_id: '', - cate_id: '', - keyword: '', - temp_id: '', - type: this.$route.query.type ? this.$route.query.type : '1', - is_gift_bag: '', - us_status: '', - mer_labels: '', - svip_price_type: '', - product_id: this.$route.query.id ? this.$route.query.id : '' + mer_cate_id: "", + cate_id: "", + keyword: "", + temp_id: "", + type: this.$route.query.type ? this.$route.query.type : "1", + is_gift_bag: "", + us_status: "", + mer_labels: "", + svip_price_type: "", + product_id: this.$route.query.id ? this.$route.query.id : "" }, categoryList: [], // 平台 merCateList: [], // 商户分类筛选 modals: false, - tabClickIndex: '', + tabClickIndex: "", multipleSelection: [], productStatusList: [ - { label: '上架显示', value: 1 }, - { label: '下架', value: 0 }, - { label: '平台关闭', value: -1 } + { label: "上架显示", value: 1 }, + { label: "下架", value: 0 }, + { label: "平台关闭", value: -1 } ], tempRule: { - temp_id: [{required: true,message: '请选择运费模板',trigger: 'change'}] + temp_id: [ + { required: true, message: "请选择运费模板", trigger: "change" } + ] }, commisionRule: { - extension_one: [{required: true,message: '请输入一级佣金',trigger: 'change'}], - extension_two: [{required: true,message: '请输入二级佣金',trigger: 'change'}] + extension_one: [ + { required: true, message: "请输入一级佣金", trigger: "change" } + ], + extension_two: [ + { required: true, message: "请输入二级佣金", trigger: "change" } + ] }, - commisionForm: {extension_one:0,extension_two:0}, - svipForm: {svip_price_type: 0}, - goodsId: '', - previewKey: '', - product_id: '', + commisionForm: { extension_one: 0, extension_two: 0 }, + svipForm: { svip_price_type: 0 }, + goodsId: "", + previewKey: "", + product_id: "", previewVisible: false, dialogLabel: false, dialogFreight: false, @@ -399,88 +580,96 @@ export default { labelForm: {}, tempForm: {}, isBatch: false, - open_svip: false - } + open_svip: false, + product:'' + }; }, mounted() { - this.getLstFilterApi() - this.getCategorySelect() - this.getCategoryList() - this.getList(1) - this.getLabelLst() - this.getTempLst() - this.productCon() + this.getLstFilterApi(); + this.getCategorySelect(); + this.getCategoryList(); + this.getList(1); + this.getLabelLst(); + this.getTempLst(); + this.productCon(); + }, + updated(){ + getBaseInfo().then(res => { + let typeName = res.data.merchantType.type_name; + if (typeName !== "市级供应链") { + this.product = 0; + } else { + this.product = 98; + } + }); + console.log(this.product); }, methods: { // 把每一行的索引放进row tableRowClassName({ row, rowIndex }) { - row.index = rowIndex + row.index = rowIndex; }, // 添加明细原因 row 当前行 column 当前列 tabClick(row) { - this.tabClickIndex = row.index + this.tabClickIndex = row.index; }, // 失去焦点初始化 inputBlur(scope) { - if (!scope.row.sort || scope.row.sort < 0) scope.row.sort = 0 + if (!scope.row.sort || scope.row.sort < 0) scope.row.sort = 0; productSort(scope.row.product_id, { sort: scope.row.sort }) - .then((res) => { - this.closeEdit() - }) - .catch((res) => { + .then(res => { + this.closeEdit(); }) + .catch(res => {}); }, closeEdit() { - this.tabClickIndex = null + this.tabClickIndex = null; }, handleSelectionChange(val) { - this.multipleSelection = val - const data = [] - this.multipleSelection.map((item) => { - data.push(item.product_id) - }) - this.product_ids = data + this.multipleSelection = val; + const data = []; + this.multipleSelection.map(item => { + data.push(item.product_id); + }); + this.product_ids = data; }, productCon() { productConfigApi() .then(res => { - this.is_audit = res.data.is_audit - this.open_svip = res.data.mer_svip_status == 1 && res.data.svip_switch_status == 1 - this.deliveryType = res.data.delivery_way.map(String) + this.is_audit = res.data.is_audit; + this.open_svip = + res.data.mer_svip_status == 1 && res.data.svip_switch_status == 1; + this.deliveryType = res.data.delivery_way.map(String); if (this.deliveryType.length == 2) { this.deliveryList = [ - { value: '1', name: '到店自提' }, - { value: '2', name: '快递配送' } - ] + { value: "1", name: "到店自提" }, + { value: "2", name: "快递配送" } + ]; } else { - if (this.deliveryType.length == 1 && this.deliveryType[0] == '1') { - this.deliveryList = [ - { value: '1', name: '到店自提' } - ] + if (this.deliveryType.length == 1 && this.deliveryType[0] == "1") { + this.deliveryList = [{ value: "1", name: "到店自提" }]; } else { - this.deliveryList = [ - { value: '2', name: '快递配送' } - ] + this.deliveryList = [{ value: "2", name: "快递配送" }]; } } }) .catch(res => { - this.$message.error(res.message) - }) + this.$message.error(res.message); + }); }, getSuccess() { - this.getLstFilterApi() - this.getList(1) + this.getLstFilterApi(); + this.getList(1); }, handleClose() { - this.dialogLabel = false + this.dialogLabel = false; }, handleFreightClose() { - this.dialogFreight = false + this.dialogFreight = false; }, // 添加淘宝商品成功 onClose() { - this.modals = false + this.modals = false; }, // 复制淘宝 onCopy() { @@ -488,100 +677,108 @@ export default { // this.$refs.taoBao.soure_link = '' // this.$refs.taoBao.formValidate = {} // this.$refs.taoBao.isData = false - this.$router.push({ - path: this.roterPre + '/product/list/addProduct', - query: { type: 1 }, + this.$router.push({ + path: this.roterPre + "/product/list/addProduct", + query: { type: 1 } }); }, // 获取标签项 getLabelLst() { - getProductLabelApi().then(res => { - this.labelList = res.data - }) - .catch(res => { - this.$message.error(res.message) + getProductLabelApi() + .then(res => { + this.labelList = res.data; }) + .catch(res => { + this.$message.error(res.message); + }); }, // 获取运费模板 getTempLst() { - shippingListApi().then(res => { - this.tempList = res.data - }) - .catch(res => { - this.$message.error(res.message) + shippingListApi() + .then(res => { + this.tempList = res.data; }) + .catch(res => { + this.$message.error(res.message); + }); }, // 免审编辑 onAuditFree(row) { - this.$refs.editAttr.getAttrDetail(row.product_id) + this.$refs.editAttr.getAttrDetail(row.product_id); }, // 批量设置佣金 batchCommision() { - if(this.multipleSelection.length === 0) return this.$message.warning('请先选择商品') + if (this.multipleSelection.length === 0) + return this.$message.warning("请先选择商品"); this.dialogCommision = true; }, // 批量设置会员价 batchSvip() { - if(this.multipleSelection.length === 0) return this.$message.warning('请先选择商品') + if (this.multipleSelection.length === 0) + return this.$message.warning("请先选择商品"); this.dialogSvip = true; }, submitCommisionForm(name) { - this.$refs[name].validate(valid => { + this.$refs[name].validate(valid => { if (valid) { - this.commisionForm.ids = this.product_ids + this.commisionForm.ids = this.product_ids; productBathExtApi(this.commisionForm).then(({ message }) => { - this.$message.success(message) - this.getList('') - this.dialogCommision = false - }) + this.$message.success(message); + this.getList(""); + this.dialogCommision = false; + }); } else { - return + return; } - }) + }); }, // 提交会员价 submitSvipForm(name) { - this.svipForm.ids = this.product_ids + this.svipForm.ids = this.product_ids; productBathSvipApi(this.svipForm).then(({ message }) => { - this.$message.success(message) - this.getList('') - this.dialogSvip = false - }) + this.$message.success(message); + this.getList(""); + this.dialogSvip = false; + }); }, // 批量上架 batchShelf() { - if(this.multipleSelection.length === 0) return this.$message.warning('请先选择商品') - let data = {status: 1,ids: this.product_ids} - batchesOnOffApi(data).then(res => { - this.$message.success(res.message) - this.getLstFilterApi() - this.getList('') - }) - .catch(res => { - this.$message.error(res.message) - }) + if (this.multipleSelection.length === 0) + return this.$message.warning("请先选择商品"); + let data = { status: 1, ids: this.product_ids }; + batchesOnOffApi(data) + .then(res => { + this.$message.success(res.message); + this.getLstFilterApi(); + this.getList(""); + }) + .catch(res => { + this.$message.error(res.message); + }); }, // 批量下架 batchOff() { - if(this.multipleSelection.length === 0) return this.$message.warning('请先选择商品') - let data = {status: 0,ids: this.product_ids} - batchesOnOffApi(data).then(res => { - this.$message.success(res.message) - this.getLstFilterApi() - this.getList('') - }) - .catch(res => { - this.$message.error(res.message) - }) + if (this.multipleSelection.length === 0) + return this.$message.warning("请先选择商品"); + let data = { status: 0, ids: this.product_ids }; + batchesOnOffApi(data) + .then(res => { + this.$message.success(res.message); + this.getLstFilterApi(); + this.getList(""); + }) + .catch(res => { + this.$message.error(res.message); + }); }, // 批量设置标签 batchLabel() { this.labelForm = { mer_labels: [], ids: this.product_ids - } - this.isBatch = true - this.dialogLabel = true + }; + this.isBatch = true; + this.dialogLabel = true; }, // 批量设置运费模板 batchFreight() { @@ -590,165 +787,170 @@ export default { submitTempForm(name) { this.$refs[name].validate(valid => { if (valid) { - this.tempForm.ids = this.product_ids + this.tempForm.ids = this.product_ids; batchesTempApi(this.tempForm).then(({ message }) => { - this.$message.success(message) - this.getList('') - this.dialogFreight = false - }) + this.$message.success(message); + this.getList(""); + this.dialogFreight = false; + }); } else { - return + return; } - }) + }); }, handleRestore(id) { - this.$modalSure('恢复商品').then(() => { + this.$modalSure("恢复商品").then(() => { restoreApi(id) .then(res => { - this.$message.success(res.message) - this.getLstFilterApi() - this.getList('') + this.$message.success(res.message); + this.getLstFilterApi(); + this.getList(""); }) .catch(res => { - this.$message.error(res.message) - }) - }) + this.$message.error(res.message); + }); + }); }, // 预览 handlePreview(id) { - this.previewVisible = true - this.goodsId = id - this.previewKey = '' + console.log(id); + console.log("123"); + this.previewVisible = true; + this.goodsId = id; + this.previewKey = ""; }, // 商户分类; getCategorySelect() { categorySelectApi() .then(res => { - this.merCateList = res.data + this.merCateList = res.data; }) .catch(res => { - this.$message.error(res.message) - }) + this.$message.error(res.message); + }); }, // 平台分类; getCategoryList() { categoryListApi() .then(res => { - this.categoryList = res.data + this.categoryList = res.data; }) .catch(res => { - this.$message.error(res.message) - }) + this.$message.error(res.message); + }); }, // 列表表头; getLstFilterApi() { lstFilterApi() .then(res => { - this.headeNum = res.data + this.headeNum = res.data; }) .catch(res => { - this.$message.error(res.message) - }) + this.$message.error(res.message); + }); }, // 列表 getList(num) { - this.listLoading = true - this.tableFrom.page = num || this.tableFrom.page + this.listLoading = true; + this.tableFrom.page = num || this.tableFrom.page; productLstApi(this.tableFrom) .then(res => { - this.tableData.data = res.data.list - this.tableData.total = res.data.count - this.listLoading = false + this.tableData.data = res.data.list; + this.tableData.total = res.data.count; + this.listLoading = false; }) .catch(res => { - this.listLoading = false - this.$message.error(res.message) - }) - this.getLstFilterApi() + this.listLoading = false; + this.$message.error(res.message); + }); + this.getLstFilterApi(); }, pageChange(page) { - this.tableFrom.page = page - this.getList('') + this.tableFrom.page = page; + this.getList(""); }, handleSizeChange(val) { - this.tableFrom.limit = val - this.getList('') + this.tableFrom.limit = val; + this.getList(""); }, // 删除 handleDelete(id, idx) { - this.$modalSure(this.tableFrom.type !== '5' ? '加入回收站' : '删除该商品').then( - () => { - this.tableFrom.type === '5' - ? destoryApi(id) + this.$modalSure( + this.tableFrom.type !== "5" ? "加入回收站" : "删除该商品" + ).then(() => { + this.tableFrom.type === "5" + ? destoryApi(id) .then(({ message }) => { - this.$message.success(message) - this.getList('') - this.getLstFilterApi() + this.$message.success(message); + this.getList(""); + this.getLstFilterApi(); }) .catch(({ message }) => { - this.$message.error(message) + this.$message.error(message); }) - : productDeleteApi(id) + : productDeleteApi(id) .then(({ message }) => { - this.$message.success(message) - this.getList('') - this.getLstFilterApi() + this.$message.success(message); + this.getList(""); + this.getLstFilterApi(); }) .catch(({ message }) => { - this.$message.error(message) - }) - } - ) + this.$message.error(message); + }); + }); }, // 编辑标签 onEditLabel(row) { - this.dialogLabel = true - this.product_id = row.product_id + this.dialogLabel = true; + this.product_id = row.product_id; if (row.mer_labels && row.mer_labels.length) { const arrNew = row.mer_labels.map(item => { - return item.product_label_id - }) + return item.product_label_id; + }); this.labelForm = { mer_labels: arrNew - } + }; } else { this.labelForm = { mer_labels: [] - } + }; } }, submitForm(name) { this.$refs[name].validate(valid => { if (valid) { - this.isBatch ? batchesLabelsApi(this.labelForm).then(({ message }) => { - this.$message.success(message) - this.getList('') - this.dialogLabel = false - this.isBatch = false - }) : - updatetProductLabel(this.product_id, this.labelForm).then(({ message }) => { - this.$message.success(message) - this.getList('') - this.dialogLabel = false - }) + this.isBatch + ? batchesLabelsApi(this.labelForm).then(({ message }) => { + this.$message.success(message); + this.getList(""); + this.dialogLabel = false; + this.isBatch = false; + }) + : updatetProductLabel(this.product_id, this.labelForm).then( + ({ message }) => { + this.$message.success(message); + this.getList(""); + this.dialogLabel = false; + } + ); } else { - return + return; } - }) + }); }, onchangeIsShow(row) { statusApi(row.product_id, row.is_show) .then(({ message }) => { - this.$message.success(message) - this.getList('') - this.getLstFilterApi() + this.$message.success(message); + this.getList(""); + this.getLstFilterApi(); }) .catch(({ message }) => { - this.$message.error(message) - }) + this.$message.error(message); + }); } } -} +}; </script> <style scoped lang="scss">