doum
7 天以前 bcad3fe1b888ae11d437f6558b7974cfa30cfb2e
admin/src/views/business/platformGoods.vue
@@ -2,11 +2,11 @@
  <TableLayout :permissions="['business:goods:query']">
    <!-- 搜索表单 -->
    <el-form ref="searchForm" slot="search-form" :model="searchForm" label-width="100px" inline>
      <el-tabs v-model="activeName" @tab-click="handleClick">
<!--      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="全部商品" name="first"></el-tab-pane>
        <el-tab-pane label="已售罄商品" name="second"></el-tab-pane>
        <el-tab-pane label="回收站商品" name="third"></el-tab-pane>
      </el-tabs>
      </el-tabs>-->
      <el-form-item label="商品名称" prop="name">
        <el-input v-model="searchForm.name" placeholder="请输入商品名称" @keypress.enter.native="search"></el-input>
      </el-form-item>
@@ -51,15 +51,14 @@
      <section>
        <el-button type="primary" @click="search">搜索</el-button>
        <el-button @click="reset">重置</el-button>
        <el-button @click="$refs.operaPlatformGoodsSkuWindow.open('平台SKU')">重置</el-button>
      </section>
    </el-form>
    <!-- 表格和分页 -->
    <template v-slot:table-wrap>
      <ul class="toolbar" v-permissions="['business:goods:create', 'business:goods:delete']">
        <li><el-button type="primary" @click="$refs.operaGoodsWindow.open('新建商品', null, 0)" v-permissions="['business:goods:create']">新建</el-button></li>
        <li><el-button type="primary" @click="issued(0)">上架</el-button></li>
        <li><el-button type="primary" @click="soldOut(1)">下架</el-button></li>
        <li><el-button type="primary" icon="el-icon-plus" @click="$refs.operaGoodsWindow.open('新建商品', null, 0)" v-permissions="['business:goods:create']">新建</el-button></li>
        <li><el-button type="primary"  icon="el-icon-edit"  @click="issued(0)">上架</el-button></li>
        <li><el-button type="danger"  icon="el-icon-edit"  @click="issued(1)">下架</el-button></li>
      </ul>
      <el-table
        v-loading="isWorking.search"
@@ -69,10 +68,9 @@
        @selection-change="handleSelectionChange"
      >
        <el-table-column type="selection" width="55"></el-table-column>
        <el-table-column prop="imgurl" label="商品信息" min-width="200px">
        <el-table-column prop="imgurl" label="商品信息" min-width="100px">
          <template slot-scope="{row}">
            <el-image v-if="row.imgurl" :src="row.resourcePath+row.imgurl" :preview-src-list="[row.resourcePath+row.imgurl]"></el-image>
            {{ row.name }}
            <el-image style="width: 80px;height: 80px;" v-if="row.imgurl && row.imgurl!=''" :src="row.resourcePath+row.imgurl" :preview-src-list="[row.resourcePath+row.imgurl]"></el-image>
          </template>
        </el-table-column>
        <el-table-column prop="id" label="商品ID" min-width="150px" ></el-table-column>
@@ -83,13 +81,18 @@
        <el-table-column prop="stockNum" label="剩余库存量" min-width="100px"></el-table-column>
        <el-table-column prop="salesVolume" label="实际销量" min-width="100px"></el-table-column>
        <el-table-column prop="skuPrice" label="零售价(元)" min-width="100px"></el-table-column>
        <el-table-column prop="shopPrice" label="供货价设置" min-width="100px" align="center">
          <template slot-scope="{row}" >
          <div @click="goPriceSet(row)" style="cursor:pointer;"><span  class="red"> {{row.shopPriceNum||0}}</span> / <span class="green"> {{row.shopNum||0}}</span>  </div>
          </template>
        </el-table-column>
        <el-table-column prop="editDate" label="最近更新时间" min-width="100px"></el-table-column>
        <el-table-column prop="status" label="状态" min-width="100px">
        <el-table-column prop="status" label="上下架状态" min-width="100px" fixed="right" align="center">
          <template slot-scope="{row}">
            <el-switch
              v-model="row.status"
              :active-value="1"
              :inactive-value="0"
              :active-value="0"
              :inactive-value="1"
              active-color="#13ce66"
              inactive-color="#ff4949"
              @change="statusChange(row)"
