Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
a8b4c16a
authored
Apr 10, 2023
by
dhb52
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: WxMaterialSelect组件setup
parent
e035eb26
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
91 additions
and
108 deletions
+91
-108
src/views/mp/components/wx-material-select/main.vue
+91
-108
No files found.
src/views/mp/components/wx-material-select/main.vue
View file @
a8b4c16a
...
@@ -14,7 +14,8 @@
...
@@ -14,7 +14,8 @@
<p
class=
"item-name"
>
{{
item
.
name
}}
</p>
<p
class=
"item-name"
>
{{
item
.
name
}}
</p>
<el-row
class=
"ope-row"
>
<el-row
class=
"ope-row"
>
<el-button
type=
"success"
@
click=
"selectMaterialFun(item)"
>
<el-button
type=
"success"
@
click=
"selectMaterialFun(item)"
>
选择
<Icon
icon=
"ep:circle-check"
/>
选择
<Icon
icon=
"ep:circle-check"
/>
</el-button>
</el-button>
</el-row>
</el-row>
</div>
</div>
...
@@ -48,7 +49,8 @@
...
@@ -48,7 +49,8 @@
<el-table-column
label=
"操作"
align=
"center"
fixed=
"right"
>
<el-table-column
label=
"操作"
align=
"center"
fixed=
"right"
>
<
template
#
default=
"scope"
>
<
template
#
default=
"scope"
>
<el-button
type=
"primary"
link
@
click=
"selectMaterialFun(scope.row)"
<el-button
type=
"primary"
link
@
click=
"selectMaterialFun(scope.row)"
>
选择
<Icon
icon=
"ep:plus"
/>
>
选择
<Icon
icon=
"ep:plus"
/>
</el-button>
</el-button>
</
template
>
</
template
>
</el-table-column>
</el-table-column>
...
@@ -89,7 +91,8 @@
...
@@ -89,7 +91,8 @@
>
>
<
template
#
default=
"scope"
>
<
template
#
default=
"scope"
>
<el-button
type=
"primary"
link
@
click=
"selectMaterialFun(scope.row)"
<el-button
type=
"primary"
link
@
click=
"selectMaterialFun(scope.row)"
>
选择
<Icon
icon=
"akar-icons:circle-plus"
/>
>
选择
<Icon
icon=
"akar-icons:circle-plus"
/>
</el-button>
</el-button>
</
template
>
</
template
>
</el-table-column>
</el-table-column>
...
@@ -110,7 +113,8 @@
...
@@ -110,7 +113,8 @@
<WxNews
:articles=
"item.content.newsItem"
/>
<WxNews
:articles=
"item.content.newsItem"
/>
<el-row
class=
"ope-row"
>
<el-row
class=
"ope-row"
>
<el-button
type=
"success"
@
click=
"selectMaterialFun(item)"
>
<el-button
type=
"success"
@
click=
"selectMaterialFun(item)"
>
选择
<Icon
icon=
"ep:circle-check"
/>
选择
<Icon
icon=
"ep:circle-check"
/>
</el-button>
</el-button>
</el-row>
</el-row>
</div>
</div>
...
@@ -127,124 +131,101 @@
...
@@ -127,124 +131,101 @@
</div>
</div>
</template>
</template>
<
script
lang=
"ts"
name=
"WxMaterialSelect"
>
<
script
lang=
"ts"
setup
name=
"WxMaterialSelect"
>
import
WxNews
from
'@/views/mp/components/wx-news/main.vue'
import
WxNews
from
'@/views/mp/components/wx-news/main.vue'
import
WxVoicePlayer
from
'@/views/mp/components/wx-voice-play/main.vue'
import
WxVoicePlayer
from
'@/views/mp/components/wx-voice-play/main.vue'
import
WxVideoPlayer
from
'@/views/mp/components/wx-video-play/main.vue'
import
WxVideoPlayer
from
'@/views/mp/components/wx-video-play/main.vue'
import
{
getMaterialPage
}
from
'@/api/mp/material'
import
*
as
MpMaterialApi
from
'@/api/mp/material'
import
{
getFreePublishPage
}
from
'@/api/mp/freePublish'
import
*
as
MpFreePublishApi
from
'@/api/mp/freePublish'
import
{
getDraftPage
}
from
'@/api/mp/draft'
import
*
as
MpDraftApi
from
'@/api/mp/draft'
import
{
dateFormatter
}
from
'@/utils/formatTime'
import
{
dateFormatter
}
from
'@/utils/formatTime'
import
{
defineComponent
,
PropType
}
from
'vue'
export
default
defineComponent
({
const
props
=
defineProps
({
components
:
{
objData
:
{
WxNews
,
type
:
Object
,
// type - 类型;accountId - 公众号账号编号
WxVoicePlayer
,
required
:
true
WxVideoPlayer
},
},
props
:
{
newsType
:
{
objData
:
{
// 图文类型:1、已发布图文;2、草稿箱图文
type
:
Object
,
// type - 类型;accountId - 公众号账号编号
type
:
String
as
PropType
<
string
>
,
required
:
true
default
:
'1'
},
}
newsType
:
{
})
// 图文类型:1、已发布图文;2、草稿箱图文
type
:
String
as
PropType
<
string
>
,
default
:
'1'
}
},
setup
(
props
,
ctx
)
{
// 遮罩层
const
loading
=
ref
(
false
)
// 总条数
const
total
=
ref
(
0
)
// 数据列表
const
list
=
ref
([])
// 查询参数
const
queryParams
=
reactive
({
pageNo
:
1
,
pageSize
:
10
,
accountId
:
props
.
objData
.
accountId
})
const
objDataRef
=
reactive
(
props
.
objData
)
const
newsTypeRef
=
ref
(
props
.
newsType
)
const
selectMaterialFun
=
(
item
)
=>
{
const
emit
=
defineEmits
([
'select-material'
])
ctx
.
emit
(
'select-material'
,
item
)
}
/** 搜索按钮操作 */
const
handleQuery
=
()
=>
{
queryParams
.
pageNo
=
1
getPage
()
}
const
getPage
=
()
=>
{
loading
.
value
=
true
if
(
objDataRef
.
type
===
'news'
&&
newsTypeRef
.
value
===
'1'
)
{
// 【图文】+ 【已发布】
getFreePublishPageFun
()
}
else
if
(
objDataRef
.
type
===
'news'
&&
newsTypeRef
.
value
===
'2'
)
{
// 【图文】+ 【草稿】
getDraftPageFun
()
}
else
{
// 【素材】
getMaterialPageFun
()
}
}
const
getMaterialPageFun
=
async
()
=>
{
// 遮罩层
let
data
=
await
getMaterialPage
({
const
loading
=
ref
(
false
)
...
queryParams
,
// 总条数
type
:
objDataRef
.
type
const
total
=
ref
(
0
)
})
// 数据列表
list
.
value
=
data
.
list
const
list
=
ref
([])
total
.
value
=
data
.
total
// 查询参数
loading
.
value
=
false
const
queryParams
=
reactive
({
}
pageNo
:
1
,
pageSize
:
10
,
accountId
:
props
.
objData
.
accountId
})
const
objDataRef
=
reactive
(
props
.
objData
)
const
newsTypeRef
=
ref
(
props
.
newsType
)
const
getFreePublishPageFun
=
async
()
=>
{
const
selectMaterialFun
=
(
item
)
=>
{
let
data
=
await
getFreePublishPage
(
queryParams
)
emit
(
'select-material'
,
item
)
data
.
list
.
forEach
((
item
)
=>
{
}
const
newsItem
=
item
.
content
.
newsItem
newsItem
.
forEach
((
article
)
=>
{
article
.
picUrl
=
article
.
thumbUrl
})
})
list
.
value
=
data
.
list
total
.
value
=
data
.
total
loading
.
value
=
false
}
const
getDraftPageFun
=
async
()
=>
{
const
getPage
=
async
()
=>
{
let
data
=
await
getDraftPage
(
queryParams
)
loading
.
value
=
true
data
.
list
.
forEach
((
item
)
=>
{
try
{
const
newsItem
=
item
.
content
.
newsItem
if
(
objDataRef
.
type
===
'news'
&&
newsTypeRef
.
value
===
'1'
)
{
newsItem
.
forEach
((
article
)
=>
{
// 【图文】+ 【已发布】
article
.
picUrl
=
article
.
thumbUrl
await
getFreePublishPageFun
()
})
}
else
if
(
objDataRef
.
type
===
'news'
&&
newsTypeRef
.
value
===
'2'
)
{
})
// 【图文】+ 【草稿】
list
.
value
=
data
.
list
await
getDraftPageFun
()
total
.
value
=
data
.
total
}
else
{
loading
.
value
=
false
// 【素材】
await
getMaterialPageFun
()
}
}
}
finally
{
loading
.
value
=
false
}
}
const
getMaterialPageFun
=
async
()
=>
{
const
data
=
await
MpMaterialApi
.
getMaterialPage
({
...
queryParams
,
type
:
objDataRef
.
type
})
list
.
value
=
data
.
list
total
.
value
=
data
.
total
}
onMounted
(
async
()
=>
{
const
getFreePublishPageFun
=
async
()
=>
{
getPage
()
const
data
=
await
MpFreePublishApi
.
getFreePublishPage
(
queryParams
)
data
.
list
.
forEach
((
item
)
=>
{
const
newsItem
=
item
.
content
.
newsItem
newsItem
.
forEach
((
article
)
=>
{
article
.
picUrl
=
article
.
thumbUrl
})
})
})
list
.
value
=
data
.
list
total
.
value
=
data
.
total
}
return
{
const
getDraftPageFun
=
async
()
=>
{
handleQuery
,
const
data
=
await
MpDraftApi
.
getDraftPage
(
queryParams
)
dateFormatter
,
data
.
list
.
forEach
((
item
)
=>
{
selectMaterialFun
,
const
newsItem
=
item
.
content
.
newsItem
getMaterialPageFun
,
newsItem
.
forEach
((
article
)
=>
{
getPage
,
article
.
picUrl
=
article
.
thumbUrl
queryParams
,
})
objDataRef
,
})
list
,
list
.
value
=
data
.
list
total
,
total
.
value
=
data
.
total
loading
}
}
}
onMounted
(
async
()
=>
{
getPage
()
})
})
</
script
>
</
script
>
<
style
lang=
"scss"
scoped
>
<
style
lang=
"scss"
scoped
>
...
@@ -275,6 +256,7 @@ p {
...
@@ -275,6 +256,7 @@ p {
.waterfall
{
.waterfall
{
column-count
:
3
;
column-count
:
3
;
}
}
p
{
p
{
color
:
red
;
color
:
red
;
}
}
...
@@ -284,6 +266,7 @@ p {
...
@@ -284,6 +266,7 @@ p {
.waterfall
{
.waterfall
{
column-count
:
2
;
column-count
:
2
;
}
}
p
{
p
{
color
:
orange
;
color
:
orange
;
}
}
...
...
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