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
b41bb96d
Commit
b41bb96d
authored
Mar 21, 2019
by
huai.li
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改留言模块请求方式
parent
55179ae6
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
92 additions
and
33 deletions
+92
-33
ajax.js
src/ajax.js
+6
-10
leaveMessage.vue
src/components/common/leaveMessage.vue
+63
-18
scheduleHome.vue
src/components/schedule_list/scheduleHome.vue
+6
-5
viewHelper.js
src/lib/viewHelper.js
+17
-0
No files found.
src/ajax.js
View file @
b41bb96d
...
...
@@ -7,11 +7,7 @@ let config = {
ajaxOption
:
{
method
:
dev
?
'GET'
:
'POST'
,
dataType
:
'json'
,
contentType
:
'application/json'
// xhrFields: {
// withCredentials: true
// }
// contentType: 'application/x-www-form-urlencoded; charset=UTF-8'
contentType
:
'application/x-www-form-urlencoded; charset=UTF-8'
},
token
:
{
...
...
@@ -47,12 +43,12 @@ let setUrlK = (o) => {
})
return
params
}
export
function
requestAPI
(
option
,
data
)
{
//
let params = { data: JSON.stringify(data) }
return
ajax
.
requestAPI
(
option
,
data
)
}
//
export function requestAPI (option, data) {
//
let params = { data: JSON.stringify(data) }
// return ajax.requestAPI(option, params
)
//
}
export
function
request
WithJson
API
(
option
,
data
)
{
export
function
requestAPI
(
option
,
data
)
{
let
_option
=
Object
.
assign
({},
option
)
if
(
dev
&&
data
)
{
_option
.
url
+=
setUrlK
(
data
)
...
...
src/components/common/leaveMessage.vue
View file @
b41bb96d
...
...
@@ -39,20 +39,20 @@
<div
class=
"commentText"
>
<div
class=
"comment-title"
>
{{
item
.
created_by
}}
{{
item
.
created_at
}}
<a
href=
"#"
class=
"addcomment"
>
<a
href=
"#"
class=
"addcomment"
@
click
.
prevent=
"showSecondText(item.id.toString())"
>
<i
class=
"fa fa-fw fa-commenting-o pull-right"
></i>
</a>
<a
href=
"#"
class=
"removecomment"
>
<a
href=
"#"
class=
"removecomment"
@
click
.
prevent=
"del(item.id)"
>
<i
class=
"fa fa-fw fa-trash-o pull-right"
></i>
</a>
</div>
<div
class=
"date sub-text"
>
{{
item
.
description
}}
<form
class=
"form-inline form-comment"
role=
"form"
>
<form
class=
"form-inline form-comment"
role=
"form"
v-show=
"secondTextBool[item.id.toString()]"
>
<div
class=
"input-group"
>
<input
type=
"text"
class=
"form-control form-control-sm comment-input"
placeholder=
""
>
<input
type=
"text"
v-model=
"secondArrayText[item.id.toString()]"
class=
"form-control form-control-sm comment-input"
placeholder=
""
>
<span
class=
"input-group-btn"
>
<el-button
size=
"mini"
@
click
.
prevent=
"
send
"
>
回复
</el-button>
<el-button
size=
"mini"
@
click
.
prevent=
"
recover(item.id)
"
>
回复
</el-button>
</span>
</div>
</form>
...
...
@@ -65,8 +65,8 @@
<div
class=
"commentText"
>
<div
class=
"comment-title"
>
{{
sItem
.
created_by
}}
{{
sItem
.
created_at
}}
<a
href=
"#"
class=
"
addcomment
"
>
<i
class=
"fa fa-fw fa-
commenting
-o pull-right"
></i>
<a
href=
"#"
class=
"
removecomment"
@
click
.
prevent=
"del(sItem.id)
"
>
<i
class=
"fa fa-fw fa-
trash
-o pull-right"
></i>
</a>
</div>
<div
class=
"date sub-text"
>
...
...
@@ -87,21 +87,25 @@
</
template
>
<
script
>
import
{
request
WithJson
API
,
requestAPI
,
api
}
from
'@/lib/commonMixin'
import
{
setModule
}
from
'@/lib/viewHelper'
export
default
{
data
()
{
return
{
is
:
false
,
sendText
:
''
,
secondTextBool
:
{},
secondArrayText
:
{},
model
:
{},
result
:
{}
}
},
props
:
{
lmTemplate
:
Array
lmTemplate
:
Array
,
type
:
Number
},
mounted
()
{
...
...
@@ -120,29 +124,70 @@ export default {
}
},
showSecondText
(
id
)
{
Object
.
keys
(
this
.
secondTextBool
).
forEach
(
item
=>
{
this
.
secondTextBool
[
item
]
=
false
})
this
.
secondTextBool
[
id
]
=
true
},
send
()
{
requestWithJsonAPI
(
api
.
saveNewComment
)
if
(
this
.
sendText
.
trim
()
===
''
)
{
this
.
$message
.
warning
(
'请输入留言'
)
return
}
let
params
=
{}
params
.
object_id
=
this
.
model
.
id
params
.
object_type
=
this
.
type
params
.
description
=
this
.
sendText
let
_params
=
Object
.
assign
({},
setModule
(
params
,
'Comments'
))
requestAPI
(
api
.
saveNewComment
,
_params
)
.
then
((
res
)
=>
{
this
.
sendText
=
''
this
.
init
()
})
},
recover
(
id
)
{
if
(
this
.
secondArrayText
[
id
.
toString
()].
trim
()
===
''
)
{
this
.
$message
.
warning
(
'请输入留言'
)
return
}
let
params
=
{}
params
.
object_id
=
this
.
model
.
id
params
.
object_type
=
this
.
type
params
.
description
=
this
.
secondArrayText
[
id
.
toString
()].
trim
()
params
.
parent
=
id
let
_params
=
Object
.
assign
({},
setModule
(
params
,
'Comments'
))
requestAPI
(
api
.
saveNewComment
,
_params
)
.
then
((
res
)
=>
{
console
.
log
(
res
)
this
.
secondTextBool
=
{}
this
.
secondArrayText
=
{}
this
.
init
()
})
},
del
()
{
requestWithJsonAPI
(
api
.
deleteComment
)
del
(
id
)
{
let
params
=
{
id
}
requestAPI
(
api
.
deleteComment
,
params
)
.
then
((
res
)
=>
{
console
.
log
(
res
)
this
.
init
(
)
})
},
init
()
{
let
vm
=
this
let
params
=
{
object_type
:
9
,
object_id
:
7578
object_type
:
this
.
type
,
object_id
:
this
.
model
.
id
}
request
WithJson
API
(
api
.
getCommentList
,
params
)
requestAPI
(
api
.
getCommentList
,
params
)
.
then
((
res
)
=>
{
res
.
list
.
forEach
(
item
=>
{
vm
.
$set
(
this
.
secondTextBool
,
item
.
id
.
toString
(),
false
)
vm
.
$set
(
this
.
secondArrayText
,
item
.
id
.
toString
(),
''
)
})
this
.
result
=
res
console
.
log
(
res
)
})
}
}
...
...
src/components/schedule_list/scheduleHome.vue
View file @
b41bb96d
...
...
@@ -32,7 +32,8 @@
</Pagenation>
<leave-message
ref=
"leaveMessage"
:lmTemplate=
"lmTemplate"
>
:lmTemplate=
"lmTemplate"
:type=
"9"
>
</leave-message>
</div>
</div>
...
...
@@ -48,7 +49,7 @@ import ScheduleModal from '../schedule/scheduleModal'
import
LeaveMessage
from
'../common/leaveMessage'
import
Pagenation
from
'./schedulePagenation'
import
{
request
WithJson
API
,
requestAPI
,
api
}
from
'@/lib/commonMixin'
export
default
{
...
...
@@ -141,7 +142,7 @@ export default {
},
getFilter
()
{
request
WithJson
API
(
api
.
getScheduleFilter
).
then
(
res
=>
{
requestAPI
(
api
.
getScheduleFilter
).
then
(
res
=>
{
this
.
filter
=
res
})
},
...
...
@@ -164,7 +165,7 @@ export default {
cancelButtonText
:
'取消'
,
type
:
'warning'
}).
then
(()
=>
{
request
WithJson
API
(
api
.
deleteSchedule
)
requestAPI
(
api
.
deleteSchedule
)
.
then
((
res
)
=>
{
console
.
log
(
res
)
})
...
...
@@ -174,7 +175,7 @@ export default {
},
getScheduleList
()
{
request
WithJson
API
(
api
.
getScheduleList
)
requestAPI
(
api
.
getScheduleList
)
.
then
((
res
)
=>
{
const
{
list
=
[],
...
...
src/lib/viewHelper.js
View file @
b41bb96d
...
...
@@ -21,3 +21,20 @@ export function removeEmptyMemberArray (arr) {
})
return
newArr
}
export
let
setModule
=
(
obj
,
key
)
=>
{
let
ob
=
{}
Object
.
keys
(
obj
).
forEach
((
item
)
=>
{
if
(
Array
.
isArray
(
obj
[
item
]))
{
obj
[
item
].
forEach
(
arr
=>
{
if
(
arr
.
key
===
'new'
)
{
ob
[
key
+
'['
+
item
+
']['
+
arr
.
key
+
'][]'
]
=
arr
.
name
}
else
{
ob
[
key
+
'['
+
item
+
']['
+
arr
.
key
+
']'
]
=
arr
.
name
}
})
}
else
{
ob
[
key
+
'['
+
item
+
']'
]
=
obj
[
item
]
}
})
return
ob
}
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