stockSearch.vue 2.0 KB

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