<template>
  <div>
    <!-- 选择项目 -->
    <el-dialog
      title="选择会议"
      :visible.sync="showMeetingItem"
      width="800px"
      append-to-body
    >
      <el-table
        ref="meetingTable"
        @row-click="clickRow"
        :data="meetingList"
        @selection-change="handleSelectionChange"
      >
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column label="主键ID" align="center" prop="id" />
        <el-table-column label="会议主题" align="center" prop="meetingTheme" />
        <el-table-column label="会议编号" align="center" prop="meetingCode" />
        <el-table-column label="类别" align="center" prop="meetingType" />
        <el-table-column
          label="会议开始时间"
          align="center"
          prop="startTime"
          width="180"
        >
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.startTime, "{y}-{m}-{d}") }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="会议结束时间"
          align="center"
          prop="endTime"
          width="180"
        >
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.endTime, "{y}-{m}-{d}") }}</span>
          </template>
        </el-table-column>
        <el-table-column label="会议地点" align="center" prop="place" />
        <el-table-column label="会议发起人" align="center" prop="promoter" />
      </el-table>
      <pagination
        v-show="meetingItemTotal > 0"
        :total="meetingItemTotal"
        :page.sync="meetingQueryParams.pageNum"
        :limit.sync="meetingQueryParams.pageSize"
        @pagination="getList"
      />
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submit">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import { listMeeting } from "@/api/invest/meeting";
export default {
  props: {},
  dicts: ["meeting_type", "project_stage"],
  data() {
    return {
      showMeetingItem: false,
      // 总条数
      meetingItemTotal: 0,
      meetingList: [],
      meetingQueryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      
    // 选中数组
      ids: [],
      idsName:[],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
    };
  },
  mounted() {
    this.getList();
  },
  methods: {
    clickRow(row) {
      this.$refs.meetingTable.toggleRowSelection(row);
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      if (selection.length > 1) {
        this.$modal.msg("只能选择一个项目");
        this.$refs.meetingTable.clearSelection();
        return;
      }
      if (this.ids.length == 0) {
        this.ids = selection;
      } else {
        this.$modal.msg("只能选择一个项目");
        this.ids = [];
        // meetingTable与table的ref绑定的一样
        this.$refs.meetingTable.clearSelection();
      }
    },
    /** 查询会议列表 */
    getList() {
      listMeeting(this.meetingQueryParams).then((response) => {
        this.meetingList = response.rows;
        this.meetingItemTotal = response.total;
      });
    },
    submit() {
      // console.log("确定", this.ids);
      this.$emit("getMeetingInfo", this.ids);
      this.showMeetingItem = false;
    },
    cancel() {
      this.showMeetingItem = false;
    },
  },
};
</script>