| | |
| | | <script lang="ts"> |
| | | import { defineComponent, onMounted, ref } from 'vue'; |
| | | import * as echarts from 'echarts'; |
| | | import { ElMessage } from 'element-plus'; |
| | | import { facilityManagementApi } from '/@/api/facilityManagement'; |
| | | export default defineComponent({ |
| | | setup() { |
| | | const listApi = () => { |
| | | facilityManagementApi() |
| | | .getequipmentInfoStatistics() |
| | | .then((res) => { |
| | | if (res.data.code == 200) { |
| | | let arr=[] |
| | | arr=res.data.data |
| | | let date=[] |
| | | for (let i = 0; i < arr.length; i++) { |
| | | date.push(arr[i].count) |
| | | } |
| | | init(date); |
| | | } else { |
| | | ElMessage({ |
| | | showClose: true, |
| | | message: res.data.msg, |
| | | type: 'error', |
| | | }); |
| | | } |
| | | }); |
| | | }; |
| | | onMounted(() => { |
| | | listApi(); |
| | | }); |
| | | const main = ref(); |
| | | const init = () => { |
| | | const init = (data:any) => { |
| | | var myChart = echarts.init(main.value); |
| | | var option = { |
| | | tooltip: {}, |
| | |
| | | color: ['#6394f9'], |
| | | series: [ |
| | | { |
| | | data: [120, 200, 150, 80, 70, 110, 130], |
| | | data: data, |
| | | type: 'bar', |
| | | }, |
| | | ], |
| | |
| | | |
| | | myChart.setOption(option); |
| | | }; |
| | | onMounted(() => { |
| | | init(); |
| | | }); |
| | | return { |
| | | init, |
| | | onMounted, |
| | | main, |
| | | listApi, |
| | | }; |
| | | }, |
| | | }); |
| | |
| | | <style scoped> |
| | | .box { |
| | | background-color: #fff; |
| | | box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%); |
| | | box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%); |
| | | } |
| | | .title { |
| | | font-size: 16px; |