|
|
@@ -1,6 +1,6 @@
|
|
1
|
1
|
<template>
|
|
2
|
2
|
<el-card>
|
|
3
|
|
- <el-tabs v-model="activeName" @tab-click="handleClick">
|
|
|
3
|
+ <el-tabs v-model="activeName" @tab-click="handleClickTab">
|
|
4
|
4
|
<el-tab-pane label="电脑端" name="1">
|
|
5
|
5
|
<span class="bgi">自定义背景</span>
|
|
6
|
6
|
<el-upload
|
|
|
@@ -14,18 +14,47 @@
|
|
14
|
14
|
:on-error="uploadError"
|
|
15
|
15
|
list-type="picture"
|
|
16
|
16
|
:show-file-list="false"
|
|
17
|
|
- :file-list="fileList"
|
|
|
17
|
+ :file-list="fileListName"
|
|
18
|
18
|
>
|
|
19
|
19
|
<el-button size="small" type="primary">点击上传</el-button>
|
|
20
|
20
|
</el-upload>
|
|
21
|
21
|
</el-tab-pane>
|
|
22
|
|
- <el-tab-pane label="手机端" name="2">手机端</el-tab-pane>
|
|
23
|
|
- <div>
|
|
24
|
|
- <ul>
|
|
25
|
|
- <li v-for="item in imgData" :key="item.id">
|
|
26
|
|
- <img :src="item.src" alt="" srcset="">
|
|
27
|
|
- </li>
|
|
28
|
|
- </ul>
|
|
|
22
|
+ <el-tab-pane label="手机端" name="2">
|
|
|
23
|
+ <span class="bgi">自定义背景</span>
|
|
|
24
|
+ <el-upload
|
|
|
25
|
+ class="upload-demo"
|
|
|
26
|
+ name="files"
|
|
|
27
|
+ :action="uploadData.uploadUrl"
|
|
|
28
|
+ :data="uploadData.uploaderFiles"
|
|
|
29
|
+ :headers="{'Authorization': token}"
|
|
|
30
|
+ :on-success="uploadSuccess"
|
|
|
31
|
+ :on-remove="uploadRemove"
|
|
|
32
|
+ :on-error="uploadError"
|
|
|
33
|
+ list-type="picture"
|
|
|
34
|
+ :show-file-list="false"
|
|
|
35
|
+ :file-list="fileListName"
|
|
|
36
|
+ >
|
|
|
37
|
+ <el-button size="small" type="primary">点击上传</el-button>
|
|
|
38
|
+ </el-upload>
|
|
|
39
|
+ </el-tab-pane>
|
|
|
40
|
+ <div class="imgList">
|
|
|
41
|
+ <ul>
|
|
|
42
|
+ <li v-for="item in imgData" :key="item.id">
|
|
|
43
|
+ <img :src="item.src" alt srcset @click="handleClick(item.id,item.fileId)" />
|
|
|
44
|
+ <i
|
|
|
45
|
+ class="el-icon-delete"
|
|
|
46
|
+ :class="clickClass == item.id?'':'active'"
|
|
|
47
|
+ ref="delete"
|
|
|
48
|
+ @click="handleDelete(item.id)"
|
|
|
49
|
+ ></i>
|
|
|
50
|
+ <i
|
|
|
51
|
+ class="el-icon-success"
|
|
|
52
|
+ :class="clickClass == item.id?'':'active'"
|
|
|
53
|
+ ref="delete"
|
|
|
54
|
+ @click="handleDelete(item.id)"
|
|
|
55
|
+ ></i>
|
|
|
56
|
+ </li>
|
|
|
57
|
+ </ul>
|
|
29
|
58
|
</div>
|
|
30
|
59
|
</el-tabs>
|
|
31
|
60
|
<pagination
|
|
|
@@ -34,33 +63,45 @@
|
|
34
|
63
|
:pageindex.sync="pageParams.pageindex"
|
|
35
|
64
|
:pagesize.sync="pageParams.pagesize"
|
|
36
|
65
|
class="pagination"
|
|
37
|
|
- @pagination="getList" />
|
|
|
66
|
+ @pagination="getList"
|
|
|
67
|
+ />
|
|
|
68
|
+ <div class="footer">
|
|
|
69
|
+ <el-button type="primary" @click="submit">确定</el-button>
|
|
|
70
|
+ </div>
|
|
38
|
71
|
</el-card>
|
|
39
|
72
|
</template>
|
|
40
|
73
|
<script>
|
|
41
|
74
|
import { mapGetters } from "vuex";
|
|
42
|
|
-import Pagination from '@/components/Pagination' // 对el-pagination 二次封装
|
|
43
|
|
-import {getPicture, addpic} from '@/api/subjectManagement/subjectManagement'
|
|
|
75
|
+import Pagination from "@/components/Pagination"; // 对el-pagination 二次封装
|
|
|
76
|
+import {
|
|
|
77
|
+ getPicture,
|
|
|
78
|
+ addpic,
|
|
|
79
|
+ deletepic,
|
|
|
80
|
+ saveBCI,
|
|
|
81
|
+} from "@/api/subjectManagement/subjectManagement";
|
|
44
|
82
|
export default {
|
|
45
|
|
-// name:'Pagination',
|
|
46
|
|
-components: {
|
|
47
|
|
- Pagination
|
|
|
83
|
+ // name:'Pagination',
|
|
|
84
|
+ components: {
|
|
|
85
|
+ Pagination,
|
|
48
|
86
|
},
|
|
49
|
87
|
computed: {
|
|
50
|
88
|
...mapGetters(["token"]),
|
|
51
|
89
|
},
|
|
52
|
90
|
created() {
|
|
53
|
|
- this.getList()
|
|
|
91
|
+ this.getList();
|
|
54
|
92
|
},
|
|
55
|
93
|
data() {
|
|
56
|
94
|
return {
|
|
57
|
95
|
activeName: "1",
|
|
58
|
96
|
fileList: [],
|
|
59
|
|
- imgData:[],
|
|
|
97
|
+ fileListName: [],
|
|
|
98
|
+ clickClass: "-1",
|
|
|
99
|
+ fileId: "",
|
|
|
100
|
+ imgData: [],
|
|
60
|
101
|
pageParams: {
|
|
61
|
102
|
pageindex: 1, // 当前第几页
|
|
62
|
103
|
pagesize: Number(this.$store.getters.serverConfig.PAGESIZE), // 每页几条数据
|
|
63
|
|
- total: 0 // 总共多少数据
|
|
|
104
|
+ total: 0, // 总共多少数据
|
|
64
|
105
|
},
|
|
65
|
106
|
uploadData: {
|
|
66
|
107
|
// 文件上传数据
|
|
|
@@ -73,8 +114,9 @@ components: {
|
|
73
|
114
|
};
|
|
74
|
115
|
},
|
|
75
|
116
|
methods: {
|
|
76
|
|
- handleClick(tab, event,val) {
|
|
77
|
|
- console.log(tab, event,val);
|
|
|
117
|
+ handleClickTab(tab, event, val) {
|
|
|
118
|
+ this.activeName=tab.name
|
|
|
119
|
+ this.getList()
|
|
78
|
120
|
},
|
|
79
|
121
|
// 文件上传
|
|
80
|
122
|
uploadSuccess(response, file, fileList) {
|
|
|
@@ -82,15 +124,15 @@ components: {
|
|
82
|
124
|
response.data.map((item) => {
|
|
83
|
125
|
this.fileList.push(item.F_Id);
|
|
84
|
126
|
});
|
|
85
|
|
- const params={
|
|
86
|
|
- fife:this.fileList.toString(),
|
|
87
|
|
- type:this.activeName
|
|
88
|
|
- }
|
|
89
|
|
- addpic(params).then(response=>{
|
|
90
|
|
- if(response.state=='success'){
|
|
91
|
|
- this.getList()
|
|
92
|
|
- }
|
|
93
|
|
- })
|
|
|
127
|
+ const params = {
|
|
|
128
|
+ fife: this.fileList.toString(),
|
|
|
129
|
+ type: this.activeName,
|
|
|
130
|
+ };
|
|
|
131
|
+ addpic(params).then((response) => {
|
|
|
132
|
+ if (response.state == "success") {
|
|
|
133
|
+ this.getList();
|
|
|
134
|
+ }
|
|
|
135
|
+ });
|
|
94
|
136
|
} else {
|
|
95
|
137
|
this.$message.error(response.message);
|
|
96
|
138
|
}
|
|
|
@@ -102,40 +144,136 @@ components: {
|
|
102
|
144
|
this.fileList = [];
|
|
103
|
145
|
},
|
|
104
|
146
|
// 获取图片列表
|
|
105
|
|
- getList(){
|
|
106
|
|
- const params={
|
|
107
|
|
- type:this.activeName,
|
|
108
|
|
- pageindex: this.pageParams.pageindex, // 第几页
|
|
109
|
|
- pagesize: this.pageParams.pagesize, // 每页几条信息
|
|
|
147
|
+ getList() {
|
|
|
148
|
+ const params = {
|
|
|
149
|
+ type: this.activeName,
|
|
|
150
|
+ pageindex: this.pageParams.pageindex, // 第几页
|
|
|
151
|
+ pagesize: this.pageParams.pagesize, // 每页几条信息
|
|
|
152
|
+ };
|
|
|
153
|
+ getPicture(params).then((response) => {
|
|
|
154
|
+ if (response.state == "success") {
|
|
|
155
|
+ this.pageParams.total = response.total;
|
|
|
156
|
+ this.imgData = [];
|
|
|
157
|
+ response.rows.map((item) => {
|
|
|
158
|
+ if(item.F_Default==1){
|
|
|
159
|
+ this.clickClass=item.F_ID
|
|
|
160
|
+ }
|
|
|
161
|
+ this.imgData.push({
|
|
|
162
|
+ id: item.F_ID,
|
|
|
163
|
+ src: item.FileUrl.length>0?item.FileUrl[0].F_Url:'',
|
|
|
164
|
+ fileId: item.FileUrl.length>0?item.FileUrl[0].F_Id:'',
|
|
|
165
|
+ });
|
|
|
166
|
+ });
|
|
110
|
167
|
}
|
|
111
|
|
- getPicture(params).then(response=>{
|
|
112
|
|
- if(response.state=='success'){
|
|
113
|
|
- response.rows.map(item=>{
|
|
114
|
|
- this.imgData.push({
|
|
115
|
|
- id:item.FileUrl[0].F_Id,
|
|
116
|
|
- src:item.FileUrl[0].F_Url,
|
|
117
|
|
- })
|
|
118
|
|
- })
|
|
|
168
|
+ });
|
|
|
169
|
+ },
|
|
|
170
|
+ //删除图片
|
|
|
171
|
+ handleDelete(id) {
|
|
|
172
|
+ this.$confirm("确定要删除该图片吗, 是否继续?", "提示", {
|
|
|
173
|
+ confirmButtonText: "确定",
|
|
|
174
|
+ cancelButtonText: "取消",
|
|
|
175
|
+ type: "warning",
|
|
|
176
|
+ })
|
|
|
177
|
+ .then(() => {
|
|
|
178
|
+ deletepic(id).then((response) => {
|
|
|
179
|
+ if (response.state.toLowerCase() === "success") {
|
|
|
180
|
+ this.getList();
|
|
|
181
|
+ this.$message.success("删除成功!");
|
|
119
|
182
|
}
|
|
|
183
|
+ });
|
|
120
|
184
|
})
|
|
121
|
|
- }
|
|
|
185
|
+ .catch(() => {
|
|
|
186
|
+ this.$message({
|
|
|
187
|
+ type: "info",
|
|
|
188
|
+ message: "已取消删除",
|
|
|
189
|
+ });
|
|
|
190
|
+ });
|
|
|
191
|
+ },
|
|
|
192
|
+ //点击图片操作
|
|
|
193
|
+ handleClick(id, fileId) {
|
|
|
194
|
+ this.clickClass = id;
|
|
|
195
|
+ this.fileId = fileId;
|
|
|
196
|
+ },
|
|
|
197
|
+ //自定义图片保存
|
|
|
198
|
+ submit() {
|
|
|
199
|
+ if (this.clickClass == -1) {
|
|
|
200
|
+ this.$message.info("请选择图片");
|
|
|
201
|
+ return;
|
|
|
202
|
+ }
|
|
|
203
|
+ this.$confirm("确定要使用该图片吗, 是否继续?", "提示", {
|
|
|
204
|
+ confirmButtonText: "确定",
|
|
|
205
|
+ cancelButtonText: "取消",
|
|
|
206
|
+ type: "warning",
|
|
|
207
|
+ })
|
|
|
208
|
+ .then(() => {
|
|
|
209
|
+ const params = {
|
|
|
210
|
+ F_ID: this.clickClass,
|
|
|
211
|
+ F_File: this.fileId,
|
|
|
212
|
+ F_Type: this.activeName,
|
|
|
213
|
+ F_Default: 1,
|
|
|
214
|
+ };
|
|
|
215
|
+ saveBCI(params)
|
|
|
216
|
+ .then((response) => {
|
|
|
217
|
+ if (response.state == "success") {
|
|
|
218
|
+ this.$message.success("自定义背景成功");
|
|
|
219
|
+ }
|
|
|
220
|
+ })
|
|
|
221
|
+ .catch(() => {
|
|
|
222
|
+ this.$message.error("出错了!");
|
|
|
223
|
+ });
|
|
|
224
|
+ })
|
|
|
225
|
+ .catch(() => {
|
|
|
226
|
+ this.$message({
|
|
|
227
|
+ type: "info",
|
|
|
228
|
+ message: "已取消使用",
|
|
|
229
|
+ });
|
|
|
230
|
+ });
|
|
|
231
|
+ },
|
|
122
|
232
|
},
|
|
123
|
233
|
};
|
|
124
|
234
|
</script>
|
|
125
|
235
|
<style lang="scss" scoped>
|
|
126
|
|
-ul{
|
|
127
|
|
- li{
|
|
128
|
|
- margin: 0;
|
|
129
|
|
- padding: 0;
|
|
130
|
|
- width: 20%;
|
|
131
|
|
- height: 20%;
|
|
132
|
|
- list-style: none;
|
|
133
|
|
- img{
|
|
134
|
|
- display: block;
|
|
135
|
|
- width: 100%;
|
|
136
|
|
- height: 100%;
|
|
137
|
|
- }
|
|
|
236
|
+ul {
|
|
|
237
|
+ padding: 0;
|
|
|
238
|
+ margin: 0;
|
|
|
239
|
+ li {
|
|
|
240
|
+ position: relative;
|
|
|
241
|
+ display: inline-block;
|
|
|
242
|
+ padding: 0;
|
|
|
243
|
+ margin: 20px 30px 0 0;
|
|
|
244
|
+ width: 16%;
|
|
|
245
|
+ height: 180px;
|
|
|
246
|
+ list-style: none;
|
|
|
247
|
+ img {
|
|
|
248
|
+ width: 100%;
|
|
|
249
|
+ height: 100%;
|
|
|
250
|
+ cursor: pointer;
|
|
138
|
251
|
}
|
|
|
252
|
+ }
|
|
|
253
|
+}
|
|
|
254
|
+.imgList {
|
|
|
255
|
+ margin-top: 40px;
|
|
|
256
|
+ .el-icon-delete {
|
|
|
257
|
+ position: absolute;
|
|
|
258
|
+ right: 15px;
|
|
|
259
|
+ top: 5px;
|
|
|
260
|
+ cursor: pointer;
|
|
|
261
|
+ color: red;
|
|
|
262
|
+ }
|
|
|
263
|
+ .el-icon-success {
|
|
|
264
|
+ color: #1989fa;
|
|
|
265
|
+ position: absolute;
|
|
|
266
|
+ top: 50%;
|
|
|
267
|
+ left: 50%;
|
|
|
268
|
+ transform: translate(-50%, -50%);
|
|
|
269
|
+ }
|
|
|
270
|
+ .active {
|
|
|
271
|
+ display: none;
|
|
|
272
|
+ }
|
|
|
273
|
+}
|
|
|
274
|
+.footer {
|
|
|
275
|
+ float: right;
|
|
|
276
|
+ margin: 20px 30px 20px 0;
|
|
139
|
277
|
}
|
|
140
|
278
|
.bgi {
|
|
141
|
279
|
float: left;
|