@zgfe/modules-settings 2.0.0-zhongyuan.5 → 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,19 +67,19 @@ 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
  }
72
74
  }, {
73
75
  title: '文档名称',
74
76
  dataIndex: 'name',
75
- key: 'name',
76
- with: 260
77
+ key: 'name'
77
78
  }, {
78
79
  title: '创建时间',
79
80
  dataIndex: 'createdTime',
80
81
  key: 'createdTime',
81
- with: 200,
82
+ width: 200,
82
83
  sorter: function sorter(a, b) {
83
84
  return moment(b.createdTime).valueOf() - moment(a.createdTime).valueOf();
84
85
  },
@@ -88,7 +89,7 @@ var DocumentSetting = function DocumentSetting() {
88
89
  }, {
89
90
  title: '操作',
90
91
  key: 'operation',
91
- with: 120,
92
+ width: 170,
92
93
  render: function render(_, record) {
93
94
  return /*#__PURE__*/React.createElement(Space, {
94
95
  size: "middle"
@@ -182,6 +183,7 @@ var DocumentSetting = function DocumentSetting() {
182
183
  isOpenUploadModal = _useState10[0],
183
184
  setIsOpenUploadModal = _useState10[1];
184
185
  var handleValueCancel = function handleValueCancel() {
186
+ setFileList(undefined);
185
187
  setIsOpenUploadModal(false);
186
188
  setDocumentFlagLoading(false);
187
189
  };
@@ -191,25 +193,34 @@ var DocumentSetting = function DocumentSetting() {
191
193
  setFileList = _useState12[1];
192
194
  var props = {
193
195
  name: 'file',
194
- multiple: true,
196
+ maxCount: 1,
197
+ accept: '.zip,.rar,.7z',
195
198
  beforeUpload: beforeUpload,
196
199
  onChange: function onChange(info) {
197
200
  console.log(info);
198
201
  var status = info.file.status;
199
202
  if (status !== 'uploading') {
200
- console.log(info.file, info.fileList);
203
+ if (info.fileList.length > 0) {
204
+ setFileList(info.fileList[0].originFileObj);
205
+ }
201
206
  }
202
- if (status === 'done') {
203
- setFileList(info.fileList[0].originFileObj);
204
- } else if (status === 'error') {
205
- message.error("".concat(info.file.name, " file upload failed."));
207
+ if (status == 'removed') {
208
+ setFileList(undefined);
206
209
  }
210
+ // if (status === 'done') {
211
+ // } else if (status === 'error') {
212
+ // message.error(`${info.file.name} file upload failed.`);
213
+ // }
207
214
  },
208
215
  onDrop: function onDrop(e) {
209
216
  console.log('Dropped files', e.dataTransfer.files);
210
217
  }
211
218
  };
212
219
  var saveFile = function saveFile() {
220
+ if (!fileList) {
221
+ message.error('请选择上传的文件');
222
+ return;
223
+ }
213
224
  var formData = new FormData();
214
225
  formData.append('file', fileList);
215
226
  request(apis.setting.uploadDocumentFile, {
@@ -378,6 +389,7 @@ var DocumentSetting = function DocumentSetting() {
378
389
  title: "\u4E0A\u4F20",
379
390
  okText: "\u786E\u5B9A",
380
391
  cancelText: "\u53D6\u6D88",
392
+ destroyOnClose: true,
381
393
  open: isOpenUploadModal,
382
394
  onCancel: handleValueCancel,
383
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.5",
3
+ "version": "2.0.0-zhongyuan.6",
4
4
  "private": false,
5
5
  "module": "es/index.js",
6
6
  "typings": "es/index.d.ts",