commit | author | age
|
9bcb19
|
1 |
<template> |
I |
2 |
<div> |
|
3 |
<a-card :bordered="false" :bodyStyle="tstyle"> |
|
4 |
<div class="table-page-search-wrapper" v-if="hasPerm('blogArticle:page')"> |
|
5 |
<a-form layout="inline"> |
|
6 |
<a-row :gutter="48"> |
|
7 |
<a-col :md="8" :sm="24"> |
|
8 |
<a-form-item label="文章标题"> |
|
9 |
<a-input v-model="queryParam.title" allow-clear placeholder="请输入文章标题"/> |
|
10 |
</a-form-item> |
|
11 |
</a-col> |
|
12 |
<a-col :md="8" :sm="24"> |
|
13 |
<a-form-item label="文章文件id"> |
|
14 |
<a-input v-model="queryParam.articleFileId" allow-clear placeholder="请输入文章文件id"/> |
|
15 |
</a-form-item> |
|
16 |
</a-col> |
|
17 |
<template v-if="advanced"> |
|
18 |
<a-col :md="8" :sm="24"> |
|
19 |
<a-form-item label="文件类型 1:markdown 2:html"> |
|
20 |
<a-input v-model="queryParam.articleFileType" allow-clear placeholder="请输入文件类型 1:markdown 2:html"/> |
|
21 |
</a-form-item> |
|
22 |
</a-col> |
|
23 |
<a-col :md="8" :sm="24"> |
|
24 |
<a-form-item label="文章分类id 0:没有分类"> |
|
25 |
<a-input v-model="queryParam.articleTypeId" allow-clear placeholder="请输入文章分类id 0:没有分类"/> |
|
26 |
</a-form-item> |
|
27 |
</a-col> |
|
28 |
<a-col :md="8" :sm="24"> |
|
29 |
<a-form-item label="文章引言"> |
|
30 |
<a-input v-model="queryParam.introduce" allow-clear placeholder="请输入文章引言"/> |
|
31 |
</a-form-item> |
|
32 |
</a-col> |
|
33 |
<a-col :md="8" :sm="24"> |
|
34 |
<a-form-item label="封面文件地址(id)"> |
|
35 |
<a-input v-model="queryParam.coverFileId" allow-clear placeholder="请输入封面文件地址(id)"/> |
|
36 |
</a-form-item> |
|
37 |
</a-col> |
|
38 |
<a-col :md="8" :sm="24"> |
|
39 |
<a-form-item label="上次编辑时间"> |
|
40 |
<a-date-picker style="width: 100%" placeholder="请选择上次编辑时间" v-model="queryParam.lastEditorDateDate" @change="onChangelastEditorDate"/> |
|
41 |
</a-form-item> |
|
42 |
</a-col> |
|
43 |
<a-col :md="8" :sm="24"> |
|
44 |
<a-form-item label="发布时间"> |
|
45 |
<a-date-picker style="width: 100%" placeholder="请选择发布时间" v-model="queryParam.publishDateDate" @change="onChangepublishDate"/> |
|
46 |
</a-form-item> |
|
47 |
</a-col> |
|
48 |
<a-col :md="8" :sm="24"> |
|
49 |
<a-form-item label="是否置顶 0:否 1:是"> |
|
50 |
<a-input v-model="queryParam.isTop" allow-clear placeholder="请输入是否置顶 0:否 1:是"/> |
|
51 |
</a-form-item> |
|
52 |
</a-col> |
|
53 |
<a-col :md="8" :sm="24"> |
|
54 |
<a-form-item label="置顶值(越小越靠前)"> |
|
55 |
<a-input v-model="queryParam.topValue" allow-clear placeholder="请输入置顶值(越小越靠前)"/> |
|
56 |
</a-form-item> |
|
57 |
</a-col> |
|
58 |
<a-col :md="8" :sm="24"> |
|
59 |
<a-form-item label="公开状态 1:公开 2:私密 3:密码授权"> |
|
60 |
<a-input v-model="queryParam.authStatus" allow-clear placeholder="请输入公开状态 1:公开 2:私密 3:密码授权"/> |
|
61 |
</a-form-item> |
|
62 |
</a-col> |
|
63 |
<a-col :md="8" :sm="24"> |
|
64 |
<a-form-item label="授权密码(在密码授权状态时)"> |
|
65 |
<a-input v-model="queryParam.authPassword" allow-clear placeholder="请输入授权密码(在密码授权状态时)"/> |
|
66 |
</a-form-item> |
|
67 |
</a-col> |
|
68 |
<a-col :md="8" :sm="24"> |
|
69 |
<a-form-item label="编辑状态 0:草稿 1:发布"> |
|
70 |
<a-input v-model="queryParam.editorStatus" allow-clear placeholder="请输入编辑状态 0:草稿 1:发布"/> |
|
71 |
</a-form-item> |
|
72 |
</a-col> |
|
73 |
<a-col :md="8" :sm="24"> |
|
74 |
<a-form-item label="归档年份(以初次发布时间为准)"> |
|
75 |
<a-input v-model="queryParam.separateYear" allow-clear placeholder="请输入归档年份(以初次发布时间为准)"/> |
|
76 |
</a-form-item> |
|
77 |
</a-col> |
|
78 |
<a-col :md="8" :sm="24"> |
|
79 |
<a-form-item label="归档月份"> |
|
80 |
<a-input v-model="queryParam.separateMonth" allow-clear placeholder="请输入归档月份"/> |
|
81 |
</a-form-item> |
|
82 |
</a-col> |
|
83 |
<a-col :md="8" :sm="24"> |
|
84 |
<a-form-item label="归档日"> |
|
85 |
<a-input v-model="queryParam.separateDay" allow-clear placeholder="请输入归档日"/> |
|
86 |
</a-form-item> |
|
87 |
</a-col> |
|
88 |
<a-col :md="8" :sm="24"> |
|
89 |
<a-form-item label="是否启用 0:否 1:是"> |
|
90 |
<a-input v-model="queryParam.isEnable" allow-clear placeholder="请输入是否启用 0:否 1:是"/> |
|
91 |
</a-form-item> |
|
92 |
</a-col> |
|
93 |
<a-col :md="8" :sm="24"> |
|
94 |
<a-form-item label="更新时间"> |
|
95 |
<a-date-picker style="width: 100%" placeholder="请选择更新时间" v-model="queryParam.updateDateDate" @change="onChangeupdateDate"/> |
|
96 |
</a-form-item> |
|
97 |
</a-col> |
|
98 |
<a-col :md="8" :sm="24"> |
|
99 |
<a-form-item label="创建时间"> |
|
100 |
<a-date-picker style="width: 100%" placeholder="请选择创建时间" v-model="queryParam.createDateDate" @change="onChangecreateDate"/> |
|
101 |
</a-form-item> |
|
102 |
</a-col> |
|
103 |
</template> |
|
104 |
<a-col :md="8" :sm="24" > |
|
105 |
<span class="table-page-search-submitButtons"> |
|
106 |
<a-button type="primary" @click="$refs.table.refresh(true)" >查询</a-button> |
|
107 |
<a-button style="margin-left: 8px" @click="() => queryParam = {}">重置</a-button> |
|
108 |
<a @click="toggleAdvanced" style="margin-left: 8px"> |
|
109 |
{{ advanced ? '收起' : '展开' }} |
|
110 |
<a-icon :type="advanced ? 'up' : 'down'"/> |
|
111 |
</a> |
|
112 |
</span> |
|
113 |
</a-col> |
|
114 |
</a-row> |
|
115 |
</a-form> |
|
116 |
</div> |
|
117 |
</a-card> |
|
118 |
<a-card :bordered="false"> |
|
119 |
<s-table |
|
120 |
ref="table" |
|
121 |
:columns="columns" |
|
122 |
:data="loadData" |
|
123 |
:alert="options.alert" |
|
124 |
:rowKey="(record) => record.id" |
|
125 |
:rowSelection="options.rowSelection" |
|
126 |
> |
|
127 |
<template class="table-operator" slot="operator" v-if="hasPerm('blogArticle:add')" > |
|
128 |
<a-button type="primary" v-if="hasPerm('blogArticle:add')" icon="plus" @click="$refs.addForm.add()">新增blog文章主体</a-button> |
|
129 |
<a-button type="danger" :disabled="selectedRowKeys.length < 1" v-if="hasPerm('blogArticle:delete')" @click="batchDelete"><a-icon type="delete"/>批量删除</a-button> |
|
130 |
<x-down |
|
131 |
v-if="hasPerm('blogArticle:export')" |
|
132 |
ref="batchExport" |
|
133 |
@batchExport="batchExport" |
|
134 |
/> |
|
135 |
</template> |
|
136 |
<span slot="action" slot-scope="text, record"> |
|
137 |
<a v-if="hasPerm('blogArticle:edit')" @click="$refs.editForm.edit(record)">编辑</a> |
|
138 |
<a-divider type="vertical" v-if="hasPerm('blogArticle:edit') & hasPerm('blogArticle:delete')"/> |
|
139 |
<a-popconfirm v-if="hasPerm('blogArticle:delete')" placement="topRight" title="确认删除?" @confirm="() => singleDelete(record)"> |
|
140 |
<a>删除</a> |
|
141 |
</a-popconfirm> |
|
142 |
</span> |
|
143 |
</s-table> |
|
144 |
<add-form ref="addForm" @ok="handleOk" /> |
|
145 |
<edit-form ref="editForm" @ok="handleOk" /> |
|
146 |
</a-card> |
|
147 |
</div> |
|
148 |
</template> |
|
149 |
<script> |
|
150 |
import { STable, XDown } from '@/components' |
|
151 |
import moment from 'moment' |
|
152 |
import { blogArticlePage, blogArticleDelete, blogArticleExport } from '@/api/modular/main/blogarticle/blogArticleManage' |
|
153 |
import addForm from './addForm.vue' |
|
154 |
import editForm from './editForm.vue' |
|
155 |
export default { |
|
156 |
components: { |
|
157 |
STable, |
|
158 |
addForm, |
|
159 |
editForm, |
|
160 |
XDown |
|
161 |
}, |
|
162 |
data () { |
|
163 |
return { |
|
164 |
// 高级搜索 展开/关闭 |
|
165 |
advanced: false, |
|
166 |
// 查询参数 |
|
167 |
queryParam: {}, |
|
168 |
// 表头 |
|
169 |
columns: [ |
|
170 |
{ |
|
171 |
title: '文章标题', |
|
172 |
align: 'center', |
|
173 |
dataIndex: 'title' |
|
174 |
}, |
|
175 |
{ |
|
176 |
title: '文章文件id', |
|
177 |
align: 'center', |
|
178 |
dataIndex: 'articleFileId' |
|
179 |
}, |
|
180 |
{ |
|
181 |
title: '文件类型 1:markdown 2:html', |
|
182 |
align: 'center', |
|
183 |
dataIndex: 'articleFileType' |
|
184 |
}, |
|
185 |
{ |
|
186 |
title: '文章分类id 0:没有分类', |
|
187 |
align: 'center', |
|
188 |
dataIndex: 'articleTypeId' |
|
189 |
}, |
|
190 |
{ |
|
191 |
title: '文章引言', |
|
192 |
align: 'center', |
|
193 |
dataIndex: 'introduce' |
|
194 |
}, |
|
195 |
{ |
|
196 |
title: '封面文件地址(id)', |
|
197 |
align: 'center', |
|
198 |
dataIndex: 'coverFileId' |
|
199 |
}, |
|
200 |
{ |
|
201 |
title: '上次编辑时间', |
|
202 |
align: 'center', |
|
203 |
dataIndex: 'lastEditorDate' |
|
204 |
}, |
|
205 |
{ |
|
206 |
title: '发布时间', |
|
207 |
align: 'center', |
|
208 |
dataIndex: 'publishDate' |
|
209 |
}, |
|
210 |
{ |
|
211 |
title: '是否置顶 0:否 1:是', |
|
212 |
align: 'center', |
|
213 |
dataIndex: 'isTop' |
|
214 |
}, |
|
215 |
{ |
|
216 |
title: '置顶值(越小越靠前)', |
|
217 |
align: 'center', |
|
218 |
dataIndex: 'topValue' |
|
219 |
}, |
|
220 |
{ |
|
221 |
title: '公开状态 1:公开 2:私密 3:密码授权', |
|
222 |
align: 'center', |
|
223 |
dataIndex: 'authStatus' |
|
224 |
}, |
|
225 |
{ |
|
226 |
title: '授权密码(在密码授权状态时)', |
|
227 |
align: 'center', |
|
228 |
dataIndex: 'authPassword' |
|
229 |
}, |
|
230 |
{ |
|
231 |
title: '编辑状态 0:草稿 1:发布', |
|
232 |
align: 'center', |
|
233 |
dataIndex: 'editorStatus' |
|
234 |
}, |
|
235 |
{ |
|
236 |
title: '归档年份(以初次发布时间为准)', |
|
237 |
align: 'center', |
|
238 |
dataIndex: 'separateYear' |
|
239 |
}, |
|
240 |
{ |
|
241 |
title: '归档月份', |
|
242 |
align: 'center', |
|
243 |
dataIndex: 'separateMonth' |
|
244 |
}, |
|
245 |
{ |
|
246 |
title: '归档日', |
|
247 |
align: 'center', |
|
248 |
dataIndex: 'separateDay' |
|
249 |
}, |
|
250 |
{ |
|
251 |
title: '是否启用 0:否 1:是', |
|
252 |
align: 'center', |
|
253 |
dataIndex: 'isEnable' |
|
254 |
}, |
|
255 |
{ |
|
256 |
title: '更新时间', |
|
257 |
align: 'center', |
|
258 |
dataIndex: 'updateDate' |
|
259 |
}, |
|
260 |
{ |
|
261 |
title: '创建时间', |
|
262 |
align: 'center', |
|
263 |
dataIndex: 'createDate' |
|
264 |
} |
|
265 |
], |
|
266 |
tstyle: { 'padding-bottom': '0px', 'margin-bottom': '10px' }, |
|
267 |
// 加载数据方法 必须为 Promise 对象 |
|
268 |
loadData: parameter => { |
|
269 |
return blogArticlePage(Object.assign(parameter, this.switchingDate())).then((res) => { |
|
270 |
return res.data |
|
271 |
}) |
|
272 |
}, |
|
273 |
selectedRowKeys: [], |
|
274 |
selectedRows: [], |
|
275 |
options: { |
|
276 |
alert: { show: true, clear: () => { this.selectedRowKeys = [] } }, |
|
277 |
rowSelection: { |
|
278 |
selectedRowKeys: this.selectedRowKeys, |
|
279 |
onChange: this.onSelectChange |
|
280 |
} |
|
281 |
} |
|
282 |
} |
|
283 |
}, |
|
284 |
created () { |
|
285 |
if (this.hasPerm('blogArticle:edit') || this.hasPerm('blogArticle:delete')) { |
|
286 |
this.columns.push({ |
|
287 |
title: '操作', |
|
288 |
width: '150px', |
|
289 |
dataIndex: 'action', |
|
290 |
scopedSlots: { customRender: 'action' } |
|
291 |
}) |
|
292 |
} |
|
293 |
}, |
|
294 |
methods: { |
|
295 |
moment, |
|
296 |
/** |
|
297 |
* 查询参数组装 |
|
298 |
*/ |
|
299 |
switchingDate () { |
|
300 |
const queryParamlastEditorDate = this.queryParam.lastEditorDateDate |
|
301 |
if (queryParamlastEditorDate != null) { |
|
302 |
this.queryParam.lastEditorDate = moment(queryParamlastEditorDate).format('YYYY-MM-DD') |
|
303 |
if (queryParamlastEditorDate.length < 1) { |
|
304 |
delete this.queryParam.lastEditorDate |
|
305 |
} |
|
306 |
} |
|
307 |
const queryParampublishDate = this.queryParam.publishDateDate |
|
308 |
if (queryParampublishDate != null) { |
|
309 |
this.queryParam.publishDate = moment(queryParampublishDate).format('YYYY-MM-DD') |
|
310 |
if (queryParampublishDate.length < 1) { |
|
311 |
delete this.queryParam.publishDate |
|
312 |
} |
|
313 |
} |
|
314 |
const queryParamupdateDate = this.queryParam.updateDateDate |
|
315 |
if (queryParamupdateDate != null) { |
|
316 |
this.queryParam.updateDate = moment(queryParamupdateDate).format('YYYY-MM-DD') |
|
317 |
if (queryParamupdateDate.length < 1) { |
|
318 |
delete this.queryParam.updateDate |
|
319 |
} |
|
320 |
} |
|
321 |
const queryParamcreateDate = this.queryParam.createDateDate |
|
322 |
if (queryParamcreateDate != null) { |
|
323 |
this.queryParam.createDate = moment(queryParamcreateDate).format('YYYY-MM-DD') |
|
324 |
if (queryParamcreateDate.length < 1) { |
|
325 |
delete this.queryParam.createDate |
|
326 |
} |
|
327 |
} |
|
328 |
const obj = JSON.parse(JSON.stringify(this.queryParam)) |
|
329 |
return obj |
|
330 |
}, |
|
331 |
/** |
|
332 |
* 单个删除 |
|
333 |
*/ |
|
334 |
singleDelete (record) { |
|
335 |
const param = [{ 'id': record.id }] |
|
336 |
this.blogArticleDelete(param) |
|
337 |
}, |
|
338 |
/** |
|
339 |
* 批量删除 |
|
340 |
*/ |
|
341 |
batchDelete () { |
|
342 |
const paramIds = this.selectedRowKeys.map((d) => { |
|
343 |
return { 'id': d } |
|
344 |
}) |
|
345 |
this.blogArticleDelete(paramIds) |
|
346 |
}, |
|
347 |
blogArticleDelete (record) { |
|
348 |
blogArticleDelete(record).then((res) => { |
|
349 |
if (res.success) { |
|
350 |
this.$message.success('删除成功') |
|
351 |
this.$refs.table.clearRefreshSelected() |
|
352 |
} else { |
|
353 |
this.$message.error('删除失败') // + res.message |
|
354 |
} |
|
355 |
}) |
|
356 |
}, |
|
357 |
toggleAdvanced () { |
|
358 |
this.advanced = !this.advanced |
|
359 |
}, |
|
360 |
onChangelastEditorDate(date, dateString) { |
|
361 |
this.lastEditorDateDateString = dateString |
|
362 |
}, |
|
363 |
onChangepublishDate(date, dateString) { |
|
364 |
this.publishDateDateString = dateString |
|
365 |
}, |
|
366 |
onChangeupdateDate(date, dateString) { |
|
367 |
this.updateDateDateString = dateString |
|
368 |
}, |
|
369 |
onChangecreateDate(date, dateString) { |
|
370 |
this.createDateDateString = dateString |
|
371 |
}, |
|
372 |
/** |
|
373 |
* 批量导出 |
|
374 |
*/ |
|
375 |
batchExport () { |
|
376 |
const paramIds = this.selectedRowKeys.map((d) => { |
|
377 |
return { 'id': d } |
|
378 |
}) |
|
379 |
blogArticleExport(paramIds).then((res) => { |
|
380 |
this.$refs.batchExport.downloadfile(res) |
|
381 |
}) |
|
382 |
}, |
|
383 |
handleOk () { |
|
384 |
this.$refs.table.refresh() |
|
385 |
}, |
|
386 |
onSelectChange (selectedRowKeys, selectedRows) { |
|
387 |
this.selectedRowKeys = selectedRowKeys |
|
388 |
this.selectedRows = selectedRows |
|
389 |
} |
|
390 |
} |
|
391 |
} |
|
392 |
</script> |
|
393 |
<style lang="less"> |
|
394 |
.table-operator { |
|
395 |
margin-bottom: 18px; |
|
396 |
} |
|
397 |
button { |
|
398 |
margin-right: 8px; |
|
399 |
} |
|
400 |
</style> |