|
@@ -2,41 +2,40 @@
|
|
|
<div class="app-container">
|
|
|
|
|
|
<el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal">
|
|
|
- <el-menu-item index="1"><router-link to="/goods/list">全部商品</router-link></el-menu-item>
|
|
|
- <el-menu-item index="2"><router-link to="/goods/list/preferred">星范优选</router-link></el-menu-item>
|
|
|
- <el-menu-item index="3"><router-link to="/goods/list/preferential">星范精品</router-link></el-menu-item>
|
|
|
- <el-menu-item index="4"><router-link to="/goods/list/commonly">常用商品</router-link></el-menu-item>
|
|
|
+ <el-menu-item index="0"><router-link to="/goods/list">全部商品</router-link></el-menu-item>
|
|
|
+ <el-menu-item v-if="modules && modules.firstModulesName" index="1"><router-link to="/goods/list/preferred">{{ modules.firstModulesName }}</router-link></el-menu-item>
|
|
|
+ <el-menu-item v-if="modules && modules.secondModulesName" index="2"><router-link to="/goods/list/preferential">{{ modules.secondModulesName }}</router-link></el-menu-item>
|
|
|
+ <el-menu-item v-if="modules && modules.thirdModulesName" index="3"><router-link to="/goods/list/commonly">{{ modules.thirdModulesName }}</router-link></el-menu-item>
|
|
|
</el-menu>
|
|
|
|
|
|
<div class="filter-container" style="margin-top:20px;">
|
|
|
- <el-input v-model="listQuery.form.id" placeholder="商品ID" style="width: 120px;" class="filter-item" @keyup.enter.native="handleFilter" />
|
|
|
- <el-input v-model="listQuery.form.productName" placeholder="商品名称" style="width: 120px;" class="filter-item" @keyup.enter.native="handleFilter" />
|
|
|
- <el-input v-model="listQuery.form.shopName" placeholder="供应商名称" style="width: 120px;" class="filter-item" @keyup.enter.native="handleFilter" />
|
|
|
- <el-select v-model="listQuery.form.validFlag" placeholder="商品状态" clearable style="width: 110px" class="filter-item" value="" @change="handleFilter">
|
|
|
+ <el-input v-model="listQuery.id" placeholder="商品ID" style="width: 120px;" class="filter-item" @keyup.enter.native="handleFilter" />
|
|
|
+ <el-input v-model="listQuery.productName" placeholder="商品名称" style="width: 120px;" class="filter-item" @keyup.enter.native="handleFilter" />
|
|
|
+ <el-input v-model="listQuery.shopName" placeholder="供应商名称" style="width: 120px;" class="filter-item" @keyup.enter.native="handleFilter" />
|
|
|
+ <el-select v-model="listQuery.validFlag" placeholder="商品状态" clearable style="width: 110px" class="filter-item" value="" @change="handleFilter">
|
|
|
<el-option label="已上架" value="1" />
|
|
|
<el-option label="已下架" value="2" />
|
|
|
</el-select>
|
|
|
- <el-select v-model="listQuery.form.classifyID" placeholder="商品分类" clearable style="width: 110px" class="filter-item" value="" @change="handleFilter">
|
|
|
- <!-- <el-option v-for="item in productsClassifyList" :key="item.id" :label="item.classifyName" :value="item.id" /> -->
|
|
|
+ <el-select v-model="listQuery.classifyID" placeholder="商品分类" clearable style="width: 110px" class="filter-item" value="" @change="handleFilter">
|
|
|
+ <template v-for="item in classify">
|
|
|
+ <el-option v-if="item.status*1 === 1" :key="item.id" :label="item.classifyName" :value="item.id" />
|
|
|
+ </template>
|
|
|
</el-select>
|
|
|
- <el-select v-model="listQuery.form.preferredProduct" placeholder="星范优选" clearable style="width: 110px" class="filter-item" value="" @change="handleFilter">
|
|
|
- <el-option label="是" value="1" />
|
|
|
- <el-option label="否" value="0" />
|
|
|
+ <el-select v-model="listQuery.preferredProduct" placeholder="星范优选" clearable style="width: 110px" class="filter-item" value="" @change="handleFilter">
|
|
|
+ <el-option label="星范优选" value="1" />
|
|
|
+ <el-option label="非星范优选" value="0" />
|
|
|
</el-select>
|
|
|
- <el-select v-model="listQuery.form.commonlyProduct" placeholder="常用商品" clearable style="width: 110px" class="filter-item" value="" @change="handleFilter">
|
|
|
- <el-option label="是" value="1" />
|
|
|
- <el-option label="否" value="0" />
|
|
|
+ <el-select v-model="listQuery.commonlyProduct" placeholder="常用商品" clearable style="width: 110px" class="filter-item" value="" @change="handleFilter">
|
|
|
+ <el-option label="常用商品" value="1" />
|
|
|
+ <el-option label="非常用商品" value="0" />
|
|
|
</el-select>
|
|
|
- <el-select v-model="listQuery.form.preferentialProduct" placeholder="星范精品" clearable style="width: 110px" class="filter-item" value="" @change="handleFilter">
|
|
|
- <el-option label="是" value="1" />
|
|
|
- <el-option label="否" value="0" />
|
|
|
+ <el-select v-model="listQuery.preferentialProduct" placeholder="星范精品" clearable style="width: 110px" class="filter-item" value="" @change="handleFilter">
|
|
|
+ <el-option label="星范精品" value="1" />
|
|
|
+ <el-option label="非星范精品" value="0" />
|
|
|
</el-select>
|
|
|
<el-button class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">
|
|
|
搜索
|
|
|
</el-button>
|
|
|
- <el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-edit">
|
|
|
- <router-link to="/goods/list/select">添加商品</router-link>
|
|
|
- </el-button>
|
|
|
</div>
|
|
|
|
|
|
<el-table
|
|
@@ -49,36 +48,39 @@
|
|
|
style="width:100%;margin-top:20px;"
|
|
|
:header-cell-style="{background:'#eef1f6',color:'#606266'}"
|
|
|
>
|
|
|
- <el-table-column align="center" label="序号">
|
|
|
+ <el-table-column align="center" label="序号" width="50px">
|
|
|
<template slot-scope="scope">
|
|
|
{{ scope.$index }}
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column label="商品ID" align="center" prop="id" />
|
|
|
+ <el-table-column label="商品ID" align="center" prop="id" width="70px" />
|
|
|
<el-table-column label="商品图片" align="center" prop="mainImage">
|
|
|
<template slot-scope="{row}">
|
|
|
<img :src="row.mainImage" alt="" width="50">
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column label="商品名称" align="center" prop="productName" />
|
|
|
- <el-table-column label="供应商名称" align="center" prop="shopName" />
|
|
|
+ <el-table-column label="商品名称" align="center" prop="productName" min-width="200px" />
|
|
|
+ <el-table-column label="供应商" align="center" prop="shopName" min-width="120px" />
|
|
|
<el-table-column label="市场价" align="center" prop="normalPrice" />
|
|
|
<el-table-column label="成本价" align="center" prop="costPrice" />
|
|
|
<el-table-column label="售价" align="center" prop="retailPrice" />
|
|
|
<el-table-column label="起订量" align="center" prop="minBuyNumber" />
|
|
|
<el-table-column label="星范优选" align="center" prop="preferredProduct">
|
|
|
<template slot-scope="{row}">
|
|
|
- <el-tag :type="row.preferredProduct | statusFilter">{{ row.preferredProduct*1 === 1 ? '启用' : '停用' }}</el-tag>
|
|
|
+ <!--<el-tag :type="row.preferredProduct | statusFilter">{{ row.preferredProduct*1 === 1 ? '启用' : '停用' }}</el-tag>-->
|
|
|
+ <i v-if="row.preferredProduct*1 === 1" class="el-icon-success" type="success" />
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="星范精品" align="center" prop="preferentialProduct">
|
|
|
<template slot-scope="{row}">
|
|
|
- <el-tag :type="row.preferentialProduct | statusFilter">{{ row.preferentialProduct*1 === 1 ? '启用' : '停用' }}</el-tag>
|
|
|
+ <!--<el-tag :type="row.preferentialProduct | statusFilter">{{ row.preferentialProduct*1 === 1 ? '启用' : '停用' }}</el-tag>-->
|
|
|
+ <i v-if="row.preferentialProduct*1 === 1" class="el-icon-success" type="success" />
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="常用商品" align="center" prop="commonlyProduct">
|
|
|
<template slot-scope="{row}">
|
|
|
- <el-tag :type="row.commonlyProduct | statusFilter">{{ row.commonlyProduct*1 === 1 ? '启用' : '停用' }}</el-tag>
|
|
|
+ <!--<el-tag :type="row.commonlyProduct | statusFilter">{{ row.commonlyProduct*1 === 1 ? '启用' : '停用' }}</el-tag>-->
|
|
|
+ <i v-if="row.commonlyProduct*1 === 1" class="el-icon-success" type="success" />
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column class-name="status-col" label="商品状态" align="center" prop="validFlag">
|
|
@@ -88,26 +90,28 @@
|
|
|
</el-table-column>
|
|
|
<el-table-column label="商品分类" align="center" prop="productClassifyName" />
|
|
|
<el-table-column align="center" label="添加时间" prop="addTime">
|
|
|
- <template slot-scope="{row}">
|
|
|
+ <template v-if="row.addTime" slot-scope="{row}">
|
|
|
<i class="el-icon-time" />
|
|
|
<span>{{ row.addTime | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
|
|
<template slot-scope="{row}">
|
|
|
- <el-button type="primary" size="small" @click="handleEdit(row.id)">编辑</el-button>
|
|
|
- <el-button type="success" size="small" style="margin:5px 0 0 0;">上架</el-button>
|
|
|
+ <el-button type="primary" size="small" @click="handleEdit(row)">编辑</el-button>
|
|
|
+ <el-button :type="row.validFlag*1 === 1 ? 'danger' : 'success'" size="small" style="margin:5px 0 0 0;" @click="handleSwitch(row.id)">{{ row.validFlag*1 === 1 ? '下架' : '上架' }}</el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
|
|
|
- <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="fetchData" />
|
|
|
+ <pagination v-show="total>0" :total="total" :page.sync="listQuery.index" :limit.sync="listQuery.pageSize" @pagination="fetchData" />
|
|
|
|
|
|
<el-dialog :title="dialogTitle" :visible.sync="dialogFormVisible">
|
|
|
- <el-form ref="dataForm" :rules="rules" :model="dialog" label-position="left" label-width="260px" style="width:400px; margin:0 auto;">
|
|
|
+ <el-form ref="dataForm" :rules="rules" :model="dialog" label-position="left" label-width="220px" style="width:360px; margin:0 auto;">
|
|
|
<el-form-item label="商品分类" prop="classifyID">
|
|
|
- <el-select v-model="dialog.classifyID" placeholder="商品分类" clearable style="width: 110px" class="filter-item" value="" @change="handleFilter">
|
|
|
- <!-- <el-option v-for="item in productsClassifyList" :key="item.id" :label="item.classifyName" :value="item.id" /> -->
|
|
|
+ <el-select v-model="dialog.classifyID" placeholder="商品分类" :label="dialog.productClassifyName" clearable class="filter-item" :value="dialog.classifyID*1">
|
|
|
+ <template v-for="item in classify">
|
|
|
+ <el-option v-if="item.status*1 === 1" :key="item.id" :label="item.classifyName" :value="item.id" />
|
|
|
+ </template>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
<el-form-item :label="'市场价(' + dialog.normalPrice + '),修改为:'" prop="normalPrice">
|
|
@@ -137,7 +141,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { getList } from '@/api/goods'
|
|
|
+import { getList, getModule, switchGoods, saveGoods } from '@/api/goods'
|
|
|
import Pagination from '@/components/Pagination'
|
|
|
export default {
|
|
|
components: { Pagination },
|
|
@@ -145,47 +149,44 @@ export default {
|
|
|
statusFilter(status) {
|
|
|
const statusMap = {
|
|
|
1: 'success',
|
|
|
- 0: 'gray'
|
|
|
+ 0: 'danger'
|
|
|
}
|
|
|
return statusMap[status]
|
|
|
}
|
|
|
},
|
|
|
- data() {
|
|
|
+ data: function() {
|
|
|
return {
|
|
|
+ activeIndex: '0',
|
|
|
list: null,
|
|
|
+ modules: null,
|
|
|
+ classify: null,
|
|
|
listLoading: true,
|
|
|
total: 0,
|
|
|
- activeIndex: '1',
|
|
|
listQuery: {
|
|
|
- page: 1,
|
|
|
- limit: 10,
|
|
|
- form: {
|
|
|
- id: '',
|
|
|
- mainImage: '',
|
|
|
- productName: '',
|
|
|
- shopName: '',
|
|
|
- normalPrice: '', // 市场价',
|
|
|
- costPrice: '', // 成本价',
|
|
|
- retailPrice: '', // '售价',
|
|
|
- minBuyNumber: '', // '最小起订量',
|
|
|
- preferredProduct: '', // 是否是优选商品:0不是优选,1优选商品',
|
|
|
- commonlyProduct: '', // 是否是常用商品:0不是常用,1常用商品',
|
|
|
- preferentialProduct: '', // 是否是星范精品:0不是精品,1星范精品商品',
|
|
|
- validFlag: '', // '商品状态,1已上架,2已下架',
|
|
|
- productClassifyName: '', // '对应cm_mall_products_classify商品分类表id',
|
|
|
- addTime: '', // '添加时间',
|
|
|
- organizeID: this.organizeID // '组织ID,具体对应cm_mall_organize表ID',
|
|
|
- }
|
|
|
+ index: 1,
|
|
|
+ pageSize: 20,
|
|
|
+ organizeID: this.organizeID,
|
|
|
+ id: '',
|
|
|
+ productName: '',
|
|
|
+ shopName: '',
|
|
|
+ classifyID: '', // 商品分类
|
|
|
+ validFlag: '', // '商品状态,1已上架,2已下架',
|
|
|
+ preferredProduct: '', // 是否是优选商品:0不是优选,1优选商品',
|
|
|
+ commonlyProduct: '', // 是否是常用商品:0不是常用,1常用商品',
|
|
|
+ preferentialProduct: '', // 是否是星范精品:0不是精品,1星范精品商品',
|
|
|
+ productClassifyName: '' // '对应cm_mall_products_classify商品分类表id',
|
|
|
},
|
|
|
dialogFormVisible: false,
|
|
|
dialogStatus: '',
|
|
|
dialogTitle: '编辑',
|
|
|
dialog: {
|
|
|
- classifyID: '',
|
|
|
+ id: '',
|
|
|
+ classifyID: 0,
|
|
|
normalPrice: '',
|
|
|
costPrice: '',
|
|
|
retailPrice: '',
|
|
|
- minBuyNumber: ''
|
|
|
+ minBuyNumber: '',
|
|
|
+ productClassifyName: ''
|
|
|
},
|
|
|
rules: {
|
|
|
classifyID: [{ required: true, message: '请选择分类', trigger: 'change' }],
|
|
@@ -197,64 +198,38 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
+ this.getModuleType()
|
|
|
this.fetchData()
|
|
|
},
|
|
|
methods: {
|
|
|
+ getModuleType() {
|
|
|
+ getModule({ organizeID: this.organizeID }).then(response => {
|
|
|
+ this.modules = response.data
|
|
|
+ })
|
|
|
+ },
|
|
|
fetchData() {
|
|
|
this.listLoading = true
|
|
|
- getList().then(response => {
|
|
|
- this.list = response.data.items
|
|
|
+ getList(this.listQuery).then(response => {
|
|
|
+ const { organizeProductsPage, listByEffective } = response.data
|
|
|
+ this.list = organizeProductsPage.results
|
|
|
+ this.total = organizeProductsPage.totalRecord
|
|
|
+ this.classify = listByEffective
|
|
|
this.listLoading = false
|
|
|
- }).catch(() => {
|
|
|
- // 封装静态数据
|
|
|
- this.list = [
|
|
|
- {
|
|
|
- id: 0,
|
|
|
- mainImage: 'https://img.caimei365.com/group1/M00/00/C3/Cmis21ogFTuATpnrAAIh4ixubXM38.JPEG',
|
|
|
- productName: '韩国恩盛进口 素提亚 BeautyHeart 电穿孔技术 打造V脸 紧致提升',
|
|
|
- shopName: '北京恩盛众成国际贸易有限公司',
|
|
|
- normalPrice: '10000.00',
|
|
|
- costPrice: '6666.00',
|
|
|
- retailPrice: '6600.00',
|
|
|
- minBuyNumber: '1',
|
|
|
- preferredProduct: '1',
|
|
|
- commonlyProduct: '1',
|
|
|
- preferentialProduct: '1',
|
|
|
- validFlag: '1',
|
|
|
- productClassifyName: 0,
|
|
|
- addTime: new Date(),
|
|
|
- organizeID: this.organizeID
|
|
|
- },
|
|
|
- {
|
|
|
- id: 0,
|
|
|
- mainImage: '',
|
|
|
- productName: 'hahaah',
|
|
|
- shopName: '',
|
|
|
- normalPrice: '',
|
|
|
- costPrice: '',
|
|
|
- retailPrice: '',
|
|
|
- minBuyNumber: '',
|
|
|
- preferredProduct: '',
|
|
|
- commonlyProduct: '',
|
|
|
- preferentialProduct: '',
|
|
|
- validFlag: '',
|
|
|
- productClassifyName: 0,
|
|
|
- addTime: '',
|
|
|
- organizeID: this.organizeID
|
|
|
- }
|
|
|
- ]
|
|
|
})
|
|
|
- this.listLoading = false
|
|
|
- this.total = 2
|
|
|
},
|
|
|
handleFilter() {
|
|
|
- alert('搜索')
|
|
|
+ this.fetchData()
|
|
|
},
|
|
|
- handleCreate() {
|
|
|
- alert('添加')
|
|
|
+ handleSwitch(id) {
|
|
|
+ switchGoods({ id: id }).then(() => {
|
|
|
+ this.fetchData()
|
|
|
+ }).catch(() => {
|
|
|
+ this.fetchData()
|
|
|
+ })
|
|
|
},
|
|
|
handleEdit(row) {
|
|
|
this.dialog = Object.assign({}, row)
|
|
|
+ this.dialog.classifyID = this.dialog.classifyID * 1
|
|
|
this.dialogFormVisible = true
|
|
|
this.$nextTick(() => {
|
|
|
this.$refs['dataForm'].clearValidate()
|
|
@@ -263,7 +238,16 @@ export default {
|
|
|
updateGoods() {
|
|
|
this.$refs['dataForm'].validate((valid) => {
|
|
|
if (valid) {
|
|
|
- alert('更新')
|
|
|
+ saveGoods(this.dialog).then(response => {
|
|
|
+ this.$notify({
|
|
|
+ title: response.code * 1 === 1 ? 'Success' : 'Error',
|
|
|
+ message: response.code * 1 === 1 ? '编辑成功' : response.msg,
|
|
|
+ type: response.code * 1 === 1 ? 'success' : 'error',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ this.fetchData()
|
|
|
+ this.dialogFormVisible = false
|
|
|
+ })
|
|
|
}
|
|
|
})
|
|
|
}
|
|
@@ -272,6 +256,8 @@ export default {
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
|
|
-
|
|
|
+ i[type=success]{
|
|
|
+ color:#67C23A;
|
|
|
+ }
|
|
|
</style>
|
|
|
|