aldehyde 0.2.159 → 0.2.161

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.
Files changed (210) hide show
  1. package/lib/controls/action/index.js +1 -1
  2. package/lib/controls/action/index.js.map +1 -1
  3. package/lib/controls/action/utils.d.ts +2 -2
  4. package/lib/controls/action/utils.d.ts.map +1 -1
  5. package/lib/controls/action/utils.js +5 -5
  6. package/lib/controls/action/utils.js.map +1 -1
  7. package/lib/controls/entry-control.d.ts.map +1 -1
  8. package/lib/controls/entry-control.js +5 -8
  9. package/lib/controls/entry-control.js.map +1 -1
  10. package/lib/controls/file-export/select-code-export.d.ts +13 -0
  11. package/lib/controls/file-export/select-code-export.d.ts.map +1 -0
  12. package/lib/controls/file-export/select-code-export.js +14 -0
  13. package/lib/controls/file-export/select-code-export.js.map +1 -0
  14. package/lib/detail/button/edit-button.d.ts +11 -0
  15. package/lib/detail/button/edit-button.d.ts.map +1 -0
  16. package/lib/detail/button/edit-button.js +23 -0
  17. package/lib/detail/button/edit-button.js.map +1 -0
  18. package/lib/detail/view/act-dtmpl-view.d.ts +3 -1
  19. package/lib/detail/view/act-dtmpl-view.d.ts.map +1 -1
  20. package/lib/detail/view/act-dtmpl-view.js +9 -3
  21. package/lib/detail/view/act-dtmpl-view.js.map +1 -1
  22. package/lib/{exportor → export}/export-frame.d.ts +4 -0
  23. package/lib/export/export-frame.d.ts.map +1 -0
  24. package/lib/{exportor → export}/export-frame.js +6 -4
  25. package/lib/export/export-frame.js.map +1 -0
  26. package/lib/export/select-code-export-frame.d.ts +49 -0
  27. package/lib/export/select-code-export-frame.d.ts.map +1 -0
  28. package/lib/export/select-code-export-frame.js +145 -0
  29. package/lib/export/select-code-export-frame.js.map +1 -0
  30. package/lib/form/criteria-form.d.ts.map +1 -1
  31. package/lib/form/criteria-form.js +26 -2
  32. package/lib/form/criteria-form.js.map +1 -1
  33. package/lib/hooks/useVarCssColor.d.ts +2 -0
  34. package/lib/hooks/useVarCssColor.d.ts.map +1 -0
  35. package/lib/hooks/useVarCssColor.js +7 -0
  36. package/lib/hooks/useVarCssColor.js.map +1 -0
  37. package/lib/index.d.ts +1 -1
  38. package/lib/index.d.ts.map +1 -1
  39. package/lib/index.js +1 -1
  40. package/lib/index.js.map +1 -1
  41. package/lib/layout/MainPage.d.ts.map +1 -1
  42. package/lib/layout/MainPage.js.map +1 -1
  43. package/lib/layout/menu/block.css +1 -1
  44. package/lib/layout/menu/block.d.ts.map +1 -1
  45. package/lib/layout/menu/block.js +1 -1
  46. package/lib/layout/menu/block.js.map +1 -1
  47. package/lib/layout2/components/userButton.d.ts +5 -0
  48. package/lib/layout2/components/userButton.d.ts.map +1 -0
  49. package/lib/layout2/components/userButton.js +133 -0
  50. package/lib/layout2/components/userButton.js.map +1 -0
  51. package/lib/layout2/css/header.css +38 -0
  52. package/lib/layout2/header.d.ts +12 -0
  53. package/lib/layout2/header.d.ts.map +1 -0
  54. package/lib/layout2/header.js +218 -0
  55. package/lib/layout2/header.js.map +1 -0
  56. package/lib/layout2/imgs/1.png +0 -0
  57. package/lib/layout2/imgs/2.png +0 -0
  58. package/lib/layout2/imgs/3.png +0 -0
  59. package/lib/layout2/imgs/4.png +0 -0
  60. package/lib/layout2/imgs/5.png +0 -0
  61. package/lib/layout2/imgs/6.png +0 -0
  62. package/lib/layout2/imgs/home.png +0 -0
  63. package/lib/layout2/main.d.ts +9 -0
  64. package/lib/layout2/main.d.ts.map +1 -0
  65. package/lib/layout2/main.js +14 -0
  66. package/lib/layout2/main.js.map +1 -0
  67. package/lib/layout2/page.d.ts +7 -0
  68. package/lib/layout2/page.d.ts.map +1 -0
  69. package/lib/layout2/page.js +120 -0
  70. package/lib/layout2/page.js.map +1 -0
  71. package/lib/layout2/sider.d.ts +10 -0
  72. package/lib/layout2/sider.d.ts.map +1 -0
  73. package/lib/layout2/sider.js +259 -0
  74. package/lib/layout2/sider.js.map +1 -0
  75. package/lib/layout2/type/layout.type.d.ts +10 -0
  76. package/lib/layout2/type/layout.type.d.ts.map +1 -0
  77. package/lib/layout2/type/layout.type.js +2 -0
  78. package/lib/layout2/type/layout.type.js.map +1 -0
  79. package/lib/layout2/util/menu.util.d.ts +28 -0
  80. package/lib/layout2/util/menu.util.d.ts.map +1 -0
  81. package/lib/layout2/util/menu.util.js +76 -0
  82. package/lib/layout2/util/menu.util.js.map +1 -0
  83. package/lib/login2/Login.d.ts +10 -0
  84. package/lib/login2/Login.d.ts.map +1 -0
  85. package/lib/login2/Login.js +63 -0
  86. package/lib/login2/Login.js.map +1 -0
  87. package/lib/login2/LoginPage.d.ts +4 -0
  88. package/lib/login2/LoginPage.d.ts.map +1 -0
  89. package/lib/login2/LoginPage.js +42 -0
  90. package/lib/login2/LoginPage.js.map +1 -0
  91. package/lib/login2/img/login-bg.png +0 -0
  92. package/lib/login2/index.d.ts +4 -0
  93. package/lib/login2/index.d.ts.map +1 -0
  94. package/lib/login2/index.js +4 -0
  95. package/lib/login2/index.js.map +1 -0
  96. package/lib/module/ltmpl-table.d.ts +4 -2
  97. package/lib/module/ltmpl-table.d.ts.map +1 -1
  98. package/lib/module/ltmpl-table.js +10 -8
  99. package/lib/module/ltmpl-table.js.map +1 -1
  100. package/lib/routable/dtmpl-route.d.ts +3 -2
  101. package/lib/routable/dtmpl-route.d.ts.map +1 -1
  102. package/lib/routable/dtmpl-route.js +20 -16
  103. package/lib/routable/dtmpl-route.js.map +1 -1
  104. package/lib/routable/import-route.d.ts +3 -2
  105. package/lib/routable/import-route.d.ts.map +1 -1
  106. package/lib/routable/import-route.js +10 -6
  107. package/lib/routable/import-route.js.map +1 -1
  108. package/lib/routable/ltmpl-route.d.ts +1 -0
  109. package/lib/routable/ltmpl-route.d.ts.map +1 -1
  110. package/lib/routable/ltmpl-route.js +21 -15
  111. package/lib/routable/ltmpl-route.js.map +1 -1
  112. package/lib/routable/ttmpl-route.d.ts +3 -2
  113. package/lib/routable/ttmpl-route.d.ts.map +1 -1
  114. package/lib/routable/ttmpl-route.js +13 -9
  115. package/lib/routable/ttmpl-route.js.map +1 -1
  116. package/lib/routable/withroute.d.ts +1 -1
  117. package/lib/routable/withroute.d.ts.map +1 -1
  118. package/lib/routable/withroute.js +3 -3
  119. package/lib/routable/withroute.js.map +1 -1
  120. package/lib/table/act-table.d.ts +6 -3
  121. package/lib/table/act-table.d.ts.map +1 -1
  122. package/lib/table/act-table.js +110 -88
  123. package/lib/table/act-table.js.map +1 -1
  124. package/lib/table/index.css +4 -4
  125. package/lib/table/query-table.d.ts +1 -1
  126. package/lib/table/query-table.d.ts.map +1 -1
  127. package/lib/table/query-table.js +24 -16
  128. package/lib/table/query-table.js.map +1 -1
  129. package/lib/table/relation-table.d.ts +2 -2
  130. package/lib/table/relation-table.d.ts.map +1 -1
  131. package/lib/table/relation-table.js +5 -5
  132. package/lib/table/relation-table.js.map +1 -1
  133. package/lib/table/select-table.js +2 -2
  134. package/lib/table/select-table.js.map +1 -1
  135. package/lib/tmpl/hc-data-source.d.ts.map +1 -1
  136. package/lib/tmpl/hc-data-source.js +2 -3
  137. package/lib/tmpl/hc-data-source.js.map +1 -1
  138. package/lib/tmpl/hcservice-v3.d.ts +3 -2
  139. package/lib/tmpl/hcservice-v3.d.ts.map +1 -1
  140. package/lib/tmpl/hcservice-v3.js +11 -2
  141. package/lib/tmpl/hcservice-v3.js.map +1 -1
  142. package/lib/tmpl/interface.d.ts +41 -6
  143. package/lib/tmpl/interface.d.ts.map +1 -1
  144. package/lib/tmpl/tmpl-config-analysis.d.ts.map +1 -1
  145. package/lib/tmpl/tmpl-config-analysis.js +33 -27
  146. package/lib/tmpl/tmpl-config-analysis.js.map +1 -1
  147. package/lib/tree/tmpl-tree.d.ts.map +1 -1
  148. package/lib/tree/tmpl-tree.js +2 -1
  149. package/lib/tree/tmpl-tree.js.map +1 -1
  150. package/lib/welcome/HCWelcome.d.ts +1 -1
  151. package/lib/welcome/HCWelcome.js +254 -169
  152. package/lib/welcome/HCWelcome.js.map +1 -1
  153. package/lib/welcome/img/welcome.png +0 -0
  154. package/package.json +1 -1
  155. package/src/aldehyde/controls/action/index.tsx +1 -1
  156. package/src/aldehyde/controls/action/utils.tsx +4 -5
  157. package/src/aldehyde/controls/entry-control.tsx +5 -8
  158. package/src/aldehyde/controls/file-export/select-code-export.tsx +40 -0
  159. package/src/aldehyde/detail/button/edit-button.tsx +51 -0
  160. package/src/aldehyde/detail/view/act-dtmpl-view.tsx +14 -2
  161. package/src/aldehyde/{exportor → export}/export-frame.tsx +10 -6
  162. package/src/aldehyde/export/select-code-export-frame.tsx +218 -0
  163. package/src/aldehyde/form/criteria-form.tsx +35 -0
  164. package/src/aldehyde/hooks/useVarCssColor.ts +6 -0
  165. package/src/aldehyde/index.tsx +2 -2
  166. package/src/aldehyde/layout/MainPage.tsx +8 -6
  167. package/src/aldehyde/layout/menu/block.css +1 -1
  168. package/src/aldehyde/layout/menu/block.tsx +1 -0
  169. package/src/aldehyde/layout2/components/userButton.tsx +171 -0
  170. package/src/aldehyde/layout2/css/header.css +38 -0
  171. package/src/aldehyde/layout2/header.tsx +334 -0
  172. package/src/aldehyde/layout2/imgs/1.png +0 -0
  173. package/src/aldehyde/layout2/imgs/2.png +0 -0
  174. package/src/aldehyde/layout2/imgs/3.png +0 -0
  175. package/src/aldehyde/layout2/imgs/4.png +0 -0
  176. package/src/aldehyde/layout2/imgs/5.png +0 -0
  177. package/src/aldehyde/layout2/imgs/6.png +0 -0
  178. package/src/aldehyde/layout2/imgs/home.png +0 -0
  179. package/src/aldehyde/layout2/imgs/s.svg +3 -0
  180. package/src/aldehyde/layout2/main.tsx +27 -0
  181. package/src/aldehyde/layout2/page.tsx +169 -0
  182. package/src/aldehyde/layout2/sider.tsx +357 -0
  183. package/src/aldehyde/layout2/type/layout.type.ts +10 -0
  184. package/src/aldehyde/layout2/util/menu.util.tsx +112 -0
  185. package/src/aldehyde/login2/Login.tsx +110 -0
  186. package/src/aldehyde/login2/LoginPage.tsx +58 -0
  187. package/src/aldehyde/login2/img/login-bg.png +0 -0
  188. package/src/aldehyde/login2/index.tsx +4 -0
  189. package/src/aldehyde/module/ltmpl-table.tsx +12 -9
  190. package/src/aldehyde/routable/dtmpl-route.tsx +141 -121
  191. package/src/aldehyde/routable/import-route.tsx +28 -23
  192. package/src/aldehyde/routable/ltmpl-route.tsx +82 -56
  193. package/src/aldehyde/routable/ttmpl-route.tsx +73 -55
  194. package/src/aldehyde/routable/withroute.tsx +21 -18
  195. package/src/aldehyde/table/act-table.tsx +88 -66
  196. package/src/aldehyde/table/index.css +4 -4
  197. package/src/aldehyde/table/query-table.tsx +27 -20
  198. package/src/aldehyde/table/relation-table.tsx +7 -7
  199. package/src/aldehyde/table/select-table.tsx +2 -2
  200. package/src/aldehyde/tmpl/hc-data-source.tsx +373 -352
  201. package/src/aldehyde/tmpl/hcservice-v3.tsx +33 -17
  202. package/src/aldehyde/tmpl/interface.tsx +43 -6
  203. package/src/aldehyde/tmpl/tmpl-config-analysis.tsx +307 -247
  204. package/src/aldehyde/tree/tmpl-tree.tsx +2 -1
  205. package/src/aldehyde/welcome/HCWelcome.js +270 -235
  206. package/src/aldehyde/welcome/img/welcome.png +0 -0
  207. package/lib/exportor/export-frame.d.ts.map +0 -1
  208. package/lib/exportor/export-frame.js.map +0 -1
  209. /package/lib/{exportor → export}/export-frame.css +0 -0
  210. /package/src/aldehyde/{exportor → export}/export-frame.css +0 -0
