Commit fa9f9b69 authored by ccc2wdd's avatar ccc2wdd

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

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