<template>
  <ai-list class="moment">
    <template slot="content">
      <ai-bar title="总体概况">
        <template slot="right">
          <el-button size="small" type="text" icon="iconfont iconEdit" @click="toEdit('')" >修改</el-button>
        </template>
      </ai-bar>
      <ai-wrapper>
        <ai-info-item label="本届换届时间" :value="111" />
        <ai-info-item label="换届类型" :value="111" />
        <ai-info-item label="下届换届时间" :value="111" />
        <ai-info-item label="当前届次" :value="111" />
      </ai-wrapper>
      <ai-bar title="本届任职">
        <template slot="right">
          <el-button size="small" type="text" icon="iconfont iconAdd" @click="toAdd('')" >添加任职人员</el-button>
        </template>
      </ai-bar>
      <ai-table
          class="detail-table__table"
          :tableData="tableData"
          :col-configs="colConfigs"
          :total="totalJob"
          :current.sync="current"
          :size.sync="size"
          @getList="getJobList">
          <el-table-column slot="options" label="操作" align="center">
            <template slot-scope="{ row }">
              <el-button type="text" @click="jobEdit(row.id)">编辑</el-button>
              <el-button type="text" @click="jobDelete(row.id)">删除</el-button>
            </template>
          </el-table-column>
        </ai-table>
        <ai-bar title="本届候选人">
        <template slot="right">
          <el-button size="small" type="text" icon="iconfont iconAdd" @click="toAdd('')" >添加候选人</el-button>
        </template>
      </ai-bar>
      <ai-table
        class="detail-table__table"
        :tableData="tableData"
        :col-configs="colConfigs"
        :total="totalJob"
        :current.sync="current"
        :size.sync="size"
        @getList="getJobList">
        <el-table-column slot="options" label="操作" align="center">
          <template slot-scope="{ row }">
            <el-button type="text" @click="jobEdit(row.id)">编辑</el-button>
            <el-button type="text" @click="jobDelete(row.id)">删除</el-button>
          </template>
        </el-table-column>
      </ai-table>
    </template>

    <ai-dialog :visible.sync="dialogJob" title="定制大屏" @closed="custom={}" @onConfirm="handleCustomizedDV">
      <el-form ref="jobForm" size="small" :model="jobForm" :rules="rules" label-width="80px">
        <el-form-item label="职位" prop="title">
          <el-input v-model="jobForm.title" clearable placeholder="请输入"/>
        </el-form-item>
        <el-form-item label="姓名" prop="dv">
          <el-input v-model="jobForm.title" clearable placeholder="请输入"/>
        </el-form-item>
      </el-form>
    </ai-dialog>

    <ai-dialog :visible.sync="dialogCandidate" title="定制大屏" @closed="custom={}" @onConfirm="handleCustomizedDV">
      <el-form ref="CandFrom" size="small" :model="CandFrom" :rules="rules" label-width="80px">
        <el-form-item label="大屏标题" prop="title">
          <el-input v-model="custom.title" clearable placeholder="请填写"/>
        </el-form-item>
        <el-form-item label="选择大屏" prop="dv">
          <ai-select v-model="custom.dv" :selectList="dict.getDict('customizedDVs')"/>
        </el-form-item>
        <el-form-item label="静态数据">
          <el-input type="textarea" rows="5" v-model="custom.meta"/>
        </el-form-item>
      </el-form>
    </ai-dialog>
  </ai-list>
</template>

<script>
export default {
  name: "moment",
  props: {
    instance: Function,
    permissions: Function,
    dict: Object,
    selected: Object
  },
  data() {
    return {
      isEdit: false,
      tableData: [],
      totalJob: 0,
      current: 1,
      size: 10,
      dialogJob: false,
      dialogCandidate: false,
    }
  },
  computed: {
    colConfigs() {
      return [
        {prop: 'content', label: '职位'},
        {prop: 'content', label: '姓名'},
        {slot: 'options'},
      ]
    }
  },
  methods: {
    jobEdit() {},
    jobDelete() {},
    getJobList() {},
    toEdit() {
      this.$emit('change', {
        type: 'addChange',
        params: {
          id: id || ''
        }
      })
      // this.$route.push('#addChange')
    },
  }
}
</script>

<style lang="scss" scope>
.moment {
  padding-top: 0 !important;
  background-color: #FFF !important;
}
</style>