rk
2 天以前 609a1931953b2298016bd2b0d6b410666b5ad7b9
admin/src/views/business/goods.vue
@@ -2,11 +2,11 @@
  <TableLayout :permissions="['business:bikes:query']">
    <!-- 搜索表单 -->
    <el-form ref="searchForm" slot="search-form" :model="searchForm" label-width="100px" inline>
      <el-form-item label="商品名称" prop="name">
        <el-input v-model="searchForm.name" placeholder="请输入商品名称" @keypress.enter.native="search"></el-input>
      <el-form-item label="商品名称" prop="productName">
        <el-input v-model="searchForm.productName" placeholder="请输入商品名称" @keypress.enter.native="search"></el-input>
      </el-form-item>
      <el-form-item label="套餐名称" prop="name">
        <el-input v-model="searchForm.name" placeholder="请输入套餐名称" @keypress.enter.native="search"></el-input>
      <el-form-item label="套餐名称" prop="discountName">
        <el-input v-model="searchForm.discountName" placeholder="请输入套餐名称" @keypress.enter.native="search"></el-input>
      </el-form-item>
      <section>
        <el-button type="primary" @click="search">搜索</el-button>
@@ -16,22 +16,30 @@
    <!-- 表格和分页 -->
    <template v-slot:table-wrap>
      <ul class="toolbar">
        <li><el-button type="primary">同步商品</el-button></li>
        <li><el-button type="primary" :loading="isWorking.sync" :disabled="isWorking.sync" @click="handleSync">同步商品</el-button></li>
      </ul>
      <el-table
        v-loading="isWorking.search"
        :data="tableData.list"
        stripe
      >
        <el-table-column prop="id" label="抖音商品ID" min-width="100px"></el-table-column>
        <el-table-column prop="createDate" label="抖音商品名称" min-width="100px"></el-table-column>
        <el-table-column prop="creator" label="抖音商品价格" min-width="100px"></el-table-column>
        <el-table-column prop="editDate" label="套餐名称" min-width="100px"></el-table-column>
        <el-table-column prop="editor" label="已兑换数量" min-width="100px"></el-table-column>
        <el-table-column prop="isdeleted" label="卡券类型" min-width="100px"></el-table-column>
        <el-table-column prop="name" label="销售状态" min-width="100px"></el-table-column>
        <el-table-column prop="productId" label="抖音商品ID" min-width="100px"></el-table-column>
        <el-table-column prop="productName" label="抖音商品名称" min-width="100px"></el-table-column>
        <el-table-column prop="price" label="抖音商品价格" min-width="100px">
          <template slot-scope="{row}">
            {{ ((row.price || 0) / 100).toFixed(2) }}
          </template>
        </el-table-column>
        <el-table-column prop="discountName" label="套餐名称" min-width="100px"></el-table-column>
        <el-table-column prop="exchangedCount" label="已兑换数量" min-width="100px"></el-table-column>
        <el-table-column prop="category" label="卡券类型" min-width="100px"></el-table-column>
        <el-table-column prop="onlineStatus" label="销售状态" min-width="100px">
          <template slot-scope="{row}">
            {{ row.onlineStatus === 1 ? '售卖中' : row.onlineStatus === 2 ? '已下架' : '封禁' }}
          </template>
        </el-table-column>
        <el-table-column prop="syncDate" label="同步时间" min-width="100px"></el-table-column>
        <el-table-column
          v-if="containPermissions(['business:bikes:update', 'business:bikes:delete'])"
          label="操作"
          min-width="120"
          fixed="right"
@@ -58,6 +66,7 @@
import TableLayout from '@/layouts/TableLayout'
import Pagination from '@/components/common/Pagination'
import ProductConfigurationWindow from '@/components/business/productConfiguration.vue'
import { sync } from '@/api/business/douyinProduct'
export default {
  name: 'Goods',
  extends: BaseTable,
@@ -66,18 +75,39 @@
    return {
      // 搜索
      searchForm: {
        name: ''
        productName: '',
        discountName: ''
      },
      isWorking: {
        ...this.isWorking,
        sync: false
      }
    }
  },
  created () {
    this.config({
      module: '自行车信息表',
      api: '/business/bikes',
      module: '抖音商品',
      api: '/business/douyinProduct',
      'field.id': 'id',
      'field.main': 'id'
    })
    this.search()
  },
  methods: {
    handleSync () {
      this.isWorking.sync = true
      sync()
        .then(() => {
          this.$tip.apiSuccess('同步成功')
          this.search()
        })
        .catch(e => {
          this.$tip.apiFailed(e)
        })
        .finally(() => {
          this.isWorking.sync = false
        })
    }
  }
}
</script>