workdesktop-ai 1.0.2 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +155 -93
- package/README.md +123 -25
- package/dist/api-button/index.mjs +7 -0
- package/dist/api-button/index.mjs.map +1 -0
- package/dist/assets/Select-CNzSyvlZ.css +1 -0
- package/dist/auto-complete/index.mjs +7 -0
- package/dist/auto-complete/index.mjs.map +1 -0
- package/dist/auto-complete/style.css +1 -0
- package/dist/base.css +1 -0
- package/dist/checkbox-list/index.mjs +7 -0
- package/dist/checkbox-list/index.mjs.map +1 -0
- package/dist/checkbox-list/style.css +1 -0
- package/dist/chunks/ApiButton.vue_vue_type_script_setup_true_lang-KKzJxwpV.mjs +80 -0
- package/dist/chunks/ApiButton.vue_vue_type_script_setup_true_lang-KKzJxwpV.mjs.map +1 -0
- package/dist/chunks/AutoComplete-CLV_PwcZ.mjs +80 -0
- package/dist/chunks/AutoComplete-CLV_PwcZ.mjs.map +1 -0
- package/dist/chunks/CheckboxList-Bx3Ce1q5.mjs +129 -0
- package/dist/chunks/CheckboxList-Bx3Ce1q5.mjs.map +1 -0
- package/dist/chunks/ConfirmButton.vue_vue_type_script_setup_true_lang-D4w6G2Kv.mjs +99 -0
- package/dist/chunks/ConfirmButton.vue_vue_type_script_setup_true_lang-D4w6G2Kv.mjs.map +1 -0
- package/dist/chunks/DataForm-C5MBVdei.mjs +305 -0
- package/dist/chunks/DataForm-C5MBVdei.mjs.map +1 -0
- package/dist/chunks/DataGrid-HUzKWuQx.mjs +1124 -0
- package/dist/chunks/DataGrid-HUzKWuQx.mjs.map +1 -0
- package/dist/chunks/DialogButton.vue_vue_type_script_setup_true_lang-CTXP79zc.mjs +117 -0
- package/dist/chunks/DialogButton.vue_vue_type_script_setup_true_lang-CTXP79zc.mjs.map +1 -0
- package/dist/chunks/Drawer-ucXKUecL.mjs +259 -0
- package/dist/chunks/Drawer-ucXKUecL.mjs.map +1 -0
- package/dist/chunks/DrawerButton.vue_vue_type_script_setup_true_lang-DUda4p7_.mjs +125 -0
- package/dist/chunks/DrawerButton.vue_vue_type_script_setup_true_lang-DUda4p7_.mjs.map +1 -0
- package/dist/chunks/EditableGrid-C8A-nJZv.mjs +1783 -0
- package/dist/chunks/EditableGrid-C8A-nJZv.mjs.map +1 -0
- package/dist/chunks/FormItem-C1q0opnk.mjs +79 -0
- package/dist/chunks/FormItem-C1q0opnk.mjs.map +1 -0
- package/dist/chunks/Iframe-CeSiMnvR.mjs +65 -0
- package/dist/chunks/Iframe-CeSiMnvR.mjs.map +1 -0
- package/dist/chunks/ImageUpload-DGehzaYa.mjs +193 -0
- package/dist/chunks/ImageUpload-DGehzaYa.mjs.map +1 -0
- package/dist/chunks/Panel-CrRqBTj6.mjs +115 -0
- package/dist/chunks/Panel-CrRqBTj6.mjs.map +1 -0
- package/dist/chunks/PromptButton.vue_vue_type_script_setup_true_lang-Gck1QAHc.mjs +118 -0
- package/dist/chunks/PromptButton.vue_vue_type_script_setup_true_lang-Gck1QAHc.mjs.map +1 -0
- package/dist/chunks/RadioList-vE8JOuST.mjs +129 -0
- package/dist/chunks/RadioList-vE8JOuST.mjs.map +1 -0
- package/dist/chunks/Requester.vue_vue_type_script_setup_true_lang-B8TwXbYR.mjs +80 -0
- package/dist/chunks/Requester.vue_vue_type_script_setup_true_lang-B8TwXbYR.mjs.map +1 -0
- package/dist/chunks/RouteButton.vue_vue_type_script_setup_true_lang-Da0D3tKA.mjs +73 -0
- package/dist/chunks/RouteButton.vue_vue_type_script_setup_true_lang-Da0D3tKA.mjs.map +1 -0
- package/dist/chunks/SearchItem-pFO57lEO.mjs +79 -0
- package/dist/chunks/SearchItem-pFO57lEO.mjs.map +1 -0
- package/dist/chunks/SearchPanel-xQ1hPaNq.mjs +158 -0
- package/dist/chunks/SearchPanel-xQ1hPaNq.mjs.map +1 -0
- package/dist/chunks/Select-DAGZDXvI.mjs +114 -0
- package/dist/chunks/Select-DAGZDXvI.mjs.map +1 -0
- package/dist/chunks/Station-BF_QlQ8c.mjs +796 -0
- package/dist/chunks/Station-BF_QlQ8c.mjs.map +1 -0
- package/dist/chunks/Switch.vue_vue_type_script_setup_true_lang-CulPqp7M.mjs +71 -0
- package/dist/chunks/Switch.vue_vue_type_script_setup_true_lang-CulPqp7M.mjs.map +1 -0
- package/dist/chunks/Tips-IWCZcR1K.mjs +63 -0
- package/dist/chunks/Tips-IWCZcR1K.mjs.map +1 -0
- package/dist/chunks/TipsButton.vue_vue_type_script_setup_true_lang-DvcpRSV1.mjs +51 -0
- package/dist/chunks/TipsButton.vue_vue_type_script_setup_true_lang-DvcpRSV1.mjs.map +1 -0
- package/dist/chunks/Upload.vue_vue_type_script_setup_true_lang-D07Bhllc.mjs +200 -0
- package/dist/chunks/Upload.vue_vue_type_script_setup_true_lang-D07Bhllc.mjs.map +1 -0
- package/dist/chunks/Viewer-iub6TjoD.mjs +381 -0
- package/dist/chunks/Viewer-iub6TjoD.mjs.map +1 -0
- package/dist/chunks/_plugin-vue_export-helper-CHgC5LLL.mjs +10 -0
- package/dist/chunks/_plugin-vue_export-helper-CHgC5LLL.mjs.map +1 -0
- package/dist/chunks/containerContext-BgphFDeH.mjs +13 -0
- package/dist/chunks/containerContext-BgphFDeH.mjs.map +1 -0
- package/dist/chunks/http-Bs-dM076.mjs +2951 -0
- package/dist/chunks/http-Bs-dM076.mjs.map +1 -0
- package/dist/chunks/linkage-FbL1mcz3.mjs +66 -0
- package/dist/chunks/linkage-FbL1mcz3.mjs.map +1 -0
- package/dist/chunks/props-DAytpx7D.mjs +65 -0
- package/dist/chunks/props-DAytpx7D.mjs.map +1 -0
- package/dist/chunks/useApiAction-6_vvf5Fd.mjs +30 -0
- package/dist/chunks/useApiAction-6_vvf5Fd.mjs.map +1 -0
- package/dist/chunks/useColumnSettings-BYDQdk4o.mjs +216 -0
- package/dist/chunks/useColumnSettings-BYDQdk4o.mjs.map +1 -0
- package/dist/chunks/useOptionsLoader-Bi8oqNbG.mjs +64 -0
- package/dist/chunks/useOptionsLoader-Bi8oqNbG.mjs.map +1 -0
- package/dist/confirm-button/index.mjs +7 -0
- package/dist/confirm-button/index.mjs.map +1 -0
- package/dist/data-form/index.mjs +7 -0
- package/dist/data-form/index.mjs.map +1 -0
- package/dist/data-form/style.css +1 -0
- package/dist/data-grid/index.mjs +7 -0
- package/dist/data-grid/index.mjs.map +1 -0
- package/dist/data-grid/style.css +1 -0
- package/dist/dialog-button/index.mjs +7 -0
- package/dist/dialog-button/index.mjs.map +1 -0
- package/dist/drawer/index.mjs +7 -0
- package/dist/drawer/index.mjs.map +1 -0
- package/dist/drawer/style.css +1 -0
- package/dist/drawer-button/index.mjs +7 -0
- package/dist/drawer-button/index.mjs.map +1 -0
- package/dist/editable-grid/index.mjs +7 -0
- package/dist/editable-grid/index.mjs.map +1 -0
- package/dist/editable-grid/style.css +1 -0
- package/dist/form-item/index.mjs +7 -0
- package/dist/form-item/index.mjs.map +1 -0
- package/dist/form-item/style.css +1 -0
- package/dist/iframe/index.mjs +7 -0
- package/dist/iframe/index.mjs.map +1 -0
- package/dist/iframe/style.css +1 -0
- package/dist/image-upload/index.mjs +7 -0
- package/dist/image-upload/index.mjs.map +1 -0
- package/dist/image-upload/style.css +1 -0
- package/dist/index.esm.js +318 -6495
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +20 -9
- package/dist/index.umd.js.map +1 -1
- package/dist/panel/index.mjs +7 -0
- package/dist/panel/index.mjs.map +1 -0
- package/dist/panel/style.css +1 -0
- package/dist/prompt-button/index.mjs +7 -0
- package/dist/prompt-button/index.mjs.map +1 -0
- package/dist/radio-list/index.mjs +7 -0
- package/dist/radio-list/index.mjs.map +1 -0
- package/dist/radio-list/style.css +1 -0
- package/dist/requester/index.mjs +7 -0
- package/dist/requester/index.mjs.map +1 -0
- package/dist/route-button/index.mjs +7 -0
- package/dist/route-button/index.mjs.map +1 -0
- package/dist/search-item/index.mjs +7 -0
- package/dist/search-item/index.mjs.map +1 -0
- package/dist/search-item/style.css +1 -0
- package/dist/search-panel/index.mjs +7 -0
- package/dist/search-panel/index.mjs.map +1 -0
- package/dist/search-panel/style.css +1 -0
- package/dist/select/index.mjs +7 -0
- package/dist/select/index.mjs.map +1 -0
- package/dist/station/index.mjs +7 -0
- package/dist/station/index.mjs.map +1 -0
- package/dist/station/style.css +1 -0
- package/dist/style.css +1 -1
- package/dist/switch/index.mjs +7 -0
- package/dist/switch/index.mjs.map +1 -0
- package/dist/tips/index.mjs +7 -0
- package/dist/tips/index.mjs.map +1 -0
- package/dist/tips/style.css +1 -0
- package/dist/tips-button/index.mjs +7 -0
- package/dist/tips-button/index.mjs.map +1 -0
- package/dist/types/src/components/buttons/ApiButton.vue.d.ts +35 -6
- package/dist/types/src/components/buttons/ConfirmButton.vue.d.ts +37 -8
- package/dist/types/src/components/buttons/DialogButton.vue.d.ts +89 -29
- package/dist/types/src/components/buttons/DrawerButton.vue.d.ts +99 -31
- package/dist/types/src/components/buttons/PopconfirmButton.vue.d.ts +317 -0
- package/dist/types/src/components/buttons/PromptButton.vue.d.ts +45 -14
- package/dist/types/src/components/buttons/RouteButton.vue.d.ts +34 -5
- package/dist/types/src/components/buttons/TipsButton.vue.d.ts +8 -15
- package/dist/types/src/components/common/props.d.ts +32 -2
- package/dist/types/src/components/containers/Drawer.vue.d.ts +61 -8
- package/dist/types/src/components/containers/Iframe.vue.d.ts +39 -2
- package/dist/types/src/components/containers/containerContext.d.ts +1 -1
- package/dist/types/src/components/containers/useContainerController.d.ts +5 -0
- package/dist/types/src/components/containers/useIframeContainer.d.ts +20 -0
- package/dist/types/src/components/core/Requester.vue.d.ts +41 -0
- package/dist/types/src/components/data/datagrid/DataGrid.vue.d.ts +212 -5
- package/dist/types/src/components/data/datagrid/useColumnSettings.d.ts +14 -0
- package/dist/types/src/components/data/editable-grid/EditableGrid.vue.d.ts +586 -0
- package/dist/types/src/components/data/viewer/Viewer.vue.d.ts +187 -0
- package/dist/types/src/components/form/FormItem.vue.d.ts +62 -0
- package/dist/types/src/components/form/SearchItem.vue.d.ts +62 -0
- package/dist/types/src/components/{containers → form}/SearchPanel.vue.d.ts +17 -2
- package/dist/types/src/components/form/data-form/DataForm.vue.d.ts +6 -6
- package/dist/types/src/components/index.d.ts +10 -6
- package/dist/types/src/components/inputs/AutoComplete.vue.d.ts +10 -1
- package/dist/types/src/components/inputs/CheckboxList.vue.d.ts +28 -3
- package/dist/types/src/components/inputs/RadioList.vue.d.ts +28 -3
- package/dist/types/src/components/inputs/Select.vue.d.ts +11 -1
- package/dist/types/src/components/inputs/Switch.vue.d.ts +2 -2
- package/dist/types/src/components/inputs/useOptionsLoader.d.ts +3 -0
- package/dist/types/src/components/layout/Station.vue.d.ts +302 -0
- package/dist/types/src/components/layout/StationMenuNode.vue.d.ts +20 -0
- package/dist/types/src/components/layout/types.d.ts +54 -0
- package/dist/types/src/components/styles/Panel.vue.d.ts +58 -5
- package/dist/types/src/components/upload/ImageUpload.vue.d.ts +4 -4
- package/dist/types/src/components/upload/Upload.vue.d.ts +1 -1
- package/dist/types/src/entries/api-button.d.ts +9 -0
- package/dist/types/src/entries/auto-complete.d.ts +9 -0
- package/dist/types/src/entries/checkbox-list.d.ts +9 -0
- package/dist/types/src/entries/components-map.d.ts +8 -0
- package/dist/types/src/entries/confirm-button.d.ts +9 -0
- package/dist/types/src/entries/data-form.d.ts +9 -0
- package/dist/types/src/entries/data-grid.d.ts +9 -0
- package/dist/types/src/entries/dialog-button.d.ts +9 -0
- package/dist/types/src/entries/drawer-button.d.ts +9 -0
- package/dist/types/src/entries/drawer.d.ts +9 -0
- package/dist/types/src/entries/editable-grid.d.ts +9 -0
- package/dist/types/src/entries/form-item.d.ts +9 -0
- package/dist/types/src/entries/iframe.d.ts +9 -0
- package/dist/types/src/entries/image-upload.d.ts +9 -0
- package/dist/types/src/entries/panel.d.ts +9 -0
- package/dist/types/src/entries/prompt-button.d.ts +9 -0
- package/dist/types/src/entries/radio-list.d.ts +9 -0
- package/dist/types/src/entries/requester.d.ts +9 -0
- package/dist/types/src/entries/route-button.d.ts +9 -0
- package/dist/types/src/entries/search-item.d.ts +9 -0
- package/dist/types/src/entries/search-panel.d.ts +9 -0
- package/dist/types/src/entries/select.d.ts +9 -0
- package/dist/types/src/entries/station.d.ts +9 -0
- package/dist/types/src/entries/switch.d.ts +9 -0
- package/dist/types/src/entries/tips-button.d.ts +9 -0
- package/dist/types/src/entries/tips.d.ts +9 -0
- package/dist/types/src/entries/upload.d.ts +9 -0
- package/dist/types/src/entries/viewer.d.ts +9 -0
- package/dist/types/src/index.d.ts +2 -1
- package/dist/types/src/lib/composables/useDataGrid.d.ts +15 -0
- package/dist/types/src/lib/core/http.d.ts +21 -4
- package/dist/types/src/lib/core/station-linkage.d.ts +41 -0
- package/dist/types/src/types/config.d.ts +20 -3
- package/dist/types/vite.config.d.ts +6 -1
- package/dist/upload/index.mjs +7 -0
- package/dist/upload/index.mjs.map +1 -0
- package/dist/viewer/index.mjs +7 -0
- package/dist/viewer/index.mjs.map +1 -0
- package/dist/viewer/style.css +1 -0
- package/llms.txt +658 -0
- package/package.json +200 -68
- package/dist/types/src/components/containers/Dialog.vue.d.ts +0 -112
- package/dist/types/src/components/data/editable-table/EditableTable.vue.d.ts +0 -306
- package/dist/types/src/components/utils/Viewer.vue.d.ts +0 -131
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { shallowRef as g, onMounted as b, defineComponent as q, watch as C, onUnmounted as h, renderSlot as v } from "vue";
|
|
2
|
+
import { a as w, g as R, d as _, r as c } from "./http-Bs-dM076.mjs";
|
|
3
|
+
function O(n, s) {
|
|
4
|
+
const e = g(p(n, s));
|
|
5
|
+
return b(() => {
|
|
6
|
+
e.value = p(n, s);
|
|
7
|
+
}), e;
|
|
8
|
+
}
|
|
9
|
+
function x() {
|
|
10
|
+
return w();
|
|
11
|
+
}
|
|
12
|
+
function p(n, s) {
|
|
13
|
+
const e = n ? R(n) : {}, r = {};
|
|
14
|
+
if (s)
|
|
15
|
+
for (const [a, t] of Object.entries(s))
|
|
16
|
+
t !== void 0 && (r[a] = t);
|
|
17
|
+
return _({}, e, r);
|
|
18
|
+
}
|
|
19
|
+
const A = /* @__PURE__ */ q({
|
|
20
|
+
name: "WdRequester",
|
|
21
|
+
__name: "Requester",
|
|
22
|
+
props: {
|
|
23
|
+
modelValue: { type: Boolean },
|
|
24
|
+
url: {},
|
|
25
|
+
method: {},
|
|
26
|
+
params: {},
|
|
27
|
+
reqOptions: {}
|
|
28
|
+
},
|
|
29
|
+
emits: ["update:modelValue", "api-before", "api-success", "api-fail", "api-exception", "api-after"],
|
|
30
|
+
setup(n, { emit: s }) {
|
|
31
|
+
const e = n, r = O("WdRequester", e), a = s;
|
|
32
|
+
let t = null;
|
|
33
|
+
function d() {
|
|
34
|
+
t == null || t.abort();
|
|
35
|
+
}
|
|
36
|
+
function u() {
|
|
37
|
+
t && (t.abort(), t = null);
|
|
38
|
+
}
|
|
39
|
+
async function m() {
|
|
40
|
+
u();
|
|
41
|
+
const o = new AbortController();
|
|
42
|
+
t = o;
|
|
43
|
+
const f = {
|
|
44
|
+
...r.value.reqOptions || {},
|
|
45
|
+
...e.reqOptions || {},
|
|
46
|
+
signal: o.signal
|
|
47
|
+
};
|
|
48
|
+
try {
|
|
49
|
+
if (a("api-before", d), o.signal.aborted)
|
|
50
|
+
return;
|
|
51
|
+
let i;
|
|
52
|
+
const l = (e.method ?? r.value.method ?? "post").toLowerCase();
|
|
53
|
+
if (l === "get" || l === "delete" ? i = await c[l](e.url, e.params, f) : i = await c[l](e.url, e.params, f), o.signal.aborted)
|
|
54
|
+
return;
|
|
55
|
+
i.success ? a("api-success", i) : a("api-fail", i);
|
|
56
|
+
} catch (i) {
|
|
57
|
+
if (o.signal.aborted)
|
|
58
|
+
return;
|
|
59
|
+
a("api-exception", i);
|
|
60
|
+
} finally {
|
|
61
|
+
t === o && (t = null, a("api-after"), a("update:modelValue", !1));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return C(
|
|
65
|
+
() => e.modelValue,
|
|
66
|
+
(o) => {
|
|
67
|
+
o === !0 ? m() : u();
|
|
68
|
+
},
|
|
69
|
+
{ immediate: !0 }
|
|
70
|
+
), h(() => {
|
|
71
|
+
u();
|
|
72
|
+
}), (o, f) => v(o.$slots, "default");
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
export {
|
|
76
|
+
A as _,
|
|
77
|
+
x as a,
|
|
78
|
+
O as u
|
|
79
|
+
};
|
|
80
|
+
//# sourceMappingURL=Requester.vue_vue_type_script_setup_true_lang-B8TwXbYR.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Requester.vue_vue_type_script_setup_true_lang-B8TwXbYR.mjs","sources":["../../src/lib/composables/useConfig.ts","../../src/components/core/Requester.vue"],"sourcesContent":["import { onMounted, shallowRef } from 'vue'\nimport { getGlobalConfig, getComponentDefault } from '../core/config'\nimport { deepMerge } from '../core/utils'\nimport type { WorkDesktopConfig } from '../../types/config'\n\n/**\n * useConfig(PRD 5.3 / 5.2)\n *\n * 组件内合并三级配置:全局 componentDefault[组件名] → 本地 props。\n * 全局配置在组件 onMounted 时读取一次并缓存(运行中改配置只影响新挂载组件)。\n *\n * 返回一个响应式 ref,merge 后的组件配置对象:\n * componentDefault 的值作为默认,props 中非 undefined 的值覆盖。\n *\n * @example\n * const cfg = useConfig('WdDataGrid', props)\n * cfg.value.withPager\n */\nexport function useConfig<T extends Record<string, any> = Record<string, any>>(\n componentName?: string,\n props?: T\n) {\n const configRef = shallowRef<T>(buildComponentConfig<T>(componentName, props))\n\n onMounted(() => {\n // onMounted 时 install 已完成、window.workDesktopConfig 已就绪,再读一次\n configRef.value = buildComponentConfig<T>(componentName, props)\n })\n\n return configRef\n}\n\n/**\n * 非响应式:直接取当前全局 WorkDesktopConfig\n */\nexport function useGlobalConfig(): WorkDesktopConfig {\n return getGlobalConfig()\n}\n\nfunction buildComponentConfig<T extends Record<string, any>>(\n componentName?: string,\n props?: T\n): T {\n const componentDefaults = componentName ? getComponentDefault(componentName) : {}\n const localProps: Record<string, any> = {}\n if (props) {\n for (const [k, v] of Object.entries(props)) {\n if (v !== undefined) localProps[k] = v\n }\n }\n // 优先级:componentDefault < 本地 props\n return deepMerge<T>({} as T, componentDefaults, localProps)\n}\n","<template>\n <!-- 无默认插槽 -->\n <slot></slot>\n</template>\n\n<script setup lang=\"ts\">\n/**\n * WdRequester 请求触发组件\n *\n * 使用 v-model 控制请求触发:开关变为 true 时发起请求;请求完成后自动设置为 false,\n * 等待开发者下一次将它变为 true 再触发。所有组件都基于本库公开请求核心 RequestAPI。\n *\n * 特性:\n * 1. 封装 get/post/put/delete/request 全部请求方法;\n * 2. 全周期 emit 事件:apiBefore 触发后允许开发者手动 abort 请求;\n * 3. 支持中途发起新请求:旧请求会自动被中断;\n * 4. 请求完成(成功/失败/异常)后自动将 v-model 置为 false;\n *\n * @example\n * <template>\n * <wd-requester\n * v-model=\"trigger\"\n * url=\"/api/save\"\n * method=\"post\"\n * @api-before=\"onApiBefore\"\n * @api-success=\"onSuccess\"\n * />\n * <el-button @click=\"trigger = true\">提交</el-button>\n * </template>\n */\nimport { onUnmounted, watch } from 'vue'\nimport { request, type ApiResult } from '../../lib/core/http'\nimport type { Method } from 'axios'\nimport type { ReqOptions } from '../../types/config'\nimport { useConfig } from '../../lib/composables/useConfig'\n\ndefineOptions({ name: 'WdRequester' })\n\ninterface Props {\n /** v-model 触发开关:true 则发起请求,完成后自动变 false */\n modelValue: boolean\n /** 请求 URL */\n url: string\n /** 请求方法,默认 post(可通过全局配置 page.componentDefault.WdRequester.method 覆盖) */\n method?: Method\n /** 请求参数(get/delete 放 query,post/put 放 body) */\n params?: any\n /** 请求选项(透传给 http):showLoading/showTips/tipsConfig/axiosConfig/signal(可通过全局配置 page.componentDefault.WdRequester.reqOptions 覆盖) */\n reqOptions?: ReqOptions\n}\n\nconst props = defineProps<Props>()\n\n// 合并三级配置:默认层(default-config 的 WdRequester)→ 全局层(componentDefault)→ 本地 props\n// 注意:url/params 属业务参数,实时读 props;method/reqOptions 属配置类,走合并结果\nconst config = useConfig<Record<string, any>>('WdRequester', props)\n\ninterface Emits {\n (e: 'update:modelValue', value: boolean): void\n (e: 'api-before', abort: () => void): void\n (e: 'api-success', result: ApiResult): void\n (e: 'api-fail', result: ApiResult): void\n (e: 'api-exception', error: any): void\n (e: 'api-after'): void\n}\n\nconst emit = defineEmits<Emits>()\n\nlet currentController: AbortController | null = null\n\n/**\n * 仅中断当前进行中的请求(不清引用)。\n * 传给 apiBefore 的 abort:中断后本请求仍走 finally 收尾(api-after + 复位开关)。\n */\nfunction abortActive() {\n currentController?.abort()\n}\n\n/**\n * 中断并清引用:用于外部关闭开关 / 组件卸载,不触发收尾事件。\n */\nfunction abortAndClear() {\n if (currentController) {\n currentController.abort()\n currentController = null\n }\n}\n\nasync function doRequest() {\n // 中断并清掉上一次请求(旧请求的收尾会被跳过,不触发 api-after)\n abortAndClear()\n\n const controller = new AbortController()\n currentController = controller\n\n // 组装请求选项:全局默认(reqOptions)→ 实例 props 覆盖 → 注入 abort signal\n const reqOpts: ReqOptions = {\n ...(config.value.reqOptions || {}),\n ...(props.reqOptions || {}),\n signal: controller.signal,\n }\n\n try {\n // 触发 apiBefore,允许开发者在事件中手动调用 abort() 中断本次请求\n emit('api-before', abortActive)\n\n // 如果在 apiBefore 中被手动中断:直接走收尾(api-after + 复位开关)\n if (controller.signal.aborted) {\n return\n }\n\n let result: ApiResult\n // 请求方法优先级:实例 props.method → 全局默认 config.method → 内置兜底 'post'\n const method = (props.method ?? config.value.method ?? 'post').toLowerCase() as 'get' | 'post' | 'put' | 'delete'\n\n if (method === 'get' || method === 'delete') {\n result = await request[method](props.url, props.params, reqOpts)\n } else {\n result = await request[method](props.url, props.params, reqOpts)\n }\n\n if (controller.signal.aborted) {\n // 已被中断,无需后续处理\n return\n }\n\n if (result.success) {\n emit('api-success', result)\n } else {\n emit('api-fail', result)\n }\n } catch (e) {\n if (controller.signal.aborted) {\n return\n }\n emit('api-exception', e)\n } finally {\n if (currentController === controller) {\n currentController = null\n emit('api-after')\n // 自动关闭触发开关\n emit('update:modelValue', false)\n }\n }\n}\n\n// 监听 v-model 开关:变为 true 就发起请求\nwatch(\n () => props.modelValue,\n (newVal) => {\n if (newVal === true) {\n doRequest()\n } else {\n // 外部关闭开关:中断进行中的请求(不触发收尾事件)\n abortAndClear()\n }\n },\n { immediate: true }\n)\n\nonUnmounted(() => {\n abortAndClear()\n})\n</script>\n\n<style scoped>\n</style>\n"],"names":["useConfig","componentName","props","configRef","shallowRef","buildComponentConfig","onMounted","useGlobalConfig","getGlobalConfig","componentDefaults","getComponentDefault","localProps","k","v","deepMerge","__props","config","emit","__emit","currentController","abortActive","abortAndClear","doRequest","controller","reqOpts","result","method","request","e","watch","newVal","onUnmounted","_renderSlot","_ctx"],"mappings":";;AAkBO,SAASA,EACdC,GACAC,GACA;AACA,QAAMC,IAAYC,EAAcC,EAAwBJ,GAAeC,CAAK,CAAC;AAE7E,SAAAI,EAAU,MAAM;AAEd,IAAAH,EAAU,QAAQE,EAAwBJ,GAAeC,CAAK;AAAA,EAChE,CAAC,GAEMC;AACT;AAKO,SAASI,IAAqC;AACnD,SAAOC,EAAA;AACT;AAEA,SAASH,EACPJ,GACAC,GACG;AACH,QAAMO,IAAoBR,IAAgBS,EAAoBT,CAAa,IAAI,CAAA,GACzEU,IAAkC,CAAA;AACxC,MAAIT;AACF,eAAW,CAACU,GAAGC,CAAC,KAAK,OAAO,QAAQX,CAAK;AACvC,MAAIW,MAAM,WAAWF,EAAWC,CAAC,IAAIC;AAIzC,SAAOC,EAAa,CAAA,GAASL,GAAmBE,CAAU;AAC5D;;;;;;;;;;;;;ACDA,UAAMT,IAAQa,GAIRC,IAAShB,EAA+B,eAAeE,CAAK,GAW5De,IAAOC;AAEb,QAAIC,IAA4C;AAMhD,aAASC,IAAc;AACrB,MAAAD,KAAA,QAAAA,EAAmB;AAAA,IACrB;AA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
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { defineComponent as $, getCurrentInstance as q, resolveComponent as c, openBlock as m, createBlock as d, withCtx as u, createVNode as S, mergeProps as y, renderSlot as b, createTextVNode as h, toDisplayString as g } from "vue";
|
|
2
|
+
import { t as w, b as C, f as N } from "./props-DAytpx7D.mjs";
|
|
3
|
+
const T = /* @__PURE__ */ $({
|
|
4
|
+
name: "WdRouteButton",
|
|
5
|
+
inheritAttrs: !1,
|
|
6
|
+
__name: "RouteButton",
|
|
7
|
+
props: {
|
|
8
|
+
...N,
|
|
9
|
+
...C,
|
|
10
|
+
...w,
|
|
11
|
+
/** 路由 name(与 routePath 二选一) */
|
|
12
|
+
routeName: { type: String, default: "" },
|
|
13
|
+
/** 路由 path */
|
|
14
|
+
routePath: { type: String, default: "" },
|
|
15
|
+
/** 路由 params */
|
|
16
|
+
params: { type: Object, default: () => ({}) },
|
|
17
|
+
/** 路由 query */
|
|
18
|
+
query: { type: Object, default: () => ({}) },
|
|
19
|
+
/** 打开方式 */
|
|
20
|
+
target: { type: String, default: "_self" }
|
|
21
|
+
},
|
|
22
|
+
emits: ["click"],
|
|
23
|
+
setup(P, { emit: k }) {
|
|
24
|
+
const t = P, _ = k, r = q();
|
|
25
|
+
function l(e) {
|
|
26
|
+
var n, a, s, i;
|
|
27
|
+
if (_("click", e), !t.routeName && !t.routePath) return;
|
|
28
|
+
if (t.target === "_blank") {
|
|
29
|
+
const f = p();
|
|
30
|
+
f && window.open(f, "_blank");
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const o = ((n = r == null ? void 0 : r.proxy) == null ? void 0 : n.$router) || ((i = (s = (a = r == null ? void 0 : r.appContext) == null ? void 0 : a.config) == null ? void 0 : s.globalProperties) == null ? void 0 : i.$router);
|
|
34
|
+
o ? t.routeName ? o.push({ name: t.routeName, params: t.params, query: t.query }) : o.push({ path: t.routePath, query: t.query }) : t.routePath && (window.location.href = p());
|
|
35
|
+
}
|
|
36
|
+
function p() {
|
|
37
|
+
const e = t.routePath || "", o = new URLSearchParams(t.query).toString();
|
|
38
|
+
return o ? `${e}?${o}` : e;
|
|
39
|
+
}
|
|
40
|
+
return (e, o) => {
|
|
41
|
+
const n = c("el-button"), a = c("el-tooltip");
|
|
42
|
+
return e.tips ? (m(), d(a, {
|
|
43
|
+
key: 0,
|
|
44
|
+
content: e.tips,
|
|
45
|
+
effect: e.tipsType,
|
|
46
|
+
placement: e.placement
|
|
47
|
+
}, {
|
|
48
|
+
default: u(() => [
|
|
49
|
+
S(n, y(e.$attrs, { onClick: l }), {
|
|
50
|
+
default: u(() => [
|
|
51
|
+
b(e.$slots, "default", {}, () => [
|
|
52
|
+
h(g(e.label), 1)
|
|
53
|
+
])
|
|
54
|
+
]),
|
|
55
|
+
_: 3
|
|
56
|
+
}, 16)
|
|
57
|
+
]),
|
|
58
|
+
_: 3
|
|
59
|
+
}, 8, ["content", "effect", "placement"])) : (m(), d(n, y({ key: 1 }, e.$attrs, { onClick: l }), {
|
|
60
|
+
default: u(() => [
|
|
61
|
+
b(e.$slots, "default", {}, () => [
|
|
62
|
+
h(g(e.label), 1)
|
|
63
|
+
])
|
|
64
|
+
]),
|
|
65
|
+
_: 3
|
|
66
|
+
}, 16));
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
export {
|
|
71
|
+
T as _
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=RouteButton.vue_vue_type_script_setup_true_lang-Da0D3tKA.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RouteButton.vue_vue_type_script_setup_true_lang-Da0D3tKA.mjs","sources":["../../src/components/buttons/RouteButton.vue"],"sourcesContent":["<template>\r\n <el-tooltip\r\n v-if=\"tips\"\r\n :content=\"tips\"\r\n :effect=\"tipsType\"\r\n :placement=\"placement\"\r\n >\r\n <el-button v-bind=\"$attrs\" @click=\"onClick\">\r\n <slot>{{ label }}</slot>\r\n </el-button>\r\n </el-tooltip>\r\n <el-button v-else v-bind=\"$attrs\" @click=\"onClick\">\r\n <slot>{{ label }}</slot>\r\n </el-button>\r\n</template>\r\n\r\n<script setup lang=\"ts\">\r\nimport { getCurrentInstance, type PropType } from 'vue'\r\nimport { filterProp, buttonTextProp, tipsProp } from '../common/props'\r\n\r\ndefineOptions({ name: 'WdRouteButton', inheritAttrs: false })\r\n\r\nconst props = defineProps({\r\n ...filterProp,\r\n ...buttonTextProp,\r\n ...tipsProp,\r\n /** 路由 name(与 routePath 二选一) */\r\n routeName: { type: String, default: '' },\r\n /** 路由 path */\r\n routePath: { type: String, default: '' },\r\n /** 路由 params */\r\n params: { type: Object as PropType<Record<string, any>>, default: () => ({}) },\r\n /** 路由 query */\r\n query: { type: Object as PropType<Record<string, any>>, default: () => ({}) },\r\n /** 打开方式 */\r\n target: { type: String as PropType<'_self' | '_blank'>, default: '_self' }\r\n})\r\n\r\nconst emit = defineEmits(['click'])\r\n\r\nconst instance = getCurrentInstance()\r\n\r\nfunction onClick(event: MouseEvent) {\r\n emit('click', event)\r\n\r\n // 无路由配置:仅触发 click\r\n if (!props.routeName && !props.routePath) return\r\n\r\n // 新窗口:拼 URL 后 window.open\r\n if (props.target === '_blank') {\r\n const url = buildUrl()\r\n if (url) window.open(url, '_blank')\r\n return\r\n }\r\n\r\n // 当前窗口:优先走 vue-router(inject $router / globalProperties.$router)\r\n const router =\r\n (instance?.proxy as any)?.$router ||\r\n instance?.appContext?.config?.globalProperties?.$router\r\n if (router) {\r\n if (props.routeName) {\r\n router.push({ name: props.routeName, params: props.params, query: props.query })\r\n } else {\r\n router.push({ path: props.routePath, query: props.query })\r\n }\r\n } else if (props.routePath) {\r\n // 无 router 环境:退化到 location\r\n window.location.href = buildUrl()\r\n }\r\n}\r\n\r\nfunction buildUrl(): string {\r\n const base = props.routePath || ''\r\n const qs = new URLSearchParams(props.query as Record<string, string>).toString()\r\n return qs ? `${base}?${qs}` : base\r\n}\r\n</script>\r\n"],"names":["props","__props","emit","__emit","instance","getCurrentInstance","onClick","event","url","buildUrl","router","_a","_d","_c","_b","base","qs","tips","_createBlock","_component_el_tooltip","tipsType","placement","_createVNode","_component_el_button","_mergeProps","_ctx","_renderSlot","label","_openBlock","$attrs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAsBA,UAAMA,IAAQC,GAgBRC,IAAOC,GAEPC,IAAWC,EAAA;AAEjB,aAASC,EAAQC,GAAmB;;AAIlC,UAHAL,EAAK,SAASK,CAAK,GAGf,CAACP,EAAM,aAAa,CAACA,EAAM,UAAW;AAG1C,UAAIA,EAAM,WAAW,UAAU;AAC7B,cAAMQ,IAAMC,EAAA;AACZ,QAAID,KAAK,OAAO,KAAKA,GAAK,QAAQ;AAClC;AAAA,MACF;AAGA,YAAME,MACHC,IAAAP,KAAA,gBAAAA,EAAU,UAAV,gBAAAO,EAAyB,cAC1BC,KAAAC,KAAAC,IAAAV,KAAA,gBAAAA,EAAU,eAAV,gBAAAU,EAAsB,WAAtB,gBAAAD,EAA8B,qBAA9B,gBAAAD,EAAgD;AAClD,MAAIF,IACEV,EAAM,YACRU,EAAO,KAAK,EAAE,MAAMV,EAAM,WAAW,QAAQA,EAAM,QAAQ,OAAOA,EAAM,MAAA,CAAO,IAE/EU,EAAO,KAAK,EAAE,MAAMV,EAAM,WAAW,OAAOA,EAAM,OAAO,IAElDA,EAAM,cAEf,OAAO,SAAS,OAAOS,EAAA;AAAA,IAE3B;AAEA,aAASA,IAAmB;AAC1B,YAAMM,IAAOf,EAAM,aAAa,IAC1BgB,IAAK,IAAI,gBAAgBhB,EAAM,KAA+B,EAAE,SAAA;AACtE,aAAOgB,IAAK,GAAGD,CAAI,IAAIC,CAAE,KAAKD;AAAA,IAChC;;;aAzEUE,EAAAA,aADRC,EASaC,GAAA;AAAA;QAPV,SAASF,EAAAA;AAAAA,QACT,QAAQG,EAAAA;AAAAA,QACR,WAAWC,EAAAA;AAAAA,MAAAA;mBAEZ,MAEY;AAAA,UAFZC,EAEYC,GAFZC,EAEYC,UAFa,EAAG,SAAAnB,EAAA,CAAc,GAAA;AAAA,uBACxC,MAAwB;AAAA,cAAxBoB,EAAwBD,yBAAxB,MAAwB;AAAA,oBAAfE,EAAAA,KAAK,GAAA,CAAA;AAAA,cAAA;;;;;;oDAGlBC,EAAA,GAAAV,EAEYK,GAFZC,EAEY,EAAA,KAAA,EAAA,GAFcK,UAAM,EAAG,SAAAvB,EAAA,CAAc,GAAA;AAAA,mBAC/C,MAAwB;AAAA,UAAxBoB,EAAwBD,yBAAxB,MAAwB;AAAA,gBAAfE,EAAAA,KAAK,GAAA,CAAA;AAAA,UAAA;;;;;;;"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { defineComponent as _, useSlots as h, computed as b, resolveComponent as o, openBlock as s, createBlock as c, mergeProps as S, createSlots as w, withCtx as t, renderSlot as r, createElementVNode as a, createTextVNode as y, toDisplayString as g, createVNode as i, unref as k, createCommentVNode as v } from "vue";
|
|
2
|
+
import { QuestionFilled as C } from "@element-plus/icons-vue";
|
|
3
|
+
import { _ as I } from "./_plugin-vue_export-helper-CHgC5LLL.mjs";
|
|
4
|
+
const N = { class: "wd-search-item__label" }, V = { class: "wd-search-item__title" }, x = {
|
|
5
|
+
class: "wd-search-item__tip",
|
|
6
|
+
tabindex: "0",
|
|
7
|
+
role: "note",
|
|
8
|
+
"aria-label": "帮助说明"
|
|
9
|
+
}, P = /* @__PURE__ */ _({
|
|
10
|
+
name: "WdSearchItem",
|
|
11
|
+
inheritAttrs: !1,
|
|
12
|
+
__name: "SearchItem",
|
|
13
|
+
props: {
|
|
14
|
+
/** 字段标签文字 */
|
|
15
|
+
label: { type: String, default: "" },
|
|
16
|
+
/** 绑定字段名(对应查询 model 的 key,如姓名→model.name) */
|
|
17
|
+
prop: { type: String, default: "" },
|
|
18
|
+
/** 帮助说明:提供时 label 右侧自动出现带问号的图标,鼠标悬停显示说明;不传则不显示图标 */
|
|
19
|
+
tip: { type: String, default: "" },
|
|
20
|
+
/** 帮助气泡的弹出位置 */
|
|
21
|
+
tipPlacement: {
|
|
22
|
+
type: String,
|
|
23
|
+
default: "top"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
setup(e) {
|
|
27
|
+
const n = e, m = h(), p = b(() => !!(n.label || m.label || n.tip));
|
|
28
|
+
return (l, W) => {
|
|
29
|
+
const d = o("el-icon"), f = o("el-tooltip"), u = o("el-form-item");
|
|
30
|
+
return s(), c(u, S({
|
|
31
|
+
class: ["wd-search-item", { "is-help": !!e.tip }],
|
|
32
|
+
label: e.label,
|
|
33
|
+
prop: e.prop
|
|
34
|
+
}, l.$attrs), w({
|
|
35
|
+
default: t(() => [
|
|
36
|
+
r(l.$slots, "default", {}, void 0, !0)
|
|
37
|
+
]),
|
|
38
|
+
_: 2
|
|
39
|
+
}, [
|
|
40
|
+
p.value ? {
|
|
41
|
+
name: "label",
|
|
42
|
+
fn: t(() => [
|
|
43
|
+
a("span", N, [
|
|
44
|
+
a("span", V, [
|
|
45
|
+
r(l.$slots, "label", {}, () => [
|
|
46
|
+
y(g(e.label), 1)
|
|
47
|
+
], !0)
|
|
48
|
+
]),
|
|
49
|
+
e.tip ? (s(), c(f, {
|
|
50
|
+
key: 0,
|
|
51
|
+
content: e.tip,
|
|
52
|
+
placement: e.tipPlacement,
|
|
53
|
+
effect: "dark",
|
|
54
|
+
"show-after": 100
|
|
55
|
+
}, {
|
|
56
|
+
default: t(() => [
|
|
57
|
+
a("span", x, [
|
|
58
|
+
i(d, null, {
|
|
59
|
+
default: t(() => [
|
|
60
|
+
i(k(C))
|
|
61
|
+
]),
|
|
62
|
+
_: 1
|
|
63
|
+
})
|
|
64
|
+
])
|
|
65
|
+
]),
|
|
66
|
+
_: 1
|
|
67
|
+
}, 8, ["content", "placement"])) : v("", !0)
|
|
68
|
+
])
|
|
69
|
+
]),
|
|
70
|
+
key: "0"
|
|
71
|
+
} : void 0
|
|
72
|
+
]), 1040, ["class", "label", "prop"]);
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}), D = /* @__PURE__ */ I(P, [["__scopeId", "data-v-51ed7d18"]]);
|
|
76
|
+
export {
|
|
77
|
+
D as W
|
|
78
|
+
};
|
|
79
|
+
//# sourceMappingURL=SearchItem-pFO57lEO.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchItem-pFO57lEO.mjs","sources":["../../src/components/form/SearchItem.vue"],"sourcesContent":["<template>\n <el-form-item\n class=\"wd-search-item\"\n :class=\"{ 'is-help': !!tip }\"\n :label=\"label\"\n :prop=\"prop\"\n v-bind=\"$attrs\"\n >\n <!-- label 区域:文本(可被 #label 覆盖)+ tip 提供的帮助图标(鼠标悬停显示解释说明) -->\n <template v-if=\"showLabel\" #label>\n <span class=\"wd-search-item__label\">\n <span class=\"wd-search-item__title\">\n <slot name=\"label\">{{ label }}</slot>\n </span>\n <el-tooltip\n v-if=\"tip\"\n :content=\"tip\"\n :placement=\"tipPlacement\"\n effect=\"dark\"\n :show-after=\"100\"\n >\n <span class=\"wd-search-item__tip\" tabindex=\"0\" role=\"note\" aria-label=\"帮助说明\">\n <el-icon>\n <QuestionFilled />\n </el-icon>\n </span>\n </el-tooltip>\n </span>\n </template>\n\n <!-- 控件区:el-input / el-select 等放默认插槽 -->\n <slot />\n </el-form-item>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, useSlots, type PropType } from 'vue'\nimport { QuestionFilled } from '@element-plus/icons-vue'\n\ndefineOptions({ name: 'WdSearchItem', inheritAttrs: false })\n\nconst props = defineProps({\n /** 字段标签文字 */\n label: { type: String, default: '' },\n /** 绑定字段名(对应查询 model 的 key,如姓名→model.name) */\n prop: { type: String, default: '' },\n /** 帮助说明:提供时 label 右侧自动出现带问号的图标,鼠标悬停显示说明;不传则不显示图标 */\n tip: { type: String, default: '' },\n /** 帮助气泡的弹出位置 */\n tipPlacement: {\n type: String as PropType<'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'right'>,\n default: 'top'\n }\n})\n\nconst slots = useSlots()\n\n// 存在 label 文字、自定义 label 插槽或帮助说明时,才渲染 label 区域\nconst showLabel = computed(() => !!(props.label || slots.label || props.tip))\n</script>\n\n<style scoped>\n.wd-search-item__label {\n display: inline-flex;\n align-items: center;\n white-space: nowrap;\n}\n.wd-search-item__tip {\n display: inline-flex;\n align-items: center;\n margin-left: 4px;\n color: var(--wd-color-info, #909399);\n cursor: help;\n}\n.wd-search-item__tip:focus-visible {\n outline: 1px dashed currentColor;\n outline-offset: 2px;\n}\n</style>\n"],"names":["props","__props","slots","useSlots","showLabel","computed","_openBlock","_createBlock","_component_el_form_item","_mergeProps","$attrs","_createSlots","_renderSlot","_ctx","_createElementVNode","_hoisted_1","_hoisted_2","_component_el_tooltip","_hoisted_3","_createVNode","_component_el_icon","_unref","QuestionFilled"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,UAAMA,IAAQC,GAcRC,IAAQC,EAAA,GAGRC,IAAYC,EAAS,MAAM,CAAC,EAAEL,EAAM,SAASE,EAAM,SAASF,EAAM,IAAI;;;AAzD1E,aAAAM,EAAA,GAAAC,EA+BeC,GA/BfC,EA+Be;AAAA,QA9Bb,OAAK,CAAC,kBAAgB,EAAA,WAAA,CAAA,CACCR,EAAA,KAAG;AAAA,QACzB,OAAOA,EAAA;AAAA,QACP,MAAMA,EAAA;AAAA,MAAA,GACCS,EAAAA,MAAM,GAAAC,EAAA;AAAA,mBAyBd,MAAQ;AAAA,UAARC,EAAQC,EAAA,QAAA,WAAA,CAAA,GAAA,QAAA,EAAA;AAAA,QAAA;;;QAtBQT,EAAA;gBAAY;AAAA,gBAC1B,MAiBO;AAAA,YAjBPU,EAiBO,QAjBPC,GAiBO;AAAA,cAhBLD,EAEO,QAFPE,GAEO;AAAA,gBADLJ,EAAqCC,uBAArC,MAAqC;AAAA,sBAAfZ,EAAA,KAAK,GAAA,CAAA;AAAA,gBAAA;;cAGrBA,EAAA,YADRM,EAYaU,GAAA;AAAA;gBAVV,SAAShB,EAAA;AAAA,gBACT,WAAWA,EAAA;AAAA,gBACZ,QAAO;AAAA,gBACN,cAAY;AAAA,cAAA;2BAEb,MAIO;AAAA,kBAJPa,EAIO,QAJPI,GAIO;AAAA,oBAHLC,EAEUC,GAAA,MAAA;AAAA,iCADR,MAAkB;AAAA,wBAAlBD,EAAkBE,EAAAC,CAAA,CAAA;AAAA,sBAAA;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { defineComponent as J, ref as u, reactive as K, useSlots as Q, computed as l, getCurrentInstance as Y, onMounted as Z, nextTick as ee, onBeforeUnmount as te, resolveComponent as W, resolveDirective as ae, withDirectives as oe, openBlock as m, createElementBlock as w, createVNode as b, mergeProps as ne, withModifiers as re, withCtx as v, createElementVNode as x, normalizeClass as z, renderSlot as S, normalizeProps as N, guardReactiveProps as A, normalizeStyle as le, createTextVNode as P, toDisplayString as k, createBlock as se, createCommentVNode as C } from "vue";
|
|
2
|
+
import { s as ie, b as de } from "./linkage-FbL1mcz3.mjs";
|
|
3
|
+
import { h as ce, f as ue } from "./props-DAytpx7D.mjs";
|
|
4
|
+
import { _ as pe } from "./_plugin-vue_export-helper-CHgC5LLL.mjs";
|
|
5
|
+
const fe = { class: "wd-search-panel" }, he = { class: "wd-search-panel__row wd-search-panel__row--primary" }, me = { class: "wd-search-panel__fields" }, ve = ["aria-hidden"], xe = { class: "wd-search-panel__more" }, ye = 40, _e = /* @__PURE__ */ J({
|
|
6
|
+
name: "WdSearchPanel",
|
|
7
|
+
inheritAttrs: !1,
|
|
8
|
+
__name: "SearchPanel",
|
|
9
|
+
props: {
|
|
10
|
+
...ue,
|
|
11
|
+
...ce,
|
|
12
|
+
/** 是否可折叠(默认 true:面板自带 展开/收起 按钮;有 more 插槽时折叠 more 区,无 more 插槽时折叠默认区整体) */
|
|
13
|
+
collapsible: { type: Boolean, default: !0 },
|
|
14
|
+
/** 是否展开(v-model:expand) */
|
|
15
|
+
expand: { type: Boolean, default: void 0 },
|
|
16
|
+
/** 默认是否展开 */
|
|
17
|
+
defaultExpand: { type: Boolean, default: !1 },
|
|
18
|
+
/** 是否内置查询/重置按钮 */
|
|
19
|
+
withActions: { type: Boolean, default: !0 },
|
|
20
|
+
searchText: { type: String, default: "搜索" },
|
|
21
|
+
resetText: { type: String, default: "重置" },
|
|
22
|
+
expandText: { type: String, default: "展开" },
|
|
23
|
+
collapseText: { type: String, default: "收起" },
|
|
24
|
+
labelWidth: { type: [String, Number], default: "80px" },
|
|
25
|
+
/** 操作列宽度:默认 'auto' 随按钮内容自适应;数字按 px;也可传 CSS 长度(如 '120px') */
|
|
26
|
+
actionWidth: { type: [String, Number], default: "auto" }
|
|
27
|
+
},
|
|
28
|
+
emits: ["search", "reset", "expand-change", "update:expand"],
|
|
29
|
+
setup(r, { expose: M, emit: V }) {
|
|
30
|
+
const t = r, s = V, R = u(null), p = u(null), E = u(!1), o = K({}), $ = Q(), y = l(() => !!$.more), T = u(!1), H = l(() => y.value || T.value), _ = l(() => t.collapsible && H.value), f = u(t.defaultExpand), d = l(
|
|
31
|
+
() => _.value ? t.expand !== void 0 ? !!t.expand : f.value : !0
|
|
32
|
+
), L = l(() => _.value && !d.value), O = l(() => L.value && !y.value);
|
|
33
|
+
function h() {
|
|
34
|
+
const e = p.value;
|
|
35
|
+
e && (T.value = e.scrollHeight > ye + 1);
|
|
36
|
+
}
|
|
37
|
+
const q = l(() => {
|
|
38
|
+
const e = t.actionWidth;
|
|
39
|
+
return e === "auto" || e === "" || e == null ? void 0 : { width: typeof e == "number" ? `${e}px` : e, flex: "0 0 auto" };
|
|
40
|
+
});
|
|
41
|
+
function G() {
|
|
42
|
+
const e = !d.value;
|
|
43
|
+
f.value = e, s("update:expand", e), s("expand-change", e);
|
|
44
|
+
}
|
|
45
|
+
function D() {
|
|
46
|
+
return { ...o };
|
|
47
|
+
}
|
|
48
|
+
function B() {
|
|
49
|
+
const e = D();
|
|
50
|
+
s("search", e), t.headRefreshDatagrid && ie(e, t.headRefreshDatagrid, t.filter);
|
|
51
|
+
}
|
|
52
|
+
function g() {
|
|
53
|
+
var e, a;
|
|
54
|
+
Object.keys(o).forEach((n) => delete o[n]), (a = (e = R.value) == null ? void 0 : e.clearValidate) == null || a.call(e), s("reset"), t.headRefreshDatagrid && de(t.headRefreshDatagrid, t.filter);
|
|
55
|
+
}
|
|
56
|
+
function I() {
|
|
57
|
+
f.value = !0, s("update:expand", !0);
|
|
58
|
+
}
|
|
59
|
+
function j() {
|
|
60
|
+
f.value = !1, s("update:expand", !1);
|
|
61
|
+
}
|
|
62
|
+
function F() {
|
|
63
|
+
g();
|
|
64
|
+
}
|
|
65
|
+
const i = Y();
|
|
66
|
+
let c = null;
|
|
67
|
+
return Z(() => {
|
|
68
|
+
const e = i == null ? void 0 : i.appContext;
|
|
69
|
+
e && (e.config.globalProperties.q = o), ee(h), typeof ResizeObserver < "u" && p.value && (c = new ResizeObserver(() => h()), c.observe(p.value)), window.addEventListener("resize", h);
|
|
70
|
+
}), te(() => {
|
|
71
|
+
var a, n;
|
|
72
|
+
const e = i == null ? void 0 : i.appContext;
|
|
73
|
+
((n = (a = e == null ? void 0 : e.config) == null ? void 0 : a.globalProperties) == null ? void 0 : n.q) === o && delete e.config.globalProperties.q, c == null || c.disconnect(), window.removeEventListener("resize", h);
|
|
74
|
+
}), M({ expand: I, collapse: j, resetForm: F, getSearchParams: D }), (e, a) => {
|
|
75
|
+
const n = W("el-button"), U = W("el-form"), X = ae("loading");
|
|
76
|
+
return oe((m(), w("div", fe, [
|
|
77
|
+
b(U, ne({
|
|
78
|
+
ref_key: "formRef",
|
|
79
|
+
ref: R,
|
|
80
|
+
model: o,
|
|
81
|
+
inline: !0,
|
|
82
|
+
"label-width": r.labelWidth
|
|
83
|
+
}, e.$attrs, {
|
|
84
|
+
onSubmit: a[0] || (a[0] = re(() => {
|
|
85
|
+
}, ["prevent"]))
|
|
86
|
+
}), {
|
|
87
|
+
default: v(() => [
|
|
88
|
+
x("div", he, [
|
|
89
|
+
x("div", me, [
|
|
90
|
+
x("div", {
|
|
91
|
+
ref_key: "primaryRef",
|
|
92
|
+
ref: p,
|
|
93
|
+
class: z(["wd-search-panel__primary", { "is-collapsed": O.value }])
|
|
94
|
+
}, [
|
|
95
|
+
S(e.$slots, "default", N(A({ model: o })), void 0, !0)
|
|
96
|
+
], 2)
|
|
97
|
+
]),
|
|
98
|
+
r.withActions ? (m(), w("div", {
|
|
99
|
+
key: 0,
|
|
100
|
+
class: "wd-search-panel__actions",
|
|
101
|
+
style: le(q.value)
|
|
102
|
+
}, [
|
|
103
|
+
S(e.$slots, "actions", {
|
|
104
|
+
search: B,
|
|
105
|
+
reset: g
|
|
106
|
+
}, () => [
|
|
107
|
+
b(n, {
|
|
108
|
+
type: "primary",
|
|
109
|
+
loading: E.value,
|
|
110
|
+
onClick: B
|
|
111
|
+
}, {
|
|
112
|
+
default: v(() => [
|
|
113
|
+
P(k(r.searchText), 1)
|
|
114
|
+
]),
|
|
115
|
+
_: 1
|
|
116
|
+
}, 8, ["loading"]),
|
|
117
|
+
b(n, { onClick: g }, {
|
|
118
|
+
default: v(() => [
|
|
119
|
+
P(k(r.resetText), 1)
|
|
120
|
+
]),
|
|
121
|
+
_: 1
|
|
122
|
+
}),
|
|
123
|
+
_.value ? (m(), se(n, {
|
|
124
|
+
key: 0,
|
|
125
|
+
link: "",
|
|
126
|
+
type: "primary",
|
|
127
|
+
onClick: G
|
|
128
|
+
}, {
|
|
129
|
+
default: v(() => [
|
|
130
|
+
P(k(d.value ? r.collapseText : r.expandText), 1)
|
|
131
|
+
]),
|
|
132
|
+
_: 1
|
|
133
|
+
})) : C("", !0)
|
|
134
|
+
], !0)
|
|
135
|
+
], 4)) : C("", !0)
|
|
136
|
+
]),
|
|
137
|
+
y.value ? (m(), w("div", {
|
|
138
|
+
key: 0,
|
|
139
|
+
class: z(["wd-search-panel__more-wrap", { "is-open": d.value }]),
|
|
140
|
+
"aria-hidden": d.value ? void 0 : "true"
|
|
141
|
+
}, [
|
|
142
|
+
x("div", xe, [
|
|
143
|
+
S(e.$slots, "more", N(A({ model: o })), void 0, !0)
|
|
144
|
+
])
|
|
145
|
+
], 10, ve)) : C("", !0)
|
|
146
|
+
]),
|
|
147
|
+
_: 3
|
|
148
|
+
}, 16, ["model", "label-width"])
|
|
149
|
+
])), [
|
|
150
|
+
[X, E.value]
|
|
151
|
+
]);
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
}), Pe = /* @__PURE__ */ pe(_e, [["__scopeId", "data-v-bcc17462"]]);
|
|
155
|
+
export {
|
|
156
|
+
Pe as W
|
|
157
|
+
};
|
|
158
|
+
//# sourceMappingURL=SearchPanel-xQ1hPaNq.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchPanel-xQ1hPaNq.mjs","sources":["../../src/components/form/SearchPanel.vue"],"sourcesContent":["<template>\n <div class=\"wd-search-panel\" v-loading=\"loading\">\n <!-- 搜索表单:整体一个 el-form,显示项和隐藏项分两行布局,都在同一个表单作用域中 -->\n <el-form\n ref=\"formRef\"\n :model=\"searchModel\"\n :inline=\"true\"\n :label-width=\"labelWidth\"\n v-bind=\"$attrs\"\n @submit.prevent\n >\n <!-- 第一行:默认搜索项 + 右侧操作按钮,布局不随隐藏项变化 -->\n <div class=\"wd-search-panel__row wd-search-panel__row--primary\">\n <div class=\"wd-search-panel__fields\">\n <div ref=\"primaryRef\" class=\"wd-search-panel__primary\" :class=\"{ 'is-collapsed': collapsePrimary }\">\n <slot v-bind=\"{ model: searchModel }\" />\n </div>\n </div>\n\n <!-- 右侧操作列(搜索 / 重置 / 展开),固定宽度、按钮横排一行不折行 -->\n <div v-if=\"withActions\" class=\"wd-search-panel__actions\" :style=\"actionStyle\">\n <slot name=\"actions\" :search=\"onSearch\" :reset=\"onReset\">\n <el-button type=\"primary\" :loading=\"loading\" @click=\"onSearch\">{{ searchText }}</el-button>\n <el-button @click=\"onReset\">{{ resetText }}</el-button>\n <el-button v-if=\"canCollapse\" link type=\"primary\" @click=\"toggleExpand\">\n {{ expanded ? collapseText : expandText }}\n </el-button>\n </slot>\n </div>\n </div>\n\n <!-- 第二行:隐藏搜索条件区,整行平顺滑出/收起,仍然在同一个 el-form 内 -->\n <div\n v-if=\"hasMore\"\n class=\"wd-search-panel__more-wrap\"\n :class=\"{ 'is-open': expanded }\"\n :aria-hidden=\"!expanded ? 'true' : undefined\"\n >\n <div class=\"wd-search-panel__more\">\n <slot name=\"more\" v-bind=\"{ model: searchModel }\" />\n </div>\n </div>\n </el-form>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { ref, reactive, computed, onMounted, onBeforeUnmount, getCurrentInstance, useSlots, nextTick } from 'vue'\nimport { searchDataGrid, resetSearchDataGrid } from '../../lib/core/linkage'\nimport { filterProp, headRefreshDatagridProp } from '../common/props'\n\ndefineOptions({ name: 'WdSearchPanel', inheritAttrs: false })\n\nconst props = defineProps({\n ...filterProp,\n ...headRefreshDatagridProp,\n /** 是否可折叠(默认 true:面板自带 展开/收起 按钮;有 more 插槽时折叠 more 区,无 more 插槽时折叠默认区整体) */\n collapsible: { type: Boolean, default: true },\n /** 是否展开(v-model:expand) */\n expand: { type: Boolean, default: undefined },\n /** 默认是否展开 */\n defaultExpand: { type: Boolean, default: false },\n /** 是否内置查询/重置按钮 */\n withActions: { type: Boolean, default: true },\n searchText: { type: String, default: '搜索' },\n resetText: { type: String, default: '重置' },\n expandText: { type: String, default: '展开' },\n collapseText: { type: String, default: '收起' },\n labelWidth: { type: [String, Number], default: '80px' },\n /** 操作列宽度:默认 'auto' 随按钮内容自适应;数字按 px;也可传 CSS 长度(如 '120px') */\n actionWidth: { type: [String, Number], default: 'auto' }\n})\n\nconst emit = defineEmits(['search', 'reset', 'expand-change', 'update:expand'])\n\nconst formRef = ref<any>(null)\nconst primaryRef = ref<HTMLElement | null>(null)\nconst loading = ref(false)\nconst searchModel = reactive<Record<string, any>>({})\nconst slots = useSlots()\n\n// 是否提供了 more 插槽(隐藏搜索项目)\nconst hasMore = computed(() => !!slots.more)\n\n// 折叠行高(与 .wd-search-panel__primary.is-collapsed 的 max-height 保持一致)\nconst COLLAPSE_MAX_HEIGHT = 40\n// 无 more 插槽时:默认区完整内容是否超出折叠行高(超出才存在被隐藏的搜索条件)\nconst primaryOverflow = ref(false)\n\n// 是否存在可隐藏的搜索条件:有 more 插槽恒有;无 more 插槽时默认区超出折叠行高才有\nconst hasHidden = computed(() => hasMore.value || primaryOverflow.value)\n// 折叠能力:允许折叠且确实存在隐藏条件时,才显示 展开/收起 按钮\nconst canCollapse = computed(() => props.collapsible && hasHidden.value)\n\n// 展开状态(canCollapse 时生效)\nconst innerExpanded = ref(props.defaultExpand)\nconst expanded = computed(() =>\n canCollapse.value ? (props.expand !== undefined ? !!props.expand : innerExpanded.value) : true\n)\nconst collapsed = computed(() => canCollapse.value && !expanded.value)\n// 无 more 插槽时走旧行为:折叠默认区整体;有 more 插槽时默认区始终完整展示\nconst collapsePrimary = computed(() => collapsed.value && !hasMore.value)\n\n/** 测量默认区内容是否超出折叠行高(scrollHeight 包含因 overflow 隐藏的内容,折叠态下也能测到完整高度) */\nfunction measurePrimary() {\n const el = primaryRef.value\n if (!el) return\n primaryOverflow.value = el.scrollHeight > COLLAPSE_MAX_HEIGHT + 1\n}\n\n/** 操作列样式:默认随内容自适应;显式传宽度时固定宽度 */\nconst actionStyle = computed(() => {\n const w = props.actionWidth\n if (w === 'auto' || w === '' || w == null) return undefined\n const width = typeof w === 'number' ? `${w}px` : w\n return { width, flex: '0 0 auto' }\n})\n\nfunction toggleExpand() {\n const next = !expanded.value\n innerExpanded.value = next\n emit('update:expand', next)\n emit('expand-change', next)\n}\n\nfunction getSearchParams() {\n return { ...searchModel }\n}\n\nfunction onSearch() {\n const params = getSearchParams()\n emit('search', params)\n // 声明式联动:刷新同 filter 组 DataGrid(重置到第一页)\n if (props.headRefreshDatagrid) {\n searchDataGrid(params, props.headRefreshDatagrid, props.filter)\n }\n}\n\nfunction onReset() {\n // 清空表单字段\n Object.keys(searchModel).forEach((k) => delete searchModel[k])\n formRef.value?.clearValidate?.()\n emit('reset')\n if (props.headRefreshDatagrid) {\n resetSearchDataGrid(props.headRefreshDatagrid, props.filter)\n }\n}\n\nfunction expand() {\n innerExpanded.value = true\n emit('update:expand', true)\n}\nfunction collapse() {\n innerExpanded.value = false\n emit('update:expand', false)\n}\nfunction resetForm() {\n onReset()\n}\n\n// HTML 场景:插槽 v-model=\"q.xxx\" 需要根模板作用域可见 q\nconst instance = getCurrentInstance()\nlet resizeObserver: ResizeObserver | null = null\nonMounted(() => {\n const appContext = instance?.appContext\n if (appContext) {\n appContext.config.globalProperties.q = searchModel\n }\n // 初始测量 + 监听默认区尺寸/窗口宽度变化:无 more 插槽时据此判断是否存在隐藏条件\n nextTick(measurePrimary)\n if (typeof ResizeObserver !== 'undefined' && primaryRef.value) {\n resizeObserver = new ResizeObserver(() => measurePrimary())\n resizeObserver.observe(primaryRef.value)\n }\n window.addEventListener('resize', measurePrimary)\n})\nonBeforeUnmount(() => {\n const appContext = instance?.appContext\n if (appContext?.config?.globalProperties?.q === searchModel) {\n delete appContext.config.globalProperties.q\n }\n resizeObserver?.disconnect()\n window.removeEventListener('resize', measurePrimary)\n})\n\ndefineExpose({ expand, collapse, resetForm, getSearchParams })\n</script>\n\n<style scoped>\n.wd-search-panel {\n width: 100%;\n background: var(--wd-bg-color, #fff);\n padding: var(--wd-spacing-base, 8px) var(--wd-spacing-base, 12px) 0;\n box-sizing: border-box;\n}\n/* 第一行:默认搜索项(fields)+ 右侧操作列(actions),grid 三列布局锁定空间,布局稳定不受第二行影响\n * grid-template-columns: 1fr auto; —— 左侧搜索区自动占满剩余空间,右侧操作列宽度固定(随内容自适应或显式指定)\n * 避免 flex 压缩挤压导致最后一项换行不自然,结尾总是整齐\n */\n.wd-search-panel__row {\n display: grid;\n grid-template-columns: 1fr auto;\n align-items: flex-start;\n column-gap: var(--wd-spacing-base, 12px);\n padding-bottom: var(--wd-spacing-base, 4px);\n}\n.wd-search-panel__fields {\n min-width: 0;\n}\n/* 旧折叠模式(无 more 插槽):默认区超出一行隐藏 */\n.wd-search-panel__primary.is-collapsed {\n max-height: 40px;\n overflow: hidden;\n}\n/* 第二行:隐藏搜索条件区(独立容器 + 独立 el-form 作用域)。\n 外层 grid 行高 0fr→1fr 动画实现平顺滑出/收起;visibility 延迟隐藏,收起后不占位、不可聚焦 */\n.wd-search-panel__more-wrap {\n display: grid;\n grid-template-rows: 0fr;\n visibility: hidden;\n transition: grid-template-rows 0.25s ease, visibility 0s linear 0.25s;\n}\n.wd-search-panel__more-wrap.is-open {\n grid-template-rows: 1fr;\n visibility: visible;\n transition: grid-template-rows 0.25s ease;\n}\n.wd-search-panel__more {\n overflow: hidden;\n min-height: 0;\n box-sizing: border-box;\n padding-top: var(--wd-spacing-base, 6px);\n border-top: 1px dashed var(--wd-border-color-light, #e4e7ed);\n}\n/* 右侧操作列:按钮横排一行、不换行/不折行(宽度默认随内容,可经 actionWidth 显式固定) */\n.wd-search-panel__actions {\n display: flex;\n flex-direction: row;\n flex-wrap: nowrap;\n align-items: center;\n gap: 0px;\n white-space: nowrap;\n}\n.wd-search-panel__actions :deep(.el-button) {\n white-space: nowrap;\n}\n\n/* SearchPanel 内让表单项更紧凑 */\n:deep(.el-form--inline .el-form-item) {\n margin-bottom: 4px;\n margin-right: 12px;\n}\n:deep(.el-form-item) {\n margin-bottom: 4px;\n}\n:deep(.el-form-item__label) {\n line-height: 30px;\n}\n:deep(.el-form-item__content) {\n line-height: 30px;\n}\n</style>\n"],"names":["COLLAPSE_MAX_HEIGHT","props","__props","emit","__emit","formRef","ref","primaryRef","loading","searchModel","reactive","slots","useSlots","hasMore","computed","primaryOverflow","hasHidden","canCollapse","innerExpanded","expanded","collapsed","collapsePrimary","measurePrimary","el","actionStyle","w","toggleExpand","next","getSearchParams","onSearch","params","searchDataGrid","onReset","k","_b","_a","resetSearchDataGrid","expand","collapse","resetForm","instance","getCurrentInstance","resizeObserver","onMounted","appContext","nextTick","onBeforeUnmount","__expose","_withDirectives","_openBlock","_createElementBlock","_hoisted_1","_createVNode","_component_el_form","_mergeProps","$attrs","_createElementVNode","_hoisted_2","_hoisted_3","_normalizeClass","_renderSlot","_ctx","_component_el_button","_createBlock","_hoisted_5"],"mappings":";;;;yNAqFMA,KAAsB;;;;;;;;;;;;;;;;;;;;;;;;;AAhC5B,UAAMC,IAAQC,GAoBRC,IAAOC,GAEPC,IAAUC,EAAS,IAAI,GACvBC,IAAaD,EAAwB,IAAI,GACzCE,IAAUF,EAAI,EAAK,GACnBG,IAAcC,EAA8B,EAAE,GAC9CC,IAAQC,EAAA,GAGRC,IAAUC,EAAS,MAAM,CAAC,CAACH,EAAM,IAAI,GAKrCI,IAAkBT,EAAI,EAAK,GAG3BU,IAAYF,EAAS,MAAMD,EAAQ,SAASE,EAAgB,KAAK,GAEjEE,IAAcH,EAAS,MAAMb,EAAM,eAAee,EAAU,KAAK,GAGjEE,IAAgBZ,EAAIL,EAAM,aAAa,GACvCkB,IAAWL;AAAA,MAAS,MACxBG,EAAY,QAAShB,EAAM,WAAW,SAAY,CAAC,CAACA,EAAM,SAASiB,EAAc,QAAS;AAAA,IAAA,GAEtFE,IAAYN,EAAS,MAAMG,EAAY,SAAS,CAACE,EAAS,KAAK,GAE/DE,IAAkBP,EAAS,MAAMM,EAAU,SAAS,CAACP,EAAQ,KAAK;AAGxE,aAASS,IAAiB;AACxB,YAAMC,IAAKhB,EAAW;AACtB,MAAKgB,MACLR,EAAgB,QAAQQ,EAAG,eAAevB,KAAsB;AAAA,IAClE;AAGA,UAAMwB,IAAcV,EAAS,MAAM;AACjC,YAAMW,IAAIxB,EAAM;AAChB,aAAIwB,MAAM,UAAUA,MAAM,MAAMA,KAAK,OAAM,SAEpC,EAAE,OADK,OAAOA,KAAM,WAAW,GAAGA,CAAC,OAAOA,GACjC,MAAM,WAAA;AAAA,IACxB,CAAC;AAED,a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,SAAStD,EAAA;AAAA,oBAAU,SAAOqB;AAAA,kBAAA;+BAAU,MAAgB;AAAA,0BAAb3B,EAAA,UAAU,GAAA,CAAA;AAAA,oBAAA;;;kBAC5EkD,EAAuDU,GAAA,EAA3C,SAAO9B,KAAO;AAAA,+BAAE,MAAe;AAAA,0BAAZ9B,EAAA,SAAS,GAAA,CAAA;AAAA,oBAAA;;;kBACvBe,EAAA,cAAjB8C,GAEYD,GAAA;AAAA;oBAFkB,MAAA;AAAA,oBAAK,MAAK;AAAA,oBAAW,SAAOpC;AAAA,kBAAA;+BACxD,MAA0C;AAAA,0BAAvCP,EAAA,QAAWjB,EAAA,eAAeA,EAAA,UAAU,GAAA,CAAA;AAAA,oBAAA;;;;;;YAQvCW,EAAA,cADRqC,EASM,OAAA;AAAA;cAPJ,OAAKS,EAAA,CAAC,8BAA4B,EAAA,WACbxC,EAAA,MAAA,CAAQ,CAAA;AAAA,cAC5B,eAAcA,EAAA,QAAoB,SAAZ;AAAA,YAAY;cAEnCqC,EAEM,OAFNQ,IAEM;AAAA,gBADJJ,EAAoDC,+BAAjBpD,EAAA,CAAW,CAAA,GAAA,QAAA,EAAA;AAAA,cAAA;;;;;;YAtCdD,EAAA,KAAO;AAAA,MAAA;;;;"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { defineComponent as b, toRefs as B, computed as D, resolveComponent as r, resolveDirective as C, withDirectives as N, openBlock as i, createBlock as d, mergeProps as A, withCtx as s, createElementBlock as F, Fragment as M, renderList as W, unref as c, createElementVNode as m, renderSlot as E, createTextVNode as K, toDisplayString as L, withModifiers as R, createVNode as f, createCommentVNode as $ } from "vue";
|
|
2
|
+
import { QuestionFilled as I } from "@element-plus/icons-vue";
|
|
3
|
+
import { u as O } from "./useOptionsLoader-Bi8oqNbG.mjs";
|
|
4
|
+
import { o as Q } from "./props-DAytpx7D.mjs";
|
|
5
|
+
import { _ as T } from "./_plugin-vue_export-helper-CHgC5LLL.mjs";
|
|
6
|
+
const U = { class: "wd-option-row" }, j = { class: "wd-option-text" }, q = /* @__PURE__ */ b({
|
|
7
|
+
name: "WdSelect",
|
|
8
|
+
inheritAttrs: !1,
|
|
9
|
+
__name: "Select",
|
|
10
|
+
props: {
|
|
11
|
+
...Q,
|
|
12
|
+
modelValue: { type: [String, Number, Boolean, Array], default: void 0 },
|
|
13
|
+
multiple: { type: Boolean, default: !1 },
|
|
14
|
+
/** 远程搜索 */
|
|
15
|
+
remote: { type: Boolean, default: !1 },
|
|
16
|
+
/** 本地可搜索 */
|
|
17
|
+
filterable: { type: Boolean, default: !0 },
|
|
18
|
+
/** 远程搜索关键字字段名 */
|
|
19
|
+
keywordKey: { type: String, default: "keyword" }
|
|
20
|
+
},
|
|
21
|
+
emits: ["update:modelValue", "change", "apiBefore", "apiSuccess", "apiFail", "apiAfter"],
|
|
22
|
+
setup(a, { emit: v }) {
|
|
23
|
+
const l = a, p = v, t = B(l), { options: _, loading: y, remoteSearch: g } = O({
|
|
24
|
+
api: t.api,
|
|
25
|
+
apiMethod: t.apiMethod,
|
|
26
|
+
apiParam: t.apiParam,
|
|
27
|
+
active: t.active,
|
|
28
|
+
dataSource: t.dataSource,
|
|
29
|
+
textProp: t.textProp,
|
|
30
|
+
valueProp: t.valueProp,
|
|
31
|
+
tipsProp: t.tipsProp,
|
|
32
|
+
addData: t.addData,
|
|
33
|
+
appendData: t.appendData,
|
|
34
|
+
emit: p
|
|
35
|
+
}), u = D({
|
|
36
|
+
get: () => l.modelValue,
|
|
37
|
+
set: (o) => p("update:modelValue", o)
|
|
38
|
+
});
|
|
39
|
+
function w(o) {
|
|
40
|
+
p("change", o);
|
|
41
|
+
}
|
|
42
|
+
function S(o) {
|
|
43
|
+
l.remote && g(o, l.keywordKey);
|
|
44
|
+
}
|
|
45
|
+
return (o, n) => {
|
|
46
|
+
const h = r("el-icon"), x = r("el-tooltip"), V = r("el-option"), k = r("el-select"), P = C("loading");
|
|
47
|
+
return N((i(), d(k, A({
|
|
48
|
+
modelValue: u.value,
|
|
49
|
+
"onUpdate:modelValue": n[1] || (n[1] = (e) => u.value = e),
|
|
50
|
+
multiple: a.multiple,
|
|
51
|
+
filterable: a.remote || a.filterable,
|
|
52
|
+
remote: a.remote,
|
|
53
|
+
"remote-method": S
|
|
54
|
+
}, o.$attrs, { onChange: w }), {
|
|
55
|
+
default: s(() => [
|
|
56
|
+
(i(!0), F(M, null, W(c(_), (e) => (i(), d(V, {
|
|
57
|
+
key: String(e.value),
|
|
58
|
+
label: e.text,
|
|
59
|
+
value: e.value
|
|
60
|
+
}, {
|
|
61
|
+
default: s(() => [
|
|
62
|
+
m("span", U, [
|
|
63
|
+
m("span", j, [
|
|
64
|
+
E(o.$slots, "default", {
|
|
65
|
+
option: e.raw,
|
|
66
|
+
text: e.text,
|
|
67
|
+
value: e.value,
|
|
68
|
+
tips: e.tips
|
|
69
|
+
}, () => [
|
|
70
|
+
K(L(e.text), 1)
|
|
71
|
+
], !0)
|
|
72
|
+
]),
|
|
73
|
+
e.tips ? (i(), d(x, {
|
|
74
|
+
key: 0,
|
|
75
|
+
content: e.tips,
|
|
76
|
+
placement: "top",
|
|
77
|
+
effect: "dark",
|
|
78
|
+
"show-after": 200
|
|
79
|
+
}, {
|
|
80
|
+
default: s(() => [
|
|
81
|
+
m("span", {
|
|
82
|
+
class: "wd-option-tip",
|
|
83
|
+
tabindex: "0",
|
|
84
|
+
role: "note",
|
|
85
|
+
"aria-label": "帮助说明",
|
|
86
|
+
onClick: n[0] || (n[0] = R(() => {
|
|
87
|
+
}, ["stop"]))
|
|
88
|
+
}, [
|
|
89
|
+
f(h, null, {
|
|
90
|
+
default: s(() => [
|
|
91
|
+
f(c(I))
|
|
92
|
+
]),
|
|
93
|
+
_: 1
|
|
94
|
+
})
|
|
95
|
+
])
|
|
96
|
+
]),
|
|
97
|
+
_: 1
|
|
98
|
+
}, 8, ["content"])) : $("", !0)
|
|
99
|
+
])
|
|
100
|
+
]),
|
|
101
|
+
_: 2
|
|
102
|
+
}, 1032, ["label", "value"]))), 128))
|
|
103
|
+
]),
|
|
104
|
+
_: 3
|
|
105
|
+
}, 16, ["modelValue", "multiple", "filterable", "remote"])), [
|
|
106
|
+
[P, c(y)]
|
|
107
|
+
]);
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
}), Y = /* @__PURE__ */ T(q, [["__scopeId", "data-v-a8ac119c"]]);
|
|
111
|
+
export {
|
|
112
|
+
Y as W
|
|
113
|
+
};
|
|
114
|
+
//# sourceMappingURL=Select-DAGZDXvI.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Select-DAGZDXvI.mjs","sources":["../../src/components/inputs/Select.vue"],"sourcesContent":["<template>\n <el-select\n v-model=\"inner\"\n v-loading=\"loading\"\n :multiple=\"multiple\"\n :filterable=\"remote || filterable\"\n :remote=\"remote\"\n :remote-method=\"onRemote\"\n v-bind=\"$attrs\"\n @change=\"onChange\"\n >\n <el-option\n v-for=\"opt in options\"\n :key=\"String(opt.value)\"\n :label=\"opt.text\"\n :value=\"opt.value\"\n >\n <span class=\"wd-option-row\">\n <span class=\"wd-option-text\">\n <slot :option=\"opt.raw\" :text=\"opt.text\" :value=\"opt.value\" :tips=\"opt.tips\">\n {{ opt.text }}\n </slot>\n </span>\n <el-tooltip\n v-if=\"opt.tips\"\n :content=\"opt.tips\"\n placement=\"top\"\n effect=\"dark\"\n :show-after=\"200\"\n >\n <span class=\"wd-option-tip\" tabindex=\"0\" role=\"note\" aria-label=\"帮助说明\" @click.stop>\n <el-icon><QuestionFilled /></el-icon>\n </span>\n </el-tooltip>\n </span>\n </el-option>\n </el-select>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, toRefs, type PropType } from 'vue'\nimport { QuestionFilled } from '@element-plus/icons-vue'\nimport { useOptionsLoader } from './useOptionsLoader'\nimport { optionsProps } from '../common/props'\n\ndefineOptions({ name: 'WdSelect', inheritAttrs: false })\n\nconst props = defineProps({\n ...optionsProps,\n modelValue: { type: [String, Number, Boolean, Array] as PropType<any>, default: undefined },\n multiple: { type: Boolean, default: false },\n /** 远程搜索 */\n remote: { type: Boolean, default: false },\n /** 本地可搜索 */\n filterable: { type: Boolean, default: true },\n /** 远程搜索关键字字段名 */\n keywordKey: { type: String, default: 'keyword' }\n})\n\nconst emit = defineEmits(['update:modelValue', 'change', 'apiBefore', 'apiSuccess', 'apiFail', 'apiAfter'])\n\nconst refs = toRefs(props)\nconst { options, loading, remoteSearch } = useOptionsLoader({\n api: refs.api,\n apiMethod: refs.apiMethod as any,\n apiParam: refs.apiParam,\n active: refs.active,\n dataSource: refs.dataSource as any,\n textProp: refs.textProp,\n valueProp: refs.valueProp,\n tipsProp: refs.tipsProp,\n addData: refs.addData as any,\n appendData: refs.appendData as any,\n emit\n})\n\nconst inner = computed({\n get: () => props.modelValue,\n set: (val) => emit('update:modelValue', val)\n})\n\nfunction onChange(val: any) {\n emit('change', val)\n}\n\nfunction onRemote(query: string) {\n if (props.remote) remoteSearch(query, props.keywordKey)\n}\n</script>\n\n<style scoped>\n.wd-option-row {\n display: flex;\n align-items: center;\n gap: 6px;\n width: 100%;\n}\n.wd-option-text {\n flex: 1;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.wd-option-tip {\n flex: none;\n display: inline-flex;\n align-items: center;\n color: var(--el-text-color-secondary, #909399);\n font-size: 14px;\n cursor: help;\n}\n.wd-option-tip:focus-visible {\n outline: 1px dashed currentColor;\n outline-offset: 2px;\n}\n</style>\n"],"names":["props","__props","emit","__emit","refs","toRefs","options","loading","remoteSearch","useOptionsLoader","inner","computed","val","onChange","onRemote","query","_withDirectives","_openBlock","_createBlock","_component_el_select","_mergeProps","$event","$attrs","_createElementBlock","_Fragment","_renderList","_unref","opt","_component_el_option","_createElementVNode","_hoisted_1","_hoisted_2","_renderSlot","_ctx","_createTextVNode","_toDisplayString","_component_el_tooltip","_createVNode","_component_el_icon","QuestionFilled"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA+CA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