From 150498c25a32b3ed8749ff7f575339d6428f0844 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E4=BB=99=E9=83=BD=E6=B2=A1=E7=94=A8?= <615206459@qq.com> Date: Sun, 4 Feb 2024 20:12:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/distpicker/components/index.tsx | 25 ++++++++++++++++++--- src/plugins/distpicker/config.ts | 6 ++--- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/plugins/distpicker/components/index.tsx b/src/plugins/distpicker/components/index.tsx index 02ede2f..32f24b9 100644 --- a/src/plugins/distpicker/components/index.tsx +++ b/src/plugins/distpicker/components/index.tsx @@ -1,18 +1,37 @@ -import { defineComponent } from "vue"; +import { PropType, defineComponent } from "vue"; import data from "../data/pca.json"; export default defineComponent({ name: "cl-distpicker", props: { - props: Object + props: Object, + type: { + type: String as PropType<"pc" | "pca">, + default: "pca" + } }, setup(props) { return () => { return ( { + if (props.type === "pc") { + return { + ...e, + children: e.children.map((a) => { + return { + ...a, + children: undefined + }; + }) + }; + } + + return e; + })} props={{ label: "name", value: "name", ...props.props }} /> ); diff --git a/src/plugins/distpicker/config.ts b/src/plugins/distpicker/config.ts index d67ba1f..67ab468 100644 --- a/src/plugins/distpicker/config.ts +++ b/src/plugins/distpicker/config.ts @@ -4,7 +4,7 @@ import { registerFormHook } from "@cool-vue/crud"; // 注册hook registerFormHook("pca", (value, { method, form, prop }) => { if (method == "bind") { - return [form.province, form.city, form.district]; + return [form.province, form.city, form.district].filter(Boolean); } else { const [province, city, district] = value || []; form.province = province; @@ -19,8 +19,8 @@ export default (): ModuleConfig => { label: "省市区选择器", description: "快速增删改查及一系列辅助组件", author: "COOL", - version: "1.0.0", - updateTime: "2024-02-01", + version: "1.0.1", + updateTime: "2024-02-04", demo: [ { name: "基础用法",