修改测试问题及优化项

This commit is contained in:
fks-xuxinyue
2024-08-28 17:34:54 +08:00
parent c21a79da87
commit 06e0ec7425
10 changed files with 454 additions and 151 deletions

View File

@@ -1,3 +1,5 @@
import { quickCalculation, carbonEmissionFactorLibrary } from '/@/api/carbonEmissionFactorLibrary';
import { ref } from 'vue';
// 凭证弹窗表头
export const voucherColumns = [
{
@@ -9,8 +11,8 @@ export const voucherColumns = [
},
{
title: '日期',
dataIndex: 'updateTime',
key: 'updateTime',
dataIndex: 'bizName',
key: 'bizName',
ellipsis: true,
},
{
@@ -42,3 +44,107 @@ export const drawerColumns = [
dataIndex: 'dataSources',
},
];
export const setFactorConfig = (orgId) => {
return ref({
api: carbonEmissionFactorLibrary.getTableList,
params: { orgId, pageNum: 1, pageSize: 9999, emissionList: [0] },
treeConfig: {
header: {
icon: 'deviceType',
title: '排放分类',
},
params: { orgId},
dynamicParams: { emissionList: 'id[]' },
defaultExpandAll: true,
// checkable:true,
api: carbonEmissionFactorLibrary.getCarbonFactorTree,
fieldNames: { title: 'emissionName', key: 'id' },
formConfig: {
schemas: [
{
field: 'deviceType',
label: '设备名称',
component: 'NsInput',
autoSubmit: true,
componentProps: {
placeholder: '请输入关键字',
},
},
],
},
},
rowSelection: { type: 'radio' },
columns: [
{
title: '序号',
textNumber: 2,
dataIndex: 'address',
customRender: (text: any) => {
return text.index + 1;
},
},
{
title: '名称',
dataIndex: 'emissionSources',
textNumber: 3,
},
{
title: '排放因子',
dataIndex: 'emissionFactors',
textNumber: 4,
textEllipsis: true,
},
{
title: '排放因子单位',
dataIndex: 'emissionFactorUnits',
width: 100,
textEllipsis: true,
},
{
title: '排放环节',
dataIndex: 'emissionProcess',
textWidth: 88,
textEllipsis: true,
},
{
title: '数据来源',
dataIndex: 'dataSources',
textNumber: 5,
textEllipsis: true,
},
],
formConfig: {
schemas: [
{
field: 'emissionSources',
label: '排放源',
component: 'NsInput',
componentProps: {
placeholder: '请输入排放源',
maxLength: 20,
},
},
{
field: 'emissionProcess',
label: '排放环节',
component: 'NsSelectApi',
componentProps: {
placeholder: '请选择排放环节',
api: carbonEmissionFactorLibrary.gasAndDatabase,
resultField: 'data',
params: {
orgId: orgId.value,
type: 'emissionProcess',
},
immediate: true,
labelField: 'label',
valueField: 'value',
},
},
],
params: {},
},
// pagination: { pageSizeOptions: false },
rowKey: 'id',
});
};

View File

@@ -106,8 +106,13 @@
<span>{{ data.emissionSource }}</span>
</div>
<div class="actionMore">
<EditOutlined @click="editUnit(data)" />
<MinusCircleOutlined style="margin-left: 6px" @click="delUnit(data)" />
<EditOutlined
@click="editUnit(data)"
v-if="data.emissionSource !== '全部'" />
<MinusCircleOutlined
v-if="data.emissionSource !== '全部'"
style="margin-left: 6px"
@click="delUnit(data)" />
<PlusCircleOutlined
v-if="data.emissionSource === '全部'"
style="margin-left: 6px"
@@ -131,7 +136,7 @@
:pagination="false"
bordered
size="middle"
:scroll="{ y: 380 }">
:scroll="{ x: 660, y: 380 }">
<template #title>
<a-button type="primary" @click="downLoadVoucher">凭证</a-button>
</template>
@@ -373,20 +378,21 @@
@keydown="handleKeyDown" />
</a-form-item>
</a-col>
<a-col :span="24">
<!-- <a-col :span="24">
<a-form-item ref="name" label="关键字" name="key">
<a-input-search
v-model:value="editFormState.key"
@search="searchKey"
placeholder="请输入关键字" />
</a-form-item>
</a-col>
</a-col> -->
</a-row>
</a-form>
</a-spin>
<div class="ns-form-title-edit" style="display: flex">
<!-- <div class="ns-form-title-edit" style="display: flex">
<div class="titleEdit">因子列表</div>
</div>
</div> -->
<a-button type="primary" style="margin-bottom: 10px" @click="selectFactor">选择因子</a-button>
<a-table
:columns="drawerColumns"
:data-source="newTableData"
@@ -430,14 +436,23 @@
<inbox-outlined></inbox-outlined>
</p>
<p class="ant-upload-hint">1.仅支持pdf格式文件或文件夹</p>
<p class="ant-upload-hint">2.文件名命名规则为能源种类_年份</p>
<p class="ant-upload-hint">3.每次上传自动覆盖</p>
<p class="ant-upload-hint">2.每次上传自动覆盖</p>
</a-upload-dragger>
<template #footer>
<a-button style="margin-right: 8px" @click="onCloseEditData">取消</a-button>
<a-button type="primary" @click="submitEditData">确定</a-button>
</template>
</a-drawer>
<!-- 选择因子 -->
<a-modal
v-model:visible="openVisible"
v-if="openVisible"
width="60%"
title="选择因子"
@ok="btnClick"
@cancel="onCloseClick">
<ns-view-list-table v-bind="config" ref="setFactorRef" style="height: 500px" />
</a-modal>
</div>
</template>
@@ -464,6 +479,8 @@
import { group } from '/@/api/deviceManage';
import { debug, log } from 'node:console';
import { dict } from '/@/api';
import { NsMessage } from '/nerv-lib/saas';
import { setFactorConfig } from '../config';
defineOptions({
energyType: 'fillInPage', // 与页面路由name一致缓存才可生效
components: {
@@ -673,12 +690,14 @@
}
};
// 获取表头单位
const carbonEmission = ref();
const getTableHeardUnit = (id) => {
fetch(carbonInventoryCheck.findUnitById, { id: id }).then((res) => {
if (res.data) {
columns.value[1].title = '消耗量【' + res.data.unit + '】';
columns.value[2].title = '碳排因子【' + res.data.carbonEmission + '】';
columns.value[3].title = '排放量【' + res.data.carbonUnits + '】';
carbonEmission.value = res.data.carbonEmission;
}
});
};
@@ -879,6 +898,7 @@
{
title: '日期',
dataIndex: 'acquisitionDate',
width: 80,
key: 'acquisitionDate',
},
{
@@ -887,11 +907,13 @@
{
title: '数据来源',
dataIndex: 'dataSources',
width: 100,
key: 'dataSources',
},
{
title: '数值',
dataIndex: 'consumption',
width: 100,
key: 'consumption',
},
],
@@ -902,11 +924,13 @@
{
title: '数据来源',
dataIndex: 'carbonSource',
width: 100,
key: 'carbonSource',
},
{
title: '数值',
dataIndex: 'emissionFactors',
width: 100,
key: 'emissionFactors',
},
],
@@ -914,6 +938,7 @@
{
title: '排放量',
dataIndex: 'emissions',
width: 100,
key: 'emissions',
fixed: 'right',
},
@@ -1069,12 +1094,23 @@
// 获取能耗类型
const options = await dict({ params: { dicKey: 'ENERGY_TYPE' } });
energyTypeOptions.value = options.data.data;
editFormState.value.key = record.factorName;
editFormState.value.key = record.factorId;
searchKey();
editFormState.value.id = record.id;
editFormState.value.dataSources = record.dataSources;
if (record.dataSources !== undefined) {
if (record.dataSources.value === 3) {
canEdit.value = true;
automatic.value = true;
} else {
canEdit.value = false;
automatic.value = false;
}
}
editFormState.value.consumption = record.consumption;
editFormState.value.collectionNode = record.carbonSource;
editFormState.value.energyConsumptionType = record.energyConsumptionType;
changeEnergyType(record.energyConsumptionType);
editFormState.value.collectionNode = record.collectionNode;
editFormState.value.factorId = record.factorId;
editFormState.value.emissionFactors = record.emissionFactors;
selectedRowKeysEdit.value = [record.factorId];
@@ -1097,9 +1133,9 @@
};
const searchKey = () => {
if (editFormState.value.key) {
queryData.value.emissionSources = editFormState.value.key;
queryData.value.factorId = editFormState.value.key;
} else {
queryData.value.emissionSources = '';
queryData.value.factorId = 0;
}
getNewTable();
};
@@ -1137,6 +1173,7 @@
};
const spinning = ref(false);
const selectNode = (value) => {
editFormState.value.collectionNode = value;
spinning.value = true;
const getConsumeData = ref({
acquisitionDate: acquisitionDate.value,
@@ -1198,9 +1235,9 @@
if (editFormState.value.dataSources.value) {
editFormState.value.dataSources = editFormState.value.dataSources.value;
}
if (editFormState.value.collectionNode) {
editFormState.value.collectionNode = editFormState.value.collectionNode.value;
}
// if (editFormState.value.collectionNode) {
// editFormState.value.collectionNode = editFormState.value.collectionNode.value;
// }
fetch(carbonInventoryCheck.updateTable, editFormState.value).then((res) => {
if (fileList.value.length !== 0) {
const formData = ref(new FormData());
@@ -1235,6 +1272,32 @@
console.log('error', error);
});
};
const openVisible = ref(false);
const setFactorRef = ref();
const config = setFactorConfig(orgId.value);
const selectFactor = () => {
openVisible.value = true;
};
const btnClick = () => {
let selectRowKeys = setFactorRef.value?.nsTableRef.tableState.selectedRowKeys;
if (selectRowKeys.length === 0) {
NsMessage.warn('请选择因子');
return;
} else {
if (newTableData.value.emissionFactorUnits === carbonEmission.value) {
newTableData.value = setFactorRef.value?.nsTableRef.tableState.selectedRows;
selectedRowKeysEdit.value = setFactorRef.value?.nsTableRef.tableState.selectedRowKeys;
editFormState.value.emissionFactors = newTableData.value[0].emissionFactors;
editFormState.value.factorId = selectedRowKeysEdit.value[0];
openVisible.value = false;
} else {
NsMessage.warn('因子值单位不统一,请重新选择!');
}
}
};
const onCloseClick = () => {
openVisible.value = false;
};
const onCloseEditData = () => {
editData.value = false;
delIds.value = [];
@@ -1249,7 +1312,7 @@
const onChange = (pageNumber: number, size: number) => {
queryData.value.pageNum = pageNumber;
queryData.value.pageSize = size;
getNewTable();
// getNewTable();
};
// 点击切换排放统计/碳排流向
const fillInPage = ref(true);
@@ -1730,9 +1793,11 @@
.mainLeft {
width: 19%;
margin-right: 1%;
border-right: 1px solid #f2f2f2;
position: relative;
height: 96%;
height: 100%;
border: 1px solid #f2f2f2;
border-radius: 8px;
padding: 4px;
.treeRow {
display: flex;
justify-content: space-between;
@@ -1757,6 +1822,7 @@
}
.mainRight {
width: 80%;
border-left: 1px solid #f2f2f2;
}
}

View File

@@ -79,7 +79,7 @@
</template>
<script lang="ts" setup>
import { ref, toRaw } from 'vue';
import { ref, toRaw, watch, nextTick } from 'vue';
import { http } from '/nerv-lib/util/http';
import { carbonInventoryCheck } from '/@/api/carbonEmissionFactorLibrary';
import fillIn from './fillInPage/index.vue';
@@ -118,7 +118,10 @@
const openChange = (status) => {
if (status === false) {
if (formState.value.reportYear) {
defaultPickerValue.value = [dayjs('2022'), dayjs('2022')];
defaultPickerValue.value = [
dayjs(formState.value.reportYear),
dayjs(formState.value.reportYear),
];
}
}
};