<template>
  <div>
    <el-row>
      <el-col :span="24">
        <div class="searchInput" style="width: 250px; margin-bottom: 10px">
          <el-input @keyup.enter.native="(msg.pageIndex = 1), getList()" @clear="(msg.pageIndex = 1), getList()"
            style="display: inline-block; width: 225px; height: 30px" placeholder="品牌名" v-model="msg.BrandName"
            size="small" clearable>
          </el-input>
          <span @click="(msg.pageIndex = 1), getList()" class="el-icon-search" style="
              color: #979dad;
              font-size: 14px;
              position: relative;
              top: 1px;
            "></span>
        </div>
        <div style="margin-bottom: 10px;width:250px;display:inline-block;">
          <span style="margin-left: 10px">商铺性质</span>
          <el-select class="w100" @change="(msg.pageIndex = 1), getList()" style="margin-left: 10px"
            v-model="msg.ProjectType" size="small" placeholder="请选择商铺性质">
            <el-option label="不限" :value="0"></el-option>
            <el-option :label="x.Name" :value="x.Id" v-for="(x, y) in ProjectTypeList" :key="y"></el-option>
          </el-select>
        </div>
      </el-col>
    </el-row>
    <el-table :data="dataList" ref="multipleTable" @selection-change="handleSelectionChange" tooltip-effect="dark"
      height="450" style="width: 100%">
      <el-table-column type="selection" width="50px">
      </el-table-column>
      <el-table-column prop="Id" label="ID" width="100">
        <template slot-scope="scope">
          <span @click="goRecruit(scope.row.ID)">{{ scope.row.ID }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="ClassName" label="分类" width="150">
      </el-table-column>
      <el-table-column prop="BrandName" label="品牌"> </el-table-column>
      <el-table-column prop="Logo" label="Logo" width="100">
        <template slot-scope="scope">
          <el-image v-if="scope.row.Logo" :src="scope.row.Logo" style="width: 50px"
            :preview-src-list="scope.row.LogoList">
          </el-image>
        </template>
      </el-table-column>
      <el-table-column prop="ShopNum" label="店铺数量" width="80">
      </el-table-column>
      <el-table-column prop="BuiltUpArea" label="建筑面积">
        <template slot-scope="scope">
          <span>{{ scope.row.BuiltUpArea }} 至
            {{ scope.row.EndBuiltUpArea }} 平</span>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination style="text-align:center" background @current-change="handleCurrentChange" :page-size="msg.pageSize"
      layout="prev, pager, next" :total="total">
    </el-pagination>
  </div>
</template>
<script>
  export default {
    props: ['ckGoods', "IsGetSpec"],
    data() {
      return {
        dataList: [],
        msg: {
          pageIndex: 1,
          pageSize: 20,
          BrandName: "", //品牌名
          ProjectType: 0, //商铺性质
          Plumbing: -1, //上下水（0-否1-有）
          Caliber: -1, //管径（0-否1-有）
          Sewage: -1, //排污（0-否1-有）
          RanQi: -1, //燃气（0-否1-有）
          DianLiang: "", //电量（0-否1-有）
          PaiYan: -1, //排烟量（0-否1-有）
          KongTiao: -1, //空调（0-否1-有）
          XinFeng: -1, //新风（0-否1-有）
          BrandClassId: 0, //分类
          ExcelEnumIds: [],
          UserId: 0, //用户认证
        },
        total: 0,
        ProjectTypeList: [], //商铺性质列表
        selectRow: []
      };
    },
    created() {},
    methods: {
      //获取所有菜单
      getList() {
        this.apipost("/api/Trade/GetBrandPageList", this.msg, (res) => {
          if (res.data.resultCode == 1) {
            this.dataList = res.data.data.pageData;
            this.pageCount = res.data.data.count;
            this.dataList.forEach((x) => {
              x.LogoList = [];
              x.LogoList.push(x.Logo);
            });
          } else {
            this.Error(res.data.message);
          }
        });
      },
      //获取商铺性质
      getProjectType() {
        this.apipost("/api/Trade/GetProjectTypeEnumList", {}, (res) => {
          if (res.data.resultCode == 1) {
            this.ProjectTypeList = res.data.data;
          } else {
            this.Error(res.data.message);
          }
        });
      },

      handleCurrentChange(val) {
        this.msg.pageIndex = val;
        this.getList();
      },
      //父组件调用方法
      getChoicedGoods() {
        return this.selectRow;
      },
      handleSelectionChange(val) {
        this.selectRow = JSON.parse(JSON.stringify(val));
      },
      //清空多选方法
      toggleSelection(rows) {
        if (rows) {
          rows.forEach(row => {
            this.$refs.multipleTable.toggleRowSelection(row);
          });
        } else {
          this.$refs.multipleTable.clearSelection();
        }
      }

    },
    mounted() {
      this.getProjectType();
      this.getList();
    }
  };

</script>
