Browse Source

修改测试问题

temp
fks-xuxinyue 1 month ago
parent
commit
196f7de9b4
  1. BIN
      hx-ai-intelligent/public/asset/file/emissionSource.xlsx
  2. 1
      hx-ai-intelligent/src/api/carbonEmissionFactorLibrary.ts
  3. 87
      hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionFactorLibrary/config.ts
  4. 20
      hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionFactorLibrary/index.vue
  5. 251
      hx-ai-intelligent/src/view/carbonEmissionManage/carbonPlanning/category/categoryDeatil.vue

BIN
hx-ai-intelligent/public/asset/file/emissionSource.xlsx

Binary file not shown.

1
hx-ai-intelligent/src/api/carbonEmissionFactorLibrary.ts

@ -106,5 +106,6 @@ export enum carbonPlanning {
batchOrUpdate = '/carbon-smart/api/carbon/planning/batchOrUpdate', batchOrUpdate = '/carbon-smart/api/carbon/planning/batchOrUpdate',
addNodes = '/carbon-smart/api/carbon/planning/addNodes', addNodes = '/carbon-smart/api/carbon/planning/addNodes',
benchmarkSetting = '/carbon-smart/api/carbon/planning/benchmarkSetting', benchmarkSetting = '/carbon-smart/api/carbon/planning/benchmarkSetting',
monthBenchmarkSetting = '/carbon-smart/api/carbon/planning/monthBenchmarkSetting',
benchmarkSubmit = '/carbon-smart/api/carbon/planning/benchmarkSubmit', benchmarkSubmit = '/carbon-smart/api/carbon/planning/benchmarkSubmit',
} }

87
hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionFactorLibrary/config.ts

@ -17,12 +17,12 @@ export const formConfig = (disabled) => {
placeholder: '请输入排放源', placeholder: '请输入排放源',
maxLength: 20, maxLength: 20,
}, },
// rules: [ rules: [
// { {
// required: true, required: true,
// message: '请输入排放源', message: '请输入排放源',
// }, },
// ], ],
}, },
{ {
field: 'emissionType', field: 'emissionType',
@ -38,12 +38,12 @@ export const formConfig = (disabled) => {
fieldNames: { label: 'emissionName', value: 'id' }, fieldNames: { label: 'emissionName', value: 'id' },
showSearch: true, showSearch: true,
}, },
// rules: [ rules: [
// { {
// required: true, required: true,
// message: '请选择排放分类', message: '请选择排放分类',
// }, },
// ], ],
}, },
{ {
field: 'emissionGas', field: 'emissionGas',
@ -79,12 +79,12 @@ export const formConfig = (disabled) => {
}, },
], ],
}, },
// rules: [ rules: [
// { {
// required: true, required: true,
// message: '请选择排放气体', message: '请选择排放气体',
// }, },
// ], ],
}, },
{ {
label: '排放环节', label: '排放环节',
@ -94,12 +94,12 @@ export const formConfig = (disabled) => {
placeholder: '请输入排放环节', placeholder: '请输入排放环节',
maxLength: 20, maxLength: 20,
}, },
// rules: [ rules: [
// { {
// required: true, required: true,
// message: '请输入排放环节', message: '请输入排放环节',
// }, },
// ], ],
}, },
{ {
label: '排放因子', label: '排放因子',
@ -109,13 +109,13 @@ export const formConfig = (disabled) => {
placeholder: '请输入排放因子值', placeholder: '请输入排放因子值',
maxLength: 20, maxLength: 20,
}, },
// rules: [ rules: [
// { {
// required: true, required: true,
// message: '请输入排放因子值', message: '请输入排放因子值',
// trigger: 'change', trigger: 'change',
// }, },
// ], ],
}, },
{ {
field: 'carbonEmissionPrefix', field: 'carbonEmissionPrefix',
@ -141,12 +141,12 @@ export const formConfig = (disabled) => {
}, },
], ],
}, },
// rules: [ rules: [
// { {
// required: true, required: true,
// message: '请选择碳排前缀', message: '请选择碳排前缀',
// }, },
// ], ],
}, },
{ {
label: '碳排后缀', label: '碳排后缀',
@ -156,17 +156,18 @@ export const formConfig = (disabled) => {
placeholder: '请输入碳排后缀', placeholder: '请输入碳排后缀',
maxLength: 20, maxLength: 20,
}, },
// rules: [ rules: [
// { {
// required: true, required: true,
// message: '请输入碳排后缀', message: '请输入碳排后缀',
// }, },
// ], ],
}, },
{ {
label: '已引用数', label: '已引用数',
field: 'numberOfReferences', field: 'numberOfReferences',
component: 'NsInput', component: 'NsInput',
show:disabled,
componentProps: { componentProps: {
defaultValue: '', defaultValue: '',
disabled: true, disabled: true,

20
hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionFactorLibrary/index.vue

@ -12,6 +12,7 @@
<a-input-search <a-input-search
v-model:value="selectTreeDataValue" v-model:value="selectTreeDataValue"
placeholder="请输入关键词" placeholder="请输入关键词"
allowClear
@search="onSearchTreeData" /> @search="onSearchTreeData" />
</a-col> </a-col>
</a-row> </a-row>
@ -274,7 +275,8 @@
watchEffect(() => { watchEffect(() => {
disabled.value = opMap.value.type === 'edit'; disabled.value = opMap.value.type === 'edit';
}); });
const formSchema = formConfig(disabled); const show = ref(true);
const formSchema = formConfig(show);
const casData = ref([]); const casData = ref([]);
const treeData = ref([]); const treeData = ref([]);
const userAuthList = ref([]); const userAuthList = ref([]);
@ -634,6 +636,7 @@
NsMessage.success('操作成功'); NsMessage.success('操作成功');
}); });
}; };
show.value = false;
visible.value = true; visible.value = true;
}, },
}, },
@ -808,6 +811,7 @@
NsMessage.success('操作成功'); NsMessage.success('操作成功');
}); });
}; };
show.value = true;
visible.value = true; visible.value = true;
}, },
}, },
@ -856,6 +860,7 @@
componentProps: { componentProps: {
placeholder: '请选择排放气体', placeholder: '请选择排放气体',
api: carbonEmissionFactorLibrary.gasAndDatabase, api: carbonEmissionFactorLibrary.gasAndDatabase,
resultField: 'data',
params: { params: {
orgId: orgId.value, orgId: orgId.value,
emissionList, emissionList,
@ -874,6 +879,7 @@
allowClear: true, allowClear: true,
placeholder: '请选择数据库名称', placeholder: '请选择数据库名称',
api: carbonEmissionFactorLibrary.gasAndDatabase, api: carbonEmissionFactorLibrary.gasAndDatabase,
resultField: 'data',
params: { params: {
orgId: orgId.value, orgId: orgId.value,
emissionList, emissionList,
@ -1181,4 +1187,16 @@
} }
} }
} }
:deep(
.ant-form-item-label
> label.ant-form-item-required:not(.ant-form-item-required-mark-optional)::before
) {
display: none !important;
}
:deep(.ant-form-item-label) {
z-index: 20;
text-align: right;
width: 27%;
}
</style> </style>
 

