<template>
|
<a-card :bordered='false'>
|
<!-- 查询区域 -->
|
<div class='table-page-search-wrapper'>
|
<a-form layout='inline' @keyup.enter.native='searchQuery'>
|
<a-row :gutter='24'>
|
|
<a-col :md='8' :sm='8'>
|
<a-form-item label='时间区间'>
|
<a-range-picker
|
v-model='queryParam.dateRange'
|
format='YYYY-MM-DD'
|
:placeholder="['开始时间', '结束时间']"
|
@change='onDateChange'>
|
<template slot='renderExtraFooter'>
|
extra footer
|
</template>
|
</a-range-picker>
|
</a-form-item>
|
</a-col>
|
|
<template v-if='toggleSearchStatus'>
|
<a-col :md='24' :sm='24'>
|
<a-form-item label='选择项目'>
|
<j-select-multi-project v-model='queryParam.xm' />
|
</a-form-item>
|
</a-col>
|
|
<a-col :md='24' :sm='24'>
|
<a-form-item label='选择用户'>
|
<j-select-user-by-dep v-model='queryParam.user' :multi='true' />
|
</a-form-item>
|
</a-col>
|
<a-col :md='24' :sm='24'>
|
<a-form-item label='快捷查询'>
|
<a-radio-group v-model='queryType' @change='onChange'>
|
<a-radio :value='0'>
|
自定义
|
</a-radio>
|
<a-radio :value='1'>
|
上周
|
</a-radio>
|
<a-radio :value='2'>
|
本周
|
</a-radio>
|
<a-radio :value='3'>
|
上月
|
</a-radio>
|
<a-radio :value='4'>
|
本月
|
</a-radio>
|
<a-radio :value='5'>
|
上季度
|
</a-radio>
|
<a-radio :value='6'>
|
本季度
|
</a-radio>
|
<a-radio :value='7'>
|
上年
|
</a-radio>
|
<a-radio :value='8'>
|
本年
|
</a-radio>
|
</a-radio-group>
|
</a-form-item>
|
</a-col>
|
</template>
|
|
<a-col :md='6' :sm='8'>
|
<span style='float: left;overflow: hidden;' class='table-page-search-submitButtons'>
|
<a-button type='primary' @click='searchQuery' icon='search'>查询</a-button>
|
<a-button type='primary' @click='searchReset' icon='reload' style='margin-left: 8px'>重置</a-button>
|
<a @click='handleToggleSearch' style='margin-left: 8px'>
|
{{ toggleSearchStatus ? '收起' : '展开' }}
|
<a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
|
</a>
|
</span>
|
</a-col>
|
|
</a-row>
|
</a-form>
|
</div>
|
<!-- 操作按钮区域 -->
|
<div class='table-operator' style='border-top: 5px'>
|
<!-- <a-button type="primary" icon="download" @click="handleExportXls('模板信息')">导出</a-button>-->
|
<!-- <a-button type="primary" icon="hdd" @click="recycleBinVisible=true">回收站</a-button>-->
|
<a-dropdown v-if='selectedRowKeys.length > 0'>
|
<a-menu slot='overlay' @click='handleMenuClick'>
|
<a-menu-item key='1'>
|
<a-icon type='delete' @click='batchDel' />
|
删除
|
</a-menu-item>
|
|
</a-menu>
|
<a-button style='margin-left: 8px'>
|
批量操作
|
<a-icon type='down' />
|
</a-button>
|
</a-dropdown>
|
|
|
</div>
|
|
<a-collapse v-model='activeKey'>
|
<a-collapse-panel key='1' header='表单'>
|
<!-- table区域-begin -->
|
<div>
|
|
<a-table
|
:scroll='{x: tableWidth}'
|
bordered
|
size='small'
|
ref='table'
|
rowKey='xm'
|
:columns='columns'
|
:dataSource='dataSource'
|
:loading='loading'
|
:pagination='false'
|
@change='handleTableChange'>
|
|
|
<!-- 字符串超长截取省略号显示-->
|
<span slot='esContent' slot-scope='text'>
|
<j-ellipsis :value='text' :length='18' />
|
</span>
|
|
|
<span slot='tag' slot-scope='tag,record'>
|
|
<template v-if='record.xmName == "合计"'>
|
<a-tag v-if='tag > 0' color='pink'>
|
{{ tag }}
|
</a-tag>
|
<a-tag v-else>
|
{{ tag }}
|
</a-tag>
|
</template>
|
|
<template v-else>
|
<a-tag v-if='tag > 0' color='cyan'>
|
{{ tag }}
|
</a-tag>
|
<a-tag v-else>
|
{{ tag }}
|
</a-tag>
|
</template>
|
</span>
|
|
<span slot='total' slot-scope='text'>
|
<a-tag v-if='text > 0' color='red'>
|
{{ text }}
|
</a-tag>
|
<a-tag v-else>
|
{{ text }}
|
</a-tag>
|
</span>
|
|
</a-table>
|
</div>
|
<!-- table区域-end -->
|
<a-icon slot="extra" type="export" @click="handleClick" />
|
</a-collapse-panel>
|
<a-collapse-panel key='2' header='饼图'>
|
<div style='padding-top: 50px'>
|
<statistics-pie :data-source='dataSource' :user-dict-options='userDictOptions' />
|
</div>
|
</a-collapse-panel>
|
<a-collapse-panel key='3' header='柱状图'>
|
<statistics-bar :data-source='dataSource' />
|
</a-collapse-panel>
|
</a-collapse>
|
</a-card>
|
</template>
|
|
<script>
|
import UploadTemplateModal from '@views/pro/modules/UploadTemplateModal'
|
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
|
import { initDictOptions, filterDictText, filterMultiDictText } from '@/components/dict/JDictSelectUtil'
|
import JMultiSelectTag from '@comp/dict/JMultiSelectTag'
|
import JSelectMultiProject from '@comp/jeecgbiz/JSelectMultiProject'
|
import { getWeek, getLastWeek, getLastMonth, getLastQuarter, getLastYear } from '@/utils/util'
|
import moment from 'moment'
|
import locale from 'ant-design-vue/es/date-picker/locale/zh_CN'
|
import StatisticsPie from '@views/week/modules/StatisticsPie'
|
import BarHorizontal from '@comp/chart/BarHorizontal'
|
import StatisticsBar from '@views/week/modules/StatisticsBar'
|
|
export default {
|
name: 'RightStatisticsUser',
|
components: { StatisticsBar, BarHorizontal, StatisticsPie, JSelectMultiProject, UploadTemplateModal, JMultiSelectTag },
|
mixins: [JeecgListMixin],
|
watch: {
|
extSource(newVal) {
|
if (newVal.length === 0) {
|
|
} else {
|
this.initColumns()
|
}
|
},
|
|
queryParam: {
|
immediate: true,
|
handler() {
|
|
}
|
}
|
},
|
data() {
|
return {
|
activeKey: ['1','2','3'],
|
locale,
|
moment,
|
queryType: 0,
|
dateFormat: 'YYYY-MM-DD',
|
description: '周报工时统计页面',
|
disableMixinCreated: true,
|
// 表头
|
columns: [],
|
tableWidth: 0,
|
//用户字典信息
|
userDictOptions: [],
|
|
url: {
|
list: '/wek/record/statisticsList',
|
exportXlsUrl: "/wek/record/exportXls",
|
}
|
}
|
},
|
|
methods: {
|
handleClick(){
|
//this.handleExportXls("demo")
|
|
},
|
onChange(e) {
|
let value = e.target.value
|
switch (value) {
|
case 1:
|
let lastWeek = getLastWeek(1)
|
this.initQuery(lastWeek.start, lastWeek.end)
|
break
|
case 2:
|
this.initQuery(this.week.start, this.week.end)
|
break
|
|
case 3:
|
let lastMonth = getLastMonth(1)
|
this.initQuery(lastMonth.start, lastMonth.end)
|
break
|
case 4:
|
let thisMonth = getLastMonth(0)
|
this.initQuery(thisMonth.start, thisMonth.end)
|
break
|
|
case 5:
|
let lastQuarter = getLastQuarter(1)
|
this.initQuery(lastQuarter.start, lastQuarter.end)
|
break
|
case 6:
|
let thisQuarter = getLastQuarter(0)
|
this.initQuery(thisQuarter.start, thisQuarter.end)
|
break
|
|
case 7:
|
let lastYear = getLastYear(1)
|
this.initQuery(lastYear.start, lastYear.end)
|
break
|
case 8:
|
let thisYear = getLastYear(0)
|
this.initQuery(thisYear.start, thisYear.end)
|
break
|
}
|
},
|
searchReset() {
|
this.queryParam = {}
|
//重置默认查询当年数据
|
let thisYear = getLastYear(0)
|
this.initQuery(thisYear.start, thisYear.end)
|
this.loadData(1)
|
},
|
onDateChange: function(value, dateString) {
|
this.queryParam.ksrq = dateString[0]
|
this.queryParam.jsrq = dateString[1]
|
this.$forceUpdate()
|
},
|
|
handleMenuClick(e) {
|
if (e.key == 1) {
|
this.batchDel()
|
}
|
},
|
download(record) {
|
this.downloadFile(record.filePath)
|
},
|
initColumns() {
|
let itemWidth = 60
|
this.columns = []
|
let width = this.$refs.table.$el.offsetWidth
|
let dataWidth = 300 + 50 + 60 + this.extSource.length * itemWidth
|
|
if (dataWidth > width) {
|
this.tableWidth = dataWidth
|
} else {
|
this.tableWidth = 0
|
itemWidth = (width - 300 - 50 - 60) / this.extSource.length
|
}
|
|
|
this.columns.push({
|
title: '序号',
|
dataIndex: '',
|
key: 'rowIndex',
|
fixed: 'left',
|
align: 'center',
|
width: 50,
|
customRender: function(t, r, index) {
|
return parseInt(index) + 1
|
}
|
})
|
this.columns.push({
|
title: '项目',
|
dataIndex: 'xmName',
|
width: 300,
|
fixed: 'left',
|
scopedSlots: { customRender: 'esContent' }
|
})
|
this.extSource.forEach(item => {
|
this.columns.push({
|
title: this.getDictText(item.name),
|
dataIndex: item.name,
|
width: itemWidth,
|
align: 'center',
|
scopedSlots: { customRender: 'tag' }
|
})
|
})
|
|
this.columns.push({
|
title: '合计',
|
dataIndex: 'hj',
|
align: 'center',
|
width: 60,
|
fixed: 'right',
|
scopedSlots: { customRender: 'total' }
|
})
|
|
this.$nextTick(() => {
|
window.dispatchEvent(new Event('resize'))
|
})
|
|
},
|
initDictConfig() {
|
//初始化字典 - 性别
|
initDictOptions('sys_user,realname,username').then((res) => {
|
if (res.success) {
|
this.$set(this.userDictOptions, 'username', res.result)
|
if (this.extSource) {
|
this.initColumns()
|
}
|
}
|
})
|
|
},
|
getDictText(text) {
|
return filterMultiDictText(this.userDictOptions['username'], text)
|
},
|
initQuery(start, end) {
|
this.queryParam.ksrq = start
|
this.queryParam.jsrq = end
|
this.queryParam.dateRange = [
|
moment(start, this.dateFormat),
|
moment(end, this.dateFormat)
|
]
|
this.$forceUpdate()
|
this.loadData()
|
}
|
},
|
|
|
created() {
|
this.initDictConfig()
|
//默认查询上周数据
|
let lastWeek = getLastWeek(1)
|
this.initQuery(lastWeek.start, lastWeek.end)
|
this.loadData()
|
},
|
computed: {
|
week() {
|
return getWeek()
|
}
|
}
|
}
|
</script>
|
|
<style lang='less' scoped>
|
|
/deep/ .table-page-search-wrapper .ant-form-inline .ant-form-item .ant-form-item-control {
|
height: auto;
|
}
|
|
/deep/ .ant-collapse-content-box {
|
margin: 0;
|
padding: 0;
|
}
|
</style>
|