首页机具供应展示图表等接口调试完成

This commit is contained in:
BianLzhaoMin 2025-03-27 16:58:44 +08:00
parent 93d078d2be
commit dc6efc9d90
6 changed files with 219 additions and 23 deletions

View File

@ -8,3 +8,19 @@ export const getCardListApi = data => {
params: data params: data
}) })
} }
// 获取饼图1数据信息
export const getPie_1DataApi = data => {
return request({
url: '/material/mainPage/getDemandTotal',
method: 'get',
params: data
})
}
// 获取柱状图和折线图数据信息
export const getBarAndLineDataApi = data => {
return request({
url: '/material/mainPage/getDemandList',
method: 'get',
params: data
})
}

View File

@ -23,6 +23,18 @@ export default {
height: { height: {
type: String, type: String,
default: '100%' default: '100%'
},
barAndLineX: {
type: Array,
default: () => ['机具']
},
barY1: {
type: Array,
default: () => ['0']
},
barY2: {
type: Array,
default: () => ['0']
} }
}, },
data() { data() {
@ -42,6 +54,26 @@ export default {
this.chart.dispose() this.chart.dispose()
this.chart = null this.chart = null
}, },
watch: {
barAndLineX: {
deep: true,
handler() {
this.initChart()
}
},
barY1: {
deep: true,
handler() {
this.initChart()
}
},
barY2: {
deep: true,
handler() {
this.initChart()
}
}
},
methods: { methods: {
initChart() { initChart() {
this.chart = echarts.init(this.$el, 'macarons') this.chart = echarts.init(this.$el, 'macarons')
@ -77,7 +109,8 @@ export default {
xAxis: [ xAxis: [
{ {
type: 'category', type: 'category',
data: ['卸扣5t', '卸扣8t', '手扳葫芦', '绞磨', '机具1', '机具2', '机具13'], // data: ['5t', '8t', '', '', '1', '2', '13'],
data: this.barAndLineX,
axisTick: { axisTick: {
alignWithLabel: true alignWithLabel: true
}, },
@ -111,7 +144,7 @@ export default {
name: '需求', name: '需求',
type: 'bar', type: 'bar',
barWidth: '20%', // barWidth: '20%', //
data: [79, 52, 200, 334, 390, 330, 220], data: this.barY1,
animationDuration: 2000, animationDuration: 2000,
itemStyle: { itemStyle: {
color: '#26a8ff' // color: '#26a8ff' //
@ -121,7 +154,7 @@ export default {
name: '供应', name: '供应',
type: 'bar', type: 'bar',
barWidth: '20%', // barWidth: '20%', //
data: [80, 52, 200, 334, 390, 330, 220], data: this.barY2,
animationDuration: 2000, animationDuration: 2000,
itemStyle: { itemStyle: {
color: '#ff8e9d' // color: '#ff8e9d' //

View File

@ -29,6 +29,24 @@ export default {
chartData: { chartData: {
type: Object, type: Object,
required: true required: true
},
barAndLineX: {
type: Array,
default: () => ['机具']
},
// 线 Y 1
lineY1: {
type: Array,
default: () => {
return []
}
},
// 线 Y 2
lineY2: {
type: Array,
default: () => {
return []
}
} }
}, },
data() { data() {
@ -37,10 +55,22 @@ export default {
} }
}, },
watch: { watch: {
chartData: { barAndLineX: {
deep: true, deep: true,
handler(val) { handler() {
this.setOptions(val) this.initChart()
}
},
lineY1: {
deep: true,
handler() {
this.initChart()
}
},
lineY2: {
deep: true,
handler() {
this.initChart()
} }
} }
}, },
@ -65,7 +95,8 @@ export default {
this.chart.setOption({ this.chart.setOption({
xAxis: { xAxis: {
type: 'category', type: 'category',
data: ['卸扣5t', '卸扣8t', '手扳葫芦', '绞磨', '机具1', '机具2', '机具13'], // data: ['5t', '8t', '', '', '1', '2', '13'],
data: this.barAndLineX,
boundaryGap: false, // 线 y boundaryGap: false, // 线 y
axisTick: { axisTick: {
show: true // 线 show: true // 线
@ -124,7 +155,7 @@ export default {
name: '需求量', name: '需求量',
type: 'line', type: 'line',
smooth: false, // 线 smooth: false, // 线
data: [12, 66, 88, 90, 70, 110, 20], // data: this.lineY1, //
itemStyle: { itemStyle: {
color: '#33aeff' // 线 color: '#33aeff' // 线
}, },
@ -144,7 +175,7 @@ export default {
name: '待供应量', name: '待供应量',
type: 'line', type: 'line',
smooth: false, // 线 smooth: false, // 线
data: [12, 20, 22, 30, 99, 60, 3], // data: this.lineY2, //
itemStyle: { itemStyle: {
color: '#ff8e9d' // 线 color: '#ff8e9d' // 线
}, },

View File

@ -21,6 +21,16 @@ export default {
height: { height: {
type: String, type: String,
default: '100%' default: '100%'
},
pie_1Data: {
type: Array,
default: () => {
return [
{ value: 0, name: '计划需求量', itemStyle: { color: '#65dfe0' } },
{ value: 0, name: '已供应量', itemStyle: { color: '#ff8e9d' } },
{ value: 0, name: '待供应量', itemStyle: { color: '#6ccaf6' } }
]
}
} }
}, },
data() { data() {
@ -30,7 +40,7 @@ export default {
}, },
mounted() { mounted() {
this.$nextTick(() => { this.$nextTick(() => {
this.initChart() this.initChart(this.pie_1Data)
}) })
}, },
beforeDestroy() { beforeDestroy() {
@ -40,20 +50,29 @@ export default {
this.chart.dispose() this.chart.dispose()
this.chart = null this.chart = null
}, },
watch: {
pie_1Data: {
deep: true,
handler(val) {
this.initChart(val)
}
}
},
methods: { methods: {
initChart() { initChart(pie_1Data) {
this.chart = echarts.init(this.$el, 'macarons') this.chart = echarts.init(this.$el, 'macarons')
this.chart.setOption({ this.chart.setOption({
tooltip: { tooltip: {
trigger: 'item', trigger: 'item',
formatter: '{b} : {c} ({d}%)' // formatter: '{b} : {c} ({d}%)'
formatter: '{b} {c}'
}, },
legend: { legend: {
left: 'center', left: 'center',
bottom: '0', bottom: '0',
icon: 'circle', icon: 'circle',
data: ['待供应量', '计划需求量', '已供应量'] data: ['计划需求量', '已供应量', '待供应量']
}, },
series: [ series: [
{ {
@ -61,11 +80,12 @@ export default {
// roseType: 'radius', // radius // roseType: 'radius', // radius
radius: [0, 95], radius: [0, 95],
center: ['50%', '50%'], center: ['50%', '50%'],
data: [ // data: [
{ value: 320, name: '待供应量', itemStyle: { color: '#6ccaf6' } }, // { value: 320, name: '', itemStyle: { color: '#6ccaf6' } },
{ value: 240, name: '计划需求量', itemStyle: { color: '#65dfe0' } }, // { value: 240, name: '', itemStyle: { color: '#65dfe0' } },
{ value: 149, name: '已供应量', itemStyle: { color: '#ff8e9d' } } // { value: 149, name: '', itemStyle: { color: '#ff8e9d' } }
], // ],
data: pie_1Data,
animationEasing: 'cubicInOut', animationEasing: 'cubicInOut',
animationDuration: 2600, animationDuration: 2600,
itemStyle: { itemStyle: {
@ -74,7 +94,8 @@ export default {
}, },
label: { label: {
show: true, // show: true, //
formatter: '{b}: {d}%', // name // formatter: '{b}: {d}%', // name
formatter: '{b} {c}%', // name
fontSize: 12, // fontSize: 12, //
color: '#333' // color: '#333' //
} }

View File

@ -3,7 +3,16 @@
<div class="chart-title">{{ chartTitle }}</div> <div class="chart-title">{{ chartTitle }}</div>
<div class="chart-content"> <div class="chart-content">
<!-- <PieChart /> --> <!-- <PieChart /> -->
<component :is="ChartTypeName" :chartData="chartData" /> <component
:is="ChartTypeName"
:chartData="chartData"
:pie_1Data="pie_1Data"
:barAndLineX="barAndLineX"
:barY1="barY1"
:barY2="barY2"
:lineY1="lineY1"
:lineY2="lineY2"
/>
</div> </div>
</div> </div>
</template> </template>
@ -28,6 +37,48 @@ export default {
ChartTypeName: { ChartTypeName: {
type: String, type: String,
default: 'PieChart' default: 'PieChart'
},
// 1
pie_1Data: {
type: Array,
default: () => {
return []
}
},
// 线 X
barAndLineX: {
type: Array,
default: () => {
return []
}
},
// Y 1
barY1: {
type: Array,
default: () => {
return []
}
},
// Y 2
barY2: {
type: Array,
default: () => {
return []
}
},
// 线 Y 1
lineY1: {
type: Array,
default: () => {
return []
}
},
// 线 Y 2
lineY2: {
type: Array,
default: () => {
return []
}
} }
}, },
data() { data() {

View File

@ -104,7 +104,16 @@
<!-- 图表区域 --> <!-- 图表区域 -->
<div class="chart-box"> <div class="chart-box">
<div :key="index" v-for="(chart, index) in chartList"> <div :key="index" v-for="(chart, index) in chartList">
<ChartModelBox :chartTitle="chart.title" :ChartTypeName="chart.type" /> <ChartModelBox
:chartTitle="chart.title"
:ChartTypeName="chart.type"
:pie_1Data="pie_1Data"
:barAndLineX="barAndLineX"
:barY1="barY1"
:barY2="barY2"
:lineY1="lineY1"
:lineY2="lineY2"
/>
</div> </div>
</div> </div>
</template> </template>
@ -123,7 +132,7 @@ import TableModel from './components/table-model' // 二级页面列表组件
import Treeselect from '@riophae/vue-treeselect' import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css' import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import { getCardListApi } from '@/api/home/equipment-supply.js' import { getCardListApi, getPie_1DataApi, getBarAndLineDataApi } from '@/api/home/equipment-supply.js'
import { getListProject, getListUnite } from '@/api/lease/apply' import { getListProject, getListUnite } from '@/api/lease/apply'
export default { export default {
components: { components: {
@ -250,7 +259,13 @@ export default {
title: '待供应占比统计', title: '待供应占比统计',
type: 'LineChart' type: 'LineChart'
} }
] ],
pie_1Data: [],
barAndLineX: [],
barY1: [],
lineY1: [],
barY2: [],
lineY2: []
} }
}, },
methods: { methods: {
@ -287,7 +302,34 @@ export default {
this.cardList_3[0].cardNum = projectNum this.cardList_3[0].cardNum = projectNum
this.cardList_3[1].cardNum = suppliedQuantityAllNum || 0 this.cardList_3[1].cardNum = suppliedQuantityAllNum || 0
this.cardList_3[2].cardNum = suppliedQuantityPrice || 0 this.cardList_3[2].cardNum = suppliedQuantityPrice || 0
//
const { data: barAndLine } = await getBarAndLineDataApi(queryParams)
const { typeNameList, demandNumList, suppliedQuantityNumList, suppliedToBeQuantityNumList } = barAndLine
this.barAndLineX = typeNameList
this.barY1 = demandNumList
this.lineY1 = demandNumList
this.barY2 = suppliedQuantityNumList
this.lineY2 = suppliedToBeQuantityNumList
console.log('barAndLine', barAndLine)
}, },
//
async getPie_1DataFun() {
const queryParams = {
...this.queryParams,
startTime: this.queryDate && this.queryDate.length > 0 ? this.queryDate[0] : '',
endTime: this.queryDate && this.queryDate.length > 0 ? this.queryDate[1] : ''
}
const { data: pie1 } = await getPie_1DataApi(queryParams)
const { demandNum, suppliedQuantityNum, suppliedToBeQuantityNum } = pie1
this.pie_1Data = [
{ value: demandNum, name: '计划需求量', itemStyle: { color: '#65dfe0' } },
{ value: suppliedQuantityNum, name: '已供应量', itemStyle: { color: '#ff8e9d' } },
{ value: suppliedToBeQuantityNum, name: '待供应量', itemStyle: { color: '#6ccaf6' } }
]
},
// //
async getCompanyAndProjectFun() { async getCompanyAndProjectFun() {
const comRes = await getListUnite({ projectId: null }) const comRes = await getListUnite({ projectId: null })
@ -298,6 +340,7 @@ export default {
// //
onHandleSearch() { onHandleSearch() {
this.getCardListFun() this.getCardListFun()
this.getPie_1DataFun()
}, },
// //
onHandleReset() { onHandleReset() {
@ -354,6 +397,7 @@ export default {
this.queryDate = this.getDefaultDateRange() this.queryDate = this.getDefaultDateRange()
this.getCompanyAndProjectFun() this.getCompanyAndProjectFun()
this.getCardListFun() this.getCardListFun()
this.getPie_1DataFun()
} }
} }
</script> </script>