123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524 |
- <template>
- <!-- 同屏对比弹窗 -->
- <el-dialog title="同屏对比" fullscreen :visible.sync="dialogVisible" :before-close="handleClose">
- <template slot="title">
- <div class="dialogTitle">
- <div class="dialogTitleIcon"></div>
- 同屏对比
- </div>
- </template>
- <!-- 同屏对比主题 -->
- <div class="ssc_main">
- <!-- 地图列表 -->
- <div class="ssc_main_mapList" id="doPrint" ref="doPrint">
- <div
- class="ssc_main_mapList_showList"
- :id="'map' + index"
- v-for="(mapIndex, index) in checkedCities"
- :key="index"
- :style="mapListBoxStyle()"
- @mousedown="changeMouseIndex(index)"
- >
- <span>{{ mapList[mapIndex].mapName }}</span>
- <Map
- :mapUrl="mapList[mapIndex].mapUrl"
- :index="index"
- :mouseIndex="mouseIndex"
- :centerZoom="centerZoom"
- @changeCenterZoom="changeCenterZoom"
- />
- </div>
- </div>
- <!-- 底图列表 -->
- <div class="ssc_main_aimapList">
- <span>地图底图(最多选择6个) </span>
- <div>
- 已选择<span class="checkLength">{{ checkedCities.length }}</span
- >个
- </div>
- <el-checkbox-group id="mapCheckBox" v-model="checkedCities" @change="handleCheckedCitiesChange" :min="2" :max="6">
- <el-checkbox
- class="mapCheckBox"
- :disabled="checkedCities.length >= 6 && checkedCities.indexOf(index) == -1"
- v-for="(city, index) in mapList"
- :checked="city.active"
- :label="index"
- :key="index"
- >{{ city.mapName }}</el-checkbox
- >
- </el-checkbox-group>
- </div>
- </div>
- <!-- 底部文本域 -->
- <div id="textareaBox">
- <div class="textareaTitle">描述记录:</div>
- <el-input type="textarea" :autosize="{ minRows: 3, maxRows: 4 }" placeholder="请输入内容" v-model="textarea1"> </el-input>
- </div>
- <!-- 打印区域 -->
- <div id="imgBox">
- <span>基本农田被侵占</span>
- <img src="" id="imgOut" style="width: 1240px; background-repeat: no-repeat; background-size: 100% 100%" />
- <span><div>描述记录:</div></span>
- <div>{{ textarea1 }}</div>
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button @click="clearDialogVisible()">取 消</el-button>
- <el-button type="primary" @click="subMitDialogVisible()">打 印</el-button>
- </span>
- </el-dialog>
- </template>
- <script>
- /**
- * 底部菜单(同屏对比)组件
- * @author: LiuMengxiang
- * @Date: 2022年11月21-25日
- */
- import Map from "../../map/Map.vue";
- import html2canvas from "html2canvas";
- export default {
- name: "SameScreenComparison",
- components: { Map },
- data() {
- return {
- // 同屏对比弹窗显示状态
- dialogVisible: false,
- // 默认选中第一个
- checkedCities: [],
- // 定时器暂存
- interval: "",
- // 地图暂存显示变量
- centerZoom: {},
- mouseIndex: -1,
- // 底部文本域
- textarea1: "",
- // 地图底图列表
- mapList: [
- {
- mapName: "2018年航空影像图(春季)",
- mapUrl: "http://t0.tianditu.gov.cn/DataServer?T=img_w&X={x}&Y={y}&L={z}&tk=f331ba0b9ab96fb21c56d91de868935d",
- active: true
- },
- {
- mapName: "2019年航空影像图(春季)",
- mapUrl: "http://t0.tianditu.gov.cn/DataServer?T=img_w&X={x}&Y={y}&L={z}&tk=f331ba0b9ab96fb21c56d91de868935d",
- active: false
- },
- {
- mapName: "2020年航空影像图(春季)",
- mapUrl: "http://t0.tianditu.gov.cn/DataServer?T=img_w&X={x}&Y={y}&L={z}&tk=f331ba0b9ab96fb21c56d91de868935d",
- active: false
- },
- {
- mapName: "2021年航空影像图(春季)",
- mapUrl: "http://t0.tianditu.gov.cn/DataServer?T=img_w&X={x}&Y={y}&L={z}&tk=f331ba0b9ab96fb21c56d91de868935d",
- active: false
- },
- {
- mapName: "2022年航空影像图(春季)",
- mapUrl: "http://t0.tianditu.gov.cn/DataServer?T=img_w&X={x}&Y={y}&L={z}&tk=f331ba0b9ab96fb21c56d91de868935d",
- active: false
- },
- {
- mapName: "2018年卫星影像图(春季)",
- mapUrl: "http://t0.tianditu.gov.cn/DataServer?T=img_w&X={x}&Y={y}&L={z}&tk=f331ba0b9ab96fb21c56d91de868935d",
- active: false
- },
- {
- mapName: "2019年卫星影像图(春季)",
- mapUrl: "http://t0.tianditu.gov.cn/DataServer?T=img_w&X={x}&Y={y}&L={z}&tk=f331ba0b9ab96fb21c56d91de868935d",
- active: false
- },
- {
- mapName: "2020年卫星影像图(春季)",
- mapUrl: "http://t0.tianditu.gov.cn/DataServer?T=img_w&X={x}&Y={y}&L={z}&tk=f331ba0b9ab96fb21c56d91de868935d",
- active: false
- },
- {
- mapName: "2021年卫星影像图(春季)",
- mapUrl: "http://t0.tianditu.gov.cn/DataServer?T=img_w&X={x}&Y={y}&L={z}&tk=f331ba0b9ab96fb21c56d91de868935d",
- active: false
- },
- {
- mapName: "2022年卫星影像图(春季)",
- mapUrl: "http://t0.tianditu.gov.cn/DataServer?T=img_w&X={x}&Y={y}&L={z}&tk=f331ba0b9ab96fb21c56d91de868935d",
- active: false
- },
- {
- mapName: "2018年航空影像图(秋季)",
- mapUrl: "http://t0.tianditu.gov.cn/DataServer?T=img_w&X={x}&Y={y}&L={z}&tk=f331ba0b9ab96fb21c56d91de868935d",
- active: false
- },
- {
- mapName: "2019年航空影像图(秋季)",
- mapUrl: "http://t0.tianditu.gov.cn/DataServer?T=img_w&X={x}&Y={y}&L={z}&tk=f331ba0b9ab96fb21c56d91de868935d",
- active: false
- },
- {
- mapName: "2020年航空影像图(秋季)",
- mapUrl: "http://t0.tianditu.gov.cn/DataServer?T=img_w&X={x}&Y={y}&L={z}&tk=f331ba0b9ab96fb21c56d91de868935d",
- active: false
- },
- {
- mapName: "2021年航空影像图(秋季)",
- mapUrl: "http://t0.tianditu.gov.cn/DataServer?T=img_w&X={x}&Y={y}&L={z}&tk=f331ba0b9ab96fb21c56d91de868935d",
- active: false
- },
- {
- mapName: "2022年航空影像图(秋季)",
- mapUrl: "http://t0.tianditu.gov.cn/DataServer?T=img_w&X={x}&Y={y}&L={z}&tk=f331ba0b9ab96fb21c56d91de868935d",
- active: false
- },
- {
- mapName: "2018年卫星影像图(秋季)",
- mapUrl: "http://t0.tianditu.gov.cn/DataServer?T=img_w&X={x}&Y={y}&L={z}&tk=f331ba0b9ab96fb21c56d91de868935d",
- active: false
- },
- {
- mapName: "2019年卫星影像图(秋季)",
- mapUrl: "http://t0.tianditu.gov.cn/DataServer?T=img_w&X={x}&Y={y}&L={z}&tk=f331ba0b9ab96fb21c56d91de868935d",
- active: false
- },
- {
- mapName: "2020年卫星影像图(秋季)",
- mapUrl: "http://t0.tianditu.gov.cn/DataServer?T=img_w&X={x}&Y={y}&L={z}&tk=f331ba0b9ab96fb21c56d91de868935d",
- active: false
- },
- {
- mapName: "2021年卫星影像图(秋季)",
- mapUrl: "http://t0.tianditu.gov.cn/DataServer?T=img_w&X={x}&Y={y}&L={z}&tk=f331ba0b9ab96fb21c56d91de868935d",
- active: false
- },
- {
- mapName: "2022年卫星影像图(秋季)",
- mapUrl: "http://t0.tianditu.gov.cn/DataServer?T=img_w&X={x}&Y={y}&L={z}&tk=f331ba0b9ab96fb21c56d91de868935d",
- active: false
- }
- ]
- };
- },
- mounted() {
- // 同屏对比事件监听
- this.$bus.$on("tpdb", () => {
- this.changeShowBottomMenusStatus();
- });
- },
- destroy() {
- // 当容器销毁时,需要停止监听该事件
- this.$bus.$off("tpdb");
- },
- props: [],
- methods: {
- // 当用户点击svg底座时,切换底部菜单显示隐藏状态。
- changeShowBottomMenusStatus() {
- // 打开弹窗
- this.dialogVisible = true;
- this.$emit("changeShowBottomMenusStatus", false);
- },
- // 弹窗关闭询问
- handleClose() {
- if (this.dialogVisible) {
- this.$confirm("确认关闭?")
- .then(_ => {
- this.clearDialogVisible();
- })
- .catch(_ => {});
- }
- },
- // 同屏对比取消
- clearDialogVisible() {
- if (this.interval) {
- this.$message.info("取消打印!");
- this.clearDiyInterval();
- } else {
- // 关闭弹窗
- this.dialogVisible = false;
- // 恢复默认选中第一个地图底图
- this.checkedCities = [];
- this.mapList = [
- {
- mapName: "2018年航空影像图(春季)",
- mapUrl: "http://t0.tianditu.gov.cn/DataServer?T=img_w&X={x}&Y={y}&L={z}&tk=f331ba0b9ab96fb21c56d91de868935d",
- active: true
- },
- {
- mapName: "2019年航空影像图(春季)",
- mapUrl: "http://t0.tianditu.gov.cn/DataServer?T=img_w&X={x}&Y={y}&L={z}&tk=f331ba0b9ab96fb21c56d91de868935d",
- active: false
- },
- {
- mapName: "2020年航空影像图(春季)",
- mapUrl: "http://t0.tianditu.gov.cn/DataServer?T=img_w&X={x}&Y={y}&L={z}&tk=f331ba0b9ab96fb21c56d91de868935d",
- active: false
- },
- {
- mapName: "2021年航空影像图(春季)",
- mapUrl: "http://t0.tianditu.gov.cn/DataServer?T=img_w&X={x}&Y={y}&L={z}&tk=f331ba0b9ab96fb21c56d91de868935d",
- active: false
- },
- {
- mapName: "2022年航空影像图(春季)",
- mapUrl: "http://t0.tianditu.gov.cn/DataServer?T=img_w&X={x}&Y={y}&L={z}&tk=f331ba0b9ab96fb21c56d91de868935d",
- active: false
- },
- {
- mapName: "2018年卫星影像图(春季)",
- mapUrl: "http://t0.tianditu.gov.cn/DataServer?T=img_w&X={x}&Y={y}&L={z}&tk=f331ba0b9ab96fb21c56d91de868935d",
- active: false
- },
- {
- mapName: "2019年卫星影像图(春季)",
- mapUrl: "http://t0.tianditu.gov.cn/DataServer?T=img_w&X={x}&Y={y}&L={z}&tk=f331ba0b9ab96fb21c56d91de868935d",
- active: false
- },
- {
- mapName: "2020年卫星影像图(春季)",
- mapUrl: "http://t0.tianditu.gov.cn/DataServer?T=img_w&X={x}&Y={y}&L={z}&tk=f331ba0b9ab96fb21c56d91de868935d",
- active: false
- },
- {
- mapName: "2021年卫星影像图(春季)",
- mapUrl: "http://t0.tianditu.gov.cn/DataServer?T=img_w&X={x}&Y={y}&L={z}&tk=f331ba0b9ab96fb21c56d91de868935d",
- active: false
- },
- {
- mapName: "2022年卫星影像图(春季)",
- mapUrl: "http://t0.tianditu.gov.cn/DataServer?T=img_w&X={x}&Y={y}&L={z}&tk=f331ba0b9ab96fb21c56d91de868935d",
- active: false
- },
- {
- mapName: "2018年航空影像图(秋季)",
- mapUrl: "http://t0.tianditu.gov.cn/DataServer?T=img_w&X={x}&Y={y}&L={z}&tk=f331ba0b9ab96fb21c56d91de868935d",
- active: false
- },
- {
- mapName: "2019年航空影像图(秋季)",
- mapUrl: "http://t0.tianditu.gov.cn/DataServer?T=img_w&X={x}&Y={y}&L={z}&tk=f331ba0b9ab96fb21c56d91de868935d",
- active: false
- },
- {
- mapName: "2020年航空影像图(秋季)",
- mapUrl: "http://t0.tianditu.gov.cn/DataServer?T=img_w&X={x}&Y={y}&L={z}&tk=f331ba0b9ab96fb21c56d91de868935d",
- active: false
- },
- {
- mapName: "2021年航空影像图(秋季)",
- mapUrl: "http://t0.tianditu.gov.cn/DataServer?T=img_w&X={x}&Y={y}&L={z}&tk=f331ba0b9ab96fb21c56d91de868935d",
- active: false
- },
- {
- mapName: "2022年航空影像图(秋季)",
- mapUrl: "http://t0.tianditu.gov.cn/DataServer?T=img_w&X={x}&Y={y}&L={z}&tk=f331ba0b9ab96fb21c56d91de868935d",
- active: false
- },
- {
- mapName: "2018年卫星影像图(秋季)",
- mapUrl: "http://t0.tianditu.gov.cn/DataServer?T=img_w&X={x}&Y={y}&L={z}&tk=f331ba0b9ab96fb21c56d91de868935d",
- active: false
- },
- {
- mapName: "2019年卫星影像图(秋季)",
- mapUrl: "http://t0.tianditu.gov.cn/DataServer?T=img_w&X={x}&Y={y}&L={z}&tk=f331ba0b9ab96fb21c56d91de868935d",
- active: false
- },
- {
- mapName: "2020年卫星影像图(秋季)",
- mapUrl: "http://t0.tianditu.gov.cn/DataServer?T=img_w&X={x}&Y={y}&L={z}&tk=f331ba0b9ab96fb21c56d91de868935d",
- active: false
- },
- {
- mapName: "2021年卫星影像图(秋季)",
- mapUrl: "http://t0.tianditu.gov.cn/DataServer?T=img_w&X={x}&Y={y}&L={z}&tk=f331ba0b9ab96fb21c56d91de868935d",
- active: false
- },
- {
- mapName: "2022年卫星影像图(秋季)",
- mapUrl: "http://t0.tianditu.gov.cn/DataServer?T=img_w&X={x}&Y={y}&L={z}&tk=f331ba0b9ab96fb21c56d91de868935d",
- active: false
- }
- ];
- // 修改父级菜单变量(弹窗显示状态和显示底部菜单)
- this.$emit("changeShowBottomMenusStatus", true);
- }
- },
- // 同屏对比表单提交
- subMitDialogVisible() {
- if (this.interval) {
- this.$message.info("正在打印,请稍后操作!");
- } else {
- this.cutDiv();
- }
- },
- // div转图片
- cutDiv() {
- var container = document.getElementById("doPrint").innerHTML;
- const _width = container.offsetWidth;
- const _height = container.offsetHeight;
- const ops = {
- _width,
- _height,
- useCORS: true,
- allowTaint: false
- };
- let that = this;
- html2canvas(this.$refs.doPrint, ops).then(canvas => {
- document.getElementById("imgOut").setAttribute("src", canvas.toDataURL("image/png"));
- });
- this.interval = setInterval(() => {
- if ($("#imgOut").attr("src")) {
- that.clearDiyInterval();
- setTimeout(() => {
- that.doPrint();
- }, 500);
- }
- }, 500);
- },
- clearDiyInterval() {
- let that = this;
- // 先销毁定时器
- clearInterval(that.interval);
- that.interval = "";
- },
- // div打印(iframe的方式为最优)
- doPrint() {
- // 将包含转为图片的div获取。
- var new_iframe = document.createElement("IFRAME");
- var doc = null;
- document.body.appendChild(new_iframe);
- doc = new_iframe.contentWindow.document;
- var obj = document.getElementById("imgBox");
- doc.write('<div style="width:100%;height:auto;margin:0px;">' + obj.innerHTML + "</div>");
- doc.close();
- new_iframe.contentWindow.focus();
- new_iframe.contentWindow.print();
- // document.body.removeChild(iframe);
- },
- // 修改
- handleCheckedCitiesChange(e) {
- // console.log("已选中的底图:", this.checkedCities, this.checkedCities.length);
- },
- // 根据地图列表,返回合适的样式
- mapListBoxStyle() {
- return "width:calc(33% - 2px);height:calc(50% - 2px);";
- },
- // 当其中一个地图移动或缩放时
- changeCenterZoom(data) {
- this.centerZoom = data;
- },
- // 暂存当前光标所在map组件的下标
- changeMouseIndex(mouseIndex) {
- this.mouseIndex = mouseIndex;
- }
- },
- watch: {}
- };
- </script>
- <style lang="less" scoped>
- .ssc_main {
- display: flex;
- width: 100%;
- height: calc(100vh - 310px);
- position: relative;
- #textareaBox {
- width: calc(100% - 20px);
- height: 100px;
- position: absolute;
- bottom: 0;
- }
- &_mapList {
- width: calc(100% - 20rem);
- height: 100%;
- display: flex;
- flex-wrap: wrap;
- padding: 10px;
- box-sizing: border-box;
- overflow-x: hidden;
- overflow-y: auto;
- scrollbar-width: none; /* Firefox */
- -ms-overflow-style: none; /* IE 10+ */
- &::-webkit-scrollbar {
- display: none; /* Chrome Safari */
- }
- &_showList {
- border: 1px solid #ccc;
- text-align: right;
- position: relative;
- span {
- position: absolute;
- right: 10px;
- top: 10px;
- font-size: 22px;
- font-weight: bold;
- color: #fff;
- z-index: 999;
- -moz-user-select: none;
- -webkit-user-select: none;
- -ms-user-select: none;
- -khtml-user-select: none;
- user-select: none;
- }
- }
- }
- &_aimapList {
- width: 20rem;
- height: 100%;
- font-size: 20px;
- color: #fff;
- padding: 10px;
- box-sizing: border-box;
- background: #002645 !important;
- .checkLength {
- font-size: 24px;
- color: #74ffff;
- }
- #mapCheckBox {
- height: calc(100% - 58px);
- width: 100%;
- overflow-x: hidden;
- overflow-y: auto;
- scrollbar-width: none; /* Firefox */
- -ms-overflow-style: none; /* IE 10+ */
- border: 1px solid #fff;
- &::-webkit-scrollbar {
- display: none; /* Chrome Safari */
- }
- }
- .mapCheckBox:hover {
- color: #ffffff;
- background: #002645 !important;
- }
- .mapCheckBox[disabled] {
- color: #666666;
- cursor: not-allowed;
- }
- .mapCheckBox {
- width: 100%;
- padding: 10px 5px;
- border-bottom: 1px solid;
- color: #cccccc;
- font-size: 18px;
- background: #001e37 !important;
- .el-checkbox__label {
- font-size: 18px;
- }
- }
- }
- }
- .textareaTitle {
- font-size: 20px;
- font-weight: 400;
- }
- #imgBox {
- display: none;
- font-size: 16px;
- color: #000;
- font-weight: 400;
- span {
- font-size: 20px;
- color: #000000;
- font-weight: bold;
- padding: 20px 10px;
- }
- }
- </style>
|