123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272 |
- <template>
- <div class="app-container" style="padding: 0 20px;padding-bottom: 20px;">
- <el-menu :router="true" default-active="/goods/list/commonly" class="el-menu-demo" mode="horizontal">
- <el-menu-item index="/goods/list">全部商品</el-menu-item>
- <el-menu-item v-if="modules && modules.firstModulesName" index="/goods/list/preferred">{{ modules.firstModulesName }}</el-menu-item>
- <el-menu-item v-if="modules && modules.secondModulesName" index="/goods/list/preferential">{{ modules.secondModulesName }}</el-menu-item>
- <el-menu-item v-if="modules && modules.thirdModulesName" index="/goods/list/commonly">{{ modules.thirdModulesName }}</el-menu-item>
- </el-menu>
- <div class="filter-container">
- <el-form class="demo-form-inline goods-list">
- <el-form-item label="商品ID:" style="width:190px;float: left;">
- <el-input v-model="listQuery.id" placeholder="请输入商品ID" oninput="if(value.length>9)value=value.slice(0,9)" type="number" style="width: 120px;" class="filter-item" @keyup.enter.native="handleFilter" />
- </el-form-item>
- <el-form-item label="商品名称:" style="width:240px;float: left;">
- <el-input v-model="listQuery.productName" placeholder="请输入商品名称" style="width: 150px;" class="filter-item" @keyup.enter.native="handleFilter" />
- </el-form-item>
- <el-form-item label="供应商名称:" style="width:250px;float: left;">
- <el-input v-model="listQuery.shopName" placeholder="请输入供应商名称" style="width: 150px;" class="filter-item" @keyup.enter.native="handleFilter" />
- </el-form-item>
- <el-form-item label="商品分类:" style="width:200px;float: left;">
- <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-form-item>
- <el-form-item style="width:95px;float: left;">
- <el-button class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">搜索</el-button>
- </el-form-item>
- <el-form-item style="width:150px;float: left;">
- <el-button class="filter-item" type="primary" icon="el-icon-sort" @click="batchSaveSort">批量更新排序</el-button>
- </el-form-item>
- <el-form-item style="width:120px;float: left;">
- <router-link :to="'/goods/list/select/'+ modulesId">
- <el-button class="filter-item" type="primary" icon="el-icon-circle-plus-outline">添加商品</el-button>
- </router-link>
- </el-form-item>
- </el-form>
- </div>
- <div class="filter-title">
- <p>排序值是指本页面和商城小程序对应商品列表的排列顺序,数值越小排序越靠前,排序值允许重复。</p>
- </div>
- <el-table
- v-loading="listLoading"
- :data="list"
- element-loading-text="Loading"
- border
- fit
- highlight-current-row
- :header-cell-style="{background:'#eef1f6',color:'#606266'}"
- style="width:100%;margin-top:20px;"
- >
- <el-table-column align="center" label="序号" width="40px">
- <template slot-scope="scope">
- {{ ((pageNum-1)*listQuery.pageSize)+scope.$index+1 }}
- </template>
- </el-table-column>
- <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" min-width="200px" />
- <el-table-column label="供应商" align="center" prop="shopName" min-width="120px" />
- <el-table-column label="市场价" align="center">
- <template slot-scope="{row}">
- ¥{{ row.normalPrice | toThousandFloatFilter }}
- </template>
- </el-table-column>
- <el-table-column label="成本价" align="center">
- <template slot-scope="{row}">
- ¥{{ row.costPrice | toThousandFloatFilter }}
- </template>
- </el-table-column>
- <el-table-column label="售价" align="center">
- <template slot-scope="{row}">
- <template v-if="row.ladderPriceFlag*1===1">
- <div v-for="(item, index) in row.ladderShownList" :key="row.id+'list_ladder_pri'+index">
- ¥{{ item.price | toThousandFloatFilter }}</div>
- </template>
- <template v-else>¥{{ row.retailPrice | toThousandFloatFilter }}</template>
- </template>
- </el-table-column>
- <el-table-column label="起订量" align="center" width="70">
- <template slot-scope="{row}">
- <template v-if="row.ladderPriceFlag*1===1">
- <div v-for="(item, index) in row.ladderShownList" :key="row.id+'list_ladder_pri'+index">{{ item.number }}</div>
- </template>
- <template v-else>{{ row.minBuyNumber }}</template>
- </template>
- </el-table-column>
- <el-table-column label="商品分类" align="center" prop="productClassifyName" />
- <el-table-column align="center" label="添加时间" prop="addTime">
- <template v-if="row.addTime" slot-scope="{row}">
- <span>{{ row.addTime | parseTime('{y}-{m}-{d} {h}:{i}:{s}') }}</span>
- </template>
- </el-table-column>
- <el-table-column label="排序值" align="center" prop="commonlyProductSort">
- <template slot-scope="{row}">
- <el-input-number v-model="row.commonlyProductSort" controls-position="right" :min="1" :max="999" :maxlength="3" size="mini" style="width:65px;" />
- </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="mini" style="width: 70px;margin:5px 0 0 0;" @click="cancelGoods(row)">取消</el-button>
- </template>
- </el-table-column>
- </el-table>
- <pagination v-show="total>20" :total="total" :page.sync="listQuery.index" :limit.sync="listQuery.pageSize" @pagination="fetchData" />
- <template>
- <el-backtop style="right: 40px; bottom: 40px;">
- <i class="el-icon-upload2" />
- </el-backtop>
- </template>
- </div>
- </template>
- <script>
- import { getList, getModule, saveGoodsSort, canncelProduct } from '@/api/goods'
- import Pagination from '@/components/Pagination'
- export default {
- components: { Pagination },
- data() {
- return {
- modulesId: '3', // 模块
- pageNum: 0,
- list: null,
- classify: null,
- modules: null,
- listLoading: true,
- total: 0,
- listQuery: {
- index: 1,
- pageSize: 20,
- organizeID: this.$store.getters.organizeID,
- commonlyProduct: '1', // 常用商品
- id: '',
- productName: '',
- shopName: '',
- classifyID: ''
- }
- }
- },
- computed: {
- organizeID() {
- return this.$store.getters.organizeID
- },
- onKeypress() {
- return (/[\d]/.test(String.fromCharCode(event.keyCode)))
- }
- },
- created() {
- this.getModuleType()
- this.fetchData()
- },
- methods: {
- getModuleType() {
- getModule({ organizeID: this.$store.getters.organizeID }).then(response => {
- this.modules = response.data[0]
- })
- },
- fetchData() {
- this.listLoading = true
- getList(this.listQuery).then(response => {
- const { organizeProductsPage, listByEffective } = response.data
- this.list = organizeProductsPage.results
- this.total = organizeProductsPage.totalRecord
- this.pageNum = organizeProductsPage.index
- this.classify = listByEffective
- this.listLoading = false
- this.list.map(row => {
- row.ladderShownList = []
- if (row.ladderPriceFlag * 1 === 1 && row.ladderPriceList != null) {
- for (let i = 0; i < row.ladderPriceList.length; i++) {
- if (row.ladderPriceList[i] && row.ladderPriceList[i].delFlag * 1 === 0) {
- let str = ''
- if (row.ladderPriceList[i + 1] && row.ladderPriceList[i + 1].delFlag * 1 === 0) {
- str = row.ladderPriceList[i].buyNum + '-' + (row.ladderPriceList[i + 1].buyNum - 1)
- } else {
- str = '≥' + row.ladderPriceList[i].buyNum
- }
- row.ladderShownList.push({
- price: row.ladderPriceList[i].buyPrice,
- number: str
- })
- }
- }
- }
- })
- })
- },
- handleFilter() {
- this.fetchData()
- },
- batchSaveSort() {
- const sorts = []
- this.list.map(item => {
- if (item.commonlyProductSort) {
- sorts.push(item.id + '-' + Math.abs(item.commonlyProductSort))
- }
- })
- saveGoodsSort({ newProducSorttList: sorts.join(','), modules: this.modulesId }).then(response => {
- this.$message({ message: response.msg, type: 'success', center: true })
- this.clearListQuery()
- this.fetchData()
- }).catch(() => {
- this.clearListQuery()
- this.fetchData()
- })
- },
- cancelGoods(row) {
- this.$confirm('确定取消该商品吗?取消后该商品将不在出现在本页面', '系统提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- canncelProduct({ id: row.id, modules: this.modulesId }).then(() => {
- this.clearListQuery()
- this.fetchData()
- }).catch(() => {
- this.clearListQuery()
- this.fetchData()
- })
- })
- },
- clearListQuery() {
- this.listQuery.id = ''
- this.listQuery.productName = ''
- this.listQuery.shopName = ''
- this.listQuery.classifyID = ''
- }
- }
- }
- </script>
- <style>
- .el-input-number.is-controls-right .el-input__inner {
- padding-left: 5px;
- padding-right: 30px;
- }
- </style>
- <style scoped>
- .filter-container .filter-item,.el-form-item{
- margin-bottom: 0;
- }
- .filter-container{
- width: 100%;
- float: left;
- height: auto;
- margin-top:20px;
- padding-bottom: 0;
- }
- .filter-title{
- float: left;
- font-size: 14px;
- line-height: 18px;
- text-align: left;
- color: #2E3748;
- }
- .filter-title p{
- margin:10px 0;
- }
- .goods-list .el-form-item{
- margin-bottom: 8px;
- }
- </style>
|