|
@@ -0,0 +1,420 @@
|
|
1
|
+<template>
|
|
2
|
+ <div class="edit-carousel">
|
|
3
|
+ <el-form ref="form" :model="building" label-width="180px">
|
|
4
|
+ <el-form-item label="所属项目:">
|
|
5
|
+ <el-select v-model="buildingProperty" multiple placeholder="请选择">
|
|
6
|
+ <el-option v-for="(t,i) in propertyType" :key="i" :label="t.name" :value="t.id"></el-option>
|
|
7
|
+ </el-select>
|
|
8
|
+ </el-form-item>
|
|
9
|
+ <el-form-item label="主图:">
|
|
10
|
+ <el-upload
|
|
11
|
+ :action="upFileUrl"
|
|
12
|
+ name='file'
|
|
13
|
+ list-type="picture-card"
|
|
14
|
+ :headers="uploadHeaders"
|
|
15
|
+ :file-list="imgList"
|
|
16
|
+ :show-file-list="true"
|
|
17
|
+ :before-upload="beforeImgUpload"
|
|
18
|
+ :on-success="handleAvatarSuccess"
|
|
19
|
+ :on-remove="handleRemove">
|
|
20
|
+ <i class="el-icon-plus"></i>
|
|
21
|
+ </el-upload>
|
|
22
|
+ <el-dialog :visible.sync="dialogVisible">
|
|
23
|
+ <img width="100%" :src="dialogImageUrl" alt="">
|
|
24
|
+ </el-dialog>
|
|
25
|
+ </el-form-item>
|
|
26
|
+ <el-form-item label="标题:">
|
|
27
|
+ <el-input v-model="building.tel"></el-input>
|
|
28
|
+ </el-form-item>
|
|
29
|
+ <el-form-item label="发布位置:">
|
|
30
|
+ <el-select v-model="buildingProperty" multiple placeholder="请选择">
|
|
31
|
+ <el-option v-for="(t,i) in propertyType" :key="i" :label="t.name" :value="t.id"></el-option>
|
|
32
|
+ </el-select>
|
|
33
|
+ </el-form-item>
|
|
34
|
+ <el-form-item label="类型:">
|
|
35
|
+ <el-select v-model="buildingProperty" multiple placeholder="请选择">
|
|
36
|
+ <el-option v-for="(t,i) in propertyType" :key="i" :label="t.name" :value="t.id"></el-option>
|
|
37
|
+ </el-select>
|
|
38
|
+ </el-form-item>
|
|
39
|
+ <el-form-item label="发布内容:">
|
|
40
|
+ <div id="websiteEditorElem" style="height: 400px"></div>
|
|
41
|
+ </el-form-item>
|
|
42
|
+ <el-form-item label="发布内容:" class="publish">
|
|
43
|
+ <p>活动名称展示处 <span class="choose">请选择</span></p>
|
|
44
|
+ </el-form-item>
|
|
45
|
+ <el-form-item label="状态:">
|
|
46
|
+ <el-select v-model="buildingProperty" multiple placeholder="请选择">
|
|
47
|
+ <el-option v-for="(t,i) in propertyType" :key="i" :label="t.name" :value="t.id"></el-option>
|
|
48
|
+ </el-select>
|
|
49
|
+ </el-form-item>
|
|
50
|
+ <el-form-item>
|
|
51
|
+ <el-button type="primary" @click="onSubmit">保存</el-button>
|
|
52
|
+ <el-button @click="onCancel">取消</el-button>
|
|
53
|
+ </el-form-item>
|
|
54
|
+ </el-form>
|
|
55
|
+ </div>
|
|
56
|
+</template>
|
|
57
|
+
|
|
58
|
+<script>
|
|
59
|
+import { createNamespacedHelpers } from "vuex";
|
|
60
|
+import apis from "../../config/api";
|
|
61
|
+import { mapState } from "vuex";
|
|
62
|
+import E from "wangeditor";
|
|
63
|
+
|
|
64
|
+const {
|
|
65
|
+ mapState: mapBuildingState,
|
|
66
|
+ mapActions: mapBuildingActions,
|
|
67
|
+ mapMutations: mapBuildingMutations
|
|
68
|
+} = createNamespacedHelpers("building");
|
|
69
|
+
|
|
70
|
+const { mapActions: mapApartmentActions } = createNamespacedHelpers(
|
|
71
|
+ "apartment"
|
|
72
|
+);
|
|
73
|
+
|
|
74
|
+const { mapActions: mapImgActions } = createNamespacedHelpers("img");
|
|
75
|
+
|
|
76
|
+export default {
|
|
77
|
+ data() {
|
|
78
|
+ var _self = this;
|
|
79
|
+ return {
|
|
80
|
+ upFileUrl: apis.file.upload.url,
|
|
81
|
+ commPrefix: "",
|
|
82
|
+ imgurl: "",
|
|
83
|
+ loadingZm: false,
|
|
84
|
+ activeName: "detail",
|
|
85
|
+ dialogImageUrl: "",
|
|
86
|
+ dialogVisible: false,
|
|
87
|
+ dialogApartImageUrl: "",
|
|
88
|
+ dialogApartVisible: false,
|
|
89
|
+ showHx: false,
|
|
90
|
+ imgList: [],
|
|
91
|
+ tags: [],
|
|
92
|
+ buildingProperty: [],
|
|
93
|
+ aparments: [],
|
|
94
|
+ aparmentInfo: {},
|
|
95
|
+ aparmentImg: [],
|
|
96
|
+ saleType: [
|
|
97
|
+ {
|
|
98
|
+ id: 1,
|
|
99
|
+ name: "待定"
|
|
100
|
+ },
|
|
101
|
+ {
|
|
102
|
+ id: 2,
|
|
103
|
+ name: "售罄"
|
|
104
|
+ },
|
|
105
|
+ {
|
|
106
|
+ id: 3,
|
|
107
|
+ name: "在售"
|
|
108
|
+ }
|
|
109
|
+ ]
|
|
110
|
+ };
|
|
111
|
+ },
|
|
112
|
+ computed: {
|
|
113
|
+ ...mapBuildingState({
|
|
114
|
+ detail: x => x.detail
|
|
115
|
+ }),
|
|
116
|
+ ...mapState({
|
|
117
|
+ dicts: x => x.dicts
|
|
118
|
+ }),
|
|
119
|
+ building: {
|
|
120
|
+ get() {
|
|
121
|
+ return this.detail;
|
|
122
|
+ },
|
|
123
|
+ set(val) {
|
|
124
|
+ return this.updateDetail(val);
|
|
125
|
+ }
|
|
126
|
+ },
|
|
127
|
+ propertyType() {
|
|
128
|
+ return (this.dicts || []).filter(x => x.type === "propertyType");
|
|
129
|
+ },
|
|
130
|
+ uploadHeaders() {
|
|
131
|
+ const token = localStorage.getItem("x-token") || "";
|
|
132
|
+ return {
|
|
133
|
+ Authorization: `Bearer ${token}`
|
|
134
|
+ };
|
|
135
|
+ }
|
|
136
|
+ },
|
|
137
|
+ methods: {
|
|
138
|
+ ...mapBuildingMutations(["updateDetail"]),
|
|
139
|
+ ...mapBuildingActions(["getDetail", "addBuilding", "editBuilding"]),
|
|
140
|
+ ...mapApartmentActions([
|
|
141
|
+ "getApartments",
|
|
142
|
+ "getApartmentDetail",
|
|
143
|
+ "addApartment",
|
|
144
|
+ "editApartment",
|
|
145
|
+ "deleteApartment"
|
|
146
|
+ ]),
|
|
147
|
+ ...mapImgActions(["uploadImg"]),
|
|
148
|
+ getSaleTypeName(id) {
|
|
149
|
+ return (this.saleType.filter(x => x.id == id)[0] || {}).name;
|
|
150
|
+ },
|
|
151
|
+ onCancel() {
|
|
152
|
+ this.$router.push({ name: "buildinglist" });
|
|
153
|
+ },
|
|
154
|
+ handleRemove(file, fileList) {
|
|
155
|
+ this.imgList = fileList;
|
|
156
|
+ },
|
|
157
|
+ handleAparmentRemove(file, fileList) {
|
|
158
|
+ this.aparmentImg = fileList;
|
|
159
|
+ },
|
|
160
|
+
|
|
161
|
+ beforeImgUpload(file) {
|
|
162
|
+ if (file.type !== "image/jpeg" && file.type !== "image/png") {
|
|
163
|
+ this.$message.error("上传图片只能是 JPG 或 PNG 格式!");
|
|
164
|
+ return false;
|
|
165
|
+ }
|
|
166
|
+ // if (file.size / 1024 > 300) {
|
|
167
|
+ // this.$message.error('图片大小不允许超过300k!')
|
|
168
|
+ // return false
|
|
169
|
+ // }
|
|
170
|
+ this.loading = this.$loading({
|
|
171
|
+ lock: true,
|
|
172
|
+ text: "上传中...",
|
|
173
|
+ spinner: "el-icon-loading",
|
|
174
|
+ background: "rgba(0, 0, 0, 0.7)"
|
|
175
|
+ });
|
|
176
|
+
|
|
177
|
+ return true;
|
|
178
|
+ },
|
|
179
|
+ handleAvatarSuccess(res) {
|
|
180
|
+ this.imgList = [
|
|
181
|
+ ...this.imgList,
|
|
182
|
+ {
|
|
183
|
+ url: res.data
|
|
184
|
+ }
|
|
185
|
+ ];
|
|
186
|
+ this.loading.close();
|
|
187
|
+ },
|
|
188
|
+ handleMapImgSuccess(res) {
|
|
189
|
+ this.building = { ...this.building, mapImg: res.data };
|
|
190
|
+ this.loading.close();
|
|
191
|
+ },
|
|
192
|
+ handlePosterSuccess(res) {
|
|
193
|
+ this.building = { ...this.building, poster: res.data };
|
|
194
|
+ this.loading.close();
|
|
195
|
+ },
|
|
196
|
+ handleAparmentSuccess(res) {
|
|
197
|
+ this.aparmentImg = [
|
|
198
|
+ ...this.aparmentImg,
|
|
199
|
+ {
|
|
200
|
+ url: res.data
|
|
201
|
+ }
|
|
202
|
+ ];
|
|
203
|
+ this.loading.close();
|
|
204
|
+ },
|
|
205
|
+ onSubmit() {
|
|
206
|
+ const imgs = this.imgList.map((x, i) => {
|
|
207
|
+ return {
|
|
208
|
+ imgType: "banner",
|
|
209
|
+ url: x.url,
|
|
210
|
+ orderNo: i + 1
|
|
211
|
+ };
|
|
212
|
+ });
|
|
213
|
+ const tag = this.tags.map(x => {
|
|
214
|
+ return {
|
|
215
|
+ tagName: x
|
|
216
|
+ };
|
|
217
|
+ });
|
|
218
|
+ const building = {
|
|
219
|
+ ...this.building,
|
|
220
|
+ img: imgs,
|
|
221
|
+ propertyType: this.buildingProperty.join(","),
|
|
222
|
+ tag
|
|
223
|
+ };
|
|
224
|
+ if (!building.buildingId) {
|
|
225
|
+ // 新增
|
|
226
|
+ this.addBuilding({
|
|
227
|
+ onSuccess: this.onCancel,
|
|
228
|
+ detail: JSON.stringify(building)
|
|
229
|
+ });
|
|
230
|
+ } else {
|
|
231
|
+ // 修改
|
|
232
|
+ this.editBuilding({
|
|
233
|
+ onSuccess: this.onCancel,
|
|
234
|
+ detail: JSON.stringify(building)
|
|
235
|
+ });
|
|
236
|
+ }
|
|
237
|
+ },
|
|
238
|
+ FormatDate(date) {
|
|
239
|
+ return (date || "").split("T")[0] === "0001-01-01"
|
|
240
|
+ ? ""
|
|
241
|
+ : (date || "").split("T")[0];
|
|
242
|
+ },
|
|
243
|
+ saveAparment() {
|
|
244
|
+ const imgs = this.aparmentImg.map((x, i) => {
|
|
245
|
+ return {
|
|
246
|
+ imgType: "aparment",
|
|
247
|
+ url: x.url,
|
|
248
|
+ orderNo: i + 1
|
|
249
|
+ };
|
|
250
|
+ });
|
|
251
|
+ if (!this.aparmentInfo.apartmentId) {
|
|
252
|
+ this.addApartment(
|
|
253
|
+ JSON.stringify({
|
|
254
|
+ ...this.aparmentInfo,
|
|
255
|
+ img: imgs
|
|
256
|
+ })
|
|
257
|
+ ).then(() => {
|
|
258
|
+ this.getAparmentList();
|
|
259
|
+ this.showHx = false;
|
|
260
|
+ });
|
|
261
|
+ } else {
|
|
262
|
+ this.editApartment(
|
|
263
|
+ JSON.stringify({
|
|
264
|
+ ...this.aparmentInfo,
|
|
265
|
+ img: imgs
|
|
266
|
+ })
|
|
267
|
+ ).then(() => {
|
|
268
|
+ this.getAparmentList();
|
|
269
|
+ this.showHx = false;
|
|
270
|
+ });
|
|
271
|
+ }
|
|
272
|
+ },
|
|
273
|
+ addHx() {
|
|
274
|
+ this.aparmentImg = [];
|
|
275
|
+ this.aparmentInfo = { buildingId: this.building.buildingId };
|
|
276
|
+ this.showHx = true;
|
|
277
|
+ },
|
|
278
|
+ getAparmentList() {
|
|
279
|
+ this.getApartments({ buildingId: this.$route.query.id }).then(data => {
|
|
280
|
+ this.aparments = data;
|
|
281
|
+ });
|
|
282
|
+ },
|
|
283
|
+ handleEdit(row) {
|
|
284
|
+ this.aparmentImg = [];
|
|
285
|
+ this.getApartmentDetail({
|
|
286
|
+ id: row.apartmentId
|
|
287
|
+ }).then(data => {
|
|
288
|
+ console.log("...", data);
|
|
289
|
+ this.aparmentImg = data.buildingImgList.map(x => {
|
|
290
|
+ return {
|
|
291
|
+ name: x.imgId,
|
|
292
|
+ url: x.url
|
|
293
|
+ };
|
|
294
|
+ });
|
|
295
|
+ this.aparmentInfo = data;
|
|
296
|
+ this.showHx = true;
|
|
297
|
+ });
|
|
298
|
+ },
|
|
299
|
+ handleDel(row) {
|
|
300
|
+ this.$confirm("确认删除此数据?", "提示", {
|
|
301
|
+ confirmButtonText: "确定",
|
|
302
|
+ cancelButtonText: "取消",
|
|
303
|
+ type: "warning"
|
|
304
|
+ }).then(() => {
|
|
305
|
+ if (this.building.status === 1) {
|
|
306
|
+ this.$message.error("当前楼盘处于发布状态,不允许删除!");
|
|
307
|
+ return false;
|
|
308
|
+ }
|
|
309
|
+ this.deleteApartment({
|
|
310
|
+ id: row.apartmentId
|
|
311
|
+ }).then(() => {
|
|
312
|
+ this.getAparmentList();
|
|
313
|
+ });
|
|
314
|
+ });
|
|
315
|
+ }
|
|
316
|
+ },
|
|
317
|
+ mounted() {
|
|
318
|
+ const _that = this;
|
|
319
|
+ const phoneEditor = new E("#websiteEditorElem");
|
|
320
|
+ phoneEditor.customConfig.onchange = function(html) {
|
|
321
|
+ _that.building = { ..._that.building, remark: html };
|
|
322
|
+ };
|
|
323
|
+ phoneEditor.customConfig.customUploadImg = function(files, insert) {
|
|
324
|
+ _that.uploadImg(files[0]).then(data => {
|
|
325
|
+ insert(data[0]);
|
|
326
|
+ });
|
|
327
|
+ };
|
|
328
|
+ phoneEditor.customConfig.menus = [
|
|
329
|
+ "head", // 标题
|
|
330
|
+ "bold", // 粗体
|
|
331
|
+ "fontSize", // 字号
|
|
332
|
+ "fontName", // 字体
|
|
333
|
+ "italic", // 斜体
|
|
334
|
+ "underline", // 下划线
|
|
335
|
+ "strikeThrough", // 删除线
|
|
336
|
+ "foreColor", // 文字颜色
|
|
337
|
+ "backColor", // 背景颜色
|
|
338
|
+ "justify", // 对齐方式
|
|
339
|
+ "image" // 插入图片
|
|
340
|
+ ];
|
|
341
|
+ phoneEditor.create();
|
|
342
|
+ if ((this.$route.query.id || "") !== "") {
|
|
343
|
+ this.getAparmentList();
|
|
344
|
+ window.console.log(this.getDetail);
|
|
345
|
+ this.getDetail({ id: this.$route.query.id }).then(data => {
|
|
346
|
+ this.buildingProperty = data.propertyType.split(",");
|
|
347
|
+ phoneEditor.txt.html(data.remark);
|
|
348
|
+ this.imgList = data.buildingImg.map(x => {
|
|
349
|
+ return {
|
|
350
|
+ name: x.imgId,
|
|
351
|
+ url: x.url
|
|
352
|
+ };
|
|
353
|
+ });
|
|
354
|
+ this.tags = data.buildingTag.map(x => x.tagName);
|
|
355
|
+ });
|
|
356
|
+ } else {
|
|
357
|
+ phoneEditor.txt.html("");
|
|
358
|
+ }
|
|
359
|
+ }
|
|
360
|
+};
|
|
361
|
+</script>
|
|
362
|
+
|
|
363
|
+<style lang="scss">
|
|
364
|
+.header {
|
|
365
|
+ width: 50px;
|
|
366
|
+ height: 50px;
|
|
367
|
+ img {
|
|
368
|
+ width: 100%;
|
|
369
|
+ height: 100%;
|
|
370
|
+ }
|
|
371
|
+}
|
|
372
|
+.avatar-uploader .el-upload {
|
|
373
|
+ border: 1px dashed #d9d9d9;
|
|
374
|
+ border-radius: 6px;
|
|
375
|
+ cursor: pointer;
|
|
376
|
+ position: relative;
|
|
377
|
+ overflow: hidden;
|
|
378
|
+}
|
|
379
|
+.avatar-uploader .el-upload:hover {
|
|
380
|
+ border-color: #409eff;
|
|
381
|
+}
|
|
382
|
+.avatar-uploader-icon {
|
|
383
|
+ font-size: 28px;
|
|
384
|
+ color: #8c939d;
|
|
385
|
+ width: 178px;
|
|
386
|
+ height: 178px;
|
|
387
|
+ line-height: 178px;
|
|
388
|
+ text-align: center;
|
|
389
|
+}
|
|
390
|
+.avatar {
|
|
391
|
+ width: 178px;
|
|
392
|
+ height: 178px;
|
|
393
|
+ display: block;
|
|
394
|
+}
|
|
395
|
+.edit-carousel {
|
|
396
|
+ .el-select {
|
|
397
|
+ max-width: 300px !important;
|
|
398
|
+ }
|
|
399
|
+ .el-input {
|
|
400
|
+ max-width: 400px;
|
|
401
|
+ }
|
|
402
|
+ .publish{
|
|
403
|
+ p{
|
|
404
|
+ margin: 0;
|
|
405
|
+ font-size: 15.4px;
|
|
406
|
+ .choose{
|
|
407
|
+ color: blue;
|
|
408
|
+ }
|
|
409
|
+ }
|
|
410
|
+ }
|
|
411
|
+}
|
|
412
|
+
|
|
413
|
+.el-select-dropdown {
|
|
414
|
+ z-index: 10003 !important;
|
|
415
|
+}
|
|
416
|
+
|
|
417
|
+.el-date-picker {
|
|
418
|
+ z-index: 10002 !important;
|
|
419
|
+}
|
|
420
|
+</style>
|