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
| <template>
| <el-bus-crud ref="crud" v-bind="tableConfig" />
| </template>
|
| <script>
| export default {
| data() {
| return {
| tableConfig: {
| url: 'flower/api/announcement/page',
| dialogNeedRequest: true,
| persistSelection: true,
| columns: [
| { type: 'selection' },
| { label: '标题', prop: 'title' },
| { label: '发布日期', prop: 'publishDate' },
| { label: '编辑日期', prop: 'updateTime' },
| { label: '状态', prop: 'statusStr' },
| ],
| searchForm: [
| {
| type: 'row',
| items: [
| { label: '标题', id: 'title', type: 'input' },
| {
| label: '创建日期',
| id: 'createDateBeginStr',
| component: 'el-bus-date-range',
| commonFormat: true,
| commonFormatProps: ['createDateBeginStr', 'createDateEndStr'],
| customClass: 'in-bus-form',
| },
| ],
| },
| ],
| form: [
| {
| label: '标题:',
| id: 'title',
| type: 'input',
| rules: {
| required: true,
| message: '请输入标题',
| trigger: 'blur',
| },
| },
| {
| label: '公告类型:',
| id: 'type',
| type: 'bus-select-dict',
| el: {
| code: 'ANNOUNCEMENT_TYPE',
| style: 'width:100%',
| clearable: true,
| },
| rules: {
| required: true,
| message: '请选择公告类型',
| },
| },
| {
| label: '内容:',
| id: 'content',
| component: 'base-editor',
| richText: true,
| rules: { required: true, message: '请输入内容', trigger: 'blur' },
| },
| {
| label: '封面:',
| id: 'cover',
| type: 'bus-upload',
| el: {
| listType: 'picture-card',
| limitSize: 2,
| limit: 1,
| tipText: '大小不超过2M',
| valueType: 'string',
| },
| forceDisabled: true,
| },
| ],
| extraButtons: [
| {
| text: (row) => (row.status === 'unpublished' ? '发布' : '下架'),
| atClick: async (row) => {
| const action = row.status === 'unpublished' ? '发布' : '下架'
| try {
| await this.$elBusUtil.confirm(`确定要${action}吗?`)
| const { code } = await this.$elBusHttp.request(
| 'flower/api/announcement/page/changeStatus',
| { params: { id: row.id } }
| )
| if (code === 0) {
| this.$message.success(`${action}成功`)
| }
| } catch (e) {
| return false
| }
| },
| },
| ],
| headerButtons: [
| {
| text: '批量发布',
| type: 'primary',
| disabled: (selected) =>
| selected.filter((item) => item.status === 'unpublished')
| .length === 0,
| atClick: async (selected) => {
| const selectedNotice = selected.filter(
| (item) => item.status === 'unpublished'
| )
| try {
| await this.$elBusUtil.confirm(
| `确定要批量发布这${selectedNotice.length}个公告吗?`
| )
| const { code } = await this.$elBusHttp.request(
| 'flower/api/announcement/page/publish/batch',
| {
| method: 'post',
| data: {
| ids: selected.map((item) => item.id),
| },
| }
| )
| if (code === 0) {
| this.$message.success('操作成功')
| this.$refs.crud.clearSelection()
| }
| } catch (e) {
| return false
| }
| },
| },
| {
| text: '批量删除',
| type: 'danger',
| disabled: (selected) => selected.length === 0,
| atClick: async (selected) => {
| try {
| await this.$elBusUtil.confirm(
| `确定要批量删除这${selected.length}个公告吗?`
| )
| const { code } = await this.$elBusHttp.request(
| 'flower/api/announcement/page/delete/batch',
| {
| method: 'post',
| data: {
| ids: selected.map((item) => item.id),
| },
| }
| )
| if (code === 0) {
| this.$message.success('操作成功')
| this.$refs.crud.clearSelection()
| }
| } catch (e) {
| return false
| }
| },
| },
| ],
| },
| }
| },
| head() {
| return {
| title: '公告管理',
| }
| },
| }
| </script>
|
| <style lang="scss" scoped>
| ::v-deep {
| .el-upload {
| &-list__item {
| width: 345px;
| height: 128px;
| }
| &.el-upload--picture-card {
| width: 345px;
| height: 128px;
| }
| }
| }
| </style>
|
|