companySearch.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <div class="companySearch" style="width: 200px; display: inline-block">
  3. <div class="block" style="width: 100%">
  4. <!-- <el-cascader
  5. style="width: 400px"
  6. :options="options"
  7. v-model="value"
  8. collapse-tags
  9. :props="{ multiple: true, checkStrictly: false }"
  10. clearable
  11. filterable
  12. @change="a"
  13. ></el-cascader> -->
  14. <el-select
  15. :size="searchSize"
  16. v-model="value"
  17. :multiple="false"
  18. filterable
  19. remote
  20. reserve-keyword
  21. placeholder="请选择公司"
  22. :remote-method="remoteMethod"
  23. :loading="loading"
  24. @change="a"
  25. >
  26. <el-option
  27. v-for="item in options"
  28. :key="item.value"
  29. :label="item.label"
  30. :value="item.value"
  31. >
  32. </el-option>
  33. </el-select>
  34. </div>
  35. </div>
  36. </template>
  37. <script>
  38. import { mapGetters } from "vuex";
  39. export default {
  40. data() {
  41. return {
  42. options: [],
  43. value: [],
  44. list: [],
  45. states: [],
  46. children: [],
  47. };
  48. },
  49. mounted() {
  50. this.list = this.states.map((item) => {
  51. return { value: `value:${item}`, label: `label:${item}` };
  52. });
  53. },
  54. computed: {
  55. ...mapGetters(["searchSize"]),
  56. },
  57. props: ["options"],
  58. methods: {
  59. a() {
  60. console.log("选择了一个公司");
  61. console.log(this.value);
  62. // console.log(this.list);
  63. console.log(this.options);
  64. this.$emit("searchCard", this.value);
  65. this.options.forEach((element) => {
  66. // console.log(element);
  67. if (element.value === this.value) {
  68. console.log(element.label);
  69. console.log(element.children);
  70. this.children = element.children;
  71. this.$emit("stock", this.children);
  72. }
  73. });
  74. },
  75. remoteMethod(query) {
  76. if (query !== "") {
  77. this.loading = true;
  78. setTimeout(() => {
  79. this.loading = false;
  80. this.options = this.list.filter((item) => {
  81. return item.label.toLowerCase().indexOf(query.toLowerCase()) > -1;
  82. });
  83. }, 200);
  84. } else {
  85. this.options = [];
  86. }
  87. },
  88. },
  89. };
  90. </script>
  91. <style>
  92. </style>