Ssnyd copy.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  1. <template>
  2. <div class="page-gd-manage">
  3. <div v-show="menusShow" class="page-left" :style="{height:contentHeight+'px',width:menusWidth+'px'}">
  4. <div class="nzy-tools">
  5. <div class="panels">
  6. <div class="panel-dropdown" style="background: #F5FBFF">
  7. <el-dropdown>
  8. <div class="el-dropdown-link">
  9. <img src="@/assets/images/datamanage/sc.png"/>
  10. 导入文件
  11. <img src="@/assets/images/datamanage/sc-i.png"/>
  12. </div>
  13. <el-dropdown-menu slot="dropdown">
  14. <el-dropdown-item>
  15. <el-upload
  16. class="upload-demo"
  17. action=""
  18. :before-upload="beforeUpload"
  19. multiple
  20. :limit="3"
  21. :on-exceed="2"
  22. accept=".zip">
  23. &nbsp;&nbsp;批量导入&nbsp;&nbsp;
  24. </el-upload>
  25. </el-dropdown-item>
  26. </el-dropdown-menu>
  27. </el-dropdown>
  28. </div>
  29. <div class="panel-dropdown" style="background: #FFFBF1">
  30. <el-dropdown>
  31. <div class="el-dropdown-link">
  32. <img src="@/assets/images/datamanage/xz.png"/>
  33. 导出文件
  34. <img src="@/assets/images/datamanage/xz-i.png"/>
  35. </div>
  36. <el-dropdown-menu slot="dropdown">
  37. <el-dropdown-item>
  38. <div @click="doExportExcel">
  39. 导出项目Excel
  40. </div>
  41. </el-dropdown-item>
  42. </el-dropdown-menu>
  43. </el-dropdown>
  44. </div>
  45. </div>
  46. <div class="panels">
  47. <div class="panel-input">
  48. <span>批准文号:</span>
  49. <el-input v-model="paramsList.dkbh" placeholder="请输入内容" clearable></el-input>
  50. </div>
  51. <div class="panel-input">
  52. <span>关键字:</span>
  53. <el-input v-model="paramsList.dkmc" placeholder="项目名称/用地单位名称/所属板块" clearable></el-input>
  54. </div>
  55. </div>
  56. <div class="panels">
  57. <div class="panel-input">
  58. <span>绘制范围:</span>
  59. <div class="fw" title="框选绘制" @click="createBoxEvent">
  60. <i style="font-size: 20px" class="iconfont yh-Frame"/>
  61. </div>
  62. <div class="fw" title="自定义绘制" @click="createDrawInteraction">
  63. <i style="font-size: 24px" class="iconfont yh-huizhi1"/>
  64. </div>
  65. <div class="fw" title="图斑拾取" @click="sqFeatrue">
  66. <i style="font-size: 24px" class="iconfont yh-shiqu"/>
  67. </div>
  68. <div class="fw" title="清除绘制" @click="clearLayer">
  69. 清除
  70. </div>
  71. </div>
  72. <div class="panel-input">
  73. <span>缓冲距离:</span>
  74. <el-input placeholder="请输入内容" v-model="input2">
  75. <template slot="append">米</template>
  76. </el-input>
  77. <el-button type="primary" style="margin-left: 8px;height: 36px" @click="getBpxmList">查询</el-button>
  78. </div>
  79. </div>
  80. </div>
  81. <div class="nzy-table">
  82. <el-table
  83. border
  84. :data="tableData.data"
  85. :height="contentHeight-260"
  86. :header-cell-style="tableHeaderStyle"
  87. :cell-style="tableRowStyle"
  88. :row-click="rowClick"
  89. ref="report-table"
  90. >
  91. <el-table-column
  92. type="index"
  93. width="80"
  94. label="序号"/>
  95. <el-table-column
  96. prop="pzwh"
  97. width="100"
  98. label="临时用地批准文号"/>
  99. <el-table-column
  100. prop="xmmc"
  101. label="建设项目名称"
  102. />
  103. <el-table-column
  104. prop="pzsj"
  105. label="用地批准时间">
  106. <template slot-scope="scope">
  107. {{new Date(scope.row.pzsj).toLocaleDateString("af")}}
  108. </template>
  109. </el-table-column>
  110. <el-table-column
  111. width="150"
  112. label="操作">
  113. <template slot-scope="scope">
  114. <div style="line-height: 34px;">
  115. <el-button
  116. @click.native.prevent="openDetail(scope.$index, scope.row)"
  117. plain
  118. type="primary"
  119. size="mini">
  120. 查看
  121. </el-button>
  122. <el-button
  123. @click.native.prevent="locationDk(scope.$index, scope.row)"
  124. plain
  125. type="success"
  126. size="mini">
  127. 定位
  128. </el-button>
  129. </div>
  130. </template>
  131. </el-table-column>
  132. </el-table>
  133. <Page style="float: right;margin-top: 10px;"
  134. show-total
  135. :total="paramsList.total"
  136. :page-size="paramsList.size"
  137. @on-change="pageChange"
  138. @on-page-size-change="sizeChange"
  139. show-sizer />
  140. </div>
  141. </div>
  142. <div @click="()=>{menusWidth =0;menusShow=false;detailShow=false;$refs.baseMap.resetSize();}"
  143. style="top: calc(50% - 30px);left: calc( 700px - 20px);"
  144. title="收起"
  145. v-show="menusShow"
  146. class="menus-open"
  147. >
  148. <i class="iconfont yh-Frame2"/>
  149. </div>
  150. <div @click="()=>{menusWidth =700;menusShow=true;$refs.baseMap.resetSize();}"
  151. style="top: calc(50% - 30px);left: 0px;"
  152. title="展开"
  153. v-show="!menusShow"
  154. class="menus-open"
  155. >
  156. <!-- <img src="@/assets/images/datamanage/zd.png"/>-->
  157. <i class="iconfont yh-xiangyou"/>
  158. </div>
  159. <div v-show="detailShow" class="page-detail" :style="{height:contentHeight+'px',width:contentWidth-menusWidth+'px',left:menusWidth+'px'}">
  160. <detail ref="details" @initBpxm="getBpxmList" :contentWidth="contentWidth-menusWidth" :contentHeight="contentHeight" :project="currProject"/>
  161. </div>
  162. <div @click="()=>{detailShow=false;}"
  163. style="top: calc(50% - 30px);right: 0px"
  164. title="展开"
  165. v-show="detailShow"
  166. class="menus-open"
  167. >
  168. <i class="iconfont yh-Frame2"/>
  169. </div>
  170. <div class="page-map" :style="{height:contentHeight+'px',width: contentWidth-menusWidth-30+'px'}" >
  171. <base-map ref="baseMap" :overlayShow="true" @showDetail="showDetail" @drawShapeJson="drawShapeJsonEvent" :visibleLayerIds="visibleLayerId"/>
  172. </div>
  173. </div>
  174. </template>
  175. <script>
  176. import mapshaper from "mapshaper";
  177. import BaseMap from "../../components/common/BaseMap";
  178. import Detail from "./ssnyd/Detail";
  179. const {
  180. importContent,
  181. setDatasetCRS,
  182. exportFileContent
  183. } = mapshaper.internal
  184. export default {
  185. name: "Lsyd",
  186. props:{
  187. contentWidth:Number,
  188. contentHeight:Number
  189. },
  190. components:{BaseMap,Detail},
  191. data() {
  192. return {
  193. compName: 'data-manage',
  194. visibleLayerId:['YHYZT_SSNYD'],
  195. menus:JSON.parse(window.sessionStorage.getItem('yzt-user')),
  196. menusWidth:700,
  197. menusShow:true,
  198. detailShow:false,
  199. tableData:{
  200. data:[],
  201. },
  202. currProject:null,
  203. paramsList:{dkbh:'',dkmc:'',page:1,size:15,total:0},
  204. fullscreenLoading: false,
  205. drawShapeJson:null,
  206. }
  207. },
  208. mounted(){
  209. this.getBpxmList();
  210. },
  211. methods: {
  212. createBoxEvent(){
  213. this.$refs.baseMap.createBoxEvent();
  214. },
  215. sqFeatrue(){
  216. this.$refs.baseMap.sqFeatrue();
  217. },
  218. //自定义绘制分析
  219. createDrawInteraction(){
  220. this.$refs.baseMap.drawInteractionEvent();
  221. },
  222. //清除绘制图层
  223. clearLayer(){
  224. this.$refs.baseMap.cleanLayer();
  225. this.drawShapeJson = null;
  226. this.getBpxmList();
  227. },
  228. drawShapeJsonEvent(json){
  229. if(json){
  230. this.drawShapeJson = json;
  231. this.getBpxmList();
  232. this.$message.success("绘制结束");
  233. }
  234. },
  235. pageChange:function (page){
  236. this.paramsList.page=page;
  237. this.getBpxmList()
  238. },
  239. sizeChange:function (size){
  240. this.paramsList.size=size;
  241. this.getBpxmList()
  242. },
  243. //查询报批项目信息
  244. getBpxmList(){
  245. let params = new FormData();
  246. params.append("page",this.paramsList.page);
  247. params.append("size",this.paramsList.size);
  248. params.append("dkbh",this.paramsList.dkbh);
  249. params.append("dkmc",this.paramsList.dkmc);
  250. if(this.drawShapeJson){
  251. params.append("shapes",JSON.stringify(this.drawShapeJson));
  252. }
  253. let _this = this;
  254. this.$ajax.post('/api/data/manage/ssnyd/getList', params, this, true).then(res => {
  255. const {success,data} = res;
  256. if(success){
  257. _this.tableData.data =[];
  258. _this.paramsList.total=0;
  259. if(data.list){
  260. _this.tableData.data= data.list;
  261. _this.paramsList.total = data.total;
  262. }
  263. }
  264. })
  265. },
  266. rowClick(row, column, event){
  267. this.currProject = row;
  268. this.detailShow =true;
  269. },
  270. openDetail(index,row){
  271. this.currProject = row;
  272. this.detailShow =true;
  273. this.$refs.details.activeName='first';
  274. },
  275. showDetail(item){
  276. let params = new FormData();
  277. params.append("guid",item.index_id);
  278. this.$ajax.post('/api/data/manage/gd/getGdDetail', params, this, true).then(res => {
  279. const {success,data} = res;
  280. if(success){
  281. this.openDetail(0,data);
  282. }
  283. })
  284. },
  285. locationDk(index,row){
  286. if(row.objectid){
  287. this.detailShow = false;
  288. let dkbhArr = row.objectid?row.objectid:'';
  289. let arr = "'"+dkbhArr+"'";
  290. this.$vm.$emit('locationGlobal', this.visibleLayerId[0], `objectid in (${arr})`)
  291. //this.$message.warning("暂无图形")
  292. }
  293. },
  294. tableRowStyle({row, rowIndex}) {
  295. if (rowIndex%2 === 1) {
  296. return 'text-align:center;background:#F7F8FA';
  297. }else{
  298. return 'text-align:center;';
  299. }
  300. },
  301. tableHeaderStyle(){
  302. return 'background:#E5EDFE; font-family:AlibabaPuHuiTiR; font-size:16px; color:rgba(51, 51, 51, 1);text-align:center;';
  303. },
  304. beforeUpload(file){
  305. if(file){
  306. if(file.name.endsWith("zip")){
  307. this.doInput(file)
  308. }
  309. return false;
  310. }
  311. },
  312. //处理内容变化记录信息
  313. recordInfo(type,name,content){
  314. let info = {};
  315. info.re_recorder = this.menus.userInfo.orgName;
  316. info.table_type = '设施农用地导入';
  317. info.re_content='';
  318. let _this = this;
  319. info.re_name = name;
  320. if(type=='input'){
  321. info.re_content ='导入项目文件名:'+content;
  322. }else{
  323. info.re_content ='导出文件名:'+content;
  324. }
  325. let params = new FormData();
  326. params.append('data',JSON.stringify(info))
  327. //执行持久化操作(记录入库)
  328. this.$ajax.post('/api/opera/record/insert',params, this, true).then(res => {
  329. const {success,data} = res;
  330. if(success){
  331. this.$message.success("操作成功!")
  332. }else{
  333. this.$message.error("操作失败!")
  334. }
  335. })
  336. },
  337. doInput(file){
  338. let params = new FormData();
  339. params.append("file",file);
  340. let _this = this;
  341. const loading = this.$loading({
  342. lock: true,
  343. text: '正在导入中',
  344. spinner: 'el-icon-loading',
  345. background: 'rgba(0, 0, 0, 0.7)'
  346. });
  347. this.$ajax.post('/api/data/upload/ssnyd/zip', params, this).then(res => {
  348. const {success,data} = res;
  349. loading.close();
  350. if(success && data){
  351. this.recordInfo("input",'设施农用地成果导入',file.name);
  352. }
  353. })
  354. },
  355. doExportExcel(){
  356. try {
  357. const $e = this.$refs['report-table'].$el
  358. let $table = $e.querySelector('.el-table__fixed')
  359. if(!$table) {
  360. $table = $e
  361. }
  362. const wb = XLSX.utils.table_to_book($table, {raw:true})
  363. const wbout = XLSX.write(wb, {bookType: 'xlsx', bookSST:true, type: 'array'})
  364. saveAs(
  365. new Blob([wbout],{type: 'application/octet-stream'}),
  366. `设施农用地列表.xlsx`,
  367. )
  368. this.recordInfo("export","设施农用地导出","设施农用地列表.xlsx")
  369. } catch (e) {
  370. if (typeof console !== 'undefined') console.error(e)
  371. }
  372. },
  373. doExport(){
  374. let params = new FormData();
  375. params.append("dkbh",this.paramsList.dkbh);
  376. params.append("dkmc",this.paramsList.dkmc);
  377. if(this.drawShapeJson){
  378. params.append("shapes",JSON.stringify(this.drawShapeJson));
  379. }
  380. const loading = this.$loading({
  381. lock: true,
  382. text: '正在导出',
  383. spinner: 'el-icon-loading',
  384. background: 'rgba(0, 0, 0, 0.7)'
  385. });
  386. this.$ajax.post('/api/data/manage/gd/exportGdShapeFile', params, this).then(res => {
  387. const {success, data} = res;
  388. if(success){
  389. if(data.length<=0) {
  390. loading.close();
  391. return;
  392. };
  393. const geos = {
  394. 'type': 'FeatureCollection',
  395. 'features': []
  396. }
  397. data.map(i=>{
  398. let geoT = {
  399. type: 'Feature',
  400. geometry: {},
  401. properties: {}
  402. }
  403. const geo = WkxGeometry.parse(i.geomText).toGeoJSON()
  404. geoT.geometry = { ...geo }
  405. delete i.shape
  406. delete i.geomText
  407. geoT['properties'] = i
  408. geos.features.push(geoT)
  409. })
  410. const dataset = importContent({ json: { filename: '供地项目.json', content: JSON.stringify(geos) }})
  411. setDatasetCRS(dataset, { prj: 'GEOGCS["GCS_China_Geodetic_Coordinate_System_2000",DATUM["D_China_2000",SPHEROID["CGCS2000",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]' })
  412. this.saveDataset(dataset);
  413. loading.close();
  414. }else{
  415. this.$Message.error("查询异常,请联系管理员!");
  416. loading.close();
  417. }
  418. })
  419. },
  420. saveDataset(dataset, type = 'shapefile') {
  421. const fileContent = exportFileContent(dataset, { format: type })
  422. this.saveFileContent(fileContent)
  423. },
  424. saveFileContent(fileContent) {
  425. var zip = new JSZip()
  426. fileContent.forEach(i => {
  427. zip.file(i.filename, i.content)
  428. })
  429. zip.file('供地项目.cpg', 'UTF-8')
  430. zip.generateAsync({ type: 'blob' }, function updateCallback(metadata) {
  431. var msg = 'progression : ' + metadata.percent.toFixed(2) + ' %'
  432. if (metadata.currentFile) {
  433. msg += ', current file = ' + metadata.currentFile
  434. }
  435. console.log(msg)
  436. }).then((blob) => {
  437. // see FileSaver.js
  438. saveAs(blob, '供地项目.zip')
  439. console.log('done !')
  440. })
  441. .catch(error => console.error(error.stack))
  442. },
  443. }
  444. }
  445. </script>
  446. <style scoped lang="scss">
  447. .page-gd-manage{
  448. position: relative;
  449. display: flex;
  450. .page-left{
  451. background: #fff;
  452. border-radius: 0px 0px 0px 0px;
  453. z-index: 99;
  454. padding: 20px;
  455. border-right:2px solid #e9e3e3;
  456. .nzy-tools{
  457. .panels{
  458. width: 100%;
  459. display: flex;
  460. justify-content: space-between;
  461. align-items: center;
  462. margin-bottom: 20px;
  463. }
  464. .panel-dropdown{
  465. width: 49%;
  466. border-radius: 4px 4px 4px 4px;
  467. .el-dropdown{
  468. width: 100%;
  469. .el-dropdown-link{
  470. cursor: pointer;
  471. width: 100%;
  472. display: flex;
  473. align-items: center;
  474. justify-content: space-around;
  475. font-family: AlibabaPuHuiTiM;
  476. font-weight: normal;
  477. font-size: 16px;
  478. color: #3C4859;
  479. line-height: 20px;
  480. text-align: center;
  481. }
  482. }
  483. }
  484. .panel-input{
  485. width: 49%;
  486. display: flex;
  487. align-items: center;
  488. justify-content: center;
  489. span{
  490. font-family: AlibabaPuHuiTiM;
  491. font-size: 14px;
  492. color: #404A5B;
  493. text-align: center;
  494. width: 130px;
  495. }
  496. .fw{
  497. width: 60px;
  498. height: 36px;
  499. display: flex;
  500. justify-content: center;
  501. align-items: center;
  502. border-radius: 4px;
  503. border: 1px solid #CCD1DC;
  504. color: #446AE7;
  505. margin-left: 8px;
  506. cursor: pointer;
  507. }
  508. ::v-deep{
  509. .el-input__inner{
  510. height: 36px;
  511. line-height: 36px;
  512. }
  513. }
  514. }
  515. }
  516. }
  517. .page-detail{
  518. background: #FFFFFF;
  519. border-radius: 0px 0px 0px 0px;
  520. position: absolute;
  521. z-index: 999;
  522. right: 0px;
  523. }
  524. .menus-open{
  525. width: 32px;
  526. height: 62px;
  527. background: #E8EEFF;
  528. box-shadow: 0px 2px 2px 0px rgba(55,90,178,0.2);
  529. border-radius: 4px 0px 0px 4px;
  530. display: flex;
  531. align-items: center;
  532. justify-content: center;
  533. border-radius: 6px;
  534. position: absolute;
  535. cursor: pointer;
  536. z-index: 999;
  537. i{
  538. color: #4880FF;
  539. font-size: 26px;
  540. }
  541. }
  542. .page-map{
  543. //position: absolute;
  544. //background:#434;
  545. }
  546. }
  547. </style>