<template>
  <div>
    <ai-list class="list">
      <ai-title
        slot="title"
        title="商品列表"
        isShowBottomBorder>
      </ai-title>
      <template slot="content">
        <div class="content">
          <ai-search-bar>
            <template #left>
            </template>
            <template #right>
              <el-button size="small" circle icon="el-icon-refresh-right" @click="getList()"></el-button>
            </template>
          </ai-search-bar>
          <ai-table
            :tableData="tableData"
            :col-configs="colConfigs"
            :total="total"
            style="margin-top: 8px;"
            :current.sync="search.current" :size.sync="search.size"
            @selection-change="handleSelectionChange"
            @getList="getList">
            <el-table-column slot="options" label="操作" width="180px" show-overflow-tooltip align="center" fixed="right">
              <template slot-scope="{ row }">
                <div class="table-options">
                  <el-button type="text" @click="statistic(row.id)">统计数据</el-button>
                </div>
              </template>
            </el-table-column>
          </ai-table>
        </div>
      </template>
    </ai-list>
  </div>
</template>

<script>
import {sendTemuAPIMessage} from '@/api/chromeApi'
import {timestampToTime} from '@/utils/date'

  export default {
    name: 'Detail',

    data () {
      return {
        search: {
          current: 1,
          type: '1',
          size: 10
        },
        colConfigs: [
          { prop: 'content', label: '店铺ID', align: 'left' },
          { prop: 'lastUpdateTime', label: '最后一次更新时间', align: 'left' },
          { prop: 'status', label: '状态', align: 'left', format: v => this.$dict.getLabel('monitor_status', v), },
          { prop: 'expireTime', label: '失效时间', align: 'left' },
          { prop: 'createTime', label: '添加时间', width: '180px', fixed: 'right'}
        ],
        tableData: [],
        total: 0
      }
    },

    created () {
      this.getList()
    },

    methods: {
      getList () {
        this.$http.post('/api/monitorDetail/myPage',null,{
            params: {
                ...this.search
            }
        }).then(res => {
            this.tableData = res.data.records
            this.total = res.data.total
        })
      }
    }
  }
</script>

<style scoped lang="scss">
</style>
