@ecoding/components.antd 0.5.14 → 0.5.16

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.
@@ -12,6 +12,7 @@ import { Upload, message, Button, Popover, Typography, Space, Empty } from 'antd
12
12
  import { UploadOutlined, LinkOutlined, DeleteOutlined, EllipsisOutlined } from '@ant-design/icons';
13
13
  import { buildURL } from '@ecoding/helper.url';
14
14
  import Toast from "../../core/toast";
15
+ import Loading from "../../core/loading";
15
16
  const InfosRender = ({ infos, updateItems, domain, nameKey }) => {
16
17
  const remove = (i) => {
17
18
  const temp = infos.concat([]);
@@ -47,6 +48,7 @@ const InfosRender = ({ infos, updateItems, domain, nameKey }) => {
47
48
  const MultipleUpload = (props) => {
48
49
  const { value, domain, onChange, valueKey, objectInValue, nameKey } = props;
49
50
  const isInnerChange = useRef(false);
51
+ const isInnerDone = useRef([]);
50
52
  const [infos, setInfos] = useState(() => {
51
53
  return [];
52
54
  });
@@ -88,15 +90,19 @@ const MultipleUpload = (props) => {
88
90
  const urls = temp.map((item) => domain ? item.url.replace(domain, '') : item.url);
89
91
  onChange && onChange(!isEmpty ? urls : undefined);
90
92
  }
91
- if (open) {
92
- setOpen(true);
93
- clearTimeout(timeout.current);
94
- timeout.current = setTimeout(() => {
95
- setOpen(undefined);
96
- }, 3000);
93
+ if (isInnerDone.current.length == newItems.length) {
94
+ if (open) {
95
+ setOpen(true);
96
+ clearTimeout(timeout.current);
97
+ timeout.current = setTimeout(() => {
98
+ setOpen(undefined);
99
+ }, 3000);
100
+ }
101
+ Loading.hide();
97
102
  }
98
103
  };
99
104
  const handleChange = ({ fileList }) => {
105
+ Loading.show();
100
106
  fileList && fileList.forEach((file) => {
101
107
  if (file.status == "done") {
102
108
  const response = file.response || {};
@@ -107,6 +113,7 @@ const MultipleUpload = (props) => {
107
113
  const data = response.data || response.model;
108
114
  file.url = data && data[valueKey || "url"];
109
115
  file.responseData = data;
116
+ isInnerDone.current.push(true);
110
117
  delete file.response;
111
118
  delete file.xhr;
112
119
  delete file.lastModifiedDate;
@@ -114,6 +121,7 @@ const MultipleUpload = (props) => {
114
121
  }
115
122
  }
116
123
  else if (file.status === "error") {
124
+ Loading.hide();
117
125
  Toast.error({
118
126
  mask: true,
119
127
  title: file.response ? file.response.msg || file.response.message : `${props.i18n ? props.i18n.$t('global.upload.error.img') : '服务出错,文件上传失败'}`
@@ -144,9 +152,13 @@ const MultipleUpload = (props) => {
144
152
  isInnerChange.current = false;
145
153
  return;
146
154
  }
155
+ if (!value) {
156
+ setInfos([]);
157
+ }
147
158
  if (value && value.length > 0) {
148
159
  const temp = [];
149
160
  value.forEach((item, index) => {
161
+ isInnerDone.current.push(true);
150
162
  if (typeof item === "string" && item) {
151
163
  // 防止重复拼接domain
152
164
  item = domain ? item.replace(domain, "") : item;
@@ -222,6 +222,9 @@ const MultipleImgUpload = (props) => {
222
222
  isInnerChange.current = false;
223
223
  return;
224
224
  }
225
+ if (!value) {
226
+ setImgList([]);
227
+ }
225
228
  if (value && value.length > 0) {
226
229
  const temp = [];
227
230
  value.forEach((item, index) => {
@@ -13,7 +13,7 @@ import { UploadOutlined } from "@ant-design/icons";
13
13
  import { buildURL } from "@ecoding/helper.url";
14
14
  import Toast from "../../core/toast";
15
15
  const SingleFileUpload = (props) => {
16
- const [fileUrl, setFileUrl] = useState('');
16
+ const [fileUrl, setFileUrl] = useState(undefined);
17
17
  const [loading, setLoading] = useState(false);
18
18
  const action = useMemo(() => {
19
19
  if (typeof props.action === "string") {
@@ -93,6 +93,9 @@ const SingleFileUpload = (props) => {
93
93
  }, []);
94
94
  useEffect(() => {
95
95
  let item = props.value;
96
+ if (!item) {
97
+ setFileUrl(undefined);
98
+ }
96
99
  if (typeof item === "string" && (item || item == '') && fileUrl != item) {
97
100
  // 防止重复拼接domain
98
101
  item = props.domain ? item.replace(props.domain, "") : item;
@@ -166,6 +166,9 @@ const ImgUpload = (props) => {
166
166
  React.createElement("div", { style: { marginTop: 8 } }, props.buttonText))), [loading]);
167
167
  useEffect(() => {
168
168
  let item = props.value;
169
+ if (!item) {
170
+ setImageUrl(undefined);
171
+ }
169
172
  if (typeof item === "string" && item) {
170
173
  // 防止重复拼接domain
171
174
  item = props.domain ? item.replace(props.domain, "") : item;
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  interface IProps {
3
3
  items: React.ReactElement[];
4
+ itemValues?: any;
4
5
  overMax?: number;
5
6
  colOpts?: any;
6
7
  onFinish?: (v: any) => Promise<void>;
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import React, { useRef, useEffect, useState, useMemo, memo } from 'react';
11
11
  import { Button, Form, Row, Col, Space } from 'antd';
12
12
  import { DownOutlined, UpOutlined } from '@ant-design/icons';
13
- const FiltersHorizontal = ({ items, onFinish, onClear, y, setY, overMax, colOpts, searchText, resetText, i18n }) => {
13
+ const FiltersHorizontal = ({ items, itemValues, onFinish, onClear, y, setY, overMax, colOpts, searchText, resetText, i18n }) => {
14
14
  const [form] = Form.useForm(); // 该组件内form全局变量
15
15
  const ref = useRef(null);
16
16
  const refInitY = useRef(undefined);
@@ -71,6 +71,9 @@ const FiltersHorizontal = ({ items, onFinish, onClear, y, setY, overMax, colOpts
71
71
  setShowMore(true);
72
72
  setWrapH(110);
73
73
  }
74
+ if (itemValues) {
75
+ form.setFieldsValue(itemValues);
76
+ }
74
77
  }
75
78
  }, []);
76
79
  useEffect(() => {
@@ -17,6 +17,7 @@ interface IProps {
17
17
  overMax?: number;
18
18
  colOpts?: ColProps;
19
19
  items: React.ReactElement[];
20
+ itemValues?: any;
20
21
  onFinish?: (v: any) => Promise<void>;
21
22
  onClear?: () => Promise<void>;
22
23
  searchText?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecoding/components.antd",
3
- "version": "0.5.14",
3
+ "version": "0.5.16",
4
4
  "author": "cxc",
5
5
  "homepage": "",
6
6
  "license": "MIT",
@@ -47,5 +47,5 @@
47
47
  "antd": "^6.0.0",
48
48
  "axios": "^1.1.2"
49
49
  },
50
- "gitHead": "63dbd74fd806139370f6f812cc712756866283ff"
50
+ "gitHead": "078ccdbbe6892e97efd42efdd2afbe123be1daef"
51
51
  }