index.vue 22.1 KB
Newer Older
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
<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="82px">
      <el-form-item label="储配站名称" prop="stationName">
        <el-input
          v-model="queryParams.stationName"
          placeholder="请输入储配站名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="储配站编号" prop="stationCode">
        <el-input
          v-model="queryParams.stationCode"
          placeholder="请输入储配站编号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="创建时间" prop="createTime">
        <el-date-picker
          v-model="createTime"
          type="datetimerange"
          value-format="yyyy-MM-dd HH:mm:ss"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          @change="timeChange"
        >
        </el-date-picker>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" 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"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
        >新增储配站</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          plain
          icon="el-icon-upload2"
          size="mini"
          @click="handleImport"
          style="color: #1890ff"
        >导入</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          plain
          icon="el-icon-download"
          size="mini"
          :loading="exportLoading"
          @click="handleExport"
          style="color: #1890ff"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="infoList">
      <el-table-column label="储配站名称" align="center" prop="stationName" width="120" :show-overflow-tooltip="true"/>
      <el-table-column label="储配站编号" align="center" prop="stationCode" width="120" :show-overflow-tooltip="true"/>
      <el-table-column label="负责人" align="center" prop="director" />
      <el-table-column label="联系电话" align="center" prop="telNum" width="120"/>
      <el-table-column label="许可证编号" align="center" prop="licenceCode" width="120" :show-overflow-tooltip="true"/>
      <el-table-column label="许可证日期起" align="center" prop="licenceEffectiveDate" width="120">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.licenceEffectiveDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="许可证日期止" align="center" prop="licenceLimitDate" width="120">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.licenceLimitDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="创建时间" align="center" prop="createTime" width="150">
        <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" prop="address" :show-overflow-tooltip="true"/>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="150">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-document"
            @click="showDetail(scope.row)"
          >详情</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
          >删除</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="120px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="储配站名称" prop="stationName">
              <el-input v-model="form.stationName" placeholder="请输入名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="储配站编码" prop="stationCode">
              <el-input v-model="form.stationCode" placeholder="请输入代码" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="负责人" prop="director">
              <el-input v-model="form.director" placeholder="请输入负责人" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="联系电话" prop="telNum">
              <el-input v-model="form.telNum" placeholder="请输入联系电话" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-form-item label="许可证文件">
          <!--<fileUpload v-model="form.licenceFile"/>-->
          <FileUpload
            listType="picture"
            @resFun="getFileInfoFile"
            @remove="listRemoveFile"
            :fileArr="fileListFile"
            :fileType="fileType"
          />
          <el-input v-show="false" disabled v-model="form.licenceFile"></el-input>
        </el-form-item>

        <el-row>
          <el-col :span="12">
            <el-form-item label="许可证编号" prop="licenceCode">
              <el-input v-model="form.licenceCode" placeholder="请输入许可证编号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="许可证日期起" prop="licenceEffectiveDate">
              <el-date-picker clearable size="small"
                              v-model="form.licenceEffectiveDate"
                              type="date"
                              value-format="yyyy-MM-dd"
                              style="width: 100%"
                              placeholder="选择许可证日期起">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="许可证日期止" prop="licenceLimitDate">
              <el-date-picker clearable size="small"
                              v-model="form.licenceLimitDate"
                              type="date"
                              value-format="yyyy-MM-dd"
                              style="width: 100%"
                              placeholder="选择许可证日期止">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="地址" prop="address">
              <el-input v-model="form.address" placeholder="请输入地址" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-form-item label="经纬度坐标" prop="longitude">
          <el-col :span="9">
            <el-input v-model="form.longitude" placeholder="请输入经度" />
          </el-col>
          <el-col :span="9" style="margin-left: 10px">
            <el-input v-model="form.latitude" placeholder="请输入纬度"/>
          </el-col>
          <el-col :span="3" style="margin-left: 30px">
            <el-button type="primary" plain @click="MapdialogFun">选择经纬度</el-button>
          </el-col>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm"> </el-button>
        <el-button @click="cancel"> </el-button>
      </div>
    </el-dialog>

    <GetPos
      :dialogVisible.sync="dialogTableVisible"
      device=""
      :devicePos="devicePos"
      @close="dialogcancelFun"
      @getPath="getPath"
    />

    <!-- 储配站导入 -->
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
      <el-upload
        ref="upload"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="upload.headers"
        :action="upload.url + '?updateSupport=' + upload.updateSupport"
        :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress"
        :on-success="handleFileSuccess"
        :auto-upload="false"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">
          将文件拖到此处,或
          <em>点击上传</em>
        </div>
        <div class="el-upload__tip" slot="tip">
          <el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据
          <el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link>
        </div>
        <div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“xls”或“xlsx”格式文件!</div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm"> </el-button>
        <el-button @click="upload.open = false"> </el-button>
      </div>
    </el-dialog>

    <el-dialog title="储配站详情" :visible.sync="detailOpen" width="1000px" append-to-body @close="cancel">
      <el-row>
        <el-col :span="14">
          <el-form ref="form" :model="form" label-width="120px">
            <el-row>
              <el-col :span="12">
                <el-form-item label="储配站名称" prop="stationName">
                  <span>{{ form.stationName }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="储配站编码" prop="stationCode">
                  <span>{{ form.stationCode }}</span>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="负责人" prop="director">
                  <span>{{ form.director }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="联系电话" prop="telNum">
                  <span>{{ form.telNum }}</span>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="12">
                <el-form-item label="许可证文件">
               <span class="dbtn" @click="checkFile(form.licenceFile)" v-if="form.licenceFile != ''">
                      <i class="el-icon el-icon-view"></i>查看/下载
                    </span>
                  <span v-else>-</span>
                </el-form-item>
              </el-col>

              <el-col :span="12">
                <el-form-item label="许可证编号" prop="licenceCode">
                  <span>{{ form.licenceCode }}</span>
                </el-form-item>
              </el-col>
            </el-row>


            <el-row>
              <el-col :span="12">
                <el-form-item label="许可证日期起" prop="licenceEffectiveDate">
                  <span>{{ form.licenceEffectiveDate }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="许可证日期止" prop="licenceLimitDate">
                  <span>{{ form.licenceLimitDate }}</span>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="地址" prop="address">
                  <span>{{ form.address }}</span>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </el-col>

        <el-col :span="9">
          <div style="width: 100%;height: 350px; border: 1px solid rgb(218, 213, 213);margin-bottom: 10px;">
            <div style="width: 100%;height: 100%" id="gasHolderStationContainer"></div>
          </div>
        </el-col>
      </el-row>
    </el-dialog>
  </div>
</template>

<script>
import { listInfo, getInfo, delInfo, addInfo, updateInfo, exportInfo, importTemplate } from "@/api/gasBottleTrack/gasHolderStationManage";
import FileUpload from '@/components/FileUpload';
import uploadfile from "@/assets/uploadfile.png";
import GetPos from '@/components/GetPos';
import { getToken } from "@/utils/auth";
import { EditorMap } from "@/utils/mapClass/getPath.js";
export default {
  name: "Info",
  components: {
    FileUpload,
    GetPos
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 储配站信息表格数据
      infoList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        stationName: null,
        stationCode: null,
        director: null,
        telNum: null,
        address: null,
        licenceFile: null,
        licenceCode: null,
        licenceEffectiveDate: null,
        licenceLimitDate: null,
        longitude: null,
        latitude: null,
        createBeginTime: null,
        createEndTime: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        stationName: [
          { required: true, message: "储配站名称不能为空", trigger: "blur" }
        ],
        stationCode: [
          { required: true, message: "储配站编号不能为空", trigger: "blur" }
        ],
        director: [
          { required: true, message: "负责人不能为空", trigger: "blur" }
        ],
        telNum: [
          { required: true, message: "联系电话不能为空", trigger: "blur" }
        ],
        licenceCode: [
          { required: true, message: "许可证编号不能为空", trigger: "blur" }
        ],
        licenceEffectiveDate: [
          { required: true, message: "许可证日期起不能为空", trigger: "change" }
        ],
        licenceLimitDate: [
          { required: true, message: "许可证日期止不能为空", trigger: "change" }
        ],
        address: [
          { required: true, message: "地址不能为空", trigger: "blur" }
        ],
        longitude: [
          { required: true, message: "请输入经纬度", trigger: "blur" },
        ],
      },
      fileListFile:[],
      fileType: ['doc', 'xls', 'ppt','txt','pdf'],
      // 地图
      dialogTableVisible: false,
      devicePos: [],
      createTime: [],
      upload: {
        // 是否显示弹出层(用户导入)
        open: false,
        // 弹出层标题(用户导入)
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/gasBottleTrack/storageStationManage/importData"
      },
      readOnly: false,
      detailOpen: false,
      map: null
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询储配站信息列表 */
    getList() {
      this.loading = true;
      listInfo(this.queryParams).then(response => {
        this.infoList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.detailOpen = false;
      this.reset();
      this.map.destroy();
    },
    // 表单重置
    reset() {
      this.form = {
        stationId: null,
        stationName: null,
        stationCode: null,
        director: null,
        telNum: null,
        address: null,
        licenceFile: null,
        licenceCode: null,
        licenceEffectiveDate: null,
        licenceLimitDate: null,
        longitude: null,
        latitude: null,
        createTime: null,
        updateTime: null,
        remark: null
      };
      this.resetForm("form");
      this.fileListFile = [];
      this.devicePos = [];
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.createTime = [];
      this.queryParams.createBeginTime =  null;
      this.queryParams.createEndTime =  null;
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.stationId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加储配站信息";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const stationId = row.stationId || this.ids
      getInfo(stationId).then(response => {
        this.form = response.data;
        this.open = true;
        if(this.form.longitude && this.form.latitude){
          this.devicePos = [this.form.longitude,this.form.latitude];
        }
        if(this.form.licenceFile){
          this.fileListFile = [
            {
              name: this.form.stationName,
              url: uploadfile,
            }];
        }
        this.title = "修改储配站信息";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.stationId != null) {
            updateInfo(this.form).then(response => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addInfo(this.form).then(response => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const stationIds = row.stationId || this.ids;
      this.$confirm('是否确认删除储配站信息编号为"' + row.stationName + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delInfo(stationIds);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有储配站信息数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(() => {
          this.exportLoading = true;
          return exportInfo(queryParams);
        }).then(response => {
          this.download(response.msg);
          this.exportLoading = false;
        }).catch(() => {});
    },
    getFileInfoFile(res) {
      this.form.licenceFile = res.url;
      this.fileListFile = [
        {
          name: res.fileName,
          url: uploadfile,
        },
      ];
    },
    listRemoveFile(e) {
      this.fileListFile = [];
      this.form.licenceFile = "";
    },
    MapdialogFun() {
      this.dialogTableVisible = true;
    },
    dialogcancelFun() {
      this.dialogTableVisible = false;
    },
    getPath(res){
      //确认选择经纬度
      this.form.longitude = res[0];
      this.form.latitude = res[1];
    },
    timeChange(value){
      this.queryParams.createBeginTime =  value[0];
      this.queryParams.createEndTime =  value[1];
    },
    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = "储配站导入";
      this.upload.open = true;
    },
    /** 下载模板操作 */
    importTemplate() {
      importTemplate().then(response => {
        this.download(response.msg);
    });
    },
    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    // 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
      this.getList();
    },
    // 提交上传文件
    submitFileForm() {
      this.$refs.upload.submit();
    },
    showDetail(row){
      this.reset();
      const stationId = row.stationId || this.ids
      getInfo(stationId).then(response => {
        this.form = response.data;
        const devicePos = [this.form.longitude, this.form.latitude];
        this.detailOpen = true;
        this.$nextTick(() => {
          this.map = new EditorMap("gasHolderStationContainer", {}, this);
          this.map.addDevice({ path: devicePos });
          this.map.nowMouseTarget = null;
          this.map.mousetoolClose(false);
        });
      });
    },
    checkFile(url) {
      window.open(url,'_blank');
    },
  }
};
</script>
<style scoped lang="scss">
  .dbtn {
    display: inline-block;
    line-height: normal;
    padding-left: 2px;
    padding-right: 2px;
    cursor: pointer;
    border-radius: 3px;
    border-style: solid;
    border-width: 0;
    color: rgb(48, 180, 107);
  }
  .dbtn:hover {
    border-width: 1px;
    border-color: rgb(48, 180, 107);
  }
</style>