TemplateLibrary.vue
6.66 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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
<template>
<div class="left pad20" style="border-radius: 4px; background: #fff">
<!--模板库 -->
<div>
<!-- v-hasPermi="['wecom:tlp:add']" -->
<el-form label-position="left" inline label-width="80px">
<el-form-item>
<el-input
:placeholder="isGroup ? '请输入群发内容' : '请输入欢迎语'"
v-model="query.templateInfo"
style="width: 260px"></el-input>
</el-form-item>
<el-form-item label-width="0">
<el-button type="primary" @click="getList(0)">查询</el-button>
<el-button @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
</div>
<div>
<el-table v-loading="loading" :data="list" @current-change="currentChange">
<el-table-column width="60">
<template slot-scope="{ row }">
<i
v-if="welSelected ? welSelected.id === row.id : false"
class="el-icon-check"
style="color: rgb(65, 133, 244); font-size: 25px"></i>
</template>
</el-table-column>
<el-table-column :label="isGroup ? '群发内容' : '欢迎语'" align="center" min-width="250" show-overflow-tooltip>
<template slot-scope="scope">
{{ scope.row.templateInfo }}
</template>
</el-table-column>
<!-- <el-table-column
v-if="type === '2'"
label="员工"
prop="userNames"
align="center"
></el-table-column> -->
<el-table-column label="附件" align="center" prop="attachTotalNum" />
<el-table-column label="最近更新" align="center">
<template slot-scope="scope">
<div>{{ scope.row.updateBy }}</div>
<span>{{ scope.row.createTime }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button size="mini" type="text" @click="showPreview(scope.row)">预览</el-button>
</template>
</el-table-column>
</el-table>
<div class="bottom">
<pagination :total="total" :page.sync="query.pageNum" :limit.sync="query.pageSize" @pagination="getList()" />
</div>
</div>
<el-dialog title="预览" :visible.sync="showPreviewDialog" width="50%" append-to-body>
<div>
<PreviewInPhone :list="previewList" :templateInfo="templateInfo"></PreviewInPhone>
</div>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="showPreviewDialog = false">关闭</el-button>
</span>
</el-dialog>
<!-- 批量新建弹窗 -->
<SelectWeUser
:visible.sync="dialogVisible"
title="组织架构"
:defaultValues="userArray"
@success="getSelectUser"></SelectWeUser>
</div>
</template>
<script>
import PreviewInPhone from '@/components/ContentCenter/PreviewInPhone'
import { getList } from '@/api/drainageCode/welcome'
// import { lexicalDetail } from '@/api/contentCenter/scriptCenter'
import { templateDetail } from '@/api/contentCenter/modleCenter'
export default {
name: 'Tab2',
components: {
PreviewInPhone,
},
props: {
type: {
type: Number | String,
default: '1',
},
// 1.欢迎语模板 2.群发模板 3.sop
isGroup: {
type: Boolean,
default: false,
},
},
data() {
return {
welSelected: {
id: '',
},
userArray: [], // 选择人员
qrUserName: undefined,
ids: [],
// 查询参数
query: {
pageNum: 1,
pageSize: 10,
templateType: 1,
// welcomeMsg: undefined,
// orderByColumn: 'wmt.create_time',
// isAsc: 'desc',
},
dialogVisible: false,
loading: false,
total: 0,
list: [],
showPreviewDialog: false,
previewList: [],
templateInfo: '',
materialMsgList: [],
}
},
watch: {},
computed: {},
created() {
this.getList()
},
mounted() {},
methods: {
currentChange(val) {
this.welSelected = val
if (val) {
this.$emit('changeObj', val.id)
// templateDetail(val.id).then((res) => {
// this.$emit('changeObj', res.data)
// })
}
},
resetQuery() {
this.query.templateInfo = ''
this.userArray = []
this.qrUserName = ''
this.query.pageNum = 1
this.getList()
},
getSelectUser(data) {
this.userArray = data
this.qrUserName = this.userArray
.map(function (obj, index) {
return obj.name
})
.join(',')
this.query.qrUserIds = this.userArray
.map(function (obj, index) {
return obj.userId
})
.join(',')
},
handleSelectionChange(selection) {
this.ids = selection.map((item) => item.id)
},
/** 查询 */
getList(page) {
page && (this.query.pageNum = page)
this.loading = true
this.query.templateType = this.isGroup ? 2 : 1
getList(this.query)
.then(({ rows, total }) => {
this.list = rows
this.total = +total
this.loading = false
})
.catch(() => {
this.loading = false
})
},
showPreview(data) {
this.templateInfo = data.templateInfo
this.getDeatil(data.id)
this.showPreviewDialog = true
},
getDeatil(id) {
this.loading = true
templateDetail(id)
.then((res) => {
this.previewList = res.data.weMaterialList
this.loading = false
})
.catch(() => {
this.loading = false
})
},
setEditList(list) {
let arr = []
if (list && list.length) {
list.forEach((dd) => {
if (dd.msgType === 'image') {
let obj = {
msgType: '0',
materialUrl: dd.picUrl,
}
arr.push(obj)
} else if (dd.msgType === 'link') {
let ob = {
msgType: '8',
materialName: dd.title,
materialUrl: dd.linkUrl,
}
arr.push(ob)
} else if (dd.msgType === 'miniprogram') {
let ff = {
msgType: '9',
digest: dd.appId,
materialName: dd.title,
coverUrl: dd.picUrl,
materialUrl: dd.linkUrl,
}
arr.push(ff)
}
})
}
return arr
},
},
}
</script>
<style lang="scss" scoped>
.header {
padding: 0 20px;
}
.divider-content {
width: 100%;
height: 10px;
background-color: #f5f7fb;
}
.bottom {
display: flex;
justify-content: flex-end;
align-items: center;
}
</style>