szld-libs 0.4.38 → 0.4.40
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/dist/szld-components.es.js +3550 -3538
- package/dist/szld-components.umd.js +29 -29
- package/es/components/DynamicForm/func.js +4 -1
- package/es/components/DynamicForm/useDynamicForm.js +3 -3
- package/es/components/DynamicFormMobile/func.js +4 -1
- package/es/components/DynamicFormMobile/myCalendar/index.js +4 -2
- package/es/components/DynamicFormMobile/useDynamicForm.js +5 -5
- package/es/index.js +10 -4
- package/es/mock/index.js +225 -366
- package/es/utils/method.js +7 -4
- package/es/utils/szxkFunc.d.ts +1 -0
- package/es/utils/szxkFunc.js +10 -1
- package/lib/components/DynamicForm/func.js +4 -1
- package/lib/components/DynamicForm/useDynamicForm.js +3 -3
- package/lib/components/DynamicFormMobile/func.js +4 -1
- package/lib/components/DynamicFormMobile/myCalendar/index.js +4 -2
- package/lib/components/DynamicFormMobile/useDynamicForm.js +5 -5
- package/lib/index.js +8 -2
- package/lib/mock/index.js +225 -366
- package/lib/utils/method.js +7 -4
- package/lib/utils/szxkFunc.d.ts +1 -0
- package/lib/utils/szxkFunc.js +9 -0
- package/package.json +2 -2
package/es/utils/method.js
CHANGED
|
@@ -160,18 +160,21 @@ const handleSubmitForm = (originalData, allValues) => {
|
|
|
160
160
|
}
|
|
161
161
|
if (isAutoFill) {
|
|
162
162
|
(_a = updatedData == null ? void 0 : updatedData.attr_list) == null ? void 0 : _a.forEach((v) => {
|
|
163
|
-
var _a2, _b, _c, _d, _e, _f;
|
|
163
|
+
var _a2, _b, _c, _d, _e, _f, _g;
|
|
164
164
|
const attrvalue = (v == null ? void 0 : v.attrvalue) || "";
|
|
165
165
|
if (((_a2 = v == null ? void 0 : v.json) == null ? void 0 : _a2["auto-generate"]) && ((_b = v == null ? void 0 : v.json) == null ? void 0 : _b["auto-generate-type"]) && !attrvalue) {
|
|
166
166
|
if (((_c = v == null ? void 0 : v.json) == null ? void 0 : _c["auto-generate-type"]) === "currenttime") {
|
|
167
167
|
v.attrvalue = dayjs().format("YYYY-MM-DD HH:mm:ss");
|
|
168
168
|
}
|
|
169
|
-
if (((_d = v == null ? void 0 : v.json) == null ? void 0 : _d["auto-generate-type"]) === "
|
|
169
|
+
if (((_d = v == null ? void 0 : v.json) == null ? void 0 : _d["auto-generate-type"]) === "currenttimestamp") {
|
|
170
|
+
v.attrvalue = dayjs().unix().toString();
|
|
171
|
+
}
|
|
172
|
+
if (((_e = v == null ? void 0 : v.json) == null ? void 0 : _e["auto-generate-type"]) === "guid" && !attrvalue) {
|
|
170
173
|
v.attrvalue = onlyNumber || guid || "";
|
|
171
174
|
}
|
|
172
175
|
}
|
|
173
|
-
if (((
|
|
174
|
-
v.attrvalue = (
|
|
176
|
+
if (((_f = v == null ? void 0 : v.json) == null ? void 0 : _f["default"]) && !attrvalue) {
|
|
177
|
+
v.attrvalue = (_g = v == null ? void 0 : v.json) == null ? void 0 : _g["default"];
|
|
175
178
|
}
|
|
176
179
|
});
|
|
177
180
|
}
|
package/es/utils/szxkFunc.d.ts
CHANGED
|
@@ -69,3 +69,4 @@ export declare const handleSetTableRowColor: (record: any, index: number | undef
|
|
|
69
69
|
export declare const handleFormatMobileDate: (values: Record<string, any>, format?: string) => Record<string, any>;
|
|
70
70
|
export declare const handleNonUniversalHeader: (nonUniversalHeader: Record<string, string>, data: Record<string, any>) => Record<string, any>;
|
|
71
71
|
export declare const handleGetControlPanelConfig: (sourceNumber: string | number, commonRequest: (InterfaceType: string, data?: any) => Promise<AxiosResponse<any, any>>) => Promise<any>;
|
|
72
|
+
export declare const isJson: (str: string) => boolean;
|
package/es/utils/szxkFunc.js
CHANGED
|
@@ -98,6 +98,14 @@ const handleGetControlPanelConfig = async (sourceNumber, commonRequest) => {
|
|
|
98
98
|
} catch (error) {
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
|
+
const isJson = (str) => {
|
|
102
|
+
try {
|
|
103
|
+
JSON.parse(str);
|
|
104
|
+
return true;
|
|
105
|
+
} catch (e) {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
101
109
|
export {
|
|
102
110
|
handleCallSupportCode,
|
|
103
111
|
handleFormatMobileDate,
|
|
@@ -107,5 +115,6 @@ export {
|
|
|
107
115
|
handleGetList,
|
|
108
116
|
handleNonUniversalHeader,
|
|
109
117
|
handleObjDetailToSignleAttrList,
|
|
110
|
-
handleSetTableRowColor
|
|
118
|
+
handleSetTableRowColor,
|
|
119
|
+
isJson
|
|
111
120
|
};
|
|
@@ -36,7 +36,7 @@ const handleGetPlaceholder = (itemWithJson, langId) => {
|
|
|
36
36
|
return defaultMessage;
|
|
37
37
|
};
|
|
38
38
|
const handleSetFormItemInitialValue = (itemWithJson) => {
|
|
39
|
-
var _a, _b, _c, _d, _e, _f;
|
|
39
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
40
40
|
const inputType = (_a = itemWithJson.json) == null ? void 0 : _a.input;
|
|
41
41
|
let initialValue = itemWithJson.attrvalue || ((_b = itemWithJson.json) == null ? void 0 : _b.default);
|
|
42
42
|
if (inputType === "label" && initialValue) {
|
|
@@ -83,6 +83,9 @@ const handleSetFormItemInitialValue = (itemWithJson) => {
|
|
|
83
83
|
if (inputType === "time-picker" && !initialValue && ((_e = itemWithJson.json) == null ? void 0 : _e["auto-generate"]) && ((_f = itemWithJson.json) == null ? void 0 : _f["auto-generate-type"]) === "currenttime") {
|
|
84
84
|
initialValue = dayjs().format("YYYY-MM-DD HH:mm:ss:ss");
|
|
85
85
|
}
|
|
86
|
+
if (inputType === "time-picker" && !initialValue && ((_g = itemWithJson.json) == null ? void 0 : _g["auto-generate"]) && ((_h = itemWithJson.json) == null ? void 0 : _h["auto-generate-type"]) === "currenttimestamp") {
|
|
87
|
+
initialValue = dayjs().unix().toString();
|
|
88
|
+
}
|
|
86
89
|
if (itemWithJson.attrtype === 1) {
|
|
87
90
|
initialValue = handleGetSingleAttrListObj(itemWithJson.children || []);
|
|
88
91
|
}
|
|
@@ -334,7 +334,7 @@ function useDynamicForm(props) {
|
|
|
334
334
|
antd.Form.Item,
|
|
335
335
|
{
|
|
336
336
|
label: (_d = itemWithJson == null ? void 0 : itemWithJson.json) == null ? void 0 : _d["combination-name"],
|
|
337
|
-
required: (_e = itemWithJson.json) == null ? void 0 : _e.must,
|
|
337
|
+
required: ((_e = itemWithJson.json) == null ? void 0 : _e.must) && !hidden,
|
|
338
338
|
children: /* @__PURE__ */ jsxRuntime.jsx(antd.Space.Compact, { children: combinations.map((item, index) => {
|
|
339
339
|
var _a2, _b2, _c2, _d2, _e2;
|
|
340
340
|
let initValue = func.handleSetFormItemInitialValue(item);
|
|
@@ -360,7 +360,7 @@ function useDynamicForm(props) {
|
|
|
360
360
|
noStyle: true,
|
|
361
361
|
initialValue: initValue,
|
|
362
362
|
rules: [
|
|
363
|
-
...((_c2 = item.json) == null ? void 0 : _c2.must) ? [
|
|
363
|
+
...((_c2 = item.json) == null ? void 0 : _c2.must) && !hidden ? [
|
|
364
364
|
{
|
|
365
365
|
required: true,
|
|
366
366
|
message: message2 || `${placeholder}${item.attrname}`
|
|
@@ -401,7 +401,7 @@ function useDynamicForm(props) {
|
|
|
401
401
|
initialValue,
|
|
402
402
|
hidden,
|
|
403
403
|
rules: [
|
|
404
|
-
...((_f = itemWithJson.json) == null ? void 0 : _f.must) ? [
|
|
404
|
+
...((_f = itemWithJson.json) == null ? void 0 : _f.must) && !hidden ? [
|
|
405
405
|
{
|
|
406
406
|
required: true,
|
|
407
407
|
message: `${placeholder}${itemWithJson.attrname}`
|
|
@@ -36,7 +36,7 @@ const handleGetPlaceholder = (itemWithJson, langId) => {
|
|
|
36
36
|
return defaultMessage;
|
|
37
37
|
};
|
|
38
38
|
const handleSetFormItemInitialValue = (itemWithJson) => {
|
|
39
|
-
var _a, _b, _c, _d, _e, _f;
|
|
39
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
40
40
|
const inputType = (_a = itemWithJson.json) == null ? void 0 : _a.input;
|
|
41
41
|
let initialValue = itemWithJson.attrvalue || ((_b = itemWithJson.json) == null ? void 0 : _b.default) || "";
|
|
42
42
|
if (inputType === "label" && initialValue) {
|
|
@@ -82,6 +82,9 @@ const handleSetFormItemInitialValue = (itemWithJson) => {
|
|
|
82
82
|
if (inputType === "time-picker" && !initialValue && ((_e = itemWithJson.json) == null ? void 0 : _e["auto-generate"]) && ((_f = itemWithJson.json) == null ? void 0 : _f["auto-generate-type"]) === "currenttime") {
|
|
83
83
|
initialValue = dayjs().format("YYYY-MM-DD HH:mm:ss:ss");
|
|
84
84
|
}
|
|
85
|
+
if (inputType === "time-picker" && !initialValue && ((_g = itemWithJson.json) == null ? void 0 : _g["auto-generate"]) && ((_h = itemWithJson.json) == null ? void 0 : _h["auto-generate-type"]) === "currenttimestamp") {
|
|
86
|
+
initialValue = dayjs().unix().toString();
|
|
87
|
+
}
|
|
85
88
|
if (itemWithJson.attrtype === 1) {
|
|
86
89
|
initialValue = handleGetSingleAttrListObj(itemWithJson.children || []);
|
|
87
90
|
}
|
|
@@ -53,10 +53,12 @@ const StringCompatibleCalendar = (props) => {
|
|
|
53
53
|
onChange(str);
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
|
+
const placeholder = langId === "10001" ? "请选择日期" : "Please select a date";
|
|
56
57
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(reactVant.Calendar, { type, value: internalValue, onConfirm: handleChange, children: (val, actions) => {
|
|
57
58
|
const valType = typeof val;
|
|
59
|
+
const delimiter = type === "multiple" ? "," : "~";
|
|
58
60
|
if (valType === "string") {
|
|
59
|
-
val = val.split(
|
|
61
|
+
val = val.split(delimiter);
|
|
60
62
|
if (val.length === 1) {
|
|
61
63
|
val = [val[0], val[1]];
|
|
62
64
|
}
|
|
@@ -67,7 +69,7 @@ const StringCompatibleCalendar = (props) => {
|
|
|
67
69
|
style: { padding: 0 },
|
|
68
70
|
value: val ? val.map(
|
|
69
71
|
(el) => dayjs(el).format("YYYY-MM-DD")
|
|
70
|
-
).join(
|
|
72
|
+
).join(delimiter) : placeholder,
|
|
71
73
|
onClick: (e) => {
|
|
72
74
|
actions.open();
|
|
73
75
|
}
|
|
@@ -304,14 +304,14 @@ function useDynamicForm(props) {
|
|
|
304
304
|
flex: width,
|
|
305
305
|
pointerEvents: readonly ? "none" : "auto",
|
|
306
306
|
opacity: readonly ? 0.5 : 1,
|
|
307
|
-
display: hidden ? "none" : "
|
|
307
|
+
display: hidden ? "none" : "flex"
|
|
308
308
|
},
|
|
309
309
|
label: index === 0 ? (_b2 = itemWithJson == null ? void 0 : itemWithJson.json) == null ? void 0 : _b2["combination-name"] : /* @__PURE__ */ jsxRuntime.jsx("div", { style: { visibility: "hidden" }, children: (_c2 = itemWithJson == null ? void 0 : itemWithJson.json) == null ? void 0 : _c2["combination-name"] }),
|
|
310
|
-
required: index === 0 ? (_d2 = item.json) == null ? void 0 : _d2.must : false,
|
|
310
|
+
required: index === 0 ? ((_d2 = item.json) == null ? void 0 : _d2.must) && !hidden : false,
|
|
311
311
|
name: formListField ? Array.isArray(formListField.name) ? [...formListField.name, item.attrid] : [formListField.name, item.attrid] : item.attrid,
|
|
312
312
|
initialValue: initValue,
|
|
313
313
|
rules: [
|
|
314
|
-
...((_e2 = item.json) == null ? void 0 : _e2.must) ? [
|
|
314
|
+
...((_e2 = item.json) == null ? void 0 : _e2.must) && !hidden ? [
|
|
315
315
|
{
|
|
316
316
|
required: true,
|
|
317
317
|
message: message2 || `${placeholder}${item.attrname}`
|
|
@@ -352,10 +352,10 @@ function useDynamicForm(props) {
|
|
|
352
352
|
style: {
|
|
353
353
|
pointerEvents: readonly ? "none" : "auto",
|
|
354
354
|
opacity: readonly ? 0.5 : 1,
|
|
355
|
-
display: hidden ? "none" : "
|
|
355
|
+
display: hidden ? "none" : "flex"
|
|
356
356
|
},
|
|
357
357
|
rules: [
|
|
358
|
-
...((_e = itemWithJson.json) == null ? void 0 : _e.must) ? [
|
|
358
|
+
...((_e = itemWithJson.json) == null ? void 0 : _e.must) && !hidden ? [
|
|
359
359
|
{
|
|
360
360
|
required: true,
|
|
361
361
|
message: `${placeholder}${itemWithJson.attrname}`
|
package/lib/index.js
CHANGED
|
@@ -27,10 +27,16 @@ const Demo = () => {
|
|
|
27
27
|
}, 2e3);
|
|
28
28
|
}, []);
|
|
29
29
|
const onFinish = async (values) => {
|
|
30
|
+
method.handleSubmitForm(
|
|
31
|
+
{
|
|
32
|
+
attr_list: mock.attrList
|
|
33
|
+
},
|
|
34
|
+
values
|
|
35
|
+
);
|
|
30
36
|
};
|
|
31
37
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { height: "100vh", display: "flex", flexDirection: "column", gap: 20 }, children: [
|
|
32
38
|
/* @__PURE__ */ jsxRuntime.jsx(main.BackHeader, { title: "页头组件", isBack: true }),
|
|
33
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { padding: "20px" }, children: /* @__PURE__ */ jsxRuntime.jsxs(reactVant.Form, { form, onValuesChange, onFinish, children: [
|
|
39
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { padding: "20px" }, children: /* @__PURE__ */ jsxRuntime.jsxs(reactVant.Form, { form, onValuesChange, layout: "vertical", onFinish, children: [
|
|
34
40
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
35
41
|
main.DynamicFormMobile,
|
|
36
42
|
{
|
|
@@ -48,7 +54,7 @@ const Demo = () => {
|
|
|
48
54
|
langId
|
|
49
55
|
}
|
|
50
56
|
),
|
|
51
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactVant.Form.Item, { name: "submit", style: { marginLeft: "auto" }
|
|
57
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactVant.Form.Item, { name: "submit", style: { marginLeft: "auto" } })
|
|
52
58
|
] }) }),
|
|
53
59
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
54
60
|
"2. 测试循环滚动组件",
|