魏熙美 6 年之前
父節點
當前提交
2272f03002
共有 1 個檔案被更改,包括 216 行新增197 行删除
  1. 216
    197
      VUECODE/smart-operate-manage/src/views/community/communityTable.vue

+ 216
- 197
VUECODE/smart-operate-manage/src/views/community/communityTable.vue 查看文件

@@ -104,16 +104,17 @@
104 104
           </el-select>
105 105
         </el-form-item>
106 106
         <el-form-item label="高德坐标*">
107
-          <el-input v-model="detail.longitude" placeholder="经度" />
108
-          <el-input v-model="detail.latitude" placeholder="纬度" />
107
+          <el-input v-model="detail.longitude" placeholder="经度" style="width: 150px;" />
108
+          <el-input v-model="detail.latitude" placeholder="纬度" style="width: 150px;" />
109 109
         </el-form-item>
110 110
         <!-- <el-amap-search-box class="search-box" :search-option="searchOption" :on-search-result="onSearchResult"></el-amap-search-box> -->
111
-        <div style="width:100%;height:200px;">
111
+        <div style="width:100%;height:200px;" class="amap-page-container">
112
+          <el-amap-search-box :search-option="searchOption" :on-search-result="onSearchResult" class="search-box"/>
112 113
           <el-amap ref="map" :events="events" :center="mapCenter" :zoom="12" class="amap-demo" vid="amapDemo">
113 114
             <el-amap-marker v-for="(item,index) in markers" :key="index" :position="item" />
114 115
           </el-amap>
115 116
         </div>
116
-        <el-form-item label="管理员姓名*">
117
+        <el-form-item label="管理员姓名*" style="margin-top: 40px;">
117 118
           <el-input v-model="detail.userName" placeholder="建议先填写运营人员姓名" />
118 119
         </el-form-item>
119 120
         <el-form-item label="管理员账号*">
@@ -143,6 +144,7 @@
143 144
         </el-form-item>
144 145
         <!-- <el-amap-search-box class="search-box" :search-option="searchOption" :on-search-result="onSearchResult"></el-amap-search-box> -->
145 146
         <div style="width:100%;height:200px;">
147
+          <el-amap-search-box :search-option="searchOption" :on-search-result="onSearchResult" class="search-box"/>
146 148
           <el-amap ref="map" :events="events" :center="mapCenter" :zoom="12" class="amap-demo" vid="amapDemo">
147 149
             <el-amap-marker v-for="(item,index) in markers" :key="index" :position="item" />
148 150
           </el-amap>
@@ -174,54 +176,54 @@
174 176
 </template>
175 177
 
176 178
 <script>
177
-import { mapState, mapActions, mapMutations } from "vuex";
178
-import waves from "@/directive/waves"; // Waves directive
179
-import { parseTime } from "@/utils";
180
-import Pagination from "@/components/Pagination"; // Secondary package based on el-pagination
179
+import { mapState, mapActions, mapMutations } from 'vuex'
180
+import waves from '@/directive/waves' // Waves directive
181
+import { parseTime } from '@/utils'
182
+import Pagination from '@/components/Pagination' // Secondary package based on el-pagination
181 183
 
182 184
 const calendarTypeOptions = [
183
-  { key: "CN", display_name: "China" },
184
-  { key: "US", display_name: "USA" },
185
-  { key: "JP", display_name: "Japan" },
186
-  { key: "EU", display_name: "Eurozone" }
187
-];
185
+  { key: 'CN', display_name: 'China' },
186
+  { key: 'US', display_name: 'USA' },
187
+  { key: 'JP', display_name: 'Japan' },
188
+  { key: 'EU', display_name: 'Eurozone' }
189
+]
188 190
 
189 191
 // arr to obj ,such as { CN : "China", US : "USA" }
190 192
 const calendarTypeKeyValue = calendarTypeOptions.reduce((acc, cur) => {
191
-  acc[cur.key] = cur.display_name;
192
-  return acc;
193
-}, {});
193
+  acc[cur.key] = cur.display_name
194
+  return acc
195
+}, {})
194 196
 
