Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bms-vue-obear
Project
Project
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
daywrite
bms-vue-obear
Commits
3d979067
Commit
3d979067
authored
Apr 20, 2019
by
daywrite
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
费用报销新建编辑成功
parent
22065a4e
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
127 additions
and
35 deletions
+127
-35
api_old.js
src/api_old.js
+33
-0
reimbursement.js
src/apis/reimbursement.js
+3
-0
reimbursementForm.vue
src/components/reimbursement/reimbursementForm.vue
+12
-0
reimbursementModal.vue
src/components/reimbursement/reimbursementModal.vue
+11
-2
reimbursementHome.vue
src/components/reimbursement_list/reimbursementHome.vue
+10
-1
commonMixin.js
src/lib/commonMixin.js
+1
-0
request.js
src/lib/request.js
+42
-29
viewHelper.js
src/lib/viewHelper.js
+15
-3
No files found.
src/api_old.js
0 → 100644
View file @
3d979067
import
ScheduleApi
from
'./apis/schedule.js'
import
ReimburrsementApi
from
'./apis/reimbursement.js'
const
usingJSONP
=
process
.
env
.
NODE_ENV
!==
'production'
const
API_HOST
=
process
.
env
.
API_HOST
const
API_PORT
=
process
.
env
.
API_PORT
const
JANUS_HOST
=
process
.
env
.
JANUS_HOST
const
JANUS_PORT
=
process
.
env
.
JANUS_PORT
const
option
=
{
tokenKey
:
'__token__'
,
sessionExpiredCode
:
401
,
loginUrl
:
'/logout.php'
,
host
:
API_HOST
,
port
:
API_PORT
,
hostJanus
:
JANUS_HOST
,
portJanus
:
JANUS_PORT
,
baseUrl
:
''
,
ajax
:
{
method
:
usingJSONP
?
'GET'
:
'POST'
,
dataType
:
'json'
,
getQuery
:
usingJSONP
?
'?duplextrans'
:
''
,
contentType
:
'application/x-www-form-urlencoded; charset=UTF-8'
}
}
let
apis
=
{}
apis
=
Object
.
assign
(
apis
,
ScheduleApi
)
apis
=
Object
.
assign
(
apis
,
ReimburrsementApi
)
export
default
{
option
,
...
apis
}
src/apis/reimbursement.js
View file @
3d979067
...
...
@@ -16,5 +16,8 @@ export default {
},
saveEditReim
:
{
url
:
'/vue/reimbursement/save-edit'
},
deleteReim
:
{
url
:
'/vue/reimbursement/delete'
}
}
src/components/reimbursement/reimbursementForm.vue
View file @
3d979067
...
...
@@ -20,6 +20,8 @@
size=
"small"
v-model=
"model.occurrence_at"
type=
"datetime"
value-format=
"yyyy-MM-dd HH:mm:ss"
@
change=
"occurrenceAtChange"
placeholder=
"选择日期时间"
>
</el-date-picker>
</el-form-item>
...
...
@@ -28,6 +30,8 @@
size=
"small"
v-model=
"model.settle_accounts_at"
type=
"datetime"
value-format=
"yyyy-MM-dd HH:mm:ss"
@
change=
"settleAccountsAtChange"
placeholder=
"选择日期时间"
>
</el-date-picker>
</el-form-item>
...
...
@@ -147,6 +151,14 @@ export default {
},
methods
:
{
occurrenceAtChange
(
val
)
{
this
.
model
.
occurrence_at
=
val
},
settleAccountsAtChange
(
val
)
{
this
.
model
.
settle_accounts_at
=
val
},
getProjectArray
(
id
)
{
requestAPI
(
api
.
searchProjectByClientId
,
{
client_id
:
id
...
...
src/components/reimbursement/reimbursementModal.vue
View file @
3d979067
...
...
@@ -38,6 +38,7 @@ export default {
client_name
:
''
,
// 客户
form_reimbursementVerifyRels
:
[],
form_reimbursementCarbonCopyRels
:
[],
settle_accounts_by
:
''
,
description
:
''
,
project_id
:
''
,
attachmentFiles
:
[]
...
...
@@ -47,7 +48,15 @@ export default {
methods
:
{
show
(
model
)
{
model
&&
UTIL
.
flatten
(
this
.
model
,
model
)
if
(
model
)
{
UTIL
.
flatten
(
this
.
model
,
model
)
this
.
model
.
form_type
=
model
.
type
.
id
this
.
model
.
form_costType
=
model
.
costType
.
id
this
.
model
.
client_name
=
model
.
client
.
name
this
.
model
.
form_reimbursementVerifyRels
=
model
.
reimbursementVerifyRels
.
map
(
item
=>
item
.
user_id
)
this
.
model
.
form_reimbursementCarbonCopyRels
=
model
.
reimbursementCarbonCopyRels
.
map
(
item
=>
item
.
user_id
)
this
.
model
.
settle_accounts_by
=
model
.
settleAccountsBy
.
id
}
this
.
$refs
.
sidePopup
.
show
()
},
...
...
@@ -69,7 +78,7 @@ export default {
console
.
log
(
_params
)
requestAPI
(
Object
.
assign
(
_apiUrl
,
{
method
:
'POST'
}),
_params
)
.
then
((
res
)
=>
{
this
.
$refs
.
s
cheduleS
idePopup
.
close
()
this
.
$refs
.
sidePopup
.
close
()
this
.
$message
.
success
(
'操作成功'
)
})
}
...
...
src/components/reimbursement_list/reimbursementHome.vue
View file @
3d979067
...
...
@@ -167,6 +167,14 @@ export default {
this
.
getFilter
()
},
_reload
()
{
let
params
=
this
.
setParams
({
...
this
.
form
,
page
:
this
.
pagenation
.
thispage
},
{})
this
.
getList
(
params
)
},
timeSearchForm
(
search
)
{
let
params
=
this
.
setParams
({
...
this
.
form
,
...
...
@@ -230,8 +238,9 @@ export default {
cancelButtonText
:
'取消'
,
type
:
'warning'
}).
then
(()
=>
{
requestAPI
(
api
.
delete
Schedule
,
{
id
})
requestAPI
(
api
.
delete
Reim
,
{
id
})
.
then
((
res
)
=>
{
this
.
_reload
()
this
.
$message
.
success
(
'删除成功'
)
})
}).
catch
(()
=>
{
...
...
src/lib/commonMixin.js
View file @
3d979067
// request
export
{
requestAPI
,
requestWithJsonAPI
}
from
'../ajax'
export
{
requestOAPI
}
from
'./request'
export
{
requestJanusAPI
}
from
'../ajax-janus'
export
{
default
as
api
}
from
'@/api'
export
{
default
as
UTIL
}
from
'./util'
src/lib/request.js
View file @
3d979067
import
api
from
'../api'
import
api
from
'../api
_old
'
import
$
from
'jquery'
import
Cookie
from
'browser-cookie'
//
import Cookie from 'browser-cookie'
let
globalOpt
=
api
.
option
const
SESSION_EXPIRED_CODE
=
globalOpt
.
sessionExpiredCode
const
SUCCESS_CODE
=
200
const
SUCCESS_CODE
=
200
0
const
HTTP_PROTOCOL
=
/^http
[
s
]?
:
\/\/
/
// const usingJSONP = false
const
usingJSONP
=
process
.
env
.
NODE_ENV
!==
'production'
function
normalizeUrl
(
url
,
query
,
option
)
{
if
(
HTTP_PROTOCOL
.
test
(
url
))
return
url
...
...
@@ -23,7 +24,6 @@ function normalizeUrl (url, query, option) {
fullUrl
+=
url
if
(
Object
.
keys
(
query
).
length
>
0
)
{
fullUrl
+=
'?'
+
$
.
param
(
query
)
console
.
log
(
fullUrl
)
}
return
fullUrl
...
...
@@ -32,6 +32,7 @@ function normalizeUrl (url, query, option) {
function
mergeAjaxOption
(...
options
)
{
let
option1
=
options
.
shift
()
let
option2
=
options
.
shift
()
console
.
log
(
option1
,
option2
)
let
query
=
{...
option1
.
query
,
...
option2
.
query
}
let
data
=
{...
option1
.
data
,
...
option2
.
data
}
let
headers
=
{...
option1
.
headers
,
...
option2
.
headers
}
...
...
@@ -62,13 +63,13 @@ export function request (option) {
resolve
(
res
.
result
)
}
else
{
// 如果不执行 reject,可能加载中动画不被关闭
reject
(
res
.
result
,
xhr
,
null
)
reject
(
res
,
xhr
,
null
)
if
(
res
.
msg
)
{
// 先让界面变化
setTimeout
(
function
()
{
window
.
alert
(
res
.
msg
)
},
300
)
//
setTimeout(function () {
//
window.alert(res.msg)
//
}, 300)
}
}
},
function
(
xhr
,
status
,
error
)
{
...
...
@@ -93,13 +94,13 @@ export function request (option) {
})
}
function
getTokenFromCookie
()
{
let
cookie
=
new
Cookie
()
return
cookie
.
get
(
'vup_token'
)
}
//
function getTokenFromCookie () {
//
let cookie = new Cookie()
//
return cookie.get('vup_token')
//
}
let
isSessionExpired
=
false
export
function
requestAPI
(
api
,
option
=
{})
{
export
function
request
O
API
(
api
,
option
=
{})
{
// 第一个请求会放过期提示用户登录后,避免之后的其他请求再次弹消息
if
(
isSessionExpired
)
{
window
.
location
.
href
=
globalOpt
.
loginUrl
...
...
@@ -107,7 +108,13 @@ export function requestAPI (api, option = {}) {
resolve
({})
})
}
let
setUrlK
=
(
ojson
)
=>
{
let
params
=
''
Object
.
keys
(
ojson
).
forEach
(
item
=>
{
params
+=
'&'
+
encodeURIComponent
(
item
)
+
'='
+
ojson
[
item
]
})
return
params
}
// merge option
let
ajaxOption
=
mergeAjaxOption
(
globalOpt
.
ajax
,
// global
...
...
@@ -116,11 +123,17 @@ export function requestAPI (api, option = {}) {
)
ajaxOption
.
url
=
normalizeUrl
(
ajaxOption
.
url
,
ajaxOption
.
query
,
globalOpt
)
delete
ajaxOption
.
query
if
(
usingJSONP
)
{
ajaxOption
.
url
=
ajaxOption
.
url
+
ajaxOption
.
getQuery
if
(
ajaxOption
.
data
)
{
ajaxOption
.
url
+=
setUrlK
(
ajaxOption
.
data
)
delete
ajaxOption
.
data
}
}
// ajaxOption.contentType = 'application/json'
// ajaxOption.dataType = 'json'
// ajaxOption.data = JSON.stringify(ajaxOption.data)
ajaxOption
.
data
=
{
data
:
JSON
.
stringify
(
ajaxOption
.
data
)}
//
ajaxOption.data = {data: JSON.stringify(ajaxOption.data)}
// stringify object member of data
let
data
=
ajaxOption
.
data
...
...
@@ -132,20 +145,20 @@ export function requestAPI (api, option = {}) {
}
// check is session expired
let
token
=
getTokenFromCookie
()
if
(
!
token
&&
process
.
env
.
NODE_ENV
===
'production'
)
{
console
.
info
(
'token expired'
)
isSessionExpired
=
true
window
.
alert
(
'登录超时,请重新登录!'
)
window
.
location
.
href
=
globalOpt
.
loginUrl
return
new
Promise
(
function
(
resolve
,
reject
)
{
resolve
({})
})
}
//
let token = getTokenFromCookie()
//
if (!token && process.env.NODE_ENV === 'production') {
//
console.info('token expired')
//
isSessionExpired = true
//
window.alert('登录超时,请重新登录!')
//
window.location.href = globalOpt.loginUrl
//
return new Promise(function (resolve, reject) {
//
resolve({})
//
})
//
}
// append token to header
let
headers
=
ajaxOption
.
headers
||
(
ajaxOption
.
headers
=
{})
headers
[
'X-Token'
]
=
token
//
let headers = ajaxOption.headers || (ajaxOption.headers = {})
//
headers['X-Token'] = token
return
request
(
ajaxOption
)
}
src/lib/viewHelper.js
View file @
3d979067
...
...
@@ -21,12 +21,24 @@ export function removeEmptyMemberArray (arr) {
})
return
newArr
}
export
let
setModule
=
(
obj
,
key
)
=>
{
export
let
setModule
=
(
obj
,
key
,
options
)
=>
{
let
ob
=
{}
console
.
log
(
options
)
Object
.
keys
(
obj
).
forEach
((
item
)
=>
{
// ob[key + '[' + item + ']'] = obj[item]
if
(
Array
.
isArray
(
obj
[
item
]))
{
ob
[
key
+
'['
+
item
+
']'
]
=
obj
[
item
]
let
opt
=
options
&&
options
.
find
(
i
=>
key
+
'['
+
item
+
']'
===
i
.
key
)
console
.
log
(
opt
)
obj
[
item
].
forEach
((
arr
,
index
)
=>
{
if
(
arr
.
key
)
{
if
(
arr
.
key
===
'new'
)
{
ob
[
key
+
'['
+
item
+
']['
+
arr
.
key
+
'][]'
]
=
arr
.
name
}
else
{
ob
[
key
+
'['
+
item
+
']['
+
arr
.
key
+
']'
]
=
arr
.
name
}
}
else
{
ob
[
key
+
'['
+
item
+
']['
+
index
+
']'
]
=
arr
}
})
}
else
{
ob
[
key
+
'['
+
item
+
']'
]
=
obj
[
item
]
}
...
...
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