zy-react-library 1.0.62 → 1.0.64

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.
@@ -10,6 +10,7 @@ import { UPLOAD_FILE_TYPE_ENUM } from "../../../enum/uploadFile/gwj";
10
10
  import useGetFile from "../../../hooks/useGetFile";
11
11
  import { getLabelName } from "../../../utils";
12
12
  import { HIDDEN_SOURCE_ENUM, HIDDEN_STATE_ENUM } from "../../../enum/hidden/gwj";
13
+ import useGetUrlQuery from "../../../hooks/useGetUrlQuery";
13
14
 
14
15
  /**
15
16
  * 隐患查看组件(港务局版本)
@@ -39,29 +40,27 @@ function HiddenInfo(props) {
39
40
  const [rectificationPlanImageFiles, setRectificationPlanImageFiles] = useState([]);
40
41
  const [acceptImageFiles, setAcceptImageFiles] = useState([]);
41
42
  const { getFile } = useGetFile();
43
+ const query = useGetUrlQuery();
42
44
 
43
45
  const getData = async () => {
44
- const urlParams = new URLSearchParams(window.location.search);
45
- const queryId = urlParams.get(idKey);
46
- const queryHiddenId = urlParams.get(hiddenIdKey);
47
- request(`/hidden/hidden/${id || queryId}`, "get").then((res) => {
46
+ request(`/hidden/hidden/${id || query[idKey]}`, "get").then((res) => {
48
47
  setInfo(res.data);
49
48
  });
50
- const hiddenImageFiles = await getFile({ eqType: UPLOAD_FILE_TYPE_ENUM["3"], eqForeignKey: hiddenId || queryHiddenId });
49
+ const hiddenImageFiles = await getFile({ eqType: UPLOAD_FILE_TYPE_ENUM["3"], eqForeignKey: hiddenId || query[hiddenIdKey] });
51
50
  setHiddenImageFiles(hiddenImageFiles);
52
- const hiddenVideoFiles = await getFile({ eqType: UPLOAD_FILE_TYPE_ENUM["102"], eqForeignKey: hiddenId || queryHiddenId });
51
+ const hiddenVideoFiles = await getFile({ eqType: UPLOAD_FILE_TYPE_ENUM["102"], eqForeignKey: hiddenId || query[hiddenIdKey] });
53
52
  setHiddenVideoFiles(hiddenVideoFiles);
54
53
  const afterRectificationImageFiles = await getFile({
55
54
  eqType: UPLOAD_FILE_TYPE_ENUM["4"],
56
- eqForeignKey: hiddenId || queryHiddenId,
55
+ eqForeignKey: hiddenId || query[hiddenIdKey],
57
56
  });
58
57
  setAfterRectificationImageFiles(afterRectificationImageFiles);
59
58
  const rectificationPlanImageFiles = await getFile({
60
59
  eqType: UPLOAD_FILE_TYPE_ENUM["8"],
61
- eqForeignKey: hiddenId || queryHiddenId,
60
+ eqForeignKey: hiddenId || query[hiddenIdKey],
62
61
  });
63
62
  setRectificationPlanImageFiles(rectificationPlanImageFiles);
64
- const acceptImageFiles = await getFile({ eqType: UPLOAD_FILE_TYPE_ENUM["5"], eqForeignKey: hiddenId || queryHiddenId });
63
+ const acceptImageFiles = await getFile({ eqType: UPLOAD_FILE_TYPE_ENUM["5"], eqForeignKey: hiddenId || query[hiddenIdKey] });
65
64
  setAcceptImageFiles(acceptImageFiles);
66
65
  };
67
66
  useEffect(() => {
@@ -127,8 +126,8 @@ function HiddenInfo(props) {
127
126
  column={1}
128
127
  labelStyle={{ width: 200 }}
129
128
  items={[
130
- { label: "整改部门", children: info.hiddenUserPresetsCO.deptName },
131
- { label: "整改人", children: info.hiddenUserPresetsCO.userName },
129
+ { label: "整改部门", children: info.hiddenUserPresetsCO.rectifyDeptName },
130
+ { label: "整改人", children: info.hiddenUserPresetsCO.rectifyUserName },
132
131
  ...(info.rectificationType === 2
133
132
  ? [
134
133
  { label: "整改期限", children: dayjs(info.hiddenUserPresetsCO.rectifyDeadline).format("YYYY-MM-DD") },
@@ -136,8 +135,8 @@ function HiddenInfo(props) {
136
135
  : []),
137
136
  ...(info.rectificationType === 1
138
137
  ? [
139
- { label: "验收部门", children: info.hiddenUserPresetsCO.deptName },
140
- { label: "验收人", children: info.hiddenUserPresetsCO.userName },
138
+ { label: "验收部门", children: info.hiddenUserPresetsCO.checkDeptName },
139
+ { label: "验收人", children: info.hiddenUserPresetsCO.checkUserName },
141
140
  ]
142
141
  : []),
143
142
  ]}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 获取路由参数
3
+ */
4
+ export default function useGetUrlQuery(): Record<string, any>;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * 获取路由参数
3
+ */
4
+ function useGetUrlQuery() {
5
+ const urlQuery = new URLSearchParams(window.location.search);
6
+
7
+ // 直接返回包含所有参数的对象
8
+ const queryParams = {};
9
+ for (const [key, value] of urlQuery.entries()) {
10
+ queryParams[key] = value;
11
+ }
12
+
13
+ return queryParams;
14
+ }
15
+
16
+ export default useGetUrlQuery;
@@ -1,5 +1,6 @@
1
1
  import { tools } from "@cqsjjb/jjb-common-lib";