195 197
 export default {
196
-  name: "ComplexTable",
198
+  name: 'ComplexTable',
197 199
   components: { Pagination },
198 200
   directives: { waves },
199 201
   filters: {
200 202
     statusFilter(status) {
201 203
       const statusMap = {
202
-        published: "success",
203
-        draft: "info",
204
-        deleted: "danger"
205
-      };
206
-      return statusMap[status];
204
+        published: 'success',
205
+        draft: 'info',
206
+        deleted: 'danger'
207
+      }
208
+      return statusMap[status]
207 209
     },
208 210
     typeFilter(type) {
209
-      return calendarTypeKeyValue[type];
211
+      return calendarTypeKeyValue[type]
210 212
     }
211 213
   },
212 214
   data() {
213
-    var _self = this;
215
+    var _self = this
214 216
     return {
215 217
       events: {
216 218
         click: e => {
217 219
           // _self.postData.Coordinate = e.lnglat.lat + ',' + e.lnglat.lng
218
-          _self.detail.longitude = e.lnglat.lng;
219
-          _self.detail.latitude = e.lnglat.lat;
220
+          _self.detail.longitude = e.lnglat.lng
221
+          _self.detail.latitude = e.lnglat.lat
220 222
         }
221 223
       },
222 224
       markers: [],
223 225
       searchOption: {
224
-        city: "南京",
226
+        city: '南京',
225 227
         citylimit: false
226 228
       },
227 229
       mapCenter: [118.789509, 32.019989],
@@ -239,41 +241,41 @@ export default {
239 241
       importanceOptions: [1, 2, 3],
240 242
       calendarTypeOptions,
241 243
       sortOptions: [
242
-        { label: "ID Ascending", key: "+id" },
243
-        { label: "ID Descending", key: "-id" }
244
+        { label: 'ID Ascending', key: '+id' },
245
+        { label: 'ID Descending', key: '-id' }
244 246
       ],
245
-      statusOptions: ["published", "draft", "deleted"],
247
+      statusOptions: ['published', 'draft', 'deleted'],
246 248
       showReviewer: false,
247 249
       dialogFormVisible: false,
248 250
       dialogLookFormVisible: false,
249
-      dialogStatus: "",
251
+      dialogStatus: '',
250 252
       textMap: {
251
-        update: "编辑",
252
-        create: "新增"
253
+        update: '编辑',
254
+        create: '新增'
253 255
       },
254 256
       dialogPvVisible: false,
255 257
       pvData: [],
256 258
       rules: {
257 259
         type: [
258
-          { required: true, message: "type is required", trigger: "change" }
260
+          { required: true, message: 'type is required', trigger: 'change' }
259 261
         ],
260 262
         createData: [
261 263
           {
262
-            type: "date",
264
+            type: 'date',
263 265
             required: true,
264
-            message: "createData is required",
265
-            trigger: "change"
266
+            message: 'createData is required',
267
+            trigger: 'change'
266 268
           }
267 269
         ],
268 270
         title: [
269
-          { required: true, message: "title is required", trigger: "blur" }
271
+          { required: true, message: 'title is required', trigger: 'blur' }
270 272
         ]
271 273
       },
272 274
       downloadLoading: false
273
-    };
275
+    }
274 276
   },
