<template>
  <div>
    <Row class="search-row">
      <i-col span="24"
             class="search-col">
        <Row class="row-style">
          <Button @click="handleEdit"
                  type="primary">配置欢迎语</Button>
        </Row>
      </i-col>
    </Row>
    <Table :columns="columns1"
           style="margin-top: 20px;"
           size="small">
      <template slot-scope="{s}"
                slot="action">
        <Button type="primary"
                size="small"
                @click="handleEdit(s)">修改</Button>
        <Button type="error"
                size="small"
                @click="handleDelete(s)">删除</Button>
      </template>
    </Table>
    <Page :total="total"
          :current="pageNum"
          :page-size="pageSize"
          show-elevator
          show-total
          placement="top"
          @on-change="handlePage"
          class="ks-page"></Page>
  </div>
</template>

<script>
import data from "../../utils/PhoneRegionData";
import http from "../../services/store/IncreaseStoreManager";

import staff from "../../services/staff/staff";

export default {
  name: "IncreaseWelcomeList",
  inject: ["setMenuName"],
  data () {
    return {
      loading: true,
      // 分页
      total: 0,
      pageSize: 10,
      pageNum: 1,
      columns1: [
        { title: "序号", key: "id" },
        { title: "欢迎语", key: "content" },
        { title: "配置范围", key: "range" },
        { title: "配置时间", key: "createdate" },
        { title: "修改时间", key: "updatedate" },
        { title: "操作", slot: "action" },
      ],
      formValidate: {
      },
    };
  },
  mounted () {
    this.setMenuName("门店推广", "欢迎语");
    this.handlePaginate();
  },
  methods: {
    // 分页刷新
    handlePaginate () {
      this.loading = true;
      if (this.formValidate.startDate) {
        this.formValidate.startDate = formatDate(this.formValidate.startDate);
      } else {
        this.formValidate.startDate = undefined;
      }
      if (this.formValidate.endDate) {
        this.formValidate.endDate = formatDate(this.formValidate.endDate);
      } else {
        this.formValidate.endDate = undefined;
      }
      params.pageNum = this.pageNum;
      params.pageSize = this.pageSize;
      params = { ...params, ...this.formValidate };
      params.userId = JSON.parse(sessionStorage.getItem("loginInfo")).userId;
      if (params.status == 0) {
        params.status = undefined;
      }
      params.date = undefined;
      http.get("/activity/instance/list", params).then(res => {
        const data = res.data.results.this || {};
        this.data = data.list || [];
        this.totalSize = data.total || 0;
        this.loading = false;
      });
    },
    //切页处理
    handlePage: function (value) {
      this.pageNum = value;
    },
    // 新增或修改
    handleEdit (row) {
      this.$router.push({ path: "/shop/increase/welcome/edit", params: { id: row.id } })
    },
    // 删除
    handleDelete (row) {

    },
  },
};
</script>

<style scoped>
</style>
