123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204 |
- <template>
- <div class="app-container" style="padding: 0 20px;padding-bottom: 0;">
- <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:225px;float: left;margin-bottom: 8px;">
- <el-input v-model="listQuery.id" placeholder="请输入商品ID" maxlength="30" style="width: 150px;" 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;">
- <el-button class="filter-item" type="primary" icon="el-icon-circle-plus-outline">
- <router-link :to="'/goods/list/select/'+ modulesId">添加商品</router-link>
- </el-button>
- </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="50px">
- <template slot-scope="scope">
- {{ 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" 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="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}') }}</span>
- </template>
- </el-table-column>
- <el-table-column label="排序值" align="center" prop="commonlyProductSort">
- <template slot-scope="{row}">
- <el-input v-model="row.commonlyProductSort" size="small" type="number" min="1" />
- </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: 80px;margin:5px 0 0 0;" @click="cancelGoods(row.id)">取消</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', // 模块3
- 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
- }
- },
- 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.classify = listByEffective
- this.listLoading = false
- })
- },
- handleFilter() {
- this.fetchData()
- },
- batchSaveSort() {
- const sorts = []
- this.list.map(item => {
- if (item.commonlyProductSort) {
- sorts.push(item.id + '-' + item.commonlyProductSort)
- }
- })
- saveGoodsSort({ newProducSorttList: sorts.join(','), modules: this.modulesId }).then(response => {
- this.$notify({
- title: response.code * 1 === 1 ? 'Success' : 'Error',
- message: response.msg,
- type: response.code * 1 === 1 ? 'success' : 'error',
- duration: 2000
- })
- this.fetchData()
- }).catch(() => {
- this.fetchData()
- })
- },
- cancelGoods(id) {
- canncelProduct({ id: id, modules: this.modulesId }).then(() => {
- this.fetchData()
- }).catch(() => {
- this.fetchData()
- })
- }
- }
- }
- </script>
- <style scoped>
- .filter-container{
- width: 100%;
- float: left;
- margin-top:20px;
- padding-bottom: 0;
- }
- .filter-title{
- float: left;
- font-size: 12px;
- line-height: 18px;
- text-align: left;
- color: #2E3748;
- }
- .filter-title p{
- margin:5px 0;
- }
- .goods-list .el-form-item{
- margin-bottom: 8px;
- }
- </style>
|