275 277
   computed: {
276
-    ...mapState("community", {
278
+    ...mapState('community', {
277 279
       list: s => s.list,
278 280
       detail: s => s.detail,
279 281
       total: s => s.total,
@@ -299,310 +301,327 @@ export default {
299 301
   //   }
300 302
   // },
301 303
   created() {
302
-    this.getList();
303
-    this.getProvinceList();
304
+    this.getList()
305
+    this.getProvinceList()
304 306
   },
305 307
   methods: {
306
-    ...mapMutations("community", {
307
-      resetDetail: "resetDetail",
308
-      setDetail: "setDetail"
308
+    ...mapMutations('community', {
309
+      resetDetail: 'resetDetail',
310
+      setDetail: 'setDetail'
309 311
     }),
310
-    ...mapActions("community", [
311
-      "FetchCommunityList",
312
-      "CreateCommunity",
313
-      "UpdateCommunity",
314
-      "FetchProvinceList",
315
-      "FetchCityList",
316
-      "FetchDistrictList",
317
-      "FetchEditCityList",
318
-      "FetchEditDistrictList"
312
+    ...mapActions('community', [
313
+      'FetchCommunityList',
314
+      'CreateCommunity',
315
+      'UpdateCommunity',
316
+      'FetchProvinceList',
317
+      'FetchCityList',
318
+      'FetchDistrictList',
319
+      'FetchEditCityList',
320
+      'FetchEditDistrictList'
319 321
     ]),
322
+    addMarker() {
323
+      const lng = 121.5 + Math.round(Math.random() * 1000) / 10000
324
+      const lat = 31.197646 + Math.round(Math.random() * 500) / 10000
325
+      this.markers.push([lng, lat])
326
+    },
320 327
     onSearchResult(pois) {
321 328
       // 搜索地图
322
-      let latSum = 0;
323
-      let lngSum = 0;
329
+      let latSum = 0
330
+      let lngSum = 0
324 331
       if (pois.length > 0) {
325 332
         pois.forEach(poi => {
326
-          const { lng, lat } = poi;
327
-          lngSum += lng;
328
-          latSum += lat;
329
-          this.markers.push([poi.lng, poi.lat]);
330
-        });
333
+          const { lng, lat } = poi
334
+          lngSum += lng
335
+          latSum += lat
336
+          this.markers.push([poi.lng, poi.lat])
337
+        })
331 338
         const center = {
332 339
           lng: lngSum / pois.length,
333 340
           lat: latSum / pois.length
334
-        };
335
-        this.mapCenter = [center.lng, center.lat];
341
+        }
342
+        this.mapCenter = [center.lng, center.lat]
336 343
       }
337 344
     },
338 345
     setCurrent(item) {
339
-      this.setDetail({ ...item });
346
+      this.setDetail({ ...item })
340 347
     },
341 348
     getList() {
342
-      this.listLoading = true;
349
+      this.listLoading = true
343 350
       this.FetchCommunityList(this.listQuery)
344 351
         .then(() => {
345
-          this.listLoading = false;
352
+          this.listLoading = false
346 353
         })
347 354
         .catch(() => {
348
-          this.loading = false;
349
-          console.log("get list error");
350
-        });
355
+          this.loading = false
356
+          console.log('get list error')
357
+        })
351 358
     },
352 359
     getProvinceList() {
353 360
       this.FetchProvinceList()
354 361
         .then(() => {})
355 362
         .catch(() => {
356
-          console.log("get list error");
357
-        });
363
+          console.log('get list error')
364
+        })
358 365
     },
359 366
     getCityList() {
360
-      this.listQuery.cityId = undefined;
361
-      this.listQuery.districtId = undefined;
367
+      this.listQuery.cityId = undefined
368
+      this.listQuery.districtId = undefined
362 369
       this.FetchCityList(this.listQuery.provinceId)
363 370
         .then(() => {})
364 371
         .catch(() => {
365
-          console.log("get list error");
366
-        });
372
+          console.log('get list error')
373
+        })
367 374
     },
368 375
     getDistrictList() {
369
-      this.listQuery.districtId = undefined;
376
+      this.listQuery.districtId = undefined
370 377
       this.FetchDistrictList(this.listQuery.cityId)
371 378
         .then(() => {})
372 379
         .catch(() => {
373
-          console.log("get list error");
374
-        });
380
+          console.log('get list error')
381
+        })
375 382
     },
376 383
     getEditCityList() {
377 384
       this.FetchEditCityList(this.detail.provinceId)
378 385
         .then(() => {})
379 386
         .catch(() => {
380
-          console.log("get list error");
381
-        });
387
+          console.log('get list error')
388
+        })
382 389
     },