2
2
  import { useAntdTable } from "ahooks";
3
+ import useGetUrlQuery from "../useGetUrlQuery";
3
4
 
4
5
  const { query } = tools.router;
5
6
 
@@ -75,9 +76,10 @@ function setQuery(searchForm, pagination) {
75
76
  * 从 URL 中获取查询参数
76
77
  */
77
78
  function getQuery(keysStr, valuesStr) {
79
+ const query = useGetUrlQuery();
78
80
  // 将键值字符串分割为数组
79
- const keys = keysStr ? keysStr.split(",") : [];
80
- const values = valuesStr ? valuesStr.split(",") : [];
81
+ const keys = query[keysStr] ? query[keysStr].split(",") : [];
82
+ const values = query[valuesStr] ? query[valuesStr].split(",") : [];
81
83
 
82
84
  // 构建结果对象
83
85
  const resultMap = {};
@@ -119,8 +121,8 @@ function useTable(service, options) {
119
121
  } = restOptions;
120
122
 
121
123
  // 获取存储的查询条件
122
- const storageQueryCriteriaSearchForm = useStorageQueryCriteria ? getQuery(query.searchFormKeys, query.searchFormValues) : {};
123
- const storageQueryCriteriaPagination = useStorageQueryCriteria && usePagination ? getQuery(query.paginationKeys, query.paginationValues) : {};
124
+ const storageQueryCriteriaSearchForm = useStorageQueryCriteria ? getQuery("searchFormKeys", "searchFormValues") : {};
125
+ const storageQueryCriteriaPagination = useStorageQueryCriteria && usePagination ? getQuery("paginationKeys", "paginationValues") : {};
124
126
 
125
127
  // 确定实际使用的搜索表单和分页参数
126
128
  const actualSearchForm = Object.keys(storageQueryCriteriaSearchForm).length > 0 ? storageQueryCriteriaSearchForm : {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "zy-react-library",
3
3
  "private": false,
4
- "version": "1.0.62",
4
+ "version": "1.0.64",
5
5
  "type": "module",
6
6
  "description": "",
7
7
  "author": "LiuJiaNan",