k94314517
2023-09-15 64f45c75ea93911b9841bf00bb4c436cd294be3a
company_admin/src/views/business/goods.vue
@@ -44,7 +44,6 @@
        </el-form-item>
        <section>
          <el-button type="primary" @click="search">搜索</el-button>
          <el-button @click="reset">重置</el-button>
        </section>
      </el-form>
@@ -52,8 +51,12 @@
      <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('新建商品')" icon="el-icon-plus" v-permissions="['business:goods:create']">新建</el-button></li>
          <el-button type="primary" :loading="isWorking.export" @click="$refs.selectProduct.open('选择平台商品')">选择平台商品</el-button>
          <el-button type="primary" :loading="isWorking.export" v-permissions="['business:goods:exportExcel']" @click="importFile">导入</el-button>
          <el-button type="primary" :loading="isWorking.export" @click="downloadFile">下载模板</el-button>
          <el-button type="primary" :loading="isWorking.export" @click="bulkOperation(0)">批量上架</el-button>
          <el-button type="primary" :loading="isWorking.export" @click="bulkOperation(1)">批量下架</el-button>
          <!-- <li><el-button @click="deleteByIdInBatch" icon="el-icon-delete" v-permissions="['business:goods:delete']">删除</el-button></li> -->
        </ul>
        <el-table
@@ -63,7 +66,9 @@
          border
          :header-cell-style="rowStyle"
          :cell-style="rowStyle"
          @selection-change="handleSelectionChange"
        >
          <el-table-column type="selection" width="55"></el-table-column>
          <el-table-column prop="id" label="商品ID" min-width="100px"></el-table-column>
          <el-table-column prop="name" label="商品名称/型号" min-width="200px">
            <template slot-scope="{row}">
@@ -82,9 +87,8 @@
          </el-table-column>
          <el-table-column prop="brandName" label="品牌" min-width="100px"></el-table-column>
          <el-table-column prop="categoryName" label="类别" min-width="100px"></el-table-column>
          <el-table-column prop="attrFirstNames" label="属性1" min-width="100px"></el-table-column>
          <el-table-column prop="attrSecodNames" label="属性2" min-width="100px"></el-table-column>
          <el-table-column prop="zdPrice" label="指导价(元)" min-width="100px"></el-table-column>
          <el-table-column prop="baseZdPrice" label="指导价(元)" min-width="100px"></el-table-column>
          <el-table-column prop="basePrice" label="采购价(元)" min-width="100px"></el-table-column>
          <el-table-column prop="price" label="入手价(元)" min-width="100px"></el-table-column>
          <el-table-column prop="createDate" label="创建时间" min-width="100px"></el-table-column>
          <el-table-column prop="status" label="状态" min-width="100px">
@@ -121,6 +125,8 @@
      </template>
      <!-- 新建/修改 -->
      <OperaGoodsWindow ref="operaGoodsWindow" @success="handlePageChange"/>
      <!-- 选择平台商品 -->
      <selectProduct ref="selectProduct" @success="handlePageChange" @result="search"/>
    </TableLayout>
  </template>
  
@@ -129,12 +135,13 @@
  import TableLayout from '@/layouts/TableLayout'
  import Pagination from '@/components/common/Pagination'
  import OperaGoodsWindow from '@/components/business/OperaGoodsWindow'
  import selectProduct from '@/components/business/selectProduct'
  import { brand, category, importExcel } from '@/api/system/common.js'
  import { updateDisableById, queryById, exportDoc } from '@/api/business/goods.js'
  import { updateDisableById, queryById, exportDoc, batchUpdateDisableById } from '@/api/business/goods.js'
  export default {
    name: 'Goods',
    extends: BaseTable,
    components: { TableLayout, Pagination, OperaGoodsWindow },
    components: { TableLayout, Pagination, OperaGoodsWindow, selectProduct },
    data () {
      return {
        // 搜索
@@ -145,6 +152,7 @@
          categoryId: '',
          brandId: ''
        },
        ids: '',
        categoryList: [],
        brandList: [],
        statusList: [
@@ -165,8 +173,26 @@
      this.getcategory()
    },
    methods: {
      handleSelectionChange(e) {
        let arr = e.map(item => item.id)
        this.ids = arr.join(',')
        console.log(this.ids)
      },
      // 批量上下架
      bulkOperation(type) {
        if (!this.ids) {
          this.$message.warning({ message: '至少选择一项内容' })
          return
        }
        batchUpdateDisableById({
          ids: this.ids,
          status: type
        }).then(res => {
          this.$message.success({ message: res })
          this.search()
        })
      },
      downloadFile() {
        // window.open(`${process.env.VUE_APP_API_PREFIX}/business/goods/export`)
        exportDoc({})
          .then(response => {
            this.download(response)