Commit 6f6af664 authored by wangjiankun's avatar wangjiankun

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

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