0
0

select2.html 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <div id="{$name}">
  2. <input type="hidden" name="{$name}" v-model="value.join(',')">
  3. <input type="hidden" name="{$name1}" v-model="value1.join(',')">
  4. <el-select clearable filterable multiple v-model="value" placeholder="请选择分类">
  5. <el-option
  6. v-for="item in options"
  7. :key="item.id"
  8. :label="item.title"
  9. :value="item.id.toString()">
  10. </el-option>
  11. </el-select>
  12. </br>
  13. </br>
  14. <el-select
  15. clearable filterable
  16. v-model="value1"
  17. multiple
  18. collapse-tags
  19. placeholder="选择{$title}">
  20. <el-option
  21. v-for="item in options1"
  22. :key="item.id"
  23. :label="item.title"
  24. :value="item.id.toString()">
  25. </el-option>
  26. </el-select>
  27. </div>
  28. <script>
  29. new Vue({
  30. el: '#{$name}',
  31. data: function() {
  32. return {
  33. options: {:json_encode($lists)},
  34. value:{:json_encode($value)},
  35. options1:{:json_encode($options1)},
  36. value1:{:json_encode($value1)},
  37. }
  38. },
  39. watch: {
  40. value: function (newVal, oldVal) {
  41. var that = this;
  42. $.post('{$url}',{id:newVal},function (res) {
  43. that.options1 = res.data;
  44. that.value1 = [];
  45. })
  46. $('input[name={$name}]').val(newVal.join(','));
  47. },
  48. value1: function (newVal, oldVal) {
  49. $('input[name={$name}]').val(newVal.join(','));
  50. }
  51. }
  52. })
  53. </script>