修改测试问题
This commit is contained in:
@@ -74,9 +74,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="button" style="margin-bottom: 12px">
|
||||
<a-button type="primary" :disabled="selectedRowKeys.length === 0" @click="editData">
|
||||
批量设置
|
||||
</a-button>
|
||||
<a-button type="primary" @click="editData"> 批量设置 </a-button>
|
||||
<a-button type="primary" style="margin-left: 6px" @click="setBasicData">
|
||||
基准值设置
|
||||
</a-button>
|
||||
@@ -137,20 +135,13 @@
|
||||
:columns="drawerColumns"
|
||||
:data-source="newTableData"
|
||||
bordered
|
||||
rowKey="id"
|
||||
:rowKey="(record, index) => index"
|
||||
:rowSelection="{
|
||||
selectedRowKeys: selectedRowKeysSet,
|
||||
onChange: onSelectionChangeSet,
|
||||
type: 'radio',
|
||||
}"
|
||||
:pagination="false">
|
||||
<template #bodyCell="{ column, text, record }">
|
||||
<template v-if="column.key === 'action'">
|
||||
<span>
|
||||
<a @click="setBasic(record)">设为基准值</a>
|
||||
</span>
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
<template #footer>
|
||||
<a-button style="margin-right: 8px" @click="onClose">取消</a-button>
|
||||
@@ -206,9 +197,11 @@
|
||||
itemizeId: props.parentId,
|
||||
type: props.type,
|
||||
});
|
||||
const ids = ref([]);
|
||||
const getTableData = () => {
|
||||
fetch(carbonPlanning.detailedStatisticalDataTable, queryParams.value).then((res) => {
|
||||
data.value = res.data;
|
||||
ids.value = data.value.map((item) => item.id);
|
||||
});
|
||||
};
|
||||
getTableData();
|
||||
@@ -261,7 +254,7 @@
|
||||
const wrapperCol = { span: 18 };
|
||||
const editData = (record) => {
|
||||
open.value = true;
|
||||
if (record) {
|
||||
if (record.isLastYear) {
|
||||
formState.value.ids = [record.id];
|
||||
if (record.lastYear === '是') {
|
||||
formState.value.isLastYear = 1;
|
||||
@@ -285,6 +278,9 @@
|
||||
.validate()
|
||||
.then(() => {
|
||||
console.log('values', formState, toRaw(formState));
|
||||
if (formState.value.ids[0] === undefined) {
|
||||
formState.value.ids = ids.value;
|
||||
}
|
||||
fetch(carbonPlanning.batchOrUpdate, formState.value).then((res) => {
|
||||
open.value = false;
|
||||
formState.value = {};
|
||||
@@ -301,27 +297,38 @@
|
||||
};
|
||||
const visible = ref(false);
|
||||
const selectedRowKeysSet = ref([]);
|
||||
const referenceQuery = ref();
|
||||
const onSelectionChangeSet = (selectedKeys, selectedRows) => {
|
||||
selectedRowKeysSet.value = selectedKeys;
|
||||
referenceQuery.value = selectedRows[0].referenceValue;
|
||||
};
|
||||
const drawerColumns = [
|
||||
{
|
||||
title: '年份',
|
||||
dataIndex: 'emissionSources',
|
||||
dataIndex: 'year',
|
||||
},
|
||||
{
|
||||
title: '用电量',
|
||||
dataIndex: 'emissionFactors',
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
dataIndex: 'referenceValue',
|
||||
},
|
||||
];
|
||||
const newTableData = ref([]);
|
||||
const setBasicData = () => {
|
||||
fetch(carbonPlanning.benchmarkSetting, { orgId: orgId.value }).then((res) => {
|
||||
newTableData.value = res.data;
|
||||
});
|
||||
visible.value = true;
|
||||
};
|
||||
const onSubmit = () => {
|
||||
fetch(carbonPlanning.benchmarkSubmit, {
|
||||
ids: ids.value,
|
||||
referenceValue: referenceQuery.value,
|
||||
}).then((res) => {
|
||||
visible.value = false;
|
||||
selectedRowKeysSet.value = [];
|
||||
getTableData();
|
||||
});
|
||||
};
|
||||
const onClose = () => {
|
||||
visible.value = false;
|
||||
};
|
||||
|
Reference in New Issue
Block a user