2月3日提交是否维度和合计功能
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
:data="tableData"
|
||||
:option="tableOption"
|
||||
v-bind="crudBind"
|
||||
:summary-method=summaryMethod1
|
||||
@search-change="searchChange"
|
||||
@search-reset="resetChange"
|
||||
@refresh-change="refreshChange"
|
||||
@@ -66,8 +67,8 @@
|
||||
:column="scope.column"
|
||||
></InputTimeRange>
|
||||
</template>
|
||||
<template #page>
|
||||
合计:
|
||||
<template #header>
|
||||
|
||||
</template>
|
||||
</avue-crud>
|
||||
</div>
|
||||
@@ -117,8 +118,8 @@ const numberRange = ref<string[]>([])
|
||||
const dateRange=ref<string[]>([])
|
||||
const dateTimeRange=ref<string[]>([])
|
||||
const timeRange=ref<string[]>([])
|
||||
|
||||
|
||||
const amountFieds=ref<any>({})
|
||||
const amountObj=ref<any>({})
|
||||
const crudRef = ref()
|
||||
|
||||
const exportLoading = ref(false)
|
||||
@@ -133,6 +134,24 @@ const crudBind = computed(() => {
|
||||
return obj
|
||||
})
|
||||
|
||||
const setLastAmountRowClass=(row,rowIndex)=>{
|
||||
if(row.isAmount===true){
|
||||
return 'lastAmountRow'
|
||||
}
|
||||
}
|
||||
const summaryMethod1=({columns,data})=>{
|
||||
// 1. 初始化汇总结果数组(和表格列数量一致)
|
||||
const result = new Array(columns.length).fill("");
|
||||
result[0] = `合计`;
|
||||
|
||||
let keys=Object.values(amountFieds.value).map(item=>item.prop)
|
||||
columns.forEach((item,index)=>{
|
||||
if(keys.includes(item.property)){
|
||||
result[index]=amountObj.value[item.property]
|
||||
}
|
||||
})
|
||||
return result;
|
||||
}
|
||||
const initTable = async () => {
|
||||
isInit.value = false
|
||||
loading.value = true
|
||||
@@ -152,6 +171,8 @@ const initTable = async () => {
|
||||
index: reportVo.tableConfig.includes('index'),
|
||||
border: reportVo.tableConfig.includes('border'),
|
||||
stripe: reportVo.tableConfig.includes('stripe'),
|
||||
showSummary:true,
|
||||
|
||||
column: {}
|
||||
}
|
||||
//国际化处理
|
||||
@@ -160,7 +181,7 @@ const initTable = async () => {
|
||||
mergeLocaleMessage(key, { [props.reportCode]: fieldLengObj[key] })
|
||||
}
|
||||
//字段处理
|
||||
fieldList.forEach((item) => {
|
||||
fieldList.forEach((item,index) => {
|
||||
const config: any = {
|
||||
prop: item.fieldCode,
|
||||
label: t(`${props.reportCode}.${item.fieldCode}`),
|
||||
@@ -168,7 +189,11 @@ const initTable = async () => {
|
||||
overHidden: true,
|
||||
isExport: item.isExport == 'Y',
|
||||
sortable: item.isShowSort == 'Y' ? 'custom' : false,
|
||||
search: item.queryIsWeb == 'Y'
|
||||
search: item.queryIsWeb == 'Y',
|
||||
}
|
||||
if(!!item.isAmount){
|
||||
index==0?amountFieds.value.fistField=config.prop:''
|
||||
amountFieds.value[item.isAmount]=config
|
||||
}
|
||||
if (item.queryMode == 'RANGE') config.searchRange = true
|
||||
if (['Integer', 'BigInt', 'BigDecimal'].includes(item.fieldType)) config.type = 'number'
|
||||
@@ -275,6 +300,30 @@ const getTableData = async (isLoading = true) => {
|
||||
const data = await ReportApi.getTableList(props.reportCode, searchObj)
|
||||
if (tablePage.value) tablePage.value['total'] = data.total
|
||||
tableData.value = data.records
|
||||
// amountFieds.value={
|
||||
// 'thissaqty_s':{
|
||||
// prop:'thissaqty',
|
||||
// },
|
||||
// "monthsaqty_s":{
|
||||
// prop:'monthsaqty',
|
||||
//},
|
||||
//'lastsaqty_s':{
|
||||
// prop:'lastsaqty'
|
||||
//}
|
||||
//}
|
||||
//tableData.value[0]['thissaqty_s']=6083195687
|
||||
// tableData.value[0]['monthsaqty_s']=972705058
|
||||
// tableData.value[0]['lastsaqty_s']=6075936725
|
||||
|
||||
let keys=Object.keys(amountFieds.value)
|
||||
if(!!keys.length&&!!tableData.value.length){
|
||||
let obj={isAmount:true}
|
||||
keys.forEach(item=>{
|
||||
let key=amountFieds.value[item].prop
|
||||
key!=='fistField'?obj[key]=tableData.value[0][item]:''
|
||||
})
|
||||
amountObj.value=obj
|
||||
}
|
||||
resolve(data.records)
|
||||
} finally {
|
||||
if (isLoading) loading.value = false
|
||||
@@ -382,4 +431,16 @@ defineExpose({
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
<style lang="scss" scoped>
|
||||
.amountBox{
|
||||
&::after{
|
||||
content:'、'
|
||||
}
|
||||
&:last-of-type::after{
|
||||
content:''
|
||||
}
|
||||
}
|
||||
.lastAmountRow{
|
||||
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -101,6 +101,7 @@ export const useRenderVxeColumn = (useType = 'table') => {
|
||||
return <el-checkbox v-model={row[column.field]} true-value={row.fieldCode+'_s'} false-value="" />
|
||||
}
|
||||
},
|
||||
|
||||
LowSelect: {
|
||||
default: (renderOpts, { row, column }, isStop = false) => {
|
||||
if (column.field == 'dictType' && !row[column.field] && infoTableIsEdit({ row, column }, renderOpts)) {
|
||||
|
||||
@@ -156,7 +156,9 @@ const infoColumn = {
|
||||
queryMode: { title: '查询模式', width: 130, editRender: { name: 'LowSelect', verifyEdit: true, dicData: dicObj.queryMode, dicObj: getDicObj('queryMode') } },
|
||||
dictCode: { title: '字典Code', width: 180, editRender: { name: 'LowSelect', verifyEdit: true, filterable: true, noStop: true, dicData: [] } },
|
||||
isExport: { title: '是否可导出', width: 90, align: "center", editRender: { name: 'LowCheckbox' } },
|
||||
isSort: { title: '是否合计', width: 75, align: "center", editRender: { name: 'LowCheckboxSum' } },
|
||||
isAmount: { title: '是否合计', width: 75, align: "center", editRender: { name: 'LowCheckboxSum' } },
|
||||
isDimension: { title: '是否维度', width: 75, align: "center", editRender: { name: 'LowCheckbox' } },
|
||||
|
||||
isShowSort: { title: '是否排序', width: 75, align: "center", editRender: { name: 'LowCheckbox' } },
|
||||
},
|
||||
}
|
||||
@@ -174,7 +176,7 @@ for (const key in infoColumn) {
|
||||
//默认值
|
||||
const infoDefaultData = {
|
||||
basics: {
|
||||
fieldCode: '', fieldName: '', labelI18n: '', fieldType: 'String', queryIsDb: 'N', queryIsWeb: 'N', queryMode: 'LIKE', dictCode: '', isExport: 'Y', isShowSort: 'N',isSort:''
|
||||
fieldCode: '', fieldName: '', labelI18n: '', fieldType: 'String', queryIsDb: 'N', queryIsWeb: 'N', queryMode: 'LIKE', dictCode: '', isExport: 'Y', isShowSort: 'N',isAmount:'',isDimension:''
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user