@zgfe/modules-settings 2.0.0-zhongyuan.4 → 2.0.0-zhongyuan.6

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.
@@ -25,15 +25,16 @@ var Dragger = Upload.Dragger;
25
25
  var pageName = 'DocumentSetting';
26
26
  var confirm = Modal.confirm;
27
27
  var beforeUpload = function beforeUpload(file) {
28
- var isJpgOrPng = file.type == 'application/x-zip-compressed' || file.type == 'application/x-compressed';
29
- if (!isJpgOrPng) {
30
- message.error('只能传入是ZIP或者RAR文件');
31
- }
28
+ // const isJpgOrPng =
29
+ // file.type == 'application/x-zip-compressed' || file.type == 'application/x-compressed';
30
+ // if (!isJpgOrPng) {
31
+ // message.error('只能传入是ZIP或者RAR文件');
32
+ // }
32
33
  var isLt2M = file.size / 1024 / 1024 < 100;
33
34
  if (!isLt2M) {
34
35
  message.error('文件不能大于100M');
35
36
  }
36
- return isJpgOrPng && isLt2M;
37
+ return isLt2M;
37
38
  };
38
39
  var downloadFile = function downloadFile(resData, name) {
39
40
  var blob = resData.data;
@@ -66,6 +67,7 @@ var DocumentSetting = function DocumentSetting() {
66
67
  title: '序号',
67
68
  dataIndex: 'index',
68
69
  key: 'index',
70
+ width: 80,
69
71
  render: function render(_, obj, index) {
70
72
  return index + 1;
71
73
  }
@@ -77,6 +79,7 @@ var DocumentSetting = function DocumentSetting() {
77
79
  title: '创建时间',
78
80
  dataIndex: 'createdTime',
79
81
  key: 'createdTime',
82
+ width: 200,
80
83
  sorter: function sorter(a, b) {
81
84
  return moment(b.createdTime).valueOf() - moment(a.createdTime).valueOf();
82
85
  },
@@ -86,6 +89,7 @@ var DocumentSetting = function DocumentSetting() {
86
89
  }, {
87
90
  title: '操作',
88
91
  key: 'operation',
92
+ width: 170,
89
93
  render: function render(_, record) {
90
94
  return /*#__PURE__*/React.createElement(Space, {
91
95
  size: "middle"
@@ -179,6 +183,7 @@ var DocumentSetting = function DocumentSetting() {
179
183
  isOpenUploadModal = _useState10[0],
180
184
  setIsOpenUploadModal = _useState10[1];
181
185
  var handleValueCancel = function handleValueCancel() {
186
+ setFileList(undefined);
182
187
  setIsOpenUploadModal(false);
183
188
  setDocumentFlagLoading(false);
184
189
  };
@@ -188,24 +193,34 @@ var DocumentSetting = function DocumentSetting() {
188
193
  setFileList = _useState12[1];
189
194
  var props = {
190
195
  name: 'file',
191
- multiple: true,
196
+ maxCount: 1,
197
+ accept: '.zip,.rar,.7z',
192
198
  beforeUpload: beforeUpload,
193
199
  onChange: function onChange(info) {
200
+ console.log(info);
194
201
  var status = info.file.status;
195
202
  if (status !== 'uploading') {
196
- console.log(info.file, info.fileList);
203
+ if (info.fileList.length > 0) {
204
+ setFileList(info.fileList[0].originFileObj);
205
+ }
197
206
  }
198
- if (status === 'done') {
199
- setFileList(info.fileList[0].originFileObj);
200
- } else if (status === 'error') {
201
- message.error("".concat(info.file.name, " file upload failed."));
207
+ if (status == 'removed') {
208
+ setFileList(undefined);
202
209
  }
210
+ // if (status === 'done') {
211
+ // } else if (status === 'error') {
212
+ // message.error(`${info.file.name} file upload failed.`);
213
+ // }
203
214
  },
204
215
  onDrop: function onDrop(e) {
205
216
  console.log('Dropped files', e.dataTransfer.files);
206
217
  }
207
218
  };
208
219
  var saveFile = function saveFile() {
220
+ if (!fileList) {
221
+ message.error('请选择上传的文件');
222
+ return;
223
+ }
209
224
  var formData = new FormData();
210
225
  formData.append('file', fileList);
211
226
  request(apis.setting.uploadDocumentFile, {
@@ -374,6 +389,7 @@ var DocumentSetting = function DocumentSetting() {
374
389
  title: "\u4E0A\u4F20",
375
390
  okText: "\u786E\u5B9A",
376
391
  cancelText: "\u53D6\u6D88",
392
+ destroyOnClose: true,
377
393
  open: isOpenUploadModal,
378
394
  onCancel: handleValueCancel,
379
395
  onOk: saveFile
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zgfe/modules-settings",
3
- "version": "2.0.0-zhongyuan.4",
3
+ "version": "2.0.0-zhongyuan.6",
4
4
  "private": false,
5
5
  "module": "es/index.js",
6
6
  "typings": "es/index.d.ts",