Commit 6f6af664 authored by wangjiankun's avatar wangjiankun

fix: 文件下载方法提取公共 楼盘详情导出按钮加loading 容积率去掉百分号

parent 3be6a545
...@@ -41,7 +41,6 @@ export function averagePosition(array) { ...@@ -41,7 +41,6 @@ export function averagePosition(array) {
} }
} }
// base64编码转BLOB对象 // base64编码转BLOB对象
export function dataURLtoBlob(dataurl) { export function dataURLtoBlob(dataurl) {
var arr = dataurl.split(','); var arr = dataurl.split(',');
var bstr = atob(arr[1]); var bstr = atob(arr[1]);
...@@ -53,7 +52,7 @@ export function dataURLtoBlob(dataurl) { ...@@ -53,7 +52,7 @@ export function dataURLtoBlob(dataurl) {
} }
return new Blob([u8arr], {type: mime }); return new Blob([u8arr], {type: mime });
} }
// 高得地图坐标转为百度地图坐标 // 高得地图坐标转为百度地图坐标 弃用
export function GDmapPositionTransform(lng, lat) { export function GDmapPositionTransform(lng, lat) {
var X_PI = Math.PI * 3000.0 / 180.0; var X_PI = Math.PI * 3000.0 / 180.0;
var x = lng, y = lat; var x = lng, y = lat;
...@@ -80,3 +79,17 @@ export function distinct5(arr) { ...@@ -80,3 +79,17 @@ export function distinct5(arr) {
return result; return result;
} }
// 下载文件--公共方法 blob文件 文件名 文件类型
export function downloadFile(blob, title, fileType) {
return new Promise(resolve => {
const url = window.URL.createObjectURL(new Blob([blob], { type: fileType }))
const link = document.createElement('a')
link.style.display = 'none'
link.href = url
link.setAttribute('download', title) // 自定义下载文件名
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
resolve()
})
}
...@@ -26,13 +26,13 @@ ...@@ -26,13 +26,13 @@
upText: { upText: {
type: String, type: String,
default() { default() {
return '' return '蓝色文字'
} }
}, },
downText: { downText: {
type: String, type: String,
default() { default() {
return ""; return "绿色文字";
} }
} }
}, },
......
...@@ -153,6 +153,7 @@ ...@@ -153,6 +153,7 @@
import { unitArea } from "./unitArea"; import { unitArea } from "./unitArea";
import {plateAnalysis, queryProductionType, exportExcelJson, exportAsExcel, plateAnalysisHouseImg} from "@assets/js/api/projectManage"; import {plateAnalysis, queryProductionType, exportExcelJson, exportAsExcel, plateAnalysisHouseImg} from "@assets/js/api/projectManage";
import { propertyMapFunction } from "../propertiesDetail/propertyFunctionMap"; import { propertyMapFunction } from "../propertiesDetail/propertyFunctionMap";
import {downloadFile} from "../../assets/js/public";
export default { export default {
name: "ProductAnalysis", name: "ProductAnalysis",
components:{ components:{
...@@ -247,19 +248,14 @@ ...@@ -247,19 +248,14 @@
dataJsonTwo: JSON.stringify(this.exportExcelSave.detilProductJsonDtoList) dataJsonTwo: JSON.stringify(this.exportExcelSave.detilProductJsonDtoList)
}).then(res => { }).then(res => {
if(res) { if(res) {
const url = window.URL.createObjectURL(new Blob([res], { type: 'application/vnd.ms-excel;charset=utf-8' })) const title = this.exportExcelSave.title.replace(/;/g, '-')
const link = document.createElement('a') downloadFile(res, title, 'application/vnd.ms-excel;charset=utf-8').then(() => {
link.style.display = 'none' this.$message({
link.href = url type: 'success',
link.setAttribute('download', this.exportExcelSave.title.replace(/;/g, '-')) // 自定义下载文件名 message: '导出完成'
document.body.appendChild(link) })
link.click() this.exportLoading = false
document.body.removeChild(link)
this.$message({
type: 'success',
message: '导出完成'
}) })
this.exportLoading = false
} else { } else {
this.$message({ this.$message({
type: 'warning', type: 'warning',
......
...@@ -119,11 +119,11 @@ ...@@ -119,11 +119,11 @@
<div v-if="infotType === 0" style="margin-top: 10px"> <div v-if="infotType === 0" style="margin-top: 10px">
<el-col v-for="item in plateRegionColum" :span="item.flex" :key="item.prop" :class="{'rightBorder': item.title === '置业均价'}"> <el-col v-for="item in plateRegionColum" :span="item.flex" :key="item.prop" :class="{'rightBorder': item.title === '置业均价'}">
<div class="plateRegionDetailShowHeader"> <div class="plateRegionDetailShowHeader">
{{item.title}} {{item.title + item.defaultSetting}}
</div> </div>
<div class="plateRegionDetailShowContainer" <div class="plateRegionDetailShowContainer"
:style="{ color: item.color || '#000000', fontWeight: item.color ? '600' : 'normal' }"> :style="{ color: item.color || '#000000', fontWeight: item.color ? '600' : 'normal' }">
{{dataType.plateRegion.plateInfo[item.prop] || '无'}} {{ dataType.plateRegion.plateInfo[item.prop] || '无'}}
</div> </div>
</el-col> </el-col>
</div> </div>
...@@ -400,7 +400,7 @@ ...@@ -400,7 +400,7 @@
} }
}) })
if(res.data.resultBnsProjectDTOS[i].productType) { if(res.data.resultBnsProjectDTOS[i].productType) {
productTypeName = productTypeName + res.data.resultBnsProjectDTOS[i].productType + (i === l -1 ? '' : ',') productTypeName = productTypeName + res.data.resultBnsProjectDTOS[i].productType + (i === l -1 ? ',' : '')
} }
} }
} else { } else {
...@@ -629,6 +629,7 @@ ...@@ -629,6 +629,7 @@
}) })
}) })
}, },
// 批量转换方法,待用
transformArray(arr) { transformArray(arr) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if(arr.length > 100) { if(arr.length > 100) {
......
...@@ -3,38 +3,45 @@ export const plateRegionDetail = [ ...@@ -3,38 +3,45 @@ export const plateRegionDetail = [
{ {
title: '目标客群', title: '目标客群',
flex: 24, flex: 24,
defaultSetting: '',
prop: 'regionPosition', prop: 'regionPosition',
color: '#409EFF' color: '#409EFF'
}, },
{ {
title: '产品类型', title: '产品类型',
flex: 24, flex: 24,
defaultSetting: '',
prop: 'productionTypeName', prop: 'productionTypeName',
color: '#409EFF' color: '#409EFF'
}, },
{ {
title: '区域特征', title: '区域特征',
flex: 24, flex: 24,
defaultSetting: '',
prop: 'regionAdvantage' prop: 'regionAdvantage'
}, },
{ {
title: '已有楼盘', title: '已有楼盘',
flex: 24, flex: 24,
defaultSetting: '',
prop: 'existProject' prop: 'existProject'
}, },
{ {
title: '置业均价', title: '置业均价',
flex: 12, flex: 12,
defaultSetting: '(元)',
prop: 'businessAveragePrice' prop: 'businessAveragePrice'
}, },
{ {
title: '楼面均价', title: '楼面均价',
flex: 12, flex: 12,
defaultSetting: '(元)',
prop: 'projectAveragePrice' prop: 'projectAveragePrice'
}, },
{ {
title: '区域发展', title: '区域发展',
flex: 24, flex: 24,
defaultSetting: '',
prop: 'regionDevelop' prop: 'regionDevelop'
} }
] ]
...@@ -77,6 +77,7 @@ ...@@ -77,6 +77,7 @@
import { getSupplyNumData, getRegionPlate, exportSupplyData } from "../../assets/js/api/plateSupplyManage"; import { getSupplyNumData, getRegionPlate, exportSupplyData } from "../../assets/js/api/plateSupplyManage";
import { colors } from "../../components/color"; import { colors } from "../../components/color";
import { areaRangeMap } from "./areaRangeMap"; import { areaRangeMap } from "./areaRangeMap";
import {downloadFile} from "../../assets/js/public";
export default { export default {
name: "ProductAnalysis", name: "ProductAnalysis",
data () { data () {
...@@ -195,19 +196,14 @@ ...@@ -195,19 +196,14 @@
dataJson: this.exportSaveStatus dataJson: this.exportSaveStatus
}).then(res => { }).then(res => {
if(res) { if(res) {
const url = window.URL.createObjectURL(new Blob([res], { type: 'application/vnd.ms-excel;charset=utf-8' })) const title = `${this.regionVal}-${this.plateVal}-${this.timeVal}年份供求信息`
const link = document.createElement('a') downloadFile(res, title, 'application/vnd.ms-excel;charset=utf-8').then(() => {
link.style.display = 'none' this.$message({
link.href = url type: 'success',
link.setAttribute('download', `${this.regionVal}-${this.plateVal}-${this.timeVal}年份供求信息`) // 自定义下载文件名 message: '导出完成'
document.body.appendChild(link) })
link.click() this.exportLoading = false
document.body.removeChild(link)
this.$message({
type: 'success',
message: '导出完成'
}) })
this.exportLoading = false
} else { } else {
this.$message({ this.$message({
type: 'warning', type: 'warning',
......
...@@ -78,7 +78,7 @@ ...@@ -78,7 +78,7 @@
<div class="salesInfomation" v-if="bannerType !== 2"> <div class="salesInfomation" v-if="bannerType !== 2">
<div class="title" style="padding-left: 20px">销售信息</div> <div class="title" style="padding-left: 20px">销售信息</div>
<div style="text-align: right;padding-right: 20px"> <div style="text-align: right;padding-right: 20px">
<el-button type="primary" @click="properySaleInfoExport">导出数据</el-button> <el-button type="primary" :disabled="propertyExportLoading" :loading="propertyExportLoading" @click="propertySaleInfoExport">导出数据</el-button>
</div> </div>
<div ref="imgExport" class="container"> <div ref="imgExport" class="container">
<el-row class="firstRow supplyDataDetail"> <el-row class="firstRow supplyDataDetail">
...@@ -196,6 +196,7 @@ ...@@ -196,6 +196,7 @@
import { propertyMapFunction } from "./propertyFunctionMap"; import { propertyMapFunction } from "./propertyFunctionMap";
import {queryLandInfoById, queryPropertyDetail, queryPropertySupplyData, queryAnalysisById, getJsonForProduction, exportPropertyAnalysis} from "@assets/js/api/unitManage"; import {queryLandInfoById, queryPropertyDetail, queryPropertySupplyData, queryAnalysisById, getJsonForProduction, exportPropertyAnalysis} from "@assets/js/api/unitManage";
import { areaRangeMap } from "../plateSupplyData/areaRangeMap"; import { areaRangeMap } from "../plateSupplyData/areaRangeMap";
import { downloadFile } from "../../assets/js/public";
export default { export default {
name: "propertiesDetail", name: "propertiesDetail",
components: {banner, multiHeaderTable}, components: {banner, multiHeaderTable},
...@@ -359,30 +360,36 @@ ...@@ -359,30 +360,36 @@
exportSupplyDataSave: [], exportSupplyDataSave: [],
exportHouseInfoSave: [], exportHouseInfoSave: [],
// 暂无数据变量 // 暂无数据变量
supplyNoDataFlag: false supplyNoDataFlag: false,
propertyExportLoading: false
} }
}, },
methods: { methods: {
// 导出数据 // 导出数据
properySaleInfoExport () { propertySaleInfoExport () {
// this.propertyData.projectInformation.businessId // this.propertyData.projectInformation.businessId
if(this.propertyId) { if(this.propertyId) {
this.propertyExportLoading = true
exportPropertyAnalysis({ exportPropertyAnalysis({
title: `${this.propertyData.projectInformation.name}`, title: `${this.propertyData.projectInformation.name}`,
dataJsonTwo: JSON.stringify(this.exportSupplyDataSave), dataJsonTwo: JSON.stringify(this.exportSupplyDataSave),
dataJson: JSON.stringify(this.exportHouseInfoSave) dataJson: JSON.stringify(this.exportHouseInfoSave)
}).then(res => { }).then(res => {
const url = window.URL.createObjectURL(new Blob([res], { type: 'application/vnd.ms-excel;charset=utf-8' })) // const url = window.URL.createObjectURL(new Blob([res], { type: 'application/vnd.ms-excel;charset=utf-8' }))
const link = document.createElement('a') // const link = document.createElement('a')
link.style.display = 'none' // link.style.display = 'none'
link.href = url // link.href = url
link.setAttribute('download', `${this.propertyData.projectInformation.name}楼盘销售信息数据分析`) // 自定义下载文件名 // link.setAttribute('download', `${this.propertyData.projectInformation.name}楼盘销售信息数据分析`) // 自定义下载文件名
document.body.appendChild(link) // document.body.appendChild(link)
link.click() // link.click()
document.body.removeChild(link) // document.body.removeChild(link)
this.$message({ let title = `${this.propertyData.projectInformation.name}楼盘销售信息数据分析.xls`
type: 'success', downloadFile(res, title, 'application/vnd.ms-excel;charset=utf-8').then(() => {
message: '导出完成' this.$message({
type: 'success',
message: '导出完成'
})
this.propertyExportLoading = false
}) })
}) })
} }
......
...@@ -11,7 +11,7 @@ export default { ...@@ -11,7 +11,7 @@ export default {
}, },
plotRatio: { plotRatio: {
name: '容积率', name: '容积率',
defaultSetting: '%' defaultSetting: ''
}, },
productTypeName: { productTypeName: {
name: '产品类型', name: '产品类型',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment