123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <template>
- <div class="companySearch" style="width: 200px; display: inline-block">
- <div class="block" style="width: 100%">
-
- <el-select
- :size="searchSize"
- v-model="value"
- :multiple="false"
- filterable
- remote
- reserve-keyword
- placeholder="请选择公司"
- :remote-method="remoteMethod"
- :loading="loading"
- @change="a"
- >
- <el-option
- v-for="item in options"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </el-select>
- </div>
- </div>
- </template>
- <script>
- import { mapGetters } from "vuex";
- export default {
- data() {
- return {
- options: [],
- value: [],
- list: [],
- states: [],
- children: [],
- };
- },
- mounted() {
- this.list = this.states.map((item) => {
- return { value: `value:${item}`, label: `label:${item}` };
- });
- },
- computed: {
- ...mapGetters(["searchSize"]),
- },
- props: ["options"],
- methods: {
- a() {
- console.log("选择了一个公司");
- console.log(this.value);
-
- console.log(this.options);
- this.$emit("searchCard", this.value);
- this.options.forEach((element) => {
-
- if (element.value === this.value) {
- console.log(element.label);
- console.log(element.children);
- this.children = element.children;
- this.$emit("stock", this.children);
- }
- });
- },
- remoteMethod(query) {
- if (query !== "") {
- this.loading = true;
- setTimeout(() => {
- this.loading = false;
- this.options = this.list.filter((item) => {
- return item.label.toLowerCase().indexOf(query.toLowerCase()) > -1;
- });
- }, 200);
- } else {
- this.options = [];
- }
- },
- },
- };
- </script>
- <style>
- </style>
|