index.vue 2.56 KB
Newer Older
何虹's avatar
何虹 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
<template>
  <div :id="elId"  style="width:100%;height:100%">
      <div id="hsCarousel"  style="width:100%;height:100%">
      <el-carousel  style="width:100%;height:100%">
        <el-carousel-item v-for="(item,index) in dataList" :key="index">
          <h3 class="small">{{ item.text }}</h3>
        </el-carousel-item>
      </el-carousel>
    </div>
      <jsoneditor v-model='jsoneditorVisible'
                  :elInfo='elInfo'
                  :dealWithSourceFun='dealWithSource'
                  :jsoneditorCloseAfter='jsoneditorCloseAfter'
                  :jsoneditorOpenAfter='jsoneditorOpenAfter'
                  >
      </jsoneditor>

  </div>
</template>
<script>
import jsoneditor from '../common/jsoneditor'
import uuidv1 from 'uuid/v1'
import ucComponent from '../ucClass/uc_component'
export default {
  mixins: [ucComponent],
  name: 'hsCarousel',
  components: {
    jsoneditor
  },
  props: {
    allSourceData: {
      default: {}
    },
    elInfo: {
      type: Object,
      default() {
        return {}
      }
    },
    initStyle: {
      type: Object,
      default() {
        return {}
      }
    },
    jsoneditorCloseAfter: {
      type: Function
    },
    jsoneditorOpenAfter: {
      type: Function
    }
  },
  watch: {
    allSourceData: {
      handler: function(newVal, oldVal) {
        this.initData(newVal)
      },
      deep: true
    }
  },
  data() {
    return {
      elId: uuidv1(),
      jsoneditorVisible: false,
      dataList: [],
      jsoneditorConfig: {}, // 配置
      jsoneditorSource: [], // 原始数据
      sourceData: {}
    }
  },
  mounted() {
  },
  methods: {
    dealWithSource(config, sourceData) {
      return {
        config,
        sourceData
      }
    },
    initData(data) {
      if (data && data.sourceData && data.sourceData.length) {
        this.dataList = data.sourceData
        this.jsoneditorConfig = data.config || {}
        this.jsoneditorSource = data.sourceData
      } else {
        this.dataList = [{ id: '1', text: '华晨宝马x5' }, { id: '2', text: '梅赛德斯大G' }, { id: '3', text: '奥迪Q8' }]
        this.jsoneditorConfig = {}
        this.jsoneditorSource = this.dataList
      }
    }
  }
}
</script>
<style scoped>
#hsCarousel >>>  .el-carousel__item h3 {
    color: #475669;
    font-size: 14px;
    opacity: 0.75;
    margin: 0;
  }

#hsCarousel >>>   .el-carousel__item:nth-child(2n) {
     background-color: #99a9bf;
  }

#hsCarousel >>>   .el-carousel__item:nth-child(2n+1) {
     background-color: #d3dce6;
  }
#hsCarousel  >>> .el-carousel__container{
    height: 100%;
  }
</style>