fmui-base 2.2.11 → 2.2.13

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