|
|
@@ -0,0 +1,449 @@
|
|
|
1
|
+<template>
|
|
|
2
|
+ <div class="app-container">
|
|
|
3
|
+ <!-- 检索区 -->
|
|
|
4
|
+ <el-card shadow="never" class="search-card">
|
|
|
5
|
+ <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="80px">
|
|
|
6
|
+ <el-form-item label="商品编号" prop="goodsSn">
|
|
|
7
|
+ <el-input v-model="queryParams.goodsSn" placeholder="商品编号" clearable style="width: 160px" @keyup.enter.native="handleQuery" />
|
|
|
8
|
+ </el-form-item>
|
|
|
9
|
+ <el-form-item label="商品名称" prop="goodsName">
|
|
|
10
|
+ <el-input v-model="queryParams.goodsName" placeholder="商品名称" clearable style="width: 160px" @keyup.enter.native="handleQuery" />
|
|
|
11
|
+ </el-form-item>
|
|
|
12
|
+ <el-form-item label="商品分类" prop="categoryId">
|
|
|
13
|
+ <el-select v-model="queryParams.categoryId" placeholder="全部" clearable filterable style="width: 200px">
|
|
|
14
|
+ <el-option v-for="item in categoryOptions" :key="item.categoryId" :label="item.label" :value="item.categoryId" />
|
|
|
15
|
+ </el-select>
|
|
|
16
|
+ </el-form-item>
|
|
|
17
|
+ <el-form-item>
|
|
|
18
|
+ <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
|
|
19
|
+ <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
|
|
20
|
+ </el-form-item>
|
|
|
21
|
+ </el-form>
|
|
|
22
|
+ </el-card>
|
|
|
23
|
+
|
|
|
24
|
+ <br/>
|
|
|
25
|
+
|
|
|
26
|
+ <!-- 列表区 -->
|
|
|
27
|
+ <el-card shadow="never" class="table-card">
|
|
|
28
|
+ <el-tabs v-model="statusTab" @tab-click="handleTabClick">
|
|
|
29
|
+ <el-tab-pane label="全部" name="all" />
|
|
|
30
|
+ <el-tab-pane label="未上架" name="0" />
|
|
|
31
|
+ <el-tab-pane label="待审核" name="1" />
|
|
|
32
|
+ <el-tab-pane label="出售中" name="2" />
|
|
|
33
|
+ <el-tab-pane label="审核失败" name="3" />
|
|
|
34
|
+ <el-tab-pane label="已下架" name="4" />
|
|
|
35
|
+ </el-tabs>
|
|
|
36
|
+
|
|
|
37
|
+ <el-row :gutter="10" class="mb8">
|
|
|
38
|
+ <el-col :span="1.5">
|
|
|
39
|
+ <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['agri:seller:goods:add']">添加商品</el-button>
|
|
|
40
|
+ </el-col>
|
|
|
41
|
+ <el-col :span="1.5">
|
|
|
42
|
+ <el-button type="success" plain icon="el-icon-upload2" size="mini" :disabled="!canBatchSubmit" @click="handleBatchSubmit" v-hasPermi="['agri:seller:goods:edit']">批量提交上架</el-button>
|
|
|
43
|
+ </el-col>
|
|
|
44
|
+ <el-col :span="1.5">
|
|
|
45
|
+ <el-button type="warning" plain icon="el-icon-bottom" size="mini" :disabled="!canBatchOffShelf" @click="handleBatchOffShelf" v-hasPermi="['agri:seller:goods:offshelf']">批量下架</el-button>
|
|
|
46
|
+ </el-col>
|
|
|
47
|
+ <el-col :span="1.5">
|
|
|
48
|
+ <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="!canBatchDelete" @click="handleBatchDelete" v-hasPermi="['agri:seller:goods:remove']">批量删除</el-button>
|
|
|
49
|
+ </el-col>
|
|
|
50
|
+ <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
|
|
51
|
+ </el-row>
|
|
|
52
|
+
|
|
|
53
|
+ <el-table border v-loading="loading" :data="goodsList" @selection-change="handleSelectionChange">
|
|
|
54
|
+ <el-table-column type="selection" width="55" align="center" />
|
|
|
55
|
+ <el-table-column label="商品编号" align="center" prop="goodsSn" width="140" />
|
|
|
56
|
+ <el-table-column label="主图" align="center" width="80">
|
|
|
57
|
+ <template slot-scope="scope">
|
|
|
58
|
+ <image-preview :src="scope.row.mainPic" :width="50" :height="50" />
|
|
|
59
|
+ </template>
|
|
|
60
|
+ </el-table-column>
|
|
|
61
|
+ <el-table-column label="商品名称" align="center" prop="goodsName" min-width="140" :show-overflow-tooltip="true" />
|
|
|
62
|
+ <el-table-column label="售价" align="center" prop="salePrice" width="90" />
|
|
|
63
|
+ <el-table-column label="库存" align="center" prop="stock" width="70" />
|
|
|
64
|
+ <el-table-column label="销量" align="center" prop="salesCount" width="70" />
|
|
|
65
|
+ <el-table-column label="商品分类" align="center" prop="categoryPath" min-width="120" :show-overflow-tooltip="true" />
|
|
|
66
|
+ <el-table-column label="店铺分类" align="center" prop="shopCategoryName" min-width="110" :show-overflow-tooltip="true">
|
|
|
67
|
+ <template slot-scope="scope">
|
|
|
68
|
+ <span>{{ scope.row.shopCategoryName || '—' }}</span>
|
|
|
69
|
+ </template>
|
|
|
70
|
+ </el-table-column>
|
|
|
71
|
+ <el-table-column label="状态" align="center" prop="goodsStatus" width="90">
|
|
|
72
|
+ <template slot-scope="scope">
|
|
|
73
|
+ <el-tag size="small" :type="goodsStatusTag(scope.row.goodsStatus)">{{ goodsStatusLabel(scope.row) }}</el-tag>
|
|
|
74
|
+ </template>
|
|
|
75
|
+ </el-table-column>
|
|
|
76
|
+ <el-table-column label="操作" align="center" width="240" fixed="right">
|
|
|
77
|
+ <template slot-scope="scope">
|
|
|
78
|
+ <el-button size="mini" type="text" icon="el-icon-view" @click="handleDetail(scope.row)" v-hasPermi="['agri:seller:goods:query']">详情</el-button>
|
|
|
79
|
+ <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['agri:seller:goods:edit']">编辑</el-button>
|
|
|
80
|
+ <el-button v-if="canRowSubmit(scope.row)" size="mini" type="text" icon="el-icon-upload2" @click="handleRowSubmit(scope.row)" v-hasPermi="['agri:seller:goods:edit']">提交上架</el-button>
|
|
|
81
|
+ <el-button v-if="scope.row.goodsStatus === '2'" size="mini" type="text" icon="el-icon-bottom" @click="handleRowOffShelf(scope.row)" v-hasPermi="['agri:seller:goods:offshelf']">下架</el-button>
|
|
|
82
|
+ <el-button v-if="canRowDelete(scope.row)" size="mini" type="text" icon="el-icon-delete" @click="handleRowDelete(scope.row)" v-hasPermi="['agri:seller:goods:remove']">删除</el-button>
|
|
|
83
|
+ </template>
|
|
|
84
|
+ </el-table-column>
|
|
|
85
|
+ </el-table>
|
|
|
86
|
+
|
|
|
87
|
+ <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
|
|
|
88
|
+ </el-card>
|
|
|
89
|
+
|
|
|
90
|
+ <!-- 详情抽屉 -->
|
|
|
91
|
+ <seller-goods-detail
|
|
|
92
|
+ :visible.sync="detailOpen"
|
|
|
93
|
+ :goods-id="currentGoodsId"
|
|
|
94
|
+ @edit="handleUpdateFromDetail"
|
|
|
95
|
+ @success="handleSuccess"
|
|
|
96
|
+ />
|
|
|
97
|
+
|
|
|
98
|
+ <!-- 添加/编辑弹窗 -->
|
|
|
99
|
+ <el-dialog :title="formTitle" :visible.sync="formOpen" width="720px" append-to-body @close="cancelForm">
|
|
|
100
|
+ <el-form ref="form" :model="form" :rules="rules" label-width="110px">
|
|
|
101
|
+ <el-form-item label="商品分类" prop="categoryId">
|
|
|
102
|
+ <el-select v-model="form.categoryId" placeholder="请选择平台二级分类" filterable style="width: 100%">
|
|
|
103
|
+ <el-option v-for="item in categoryOptions" :key="item.categoryId" :label="item.label" :value="item.categoryId" />
|
|
|
104
|
+ </el-select>
|
|
|
105
|
+ </el-form-item>
|
|
|
106
|
+ <el-form-item label="店铺商品分类" prop="shopCategoryId">
|
|
|
107
|
+ <el-select v-model="form.shopCategoryId" placeholder="选填,本店二级分类" clearable filterable style="width: 100%">
|
|
|
108
|
+ <el-option v-for="item in shopCategoryOptions" :key="item.shopCategoryId" :label="item.label" :value="item.shopCategoryId" />
|
|
|
109
|
+ </el-select>
|
|
|
110
|
+ </el-form-item>
|
|
|
111
|
+ <el-form-item label="商品名称" prop="goodsName">
|
|
|
112
|
+ <el-input v-model="form.goodsName" placeholder="请输入商品名称" maxlength="200" />
|
|
|
113
|
+ </el-form-item>
|
|
|
114
|
+ <el-form-item label="商品主图" prop="mainPic">
|
|
|
115
|
+ <image-upload v-model="form.mainPic" :limit="1" :file-size="5" :file-type="['png', 'jpg', 'jpeg']" />
|
|
|
116
|
+ </el-form-item>
|
|
|
117
|
+ <el-row :gutter="16">
|
|
|
118
|
+ <el-col :span="12">
|
|
|
119
|
+ <el-form-item label="销售价" prop="salePrice">
|
|
|
120
|
+ <el-input-number v-model="form.salePrice" :min="0" :precision="2" controls-position="right" style="width: 100%" />
|
|
|
121
|
+ </el-form-item>
|
|
|
122
|
+ </el-col>
|
|
|
123
|
+ <el-col :span="12">
|
|
|
124
|
+ <el-form-item label="库存" prop="stock">
|
|
|
125
|
+ <el-input-number v-model="form.stock" :min="0" :precision="0" controls-position="right" style="width: 100%" />
|
|
|
126
|
+ </el-form-item>
|
|
|
127
|
+ </el-col>
|
|
|
128
|
+ </el-row>
|
|
|
129
|
+ <el-form-item label="商品详情" prop="detailContent">
|
|
|
130
|
+ <editor v-model="form.detailContent" :min-height="200" />
|
|
|
131
|
+ </el-form-item>
|
|
|
132
|
+ <el-form-item label="服务说明">
|
|
|
133
|
+ <el-checkbox-group v-model="form.serviceIds">
|
|
|
134
|
+ <el-checkbox v-for="item in serviceOptions" :key="item.serviceId" :label="item.serviceId">{{ item.serviceName }}</el-checkbox>
|
|
|
135
|
+ </el-checkbox-group>
|
|
|
136
|
+ <div v-if="!serviceOptions.length" class="form-tip">暂无可用服务项</div>
|
|
|
137
|
+ </el-form-item>
|
|
|
138
|
+ </el-form>
|
|
|
139
|
+ <div slot="footer" class="dialog-footer">
|
|
|
140
|
+ <el-button type="primary" @click="submitForm">保 存</el-button>
|
|
|
141
|
+ <el-button @click="cancelForm">取 消</el-button>
|
|
|
142
|
+ </div>
|
|
|
143
|
+ </el-dialog>
|
|
|
144
|
+ </div>
|
|
|
145
|
+</template>
|
|
|
146
|
+
|
|
|
147
|
+<script>
|
|
|
148
|
+import {
|
|
|
149
|
+ listSellerGoods,
|
|
|
150
|
+ sellerGoodsCategoryOptions,
|
|
|
151
|
+ sellerGoodsShopCategoryOptions,
|
|
|
152
|
+ sellerGoodsServiceOptions,
|
|
|
153
|
+ getSellerGoods,
|
|
|
154
|
+ addSellerGoods,
|
|
|
155
|
+ updateSellerGoods,
|
|
|
156
|
+ submitSellerGoods,
|
|
|
157
|
+ submitSellerGoodsBatch,
|
|
|
158
|
+ offShelfSellerGoods,
|
|
|
159
|
+ offShelfSellerGoodsBatch,
|
|
|
160
|
+ delSellerGoods
|
|
|
161
|
+} from "@/api/agri/seller/goods"
|
|
|
162
|
+import { getSellerContext } from "@/api/agri/seller/context"
|
|
|
163
|
+import { setSellerShopContext } from "@/utils/sellerShop"
|
|
|
164
|
+import SellerGoodsDetail from "./detail"
|
|
|
165
|
+
|
|
|
166
|
+export default {
|
|
|
167
|
+ name: "AgriSellerGoods",
|
|
|
168
|
+ components: { SellerGoodsDetail },
|
|
|
169
|
+ data() {
|
|
|
170
|
+ return {
|
|
|
171
|
+ loading: true,
|
|
|
172
|
+ showSearch: true,
|
|
|
173
|
+ total: 0,
|
|
|
174
|
+ goodsList: [],
|
|
|
175
|
+ selection: [],
|
|
|
176
|
+ detailOpen: false,
|
|
|
177
|
+ currentGoodsId: null,
|
|
|
178
|
+ formOpen: false,
|
|
|
179
|
+ formTitle: "",
|
|
|
180
|
+ statusTab: "all",
|
|
|
181
|
+ categoryOptions: [],
|
|
|
182
|
+ shopCategoryOptions: [],
|
|
|
183
|
+ serviceOptions: [],
|
|
|
184
|
+ defaultServiceIds: [],
|
|
|
185
|
+ queryParams: {
|
|
|
186
|
+ pageNum: 1,
|
|
|
187
|
+ pageSize: 10,
|
|
|
188
|
+ goodsSn: undefined,
|
|
|
189
|
+ goodsName: undefined,
|
|
|
190
|
+ categoryId: undefined,
|
|
|
191
|
+ goodsStatusQuery: undefined
|
|
|
192
|
+ },
|
|
|
193
|
+ form: {},
|
|
|
194
|
+ rules: {
|
|
|
195
|
+ categoryId: [{ required: true, message: "请选择商品分类", trigger: "change" }],
|
|
|
196
|
+ goodsName: [{ required: true, message: "请输入商品名称", trigger: "blur" }],
|
|
|
197
|
+ mainPic: [{ required: true, message: "请上传商品主图", trigger: "change" }],
|
|
|
198
|
+ salePrice: [{ required: true, message: "请输入销售价", trigger: "blur" }],
|
|
|
199
|
+ stock: [{ required: true, message: "请输入库存", trigger: "blur" }],
|
|
|
200
|
+ detailContent: [{ required: true, message: "请填写商品详情", trigger: "blur" }]
|
|
|
201
|
+ }
|
|
|
202
|
+ }
|
|
|
203
|
+ },
|
|
|
204
|
+ computed: {
|
|
|
205
|
+ /** 所选是否均可提交上架 */
|
|
|
206
|
+ canBatchSubmit() {
|
|
|
207
|
+ return this.selection.length > 0 && this.selection.every(item => this.canRowSubmit(item))
|
|
|
208
|
+ },
|
|
|
209
|
+ /** 所选是否均可下架 */
|
|
|
210
|
+ canBatchOffShelf() {
|
|
|
211
|
+ return this.selection.length > 0 && this.selection.every(item => item.goodsStatus === "2")
|
|
|
212
|
+ },
|
|
|
213
|
+ /** 所选是否均可删除 */
|
|
|
214
|
+ canBatchDelete() {
|
|
|
215
|
+ return this.selection.length > 0 && this.selection.every(item => this.canRowDelete(item))
|
|
|
216
|
+ }
|
|
|
217
|
+ },
|
|
|
218
|
+ created() {
|
|
|
219
|
+ this.initPage()
|
|
|
220
|
+ },
|
|
|
221
|
+ methods: {
|
|
|
222
|
+ /** 初始化:店铺上下文 + 下拉 + 列表 */
|
|
|
223
|
+ initPage() {
|
|
|
224
|
+ this.loadShopContext().then(() => {
|
|
|
225
|
+ this.loadFormOptions()
|
|
|
226
|
+ this.getList()
|
|
|
227
|
+ }).catch(() => {
|
|
|
228
|
+ this.loadFormOptions()
|
|
|
229
|
+ this.getList()
|
|
|
230
|
+ })
|
|
|
231
|
+ },
|
|
|
232
|
+ /** 写入 X-Shop-Id 缓存 */
|
|
|
233
|
+ loadShopContext() {
|
|
|
234
|
+ return getSellerContext().then(response => {
|
|
|
235
|
+ const data = response.data || {}
|
|
|
236
|
+ if (data.shopId != null) {
|
|
|
237
|
+ setSellerShopContext(data.shopId, data.shopName)
|
|
|
238
|
+ }
|
|
|
239
|
+ })
|
|
|
240
|
+ },
|
|
|
241
|
+ /** 加载发品/检索用下拉 */
|
|
|
242
|
+ loadFormOptions() {
|
|
|
243
|
+ sellerGoodsCategoryOptions().then(response => {
|
|
|
244
|
+ this.categoryOptions = response.data || []
|
|
|
245
|
+ }).catch(() => {})
|
|
|
246
|
+ sellerGoodsShopCategoryOptions(false).then(response => {
|
|
|
247
|
+ this.shopCategoryOptions = response.data || []
|
|
|
248
|
+ }).catch(() => {})
|
|
|
249
|
+ sellerGoodsServiceOptions().then(response => {
|
|
|
250
|
+ const data = response.data || {}
|
|
|
251
|
+ this.serviceOptions = data.all || []
|
|
|
252
|
+ const defaults = data.defaultShow || []
|
|
|
253
|
+ this.defaultServiceIds = defaults.map(item => item.serviceId)
|
|
|
254
|
+ }).catch(() => {})
|
|
|
255
|
+ },
|
|
|
256
|
+ /** 查询商品列表 */
|
|
|
257
|
+ getList() {
|
|
|
258
|
+ this.loading = true
|
|
|
259
|
+ listSellerGoods(this.queryParams).then(response => {
|
|
|
260
|
+ this.goodsList = response.rows || []
|
|
|
261
|
+ this.total = response.total || 0
|
|
|
262
|
+ this.loading = false
|
|
|
263
|
+ }).catch(() => {
|
|
|
264
|
+ this.loading = false
|
|
|
265
|
+ })
|
|
|
266
|
+ },
|
|
|
267
|
+ goodsStatusLabel(row) {
|
|
|
268
|
+ if (row.goodsStatusLabel) {
|
|
|
269
|
+ return row.goodsStatusLabel
|
|
|
270
|
+ }
|
|
|
271
|
+ const map = { "0": "未上架", "1": "待审核", "2": "出售中", "3": "审核失败", "4": "已下架" }
|
|
|
272
|
+ return map[row.goodsStatus] || "—"
|
|
|
273
|
+ },
|
|
|
274
|
+ goodsStatusTag(status) {
|
|
|
275
|
+ const map = { "0": "", "1": "warning", "2": "success", "3": "danger", "4": "info" }
|
|
|
276
|
+ return map[status] || "info"
|
|
|
277
|
+ },
|
|
|
278
|
+ /** 是否可提交上架 */
|
|
|
279
|
+ canRowSubmit(row) {
|
|
|
280
|
+ return row.goodsStatus === "0" || row.goodsStatus === "3" || row.goodsStatus === "4"
|
|
|
281
|
+ },
|
|
|
282
|
+ /** 是否可删除 */
|
|
|
283
|
+ canRowDelete(row) {
|
|
|
284
|
+ return this.canRowSubmit(row)
|
|
|
285
|
+ },
|
|
|
286
|
+ handleTabClick() {
|
|
|
287
|
+ this.queryParams.goodsStatusQuery = this.statusTab === "all" ? undefined : this.statusTab
|
|
|
288
|
+ this.queryParams.pageNum = 1
|
|
|
289
|
+ this.getList()
|
|
|
290
|
+ },
|
|
|
291
|
+ handleQuery() {
|
|
|
292
|
+ this.queryParams.pageNum = 1
|
|
|
293
|
+ this.getList()
|
|
|
294
|
+ },
|
|
|
295
|
+ resetQuery() {
|
|
|
296
|
+ this.resetForm("queryForm")
|
|
|
297
|
+ this.statusTab = "all"
|
|
|
298
|
+ this.queryParams.goodsStatusQuery = undefined
|
|
|
299
|
+ this.handleQuery()
|
|
|
300
|
+ },
|
|
|
301
|
+ handleSelectionChange(selection) {
|
|
|
302
|
+ this.selection = selection
|
|
|
303
|
+ },
|
|
|
304
|
+ handleDetail(row) {
|
|
|
305
|
+ this.currentGoodsId = row.goodsId
|
|
|
306
|
+ this.detailOpen = true
|
|
|
307
|
+ },
|
|
|
308
|
+ /** 重置表单 */
|
|
|
309
|
+ resetFormData() {
|
|
|
310
|
+ this.form = {
|
|
|
311
|
+ goodsId: undefined,
|
|
|
312
|
+ categoryId: undefined,
|
|
|
313
|
+ shopCategoryId: undefined,
|
|
|
314
|
+ goodsName: undefined,
|
|
|
315
|
+ mainPic: undefined,
|
|
|
316
|
+ detailContent: undefined,
|
|
|
317
|
+ salePrice: undefined,
|
|
|
318
|
+ stock: undefined,
|
|
|
319
|
+ serviceIds: [...this.defaultServiceIds]
|
|
|
320
|
+ }
|
|
|
321
|
+ this.resetForm("form")
|
|
|
322
|
+ },
|
|
|
323
|
+ /** 打开添加商品 */
|
|
|
324
|
+ handleAdd() {
|
|
|
325
|
+ this.resetFormData()
|
|
|
326
|
+ this.formOpen = true
|
|
|
327
|
+ this.formTitle = "添加商品"
|
|
|
328
|
+ },
|
|
|
329
|
+ /** 打开编辑商品 */
|
|
|
330
|
+ handleUpdate(row) {
|
|
|
331
|
+ this.resetFormData()
|
|
|
332
|
+ getSellerGoods(row.goodsId).then(response => {
|
|
|
333
|
+ const data = response.data || {}
|
|
|
334
|
+ this.form = {
|
|
|
335
|
+ goodsId: data.goodsId,
|
|
|
336
|
+ categoryId: data.categoryId,
|
|
|
337
|
+ shopCategoryId: data.shopCategoryId,
|
|
|
338
|
+ goodsName: data.goodsName,
|
|
|
339
|
+ mainPic: data.mainPic,
|
|
|
340
|
+ detailContent: data.detailContent,
|
|
|
341
|
+ salePrice: data.salePrice,
|
|
|
342
|
+ stock: data.stock,
|
|
|
343
|
+ serviceIds: (data.services || []).map(item => item.serviceId)
|
|
|
344
|
+ }
|
|
|
345
|
+ this.formOpen = true
|
|
|
346
|
+ this.formTitle = "编辑商品"
|
|
|
347
|
+ })
|
|
|
348
|
+ },
|
|
|
349
|
+ /** 详情抽屉跳转编辑 */
|
|
|
350
|
+ handleUpdateFromDetail(detail) {
|
|
|
351
|
+ this.handleUpdate({ goodsId: detail.goodsId })
|
|
|
352
|
+ },
|
|
|
353
|
+ cancelForm() {
|
|
|
354
|
+ this.formOpen = false
|
|
|
355
|
+ this.resetFormData()
|
|
|
356
|
+ },
|
|
|
357
|
+ /** 保存商品 */
|
|
|
358
|
+ submitForm() {
|
|
|
359
|
+ this.$refs["form"].validate(valid => {
|
|
|
360
|
+ if (!valid) {
|
|
|
361
|
+ return
|
|
|
362
|
+ }
|
|
|
363
|
+ const payload = { ...this.form }
|
|
|
364
|
+ if (!payload.shopCategoryId) {
|
|
|
365
|
+ payload.shopCategoryId = null
|
|
|
366
|
+ }
|
|
|
367
|
+ const submitFn = payload.goodsId != null ? updateSellerGoods : addSellerGoods
|
|
|
368
|
+ submitFn(payload).then(() => {
|
|
|
369
|
+ this.$modal.msgSuccess(payload.goodsId != null ? "修改成功" : "添加成功,商品状态为未上架")
|
|
|
370
|
+ this.formOpen = false
|
|
|
371
|
+ this.getList()
|
|
|
372
|
+ })
|
|
|
373
|
+ })
|
|
|
374
|
+ },
|
|
|
375
|
+ /** 单条提交上架 */
|
|
|
376
|
+ handleRowSubmit(row) {
|
|
|
377
|
+ this.$modal.confirm("确认提交上架商品「" + row.goodsName + "」?").then(() => {
|
|
|
378
|
+ return submitSellerGoods(row.goodsId)
|
|
|
379
|
+ }).then(response => {
|
|
|
380
|
+ const data = response.data || {}
|
|
|
381
|
+ const label = data.goodsStatusLabel || "操作成功"
|
|
|
382
|
+ this.$modal.msgSuccess("提交成功,当前状态:" + label)
|
|
|
383
|
+ this.handleSuccess()
|
|
|
384
|
+ }).catch(() => {})
|
|
|
385
|
+ },
|
|
|
386
|
+ /** 批量提交上架 */
|
|
|
387
|
+ handleBatchSubmit() {
|
|
|
388
|
+ const ids = this.selection.map(item => item.goodsId)
|
|
|
389
|
+ this.$modal.confirm("确认批量提交上架所选 " + ids.length + " 件商品?").then(() => {
|
|
|
390
|
+ return submitSellerGoodsBatch({ goodsIds: ids })
|
|
|
391
|
+ }).then(() => {
|
|
|
392
|
+ this.$modal.msgSuccess("批量提交成功")
|
|
|
393
|
+ this.handleSuccess()
|
|
|
394
|
+ }).catch(() => {})
|
|
|
395
|
+ },
|
|
|
396
|
+ /** 单条下架 */
|
|
|
397
|
+ handleRowOffShelf(row) {
|
|
|
398
|
+ this.$modal.confirm("下架后 C 端不可购买,是否继续?").then(() => {
|
|
|
399
|
+ return offShelfSellerGoods(row.goodsId)
|
|
|
400
|
+ }).then(() => {
|
|
|
401
|
+ this.$modal.msgSuccess("下架成功")
|
|
|
402
|
+ this.handleSuccess()
|
|
|
403
|
+ }).catch(() => {})
|
|
|
404
|
+ },
|
|
|
405
|
+ /** 批量下架 */
|
|
|
406
|
+ handleBatchOffShelf() {
|
|
|
407
|
+ const ids = this.selection.map(item => item.goodsId)
|
|
|
408
|
+ this.$modal.confirm("确认批量下架所选 " + ids.length + " 件商品?").then(() => {
|
|
|
409
|
+ return offShelfSellerGoodsBatch({ goodsIds: ids })
|
|
|
410
|
+ }).then(() => {
|
|
|
411
|
+ this.$modal.msgSuccess("批量下架成功")
|
|
|
412
|
+ this.handleSuccess()
|
|
|
413
|
+ }).catch(() => {})
|
|
|
414
|
+ },
|
|
|
415
|
+ /** 单条删除 */
|
|
|
416
|
+ handleRowDelete(row) {
|
|
|
417
|
+ this.$modal.confirm("确认删除商品「" + row.goodsName + "」?").then(() => {
|
|
|
418
|
+ return delSellerGoods(row.goodsId)
|
|
|
419
|
+ }).then(() => {
|
|
|
420
|
+ this.$modal.msgSuccess("删除成功")
|
|
|
421
|
+ this.handleSuccess()
|
|
|
422
|
+ }).catch(() => {})
|
|
|
423
|
+ },
|
|
|
424
|
+ /** 批量删除 */
|
|
|
425
|
+ handleBatchDelete() {
|
|
|
426
|
+ const ids = this.selection.map(item => item.goodsId)
|
|
|
427
|
+ this.$modal.confirm("确认批量删除所选 " + ids.length + " 件商品?").then(() => {
|
|
|
428
|
+ return delSellerGoods(ids.join(","))
|
|
|
429
|
+ }).then(() => {
|
|
|
430
|
+ this.$modal.msgSuccess("批量删除成功")
|
|
|
431
|
+ this.handleSuccess()
|
|
|
432
|
+ }).catch(() => {})
|
|
|
433
|
+ },
|
|
|
434
|
+ handleSuccess() {
|
|
|
435
|
+ this.getList()
|
|
|
436
|
+ }
|
|
|
437
|
+ }
|
|
|
438
|
+}
|
|
|
439
|
+</script>
|
|
|
440
|
+
|
|
|
441
|
+<style scoped>
|
|
|
442
|
+.search-card {
|
|
|
443
|
+ margin-bottom: 0;
|
|
|
444
|
+}
|
|
|
445
|
+.form-tip {
|
|
|
446
|
+ color: #909399;
|
|
|
447
|
+ font-size: 13px;
|
|
|
448
|
+}
|
|
|
449
|
+</style>
|