Explorar el Código

Update 优化字典下拉框,可以使用exclude进行排除不需要的字典

Yue hace 1 semana
padre
commit
ab03df68f2
Se han modificado 1 ficheros con 15 adiciones y 1 borrados
  1. 15 1
      UI/VAP_V3.VUE/src/components/dict/DictSelect.vue

+ 15 - 1
UI/VAP_V3.VUE/src/components/dict/DictSelect.vue

@@ -9,6 +9,7 @@ const props = withDefaults(
 		placeholder?: string
 		type?: "select" | "checkbox" | "radio"
 		valueIsNumber?: boolean
+		exclude?: string[] | string // 需要排除的值,统一转成string处理
 		listeners?: any
 	}>(),
 	{
@@ -30,7 +31,20 @@ function onChange(v: any) {
 }
 
 function getData() {
-	return appStore.dictStore.getDict(props.dictType)
+	return new Promise((resolve, reject) => {
+		appStore.dictStore
+			.getDict(props.dictType)
+			.then((res: any[]) => {
+				if (props.exclude) {
+					const exList = typeof props.exclude === "string" ? [props.exclude] : props.exclude
+					res = res.filter((item: any) => !exList.includes(item.value + ""))
+				}
+				resolve(res)
+			})
+			.catch((err) => {
+				reject(err)
+			})
+	})
 }
 </script>
 <template>