增加集团数据统计功能

main
rogersun 3 days ago
parent 4f7a97c372
commit 69420e45f7
  1. 15
      src/apis/group.js
  2. 6
      src/layout/components/PageAside.vue
  3. 8
      src/router/index.js
  4. 147
      src/views/group/index.vue

@ -0,0 +1,15 @@
import {request} from '@/request/index.js'
export const get_group_data = () => {
return request({
url: 'group/get_group_data',
method: 'get',
})
}
export const get_group_func = () => {
return request({
url: 'group/get_group_func',
method: 'get',
})
}

@ -50,6 +50,12 @@ const route = useRoute()
</el-icon>
<span>智能排片</span>
</el-menu-item>
<el-menu-item index="group">
<el-icon>
<icon-menu/>
</el-icon>
<span>集团数据统计</span>
</el-menu-item>
</el-menu>
</el-col>
</el-row>

@ -57,6 +57,14 @@ const routes = [
meta:{
keepAlive: true,
}
},
{
path: 'group',
name: 'Group',
component: () => import('@/views/group/index.vue'),
meta:{
keepAlive: true,
}
}
]
}

@ -0,0 +1,147 @@
<script setup>
import {onBeforeMount, ref, computed} from 'vue';
import {get_group_data, get_group_func} from "@/apis/group.js";
// region
const groupData = ref([])
// const tableData = ref([])
const dataSwitch = ref(false)
const update_time = ref('')
//
const funcData = ref([])
const modelArray = ref([])
const groupFilter = ref([])
// const funcObj = ref({})
//
async function get_func() {
funcData.value = []
await get_group_func().then(res => {
console.log(res)
funcData.value = [...res]
}).catch(err => {
console.log(err)
}
)
}
//
async function get_data() {
tableData.value = []
await get_group_data().then(res => {
console.log(res)
if (res.status === 'success') {
update_time.value = res.data.update_datetime
groupData.value = [...res.data.groups_data]
console.log(groupData.value)
}
}).catch(err => {
console.log(err)
})
}
//
const tableData = computed(() => {
const data = []
groupData.value.forEach(item => {
groupFilter.value.push({
'text': item['group_info']['group_name'] + '(' + item['group_info']['group_code'] + ')',
'value': item['group_info']['group_name'] + '(' + item['group_info']['group_code'] + ')'
})
let tempData = {
'group_info': item['group_info']['group_name'] + '(' + item['group_info']['group_code'] + ')',
'group_link': item['group_info']['group_address'],
'cinema_count': item['group_info']['cinema_count'],
}
item['group_data'].forEach(data => {
if (dataSwitch.value === false) {
tempData[data['func_id']] = data['data_count']
// tempData[data['func_id']] = {'data': data['data_count'], 'tips':data['data_lasttime']}
// tempData[data['func_id'] + '_data'] = data['data_count']
// tempData[data['func_id'] + '_tips'] = data['data_lasttime']
} else {
tempData[data['func_id']] = data['data_lasttime']
// tempData[data['func_id']] = {'data': data['data_lasttime'], 'tips':data['data_count']}
// tempData[data['func_id'] + '_data'] = data['data_lasttime']
// tempData[data['func_id'] + '_tips'] = data['data_count']
}
})
data.push(tempData)
})
console.log('tableData', data)
return data
})
const tableHeader = computed(() => {
let funcObj = {}
funcData.value.forEach(item => {
modelArray.value.push(item['func_model'])
if (funcObj.hasOwnProperty(item['func_model'])) {
funcObj[item['func_model']].push(item)
} else {
funcObj[item['func_model']] = [item]
}
})
console.log('funcObj', funcObj)
modelArray.value = [...new Set(modelArray.value)]
console.log('modelArray', modelArray.value)
return funcObj
})
const filterHandler = (value, row, column) => {
const property = column['property']
return row[property] === value
}
//
onBeforeMount(
async () => {
await get_func()
await get_data()
}
)
// endregion
</script>
<template>
<el-row align="middle" justify="end">
<el-col :span="2">
<el-text>数据更新时间</el-text>
</el-col>
<el-col :span="3">
<el-text>{{ update_time }}</el-text>
</el-col>
<el-col :span="6">
<el-switch v-model="dataSwitch" active-text="数据最后更新时间" inactive-text="数据总条数" @change="get_data"/>
</el-col>
</el-row>
<el-table :data="tableData" max-height="700" :row-style="{ height: '60px' }"
empty-text='数据生成中,请等待3分钟后刷新!'>
<el-table-column prop="group_info" label="集团名称" min-width="200" fixed column-key="group_info" :filters="groupFilter" :filter-method="filterHandler"></el-table-column>
<el-table-column prop="cinema_count" label="集团影院数" min-width="120" sortable></el-table-column>
<el-table-column v-for="(func_array,model) in tableHeader" :label="model" align="center">
<el-table-column v-for="func in func_array" :prop="func['id']" :label="func['func_name']"
align="center" min-width="120" sortable>
</el-table-column>
</el-table-column>
</el-table>
</template>
<style>
.el-text {
white-space: pre-wrap; /* 或者使用 pre-line */
}
.el-table .cell {
white-space: pre-line;
}
</style>
Loading…
Cancel
Save