Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
sun
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
钟尚武
sun
Commits
51e1a750
Commit
51e1a750
authored
Nov 17, 2018
by
Davve
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pick接口调通
parent
938e4cf3
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
397 additions
and
208 deletions
+397
-208
pick.py
api/pick.py
+8
-7
search.py
api/search.py
+54
-0
urls.py
api/urls.py
+18
-10
webpack.base.conf.js
vu/buildconfig/webpack.base.conf.js
+0
-1
proxy.js
vu/mock/proxy.js
+1
-1
package.json
vu/package.json
+1
-0
account.js
vu/src/api/account.js
+1
-1
group.js
vu/src/api/group.js
+0
-1
login.js
vu/src/api/login.js
+1
-0
pick.js
vu/src/api/pick.js
+1
-1
remoteSearch.js
vu/src/api/remoteSearch.js
+16
-0
index.js
vu/src/utils/index.js
+65
-31
PickDetail.vue
vu/src/views/pick/components/PickDetail.vue
+223
-153
list.vue
vu/src/views/pick/list.vue
+8
-2
No files found.
api/pick.py
View file @
51e1a750
...
@@ -40,13 +40,14 @@ class UpdateOrCreateView(APIView):
...
@@ -40,13 +40,14 @@ class UpdateOrCreateView(APIView):
def
post
(
self
,
request
):
def
post
(
self
,
request
):
data
=
{
data
=
{
'name'
:
request
.
POST
.
get
(
' name'
),
'name'
:
request
.
POST
.
get
(
'name'
),
'desc'
:
request
.
POST
.
get
(
' desc'
),
'desc'
:
request
.
POST
.
get
(
'desc'
),
'gender'
:
request
.
POST
.
get
(
' gender'
),
'gender'
:
request
.
POST
.
get
(
'gender'
),
'region'
:
request
.
POST
.
get
(
' region'
),
'region'
:
list
(
set
(
request
.
POST
.
get
(
'region'
,
''
)
.
split
(
','
))),
'pick_type'
:
request
.
POST
.
get
(
' pick_type'
),
'pick_type'
:
request
.
POST
.
get
(
'pick_type'
),
'position'
:
request
.
POST
.
get
(
' position'
),
'pick_group'
:
list
(
set
(
request
.
POST
.
get
(
'pick_group'
,
''
)
.
split
(
','
))),
'is_online'
:
request
.
POST
.
get
(
' is_online'
),
'position'
:
request
.
POST
.
get
(
'position'
),
'is_online'
:
request
.
POST
.
get
(
'is_online'
),
}
}
try
:
try
:
self
.
rpc
[
'venus/community/pick/update_or_create'
](
data
=
data
)
.
unwrap
()
self
.
rpc
[
'venus/community/pick/update_or_create'
](
data
=
data
)
.
unwrap
()
...
...
api/search.py
0 → 100644
View file @
51e1a750
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# __author__ = "chenwei"
# Date: 2018/11/17
from
utils.base
import
APIView
class
GroupSearchView
(
APIView
):
def
get
(
self
,
request
):
name
=
request
.
GET
.
get
(
'name'
)
print
(
name
,
'0------'
)
try
:
pass
except
Exception
as
e
:
raise
e
return
{
'total'
:
100
,
'data'
:
[
{
'name'
:
'小组1'
,
'id'
:
1
},
{
'name'
:
'小组2'
,
'id'
:
2
},
{
'name'
:
'小组3'
,
'id'
:
3
},
{
'name'
:
'小组4'
,
'id'
:
4
},
{
'name'
:
'小组5'
,
'id'
:
5
},
{
'name'
:
'小组6'
,
'id'
:
6
},
]
}
class
RegionSearchView
(
APIView
):
def
get
(
self
,
request
):
name
=
request
.
GET
.
get
(
'name'
)
print
(
request
.
GET
)
try
:
pass
except
Exception
as
e
:
raise
e
return
{
'total'
:
100
,
'data'
:
[
{
'name'
:
'北京'
,
'id'
:
1
},
{
'name'
:
'上海'
,
'id'
:
2
},
{
'name'
:
'深圳'
,
'id'
:
3
},
{
'name'
:
'武汉'
,
'id'
:
4
},
{
'name'
:
'成都'
,
'id'
:
5
},
{
'name'
:
'宁波'
,
'id'
:
6
},
]
}
class
UserSearchView
(
APIView
):
def
get
(
self
,
request
):
pass
\ No newline at end of file
api/urls.py
View file @
51e1a750
...
@@ -13,17 +13,18 @@ from .user import *
...
@@ -13,17 +13,18 @@ from .user import *
from
.topic
import
*
from
.topic
import
*
from
.star
import
*
from
.star
import
*
from
.account
import
*
from
.account
import
*
from
.search
import
*
urlpatterns
=
[
urlpatterns
=
[
# 登陆,注销相关
# 登陆,注销相关
url
(
r'account/login$'
,
LoginView
.
as_view
()),
url
(
r'account/login$'
,
LoginView
.
as_view
()),
url
(
r'account/logout'
,
LogoutView
.
as_view
()),
url
(
r'account/logout
$
'
,
LogoutView
.
as_view
()),
url
(
r'account/get'
,
LoginView
.
as_view
()),
url
(
r'account/get
$
'
,
LoginView
.
as_view
()),
url
(
r'account/list'
,
AccountList
.
as_view
()),
url
(
r'account/list
$
'
,
AccountList
.
as_view
()),
url
(
r'account/list/update'
,
AccountList
.
as_view
()),
url
(
r'account/list/update
$
'
,
AccountList
.
as_view
()),
url
(
r'account/detail'
,
AccountUpdateOrCreateView
.
as_view
()),
url
(
r'account/detail
$
'
,
AccountUpdateOrCreateView
.
as_view
()),
url
(
r'account/create'
,
AccountUpdateOrCreateView
.
as_view
()),
url
(
r'account/create
$
'
,
AccountUpdateOrCreateView
.
as_view
()),
# user相关
# user相关
url
(
r'user/list$'
,
UserListView
.
as_view
()),
url
(
r'user/list$'
,
UserListView
.
as_view
()),
...
@@ -44,6 +45,14 @@ urlpatterns = [
...
@@ -44,6 +45,14 @@ urlpatterns = [
url
(
r'pick/list$'
,
PickListView
.
as_view
()),
url
(
r'pick/list$'
,
PickListView
.
as_view
()),
url
(
r'pick/list/update$'
,
PickListView
.
as_view
()),
url
(
r'pick/list/update$'
,
PickListView
.
as_view
()),
url
(
r'pick/create'
,
UpdateOrCreateView
.
as_view
()),
url
(
r'pick/create$'
,
UpdateOrCreateView
.
as_view
()),
url
(
r'pick/detail'
,
UpdateOrCreateView
.
as_view
()),
url
(
r'pick/detail/'
,
UpdateOrCreateView
.
as_view
()),
]
]
\ No newline at end of file
searchurlpatterns
=
[
url
(
r'search/group$'
,
GroupSearchView
.
as_view
()),
url
(
r'search/region'
,
RegionSearchView
.
as_view
()),
url
(
r'search/user'
,
UserSearchView
.
as_view
()),
]
urlpatterns
+=
searchurlpatterns
vu/buildconfig/webpack.base.conf.js
View file @
51e1a750
...
@@ -9,7 +9,6 @@ function resolve(dir) {
...
@@ -9,7 +9,6 @@ function resolve(dir) {
return
path
.
join
(
__dirname
,
'..'
,
dir
)
return
path
.
join
(
__dirname
,
'..'
,
dir
)
}
}
module
.
exports
=
{
module
.
exports
=
{
context
:
path
.
resolve
(
__dirname
,
'../'
),
context
:
path
.
resolve
(
__dirname
,
'../'
),
entry
:
{
entry
:
{
...
...
vu/mock/proxy.js
View file @
51e1a750
var
api
=
require
(
'./api'
)
var
api
=
require
(
'./api'
)
//
// const target = 'http://doctor.test.env'
// const target = 'http://doctor.test.env'
const
target
=
'http://172.30.8.231:8000'
const
target
=
'http://172.30.8.231:8000'
// const target = 'http://192.168.1.6:8000'
// const target = 'http://192.168.1.6:8000'
...
...
vu/package.json
View file @
51e1a750
...
@@ -47,6 +47,7 @@
...
@@ -47,6 +47,7 @@
"js-cookie"
:
"2.2.0"
,
"js-cookie"
:
"2.2.0"
,
"jsonlint"
:
"1.6.3"
,
"jsonlint"
:
"1.6.3"
,
"jszip"
:
"3.1.5"
,
"jszip"
:
"3.1.5"
,
"linq"
:
"^3.1.1"
,
"mockjs"
:
"1.0.1-beta3"
,
"mockjs"
:
"1.0.1-beta3"
,
"normalize.css"
:
"7.0.0"
,
"normalize.css"
:
"7.0.0"
,
"nprogress"
:
"0.2.0"
,
"nprogress"
:
"0.2.0"
,
...
...
vu/src/api/account.js
View file @
51e1a750
...
@@ -28,6 +28,6 @@ export function fetchAccountDetail(id) {
...
@@ -28,6 +28,6 @@ export function fetchAccountDetail(id) {
return
request
({
return
request
({
url
:
'/api/account/detail'
,
url
:
'/api/account/detail'
,
method
:
'get'
,
method
:
'get'
,
param
:
{
id
}
param
s
:
{
id
}
})
})
}
}
vu/src/api/group.js
View file @
51e1a750
...
@@ -8,7 +8,6 @@ export function fetchList(query) {
...
@@ -8,7 +8,6 @@ export function fetchList(query) {
})
})
}
}
export
function
OffLineOrOnLine
(
data
)
{
export
function
OffLineOrOnLine
(
data
)
{
return
request
({
return
request
({
url
:
'/api/group/update'
,
url
:
'/api/group/update'
,
...
...
vu/src/api/login.js
View file @
51e1a750
...
@@ -20,6 +20,7 @@ export function logout() {
...
@@ -20,6 +20,7 @@ export function logout() {
}
}
export
function
getUserInfo
(
token
)
{
export
function
getUserInfo
(
token
)
{
console
.
log
(
token
)
return
request
({
return
request
({
url
:
'/api/account/get'
,
url
:
'/api/account/get'
,
method
:
'get'
,
method
:
'get'
,
...
...
vu/src/api/pick.js
View file @
51e1a750
...
@@ -29,6 +29,6 @@ export function fetchPickDetail(id) {
...
@@ -29,6 +29,6 @@ export function fetchPickDetail(id) {
return
request
({
return
request
({
url
:
'/api/pick/detail'
,
url
:
'/api/pick/detail'
,
method
:
'get'
,
method
:
'get'
,
param
:
{
id
}
param
s
:
{
id
}
})
})
}
}
vu/src/api/remoteSearch.js
View file @
51e1a750
...
@@ -7,3 +7,19 @@ export function userSearch(name) {
...
@@ -7,3 +7,19 @@ export function userSearch(name) {
params
:
{
name
}
params
:
{
name
}
})
})
}
}
export
function
groupSearch
(
name
)
{
return
request
({
url
:
'/api/search/group'
,
method
:
'get'
,
params
:
{
name
}
})
}
export
function
regionSearch
(
name
)
{
return
request
({
url
:
'/api/search/region'
,
method
:
'get'
,
params
:
{
name
}
})
}
vu/src/utils/index.js
View file @
51e1a750
...
@@ -26,12 +26,16 @@ export function parseTime(time, cFormat) {
...
@@ -26,12 +26,16 @@ export function parseTime(time, cFormat) {
const
time_str
=
format
.
replace
(
/{
(
y|m|d|h|i|s|a
)
+}/g
,
(
result
,
key
)
=>
{
const
time_str
=
format
.
replace
(
/{
(
y|m|d|h|i|s|a
)
+}/g
,
(
result
,
key
)
=>
{
let
value
=
formatObj
[
key
]
let
value
=
formatObj
[
key
]
// Note: getDay() returns 0 on Sunday
// Note: getDay() returns 0 on Sunday
if
(
key
===
'a'
)
{
return
[
'日'
,
'一'
,
'二'
,
'三'
,
'四'
,
'五'
,
'六'
][
value
]
}
if
(
key
===
'a'
if
(
result
.
length
>
0
&&
value
<
10
)
{
)
value
=
'0'
+
value
{
}
return
[
'日'
,
'一'
,
'二'
,
'三'
,
'四'
,
'五'
,
'六'
][
value
]
return
value
||
0
}
})
if
(
result
.
length
>
0
&&
value
<
10
)
{
value
=
'0'
+
value
}
return
value
||
0
})
return
time_str
return
time_str
}
}
...
@@ -81,7 +85,8 @@ export function getQueryObject(url) {
...
@@ -81,7 +85,8 @@ export function getQueryObject(url) {
val
=
String
(
val
)
val
=
String
(
val
)
obj
[
name
]
=
val
obj
[
name
]
=
val
return
rs
return
rs
})
}
)
return
obj
return
obj
}
}
...
@@ -116,10 +121,12 @@ export function param(json) {
...
@@ -116,10 +121,12 @@ export function param(json) {
if
(
!
json
)
return
''
if
(
!
json
)
return
''
return
cleanArray
(
return
cleanArray
(
Object
.
keys
(
json
).
map
(
key
=>
{
Object
.
keys
(
json
).
map
(
key
=>
{
if
(
json
[
key
]
===
undefined
)
return
''
if
(
json
[
key
]
===
undefined
)
return
encodeURIComponent
(
key
)
+
'='
+
encodeURIComponent
(
json
[
key
])
return
''
})
return
encodeURIComponent
(
key
)
+
'='
+
encodeURIComponent
(
json
[
key
])
).
join
(
'&'
)
})
).
join
(
'&'
)
}
}
export
function
param2Obj
(
url
)
{
export
function
param2Obj
(
url
)
{
...
@@ -127,14 +134,13 @@ export function param2Obj(url) {
...
@@ -127,14 +134,13 @@ export function param2Obj(url) {
if
(
!
search
)
{
if
(
!
search
)
{
return
{}
return
{}
}
}
console
.
log
(
url
)
return
JSON
.
parse
(
return
JSON
.
parse
(
'{"'
+
'{"'
+
decodeURIComponent
(
search
)
decodeURIComponent
(
search
)
.
replace
(
/"/g
,
'
\\
"'
)
.
replace
(
/"/g
,
'
\\
"'
)
.
replace
(
/&/g
,
'","'
)
.
replace
(
/&/g
,
'","'
)
.
replace
(
/=/g
,
'":"'
)
+
.
replace
(
/=/g
,
'":"'
)
+
'"}'
'"}'
)
)
}
}
...
@@ -156,12 +162,16 @@ export function objectMerge(target, source) {
...
@@ -156,12 +162,16 @@ export function objectMerge(target, source) {
}
}
Object
.
keys
(
source
).
forEach
(
property
=>
{
Object
.
keys
(
source
).
forEach
(
property
=>
{
const
sourceProperty
=
source
[
property
]
const
sourceProperty
=
source
[
property
]
if
(
typeof
sourceProperty
===
'object'
)
{
if
(
typeof
sourceProperty
===
'object'
target
[
property
]
=
objectMerge
(
target
[
property
],
sourceProperty
)
)
}
else
{
{
target
[
property
]
=
sourceProperty
target
[
property
]
=
objectMerge
(
target
[
property
],
sourceProperty
)
}
}
})
else
{
target
[
property
]
=
sourceProperty
}
})
return
target
return
target
}
}
...
@@ -231,7 +241,7 @@ export function getTime(type) {
...
@@ -231,7 +241,7 @@ export function getTime(type) {
export
function
debounce
(
func
,
wait
,
immediate
)
{
export
function
debounce
(
func
,
wait
,
immediate
)
{
let
timeout
,
args
,
context
,
timestamp
,
result
let
timeout
,
args
,
context
,
timestamp
,
result
const
later
=
function
()
{
const
later
=
function
()
{
// 据上一次触发时间间隔
// 据上一次触发时间间隔
const
last
=
+
new
Date
()
-
timestamp
const
last
=
+
new
Date
()
-
timestamp
...
@@ -248,7 +258,9 @@ export function debounce(func, wait, immediate) {
...
@@ -248,7 +258,9 @@ export function debounce(func, wait, immediate) {
}
}
}
}
return
function
(...
args
)
{
return
function
(...
args
)
{
context
=
this
context
=
this
timestamp
=
+
new
Date
()
timestamp
=
+
new
Date
()
const
callNow
=
immediate
&&
!
timeout
const
callNow
=
immediate
&&
!
timeout
...
@@ -274,12 +286,16 @@ export function deepClone(source) {
...
@@ -274,12 +286,16 @@ export function deepClone(source) {
}
}
const
targetObj
=
source
.
constructor
===
Array
?
[]
:
{}
const
targetObj
=
source
.
constructor
===
Array
?
[]
:
{}
Object
.
keys
(
source
).
forEach
(
keys
=>
{
Object
.
keys
(
source
).
forEach
(
keys
=>
{
if
(
source
[
keys
]
&&
typeof
source
[
keys
]
===
'object'
)
{
if
(
source
[
keys
]
&&
typeof
source
[
keys
]
===
'object'
targetObj
[
keys
]
=
deepClone
(
source
[
keys
])
)
}
else
{
{
targetObj
[
keys
]
=
source
[
keys
]
targetObj
[
keys
]
=
deepClone
(
source
[
keys
])
}
}
})
else
{
targetObj
[
keys
]
=
source
[
keys
]
}
})
return
targetObj
return
targetObj
}
}
...
@@ -290,3 +306,21 @@ export function uniqueArr(arr) {
...
@@ -290,3 +306,21 @@ export function uniqueArr(arr) {
export
function
isExternal
(
path
)
{
export
function
isExternal
(
path
)
{
return
/^
(
https
?
:|mailto:|tel:
)
/
.
test
(
path
)
return
/^
(
https
?
:|mailto:|tel:
)
/
.
test
(
path
)
}
}
export
function
isInArray
(
arr
,
value
)
{
for
(
var
i
=
0
;
i
<
arr
.
length
;
i
++
)
{
if
(
value
===
arr
[
i
])
{
return
true
;
}
}
return
false
;
}
export
function
removeByvale
(
arr
,
val
)
{
for
(
var
i
=
0
;
i
<
arr
.
length
;
i
++
){
if
(
arr
[
i
]
==
val
){
arr
.
splice
(
i
,
1
);
break
}
}
}
vu/src/views/pick/components/PickDetail.vue
View file @
51e1a750
...
@@ -9,60 +9,83 @@
...
@@ -9,60 +9,83 @@
<div
class=
"createPost-main-container"
>
<div
class=
"createPost-main-container"
>
<el-row>
<el-row>
<el-col
:span=
"24"
>
<el-col
:span=
"24"
>
<el-form-item
style=
"margin-bottom: 40px;"
prop=
"name"
>
<el-form-item
style=
"margin-bottom: 40px;"
prop=
"name"
>
<MDinput
v-model=
"postForm.name"
:maxlength=
"100"
name=
"name"
required
>
<MDinput
v-model=
"postForm.name"
:maxlength=
"100"
name=
"name"
required
>
pick名称
pick名称
</MDinput>
</MDinput>
</el-form-item>
</el-form-item>
<div
class=
"postInfo-container"
>
<div
class=
"postInfo-container"
>
<el-row>
<el-row>
<el-col
:span=
"8"
>
<el-col
:span=
"8"
>
<el-form-item
label-width=
"45px"
label=
"性别:"
class=
"postInfo-container-item"
>
<el-form-item
label-width=
"45px"
label=
"性别:"
class=
"postInfo-container-item"
>
<el-select
v-model=
"postForm.gender"
:remote-method=
"getRemoteUserList"
filterable
remote
placeholder=
"搜索用户"
>
<el-select
v-model=
"postForm.gender"
:placeholder=
"'性别:'"
clearable
class=
"postInfo-container-item"
<el-option
v-for=
"(item,index) in userListOptions"
:key=
"item+index"
:label=
"item"
:value=
"item"
/>
style=
"width: 120px"
>
<el-option
v-for=
"item in GenderTypeOptions"
:key=
"item.key"
:label=
"item.display_name"
:value=
"item.key"
/>
</el-select>
</el-select>
</el-form-item>
</el-form-item>
</el-col>
</el-col>
<el-col
:span=
"8"
>
<el-col
:span=
"8"
>
<el-form-item
label-width=
"60px"
label=
"地区:"
class=
"postInfo-container-item"
>
<el-form-item
label-width=
"60px"
label=
"属性:"
class=
"postInfo-container-item"
>
<el-select
v-model=
"postForm.region"
:remote-method=
"getRemoteUserList"
filterable
remote
placeholder=
"搜索用户"
>
<el-select
v-model=
"postForm.pick_type"
:placeholder=
"'性别:'"
clearable
<el-option
v-for=
"(item,index) in userListOptions"
:key=
"item+index"
:label=
"item"
:value=
"item"
/>
class=
"postInfo-container-item"
style=
"width:120px"
>
<el-option
v-for=
"item in PickTypeOptions"
:key=
"item.key"
:label=
"item.display_name"
:value=
"item.key"
/>
</el-select>
</el-select>
</el-form-item>
</el-form-item>
</el-col>
</el-col>
<el-col
:span=
"8"
>
<el-col
:span=
"8"
>
<el-form-item
label-width=
"60px"
label=
"属性:"
class=
"postInfo-container-item"
>
<el-form-item
style=
"margin-bottom: 40px;"
label-width=
"45px"
label=
"位置:"
prop=
"position"
>
<el-
select
v-model=
"postForm.pick_type"
:remote-method=
"getRemoteUserList"
filterable
remote
placeholder=
"搜索用户"
>
<el-
input
:rows=
"1"
v-model=
"postForm.position"
type=
"number"
class=
"article-textarea"
<el-option
v-for=
"(item,index) in userListOptions"
:key=
"item+index"
:label=
"item"
:value=
"item"
/>
style=
"width: 120px"
</el-select
>
placeholder=
"请输入内容"
/
>
</el-form-item>
</el-form-item>
</el-col>
</el-col>
</el-row>
</el-row>
</div>
</div>
</el-col>
</el-col>
</el-row>
</el-row>
<el-row>
<el-col
:span=
"12"
>
<el-form-item
label-width=
"45px"
label=
"地区:"
class=
"postInfo-container-item"
>
<el-select
v-model=
"postForm.region"
:remote-method=
"getRemoteRegionList"
filterable
remote
multiple
value-key=
"id"
placeholder=
"搜索地区"
style=
"width: 100%"
>
<el-option
v-for=
"(item,index) in regionListOptions"
:key=
"item+index"
:label=
"item.name"
:value=
"item.id"
/>
</el-select>
</el-form-item>
</el-col>
<el-col
:span=
"12"
>
<el-form-item
style=
"margin-bottom: 40px;"
label-width=
"45px"
label=
"位置:"
prop=
"position"
>
<el-form-item
label-width=
"45px"
label=
"小组:"
class=
"postInfo-container-item"
>
<el-input
:rows=
"1"
v-model=
"postForm.position"
type=
"number"
class=
"article-textarea"
autosize
placeholder=
"请输入内容"
/>
<el-select
</el-form-item>
v-model=
"postForm.pick_group"
:remote-method=
"getRemoteGroupList"
multiple
filterable
remote
reserve-keyword
placeholder=
"搜索小组"
style=
"width: 100%"
:loading=
"loading"
value-key=
"id"
>
<el-option
v-for=
"(item, index) in groupListOptions"
:key=
"item+index"
:label=
"item.name"
:value=
"item.id"
/>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-form-item
style=
"margin-bottom: 40px;"
label-width=
"45px"
label=
"简介:"
prop=
"desc"
>
<el-form-item
style=
"margin-bottom: 40px;"
label-width=
"45px"
label=
"简介:"
prop=
"desc"
>
<el-input
:rows=
"1"
v-model=
"postForm.desc"
type=
"textarea"
class=
"article-textarea"
autosize
placeholder=
"请输入内容"
/>
<el-input
:rows=
"1"
v-model=
"postForm.desc"
type=
"textarea"
class=
"article-textarea"
autosize
placeholder=
"请输入内容"
/>
<span
v-show=
"contentShortLength"
class=
"word-counter"
>
{{
contentShortLength
}}
字
</span>
<span
v-show=
"contentShortLength"
class=
"word-counter"
>
{{
contentShortLength
}}
字
</span>
</el-form-item>
</el-form-item>
<el-form-item
style=
"margin-bottom: 40px;"
label-width=
"45px"
label=
"下线:"
>
<el-form-item
style=
"margin-bottom: 40px;"
label-width=
"45px"
label=
"下线:"
>
<el-radio-group
v-model=
"postForm.is_online"
>
<el-radio-group
v-model=
"postForm.is_online"
>
<el-radio
:label=
"1"
>
是
</el-radio>
<el-radio
:label=
"1"
>
是
</el-radio>
<el-radio
:label=
"0"
>
否
</el-radio>
<el-radio
:label=
"0"
>
否
</el-radio>
</el-radio-group>
</el-radio-group>
</el-form-item>
</el-form-item>
</div>
</div>
</el-form>
</el-form>
...
@@ -70,156 +93,203 @@
...
@@ -70,156 +93,203 @@
</
template
>
</
template
>
<
script
>
<
script
>
import
MDinput
from
'@/components/MDinput'
import
MDinput
from
'@/components/MDinput'
import
Sticky
from
'@/components/Sticky'
// 粘性header组件
import
Sticky
from
'@/components/Sticky'
// 粘性header组件
import
{
fetchPickDetail
,
CreatePick
}
from
'@/api/pick'
import
{
fetchPickDetail
,
CreatePick
}
from
'@/api/pick'
import
{
userSearch
}
from
'@/api/remoteSearch'
import
{
groupSearch
,
regionSearch
}
from
'@/api/remoteSearch'
import
{
isInArray
,
removeByvale
}
from
"@/utils"
;
const
defaultForm
=
{
// status: 'draft',
name
:
''
,
desc
:
''
,
gender
:
''
,
region
:
''
,
pick_type
:
''
,
position
:
''
,
is_online
:
1
,
}
export
default
{
function
Assembledata
(
target
,
source
)
{
name
:
'PickDetail'
,
var
region_data
=
[]
components
:
{
MDinput
,
Sticky
},
for
(
var
i
=
0
;
i
<
target
.
length
;
i
++
){
props
:
{
if
(
isInArray
(
source
,
target
[
i
][
'name'
])){
isEdit
:
{
region_data
.
push
(
target
[
i
][
'id'
])
type
:
Boolean
,
removeByvale
(
source
,
target
[
i
][
'name'
]);
default
:
false
}
},
data
()
{
const
validateRequire
=
(
rule
,
value
,
callback
)
=>
{
if
(
value
===
''
)
{
this
.
$message
({
message
:
rule
.
field
+
'为必传项'
,
type
:
'error'
})
callback
(
new
Error
(
rule
.
field
+
'为必传项'
))
}
else
{
callback
()
}
}
}
}
return
{
region_data
.
push
(...
source
)
postForm
:
Object
.
assign
({},
defaultForm
),
return
region_data
.
join
(
','
)
loading
:
false
,
}
userListOptions
:
[],
rules
:
{
name
:
[{
validator
:
validateRequire
,
trigger
:
'blur'
}],
desc
:
[{
validator
:
validateRequire
,
trigger
:
'blur'
}],
position
:
[{
validator
:
validateRequire
,
trigger
:
'blur'
}],
},
tempRoute
:
{}
}
},
computed
:
{
contentShortLength
()
{
return
this
.
postForm
.
desc
.
length
}
},
created
()
{
if
(
this
.
isEdit
)
{
const
id
=
this
.
$route
.
params
&&
this
.
$route
.
params
.
id
console
.
log
(
id
)
this
.
fetchData
(
id
)
}
else
{
this
.
postForm
=
Object
.
assign
({},
defaultForm
)
}
this
.
tempRoute
=
Object
.
assign
({},
this
.
$route
)
const
defaultForm
=
{
},
status
:
'draft'
,
methods
:
{
name
:
''
,
fetchData
(
id
)
{
desc
:
''
,
fetchPickDetail
(
id
).
then
(
response
=>
{
gender
:
''
,
console
.
log
(
response
.
data
.
data
.
data
)
region
:
[],
// this.postForm = response.data.data.data
pick_group
:
[],
pick_type
:
''
,
position
:
''
,
is_online
:
1
,
}
export
default
{
name
:
'PickDetail'
,
components
:
{
MDinput
,
Sticky
},
props
:
{
isEdit
:
{
type
:
Boolean
,
default
:
false
}
},
data
()
{
const
validateRequire
=
(
rule
,
value
,
callback
)
=>
{
if
(
value
===
''
)
{
this
.
$message
({
message
:
rule
.
field
+
'为必传项'
,
type
:
'error'
})
callback
(
new
Error
(
rule
.
field
+
'为必传项'
))
}
else
{
callback
()
}
}
return
{
postForm
:
Object
.
assign
({},
defaultForm
),
loading
:
false
,
regionListOptions
:
[],
groupListOptions
:
[],
GenderTypeOptions
:
[
{
'key'
:
2
,
'display_name'
:
'全部'
},
{
'key'
:
0
,
'display_name'
:
'男'
},
{
'key'
:
1
,
'display_name'
:
'女'
},
],
PickTypeOptions
:
[
{
'key'
:
1
,
'display_name'
:
'明星打榜'
},
{
'key'
:
0
,
'display_name'
:
'用戶打榜'
},
],
rules
:
{
name
:
[{
validator
:
validateRequire
,
trigger
:
'blur'
}],
desc
:
[{
validator
:
validateRequire
,
trigger
:
'blur'
}],
position
:
[{
validator
:
validateRequire
,
trigger
:
'blur'
}],
},
tempRoute
:
{},
temparray
:{
'region'
:[],
'pick_group'
:
[],
}
}
},
computed
:
{
contentShortLength
()
{
return
this
.
postForm
.
desc
.
length
}
},
created
()
{
if
(
this
.
isEdit
)
{
const
id
=
this
.
$route
.
params
&&
this
.
$route
.
params
.
id
this
.
fetchData
(
id
)
}
else
{
this
.
postForm
=
Object
.
assign
({},
defaultForm
)
}
}).
catch
(
err
=>
{
this
.
tempRoute
=
Object
.
assign
({},
this
.
$route
)
console
.
log
(
err
)
})
},
},
submitForm
()
{
methods
:
{
console
.
log
(
this
.
postForm
)
fetchData
(
id
)
{
this
.
$refs
.
postForm
.
validate
(
valid
=>
{
fetchPickDetail
(
id
).
then
(
response
=>
{
if
(
valid
)
{
// select 回填数据处理,后期再进行优化
this
.
loading
=
true
let
rep
=
response
.
data
.
data
.
data
;
CreatePick
(
this
.
postForm
).
then
(
response
=>
{
let
pick_temp
=
[]
let
region_temp
=
[]
for
(
let
i
=
0
;
i
<
rep
.
pick_group
.
length
;
i
++
){
pick_temp
.
push
(
rep
.
pick_group
[
i
][
'name'
]);
this
.
temparray
[
'pick_group'
].
push
(
rep
.
pick_group
[
i
])
}
for
(
let
i
=
0
;
i
<
rep
.
region
.
length
;
i
++
){
region_temp
.
push
(
rep
.
region
[
i
][
'name'
]);
this
.
temparray
[
'region'
].
push
(
rep
.
region
[
i
])
}
rep
.
region
=
region_temp
rep
.
pick_group
=
pick_temp
this
.
postForm
=
rep
}).
catch
(
err
=>
{
console
.
log
(
err
)
})
},
submitForm
()
{
this
.
$refs
.
postForm
.
validate
(
valid
=>
{
if
(
valid
)
{
this
.
loading
=
true
;
this
.
postForm
.
region
=
Assembledata
(
this
.
temparray
[
'region'
],
this
.
postForm
.
region
);
this
.
postForm
.
pick_group
=
Assembledata
(
this
.
temparray
[
'pick_group'
],
this
.
postForm
.
pick_group
);
CreatePick
(
this
.
postForm
).
then
(
response
=>
{
this
.
$notify
({
this
.
$notify
({
title
:
'成功'
,
title
:
'成功'
,
message
:
response
.
data
.
data
.
message
,
message
:
response
.
data
.
data
.
message
,
type
:
'success'
,
type
:
'success'
,
duration
:
2000
duration
:
2000
})
})
setTimeout
(()
=>
{
setTimeout
(()
=>
{
this
.
$router
.
push
(
'/pick/list'
)
this
.
$router
.
push
(
'/pick/list'
)
},
1000
)
},
1000
)
}).
catch
(
err
=>
{
}).
catch
(
err
=>
{
this
.
$notify
({
this
.
$notify
({
title
:
'失败'
,
title
:
'失败'
,
message
:
'操作失败'
,
message
:
'操作失败'
,
type
:
'danger'
,
type
:
'danger'
,
duration
:
2000
duration
:
2000
})
})
});
});
// this.postForm.status = 'published'
this
.
postForm
.
status
=
'published'
this
.
loading
=
false
this
.
loading
=
false
}
else
{
}
else
{
console
.
log
(
'error submit!!'
)
console
.
log
(
'error submit!!'
)
return
false
return
false
}
}
})
})
},
},
getRemoteUserList
(
query
)
{
getRemoteRegionList
(
query
)
{
userSearch
(
query
).
then
(
response
=>
{
regionSearch
(
query
).
then
(
response
=>
{
if
(
!
response
.
data
.
items
)
return
if
(
!
response
.
data
.
data
.
data
)
return
this
.
userListOptions
=
response
.
data
.
items
.
map
(
v
=>
v
.
name
)
this
.
regionListOptions
=
response
.
data
.
data
.
data
})
})
},
getRemoteGroupList
(
query
)
{
groupSearch
(
query
).
then
(
response
=>
{
if
(
!
response
.
data
.
data
.
data
)
return
this
.
groupListOptions
=
response
.
data
.
data
.
data
})
},
}
}
}
}
}
</
script
>
</
script
>
<
style
rel=
"stylesheet/scss"
lang=
"scss"
scoped
>
<
style
rel=
"stylesheet/scss"
lang=
"scss"
scoped
>
@import
"src/styles/mixin.scss"
;
@import
"src/styles/mixin.scss"
;
.createPost-container
{
position
:
relative
;
.createPost-container
{
.createPost-main-container
{
position
:
relative
;
padding
:
40px
45px
20px
50px
;
.createPost-main-container
{
.postInfo-container
{
padding
:
40px
45px
20px
50px
;
position
:
relative
;
.postInfo-container
{
@include
clearfix
;
position
:
relative
;
margin-bottom
:
10px
;
@include
clearfix
;
.postInfo-container-item
{
margin-bottom
:
10px
;
float
:
left
;
.postInfo-container-item
{
float
:
left
;
}
}
}
}
.editor-container
{
.editor-container
{
min-height
:
500px
;
min-height
:
50
0px
;
margin
:
0
0
3
0px
;
margin
:
0
0
30px
;
.editor-upload-btn-container
{
.editor-upload-btn-container
{
text-align
:
right
;
text-align
:
right
;
margin-right
:
10px
;
margin-right
:
10px
;
.editor-upload-btn
{
.editor-upload-btn
{
display
:
inline-block
;
display
:
inline-block
;
}
}
}
}
}
}
}
.word-counter
{
width
:
40px
;
position
:
absolute
;
right
:
-10px
;
top
:
0px
;
}
}
}
.word-counter
{
width
:
40px
;
position
:
absolute
;
right
:
-10px
;
top
:
0px
;
}
}
</
style
>
</
style
>
vu/src/views/pick/list.vue
View file @
51e1a750
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
</
template
>
</
template
>
</el-table-column>
</el-table-column>
<el-table-column
width=
"
12
0px"
align=
"center"
label=
"pick简介"
>
<el-table-column
width=
"
28
0px"
align=
"center"
label=
"pick简介"
>
<
template
slot-scope=
"scope"
>
<
template
slot-scope=
"scope"
>
<span>
{{
scope
.
row
.
desc
}}
</span>
<span>
{{
scope
.
row
.
desc
}}
</span>
</
template
>
</
template
>
...
@@ -41,6 +41,12 @@
...
@@ -41,6 +41,12 @@
</
template
>
</
template
>
</el-table-column>
</el-table-column>
<el-table-column
width=
"120px"
align=
"center"
label=
"pick小组数"
>
<
template
slot-scope=
"scope"
>
<span>
{{
scope
.
row
.
pick_group_nums
}}
</span>
</
template
>
</el-table-column>
<el-table-column
width=
"120px"
align=
"center"
label=
"pick属性"
>
<el-table-column
width=
"120px"
align=
"center"
label=
"pick属性"
>
<
template
slot-scope=
"scope"
>
<
template
slot-scope=
"scope"
>
<span>
{{
scope
.
row
.
pick_type
}}
</span>
<span>
{{
scope
.
row
.
pick_type
}}
</span>
...
@@ -53,7 +59,7 @@
...
@@ -53,7 +59,7 @@
</
template
>
</
template
>
</el-table-column>
</el-table-column>
<el-table-column
width=
"1
2
0px"
align=
"center"
label=
"地区"
>
<el-table-column
width=
"1
3
0px"
align=
"center"
label=
"地区"
>
<
template
slot-scope=
"scope"
>
<
template
slot-scope=
"scope"
>
<span>
{{
scope
.
row
.
region
}}
</span>
<span>
{{
scope
.
row
.
region
}}
</span>
</
template
>
</
template
>
...
...
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