xydata-tools 1.0.49 → 1.0.51

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.
@@ -22,19 +22,21 @@ import DownloadFileTool from "../../utils/downloadFile";
22
22
  * @preserve
23
23
  * @param {Object} props 组件的属性
24
24
  * @param {string|React.ReactNode} [props.text] 按钮内容,可传入 string 或 ReactNode
25
- * @param {Object} [props.queryOption] 下载参数对象
26
- * @param {string} [props.queryOption.url] 下载地址
27
- * @param {string} [props.queryOption.methods] 请求方法 (GET/POST)
28
- * @param {string} [props.queryOption.fileName] 文件名
29
- * @param {Object} [props.queryOption.params] 请求参数
30
- * @param {Object} [props.queryOption.customField] 自定义字段
31
- * @param {string} [props.queryOption.customField.url] 自定义文件地址字段(表示取值res.data.[传入的参数])
32
- * @param {string} [props.queryOption.customField.fileName] 自定义文件名字段(表示取值res.data.[传入的参数])
33
- * @param {(error: Error) => void} [props.onError] 接口异常回调函数
34
25
  * @param {React.ReactNode} [props.icon] 按钮的图标
35
26
  * @param {boolean} [props.disabled] 是否禁用按钮
36
27
  * @param {boolean} [props.danger] 是否为危险按钮
37
28
  * @param {"default"|"primary"|"ghost"|"dashed"|"link"|"text"} [props.type] 按钮类型
29
+ * @param {Object} [props.queryOption] 下载参数对象
30
+ * @param {string} [props.queryOption.url] 下载接口地址
31
+ * @param {string} [props.queryOption.methods] 请求方法 (GET/POST)
32
+ * @param {string} [props.queryOption.downloadType] 下载类型,值为 'pure' 时表示下载外链文件(通过网页地址栏打开就可以下载的链接)
33
+ * @param {string} [props.queryOption.fileName] 默认下载的文件名,需要后缀,如接口中返回了fileName,以接口返回的为准
34
+ * @param {Object} [props.queryOption.params] 默认请求参数
35
+ * @param {(params: Object) => Object} [props.queryOption.onBeforeDownload] 请求前调用,用于获取或修改请求参数
36
+ * @param {Object} [props.queryOption.customField] 自定义接口取值字段
37
+ * @param {string} [props.queryOption.customField.url] 自定义文件地址字段(表示取值res.data.[传入的参数])
38
+ * @param {string} [props.queryOption.customField.fileName] 自定义文件名字段(表示取值res.data.[传入的参数])
39
+ * @param {(error: Error) => void} [props.queryOption.onError] 接口异常回调函数
38
40
  */
