Nzy.vue 12 KB

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