@@ -0,0 +1,110 @@
1
+ import { Button, Form, Input } from "antd";
2
+ import React, { useState } from "react";
3
+ import HCserviceV3 from "../tmpl/hcservice-v3";
4
+ import { useLocale } from "../locale/useLocale";
5
+
6
+ type LoginPropType = {
7
+ onFinish?: (token: string) => void;
8
+ title?: any;
9
+ programCode?: string;
10
+ autoSaveUser?: boolean;
11
+ };
12
+
13
+ type FormType = {
14
+ username: string;
15
+ password: string;
16
+ };
17
+
18
+ const Login = (props: LoginPropType) => {
19
+ // locale
20
+ const { translate } = useLocale();
21
+
22
+ // form
23
+ const [form] = Form.useForm<FormType>();
24
+ const submit = async () => {
25
+ try {
26
+ const { username, password } = await form.validateFields();
27
+
28
+ setLoading(true);
29
+ const { programCode, onFinish } = props;
30
+ const pubkey = await HCserviceV3.getRasPubkey(null, programCode);
31
+ const res = await HCserviceV3.login(
32
+ { username, password },
33
+ "",
34
+ "",
35
+ pubkey,
36
+ programCode
37
+ );
38
+ if (res.status === "success") {
39
+ onFinish(res.token);
40
+ }
41
+ setLoading(false);
42
+ } catch (err) {
43
+ console.error(err);
44
+ }
45
+ };
46
+
47
+ // button
48
+ const [loading, setLoading] = useState<boolean>(false);
49
+
50
+ return (
51
+ <Form
52
+ name="login"
53
+ form={form}
54
+ wrapperCol={{ span: 24 }}
55
+ initialValues={{ remember: true }}
56
+ autoComplete="off"
57
+ >
58
+ <Form.Item
59
+ name="username"
60
+ rules={[{ required: true, message: translate("请输入用户名") }]}
61
+ >
62
+ <Input
63
+ placeholder={translate("请输入用户名")}
64
+ style={{
65
+ borderRadius: "50px",
66
+ background: "#EEF3FB",
67
+ height: "50px",
68
+ fontSize: "15px",
69
+ lineHeight: "15px",
70
+ }}
71
+ />
72
+ </Form.Item>
73
+
74
+ <Form.Item
75
+ name="password"
76
+ rules={[{ required: true, message: translate("请输入密码") }]}
77
+ >
78
+ <Input.Password
79
+ placeholder={translate("请输入密码")}
80
+ style={{
81
+ borderRadius: "50px",
82
+ background: "#EEF3FB",
83
+ height: "50px",
84
+ fontSize: "15px",
85
+ lineHeight: "15px",
86
+ }}
87
+ />
88
+ </Form.Item>
89
+
90
+ <Form.Item wrapperCol={{ span: 24 }}>
91
+ <Button
92
+ type="primary"
93
+ onClick={submit}
94
+ shape="round"
95
+ loading={loading}
96
+ style={{
97
+ width: "100%",
98
+ height: "50px",
99
+ fontSize: "15px",
100
+ lineHeight: "15px",
101
+ }}
102
+ >
103
+ 登录
104
+ </Button>
105
+ </Form.Item>
106
+ </Form>
107
+ );
108
+ };
109
+
110
+ export default Login;
@@ -0,0 +1,58 @@
1
+ import React from "react";
2
+ import Login from "./Login";
3
+ import LoginBgPng from "./img/login-bg.png";
4
+ import { useLocale } from "../locale/useLocale";
5
+ import HCDataSource from "../tmpl/hc-data-source";
6
+ import Units from "../units";
7
+
8
+ const LoginPage = () => {
9
+ const { translate } = useLocale();
10
+
11
+ return (
12
+ <div
13
+ style={{
14
+ width: "100%",
15
+ height: "100%",
16
+ minWidth: "1600px",
17
+ position: "absolute",
18
+ background: `url(${LoginBgPng})`,
19
+ backgroundSize: "cover",
20
+ display: "flex",
21
+ flexDirection: "row-reverse",
22
+ justifyContent: "flex-start",
23
+ alignItems: "center",
24
+ }}
25
+ >
26
+ <div
27
+ style={{
28
+ width: "500px",
29
+ height: "500px",
30
+ background: "linear-gradient(0deg, #FFFFFF 65%, #DFEDFF)",
31
+ boxShadow: "0px 10px 15px -3px rgba(0,0,0,0.1)",
32
+ marginRight: "10%",
33
+ padding: "60px",
34
+ }}
35
+ >
36
+ <div
37
+ style={{
38
+ fontWeight: 600,
39
+ fontSize: "30px",
40
+ color: "#222222",
41
+ marginBottom: 60,
42
+ }}
43
+ >
44
+ {translate("欢迎, 登录")}
45
+ </div>
46
+ <Login
47
+ onFinish={(token) => {
48
+ HCDataSource.clear();
49
+ window.location.hash = "/v2";
50
+ Units.setHydrocarbonToken(token);
51
+ }}
52
+ ></Login>
53
+ </div>
54
+ </div>
55
+ );
56
+ };
57
+
58
+ export default LoginPage;
@@ -0,0 +1,4 @@
1
+ import Login from "./Login";
2
+ import LoginPage from "./LoginPage";
3
+
4
+ export { Login, LoginPage };
@@ -1,5 +1,5 @@
1
1
  import React, { ReactNode } from "react";
