fmui-base 2.3.34 → 2.3.35

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.
@@ -49,8 +49,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
49
49
 
50
50
  function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
51
51
 
52
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
53
- * 流程批示意见区块(默认意见、退回意见等),与 TblForm 纯表单分离使用
52
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
53
+ * 流程批示意见区块(默认意见、退回意见等),与 TblForm 纯表单分离使用
54
54
  */
55
55
 
56
56
 
@@ -139,6 +139,11 @@ var PageHome = function (_React$Component) {
139
139
  var canDel = props.canDel;
140
140
  //可下载
141
141
  var canDownload = props.canDownload;
142
+ // 普通微信端:UA 判断(thirdMenuType 可能为 null,且值为 WX 而非 WeChat)
143
+ var isWeChatClient = _this.isRegularWeChatClient();
144
+ // 鸿蒙端:不设 input accept,事件内校验文件类型
145
+ var isHarmonyClient = _this.isHarmonyClient();
146
+ var skipInputAccept = isWeChatClient && isHarmonyClient;
142
147
  // 公众号不展示下载按钮
143
148
  if (getLoginUserInfo().thirdMenuType == 'WeChat') {
144
149
  canDownload = false;
@@ -243,7 +248,10 @@ var PageHome = function (_React$Component) {
243
248
  returnOnce: returnOnce,
244
249
  percent1: 0,
245
250
  showProgress: true,
246
- isDesktop: isDesktop
251
+ isDesktop: isDesktop,
252
+ isWeChatClient: isWeChatClient,
253
+ isHarmonyClient: isHarmonyClient,
254
+ skipInputAccept: skipInputAccept
247
255
  };
248
256
  return _this;
249
257
  }
@@ -253,6 +261,36 @@ var PageHome = function (_React$Component) {
253
261
  value: function GenNonDuplicateID(randomLength) {
254
262
  return Number(Math.random().toString().substr(3, randomLength) + Date.now()).toString(36);
255
263
  }
264
+
265
+ // 普通微信(非企业微信):与 base.js 中 isRegularWeChat 逻辑一致
266
+
267
+ }, {
268
+ key: 'isRegularWeChatClient',
269
+ value: function isRegularWeChatClient() {
270
+ if (typeof isRegularWeChat !== 'undefined') {
271
+ return !!isRegularWeChat;
272
+ }
273
+ var ua = navigator.userAgent || '';
274
+ return (/MicroMessenger/i.test(ua) && !/wxwork/i.test(ua)
275
+ );
276
+ }
277
+
278
+ // 鸿蒙端:thirdMenuType=MH、emp JSBridge 或 UA 识别
279
+
280
+ }, {
281
+ key: 'isHarmonyClient',
282
+ value: function isHarmonyClient() {
283
+ var thirdMenuType = getLoginUserInfo().thirdMenuType;
284
+ if (thirdMenuType == 'MH') {
285
+ return true;
286
+ }
287
+ if (typeof emp !== 'undefined') {
288
+ return true;
289
+ }
290
+ var ua = navigator.userAgent || '';
291
+ return (/HarmonyOS|OpenHarmony/i.test(ua)
292
+ );
293
+ }
256
294
  }, {
257
295
  key: 'del',
258
296
  value: function del(delIndex) {
@@ -269,7 +307,8 @@ var PageHome = function (_React$Component) {
269
307
  name: 'file',
270
308
  url: this.state.uploadUrl,
271
309
  autoPending: true,
272
- accept: t.state.accept,
310
+ // 普通微信/鸿蒙端不设 input accept,避免选择文件异常
311
+ accept: t.state.skipInputAccept ? null : t.state.accept,
273
312
  multiple: true,
274
313
  fileSizeLimit: t.state.fileSizeLimit
275
314
  };
@@ -300,7 +339,15 @@ var PageHome = function (_React$Component) {
300
339
  request.setParam('businessExt', t.state.businessExt);
301
340
  console.info(request.getParam('token'));
302
341
  }).on(_uploadcore.Events.QUEUE_FILE_ADDED, function (file) {
303
- // return false;
342
+ // 普通微信/鸿蒙端:事件内校验文件类型(input 未设 accept)
343
+ if (t.state.skipInputAccept && t.state.accept && !t.isFileExtensionAllowed(file)) {
344
+ file.cancel();
345
+ _Toast2.default.show({
346
+ type: 'error',
347
+ content: '文件类型错误!'
348
+ });
349
+ return false;
350
+ }
304
351
  //判断总文件大小不超过
305
352
  var fileAllSizeLimit = t.state.fileAllSizeLimit;
306
353
  if (fileAllSizeLimit > 0) {
@@ -508,6 +555,28 @@ var PageHome = function (_React$Component) {
508
555
  });
509
556
  return up;
510
557
  }
558
+ // 校验文件扩展名(普通微信端 input 不设 accept 时使用)
559
+
560
+ }, {
561
+ key: 'isFileExtensionAllowed',
562
+ value: function isFileExtensionAllowed(file) {
563
+ var accept = this.state.accept;
564
+ if (!accept || !accept.extensions) {
565
+ return true;
566
+ }
567
+ var allowedExts = accept.extensions.toLowerCase().split(',').map(function (ext) {
568
+ return ext.trim().replace(/^\./, '');
569
+ });
570
+ var fileExt = (file.ext || '').toLowerCase().replace(/^\./, '');
571
+ if (!fileExt && file.name) {
572
+ var parts = file.name.split('.');
573
+ if (parts.length > 1) {
574
+ fileExt = parts[parts.length - 1].toLowerCase();
575
+ }
576
+ }
577
+ return allowedExts.indexOf(fileExt) >= 0;
578
+ }
579
+
511
580
  //计算大小
512
581
 
513
582
  }, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fmui-base",
3
- "version": "2.3.34",
3
+ "version": "2.3.35",
4
4
  "title": "fmui-base",
5
5
  "description": "fmui移动端组件",
6
6
  "main": "lib/index.js",
@@ -1,16 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- var _nvoice = require('./nvoice');
8
-
9
- Object.defineProperty(exports, 'default', {
10
- enumerable: true,
11
- get: function get() {
12
- return _interopRequireDefault(_nvoice).default;
13
- }
14
- });
15
-
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -1,177 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = undefined;
7
-
8
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
9
-
10
- var _react = require('react');
11
-
12
- var _react2 = _interopRequireDefault(_react);
13
-
14
- var _Group = require('saltui/lib/Group');
15
-
16
- var _Group2 = _interopRequireDefault(_Group);
17
-
18
- var _Field = require('saltui/lib/Field');
19
-
20
- var _Field2 = _interopRequireDefault(_Field);
21
-
22
- var _upload = require('../upload/upload');
23
-
24
- var _upload2 = _interopRequireDefault(_upload);
25
-
26
- var _Boxs = require('saltui/lib/Boxs');
27
-
28
- var _Boxs2 = _interopRequireDefault(_Boxs);
29
-
30
- var _db = require('../db/db');
31
-
32
- var _db2 = _interopRequireDefault(_db);
33
-
34
- require('./nvoice.less');
35
-
36
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
37
-
38
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
39
-
40
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
41
-
42
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
43
-
44
- var HBox = _Boxs2.default.HBox,
45
- Box = _Boxs2.default.Box,
46
- VBox = _Boxs2.default.VBox;
47
-
48
- var Nvoice = function (_React$Component) {
49
- _inherits(Nvoice, _React$Component);
50
-
51
- function Nvoice(props) {
52
- _classCallCheck(this, Nvoice);
53
-
54
- // 传入的props参数
55
- var _this = _possibleConstructorReturn(this, (Nvoice.__proto__ || Object.getPrototypeOf(Nvoice)).call(this, props));
56
-
57
- _this.initFn = function (id) {
58
-
59
- // 初始发票详情数据
60
- _db2.default.form.getNoInvoiceList({
61
- invoicedataid: id
62
- }).then(function (content) {
63
- _this.setState({
64
- invoicedata: content
65
- });
66
- }).catch(function (error) {
67
- console.error('获取详情数据失败', error);
68
- });
69
- };
70
-
71
- var invoicedataid = _this.props.id;
72
- var title = _this.props.label || '发票详情';
73
- var required = _this.props.required || false;
74
-
75
- _this.state = {
76
- invoicedataid: invoicedataid,
77
- invoicedata: [],
78
- title: title,
79
- required: required
80
- };
81
-
82
- return _this;
83
- }
84
-
85
- _createClass(Nvoice, [{
86
- key: 'componentDidMount',
87
- value: function componentDidMount() {
88
- this.initFn(this.state.invoicedataid);
89
- }
90
- }, {
91
- key: 'downloadFile',
92
-
93
-
94
- // 下载函数
95
- value: function (_downloadFile) {
96
- function downloadFile(_x) {
97
- return _downloadFile.apply(this, arguments);
98
- }
99
-
100
- downloadFile.toString = function () {
101
- return _downloadFile.toString();
102
- };
103
-
104
- return downloadFile;
105
- }(function (file) {
106
- downloadFile(file.relaObjId);
107
- })
108
- }, {
109
- key: 'render',
110
- value: function render() {
111
- return _react2.default.createElement(
112
- _Group2.default.List,
113
- { borderTopNone: true },
114
- _react2.default.createElement(
115
- _Field2.default,
116
- { required: this.state.required, label: this.state.title, layout: 'h', multiLine: true },
117
- _react2.default.createElement(
118
- 'div',
119
- null,
120
- this.state.invoicedata.map(function (item, index) {
121
- var fileList = [];
122
- try {
123
- if (item.invoicefileInfo) {
124
- fileList = JSON.parse(item.invoicefileInfo);
125
- }
126
- } catch (e) {
127
- console.error('发票附件解析失败', e);
128
- }
129
-
130
- return _react2.default.createElement(
131
- 'div',
132
- { key: item.id, className: 't-MT2' },
133
- _react2.default.createElement(
134
- VBox,
135
- { className: 'nvoice-filetitle', hAlign: 'start' },
136
- _react2.default.createElement(
137
- Box,
138
- null,
139
- item.invoicename
140
- ),
141
- _react2.default.createElement(
142
- HBox,
143
- { vAlign: 'center' },
144
- _react2.default.createElement(
145
- Box,
146
- { className: 'label label-primary' },
147
- item.invoicetype
148
- ),
149
- _react2.default.createElement(
150
- Box,
151
- null,
152
- '\uFFE5',
153
- item.invoiceamount
154
- )
155
- )
156
- ),
157
- _react2.default.createElement(_upload2.default, {
158
- required: false,
159
- canDel: false,
160
- canPreview: true,
161
- canDownload: true,
162
- initList: fileList,
163
- dir: 'form_invoice',
164
- ref: 'upload_invoice'
165
- })
166
- );
167
- })
168
- )
169
- )
170
- );
171
- }
172
- }]);
173
-
174
- return Nvoice;
175
- }(_react2.default.Component);
176
-
177
- exports.default = Nvoice;
File without changes