mirror of
				https://github.com/apache/skywalking-booster-ui.git
				synced 2025-10-31 17:34:45 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			114 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			Vue
		
	
	
	
	
	
			
		
		
	
	
			114 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			Vue
		
	
	
	
	
	
| <!-- Licensed to the Apache Software Foundation (ASF) under one or more
 | |
| contributor license agreements.  See the NOTICE file distributed with
 | |
| this work for additional information regarding copyright ownership.
 | |
| The ASF licenses this file to You under the Apache License, Version 2.0
 | |
| (the "License"); you may not use this file except in compliance with
 | |
| the License.  You may obtain a copy of the License at
 | |
| 
 | |
|   http://www.apache.org/licenses/LICENSE-2.0
 | |
| 
 | |
| Unless required by applicable law or agreed to in writing, software
 | |
| distributed under the License is distributed on an "AS IS" BASIS,
 | |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | |
| See the License for the specific language governing permissions and
 | |
| limitations under the License. -->
 | |
| <template>
 | |
|   <el-select
 | |
|     :size="size"
 | |
|     v-model="selected"
 | |
|     :placeholder="placeholder"
 | |
|     @change="changeSelected"
 | |
|     filterable
 | |
|     :multiple="multiple"
 | |
|     :disabled="disabled"
 | |
|     :style="{ borderRadius }"
 | |
|   >
 | |
|     <el-option
 | |
|       v-for="item in options"
 | |
|       :key="item.value"
 | |
|       :label="item.label"
 | |
|       :value="item.value"
 | |
|     >
 | |
|     </el-option>
 | |
|   </el-select>
 | |
| </template>
 | |
| <script lang="ts" setup>
 | |
| import { ref, defineEmits } from "vue";
 | |
| import type { PropType } from "vue";
 | |
| import { ElSelect, ElOption } from "element-plus";
 | |
| 
 | |
| interface Option {
 | |
|   label: string;
 | |
|   value: string;
 | |
| }
 | |
| 
 | |
| const emit = defineEmits(["change"]);
 | |
| /*global  defineProps*/
 | |
| const props = defineProps({
 | |
|   options: {
 | |
|     type: Array as PropType<Option[]>,
 | |
|     default: () => [],
 | |
|   },
 | |
|   value: {
 | |
|     type: [Array, String] as PropType<string[] | string>,
 | |
|     default: () => [],
 | |
|   },
 | |
|   size: { type: String, default: "small" },
 | |
|   placeholder: { type: String, default: "Select a option" },
 | |
|   borderRadius: { type: Number, default: 3 },
 | |
|   multiple: { type: Boolean, default: false },
 | |
|   disabled: { type: Boolean, default: false },
 | |
| });
 | |
| 
 | |
| const selected = ref<string[] | string>(props.value);
 | |
| function changeSelected() {
 | |
|   const options = props.options.filter((d: Option) =>
 | |
|     props.multiple
 | |
|       ? selected.value.includes(d.value)
 | |
|       : selected.value === d.value
 | |
|   );
 | |
|   emit("change", options);
 | |
| }
 | |
| </script>
 | |
| <style lang="scss" scope>
 | |
| .icon {
 | |
|   width: 16px;
 | |
|   height: 16px;
 | |
|   vertical-align: middle;
 | |
|   fill: currentColor;
 | |
| 
 | |
|   &.sm {
 | |
|     width: 14px;
 | |
|     height: 14px;
 | |
|   }
 | |
| 
 | |
|   &.middle {
 | |
|     width: 18px;
 | |
|     height: 18px;
 | |
|   }
 | |
| 
 | |
|   &.lg {
 | |
|     width: 24px;
 | |
|     height: 24px;
 | |
|   }
 | |
| 
 | |
|   &.loading {
 | |
|     animation: loading 1.5s linear infinite;
 | |
|   }
 | |
| 
 | |
|   &.logo {
 | |
|     height: 30px;
 | |
|     width: 110px;
 | |
|   }
 | |
| 
 | |
|   &.xl {
 | |
|     height: 30px;
 | |
|     width: 30px;
 | |
|   }
 | |
| }
 | |
| 
 | |
| .el-input__inner {
 | |
|   border-radius: unset !important;
 | |
| }
 | |
| </style>
 | 
