@vunk/form 1.1.16 → 1.1.18
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.
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { _VkfCascaderCtx, _VkfCascaderUse } from '@vunk/form/components/cascader';
|
|
2
|
-
import { defineComponent, ref, watch, resolveComponent, openBlock, createBlock, mergeProps, withCtx, createVNode
|
|
2
|
+
import { defineComponent, ref, watch, resolveComponent, openBlock, createBlock, mergeProps, withCtx, createVNode } from 'vue';
|
|
3
3
|
import { VkfFormItem, _VkfFormItemCtx } from '@vunk/form/components/form-item';
|
|
4
4
|
import { Cascader, Popup } from 'vant';
|
|
5
5
|
import { ElSelect } from 'element-plus';
|
|
6
6
|
import 'vant/es/cascader/style';
|
|
7
7
|
import 'vant/es/popup/style';
|
|
8
|
+
import { useComputedReadonly } from '@vunk/form/composables';
|
|
8
9
|
|
|
9
10
|
var __defProp = Object.defineProperty;
|
|
10
11
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
@@ -49,6 +50,7 @@ const _sfc_main = defineComponent({
|
|
|
49
50
|
const fieldValue = ref("");
|
|
50
51
|
const cascaderValue = ref("");
|
|
51
52
|
const options = _VkfCascaderUse.useOptions(props2, emit);
|
|
53
|
+
const readonly = useComputedReadonly(props2);
|
|
52
54
|
watch(() => props2.modelValue, (val) => {
|
|
53
55
|
if (Array.isArray(val) && val.length) {
|
|
54
56
|
fieldValue.value = val.join("/");
|
|
@@ -64,13 +66,19 @@ const _sfc_main = defineComponent({
|
|
|
64
66
|
popupShow.value = false;
|
|
65
67
|
emit("update:modelValue", selectedOptions.map((item) => item.value));
|
|
66
68
|
};
|
|
69
|
+
const preInput = () => {
|
|
70
|
+
if (readonly.value)
|
|
71
|
+
return;
|
|
72
|
+
popupShow.value = true;
|
|
73
|
+
};
|
|
67
74
|
return {
|
|
68
75
|
formItemBindProps,
|
|
69
76
|
fieldValue,
|
|
70
77
|
popupShow,
|
|
71
78
|
handleFinish,
|
|
72
79
|
cascaderValue,
|
|
73
|
-
options
|
|
80
|
+
options,
|
|
81
|
+
preInput
|
|
74
82
|
};
|
|
75
83
|
}
|
|
76
84
|
});
|
|
@@ -82,24 +90,21 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
82
90
|
return openBlock(), createBlock(_component_VkfFormItem, mergeProps({ class: "vkf-van-cascader" }, _ctx.formItemBindProps), {
|
|
83
91
|
default: withCtx(() => [
|
|
84
92
|
createVNode(_component_ElSelect, {
|
|
85
|
-
|
|
86
|
-
class: normalizeClass({
|
|
87
|
-
"is-readonly": true
|
|
88
|
-
}),
|
|
93
|
+
"popper-class": "vkf-van-cascader-input",
|
|
89
94
|
"model-value": _ctx.fieldValue,
|
|
90
|
-
onClick:
|
|
91
|
-
}, null, 8, ["model-value"]),
|
|
95
|
+
onClick: _ctx.preInput
|
|
96
|
+
}, null, 8, ["model-value", "onClick"]),
|
|
92
97
|
createVNode(_component_Popup, {
|
|
93
98
|
show: _ctx.popupShow,
|
|
94
|
-
"onUpdate:show": _cache[
|
|
99
|
+
"onUpdate:show": _cache[2] || (_cache[2] = ($event) => _ctx.popupShow = $event),
|
|
95
100
|
round: "",
|
|
96
101
|
position: "bottom"
|
|
97
102
|
}, {
|
|
98
103
|
default: withCtx(() => [
|
|
99
104
|
createVNode(_component_Cascader, {
|
|
100
105
|
modelValue: _ctx.cascaderValue,
|
|
101
|
-
"onUpdate:modelValue": _cache[
|
|
102
|
-
onClose: _cache[
|
|
106
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.cascaderValue = $event),
|
|
107
|
+
onClose: _cache[1] || (_cache[1] = ($event) => _ctx.popupShow = false),
|
|
103
108
|
options: _ctx.options,
|
|
104
109
|
"field-names": {
|
|
105
110
|
text: "label",
|
|
@@ -131,6 +131,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
131
131
|
}) => void;
|
|
132
132
|
cascaderValue: import("vue").Ref<string>;
|
|
133
133
|
options: import("vue").ComputedRef<import("element-plus").CascaderOption[] | undefined>;
|
|
134
|
+
preInput: () => void;
|
|
134
135
|
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
135
136
|
"update:modelValue": (val: import("element-plus").CascaderValue) => boolean;
|
|
136
137
|
change: (val: import("element-plus").CascaderValue) => boolean;
|
package/index.css
CHANGED
package/package.json
CHANGED
package/shared/form/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 表单验证失败, 处理方式
|
|
3
3
|
* 消息提示
|
|
4
|
-
* @param err
|
|
4
|
+
* @param err Record<string, {message: string}[]>
|
|
5
5
|
*/
|
|
6
|
-
export declare const validateCatch: (err: any
|
|
6
|
+
export declare const validateCatch: (err: any, init?: {
|
|
7
|
+
prefix?: string;
|
|
8
|
+
suffix?: string;
|
|
9
|
+
}) => void;
|
package/shared/form/index.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { ElMessage } from 'element-plus';
|
|
2
2
|
|
|
3
|
-
const validateCatch = (err) => {
|
|
3
|
+
const validateCatch = (err, init = {}) => {
|
|
4
4
|
let msg = "";
|
|
5
|
+
msg += init.prefix || "";
|
|
5
6
|
for (const key in err) {
|
|
6
7
|
err[key].forEach((v) => {
|
|
7
8
|
msg += v.message + ";";
|
|
8
9
|
});
|
|
9
10
|
}
|
|
11
|
+
msg += init.suffix || "";
|
|
10
12
|
ElMessage({
|
|
11
13
|
type: "warning",
|
|
12
14
|
message: msg
|