<!--
  @description: 客服管理
  @Modifier：dijia
  @routerPath:/personalCenter/customerManage
  @date：  2021/7/20
-->
<template>
  <div>
    <div class="shopmall-page-title">
      客服管理
    </div>
    <div class="search-content clearfix">
      <section class="fl">
        <el-form ref="formitInfo" :model="initDataParams" :inline="true">
          <el-form-item label="广告位名称">
            <el-input v-model.trim="initDataParams.advertisingName" placeholder="" />
          </el-form-item>
          <el-form-item label="是否使用">
            <el-select v-model="initDataParams.useStatus" placeholder="请选择">
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value"
                :disabled="item.disabled"
              />
            </el-select>
          </el-form-item>
        </el-form>
      </section>
      <div class="fr">
        <el-button type="purple" @click.native="getList">
          搜索
        </el-button>
        <el-button type="gray" @click.native="resetList">
          重置
        </el-button>
      </div>
    </div>
    <div class="shopmall-page-add">
      <el-button type="purple" @click="addInstitutions">
        添加客服
      </el-button>
    </div>
    <!-- 表格区域 -->
    <div class="shopmall-view">
      <el-table
        ref="listTable"
        :data="tableData"
        :row-key="getRowKeys"
        size="small"
        :stripe="false"
      >
        <el-table-column align="center" label="序号" width="55" type="index" />
        <el-table-column label="广告位名称" prop="advertisingName" min-width="200" />
        <el-table-column label="尺寸" align="center" min-width="120">
          <template slot-scope="scope">
            <span>{{ scope.row.measurement || '无' }}</span>
          </template>
        </el-table-column>
        <el-table-column label="广告数" prop="advertisementCount" align="center" min-width="100" />
        <el-table-column align="center" label="是否使用" min-width="80">
          <template slot-scope="scope">
            <span v-if="scope.row.useStatus==='01'" style="color:#00AACA">启用</span>
            <span v-if="scope.row.useStatus==='02'" style="color:#F77C46">禁用</span>
          </template>
        </el-table-column>
        <el-table-column
          label="操作"
          width="340"
          align="center"
        >
          <template slot-scope="scope">
            <el-link type="primary">
              [查看]
            </el-link>
            <el-link type="primary">
              [编辑]
            </el-link>
            <el-link type="primary">
              <span v-if="scope.row.useStatus==='01'" style="color:#F77C46">[禁用]</span>
              <span v-if="scope.row.useStatus==='02'">[启用]</span>
            </el-link>
            <el-link type="primary">
              [删除]
            </el-link>
            <el-link type="primary">
              [广告列表]
            </el-link>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <!--分页组件-->
    <pagination :pagination-data="paginationData" @change="getList" />
  </div>
</template>

<script>
/* api */
import {
  getShptAdvertisementList
} from '@/api/shoppingmall/products'
/* 组件*/
import pagination from '@comp/common/pagination/pagination'// 分页
export default {
  name: 'CustomerManageList',
  components: {
    pagination
  },
  data() {
    return {
      // 获取row的key值
      getRowKeys(row) {
        return row.id
      },
      // table数据
      tableData: [],
      // search参数
      initDataParams: {
        advertisingName: '',
        useStatus: ''
      },
      // select使用状态数组 01 启用 02 禁用
      options: [
        {
          value: '00',
          label: '请选择',
          disabled: true
        },
        {
          value: '01',
          label: '启用'
        },
        {
          value: '02',
          label: '禁用'
        }
      ],
      // 分页数据
      paginationData: {
        pageNo: 1,
        pageSize: 10,
        total: 0
      }
    }
  },
  watch: {
  },
  created() {
    this.getList()
  },
  methods: {
    // 获取列表
    getList() {
      this.getData(this.initDataParams)
    },
    // 获取列表
    getData(params) {
      params.pageNo = this.paginationData.pageNo
      params.pageSize = this.paginationData.pageSize
      getShptAdvertisementList(params).then(res => {
        if (res.header.ret === '0') {
          this.tableData = res.data.records
          this.paginationData.total = res.data.total
        }
      }).catch((err) => {
        throw new Error('获取广告列表失败' + err)
      })
    },
    // 新增广告位
    addInstitutions() {
    },
    // 重置
    resetList() {
      this.initDataParams = {
        paramName: '',
        useStatus: ''
      }
      this.getList()
    }
  }
}
</script>

<style scoped lang="less">
.shopmall-page-add {
  width: 100%;
  margin-top:  12px;
  padding-left: 12px;
  display: flex;
  align-items: center;
}
</style>
