commit | author | age
|
91dc6c
|
1 |
<template> |
I |
2 |
<div> |
|
3 |
<a-card :bordered="false" :bodyStyle="tstyle"> |
|
4 |
<div class="table-page-search-wrapper" v-if="hasPerm('blogArticleType: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.typeName" allow-clear placeholder="请输入分类名称"/> |
|
10 |
</a-form-item> |
|
11 |
</a-col> |
|
12 |
<a-col :md="8" :sm="24"> |
|
13 |
<a-form-item label="公开类型"> |
|
14 |
<a-select style="width: 100%" v-model="queryParam.openType" placeholder="请选择公开类型"> |
|
15 |
<a-select-option v-for="(item,index) in openTypeData" :key="index" :value="item.code">{{ item.name }}</a-select-option> |
|
16 |
</a-select> |
|
17 |
</a-form-item> |
|
18 |
</a-col> |
|
19 |
<template v-if="advanced"> |
|
20 |
<a-col :md="8" :sm="24"> |
|
21 |
<a-form-item label="是否启用"> |
|
22 |
<a-select style="width: 100%" v-model="queryParam.isEnable" placeholder="请选择是否启用"> |
|
23 |
<a-select-option v-for="(item,index) in isEnableData" :key="index" :value="item.code">{{ item.name }}</a-select-option> |
|
24 |
</a-select> |
|
25 |
</a-form-item> |
|
26 |
</a-col> |
|
27 |
<a-col :md="8" :sm="24"> |
|
28 |
<a-form-item label="创建时间"> |
|
29 |
<a-date-picker style="width: 100%" placeholder="请选择创建时间" v-model="queryParam.createDateDate" @change="onChangecreateDate"/> |
|
30 |
</a-form-item> |
|
31 |
</a-col> |
|
32 |
</template> |
|
33 |
<a-col :md="8" :sm="24" > |
|
34 |
<span class="table-page-search-submitButtons"> |
|
35 |
<a-button type="primary" @click="$refs.table.refresh(true)" >查询</a-button> |
|
36 |
<a-button style="margin-left: 8px" @click="() => queryParam = {}">重置</a-button> |
|
37 |
<a @click="toggleAdvanced" style="margin-left: 8px"> |
|
38 |
{{ advanced ? '收起' : '展开' }} |
|
39 |
<a-icon :type="advanced ? 'up' : 'down'"/> |
|
40 |
</a> |
|
41 |
</span> |
|
42 |
</a-col> |
|
43 |
</a-row> |
|
44 |
</a-form> |
|
45 |
</div> |
|
46 |
</a-card> |
|
47 |
<a-card :bordered="false"> |
|
48 |
<s-table |
|
49 |
ref="table" |
|
50 |
:columns="columns" |
|
51 |
:data="loadData" |
|
52 |
:alert="options.alert" |
|
53 |
:rowKey="(record) => record.id" |
|
54 |
:rowSelection="options.rowSelection" |
|
55 |
> |
|
56 |
<template class="table-operator" slot="operator" v-if="hasPerm('blogArticleType:add')" > |
|
57 |
<a-button type="primary" v-if="hasPerm('blogArticleType:add')" icon="plus" @click="$refs.addForm.add()">新增blog文章分类</a-button> |
|
58 |
<a-button type="danger" :disabled="selectedRowKeys.length < 1" v-if="hasPerm('blogArticleType:delete')" @click="batchDelete"><a-icon type="delete"/>批量删除</a-button> |
|
59 |
<x-down |
|
60 |
v-if="hasPerm('blogArticleType:export')" |
|
61 |
ref="batchExport" |
|
62 |
@batchExport="batchExport" |
|
63 |
/> |
|
64 |
</template> |
|
65 |
<span slot="openTypeScopedSlots" slot-scope="text"> |
|
66 |
{{ 'blog_auth_status' | dictType(text) }} |
|
67 |
</span> |
|
68 |
<span slot="isEnableScopedSlots" slot-scope="text"> |
|
69 |
{{ 'blog_yes_or_no' | dictType(text) }} |
|
70 |
</span> |
|
71 |
<span slot="action" slot-scope="text, record"> |
|
72 |
<a v-if="hasPerm('blogArticleType:edit')" @click="$refs.editForm.edit(record)">编辑</a> |
|
73 |
<a-divider type="vertical" v-if="hasPerm('blogArticleType:edit') & hasPerm('blogArticleType:delete')"/> |
|
74 |
<a-popconfirm v-if="hasPerm('blogArticleType:delete')" placement="topRight" title="确认删除?" @confirm="() => singleDelete(record)"> |
|
75 |
<a>删除</a> |
|
76 |
</a-popconfirm> |
|
77 |
</span> |
|
78 |
</s-table> |
|
79 |
<add-form ref="addForm" @ok="handleOk" /> |
|
80 |
<edit-form ref="editForm" @ok="handleOk" /> |
|
81 |
</a-card> |
|
82 |
</div> |
|
83 |
</template> |
|
84 |
<script> |
|
85 |
import { STable, XDown } from '@/components' |
|
86 |
import moment from 'moment' |
|
87 |
import { blogArticleTypePage, blogArticleTypeDelete, blogArticleTypeExport } from '@/api/modular/main/blogarticletype/blogArticleTypeManage' |
|
88 |
import addForm from './addForm.vue' |
|
89 |
import editForm from './editForm.vue' |
|
90 |
export default { |
|
91 |
components: { |
|
92 |
STable, |
|
93 |
addForm, |
|
94 |
editForm, |
|
95 |
XDown |
|
96 |
}, |
|
97 |
data () { |
|
98 |
return { |
|
99 |
// 高级搜索 展开/关闭 |
|
100 |
advanced: false, |
|
101 |
// 查询参数 |
|
102 |
queryParam: {}, |
|
103 |
// 表头 |
|
104 |
columns: [ |
|
105 |
{ |
|
106 |
title: '分类名称', |
|
107 |
align: 'center', |
|
108 |
dataIndex: 'typeName' |
|
109 |
}, |
|
110 |
{ |
|
111 |
title: '公开类型', |
|
112 |
align: 'center', |
|
113 |
dataIndex: 'openType', |
|
114 |
scopedSlots: { customRender: 'openTypeScopedSlots' } |
|
115 |
}, |
|
116 |
{ |
|
117 |
title: '是否启用', |
|
118 |
align: 'center', |
|
119 |
dataIndex: 'isEnable', |
|
120 |
scopedSlots: { customRender: 'isEnableScopedSlots' } |
|
121 |
}, |
|
122 |
{ |
|
123 |
title: '置顶值', |
|
124 |
align: 'center', |
|
125 |
dataIndex: 'topValue' |
|
126 |
}, |
|
127 |
{ |
|
128 |
title: '更新时间', |
|
129 |
align: 'center', |
|
130 |
dataIndex: 'updateDate' |
|
131 |
}, |
|
132 |
{ |
|
133 |
title: '创建时间', |
|
134 |
align: 'center', |
|
135 |
dataIndex: 'createDate' |
|
136 |
} |
|
137 |
], |
|
138 |
tstyle: { 'padding-bottom': '0px', 'margin-bottom': '10px' }, |
|
139 |
// 加载数据方法 必须为 Promise 对象 |
|
140 |
loadData: parameter => { |
|
141 |
return blogArticleTypePage(Object.assign(parameter, this.switchingDate())).then((res) => { |
|
142 |
return res.data |
|
143 |
}) |
|
144 |
}, |
|
145 |
openTypeData: [], |
|
146 |
isEnableData: [], |
|
147 |
selectedRowKeys: [], |
|
148 |
selectedRows: [], |
|
149 |
options: { |
|
150 |
alert: { show: true, clear: () => { this.selectedRowKeys = [] } }, |
|
151 |
rowSelection: { |
|
152 |
selectedRowKeys: this.selectedRowKeys, |
|
153 |
onChange: this.onSelectChange |
|
154 |
} |
|
155 |
} |
|
156 |
} |
|
157 |
}, |
|
158 |
created () { |
|
159 |
if (this.hasPerm('blogArticleType:edit') || this.hasPerm('blogArticleType:delete')) { |
|
160 |
this.columns.push({ |
|
161 |
title: '操作', |
|
162 |
width: '150px', |
|
163 |
dataIndex: 'action', |
|
164 |
scopedSlots: { customRender: 'action' } |
|
165 |
}) |
|
166 |
} |
|
167 |
const openTypeOption = this.$options |
|
168 |
this.openTypeData = openTypeOption.filters['dictData']('blog_auth_status') |
|
169 |
const isEnableOption = this.$options |
|
170 |
this.isEnableData = isEnableOption.filters['dictData']('blog_yes_or_no') |
|
171 |
}, |
|
172 |
methods: { |
|
173 |
moment, |
|
174 |
/** |
|
175 |
* 查询参数组装 |
|
176 |
*/ |
|
177 |
switchingDate () { |
|
178 |
const queryParamcreateDate = this.queryParam.createDateDate |
|
179 |
if (queryParamcreateDate != null) { |
|
180 |
this.queryParam.createDate = moment(queryParamcreateDate).format('YYYY-MM-DD') |
|
181 |
if (queryParamcreateDate.length < 1) { |
|
182 |
delete this.queryParam.createDate |
|
183 |
} |
|
184 |
} |
|
185 |
const obj = JSON.parse(JSON.stringify(this.queryParam)) |
|
186 |
return obj |
|
187 |
}, |
|
188 |
/** |
|
189 |
* 单个删除 |
|
190 |
*/ |
|
191 |
singleDelete (record) { |
|
192 |
const param = [{ 'id': record.id }] |
|
193 |
this.blogArticleTypeDelete(param) |
|
194 |
}, |
|
195 |
/** |
|
196 |
* 批量删除 |
|
197 |
*/ |
|
198 |
batchDelete () { |
|
199 |
const paramIds = this.selectedRowKeys.map((d) => { |
|
200 |
return { 'id': d } |
|
201 |
}) |
|
202 |
this.blogArticleTypeDelete(paramIds) |
|
203 |
}, |
|
204 |
blogArticleTypeDelete (record) { |
|
205 |
blogArticleTypeDelete(record).then((res) => { |
|
206 |
if (res.success) { |
|
207 |
this.$message.success('删除成功') |
|
208 |
this.$refs.table.clearRefreshSelected() |
|
209 |
} else { |
|
210 |
this.$message.error('删除失败') // + res.message |
|
211 |
} |
|
212 |
}) |
|
213 |
}, |
|
214 |
toggleAdvanced () { |
|
215 |
this.advanced = !this.advanced |
|
216 |
}, |
|
217 |
onChangecreateDate(date, dateString) { |
|
218 |
this.createDateDateString = dateString |
|
219 |
}, |
|
220 |
/** |
|
221 |
* 批量导出 |
|
222 |
*/ |
|
223 |
batchExport () { |
|
224 |
const paramIds = this.selectedRowKeys.map((d) => { |
|
225 |
return { 'id': d } |
|
226 |
}) |
|
227 |
blogArticleTypeExport(paramIds).then((res) => { |
|
228 |
this.$refs.batchExport.downloadfile(res) |
|
229 |
}) |
|
230 |
}, |
|
231 |
handleOk () { |
|
232 |
this.$refs.table.refresh() |
|
233 |
}, |
|
234 |
onSelectChange (selectedRowKeys, selectedRows) { |
|
235 |
this.selectedRowKeys = selectedRowKeys |
|
236 |
this.selectedRows = selectedRows |
|
237 |
} |
|
238 |
} |
|
239 |
} |
|
240 |
</script> |
|
241 |
<style lang="less"> |
|
242 |
.table-operator { |
|
243 |
margin-bottom: 18px; |
|
244 |
} |
|
245 |
button { |
|
246 |
margin-right: 8px; |
|
247 |
} |
|
248 |
</style> |