index.vue 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008
  1. <template>
  2. <div class="base-container">
  3. <fnHeader :hideSwitch="true" :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. const location = ref(userInfo.location);
  245. onMounted(() => {
  246. authenticMap.initMap(location.value, mapRef.value);
  247. getList();
  248. });
  249. // 获取地块列表
  250. const plotList = ref([]);
  251. const getList = (callback) => {
  252. authenticMap.clearLayer();
  253. return VE_API.authentic.getList(formInlineSearch).then(({ code, data }) => {
  254. plotList.value = data || [];
  255. const geom = [];
  256. data.forEach((item) => {
  257. geom.push({ featureWkt: item.geom, ...item });
  258. });
  259. authenticMap.setAreaGeometry(geom);
  260. authenticMap.addPoint(data);
  261. callback && callback(geom);
  262. });
  263. };
  264. // 搜索
  265. const locationVal = ref("");
  266. const loading = ref(false);
  267. const MAP_KEY = "CZLBZ-LJICQ-R4A5J-BN62X-YXCRJ-GNBUT";
  268. const handleSearchRes = (v) => {
  269. authenticMap.setMapCenter(v);
  270. onRest();
  271. };
  272. const locationOptions = reactive({
  273. list: [],
  274. });
  275. const remoteMethod = async (keyword) => {
  276. if (keyword) {
  277. locationOptions.list = [];
  278. loading.value = true;
  279. const params = {
  280. key: MAP_KEY,
  281. keyword,
  282. // location: location.value,
  283. location: "22.574540836684672,113.1093017627431",
  284. };
  285. await VE_API.old_mini_map.getCtiyList({ word: keyword }).then(({ data }) => {
  286. if (data && data.length) {
  287. data.forEach((item) => {
  288. item.point = item.location.lat + "," + item.location.lng;
  289. locationOptions.list.push(item);
  290. });
  291. }
  292. });
  293. VE_API.old_mini_map.search(params).then(({ data }) => {
  294. loading.value = false;
  295. data.forEach((item) => {
  296. item.point = item.location.lat + "," + item.location.lng;
  297. locationOptions.list.push(item);
  298. });
  299. });
  300. } else {
  301. locationOptions.list = [];
  302. }
  303. };
  304. const validatePhoneNumber = (rule, value, callback) => {
  305. const phoneRegex = /^[1][3-9]\d{9}$/;
  306. if (!value) {
  307. callback(new Error("请输入联系电话"));
  308. } else if (!phoneRegex.test(value)) {
  309. callback(new Error("手机号码格式不正确"));
  310. } else {
  311. callback();
  312. }
  313. };
  314. const rules = {
  315. address: [{ required: true, message: "请输入农场地址", trigger: "change" }],
  316. farmName: [{ required: true, message: "请输入农场名称", trigger: "change" }],
  317. speciesTypeName: [{ required: true, message: "请输入作物物种", trigger: "change" }],
  318. masterName: [{ required: true, message: "请输入姓名", trigger: "change" }],
  319. masterTel: [{ required: true, validator: validatePhoneNumber, trigger: "change" }],
  320. };
  321. const ruleFormRef = ref(null);
  322. const initForm = {
  323. id: "",
  324. address: "",
  325. farmName: "",
  326. createDate: "",
  327. mu: "",
  328. slopeMu: "",
  329. speciesTypeName: "",
  330. masterName: "",
  331. masterTel: "",
  332. geom: "",
  333. };
  334. const formInline = reactive({
  335. ...initForm,
  336. });
  337. const disabledForm = ref(false);
  338. // 筛选
  339. const formInlineRef = ref(null);
  340. const formInlineSearch = reactive({
  341. ...initForm,
  342. });
  343. const onSearch = () => {
  344. authenticMap.search(formInlineSearch);
  345. };
  346. const onRest = () => {
  347. Object.assign(formInlineSearch, initForm);
  348. isUpdata.value = false;
  349. onCancel();
  350. };
  351. const isEdit = ref(false);
  352. const typeStr = ref("");
  353. // 编辑
  354. const handleEdit = () => {
  355. typeStr.value = "edit";
  356. disabledForm.value = false;
  357. mapData.disabledForm = false;
  358. authenticMap.startModify('edit');
  359. authenticMap.clearSelectPoint()
  360. };
  361. // 取消
  362. const isUpdata = ref(true);
  363. const onCancel = () => {
  364. authenticMap.clearSelectPoint()
  365. isEdit.value = false;
  366. store.commit("authentic/SET_ISEDIT_STATUS", false);
  367. if (isUpdata.value) {
  368. authenticMap.cancelDraw();
  369. getList((geoms) => {
  370. authenticMap.allUnSelect();
  371. });
  372. } else {
  373. Object.assign(formInlineSearch, initForm);
  374. getList((geoms) => {
  375. authenticMap.allUnSelect();
  376. });
  377. }
  378. authenticMap.setPoint("point");
  379. authenticMap.clearMapData("isEdit", false, formInline.id);
  380. authenticMap.endDraw();
  381. };
  382. // 保存
  383. const onSubmit = () => {
  384. if (!ruleFormRef.value) return;
  385. ruleFormRef.value.validate((valid, fields) => {
  386. if (valid) {
  387. formInline.mu = formInline.mu.split("亩")[0];
  388. formInline.slopeMu = formInline.slopeMu.split("亩")[0];
  389. if(heightArr.value.length>0){
  390. formInline.height = heightArr.value
  391. }
  392. VE_API.authentic.saveData(formInline).then((res) => {
  393. store.commit("authentic/SET_ISEDIT_STATUS", false);
  394. isUpdata.value = false;
  395. disabledForm.value = true;
  396. mapData.disabledForm = true;
  397. Object.assign(formInlineSearch, initForm);
  398. authenticMap.endDraw();
  399. getList().then(() => {
  400. isRefresh.value = false;
  401. isEdit.value = false;
  402. authenticMap.allUnSelect();
  403. authenticMap.clearMapData();
  404. // authenticMap.getSelectPointArr(
  405. // point.id || plotList.value[plotList.value.length - 1].id
  406. // );
  407. });
  408. });
  409. }
  410. });
  411. };
  412. //上传
  413. const uploadRef = ref(null);
  414. const headerUpload = { token: store.getters.token };
  415. // 校验文件格式和大小
  416. const beforeUpload = (file) => {
  417. const isCsv = file.type === "application/vnd.ms-excel" || file.type === "text/csv" || file.name.endsWith(".csv");
  418. updateFormInline({ ...initForm });
  419. ruleFormRef.value.resetFields();
  420. authenticMap.clearSelectPoint()
  421. isEdit.value = false;
  422. authenticMap.setPoint("point");
  423. authenticMap.clearMapData("isEdit", false, formInline.id);
  424. authenticMap.endDraw();
  425. if (!isCsv) {
  426. ElMessage.error("上传文件只能是 CSV 格式!");
  427. }
  428. return isCsv;
  429. };
  430. const handleExceed = (files) => {
  431. uploadRef.value.clearFiles();
  432. const file = files[0];
  433. uploadRef.value.handleStart(file);
  434. };
  435. const heightArr = ref([]);
  436. const onSuccess = (res) => {
  437. typeStr.value = "upload";
  438. if (res.code === 0) {
  439. ElMessage.success("上传成功");
  440. store.commit("authentic/SET_ISEDIT_STATUS", true);
  441. isEdit.value = true;
  442. disabledForm.value = false;
  443. formInline.createDate = dateFormat(new Date(), "YYYY-mm-dd HH:MM:SS");
  444. const geom = [{ featureWkt: res.data.geom, ...res.data }];
  445. let featureList = authenticMap.setAreaGeometry(geom);
  446. authenticMap.fit([res.data.geom]);
  447. updatePointList("upload", geom[0]);
  448. heightArr.value = res.data.height;
  449. const arr = pointList.value.map((item, index) => {
  450. return [...item, res.data.height[index]];
  451. });
  452. getArea(arr);
  453. authenticMap.startModify("upload", featureList[0]);
  454. uploadRef.value.clearFiles();
  455. } else {
  456. ElMessage.error("上传失败");
  457. }
  458. };
  459. // 获取面积/亩
  460. const getArea = (arr) => {
  461. VE_API.authentic.getArea(arr).then((res) => {
  462. const area = (res.data / 666.67).toFixed(2);
  463. formInline.mu = area + "亩";
  464. });
  465. };
  466. // 斜面面积
  467. const getSlopeArea = (arr) => {
  468. VE_API.authentic.fetchSlopeArea({wkt: arr}).then(({data}) => {
  469. const area = (data / 666.67).toFixed(2);
  470. formInline.slopeMu = area + "亩";
  471. });
  472. };
  473. // 打印
  474. const handlePrint = () => {
  475. pdfShow.value = true;
  476. };
  477. // 返回
  478. const goBack = () => {
  479. router.go(-1);
  480. };
  481. function updateFormInline(newData, name) {
  482. Object.assign(formInline, newData);
  483. }
  484. // 删除地块
  485. const handleDelete = () => {
  486. const id = mapData.selectPointArr.map((item) => item.values_.id);
  487. if (id.length < 0) return ElMessage("请选择地块");
  488. ElMessageBox.confirm("您确定删除该地块吗?", "提示", {
  489. confirmButtonText: "确认",
  490. cancelButtonText: "取消",
  491. type: "warning",
  492. })
  493. .then(() => {
  494. VE_API.authentic.deleteData(id).then((res) => {
  495. isUpdata.value = false;
  496. onCancel();
  497. });
  498. })
  499. .catch(() => {});
  500. };
  501. // 创建
  502. const isRefresh = ref(true);
  503. const handleAdd = () => {
  504. authenticMap.clearSelectPoint()
  505. typeStr.value = "add";
  506. isRefresh.value = false;
  507. isEdit.value = false;
  508. if (isUpdata.value) {
  509. authenticMap.cancelDraw();
  510. authenticMap.allUnSelect();
  511. } else {
  512. getList();
  513. isUpdata.value = true;
  514. }
  515. updateFormInline({ ...initForm });
  516. ruleFormRef.value.resetFields();
  517. pointList.value = [];
  518. authenticMap.clearMapData("curPointData", {});
  519. authenticMap.clearMapData("isEdit", false);
  520. authenticMap.setPoint("point");
  521. authenticMap.startDraw();
  522. };
  523. // 删除点
  524. const handleDeletePoint = () => {
  525. authenticMap.removePoint((index) => {
  526. updatePointList(typeStr.value);
  527. heightArr.value.splice(index,1)
  528. });
  529. };
  530. // 撤销
  531. const handleCancel = () => {
  532. authenticMap.undoLastDraw();
  533. };
  534. // 导出
  535. const gridData = ref([]);
  536. const dialogVisible = ref(false);
  537. const handleExport = () => {
  538. if (mapData.selectPointArr.length < 1) return ElMessage("请选择地块");
  539. const ids = mapData.selectPointArr.map((item) => item.values_.id);
  540. VE_API.authentic.exportData(ids).then(({ data }) => {
  541. gridData.value = data.map((item) => {
  542. return {
  543. ...item,
  544. createDate: dateFormat(new Date(item.createDate), "YYYY-mm-dd HH:MM:SS"),
  545. };
  546. });
  547. dialogVisible.value = true;
  548. });
  549. };
  550. // 下载
  551. const handleDowload = () => {
  552. const fieldLabels = [
  553. "农场名称",
  554. "农场地址",
  555. "创建时间",
  556. "农场面积",
  557. "作物物种",
  558. "客户姓名",
  559. "联系电话",
  560. "边界点经纬度",
  561. ];
  562. const fieldKeys = [
  563. "farmName",
  564. "address",
  565. "createDate",
  566. "mu",
  567. "speciesTypeName",
  568. "masterName",
  569. "masterTel",
  570. "points",
  571. ];
  572. const fileName = "农场数据" + dateFormat(new Date(), "YYYY-mm-dd HH:MM");
  573. exportExcel(gridData.value, fieldLabels, fieldKeys, fileName);
  574. };
  575. const pointList = ref([]);
  576. // 获取编辑回显数据
  577. const getDetailsData = (id) => {
  578. VE_API.authentic.getDetails({ id }).then(({ data }) => {
  579. isEdit.value = true;
  580. disabledForm.value = true;
  581. mapData.disabledForm = true;
  582. data.createDate = dateFormat(new Date(data.createDate), "YYYY-mm-dd HH:MM:SS");
  583. updateFormInline({ ...data });
  584. // 经纬度列表
  585. let arr = JSON.parse(data.points);
  586. // 删除最后数组最后一项闭合数据
  587. arr.pop();
  588. pointList.value = arr;
  589. if(data.height.length>0){
  590. heightArr.value = data.height
  591. store.commit("authentic/SET_ISEDIT_STATUS", true);
  592. // authenticMap.startModify("upload");
  593. }
  594. formInline.mu = data.mu + "亩";
  595. formInline.slopeMu = data.slopeMu + "亩";
  596. });
  597. };
  598. // 添加经纬度列表
  599. const updatePointList = (type, geom) => {
  600. const { geometryArr, area } = authenticMap.getAreaGeometry(type);
  601. let lastItem = null
  602. if(type === 'upload'){
  603. lastItem = geom
  604. }else{
  605. lastItem = geometryArr[geometryArr.length - 1];
  606. }
  607. formInline.geom = lastItem.featureWkt;
  608. console.log("formInline.geom", formInline.geom)
  609. getSlopeArea(formInline.geom)
  610. let result = parseMultiPolygon(lastItem.featureWkt);
  611. result.pop();
  612. pointList.value = result;
  613. //判断是否是导入数据
  614. if (store.state.authentic.isEditStatus) {
  615. const arr = pointList.value.map((item, index) => {
  616. return [...item, heightArr.value[index]];
  617. });
  618. if (arr[0][2]) {
  619. getArea(arr);
  620. }
  621. } else {
  622. formInline.mu = area + "亩";
  623. }
  624. };
  625. watchEffect(() => {
  626. if (mapData.isEditArea) {
  627. isUpdata.value = false;
  628. updatePointList("edit");
  629. }
  630. });
  631. watch(
  632. () => mapData.isEdit,
  633. (newVale, oldValue) => {
  634. if (newVale && mapData.selectPointArr.length < 2 && !isRefresh.value) {
  635. isEdit.value = true;
  636. disabledForm.value = false;
  637. mapData.disabledForm = false;
  638. isUpdata.value = true;
  639. formInline.createDate = dateFormat(new Date(), "YYYY-mm-dd HH:MM:SS");
  640. updatePointList("add");
  641. authenticMap.startModify('add');
  642. }
  643. }
  644. );
  645. watch(
  646. () => mapData.selectPointArr,
  647. (newVale, oldValue) => {
  648. if (mapData.selectPointArr.length === 1) {
  649. const obj = mapData.selectPointArr[0];
  650. const id = obj.values_.id;
  651. getDetailsData(id);
  652. mapData.curPointData = obj.values_;
  653. } else {
  654. if (isRefresh.value) {
  655. isEdit.value = false;
  656. authenticMap.endDraw();
  657. isRefresh.value = true;
  658. }
  659. if (mapData.selectPointArr.length === 0 || mapData.selectPointArr.length > 1) {
  660. isEdit.value = false;
  661. }
  662. }
  663. }
  664. );
  665. </script>
  666. <style lang="scss" scoped>
  667. ::v-deep {
  668. .el-upload-list {
  669. display: none;
  670. }
  671. }
  672. .base-container {
  673. width: 100%;
  674. height: 100vh;
  675. color: #fff;
  676. box-sizing: border-box;
  677. z-index: 1;
  678. position: relative;
  679. .top-bg {
  680. position: absolute;
  681. top: 0;
  682. width: 100%;
  683. height: 74px;
  684. background: #101010;
  685. z-index: -1;
  686. }
  687. .upload-demo {
  688. display: flex;
  689. align-items: center;
  690. justify-content: flex-end;
  691. padding-right: 20px;
  692. background: #101010;
  693. }
  694. .blue {
  695. background: #2199f8;
  696. }
  697. .btn {
  698. display: flex;
  699. align-items: center;
  700. padding: 6px 16px;
  701. border-radius: 4px;
  702. cursor: pointer;
  703. .icon {
  704. width: 13px;
  705. height: 13px;
  706. }
  707. span {
  708. margin-left: 10px;
  709. }
  710. }
  711. .disabled-button {
  712. pointer-events: none;
  713. opacity: 0.5;
  714. cursor: not-allowed;
  715. }
  716. .top {
  717. display: flex;
  718. justify-content: space-between;
  719. // justify-content: flex-end;
  720. width: 100%;
  721. height: 40px;
  722. background: #101010;
  723. padding: 17px 20px 0 20px;
  724. box-sizing: border-box;
  725. display: flex;
  726. align-items: center;
  727. .back {
  728. border: 1px solid rgba(255, 255, 255, 0.4);
  729. }
  730. .v-select {
  731. width: 300px;
  732. ::v-deep {
  733. .el-select__wrapper {
  734. background: #101010;
  735. box-shadow: none;
  736. border: 1px solid rgba(255, 255, 255, 0.7);
  737. .el-select__input {
  738. color: #fff;
  739. }
  740. }
  741. }
  742. }
  743. .search {
  744. display: flex;
  745. align-items: center;
  746. justify-content: flex-end;
  747. width: 60%;
  748. .input-with-select {
  749. margin-left: 25px;
  750. }
  751. .upload {
  752. background: #2199f8;
  753. margin-left: 25px;
  754. }
  755. .add {
  756. background: #fff;
  757. color: #000;
  758. margin-left: 25px;
  759. }
  760. }
  761. }
  762. .content {
  763. width: 100%;
  764. height: calc(100% - 74px - 40px - 32px);
  765. box-sizing: border-box;
  766. background: #101010;
  767. padding: 13px 20px 20px 20px;
  768. .search-form {
  769. height: 40px;
  770. margin: 5px 0;
  771. display: flex;
  772. // justify-content: flex-end;
  773. justify-content: space-between;
  774. ::v-deep {
  775. .el-form-item__label {
  776. color: #fff;
  777. }
  778. .el-form-item__content {
  779. width: 190px;
  780. }
  781. .el-input__wrapper {
  782. background: #101010;
  783. box-shadow: none;
  784. border: 1px solid rgba(255, 255, 255, 0.7);
  785. .el-input__inner {
  786. color: #fff;
  787. }
  788. }
  789. }
  790. .button {
  791. display: flex;
  792. .btn {
  793. width: 84px;
  794. &.reset {
  795. margin-left: 25px;
  796. }
  797. }
  798. }
  799. }
  800. .box {
  801. border: 1px solid rgba(255, 255, 255, 0.4);
  802. border-radius: 8px;
  803. padding: 20px;
  804. box-sizing: border-box;
  805. background: #232323;
  806. width: 100%;
  807. height: calc(100% - 50px);
  808. position: relative;
  809. .map-box {
  810. width: 100%;
  811. height: 100%;
  812. border-radius: 4px;
  813. border: 1px solid rgba(255, 255, 255, 0.4);
  814. .map {
  815. width: 100%;
  816. height: 100%;
  817. }
  818. }
  819. .tool-group {
  820. position: absolute;
  821. display: flex;
  822. right: calc(500px + 36px);
  823. top: 42px;
  824. .btn {
  825. background: #fff;
  826. color: #000;
  827. margin-right: 10px;
  828. }
  829. .delete {
  830. background: #e45c5c;
  831. color: #fff;
  832. }
  833. }
  834. .edit-popup {
  835. width: 500px;
  836. height: calc(100% - 53px - 20px);
  837. position: absolute;
  838. top: 36px;
  839. right: 36px;
  840. border: 1px solid rgba(255, 255, 255, 0.4);
  841. border-radius: 8px;
  842. background: #232323;
  843. .edit-title {
  844. padding: 0 10px;
  845. background: rgba(68, 68, 68, 0.4);
  846. border-bottom: 1px solid rgba(68, 68, 68, 0.4);
  847. display: flex;
  848. align-items: center;
  849. justify-content: space-between;
  850. .btn-group {
  851. display: flex;
  852. .ml {
  853. margin-left: 20px;
  854. }
  855. }
  856. .name {
  857. display: flex;
  858. padding: 12px 0px;
  859. align-items: center;
  860. }
  861. span {
  862. margin-left: 8px;
  863. font-size: 18px;
  864. font-family: "SOURCEHANTIFINE";
  865. }
  866. .edit {
  867. color: #2199f8;
  868. padding: 6px 20px;
  869. border: 1px solid #2199f8;
  870. border-radius: 4px;
  871. cursor: pointer;
  872. }
  873. }
  874. .edit-cont {
  875. padding: 16px;
  876. width: calc(100% - 32px);
  877. height: calc(100% - 64px - 84px);
  878. .form-inline {
  879. height: 320px;
  880. &.no-area {
  881. height: 260px;
  882. }
  883. ::v-deep {
  884. .el-input {
  885. width: 200px;
  886. --el-input-placeholder-color: #666666;
  887. }
  888. .el-form-item__label {
  889. color: #bbbbbb;
  890. }
  891. .el-input__wrapper {
  892. background: #232323;
  893. border: 1px solid #444444;
  894. box-shadow: none;
  895. .el-input__inner {
  896. color: #fff;
  897. }
  898. }
  899. }
  900. }
  901. .list-box {
  902. width: 100%;
  903. height: calc(100% - 320px);
  904. &.no-area {
  905. height: calc(100% - 260px);
  906. }
  907. span {
  908. color: #bbbbbb;
  909. }
  910. .list-cont {
  911. width: 100%;
  912. height: calc(100% - 20px);
  913. border-radius: 4px;
  914. margin-top: 5px;
  915. background: rgba(68, 68, 68, 0.4);
  916. padding: 12px 16px;
  917. box-sizing: border-box;
  918. overflow-y: auto;
  919. .list-item {
  920. width: 100%;
  921. margin-bottom: 8px;
  922. display: flex;
  923. align-items: center;
  924. .item-box {
  925. padding: 8px;
  926. border: 1px solid #444444;
  927. border-radius: 4px;
  928. margin-left: 10px;
  929. }
  930. }
  931. }
  932. }
  933. }
  934. .edit-footer {
  935. width: 100%;
  936. height: 64px;
  937. display: flex;
  938. align-items: center;
  939. justify-content: flex-end;
  940. box-sizing: border-box;
  941. padding: 12px 16px;
  942. border-top: 1px solid rgba(68, 68, 68, 0.4);
  943. background: rgba(68, 68, 68, 0.4);
  944. .btn {
  945. padding: 10px 35px;
  946. }
  947. .cancel {
  948. border: 1px solid rgba(255, 255, 255, 0.4);
  949. margin-right: 16px;
  950. }
  951. .save {
  952. background: #2199f8;
  953. }
  954. }
  955. }
  956. }
  957. }
  958. }
  959. .dialog-footer {
  960. .btn {
  961. width: 200px;
  962. height: 40px;
  963. }
  964. }
  965. </style>