Commit fa9f9b69 authored by ccc2wdd's avatar ccc2wdd

结算管理,统计页面有初始年份和季度

parent e173f956
...@@ -14,31 +14,46 @@ ...@@ -14,31 +14,46 @@
bordered bordered
:loading="loadingRef" :loading="loadingRef"
:rowClassName="setRowClassName" :rowClassName="setRowClassName"
:scroll="{ x: 1300,y: 350 }" :scroll="{ x: 1300, y: 350 }"
> />
</Table>
</PageCard> </PageCard>
<StatisticWindow @register="register" /> <StatisticWindow @register="register" />
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { onMounted, ref } from 'vue'; import { onMounted, ref } from 'vue';
import { Table } from 'ant-design-vue'; import { Table } from 'ant-design-vue';
import { getListAll,exportStatisticList } from '@/api/project/settlementManage'; import { getListAll, exportStatisticList } from '@/api/project/settlementManage';
import {BasicForm, FormActionType, FormSchema, useForm} from '@/components/Form'; import { BasicForm, FormActionType, FormSchema, useForm } from '@/components/Form';
import StatisticWindow from '@/views/monthlyPlan/statisticWindow/statisticWindow.vue'; import StatisticWindow from '@/views/monthlyPlan/statisticWindow/statisticWindow.vue';
import { useModal } from '@/components/Modal'; import { useModal } from '@/components/Modal';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
import PageCard from '@/components/Page/src/PageCard.vue'; import PageCard from '@/components/Page/src/PageCard.vue';
import { downloadByData } from '@/utils/file/download'; import { downloadByData } from '@/utils/file/download';
import { useUserStore } from '@/store/modules/user'; import { useUserStore } from '@/store/modules/user';
import moment from 'moment';
const seach = ref([ const currentMonth = moment().format('MM');
const currentquarter = getQuarter();
function getQuarter() {
if (currentMonth <= 3) {
return '第一季度';
} else if (currentMonth <= 6) {
return '第二季度';
} else if (currentMonth <= 9) {
return '第三季度';
} else {
return '第四季度';
}
}
const params = ref({ givenYear: '', quarter: '', deptId: '' });
const seach = ref([
{ {
field: 'givenYear', field: 'givenYear',
label: '', label: '',
component: 'DatePicker', component: 'DatePicker',
componentProps: { componentProps: {
defaultValue: moment().format('YYYY'),
placeholder: '年份', placeholder: '年份',
picker: 'year', picker: 'year',
valueFormat: 'YYYY', valueFormat: 'YYYY',
...@@ -55,6 +70,7 @@ const seach = ref([ ...@@ -55,6 +70,7 @@ const seach = ref([
component: 'Select', component: 'Select',
componentProps: { componentProps: {
placeholder: '季度', placeholder: '季度',
defaultValue: currentquarter,
options: [ options: [
{ {
label: '第一季度', label: '第一季度',
...@@ -76,62 +92,66 @@ const seach = ref([ ...@@ -76,62 +92,66 @@ const seach = ref([
}, },
colProps: { span: 4 }, colProps: { span: 4 },
}, },
]) ]);
const deptId = ref(''); const deptId = ref('');
onMounted(async () => { onMounted(async () => {
deptId.value = useUserStore().userInfo.deptId; deptId.value = useUserStore().userInfo.deptId;
// 设置当前年份
params.value.givenYear = moment().format('YYYY');
// 设置当前季度
params.value.quarter = currentquarter;
getStatisticList(); getStatisticList();
}); });
// defineOptions({ name: 'MonthlyPlan' }); // defineOptions({ name: 'MonthlyPlan' });
const [register, { openModal: openModal }] = useModal(); const [register, { openModal: openModal }] = useModal();
const formElRef = ref<Nullable<FormActionType>>(null); const formElRef = ref<Nullable<FormActionType>>(null);
const [registerForm, { getFieldsValue }] = useForm({ const [registerForm, { getFieldsValue }] = useForm({
labelWidth: 90, labelWidth: 90,
baseColProps: { span: 24 }, baseColProps: { span: 24 },
schemas: seach, schemas: seach,
showActionButtonGroup: false, showActionButtonGroup: false,
}); });
async function exportCount() { async function exportCount() {
const params = getFieldsValue(); const data = await exportStatisticList(params.value);
const data = await exportStatisticList(params);
downloadByData(data, '结算管理统计报表' + '.xls'); downloadByData(data, '结算管理统计报表' + '.xls');
} }
const loadingRef = ref(false); const loadingRef = ref(false);
function handleSubmit() { function handleSubmit() {
let data = getFieldsValue();
params.value = data;
getStatisticList(); getStatisticList();
} }
function setRowClassName(record) { function setRowClassName(record) {
if (record.projectName === '总计(万元)') { if (record.projectName === '总计(万元)') {
return 'rowcolor'; return 'rowcolor';
} }
if (record.companyName === '合计(万元)'){ if (record.companyName === '合计(万元)') {
return 'rowcolor'; return 'rowcolor';
} else { } else {
return; return;
} }
} }
function getCurrentDateFormatted() { function getCurrentDateFormatted() {
const now = new Date(); const now = new Date();
const year = now.getFullYear(); const year = now.getFullYear();
const month = (now.getMonth() + 1).toString().padStart(2, '0'); // 月份从0开始,所以要加1,并且格式化为两位数 const month = (now.getMonth() + 1).toString().padStart(2, '0'); // 月份从0开始,所以要加1,并且格式化为两位数
return `${year}-${month}`; return `${year}-${month}`;
} }
async function getStatisticList() { async function getStatisticList() {
const params = getFieldsValue();
loadingRef.value = true; loadingRef.value = true;
let data = await getListAll(params); let data = await getListAll(params.value);
// dataSource.value = data; // dataSource.value = data;
let propsList = ['companyName','projectName']; let propsList = ['companyName', 'projectName'];
propsList.map((item) => { propsList.map((item) => {
changeData(data, item); changeData(data, item);
}); });
loadingRef.value = false; loadingRef.value = false;
} }
function changeData(data, field) { function changeData(data, field) {
if (field == 'companyName'){ if (field == 'companyName') {
let count = 0; //重复项的第一项 let count = 0; //重复项的第一项
let indexCount = 1; //下一项 let indexCount = 1; //下一项
while (indexCount < data.length) { while (indexCount < data.length) {
...@@ -149,7 +169,7 @@ function changeData(data, field) { ...@@ -149,7 +169,7 @@ function changeData(data, field) {
indexCount++; indexCount++;
} }
} }
if (field == 'projectName'){ if (field == 'projectName') {
let count = 0; //重复项的第一项 let count = 0; //重复项的第一项
let indexCount = 1; //下一项 let indexCount = 1; //下一项
while (indexCount < data.length) { while (indexCount < data.length) {
...@@ -157,7 +177,10 @@ function changeData(data, field) { ...@@ -157,7 +177,10 @@ function changeData(data, field) {
if (!item[`${field}rowSpan`]) { if (!item[`${field}rowSpan`]) {
item[`${field}rowSpan`] = 1; //初始化为1 item[`${field}rowSpan`] = 1; //初始化为1
} }
if (item[field] === data[indexCount][field] && item['companyName'] === data[indexCount]['companyName']) { if (
item[field] === data[indexCount][field] &&
item['companyName'] === data[indexCount]['companyName']
) {
//第一个对象与后面的对象相比,有相同项就累加,并且后面相同项设置为0 //第一个对象与后面的对象相比,有相同项就累加,并且后面相同项设置为0
item[`${field}rowSpan`]++; item[`${field}rowSpan`]++;
data[indexCount][`${field}rowSpan`] = 0; data[indexCount][`${field}rowSpan`] = 0;
...@@ -169,12 +192,12 @@ function changeData(data, field) { ...@@ -169,12 +192,12 @@ function changeData(data, field) {
} }
} }
dataSource.value = data; dataSource.value = data;
} }
// 列表 // 列表
const dataSource = ref([]); const dataSource = ref([]);
// 表头 // 表头
const columns = [ const columns = [
{ {
title: '公司名称', title: '公司名称',
dataIndex: 'companyName', dataIndex: 'companyName',
...@@ -239,13 +262,13 @@ const columns = [ ...@@ -239,13 +262,13 @@ const columns = [
dataIndex: 'sumOfMoney', dataIndex: 'sumOfMoney',
width: 180, width: 180,
}, },
]; ];
const { push } = useRouter(); const { push } = useRouter();
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
::v-deep .ant-table-tbody .ant-table-row { ::v-deep .ant-table-tbody .ant-table-row {
&.rowcolor .ant-table-cell-fix-left { &.rowcolor .ant-table-cell-fix-left {
background-color: #f5f5f5; background-color: #f5f5f5;
} }
} }
</style> </style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment