@ecoding/components.antd 0.4.22 → 0.4.24

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,8 +12,9 @@ import { Upload, Image as Img, Alert, Flex, message, Space } from 'antd';
12
12
  import { PlusOutlined } from '@ant-design/icons';
13
13
  import { buildURL } from "@ecoding/helper.url";
14
14
  import { DndContext, PointerSensor, useSensor } from '@dnd-kit/core';
15
- import { arrayMove, SortableContext, useSortable, horizontalListSortingStrategy, } from '@dnd-kit/sortable';
15
+ import { arrayMove, SortableContext, useSortable, rectSortingStrategy, } from '@dnd-kit/sortable';
16
16
  import { CSS } from '@dnd-kit/utilities';
17
+ import Toast from "../../core/toast";
17
18
  const DraggableUploadListItem = ({ originNode, file }) => {
18
19
  const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({
19
20
  id: file.uid,
@@ -63,17 +64,25 @@ const MultipleImgUpload = (props) => {
63
64
  onChange && (onChange === null || onChange === void 0 ? void 0 : onChange(!isEmpty ? urls : undefined));
64
65
  };
65
66
  const handleChange = ({ fileList }) => {
66
- fileList && fileList.forEach((item) => {
67
- var _a, _b, _c;
68
- if (item.status == "done" && (((_a = item.response) === null || _a === void 0 ? void 0 : _a.code) == 200 || ((_b = item.response) === null || _b === void 0 ? void 0 : _b.code) == 0) && ((_c = item.response) === null || _c === void 0 ? void 0 : _c.data)) {
69
- item.url = item.response.data.url;
67
+ fileList && fileList.forEach((file) => {
68
+ if (file.status == "done") {
69
+ const response = file.response || {};
70
+ if (response.code === 200 ||
71
+ response.code === 0 ||
72
+ response.success ||
73
+ response.successed) {
74
+ const data = response.data || response.model;
75
+ file.url = data.url;
76
+ }
77
+ }
78
+ else if (file.status === "error") {
79
+ Toast.error({
80
+ mask: true,
81
+ title: file.response ? file.response.msg || file.response.message : `${props.i18n ? props.i18n.$t('global.upload.error.img') : '服务出错,图片上传失败'}`
82
+ });
70
83
  }
71
84
  });
72
85
  updateItems(fileList);
73
- // if (len) {
74
- // return;
75
- // }
76
- // updateItems(fileList)
77
86
  };
78
87
  const handleRemove = (file) => {
79
88
  const lefts = imgList.filter(item => item.uid !== file.uid);
@@ -222,7 +231,7 @@ const MultipleImgUpload = (props) => {
222
231
  !((_c = props.opts) === null || _c === void 0 ? void 0 : _c.minH) ? null : (React.createElement("span", null, i18n ? `${i18n.$t("global.minH", "最小高")}:${props.opts.minH}` : `最小高:${props.opts.minH}`)),
223
232
  !((_d = props.opts) === null || _d === void 0 ? void 0 : _d.maxH) ? null : (React.createElement("span", null, i18n ? `${i18n.$t("global.maxH", "最大高")}:${props.opts.maxH}` : `最大高:${props.opts.maxH}`))))) : null)), type: "warning", showIcon: true })),
224
233
  React.createElement(DndContext, { sensors: [sensor], onDragEnd: onDragEnd },
225
- React.createElement(SortableContext, { items: imgList === null || imgList === void 0 ? void 0 : imgList.map((i) => i.uid), strategy: horizontalListSortingStrategy },
234
+ React.createElement(SortableContext, { items: imgList === null || imgList === void 0 ? void 0 : imgList.map((i) => i.uid), strategy: rectSortingStrategy },
226
235
  React.createElement(Upload, { listType: "picture-card", fileList: imgList, action: action, beforeUpload: beforeUpload, onPreview: handlePreview, onChange: handleChange, onRemove: handleRemove, name: name, data: props.data, multiple: true, disabled: disabled, withCredentials: true, itemRender: (originNode, file) => (React.createElement(DraggableUploadListItem, { originNode: originNode, file: file })) }, maxCount == 0 ? uploadButton : maxCount && imgList.length >= maxCount ? null : uploadButton),
227
236
  previewImage && (React.createElement(Img, { wrapperStyle: { display: 'none' }, preview: {
228
237
  visible: previewOpen,
@@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react';
2
2
  import { Flex, Alert, Space } from 'antd';
3
3
  import { DragOutlined } from '@ant-design/icons';
4
4
  import { DndContext, closestCenter, PointerSensor, useSensor, useSensors } from '@dnd-kit/core';
5
- import { arrayMove, SortableContext, horizontalListSortingStrategy, useSortable } from '@dnd-kit/sortable';
5
+ import { arrayMove, SortableContext, rectSortingStrategy, useSortable } from '@dnd-kit/sortable';
6
6
  import { CSS } from '@dnd-kit/utilities';
7
7
  import ImgUpload from '../single-img-upload';
8
8
  const SortableItem = (props) => {
@@ -120,7 +120,7 @@ const MultiPileImgUpload = (props) => {
120
120
  !((_c = props.opts) === null || _c === void 0 ? void 0 : _c.minW) ? null : (React.createElement("span", null, props.i18n ? `${props.i18n.$t("global.minW", "最小宽")}:${props.opts.minW}` : `最小宽:${props.opts.minW}`)),
121
121
  !((_d = props.opts) === null || _d === void 0 ? void 0 : _d.maxH) ? null : (React.createElement("span", null, props.i18n ? `${props.i18n.$t("global.maxH", "最大高")}:${props.opts.maxH}` : `最大高:${props.opts.maxH}`))))) : null)), type: "warning", showIcon: true })),
122
122
  React.createElement(DndContext, { sensors: sensors, collisionDetection: closestCenter, onDragEnd: handleDragEnd },
123
- React.createElement(SortableContext, { items: items, strategy: horizontalListSortingStrategy },
123
+ React.createElement(SortableContext, { items: items, strategy: rectSortingStrategy },
124
124
  React.createElement(Flex, { wrap: true, align: "start" }, items.map((item, index) => (React.createElement(SortableItem, Object.assign({}, props, { index: index, items: items, updateItems: updateItems, value: item.url, key: item.id, id: item.id })))))))));
125
125
  };
126
126
  MultiPileImgUpload.defaultProps = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecoding/components.antd",
3
- "version": "0.4.22",
3
+ "version": "0.4.24",
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": "92f998a40fb7a5d3f41530d8533ca3eed9fd22a0"
50
+ "gitHead": "fe2f4ed23efc30f329c9ca878e2f4928241a6e04"
51
51
  }