From 4342ccaa6a8dff9f10554867891c3abfbc23f0b1 Mon Sep 17 00:00:00 2001
From: liuyg <liuyg@qq.com>
Date: Thu, 24 Mar 2022 11:59:06 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.0.105:10010/r/school-java-web
---
src/views/hd/baseMap.vue | 632 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 632 insertions(+), 0 deletions(-)
diff --git a/src/views/hd/baseMap.vue b/src/views/hd/baseMap.vue
new file mode 100644
index 0000000..e76c086
--- /dev/null
+++ b/src/views/hd/baseMap.vue
@@ -0,0 +1,632 @@
+<template>
+ <basic-container>
+ <avue-crud
+ :option="option"
+ :table-loading="loading"
+ :data="data"
+ :page.sync="page"
+ :permission="permissionList"
+ :before-open="beforeOpen"
+ v-model="form"
+ ref="crud"
+ @row-update="rowUpdate"
+ @row-save="rowSave"
+ @row-del="rowDel"
+ @search-change="searchChange"
+ @search-reset="searchReset"
+ @selection-change="selectionChange"
+ @current-change="currentChange"
+ @size-change="sizeChange"
+ @refresh-change="refreshChange"
+ @on-load="onLoad"
+ >
+ <!-- <template slot="menuLeft">
+ <el-button
+ type="danger"
+ size="small"
+ icon="el-icon-delete"
+ plain
+ v-if="permission.hd_delete"
+ @click="handleDelete"
+ >删 除
+ </el-button>
+ </template> -->
+ <template slot-scope="{ type, disabled }" slot="haveBaseMapForm">
+ <div class="inputInline" v-show="!notSet">
+ <el-input
+ v-model="chouseBaseMapTypeOnce"
+ placeholder="底图名称"
+ class="inputInlineType"
+ ></el-input>
+ <el-input
+ placeholder="请输入底图地址"
+ v-model="mapServiceValueOnce"
+ class="input-with-select"
+ >
+ <!-- <el-select
+ v-model="chouseBaseMapTypeOnce"
+ slot="prepend"
+ placeholder="请选择"
+ >
+ <el-option label="餐厅名" value="1"></el-option>
+ <el-option label="2" value="2"></el-option>
+ </el-select> -->
+ <el-button
+ slot="append"
+ icon="el-icon-plus"
+ @click="addMapServices"
+ ></el-button>
+ </el-input>
+ </div>
+ </template>
+ <template slot-scope="{ type, disabled }" slot="lineForm">
+ <baseMapMap
+ ref="baseMapMap"
+ id="baseMapMap"
+ @setMapData="setMapData"
+ @changeMapSI="changeMapSI"
+ ></baseMapMap>
+ </template>
+ </avue-crud>
+ </basic-container>
+</template>
+
+<script>
+import {
+ getList,
+ getHdName,
+ getDetail,
+ add,
+ update,
+ remove,
+} from "@/api/hd/baseMap";
+import { mapGetters } from "vuex";
+import baseMapMap from "./baseMapMap.vue";
+
+export default {
+ components: {
+ // Map,
+ baseMapMap,
+ },
+ data() {
+ return {
+ mapServiceValueOnce: "",
+ chouseBaseMapTypeOnce: "XYZ",
+ form: {},
+ query: {},
+ loading: true,
+ page: {
+ pageSize: 10,
+ currentPage: 1,
+ total: 0,
+ },
+ selectionList: [],
+ option: {
+ height: "auto",
+ calcHeight: 30,
+ tip: false,
+ searchShow: true,
+ searchMenuSpan: 6,
+ border: true,
+ index: true,
+ viewBtn: true,
+ align: "center",
+ selection: true,
+ indexLabel: "序号",
+ dialogClickModal: false,
+ column: [
+ {
+ label: "专题名称",
+ prop: "hdid",
+ editDisabled: true,
+ type: "select",
+ dicData: [
+ // {
+ // label: "真",
+ // value: "true",
+ // },
+ // {
+ // label: "假",
+ // value: "false",
+ // },
+ ],
+ rules: [
+ {
+ required: true,
+ message: "请输入活动名称",
+ trigger: "blur",
+ },
+ ],
+ },
+ // {
+ // label: "活动地点",
+ // viewDisply:false,
+ // addDisplay: false,
+ // hide: true,
+ // editDisply: false,
+ // prop: "address",
+ // },
+ // {
+ // label: "时间",
+ // prop: "time",
+ // type: "datetime",
+ // span: 8,
+ // format: "yyyy-MM-dd hh:mm:ss",
+ // valueFormat: "yyyy-MM-dd hh:mm:ss",
+ // mock: {
+ // type: "datetime",
+ // format: "yyyy-MM-dd hh:mm:ss",
+ // now: true,
+ // },
+ // },
+ // {
+ // label: "图片",
+ // prop: "tpurl",
+ // // dataType: 'string',
+ // type: "upload",
+ // propsHttp: {
+ // res: "data",
+ // url: "link",
+ // },
+ // span: 24,
+ // listType: "picture-card",
+ // tip: "只能上传jpg/png文件,且不超过500kb",
+ // action: "/api/blade-resource/oss/endpoint/put-file",
+ // },
+ {
+ label: "专题底图",
+ hide: true,
+ prop: "haveBaseMap",
+ component: "AvueUeditor",
+ // options: {
+ // action: "/api/blade-resource/oss/endpoint/put-file",
+ // props: {
+ // res: "data",
+ // url: "link",
+ // },
+ // },
+ // rules: [
+ // {
+ // required: true,
+ // message: "请输入完整的底图服务内容",
+ // trigger: "blur",
+ // },
+ // ],
+ minRows: 5,
+ span: 24,
+ },
+ {
+ label: "选择路径和标点",
+ labelWidth: "0",
+ prop: "line",
+ className: "mapClass",
+ hide: true,
+ display: true,
+ span: 24,
+ formslot: true,
+ addDisplay: true,
+ },
+ // {
+ // label: "路线",活动
+ // hide: true,
+ // prop: "lx",
+ // editDisply: false,
+ // addDisplay: false,
+ // },
+ ],
+ },
+ data: [],
+ LineData: [],
+ PointData: [],
+ };
+ },
+ // watch: {
+ // rotesData() {
+ // console.log(this.rotesData);
+ // },
+ // pointData() {
+ // console.log(this.pointData);
+ // },
+ // },
+ computed: {
+ ...mapGetters(["permission", "mapServiceValue", "notSet"]),
+ permissionList() {
+ return {
+ addBtn: this.vaildData(this.permission.hd_add, false),
+ viewBtn: this.vaildData(this.permission.hd_view, false),
+ delBtn: this.vaildData(this.permission.hd_delete, false),
+ editBtn: this.vaildData(this.permission.hd_edit, false),
+ };
+ },
+ ids() {
+ let ids = [];
+ this.selectionList.forEach((ele) => {
+ ids.push(ele.id);
+ });
+ return ids.join(",");
+ },
+ },
+ mounted() {
+ let that = this;
+ getHdName().then((res) => {
+ let data = res.data.data;
+ // console.log(data);
+ for (let k in data) {
+ that.option.column[0].dicData.push({
+ label: data[k].hdname,
+ value: data[k].id,
+ });
+ }
+ });
+ },
+ methods: {
+ changeMapSI() {
+ this.form["haveBaseMap"] = this.mapServiceValue.length != 0 ? "have" : "";
+ },
+ addMapServices(val) {
+ if (val == 1) {
+ this.mapServiceValueOnce = "";
+ }
+ if (this.mapServiceValueOnce == "") {
+ this.$message({
+ message: "请输入地图服务地址",
+ type: "warning",
+ });
+ return;
+ }
+ if (this.chouseBaseMapTypeOnce == "") {
+ this.$message({
+ message: "请输入地图服务类型",
+ type: "warning",
+ });
+ return;
+ }
+ // console.log(this.mapServiceValue, this.chouseBaseMapType);
+ // this.form["haveBaseMap"] = this.mapServiceValueOnce;
+ //传入控制地图层 转store
+ // this.$refs.baseMapMap.addService({
+ // type: this.chouseBaseMapType,
+ // service: this.mapServiceValue,
+ // });
+ let that = this;
+ this.$store.commit("setMapServiceValue", {
+ type: that.chouseBaseMapTypeOnce,
+ service: that.mapServiceValueOnce,
+ show: true,
+ layer: null,
+ });
+ this.mapServiceValueOnce = "";
+ },
+ setMapData(val) {
+ this.LineData = val[0];
+ this.PointData = val[1];
+ },
+ rowSave(row, done, loading) {
+ if (row.haveBaseMap == "") {
+ this.$message({
+ message: "请输入至少一个完整的底图服务内容",
+ type: "warning",
+ });
+ loading();
+ return;
+ }
+ let types = "",
+ urls = "",
+ leng = this.mapServiceValue.length - 1;
+ for (let k in this.mapServiceValue) {
+ types += this.mapServiceValue[k].type;
+ urls += this.mapServiceValue[k].service;
+ if (k != leng) {
+ types += ",";
+ urls += ",";
+ }
+ }
+ let data = {
+ hdid: row.hdid,
+ maptype: types,
+ mapurl: urls,
+ };
+ // console.log(data);
+ // loading();
+ // return;
+ // var d = [];
+ // for (var k in row.tpurl) {
+ // d.push(row.tpurl[k].value);
+ // }
+ // row.tpurl = d.join(",");
+ // let outMapData = this.$refs.getMapData.myRulesUse();
+ // if (!outMapData) {
+ // loading();
+ // return;
+ // }
+ // row["lxname"] = outMapData[0][0];
+ // row["lx"] = outMapData[0][1];
+ // row["addressname"] = outMapData[1][0];
+ // row["address"] = outMapData[1][1];
+ // console.log(row);
+ // loading();
+ // return;
+ add(data).then(
+ () => {
+ this.onLoad(this.page);
+ this.$message({
+ type: "success",
+ message: "操作成功!",
+ });
+ done();
+ },
+ (error) => {
+ loading();
+ window.console.log(error);
+ }
+ );
+ },
+ rowUpdate(row, index, done, loading) {
+ // let outMapData = this.$refs.getMapData.myRulesUse();
+ // if (!outMapData) {
+ // loading();
+ // return;
+ // }
+ // row["lxname"] = outMapData[0][0];
+ // row["lx"] = outMapData[0][1];
+ // row["addressname"] = outMapData[1][0];
+ // row["address"] = outMapData[1][1];
+ // console.log(row);
+ // loading();
+ // return;
+ if (row.haveBaseMap == "") {
+ this.$message({
+ message: "请输入至少一个完整的底图服务内容",
+ type: "warning",
+ });
+ loading();
+ return;
+ }
+ let types = "",
+ urls = "",
+ leng = this.mapServiceValue.length - 1;
+ for (let k in this.mapServiceValue) {
+ types += this.mapServiceValue[k].type;
+ urls += this.mapServiceValue[k].service;
+ if (k != leng) {
+ types += ",";
+ urls += ",";
+ }
+ }
+ row.maptype = types;
+ row.mapurl = urls;
+ // console.log(row);
+ // loading();
+ // return;
+ update(row).then(
+ () => {
+ this.onLoad(this.page);
+ this.$message({
+ type: "success",
+ message: "操作成功!",
+ });
+ done();
+ },
+ (error) => {
+ loading();
+ console.log(error);
+ }
+ );
+ },
+ rowDel(row) {
+ this.$confirm("确定将选择数据删除?", {
+ confirmButtonText: "确定",
+ cancelButtonText: "取消",
+ type: "warning",
+ })
+ .then(() => {
+ return remove(row.id);
+ })
+ .then(() => {
+ this.onLoad(this.page);
+ this.$message({
+ type: "success",
+ message: "操作成功!",
+ });
+ });
+ },
+ handleDelete() {
+ if (this.selectionList.length === 0) {
+ this.$message.warning("请选择至少一条数据");
+ return;
+ }
+ this.$confirm("确定将选择数据删除?", {
+ confirmButtonText: "确定",
+ cancelButtonText: "取消",
+ type: "warning",
+ })
+ .then(() => {
+ return remove(this.ids);
+ })
+ .then(() => {
+ this.onLoad(this.page);
+ this.$message({
+ type: "success",
+ message: "操作成功!",
+ });
+ this.$refs.crud.toggleSelection();
+ });
+ },
+ checkDom(name, fn) {
+ // 声明定时器
+ let that = this;
+ var timer = null;
+
+ // 检查dom是否执行完成
+ function checkDom() {
+ let dom = that.$refs[name];
+ if (dom) {
+ // 执行dom加载完成后的操作
+ // 清除定时器
+ if (!timer) {
+ clearTimeout(timer);
+ }
+ if (fn) {
+ //回调函数
+ fn(dom);
+ return;
+ } else {
+ return dom;
+ }
+ } else {
+ // 自我调用
+ timer = setTimeout(checkDom, 100);
+ }
+ }
+
+ // 首次执行
+ checkDom();
+ },
+ beforeOpen(done, type) {
+ let that = this;
+ if (this.notSet == true) {
+ this.$store.commit("changeNotSet", false);
+ }
+ if (["edit", "view"].includes(type)) {
+ getDetail(this.form.id).then((res) => {
+ this.form = res.data.data;
+ console.log(res);
+ //解析数据
+ let types = this.form.maptype.split(","),
+ urls = this.form.mapurl.split(",");
+ console.log(types);
+ console.log(urls);
+
+ for (let k in types) {
+ setTimeout(() => {
+ this.$store.commit("setMapServiceValue", {
+ type: types[k],
+ service: urls[k],
+ show: true,
+ layer: null,
+ });
+ }, 500);
+ }
+ });
+ //控制按钮不可编辑
+ if (type == "view") {
+ this.$store.commit("changeNotSet", true);
+ }
+
+ // this.checkDom("getMapData", (dom) => {
+ // // dom.init(val, num, value);
+ // dom[type + "Init"]([
+ // [that.form.lxname, that.form.lx],
+ // [that.form.addressname, that.form.address],
+ // ]);
+ // });
+ }
+ // if (type == "add") {
+ // let that = this;
+ // getHdName().then((res) => {
+ // let data = res.data.data;
+ // // console.log(data);
+ // for (let k in data) {
+ // that.option.column[0].dicData.push({
+ // label: data[k].hdname,
+ // value: data[k].id,
+ // });
+ // }
+ // });
+ // }
+
+ done();
+ },
+ searchReset() {
+ this.query = {};
+ this.onLoad(this.page);
+ },
+ searchChange(params, done) {
+ this.query = params;
+ this.page.currentPage = 1;
+ this.onLoad(this.page, params);
+ done();
+ },
+ selectionChange(list) {
+ this.selectionList = list;
+ },
+ selectionClear() {
+ this.selectionList = [];
+ this.$refs.crud.toggleSelection();
+ },
+ currentChange(currentPage) {
+ this.page.currentPage = currentPage;
+ },
+ sizeChange(pageSize) {
+ this.page.pageSize = pageSize;
+ },
+ refreshChange() {
+ this.onLoad(this.page, this.query);
+ },
+ onLoad(page, params = {}) {
+ this.loading = true;
+ getList(
+ page.currentPage,
+ page.pageSize,
+ Object.assign(params, this.query)
+ ).then((res) => {
+ const data = res.data.data;
+ this.page.total = data.total;
+ this.data = data.records;
+ for (let k in this.data) {
+ this.data[k]["haveBaseMap"] = this.data[k].maptype;
+ }
+ this.loading = false;
+ this.selectionClear();
+ });
+ },
+ },
+};
+</script>
+
+<style lang="scss">
+.mapClass {
+ margin-left: 88px;
+}
+
+.mapClass div label {
+ display: none;
+}
+
+.mapClassMain {
+ /* padding-left: 25px !important; */
+}
+
+#baseMapMap {
+ width: calc(100% + 90px);
+ position: relative;
+ left: -90px;
+ height: 400px;
+}
+.input-with-select {
+ width: calc(100% - 10px);
+ position: relative;
+ left: 10px;
+ .el-input-group__prepend {
+ // width: auto !important;
+ // // height: auto !important;
+ // padding: 0 !important;
+ }
+ .el-input__inner {
+ // width: auto !important;
+ // height: auto !important;
+ }
+ .el-input--small {
+ width: 100px;
+ }
+}
+.inputInline {
+ display: flex;
+ width: 100%;
+ height: 100%;
+ justify-content: center;
+ .inputInlineType {
+ width: 110px;
+ }
+}
+</style>
--
Gitblit v1.9.3