szld-libs 0.3.21 → 0.3.22
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 +14449 -14234
- package/dist/szld-components.umd.js +50 -50
- package/es/hooks/useDetailRender.d.ts +13 -7
- package/es/hooks/useDetailRender.js +162 -83
- package/lib/hooks/useDetailRender.d.ts +13 -7
- package/lib/hooks/useDetailRender.js +160 -81
- package/package.json +1 -1
- package/es/hooks/useRenderAttrSetDetail.d.ts +0 -25
- package/es/hooks/useRenderAttrSetDetail.js +0 -204
- package/lib/hooks/useRenderAttrSetDetail.d.ts +0 -25
- package/lib/hooks/useRenderAttrSetDetail.js +0 -203
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 宠物详情渲染 Hook
|
|
3
|
-
* @param
|
|
3
|
+
* @param attrList 属性列表数据
|
|
4
4
|
* @param config 配置信息(用于文件预览地址)
|
|
5
5
|
* @returns 渲染函数
|
|
6
6
|
*/
|
|
7
|
-
interface
|
|
8
|
-
detailInfo: any;
|
|
9
|
-
mainApplicationDomain: string;
|
|
7
|
+
interface IAttrSetDetailRendererProps {
|
|
10
8
|
labelSpan?: number;
|
|
11
9
|
valueSpan?: number;
|
|
12
10
|
imgWidth?: number;
|
|
13
11
|
imgHeight?: number;
|
|
14
|
-
|
|
12
|
+
layoutType?: 'row' | 'flex';
|
|
15
13
|
}
|
|
16
|
-
export default function
|
|
17
|
-
renderDetail: (
|
|
14
|
+
export default function useAttrSetDetailRenderer({ labelSpan, valueSpan, imgWidth, imgHeight, layoutType, }: IAttrSetDetailRendererProps): {
|
|
15
|
+
renderDetail: ({ attrList, detailList, span, type, universalHeader, beforeExtraValue, operationColumn, }: {
|
|
16
|
+
attrList?: any[] | undefined;
|
|
17
|
+
detailList?: any[] | undefined;
|
|
18
|
+
span?: number | undefined;
|
|
19
|
+
type?: "form" | "table" | undefined;
|
|
20
|
+
universalHeader?: any[] | undefined;
|
|
21
|
+
beforeExtraValue?: string | undefined;
|
|
22
|
+
operationColumn?: any;
|
|
23
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
18
24
|
};
|
|
19
25
|
export {};
|
|
@@ -1,24 +1,43 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
1
|
+
import { jsx, jsxs, Fragment as Fragment$1 } from "react/jsx-runtime";
|
|
2
|
+
import { getJson, base64ToString } from "szld-libs/lib/utils/method";
|
|
3
|
+
import { App, Row, Col, Flex, Table, Space, Image } from "antd";
|
|
4
|
+
import { handleSetTableRowColor } from "../utils/szxkFunc";
|
|
5
|
+
import { useMemoizedFn } from "ahooks";
|
|
3
6
|
import { Fragment } from "react";
|
|
4
|
-
function
|
|
5
|
-
detailInfo,
|
|
7
|
+
function useAttrSetDetailRenderer({
|
|
6
8
|
labelSpan = 3,
|
|
7
9
|
valueSpan = 9,
|
|
8
10
|
imgWidth = 93,
|
|
9
11
|
imgHeight = 93,
|
|
10
|
-
|
|
11
|
-
mainApplicationDomain = ""
|
|
12
|
+
layoutType = "row"
|
|
12
13
|
}) {
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
const { message } = App.useApp();
|
|
15
|
+
const renderRadioCardAttr = (item, span) => {
|
|
16
|
+
try {
|
|
17
|
+
const attrvalue = JSON.parse((item == null ? void 0 : item.attrvalue) || "{}") || "";
|
|
18
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
19
|
+
layoutType === "flex" && /* @__PURE__ */ jsx(Col, { span, children: /* @__PURE__ */ jsxs(Flex, { children: [
|
|
20
|
+
/* @__PURE__ */ jsxs("span", { style: { flexShrink: 0 }, children: [
|
|
21
|
+
item == null ? void 0 : item.attrname,
|
|
22
|
+
":"
|
|
23
|
+
] }),
|
|
24
|
+
/* @__PURE__ */ jsx("span", { style: { wordWrap: "break-word" }, children: attrvalue == null ? void 0 : attrvalue.typename })
|
|
25
|
+
] }) }),
|
|
26
|
+
layoutType === "row" && /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
27
|
+
/* @__PURE__ */ jsx(Col, { span: labelSpan, children: item == null ? void 0 : item.attrname }),
|
|
28
|
+
/* @__PURE__ */ jsx(Col, { span: valueSpan, style: { wordWrap: "break-word" }, children: item == null ? void 0 : item.attrvalue })
|
|
29
|
+
] })
|
|
30
|
+
] }, item == null ? void 0 : item.attrid);
|
|
31
|
+
} catch (error) {
|
|
32
|
+
message.error("房型数据格式错误,转json失败");
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
16
35
|
};
|
|
17
|
-
const renderImageAttr = (item) => {
|
|
36
|
+
const renderImageAttr = (item, span) => {
|
|
18
37
|
if (typeof (item == null ? void 0 : item.attrvalue) !== "string")
|
|
19
38
|
return;
|
|
20
39
|
const attrvalues = JSON.parse((item == null ? void 0 : item.attrvalue) || "[]");
|
|
21
|
-
const
|
|
40
|
+
const valueNode = () => /* @__PURE__ */ jsx(Space, { wrap: true, children: attrvalues.map((el, index) => /* @__PURE__ */ jsx(
|
|
22
41
|
"div",
|
|
23
42
|
{
|
|
24
43
|
style: {
|
|
@@ -33,93 +52,153 @@ function useDetailRenderer({
|
|
|
33
52
|
height: imgHeight,
|
|
34
53
|
src: el == null ? void 0 : el.FilePath,
|
|
35
54
|
alt: (item == null ? void 0 : item.attrname) || "-"
|
|
36
|
-
}
|
|
37
|
-
index
|
|
55
|
+
}
|
|
38
56
|
)
|
|
39
57
|
},
|
|
40
58
|
index
|
|
41
59
|
)) });
|
|
42
|
-
if (!useGrid) {
|
|
43
|
-
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Col, { span: labelSpan, children: [
|
|
44
|
-
item == null ? void 0 : item.attrname,
|
|
45
|
-
":",
|
|
46
|
-
renderItem
|
|
47
|
-
] }) }, item.attrid);
|
|
48
|
-
}
|
|
49
60
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
50
|
-
/* @__PURE__ */ jsx(Col, { span
|
|
51
|
-
|
|
52
|
-
|
|
61
|
+
layoutType === "flex" && /* @__PURE__ */ jsx(Col, { span, children: /* @__PURE__ */ jsxs(Flex, { children: [
|
|
62
|
+
/* @__PURE__ */ jsxs("span", { style: { flexShrink: 0 }, children: [
|
|
63
|
+
item == null ? void 0 : item.attrname,
|
|
64
|
+
":"
|
|
65
|
+
] }),
|
|
66
|
+
valueNode()
|
|
67
|
+
] }) }),
|
|
68
|
+
layoutType === "row" && /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
69
|
+
/* @__PURE__ */ jsx(Col, { span: labelSpan, children: item == null ? void 0 : item.attrname }),
|
|
70
|
+
/* @__PURE__ */ jsx(Col, { span: valueSpan, style: { wordWrap: "break-word" }, children: valueNode() })
|
|
71
|
+
] })
|
|
72
|
+
] }, item == null ? void 0 : item.attrid);
|
|
53
73
|
};
|
|
54
|
-
const renderFileAttr = (item) => {
|
|
55
|
-
if (typeof (item == null ? void 0 : item.attrvalue) !== "string")
|
|
56
|
-
return;
|
|
74
|
+
const renderFileAttr = (item, span) => {
|
|
57
75
|
const attrvalues = JSON.parse((item == null ? void 0 : item.attrvalue) || "[]");
|
|
58
|
-
const
|
|
59
|
-
if (!useGrid) {
|
|
60
|
-
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Col, { span: labelSpan, style: { wordWrap: "break-word" }, children: [
|
|
61
|
-
item == null ? void 0 : item.attrname,
|
|
62
|
-
":",
|
|
63
|
-
renderItem
|
|
64
|
-
] }) }, item.attrid);
|
|
65
|
-
}
|
|
76
|
+
const valueNode = () => /* @__PURE__ */ jsx(Space, { wrap: true, children: attrvalues.map((el, index) => /* @__PURE__ */ jsx("a", { onClick: () => window.open(el == null ? void 0 : el.FilePath), children: (el == null ? void 0 : el.FileName) || "-" }, index)) });
|
|
66
77
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
67
|
-
/* @__PURE__ */ jsx(Col, { span
|
|
68
|
-
|
|
69
|
-
|
|
78
|
+
layoutType === "flex" && /* @__PURE__ */ jsx(Col, { span, children: /* @__PURE__ */ jsxs(Flex, { children: [
|
|
79
|
+
/* @__PURE__ */ jsxs("span", { style: { flexShrink: 0 }, children: [
|
|
80
|
+
item == null ? void 0 : item.attrname,
|
|
81
|
+
":"
|
|
82
|
+
] }),
|
|
83
|
+
valueNode()
|
|
84
|
+
] }) }),
|
|
85
|
+
layoutType === "row" && /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
86
|
+
/* @__PURE__ */ jsx(Col, { span: labelSpan, children: item == null ? void 0 : item.attrname }),
|
|
87
|
+
/* @__PURE__ */ jsx(Col, { span: valueSpan, style: { wordWrap: "break-word" }, children: valueNode() })
|
|
88
|
+
] })
|
|
89
|
+
] }, item == null ? void 0 : item.attrid);
|
|
70
90
|
};
|
|
71
|
-
const renderTextAttr = (item) => {
|
|
72
|
-
if (!useGrid) {
|
|
73
|
-
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Col, { span: labelSpan, style: { wordWrap: "break-word" }, children: [
|
|
74
|
-
item == null ? void 0 : item.attrname,
|
|
75
|
-
":",
|
|
76
|
-
(item == null ? void 0 : item.attrvalue) || "-"
|
|
77
|
-
] }) }, item.attrid);
|
|
78
|
-
}
|
|
91
|
+
const renderTextAttr = (item, span, beforeExtraValue) => {
|
|
79
92
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
80
|
-
/* @__PURE__ */ jsx(Col, { span
|
|
81
|
-
|
|
82
|
-
|
|
93
|
+
layoutType === "flex" && /* @__PURE__ */ jsx(Col, { span, children: /* @__PURE__ */ jsxs(Flex, { children: [
|
|
94
|
+
/* @__PURE__ */ jsxs("span", { style: { flexShrink: 0 }, children: [
|
|
95
|
+
item == null ? void 0 : item.attrname,
|
|
96
|
+
":"
|
|
97
|
+
] }),
|
|
98
|
+
/* @__PURE__ */ jsxs("span", { style: { wordWrap: "break-word" }, children: [
|
|
99
|
+
beforeExtraValue || "",
|
|
100
|
+
" ",
|
|
101
|
+
(item == null ? void 0 : item.attrvalue) || "-",
|
|
102
|
+
" "
|
|
103
|
+
] })
|
|
104
|
+
] }) }),
|
|
105
|
+
layoutType === "row" && /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
106
|
+
/* @__PURE__ */ jsx(Col, { span: labelSpan, children: item == null ? void 0 : item.attrname }),
|
|
107
|
+
/* @__PURE__ */ jsxs(Col, { span: valueSpan, style: { wordWrap: "break-word" }, children: [
|
|
108
|
+
beforeExtraValue || "",
|
|
109
|
+
(item == null ? void 0 : item.attrvalue) || "-"
|
|
110
|
+
] })
|
|
111
|
+
] })
|
|
112
|
+
] }, item == null ? void 0 : item.attrid);
|
|
83
113
|
};
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
114
|
+
const renderTableDetail = ({
|
|
115
|
+
detailList = [],
|
|
116
|
+
attrList = [],
|
|
117
|
+
universalHeader = [],
|
|
118
|
+
operationColumn
|
|
119
|
+
}) => {
|
|
120
|
+
var _a;
|
|
121
|
+
let columns = [];
|
|
122
|
+
if (universalHeader == null ? void 0 : universalHeader.length) {
|
|
123
|
+
columns = universalHeader == null ? void 0 : universalHeader.map((item) => ({
|
|
124
|
+
title: item == null ? void 0 : item["header-name"],
|
|
125
|
+
dataIndex: item == null ? void 0 : item["header-attribute-id"],
|
|
126
|
+
key: item == null ? void 0 : item["header-attribute-id"],
|
|
127
|
+
width: item == null ? void 0 : item["header-width"]
|
|
128
|
+
}));
|
|
129
|
+
} else {
|
|
130
|
+
columns = (_a = attrList == null ? void 0 : attrList[0]) == null ? void 0 : _a.map((item) => {
|
|
131
|
+
var _a2;
|
|
132
|
+
return {
|
|
133
|
+
title: item == null ? void 0 : item.attrname,
|
|
134
|
+
dataIndex: item == null ? void 0 : item.attrid,
|
|
135
|
+
key: item == null ? void 0 : item.attrid,
|
|
136
|
+
width: ((_a2 = item == null ? void 0 : item.json) == null ? void 0 : _a2["input-width"]) || 200
|
|
137
|
+
};
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
if (operationColumn && (columns == null ? void 0 : columns.length)) {
|
|
141
|
+
columns.push(operationColumn);
|
|
142
|
+
}
|
|
143
|
+
let dataSource = detailList;
|
|
144
|
+
if (attrList == null ? void 0 : attrList.length) {
|
|
145
|
+
dataSource = attrList == null ? void 0 : attrList.map((v, i) => ({
|
|
146
|
+
jxqyglbh: i,
|
|
147
|
+
...handleDealAttrList(v)
|
|
148
|
+
}));
|
|
149
|
+
}
|
|
150
|
+
return /* @__PURE__ */ jsx(Flex, { align: "center", style: { width: "100%" }, children: /* @__PURE__ */ jsx(
|
|
151
|
+
Table,
|
|
152
|
+
{
|
|
153
|
+
style: { width: "100%" },
|
|
154
|
+
columns,
|
|
155
|
+
scroll: { x: "max-content" },
|
|
156
|
+
size: "small",
|
|
157
|
+
rowKey: "jxqyglbh",
|
|
158
|
+
onRow: handleSetTableRowColor,
|
|
159
|
+
dataSource,
|
|
160
|
+
pagination: false
|
|
161
|
+
}
|
|
162
|
+
) });
|
|
163
|
+
};
|
|
164
|
+
const handleDealAttrList = (attrList) => {
|
|
165
|
+
return attrList == null ? void 0 : attrList.reduce((pre, cur) => {
|
|
166
|
+
pre[cur == null ? void 0 : cur.attrid] = cur == null ? void 0 : cur.attrvalue;
|
|
167
|
+
return pre;
|
|
168
|
+
}, {});
|
|
169
|
+
};
|
|
170
|
+
const renderDetail = useMemoizedFn(
|
|
171
|
+
({
|
|
172
|
+
attrList = [],
|
|
173
|
+
detailList = [],
|
|
174
|
+
span = 24,
|
|
175
|
+
type = "form",
|
|
176
|
+
universalHeader = [],
|
|
177
|
+
beforeExtraValue = "",
|
|
178
|
+
operationColumn
|
|
179
|
+
}) => {
|
|
180
|
+
if (type === "table") {
|
|
181
|
+
return /* @__PURE__ */ jsx(Fragment, { children: renderTableDetail({ detailList, attrList, universalHeader, operationColumn }) });
|
|
182
|
+
}
|
|
183
|
+
return /* @__PURE__ */ jsx(Row, { gutter: [10, 8], children: attrList == null ? void 0 : attrList.map((item) => {
|
|
184
|
+
if ((item == null ? void 0 : item.attrtype) !== 0)
|
|
185
|
+
return /* @__PURE__ */ jsx(Fragment, {}, item == null ? void 0 : item.attrid);
|
|
186
|
+
const info = item.info_base64 === 1 ? getJson(base64ToString(item.info)) : getJson(item.info);
|
|
92
187
|
if ((info == null ? void 0 : info.input) === "image") {
|
|
93
|
-
|
|
94
|
-
} else if (["file", "audio", "video"].includes(info == null ? void 0 : info.input)) {
|
|
95
|
-
content = renderFileAttr(item);
|
|
96
|
-
} else {
|
|
97
|
-
content = renderTextAttr(item);
|
|
188
|
+
return renderImageAttr(item, span);
|
|
98
189
|
}
|
|
99
|
-
if ((
|
|
100
|
-
return
|
|
101
|
-
content,
|
|
102
|
-
/* @__PURE__ */ jsx(
|
|
103
|
-
"div",
|
|
104
|
-
{
|
|
105
|
-
style: {
|
|
106
|
-
marginLeft: "16px",
|
|
107
|
-
marginTop: "8px",
|
|
108
|
-
borderLeft: "2px dashed #e8e8e8",
|
|
109
|
-
paddingLeft: "16px"
|
|
110
|
-
},
|
|
111
|
-
children: renderAttrItems(item.children)
|
|
112
|
-
}
|
|
113
|
-
)
|
|
114
|
-
] }, item.attrid);
|
|
190
|
+
if (["file", "audio", "video"].includes(info == null ? void 0 : info.input)) {
|
|
191
|
+
return renderFileAttr(item, span);
|
|
115
192
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
193
|
+
if ((info == null ? void 0 : info.input) === "radio-card") {
|
|
194
|
+
return renderRadioCardAttr(item, span);
|
|
195
|
+
}
|
|
196
|
+
return renderTextAttr(item, span, beforeExtraValue);
|
|
197
|
+
}) });
|
|
198
|
+
}
|
|
199
|
+
);
|
|
121
200
|
return { renderDetail };
|
|
122
201
|
}
|
|
123
202
|
export {
|
|
124
|
-
|
|
203
|
+
useAttrSetDetailRenderer as default
|
|
125
204
|
};
|
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 宠物详情渲染 Hook
|
|
3
|
-
* @param
|
|
3
|
+
* @param attrList 属性列表数据
|
|
4
4
|
* @param config 配置信息(用于文件预览地址)
|
|
5
5
|
* @returns 渲染函数
|
|
6
6
|
*/
|
|
7
|
-
interface
|
|
8
|
-
detailInfo: any;
|
|
9
|
-
mainApplicationDomain: string;
|
|
7
|
+
interface IAttrSetDetailRendererProps {
|
|
10
8
|
labelSpan?: number;
|
|
11
9
|
valueSpan?: number;
|
|
12
10
|
imgWidth?: number;
|
|
13
11
|
imgHeight?: number;
|
|
14
|
-
|
|
12
|
+
layoutType?: 'row' | 'flex';
|
|
15
13
|
}
|
|
16
|
-
export default function
|
|
17
|
-
renderDetail: (
|
|
14
|
+
export default function useAttrSetDetailRenderer({ labelSpan, valueSpan, imgWidth, imgHeight, layoutType, }: IAttrSetDetailRendererProps): {
|
|
15
|
+
renderDetail: ({ attrList, detailList, span, type, universalHeader, beforeExtraValue, operationColumn, }: {
|
|
16
|
+
attrList?: any[] | undefined;
|
|
17
|
+
detailList?: any[] | undefined;
|
|
18
|
+
span?: number | undefined;
|
|
19
|
+
type?: "form" | "table" | undefined;
|
|
20
|
+
universalHeader?: any[] | undefined;
|
|
21
|
+
beforeExtraValue?: string | undefined;
|
|
22
|
+
operationColumn?: any;
|
|
23
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
18
24
|
};
|
|
19
25
|
export {};
|
|
@@ -1,25 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const jsxRuntime = require("react/jsx-runtime");
|
|
3
|
+
const method = require("szld-libs/lib/utils/method");
|
|
3
4
|
const antd = require("antd");
|
|
5
|
+
const szxkFunc = require("../utils/szxkFunc");
|
|
6
|
+
const ahooks = require("ahooks");
|
|
4
7
|
const react = require("react");
|
|
5
|
-
function
|
|
6
|
-
detailInfo,
|
|
8
|
+
function useAttrSetDetailRenderer({
|
|
7
9
|
labelSpan = 3,
|
|
8
10
|
valueSpan = 9,
|
|
9
11
|
imgWidth = 93,
|
|
10
12
|
imgHeight = 93,
|
|
11
|
-
|
|
12
|
-
mainApplicationDomain = ""
|
|
13
|
+
layoutType = "row"
|
|
13
14
|
}) {
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
const { message } = antd.App.useApp();
|
|
16
|
+
const renderRadioCardAttr = (item, span) => {
|
|
17
|
+
try {
|
|
18
|
+
const attrvalue = JSON.parse((item == null ? void 0 : item.attrvalue) || "{}") || "";
|
|
19
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, { children: [
|
|
20
|
+
layoutType === "flex" && /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span, children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { children: [
|
|
21
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: { flexShrink: 0 }, children: [
|
|
22
|
+
item == null ? void 0 : item.attrname,
|
|
23
|
+
":"
|
|
24
|
+
] }),
|
|
25
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { wordWrap: "break-word" }, children: attrvalue == null ? void 0 : attrvalue.typename })
|
|
26
|
+
] }) }),
|
|
27
|
+
layoutType === "row" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
28
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: labelSpan, children: item == null ? void 0 : item.attrname }),
|
|
29
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: valueSpan, style: { wordWrap: "break-word" }, children: item == null ? void 0 : item.attrvalue })
|
|
30
|
+
] })
|
|
31
|
+
] }, item == null ? void 0 : item.attrid);
|
|
32
|
+
} catch (error) {
|
|
33
|
+
message.error("房型数据格式错误,转json失败");
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
17
36
|
};
|
|
18
|
-
const renderImageAttr = (item) => {
|
|
37
|
+
const renderImageAttr = (item, span) => {
|
|
19
38
|
if (typeof (item == null ? void 0 : item.attrvalue) !== "string")
|
|
20
39
|
return;
|
|
21
40
|
const attrvalues = JSON.parse((item == null ? void 0 : item.attrvalue) || "[]");
|
|
22
|
-
const
|
|
41
|
+
const valueNode = () => /* @__PURE__ */ jsxRuntime.jsx(antd.Space, { wrap: true, children: attrvalues.map((el, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
23
42
|
"div",
|
|
24
43
|
{
|
|
25
44
|
style: {
|
|
@@ -34,91 +53,151 @@ function useDetailRenderer({
|
|
|
34
53
|
height: imgHeight,
|
|
35
54
|
src: el == null ? void 0 : el.FilePath,
|
|
36
55
|
alt: (item == null ? void 0 : item.attrname) || "-"
|
|
37
|
-
}
|
|
38
|
-
index
|
|
56
|
+
}
|
|
39
57
|
)
|
|
40
58
|
},
|
|
41
59
|
index
|
|
42
60
|
)) });
|
|
43
|
-
if (!useGrid) {
|
|
44
|
-
return /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Col, { span: labelSpan, children: [
|
|
45
|
-
item == null ? void 0 : item.attrname,
|
|
46
|
-
":",
|
|
47
|
-
renderItem
|
|
48
|
-
] }) }, item.attrid);
|
|
49
|
-
}
|
|
50
61
|
return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, { children: [
|
|
51
|
-
/* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span
|
|
52
|
-
|
|
53
|
-
|
|
62
|
+
layoutType === "flex" && /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span, children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { children: [
|
|
63
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: { flexShrink: 0 }, children: [
|
|
64
|
+
item == null ? void 0 : item.attrname,
|
|
65
|
+
":"
|
|
66
|
+
] }),
|
|
67
|
+
valueNode()
|
|
68
|
+
] }) }),
|
|
69
|
+
layoutType === "row" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
70
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: labelSpan, children: item == null ? void 0 : item.attrname }),
|
|
71
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: valueSpan, style: { wordWrap: "break-word" }, children: valueNode() })
|
|
72
|
+
] })
|
|
73
|
+
] }, item == null ? void 0 : item.attrid);
|
|
54
74
|
};
|
|
55
|
-
const renderFileAttr = (item) => {
|
|
56
|
-
if (typeof (item == null ? void 0 : item.attrvalue) !== "string")
|
|
57
|
-
return;
|
|
75
|
+
const renderFileAttr = (item, span) => {
|
|
58
76
|
const attrvalues = JSON.parse((item == null ? void 0 : item.attrvalue) || "[]");
|
|
59
|
-
const
|
|
60
|
-
if (!useGrid) {
|
|
61
|
-
return /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Col, { span: labelSpan, style: { wordWrap: "break-word" }, children: [
|
|
62
|
-
item == null ? void 0 : item.attrname,
|
|
63
|
-
":",
|
|
64
|
-
renderItem
|
|
65
|
-
] }) }, item.attrid);
|
|
66
|
-
}
|
|
77
|
+
const valueNode = () => /* @__PURE__ */ jsxRuntime.jsx(antd.Space, { wrap: true, children: attrvalues.map((el, index) => /* @__PURE__ */ jsxRuntime.jsx("a", { onClick: () => window.open(el == null ? void 0 : el.FilePath), children: (el == null ? void 0 : el.FileName) || "-" }, index)) });
|
|
67
78
|
return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, { children: [
|
|
68
|
-
/* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span
|
|
69
|
-
|
|
70
|
-
|
|
79
|
+
layoutType === "flex" && /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span, children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { children: [
|
|
80
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: { flexShrink: 0 }, children: [
|
|
81
|
+
item == null ? void 0 : item.attrname,
|
|
82
|
+
":"
|
|
83
|
+
] }),
|
|
84
|
+
valueNode()
|
|
85
|
+
] }) }),
|
|
86
|
+
layoutType === "row" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
87
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: labelSpan, children: item == null ? void 0 : item.attrname }),
|
|
88
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: valueSpan, style: { wordWrap: "break-word" }, children: valueNode() })
|
|
89
|
+
] })
|
|
90
|
+
] }, item == null ? void 0 : item.attrid);
|
|
71
91
|
};
|
|
72
|
-
const renderTextAttr = (item) => {
|
|
73
|
-
if (!useGrid) {
|
|
74
|
-
return /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Col, { span: labelSpan, style: { wordWrap: "break-word" }, children: [
|
|
75
|
-
item == null ? void 0 : item.attrname,
|
|
76
|
-
":",
|
|
77
|
-
(item == null ? void 0 : item.attrvalue) || "-"
|
|
78
|
-
] }) }, item.attrid);
|
|
79
|
-
}
|
|
92
|
+
const renderTextAttr = (item, span, beforeExtraValue) => {
|
|
80
93
|
return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, { children: [
|
|
81
|
-
/* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span
|
|
82
|
-
|
|
83
|
-
|
|
94
|
+
layoutType === "flex" && /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span, children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { children: [
|
|
95
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: { flexShrink: 0 }, children: [
|
|
96
|
+
item == null ? void 0 : item.attrname,
|
|
97
|
+
":"
|
|
98
|
+
] }),
|
|
99
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: { wordWrap: "break-word" }, children: [
|
|
100
|
+
beforeExtraValue || "",
|
|
101
|
+
" ",
|
|
102
|
+
(item == null ? void 0 : item.attrvalue) || "-",
|
|
103
|
+
" "
|
|
104
|
+
] })
|
|
105
|
+
] }) }),
|
|
106
|
+
layoutType === "row" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
107
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: labelSpan, children: item == null ? void 0 : item.attrname }),
|
|
108
|
+
/* @__PURE__ */ jsxRuntime.jsxs(antd.Col, { span: valueSpan, style: { wordWrap: "break-word" }, children: [
|
|
109
|
+
beforeExtraValue || "",
|
|
110
|
+
(item == null ? void 0 : item.attrvalue) || "-"
|
|
111
|
+
] })
|
|
112
|
+
] })
|
|
113
|
+
] }, item == null ? void 0 : item.attrid);
|
|
84
114
|
};
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
115
|
+
const renderTableDetail = ({
|
|
116
|
+
detailList = [],
|
|
117
|
+
attrList = [],
|
|
118
|
+
universalHeader = [],
|
|
119
|
+
operationColumn
|
|
120
|
+
}) => {
|
|
121
|
+
var _a;
|
|
122
|
+
let columns = [];
|
|
123
|
+
if (universalHeader == null ? void 0 : universalHeader.length) {
|
|
124
|
+
columns = universalHeader == null ? void 0 : universalHeader.map((item) => ({
|
|
125
|
+
title: item == null ? void 0 : item["header-name"],
|
|
126
|
+
dataIndex: item == null ? void 0 : item["header-attribute-id"],
|
|
127
|
+
key: item == null ? void 0 : item["header-attribute-id"],
|
|
128
|
+
width: item == null ? void 0 : item["header-width"]
|
|
129
|
+
}));
|
|
130
|
+
} else {
|
|
131
|
+
columns = (_a = attrList == null ? void 0 : attrList[0]) == null ? void 0 : _a.map((item) => {
|
|
132
|
+
var _a2;
|
|
133
|
+
return {
|
|
134
|
+
title: item == null ? void 0 : item.attrname,
|
|
135
|
+
dataIndex: item == null ? void 0 : item.attrid,
|
|
136
|
+
key: item == null ? void 0 : item.attrid,
|
|
137
|
+
width: ((_a2 = item == null ? void 0 : item.json) == null ? void 0 : _a2["input-width"]) || 200
|
|
138
|
+
};
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
if (operationColumn && (columns == null ? void 0 : columns.length)) {
|
|
142
|
+
columns.push(operationColumn);
|
|
143
|
+
}
|
|
144
|
+
let dataSource = detailList;
|
|
145
|
+
if (attrList == null ? void 0 : attrList.length) {
|
|
146
|
+
dataSource = attrList == null ? void 0 : attrList.map((v, i) => ({
|
|
147
|
+
jxqyglbh: i,
|
|
148
|
+
...handleDealAttrList(v)
|
|
149
|
+
}));
|
|
150
|
+
}
|
|
151
|
+
return /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { align: "center", style: { width: "100%" }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
152
|
+
antd.Table,
|
|
153
|
+
{
|
|
154
|
+
style: { width: "100%" },
|
|
155
|
+
columns,
|
|
156
|
+
scroll: { x: "max-content" },
|
|
157
|
+
size: "small",
|
|
158
|
+
rowKey: "jxqyglbh",
|
|
159
|
+
onRow: szxkFunc.handleSetTableRowColor,
|
|
160
|
+
dataSource,
|
|
161
|
+
pagination: false
|
|
162
|
+
}
|
|
163
|
+
) });
|
|
164
|
+
};
|
|
165
|
+
const handleDealAttrList = (attrList) => {
|
|
166
|
+
return attrList == null ? void 0 : attrList.reduce((pre, cur) => {
|
|
167
|
+
pre[cur == null ? void 0 : cur.attrid] = cur == null ? void 0 : cur.attrvalue;
|
|
168
|
+
return pre;
|
|
169
|
+
}, {});
|
|
170
|
+
};
|
|
171
|
+
const renderDetail = ahooks.useMemoizedFn(
|
|
172
|
+
({
|
|
173
|
+
attrList = [],
|
|
174
|
+
detailList = [],
|
|
175
|
+
span = 24,
|
|
176
|
+
type = "form",
|
|
177
|
+
universalHeader = [],
|
|
178
|
+
beforeExtraValue = "",
|
|
179
|
+
operationColumn
|
|
180
|
+
}) => {
|
|
181
|
+
if (type === "table") {
|
|
182
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, { children: renderTableDetail({ detailList, attrList, universalHeader, operationColumn }) });
|
|
183
|
+
}
|
|
184
|
+
return /* @__PURE__ */ jsxRuntime.jsx(antd.Row, { gutter: [10, 8], children: attrList == null ? void 0 : attrList.map((item) => {
|
|
185
|
+
if ((item == null ? void 0 : item.attrtype) !== 0)
|
|
186
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, {}, item == null ? void 0 : item.attrid);
|
|
187
|
+
const info = item.info_base64 === 1 ? method.getJson(method.base64ToString(item.info)) : method.getJson(item.info);
|
|
93
188
|
if ((info == null ? void 0 : info.input) === "image") {
|
|
94
|
-
|
|
95
|
-
} else if (["file", "audio", "video"].includes(info == null ? void 0 : info.input)) {
|
|
96
|
-
content = renderFileAttr(item);
|
|
97
|
-
} else {
|
|
98
|
-
content = renderTextAttr(item);
|
|
189
|
+
return renderImageAttr(item, span);
|
|
99
190
|
}
|
|
100
|
-
if ((
|
|
101
|
-
return
|
|
102
|
-
content,
|
|
103
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
104
|
-
"div",
|
|
105
|
-
{
|
|
106
|
-
style: {
|
|
107
|
-
marginLeft: "16px",
|
|
108
|
-
marginTop: "8px",
|
|
109
|
-
borderLeft: "2px dashed #e8e8e8",
|
|
110
|
-
paddingLeft: "16px"
|
|
111
|
-
},
|
|
112
|
-
children: renderAttrItems(item.children)
|
|
113
|
-
}
|
|
114
|
-
)
|
|
115
|
-
] }, item.attrid);
|
|
191
|
+
if (["file", "audio", "video"].includes(info == null ? void 0 : info.input)) {
|
|
192
|
+
return renderFileAttr(item, span);
|
|
116
193
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
194
|
+
if ((info == null ? void 0 : info.input) === "radio-card") {
|
|
195
|
+
return renderRadioCardAttr(item, span);
|
|
196
|
+
}
|
|
197
|
+
return renderTextAttr(item, span, beforeExtraValue);
|
|
198
|
+
}) });
|
|
199
|
+
}
|
|
200
|
+
);
|
|
122
201
|
return { renderDetail };
|
|
123
202
|
}
|
|
124
|
-
module.exports =
|
|
203
|
+
module.exports = useAttrSetDetailRenderer;
|