|
@@ -1,14 +1,361 @@
|
1
|
1
|
<template>
|
2
|
|
- <div>user</div>
|
|
2
|
+ <div>
|
|
3
|
+ <div class="searchBox">
|
|
4
|
+ <div>
|
|
5
|
+ <RadioGroup v-model="newsSearch.ltype" @on-change="searchList()">
|
|
6
|
+ <Radio :label="1">中文</Radio>
|
|
7
|
+ <Radio :label="2">英文</Radio>
|
|
8
|
+ </RadioGroup>
|
|
9
|
+ <Input
|
|
10
|
+ v-model="newsSearch.newstitle"
|
|
11
|
+ @on-search="searchList()"
|
|
12
|
+ placeholder="请输入标题"
|
|
13
|
+ style="margin: 0 16px; width: 200px"
|
|
14
|
+ clearable
|
|
15
|
+ search
|
|
16
|
+ />
|
|
17
|
+ <!-- <Button type="primary" @click="searchList()">搜索</Button> -->
|
|
18
|
+ </div>
|
|
19
|
+ <div>
|
|
20
|
+ <Button type="primary" @click="toAdd()">添加</Button>
|
|
21
|
+ </div>
|
|
22
|
+ </div>
|
|
23
|
+ <Table border :columns="newsColumns" :data="newsSearch.list">
|
|
24
|
+ <template slot-scope="{ row }" slot="newspicSlot">
|
|
25
|
+ <img v-viewer class="news_pic" :src="$api.showImageUrl + row.newspic" />
|
|
26
|
+ </template>
|
|
27
|
+ <template slot-scope="{ row }" slot="loginstateSlot">
|
|
28
|
+ <span>{{ row.loginstate === 1 ? "成功" : "失败" }}</span>
|
|
29
|
+ </template>
|
|
30
|
+ <template slot-scope="{ row }" slot="createtimeSlot">
|
|
31
|
+ <span>{{ dateFormat(row.createtime) }}</span>
|
|
32
|
+ </template>
|
|
33
|
+ <template slot-scope="{ row }" slot="actionSlot">
|
|
34
|
+ <div>
|
|
35
|
+ <span
|
|
36
|
+ style="color: #2d8cf0; cursor: pointer"
|
|
37
|
+ @click="toViewDetail(row)"
|
|
38
|
+ >查看</span
|
|
39
|
+ >
|
|
40
|
+ <span style="margin: 0 10px; color: #2d8cf0">|</span>
|
|
41
|
+ <span style="color: #2d8cf0; cursor: pointer" @click="toModify(row)"
|
|
42
|
+ >修改</span
|
|
43
|
+ >
|
|
44
|
+ <span style="margin: 0 10px; color: #2d8cf0">|</span>
|
|
45
|
+ <span
|
|
46
|
+ style="color: #ff001e; cursor: pointer"
|
|
47
|
+ @click="toDel(row.newsid)"
|
|
48
|
+ >删除</span
|
|
49
|
+ >
|
|
50
|
+ </div>
|
|
51
|
+ </template>
|
|
52
|
+ </Table>
|
|
53
|
+ <div class="foot_page" v-if="newsSearch.total > 0">
|
|
54
|
+ <Page
|
|
55
|
+ :total="newsSearch.total"
|
|
56
|
+ @on-change="changePage"
|
|
57
|
+ :current="newsSearch.page"
|
|
58
|
+ show-total
|
|
59
|
+ ></Page>
|
|
60
|
+ </div>
|
|
61
|
+ <Modal
|
|
62
|
+ v-model="addForm.show"
|
|
63
|
+ class="modal1"
|
|
64
|
+ :mask-closable="false"
|
|
65
|
+ title="添加新闻资讯"
|
|
66
|
+ >
|
|
67
|
+ <Form
|
|
68
|
+ :label-width="60"
|
|
69
|
+ label-position="right"
|
|
70
|
+ ref="addForm"
|
|
71
|
+ :rules="formRules"
|
|
72
|
+ :model="addForm"
|
|
73
|
+ >
|
|
74
|
+ <FormItem label="语言" prop="ltype">
|
|
75
|
+ <RadioGroup v-model="addForm.ltype">
|
|
76
|
+ <Radio :label="1">中文</Radio>
|
|
77
|
+ <Radio :label="2">英文</Radio>
|
|
78
|
+ </RadioGroup>
|
|
79
|
+ </FormItem>
|
|
80
|
+ <FormItem label="封面" prop="newspic"></FormItem>
|
|
81
|
+ <FormItem label="置顶" prop="newsup">
|
|
82
|
+ <RadioGroup v-model="addForm.newsup">
|
|
83
|
+ <Radio :label="1">置顶</Radio>
|
|
84
|
+ <Radio :label="2">不置顶</Radio>
|
|
85
|
+ </RadioGroup>
|
|
86
|
+ </FormItem>
|
|
87
|
+ <FormItem label="排序" prop="newsorder">
|
|
88
|
+ <InputNumber :min="1" v-model="addForm.newsorder" />
|
|
89
|
+ </FormItem>
|
|
90
|
+ <FormItem label="标题" prop="newstitle">
|
|
91
|
+ <Input
|
|
92
|
+ :maxlength="255"
|
|
93
|
+ show-word-limit
|
|
94
|
+ v-model="addForm.newstitle"
|
|
95
|
+ placeholder="请输入标题"
|
|
96
|
+ />
|
|
97
|
+ </FormItem>
|
|
98
|
+ <FormItem label="摘要" prop="newssummary">
|
|
99
|
+ <Input
|
|
100
|
+ type="textarea"
|
|
101
|
+ :rows="3"
|
|
102
|
+ v-model="addForm.newssummary"
|
|
103
|
+ :maxlength="255"
|
|
104
|
+ show-word-limit
|
|
105
|
+ placeholder="请输入摘要"
|
|
106
|
+ />
|
|
107
|
+ </FormItem>
|
|
108
|
+ <FormItem label="内容" prop="newscontent"></FormItem>
|
|
109
|
+ </Form>
|
|
110
|
+ <div slot="footer" style="text-align: right">
|
|
111
|
+ <Button @click="addForm.show = false">取消</Button>
|
|
112
|
+ <Button @click="toSaveAdd()" type="primary">保存</Button>
|
|
113
|
+ </div>
|
|
114
|
+ </Modal>
|
|
115
|
+ </div>
|
3
|
116
|
</template>
|
4
|
117
|
|
5
|
118
|
<script>
|
|
119
|
+import { n_list, n_save, n_update, n_remove, n_detail } from "@/api";
|
|
120
|
+import { dateFormat } from "@/utils";
|
6
|
121
|
export default {
|
7
|
122
|
data() {
|
8
|
|
- return {};
|
|
123
|
+ return {
|
|
124
|
+ dateFormat,
|
|
125
|
+ newsSearch: {
|
|
126
|
+ ltype: 1,
|
|
127
|
+ newstitle: "",
|
|
128
|
+ page: 1,
|
|
129
|
+ size: 10,
|
|
130
|
+ total: 0,
|
|
131
|
+ list: []
|
|
132
|
+ },
|
|
133
|
+ newsColumns: [
|
|
134
|
+ {
|
|
135
|
+ title: "序号",
|
|
136
|
+ width: 70,
|
|
137
|
+ render: (h, params) => {
|
|
138
|
+ return h(
|
|
139
|
+ "span",
|
|
140
|
+ params.index +
|
|
141
|
+ (this.newsSearch.page - 1) * this.newsSearch.size +
|
|
142
|
+ 1
|
|
143
|
+ );
|
|
144
|
+ }
|
|
145
|
+ },
|
|
146
|
+ {
|
|
147
|
+ title: "封面",
|
|
148
|
+ slot: "newspicSlot",
|
|
149
|
+ width: 240
|
|
150
|
+ },
|
|
151
|
+ {
|
|
152
|
+ title: "置顶",
|
|
153
|
+ key: "newsup",
|
|
154
|
+ width: 70
|
|
155
|
+ },
|
|
156
|
+ {
|
|
157
|
+ title: "排序",
|
|
158
|
+ key: "newsorder",
|
|
159
|
+ width: 70
|
|
160
|
+ },
|
|
161
|
+ {
|
|
162
|
+ title: "标题",
|
|
163
|
+ key: "newstitle",
|
|
164
|
+ width: 240
|
|
165
|
+ },
|
|
166
|
+ {
|
|
167
|
+ title: "摘要",
|
|
168
|
+ key: "newssummary"
|
|
169
|
+ },
|
|
170
|
+ {
|
|
171
|
+ title: "创建人",
|
|
172
|
+ key: "createname",
|
|
173
|
+ width: 100
|
|
174
|
+ },
|
|
175
|
+ {
|
|
176
|
+ title: "创建时间",
|
|
177
|
+ slot: "createtimeSlot",
|
|
178
|
+ width: 180
|
|
179
|
+ },
|
|
180
|
+ {
|
|
181
|
+ title: "操作",
|
|
182
|
+ slot: "actionSlot",
|
|
183
|
+ width: 180
|
|
184
|
+ }
|
|
185
|
+ ],
|
|
186
|
+ userInfo: {},
|
|
187
|
+ searchOption: {
|
|
188
|
+ disabledDate(date) {
|
|
189
|
+ return date && date.valueOf() > Date.now();
|
|
190
|
+ }
|
|
191
|
+ },
|
|
192
|
+ addForm: {
|
|
193
|
+ show: false,
|
|
194
|
+ ltype: 1,
|
|
195
|
+ newspic: "",
|
|
196
|
+ newstitle: "",
|
|
197
|
+ newssummary: "",
|
|
198
|
+ newsup: 2,
|
|
199
|
+ newsorder: 1,
|
|
200
|
+ newscontent: ""
|
|
201
|
+ },
|
|
202
|
+ formRules: {
|
|
203
|
+ ltype: [
|
|
204
|
+ {
|
|
205
|
+ required: true,
|
|
206
|
+ message: "请选择语言",
|
|
207
|
+ trigger: "change"
|
|
208
|
+ }
|
|
209
|
+ ],
|
|
210
|
+ newsup: [
|
|
211
|
+ {
|
|
212
|
+ required: true,
|
|
213
|
+ message: "请选择是否置顶",
|
|
214
|
+ trigger: "change"
|
|
215
|
+ }
|
|
216
|
+ ],
|
|
217
|
+ newspic: [
|
|
218
|
+ {
|
|
219
|
+ required: true,
|
|
220
|
+ message: "请上传图片",
|
|
221
|
+ trigger: "change"
|
|
222
|
+ }
|
|
223
|
+ ],
|
|
224
|
+ newstitle: [
|
|
225
|
+ {
|
|
226
|
+ required: true,
|
|
227
|
+ message: "请输入标题",
|
|
228
|
+ trigger: "blur"
|
|
229
|
+ }
|
|
230
|
+ ],
|
|
231
|
+ newscontent: [
|
|
232
|
+ {
|
|
233
|
+ required: true,
|
|
234
|
+ message: "请输入内容",
|
|
235
|
+ trigger: "change"
|
|
236
|
+ }
|
|
237
|
+ ],
|
|
238
|
+ newssummary: [
|
|
239
|
+ {
|
|
240
|
+ required: true,
|
|
241
|
+ message: "请输入摘要",
|
|
242
|
+ trigger: "blur"
|
|
243
|
+ }
|
|
244
|
+ ],
|
|
245
|
+ newsorder: [
|
|
246
|
+ {
|
|
247
|
+ required: true,
|
|
248
|
+ message: "请输入排序",
|
|
249
|
+ trigger: "blur"
|
|
250
|
+ }
|
|
251
|
+ ]
|
|
252
|
+ },
|
|
253
|
+ modifyForm: {
|
|
254
|
+ show: false,
|
|
255
|
+ newsid: null,
|
|
256
|
+ newspic: "",
|
|
257
|
+ newstitle: "",
|
|
258
|
+ newssummary: "",
|
|
259
|
+ newsup: 2,
|
|
260
|
+ newsorder: 1,
|
|
261
|
+ newscontent: ""
|
|
262
|
+ }
|
|
263
|
+ };
|
9
|
264
|
},
|
10
|
|
- methods: {}
|
|
265
|
+ created() {
|
|
266
|
+ this.userInfo = JSON.parse(localStorage.getItem("xhWebAdminUser"));
|
|
267
|
+ this.getNewsList();
|
|
268
|
+ },
|
|
269
|
+ methods: {
|
|
270
|
+ searchList() {
|
|
271
|
+ this.newsSearch.page = 1;
|
|
272
|
+ this.getNewsList();
|
|
273
|
+ },
|
|
274
|
+ getNewsList() {
|
|
275
|
+ n_list({
|
|
276
|
+ ltype: this.newsSearch.ltype,
|
|
277
|
+ newstitle: this.newsSearch.newstitle,
|
|
278
|
+ page: this.newsSearch.page,
|
|
279
|
+ size: this.newsSearch.size
|
|
280
|
+ })
|
|
281
|
+ .then((data) => {
|
|
282
|
+ if (data.code === 0) {
|
|
283
|
+ this.newsSearch.total = data.obj.total;
|
|
284
|
+ this.newsSearch.list = data.obj.list;
|
|
285
|
+ } else {
|
|
286
|
+ this.newsSearch.total = 0;
|
|
287
|
+ this.newsSearch.list = [];
|
|
288
|
+ this.$Message.error(data.msg);
|
|
289
|
+ }
|
|
290
|
+ })
|
|
291
|
+ .catch(() => {});
|
|
292
|
+ },
|
|
293
|
+ changePage(page) {
|
|
294
|
+ this.newsSearch.page = page;
|
|
295
|
+ this.getNewsList();
|
|
296
|
+ },
|
|
297
|
+ toAdd() {
|
|
298
|
+ this.addForm = {
|
|
299
|
+ show: true,
|
|
300
|
+ ltype: 1,
|
|
301
|
+ newspic: "",
|
|
302
|
+ newstitle: "",
|
|
303
|
+ newssummary: "",
|
|
304
|
+ newsup: 2,
|
|
305
|
+ newsorder: 1,
|
|
306
|
+ newscontent: ""
|
|
307
|
+ };
|
|
308
|
+ },
|
|
309
|
+ toSaveAdd() {},
|
|
310
|
+ toModify(row) {
|
|
311
|
+ this.modifyForm = {
|
|
312
|
+ show: true,
|
|
313
|
+ newsid: row.newsid,
|
|
314
|
+ newspic: row.newspic,
|
|
315
|
+ newstitle: row.newstitle,
|
|
316
|
+ newssummary: row.newssummary,
|
|
317
|
+ newsup: row.newsup,
|
|
318
|
+ newsorder: row.newsorder,
|
|
319
|
+ newscontent: row.newscontent
|
|
320
|
+ };
|
|
321
|
+ },
|
|
322
|
+ toSaveModify() {},
|
|
323
|
+ toDel(newsid) {
|
|
324
|
+ this.$Modal.confirm({
|
|
325
|
+ title: "提示",
|
|
326
|
+ content: "您确定删除选中数据吗?",
|
|
327
|
+ onOk: () => {
|
|
328
|
+ n_remove({ newsid }).then((res) => {
|
|
329
|
+ if (res.code == 0) {
|
|
330
|
+ this.$Message.success(res.msg);
|
|
331
|
+ this.searchList();
|
|
332
|
+ }
|
|
333
|
+ });
|
|
334
|
+ },
|
|
335
|
+ onCancel: () => {}
|
|
336
|
+ });
|
|
337
|
+ },
|
|
338
|
+ toViewDetail(row) {
|
|
339
|
+ console.log("toViewDetail", row);
|
|
340
|
+ }
|
|
341
|
+ }
|
11
|
342
|
};
|
12
|
343
|
</script>
|
13
|
344
|
|
14
|
|
-<style scoped lang="less"></style>
|
|
345
|
+<style scoped lang="less">
|
|
346
|
+.searchBox {
|
|
347
|
+ display: flex;
|
|
348
|
+ justify-content: space-between;
|
|
349
|
+ padding: 16px 0;
|
|
350
|
+}
|
|
351
|
+.news_pic {
|
|
352
|
+ display: block;
|
|
353
|
+ margin: 10px auto;
|
|
354
|
+ width: 200px;
|
|
355
|
+ object-fit: cover;
|
|
356
|
+}
|
|
357
|
+.foot_page {
|
|
358
|
+ padding: 16px 0;
|
|
359
|
+ text-align: right;
|
|
360
|
+}
|
|
361
|
+</style>
|