list.vue
3.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<script>
import { getTree, getList } from '@/api/material'
export default {
components: {},
props: {
type: {
type: String,
default: '4'
}
},
data() {
return {
loading: true, // 遮罩层
// 查询条件
query: {
pageNum: 1,
pageSize: 10,
categoryId: '',
search: '',
mediaType: '4'
},
list: [], // 列表
total: 0, // 总条数
treeData: [], // 树
// 树props
treeProps: {
children: 'children',
label: 'name'
},
// 分组props
groupProps: {
// expandTrigger: 'hover',
checkStrictly: true,
children: 'children',
label: 'name',
value: 'id',
emitPath: false
},
radio: ''
}
},
watch: {
radio(val) {
this.$emit('change', val)
}
},
computed: {},
created() {
this.query.mediaType = this.type
this.getTree()
this.getList()
},
mounted() {},
methods: {
// 获取类目树
getTree() {
getTree(this.type).then(({ data }) => {
this.treeData = data
})
},
// 获取素材列表
getList(page) {
page && (this.query.pageNum = page)
this.loading = true
getList(this.query)
.then(({ rows, total }) => {
this.list = rows
this.total = +total
this.loading = false
this.$emit('listChange', this.list)
})
.catch(() => {
this.loading = false
})
}
}
}
</script>
<template>
<div>
<el-form ref="form" :model="query" label-width="70px">
<el-form-item label="选择分组">
<el-cascader
v-model="query.categoryId"
:options="treeData"
:props="groupProps"
></el-cascader>
<el-input
v-model="query.search"
class="ml10 mr10"
style="width: 150px;"
@keydown.enter="getList(1)"
></el-input>
<el-button
v-hasPermi="['contacts:organization:query']"
icon="el-icon-search"
circle
@click="getList(1)"
></el-button>
<el-pagination
class="fr"
@current-change="getList"
:current-page="query.pageNum"
:page-size="query.pageSize"
layout="prev, pager, next"
:total="total"
></el-pagination>
</el-form-item>
</el-form>
<!-- <slot :list="list"></slot> -->
<!-- 文本 -->
<el-table
v-if="type == 4"
v-loading="loading"
:data="list"
:show-header="false"
>
<el-table-column width="30">
<template slot-scope="scope">
<el-radio v-model="radio" :label="scope.row">'</el-radio>
</template>
</el-table-column>
<el-table-column prop="content"> </el-table-column>
</el-table>
<!-- 图片 -->
<el-radio-group
v-if="type == 0"
v-loading="loading"
class="img-wrap"
v-model="radio"
>
<el-radio v-for="(item, index) in list" :label="item" :key="index">
<div class="ma-img ac mb20">
<el-card shadow="hover" body-style="padding: 0px;">
<img
crossorigin="anonymous"
class="img-li"
:src="item.materialUrl"
alt
/>
</el-card>
<div class="mt10 toe" :title="item.materialName">
{{ item.materialName }}
</div>
</div>
</el-radio>
</el-radio-group>
</div>
</template>
<style lang="scss" scoped>
// .img-wrap {
// /deep/.el-radio__input {
// position: absolute;
// left: 50%;
// top: 50%;
// transform: translate(-50%, -50%);
// }
// }
.ma-img {
width: 160px;
}
.img-li {
max-width: 100%;
height: 160px;
border-radius: 8px;
border: 1px solid #e6ebf5;
}
</style>