123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818 |
- <template>
- <div class="BoxCommonVector" v-if="title">
- <div class="innerContainerVector leftPaneVector" v-drag>
- <h2 class="PangetitleVector darg-div">
- <span class="pange_textVector">{{ title }}</span>
- <slot name="title"></slot>
- <i
- class="el-icon-close"
- v-if="$route.path == '/overview'"
- @click="close"
- ></i>
- </h2>
- <template v-if="islist">
- <el-input
- v-if="word"
- clearable
- v-model="state"
- @input="change_witch"
- class="search"
- placeholder="请输入内容"
- ></el-input>
- <div class="searchDiv" v-else>
- <div class="sidiv" v-for="sitem in searchs" :key="sitem.key">
- <el-input
- v-if="sitem.type == 'input'"
- clearable
- v-model="searchform[sitem.key]"
- @input="change_witch"
- class="search"
- :placeholder="sitem.label"
- ></el-input>
- <el-select
- v-else-if="sitem.type == 'select'"
- clearable
- v-model="searchform[sitem.key]"
- :placeholder="sitem.label"
- @change="change_witch"
- >
- <el-option
- v-for="item in sitem.options"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- ></el-option>
- </el-select>
- <!-- clearable -->
- <el-cascader
- v-else-if="sitem.type == 'cascader'"
- v-model="searchform[sitem.key]"
- :show-all-levels="false"
- :options="sitem.options"
- :placeholder="sitem.label"
- :props="{
- checkStrictly: true,
- expandTrigger: 'hover',
- emitPath: false,
- }"
- @change="change_witch"
- ></el-cascader>
- </div>
- </div>
- <div v-if="cockpit_vector.showtotal" class="shownum">
- 上报总数量:{{ active_dableData.length }}个
- </div>
- <el-table
- :row-class-name="tableRowClassName"
- ref="singleTable"
- :data="active_dableData"
- style="width: 100%"
- height="670"
- :header-cell-style="{
- background: 'rgba(10, 25, 38, 0.6)',
- color: '#66b1ff',
- fontSize: '14px',
- fontFamily: 'Microsoft YaHei',
- fontWeight: '400',
- }"
- >
- <el-table-column
- show-overflow-tooltip="true"
- v-for="(item, index) in store.state.cockpit_vector.columns"
- :key="index"
- :width="index ? 100 : cockpit_vector.columns.length > 2 ? 150 : 230"
- :prop="item"
- :label="item"
- >
- </el-table-column>
- <el-table-column fixed="right" label="操作" width="50">
- <template slot-scope="scope">
- <!-- <el-button @click="info(scope.row)" type="text" size="small">详情</el-button> -->
- <el-button @click="go(scope.row)" type="text" size="small"
- >定位</el-button
- >
- </template>
- </el-table-column>
- </el-table>
- </template>
- <slot name="all"></slot>
- </div>
- </div>
- </template>
-
- <script>
- import { QueryOne, QueryList } from "@/api/cockpitNew";
- import * as tdsy from "@/views/cockpit/js/tdsy";
- import * as wellknown from "wellknown";
- import * as turf from "@turf/turf";
- let BoxCommonVector_entity = null;
- let layerSources = {};
- export default {
- props: {
- islist: {
- type: Boolean,
- default: true,
- },
- },
- data() {
- return {
- state: "",
- timeout: null,
- title: "",
- active_dableData: null,
- tableData: null,
- layersData: {},
- scrollTop_index: null,
- tempdataLayerId: null,
- searchs: [],
- searchform: {},
- xzqTreeData: [],
- };
- },
- methods: {
- tableRowClassName({ row, rowIndex }) {
- if (rowIndex === this.scrollTop_index) {
- return "warning-row";
- }
- return "";
- },
- async draw_vector_server(jscType, goitrem) {
- let res = await QueryOne({ jscType, id: "4602" });
- this.layersData = {
- ...res.data,
- title: this.title,
- id: "81f91e995b80435184cc51519bf0c1d3",
- };
- if (goitrem) this.go(goitrem);
- else {
- tdsy.addLayer(this.layersData);
- store.state.vectorlayerlist.push(this.layersData);
- console.log("---aaa", store.state.vectorlayerlist);
- }
- // this.Getlayers(res.data.url);
- },
- async Getlayers(mapurl) {
- let url = `${mapurl}/layers.json`;
- let res = await axios.get(url);
- let layers = res.data[0].subLayers.layers;
- if (layers.length > 0) this.layersData.layerName = layers[0].name;
- },
- async setLayerStatus(item) {
- let did_v = Number(item.did) - 1;
- this.tempdataLayerId = did_v;
- if (tdsy.layersObj[did_v]) {
- tdsy.layersObj[did_v].show = true;
- viewer.flyTo(layerSources[did_v], {
- offset: new Cesium.HeadingPitchRange(0, -45),
- });
- } else {
- if (tdsy.layer) tdsy.layer.show = false;
- let layer = viewer.imageryLayers.addImageryProvider(
- new Cesium.SuperMapImageryProvider({
- url: this.layersData.url,
- layersID: `[${did_v}]`,
- })
- );
- tdsy.layersObj[did_v] = layer;
- this.loadGeoJSON(item.geom, did_v);
- }
- // } else if (this.layersData.layerName) {
- // var params_gh = {
- // layerName: this.layersData.layerName,
- // isVisible: true,
- // displayFilter: `xmmc = '${item["项目名称"]}'`,
- // };
- // tdsy.superProvider.setLayerStatusParameters([params_gh]);
- // tdsy.layer.show = false;
- // let layer = viewer.imageryLayers.addImageryProvider(tdsy.superProvider);
- // tdsy.layersObj[item.did] = layer;
- },
- loadGeoJSON(geojson, id) {
- let polygon = Cesium.GeoJsonDataSource.load(geojson, {
- clampToGround: true,
- stroke: Cesium.Color.RED.withAlpha(0),
- fill: Cesium.Color.WHITE.withAlpha(0),
- });
- polygon.then(function (dataSource) {
- viewer.dataSources.add(dataSource);
- layerSources[id] = dataSource;
- viewer.flyTo(dataSource, {
- offset: new Cesium.HeadingPitchRange(0, -45),
- });
- });
- },
- multiPolygonToPolygons(multiPolygon) {
- const polygons = [];
- multiPolygon.coordinates.forEach((polygonCoordinates) => {
- polygons.push({
- type: "Polygon",
- coordinates: polygonCoordinates,
- });
- });
- return polygons;
- },
- // draw_vector_tdgy_gy_jd(data) {
- // const that = this;
- // data.forEach((res) => {
- // res.type = this.title
- // if (res.geom) {
- // res.geom.coordinates.forEach((res_coordinates) => {
- // // let arrayt = [];
- // // if (res_coordinates.length == 1) {
- // // arrayt = res_coordinates[0]
- // // const twoDArray = arrayt;
- // // const oneDArray = twoDArray.reduce((accumulator, currentValue) => accumulator.concat(currentValue), []);
- // // tdsy.add(res, oneDArray);
- // // } else {
- // // // arrayt = res_coordinates
- // // }
- // // 多面转单面
- // // if (res.geom.type == 'MultiPolygon') {
- // // let polygons = that.multiPolygonToPolygons(geojson);
- // // // 在
- // // polygons.forEach((res) => {
- // // that.add_viewer_for_vector(res, data);
- // // tdsy.add(res, oneDArray);
- // // })
- // // } else {
- // // }
- // })
- // }
- // })
- // },
- draw_vector_tdgy_gy_jd(data) {
- // tdsy.remove();
- data.forEach((res, index) => {
- res.type = "图斑上图";
- res.index = index;
- if (res.geom) {
- let geojson = res.geom;
- if (geojson.type == "MultiPolygon") {
- geojson.coordinates.forEach((res) => {
- const twoDArray = res[0];
- const oneDArray = twoDArray.reduce(
- (accumulator, currentValue) => accumulator.concat(currentValue),
- []
- );
- tdsy.add(res, oneDArray);
- });
- } else {
- const twoDArray = geojson.coordinates[0];
- const oneDArray = twoDArray.reduce(
- (accumulator, currentValue) => accumulator.concat(currentValue),
- []
- );
- tdsy.add(res, oneDArray);
- }
- }
- });
- },
- close() {
- store.setViewerFlagb(true);
- tdsy.remove(true);
- store.state.vectorData = [];
- store.hideToolBar();
- },
- info() {},
- switch_show(flag) {
- BoxCommonVector_entity.entities.values.forEach((res) => {
- res.show = flag;
- });
- },
- build_data(geojson) {
- geojson.coordinates.forEach((res) => {
- const twoDArray = res[0];
- const oneDArray = twoDArray.reduce(
- (accumulator, currentValue) => accumulator.concat(currentValue),
- []
- );
- BoxCommonVector_entity.entities.add({
- polygon: {
- // 获取指定属性(positions,holes(图形内需要挖空的区域))
- hierarchy: {
- positions: Cesium.Cartesian3.fromDegreesArrayHeights(
- oneDArray.slice(0, -3)
- ),
- },
- // 边框
- outline: true,
- // 边框颜色
- outlineColor: Cesium.Color.RED,
- // 边框尺寸
- outlineWidth: 10,
- // 填充的颜色,withAlpha透明度
- material: Cesium.Color.GREEN.withAlpha(0),
- // 是否被提供的材质填充
- fill: false,
- // 恒定高度
- height: 1.1,
- // 显示在距相机的距离处的属性,多少区间内是可以显示的
- // distanceDisplayCondition: new Cesium.DistanceDisplayCondition(1000, 10000000),
- // 是否显示
- show: true,
- // 顺序,仅当`clampToGround`为true并且支持地形上的折线时才有效。
- zIndex: 10,
- },
- });
- // 注意:polygon首尾坐标要一致
- var polygon = turf.polygon([twoDArray]);
- var centroid = turf.centroid(polygon).geometry.coordinates;
- viewer.camera.flyTo({
- duration: 1,
- destination: Cesium.Cartesian3.fromDegrees(
- centroid[0],
- centroid[1],
- 3000
- ),
- // destination: {
- // x: -6283267.004204832,
- // y: 28123682.896774407,
- // z: 23709669.98539126
- // },
- orientation: {
- heading: 6.149339593573709,
- pitch: -1.539825618847483,
- roll: 0,
- },
- });
- });
- },
- go(item) {
- if (!item.geom) {
- this.$message.warning("缺少定位图斑");
- } else {
- if (this.cockpit_vector.mapType) {
- this.setLayerStatus(item);
- } else this.addpolygon(item);
- }
- store.setVectordataid(item.dataid);
- let arr = [];
- // BoxCommonVector_entity = new Cesium.CustomDataSource("BoxCommonVector_entity");
- // viewer.dataSources.add(BoxCommonVector_entity);
- Object.keys(item).forEach((key) => {
- arr.push({
- name: key,
- value: item[key],
- });
- });
- store.state.vectorData = arr;
- store.setActiveToolBar(9);
- },
- addpolygon(item) {
- const that = this;
- let geojson = item.geom;
- if (geojson.type == "MultiPolygon") {
- this.build_data(geojson);
- } else {
- const twoDArray = geojson.coordinates[0];
- const oneDArray = twoDArray.reduce(
- (accumulator, currentValue) => accumulator.concat(currentValue),
- []
- );
- BoxCommonVector_entity.entities.add({
- polygon: {
- // 获取指定属性(positions,holes(图形内需要挖空的区域))
- hierarchy: {
- positions: Cesium.Cartesian3.fromDegreesArrayHeights(
- oneDArray.slice(0, -3)
- ),
- },
- // 边框
- outline: true,
- // 边框颜色
- outlineColor: Cesium.Color.RED,
- // 边框尺寸
- outlineWidth: 10,
- // 填充的颜色,withAlpha透明度
- material: Cesium.Color.GREEN.withAlpha(0),
- // 是否被提供的材质填充
- fill: false,
- // 恒定高度
- height: 1.1,
- // 显示在距相机的距离处的属性,多少区间内是可以显示的
- // distanceDisplayCondition: new Cesium.DistanceDisplayCondition(1000, 10000000),
- // 是否显示
- show: true,
- // 顺序,仅当`clampToGround`为true并且支持地形上的折线时才有效。
- zIndex: 10,
- },
- });
- // 注意:polygon首尾坐标要一致
- var polygon = turf.polygon([geojson.coordinates[0]]);
- var centroid = turf.centroid(polygon).geometry.coordinates;
- viewer.camera.flyTo({
- duration: 1,
- destination: Cesium.Cartesian3.fromDegrees(
- centroid[0],
- centroid[1],
- 3000
- ),
- // destination: {
- // x: -6283267.004204832,
- // y: 28123682.896774407,
- // z: 23709669.98539126
- // },
- orientation: {
- heading: 6.149339593573709,
- pitch: -1.539825618847483,
- roll: 0,
- },
- });
- }
- let flag = true;
- let time = setInterval(() => {
- flag = !flag;
- that.switch_show(flag);
- }, 500);
- setTimeout(() => {
- clearInterval(time);
- for (var i = 0; i < 10; i++) {
- BoxCommonVector_entity.entities.values.forEach((res) => {
- BoxCommonVector_entity.entities.remove(res);
- });
- }
- }, 6000);
- },
- change_witch() {
- if (this.word) this.get_searchWord(this.state);
- else this.init_vector(this.searchform);
- },
- // get_search(word) {
- // if (word.length == 0) {
- // this.active_dableData = this.tableData;
- // } else {
- // let gy_ju = {
- // beginTime: store.state.cockpit_date[0],
- // endTime: store.state.cockpit_date[1],
- // jscType: store.state.cockpit_vector.tablejscType + '_cx',
- // id: '4602',
- // val0: word,
- // }
- // if (this.title == '土地供应完成项目' || this.title == '山水工程项目') {
- // gy_ju.beginTime = undefined
- // gy_ju.endTime = undefined
- // }
- // Promise.all([QueryList(gy_ju)]).then((values) => {
- // values[0].data.map((res) => {
- // if (res.geom) {
- // res.geom = wellknown.parse(res.geom.split(";")[1]);
- // }
- // })
- // this.active_dableData = values[0].data
- // }).catch((error) => {
- // console.error(error); // 如果有任何一个 promise 失败,则捕获这个错误
- // });
- // }
- // },
- get_searchWord() {
- if (this.state.length == 0) {
- this.active_dableData = this.tableData;
- console.log("this.active_dableData: ", this.active_dableData);
- } else {
- // console.log('this.tableData: ', this.tableData);
- // this.active_dableData = this.tableData.filter((item) => {
- // item.项目名称.indexOf(word) >= 0
- // })
- console.log("this.tableData: ", this.word);
- this.active_dableData = this.tableData.filter((item) => {
- console.log("item: ", item);
- if (item[this.word] && this.state) {
- return item[this.word].indexOf(this.state) >= 0;
- }
- return false;
- });
- }
- },
- async init_vector(params) {
- const that = this;
- console.log(store.state.cockpit_date, "--");
- let obj = {
- jscType: store.state.cockpit_vector.tablejscType,
- beginTime: store.state.cockpit_date[0],
- endTime: store.state.cockpit_date[1],
- id: store.state.cockpit_region.id,
- ...params,
- };
- if (this.title == "土地供应完成项目" || this.title == "山水工程项目") {
- obj.beginTime = undefined;
- obj.endTime = undefined;
- }
- if (this.title == "进出平衡") {
- (obj.jscType = "jsc_gdbh_jcph_zbmc"),
- (obj.val2 = 0),
- (obj.val1 = 50000),
- (obj.beginTime = store.state.cockpit_date[1].slice(0, 4)),
- (obj.endTime = undefined);
- }
- if (this.title == "土地收储计划项目") {
- obj.beginTime = undefined;
- obj.endTime = undefined;
- }
- let data = await QueryList(obj);
- data.data.map((res) => {
- if (res.geom) {
- res.geom = wellknown.parse(res.geom.split(";")[1]);
- }
- });
- this.active_dableData = data.data;
- this.tableData = data.data;
- },
- },
- computed: {
- cockpit_vector() {
- return store.state.cockpit_vector;
- },
- computed_vectorData() {
- return store.state.vectorData;
- },
- },
- watch: {
- cockpit_vector(newVal, oldVal) {
- this.title = newVal.title;
- console.log("---", newVal);
- this.word = newVal.word;
- this.searchs = newVal.searchs;
- this.searchform = newVal.searchform;
- this.state = "";
- if (newVal.goitem) {
- this.draw_vector_server(newVal.mapType, newVal.goitem);
- } else if (newVal.tableData && newVal.tableData.length > 0) {
- this.active_dableData = []; //防止重复点击tableData不刷新
- this.active_dableData = newVal.tableData;
- this.tableData = newVal.tableData;
- // this.init_vector()
- } else if (this.title) {
- this.init_vector();
- }
- },
- active_dableData(newVal, oldVal) {
- if (this.cockpit_vector.mapType)
- this.draw_vector_server(this.cockpit_vector.mapType);
- else this.draw_vector_tdgy_gy_jd(newVal);
- },
- tempdataLayerId(newVal, oldVal) {
- if (oldVal && tdsy.layersObj[oldVal]) {
- tdsy.layersObj[oldVal].show = false;
- } else if (tdsy.layersObj[newVal]) {
- // tdsy.layersObj[newVal].show = true;
- }
- console.log(newVal, oldVal, "----");
- },
- computed_vectorData(newVal, oldVal) {
- newVal.forEach((res) => {
- if (res.name == "index") {
- const TableRows = this.$refs.singleTable.bodyWrapper.querySelectorAll(
- ".el-table__body tbody .el-table__row"
- );
- let scrollTop = 0;
- for (let i = 0; i < TableRows.length; i++) {
- if (i === res.value) {
- break;
- }
- scrollTop += TableRows[i].offsetHeight;
- }
- this.$refs.singleTable.bodyWrapper.scrollTop = scrollTop;
- this.scrollTop_index = res.value;
- }
- });
- },
- },
- mounted() {
- const that = this;
- this.$nextTick(() => {
- BoxCommonVector_entity = new Cesium.CustomDataSource(
- "BoxCommonVector_entity"
- );
- viewer.dataSources.add(BoxCommonVector_entity);
- });
- },
- };
- </script>
-
- <style lang="scss" scoped>
- div::-webkit-scrollbar {
- width: 9px;
- height: 19px;
- }
- .BoxCommonVector {
- width: 100%;
- height: 100%;
- position: absolute;
- left: 0rem;
- top: 0rem;
- }
- .innerContainerVector {
- width: 430px;
- height: 760px; //calc(100% - 20px);
- position: absolute;
- top: 28px;
- z-index: 99;
- background-image: url("/static/images/ghzc/内容框.png");
- background-size: 100% 100%;
- border-top-right-radius: 15px;
- .searchDiv {
- width: 100%;
- display: flex;
- justify-content: space-between;
- margin-right: 10px;
- .sidiv {
- // min-width: calc(50% - 10px);
- height: 40px;
- margin-bottom: 5px;
- margin-right: 5px;
- display: inline-block;
- }
- }
- .shownum {
- line-height: 20px;
- padding-top: 10px;
- padding-left: 5px;
- background: rgba(10, 25, 38, 1) !important;
- }
- .search {
- // margin: 2rem;
- }
- /deep/ .el-input {
- display: inline-block;
- }
- /deep/ .el-input__inner {
- // background: transparent !important;
- color: white !important;
- background: rgba(10, 25, 38, 0.5);
- border-color: #5ecef09a;
- // color: #64daff;
- // font-size: 12px;
- }
- }
- .leftPaneVector {
- left: 20px;
- .el-icon-close {
- width: 22px;
- height: 22px;
- color: #fff !important;
- background-color: #335f87;
- line-height: 23px;
- padding: 0 5px;
- border-radius: 4px;
- top: -1.9rem !important;
- position: relative;
- right: -24rem;
- }
- .PangetitleVector {
- box-sizing: border-box;
- width: 100%;
- height: 42px;
- background: url("/static/images/overview/titlebox.gif") no-repeat !important;
- background-size: 100% 100% !important;
- line-height: 35px;
- font-size: 14px;
- padding-left: 15px;
- display: flex;
- position: relative;
- overflow: hidden;
- }
- .pange_textVector {
- font-size: 14px !important;
- font-family: "HarmonyOS Sans, HarmonyOS Sans";
- font-weight: bold;
- font-size: 18px;
- color: #ffffff;
- margin-left: 30px;
- }
- }
- /deep/.el-input__inner:focus {
- border: 1px solid #1fb1ef;
- }
- /deep/.el-input__inner {
- border: 1px solid rgba(10, 25, 38, 0.5);
- background: rgba(10, 25, 38, 0.5);
- border-radius: 18px;
- height: 30px;
- color: white;
- line-height: 30px;
- // background: #ffffff3b;
- }
- /deep/.el-input__icon {
- line-height: 30px;
- border-radius: 0 18px 18px 0;
- cursor: pointer;
- }
- /deep/.el-input__suffix {
- background: #1fb1ef;
- right: 1px;
- padding: 0 5px;
- border-radius: 0 18px 18px 0;
- opacity: 0.8;
- color: #fff;
- }
- /deep/ .el-autocomplete-suggestion {
- margin-top: 8px;
- border-radius: 6px;
- border: 1px solid #198ec0;
- background: rgba(10, 25, 38, 0.9);
- color: rgba(25, 142, 192, 1);
- .popper__arrow {
- top: -8px;
- border-bottom-color: rgba(31, 177, 239, 1);
- }
- .popper__arrow::after {
- border-bottom-color: rgba(0, 80, 111, 0.9);
- }
- .el-autocomplete-suggestion__wrap {
- padding: 2px;
- }
- }
- /deep/ .el-autocomplete-suggestion li {
- color: #ffffff;
- }
- /deep/ .el-autocomplete-suggestion li:hover {
- background-color: rgba(8, 162, 223, 0.8);
- border-radius: 6px;
- }
- /deep/ .el-table tr {
- background: rgba(10, 25, 38, 0.5) !important;
- }
- /deep/ .el-table td.el-table__cell,
- .el-table th.el-table__cell.is-leaf {
- background: rgba(10, 25, 38, 0.5) !important;
- border-bottom: 0px solid #ebeef5;
- }
- /deep/.el-table th.el-table__cell {
- background: rgba(10, 25, 38, 0.5) !important;
- }
- .el-table {
- color: #fff;
- background: rgba(10, 25, 38, 0.5) !important;
- }
- /deep/ .el-table__fixed-right::before,
- .el-table__fixed::before {
- background: rgba(10, 25, 38, 0.9) !important;
- }
- /deep/ .el-table__fixed-right-patch {
- background: rgba(10, 25, 38, 0.9) !important;
- }
- /deep/ .el-table--border::after,
- .el-table--group::after,
- .el-table::before {
- background: rgba(10, 25, 38, 0) !important;
- }
- /deep/ .el-table .warning-row {
- background: rgb(102, 177, 255) !important;
- }
- </style>
-
|