export function parseTime(time, cFormat) {
if (time == null) {
return null
}
if (arguments.length === 0) {
return null
}
const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
let date
if (typeof time === 'object') {
date = time
} else {
if (('' + time).length === 10) time = parseInt(time) * 1000
date = new Date(time)
}
const formatObj = {
y: date.getFullYear(),
m: date.getMonth() + 1,
d: date.getDate(),
h: date.getHours(),
i: date.getMinutes(),
s: date.getSeconds(),
a: date.getDay()
}
const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
let value = formatObj[key]
if (key === 'a') return ['一', '二', '三', '四', '五', '六', '日'][value - 1]
if (result.length > 0 && value < 10) {
value = '0' + value
}
return value || 0
})
return time_str
}
<el-button type="primary" @click="expFcs" >导出房产税台账</el-button>
<el-button type="primary" @click="expCztds" >导出城镇土地使用税台账</el-button>
// <!-- 分割 -->
import {fcsExport} from '@/api/modules/fcxx/fctz'
import {parseTime} from '@/utils/tools'
export default {
data() {
return {
centerDialogVisible: false
}
},
expFcs(){
let tHeader = ['序号','房产编号','房产名称','是否有产权证','产权证书号','房屋坐落地址','纳税人类型',
'所有权人纳税识别码','所有权人名称','房屋所在土地编号','房屋所在土地地址','房产用途','房产取得时间','纳税义务终止时间',
'建筑面积','其中出租房产建筑面积','是否启用','房产原值','其中出租房产原值','计税比例','税金金额'];
let filterVal = ['a1','a2','zcmc','iszh','bdczh','zcdz','a3',
'a4','a5','a6','zcdz','fclx','a7','a8',
'fcmj','czmj','xzzt','zcyz','a9','jsbl','jsje'];
let tipName="房产税台账"
fcsExport().then(({data}) => {
let list = data.fcsList;
import('@/vendor/Export2Excel').then(excel => {
const data = this.formatJson(filterVal, list);
const time = parseTime(new Date().getTime());
excel.export_json_to_excel({
header: tHeader,
sheetName:tipName,
data,
filename: tipName+'导出_' + time,
style:{},
});
this.$message.success("导出成功!")
})
}).catch(() => {
this.$message.error("导出失败!")
});
},
formatJson(filterVal, jsonData) {
return jsonData.map(v => filterVal.map(j => {
return v[j];
}))
},
expCztds(){
let tHeader = ['序号','土地编号','地号','土地名称','纳税人类型','土地使用权人纳税识别号','土地使用权人名称',
'土地使用权证号','土地性质','土地取得方式','土地用途','土地坐落地址','土地取得时间','纳税义务终止时间',
'启用标记','占用土地面积','土地等级','税额标准','地价','其中取得土地使用权支付金额','其中土地开发成本'];
let filterVal = ['a1','b2','b3','zcmc','b4','b5','b6',
'bdczh','b7','b8','b9','zcdz','b10','b11',
'b12','tdmj','b13','b14','b15','b16','b17'];
let tipName="城镇土地使用税台账"
fcsExport().then(({data}) => {
let list = data.fcsList;
import('@/vendor/Export2Excel').then(excel => {
const data = this.formatJson(filterVal, list);
const time = parseTime(new Date().getTime());
excel.export_json_to_excel({
header: tHeader,
sheetName:tipName,
data,
filename: tipName+'导出_' + time,
style:{},
});
this.$message.success("导出成功!")
})
}).catch(() => {
this.$message.error("导出失败!")
});
}
后台返回的字段
image.png
网友评论