aldehyde 0.2.4 → 0.2.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.
- package/lib/controls/entity-select/entity-select.d.ts +4 -3
- package/lib/controls/entity-select/entity-select.d.ts.map +1 -1
- package/lib/controls/entity-select/entity-select.js +59 -37
- package/lib/controls/entity-select/entity-select.js.map +1 -1
- package/lib/controls/entry-control.d.ts.map +1 -1
- package/lib/controls/entry-control.js +3 -2
- package/lib/controls/entry-control.js.map +1 -1
- package/lib/controls/upload/index.js +1 -1
- package/lib/controls/upload/index.js.map +1 -1
- package/lib/controls/view-control.d.ts.map +1 -1
- package/lib/controls/view-control.js +8 -2
- package/lib/controls/view-control.js.map +1 -1
- package/lib/exportor/export-frame.js +1 -1
- package/lib/exportor/export-frame.js.map +1 -1
- package/lib/login/login.d.ts.map +1 -1
- package/lib/login/login.js +2 -1
- package/lib/login/login.js.map +1 -1
- package/lib/table/act-table.js +2 -2
- package/lib/table/act-table.js.map +1 -1
- package/lib/tmpl/hcservice-v3.js +4 -4
- package/lib/tmpl/hcservice-v3.js.map +1 -1
- package/lib/tmpl/superagent.d.ts +1 -1
- package/lib/tmpl/superagent.js +4 -4
- package/lib/tmpl/superagent.js.map +1 -1
- package/lib/units/config-loader.d.ts +2 -0
- package/lib/units/config-loader.d.ts.map +1 -0
- package/lib/units/config-loader.js +22 -0
- package/lib/units/config-loader.js.map +1 -0
- package/lib/units/index.d.ts +5 -1
- package/lib/units/index.d.ts.map +1 -1
- package/lib/units/index.js +31 -19
- package/lib/units/index.js.map +1 -1
- package/package.json +1 -1
- package/src/aldehyde/controls/entity-select/entity-select.tsx +70 -44
- package/src/aldehyde/controls/entry-control.tsx +6 -2
- package/src/aldehyde/controls/upload/index.tsx +1 -1
- package/src/aldehyde/controls/view-control.tsx +8 -2
- package/src/aldehyde/exportor/export-frame.tsx +1 -1
- package/src/aldehyde/login/login.js +2 -1
- package/src/aldehyde/table/act-table.tsx +2 -2
- package/src/aldehyde/tmpl/hcservice-v3.tsx +4 -4
- package/src/aldehyde/tmpl/superagent.js +4 -4
- package/src/aldehyde/units/config-loader.tsx +28 -0
- package/src/aldehyde/units/index.tsx +35 -23
|
@@ -14,7 +14,7 @@ interface InnerEntitySelectProps extends EControlProps {
|
|
|
14
14
|
maxSelected?: number,
|
|
15
15
|
onEntityClick?: (code: string) => void,
|
|
16
16
|
baseCriteria: object,
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
interface InnerEntitySelectState {
|
|
@@ -22,7 +22,8 @@ interface InnerEntitySelectState {
|
|
|
22
22
|
optionCacheKey: string,
|
|
23
23
|
pageNo: number,
|
|
24
24
|
loading: boolean,
|
|
25
|
-
optionsCache:
|
|
25
|
+
optionsCache:object;
|
|
26
|
+
codeLabel:object;
|
|
26
27
|
selectConfig: SelectConfig,
|
|
27
28
|
showView: boolean,
|
|
28
29
|
drawCode: string,
|
|
@@ -30,11 +31,12 @@ interface InnerEntitySelectState {
|
|
|
30
31
|
};
|
|
31
32
|
|
|
32
33
|
type OptionCache = {
|
|
33
|
-
queryKey
|
|
34
|
-
pageInfo
|
|
35
|
-
touchEnd
|
|
36
|
-
options
|
|
37
|
-
searchValue
|
|
34
|
+
queryKey?: QueryKey,
|
|
35
|
+
pageInfo?: PageInfo,
|
|
36
|
+
touchEnd?: boolean,
|
|
37
|
+
options?: any,
|
|
38
|
+
searchValue?: string,
|
|
39
|
+
optionCacheKey?:string,
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
type LoadDataSource = {
|
|
@@ -55,17 +57,19 @@ export default class EntitySelect extends React.PureComponent<InnerEntitySelectP
|
|
|
55
57
|
pageNo: 1,
|
|
56
58
|
loading: false,
|
|
57
59
|
optionsCache: {},
|
|
60
|
+
codeLabel:{},
|
|
58
61
|
selectConfig: undefined,
|
|
59
62
|
showView: false,
|
|
60
63
|
showEdit: false,
|
|
61
64
|
drawCode: undefined,
|
|
62
65
|
}
|
|
63
66
|
dropdownRender = (menu) => {
|
|
64
|
-
const {fieldConfig
|
|
67
|
+
const {fieldConfig}= this.props;
|
|
68
|
+
const {actions}=fieldConfig;
|
|
65
69
|
// console.log("menu",menu);
|
|
66
70
|
return <>
|
|
67
71
|
{menu}
|
|
68
|
-
{actions && actions.indexOf('add') ?
|
|
72
|
+
{actions && actions.indexOf('add')>=0 ?
|
|
69
73
|
<>
|
|
70
74
|
<Divider style={{margin: '8px 0'}}/>
|
|
71
75
|
<Row justify="end">
|
|
@@ -102,7 +106,8 @@ export default class EntitySelect extends React.PureComponent<InnerEntitySelectP
|
|
|
102
106
|
if ((baseCriteria && JSON.stringify(baseCriteria) != JSON.stringify(preBaseCriteria)) || (mainCode && mainCode != preMainCode)
|
|
103
107
|
|| (fieldConfig && preFieldConfig && fieldConfig.id != preFieldConfig.id)) {
|
|
104
108
|
this.setState({
|
|
105
|
-
optionsCache: {}
|
|
109
|
+
optionsCache: {},
|
|
110
|
+
codeLabel:{}
|
|
106
111
|
})
|
|
107
112
|
}
|
|
108
113
|
}
|
|
@@ -115,30 +120,26 @@ export default class EntitySelect extends React.PureComponent<InnerEntitySelectP
|
|
|
115
120
|
|
|
116
121
|
|
|
117
122
|
toOption = (code: string, title: string, onEntityClick) => {
|
|
118
|
-
const {
|
|
123
|
+
const {fieldConfig}=this.props;
|
|
124
|
+
const {actions}=fieldConfig;
|
|
125
|
+
const {codeLabel}=this.state;
|
|
126
|
+
codeLabel[code]=title;
|
|
119
127
|
let option = {
|
|
120
|
-
|
|
121
|
-
value: code + '@R@' + title,
|
|
122
|
-
// showlabel: onEntityClick ? <Button size={'small'} style={{padding: '0px'}} type="link" title=""
|
|
123
|
-
// onClick={(e) => {
|
|
124
|
-
// e.stopPropagation();
|
|
125
|
-
// onEntityClick(code);
|
|
126
|
-
// }}>{title}
|
|
127
|
-
// </Button> : title,
|
|
128
|
+
value: code,
|
|
128
129
|
label: <>
|
|
129
130
|
{title}
|
|
130
|
-
{actions && actions.indexOf("detail") ?
|
|
131
|
+
{actions && actions.indexOf("detail")>=0 ?
|
|
131
132
|
<Button size={'small'} type={'text'}><AlignLeftOutlined style={{color: '#0958d9'}} onClick={(event) => {
|
|
132
133
|
event.stopPropagation();
|
|
133
134
|
this.showItem(code);
|
|
134
135
|
}}/></Button>:null}
|
|
135
136
|
|
|
136
|
-
{actions && actions.indexOf("edit") ?
|
|
137
|
+
{actions && actions.indexOf("edit")>=0 ?
|
|
137
138
|
<Button size={'small'} type={'text'}><EditOutlined style={{color: '#0958d9'}} onClick={(event) => {
|
|
138
139
|
event.stopPropagation();
|
|
139
140
|
this.editItem(code);
|
|
140
|
-
}}/></Button
|
|
141
|
-
|
|
141
|
+
}}/></Button>
|
|
142
|
+
:null}
|
|
142
143
|
</>,
|
|
143
144
|
};
|
|
144
145
|
return option;
|
|
@@ -154,10 +155,28 @@ export default class EntitySelect extends React.PureComponent<InnerEntitySelectP
|
|
|
154
155
|
}
|
|
155
156
|
|
|
156
157
|
drawSubmited = () => {
|
|
158
|
+
this.setState({
|
|
159
|
+
optionsCache: {},
|
|
160
|
+
codeLabel:{},
|
|
161
|
+
})
|
|
157
162
|
this.doClose();
|
|
158
163
|
}
|
|
159
164
|
|
|
160
165
|
toValueArray = (value) => {
|
|
166
|
+
let result=[];
|
|
167
|
+
let valueArray =this.toArray(value);
|
|
168
|
+
for (let v of valueArray) {
|
|
169
|
+
if (v) {
|
|
170
|
+
let vs = v.split("@R@");
|
|
171
|
+
if (vs[1] != 'null') {
|
|
172
|
+
result.push(vs[0]);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return result;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
toArray = (value) => {
|
|
161
180
|
let valueArray: string[] = [];
|
|
162
181
|
if (value instanceof Array) {
|
|
163
182
|
valueArray = value;
|
|
@@ -168,16 +187,8 @@ export default class EntitySelect extends React.PureComponent<InnerEntitySelectP
|
|
|
168
187
|
valueArray = [];
|
|
169
188
|
}
|
|
170
189
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
if (v) {
|
|
174
|
-
let vs = v.split("@R@");
|
|
175
|
-
if (vs[1] != 'null') {
|
|
176
|
-
result.push(v);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
return result;
|
|
190
|
+
|
|
191
|
+
return valueArray;
|
|
181
192
|
}
|
|
182
193
|
|
|
183
194
|
toOptions = (value, onEntityClick) => {
|
|
@@ -185,7 +196,7 @@ export default class EntitySelect extends React.PureComponent<InnerEntitySelectP
|
|
|
185
196
|
let options: object[] = [];
|
|
186
197
|
//console.log('options value', value);
|
|
187
198
|
|
|
188
|
-
let valueArray: string[] = this.
|
|
199
|
+
let valueArray: string[] = this.toArray(value);
|
|
189
200
|
for (let v of valueArray) {
|
|
190
201
|
if (v) {
|
|
191
202
|
let vs = v.split("@R@");
|
|
@@ -200,7 +211,7 @@ export default class EntitySelect extends React.PureComponent<InnerEntitySelectP
|
|
|
200
211
|
fieldConfig.suppleOptions.forEach((o) => {
|
|
201
212
|
let had = false;
|
|
202
213
|
options.forEach((s) => {
|
|
203
|
-
if (s['
|
|
214
|
+
if (s['value'] == o.code) {
|
|
204
215
|
had = true;
|
|
205
216
|
return;
|
|
206
217
|
}
|
|
@@ -251,7 +262,7 @@ export default class EntitySelect extends React.PureComponent<InnerEntitySelectP
|
|
|
251
262
|
}
|
|
252
263
|
let pageInfo = {
|
|
253
264
|
pageNo: 1,
|
|
254
|
-
pageSize:
|
|
265
|
+
pageSize: 6,
|
|
255
266
|
virtualEndPageNo: undefined,
|
|
256
267
|
};
|
|
257
268
|
titleId = selectConfig_.primaryColumn.id;
|
|
@@ -318,14 +329,20 @@ export default class EntitySelect extends React.PureComponent<InnerEntitySelectP
|
|
|
318
329
|
}
|
|
319
330
|
|
|
320
331
|
onChange = (values: any[]) => {
|
|
332
|
+
const {codeLabel}=this.state;
|
|
333
|
+
let newValues:Array<string>=[...values];
|
|
321
334
|
if (values && values.length > this.props.maxSelected) {
|
|
322
|
-
//console.log('selected value:', values);
|
|
323
|
-
let newValues = [...values];
|
|
324
335
|
newValues.shift();
|
|
325
|
-
this.onChange(newValues);
|
|
326
|
-
} else {
|
|
327
|
-
this.props.onChange(values);
|
|
328
336
|
}
|
|
337
|
+
let formValues:Array<string>=[];
|
|
338
|
+
newValues.forEach((c)=>{
|
|
339
|
+
if(c.indexOf("@R@")>0){
|
|
340
|
+
formValues.push(c);
|
|
341
|
+
}else{
|
|
342
|
+
formValues.push(c+"@R@"+codeLabel[c]);
|
|
343
|
+
}
|
|
344
|
+
})
|
|
345
|
+
this.props.onChange(formValues);
|
|
329
346
|
}
|
|
330
347
|
|
|
331
348
|
tagRender = (props: CustomTagProps) => {
|
|
@@ -388,17 +405,25 @@ export default class EntitySelect extends React.PureComponent<InnerEntitySelectP
|
|
|
388
405
|
}
|
|
389
406
|
|
|
390
407
|
render() {
|
|
391
|
-
const {id, value, fieldConfig, onChange, disabled, style, maxSelected, onEntityClick
|
|
408
|
+
const {id, value, fieldConfig, onChange, disabled, style, maxSelected, onEntityClick} = this.props;
|
|
409
|
+
const {actions}=fieldConfig;
|
|
392
410
|
const {optionCacheKey, loading, optionsCache, drawCode, showEdit, showView} = this.state;
|
|
393
411
|
let initOptions = this.toOptions(value, onEntityClick);
|
|
394
412
|
let exists;
|
|
395
413
|
let properOptions = [...initOptions];
|
|
414
|
+
let listHeight=256;
|
|
396
415
|
if (optionCacheKey && optionsCache[optionCacheKey]) {
|
|
397
|
-
|
|
416
|
+
let optionCache=optionsCache[optionCacheKey];
|
|
417
|
+
if(optionCache['pageInfo'] && optionCache.pageInfo.pageSize<8){
|
|
418
|
+
listHeight=32*(optionCache['pageInfo'].pageSize)-10;
|
|
419
|
+
}
|
|
420
|
+
for (let option of optionCache.options) {
|
|
398
421
|
exists = false;
|
|
399
422
|
for (let init of initOptions) {
|
|
400
423
|
if (init['value'] == option['value']) {
|
|
401
424
|
exists = true;
|
|
425
|
+
//用查询的覆盖之前的
|
|
426
|
+
init['label']=option['label'];
|
|
402
427
|
}
|
|
403
428
|
}
|
|
404
429
|
if (!exists) {
|
|
@@ -410,6 +435,7 @@ export default class EntitySelect extends React.PureComponent<InnerEntitySelectP
|
|
|
410
435
|
return <><Select
|
|
411
436
|
disabled={disabled}
|
|
412
437
|
id={id}
|
|
438
|
+
listHeight={listHeight}
|
|
413
439
|
style={{...style}}
|
|
414
440
|
onChange={this.onChange}
|
|
415
441
|
value={this.toValueArray(value)}
|
|
@@ -420,7 +446,7 @@ export default class EntitySelect extends React.PureComponent<InnerEntitySelectP
|
|
|
420
446
|
showArrow={true}
|
|
421
447
|
suffixIcon={<SearchOutlined/>}
|
|
422
448
|
dropdownRender={this.dropdownRender}
|
|
423
|
-
tagRender={actions && (actions.indexOf("detail") || actions.indexOf("edit")) ? this.tagRender : undefined}
|
|
449
|
+
tagRender={actions && (actions.indexOf("detail")>=0 || actions.indexOf("edit")>=0) ? this.tagRender : undefined}
|
|
424
450
|
onSearch={this.debounceFetcher()}
|
|
425
451
|
onClick={() => {
|
|
426
452
|
debounce(this.fetchOptions, 100)(undefined)
|
|
@@ -18,6 +18,7 @@ import ColorPicker from './color-picker'
|
|
|
18
18
|
import LabTreeSelect from './entity-select/lab-tree-select'
|
|
19
19
|
import Units from "../units";
|
|
20
20
|
import {ProgramConfig} from "../index";
|
|
21
|
+
import {LockOutlined,} from '@ant-design/icons';
|
|
21
22
|
|
|
22
23
|
const CheckboxGroup=Checkbox.Group;
|
|
23
24
|
const RadioGroup=Radio.Group;
|
|
@@ -203,7 +204,10 @@ function renderControl(id:any,mainCode:string|Promise<string>,fieldConfig: Fiel
|
|
|
203
204
|
entryControl = <Steps {...controlProps}/>
|
|
204
205
|
break;
|
|
205
206
|
case 'password':
|
|
206
|
-
entryControl =
|
|
207
|
+
entryControl = <Input.Password
|
|
208
|
+
{...antdControlProps}
|
|
209
|
+
prefix={<LockOutlined className="site-form-item-icon"/>}
|
|
210
|
+
/>
|
|
207
211
|
break;
|
|
208
212
|
case 'preselect':
|
|
209
213
|
entryControl = <AutoComplete {...controlProps} />
|
|
@@ -230,7 +234,7 @@ function renderControl(id:any,mainCode:string|Promise<string>,fieldConfig: Fiel
|
|
|
230
234
|
case 'relselect':
|
|
231
235
|
case 'refselect':
|
|
232
236
|
case 'entity-select':
|
|
233
|
-
entryControl=<EntitySelect maxSelected={max?parseInt(max):undefined}
|
|
237
|
+
entryControl=<EntitySelect maxSelected={max?parseInt(max):undefined} {...controlProps} />
|
|
234
238
|
break;
|
|
235
239
|
case 'table-entity-select':
|
|
236
240
|
entryControl=<PopoverEntitySelect maxSelected={max?parseInt(max):undefined} {...controlProps} />
|
|
@@ -86,7 +86,7 @@ export default class Upload extends React.PureComponent<UploadProps, UploadState
|
|
|
86
86
|
uid: '-1',
|
|
87
87
|
name: value_1.base.fileName,
|
|
88
88
|
status: 'done',
|
|
89
|
-
url: Units.api()+'/v3/files'+value_1.base.path+`?@token=${Units.
|
|
89
|
+
url: Units.api()+'/v3/files'+value_1.base.path+`?@token=${Units.hydrocarbonToken()}&@programToken=${Units.programCode()}&disposition=attachment`,
|
|
90
90
|
})
|
|
91
91
|
}else if(value_1.valid=='new'){
|
|
92
92
|
fileList.push({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import {Alert, Badge, Input, Spin, Tag} from "antd";
|
|
2
|
+
import {Alert, Badge, Input, Spin, Tag,Tooltip} from "antd";
|
|
3
3
|
import loadable from "@loadable/component";
|
|
4
4
|
import {ControlHolderType, EnumItem, FieldConfig, ViewOrEdit} from "../tmpl/interface";
|
|
5
5
|
import ControlTypeSupportor from '../tmpl/control-type-supportor';
|
|
@@ -135,7 +135,13 @@ function renderControl(fieldConfig: FieldConfig, fieldValue: any,pHolderType:Con
|
|
|
135
135
|
viewControl = <Steps {...controlProps}/>
|
|
136
136
|
break;
|
|
137
137
|
case 'password':
|
|
138
|
-
|
|
138
|
+
if(value){
|
|
139
|
+
viewControl = <Tooltip title={value} color={'#fff1b8'} {...controlProps}>
|
|
140
|
+
<span className="infoStyle">********</span>
|
|
141
|
+
</Tooltip>
|
|
142
|
+
}else{
|
|
143
|
+
viewControl=null;
|
|
144
|
+
}
|
|
139
145
|
break;
|
|
140
146
|
case 'caselect':
|
|
141
147
|
viewControl = <span className="infoStyle">{value}</span>;
|
|
@@ -134,7 +134,7 @@ export default class ExportFrame extends React.PureComponent<ExportFrameProps, E
|
|
|
134
134
|
download=()=>{
|
|
135
135
|
const {title}=this.props;
|
|
136
136
|
const {exportId}=this.state;
|
|
137
|
-
const hydrocarbonToken=Units.
|
|
137
|
+
const hydrocarbonToken=Units.hydrocarbonToken();
|
|
138
138
|
Units.downloadFile(Units.joinPath(Units.api(),`/v3/exporter/excel?exportId=${exportId}&@token=${hydrocarbonToken}&@programToken=${Units.programCode()}`),title)
|
|
139
139
|
}
|
|
140
140
|
|
|
@@ -3,6 +3,7 @@ import './index.css'
|
|
|
3
3
|
import {Button, Col, Form, Input, Row} from 'antd'
|
|
4
4
|
import {LockOutlined, SafetyCertificateOutlined, UserOutlined} from '@ant-design/icons';
|
|
5
5
|
import HCserviceV3 from "../tmpl/hcservice-v3"
|
|
6
|
+
import Units from "../units";
|
|
6
7
|
|
|
7
8
|
export default class Loginit extends React.Component {
|
|
8
9
|
state = {
|
|
@@ -19,7 +20,7 @@ export default class Loginit extends React.Component {
|
|
|
19
20
|
if (this.props && this.props.match && this.props.match.params) {
|
|
20
21
|
const {programCode} = this.props.match.params;
|
|
21
22
|
if (programCode) {
|
|
22
|
-
|
|
23
|
+
Units.setProgramCode(programCode);
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
26
|
let pubkey = await HCserviceV3.getRasPubkey();
|
|
@@ -493,8 +493,8 @@ class ActTable extends React.PureComponent<ActTableProps, ActTableStat> {
|
|
|
493
493
|
let result = await HcserviceV3.postJumps(jumpId, code);
|
|
494
494
|
|
|
495
495
|
if (result.status === "success") {
|
|
496
|
-
let hydrocarbonToken = Units.
|
|
497
|
-
let url = result.url + "hydrocarbon_token=" + Units.
|
|
496
|
+
let hydrocarbonToken = Units.hydrocarbonToken();
|
|
497
|
+
let url = result.url + "hydrocarbon_token=" + Units.hydrocarbonToken();
|
|
498
498
|
// console.log(url);
|
|
499
499
|
window.open(url);
|
|
500
500
|
}
|
|
@@ -470,7 +470,7 @@ export default class HcserviceV3 {
|
|
|
470
470
|
}
|
|
471
471
|
|
|
472
472
|
static downloadDetailExcel(sourceId, entityCode) {
|
|
473
|
-
const hydrocarbonToken = Units.
|
|
473
|
+
const hydrocarbonToken = Units.hydrocarbonToken();
|
|
474
474
|
let url = Units.api() + `/v3/dtmpl/excel?sourceId=${sourceId}&code=${entityCode}&@token=${hydrocarbonToken}&@programToken=${Units.programCode()}`
|
|
475
475
|
Units.downloadFile(url, "详情");
|
|
476
476
|
}
|
|
@@ -488,13 +488,13 @@ export default class HcserviceV3 {
|
|
|
488
488
|
}
|
|
489
489
|
|
|
490
490
|
static getFileUrl(path) {
|
|
491
|
-
const hydrocarbonToken = Units.
|
|
491
|
+
const hydrocarbonToken = Units.hydrocarbonToken();
|
|
492
492
|
let url = Units.api() + Units.joinPath("/v3/files", path) + `?@token=${hydrocarbonToken}&@programToken=${Units.programCode()}`;
|
|
493
493
|
return url;
|
|
494
494
|
}
|
|
495
495
|
|
|
496
496
|
static getFileTxtUrl(path) {
|
|
497
|
-
const hydrocarbonToken = Units.
|
|
497
|
+
const hydrocarbonToken = Units.hydrocarbonToken();
|
|
498
498
|
let url = Units.api() + "/v3/files/text" + path + `?@token=${hydrocarbonToken}&@programToken=${Units.programCode()}`;
|
|
499
499
|
return url;
|
|
500
500
|
}
|
|
@@ -601,7 +601,7 @@ export default class HcserviceV3 {
|
|
|
601
601
|
//window.location.hash = "#/home";
|
|
602
602
|
HCDataSource.clear();
|
|
603
603
|
window.location.hash = "#/context-setter";
|
|
604
|
-
Units.
|
|
604
|
+
Units.setHydrocarbonToken( res.token);
|
|
605
605
|
}
|
|
606
606
|
return res;
|
|
607
607
|
}
|
|
@@ -4,7 +4,7 @@ import Units from '../units';
|
|
|
4
4
|
|
|
5
5
|
export default class Superagent {
|
|
6
6
|
static super(options, type, load) {
|
|
7
|
-
const hydrocarbonToken = Units.
|
|
7
|
+
const hydrocarbonToken = Units.hydrocarbonToken()? Units.hydrocarbonToken()
|
|
8
8
|
: options.header && options.header.hydrocarbonToken ?
|
|
9
9
|
options.header.hydrocarbonToken : Units.getAnoHydrocarbonToken();
|
|
10
10
|
const programCode = Units.programCode();
|
|
@@ -41,14 +41,14 @@ export default class Superagent {
|
|
|
41
41
|
loading.style.display = "none"
|
|
42
42
|
}
|
|
43
43
|
if (res.status === 200) {
|
|
44
|
-
Units.
|
|
44
|
+
//Units.setHydrocarbonToken("hydrocarbonToken", hydrocarbonToken)
|
|
45
45
|
let result = res.body;
|
|
46
46
|
if (result && result.status === 'error') {
|
|
47
47
|
message.error("错误消息:" + result.message)
|
|
48
48
|
}
|
|
49
49
|
resolve(result)
|
|
50
50
|
} else if (res.status === 201) {
|
|
51
|
-
Units.setLocalStorge("hydrocarbonToken", hydrocarbonToken)
|
|
51
|
+
//Units.setLocalStorge("hydrocarbonToken", hydrocarbonToken)
|
|
52
52
|
resolve(res)
|
|
53
53
|
} else if (res.status === 403) {
|
|
54
54
|
//message.info("请求权限不足,可能是token已经超时")
|
|
@@ -108,7 +108,7 @@ export default class Superagent {
|
|
|
108
108
|
|
|
109
109
|
static getHeaderObj() {
|
|
110
110
|
return {
|
|
111
|
-
'hydrocarbon-token': Units.
|
|
111
|
+
'hydrocarbon-token': Units.hydrocarbonToken() ?Units.hydrocarbonToken() : Units.getAnoHydrocarbonToken(),
|
|
112
112
|
'hydrocarbon-program-token': Units.programCode()
|
|
113
113
|
}
|
|
114
114
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import Axios from "axios";
|
|
3
|
+
import Units from './index'
|
|
4
|
+
|
|
5
|
+
//加载本地配置
|
|
6
|
+
Axios.create().get('programConfig.json').then((result) => {
|
|
7
|
+
|
|
8
|
+
Units.setHydrocarbonServer(result.data.hydrocarbonServer);
|
|
9
|
+
if(result.data.programCode){
|
|
10
|
+
Units.setProgramCode(result.data.programCode);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
window.localStorage.setItem('programName', result.data.programName);
|
|
14
|
+
window.localStorage.setItem('programName_NavLeft', result.data.programName_NavLeft);
|
|
15
|
+
window.localStorage.setItem('programName_sub', result.data.programName_sub);
|
|
16
|
+
window.localStorage.setItem('programName_Logo', result.data.programName_Logo);
|
|
17
|
+
|
|
18
|
+
// window.sessionStorage.setItem('programName', result.data.programName);
|
|
19
|
+
// //window.sessionStorage.setItem('hydrocarbonServer', result.data.hydrocarbonServer);
|
|
20
|
+
// window.sessionStorage.setItem('programName_NavLeft', result.data.programName_NavLeft);
|
|
21
|
+
// window.sessionStorage.setItem('programName_sub', result.data.programName_sub);
|
|
22
|
+
// window.sessionStorage.setItem('programName_Logo', result.data.programName_Logo);
|
|
23
|
+
// window.sessionStorage.setItem('programCode', result.data.programCode);
|
|
24
|
+
|
|
25
|
+
}).catch((error) => {
|
|
26
|
+
console.log(error)
|
|
27
|
+
});
|
|
28
|
+
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import {Radio, Select} from 'antd'
|
|
3
|
-
import Axios from "axios";
|
|
4
3
|
import Logo from "./logo.png";
|
|
5
4
|
import {DtmplConfig, DtmplData, EnumItem} from "../tmpl/interface";
|
|
6
5
|
import HCDataSource from "../tmpl/hc-data-source";
|
|
7
6
|
import dayjs from "dayjs";
|
|
8
7
|
import TmplConfigAnalysis from "../tmpl/tmpl-config-analysis";
|
|
8
|
+
import ProgramConfigJson from "../../../public/programConfig.json";
|
|
9
9
|
|
|
10
10
|
const Option = Select.Option;
|
|
11
11
|
|
|
12
|
-
let api = undefined;
|
|
13
|
-
let programCode = undefined;
|
|
12
|
+
// let api = undefined;
|
|
13
|
+
// let programCode = undefined;
|
|
14
14
|
let programName = undefined;
|
|
15
15
|
let programName_sub = undefined;
|
|
16
16
|
let programName_NavLeft = undefined;
|
|
@@ -25,18 +25,6 @@ const AppDtmplConfigFuncMap = {}
|
|
|
25
25
|
|
|
26
26
|
const CUSTOM_EDIT_CONTROL_MAP = {}
|
|
27
27
|
|
|
28
|
-
//加载本地配置
|
|
29
|
-
Axios.create().get('programConfig.json').then((result) => {
|
|
30
|
-
window.localStorage['programName'] = result.data.programName
|
|
31
|
-
window.localStorage['hydrocarbonServer'] = result.data.hydrocarbonServer
|
|
32
|
-
window.localStorage['programName_NavLeft'] = result.data.programName_NavLeft
|
|
33
|
-
window.localStorage['programName_sub'] = result.data.programName_sub
|
|
34
|
-
window.localStorage['programName_Logo'] = result.data.programName_Logo
|
|
35
|
-
window.localStorage['programCode'] = result.data.programCode
|
|
36
|
-
}).catch((error) => {
|
|
37
|
-
console.log(error)
|
|
38
|
-
});
|
|
39
|
-
|
|
40
28
|
export default {
|
|
41
29
|
|
|
42
30
|
//静态补充
|
|
@@ -75,13 +63,13 @@ export default {
|
|
|
75
63
|
return CUSTOM_PAGE_MAP[key];
|
|
76
64
|
},
|
|
77
65
|
setHydrocarbonServer(url: string) {
|
|
78
|
-
|
|
66
|
+
window.localStorage.setItem('hydrocarbonServer', url);
|
|
79
67
|
},
|
|
80
68
|
setProgramName_Logo(logo1: String) {
|
|
81
69
|
logo = logo1;
|
|
82
70
|
},
|
|
83
71
|
api() {
|
|
84
|
-
let appi: string = window.localStorage
|
|
72
|
+
let appi: string = window.localStorage.getItem('hydrocarbonServer');
|
|
85
73
|
if (!appi) {
|
|
86
74
|
appi = new URL(window.location.href).origin;
|
|
87
75
|
//console.log('Hydrcarbon API:',api);
|
|
@@ -92,10 +80,34 @@ export default {
|
|
|
92
80
|
return appi;
|
|
93
81
|
},
|
|
94
82
|
setProgramCode(programCode_: string) {
|
|
95
|
-
programCode
|
|
83
|
+
window.localStorage.setItem('programCode',programCode_);
|
|
84
|
+
window.sessionStorage.setItem('programCode',programCode_);
|
|
85
|
+
},
|
|
86
|
+
setSessionProgramCode(programCode_: string) {
|
|
87
|
+
window.sessionStorage.setItem('programCode',programCode_);
|
|
96
88
|
},
|
|
97
89
|
programCode() {
|
|
98
|
-
|
|
90
|
+
let programCode=window.sessionStorage.getItem('programCode');
|
|
91
|
+
if(!programCode){
|
|
92
|
+
programCode=window.localStorage.getItem('programCode');
|
|
93
|
+
this.setSessionProgramCode(programCode);
|
|
94
|
+
}
|
|
95
|
+
return programCode;
|
|
96
|
+
},
|
|
97
|
+
hydrocarbonToken(){
|
|
98
|
+
let hydrocarbonToken=window.sessionStorage.getItem('hydrocarbonToken');
|
|
99
|
+
if(!hydrocarbonToken){
|
|
100
|
+
hydrocarbonToken=window.localStorage.getItem('hydrocarbonToken');
|
|
101
|
+
this.setSessionHydrocarbonToken(hydrocarbonToken);
|
|
102
|
+
}
|
|
103
|
+
return hydrocarbonToken;
|
|
104
|
+
},
|
|
105
|
+
setHydrocarbonToken(token:string){
|
|
106
|
+
window.sessionStorage.setItem('hydrocarbonToken',token) ;
|
|
107
|
+
window.localStorage.setItem('hydrocarbonToken',token);
|
|
108
|
+
},
|
|
109
|
+
setSessionHydrocarbonToken(token:string){
|
|
110
|
+
window.sessionStorage.setItem('hydrocarbonToken',token) ;
|
|
99
111
|
},
|
|
100
112
|
setProgramName(programName_: string) {
|
|
101
113
|
programName = programName_;
|
|
@@ -176,10 +188,10 @@ export default {
|
|
|
176
188
|
// message.error(e)
|
|
177
189
|
// }
|
|
178
190
|
// },
|
|
179
|
-
openFile(url, fileName,toolbar) {
|
|
191
|
+
openFile(url, fileName, toolbar) {
|
|
180
192
|
try {
|
|
181
193
|
let a = document.createElement("a");
|
|
182
|
-
a.href = url+toolbar;
|
|
194
|
+
a.href = url + toolbar;
|
|
183
195
|
a.target = "_blank";
|
|
184
196
|
document.body.appendChild(a);
|
|
185
197
|
a.click();
|
|
@@ -190,7 +202,7 @@ export default {
|
|
|
190
202
|
},
|
|
191
203
|
toLogin() {
|
|
192
204
|
let programCode = this.programCode();
|
|
193
|
-
if (programCode) {
|
|
205
|
+
if (programCode && programCode!="null" && programCode!="undefined" ) {
|
|
194
206
|
window.location.hash = "#/login/" + programCode;
|
|
195
207
|
} else {
|
|
196
208
|
window.location.hash = "#/login";
|
|
@@ -298,7 +310,7 @@ export default {
|
|
|
298
310
|
getAnoHydrocarbonToken() {
|
|
299
311
|
let token = this.getLocalStorge("anoHydrocarbonToken");
|
|
300
312
|
if (!token) {
|
|
301
|
-
token="tmpl" + this.getRandomNum(6);
|
|
313
|
+
token = "tmpl" + this.getRandomNum(6);
|
|
302
314
|
this.setLocalStorge("anoHydrocarbonToken", token);
|
|
303
315
|
}
|
|
304
316
|
return token;
|