2
- import { AddOrUpdate, LtmplConfigRes, ActTableMode } from "../tmpl/interface";
2
+ import {AddOrUpdate, LtmplConfigRes, ActTableMode, DoEditParam} from "../tmpl/interface";
3
3
  import Units from "../units";
4
4
  import ActTable from "../table/act-table";
5
5
  // import StatActTable from '../table/stat-act-table'
@@ -46,6 +46,7 @@ export interface LtmplTableState {
46
46
  ractionId?: string;
47
47
  collapse?: boolean;
48
48
  addTmplId?: string;
49
+ dtmplSourceId?:string;
49
50
  }
50
51
 
51
52
  class LtmplTable extends React.PureComponent<LtmplTableProps, LtmplTableState> {
@@ -62,6 +63,7 @@ class LtmplTable extends React.PureComponent<LtmplTableProps, LtmplTableState> {
62
63
  ractionId: undefined,
63
64
  collapse: false,
64
65
  addTmplId: undefined,
66
+ dtmplSourceId:undefined,
65
67
  };
66
68
  static contextType = LocaleContext;
67
69
  context: React.ContextType<typeof LocaleContext>;
@@ -130,22 +132,23 @@ class LtmplTable extends React.PureComponent<LtmplTableProps, LtmplTableState> {
130
132
  });
