fmui-base 2.2.10 → 2.2.12

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.
@@ -1,569 +0,0 @@
1
- import React from 'react';
2
-
3
- import Boxs from 'saltui/lib/Boxs';
4
- import Popup from 'saltui/lib/Popup';
5
- import SelectField from 'saltui/lib/SelectField';
6
- import Group from 'saltui/lib/Group';
7
- import TextField from 'saltui/lib/TextField';
8
- import TextareaField from 'saltui/lib/TextareaField';
9
- import Button from 'saltui/lib/Button';
10
- import Toast from 'saltui/lib/Toast';
11
- import Switch from 'saltui/lib/Switch';
12
-
13
- import utils from './utils';
14
-
15
- const { HBox, Box, VBox } = Boxs;
16
- const {Count} = TextareaField;
17
- const {
18
- ButtonGroup,
19
- } = Button;
20
-
21
- import './PageHome.less';
22
-
23
- export default class Page extends React.Component {
24
-
25
- constructor(props) {
26
- //关闭加载页的遮罩效果
27
- $(".loading-containter").hide();
28
- var baseContext = document.getElementById("baseContext").value;
29
- var token = document.getElementById("token").value;
30
- super(props);
31
- this.state = {
32
- baseContext:baseContext,
33
- token:token,
34
- useSonFileNo: false,
35
- required:false,
36
- visible:false,
37
-
38
- showValue:"",
39
- showValue1:"",
40
- filenoList:"",
41
- filenoValue:null,
42
- fileNo:'',
43
- sonFileNo:'',
44
- createdDateY:'',
45
-
46
- readOnly:false,
47
- label:"",
48
- placeholder:"",
49
-
50
- doubleClick:'0',
51
- };
52
-
53
- this.listener = this.handleHidePopup.bind(this);
54
- }
55
-
56
- //去除监听并关闭弹出页
57
- handleHidePopup(e) {
58
- const { state } = e;
59
- if (!state || !state.selectFileno || state.selectFileno !== this.state.historyStamp) {
60
- const t = this;
61
- window.removeEventListener('popstate', t.listener, false);
62
- t.setState({
63
- visible: false,
64
- }, () => {
65
- document.getElementById("App").style.overflow = "auto";
66
- document.getElementById("App").style.height = "";
67
- var top = t.state.top;
68
- Popup.hide();
69
- setTimeout(function(){
70
- window.scrollTo(0,top);
71
- });
72
- });
73
- }
74
- }
75
-
76
- // 触发弹出选择
77
- popupFileNoFuc(){
78
- let t = this;
79
- // 只读状态
80
- let readOnly = this.props.readOnly;
81
- if (readOnly) {
82
- return false;
83
- }
84
-
85
- // 回显值
86
- let value = t.props.value;
87
-
88
- // 请求后台获取数据
89
- // 调用弹出选择Api接口
90
- var url = this.state.baseContext + "/client/office/document/getFileNoList?token="+this.state.token;
91
- fetch(url,{
92
- method: "GET",
93
- mode: "cors",
94
- headers: {
95
- 'Accept': 'application/json, text/plain, */*',
96
- 'Content-Type': 'application/x-www-form-urlencoded'
97
- }
98
- }).then((response) => response.json()).then((result) => {
99
- // 选中数据处理
100
- if (result != null) {
101
- var content = result.content;
102
- if (content != null) {
103
- // 文号集合
104
- var filenoList = content.filenos;
105
- var filenoValue = null;
106
- // 文号
107
- var fileNo = '';
108
- // 子号
109
- var sonFileNo = '';
110
- // 日期
111
- var createdDateY = '';
112
-
113
- var text = "";
114
- if (filenoList != null && filenoList.length > 0) {
115
- if (value == null || value == undefined || value == '') {
116
- filenoValue = filenoList[0];
117
- text = filenoValue.text;
118
- // 文号
119
- fileNo = content.filenoNum;
120
- // 子号
121
- sonFileNo = content.filenoSonNum;
122
- // 日期
123
- createdDateY = content.createdDateY;
124
-
125
- } else {
126
-
127
- var str1 = value.split('〔');
128
-
129
- if (str1 != null && str1.length > 1) {
130
- text = str1[0];
131
-
132
- var temp2 = str1[1];
133
- if (temp2 != undefined && temp2 != '') {
134
- var str2 = temp2.split('〕');
135
- if (str2 != null && str2.length > 1) {
136
- createdDateY = str2[0];
137
-
138
- var temp3 = str2[1];
139
- if (temp3 != undefined && temp3 != '') {
140
- var str3 = temp3.split('号');
141
- if (str3 != null && str3.length > 0) {
142
- var temp4 = str3[0];
143
- if (temp4 != undefined && temp4 != '') {
144
- var str4 = temp4.split('');
145
- if (str4 != null && str4.length > 0) {
146
- var num = '';
147
- var sonNum = '';
148
- var checkNum = '0123456789';
149
- var flag = '0';
150
- for (var i = 0; i < str4.length; i++) {
151
- var obj = str4[i];
152
- if (flag == '0' && checkNum.indexOf(obj) > -1) {
153
- num += obj;
154
- } else {
155
- sonNum += obj;
156
- flag = '1';
157
- }
158
- }
159
- fileNo = num;
160
- sonFileNo = sonNum;
161
- }
162
- }
163
- }
164
- }
165
- }
166
- }
167
- }
168
-
169
- for (var jj = 0; jj < filenoList.length; jj++) {
170
- var obj = filenoList[jj];
171
- var tempText = obj.text;
172
- if (text != '' && text == tempText) {
173
- filenoValue = obj;
174
- }
175
- }
176
- }
177
-
178
- }
179
-
180
- var showValue = "";
181
- var useSonFileNo = false;
182
- if (text != '') {
183
- if (sonFileNo == null || sonFileNo == '' || sonFileNo == 'null') {
184
- sonFileNo = '';
185
- } else {
186
- useSonFileNo = true;
187
- }
188
- showValue = text + '〔' + createdDateY + '〕' + fileNo + sonFileNo + '号';
189
- }
190
-
191
- this.setState({
192
- visible:true,
193
- filenoList:filenoList,
194
- filenoValue:filenoValue,
195
- useSonFileNo:useSonFileNo,
196
- fileNo:fileNo,
197
- sonFileNo:sonFileNo,
198
- createdDateY:createdDateY,
199
- showValue:showValue,
200
- }, () => {
201
- if(t.instance){t.instance.update(t.getFileNoContent());}
202
-
203
- var memberDivs = document.getElementsByClassName("select-fileno-div-class");
204
- if(memberDivs && memberDivs.length>0){
205
- for(var i=0; i<memberDivs.length; i++){
206
- var parent = this.getParents(memberDivs[i], "t-popup");
207
- if(parent){
208
- parent.style.left = "0";
209
- parent.style.background = "#f7f7f7";
210
- }
211
- }
212
- }
213
-
214
-
215
- var top = 0;
216
- if(document.documentElement&&document.documentElement.scrollTop){
217
- top = document.documentElement.scrollTop;
218
- }else if(document.body){
219
- top = document.body.scrollTop;
220
- }
221
- this.setState({
222
- top: top,
223
- historyStamp: `selectFileno.index_${Date.now()}`
224
- }, () => {
225
- window.history.pushState({
226
- selectFileno: t.state.historyStamp,
227
- }, '', utils.addUrlParam('selectFileno', Date.now()));
228
- window.addEventListener('popstate', t.listener, false);
229
- });
230
- document.getElementById("App").style.overflow = "hidden";
231
- document.getElementById("App").style.height = "0";
232
-
233
- });
234
- }
235
- }
236
- }).catch((error) => {
237
- alert("错误:"+error);
238
- });
239
- }
240
-
241
- getParents(element, className) {
242
- var returnParentElement = null;
243
- if(element && element.classList.contains(className) && element.tagName.toLowerCase() != "body") {
244
- returnParentElement = element;
245
- } else {
246
- returnParentElement = this.getParents(element.parentElement, className);
247
- }
248
- return returnParentElement;
249
- }
250
-
251
- // 文号名称改变
252
- filenoListChange(value){
253
- let t = this;
254
- var text = "";
255
- var id = '';
256
- if (value != null) {
257
- text = value.text;
258
- id = value.value;
259
- }
260
- if (id != '') {
261
- var url = this.state.baseContext + "/client/office/document/getFileNoNum?token="+this.state.token+"&fileNoStr=" + text;
262
- fetch(url,{
263
- method: "GET",
264
- mode: "cors",
265
- headers: {
266
- 'Accept': 'application/json, text/plain, */*',
267
- 'Content-Type': 'application/x-www-form-urlencoded'
268
- }
269
- }).then((response) => response.json()).then((result) => {
270
-
271
- var showValue = "";
272
-
273
- var filenoNum = t.state.fileNo;
274
- var filenoSonNum = t.state.sonFileNo;
275
- var useSonFileNo = t.state.useSonFileNo;
276
- var createdDateY = t.state.createdDateY;
277
- // 选中数据处理
278
- if (result != null) {
279
- var content = result.content;
280
- if (content != null) {
281
- filenoNum = content.filenoNum;
282
- filenoSonNum = content.filenoSonNum;
283
- createdDateY = content.filenoYear;
284
- if (filenoSonNum == '' || filenoSonNum == null || filenoSonNum == 'null') {
285
- filenoSonNum = '';
286
- useSonFileNo = false;
287
- } else {
288
- useSonFileNo = true;
289
- }
290
- }
291
- }
292
- showValue = text + '〔' + createdDateY + '〕' + filenoNum + filenoSonNum + '号';
293
- this.setState({
294
- filenoValue:value,
295
- fileNo:filenoNum,
296
- sonFileNo:filenoSonNum,
297
- showValue:showValue,
298
- useSonFileNo:useSonFileNo,
299
- createdDateY:createdDateY,
300
- }, () => {
301
- if(t.instance){t.instance.update(t.getFileNoContent());}
302
- });
303
- }).catch((error) => {
304
- alert("错误:"+error);
305
- });
306
- }
307
- }
308
-
309
- handleTextAreaChange(field, size, newValue) {
310
- if(isEmojiCharacter(newValue)){
311
- Toast.show({
312
- type: 'error',
313
- content:'不能输入表情'
314
- });
315
- return false;
316
- }
317
- if (newValue.length <= size) {
318
- this.setState({
319
- [field]: newValue,
320
- });
321
- }
322
- }
323
-
324
- handleChange(field, value) {
325
- this.setState({
326
- [field]: value,
327
- });
328
- }
329
-
330
- // 弹出页的列表
331
- getFileNoContent() {
332
- let t = this;
333
- // 返回结构
334
- let content = "";
335
- content = (
336
- <div className="dd-selection select-fileno-div-class">
337
- <Group.List >
338
- <SelectField
339
- label="文号名称"
340
- options={t.state.filenoList}
341
- onSelect={t.filenoListChange.bind(t)}
342
- value={t.state.filenoValue}
343
- placeholder="请选择文号名称"
344
- />
345
- </Group.List>
346
- <Group.List>
347
- <TextField
348
- label="文号"
349
- placeholder="6位以内正整数"
350
- value={t.state.fileNo}
351
- onChange={t.handleTextAreaChange.bind(t, 'fileNo', 6)}
352
- >
353
- <Count total={6} length={t.state.fileNo.length}/>
354
- </TextField>
355
- </Group.List>
356
-
357
- <Group.List>
358
- <div className="dd-item">
359
- <label className="label-txt t-FC7">启用子号</label>
360
- <Switch on={t.state.useSonFileNo} onChange={t.handleChange.bind(t, 'useSonFileNo')}/>
361
- </div>
362
- </Group.List>
363
- <Group.List className={this.state.useSonFileNo ? '' : 't-DN'}>
364
- <TextField
365
- label="子号"
366
- placeholder="6个以内字符,非数字开头"
367
- value={t.state.sonFileNo}
368
- onChange={t.handleTextAreaChange.bind(t, 'sonFileNo', 6)}
369
- >
370
- <Count total={6} length={t.state.sonFileNo.length}/>
371
- </TextField>
372
- </Group.List>
373
- <p className={t.state.filenoList == null || t.state.filenoList.length < 1 ? 't-DN' : 't-FS16 t-FCddfontblue-60 t-ML16 t-MT10'}>{'文号预览效果:'+ t.state.showValue}</p>
374
- <p className={t.state.filenoList == null || t.state.filenoList.length < 1 ? 't-FS16 t-FCddfontblue-60 t-ML16 t-MT10' : 't-DN'}>请联系管理员在公文设置中设置文号代字</p>
375
- <div className="t-P0 t-bottom-fixed">
376
- <Button.Group>
377
- <Button type="primary" display="banner" onClick={this.confirmBtn.bind(this)}>确认</Button>
378
- <Button type="secondary" display="banner" onClick={this.cancelBtn.bind(this)}>取消</Button>
379
- </Button.Group>
380
- </div>
381
- </div>
382
- );
383
- return content;
384
- }
385
-
386
- confirmBtn(){
387
- let t = this;
388
-
389
- let doubleClick = t.state.doubleClick;
390
- if (doubleClick != '0') {
391
- return false;
392
- } else {
393
- t.setState({
394
- doubleClick:'1'
395
- })
396
- }
397
-
398
- var text = "";
399
- if (t.state.filenoValue != null) {
400
- text = t.state.filenoValue.text;
401
- } else {
402
- Toast.show({
403
- type: 'error',
404
- content: '请选择文号代字',
405
- });
406
- t.setState({
407
- doubleClick:'0'
408
- })
409
- return false;
410
- }
411
-
412
- var myreg = /^[1-9]\d*$/;
413
- if(!myreg.test(this.state.fileNo)){
414
- Toast.show({
415
- type: 'error',
416
- content: '文号应为正整数',
417
- });
418
- t.setState({
419
- doubleClick:'0'
420
- })
421
- return false;
422
- }
423
-
424
- var showValue = "";
425
- var sonFileNo = this.state.sonFileNo;
426
- if (text != '') {
427
- if (!this.state.useSonFileNo) {
428
- sonFileNo = '';
429
- }
430
-
431
- if (sonFileNo != '') {
432
- var pattern = new RegExp("[0-9]+");
433
- var obj = sonFileNo.match(pattern);
434
- if (obj != null && obj.index == 0) {
435
- Toast.show({
436
- type: 'error',
437
- content: '子号首个字符不能是数字',
438
- });
439
- t.setState({
440
- doubleClick:'0'
441
- })
442
- return false;
443
- }
444
- }
445
-
446
- showValue = text + '〔' + this.state.createdDateY + '〕' + this.state.fileNo + sonFileNo + '号';
447
- }
448
-
449
- if (showValue != '') {
450
- var url = this.state.baseContext + "/client/office/document/compareFileno?token="+this.state.token+"&fileno=" + showValue;
451
- fetch(url,{
452
- method: "GET",
453
- mode: "cors",
454
- headers: {
455
- 'Accept': 'application/json, text/plain, */*',
456
- 'Content-Type': 'application/x-www-form-urlencoded'
457
- }
458
- }).then((response) => response.json()).then((result) => {
459
- if (result != null && result.success) {
460
- t.setState({
461
- visible: false,
462
- showValue:showValue,
463
- showValue1:showValue,
464
- doubleClick:'0'
465
- }, () => {
466
- this.props.onChange(showValue);
467
- history.back();
468
- });
469
- } else {
470
- Toast.show({
471
- type: 'error',
472
- content: '文号重复',
473
- });
474
- t.setState({
475
- doubleClick:'0'
476
- })
477
- }
478
- }).catch((error) => {
479
- alert("错误:"+error);
480
- t.setState({
481
- doubleClick:'0'
482
- })
483
- });
484
- }
485
- }
486
-
487
- cancelBtn(){
488
- let t = this;
489
- let doubleClick = t.state.doubleClick;
490
- if (doubleClick != '0') {
491
- return false;
492
- } else {
493
- t.setState({
494
- doubleClick:'1'
495
- })
496
- }
497
- t.setState({
498
- visible: false,
499
- doubleClick:'0'
500
- }, () => {
501
- history.back();
502
- });
503
-
504
- }
505
-
506
- // 点击蒙层关闭
507
- closMask(){
508
- /* $("#App").removeAttr("style");
509
- $(document).scrollTop(this.props.top);*/
510
- }
511
-
512
-
513
- handleChange(from, on) {
514
- this.setState({
515
- [from]: on,
516
- });
517
- }
518
-
519
- render() {
520
- let t = this;
521
- // 必选标识
522
- let required = this.props.required;
523
- // 显示值
524
- let selectText = '';
525
- let label = t.props.label;
526
-
527
- let readOnly = t.props.readOnly;
528
-
529
- let placeholder = t.props.placeholder;
530
-
531
- let value = t.props.value;
532
- if (value == null || value == undefined) {
533
- value = '';
534
- }
535
-
536
- return (
537
- <div>
538
- <div>
539
- <HBox vAlign="center" className="t-FS16 t-PL16 t-PR16" onClick={() => {this.popupFileNoFuc(); }}>
540
- <Box className={required ? 't-field-layout-h-label required' : 't-field-layout-h-label'}>{label}</Box>
541
- <HBox flex={1} >
542
- <Box flex={1} className={value == '' ? "t-FCtips t-FS16 t-PR10" : "t-DN"}>
543
- <div className="t-omit t-poppage-placeholder">{placeholder}</div>
544
- </Box>
545
- <Box flex={1} className={value == '' ? "t-DN" : "t-FAL t-LH1_4 t-omit"}>{value}</Box>
546
- <Box className={readOnly ? "t-DN" : "t-PR4"}>
547
- <b className="iconfont icon-back t-rotate-180 t-FCc t-FS16 t-FS14"></b>
548
- </Box>
549
- </HBox>
550
- </HBox>
551
- </div>
552
-
553
- <div className="fileno-div">
554
- <Popup
555
- content={this.getFileNoContent()}
556
- animationType="slide-left"
557
- onMaskClick={() => { this.setState({ visible: false });this.closMask(); }}
558
- visible={this.state.visible}
559
- >
560
- {null}
561
- </Popup>
562
- </div>
563
- </div>
564
- );
565
- }
566
- }
567
-
568
-
569
-