123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411 |
- <template>
- <div class="page-nzy-manage">
- <div class="page-left" :style="{height:contentHeight+'px',width:contentWidth+'px'}">
- <div class="nzy-tools">
- <el-form label-width="120px" :model="searchParam">
- <el-row :gutter="10">
- <el-col :span="6">
- <el-form-item label="批次索引:">
- <el-input v-model="searchParam.pcbh" placeholder="请输入批次索引" clearable></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="批次名称:">
- <el-input v-model="searchParam.pch" placeholder="请输入项目名称" clearable></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="类型:">
- <el-select v-model="searchParam.lx" style="width: 100%;">
- <el-option value="" label="全部" />
- <el-option value="单独选址" label="单独选址" />
- <el-option value="批次用地" label="批次用地" />
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="批准文号:">
- <el-input v-model="searchParam.pwh" placeholder="请输入批准文号" clearable></el-input>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="10">
- <el-col :span="6">
- <el-form-item label="批准日期:">
- <el-date-picker
- v-model="pcrqDateRange"
- type="daterange"
- value-format="yyyy-MM-dd"
- unlink-panels
- start-placeholder="批准开始时间"
- end-placeholder="批准结束时间"
- :shortcuts="shortcuts"
- style="width:100%"
- />
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="批次总面积:">
- <el-input v-model="searchParam.pzmj" placeholder="请输入批次总面积(公顷)" clearable></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="是否农民建房:">
- <el-select style="width: 100%;" v-model="searchParam.nmjf">
- <el-option value="是" label="是"></el-option>
- <el-option value="否" label="否"></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <div class="btn-group">
- <el-button type="primary" @click="onSearchHandle">查询</el-button>
- <el-button type="info" @click="onResetHandle">清空</el-button>
- <el-upload
- class="upload-demo"
- action=""
- :before-upload="beforeUpload"
- multiple
- :limit="3"
- :on-exceed="2"
- accept=".zip"
- style="display:inline-block; margin-left: 10px;"
- >
- <el-button type="success">
- 导入文件
- </el-button>
- </el-upload>
- <el-button type="warning" @click="downloadTemplate" style="margin-left: 12px">模板下载</el-button>
- </div>
- </el-col>
- </el-row>
- </el-form>
- </div>
- <div class="nzy-table">
- <el-table
- border
- :data="tableData.data"
- :height="contentHeight-260"
- :header-cell-style="tableHeaderStyle"
- :cell-style="tableRowStyle"
- ref="report-table"
- >
- <el-table-column
- type="index"
- width="80"
- label="序号">
- </el-table-column>
- <el-table-column
- prop="pcbh"
- label="批次索引">
- </el-table-column>
- <el-table-column
- prop="pch"
- label="批次名称">
- </el-table-column>
- <el-table-column
- prop="lx"
- label="类型">
- </el-table-column>
- <el-table-column
- prop="pwh"
- label="批准文号">
- </el-table-column>
- <el-table-column
- prop="pzrq"
- label="批准日期">
- </el-table-column>
- <el-table-column
- prop="pzmj"
- label="批准总面积(公顷)">
- </el-table-column>
- <el-table-column
- prop="nmjf"
- label="是否农民建房">
- </el-table-column>
- <el-table-column
- width="260"
- label="操作">
- <template slot-scope="scope">
- <div style="line-height: 34px;">
- <el-button
- @click.native.prevent="openDetail(scope.row)"
- plain
- type="primary"
- size="mini">
- 查看
- </el-button>
- <el-button
- @click.native.prevent="openDetail(scope.row, true)"
- style="margin: 0px 10px;"
- plain
- type="primary"
- size="mini">
- 编辑
- </el-button>
- <el-popconfirm
- title="该条数据确定删除吗?"
- @confirm="deleteHandle(scope.$index, scope.row)"
- >
- <el-button
- plain
- type="danger"
- slot="reference"
- size="mini">
- 删除
- </el-button>
- </el-popconfirm>
- </div>
- </template>
- </el-table-column>
- </el-table>
- <Page style="float: right;margin-top: 10px;"
- show-total
- :total="tableData.total"
- :page-size="searchParam.size"
- @on-change="pageChange"
- @on-page-size-change="sizeChange"
- show-sizer />
- </div>
- </div>
- <el-dialog
- :visible.sync="detailShow"
- title="项目详情"
- top="5vh"
- width="80%"
- >
- <detail ref="details" @init="onSearchHandle" :contentWidth="contentWidth-menusWidth" :contentHeight="contentHeight"/>
- </el-dialog>
- </div>
- </template>
- <script>
- import Detail from "./nzy/Detail";
- import JSZip from 'jszip'
- import mapshaper from 'mapshaper';
- import { saveAs } from 'file-saver'
- const {
- exportFileContent
- } = mapshaper.internal
- export default {
- name: "Nzy",
- props:{
- contentWidth:Number,
- contentHeight:Number
- },
- components:{Detail},
- data() {
- return {
- menus:JSON.parse(window.sessionStorage.getItem('yzt-user')),
- menusWidth:700,
- detailShow:false,
- tableData:{
- data:[],
- },
- pcrqDateRange: [],
- searchParam: {
- pcbh: '',
- pch: '',
- lx: '',
- pwh: '',
- pzrqStart: '',
- pzrqEnd: '',
- pzmj: '',
- nmjf: '',
- current: 1,
- size: 10
- }
- }
- },
- created () {
- this.queryByPage();
- },
- methods: {
- onSearchHandle () {
- this.detailShow = false
- this.searchParam['current'] = 1
- this.queryByPage()
- },
- pageChange:function (page){
- this.searchParam.current=page;
- this.queryByPage()
- },
- sizeChange:function (size){
- this.searchParam.size=size;
- this.queryByPage()
- },
- //查询报批项目信息
- queryByPage () {
- let _this = this;
- if (this.pcrqDateRange && this.pcrqDateRange.length > 0) {
- this.searchParam.pzrqStart = this.pcrqDateRange[0]
- this.searchParam.pzrqEnd = this.pcrqDateRange[1]
- } else {
- this.searchParam.pzrqStart = ''
- this.searchParam.pzrqEnd = ''
- }
- const params = {
- ...this.searchParam
- }
- if (params['pwh']) {
- params['pwh'] = encodeURI(this.searchParam['pwh'])
- }
- this.$ajax.get('/api/stnzy/page', params, this, true).then(res => {
- if (res.status === 200) {
- _this.tableData.data= res.records;
- _this.tableData.total = res.total;
- }
- })
- },
- openDetail(row, isEditor = false){
- this.detailShow = true;
- this.$nextTick(() => {
- this.$refs['details'].initDetailData(row, isEditor)
- })
- },
- deleteHandle (index, row) {
- const params = {pch: row['pch']}
- this.$ajax.get('/api/stnzy/deleteByPch', params, this, true).then(res => {
- if (res) {
- this.$Message.success('删除成功!')
- this.queryByPage()
- }
- })
- },
- tableRowStyle({row, rowIndex}) {
- if (rowIndex%2 === 1) {
- return 'text-align:center;background:#F7F8FA';
- }else{
- return 'text-align:center;';
- }
- },
- tableHeaderStyle(){
- return 'background:#E5EDFE; font-family:AlibabaPuHuiTiR; font-size:16px; color:rgba(51, 51, 51, 1);text-align:center;';
- },
- beforeUpload(file){
- if(file){
- if(file.name.endsWith("zip")){
- this.doInput(file)
- }
- return false;
- }
- },
- doInput(file){
- let params = new FormData();
- params.append("file", file);
- const loading = this.$loading({
- lock: true,
- text: '正在导入中',
- spinner: 'el-icon-loading',
- background: 'rgba(0, 0, 0, 0.7)'
- });
- this.$ajax.post('/api/stnzy/upload', params, this).then(res => {
- loading.close();
- if (res.success) {
- this.$Message.success("导入成功!");
- if (Array.isArray(res.data)) {
- res.data.forEach(pcbh => {
- this.$ajax.get('/api/pewg/importFromNzydk', { pcbh }, this).then((res) => {
- // 可选:每个导入后提示
- this.$Message.success(`pcbh: ${pcbh} 导入批而未供成功:${res.data}`);
- }).catch(() => {
- this.$Message.error(`pcbh: ${pcbh} 导入批而未供失败`);
- });
- });
- }
- this.queryByPage && this.queryByPage(); // 成功后刷新数据
- } else {
- if (res.data && Array.isArray(res.data)) {
- res.data.forEach(msg => this.$Message.error(msg));
- } else {
- this.$Message.error(res.message || "导入失败!");
- }
- }
- }).catch(error => {
- loading.close();
- this.$Message.error("上传失败,请重试!");
- console.error(error);
- });
- },
- saveDataset(dataset, type = 'shapefile') {
- const fileContent = exportFileContent(dataset, { format: type })
- this.saveFileContent(fileContent)
- },
- saveFileContent(fileContent) {
- var zip = new JSZip()
- fileContent.forEach(i => {
- zip.file(i.filename, i.content)
- })
- zip.file('农转用项目.cpg', 'UTF-8')
- zip.generateAsync({ type: 'blob' }, function updateCallback(metadata) {
- var msg = 'progression : ' + metadata.percent.toFixed(2) + ' %'
- if (metadata.currentFile) {
- msg += ', current file = ' + metadata.currentFile
- }
- console.log(msg)
- }).then((blob) => {
- // see FileSaver.js
- saveAs(blob, '农转用项目.zip')
- console.log('done !')
- })
- .catch(error => console.error(error.stack))
- },
- downloadTemplate() {
- // 模板下载地址
- window.open(window.ApplicationConfig.templateUrls.nzy);
- },
- onResetHandle() {
- this.searchParam = {
- pcbh: '',
- pch: '',
- lx: '',
- pwh: '',
- pzrqStart: '',
- pzrqEnd: '',
- pzmj: '',
- nmjf: '',
- current: 1,
- size: 10
- };
- this.pcrqDateRange = [];
- }
- }
- }
- </script>
- <style scoped lang="scss">
- .page-nzy-manage{
- position: relative;
- display: flex;
- .page-left{
- background: #fff;
- border-radius: 0px 0px 0px 0px;
- z-index: 99;
- padding: 20px;
- border-right:2px solid #e9e3e3;
- .nzy-tools{
- .btn-group {
- display: flex;
- }
- .panel-dropdown{
- margin-left: 10px;
- border-radius: 4px 4px 4px 4px;
- .el-dropdown{
- width: 100%;
- }
- }
- }
- }
- .page-detail{
- background: #FFFFFF;
- border-radius: 0px 0px 0px 0px;
- position: absolute;
- z-index: 999;
- right: 0px;
- }
- .page-map{
- //position: absolute;
- //background:#434;
- }
- }
- </style>
|