@@ -98,13 +101,14 @@
        </el-table-column>
        <el-table-column
          label="操作"
          min-width="120"
          min-width="250"
          fixed="right"
        >
          <template slot-scope="{row}">
              <el-button type="text" @click="$refs.operaGoodsWindow.open('编辑商品', row, 0)" v-permissions="['business:goods:update']">编辑</el-button>
              <el-button type="text" @click="deleteById(row)" v-permissions="['business:goods:delete']">删除</el-button>
              <el-button type="text" @click="$refs.operaGoodsDetailWindow.open('商品详情', row, 0)">查看详情</el-button>
             <el-button type="text" @click="$refs.operaGoodsWindow.open('编辑商品', row, 0)" v-permissions="['business:goods:update']">编辑</el-button>
            <el-button type="text"  @click="goPriceSet(row)">供货价</el-button>
            <el-button type="text" style="color: red;" @click="deleteById(row)" v-permissions="['business:goods:delete']">删除</el-button>
            <!--              <el-button type="text" @click="$refs.operaGoodsDetailWindow.open('商品详情', row, 0)">查看详情</el-button>-->
          </template>
        </el-table-column>
      </el-table>
@@ -129,8 +133,7 @@
import OperaGoodsWindow from '@/components/business/OperaGoodsWindow'
import OperaGoodsDetailWindow from '@/components/business/OperaGoodsDetailWindow'
import OperaPlatformGoodsSkuWindow from '@/components/business/OperaPlatformGoodsSkuWindow'
import { fetchList as labelList } from '@/api/business/labels'
import { updateById } from '@/api/business/goods'
import { findAll as labelList } from '@/api/business/labels'
export default {
  name: 'Goods',
  extends: BaseTable,
@@ -165,13 +168,14 @@
        labels: ''
      },
      labels: [],
      brands: [],
      serials: [],
      brands: []
    }
  },
  provide() {
  provide () {
    return {
      labels: () => this.labels,
      brands: () => this.brands,
      brands: () => this.brands
    }
  },
  created () {
@@ -182,58 +186,50 @@
      'field.main': 'id'
    })
    this.search()
    labelList({
      capacity: 999,
      model: {
        type: 0 //商品分类
      }
      type: 0 // 商品分类
    }).then(res => {
      this.labels = res
    })
    labelList({
      type: 1 // 商品品牌
    })
      .then(res => {
        this.labels = res.records
      })
    labelList({
      capacity: 999,
      model: {
        type: 1 //商品品牌
      }
    })
      .then(res => {
        this.brands = res.records
        this.brands = res
      })
  },
  methods: {
    handleClick(val) {
    goPriceSet(row){
    },
    handleClick (val) {
    },
    /**
     *
     * @param {上下状态} status 0上架 1下架
     */
    issued(status) {
    issued (status) {
      if (this.tableData.selectedRows.length === 0) {
        this.$tip.warning('请至少选择一条数据')
        return
      }
      let message = `确认${status==0?'上架':'下架'}选中的商品么?`
      const message = `确认${status === 0 ? '上架' : '下架'}选中的商品么?`
      this.$dialog.messageWaring(message)
        .then(() => {
        })
    },
    statusChange(row) {
      updateById(row)
    statusChange (row) {
      this.statusChangeBiz([row])
    },
    statusChangeBiz (rows) {
      this.api.updateStatus(rows)
        .then(() => {
          this.$message.success('操作成功')
          this.search()
        })
        .catch(e => {
          this.$message.error('操作成功')
        })
        .then(() => {
          this.handlePageChange()
          this.search()
        })
    }
  },
  }
}
</script>