<template>
  <el-container v-if="isShow">
    <el-header height="100%" class="mg">
      <el-form
        size="small"
        :model="searchForm"
        ref="searchForm"
        :inline="false"
      >
        <el-row :gutter="20">
          <el-col :xs="24" :sm="8" :lg="8">
            <el-form-item prop="code">
              <el-input
                size="small"
                v-model="searchForm.code"
                placeholder="销售政策编号"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="8" :lg="8">
            <el-form-item prop="remark">
              <el-input
                size="small"
                v-model="searchForm.remark"
                placeholder="销售政策说明"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="8" :lg="8">
            <el-form-item prop="title">
              <el-input
                size="small"
                v-model="searchForm.title"
                placeholder="表头备注"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row class="mg">
          <el-button type="primary" size="small" @click="submitScreenForm"
            >查询</el-button
          >
          <el-button type="primary" size="small" @click="resetScreenForm"
            >重置</el-button
          >
          <el-button type="primary" size="small" @click="">导出</el-button>
        </el-row>
      </el-form>
    </el-header>
    <el-main>
      <el-table :data="dataList" border style="width: 100%">
        <el-table-column prop="name" label="操作" width="120" align="center">
          <template slot-scope>
            <el-button type="text" size="small" @click="">详情</el-button>
          </template>
        </el-table-column>
        <el-table-column prop="status" label="状态" width="120" align="center">
          <template slot-scope="scope">
            <el-tag type="success" size="small" v-if="scope.row.status == 1"
              >已生效</el-tag
            >
            <el-tag type="danger" size="small" v-else>未生效</el-tag>
          </template>
        </el-table-column>
        <el-table-column
          prop="code"
          label="销售政策编号"
          width="150"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="title"
          label="销售政策说明"
          width="400"
          align="center"
        >
        </el-table-column>
        <el-table-column prop="zip" label="表头备注" width="200" align="center">
        </el-table-column>
        <el-table-column
          prop="customerCount"
          label="关联经销商"
          width="150"
          align="center"
        >
        </el-table-column>
        <el-table-column prop="startTime" label="生效日期" align="center">
        </el-table-column>
        <el-table-column prop="endTime" label="结束日期" align="center">
        </el-table-column>
        <el-table-column prop="createBy " label="制表人" align="center">
        </el-table-column>
        <el-table-column prop="createTime" label="制表日期" align="center">
        </el-table-column>
      </el-table>
    </el-main>
    <!-- 分页 -->
    <div class="fr">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="[10, 20, 30, 50]"
        :page-size="10"
        layout="total, sizes, prev, pager, next, jumper"
        :total="listTotal"
      >
      </el-pagination>
    </div>
  </el-container>
  <Distributor v-else />
</template>

<script>
import { getCustomerlist } from "@/api/policy_list";
import Minxin from "@/mixin";
import Distributor from "./components/Distributor";
export default {
  mixins: [Minxin],
  data() {
    return {
      isShow: true,
      input: "",
      dataList: [],
      searchForm: {
        code: "",
        remark: "",
        title: "",
      },
    };
  },
  methods: {
    getList() {
      this.listLoading = true;
      const params = {
        pageNum: this.currentPage,
        pageSize: this.pageSize,
        code: this.searchForm.code,
        remark: this.searchForm.remark,
        title: this.searchForm.title,
      };
      getCustomerlist(params).then((res) => {
        console.log(res);
        this.dataList = res.data.records;
        this.listLoading = false;
      });
    },
  },
  components: {

    Distributor,
  },
};
</script>

<style lang="scss" scoped>
.mg {
  margin: 20px 0;
}

.btn {
  text-align: right;
}
</style>
