index.vue 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009
  1. <template>
  2. <div class="base-container">
  3. <fnHeader :hideSwitch="true" headerName="飞鸟确权平台" :autoGo="false" :hideShadow="true"></fnHeader>
  4. <div class="top-bg"></div>
  5. <el-upload
  6. ref="uploadRef"
  7. class="upload-demo"
  8. :limit="1"
  9. :on-exceed="handleExceed"
  10. :on-success="onSuccess"
  11. :before-upload="beforeUpload"
  12. action="https://feiniaotech-dev.sysuimars.cn/site/plugin_ownership/uploadFile"
  13. :headers="headerUpload"
  14. >
  15. <template #trigger>
  16. <div class="btn blue" :class="{ 'disabled-button': !disabledForm && isEdit }">
  17. <el-icon><Upload /></el-icon>
  18. <span>RTK点位数据导入</span>
  19. </div>
  20. </template>
  21. </el-upload>
  22. <div class="top">
  23. <!-- <div class="back btn" @click="goBack">
  24. <img class="icon" src="@/assets/images/common/back-icon.png" alt="" />
  25. <span>返回</span>
  26. </div> -->
  27. <el-select
  28. v-model="locationVal"
  29. filterable
  30. remote
  31. :disabled="!disabledForm && isEdit"
  32. effect="dark"
  33. reserve-keyword
  34. placeholder="搜索地区"
  35. :remote-method="remoteMethod"
  36. :loading="loading"
  37. @change="handleSearchRes"
  38. class="v-select"
  39. >
  40. <template #prefix>
  41. <el-icon class="el-input__icon"><search /></el-icon>
  42. </template>
  43. <el-option
  44. v-for="(item, index) in locationOptions.list"
  45. :key="index"
  46. :label="item.title"
  47. :value="item.point"
  48. >
  49. <span>{{ item.title }}</span>
  50. <span class="sub-title">{{ item.province }}{{ item.city }}{{ item.district }}</span>
  51. </el-option>
  52. </el-select>
  53. <div class="search">
  54. <div class="add btn" :class="{ 'disabled-button': !disabledForm && isEdit }" @click="handleAdd">
  55. <el-icon><Plus /></el-icon>
  56. <span>创建</span>
  57. </div>
  58. <div class="upload btn" :class="{ 'disabled-button': !disabledForm && isEdit }" @click="handleExport">
  59. <img class="icon" src="@/assets/images/common/back-icon.png" alt="" />
  60. <span>导出</span>
  61. </div>
  62. </div>
  63. </div>
  64. <div class="content">
  65. <el-form :inline="true" :model="formInlineSearch" class="search-form" ref="formInlineRef">
  66. <el-form-item label="农场地址">
  67. <el-input v-model="formInlineSearch.address" placeholder="请输入农场地址" clearable />
  68. </el-form-item>
  69. <el-form-item label="农场名称">
  70. <el-input v-model="formInlineSearch.farmName" placeholder="请输入农场名称" clearable />
  71. </el-form-item>
  72. <el-form-item label="作物物种">
  73. <el-input v-model="formInlineSearch.speciesTypeName" placeholder="请输入作物物种" clearable />
  74. </el-form-item>
  75. <el-form-item label="客户姓名">
  76. <el-input v-model="formInlineSearch.masterName" placeholder="请输入客户姓名" clearable />
  77. </el-form-item>
  78. <el-form-item label="联系电话">
  79. <el-input v-model="formInlineSearch.masterTel" placeholder="请输入联系电话" clearable />
  80. </el-form-item>
  81. <div class="button">
  82. <el-button
  83. class="btn"
  84. :class="{ 'disabled-button': !disabledForm && isEdit }"
  85. type="primary"
  86. @click="onSearch"
  87. >查询</el-button
  88. >
  89. <el-button class="btn reset" :class="{ 'disabled-button': !disabledForm && isEdit }" @click="onRest"
  90. >重置</el-button
  91. >
  92. </div>
  93. </el-form>
  94. <div class="box">
  95. <div class="map-box" :class="{ 'cursor-pointer': mouseStyle }">
  96. <div ref="mapRef" class="map"></div>
  97. </div>
  98. <div class="tool-group">
  99. <!-- <div class="btn" @click="handleCancel">
  100. <img class="icon" src="@/assets/images/common/back-black-icon.png" alt="" />
  101. <span>撤销</span>
  102. </div> -->
  103. <!-- <div
  104. class="btn"
  105. @click="handleDeletePoint"
  106. v-show="mapData.selectPointArr.length > 0 && !disabledForm"
  107. >
  108. <el-icon size="15"><CloseBold /></el-icon>
  109. <span>删除点</span>
  110. </div> -->
  111. <div class="btn delete" @click="handleDelete" v-show="mapData.selectPointArr.length > 0">
  112. <el-icon size="15" color="#fff"><CloseBold /></el-icon>
  113. <span>删除地块</span>
  114. </div>
  115. </div>
  116. <div class="edit-popup" v-show="isEdit">
  117. <div class="edit-title">
  118. <div class="name">
  119. <img src="@/assets/images/common/chart-icon.png" alt="" />
  120. <span>地块属性</span>
  121. </div>
  122. <div class="btn-group">
  123. <div v-show="disabledForm" class="edit" @click="handleEdit">编辑</div>
  124. <div v-show="!disabledForm" class="edit" @click="handleDeletePoint">删除点</div>
  125. <div
  126. v-show="mapData.selectPointArr.length > 0"
  127. class="edit ml"
  128. :class="{ 'disabled-button': !disabledForm }"
  129. @click="handlePrint"
  130. >
  131. 打印
  132. </div>
  133. </div>
  134. </div>
  135. <div class="edit-cont">
  136. <el-form
  137. :inline="true"
  138. ref="ruleFormRef"
  139. :disabled="disabledForm"
  140. :model="formInline"
  141. :rules="rules"
  142. label-position="top"
  143. class="form-inline"
  144. :class="{'no-area': store.state.authentic.isEditStatus}"
  145. >
  146. <el-form-item label="农场地址" prop="address">
  147. <el-input v-model="formInline.address" placeholder="请输入农场地址" clearable />
  148. </el-form-item>
  149. <el-form-item label="农场名称" prop="farmName">
  150. <el-input v-model="formInline.farmName" placeholder="请输入农场名称" clearable />
  151. </el-form-item>
  152. <el-form-item label="创建时间">
  153. <el-input v-model="formInline.createDate" clearable disabled />
  154. </el-form-item>
  155. <el-form-item label="农场面积">
  156. <el-input v-model="formInline.mu" disabled clearable />
  157. </el-form-item>
  158. <el-form-item label="作物物种" prop="speciesTypeName">
  159. <el-input v-model="formInline.speciesTypeName" placeholder="请输入作物物种" clearable />
  160. </el-form-item>
  161. <el-form-item label="斜面面积" v-show="!store.state.authentic.isEditStatus">
  162. <el-input v-model="formInline.slopeMu" disabled clearable />
  163. </el-form-item>
  164. <el-form-item label="联系电话" prop="masterTel">
  165. <el-input v-model="formInline.masterTel" placeholder="请输入联系电话" clearable />
  166. </el-form-item>
  167. </el-form>
  168. <div class="list-box" :class="{'no-area': store.state.authentic.isEditStatus}" v-show="pointList.length > 0">
  169. <span>边界点经纬度</span>
  170. <div class="list-cont">
  171. <div class="list-item" v-for="(item, index) in pointList" :key="index">
  172. <span>A{{ index + 1 }}</span>
  173. <div class="item-box">北纬{{ item[1] }}</div>
  174. <div class="item-box">东经{{ item[0] }}</div>
  175. </div>
  176. </div>
  177. </div>
  178. </div>
  179. <div class="edit-footer">
  180. <div @click="onCancel" class="btn cancel">取消</div>
  181. <div @click="onSubmit" class="btn save">保存</div>
  182. </div>
  183. </div>
  184. </div>
  185. </div>
  186. </div>
  187. <!-- 导出弹窗 -->
  188. <el-dialog v-model="dialogVisible" width="82%" center :show-close="false" modal-class="dialog-dark">
  189. <div>
  190. <el-table :data="gridData" border max-height="600" class="table-dark">
  191. <el-table-column property="farmName" label="农场名称" show-overflow-tooltip />
  192. <el-table-column property="address" label="农场地址" width="230" show-overflow-tooltip />
  193. <el-table-column property="createDate" label="创建时间" width="170" />
  194. <el-table-column property="mu" label="农场面积">
  195. <template #default="scope">
  196. <span>{{ scope.row.mu }}亩</span>
  197. </template>
  198. </el-table-column>
  199. <el-table-column property="slopeMu" label="斜面面积">
  200. <template #default="scope">
  201. <span>{{ scope.row.slopeMu }}亩</span>
  202. </template>
  203. </el-table-column>
  204. <el-table-column property="speciesTypeName" label="作物物种" />
  205. <el-table-column property="masterName" label="客户姓名" />
  206. <el-table-column property="masterTel" width="120" label="联系电话" />
  207. <el-table-column property="points" label="边界点经纬度" width="480" show-overflow-tooltip />
  208. </el-table>
  209. </div>
  210. <template #footer>
  211. <div class="dialog-footer">
  212. <el-button class="btn" @click="dialogVisible = false">取消</el-button>
  213. <el-button class="btn" type="primary" @click="handleDowload"> 下载 </el-button>
  214. </div>
  215. </template>
  216. </el-dialog>
  217. <Pdf
  218. :title="formInline.id + ''"
  219. :showDialog="pdfShow"
  220. @closeDialog="pdfShow = false"
  221. v-if="formInline.id && pdfShow"
  222. :rowId="formInline.id"
  223. ></Pdf>
  224. </template>
  225. <script setup>
  226. import { onMounted, ref, reactive, watchEffect, watch } from "vue";
  227. import fnHeader from "@/components/fnHeader.vue";
  228. import AuthenticMap from "./authenticMap";
  229. import { mapData } from "./authenticMap";
  230. import { useRouter } from "vue-router";
  231. import { ElMessage, ElMessageBox } from "element-plus";
  232. import { dateFormat } from "@/utils/date_util";
  233. import { exportExcel, parseMultiPolygon } from "@/utils/index";
  234. import { useStore } from "vuex";
  235. import Pdf from "./Pdf";
  236. import {Feature} from "ol";
  237. const pdfShow = ref(false);
  238. const mouseStyle = ref(1);
  239. const router = useRouter();
  240. const store = useStore();
  241. let authenticMap = new AuthenticMap();
  242. const mapRef = ref();
  243. const userInfo = JSON.parse(sessionStorage.getItem("userinfo"));
  244. debugger
  245. const location = ref(userInfo.location);
  246. onMounted(() => {
  247. authenticMap.initMap(location.value, mapRef.value);
  248. getList();
  249. });
  250. // 获取地块列表
  251. const plotList = ref([]);
  252. const getList = (callback) => {
  253. authenticMap.clearLayer();
  254. return VE_API.authentic.getList(formInlineSearch).then(({ code, data }) => {
  255. plotList.value = data || [];
  256. const geom = [];
  257. data.forEach((item) => {
  258. geom.push({ featureWkt: item.geom, ...item });
  259. });
  260. authenticMap.setAreaGeometry(geom);
  261. authenticMap.addPoint(data);
  262. callback && callback(geom);
  263. });
  264. };
  265. // 搜索
  266. const locationVal = ref("");
  267. const loading = ref(false);
  268. const MAP_KEY = "CZLBZ-LJICQ-R4A5J-BN62X-YXCRJ-GNBUT";
  269. const handleSearchRes = (v) => {
  270. authenticMap.setMapCenter(v);
  271. onRest();
  272. };
  273. const locationOptions = reactive({
  274. list: [],
  275. });
  276. const remoteMethod = async (keyword) => {
  277. if (keyword) {
  278. locationOptions.list = [];
  279. loading.value = true;
  280. const params = {
  281. key: MAP_KEY,
  282. keyword,
  283. // location: location.value,
  284. location: "22.574540836684672,113.1093017627431",
  285. };
  286. await VE_API.old_mini_map.getCtiyList({ word: keyword }).then(({ data }) => {
  287. if (data && data.length) {
  288. data.forEach((item) => {
  289. item.point = item.location.lat + "," + item.location.lng;
  290. locationOptions.list.push(item);
  291. });
  292. }
  293. });
  294. VE_API.old_mini_map.search(params).then(({ data }) => {
  295. loading.value = false;
  296. data.forEach((item) => {
  297. item.point = item.location.lat + "," + item.location.lng;
  298. locationOptions.list.push(item);
  299. });
  300. });
  301. } else {
  302. locationOptions.list = [];
  303. }
  304. };
  305. const validatePhoneNumber = (rule, value, callback) => {
  306. const phoneRegex = /^[1][3-9]\d{9}$/;
  307. if (!value) {
  308. callback(new Error("请输入联系电话"));
  309. } else if (!phoneRegex.test(value)) {
  310. callback(new Error("手机号码格式不正确"));
  311. } else {
  312. callback();
  313. }
  314. };
  315. const rules = {
  316. address: [{ required: true, message: "请输入农场地址", trigger: "change" }],
  317. farmName: [{ required: true, message: "请输入农场名称", trigger: "change" }],
  318. speciesTypeName: [{ required: true, message: "请输入作物物种", trigger: "change" }],
  319. masterName: [{ required: true, message: "请输入姓名", trigger: "change" }],
  320. masterTel: [{ required: true, validator: validatePhoneNumber, trigger: "change" }],
  321. };
  322. const ruleFormRef = ref(null);
  323. const initForm = {
  324. id: "",
  325. address: "",
  326. farmName: "",
  327. createDate: "",
  328. mu: "",
  329. slopeMu: "",
  330. speciesTypeName: "",
  331. masterName: "",
  332. masterTel: "",
  333. geom: "",
  334. };
  335. const formInline = reactive({
  336. ...initForm,
  337. });
  338. const disabledForm = ref(false);
  339. // 筛选
  340. const formInlineRef = ref(null);
  341. const formInlineSearch = reactive({
  342. ...initForm,
  343. });
  344. const onSearch = () => {
  345. authenticMap.search(formInlineSearch);
  346. };
  347. const onRest = () => {
  348. Object.assign(formInlineSearch, initForm);
  349. isUpdata.value = false;
  350. onCancel();
  351. };
  352. const isEdit = ref(false);
  353. const typeStr = ref("");
  354. // 编辑
  355. const handleEdit = () => {
  356. typeStr.value = "edit";
  357. disabledForm.value = false;
  358. mapData.disabledForm = false;
  359. authenticMap.startModify('edit');
  360. authenticMap.clearSelectPoint()
  361. };
  362. // 取消
  363. const isUpdata = ref(true);
  364. const onCancel = () => {
  365. authenticMap.clearSelectPoint()
  366. isEdit.value = false;
  367. store.commit("authentic/SET_ISEDIT_STATUS", false);
  368. if (isUpdata.value) {
  369. authenticMap.cancelDraw();
  370. getList((geoms) => {
  371. authenticMap.allUnSelect();
  372. });
  373. } else {
  374. Object.assign(formInlineSearch, initForm);
  375. getList((geoms) => {
  376. authenticMap.allUnSelect();
  377. });
  378. }
  379. authenticMap.setPoint("point");
  380. authenticMap.clearMapData("isEdit", false, formInline.id);
  381. authenticMap.endDraw();
  382. };
  383. // 保存
  384. const onSubmit = () => {
  385. if (!ruleFormRef.value) return;
  386. ruleFormRef.value.validate((valid, fields) => {
  387. if (valid) {
  388. formInline.mu = formInline.mu.split("亩")[0];
  389. formInline.slopeMu = formInline.slopeMu.split("亩")[0];
  390. if(heightArr.value.length>0){
  391. formInline.height = heightArr.value
  392. }
  393. VE_API.authentic.saveData(formInline).then((res) => {
  394. store.commit("authentic/SET_ISEDIT_STATUS", false);
  395. isUpdata.value = false;
  396. disabledForm.value = true;
  397. mapData.disabledForm = true;
  398. Object.assign(formInlineSearch, initForm);
  399. authenticMap.endDraw();
  400. getList().then(() => {
  401. isRefresh.value = false;
  402. isEdit.value = false;
  403. authenticMap.allUnSelect();
  404. authenticMap.clearMapData();
  405. // authenticMap.getSelectPointArr(
  406. // point.id || plotList.value[plotList.value.length - 1].id
  407. // );
  408. });
  409. });
  410. }
  411. });
  412. };
  413. //上传
  414. const uploadRef = ref(null);
  415. const headerUpload = { token: store.getters.token };
  416. // 校验文件格式和大小
  417. const beforeUpload = (file) => {
  418. const isCsv = file.type === "application/vnd.ms-excel" || file.type === "text/csv" || file.name.endsWith(".csv");
  419. updateFormInline({ ...initForm });
  420. ruleFormRef.value.resetFields();
  421. authenticMap.clearSelectPoint()
  422. isEdit.value = false;
  423. authenticMap.setPoint("point");
  424. authenticMap.clearMapData("isEdit", false, formInline.id);
  425. authenticMap.endDraw();
  426. if (!isCsv) {
  427. ElMessage.error("上传文件只能是 CSV 格式!");
  428. }
  429. return isCsv;
  430. };
  431. const handleExceed = (files) => {
  432. uploadRef.value.clearFiles();
  433. const file = files[0];
  434. uploadRef.value.handleStart(file);
  435. };
  436. const heightArr = ref([]);
  437. const onSuccess = (res) => {
  438. typeStr.value = "upload";
  439. if (res.code === 0) {
  440. ElMessage.success("上传成功");
  441. store.commit("authentic/SET_ISEDIT_STATUS", true);
  442. isEdit.value = true;
  443. disabledForm.value = false;
  444. formInline.createDate = dateFormat(new Date(), "YYYY-mm-dd HH:MM:SS");
  445. const geom = [{ featureWkt: res.data.geom, ...res.data }];
  446. let featureList = authenticMap.setAreaGeometry(geom);
  447. authenticMap.fit([res.data.geom]);
  448. updatePointList("upload", geom[0]);
  449. heightArr.value = res.data.height;
  450. const arr = pointList.value.map((item, index) => {
  451. return [...item, res.data.height[index]];
  452. });
  453. getArea(arr);
  454. authenticMap.startModify("upload", featureList[0]);
  455. uploadRef.value.clearFiles();
  456. } else {
  457. ElMessage.error("上传失败");
  458. }
  459. };
  460. // 获取面积/亩
  461. const getArea = (arr) => {
  462. VE_API.authentic.getArea(arr).then((res) => {
  463. const area = (res.data / 666.67).toFixed(2);
  464. formInline.mu = area + "亩";
  465. });
  466. };
  467. // 斜面面积
  468. const getSlopeArea = (arr) => {
  469. VE_API.authentic.fetchSlopeArea({wkt: arr}).then(({data}) => {
  470. const area = (data / 666.67).toFixed(2);
  471. formInline.slopeMu = area + "亩";
  472. });
  473. };
  474. // 打印
  475. const handlePrint = () => {
  476. pdfShow.value = true;
  477. };
  478. // 返回
  479. const goBack = () => {
  480. router.go(-1);
  481. };
  482. function updateFormInline(newData, name) {
  483. Object.assign(formInline, newData);
  484. }
  485. // 删除地块
  486. const handleDelete = () => {
  487. const id = mapData.selectPointArr.map((item) => item.values_.id);
  488. if (id.length < 0) return ElMessage("请选择地块");
  489. ElMessageBox.confirm("您确定删除该地块吗?", "提示", {
  490. confirmButtonText: "确认",
  491. cancelButtonText: "取消",
  492. type: "warning",
  493. })
  494. .then(() => {
  495. VE_API.authentic.deleteData(id).then((res) => {
  496. isUpdata.value = false;
  497. onCancel();
  498. });
  499. })
  500. .catch(() => {});
  501. };
  502. // 创建
  503. const isRefresh = ref(true);
  504. const handleAdd = () => {
  505. authenticMap.clearSelectPoint()
  506. typeStr.value = "add";
  507. isRefresh.value = false;
  508. isEdit.value = false;
  509. if (isUpdata.value) {
  510. authenticMap.cancelDraw();
  511. authenticMap.allUnSelect();
  512. } else {
  513. getList();
  514. isUpdata.value = true;
  515. }
  516. updateFormInline({ ...initForm });
  517. ruleFormRef.value.resetFields();
  518. pointList.value = [];
  519. authenticMap.clearMapData("curPointData", {});
  520. authenticMap.clearMapData("isEdit", false);
  521. authenticMap.setPoint("point");
  522. authenticMap.startDraw();
  523. };
  524. // 删除点
  525. const handleDeletePoint = () => {
  526. authenticMap.removePoint((index) => {
  527. updatePointList(typeStr.value);
  528. heightArr.value.splice(index,1)
  529. });
  530. };
  531. // 撤销
  532. const handleCancel = () => {
  533. authenticMap.undoLastDraw();
  534. };
  535. // 导出
  536. const gridData = ref([]);
  537. const dialogVisible = ref(false);
  538. const handleExport = () => {
  539. if (mapData.selectPointArr.length < 1) return ElMessage("请选择地块");
  540. const ids = mapData.selectPointArr.map((item) => item.values_.id);
  541. VE_API.authentic.exportData(ids).then(({ data }) => {
  542. gridData.value = data.map((item) => {
  543. return {
  544. ...item,
  545. createDate: dateFormat(new Date(item.createDate), "YYYY-mm-dd HH:MM:SS"),
  546. };
  547. });
  548. dialogVisible.value = true;
  549. });
  550. };
  551. // 下载
  552. const handleDowload = () => {
  553. const fieldLabels = [
  554. "农场名称",
  555. "农场地址",
  556. "创建时间",
  557. "农场面积",
  558. "作物物种",
  559. "客户姓名",
  560. "联系电话",
  561. "边界点经纬度",
  562. ];
  563. const fieldKeys = [
  564. "farmName",
  565. "address",
  566. "createDate",
  567. "mu",
  568. "speciesTypeName",
  569. "masterName",
  570. "masterTel",
  571. "points",
  572. ];
  573. const fileName = "农场数据" + dateFormat(new Date(), "YYYY-mm-dd HH:MM");
  574. exportExcel(gridData.value, fieldLabels, fieldKeys, fileName);
  575. };
  576. const pointList = ref([]);
  577. // 获取编辑回显数据
  578. const getDetailsData = (id) => {
  579. VE_API.authentic.getDetails({ id }).then(({ data }) => {
  580. isEdit.value = true;
  581. disabledForm.value = true;
  582. mapData.disabledForm = true;
  583. data.createDate = dateFormat(new Date(data.createDate), "YYYY-mm-dd HH:MM:SS");
  584. updateFormInline({ ...data });
  585. // 经纬度列表
  586. let arr = JSON.parse(data.points);
  587. // 删除最后数组最后一项闭合数据
  588. arr.pop();
  589. pointList.value = arr;
  590. if(data.height.length>0){
  591. heightArr.value = data.height
  592. store.commit("authentic/SET_ISEDIT_STATUS", true);
  593. // authenticMap.startModify("upload");
  594. }
  595. formInline.mu = data.mu + "亩";
  596. formInline.slopeMu = data.slopeMu + "亩";
  597. });
  598. };
  599. // 添加经纬度列表
  600. const updatePointList = (type, geom) => {
  601. const { geometryArr, area } = authenticMap.getAreaGeometry(type);
  602. let lastItem = null
  603. if(type === 'upload'){
  604. lastItem = geom
  605. }else{
  606. lastItem = geometryArr[geometryArr.length - 1];
  607. }
  608. formInline.geom = lastItem.featureWkt;
  609. console.log("formInline.geom", formInline.geom)
  610. getSlopeArea(formInline.geom)
  611. let result = parseMultiPolygon(lastItem.featureWkt);
  612. result.pop();
  613. pointList.value = result;
  614. //判断是否是导入数据
  615. if (store.state.authentic.isEditStatus) {
  616. const arr = pointList.value.map((item, index) => {
  617. return [...item, heightArr.value[index]];
  618. });
  619. if (arr[0][2]) {
  620. getArea(arr);
  621. }
  622. } else {
  623. formInline.mu = area + "亩";
  624. }
  625. };
  626. watchEffect(() => {
  627. if (mapData.isEditArea) {
  628. isUpdata.value = false;
  629. updatePointList("edit");
  630. }
  631. });
  632. watch(
  633. () => mapData.isEdit,
  634. (newVale, oldValue) => {
  635. if (newVale && mapData.selectPointArr.length < 2 && !isRefresh.value) {
  636. isEdit.value = true;
  637. disabledForm.value = false;
  638. mapData.disabledForm = false;
  639. isUpdata.value = true;
  640. formInline.createDate = dateFormat(new Date(), "YYYY-mm-dd HH:MM:SS");
  641. updatePointList("add");
  642. authenticMap.startModify('add');
  643. }
  644. }
  645. );
  646. watch(
  647. () => mapData.selectPointArr,
  648. (newVale, oldValue) => {
  649. if (mapData.selectPointArr.length === 1) {
  650. const obj = mapData.selectPointArr[0];
  651. const id = obj.values_.id;
  652. getDetailsData(id);
  653. mapData.curPointData = obj.values_;
  654. } else {
  655. if (isRefresh.value) {
  656. isEdit.value = false;
  657. authenticMap.endDraw();
  658. isRefresh.value = true;
  659. }
  660. if (mapData.selectPointArr.length === 0 || mapData.selectPointArr.length > 1) {
  661. isEdit.value = false;
  662. }
  663. }
  664. }
  665. );
  666. </script>
  667. <style lang="scss" scoped>
  668. ::v-deep {
  669. .el-upload-list {
  670. display: none;
  671. }
  672. }
  673. .base-container {
  674. width: 100%;
  675. height: 100vh;
  676. color: #fff;
  677. box-sizing: border-box;
  678. z-index: 1;
  679. position: relative;
  680. .top-bg {
  681. position: absolute;
  682. top: 0;
  683. width: 100%;
  684. height: 74px;
  685. background: #101010;
  686. z-index: -1;
  687. }
  688. .upload-demo {
  689. display: flex;
  690. align-items: center;
  691. justify-content: flex-end;
  692. padding-right: 20px;
  693. background: #101010;
  694. }
  695. .blue {
  696. background: #2199f8;
  697. }
  698. .btn {
  699. display: flex;
  700. align-items: center;
  701. padding: 6px 16px;
  702. border-radius: 4px;
  703. cursor: pointer;
  704. .icon {
  705. width: 13px;
  706. height: 13px;
  707. }
  708. span {
  709. margin-left: 10px;
  710. }
  711. }
  712. .disabled-button {
  713. pointer-events: none;
  714. opacity: 0.5;
  715. cursor: not-allowed;
  716. }
  717. .top {
  718. display: flex;
  719. justify-content: space-between;
  720. // justify-content: flex-end;
  721. width: 100%;
  722. height: 40px;
  723. background: #101010;
  724. padding: 17px 20px 0 20px;
  725. box-sizing: border-box;
  726. display: flex;
  727. align-items: center;
  728. .back {
  729. border: 1px solid rgba(255, 255, 255, 0.4);
  730. }
  731. .v-select {
  732. width: 300px;
  733. ::v-deep {
  734. .el-select__wrapper {
  735. background: #101010;
  736. box-shadow: none;
  737. border: 1px solid rgba(255, 255, 255, 0.7);
  738. .el-select__input {
  739. color: #fff;
  740. }
  741. }
  742. }
  743. }
  744. .search {
  745. display: flex;
  746. align-items: center;
  747. justify-content: flex-end;
  748. width: 60%;
  749. .input-with-select {
  750. margin-left: 25px;
  751. }
  752. .upload {
  753. background: #2199f8;
  754. margin-left: 25px;
  755. }
  756. .add {
  757. background: #fff;
  758. color: #000;
  759. margin-left: 25px;
  760. }
  761. }
  762. }
  763. .content {
  764. width: 100%;
  765. height: calc(100% - 74px - 40px - 32px);
  766. box-sizing: border-box;
  767. background: #101010;
  768. padding: 13px 20px 20px 20px;
  769. .search-form {
  770. height: 40px;
  771. margin: 5px 0;
  772. display: flex;
  773. // justify-content: flex-end;
  774. justify-content: space-between;
  775. ::v-deep {
  776. .el-form-item__label {
  777. color: #fff;
  778. }
  779. .el-form-item__content {
  780. width: 190px;
  781. }
  782. .el-input__wrapper {
  783. background: #101010;
  784. box-shadow: none;
  785. border: 1px solid rgba(255, 255, 255, 0.7);
  786. .el-input__inner {
  787. color: #fff;
  788. }
  789. }
  790. }
  791. .button {
  792. display: flex;
  793. .btn {
  794. width: 84px;
  795. &.reset {
  796. margin-left: 25px;
  797. }
  798. }
  799. }
  800. }
  801. .box {
  802. border: 1px solid rgba(255, 255, 255, 0.4);
  803. border-radius: 8px;
  804. padding: 20px;
  805. box-sizing: border-box;
  806. background: #232323;
  807. width: 100%;
  808. height: calc(100% - 50px);
  809. position: relative;
  810. .map-box {
  811. width: 100%;
  812. height: 100%;
  813. border-radius: 4px;
  814. border: 1px solid rgba(255, 255, 255, 0.4);
  815. .map {
  816. width: 100%;
  817. height: 100%;
  818. }
  819. }
  820. .tool-group {
  821. position: absolute;
  822. display: flex;
  823. right: calc(500px + 36px);
  824. top: 42px;
  825. .btn {
  826. background: #fff;
  827. color: #000;
  828. margin-right: 10px;
  829. }
  830. .delete {
  831. background: #e45c5c;
  832. color: #fff;
  833. }
  834. }
  835. .edit-popup {
  836. width: 500px;
  837. height: calc(100% - 53px - 20px);
  838. position: absolute;
  839. top: 36px;
  840. right: 36px;
  841. border: 1px solid rgba(255, 255, 255, 0.4);
  842. border-radius: 8px;
  843. background: #232323;
  844. .edit-title {
  845. padding: 0 10px;
  846. background: rgba(68, 68, 68, 0.4);
  847. border-bottom: 1px solid rgba(68, 68, 68, 0.4);
  848. display: flex;
  849. align-items: center;
  850. justify-content: space-between;
  851. .btn-group {
  852. display: flex;
  853. .ml {
  854. margin-left: 20px;
  855. }
  856. }
  857. .name {
  858. display: flex;
  859. padding: 12px 0px;
  860. align-items: center;
  861. }
  862. span {
  863. margin-left: 8px;
  864. font-size: 18px;
  865. font-family: "SOURCEHANTIFINE";
  866. }
  867. .edit {
  868. color: #2199f8;
  869. padding: 6px 20px;
  870. border: 1px solid #2199f8;
  871. border-radius: 4px;
  872. cursor: pointer;
  873. }
  874. }
  875. .edit-cont {
  876. padding: 16px;
  877. width: calc(100% - 32px);
  878. height: calc(100% - 64px - 84px);
  879. .form-inline {
  880. height: 320px;
  881. &.no-area {
  882. height: 260px;
  883. }
  884. ::v-deep {
  885. .el-input {
  886. width: 200px;
  887. --el-input-placeholder-color: #666666;
  888. }
  889. .el-form-item__label {
  890. color: #bbbbbb;
  891. }
  892. .el-input__wrapper {
  893. background: #232323;
  894. border: 1px solid #444444;
  895. box-shadow: none;
  896. .el-input__inner {
  897. color: #fff;
  898. }
  899. }
  900. }
  901. }
  902. .list-box {
  903. width: 100%;
  904. height: calc(100% - 320px);
  905. &.no-area {
  906. height: calc(100% - 260px);
  907. }
  908. span {
  909. color: #bbbbbb;
  910. }
  911. .list-cont {
  912. width: 100%;
  913. height: calc(100% - 20px);
  914. border-radius: 4px;
  915. margin-top: 5px;
  916. background: rgba(68, 68, 68, 0.4);
  917. padding: 12px 16px;
  918. box-sizing: border-box;
  919. overflow-y: auto;
  920. .list-item {
  921. width: 100%;
  922. margin-bottom: 8px;
  923. display: flex;
  924. align-items: center;
  925. .item-box {
  926. padding: 8px;
  927. border: 1px solid #444444;
  928. border-radius: 4px;
  929. margin-left: 10px;
  930. }
  931. }
  932. }
  933. }
  934. }
  935. .edit-footer {
  936. width: 100%;
  937. height: 64px;
  938. display: flex;
  939. align-items: center;
  940. justify-content: flex-end;
  941. box-sizing: border-box;
  942. padding: 12px 16px;
  943. border-top: 1px solid rgba(68, 68, 68, 0.4);
  944. background: rgba(68, 68, 68, 0.4);
  945. .btn {
  946. padding: 10px 35px;
  947. }
  948. .cancel {
  949. border: 1px solid rgba(255, 255, 255, 0.4);
  950. margin-right: 16px;
  951. }
  952. .save {
  953. background: #2199f8;
  954. }
  955. }
  956. }
  957. }
  958. }
  959. }
  960. .dialog-footer {
  961. .btn {
  962. width: 200px;
  963. height: 40px;
  964. }
  965. }
  966. </style>