251
hx-ai-intelligent/src/view/carbonEmissionManage/carbonPlanning/category/categoryDeatil.vue

@ -93,7 +93,7 @@
<template #bodyCell="{ column, text, record }"> <template #bodyCell="{ column, text, record }">
<template v-if="column.key === 'action'"> <template v-if="column.key === 'action'">
<span> <span>
<a @click="editData(record)">修改</a> <a @click="editData(record)">修改预算值</a>
</span> </span>
</template> </template>
</template> </template>
@ -109,12 +109,6 @@
<a-select-option :value="0"></a-select-option> <a-select-option :value="0"></a-select-option>
</a-select> </a-select>
</a-form-item> </a-form-item>
<!-- <a-form-item label="计算方式">
<a-select ref="select" v-model:value="formState.countMethod">
<a-select-option value="0">手动</a-select-option>
<a-select-option value="1">自动</a-select-option>
</a-select>
</a-form-item> -->
<a-form-item label="折算率"> <a-form-item label="折算率">
<a-input v-model:value="formState.conversionRate" suffix="%" :disabled="disabled" /> <a-input v-model:value="formState.conversionRate" suffix="%" :disabled="disabled" />
</a-form-item> </a-form-item>
@ -124,40 +118,107 @@
</a-form> </a-form>
</a-modal> </a-modal>
<!-- 基准值设置 --> <!-- 基准值设置 -->
<a-drawer <a-modal :visible="visible" @ok="onSubmit" @cancel="onClose">
:visible="visible" <a-tooltip placement="top">
title="设置基准" <template #title>
:width="500" <span>月基准值设置使用基准年相应月份的数据作为当前年相应月份的基准值</span>
@close="onClose" </template>
:footer-style="{ textAlign: 'right' }"> <QuestionCircleOutlined style="position: absolute; right: 60px; top: 22px; z-index: 7" />
<div> 节点{{ props.nodeName }} </div> </a-tooltip>
<a-table <div style="display: flex; margin-top: 20px; justify-content: space-between">
:columns="drawerColumns" <span> 节点{{ props.nodeName }} </span>
:data-source="newTableData" <a-date-picker
bordered v-if="activeKey === '1'"
:rowKey="(record, index) => index" v-model:value="selectYear"
:rowSelection="{ picker="year"
selectedRowKeys: selectedRowKeysSet, valueFormat="YYYY"
onChange: onSelectionChangeSet, @change="changeYearData" />
type: 'radio', </div>
}" <a-tabs v-model:activeKey="activeKey" @change="handleTabChange">
:pagination="false"> <a-tab-pane key="1" tab="年基准值设置">
</a-table> <a-table
<template #footer> :columns="yearColumns"
<a-button style="margin-right: 8px" @click="onClose">取消</a-button> :data-source="yearTableData"
<a-button type="primary" @click="onSubmit">确定</a-button> bordered
</template> :rowKey="(record, index) => record.referenceYear"
</a-drawer> :rowSelection="{
selectedRowKeys: selectedRowKeysSet,
onChange: onSelectionChangeSet,
type: 'radio',
}"
:pagination="false">
</a-table>
</a-tab-pane>
<a-tab-pane key="2" tab="月基准值设置" force-render>
<a-table :columns="monthColumns" :data-source="dataSource" bordered :pagination="false">
<template #bodyCell="{ column, text, record }">
<template v-if="['referenceValue'].includes(column.dataIndex)">
<div>
<a-input
v-if="editableData[record.yearMonth]"
v-model:value="editableData[record.yearMonth][column.dataIndex]"
style="margin: -5px 0" />
<template v-else>
{{ text }}
</template>
</div>
</template>
<template v-else-if="column.dataIndex === 'operation'">
<div class="editable-row-operations">
<span v-if="editableData[record.yearMonth]">
<a-popconfirm
title="确定要保存?"
ok-text="确定"
cancel-text="取消"
@confirm="save(record.yearMonth)"
@cancel="cancel(record.yearMonth)">
<a>保存</a>
</a-popconfirm>
</span>
<span v-else>
<a-button
type="link"
@click="edit(record.yearMonth)"
:disabled="record.isAutoObtained === 0 ? true : false">
编辑
</a-button>
</span>
</div>
</template>
<template v-if="column.key === 'isAutoObtained'">
<a-switch
checked-children="是"
un-checked-children="否"
:checked="record.isAutoObtained === 0 ? true : false"
:class="{
'blue-background': record.isAutoObtained === 0 ? true : false,
'grey-background': record.isAutoObtained === 0 ? false : true,
}"
@click="changeSwitch(record)" />
</template>
</template>
</a-table>
</a-tab-pane>
</a-tabs>
</a-modal>
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { cloneDeep } from 'lodash-es';
import type { UnwrapRef } from 'vue';
import { ref, defineEmits, reactive, toRaw } from 'vue'; import { ref, defineEmits, reactive, toRaw } from 'vue';
import { http } from '/nerv-lib/util/http'; import { http } from '/nerv-lib/util/http';
import { CaretUpOutlined, CaretDownOutlined } from '@ant-design/icons-vue'; import {
CaretUpOutlined,
CaretDownOutlined,
QuestionCircleOutlined,
} from '@ant-design/icons-vue';
import { carbonPlanning } from '/@/api/carbonEmissionFactorLibrary'; import { carbonPlanning } from '/@/api/carbonEmissionFactorLibrary';
import * as echarts from 'echarts'; import * as echarts from 'echarts';
import { any, string } from 'vue-types'; import { any, string } from 'vue-types';
import type { Dayjs } from 'dayjs';
// id // id
const props = defineProps({ const props = defineProps({
parentId: { parentId: {
@ -185,6 +246,7 @@
const changeParentData = () => { const changeParentData = () => {
emit('change-data', true); emit('change-data', true);
}; };
const activeKey = ref('1');
// //
const selectedRowKeys = ref([]); const selectedRowKeys = ref([]);
const onSelectionChange = (selectedKeys, selectedRows) => { const onSelectionChange = (selectedKeys, selectedRows) => {
@ -243,6 +305,7 @@
{ {
title: '操作', title: '操作',
key: 'action', key: 'action',
width: 200,
}, },
]); ]);
@ -300,37 +363,114 @@
open.value = false; open.value = false;
}; };
const visible = ref(false); const visible = ref(false);
const selectYear = ref<Dayjs>();
const selectedRowKeysSet = ref([]); const selectedRowKeysSet = ref([]);
const referenceQuery = ref(); const referenceQuery = ref();
const onSelectionChangeSet = (selectedKeys, selectedRows) => { const onSelectionChangeSet = (selectedKeys, selectedRows) => {
selectedRowKeysSet.value = selectedKeys; selectedRowKeysSet.value = selectedKeys;
referenceQuery.value = selectedRows[0].referenceValue; referenceQuery.value = selectedRows[0].referenceValue;
}; };
const drawerColumns = [ const yearColumns = [
{ {
title: '年份', title: '年份',
dataIndex: 'year', dataIndex: 'referenceYear',
}, },
{ {
title: '用电量', title: '用电量',
dataIndex: 'referenceValue', dataIndex: 'referenceValue',
}, },
]; ];
const newTableData = ref([]); //
const queryData = ref({
orgId: orgId.value,
type: props.type,
itemizeId: props.parentId,
});
const changeYearData = () => {
queryData.value.referenceYear = selectYear.value;
setBasicData();
};
const yearTableData = ref([]);
const setBasicData = () => { const setBasicData = () => {
fetch(carbonPlanning.benchmarkSetting, { fetch(carbonPlanning.benchmarkSetting, queryData.value).then((res) => {
orgId: orgId.value, yearTableData.value = res.data;
type: props.type,
itemizeId: props.parentId,
}).then((res) => {
newTableData.value = res.data;
}); });
visible.value = true; visible.value = true;
}; };
const handleTabChange = (key) => {
console.log('Tab changed:', key);
//
if (key === '1') {
} else if (key === '2') {
if (selectedRowKeysSet.value) {
fetch(carbonPlanning.monthBenchmarkSetting, {
type: props.type,
referenceYear: selectedRowKeysSet.value[0],
year: props.year,
itemizeId: props.parentId,
orgId: orgId.value,
}).then((res) => {
monthData.value = res.data;
});
} else {
activeKey.value = '1';
}
}
};
//
const changeSwitch = (data: any) => {
data.isAutoObtained = data.isAutoObtained === 0 ? 1 : 0;
monthData.value = [...monthData.value];
console.log(monthData.value);
};
const monthColumns = [
{
title: '日期',
dataIndex: 'yearMonth',
},
{
title: '用电量',
dataIndex: 'referenceValue',
width: '40%',
},
{
title: '是否自动获取',
key: 'isAutoObtained',
},
{
title: '操作',
dataIndex: 'operation',
},
];
const monthData = ref([]);
const dataSource = ref(monthData);
const editableData: UnwrapRef<Record<string, DataItem>> = reactive({});
const edit = (yearMonth: string) => {
editableData[yearMonth] = cloneDeep(
dataSource.value.filter((item) => yearMonth === item.yearMonth)[0],
);
};
const save = (yearMonth: string) => {
Object.assign(
dataSource.value.filter((item) => yearMonth === item.yearMonth)[0],
editableData[yearMonth],
);
delete editableData[yearMonth];
monthData.value = [...monthData.value];
};
const cancel = (yearMonth: string) => {
delete editableData[yearMonth];
};
const onSubmit = () => { const onSubmit = () => {
const benchmark = monthData.value;
fetch(carbonPlanning.benchmarkSubmit, { fetch(carbonPlanning.benchmarkSubmit, {
ids: ids.value, benchmark: benchmark,
referenceValue: referenceQuery.value, orgId: orgId.value,
type: props.type,
year: props.year,
itemizeId: props.parentId,
}).then((res) => { }).then((res) => {
visible.value = false; visible.value = false;
selectedRowKeysSet.value = []; selectedRowKeysSet.value = [];
@ -669,9 +809,34 @@
} }
} }
} }
.blue-background.ant-switch-checked .ant-switch-handle {
background-color: linear-gradient(
180deg,
rgba(1, 206, 255, 1) 0%,
rgba(57, 215, 187, 1) 100%
) !important;
}
.grey-background.ant-switch {
background-color: rgba(238, 238, 238, 1) !important;
}
.grey-background.ant-switch .ant-switch-handle {
background-color: rgba(238, 238, 238, 1) !important;
}
.ant-switch-checked {
background-color: rgba(57, 215, 187, 1) !important;
}
.grey-background.ant-switch .ant-switch-handle {
background-color: rgba(238, 238, 238, 1) !important;
}
:deep(.ant-card-body) { :deep(.ant-card-body) {
padding: unset; padding: unset;
height: 100%; height: 100%;
width: 100%; width: 100%;
} }
</style> </style>
<style scoped>
.editable-row-operations a {
margin-right: 8px;
}
</style>

Loading…
Cancel
Save