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.
@@ -1,19 +1,25 @@
1
1
  /**
2
2
  * 宠物详情渲染 Hook
3
- * @param dogInfo 宠物详情数据
3
+ * @param attrList 属性列表数据
4
4
  * @param config 配置信息(用于文件预览地址)
5
5
  * @returns 渲染函数
6
6
  */
7
- interface IDetailRenderProps {
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
- useGrid?: boolean;
12
+ layoutType?: 'row' | 'flex';
15
13
  }
16
- export default function useDetailRenderer({ detailInfo, labelSpan, valueSpan, imgWidth, imgHeight, useGrid, mainApplicationDomain, }: IDetailRenderProps): {
17
- renderDetail: () => import("react/jsx-runtime").JSX.Element | null;
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 { Row, Space, Image, Col } from "antd";
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 useDetailRenderer({
5
- detailInfo,
7
+ function useAttrSetDetailRenderer({
6
8
  labelSpan = 3,
7
9
  valueSpan = 9,
8
10
  imgWidth = 93,
9
11
  imgHeight = 93,
10
- useGrid = true,
11
- mainApplicationDomain = ""
12
+ layoutType = "row"
12
13
  }) {
13
- const handlePreviewFile = (filePath) => {
14
- var _a;
15
- (_a = window.parent) == null ? void 0 : _a.postMessage({ type: "previewDoc", docurl: filePath }, mainApplicationDomain);
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 renderItem = /* @__PURE__ */ jsx(Space, { children: attrvalues.map((el, index) => /* @__PURE__ */ jsx(
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: labelSpan, children: item == null ? void 0 : item.attrname }),
51
- /* @__PURE__ */ jsx(Col, { span: valueSpan, style: { wordWrap: "break-word" }, children: renderItem })
52
- ] }, item.attrid);
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 renderItem = /* @__PURE__ */ jsx(Space, { children: attrvalues.map((el, index) => /* @__PURE__ */ jsx("a", { onClick: () => handlePreviewFile(el == null ? void 0 : el.FilePath), children: (el == null ? void 0 : el.FileName) || "-" }, index)) });
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: labelSpan, children: item == null ? void 0 : item.attrname }),
68
- /* @__PURE__ */ jsx(Col, { span: valueSpan, style: { wordWrap: "break-word" }, children: renderItem })
69
- ] }, item.attrid);
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: labelSpan, children: item == null ? void 0 : item.attrname }),
81
- /* @__PURE__ */ jsx(Col, { span: valueSpan, style: { wordWrap: "break-word" }, children: (item == null ? void 0 : item.attrvalue) || "-" })
82
- ] }, item.attrid);
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 renderDetail = () => {
85
- if (!detailInfo)
86
- return null;
87
- const renderAttrItems = (items) => {
88
- var _a;
89
- return (_a = items == null ? void 0 : items.filter((item) => (item == null ? void 0 : item.attrtype) === 0)) == null ? void 0 : _a.map((item) => {
90
- const info = (item == null ? void 0 : item.json) || (item == null ? void 0 : item.info) && JSON.parse(item.info);
91
- let content;
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
- content = renderImageAttr(item);
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 ((item == null ? void 0 : item.children) && item.children.length > 0) {
100
- return /* @__PURE__ */ jsxs(Fragment, { children: [
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
- return content;
117
- });
118
- };
119
- return /* @__PURE__ */ jsx(Row, { gutter: [15, 15], children: renderAttrItems(detailInfo == null ? void 0 : detailInfo.attr_list) });
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
- useDetailRenderer as default
203
+ useAttrSetDetailRenderer as default
125
204
  };
@@ -1,19 +1,25 @@
1
1
  /**
2
2
  * 宠物详情渲染 Hook
3
- * @param dogInfo 宠物详情数据
3
+ * @param attrList 属性列表数据
4
4
  * @param config 配置信息(用于文件预览地址)
5
5
  * @returns 渲染函数
6
6
  */
7
- interface IDetailRenderProps {
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
- useGrid?: boolean;
12
+ layoutType?: 'row' | 'flex';
15
13
  }
16
- export default function useDetailRenderer({ detailInfo, labelSpan, valueSpan, imgWidth, imgHeight, useGrid, mainApplicationDomain, }: IDetailRenderProps): {
17
- renderDetail: () => import("react/jsx-runtime").JSX.Element | null;
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 useDetailRenderer({
6
- detailInfo,
8
+ function useAttrSetDetailRenderer({
7
9
  labelSpan = 3,
8
10
  valueSpan = 9,
9
11
  imgWidth = 93,
10
12
  imgHeight = 93,
11
- useGrid = true,
12
- mainApplicationDomain = ""
13
+ layoutType = "row"
13
14
  }) {
14
- const handlePreviewFile = (filePath) => {
15
- var _a;
16
- (_a = window.parent) == null ? void 0 : _a.postMessage({ type: "previewDoc", docurl: filePath }, mainApplicationDomain);
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 renderItem = /* @__PURE__ */ jsxRuntime.jsx(antd.Space, { children: attrvalues.map((el, index) => /* @__PURE__ */ jsxRuntime.jsx(
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: labelSpan, children: item == null ? void 0 : item.attrname }),
52
- /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: valueSpan, style: { wordWrap: "break-word" }, children: renderItem })
53
- ] }, item.attrid);
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 renderItem = /* @__PURE__ */ jsxRuntime.jsx(antd.Space, { children: attrvalues.map((el, index) => /* @__PURE__ */ jsxRuntime.jsx("a", { onClick: () => handlePreviewFile(el == null ? void 0 : el.FilePath), children: (el == null ? void 0 : el.FileName) || "-" }, index)) });
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: labelSpan, children: item == null ? void 0 : item.attrname }),
69
- /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: valueSpan, style: { wordWrap: "break-word" }, children: renderItem })
70
- ] }, item.attrid);
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: labelSpan, children: item == null ? void 0 : item.attrname }),
82
- /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: valueSpan, style: { wordWrap: "break-word" }, children: (item == null ? void 0 : item.attrvalue) || "-" })
83
- ] }, item.attrid);
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 renderDetail = () => {
86
- if (!detailInfo)
87
- return null;
88
- const renderAttrItems = (items) => {
89
- var _a;
90
- return (_a = items == null ? void 0 : items.filter((item) => (item == null ? void 0 : item.attrtype) === 0)) == null ? void 0 : _a.map((item) => {
91
- const info = (item == null ? void 0 : item.json) || (item == null ? void 0 : item.info) && JSON.parse(item.info);
92
- let content;
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
- content = renderImageAttr(item);
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 ((item == null ? void 0 : item.children) && item.children.length > 0) {
101
- return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, { children: [
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
- return content;
118
- });
119
- };
120
- return /* @__PURE__ */ jsxRuntime.jsx(antd.Row, { gutter: [15, 15], children: renderAttrItems(detailInfo == null ? void 0 : detailInfo.attr_list) });
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 = useDetailRenderer;
203
+ module.exports = useAttrSetDetailRenderer;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "szld-libs",
3
3
  "private": false,
4
- "version": "0.3.21",
4
+ "version": "0.3.22",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",