<script>
export default {
  name: "AppKeyGoods",
  label: "市场看板-重点单品",
  data() {
    return {
      tableData: [],
      columns: [
        {label: "重点单品", prop: "goodsName"},
        {label: "销售数量", prop: "saleNum", width: 70},
        {label: "库存数量", prop: "stockNum", width: 70},
        {label: "销售目标", prop: "targetSaleNum", width: 70},
        {label: "销售达成", prop: "saleAchieveRate"},
      ]
    }
  },
  computed: {
    search: v => v.$marketBoard.search,
    tableConfig: v => {
      return {
        headerBGC: 'rgba(13, 48, 99, 0.6)',
        // headerBGC: '#003B51',
        oddRowBGC: window.evenRowBGC(), evenRowBGC: "transparent",
        header: v.columns.map(e => e.label),
        columnWidth: v.columns.map(e => e.width || "0;flex:1;min-width:0;"),
        align: v.columns.map(e => e.align || "left"),
        data: v.tableData.map(e => v.columns.map(column => e[column.prop])),
      }
    },
  },
  methods: {
    getTableData() {
      const {$http, $waitFor} = window
      $waitFor($http).then(() => $http.post("/data-boot/la/screen/marketBoard/marketKeyGoods", {
        ...this.search, limit: 999
      })).then(res => {
        if (res?.data) {
          this.tableData = res.data?.records || []
        }
      })
    }
  },
  watch: {
    search: {
      immediate: true, deep: true, handler() {
        this.getTableData()
      }
    }
  }
}
</script>

<template>
  <section class="AppKeyGoods">
    <scroll-table :table-data="tableData" :columns="columns"/>
    <!--<dv-scroll-board :config="tableConfig"/>-->
  </section>
</template>

<style>
.AppKeyGoods {
  color: #fff;
  box-sizing: border-box;
}
</style>
