index.vue 34 KB

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