39
41
  var DownloadFile = function DownloadFile(props) {
40
42
  var _useState = useState(false),
@@ -46,23 +48,31 @@ var DownloadFile = function DownloadFile(props) {
46
48
  onClick: function () {
47
49
  var _onClick = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
48
50
  var _props$queryOption;
51
+ var mergedParams, dynamicParams;
49
52
  return _regeneratorRuntime().wrap(function _callee$(_context) {
50
53
  while (1) switch (_context.prev = _context.next) {
51
54
  case 0:
52
55
  if (!((_props$queryOption = props.queryOption) !== null && _props$queryOption !== void 0 && _props$queryOption.url)) {
53
- _context.next = 7;
56
+ _context.next = 9;
54
57
  break;
55
58
  }
56
59
  setLoading(true);
57
- _context.next = 4;
58
- return DownloadFileTool(props.queryOption || {});
59
- case 4:
60
+ mergedParams = props.queryOption.params || {};
61
+ if (typeof props.queryOption.onBeforeDownload === "function") {
62
+ dynamicParams = props.queryOption.onBeforeDownload(mergedParams) || {};
63
+ mergedParams = _objectSpread(_objectSpread({}, mergedParams), dynamicParams);
64
+ }
65
+ _context.next = 6;
66
+ return DownloadFileTool(_objectSpread(_objectSpread({}, props.queryOption || {}), {}, {
67
+ params: mergedParams
68
+ }));
69
+ case 6:
60
70
  setLoading(false);
61
- _context.next = 8;
71
+ _context.next = 10;
62
72
  break;
63
- case 7:
73
+ case 9:
64
74
  console.error("请传入下载参数");
65
- case 8:
75
+ case 10:
66
76
  case "end":
67
77
  return _context.stop();
68
78
  }
@@ -6,7 +6,7 @@ import React from "react";
6
6
  var ButtonBox = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: #999;\n position: absolute;\n z-index: 3;\n bottom: 20px;\n width: 100%;\n text-align: center;\n font-size: 12px;\n"])));
7
7
 
8
8
  /**
9
- * 导出Excel
9
+ * 版本注释
10
10
  * @preserve
11
11
  * @param {Object} props 组件的属性
12
12
  * @param {Object} [props.envData] 环境变量数据,默认为从 sessionStorage 中获取的 env_data
@@ -8,7 +8,7 @@
8
8
  <view v-if="enableImage && showFileList" class="media-section">
9
9
  <shmily-drag-media v-if="imageFileList.length > 0" v-model="imageUrls" :number="imageLimit"
10
10
  :cols="cols" :imageWidth="itemWidth" :padding="10" :borderRadius="itemBorderRadius"
11
- :draggable="draggable" moveType="image" @update:modelValue="handleImageDragChange">
11
+ :draggable="draggable" moveType="image" @input="handleImageDragChange">
12
12
  </shmily-drag-media>
13
13
  </view>
14
14
 
@@ -17,7 +17,7 @@
17
17
  :style="{ marginTop: enableImage && videoFileList.length > 0 ? '20rpx' : '0' }">
18
18
  <shmily-drag-media v-if="videoFileList.length > 0" v-model="videoUrls" :number="videoLimit"
19
19
  :cols="cols" :imageWidth="itemWidth" :padding="10" :borderRadius="itemBorderRadius"
20
- :draggable="draggable" moveType="video" @update:modelValue="handleVideoDragChange"
20
+ :draggable="draggable" moveType="video" @input="handleVideoDragChange"
21
21
  @videoClick="handleVideoItemClick">
22
22
  </shmily-drag-media>
23
23
  </view>
@@ -56,7 +56,7 @@
56
56
  <shmily-drag-media v-if="enableImage && !enableVideo && showFileList" v-model="imageUrls"
57
57
  :number="imageLimit" :cols="cols" :imageWidth="itemWidth" :padding="10"
58
58
  :borderRadius="itemBorderRadius" :align="align" :draggable="draggable" :enableAddButton="true"
59
- moveType="image" @update:modelValue="handleImageDragChange">
59
+ moveType="image" @input="handleImageDragChange">
60
60
  <template #add-button="{ childWidth }">
61
61
  <slot name="image-upload-button" :select="selectAndUploadImage" :limit="imageLimit"
62
62
  :count="imageFileList.length">
@@ -74,7 +74,7 @@
74
74
  <shmily-drag-media v-else-if="enableVideo && !enableImage && showFileList" v-model="videoUrls"
75
75
  :number="videoLimit" :cols="cols" :imageWidth="itemWidth" :padding="10"
76
76
  :borderRadius="itemBorderRadius" :align="align" :draggable="draggable" :enableAddButton="true"
77
- moveType="video" @update:modelValue="handleVideoDragChange" @videoClick="handleVideoItemClick">
77
+ moveType="video" @input="handleVideoDragChange" @videoClick="handleVideoItemClick">
78
78
  <template #add-button="{ childWidth }">
79
79
  <slot name="video-upload-button" :select="selectAndUploadVideo" :limit="videoLimit"
80
80
  :count="videoFileList.length">
@@ -857,7 +857,7 @@ export default {
857
857
  /**
858
858
  * 处理图片拖拽排序变化
859
859
  */
860
- handleImageDragChange(newUrls) {
860
+ handleImageDragChange(newUrls) {
861
861
  const newFileList = newUrls.map(url => {
862
862
  return this.imageFileList.find(file => file.url === url)
863
863
  }).filter(Boolean)
@@ -28,9 +28,8 @@
28
28
  <view class="media-loading-overlay" v-if="item.loading">
29
29
  <view class="loading-spinner"></view>
30
30
  </view>
31
- <view class="del-con" @click="delImages(item, index)"
32
- @touchstart.stop="delImageMp(item, index)" @touchend.stop="nothing()"
33
- @mousedown.stop="nothing()" @mouseup.stop="nothing()">
31
+ <view class="del-con" @click="delImages(item, index)" @touchstart.stop="delImageMp(item, index)"
32
+ @touchend.stop="nothing()" @mousedown.stop="nothing()" @mouseup.stop="nothing()">
34
33
  <view class="del-wrap">
35
34
  <image class="del-image"
36
35
  src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACEAAAAhCAYAAABX5MJvAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAhdEVYdENyZWF0aW9uIFRpbWUAMjAyMDowNzoyNSAyMTo1NDoyOU4TkJAAAADcSURBVFhH7ZfRCoMwDEXLvkjwwVf/bH/emmAyN6glTW9WBjsgwm28OeCLpj81Sil7zvlJ90UiONS/yY5VogsO6XrBg3IEQ5a/s8vRSWUAKmLqp2w5jz5BiNQEGMo3GbloDLtFXJ1IkaEuhAiiY6gEIqB4yqACSk9piIBiKQ8VUFpLviKg3C2rESKgWERCBZSWiEfgIfffYvrrsAgoISJ3Apy3zuTxcSxLQkV6ykNEPKVQkZEyiAiiZKgDIaC4upACSlcn5fM/+WuDCAHF1E/Z/N9AhkMZnPNDPI+UDjPIXgAQIGjNAAAAAElFTkSuQmCC">
@@ -508,7 +507,7 @@ export default {
508
507
  }
509
508
  //#endif
510
509
  },
511
- delImages(item, index) {
510
+ delImages(item, index) {
512
511
  if (typeof this.delImage === 'function') {
513
512
  this.delImage.bind(this.$parent)(() => {
514
513
  this.delImageHandle(item, index)
@@ -517,10 +516,15 @@ export default {
517
516
  this.delImageHandle(item, index)
518
517
  }
519
518
  },
519
+ delImageMp(item, index) {
520
+ //#ifdef MP
521
+ this.delImages(item, index)
522
+ //#endif
523
+ },
520
524
  delImageHandle(item, index) {
521
525
  // 设置标志,防止 watch 触发重新初始化
522
526
  this.changeStatus = false
523
-
527
+
524
528
  // 删除指定图片
525
529
  this.imageList.splice(index, 1)
526
530
 
@@ -550,17 +554,12 @@ export default {
550
554
 
551
555
  this.updateAddButtonPosition()
552
556
  this.sortList()
553
-
557
+
554
558
  // 恢复标志
555
559
  this.$nextTick(() => {
556
560
  this.changeStatus = true
557
561
  })
558
562
  },
559
- delImageMp(item, index) {
560
- //#ifdef MP
561
- this.delImages(item, index)
562
- //#endif
563
- },
564
563
  sortList() {
565
564
  const result = []
566
565
  let list = this.imageList.slice()
@@ -4,35 +4,39 @@ export default DownloadFile;
4
4
  * @preserve
5
5
  * @param {Object} props 组件的属性
6
6
  * @param {string|React.ReactNode} [props.text] 按钮内容,可传入 string 或 ReactNode
7
- * @param {Object} [props.queryOption] 下载参数对象
8
- * @param {string} [props.queryOption.url] 下载地址
9
- * @param {string} [props.queryOption.methods] 请求方法 (GET/POST)
10
- * @param {string} [props.queryOption.fileName] 文件名
11
- * @param {Object} [props.queryOption.params] 请求参数
12
- * @param {Object} [props.queryOption.customField] 自定义字段
13
- * @param {string} [props.queryOption.customField.url] 自定义文件地址字段(表示取值res.data.[传入的参数])
14
- * @param {string} [props.queryOption.customField.fileName] 自定义文件名字段(表示取值res.data.[传入的参数])
15
- * @param {(error: Error) => void} [props.onError] 接口异常回调函数
16
7
  * @param {React.ReactNode} [props.icon] 按钮的图标
17
8
  * @param {boolean} [props.disabled] 是否禁用按钮
18
9
  * @param {boolean} [props.danger] 是否为危险按钮
19
10
  * @param {"default"|"primary"|"ghost"|"dashed"|"link"|"text"} [props.type] 按钮类型
11
+ * @param {Object} [props.queryOption] 下载参数对象
12
+ * @param {string} [props.queryOption.url] 下载接口地址
13
+ * @param {string} [props.queryOption.methods] 请求方法 (GET/POST)
14
+ * @param {string} [props.queryOption.downloadType] 下载类型,值为 'pure' 时表示下载外链文件(通过网页地址栏打开就可以下载的链接)
15
+ * @param {string} [props.queryOption.fileName] 默认下载的文件名,需要后缀,如接口中返回了fileName,以接口返回的为准
16
+ * @param {Object} [props.queryOption.params] 默认请求参数
17
+ * @param {(params: Object) => Object} [props.queryOption.onBeforeDownload] 请求前调用,用于获取或修改请求参数
18
+ * @param {Object} [props.queryOption.customField] 自定义接口取值字段
19
+ * @param {string} [props.queryOption.customField.url] 自定义文件地址字段(表示取值res.data.[传入的参数])
20
+ * @param {string} [props.queryOption.customField.fileName] 自定义文件名字段(表示取值res.data.[传入的参数])
21
+ * @param {(error: Error) => void} [props.queryOption.onError] 接口异常回调函数
20
22
  */
21
23
  declare function DownloadFile(props: {
22
24
  text?: string | React.ReactNode;
25
+ icon?: React.ReactNode;
26
+ disabled?: boolean;
27
+ danger?: boolean;
28
+ type?: "default" | "primary" | "ghost" | "dashed" | "link" | "text";
23
29
  queryOption?: {
24
30
  url?: string;
25
31
  methods?: string;
32
+ downloadType?: string;
26
33
  fileName?: string;
27
34
  params?: any;
35
+ onBeforeDownload?: (params: any) => any;
28
36
  customField?: {
29
37
  url?: string;
30
38
  fileName?: string;
31
39
  };
40
+ onError?: (error: Error) => void;
32
41
  };
33
- onError?: (error: Error) => void;
34
- icon?: React.ReactNode;
35
- disabled?: boolean;
36
- danger?: boolean;
37
- type?: "default" | "primary" | "ghost" | "dashed" | "link" | "text";
38
42
  }): JSX.Element;
@@ -1,6 +1,6 @@
1
1
  export default Version;
2
2
  /**
3
- * 导出Excel
3
+ * 版本注释
4
4
  * @preserve
5
5
  * @param {Object} props 组件的属性
6
6
  * @param {Object} [props.envData] 环境变量数据,默认为从 sessionStorage 中获取的 env_data
@@ -51,7 +51,3 @@ declare function UploadFile(props: {
51
51
  uploadOptions: UploadProps;
52
52
  buttonOptions: ButtonProps;
53
53
  }): JSX.Element;
54
- import { FormProps } from "antd";
55
- import { FormItemProps } from "antd";
56
- import { UploadProps } from "antd";
57
- import { ButtonProps } from "antd";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xydata-tools",
3
- "version": "1.0.49",
3
+ "version": "1.0.51",
4
4
  "description": "xydata tools",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -27,7 +27,12 @@
27
27
  },
28
28
  "peerDependencies": {
29
29
  "react": "^17.0.0",
30
- "react-dom": "^17.0.0"
30
+ "react-dom": "^17.0.0",
31
+ "moment": "^2.30.1",
32
+ "antd": "^4.24.16",
33
+ "@ant-design/icons": "^4.5.0",
34
+ "@ant-design/pro-form": "^1.69.4",
35
+ "@ant-design/pro-table": "^2.80.8"
31
36
  },
32
37
  "devDependencies": {
33
38
  "@babel/core": "7.24.9",
@@ -41,12 +46,7 @@
41
46
  "vue-template-compiler": "2.7.16"
42
47
  },
43
48
  "dependencies": {
44
- "@ant-design/icons": "4.5.0",
45
- "@ant-design/pro-form": "1.69.4",
46
- "@ant-design/pro-table": "2.80.8",
47
49
  "@zhengxs/js.tree": "0.5.0",
48
- "antd": "4.24.16",
49
- "moment": "2.30.1",
50
50
  "querystring": "0.2.1",
51
51
  "stringify": "5.2.0",
52
52
  "styled-components": "4.4.1",