Browse Source

修改测试问题

temp
fks-xuxinyue 3 months 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. 227
      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',
addNodes = '/carbon-smart/api/carbon/planning/addNodes',
benchmarkSetting = '/carbon-smart/api/carbon/planning/benchmarkSetting',
monthBenchmarkSetting = '/carbon-smart/api/carbon/planning/monthBenchmarkSetting',
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: '请输入排放源',
maxLength: 20,
},
// rules: [
// {
// required: true,
// message: '请输入排放源',
// },
// ],
rules: [
{
required: true,
message: '请输入排放源',
},
],
},
{
field: 'emissionType',
@ -38,12 +38,12 @@ export const formConfig = (disabled) => {
fieldNames: { label: 'emissionName', value: 'id' },
showSearch: true,
},
// rules: [
// {
// required: true,
// message: '请选择排放分类',
// },
// ],
rules: [
{
required: true,
message: '请选择排放分类',
},
],
},
{
field: 'emissionGas',
@ -79,12 +79,12 @@ export const formConfig = (disabled) => {
},
],
},
// rules: [
// {
// required: true,
// message: '请选择排放气体',
// },
// ],
rules: [
{
required: true,
message: '请选择排放气体',
},
],
},
{
label: '排放环节',
@ -94,12 +94,12 @@ export const formConfig = (disabled) => {
placeholder: '请输入排放环节',
maxLength: 20,
},
// rules: [
// {
// required: true,
// message: '请输入排放环节',
// },
// ],
rules: [
{
required: true,
message: '请输入排放环节',
},
],
},
{
label: '排放因子',
@ -109,13 +109,13 @@ export const formConfig = (disabled) => {
placeholder: '请输入排放因子值',
maxLength: 20,
},
// rules: [
// {
// required: true,
// message: '请输入排放因子值',
// trigger: 'change',
// },
// ],
rules: [
{
required: true,
message: '请输入排放因子值',
trigger: 'change',
},
],
},
{
field: 'carbonEmissionPrefix',
@ -141,12 +141,12 @@ export const formConfig = (disabled) => {
},
],
},
// rules: [
// {
// required: true,
// message: '请选择碳排前缀',
// },
// ],
rules: [
{
required: true,
message: '请选择碳排前缀',
},
],
},
{
label: '碳排后缀',
@ -156,17 +156,18 @@ export const formConfig = (disabled) => {
placeholder: '请输入碳排后缀',
maxLength: 20,
},
// rules: [
// {
// required: true,
// message: '请输入碳排后缀',
// },
// ],
rules: [
{
required: true,
message: '请输入碳排后缀',
},
],
},
{
label: '已引用数',
field: 'numberOfReferences',
component: 'NsInput',
show:disabled,
componentProps: {
defaultValue: '',
disabled: true,

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

@ -12,6 +12,7 @@
<a-input-search
v-model:value="selectTreeDataValue"
placeholder="请输入关键词"
allowClear
@search="onSearchTreeData" />
</a-col>
</a-row>
@ -274,7 +275,8 @@
watchEffect(() => {
disabled.value = opMap.value.type === 'edit';
});
const formSchema = formConfig(disabled);
const show = ref(true);
const formSchema = formConfig(show);
const casData = ref([]);
const treeData = ref([]);
const userAuthList = ref([]);
@ -634,6 +636,7 @@
NsMessage.success('操作成功');
});
};
show.value = false;
visible.value = true;
},
},
@ -808,6 +811,7 @@
NsMessage.success('操作成功');
});
};
show.value = true;
visible.value = true;
},
},
@ -856,6 +860,7 @@
componentProps: {
placeholder: '请选择排放气体',
api: carbonEmissionFactorLibrary.gasAndDatabase,
resultField: 'data',
params: {
orgId: orgId.value,
emissionList,
@ -874,6 +879,7 @@
allowClear: true,
placeholder: '请选择数据库名称',
api: carbonEmissionFactorLibrary.gasAndDatabase,
resultField: 'data',
params: {
orgId: orgId.value,
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>
 

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

@ -93,7 +93,7 @@
<template #bodyCell="{ column, text, record }">
<template v-if="column.key === 'action'">
<span>
<a @click="editData(record)">修改</a>
<a @click="editData(record)">修改预算值</a>
</span>
</template>
</template>
@ -109,12 +109,6 @@
<a-select-option :value="0"></a-select-option>
</a-select>
</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-input v-model:value="formState.conversionRate" suffix="%" :disabled="disabled" />
</a-form-item>
@ -124,18 +118,29 @@
</a-form>
</a-modal>
<!-- 基准值设置 -->
<a-drawer
:visible="visible"
title="设置基准"
:width="500"
@close="onClose"
:footer-style="{ textAlign: 'right' }">
<div> 节点{{ props.nodeName }} </div>
<a-modal :visible="visible" @ok="onSubmit" @cancel="onClose">
<a-tooltip placement="top">
<template #title>
<span>月基准值设置使用基准年相应月份的数据作为当前年相应月份的基准值</span>
</template>
<QuestionCircleOutlined style="position: absolute; right: 60px; top: 22px; z-index: 7" />
</a-tooltip>
<div style="display: flex; margin-top: 20px; justify-content: space-between">
<span> 节点{{ props.nodeName }} </span>
<a-date-picker
v-if="activeKey === '1'"
v-model:value="selectYear"
picker="year"
valueFormat="YYYY"
@change="changeYearData" />
</div>
<a-tabs v-model:activeKey="activeKey" @change="handleTabChange">
<a-tab-pane key="1" tab="年基准值设置">
<a-table
:columns="drawerColumns"
:data-source="newTableData"
:columns="yearColumns"
:data-source="yearTableData"
bordered
:rowKey="(record, index) => index"
:rowKey="(record, index) => record.referenceYear"
:rowSelection="{
selectedRowKeys: selectedRowKeysSet,
onChange: onSelectionChangeSet,
@ -143,21 +148,77 @@
}"
:pagination="false">
</a-table>
<template #footer>
<a-button style="margin-right: 8px" @click="onClose">取消</a-button>
<a-button type="primary" @click="onSubmit">确定</a-button>
</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-drawer>
</a-table>
</a-tab-pane>
</a-tabs>
</a-modal>
</div>
</template>
<script lang="ts" setup>
import { cloneDeep } from 'lodash-es';
import type { UnwrapRef } from 'vue';
import { ref, defineEmits, reactive, toRaw } from 'vue';
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 * as echarts from 'echarts';
import { any, string } from 'vue-types';
import type { Dayjs } from 'dayjs';
// id
const props = defineProps({
parentId: {
@ -185,6 +246,7 @@
const changeParentData = () => {
emit('change-data', true);
};
const activeKey = ref('1');
//
const selectedRowKeys = ref([]);
const onSelectionChange = (selectedKeys, selectedRows) => {
@ -243,6 +305,7 @@
{
title: '操作',
key: 'action',
width: 200,
},
]);
@ -300,37 +363,114 @@
open.value = false;
};
const visible = ref(false);
const selectYear = ref<Dayjs>();
const selectedRowKeysSet = ref([]);
const referenceQuery = ref();
const onSelectionChangeSet = (selectedKeys, selectedRows) => {
selectedRowKeysSet.value = selectedKeys;
referenceQuery.value = selectedRows[0].referenceValue;
};
const drawerColumns = [
const yearColumns = [
{
title: '年份',
dataIndex: 'year',
dataIndex: 'referenceYear',
},
{
title: '用电量',
dataIndex: 'referenceValue',
},
];
const newTableData = ref([]);
const setBasicData = () => {
fetch(carbonPlanning.benchmarkSetting, {
//
const queryData = ref({
orgId: orgId.value,
type: props.type,
itemizeId: props.parentId,
}).then((res) => {
newTableData.value = res.data;
});
const changeYearData = () => {
queryData.value.referenceYear = selectYear.value;
setBasicData();
};
const yearTableData = ref([]);
const setBasicData = () => {
fetch(carbonPlanning.benchmarkSetting, queryData.value).then((res) => {
yearTableData.value = res.data;
});
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 benchmark = monthData.value;
fetch(carbonPlanning.benchmarkSubmit, {
ids: ids.value,
referenceValue: referenceQuery.value,
benchmark: benchmark,
orgId: orgId.value,
type: props.type,
year: props.year,
itemizeId: props.parentId,
}).then((res) => {
visible.value = false;
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) {
padding: unset;
height: 100%;
width: 100%;
}
</style>
<style scoped>
.editable-row-operations a {
margin-right: 8px;
}
</style>

Loading…
Cancel
Save