orion-design 0.1.29 → 0.1.31
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/Throne/index.js +30 -14
- package/dist/Throne/index.js.map +1 -1
- package/dist/_commonjsHelpers-DWwsNxpa.js +9 -0
- package/dist/_commonjsHelpers-DWwsNxpa.js.map +1 -0
- package/dist/components/Button/index.js +40 -33
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/Flex/index.js +122 -89
- package/dist/components/Flex/index.js.map +1 -1
- package/dist/components/Form/Form.js +2 -2
- package/dist/components/Form/Form.js.map +1 -1
- package/dist/components/Form/LovInput/LovInput.js +2 -2
- package/dist/components/Form/LovInput/LovInput.js.map +1 -1
- package/dist/components/Form/LovInput/hooks/useLov.js +5 -5
- package/dist/components/Form/LovInput/hooks/useLov.js.map +1 -1
- package/dist/components/Form/LovInput/index.js +4 -4
- package/dist/components/Form/hooks/FormItemValidateTrigger.js +2 -2
- package/dist/components/Form/hooks/FormItemValidateTrigger.js.map +1 -1
- package/dist/components/Form/hooks/index.js +128 -66
- package/dist/components/Form/hooks/index.js.map +1 -1
- package/dist/components/Form/index.js +836 -656
- package/dist/components/Form/index.js.map +1 -1
- package/dist/components/Form/utils/index.js +30 -18
- package/dist/components/Form/utils/index.js.map +1 -1
- package/dist/components/LovTable/LovPagetable.vue.d.ts +28 -0
- package/dist/components/LovTable/index.d.ts +14 -0
- package/dist/components/LovTable/index.js +179 -105
- package/dist/components/LovTable/index.js.map +1 -1
- package/dist/components/Modal/Modal.d.ts +2 -0
- package/dist/components/Modal/ModalLocator.vue.d.ts +20 -0
- package/dist/components/Modal/index.d.ts +4 -1
- package/dist/components/Modal/index.js +127 -0
- package/dist/components/Modal/index.js.map +1 -0
- package/dist/components/Modal/types.d.ts +18 -0
- package/dist/components/Modal/types.js +7 -0
- package/dist/components/Modal/types.js.map +1 -0
- package/dist/components/Modal/useModal.d.ts +1 -3
- package/dist/components/Modal/useModal.js +5 -4
- package/dist/components/Modal/useModal.js.map +1 -1
- package/dist/components/Pagetable/Pagetable.d.ts +13 -0
- package/dist/components/Pagetable/columns/PagetableColumnButtongroup.d.ts +13 -0
- package/dist/components/Pagetable/columns/PagetableColumnDate.d.ts +13 -0
- package/dist/components/Pagetable/columns/PagetableColumnDiy.d.ts +13 -0
- package/dist/components/Pagetable/columns/PagetableColumnLink.d.ts +13 -0
- package/dist/components/Pagetable/columns/PagetableColumnMultiselect.d.ts +13 -0
- package/dist/components/Pagetable/columns/PagetableColumnNumber.d.ts +13 -0
- package/dist/components/Pagetable/columns/PagetableColumnSingleselect.d.ts +13 -0
- package/dist/components/Pagetable/columns/PagetableColumnString.d.ts +13 -0
- package/dist/components/Pagetable/hooks/useColumns.js +88 -74
- package/dist/components/Pagetable/hooks/useColumns.js.map +1 -1
- package/dist/components/Pagetable/index.d.ts +9 -0
- package/dist/components/Pagetable/index.js +697 -491
- package/dist/components/Pagetable/index.js.map +1 -1
- package/dist/components/Pagetable/utils/index.js +92 -54
- package/dist/components/Pagetable/utils/index.js.map +1 -1
- package/dist/components/Querytable/hooks/useColumns.js +82 -74
- package/dist/components/Querytable/hooks/useColumns.js.map +1 -1
- package/dist/components/Querytable/index.js +579 -469
- package/dist/components/Querytable/index.js.map +1 -1
- package/dist/components/Querytable/utils/index.js +92 -54
- package/dist/components/Querytable/utils/index.js.map +1 -1
- package/dist/components/RichTextEditor/index.js +100 -74
- package/dist/components/RichTextEditor/index.js.map +1 -1
- package/dist/components/Tabs/constants.js +2 -2
- package/dist/components/Tabs/constants.js.map +1 -1
- package/dist/components/Tabs/index.js +603 -358
- package/dist/components/Tabs/index.js.map +1 -1
- package/dist/components/Tabs/tab-bar.js +6 -6
- package/dist/components/Tabs/tab-bar.js.map +1 -1
- package/dist/components/Tabs/tab-pane.js +3 -3
- package/dist/components/Tabs/tab-pane.js.map +1 -1
- package/dist/components/_constants/aria.js +2 -2
- package/dist/components/_constants/aria.js.map +1 -1
- package/dist/components/_constants/event.js +6 -4
- package/dist/components/_constants/event.js.map +1 -1
- package/dist/components/_constants/index.js +6 -6
- package/dist/components/_hooks/index.js +7 -7
- package/dist/components/_hooks/use-namespace/index.js +74 -39
- package/dist/components/_hooks/use-namespace/index.js.map +1 -1
- package/dist/components/_hooks/use-ordered-children/index.js +29 -19
- package/dist/components/_hooks/use-ordered-children/index.js.map +1 -1
- package/dist/components/_util/arrays.js +9 -5
- package/dist/components/_util/arrays.js.map +1 -1
- package/dist/components/_util/browser.js +6 -6
- package/dist/components/_util/browser.js.map +1 -1
- package/dist/components/_util/classNames.js +22 -17
- package/dist/components/_util/classNames.js.map +1 -1
- package/dist/components/_util/dom/aria.js +74 -39
- package/dist/components/_util/dom/aria.js.map +1 -1
- package/dist/components/_util/dom/element.js +9 -8
- package/dist/components/_util/dom/element.js.map +1 -1
- package/dist/components/_util/dom/event.js +14 -7
- package/dist/components/_util/dom/event.js.map +1 -1
- package/dist/components/_util/dom/index.js +36 -36
- package/dist/components/_util/dom/position.js +49 -25
- package/dist/components/_util/dom/position.js.map +1 -1
- package/dist/components/_util/dom/scroll.js +103 -61
- package/dist/components/_util/dom/scroll.js.map +1 -1
- package/dist/components/_util/dom/style.js +65 -50
- package/dist/components/_util/dom/style.js.map +1 -1
- package/dist/components/_util/easings.js +8 -4
- package/dist/components/_util/easings.js.map +1 -1
- package/dist/components/_util/error.js +12 -11
- package/dist/components/_util/error.js.map +1 -1
- package/dist/components/_util/functions.js +3 -3
- package/dist/components/_util/i18n.js +2 -2
- package/dist/components/_util/i18n.js.map +1 -1
- package/dist/components/_util/index.js +137 -137
- package/dist/components/_util/isValid.js +4 -2
- package/dist/components/_util/isValid.js.map +1 -1
- package/dist/components/_util/objects.js +18 -14
- package/dist/components/_util/objects.js.map +1 -1
- package/dist/components/_util/props-util/index.js +46 -20
- package/dist/components/_util/props-util/index.js.map +1 -1
- package/dist/components/_util/props-util/initDefaultProps.js +18 -10
- package/dist/components/_util/props-util/initDefaultProps.js.map +1 -1
- package/dist/components/_util/raf.js +5 -4
- package/dist/components/_util/raf.js.map +1 -1
- package/dist/components/_util/rand.js +4 -3
- package/dist/components/_util/rand.js.map +1 -1
- package/dist/components/_util/strings.js +9 -8
- package/dist/components/_util/strings.js.map +1 -1
- package/dist/components/_util/throttleByRaf.js +16 -10
- package/dist/components/_util/throttleByRaf.js.map +1 -1
- package/dist/components/_util/type.js +41 -38
- package/dist/components/_util/type.js.map +1 -1
- package/dist/components/_util/types.js +41 -22
- package/dist/components/_util/types.js.map +1 -1
- package/dist/components/_util/typescript.js +2 -2
- package/dist/components/_util/typescript.js.map +1 -1
- package/dist/components/_util/util.js +85 -43
- package/dist/components/_util/util.js.map +1 -1
- package/dist/components/_util/vue/global-node.js +27 -15
- package/dist/components/_util/vue/global-node.js.map +1 -1
- package/dist/components/_util/vue/icon.js +29 -25
- package/dist/components/_util/vue/icon.js.map +1 -1
- package/dist/components/_util/vue/index.js +41 -41
- package/dist/components/_util/vue/install.js +35 -18
- package/dist/components/_util/vue/install.js.map +1 -1
- package/dist/components/_util/vue/props/index.js +6 -6
- package/dist/components/_util/vue/props/runtime.js +46 -30
- package/dist/components/_util/vue/props/runtime.js.map +1 -1
- package/dist/components/_util/vue/refs.js +12 -6
- package/dist/components/_util/vue/refs.js.map +1 -1
- package/dist/components/_util/vue/size.js +5 -3
- package/dist/components/_util/vue/size.js.map +1 -1
- package/dist/components/_util/vue/validator.js +5 -4
- package/dist/components/_util/vue/validator.js.map +1 -1
- package/dist/components/_util/vue/vnode.js +100 -54
- package/dist/components/_util/vue/vnode.js.map +1 -1
- package/dist/components/_util/vue-types/index.js +231 -220
- package/dist/components/_util/vue-types/index.js.map +1 -1
- package/dist/components/components.js +20 -20
- package/dist/components/index.js +38 -35
- package/dist/components/index.js.map +1 -1
- package/dist/components-8oZ2kpUC.js +27 -0
- package/dist/components-8oZ2kpUC.js.map +1 -0
- package/dist/components-B3d9m_tn.js +27 -0
- package/dist/components-B3d9m_tn.js.map +1 -0
- package/dist/error/OrionError.js +8 -4
- package/dist/error/OrionError.js.map +1 -1
- package/dist/functions-BeMkokbY.js +63 -0
- package/dist/functions-BeMkokbY.js.map +1 -0
- package/dist/index-BOKLZnqH.js +54 -0
- package/dist/index-BOKLZnqH.js.map +1 -0
- package/dist/index-D1m0KTpK.js +69 -0
- package/dist/index-D1m0KTpK.js.map +1 -0
- package/dist/index-DR5ZP7mD.js +160 -0
- package/dist/index-DR5ZP7mD.js.map +1 -0
- package/dist/index-DkwIULcN.js +200 -0
- package/dist/index-DkwIULcN.js.map +1 -0
- package/dist/index.css +797 -1
- package/dist/index.js +36 -36
- package/dist/print/LodopFuncs.js +101 -43
- package/dist/print/LodopFuncs.js.map +1 -1
- package/dist/print/index.js +200 -108
- package/dist/print/index.js.map +1 -1
- package/dist/request/ErrorHandlerChain.js +17 -14
- package/dist/request/ErrorHandlerChain.js.map +1 -1
- package/dist/request/RequestFilterChain.js +16 -13
- package/dist/request/RequestFilterChain.js.map +1 -1
- package/dist/request/ResponseParserChain.js +17 -14
- package/dist/request/ResponseParserChain.js.map +1 -1
- package/dist/request/disivion/DateSerializer.js +47 -22
- package/dist/request/disivion/DateSerializer.js.map +1 -1
- package/dist/request/disivion/DivisionErrorHandler.js +40 -25
- package/dist/request/disivion/DivisionErrorHandler.js.map +1 -1
- package/dist/request/disivion/DivisionResponseParser.js +16 -10
- package/dist/request/disivion/DivisionResponseParser.js.map +1 -1
- package/dist/request/disivion/index.js +305 -201
- package/dist/request/disivion/index.js.map +1 -1
- package/dist/request/error/BizExceptionResponseError.js +11 -5
- package/dist/request/error/BizExceptionResponseError.js.map +1 -1
- package/dist/request/error/ExceptionResponseError.js +11 -5
- package/dist/request/error/ExceptionResponseError.js.map +1 -1
- package/dist/request/error/ResponseError.js +9 -4
- package/dist/request/error/ResponseError.js.map +1 -1
- package/dist/request/error/SessionExceptionResponseError.js +11 -5
- package/dist/request/error/SessionExceptionResponseError.js.map +1 -1
- package/dist/request/index.js +11 -11
- package/dist/utils/DateUtil.js +48 -33
- package/dist/utils/DateUtil.js.map +1 -1
- package/dist/utils/NumberUtil.js +6 -6
- package/dist/utils/NumberUtil.js.map +1 -1
- package/dist/utils/cloneDeep.js +2 -2
- package/dist/utils/delay.js +3 -3
- package/dist/utils/delay.js.map +1 -1
- package/dist/utils/functions.js +3 -3
- package/dist/utils/index.js +12 -12
- package/dist/utils/md5.js +191 -93
- package/dist/utils/md5.js.map +1 -1
- package/dist/utils/uuid.js +35 -25
- package/dist/utils/uuid.js.map +1 -1
- package/dist/version/index.js +2 -2
- package/dist/version/version.d.ts +1 -1
- package/dist/version/version.js +2 -2
- package/dist/version/version.js.map +1 -1
- package/package.json +1 -1
- package/dist/components-J6-qau6Y.js +0 -73
- package/dist/components-J6-qau6Y.js.map +0 -1
@@ -1,83 +1,145 @@
|
|
1
|
-
import { inject
|
2
|
-
import { formContextKey
|
3
|
-
import
|
4
|
-
import { castArray
|
5
|
-
import
|
6
|
-
import
|
7
|
-
const
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
const
|
12
|
-
|
13
|
-
return
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
1
|
+
import { inject, getCurrentInstance, computed } from "vue";
|
2
|
+
import { formContextKey } from "../Form.js";
|
3
|
+
import Throne from "../../../Throne/index.js";
|
4
|
+
import { castArray, isString, isArray } from "lodash-es";
|
5
|
+
import OrionError from "../../../error/OrionError.js";
|
6
|
+
import formItemValidateTrigger from "./FormItemValidateTrigger.js";
|
7
|
+
const useFormContext = () => {
|
8
|
+
return inject(formContextKey);
|
9
|
+
};
|
10
|
+
const useFormItemSpan = () => {
|
11
|
+
const formContext = useFormContext();
|
12
|
+
const { props } = getCurrentInstance();
|
13
|
+
return computed(() => props.span ? props.span : formContext.itemSpan);
|
14
|
+
};
|
15
|
+
const useFormItemRules = () => {
|
16
|
+
const formContext = useFormContext();
|
17
|
+
const { props, type } = getCurrentInstance();
|
18
|
+
const { name, label, required } = props;
|
19
|
+
let trigger = formItemValidateTrigger[type.name];
|
20
|
+
if (!trigger) {
|
21
|
+
trigger = "change";
|
22
|
+
}
|
23
|
+
return computed(() => {
|
24
|
+
const rules = [];
|
25
|
+
let flag = true;
|
26
|
+
if (required) {
|
27
|
+
if (props.rules) {
|
28
|
+
rules.push(...castArray(props.rules));
|
29
|
+
flag = !rules.some((rule) => Object.keys(rule).includes("required"));
|
30
|
+
}
|
31
|
+
if (formContext.rules && formContext.rules[name]) {
|
32
|
+
const formRules = castArray(formContext.rules[name]);
|
33
|
+
flag = !formRules.some((rule) => Object.keys(rule).includes("required"));
|
34
|
+
}
|
35
|
+
}
|
36
|
+
if (flag) {
|
37
|
+
rules.push({
|
38
|
+
required: true,
|
39
|
+
message: `必填项[${label ? label : name}]不能为空`,
|
40
|
+
trigger
|
41
|
+
});
|
42
|
+
}
|
43
|
+
return rules;
|
21
44
|
});
|
22
|
-
}
|
23
|
-
|
24
|
-
|
25
|
-
}
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
throw new
|
35
|
-
|
36
|
-
|
37
|
-
}
|
38
|
-
|
39
|
-
|
45
|
+
};
|
46
|
+
const useFormItemDisabled = () => {
|
47
|
+
const formContext = useFormContext();
|
48
|
+
const { props } = getCurrentInstance();
|
49
|
+
return computed(() => formContext.disabled || props.disabled);
|
50
|
+
};
|
51
|
+
const useFormItemCode = () => {
|
52
|
+
const { props } = getCurrentInstance();
|
53
|
+
return computed(() => {
|
54
|
+
let codeData;
|
55
|
+
const { code } = props;
|
56
|
+
if (!code) {
|
57
|
+
throw new OrionError("code为空");
|
58
|
+
} else if (isString(code)) {
|
59
|
+
codeData = Throne.getCode(code).value;
|
60
|
+
} else if (isArray(code)) {
|
61
|
+
codeData = code;
|
62
|
+
} else {
|
63
|
+
throw new OrionError("code类型错误");
|
64
|
+
}
|
65
|
+
return codeData;
|
66
|
+
});
|
67
|
+
};
|
68
|
+
const useFormItemStringModel = () => {
|
69
|
+
const formContext = useFormContext();
|
70
|
+
const { props } = getCurrentInstance();
|
71
|
+
const { name } = props;
|
72
|
+
return computed({
|
40
73
|
get: () => {
|
41
|
-
const
|
42
|
-
|
74
|
+
const value = formContext.modelValue[name];
|
75
|
+
if (!value) {
|
76
|
+
return "";
|
77
|
+
}
|
78
|
+
return value;
|
43
79
|
},
|
44
|
-
set: (
|
45
|
-
|
80
|
+
set: (newValue) => {
|
81
|
+
if (!newValue) {
|
82
|
+
formContext.updateModelValue(name, "");
|
83
|
+
} else {
|
84
|
+
formContext.updateModelValue(name, newValue);
|
85
|
+
}
|
46
86
|
}
|
47
87
|
});
|
48
|
-
}
|
49
|
-
|
50
|
-
|
88
|
+
};
|
89
|
+
const useFormItemMultiModel = () => {
|
90
|
+
const formContext = useFormContext();
|
91
|
+
const { props } = getCurrentInstance();
|
92
|
+
const { name } = props;
|
93
|
+
return computed({
|
51
94
|
get: () => {
|
52
|
-
const
|
53
|
-
if (
|
54
|
-
return
|
95
|
+
const value = formContext.modelValue[name];
|
96
|
+
if (!value) {
|
97
|
+
return void 0;
|
98
|
+
}
|
99
|
+
return value.split(",");
|
55
100
|
},
|
56
|
-
set: (
|
57
|
-
|
101
|
+
set: (newValue) => {
|
102
|
+
if (!newValue) {
|
103
|
+
formContext.updateModelValue(name, "");
|
104
|
+
} else {
|
105
|
+
formContext.updateModelValue(name, newValue.join(","));
|
106
|
+
}
|
58
107
|
}
|
59
108
|
});
|
60
|
-
}
|
61
|
-
|
62
|
-
|
109
|
+
};
|
110
|
+
const useFormItemBooleanModel = () => {
|
111
|
+
const formContext = useFormContext();
|
112
|
+
const { props } = getCurrentInstance();
|
113
|
+
const { name } = props;
|
114
|
+
return computed({
|
63
115
|
get: () => {
|
64
|
-
const
|
65
|
-
|
116
|
+
const value = formContext.modelValue[name];
|
117
|
+
if (!value) {
|
118
|
+
return false;
|
119
|
+
}
|
120
|
+
return value == "1";
|
66
121
|
},
|
67
|
-
set: (
|
68
|
-
const
|
69
|
-
|
122
|
+
set: (_newValue) => {
|
123
|
+
const oldValue = formContext.modelValue[name];
|
124
|
+
const newValue = _newValue ? "1" : "0";
|
125
|
+
if (oldValue) {
|
126
|
+
formContext.updateModelValue(name, newValue);
|
127
|
+
} else {
|
128
|
+
if (_newValue) {
|
129
|
+
formContext.updateModelValue(name, newValue);
|
130
|
+
}
|
131
|
+
}
|
70
132
|
}
|
71
133
|
});
|
72
134
|
};
|
73
135
|
export {
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
136
|
+
useFormContext,
|
137
|
+
useFormItemBooleanModel,
|
138
|
+
useFormItemCode,
|
139
|
+
useFormItemDisabled,
|
140
|
+
useFormItemMultiModel,
|
141
|
+
useFormItemRules,
|
142
|
+
useFormItemSpan,
|
143
|
+
useFormItemStringModel
|
82
144
|
};
|
83
145
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/Form/hooks/index.ts"],"sourcesContent":["import { inject, getCurrentInstance, computed } from 'vue'\r\nimport { formContextKey, FormItemRule } from '../Form'\r\nimport Throne from '../../../Throne'\r\nimport { CodeItem } from '../../types'\r\nimport { castArray, isArray, isString } from 'lodash-es'\r\nimport OrionError from '../../../error/OrionError'\r\nimport formItemValidateTrigger from './FormItemValidateTrigger'\r\n\r\nconst useFormContext = () => {\r\n return inject(formContextKey)\r\n}\r\n\r\nconst useFormItemSpan = () => {\r\n const formContext = useFormContext()!\r\n const { props } = getCurrentInstance()!\r\n\r\n return computed(() => (props.span ? (props.span as number) : formContext.itemSpan))\r\n}\r\n\r\nconst useFormItemRules = () => {\r\n const formContext = useFormContext()!\r\n const { props, type } = getCurrentInstance()!\r\n const { name, label, required } = props\r\n let trigger = formItemValidateTrigger[type.name!]\r\n if (!trigger) {\r\n trigger = 'change'\r\n }\r\n\r\n return computed(() => {\r\n const rules: FormItemRule[] = []\r\n let flag = true\r\n\r\n if (required) {\r\n if (props.rules) {\r\n rules.push(...castArray(props.rules))\r\n flag = !rules.some((rule) => Object.keys(rule).includes('required'))\r\n }\r\n if (formContext.rules && formContext.rules[name as string]) {\r\n const formRules = castArray(formContext.rules[name as string])\r\n flag = !formRules.some((rule) => Object.keys(rule).includes('required'))\r\n }\r\n }\r\n\r\n if (flag) {\r\n rules.push({\r\n required: true,\r\n message: `必填项[${label ? label : name}]不能为空`,\r\n trigger: trigger,\r\n })\r\n }\r\n\r\n return rules\r\n })\r\n}\r\n\r\nconst useFormItemDisabled = () => {\r\n const formContext = useFormContext()!\r\n const { props } = getCurrentInstance()!\r\n return computed(() => formContext.disabled || (props.disabled as boolean))\r\n}\r\n\r\nconst useFormItemCode = () => {\r\n
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/Form/hooks/index.ts"],"sourcesContent":["import { inject, getCurrentInstance, computed } from 'vue'\r\nimport { formContextKey, FormItemRule } from '../Form'\r\nimport Throne from '../../../Throne'\r\nimport { CodeItem } from '../../types'\r\nimport { castArray, isArray, isString } from 'lodash-es'\r\nimport OrionError from '../../../error/OrionError'\r\nimport formItemValidateTrigger from './FormItemValidateTrigger'\r\n\r\nconst useFormContext = () => {\r\n return inject(formContextKey)\r\n}\r\n\r\nconst useFormItemSpan = () => {\r\n const formContext = useFormContext()!\r\n const { props } = getCurrentInstance()!\r\n\r\n return computed(() => (props.span ? (props.span as number) : formContext.itemSpan))\r\n}\r\n\r\nconst useFormItemRules = () => {\r\n const formContext = useFormContext()!\r\n const { props, type } = getCurrentInstance()!\r\n const { name, label, required } = props\r\n let trigger = formItemValidateTrigger[type.name!]\r\n if (!trigger) {\r\n trigger = 'change'\r\n }\r\n\r\n return computed(() => {\r\n const rules: FormItemRule[] = []\r\n let flag = true\r\n\r\n if (required) {\r\n if (props.rules) {\r\n rules.push(...castArray(props.rules))\r\n flag = !rules.some((rule) => Object.keys(rule).includes('required'))\r\n }\r\n if (formContext.rules && formContext.rules[name as string]) {\r\n const formRules = castArray(formContext.rules[name as string])\r\n flag = !formRules.some((rule) => Object.keys(rule).includes('required'))\r\n }\r\n }\r\n\r\n if (flag) {\r\n rules.push({\r\n required: true,\r\n message: `必填项[${label ? label : name}]不能为空`,\r\n trigger: trigger,\r\n })\r\n }\r\n\r\n return rules\r\n })\r\n}\r\n\r\nconst useFormItemDisabled = () => {\r\n const formContext = useFormContext()!\r\n const { props } = getCurrentInstance()!\r\n return computed(() => formContext.disabled || (props.disabled as boolean))\r\n}\r\n\r\nconst useFormItemCode = () => {\r\n const { props } = getCurrentInstance()!\r\n\r\n return computed(() => {\r\n let codeData: Array<CodeItem>\r\n const { code } = props\r\n if (!code) {\r\n throw new OrionError('code为空')\r\n } else if (isString(code)) {\r\n codeData = Throne.getCode(code).value\r\n } else if (isArray<CodeItem>(code)) {\r\n codeData = code\r\n } else {\r\n throw new OrionError('code类型错误')\r\n }\r\n\r\n return codeData\r\n })\r\n}\r\n\r\nconst useFormItemStringModel = () => {\r\n const formContext = useFormContext()!\r\n const { props } = getCurrentInstance()!\r\n const { name } = props\r\n\r\n return computed<string>({\r\n get: () => {\r\n const value = formContext.modelValue[name as string]\r\n if (!value) {\r\n return ''\r\n }\r\n return value as string\r\n },\r\n set: (newValue) => {\r\n if (!newValue) {\r\n formContext.updateModelValue(name as string, '')\r\n } else {\r\n formContext.updateModelValue(name as string, newValue)\r\n }\r\n },\r\n })\r\n}\r\n\r\nconst useFormItemMultiModel = () => {\r\n const formContext = useFormContext()!\r\n const { props } = getCurrentInstance()!\r\n const { name } = props\r\n\r\n return computed<string[] | undefined>({\r\n get: () => {\r\n const value = formContext.modelValue[name as string]\r\n if (!value) {\r\n return undefined\r\n }\r\n return (value as string).split(',')\r\n },\r\n set: (newValue) => {\r\n if (!newValue) {\r\n formContext.updateModelValue(name as string, '')\r\n } else {\r\n formContext.updateModelValue(name as string, newValue.join(','))\r\n }\r\n },\r\n })\r\n}\r\n\r\nconst useFormItemBooleanModel = () => {\r\n const formContext = useFormContext()!\r\n const { props } = getCurrentInstance()!\r\n const { name } = props\r\n\r\n return computed<boolean>({\r\n get: () => {\r\n const value = formContext.modelValue[name as string]\r\n if (!value) {\r\n return false\r\n }\r\n return (value as string) == '1'\r\n },\r\n set: (_newValue) => {\r\n const oldValue = formContext.modelValue[name as string]\r\n const newValue = _newValue ? '1' : '0'\r\n if (oldValue) {\r\n formContext.updateModelValue(name as string, newValue)\r\n } else {\r\n if (_newValue) {\r\n formContext.updateModelValue(name as string, newValue)\r\n }\r\n }\r\n },\r\n })\r\n}\r\n\r\nexport {\r\n useFormContext,\r\n useFormItemSpan,\r\n useFormItemRules,\r\n useFormItemDisabled,\r\n useFormItemCode,\r\n useFormItemStringModel,\r\n useFormItemMultiModel,\r\n useFormItemBooleanModel,\r\n}\r\n"],"names":[],"mappings":";;;;;;AAQA,MAAM,iBAAiB,MAAM;AAC3B,SAAO,OAAO,cAAc;AAC9B;AAEA,MAAM,kBAAkB,MAAM;AAC5B,QAAM,cAAc;AACd,QAAA,EAAE,UAAU;AAElB,SAAO,SAAS,MAAO,MAAM,OAAQ,MAAM,OAAkB,YAAY,QAAS;AACpF;AAEA,MAAM,mBAAmB,MAAM;AAC7B,QAAM,cAAc;AACpB,QAAM,EAAE,OAAO,KAAK,IAAI,mBAAmB;AAC3C,QAAM,EAAE,MAAM,OAAO,SAAA,IAAa;AAC9B,MAAA,UAAU,wBAAwB,KAAK,IAAK;AAChD,MAAI,CAAC,SAAS;AACF,cAAA;AAAA,EACZ;AAEA,SAAO,SAAS,MAAM;AACpB,UAAM,QAAwB,CAAA;AAC9B,QAAI,OAAO;AAEX,QAAI,UAAU;AACZ,UAAI,MAAM,OAAO;AACf,cAAM,KAAK,GAAG,UAAU,MAAM,KAAK,CAAC;AAC7B,eAAA,CAAC,MAAM,KAAK,CAAC,SAAS,OAAO,KAAK,IAAI,EAAE,SAAS,UAAU,CAAC;AAAA,MACrE;AACA,UAAI,YAAY,SAAS,YAAY,MAAM,IAAc,GAAG;AAC1D,cAAM,YAAY,UAAU,Y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