383 390
     changeCity() {
384
-      console.log(1);
391
+      console.log(1)
385 392
       // this.detail.cityId = undefined;
386 393
       // this.detail.districtId = undefined;
387
-      this.$set(this.detail,"cityId", undefined)
388
-      this.$set(this.detail,"districtId", undefined)
389
-      this.setDetail(this.detail);
394
+      this.$set(this.detail, 'cityId', undefined)
395
+      this.$set(this.detail, 'districtId', undefined)
396
+      this.setDetail(this.detail)
390 397
     },
391 398
     changeDistrictList() {
392
-      console.log(2);
399
+      console.log(2)
393 400
       // this.detail.districtId = undefined;
394
-      this.$set(this.detail,"districtId", undefined)
395
-      this.setDetail(this.detail);
401
+      this.$set(this.detail, 'districtId', undefined)
402
+      this.setDetail(this.detail)
396 403
     },
397 404
     getEditDistrictList() {
398 405
       this.FetchEditDistrictList(this.detail.cityId)
399 406
         .then(() => {})
400 407
         .catch(() => {
401
-          console.log("get list error");
402
-        });
408
+          console.log('get list error')
409
+        })
403 410
     },
404 411
     clearListQuery() {
405
-      this.listQuery.pageNum = 1;
406
-      this.listQuery.pageSize = 20;
407
-      this.listQuery.communityId = undefined;
408
-      this.listQuery.communityName = undefined;
409
-      this.listQuery.provinceId = undefined;
410
-      this.listQuery.cityId = undefined;
411
-      this.listQuery.districtId = undefined;
412
-      this.getList();
412
+      this.listQuery.pageNum = 1
413
+      this.listQuery.pageSize = 20
414
+      this.listQuery.communityId = undefined
415
+      this.listQuery.communityName = undefined
416
+      this.listQuery.provinceId = undefined
417
+      this.listQuery.cityId = undefined
418
+      this.listQuery.districtId = undefined
419
+      this.getList()
413 420
     },
414 421
     handleFilter() {
415
-      this.listQuery.pageNum = 1;
416
-      this.getList();
422
+      this.listQuery.pageNum = 1
423
+      this.getList()
417 424
     },
418 425
     handleModifyStatus(row, status) {
419 426
       this.$message({
420
-        message: "操作成功",
421
-        type: "success"
422
-      });
423
-      row.status = status;
427
+        message: '操作成功',
428
+        type: 'success'
429
+      })
430
+      row.status = status
424 431
     },
425 432
     sortChange(data) {
426
-      const { prop, order } = data;
427
-      if (prop === "id") {
428
-        this.sortByID(order);
433
+      const { prop, order } = data
434
+      if (prop === 'id') {
435
+        this.sortByID(order)
429 436
       }
430 437
     },
431 438
     handleSizeChange(val) {
432 439
       // console.log(`每页 ${val} 条`);
433
-      this.listQuery.pageSize = val;
434
-      this.getList();
440
+      this.listQuery.pageSize = val
441
+      this.getList()
435 442
     },
436 443
     handleCurrentChange(val) {
437 444
       // console.log(`当前页: ${val}`);
438
-      this.listQuery.pageNum = val;
439
-      this.getList();
445
+      this.listQuery.pageNum = val
446
+      this.getList()
440 447
     },
441 448
     sortByID(order) {
442
-      if (order === "ascending") {
443
-        this.listQuery.sort = "+id";
449
+      if (order === 'ascending') {
450
+        this.listQuery.sort = '+id'
444 451
       } else {
445
-        this.listQuery.sort = "-id";
452
+        this.listQuery.sort = '-id'
446 453
       }
447
-      this.handleFilter();
454
+      this.handleFilter()
448 455
     },
449 456
     createData() {
450
-      this.$refs["dataForm"].validate(valid => {
457
+      this.$refs['dataForm'].validate(valid => {
451 458
         if (valid) {
452 459
           this.CreateCommunity(this.detail).then(res => {
453
-            this.dialogFormVisible = false;
460
+            this.dialogFormVisible = false
454 461
             if (res.code === '0') {
455 462
               this.$message({
456
-                message: "创建成功",
457
-                type: "success"
458
-              });
459
-              this.getList();
463
+                message: '创建成功',
464
+                type: 'success'
465
+              })
466
+              this.getList()
460 467
             } else if (res.code === '1') {
461 468
               this.$message({
462 469
                 message: res.message,
463
-                type: "warning"
464
-              });
470
+                type: 'warning'
471
+              })
465 472
             }
466
-          });
473
+          })
467 474
         }
468
-      });
475
+      })
469 476
     },
470 477
     handleUpdate(row) {
471
-      this.setCurrent(row);
472
-      this.dialogStatus = "update";
473
-      this.dialogFormVisible = true;
478
+      this.setCurrent(row)
479
+      this.dialogStatus = 'update'
480
+      this.dialogFormVisible = true
474 481
       this.$nextTick(() => {
475
-        this.$refs["dataForm"].clearValidate();
476
-      });
477
-      this.getEditCityList();
478
-      this.getEditDistrictList();
482
+        this.$refs['dataForm'].clearValidate()
483
+      })
484
+      this.getEditCityList()
485
+      this.getEditDistrictList()
479 486
     },
480 487
     handleLook(row) {
481
-      this.setCurrent(row);
482
-      this.dialogLookFormVisible = true;
488
+      this.setCurrent(row)
489
+      this.dialogLookFormVisible = true
483 490
       this.$nextTick(() => {
484
-        this.$refs["dataForm"].clearValidate();
485
-      });
486
-      this.getEditCityList();
487
-      this.getEditDistrictList();
491
+        this.$refs['dataForm'].clearValidate()
492
+      })
493
+      this.getEditCityList()
494
+      this.getEditDistrictList()
488 495
     },
489 496
     handleCreate() {
490
-      this.resetDetail();
491
-      this.dialogStatus = "create";
492
-      this.dialogFormVisible = true;
497
+      this.resetDetail()
498
+      this.dialogStatus = 'create'
499
+      this.dialogFormVisible = true
493 500
       this.$nextTick(() => {
494
-        this.$refs["dataForm"].clearValidate();
495
-      });
501
+        this.$refs['dataForm'].clearValidate()
502
+      })
496 503
     },
497 504
     updateData() {
498
-      this.$refs["dataForm"].validate(valid => {
505
+      this.$refs['dataForm'].validate(valid => {
499 506
         if (valid) {
500 507
           this.UpdateCommunity(this.detail).then(res => {
501
-            this.dialogFormVisible = false;
508
+            this.dialogFormVisible = false
502 509
             if (res.code === '0') {
503 510
               this.$message({
504
-                message: "更新成功",
505
-                type: "success"
506
-              });
507
-              this.getList();
511
+                message: '更新成功',
512
+                type: 'success'
513
+              })
514
+              this.getList()
508 515
             } else if (res.code === '1') {
509
-              this.$message.error(res.message);
516
+              this.$message.error(res.message)
510 517
             }
511
-          });
518
+          })
512 519
         }
513
-      });
520
+      })
514 521
     },
515 522
     handleDelete(row) {
516 523
       this.$notify({
517
-        title: "成功",
518
-        message: "删除成功",
519
-        type: "success",
524
+        title: '成功',
525
+        message: '删除成功',
526
+        type: 'success',
520 527
         duration: 2000
521
-      });
522
-      const index = this.list.indexOf(row);
523
-      this.list.splice(index, 1);
528
+      })
529
+      const index = this.list.indexOf(row)
530
+      this.list.splice(index, 1)
524 531
     },