131
133
  };
132
134
 
133
- doEdit = (code: string, mode: AddOrUpdate, toCustomPage?: boolean) => {
134
- const { doCustomEdit } = this.props;
135
- if (toCustomPage) {
135
+ doEdit = (param:DoEditParam) => {
136
+ const { doCustomEdit,sourceId } = this.props;
137
+ if (param.toCustomPage) {
136
138
  if (doCustomEdit) {
137
- doCustomEdit(code, mode, () => {
139
+ doCustomEdit(param.code, param.mode, () => {
138
140
  this.doSearch(this.state.criteriaData);
139
141
  });
140
142
  } else {
141
143
  this.setState({
142
- selectedCode: code,
144
+ selectedCode: param.code,
145
+ dtmplSourceId:param.dtmplSourceId?param.dtmplSourceId:sourceId,
143
146
  showDtmplCustomEdit: true,
144
147
  });
145
148
  }
146
149
  } else {
147
150
  this.setState({
148
- selectedCode: code,
151
+ selectedCode: param.code,
149
152
  showDtmplEdit: true,
150
153
  });
151
154
  }
@@ -229,7 +232,7 @@ class LtmplTable extends React.PureComponent<LtmplTableProps, LtmplTableState> {
229
232
  ractionId,
230
233
  showDraw,
231
234
  collapse,
232
- addTmplId,
235
+ addTmplId,dtmplSourceId,
233
236
  } = this.state;
234
237
  const {
235
238
  sourceId,
@@ -307,7 +310,7 @@ class LtmplTable extends React.PureComponent<LtmplTableProps, LtmplTableState> {
307
310
  showDtmplEdit: false,
308
311
  });
309
312
  }}
310
- sourceId={sourceId}
313
+ sourceId={dtmplSourceId?dtmplSourceId:sourceId}
311
314
  mainCode={mainCode}
312
315
  code={selectedCode}
313
316
  onOk={this.handleDtmplEdit}
@@ -1,145 +1,165 @@
1
- import React from 'react'
2
- import { Empty} from 'antd';
3
- import {CodeSource, RouterCompProps} from '../tmpl/interface';
1
+ import React from "react";
2
+ import { Empty } from "antd";
3
+ import { CodeSource, RouterCompProps } from "../tmpl/interface";
4
4
  import DtmplEdit from "../detail/edit/dtmpl-edit";
5
- import ActDtmplView from '../detail/view/act-dtmpl-view';
5
+ import ActDtmplView from "../detail/view/act-dtmpl-view";
6
6
  import HcserviceV3 from "../tmpl/hcservice-v3";
7
7
  import withRouter from "./withroute";
8
8
 
9
-
10
9
  export interface DtmplRouteProps extends RouterCompProps {
11
-
12
- };
10
+ layoutRootPath?: string;
11
+ }
13
12
 
14
13
  export interface DtmplRoutePropsStat {
15
- codeSource?:CodeSource,
16
- queriedCode?:string,
17
- };
14
+ codeSource?: CodeSource;
15
+ queriedCode?: string;
16
+ }
18
17
 
19
18
  class DtmplRoute extends React.Component<DtmplRouteProps, DtmplRoutePropsStat> {
20
- state={
21
- codeSource:undefined,
22
- queriedCode:undefined,
23
- }
24
- static defaultProps={
25
- basePath:"",
26
- codeSource:undefined,
27
- queriedCode:undefined,
28
- }
29
- async componentDidMount() {
30
- await this.queryCode();
19
+ state = {
20
+ codeSource: undefined,
21
+ queriedCode: undefined,
22
+ };
23
+ static defaultProps = {
24
+ basePath: "",
25
+ codeSource: undefined,
26
+ queriedCode: undefined,
27
+ };
28
+ async componentDidMount() {
29
+ await this.queryCode();
30
+ }
31
+
32
+ get computedLayoutPath() {
33
+ const { layoutRootPath } = this.props;
34
+ if (layoutRootPath !== undefined) return `/${layoutRootPath}`;
35
+ return "";
36
+ }
37
+
38
+ shouldComponentUpdate(prevProps, prevState) {
39
+ if (!prevProps || prevProps != this.props) {
40
+ this.setState({ codeSource: undefined, queriedCode: undefined });
31
41
  }
42
+ return true;
43
+ }
32
44
 
33
- shouldComponentUpdate(prevProps, prevState) {
34
- if(!prevProps || prevProps!=this.props){
35
- this.setState({codeSource:undefined,queriedCode:undefined})
36
- }
37
- return true;
45
+ async componentDidUpdate(prevProps, prevState, snapshot) {
46
+ if (!prevProps || prevProps != this.props) {
47
+ await this.queryCode();
38
48
  }
39
-
40
- async componentDidUpdate(prevProps, prevState, snapshot) {
41
- if(!prevProps || prevProps!=this.props){
42
- await this.queryCode();
43
- }
49
+ }
50
+
51
+ queryCode = async () => {
52
+ const { params } = this.props;
53
+ const { sourceId } = params;
54
+ let codeSource: CodeSource = this.getCodeSource();
55
+ let queriedCode = await HcserviceV3.queryCode(sourceId, codeSource);
56
+ this.setState({
57
+ codeSource,
58
+ queriedCode,
59
+ });
60
+ };
61
+
62
+ getMenuId = () => {
63
+ const { searchParams } = this.props;
64
+ //console.log("this.props.match.params",this.props);
65
+ // var searchParams = new URLSearchParams( location.search);
66
+ let menuId = searchParams.get("menuId");
67
+ return menuId;
68
+ };
69
+
70
+ getCodeSource = () => {
71
+ const { searchParams } = this.props;
72
+ // let params=Units.transQueryStrToParams(location.search);
73
+ // if('codeSource' in params){
74
+ return searchParams.get("codeSource");
75
+ // }else{
76
+ // return undefined;
77
+ // }
78
+ };
79
+
80
+ goBackToLtmpl = () => {
81
+ this.props.navigate(-1);
82
+ };
83
+
84
+ goDtmpl = (code: string) => {
85
+ const { sourceId } = this.props.params;
86
+ const { basePath } = this.props;
87
+ let url = `${basePath}${
88
+ this.computedLayoutPath
89
+ }/${sourceId}/detail-edit?menuId=${this.getMenuId()}`;
90
+ if (code) {
91
+ url = url + `&code=${code}`;
44
92
  }
45
-
46
- queryCode=async ()=>{
47
- const {params}=this.props;
48
- const {sourceId} = params;
49
- let codeSource:CodeSource=this.getCodeSource();
50
- let queriedCode=await HcserviceV3.queryCode(sourceId,codeSource);
51
- this.setState({
52
- codeSource,
53
- queriedCode
54
- })
93
+ let mainCode = this.getMainCode();
94
+ if (mainCode) {
95
+ url = url + `&mainCode=${mainCode}`;
55
96
  }
56
-
57
- getMenuId=()=>{
58
- const {searchParams} = this.props;
59
- //console.log("this.props.match.params",this.props);
60
- // var searchParams = new URLSearchParams( location.search);
61
- let menuId = searchParams.get('menuId');
62
- return menuId;
97
+ this.props.navigate(url);
98
+ };
99
+
100
+ getMainCode = () => {
101
+ const { searchParams } = this.props;
102
+ return searchParams.get("mainCode");
103
+ };
104
+
105
+ getCode = () => {
106
+ const { codeSource, queriedCode } = this.state;
107
+ const { searchParams } = this.props;
108
+ //let code;
109
+ if (codeSource) {
110
+ return queriedCode;
111
+ } else {
112
+ // let params=Units.transQueryStrToParams(location.search);
113
+ return searchParams.get("code");
63
114
  }
115
+ };
64
116
 
65
- getCodeSource=()=>{
66
- const {searchParams}=this.props;
67
- // let params=Units.transQueryStrToParams(location.search);
68
- // if('codeSource' in params){
69
- return searchParams.get('codeSource');
70
- // }else{
71
- // return undefined;
72
- // }
73
- }
117
+ getMode = () => {
118
+ const { searchParams } = this.props;
119
+ // let params=Units.transQueryStrToParams(location.search);
120
+ return this.getCode() ? searchParams.get("mode") : "add";
121
+ };
74
122
 
75
- goBackToLtmpl=()=>{
76
- this.props.navigate(-1);
77
- }
123
+ render() {
124
+ const { location, params, searchParams } = this.props;
125
+ const { sourceId } = params;
78
126
 
79
- goDtmpl=(code:string)=>{
80
- const { sourceId,} = this.props.params;
81
- const {basePath}=this.props;
82
- let url=`${basePath}/${sourceId}/detail-edit?menuId=${this.getMenuId()}`;
83
- if(code){
84
- url=url+`&code=${code}`;
85
- }
86
- let mainCode=this.getMainCode();
87
- if(mainCode){
88
- url=url+`&mainCode=${mainCode}`;
89
- }
90
- this.props.navigate(url);
127
+ const { codeSource } = this.state;
128
+ if (!location) {
129
+ return <></>;
91
130
  }
92
-
93
- getMainCode=()=>{
94
- const {searchParams}=this.props;
95
- return searchParams.get('mainCode');
131
+ const code = this.getCode();
132
+ if (code && code == "bad-code") {
133
+ return <Empty />;
96
134
  }
97
-
98
- getCode= ()=>{
99
- const {codeSource,queriedCode}=this.state;
100
- const {searchParams}=this.props;
101
- //let code;
102
- if(codeSource){
103
- return queriedCode;
104
- }else{
105
- // let params=Units.transQueryStrToParams(location.search);
106
- return searchParams.get('code');
107
- }
108
- }
109
-
110
- getMode=()=>{
111
- const {searchParams}=this.props;
112
- // let params=Units.transQueryStrToParams(location.search);
113
- return this.getCode()?searchParams.get('mode'):"add";
114
- }
115
-
116
- render() {
117
-
118
- const {location,params,searchParams}=this.props;
119
- const {sourceId} = params;
120
-
121
- const {codeSource}=this.state;
122
- if(!location){
123
- return <></>;
124
- }
125
- const code=this.getCode();
126
- if(code && code=='bad-code'){
127
- return <Empty />
128
- }
129
- // let params=Units.transQueryStrToParams(location.search);
130
- let versionId=params['versionId'];
131
- if(location.pathname.endsWith("detail-view")){
132
- return (
133
- <ActDtmplView serverKey={null} goDtmpl={this.goDtmpl} sourceId={sourceId} versionId={versionId} code={code} mainCode={this.getMainCode()} />
134
- );
135
- }else{
136
- return (
137
- <DtmplEdit addTmplId={searchParams.get('addTmplId')} serverKey={null} addOrUpdate={this.getMode()} sourceId={sourceId} code={code} mainCode={this.getMainCode()} goBackToLtmpl={codeSource?undefined:this.goBackToLtmpl} goDtmpl={this.goDtmpl}></DtmplEdit>
138
- );
139
- }
140
-
135
+ // let params=Units.transQueryStrToParams(location.search);
136
+ let versionId = params["versionId"];
137
+ if (location.pathname.endsWith("detail-view")) {
138
+ return (
139
+ <ActDtmplView
140
+ serverKey={null}
141
+ goDtmpl={this.goDtmpl}
142
+ sourceId={sourceId}
143
+ versionId={versionId}
144
+ code={code}
145
+ mainCode={this.getMainCode()}
146
+ />
147
+ );
148
+ } else {
149
+ return (
150
+ <DtmplEdit
151
+ addTmplId={searchParams.get("addTmplId")}
152
+ serverKey={null}
153
+ addOrUpdate={this.getMode()}
154
+ sourceId={sourceId}
155
+ code={code}
156
+ mainCode={this.getMainCode()}
157
+ goBackToLtmpl={codeSource ? undefined : this.goBackToLtmpl}
158
+ goDtmpl={this.goDtmpl}
159
+ ></DtmplEdit>
160
+ );
141
161
  }
162
+ }
142
163
  }
143
164
 
144
165
  export default withRouter(DtmplRoute);
145
-
@@ -1,29 +1,34 @@
1
- import React from 'react'
2
- import {RouterCompProps} from '../tmpl/interface';
3
- import ExcelImport from '../import/excel-import'
1
+ import React from "react";
2
+ import { RouterCompProps } from "../tmpl/interface";
3
+ import ExcelImport from "../import/excel-import";
4
4
  import withRouter from "./withroute";
5
5
 
6
6
  export interface ImportRouteProps extends RouterCompProps {
7
- serverKey?:string,
8
- };
9
- interface ImportRouteStat{
10
-
7
+ serverKey?: string;
8
+ layoutRootPath?: string;
11
9
  }
12
-
13
- class ExcelImportRoute extends React.PureComponent<ImportRouteProps, ImportRouteStat> {
14
-
15
- state = {}
16
-
17
- async componentDidMount() {
18
-
19
- }
20
-
21
-
22
- render() {
23
- const { params, serverKey} = this.props;
24
- const { sourceId} = params;
25
- return <ExcelImport serverKey={serverKey} sourceId={sourceId}></ExcelImport>
26
- }
10
+ interface ImportRouteStat {}
11
+
12
+ class ExcelImportRoute extends React.PureComponent<
13
+ ImportRouteProps,
14
+ ImportRouteStat
15
+ > {
16
+ state = {};
17
+
18
+ async componentDidMount() {}
19
+
20
+ get computedLayoutPath() {
21
+ const { layoutRootPath } = this.props;
22
+ if (layoutRootPath !== undefined) return `/${layoutRootPath}`;
23
+ return "";
24
+ }
25
+
26
+ render() {
27
+ const { params, serverKey } = this.props;
28
+ const { sourceId } = params;
29
+ return (
30
+ <ExcelImport serverKey={serverKey} sourceId={sourceId}></ExcelImport>
31
+ );
32
+ }
27
33
  }
28
34
  export default withRouter(ExcelImportRoute);
29
-