|
@@ -6,7 +6,10 @@ import updateIcon from '../image/xiazai.png'
|
|
|
import * as XLSX from 'xlsx'
|
|
import * as XLSX from 'xlsx'
|
|
|
const props = defineProps({
|
|
const props = defineProps({
|
|
|
BarData: Object,
|
|
BarData: Object,
|
|
|
- barHeight: Object
|
|
|
|
|
|
|
+ barHeight: Object,
|
|
|
|
|
+ isRevenue: Boolean,
|
|
|
|
|
+ RevenueStartDate: String,
|
|
|
|
|
+ RevenueEndDate: String
|
|
|
})
|
|
})
|
|
|
const bar_data = ref(props.BarData)
|
|
const bar_data = ref(props.BarData)
|
|
|
const bar_ref = ref()
|
|
const bar_ref = ref()
|
|
@@ -14,7 +17,6 @@ watch(
|
|
|
() => props.BarData,
|
|
() => props.BarData,
|
|
|
(current) => {
|
|
(current) => {
|
|
|
bar_data.value = current
|
|
bar_data.value = current
|
|
|
- initOption.title.text = bar_title.value
|
|
|
|
|
initOption.xAxis.data = barName.value
|
|
initOption.xAxis.data = barName.value
|
|
|
initOption.series = bar_series.value
|
|
initOption.series = bar_series.value
|
|
|
initOption.legend.data = Name.value
|
|
initOption.legend.data = Name.value
|
|
@@ -23,6 +25,9 @@ watch(
|
|
|
initOption.toolbox.feature.saveAsImage.name = downloadName.value
|
|
initOption.toolbox.feature.saveAsImage.name = downloadName.value
|
|
|
initOption.toolbox.show = isShowTooltips.value
|
|
initOption.toolbox.show = isShowTooltips.value
|
|
|
initChart()
|
|
initChart()
|
|
|
|
|
+ if (props.isRevenue) {
|
|
|
|
|
+ initOption.title.text = bar_title.value
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
deep: true
|
|
deep: true
|
|
@@ -154,6 +159,17 @@ for (var i in result) {
|
|
|
data.push(formatJson(result[i].filterVal, result[i].tableDatas))
|
|
data.push(formatJson(result[i].filterVal, result[i].tableDatas))
|
|
|
}
|
|
}
|
|
|
const exportData = ({ header, data, sheetname, filename }: any) => {
|
|
const exportData = ({ header, data, sheetname, filename }: any) => {
|
|
|
|
|
+ $api
|
|
|
|
|
+ .RevenueDownload({
|
|
|
|
|
+ date_start: props.RevenueStartDate,
|
|
|
|
|
+ date_end: props.RevenueEndDate
|
|
|
|
|
+ })
|
|
|
|
|
+ .then((res: any) => {
|
|
|
|
|
+ if (res.code === 200) {
|
|
|
|
|
+ console.log(res)
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ .finally(() => {})
|
|
|
// 将表头插入数据数组中
|
|
// 将表头插入数据数组中
|
|
|
for (let i = 0; i < header.length; i++) {
|
|
for (let i = 0; i < header.length; i++) {
|
|
|
data[i].unshift(header[i])
|
|
data[i].unshift(header[i])
|
|
@@ -178,7 +194,7 @@ const exportData = ({ header, data, sheetname, filename }: any) => {
|
|
|
wb.SheetNames.push(ws_name[k])
|
|
wb.SheetNames.push(ws_name[k])
|
|
|
wb.Sheets[ws_name[k]] = ws[k]
|
|
wb.Sheets[ws_name[k]] = ws[k]
|
|
|
}
|
|
}
|
|
|
- XLSX.writeFile(wb, filename + '.xlsx') // 导出文件
|
|
|
|
|
|
|
+ // XLSX.writeFile(wb, filename + '.xlsx') // 导出文件
|
|
|
// const data = XLSX.utils.json_to_sheet(tableData) //此处tableData.value为表格的数据
|
|
// const data = XLSX.utils.json_to_sheet(tableData) //此处tableData.value为表格的数据
|
|
|
// const wb = XLSX.utils.book_new()
|
|
// const wb = XLSX.utils.book_new()
|
|
|
// XLSX.utils.book_append_sheet(wb, data, 'test-data') //test-data为自定义的sheet表名
|
|
// XLSX.utils.book_append_sheet(wb, data, 'test-data') //test-data为自定义的sheet表名
|
|
@@ -189,7 +205,7 @@ const exportData = ({ header, data, sheetname, filename }: any) => {
|
|
|
const initOption = reactive({
|
|
const initOption = reactive({
|
|
|
//标题
|
|
//标题
|
|
|
title: {
|
|
title: {
|
|
|
- text: bar_title.value || '', //主标题
|
|
|
|
|
|
|
+ text: bar_title.value || 'Total:', //主标题
|
|
|
left: 19,
|
|
left: 19,
|
|
|
top: 9.5,
|
|
top: 9.5,
|
|
|
textStyle: {
|
|
textStyle: {
|
|
@@ -341,7 +357,6 @@ const clickParams = () => {
|
|
|
}
|
|
}
|
|
|
const initChart = () => {
|
|
const initChart = () => {
|
|
|
const bar_chart = echarts.init(bar_ref.value)
|
|
const bar_chart = echarts.init(bar_ref.value)
|
|
|
- bar_chart.setOption(initOption)
|
|
|
|
|
//图表响应式
|
|
//图表响应式
|
|
|
window.addEventListener('resize', () => {
|
|
window.addEventListener('resize', () => {
|
|
|
bar_chart.resize()
|
|
bar_chart.resize()
|
|
@@ -360,14 +375,17 @@ const initChart = () => {
|
|
|
initOption.series.forEach((item: any, index: any) => {
|
|
initOption.series.forEach((item: any, index: any) => {
|
|
|
if (item.name == Object.keys(trueObj)) {
|
|
if (item.name == Object.keys(trueObj)) {
|
|
|
initOption.series[index].label.show = true
|
|
initOption.series[index].label.show = true
|
|
|
|
|
+ initOption.title.text = `Total: ${initOption.series[index].total}`
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
} else {
|
|
} else {
|
|
|
initOption.series.forEach((item: any, index: any) => {
|
|
initOption.series.forEach((item: any, index: any) => {
|
|
|
initOption.series[index].label.show = false
|
|
initOption.series[index].label.show = false
|
|
|
|
|
+ initOption.title.text = `Total: `
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
|
|
+ bar_chart.setOption(initOption)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
defineExpose({
|
|
defineExpose({
|