index.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <template>
  2. <el-select
  3. v-model="currentValue"
  4. :disabled="disabled"
  5. :placeholder="title"
  6. :remote-method="fetchData"
  7. filterable
  8. remote
  9. reserve-keyword
  10. clearable
  11. automatic-dropdown
  12. class="filter-item"
  13. @change="handlerChange"
  14. >
  15. <el-option
  16. v-for="(item, index) in dataList"
  17. :key="index"
  18. :label="item.title"
  19. :value="item.value"
  20. />
  21. </el-select>
  22. </template>
  23. <script>
  24. import { fetchTree } from "@/api/sys/dict/value";
  25. export default {
  26. name: "DicListSelect",
  27. props: {
  28. dicCode: String,
  29. title: String,
  30. value: String,
  31. disabled: Boolean,
  32. excludes: Array,
  33. },
  34. data() {
  35. return {
  36. // 下拉选项值
  37. dataList: [],
  38. currentValue: "",
  39. };
  40. },
  41. watch: {
  42. // 检测查询变化
  43. value(val) {
  44. this.currentValue = val;
  45. },
  46. },
  47. created() {
  48. this.currentValue = this.value;
  49. this.fetchData();
  50. },
  51. methods: {
  52. fetchData() {
  53. fetchTree({ dicCode: this.dicCode, excludes: this.excludes }).then(
  54. (response) => {
  55. this.dataList = response.data;
  56. }
  57. );
  58. },
  59. handlerChange(e) {
  60. this.$emit("change", e);
  61. this.$emit("input", e);
  62. },
  63. },
  64. };
  65. </script>
  66. <style scoped>
  67. /deep/ .el-form-item--medium .el-form-item__content {
  68. line-height: 20px;
  69. }
  70. </style>