Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
swifteditor
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
daixuan
swifteditor
Commits
c5367b31
Commit
c5367b31
authored
Nov 16, 2018
by
fukai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ncb first version
parent
60bd5da0
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
263 additions
and
31 deletions
+263
-31
index.html
src/entries/index.html
+15
-6
index.js
src/routes/index.js
+1
-0
LeadPage.js
src/swift/LeadPage.js
+1
-1
SWFPage2.js
src/swift/SWFPage2.js
+71
-20
ServiceAPI.js
src/swift/ServiceAPI.js
+8
-0
T61.js
src/swift/Tags/T61.js
+10
-2
TemplateSave.js
src/swift/TemplateSave.js
+154
-0
Utils.js
src/swift/Utils.js
+3
-2
No files found.
src/entries/index.html
View file @
c5367b31
...
...
@@ -15,17 +15,26 @@
<script src="https://as.alipayobjects.com/g/component/??console-polyfill/0.2.2/index.js,es5-shim/4.5.7/es5-shim.min.js,es5-shim/4.5.7/es5-sham.min.js,html5shiv/3.7.2/html5shiv.min.js,media-match/2.0.2/media.match.min.js"></script>
<![endif]-->
<script>
window
.
serviceURL
=
"http://39.107.232.54:8000/SF2Server"
;
window
.
CUR
=
[
'EUR'
,
'USD'
,
window
.
serviceURL
=
"http://127.0.0.1:8080/webeditor/service"
;
window
.
CUR
=
[
'AUD'
,
'CAD'
,
'JPY'
,
'CHF'
,
'CAD'
,
'CNY'
,
'DKK'
,
'EUR'
,
'GBP'
,
'HKD'
,
'CNY'
'JPY'
,
'NOK'
,
'NZD'
,
'SEK'
,
'THB'
,
'USD'
,
'SGD'
];
window
.
BANK_LOGIC_ADDRESS
=
"NYCBCNS0AXXX"
window
.
BANK_BIC
=
"NYCBCNS0XXX"
</script>
<script
src=
"./common.js"
></script>
<script
src=
"./index.js"
></script>
...
...
src/routes/index.js
View file @
c5367b31
...
...
@@ -29,6 +29,7 @@ const Routes = ({ history }) =>
<
Route
path
=
"home/:mctid"
component
=
{
LeadPage
}
/
>
<
Route
path
=
"lead/:mctid"
component
=
{
LeadPage
}
/
>
<
Route
path
=
"swift/:action/:key"
component
=
{
SWFPage
}
/
>
<
Route
path
=
"swift/:action/:mctid/:key"
component
=
{
SWFPage
}
/
>
<
Route
path
=
"swift/:action/:mctid/:key/:rcvbic"
component
=
{
SWFPage
}
/
>
<
Route
path
=
"swift/:action/:mctid/:key/:sndbic/:rcvbic"
component
=
{
SWFPage
}
/
>
...
...
src/swift/LeadPage.js
View file @
c5367b31
...
...
@@ -62,7 +62,7 @@ export class LeadPage extends Component
render
:(
text
,
record
)
=>
{
return
<
a
href
=
"javascript:void(0);"
onClick
=
{()
=>
{
this
.
props
.
actions
.
initSwiftMessageTree
(
null
)
//清空
this
.
props
.
history
.
push
(
`swift/edit/
${
this
.
props
.
params
.
mctid
||
'NONE'
}
/
${
record
.
mty
}
/NONE
`
)
this
.
props
.
history
.
push
(
`swift/edit/
${
record
.
mty
}
`
)
}
}
>
Create
{
record
.
desp
}
<
/a
>
}
...
...
src/swift/SWFPage2.js
View file @
c5367b31
...
...
@@ -19,6 +19,8 @@ import {TagV} from './TagValidater'
import
YBIC
from
'./Tags/YBIC'
import
TempSaver
from
'./TemplateSave'
const
Option
=
Select
.
Option
;
const
Step
=
Steps
.
Step
;
...
...
@@ -91,7 +93,7 @@ export class SWFPage extends Component
let
rcv_bic_err_msg
=
validateRCV_BIC
(
this
.
props
.
rcv_bic_info
.
rcv_bic
)
let
snd_bic_err_msg
=
validateRCV_BIC
(
this
.
props
.
snd_bic_info
.
snd_bic
)
if
(
snd_bic_err_msg
||
rcv_bic_err_msg
||
crs
.
hasError
)
if
(
rcv_bic_err_msg
||
crs
.
hasError
)
{
//更新整个树
notification
.
error
({
description
:
'输入存在错误,请按照提示检查!'
,
message
:
'错误'
})
...
...
@@ -132,17 +134,22 @@ export class SWFPage extends Component
else
{
// message = `{1:${getLogicAdress(this.props.snd_bic_info.snd_bic)}0000000000}{2:I${this.props.params.key.substring(2)}${getLogicAdress(this.props.rcv_bic_info.rcv_bic)}N}{4:\r\n${message}\r\n}`
let
gpistr
=
':121:ID for UUID generation: TRNPAY3
\
r
\
n'
let
mty
=
this
.
props
.
params
.
key
.
substring
(
2
)
let
mty
=
this
.
props
.
extra
.
msgtyp
.
substring
(
2
)
mty
=
mty
.
toUpperCase
()
if
(
mty
!=
'103'
&&
mty
!=
'202'
&&
mty
!=
'202COV'
)
gpistr
=
''
let
s119
=
''
let
header3
=
''
if
(
mty
==
'202COV'
)
{
mty
=
'202'
s119
=
':119:COV
\
r
\
n'
//s119=':119:COV\r\n' 锦州
s119
=
'{:119:COV}'
header3
=
`{3:
${
s119
}
}`
}
message
=
`:MT:
${
mty
}
\r\n:IO:
${
this
.
props
.
rcv_bic_info
.
rcv_bic
}
\r\n:II:
${
this
.
props
.
snd_bic_info
.
snd_bic
}
\r\n:MP:N\r\n
${
s119
}${
gpistr
}
:EOH:\r\n
${
message
}
\r\n-\r\n`
//锦州 message = `:MT:${mty}\r\n:IO:${this.props.rcv_bic_info.rcv_bic}\r\n:II:${this.props.snd_bic_info.snd_bic}\r\n:MP:N\r\n${s119}${gpistr}:EOH:\r\n${message}\r\n-\r\n`
//南商
message
=
`{1:F01
${
window
.
BANK_LOGIC_ADDRESS
}
0000000000}{2:I
${
mty
}${
getLogicAdress
(
this
.
props
.
rcv_bic_info
.
rcv_bic
)}
N}
${
header3
}
{4:\r\n
${
message
}
\r\n-}`
}
console
.
log
(
message
)
this
.
props
.
actions
.
updateSwiftMessage
(
message
)
...
...
@@ -183,9 +190,8 @@ export class SWFPage extends Component
reload
=
(
flag
)
=>
{
let
smhinr
=
this
.
props
.
params
.
key
ServiceAPI
.
getSMH
(
smhinr
).
then
(
data
=>
{
let
tempinr
=
this
.
props
.
params
.
key
ServiceAPI
.
getTemplate
(
tempinr
).
then
(
data
=>
{
if
(
typeof
data
==
'string'
)
{
data
=
JSON
.
parse
(
data
)
...
...
@@ -197,20 +203,58 @@ export class SWFPage extends Component
{
data
=
JSON
.
parse
(
data
)
}
this
.
props
.
actions
.
updateRcvBic
({
rcv_bic
:
data
.
rcv_bic
})
this
.
props
.
actions
.
updateSndBic
({
snd_bic
:
data
.
snd_bic
})
//更新报文树
this
.
mty
=
"mt"
+
data
.
mty
console
.
log
(
data
.
swift_message
)
this
.
props
.
extra
.
smhinr
=
smhinr
this
.
props
.
extra
.
msgtyp
=
"mt"
+
data
.
mty
this
.
props
.
extra
.
tdheaders
=
data
.
tdheaders
this
.
props
.
extra
.
headers
=
data
.
headers
let
tree
=
JSON
.
parse
(
data
.
swift_message
)
this
.
props
.
actions
.
initSwiftMessageTree
({
Tags
:
tree
,
Title
:
data
.
title
});
this
.
mty
=
data
.
typ
this
.
props
.
extra
.
msgtyp
=
"mt"
+
this
.
mty
if
(
data
.
txt
)
data
=
data
.
txt
data
=
JSON
.
parse
(
data
)
this
.
props
.
actions
.
updateRcvBic
({
rcv_bic
:
data
.
rcv_bic_info
.
rcv_bic
})
let
tree
=
data
.
swift_message_tree
this
.
props
.
actions
.
initSwiftMessageTree
(
tree
);
}).
catch
(
err
=>
{
console
.
log
(
err
)
})
// ServiceAPI.getSMH(smhinr).then(data=>{
// if(typeof data=='string')
// {
// data = JSON.parse(data)
// }
// if(data.errorCode !== '0000')
// return
// data = data.data
// if(typeof data=='string')
// {
// data = JSON.parse(data)
// }
// this.props.actions.updateRcvBic({rcv_bic:data.rcv_bic})
// this.props.actions.updateSndBic({snd_bic:data.snd_bic})
// //更新报文树
// this.mty="mt"+data.mty
// console.log(data.swift_message)
// this.props.extra.smhinr=smhinr
// this.props.extra.msgtyp="mt"+data.mty
// this.props.extra.tdheaders=data.tdheaders
// this.props.extra.headers=data.headers
// let tree = JSON.parse(data.swift_message)
// this.props.actions.initSwiftMessageTree({Tags:tree,Title:data.title});
// }).catch(err=>{
// console.log(err)
// })
}
saveTemp
=
()
=>
{
//存储报文模板
const
{
swift_message
,
rcv_bic_info
,
snd_bic_info
,
swift_message_tree
,
extra
}
=
this
.
props
let
json
=
{
swift_message
,
rcv_bic_info
,
snd_bic_info
,
swift_message_tree
,
extra
}
let
jsonStr
=
JSON
.
stringify
(
json
)
return
jsonStr
}
componentWillMount
()
{
...
...
@@ -221,6 +265,7 @@ export class SWFPage extends Component
if
(
action
==
'edit'
)
{
let
mty
=
this
.
props
.
params
.
key
;
mty
=
mty
.
toLowerCase
()
if
(
mty
.
substring
(
0
,
2
)
!=
'mt'
)
...
...
@@ -249,6 +294,7 @@ export class SWFPage extends Component
this
.
props
.
actions
.
updateSndBic
({
snd_bic
:
sndbic
})
}
this
.
isdirect
=
false
}
else
if
(
action
==
'redit'
||
action
==
'redit2'
)
{
...
...
@@ -300,7 +346,7 @@ export class SWFPage extends Component
<
/Col
>
<
Col
span
=
{
8
}
>
<
SNDBIC
flag
=
{
flag2
}
snd_bic
=
{
snd_bic_info
.
snd_bic
}
err_msg
=
{
snd_bic_info
.
err_msg
}
onChange
=
{(
val
,
msg
)
=>
{
snd_bic_info
.
snd_bic
=
val
;
snd_bic_info
.
err_msg
=
msg
}}
/
>
<
SNDBIC
flag
=
{
true
}
snd_bic
=
{
window
.
BANK_BIC
}
err_msg
=
{
null
}
onChange
=
{(
val
,
msg
)
=>
{
snd_bic_info
.
snd_bic
=
val
;
snd_bic_info
.
err_msg
=
msg
}}
/
>
<
/Col
>
<
/Row
>
<
Row
style
=
{{}}
>
...
...
@@ -315,7 +361,7 @@ export class SWFPage extends Component
<Input placeholder="收报行BIC" maxLength={11} value={rcv_bic} onChange={e=>this.props.actions.updateRcvBic(e.target.value)}/>
}
</FormItem> */
}
<
RCVBIC
flag
=
{
f
lag1
}
rcv_bic
=
{
rcv_bic_info
.
rcv_bic
}
err_msg
=
{
rcv_bic_info
.
err_msg
}
onChange
=
{(
val
,
msg
)
=>
{
rcv_bic_info
.
rcv_bic
=
val
;
rcv_bic_info
.
err_msg
=
msg
}}
/
>
<
RCVBIC
flag
=
{
f
alse
}
rcv_bic
=
{
rcv_bic_info
.
rcv_bic
}
err_msg
=
{
rcv_bic_info
.
err_msg
}
onChange
=
{(
val
,
msg
)
=>
{
rcv_bic_info
.
rcv_bic
=
val
;
rcv_bic_info
.
err_msg
=
msg
}}
/
>
<
/Col
>
<
Col
span
=
{
10
}
/
>
<
Col
span
=
{
3
}
>
...
...
@@ -335,6 +381,11 @@ export class SWFPage extends Component
<
/div
>
:
null
}
<
TempSaver
getTemplateJSON
=
{
this
.
saveTemp
}
mty
=
{
mty
}
style
=
{{
marginRight
:
'1em'
,
width
:
'8em'
}}
/
>
<
br
/>
<
br
/>
{
!
this
.
isdirect
?
<
Popconfirm
placement
=
"topLeft"
title
=
{
"将丢失编辑的内容,确定返回?"
}
onConfirm
=
{()
=>
this
.
props
.
history
.
goBack
()}
>
...
...
src/swift/ServiceAPI.js
View file @
c5367b31
...
...
@@ -28,4 +28,12 @@ export default class ServiceAPI{
{
return
API
.
post
(
""
,{
params
:{
action
:
'savsf2'
},
data
})
}
static
saveTemplate
(
data
)
{
return
API
.
post
(
""
,{
params
:{
action
:
'savmtm'
},
data
})
}
static
getTemplate
(
sf2temp_inr
)
{
return
API
.
post
(
""
,{
params
:{
action
:
'getmtm'
,
sf2temp_inr
}})
}
}
src/swift/Tags/T61.js
View file @
c5367b31
...
...
@@ -47,6 +47,9 @@ export default class T61 extends Component
value
=
value
&&
value
.
length
?
value
[
0
]
:
{}
let
CD
=
[
'C'
,
'D'
,
'RC'
,
'RD'
]
if
(
this
.
props
.
mty
==
'mt608'
)
CD
=
[
'C'
,
'D'
]
return
(
<
div
>
...
...
@@ -90,10 +93,15 @@ export default class T61 extends Component
notFoundContent
=
"Wrong Code"
style
=
{{
width
:
"100%"
}}
value
=
{
value
.
s3
}
onChange
=
{
val
=>
this
.
onChange
(
3
,
val
)}
>
<
Option
value
=
"C"
>
C
<
/Option
>
{
/*
<Option value="C">C</Option>
<Option value="D">D</Option>
<Option value="RC">RC</Option>
<
Option
value
=
"RD"
>
RD
<
/Option
>
<Option value="RD">RD</Option>*/
}
{
CD
.
map
(
function
(
item
)
{
return
<
Option
value
=
{
item
}
key
=
{
item
}
>
{
item
}
<
/Option
>
})
}
<
/Select
>
<
/FormItem
>
<
/Col
>
...
...
src/swift/TemplateSave.js
0 → 100644
View file @
c5367b31
import
React
,{
Component
}
from
'react'
import
{
Button
,
Table
,
Modal
,
Row
,
Col
,
Form
,
Input
,
Icon
,
notification
}
from
'antd'
import
ServiceAPI
from
'./ServiceAPI'
const
createForm
=
Form
.
create
;
const
FormItem
=
Form
.
Item
;
const
formItemLayout
=
{
labelCol
:
{
span
:
6
},
wrapperCol
:
{
span
:
14
},
};
export
default
class
TemplateSaver
extends
Component
{
constructor
(
props
)
{
super
(
props
)
this
.
state
=
{
visible
:
false
,
loading
:
false
}
}
showModal
=
()
=>
{
this
.
setState
({
visible
:
true
,
});
}
handleOk
=
(
e
)
=>
{
//console.log(this.inp.getForm().submit())
this
.
inp
.
validateFields
((
errors
,
values
)
=>
{
if
(
!!
errors
)
{
console
.
log
(
'Errors in form!!!'
);
return
;
}
this
.
onSave
(
values
)
});
//.handleSubmit(e)
}
onSave
=
vals
=>
{
this
.
setState
({
loading
:
true
});
//调用模板保存API
let
tempJsn
=
this
.
props
.
getTemplateJSON
()
let
json
=
{...
vals
,
sf2temp
:
tempJsn
,
mty
:
this
.
props
.
mty
}
console
.
log
(
json
)
ServiceAPI
.
saveTemplate
(
json
).
then
(
data
=>
{
if
(
typeof
data
==
'string'
)
{
data
=
JSON
.
parse
(
data
)
}
if
(
data
.
errorCode
!==
'0000'
)
{
notification
.
error
({
description
:
'模板保存失败!'
,
message
:
'错误'
})
}
else
{
notification
.
success
({
description
:
'模板保存成功!'
,
message
:
'提示'
})
}
this
.
setState
({
loading
:
false
,
visible
:
false
});
}).
catch
(
err
=>
{
notification
.
error
({
description
:
'模板保存失败!'
,
message
:
'错误'
})
this
.
setState
({
loading
:
false
,
visible
:
false
});
})
}
handleCancel
=
()
=>
{
this
.
setState
({
visible
:
false
});
}
render
()
{
return
(
<
div
>
<
Button
style
=
{
this
.
props
.
style
}
icon
=
"save"
type
=
"primary"
onClick
=
{
this
.
showModal
}
>
Template
<
/Button
>
<
Modal
ref
=
"modal"
visible
=
{
this
.
state
.
visible
}
title
=
"保存模板"
onOk
=
{
this
.
handleOk
}
onCancel
=
{
this
.
handleCancel
}
footer
=
{[
<
Button
key
=
"back"
type
=
"ghost"
size
=
"large"
onClick
=
{
this
.
handleCancel
}
>
返
回
<
/Button>
,
<
Button
key
=
"submit"
type
=
"primary"
size
=
"large"
loading
=
{
this
.
state
.
loading
}
onClick
=
{
this
.
handleOk
}
>
提
交
<
/Button>
,
]}
>
<
TForm
ref
=
{
ref
=>
this
.
inp
=
ref
}
onSaveTemp
=
{
this
.
onSave
}
/
>
<
/Modal
>
<
/div
>
)
}
}
class
TempForm
extends
Component
{
handleSubmit
=
e
=>
{
e
.
preventDefault
();
this
.
props
.
form
.
validateFields
((
errors
,
values
)
=>
{
if
(
!!
errors
)
{
console
.
log
(
'Errors in form!!!'
);
return
;
}
this
.
props
.
onSaveTemp
(
values
)
});
}
handleReset
=
(
e
)
=>
{
e
.
preventDefault
();
this
.
props
.
form
.
resetFields
();
}
render
(){
const
{
getFieldProps
,
getFieldError
,
isFieldValidating
}
=
this
.
props
.
form
;
const
nameProps
=
getFieldProps
(
'nam'
,
{
rules
:
[
{
required
:
true
,
message
:
'填写模板名称'
},
],
});
const
textareaProps
=
getFieldProps
(
'txt'
,
{
rules
:
[
{
required
:
true
,
message
:
'填写报文备注'
},
],
});
return
(
<
Form
horizontal
form
=
{
this
.
props
.
form
}
>
<
FormItem
{...
formItemLayout
}
label
=
"模板名称"
hasFeedback
>
<
Input
name
=
"nam"
{...
nameProps
}
type
=
"text"
maxLength
=
{
10
}
placeholder
=
"onBlur 与 onChange 相结合"
/>
<
/FormItem
>
<
FormItem
{...
formItemLayout
}
label
=
"备注"
>
<
Input
{...
textareaProps
}
type
=
"textarea"
placeholder
=
"填写报文备注"
name
=
"txt"
/>
<
/FormItem
>
<
/Form
>
)
}
}
const
TForm
=
createForm
()(
TempForm
);
src/swift/Utils.js
View file @
c5367b31
...
...
@@ -8,10 +8,10 @@ export function DeepCopy(a)
export
function
getLogicAdress
(
bic
)
{
if
(
bic
.
length
==
11
)
{
return
bic
.
substring
(
0
,
8
)
+
"
A
"
+
bic
.
substring
(
8
,
11
);
return
bic
.
substring
(
0
,
8
)
+
"
X
"
+
bic
.
substring
(
8
,
11
);
}
if
(
bic
.
length
()
==
8
)
{
return
bic
+
"
A
XXX"
;
return
bic
+
"
X
XXX"
;
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment