index.vue 31.4 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864
<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="148px">
      <el-form-item label="投放点名称" prop="dropPointName">
        <el-input
          v-model="queryParams.dropPointName"
          placeholder="请输入投放点名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="区域" prop="district">
        <el-select v-model="queryParams.district" placeholder="请选择所属区域" style="width: 100%" clearable @change="getStreets">
          <el-option v-for="(area,index) in areas" :label="area.name" :value="area.code" :key="index"/>
        </el-select>
      </el-form-item>
      <el-form-item label="街道" prop="street">
        <el-select v-model="queryParams.street" placeholder="请选择所属街道" style="width: 100%" clearable @change="getCommunitys">
          <el-option v-for="(area,index) in streets" :label="area.name" :value="area.code" :key="area.code"/>
        </el-select>
      </el-form-item>
      <el-form-item label="社区" prop="community">
        <el-select v-model="queryParams.community" placeholder="请选择   所属社区" style="width: 100%" clearable :disabled="infoDisable">
          <el-option v-for="(area,index) in communitys" :label="area.name" :value="area.code" :key="area.code" @click.native="createDropPointNo(area,'community')"/>
        </el-select>
      </el-form-item>

      <el-form-item label="详细地址" prop="address">
        <el-input
          v-model="queryParams.address"
          placeholder="请输入详细地址"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="是否为实行物业管理的区域(小区)" prop="type">
        <el-select v-model="queryParams.type" placeholder="请选择是否为实行物业管理的区域(小区)" clearable size="small">
          <el-option label="全部" value=""/>
          <el-option label="是" value="是"/>
          <el-option label="否" value="否"/>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-if="checkPer(['business.supervision.droppoint.insert'])"
        >新增
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-if="checkPer(['business.supervision.droppoint.edit'])"
        >修改
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-if="checkPer(['business.supervision.droppoint.delete'])"
        >删除
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-if="checkPer(['business.supervision.droppoint.export'])"
        >导出
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="dropPointInfoList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column label="投放点编号" align="center" prop="dropPointNo"/>
      <el-table-column label="投放点名称" align="center" prop="dropPointName">
        <template slot-scope="scope">
          <a href="javascript:void(0)" @click="handleInfo(scope.row)" style="color:#90DD5F;">{{ scope.row.dropPointName }}</a>
        </template>
      </el-table-column>
      <el-table-column label="所属区域" align="center" prop="district">
        <template slot-scope="scope">
          <span>{{ dict(scope.row.district) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="所属街道" align="center" prop="street">
        <template slot-scope="scope">
          <span>{{
            dictInfo(scope.row.street)
            }}</span>
        </template>
      </el-table-column>
      <el-table-column label="社区" align="center" prop="community">
        <template slot-scope="scope">
          <span>{{
              communitysInfo(scope.row.community)
            }}</span>
          </template>
      </el-table-column>
      <el-table-column label="小区" align="center" prop="plot"/>
      <el-table-column label="详细地址" align="center" prop="address"/>
      <el-table-column label="是否为实行物业管理的区域(小区)" align="center" prop="type"/>
      <el-table-column label="投放点面积(m²)" align="center" prop="area"/>
      <el-table-column label="投放点容量(m³)" align="center" prop="capacity"/>
      <el-table-column label="管理单位" align="center" prop="managementUnit"/>
      <el-table-column label="管理员" align="center" prop="custodian"/>
      <el-table-column label="管理员电话" align="center" prop="custodianPhone"/>
      <el-table-column label="投放时间" align="center" prop="dropTime" width="180"/>
      <el-table-column label="运营单位" align="center" prop="operatingUnit"/>
      <el-table-column label="运输单位" align="center" prop="transportUnit"/>
      <el-table-column label="审批状态" align="center" prop="status">
        <template slot-scope="scope">
          <span>{{ parseStatus(scope.row.status) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="创建时间" align="center" prop="createTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-if="checkPer(['business.supervision.droppoint.edit'])"
          >修改
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-if="checkPer(['business.supervision.droppoint.remove'])"
          >删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改投放点信息管理对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="148px">

            <el-form-item label="投放点编号" prop="dropPointNo">
              <el-input v-model="form.dropPointNo" placeholder="请输入投放点编号" :disabled="true"/>
            </el-form-item>

            <el-form-item label="投放点名称" prop="dropPointName">
              <el-input v-model="form.dropPointName" placeholder="请输入投放点名称" :disabled="infoDisable"/>
            </el-form-item>

            <el-form-item label="所属区域" prop="street">
              <el-select v-model="form.district" placeholder="请输入所属区域" style="width: 100%" clearable @change="getStreets" :disabled="infoDisable">
                <el-option v-for="(area,index) in areas" :label="area.name" :value="area.code" :key="index"/>
              </el-select>
            </el-form-item>

            <el-form-item label="所属街道" prop="street">
              <el-select v-model="form.street" placeholder="请输入所属街道" style="width: 100%" clearable @change="getCommunitys" :disabled="infoDisable">
                <el-option v-for="(area,index) in streets" :label="area.name" :value="area.code" :key="area.code"/>
              </el-select>
            </el-form-item>

        <el-form-item label="社区" prop="community">
          <el-select v-model="form.community" placeholder="请输入所属社区" style="width: 100%" clearable :disabled="infoDisable">
            <el-option v-for="(area,index) in communitys" :label="area.name" :value="area.code" :key="area.code" @click.native="createDropPointNo(area,'community')"/>
          </el-select>
        </el-form-item>

          <el-form-item label="小区" prop="plot">
            <el-input v-model="form.plot" placeholder="请输入小区" :disabled="infoDisable"/>
          </el-form-item>

            <el-form-item label="详细地址" prop="address">
              <el-input v-model="form.address" placeholder="请输入详细地址" :disabled="infoDisable"/>
            </el-form-item>

            <el-form-item label="是否为实行物业管理的区域(小区)" prop="type" class="lowheight">
              <el-select v-model="form.type" placeholder="请选择是否为实行物业管理的区域(小区)" style="width: 100%" :disabled="infoDisable">
                <el-option label="是" value="是"/>
                <el-option label="否" value="否"/>
              </el-select>
            </el-form-item>

            <el-form-item label="投放点面积(m²)" prop="area">
              <el-input v-model="form.area" placeholder="请输入投放点面积" :disabled="infoDisable"/>
            </el-form-item>

            <el-form-item label="投放点容量(m³)" prop="capacity">
              <el-input v-model="form.capacity" placeholder="请输入投放点容量" :disabled="infoDisable"/>
            </el-form-item>

            <el-form-item label="管理单位" prop="managementUnit">
              <el-input v-model="form.managementUnit" placeholder="请输入管理单位" :disabled="infoDisable"/>
            </el-form-item>

            <el-form-item label="管理员" prop="custodian">
              <el-input v-model="form.custodian" placeholder="请输入管理员" :disabled="infoDisable"/>
            </el-form-item>

            <el-form-item label="管理员电话" prop="custodianPhone">
              <el-input v-model="form.custodianPhone" placeholder="请输入管理员联系电话" :maxlength="11" show-word-limit :disabled="infoDisable"/>
            </el-form-item>

            <el-form-item label="投放时间" prop="dropTime" v-if="dropTime">
              <el-time-select
                placeholder="起始时间"
                v-model="form.dropTime"
                style="width: 50%"
                :picker-options="{
                  start: '00:00',
                  step: '00:15',
                  end: '23:45'
                }" :disabled="infoDisable">
              </el-time-select>
              <el-time-select
                placeholder="结束时间"
                v-model="endTime"
                style="width: 50%"
                :picker-options="{
                start: '00:15',
                step: '00:15',
                end: '24:00',
                minTime: form.dropTime
              }" :disabled="infoDisable">
              </el-time-select>
            </el-form-item>

            <el-form-item label="运营单位" prop="operatingUnit">
              <el-input v-model="form.operatingUnit" placeholder="请输入运营单位" :disabled="infoDisable"/>
            </el-form-item>

            <el-form-item label="运输单位" prop="transportUnit">
              <el-input v-model="form.transportUnit" placeholder="请输入运输单位" :disabled="infoDisable"/>
            </el-form-item>

            <el-form-item label="坐标点" prop="coordinatePoint">
              <el-input v-model="form.coordinatePoint" placeholder="请输入坐标点经纬度" readonly @click.native="handleOpenMap" :disabled="infoDisable"/>
            </el-form-item>
<!--            <el-button type="primary" @click="handleOpenMap">坐标点</el-button>-->

      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm" v-show="!infoDisable">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <el-dialog title="高德地图" :visible.sync="openMap" width="1600px" height="750px" append-to-body>
      <div class="serach_map">
        搜索:
        <el-select
          v-model="keywords"
          filterable
          remote
          placeholder="请输入关键词"
          :remote-method="remoteMethod"
          :loading="loading"
          :clearable="true"
          size="mini"
          @change="currentSelect"
          style="width: 250px"
        >
          <el-option
            v-for="item in mapOptions"
            :key="item.id"
            :label="item.name"
            :value="item"
            class="one-text"
          >
            <span style="float: left">{{ item.name }}</span>
            <span style="float: right; color: #8492a6; font-size: 13px">{{
                item.district
              }}</span>
          </el-option>
        </el-select>
      </div>
      <div v-loading="loading" id="dropPointInfoContainer" class="am-map" style="width:100%;height: 700px;"></div>
      <div slot="footer" class="dialog-footer">
<!--        <el-button type="primary" @click="clearCoordinatePoint">清除坐标点</el-button>-->
        <el-button type="primary" @click="openMap = false">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<style>
  [for='type']{
    line-height: 18px!important;
  }
</style>
<script>
import {
  listDropPointInfo,
  getDropPointInfo,
  delDropPointInfo,
  addDropPointInfo,
  updateDropPointInfo,
  exportDropPointInfo
} from "@/api/unit/dropPointInfo";
import {getAreaList,getAreasList} from "@/api/dict"
import AMapLoader from "@amap/amap-jsapi-loader";
import Treeselect from "@riophae/vue-treeselect";


export default {
  name: "DropPointInfo",
  components: {AMapLoader},
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 投放点信息管理表格数据
      dropPointInfoList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        dropPointName: null,
        address: null,
        type: null,
        district: null,
        street: null,
        community: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        dropPointName: [
          {required: true, message: "请输入投放点名称", trigger: "blur"}
        ],
        district: [
          {required: true, message: "请输入所属区域", trigger: "blur"}
        ],
        street: [
          {required: true, message: "请输入所属街道", trigger: "blur"}
        ],
        community: [
          {required: true, message: "请选择社区", trigger: "blur"}
        ],
        plot: [
          {required: true, message: "请输入小区", trigger: "blur"}
        ],
        address: [
          {required: true, message: "请输入详细地址", trigger: "blur"}
        ],
        type: [
          {required: true, message: "请选择是否为实行物业管理的区域(小区)", trigger: "change"}
        ],
        area: [
          {required: true, message: "请输入投放点面积", trigger: "blur"},
          //只能填写数字、小数
          {pattern: /^[0-9]+(\.[0-9]{1,2})?$/, message: "只能填写数字、小数,限制两位小数", trigger: "blur"}
        ],
        capacity: [
          {required: true, message: "请输入投放点容量", trigger: "blur"},
          //只能填写数字
          {pattern: /^[0-9]+(\.[0-9]{1,2})?$/, message: "只能填写数字、小数,限制两位小数", trigger: "blur"}
        ],
        managementUnit: [
          {required: true, message: "请输入管理单位", trigger: "blur"}
        ],
        custodian: [
          {required: true, message: "请输入管理员", trigger: "blur"}
        ],
        custodianPhone: [
          {required: true, message: "请输入管理员电话", trigger: "blur"},
          {
            pattern: /^1(3|4|5|6|7|8|9)\d{9}$/,
            message: '手机号格式错误',
            trigger: 'change'
          }
        ],
        dropTime: [
          {required: true, message: "请选择投放时间", trigger: "change"}
        ],
        transportUnit: [
          {required: true, message: "请输入运输单位", trigger: "blur"}
        ],
        coordinatePoint: [
          {required: true, message: "请点击坐标点按钮选择坐标点", trigger: "blur"}
        ]
      },
      //区域
      areas: [],
      //街道
      streets:[],
      //社区
      communitys:[],
      // 地图
      map: null,
      keywords: "",
      mapOptions: [],
      openMap:false,
      center: null,
      circleMarker: null,
      endTime: null,
      dropTime: true,
      infoDisable: false,
      mapKeys:["3865c516a0e83ce0ca5cec3f2087675c","9439896287541d826bbaf6404063c9c2","0a4662cc567d13bdbebf71fa3dc036cc","c9c4209ece71ef5b067042eef519d760","f6d9c20b27210843d7e6155263e5fc9e","82e4528bd3f0f9326f3876e1f21dd2a6"],
      jsCode: ["c82d0bf9ef42c220d3295a712cdd18b8","70c91935d43cc5b7b5f95f1b295ae1d1","e7867b1dbe76542fb23e320b6086506f","c79a8e6fe3113b24a8453e9bb20f4e7f","a326cb01a4f76dbb4a1f25c6dae2c369","b9654214149df203f59c61e25092302c"],
      keyIndex: 0
    };
  },
  created() {
    this.keyIndex = this.$cache.session.get("keyIndex") || 0;
    console.log("keyIndex",this.keyIndex)
    window._AMapSecurityConfig = {
      securityJsCode: this.jsCode[this.keyIndex]
    }
    getAreasList().then(response => {
      if(response==null || response.length===0){
        this.$message.error("获取区域列表失败");
        return;
      }
      let data = response.filter(data => data.code === "430100" && data.code !== "430182" && data.code !== "430183" && data.code !== "430681"&& data.code !== "430624");
      // console.log(data)
      this.areas = data[0].items.filter(data => data.code !== "430182" && data.code !== "430183" && data.code !== "430681"&& data.code !== "430624");
      console.log(this.areas)
      // for (let dataKey in data) {
      //   if(data[dataKey].parentCode === '430100'){
      //     this.areas.push({name:data[dataKey].name,code:data[dataKey].code, streets:[]})
      //   }
      // }
      // for(let dataKey in data){
      //   for(let areas1Key in this.areas){
      //     if(data[dataKey].parentCode === this.areas[areas1Key].code){
      //       this.areas[areas1Key].streets.push({code:data[dataKey].code, name:data[dataKey].name,item:data[dataKey].items})
      //     }
      //   }
      // }
    });

    this.getList();
    // this.initAMap();
  },
  methods: {
    handleInfo(row){
      this.reset();
      const id = row.id;
      this.dropTime = false;
      getDropPointInfo(id).then(response => {
        let dropTime = response.data.dropTime.split("~");
        this.form = response.data;
        let dropNo = response.data.dropPointNo;
        console.log(this.form)
        this.getStreets(this.form.district)
        this.getCommunitys(this.form.street)
        this.form.dropTime = dropTime[0];
        this.endTime = dropTime[1];
        this.open = true;
        this.title = "查看投放点信息管理";
        this.dropTime = true;
        this.infoDisable = true;
        this.form.dropPointNo = dropNo;
      });
    },
    dict(code){
      for(let key in this.areas){
        if(this.areas[key].code === code){
          // this.streets = this.areas[key].items;
          return this.areas[key].name;
        }
      }
    },
    dictInfo(code){
      for(let key in this.areas){
        for(let key1 in this.areas[key].items){
          if(this.areas[key].items[key1].code === code){
            return this.areas[key].items[key1].name;
          }
        }
      }
    },
    communitysInfo(code){
      for(let key in this.areas){
        for(let key1 in this.areas[key].items){
         for (let key2 in this.areas[key].items[key1].items){
           if (this.areas[key].items[key1].items[key2].code === code){
             return this.areas[key].items[key1].items[key2].name;
           }
         }
        }
      }
    },
    clearCoordinatePoint(){
      this.center = null;
      this.form.coordinatePoint = null;
      this.map = null;
      this.circleMarker = null;
      this.initAMap();
    },
    handleOpenMap(){
      this.openMap = true;
      this.initAMap();
    },
    initAMap() {
      const _this = this
      // 加载高德地图
      AMapLoader.load({
        key: _this.mapKeys[_this.keyIndex],  //设置高德地图申请的key
        version: "2.0",  // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
        plugins: ['AMap.ToolBar','AMap.AutoComplete', 'AMap.PlaceSearch', 'AMap.Marker','AMap.CircleMarker'], // 需要使用的的插件列表,如比例尺'AMap.Scale'等
        AMapUI: {
          version: "1.1",
          plugins: []
        },
        Loca: {
          version: "2.0"
        },
      }).then(async (AMap) => {
        _this.map = await new AMap.Map("dropPointInfoContainer", { //设置地图容器id
          viewMode: "2D",  // 默认使用 2D 模式
          center: [113.01814545605467, 28.201039299894283], // 初始化地图中心点位置
          zoom: 11, //初始化地图层级
          resizeEnable: true,
          willreadoften: true
        });
        _this.AutoComplete = await new AMap.AutoComplete({city:'长沙'});
        // 数据回显
        if(_this.form.coordinatePoint!=null&&_this.form.coordinatePoint!==""){
          //设置圆形位置
          _this.center = new AMap.LngLat(_this.form.coordinatePoint.split(",")[0], _this.form.coordinatePoint.split(",")[1]);
          //设置圆的半径大小
          var radius = 10 //单位:px

          //创建圆形点标记 CircleMarker 实例
          _this.circleMarker = new AMap.CircleMarker({
            center: _this.center, //圆心
            radius: radius, //半径
            strokeColor: "white", //轮廓线颜色
            strokeWeight: 2, //轮廓线宽度
            strokeOpacity: 0.5, //轮廓线透明度
            fillColor: "rgba(0,0,255,1)", //圆点填充颜色
            fillOpacity: 0.5, //圆点填充透明度
            zIndex: 10, //圆点覆盖物的叠加顺序
            cursor: "pointer", //鼠标悬停时的鼠标样式
          });
          //圆形 circleMarker 对象添加到 Map
          _this.map.add(_this.circleMarker);
          //将覆盖物调整到合适视野
          _this.map.setFitView([_this.circleMarker]);
        }
        // 监听地图点击事件
        _this.map.on("click", (e) => {
          console.log(e)
          if(_this.center!=null){
            _this.map.remove(_this.circleMarker);
            _this.center = null;
            _this.form.coordinatePoint = null;
          }

          //判断是否已有圆点标记
          if(_this.center==null){
            //设置圆形位置
            _this.center = new AMap.LngLat(e.lnglat.lng, e.lnglat.lat);
            //设置圆的半径大小
            var radius = 10 //单位:px

            //创建圆形点标记 CircleMarker 实例
            _this.circleMarker = new AMap.CircleMarker({
              center: _this.center, //圆心
              radius: radius, //半径
              strokeColor: "white", //轮廓线颜色
              strokeWeight: 2, //轮廓线宽度
              strokeOpacity: 0.5, //轮廓线透明度
              fillColor: "rgba(0,0,255,1)", //圆点填充颜色
              fillOpacity: 0.5, //圆点填充透明度
              zIndex: 10, //圆点覆盖物的叠加顺序
              cursor: "pointer", //鼠标悬停时的鼠标样式
            });
            //圆形 circleMarker 对象添加到 Map
            _this.map.add(_this.circleMarker);
            //将覆盖物调整到合适视野
            _this.map.setFitView([_this.circleMarker]);
            _this.$set(_this.form, "coordinatePoint", e.lnglat.lng+","+e.lnglat.lat);
          }
        });
      }).catch(e => {
        console.log(e);
      });
      this.loading = false;
      // this.openMap = false;
    },
    // 选中提示
    currentSelect(val) {
      console.log(val);
      // 清空时不执行后面代码
      if (!val) {
        return ;
      }

      //清除marker
      if (this.searchMarker){
        this.map.remove(this.searchMarker)
      }
      //设置marker
      // this.searchMarker = new AMap.Marker({
      //   map: this.map,
      //   position: [val.location.lng, val.location.lat],
      // });
      // 自动适应显示想显示的范围区域
      //定位
      this.map.setCenter([val.location.lng, val.location.lat])
      this.map.setZoom(18);
      this.keywords = val.name

    },
    // 搜索地址
    remoteMethod(query) {
      if (query !== "") {
        this.loading = true;
        setTimeout(() => {
          this.loading = false;
          this.AutoComplete.search(query, (status, result) => {
            if(result==="USER_DAILY_QUERY_OVER_LIMIT"){
              this.$message.error("当前 key["+this.mapKeys[this.keyIndex]+"] 今日查询次数上限,请刷新页面!");
              this.keyIndex = (this.keyIndex+1) % this.mapKeys.length;
              this.$cache.session.set("keyIndex", this.keyIndex);
            }
            this.mapOptions = result.tips;
          });
        }, 200);
      } else {
        this.mapOptions = [];
      }
    },
    createDropPointNo(area){
        listDropPointInfo({dropPointNo: area.code}).then(response => {
          const total = response.total+1;
          this.form.dropPointNo = area.code+total.toString().padStart(3, '0');
        });

    },
    getStreets(regionName) {
      if(this.queryParams.district!=null){
        this.queryParams.street = null;
        this.queryParams.community = null;
      }
      if(this.form.id==null&&this.form.district!=null){
        this.form.street = null;
        this.form.community = null;
      }
      this.streets = [];
      this.form.dropPointNo = null;
      // this.form.street = null;
      const region = this.areas.find(region => region.code === regionName);
      this.streets = region.items;
    },
    getCommunitys(regionName){
      if(this.queryParams.street!=null){
        this.queryParams.community = null;
      }
      if(this.form.id==null&&this.form.street!=null){
        this.form.community = null;
      }
      this.communitys = [];
      this.form.dropPointNo = null;
      // this.form.community = null;
      console.log(this.streets)
      console.log(regionName)
      const region = this.streets.find(region => region.code === regionName);
      console.log(region)
      this.communitys = region.items;
    },
    /** 下载文件 */
    /** 查询投放点信息管理列表 */
    getList() {
      this.loading = true;
      listDropPointInfo(this.queryParams).then(response => {
        this.dropPointInfoList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        dropPointName: null,
        district: null,
        street: null,
        community: null,
        address: null,
        type: null,
        area: null,
        capacity: null,
        managementUnit: null,
        custodian: null,
        custodianPhone: null,
        dropTime: null,
        dropPointNo: null,
        operatingUnit: null,
        transportUnit: null,
        createTime: null,
        createBy: null,
        updateTime: null,
        updateBy: null
      };
      this.endTime = null;
      this.streets = [];
      this.communitys = [];
      this.map = null;
      this.center = null;
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.dropTime = true;
      this.title = "添加投放点信息管理";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      this.dropTime = false;
      this.infoDisable = false
      getDropPointInfo(id).then(response => {
        let dropTime = response.data.dropTime.split("~");
        this.form = response.data;
        let dropNo = response.data.dropPointNo;
        console.log(this.form)
        this.getStreets(this.form.district)
        this.getCommunitys(this.form.street)
        this.form.dropTime = dropTime[0];
        this.endTime = dropTime[1];
        this.open = true;
        this.title = "修改投放点信息管理";
        this.dropTime = true;
        this.form.dropPointNo = dropNo;
      });
    },
    /** 提交按钮 */
    submitForm() {

      this.$refs["form"].validate(valid => {
        if (valid) {
          let dropTime = this.form.dropTime;
          if(this.endTime!=null){
            this.form.dropTime = this.form.dropTime + "~" + this.endTime;
          }else{
            this.$message.error("请选择投放结束时间");
            return;
          }
          if (this.form.id != null) {
            updateDropPointInfo(this.form).then(response => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.form.dropTime = dropTime;
              this.getList();
            });
          } else {
            addDropPointInfo(this.form).then(response => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.form.dropTime = dropTime;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$confirm('是否确认删除投放点信息管理编号为"' + ids + '"的数据项?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(function () {
        return delDropPointInfo(ids);
      }).then(() => {
        this.getList();
        this.msgSuccess("删除成功");
      })
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有投放点信息管理数据项?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(function () {
        return exportDropPointInfo(queryParams);
      }).then(response => {
        this.download(response.message);
      })
    }
  }
};
</script>