525 532
     handleDownload() {
526
-      this.downloadLoading = true;
527
-      import("@/vendor/Export2Excel").then(excel => {
528
-        const tHeader = ["timestamp", "title", "type", "importance", "status"];
533
+      this.downloadLoading = true
534
+      import('@/vendor/Export2Excel').then(excel => {
535
+        const tHeader = ['timestamp', 'title', 'type', 'importance', 'status']
529 536
         const filterVal = [
530
-          "timestamp",
531
-          "title",
532
-          "type",
533
-          "importance",
534
-          "status"
535
-        ];
536
-        const data = this.formatJson(filterVal, this.list);
537
+          'timestamp',
538
+          'title',
539
+          'type',
540
+          'importance',
541
+          'status'
542
+        ]
543
+        const data = this.formatJson(filterVal, this.list)
537 544
         excel.export_json_to_excel({
538 545
           header: tHeader,
539 546
           data,
540
-          filename: "table-list"
541
-        });
542
-        this.downloadLoading = false;
543
-      });
547
+          filename: 'table-list'
548
+        })
549
+        this.downloadLoading = false
550
+      })
544 551
     },
545 552
     padDate(value) {
546
-      value = value < 10 ? "0" + value : value;
547
-      return value;
553
+      value = value < 10 ? '0' + value : value
554
+      return value
548 555
     },
549 556
     formatDate(val) {
550
-      var value = new Date(val);
551
-      var year = value.getFullYear();
552
-      var month = this.padDate(value.getMonth() + 1);
553
-      var day = this.padDate(value.getDate());
554
-      var hour = this.padDate(value.getHours());
555
-      var minutes = this.padDate(value.getMinutes());
556
-      var seconds = this.padDate(value.getSeconds());
557
+      var value = new Date(val)
558
+      var year = value.getFullYear()
559
+      var month = this.padDate(value.getMonth() + 1)
560
+      var day = this.padDate(value.getDate())
561
+      var hour = this.padDate(value.getHours())
562
+      var minutes = this.padDate(value.getMinutes())
563
+      var seconds = this.padDate(value.getSeconds())
557 564
       return (
558 565
         year +
559
-        "-" +
566
+        '-' +
560 567
         month +
561
-        "-" +
568
+        '-' +
562 569
         day +
563
-        " " +
570
+        ' ' +
564 571
         hour +
565
-        ":" +
572
+        ':' +
566 573
         minutes +
567
-        ":" +
574
+        ':' +
568 575
         seconds
569
-      );
576
+      )
570 577
     },
571 578
     formatJson(filterVal, jsonData) {
572 579
       return jsonData.map(v =>
573 580
         filterVal.map(j => {
574
-          if (j === "timestamp") {
575
-            return parseTime(v[j]);
581
+          if (j === 'timestamp') {
582
+            return parseTime(v[j])
576 583
           } else {
577
-            return v[j];
584
+            return v[j]
578 585
           }
579 586
         })
580
-      );
587
+      )
581 588
     },
582 589
     getProvinceName(provinceId) {
583
-      const tempProvince = this.provinceList;
590
+      const tempProvince = this.provinceList
584 591
       for (const i in tempProvince) {
585 592
         if (tempProvince[i].id === provinceId) {
586
-          return tempProvince[i].province;
593
+          return tempProvince[i].province
587 594
         }
588 595
       }
589 596
     },
590 597
     getCityName(cityId) {
591
-      const tempCity = this.editCityList;
598
+      const tempCity = this.editCityList
592 599
       for (const i in tempCity) {
593 600
         if (tempCity[i].id === cityId) {
594
-          return tempCity[i].city;
601
+          return tempCity[i].city
595 602
         }
596 603
       }
597 604
     },
598 605
     getDistrictName(districtId) {
599
-      const tempDistrict = this.editDistrictList;
606
+      const tempDistrict = this.editDistrictList
600 607
       for (const i in tempDistrict) {
601 608
         if (tempDistrict[i].id === districtId) {
602
-          return tempDistrict[i].district;
609
+          return tempDistrict[i].district
603 610
         }
604 611
       }
605 612
     }
606 613
   }
607
-};
614
+}
608 615
 </script>
616
+<style scoped>
617
+
618
+  .search-box {
619
+    position: absolute;
620
+    top: 25px;
621
+    left: 20px;
622
+  }
623
+
624
+  .amap-page-container {
625
+    position: relative;
626
+  }
627
+</style>