multiple-optgroup-select.html 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <style>
  2. .el-select-group__wrap:not(:last-of-type)::after {
  3. content: '';
  4. position: absolute;
  5. display: none;
  6. left: 20px;
  7. right: 20px;
  8. bottom: 0px !important;
  9. height: 0px !important;
  10. background: #e4e7ed;
  11. }
  12. .el-select-group__wrap:not(:last-of-type){
  13. padding-bottom: 0px !important;
  14. }
  15. </style>
  16. <div id="{$name}">
  17. <input type="hidden" name="{$name}" :value="value.join(',')">
  18. <el-select v-model="value" filterable clearable multiple placeholder="请选择" size="small"
  19. style="width:100%">
  20. <el-option-group
  21. v-for="group in options"
  22. :key="group.label"
  23. :label="group.label">
  24. <el-option
  25. v-for="item in group.options"
  26. :key="item.id"
  27. :label="item.title"
  28. :value="item.id.toString()">
  29. </el-option>
  30. </el-option-group>
  31. </el-select>
  32. {if $msg}
  33. <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> {$msg}</span>
  34. {/if}
  35. </div>
  36. <script>
  37. new Vue({
  38. el: '#{$name}',
  39. data: function() {
  40. return {
  41. options: {:json_encode($lists)},
  42. value: {:json_encode($val)}
  43. }
  44. },
  45. watch: {
  46. value: function (newVal, oldVal) {
  47. $('input[name={$name}]').val(newVal.join(','));
  48. }
  49. },
  50. created(){
  51. const vals = this.value;
  52. this.value = [];
  53. vals.forEach((item) => {
  54. this.value.push(item.toString());
  55. })
  56. console.log('11111',this.value);
  57. }
  58. })
  59. </script>