|
@@ -23,16 +23,95 @@
|
23
|
23
|
<img class="img" v-if="row.scpic" :src="row.scpic" v-viewer />
|
24
|
24
|
</template>
|
25
|
25
|
</Table>
|
|
26
|
+ <div class="foot_page" v-if="service.total > 0">
|
|
27
|
+ <Page
|
|
28
|
+ :total="service.total"
|
|
29
|
+ @on-change="changePage"
|
|
30
|
+ :current="form_search.page"
|
|
31
|
+ show-total
|
|
32
|
+ ></Page>
|
|
33
|
+ </div>
|
26
|
34
|
</div>
|
|
35
|
+ <!-- 添加-->
|
|
36
|
+ <Modal
|
|
37
|
+ v-model="add_form.show"
|
|
38
|
+ class="modal1"
|
|
39
|
+ :mask-closable="false"
|
|
40
|
+ title="添加服务案例"
|
|
41
|
+ >
|
|
42
|
+ <Form
|
|
43
|
+ :label-width="90"
|
|
44
|
+ label-position="right"
|
|
45
|
+ ref="AddForm"
|
|
46
|
+ :rules="addFormRules"
|
|
47
|
+ :model="add_form"
|
|
48
|
+ >
|
|
49
|
+ <FormItem label="服务案例" prop="scname">
|
|
50
|
+ <Input v-model="add_form.scname" placeholder="请输入服务案例" />
|
|
51
|
+ </FormItem>
|
|
52
|
+ <FormItem label="序号" prop="scorder">
|
|
53
|
+ <Input v-model="add_form.scorder" number placeholder="请输入序号" />
|
|
54
|
+ </FormItem>
|
|
55
|
+ <div class="upload">
|
|
56
|
+ <Upload
|
|
57
|
+ action
|
|
58
|
+ class="file_left_up"
|
|
59
|
+ accept=".jpg,.jpeg,.png"
|
|
60
|
+ :before-upload="
|
|
61
|
+ (file) => {
|
|
62
|
+ handleUpload(file);
|
|
63
|
+ return false;
|
|
64
|
+ }
|
|
65
|
+ "
|
|
66
|
+ >
|
|
67
|
+ <div
|
|
68
|
+ class="upload-img"
|
|
69
|
+ v-if="!this.add_form.scpic"
|
|
70
|
+ style="padding-top: 10px"
|
|
71
|
+ >
|
|
72
|
+ <Icon
|
|
73
|
+ type="ivu-icon ivu-icon- iconfont icon-shangchuan"
|
|
74
|
+ size="42"
|
|
75
|
+ color="#e6e6e6"
|
|
76
|
+ />
|
|
77
|
+ <p
|
|
78
|
+ class="shangchuan_btn"
|
|
79
|
+ style="margin-top: 10px; font-size: 14px; text-align: center"
|
|
80
|
+ >
|
|
81
|
+ 上传图片
|
|
82
|
+ </p>
|
|
83
|
+ </div>
|
|
84
|
+ <div v-else>
|
|
85
|
+ <img
|
|
86
|
+ class="upload-img"
|
|
87
|
+ :src="$api.showImageUrl + add_form.scpic"
|
|
88
|
+ />
|
|
89
|
+ </div>
|
|
90
|
+ </Upload>
|
|
91
|
+ </div>
|
|
92
|
+ </Form>
|
|
93
|
+ <div slot="footer" style="text-align: right">
|
|
94
|
+ <Button @click="add_form.show = false">取消</Button>
|
|
95
|
+ <Button @click="toSaveAdd()" type="primary">保存</Button>
|
|
96
|
+ </div>
|
|
97
|
+ </Modal>
|
|
98
|
+ <!-- 等待窗 -->
|
|
99
|
+ <Spin fix v-if="showLoading" style="background-color: transparent">
|
|
100
|
+ <Icon type="ios-loading" size="18" class="demo-spin-icon-load"></Icon>
|
|
101
|
+ <div>加载中</div>
|
|
102
|
+ </Spin>
|
27
|
103
|
</div>
|
28
|
104
|
</template>
|
29
|
105
|
|
30
|
106
|
<script>
|
31
|
|
-import { sc_list } from "@/api/index";
|
|
107
|
+import axios from "axios";
|
|
108
|
+import { sc_list, sc_save, sc_update, sc_remove } from "@/api/index";
|
32
|
109
|
import { dateFormat } from "@/utils/index";
|
33
|
110
|
export default {
|
34
|
111
|
data() {
|
35
|
112
|
return {
|
|
113
|
+ userInfo: {},
|
|
114
|
+ showLoading: false,
|
36
|
115
|
form_search: {
|
37
|
116
|
page: 1,
|
38
|
117
|
size: 10,
|
|
@@ -126,10 +205,33 @@ export default {
|
126
|
205
|
]);
|
127
|
206
|
}
|
128
|
207
|
}
|
129
|
|
- ] //列表表格
|
|
208
|
+ ], //列表表格
|
|
209
|
+ add_form: {
|
|
210
|
+ show: false,
|
|
211
|
+ scname: "",
|
|
212
|
+ scpic: "",
|
|
213
|
+ scorder: 0
|
|
214
|
+ },
|
|
215
|
+ addFormRules: {
|
|
216
|
+ scname: [
|
|
217
|
+ {
|
|
218
|
+ required: true,
|
|
219
|
+ message: "服务名称不能为空",
|
|
220
|
+ trigger: "blur"
|
|
221
|
+ }
|
|
222
|
+ ],
|
|
223
|
+ scorder: [
|
|
224
|
+ {
|
|
225
|
+ required: true,
|
|
226
|
+ message: "序号不能为空",
|
|
227
|
+ trigger: "blur"
|
|
228
|
+ }
|
|
229
|
+ ]
|
|
230
|
+ }
|
130
|
231
|
};
|
131
|
232
|
},
|
132
|
233
|
mounted() {
|
|
234
|
+ this.userInfo = JSON.parse(localStorage.getItem("xhWebAdminUser"));
|
133
|
235
|
console.log(this.form_search);
|
134
|
236
|
this.init();
|
135
|
237
|
},
|
|
@@ -142,6 +244,7 @@ export default {
|
142
|
244
|
v.scpic = this.$api.showImageUrl + v.scpic;
|
143
|
245
|
return v;
|
144
|
246
|
});
|
|
247
|
+ this.service.total = res.obj.total;
|
145
|
248
|
} else {
|
146
|
249
|
this.$Message.error(res.msg);
|
147
|
250
|
}
|
|
@@ -149,7 +252,78 @@ export default {
|
149
|
252
|
});
|
150
|
253
|
},
|
151
|
254
|
add() {
|
152
|
|
-
|
|
255
|
+ this.add_form.show = true;
|
|
256
|
+ this.add_form.scorder = this.service.total + 1;
|
|
257
|
+ },
|
|
258
|
+ //确定添加
|
|
259
|
+ toSaveAdd() {
|
|
260
|
+ console.log(this.add_form);
|
|
261
|
+ this.$refs["AddForm"].validate((valid) => {
|
|
262
|
+ if (valid) {
|
|
263
|
+ if (!this.add_form.scpic) {
|
|
264
|
+ this.$Message.error("请上传图片");
|
|
265
|
+ return false;
|
|
266
|
+ }
|
|
267
|
+ sc_save({
|
|
268
|
+ scname: this.add_form.scname,
|
|
269
|
+ scpic: this.add_form.scpic,
|
|
270
|
+ ltype: this.form_search.ltype,
|
|
271
|
+ scorder: this.add_form.scorder,
|
|
272
|
+ createid: this.userInfo.userid
|
|
273
|
+ }).then((res) => {
|
|
274
|
+ if (res.code == 0) {
|
|
275
|
+ console.log(res);
|
|
276
|
+ this.add_form.show = false;
|
|
277
|
+ this.add_form.scname = "";
|
|
278
|
+ this.add_form.scpic = "";
|
|
279
|
+ } else {
|
|
280
|
+ this.$Message.error(res.msg);
|
|
281
|
+ }
|
|
282
|
+ });
|
|
283
|
+ }
|
|
284
|
+ });
|
|
285
|
+ },
|
|
286
|
+ handleUpload(file) {
|
|
287
|
+ let that = this;
|
|
288
|
+ let size = file.size / 1024 / 1024;
|
|
289
|
+ if (!file.name) {
|
|
290
|
+ return;
|
|
291
|
+ }
|
|
292
|
+ let str = file.name.split(".");
|
|
293
|
+ let suffix = str[str.length - 1];
|
|
294
|
+ if (suffix !== "png" && suffix !== "jpg" && suffix !== "jpeg") {
|
|
295
|
+ this.$Message.error("请上传png、jpg、jpeg类型的文件");
|
|
296
|
+ return false;
|
|
297
|
+ }
|
|
298
|
+ if (size > 10) {
|
|
299
|
+ this.$Message.error("图片太大,不能超过10M!");
|
|
300
|
+ return false;
|
|
301
|
+ }
|
|
302
|
+ let formData = new FormData();
|
|
303
|
+ formData.append("file", file);
|
|
304
|
+ formData.append("savefolder", "servicecase");
|
|
305
|
+ let url = that.$api.baseUrl + "file/upload";
|
|
306
|
+ that.showLoading = true;
|
|
307
|
+ axios
|
|
308
|
+ .post(url, formData, {
|
|
309
|
+ timeout: 1000 * window._config.axiosFileTimeout
|
|
310
|
+ })
|
|
311
|
+ .then((res) => {
|
|
312
|
+ that.showLoading = false;
|
|
313
|
+ if (res.data.code === 0) {
|
|
314
|
+ that.add_form.scpic = res.data.obj;
|
|
315
|
+ that.init();
|
|
316
|
+ } else {
|
|
317
|
+ that.$Message.error("图片上传失败");
|
|
318
|
+ }
|
|
319
|
+ })
|
|
320
|
+ .catch(() => {
|
|
321
|
+ that.showLoading = false;
|
|
322
|
+ that.$Message.error("图片上传失败");
|
|
323
|
+ });
|
|
324
|
+ },
|
|
325
|
+ changePage(page) {
|
|
326
|
+ console.log(page);
|
153
|
327
|
}
|
154
|
328
|
}
|
155
|
329
|
};
|
|
@@ -173,4 +347,26 @@ export default {
|
173
|
347
|
cursor: pointer;
|
174
|
348
|
margin-top: 5px;
|
175
|
349
|
}
|
|
350
|
+.upload {
|
|
351
|
+ margin-left: 90px;
|
|
352
|
+ width: 200px;
|
|
353
|
+ height: 100px;
|
|
354
|
+ border: 1px solid #dcdee2;
|
|
355
|
+ cursor: pointer;
|
|
356
|
+ &:hover {
|
|
357
|
+ color: #2d8cf0;
|
|
358
|
+ border: 1px solid #2d8cf0;
|
|
359
|
+ .upload-img,
|
|
360
|
+ .icon-shangchuan,
|
|
361
|
+ .shangchuan_btn {
|
|
362
|
+ color: inherit !important;
|
|
363
|
+ }
|
|
364
|
+ }
|
|
365
|
+ .upload-img {
|
|
366
|
+ width: 200px;
|
|
367
|
+ height: 100px;
|
|
368
|
+ text-align: center;
|
|
369
|
+ object-fit: cover;
|
|
370
|
+ }
|
|
371
|
+}
|
176
|
372
|
</style>
|