select1.html 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <div id="{$name}">
  2. <input type="hidden" name="{$name}" v-model="value">
  3. <input type="hidden" name="c_type" v-model="value1">
  4. <el-select clearable filterable 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 v-if="options1.length >0" clearable filterable v-model="value1" placeholder="选择类型">
  15. <el-option
  16. v-for="item in options1"
  17. :key="item.id"
  18. :label="item.name"
  19. :value="item.id.toString()">
  20. </el-option>
  21. </el-select>
  22. </div>
  23. <script>
  24. new Vue({
  25. el: '#{$name}',
  26. data: function() {
  27. return {
  28. options: {:json_encode($lists)},
  29. value:"{$value==0?'':$value}",
  30. options1:{:json_encode($options1)},
  31. value1:"{$value1==0?'':$value1}"
  32. }
  33. },
  34. watch: {
  35. value: function (newVal, oldVal) {
  36. var that = this;
  37. $.post('{:url("getType")}',{id:newVal},function (res) {
  38. that.options1 = res.data;
  39. that.value1 = '';
  40. })
  41. $('input[name={$name}]').val(newVal);
  42. }
  43. }
  44. })
  45. </script>