<!-- 车场管理 -->

<template>
  <div class="mian">
    <div class="search">
      <el-input
        placeholder="输入车场名称查询"
        class="search-input"
        clearable
        v-model="mixins_query.garageName"
      ></el-input>
      <el-select
        placeholder="社区名称"
        clearable
        v-model="mixins_query.communityId"
      >
        <el-option
          v-for="(item,index) in community"
          :key="index"
          :value="item.nameId"
          :label="item.name"
        ></el-option>
      </el-select>
      <el-button
        type="primary"
        class="search-btn"
        @click="mixins_search"
        icon="el-icon-search"
      >查询</el-button>
    </div>
    <zz-table
      :cols="cols"
      :settings="{ showCheckbox: false, showIndex: true, stripe: true }"
      :data="mixins_list"
      :pageset="mixins_pageset"
      @page-change="pageChange"
      @selection-change="selectionChange"
    >
      <template
        slot-scope="scope"
        slot="opt"
      >
        <div class="opt">
          <el-tooltip
            class="item"
            effect="light"
            placement="bottom"
            content="查看"
          >
            <i
              class="zoniot_font zoniot-icon-xiangqing"
              @click="lookDetails(scope.row)"
            ></i>
          </el-tooltip>
        </div>
      </template>

    </zz-table>
  </div>
</template>


<script>
import index from './index'
import list from '@utils/list';
export default {
  mixins: [index, list],
  data () {
    return {
      mixins_post: 'post',
      community: [],//社区名称
    };
  },
  methods: {

    // 获取社区名称
    queryCommunity () {
      this.$http.get('/sc-community-web/assets/community/list').then(({ data, status, msg }) => {
        console.log('data', data);
        this.community = [];
        for (let i = 0; i < data.length; i++) {
          this.community.push({
            name: data[i].communityName,
            nameId: data[i].id
          })
        }
        console.log(this.community);
      });
    },
    // 查询对应的详情

    lookDetails (row) {
      new Promise((resolve) => {
        this.$store.dispatch('addPopup', {
          url: '/parkingManagement/setpPage/details.vue',
          width: '748px',
          height: '300px',
          props: {
            id: row.parkId,
            // callback: resolve
          },
          showConfirmButton: true,
          showCancelButton: true,
          hideStar: true,
          title: '分区信息'
        });
      }).then(() => {
        this.mixins_search();
      });
    }
  },
  created () {
    // 默认查询
    this.mixins_dataUrl = '/sc-community-web/parkingCar/findParkInfo';
    this.mixins_query = {};
    this.mixins_search();
    // 社区名称
    this.queryCommunity();
  },
}
</script>