<template>
  <div class='m-container'>
    <h2>
      <div class="squrt"></div>保存表单演示
    </h2>
    <div class="m-core">
      <save-form ref="form" :model.sync="form" inline @submit="submit" @reset="reset">
        <el-form-item
          prop="input"
        >
          <el-input v-model="form.input" placeholder="请输入内容"/>
        </el-form-item>
        <el-form-item
          prop="input2"
        >
          <el-input type="number" v-model="form.input2" placeholder="请输入内容2"/>
        </el-form-item>
        <el-form-item prop="region">
          <el-select v-model="form.region" placeholder="请选择活动区域">
            <el-option label="区域一" value="shanghai"></el-option>
            <el-option label="区域二" value="beijing"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item prop="branch">
          <el-select v-model="form.branch" placeholder="请选择分部">
            <el-option v-for="item in selects.branchs" :key="item.id" :label="item.name" :value="item.id"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item prop="subject">
          <el-select v-model="form.subject" placeholder="请选择声部">
            <el-option v-for="item in selects.subjects" :key="item.id" :label="item.name" :value="item.id"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item required>
          <el-col :span="11">
            <el-form-item prop="date1">
              <el-date-picker type="date" placeholder="选择日期" v-model="form.date1" style="width: 100%;"></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col class="line" :span="2">-</el-col>
          <el-col :span="11">
            <el-form-item prop="date2">
              <el-time-picker placeholder="选择时间" v-model="form.date2" style="width: 100%;"></el-time-picker>
            </el-form-item>
          </el-col>
        </el-form-item>
        <el-form-item prop="times">
          <el-date-picker
            v-model="form.times"
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item>
          <remoteSearch :commit='"setEducations"'  v-model='form.educations' />
        </el-form-item>
         <el-form-item>
          <remoteSearch :commit='"setTeachers"' v-model='form.teacher' />
        </el-form-item>
        <div>
          <el-button type="primary" native-type="submit">提交</el-button>
          <el-button type="danger" native-type="reset">重置</el-button>
        </div>
      </save-form>
    </div>
    <tab-router>
      <el-tab-pane label="1" name="1">12131231</el-tab-pane>
      <el-tab-pane label="2" name="2">adwqj</el-tab-pane>
    </tab-router>
    <el-table
      :data="list"
      class="table"
    >
      <el-table-column
        prop="title"
        label="标题"
      >
        <template slot-scope="scope">
          <copy-text>{{scope.row.title}}</copy-text>
        </template>
      </el-table-column>
      <el-table-column
        prop="remark"
        width="220px"
        label="备注"
      >
        <template slot-scope="scope">
          <overflow-text
            :text="scope.row.remark"
          />
        </template>
      </el-table-column>
    </el-table>
    <pagination
      :total="rules.total"
      :page.sync="rules.page"
      :limit.sync="rules.limit"
      :page-sizes="rules.page_size"
      :sync="true"
      @pagination="getList"
    />
    <el-dialog :visible.sync="testvisible" destroy-on-close>
      <test v-if="testvisible"/>
      <template #footer>
        <el-button @click="testvisible = false">关闭</el-button>
      </template>
    </el-dialog>
  </div>
</template>
<script>
import pagination from "@/components/Pagination/index";
import test from './modals/test'
import remoteSearch from "@/components/remote-search"
export default {
  components: {
    test,
    pagination,
    remoteSearch
  },
  data() {
    return {
      testvisible: false,
      rules: {
        // 分页规则
        limit: 10, // 限制显示条数
        page: 1, // 当前页
        total: 30, // 总条数
        page_size: [10, 20, 40, 50] // 选择限制显示条数
      },
      form: {
        input: '',
        input2: '',
        region: '',
        date1: '',
        date2: '',
        delivery: '',
        type: [],
        resource: '',
        desc: '',
        times: [],
        educations:'',
        teacher:''
      },
      list: [{
        id: 1,
        title: '表阿嚏内容',
        remark: '很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长'
      },{
        id: 2,
        title: '标题信息',
        remark: '很长很长很长'
      }],
    }
  },
  mounted() {
    this.$store.dispatch('setBranchs')
    this.$store.dispatch('setSubjects')
  },
  methods: {
    getList() {
      return Promise.resolve()
    },
    submit(evt) {
      console.log(this.form.educations)
      console.log(evt)
    },
    reset() {
      this.$refs.form.resetFields()
    }
  }
}
</script>
<style lang="less" scoped>
  .table{
    margin-top: 20px;
    ::v-deep  .el-table__header .has-gutter tr th{
      background-color: #EDEEF0;
      color: #444;
    }
  }
</style>
