Nzy.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. <template>
  2. <div class="page-nzy-manage">
  3. <div class="page-left" :style="{height:contentHeight+'px',width:contentWidth+'px'}">
  4. <div class="nzy-tools">
  5. <el-form label-width="120px" :model="searchParam">
  6. <el-row :gutter="10">
  7. <el-col :span="6">
  8. <el-form-item label="批次索引:">
  9. <el-input v-model="searchParam.pcbh" placeholder="请输入批次索引" clearable></el-input>
  10. </el-form-item>
  11. </el-col>
  12. <el-col :span="6">
  13. <el-form-item label="批次名称:">
  14. <el-input v-model="searchParam.pch" placeholder="请输入项目名称" clearable></el-input>
  15. </el-form-item>
  16. </el-col>
  17. <el-col :span="6">
  18. <el-form-item label="类型:">
  19. <el-select v-model="searchParam.lx" style="width: 100%;">
  20. <el-option value="" label="全部" />
  21. <el-option value="单独选址" label="单独选址" />
  22. <el-option value="批次用地" label="批次用地" />
  23. </el-select>
  24. </el-form-item>
  25. </el-col>
  26. <el-col :span="6">
  27. <el-form-item label="批准文号:">
  28. <el-input v-model="searchParam.pwh" placeholder="请输入批准文号" clearable></el-input>
  29. </el-form-item>
  30. </el-col>
  31. </el-row>
  32. <el-row :gutter="10">
  33. <el-col :span="6">
  34. <el-form-item label="批准日期:">
  35. <el-date-picker
  36. v-model="pcrqDateRange"
  37. type="daterange"
  38. value-format="yyyy-MM-dd"
  39. unlink-panels
  40. start-placeholder="批准开始时间"
  41. end-placeholder="批准结束时间"
  42. :shortcuts="shortcuts"
  43. style="width:100%"
  44. />
  45. </el-form-item>
  46. </el-col>
  47. <el-col :span="6">
  48. <el-form-item label="批次总面积:">
  49. <el-input v-model="searchParam.pzmj" placeholder="请输入批次总面积(公顷)" clearable></el-input>
  50. </el-form-item>
  51. </el-col>
  52. <el-col :span="6">
  53. <el-form-item label="是否农民建房:">
  54. <el-select style="width: 100%;" v-model="searchParam.nmjf">
  55. <el-option value="是" label="是"></el-option>
  56. <el-option value="否" label="否"></el-option>
  57. </el-select>
  58. </el-form-item>
  59. </el-col>
  60. <el-col :span="6">
  61. <div class="btn-group">
  62. <el-button type="primary" @click="onSearchHandle">查询</el-button>
  63. <div class="panel-dropdown">
  64. <el-dropdown>
  65. <el-button type="success">
  66. 导入文件<i class="el-icon-arrow-down el-icon--right"></i>
  67. </el-button>
  68. <el-dropdown-menu slot="dropdown">
  69. <el-dropdown-item>
  70. <el-upload
  71. class="upload-demo"
  72. action=""
  73. :before-upload="beforeUpload"
  74. multiple
  75. :limit="3"
  76. :on-exceed="2"
  77. accept=".zip">
  78. 批量导入&nbsp;&nbsp;
  79. </el-upload>
  80. </el-dropdown-item>
  81. </el-dropdown-menu>
  82. </el-dropdown>
  83. </div>
  84. <el-button type="primary" @click="downloadTemplate" style="margin-left: 12px">模板下载</el-button>
  85. </div>
  86. </el-col>
  87. </el-row>
  88. </el-form>
  89. </div>
  90. <div class="nzy-table">
  91. <el-table
  92. border
  93. :data="tableData.data"
  94. :height="contentHeight-260"
  95. :header-cell-style="tableHeaderStyle"
  96. :cell-style="tableRowStyle"
  97. ref="report-table"
  98. >
  99. <el-table-column
  100. type="index"
  101. width="80"
  102. label="序号">
  103. </el-table-column>
  104. <el-table-column
  105. prop="pcbh"
  106. label="批次索引">
  107. </el-table-column>
  108. <el-table-column
  109. prop="pch"
  110. label="批次名称">
  111. </el-table-column>
  112. <el-table-column
  113. prop="lx"
  114. label="类型">
  115. </el-table-column>
  116. <el-table-column
  117. prop="pwh"
  118. label="批准文号">
  119. </el-table-column>
  120. <el-table-column
  121. prop="pzrq"
  122. label="批准日期">
  123. </el-table-column>
  124. <el-table-column
  125. prop="pzmj"
  126. label="批准总面积(公顷)">
  127. </el-table-column>
  128. <el-table-column
  129. prop="nmjf"
  130. label="是否农民建房">
  131. </el-table-column>
  132. <el-table-column
  133. width="260"
  134. label="操作">
  135. <template slot-scope="scope">
  136. <div style="line-height: 34px;">
  137. <el-button
  138. @click.native.prevent="openDetail(scope.row)"
  139. plain
  140. type="primary"
  141. size="mini">
  142. 查看
  143. </el-button>
  144. <el-button
  145. @click.native.prevent="openDetail(scope.row, true)"
  146. style="margin: 0px 10px;"
  147. plain
  148. type="primary"
  149. size="mini">
  150. 编辑
  151. </el-button>
  152. <el-popconfirm
  153. title="该条数据确定删除吗?"
  154. @confirm="deleteHandle(scope.$index, scope.row)"
  155. >
  156. <el-button
  157. plain
  158. type="danger"
  159. slot="reference"
  160. size="mini">
  161. 删除
  162. </el-button>
  163. </el-popconfirm>
  164. </div>
  165. </template>
  166. </el-table-column>
  167. </el-table>
  168. <Page style="float: right;margin-top: 10px;"
  169. show-total
  170. :total="tableData.total"
  171. :page-size="searchParam.size"
  172. @on-change="pageChange"
  173. @on-page-size-change="sizeChange"
  174. show-sizer />
  175. </div>
  176. </div>
  177. <el-dialog
  178. :visible.sync="detailShow"
  179. title="项目详情"
  180. top="5vh"
  181. width="80%"
  182. >
  183. <detail ref="details" @init="onSearchHandle" :contentWidth="contentWidth-menusWidth" :contentHeight="contentHeight"/>
  184. </el-dialog>
  185. </div>
  186. </template>
  187. <script>
  188. import Detail from "./nzy/Detail";
  189. import JSZip from 'jszip'
  190. import mapshaper from 'mapshaper';
  191. import { saveAs } from 'file-saver'
  192. const {
  193. exportFileContent
  194. } = mapshaper.internal
  195. export default {
  196. name: "Nzy",
  197. props:{
  198. contentWidth:Number,
  199. contentHeight:Number
  200. },
  201. components:{Detail},
  202. data() {
  203. return {
  204. menus:JSON.parse(window.sessionStorage.getItem('yzt-user')),
  205. menusWidth:700,
  206. detailShow:false,
  207. tableData:{
  208. data:[],
  209. },
  210. pcrqDateRange: [],
  211. searchParam: {
  212. pcbh: '',
  213. pch: '',
  214. lx: '',
  215. pwh: '',
  216. pzrqStart: '',
  217. pzrqEnd: '',
  218. pzmj: '',
  219. nmjf: '',
  220. current: 1,
  221. size: 10
  222. }
  223. }
  224. },
  225. created () {
  226. this.queryByPage();
  227. },
  228. methods: {
  229. onSearchHandle () {
  230. this.detailShow = false
  231. this.searchParam['current'] = 1
  232. this.queryByPage()
  233. },
  234. pageChange:function (page){
  235. this.searchParam.current=page;
  236. this.queryByPage()
  237. },
  238. sizeChange:function (size){
  239. this.searchParam.size=size;
  240. this.queryByPage()
  241. },
  242. //查询报批项目信息
  243. queryByPage () {
  244. let _this = this;
  245. if (this.pcrqDateRange && this.pcrqDateRange.length > 0) {
  246. this.searchParam.pzrqStart = this.pcrqDateRange[0]
  247. this.searchParam.pzrqEnd = this.pcrqDateRange[1]
  248. } else {
  249. this.searchParam.pzrqStart = ''
  250. this.searchParam.pzrqEnd = ''
  251. }
  252. const params = {
  253. ...this.searchParam
  254. }
  255. if (params['pwh']) {
  256. params['pwh'] = encodeURI(this.searchParam['pwh'])
  257. }
  258. this.$ajax.get('/api/stnzy/page', params, this, true).then(res => {
  259. if (res.status === 200) {
  260. _this.tableData.data= res.records;
  261. _this.tableData.total = res.total;
  262. }
  263. })
  264. },
  265. openDetail(row, isEditor = false){
  266. this.detailShow = true;
  267. this.$nextTick(() => {
  268. this.$refs['details'].initDetailData(row, isEditor)
  269. })
  270. },
  271. deleteHandle (index, row) {
  272. const params = {pch: row['pch']}
  273. this.$ajax.get('/api/stnzy/deleteByPch', params, this, true).then(res => {
  274. if (res) {
  275. this.$Message.success('删除成功!')
  276. this.queryByPage()
  277. }
  278. })
  279. },
  280. tableRowStyle({row, rowIndex}) {
  281. if (rowIndex%2 === 1) {
  282. return 'text-align:center;background:#F7F8FA';
  283. }else{
  284. return 'text-align:center;';
  285. }
  286. },
  287. tableHeaderStyle(){
  288. return 'background:#E5EDFE; font-family:AlibabaPuHuiTiR; font-size:16px; color:rgba(51, 51, 51, 1);text-align:center;';
  289. },
  290. beforeUpload(file){
  291. if(file){
  292. if(file.name.endsWith("zip")){
  293. this.doInput(file)
  294. }
  295. return false;
  296. }
  297. },
  298. doInput(file){
  299. let params = new FormData();
  300. params.append("file", file);
  301. const loading = this.$loading({
  302. lock: true,
  303. text: '正在导入中',
  304. spinner: 'el-icon-loading',
  305. background: 'rgba(0, 0, 0, 0.7)'
  306. });
  307. this.$ajax.post('/api/stnzy/upload', params, this).then(res => {
  308. loading.close();
  309. if (res.success) {
  310. this.$Message.success("导入成功!");
  311. if (Array.isArray(res.data)) {
  312. res.data.forEach(pcbh => {
  313. this.$ajax.get('/api/pewg/importFromNzydk', { pcbh }, this).then((res) => {
  314. // 可选:每个导入后提示
  315. this.$Message.success(`pcbh: ${pcbh} 导入批而未供成功:${res.data}`);
  316. }).catch(() => {
  317. this.$Message.error(`pcbh: ${pcbh} 导入批而未供失败`);
  318. });
  319. });
  320. }
  321. this.queryByPage && this.queryByPage(); // 成功后刷新数据
  322. } else {
  323. if (res.data && Array.isArray(res.data)) {
  324. res.data.forEach(msg => this.$Message.error(msg));
  325. } else {
  326. this.$Message.error(res.message || "导入失败!");
  327. }
  328. }
  329. }).catch(error => {
  330. loading.close();
  331. this.$Message.error("上传失败,请重试!");
  332. console.error(error);
  333. });
  334. },
  335. saveDataset(dataset, type = 'shapefile') {
  336. const fileContent = exportFileContent(dataset, { format: type })
  337. this.saveFileContent(fileContent)
  338. },
  339. saveFileContent(fileContent) {
  340. var zip = new JSZip()
  341. fileContent.forEach(i => {
  342. zip.file(i.filename, i.content)
  343. })
  344. zip.file('农转用项目.cpg', 'UTF-8')
  345. zip.generateAsync({ type: 'blob' }, function updateCallback(metadata) {
  346. var msg = 'progression : ' + metadata.percent.toFixed(2) + ' %'
  347. if (metadata.currentFile) {
  348. msg += ', current file = ' + metadata.currentFile
  349. }
  350. console.log(msg)
  351. }).then((blob) => {
  352. // see FileSaver.js
  353. saveAs(blob, '农转用项目.zip')
  354. console.log('done !')
  355. })
  356. .catch(error => console.error(error.stack))
  357. },
  358. downloadTemplate() {
  359. // 模板下载地址
  360. window.open(window.ApplicationConfig.templateUrls.nzy);
  361. }
  362. }
  363. }
  364. </script>
  365. <style scoped lang="scss">
  366. .page-nzy-manage{
  367. position: relative;
  368. display: flex;
  369. .page-left{
  370. background: #fff;
  371. border-radius: 0px 0px 0px 0px;
  372. z-index: 99;
  373. padding: 20px;
  374. border-right:2px solid #e9e3e3;
  375. .nzy-tools{
  376. .btn-group {
  377. display: flex;
  378. }
  379. .panel-dropdown{
  380. margin-left: 10px;
  381. border-radius: 4px 4px 4px 4px;
  382. .el-dropdown{
  383. width: 100%;
  384. }
  385. }
  386. }
  387. }
  388. .page-detail{
  389. background: #FFFFFF;
  390. border-radius: 0px 0px 0px 0px;
  391. position: absolute;
  392. z-index: 999;
  393. right: 0px;
  394. }
  395. .page-map{
  396. //position: absolute;
  397. //background:#434;
  398. }
  399. }
  400. </style>