<template>
  <div id="layout-1">
    <el-row>
      <el-col :span="24" class="main">
        <el-col :span="24" class="one">
          <el-transfer v-model="value" :titles="['未编排', '已编排']" :button-texts="['取消', '确认']" :data="data">
            <el-col :span="24" slot-scope="{ option }">
              <el-col :span="12" class="textOver">{{ option.name }}</el-col>
              <el-col :span="12" class="textOver">{{ option.card }}</el-col>
            </el-col>
          </el-transfer>
        </el-col>
        <el-col :span="24" class="two">
          <el-button type="primary" size="small" @click="onSubmit">确认编排</el-button>
        </el-col>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { mapState, createNamespacedHelpers } from 'vuex';
const { mapActions: examination_examinee } = createNamespacedHelpers('examination_examinee');
import _ from 'lodash';
export default {
  name: 'layout-1',
  props: {
    romminfo: { type: Object },
    list: { type: Array },
  },
  components: {},
  data: function () {
    return {
      value: [],
      data: [],
    };
  },
  created() {},
  methods: {
    ...examination_examinee(['fetch']),
    // 整理数据
    search() {
      var data = this.list.map((i) => ({ key: i.id, name: i.name, card: i.card, disabled: false }));
      this.$set(this, `data`, data);
    },
    async onSubmit() {
      let res = _.cloneDeep(this.value);
      res = res.map((i) => this.list.find((f) => f.id == i));
      this.$emit('layoutSubmit', res);
    },
  },
  computed: {
    ...mapState(['user']),
  },
  metaInfo() {
    return { title: this.$route.meta.title };
  },
  watch: {
    list: {
      deep: true,
      immediate: true,
      handler(val) {
        if (val) this.search();
      },
    },
  },
};
</script>

<style lang="less" scoped>
.main {
  .one {
    /deep/.el-transfer-panel {
      width: 36%;
      height: 500px;
      overflow-y: auto;
    }
  }
  .two {
    text-align: center;
    margin: 10px 0;
  }
}
</style>
