fmui-base 2.2.52 → 2.2.54

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.
package/README.md CHANGED
@@ -3,6 +3,8 @@
3
3
  ---npm publish
4
4
 
5
5
  ## 更新日志
6
+ - 2.2.54: 手写签名样式调整
7
+ - 2.2.53: 表单字段支持手写签名
6
8
  - 2.2.52: 时间字段宏值赋值不生效
7
9
  - 2.2.51: 北京CA跳转小程序
8
10
  - 2.2.50: 上传组件查看图片功能适配桌端
package/lib/form/form.js CHANGED
@@ -97,6 +97,10 @@ var _invoice = require('../invoice/invoice');
97
97
 
98
98
  var _invoice2 = _interopRequireDefault(_invoice);
99
99
 
100
+ var _sign = require('../signature/sign');
101
+
102
+ var _sign2 = _interopRequireDefault(_sign);
103
+
100
104
  require('./form.less');
101
105
 
102
106
  var _db = require('../db/db');
@@ -1157,6 +1161,8 @@ var PageHome = function (_React$Component) {
1157
1161
  } else {
1158
1162
  itemParam.canDownload = "0";
1159
1163
  }
1164
+ itemParam.imagetype = imagetype;
1165
+ console.log("imagetype===" + imagetype);
1160
1166
  } else if (itemType == 'poppage') {
1161
1167
  //弹出选择
1162
1168
 
@@ -1473,7 +1479,7 @@ var PageHome = function (_React$Component) {
1473
1479
  this.refs['selectMember_' + key].initSelectData();
1474
1480
  }
1475
1481
  }
