123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <template>
- <el-select
- v-model="selected"
- class="size-select"
- placeholder="请选择"
- @change="select"
- :style="styles"
- filterable
- remote
- :remote-method="search"
- clearable
- >
- <el-option
- v-for="item in optionList"
- :key="item.roomCode"
- :label="item.roomName"
- :value="item.roomCode"
- >
- <span>{{ item.roomName }}</span>
- </el-option>
- </el-select>
- </template>
- <script>
- import { object2QueryString } from "@/utils/utils";
- export default {
- name: "ExamRoomSelect",
- props: {
- value: [String, Array],
- styles: { type: String },
- },
- data() {
- return {
- optionList: [],
- selected: "",
- };
- },
- async created() {
- this.search();
- },
- watch: {
- value: {
- immediate: true,
- handler(val) {
- this.selected = val;
- },
- },
- },
- methods: {
- async search(query) {
- const res = await this.$http.post(
- "/api/admin/sys/examRoom/query?" +
- object2QueryString({ roomName: query })
- );
- // console.log(res.data);
- this.optionList = res.data.data;
- },
- select() {
- this.$emit("input", this.selected);
- this.$emit("change", this.selected);
- },
- },
- };
- </script>
- <style></style>
|