c_select.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <template>
  2. <div class="slider-box">
  3. <div class="c_row-item">
  4. <el-col class="label" :span="4" v-if="datas[name].title">
  5. {{ datas[name].title }}
  6. </el-col>
  7. <el-col span="19" class="slider-box">
  8. <el-select v-model="datas[name].activeValue" clearable style="width: 350px" @change="sliderChange">
  9. <el-option
  10. v-for="(item, index) in datas[name].list"
  11. :value="item.activeValue"
  12. :key="index"
  13. :label="item.title"
  14. ></el-option>
  15. </el-select>
  16. </el-col>
  17. </div>
  18. </div>
  19. </template>
  20. <script>
  21. export default {
  22. name: 'c_select',
  23. props: {
  24. name: {
  25. type: String,
  26. },
  27. configData: {
  28. type: null,
  29. },
  30. configNum: {
  31. type: Number | String,
  32. default: 'default',
  33. },
  34. },
  35. data() {
  36. return {
  37. defaults: {},
  38. datas: this.configData[this.configNum],
  39. };
  40. },
  41. mounted() {
  42. if (this.name === 'selectConfig') {
  43. this.bus.$on('upData', (data) => {
  44. this.datas[this.name].list = data;
  45. this.bus.$off();
  46. });
  47. }
  48. },
  49. watch: {
  50. configData: {
  51. handler(nVal, oVal) {
  52. this.datas = nVal[this.configNum];
  53. },
  54. deep: true,
  55. },
  56. },
  57. methods: {
  58. sliderChange(e) {
  59. this.$emit('getConfig', { name: 'select', values: e });
  60. },
  61. },
  62. };
  63. </script>
  64. <style scoped>
  65. .slider-box {
  66. margin-top: 10px;
  67. }
  68. </style>