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
Show 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 = {
...
@@ -7,11 +7,7 @@ let config = {
ajaxOption
:
{
ajaxOption
:
{
method
:
dev
?
'GET'
:
'POST'
,
method
:
dev
?
'GET'
:
'POST'
,
dataType
:
'json'
,
dataType
:
'json'
,
contentType
:
'application/json'
contentType
:
'application/x-www-form-urlencoded; charset=UTF-8'
// xhrFields: {
// withCredentials: true
// }
// contentType: 'application/x-www-form-urlencoded; charset=UTF-8'
},
},
token
:
{
token
:
{
...
@@ -47,12 +43,12 @@ let setUrlK = (o) => {
...
@@ -47,12 +43,12 @@ let setUrlK = (o) => {
})
})
return
params
return
params
}
}
export
function
requestAPI
(
option
,
data
)
{
//
export function requestAPI (option, data) {
//
let params = { data: JSON.stringify(data) }
//
let params = { data: JSON.stringify(data) }
return
ajax
.
requestAPI
(
option
,
data
)
// return ajax.requestAPI(option, params
)
}
//
}
export
function
request
WithJson
API
(
option
,
data
)
{
export
function
requestAPI
(
option
,
data
)
{
let
_option
=
Object
.
assign
({},
option
)
let
_option
=
Object
.
assign
({},
option
)
if
(
dev
&&
data
)
{
if
(
dev
&&
data
)
{
_option
.
url
+=
setUrlK
(
data
)
_option
.
url
+=
setUrlK
(
data
)
...
...
src/components/common/leaveMessage.vue
View file @
b41bb96d
...
@@ -39,20 +39,20 @@
...
@@ -39,20 +39,20 @@
<div
class=
"commentText"
>
<div
class=
"commentText"
>
<div
class=
"comment-title"
>
<div
class=
"comment-title"
>
{{
item
.
created_by
}}
{{
item
.
created_at
}}
{{
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>
<i
class=
"fa fa-fw fa-commenting-o pull-right"
></i>
</a>
</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>
<i
class=
"fa fa-fw fa-trash-o pull-right"
></i>
</a>
</a>
</div>
</div>
<div
class=
"date sub-text"
>
<div
class=
"date sub-text"
>
{{
item
.
description
}}
{{
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"
>
<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"
>
<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>
</span>
</div>
</div>
</form>
</form>
...
@@ -65,8 +65,8 @@
...
@@ -65,8 +65,8 @@
<div
class=
"commentText"
>
<div
class=
"commentText"
>
<div
class=
"comment-title"
>
<div
class=
"comment-title"
>
{{
sItem
.
created_by
}}
{{
sItem
.
created_at
}}
{{
sItem
.
created_by
}}
{{
sItem
.
created_at
}}
<a
href=
"#"
class=
"
addcomment
"
>
<a
href=
"#"
class=
"
removecomment"
@
click
.
prevent=
"del(sItem.id)
"
>
<i
class=
"fa fa-fw fa-
commenting
-o pull-right"
></i>
<i
class=
"fa fa-fw fa-
trash
-o pull-right"
></i>
</a>
</a>
</div>
</div>
<div
class=
"date sub-text"
>
<div
class=
"date sub-text"
>
...
@@ -87,21 +87,25 @@
...
@@ -87,21 +87,25 @@
</
template
>
</
template
>
<
script
>
<
script
>
import
{
import
{
request
WithJson
API
,
requestAPI
,
api
api
}
from
'@/lib/commonMixin'
}
from
'@/lib/commonMixin'
import
{
setModule
}
from
'@/lib/viewHelper'
export
default
{
export
default
{
data
()
{
data
()
{
return
{
return
{
is
:
false
,
is
:
false
,
sendText
:
''
,
sendText
:
''
,
secondTextBool
:
{},
secondArrayText
:
{},
model
:
{},
model
:
{},
result
:
{}
result
:
{}
}
}
},
},
props
:
{
props
:
{
lmTemplate
:
Array
lmTemplate
:
Array
,
type
:
Number
},
},
mounted
()
{
mounted
()
{
...
@@ -120,29 +124,70 @@ export default {
...
@@ -120,29 +124,70 @@ export default {
}
}
},
},
showSecondText
(
id
)
{
Object
.
keys
(
this
.
secondTextBool
).
forEach
(
item
=>
{
this
.
secondTextBool
[
item
]
=
false
})
this
.
secondTextBool
[
id
]
=
true
},
send
()
{
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
)
=>
{
.
then
((
res
)
=>
{
console
.
log
(
res
)
this
.
secondTextBool
=
{}
this
.
secondArrayText
=
{}
this
.
init
()
})
})
},
},
del
()
{
del
(
id
)
{
requestWithJsonAPI
(
api
.
deleteComment
)
let
params
=
{
id
}
requestAPI
(
api
.
deleteComment
,
params
)
.
then
((
res
)
=>
{
.
then
((
res
)
=>
{
console
.
log
(
res
)
this
.
init
(
)
})
})
},
},
init
()
{
init
()
{
let
vm
=
this
let
params
=
{
let
params
=
{
object_type
:
9
,
object_type
:
this
.
type
,
object_id
:
7578
object_id
:
this
.
model
.
id
}
}
request
WithJson
API
(
api
.
getCommentList
,
params
)
requestAPI
(
api
.
getCommentList
,
params
)
.
then
((
res
)
=>
{
.
then
((
res
)
=>
{
res
.
list
.
forEach
(
item
=>
{
vm
.
$set
(
this
.
secondTextBool
,
item
.
id
.
toString
(),
false
)
vm
.
$set
(
this
.
secondArrayText
,
item
.
id
.
toString
(),
''
)
})
this
.
result
=
res
this
.
result
=
res
console
.
log
(
res
)
})
})
}
}
}
}
...
...
src/components/schedule_list/scheduleHome.vue
View file @
b41bb96d
...
@@ -32,7 +32,8 @@
...
@@ -32,7 +32,8 @@
</Pagenation>
</Pagenation>
<leave-message
<leave-message
ref=
"leaveMessage"
ref=
"leaveMessage"
:lmTemplate=
"lmTemplate"
>
:lmTemplate=
"lmTemplate"
:type=
"9"
>
</leave-message>
</leave-message>
</div>
</div>
</div>
</div>
...
@@ -48,7 +49,7 @@ import ScheduleModal from '../schedule/scheduleModal'
...
@@ -48,7 +49,7 @@ import ScheduleModal from '../schedule/scheduleModal'
import
LeaveMessage
from
'../common/leaveMessage'
import
LeaveMessage
from
'../common/leaveMessage'
import
Pagenation
from
'./schedulePagenation'
import
Pagenation
from
'./schedulePagenation'
import
{
import
{
request
WithJson
API
,
requestAPI
,
api
api
}
from
'@/lib/commonMixin'
}
from
'@/lib/commonMixin'
export
default
{
export
default
{
...
@@ -141,7 +142,7 @@ export default {
...
@@ -141,7 +142,7 @@ export default {
},
},
getFilter
()
{
getFilter
()
{
request
WithJson
API
(
api
.
getScheduleFilter
).
then
(
res
=>
{
requestAPI
(
api
.
getScheduleFilter
).
then
(
res
=>
{
this
.
filter
=
res
this
.
filter
=
res
})
})
},
},
...
@@ -164,7 +165,7 @@ export default {
...
@@ -164,7 +165,7 @@ export default {
cancelButtonText
:
'取消'
,
cancelButtonText
:
'取消'
,
type
:
'warning'
type
:
'warning'
}).
then
(()
=>
{
}).
then
(()
=>
{
request
WithJson
API
(
api
.
deleteSchedule
)
requestAPI
(
api
.
deleteSchedule
)
.
then
((
res
)
=>
{
.
then
((
res
)
=>
{
console
.
log
(
res
)
console
.
log
(
res
)
})
})
...
@@ -174,7 +175,7 @@ export default {
...
@@ -174,7 +175,7 @@ export default {
},
},
getScheduleList
()
{
getScheduleList
()
{
request
WithJson
API
(
api
.
getScheduleList
)
requestAPI
(
api
.
getScheduleList
)
.
then
((
res
)
=>
{
.
then
((
res
)
=>
{
const
{
const
{
list
=
[],
list
=
[],
...
...
src/lib/viewHelper.js
View file @
b41bb96d
...
@@ -21,3 +21,20 @@ export function removeEmptyMemberArray (arr) {
...
@@ -21,3 +21,20 @@ export function removeEmptyMemberArray (arr) {
})
})
return
newArr
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