<template>
  <div id="add-three">
    <el-row>
      <el-col :span="24" class="main">
        <el-form :model="form" :rules="rules" ref="form" label-width="180px">
          <template v-for="(i, index) in question">
            <template v-if="i.type === 'select'">
              <el-col :span="12" :key="`select${index}`">
                <el-form-item :prop="`${index}`" :label="`${i.label}`">
                  <el-select v-model="form[i.model]" placeholder="">
                    <el-option v-for="(item, index) in getList(i.list)" :key="index" :value="item" :label="item"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </template>
            <template v-else-if="i.type === 'checkbox'">
              <el-col :span="12" :key="`checkbox${index}`">
                <el-form-item :prop="`${index}`" :label="`${i.label}`">
                  <el-select v-model="form[i.model]" multiple placeholder="">
                    <el-option v-for="(item, index) in getList(i.list)" :key="index" :value="item" :label="item"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </template>
            <template v-else-if="i.type === 'object'">
              <!-- <el-col :span="24" :key="`object-addThree${index}`" style="text-align: center;padding-bottom:15px">{{ i.label }}</el-col>
              <el-row class="object" :key="`object-children${index}`">
                <el-col :span="12" v-for="(f, cindex) in i.children" :key="`children${cindex}`">
                  <el-form-item :prop="`${index}-${cindex}`" :label="`${f.label}`">
                    <el-select v-model="form[f.model]" multiple placeholder="">
                      <el-option v-for="(item, index) in getList(i.list)" :key="index" :value="item" :label="item"></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-row> -->
              <el-row type="flex" :key="`object-addThree${index}`" align="middle" class="object">
                <el-col :span="3" class="olabel">{{ i.label }}</el-col>
                <el-col :span="21" class="oselect">
                  <el-col :span="5" v-for="(f, cindex) in i.children" :key="`children${cindex}`" class="child">
                    <el-col :span="24" class="child_label">{{ f.label }}</el-col>
                    <el-col :span="24" class="child_select">
                      <el-select v-model="form[f.model]" multiple placeholder="">
                        <el-option v-for="(item, index) in getList(i.list)" :key="index" :value="item" :label="item"></el-option>
                      </el-select>
                    </el-col>
                    <!-- <el-form-item :prop="`${index}-${cindex}`" :label="`${f.label}`">
                      <el-select v-model="form[f.model]" multiple placeholder="">
                        <el-option v-for="(item, index) in getList(i.list)" :key="index" :value="item" :label="item"></el-option>
                      </el-select>
                    </el-form-item> -->
                  </el-col>
                </el-col>
              </el-row>
            </template>
          </template>
        </el-form>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { addThree } from '../fields.js';
import * as select from '../select.js';
import { mapState, createNamespacedHelpers } from 'vuex';
export default {
  name: 'addThree',
  props: {
    form: { type: Object },
    rules: { type: Object },
  },
  components: {},
  data: function() {
    return {
      question: addThree,
    };
  },
  created() {},
  methods: {
    // 获取列表
    getList(type) {
      return select[type];
    },
  },
};
</script>

<style lang="less" scoped>
@borderColor: #ccc;
.label {
  font-size: 14px;
  color: #606266;
  margin: 0 7px 0 0;
  padding: 5px 0;
}
.select {
  width: 90.8%;
  .chiList {
    width: 13.2%;
    margin: 0 10px 0 0;
    .chi_label {
      text-align: center;
      font-size: 14px;
      color: #606266;
      padding: 5px 0;
    }
  }
  .chiList:last-child {
    margin: 0;
  }
}
// .object {
//   border-bottom: 1px #ccc solid;
//   margin-bottom: 15px;
//   .olabel {
//     text-align: center;
//   }
// }
// .child {
//   width: 20%;
// }
.object {
  border-bottom: 1px #ccc solid;
  margin: 0 0 10px 0;
  padding: 0 0 10px 0;
  .olabel {
    font-size: 14px;
    color: #666;
  }
  .child {
    width: 18.9%;
    margin: 0 10px 0 0;
    .child_label {
      text-align: center;
      font-size: 14px;
      color: #666;
      padding: 10px 0;
    }
  }
  .child:nth-child(5n) {
    margin: 0;
  }
}
/deep/.el-input__inner {
  border: 1px solid #333;
}
</style>