1476
- if (itemType == 'upload' || itemType == 'image' || itemType == 'weboffice') {
1482
+ if (itemType == 'upload' || itemType == 'image' && itemParam.imagetype != '1' || itemType == 'weboffice') {
1477
1483
  this.refs["upload_" + t.state.itemParam.tableName + "_" + t.state.itemParam.key].initData();
1478
1484
  }
1479
1485
  if (itemType == 'note') {
@@ -3642,6 +3648,33 @@ var PageHome = function (_React$Component) {
3642
3648
  t.state.itemParam.isVerifySing == "1" ? _react2.default.createElement('i', { className: 'iconfont icon-checked t-PT10', style: { color: 'green' } }) : t.state.itemParam.isVerifySing == "2" ? _react2.default.createElement('i', { className: 'iconfont icon-close t-PT10', style: { color: 'red' } }) : ""
3643
3649
  )
3644
3650
  )
3651
+ ) : this.state.itemParam.itemType == 'image' && this.state.itemParam.imagetype == '1' ? _react2.default.createElement(
3652
+ 'div',
3653
+ { className: t.state.itemParam.fieldId, style: t.state.itemParam.formStyleObj.contentStyle },
3654
+ _react2.default.createElement(
3655
+ _Group2.default.List,
3656
+ { borderTopNone: true },
3657
+ _react2.default.createElement(
3658
+ 'div',
3659
+ { className: 't-W100', id: t.state.prefixName + "_" + t.state.itemParam.key },
3660
+ _react2.default.createElement(
3661
+ _Field2.default,
3662
+ { label: t.state.itemParam.title, required: t.state.itemParam.required, layout: 'h', multiLine: true },
3663
+ _react2.default.createElement(_sign2.default, {
3664
+ ref: "upload_" + t.state.itemParam.tableName + "_" + t.state.itemParam.key,
3665
+ fileId: t.state.itemParam.initIds,
3666
+ readOnly: t.state.itemParam.readOnly,
3667
+ dir: t.state.module,
3668
+ uploadType: 'image',
3669
+ title: '\u624B\u5199\u7B7E\u6279',
3670
+ onChange: function onChange(value) {
3671
+ t.handleChangePic(t.state.itemParam.key, value);
3672
+ }
3673
+ })
3674
+ ),
3675
+ t.state.itemParam.isVerifySing == "1" ? _react2.default.createElement('i', { className: 'iconfont icon-checked t-PT10', style: { color: 'green' } }) : t.state.itemParam.isVerifySing == "2" ? _react2.default.createElement('i', { className: 'iconfont icon-close t-PT10', style: { color: 'red' } }) : ""
3676
+ )
3677
+ )
3645
3678
  ) : this.state.itemParam.itemType == 'image' ? _react2.default.createElement(
3646
3679
  'div',
3647
3680
  { className: t.state.itemParam.fieldId, style: t.state.itemParam.formStyleObj.contentStyle },
@@ -3798,7 +3831,7 @@ var PageHome = function (_React$Component) {
3798
3831
  { flex: 1, className: 't-PR' },
3799
3832
  _react2.default.createElement(
3800
3833
  'span',
3801
- { className: "t-ML16", style: { color: t.state.itemParam.formStyleObj.contentStyle.color }, onClick: this.noticeClick.bind(this, t.state.itemParam.explainUrl) },
3834
+ { style: { color: t.state.itemParam.formStyleObj.contentStyle.color }, onClick: this.noticeClick.bind(this, t.state.itemParam.explainUrl) },
3802
3835
  t.state.itemParam.explain
3803
3836
  )
3804
3837
  ),
@@ -26,7 +26,7 @@ function Draw(canvas, degree) {
26
26
 
27
27
  width = parseFloat(width);
28
28
  // height = parseFloat(height);
29
- height = width / 2;
29
+ height = width / 2 - 30;
30
30
 
31
31
  // debugger;
32
32
  this.canvas = canvas;
@@ -51,9 +51,10 @@ var Page = function (_React$Component) {
51
51
 
52
52
  var _this = _possibleConstructorReturn(this, (Page.__proto__ || Object.getPrototypeOf(Page)).call(this, props));
53
53
 
54
- var baseContext = document.getElementById('context').value;
55
- var token = document.getElementById('token').value;
54
+ var baseContext = document.getElementById("context").value;
55
+ var token = getLoginUserInfo().token;
56
56
  var fileId = _this.props.fileId == null || _this.props.fileId == '' || _this.props.fileId == undefined ? "" : _this.props.fileId;
57
+ var readOnly = _this.props.readOnly || false;
57
58
  _this.state = {
58
59
  token: token,
59
60
  draw: null,
@@ -61,7 +62,8 @@ var Page = function (_React$Component) {
61
62
  baseContext: baseContext,
62
63
  fileId: fileId,
63
64
  disabled: true,
64
- imageUrl: '/static/fmui/images/signArea.png'
65
+ imageUrl: '/static/fmui/images/signArea.png',
66
+ readOnly: readOnly
65
67
  };
66
68
  return _this;
67
69
  }
@@ -91,10 +93,10 @@ var Page = function (_React$Component) {
91
93
  value: function clear() {
92
94
 
93
95
  var t = this;
94
- var disabled = document.getElementById('clear_i').getAttribute("disabled");
96
+ var disabled = document.getElementsByClassName('clear_i')[0].getAttribute("disabled");
95
97
  if (!disabled) {
96
- document.getElementById('clear_i').removeAttribute("class");
97
- document.getElementById('clear_i').setAttribute("class", 'iconfont icon-dele2 t-FS18 t-FCddfontblue-30');
98
+ // document.getElementById('clear_i').removeAttribute("class");
99
+ // document.getElementById('clear_i').setAttribute("class",'iconfont icon-dele2 t-FS18 t-FCddfontblue-30');
98
100
  document.getElementsByClassName('download_btn')[0].setAttribute("disabled", true);
99
101
  document.getElementsByClassName('can-div')[0].removeAttribute("style");
100
102
  document.getElementsByClassName('can-div')[0].setAttribute("style", "background:url(" + t.state.baseContext + t.state.imageUrl + ");background-size: 100% 100%;");
@@ -111,27 +113,51 @@ var Page = function (_React$Component) {
111
113
  if (disabled) {
112
114
  return;
113
115
  }
114
- formData.append("dir", "draw");
115
- var date = new Date();
116
- var time = date.getTime();
117
- formData.append("file", t.state.draw.dataURLtoBlob(t.state.draw.getPNGImage()), time + ".png");
118
- var url = t.state.baseContext + "/api/cmp/attachment/upload?token=" + t.state.token;
119
- fetch(url, {
120
- method: "POST",
121
- body: formData
122
- }).then(function (res) {
123
- if (res.ok) {
124
- res.json().then(function (obj) {
125
- t.setState({
126
- fileId: obj.data[0].id
116
+
117
+ // 获取原始 dataURL,然后在临时 canvas 上绘制白色背景并合并原图,再导出新的 dataURL 上传
118
+ var origDataURL = t.state.draw.getPNGImage();
119
+ var img = new Image();
120
+ img.onload = function () {
121
+ var tmpCanvas = document.createElement('canvas');
122
+ tmpCanvas.width = img.width;
123
+ tmpCanvas.height = img.height;
124
+ var ctx = tmpCanvas.getContext('2d');
125
+ ctx.fillStyle = '#ffffff';
126
+ ctx.fillRect(0, 0, tmpCanvas.width, tmpCanvas.height);
127
+ ctx.drawImage(img, 0, 0);
128
+
129
+ var newDataURL = tmpCanvas.toDataURL('image/png');
130
+
131
+ formData.append("dir", "draw");
132
+ var date = new Date();
133
+ var time = date.getTime();
134
+ formData.append("file", t.state.draw.dataURLtoBlob(newDataURL), time + ".png");
135
+ var url = t.state.baseContext + "/api/m/plugin/attachment/mobile/createFile?token=" + t.state.token;
136
+ fetch(url, {
137
+ method: "POST",
138
+ body: formData
139
+ }).then(function (res) {
140
+ if (res.ok) {
141
+ res.json().then(function (obj) {
142
+ t.setState({
143
+ fileId: obj.data[0].id
144
+ });
145
+ t.props.onChange(obj.data);
127
146
  });
128
- t.props.upload(obj.data[0].id);
129
147
  _Popup2.default.hide();
130
- });
131
- } else if (res.status == 401) {
132
- alert("手写签名图片上传报错了");
133
- }
134
- });
148
+ } else if (res.status == 401) {
149
+ alert("手写签名图片上传报错了");
150
+ } else {
151
+ alert("手写签名图片上传失败");
152
+ }
153
+ }).catch(function (error) {
154
+ alert("手写签名图片上传接口报错了");
155
+ });
156
+ };
157
+ img.onerror = function () {
158
+ alert("生成带白色背景的图片失败");
159
+ };
160
+ img.src = origDataURL;
135
161
  }
136
162
 
137
163
  //旋转
@@ -188,22 +214,21 @@ var Page = function (_React$Component) {
188
214
  canvasBox.style.width = width + "px";
189
215
  canvasBox.style.height = height + "px";
190
216
  canvasBox.style.transformOrigin = 'center center';
191
-
192
217
  var can1 = document.getElementsByTagName('canvas')[0];
193
218
  var divDom = document.getElementById("canvasBoxDiv");
194
219
  var divWidth = divDom.clientWidth || divDom.offsetWidth;
195
220
  var divHeigth = divDom.clientHeight || divDom.offsetHeight;
196
- can1.style.width = divWidth - 32 + "px";
197
- can1.style.height = divHeigth - 5 + "px";
221
+ can1.style.width = divWidth - 10 + "px";
222
+ can1.style.height = divHeigth - 30 + "px";
198
223
 
199
224
  setTimeout(function () {
200
225
  // document.getElementsByTagName('canvas')[0].style.border = '0.5px solid #ccc';
201
- document.getElementsByTagName('canvas')[0].style.background = 'rgb(255, 255, 255,.4)';
226
+ document.getElementsByTagName('canvas')[0].style.background = '#fff';
202
227
  document.getElementsByClassName('download_btn')[0].setAttribute("disabled", true);
203
228
  t.listenCanvas(document.getElementsByTagName('canvas')[0]);
204
229
  //t-BCf
205
230
  // document.getElementsByTagName('canvas')[0].class = 't-BCf t-ML16 t-MR16';
206
- }, 220);
231
+ }, 120);
207
232
 
208
233
  // $(can).addClass("aa");
209
234
  }
@@ -212,12 +237,12 @@ var Page = function (_React$Component) {
212
237
  value: function listenCanvas(cav) {
213
238
  var t = this;
214
239
  cav.addEventListener('touchstart', function (e) {
215
- document.getElementById('clear_i').removeAttribute("class");
216
- document.getElementById('clear_i').setAttribute("class", 'iconfont icon-dele2 t-FS18 t-FCddfontblue-60');
240
+ // document.getElementById('clear_i').removeAttribute("class");
241
+ // document.getElementById('clear_i').setAttribute("class",'iconfont icon-dele2 t-FS18 t-FCddfontblue-60');
217
242
  document.getElementsByClassName('download_btn')[0].removeAttribute("disabled");
218
243
 
219
244
  document.getElementsByClassName('can-div')[0].removeAttribute("style");
220
- document.getElementsByClassName('can-div')[0].setAttribute("style", "background:#fff");
245
+ // document.getElementsByClassName('can-div')[0].setAttribute("style","background:#fff");
221
246
  }, false);
222
247
  }
223
248
  }, {
@@ -231,11 +256,11 @@ var Page = function (_React$Component) {
231
256
  { id: 'canvasBox', className: 't-BCf7' },
232
257
  _react2.default.createElement(
233
258
  'div',
234
- { className: 'greet t-P16 t-FAR t-PB12' },
259
+ { className: 'greet t-P16 t-FAL t-PB12' },
235
260
  _react2.default.createElement(
236
- _TextButton2.default,
237
- { display: 'inline', className: 'dd-write-sign-del', onClick: t.clear.bind(t) },
238
- _react2.default.createElement('i', { id: 'clear_i', className: 'clear_i iconfont icon-dele2 t-FS18 t-FCddfontblue-30' })
261
+ _Button2.default,
262
+ { id: 'clear_i', className: 't-MR10 clear_i', type: 'danger', size: 'small', display: 'inline', onClick: t.clear.bind(t) },
263
+ '\u6E05\u9664'
239
264
  ),
240
265
  _react2.default.createElement(
241
266
  _Button2.default,
@@ -262,64 +287,7 @@ var Page = function (_React$Component) {
262
287
  t.getHorizontalStyle();
263
288
  t.initCanvas(0);
264
289
  t.degree(90);
265
- }, 200);
266
- }
267
-
268
- //弹出签名页面
269
-
270
- }, {
271
- key: 'popDraw',
272
- value: function popDraw() {
273
-
274
- var t = this;
275
- var url = t.state.baseContext + "/client/system/freeLimit/featureCheck?token=" + t.state.token + "&feature=signaturePicture";
276
- fetch(url, {
277
- method: "GET",
278
- mode: "cors",
279
- headers: {
280
- 'Accept': 'application/json, text/plain, */*',
281
- 'Content-Type': 'application/x-www-form-urlencoded'
282
- }
283
- }).then(function (response) {
284
- return response.json();
285
- }).then(function (result) {
286
- if (result.success) {
287
- var content = result.content;
288
- if (content.featureCheck) {
289
- t.checkAfter();
290
- } else {
291
- if (content.isAdmin) {
292
- _Dialog2.default.confirm({
293
- title: '提示',
294
- content: '您当前版本为免费版,该功能为医管云标准版功能,建议您升级为标准版',
295
- confirmText: '立即升级',
296
- cancelText: '关闭',
297
- onConfirm: function onConfirm() {
298
- var path = 'static/officeding/mobileportal/dist/index.html';
299
- pageSkip(path, '#/hospitalmanage/version');
300
- },
301
- onCancel: function onCancel() {
302
- console.log('confirm cancel');
303
- }
304
- });
305
- } else {
306
- _Dialog2.default.alert({
307
- title: '提示',
308
- content: '您当前版本为免费版,该功能为医管云标准版功能,请联系管理员升级',
309
- confirmText: '关闭',
310
- onConfirm: function onConfirm() {
311
- console.log('confirm confirm');
312
- },
313
- onCancel: function onCancel() {
314
- console.log('confirm cancel');
315
- }
316
- });
317
- }
318
- }
319
- }
320
- }).catch(function (error) {
321
- alert("错误:" + error);
322
- });
290
+ }, 100);
323
291
  }
324
292
  }, {
325
293
  key: 'render',
@@ -331,23 +299,17 @@ var Page = function (_React$Component) {
331
299
  null,
332
300
  _react2.default.createElement(
333
301
  'div',
334
- { style: { background: '#f2f3f5', height: '35px', padding: '10px 5px' } },
335
- _react2.default.createElement(
336
- 'span',
337
- { className: 't-FCblue' },
338
- _react2.default.createElement('i', { className: 'iconfont icon-back t-rotate-180 t-FS14' }),
339
- t.props.title
340
- ),
302
+ { style: { height: '25px' } },
341
303
  _react2.default.createElement(
342
304
  'span',
343
- { onClick: t.popDraw.bind(t), className: 't-FCblue t-FR' },
305
+ { onClick: t.checkAfter.bind(t), className: t.state.readOnly ? 't-DN' : "t-FCblue t-FR" },
344
306
  t.state.fileId == "" ? "去手写签名" : "重写签名"
345
307
  )
346
308
  ),
347
309
  _react2.default.createElement(
348
310
  'div',
349
311
  { className: 'img-border', style: { backgroundColor: '#fff' } },
350
- _react2.default.createElement('img', { src: t.state.fileId == "" ? t.state.baseContext + '/static/fmui/images/no_signpic.png' : t.state.baseContext + '/dingisv/api/common/viewImage?fid=' + t.state.fileId + "&token=" + t.state.token, className: 't-W100' })
312
+ _react2.default.createElement('img', { src: t.state.fileId == "" ? '' : t.state.baseContext + '/api/m/plugin/attachment/mobile/viewImage?fid=' + t.state.fileId + "&token=" + t.state.token, className: 't-W100' })
351
313
  )
352
314
  );
353
315
  }
@@ -1,7 +1,7 @@
1
1
  # 手写签名使用文档
2
2
 
3
3
  1. 安装fmui 0.0.36-ygy以上的版本
4
- 2. 引用: import Sign from 'fmui/lib/signature';
4
+ 2. 引用: import Sign from 'fmui-base/lib/signature';
5
5
  3. 写标签
6
6
  ```
7
7
  <Sign upload={(val)=>{alert(val)}}/>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fmui-base",
3
- "version": "2.2.52",
3
+ "version": "2.2.54",
4
4
  "title": "fmui-base",
5
5
  "description": "fmui移动端组件",
6
6
  "main": "lib/index.js",