rk
昨天 609a1931953b2298016bd2b0d6b410666b5ad7b9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<template>
  <TableLayout :permissions="['business:bikes:query']">
    <!-- 搜索表单 -->
    <el-form ref="searchForm" slot="search-form" :model="searchForm" label-width="100px" inline>
      <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="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>
        <el-button @click="reset">重置</el-button>
      </section>
    </el-form>
    <!-- 表格和分页 -->
    <template v-slot:table-wrap>
      <ul class="toolbar">
        <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="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
          label="操作"
          min-width="120"
          fixed="right"
        >
          <template slot-scope="{row}">
            <el-button type="text" @click="$refs.productConfigurationWindow.open('配置', row)">配置</el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        @size-change="handleSizeChange"
        @current-change="handlePageChange"
        :pagination="tableData.pagination"
      >
      </pagination>
    </template>
    <!-- 配置弹窗 -->
    <ProductConfigurationWindow ref="productConfigurationWindow" @success="handlePageChange"/>
  </TableLayout>
</template>
 
<script>
import BaseTable from '@/components/base/BaseTable'
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,
  components: { TableLayout, Pagination, ProductConfigurationWindow },
  data () {
    return {
      // 搜索
      searchForm: {
        productName: '',
        discountName: ''
      },
      isWorking: {
        ...this.isWorking,
        sync: false
      }
    }
  },
  created () {
    this.config({
      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>