Browse Source

修改测试问题

temp
fks-xuxinyue 3 months ago
parent
commit
4395408f68
  1. 9
      hx-ai-intelligent/src/api/carbonEmissionFactorLibrary.ts
  2. 3
      hx-ai-intelligent/src/router/carbonEmissionManage.ts
  3. 7
      hx-ai-intelligent/src/view/carbonEmissionManage/carbonAssets/carbonAssetsDetail/index.vue
  4. 71
      hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionFactorLibrary/index.vue
  5. 556
      hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/energyConsumption/index.vue
  6. 9
      hx-ai-intelligent/src/view/carbonEmissionManage/carbonInventoryCheck/config.ts
  7. 90
      hx-ai-intelligent/src/view/carbonEmissionManage/carbonInventoryCheck/fillInPage/index.vue
  8. 13
      hx-ai-intelligent/src/view/carbonEmissionManage/carbonInventoryCheck/index.vue
  9. 43
      hx-ai-intelligent/src/view/carbonEmissionManage/carbonPlanning/category/categoryDeatil.vue

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

@ -8,6 +8,8 @@ export enum carbonEmissionFactorLibrary {
getCarbonFactorTree = '/carbon-smart/api/carbon/emission/type/getCarbonFactorTree', getCarbonFactorTree = '/carbon-smart/api/carbon/emission/type/getCarbonFactorTree',
creat = '/carbon-smart/api/carbon/emission/type/creatOrUpdate', creat = '/carbon-smart/api/carbon/emission/type/creatOrUpdate',
delTreeNode = '/carbon-smart/api/carbon/emission/type/del', delTreeNode = '/carbon-smart/api/carbon/emission/type/del',
move = '/carbon-smart/api/carbon/emission/type/move',
excel = '/carbon-smart/api/carbon/emission/factor/excel',
// 单位管理 // 单位管理
dictionaryUnitManagement = '/carbon-smart/client/dict/dictionaryUnitManagement', dictionaryUnitManagement = '/carbon-smart/client/dict/dictionaryUnitManagement',
findOutermost = '/carbon-smart/client/dict/findOutermost', findOutermost = '/carbon-smart/client/dict/findOutermost',
@ -15,7 +17,7 @@ export enum carbonEmissionFactorLibrary {
updateDictionary = '/carbon-smart/client/dict/updateDictionary', updateDictionary = '/carbon-smart/client/dict/updateDictionary',
delDictionary = '/carbon-smart/client/dict/delDictionary', delDictionary = '/carbon-smart/client/dict/delDictionary',
} }
// 碳排管理-碳排统计接口 // 碳排管理-能耗统计接口
export enum energyConsumption { export enum energyConsumption {
getDicList = '/carbon-smart/client/dict/list', getDicList = '/carbon-smart/client/dict/list',
pageList = '/carbon-smart/api/carbon/stats/pageList', pageList = '/carbon-smart/api/carbon/stats/pageList',
@ -23,6 +25,7 @@ export enum energyConsumption {
creat = '/carbon-smart/api/carbon/stats/creat', creat = '/carbon-smart/api/carbon/stats/creat',
update = '/carbon-smart/api/carbon/stats/update', update = '/carbon-smart/api/carbon/stats/update',
del = '/carbon-smart/api/carbon/stats/del', del = '/carbon-smart/api/carbon/stats/del',
voucherDownloadList = '/carbon-smart/api/carbon/stats/voucherDownloadList',
} }
// 碳排管理-碳排速算接口 // 碳排管理-碳排速算接口
export enum quickCalculation { export enum quickCalculation {
@ -55,6 +58,7 @@ export enum carbonInventoryCheck {
findUnitById = '/carbon-smart/api/carbon/inventory/findById', findUnitById = '/carbon-smart/api/carbon/inventory/findById',
getDetailsList = '/carbon-smart/api/carbon/inventory/details/getDetailsList', getDetailsList = '/carbon-smart/api/carbon/inventory/details/getDetailsList',
updateTable = '/carbon-smart/api/carbon/inventory/details/update', updateTable = '/carbon-smart/api/carbon/inventory/details/update',
voucherDownloadList = '/carbon-smart/api/carbon/inventory/details/voucherDownloadList',
// 排放统计接口 // 排放统计接口
emissionStatistic = '/carbon-smart/api/carbon/inventory/emissionStatistic', emissionStatistic = '/carbon-smart/api/carbon/inventory/emissionStatistic',
// 碳排流向 // 碳排流向
@ -75,6 +79,7 @@ export enum uploadPic {
uploadfiles = '/carbon-smart/api/common/file/uploadfiles', uploadfiles = '/carbon-smart/api/common/file/uploadfiles',
select = '/carbon-smart/api/common/file/select', select = '/carbon-smart/api/common/file/select',
uploadfile = '/carbon-smart/api/common/file/uploadfile', uploadfile = '/carbon-smart/api/common/file/uploadfile',
download = '/carbon-smart/api/common/file/download',
} }
// 碳规划 // 碳规划
export enum carbonPlanning { export enum carbonPlanning {
@ -90,4 +95,6 @@ export enum carbonPlanning {
detailedStatisticalDataChart = '/carbon-smart/api/carbon/planning/detailedStatisticalDataChart', detailedStatisticalDataChart = '/carbon-smart/api/carbon/planning/detailedStatisticalDataChart',
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',
benchmarkSubmit = '/carbon-smart/api/carbon/planning/benchmarkSubmit',
} }

3
hx-ai-intelligent/src/router/carbonEmissionManage.ts

@ -40,6 +40,9 @@ const equipment = {
meta: { meta: {
title: '碳排因子库', title: '碳排因子库',
keepAlive: false, keepAlive: false,
operates: [
{ title: '碳排因子库导入', code: 'carbonEmissionFactorLibraryImport' },
],
// backApi: [], // backApi: [],
}, },
}, },

7
hx-ai-intelligent/src/view/carbonEmissionManage/carbonAssets/carbonAssetsDetail/index.vue

@ -290,7 +290,7 @@
getDictList(); getDictList();
visible.value = true; visible.value = true;
formState.value.id = record.id; formState.value.id = record.id;
fetch(uploadPic.select, { bizId: record.id, bizTpye: 1 }).then((res) => { fetch(uploadPic.select, { bizId: record.id, bizType: 1 }).then((res) => {
fileList.value = res.data.map((item) => ({ fileList.value = res.data.map((item) => ({
uid: item.id.toString(), // 使id uid: item.id.toString(), // 使id
name: item.fileName, // name: item.fileName, //
@ -424,9 +424,6 @@
}); });
fileList.value = newFileList; fileList.value = newFileList;
}; };
const uploadQuery = ref({
bizTpye: 1,
});
const onSubmit = () => { const onSubmit = () => {
formRef.value formRef.value
.validate() .validate()
@ -445,7 +442,7 @@
fileList.value.forEach((file) => { fileList.value.forEach((file) => {
formData.value.append('files', file.originFileObj); formData.value.append('files', file.originFileObj);
}); });
formData.value.append('bizTpye', 1); formData.value.append('bizType', 1);
formData.value.append('bizId', res.data.id); formData.value.append('bizId', res.data.id);
fetch(uploadPic.uploadfiles, formData.value) fetch(uploadPic.uploadfiles, formData.value)
.then((res) => { .then((res) => {

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

@ -62,9 +62,17 @@
<a-menu> <a-menu>
<a-menu-item @click="editTreeNodeData(data)">编辑</a-menu-item> <a-menu-item @click="editTreeNodeData(data)">编辑</a-menu-item>
<a-menu-item @click="addTreeNodeData">新增子节点</a-menu-item> <a-menu-item @click="addTreeNodeData">新增子节点</a-menu-item>
<a-menu-item>上移</a-menu-item> <a-menu-item
<a-menu-item>下移</a-menu-item> v-if="!data.isFirst && data.emissionName !== '未分类'"
<a-menu-item @click="deleteTreeNode">删除</a-menu-item> @click="moveNode(data, 'up')"
>上移</a-menu-item
>
<a-menu-item
v-if="!data.isEnd && data.emissionName !== '未分类'"
@click="moveNode(data, 'down')"
>下移</a-menu-item
>
<a-menu-item @click="deleteTreeNode(data)">删除</a-menu-item>
</a-menu> </a-menu>
</template> </template>
</a-dropdown> </a-dropdown>
@ -228,6 +236,7 @@
TreeProps, TreeProps,
} from 'ant-design-vue/es/tree'; } from 'ant-design-vue/es/tree';
import { log } from 'node:console'; import { log } from 'node:console';
import { or } from '@vueuse/core';
defineOptions({ name: 'OrderListIndex' }); defineOptions({ name: 'OrderListIndex' });
const orgId = ref(''); const orgId = ref('');
@ -253,7 +262,7 @@
const disabled = ref(false); const disabled = ref(false);
const treeNodeAdd = ref<boolean>(false); const treeNodeAdd = ref<boolean>(false);
const operationTree = ref<string>('新增'); const operationTree = ref<string>('新增');
const showOperation = ref(false); // const showOperation = ref(false);
const opMap: any = ref({ const opMap: any = ref({
type: 'add', type: 'add',
@ -442,8 +451,15 @@
editTreeNode.value.type = 'update'; editTreeNode.value.type = 'update';
addTreeNode.value = data.emissionName; addTreeNode.value = data.emissionName;
}; };
const moveNode = (data, type: opType) => {
const flag = type === 'up';
http.post(carbonEmissionFactorLibrary.move, { ...data, isUp: flag }).then(() => {
getOrgTree();
NsMessage.success('操作成功');
});
};
// //
const deleteTreeNode = () => { const deleteTreeNode = (data) => {
Modal.confirm({ Modal.confirm({
title: '警告', title: '警告',
icon: createVNode(ExclamationCircleOutlined), icon: createVNode(ExclamationCircleOutlined),
@ -452,10 +468,12 @@
okType: 'primary', okType: 'primary',
cancelText: '取消', cancelText: '取消',
onOk() { onOk() {
http.post(carbonEmissionFactorLibrary.delTreeNode, editTreeNode.value).then(() => { http
getOrgTree(); .post(carbonEmissionFactorLibrary.delTreeNode, { orgId: orgId.value, id: data.id })
NsMessage.success('操作成功'); .then(() => {
}); getOrgTree();
NsMessage.success('操作成功');
});
}, },
onCancel() { onCancel() {
console.log('Cancel'); console.log('Cancel');
@ -511,7 +529,7 @@
const editTreeNode = ref({}); const editTreeNode = ref({});
const onSelect = (selectedKeys: string[], info: any) => { const onSelect = (selectedKeys: string[], info: any) => {
if (info.selected) { if (info.selected) {
showOperation.value = true; // showOperation.value = true;
editTreeNode.value = { editTreeNode.value = {
id: info.selectedNodes[0].id, id: info.selectedNodes[0].id,
level: info.selectedNodes[0].level, level: info.selectedNodes[0].level,
@ -519,6 +537,8 @@
sortNumber: info.selectedNodes[0].sortNumber, sortNumber: info.selectedNodes[0].sortNumber,
parentEmissionId: info.selectedNodes[0].parentEmissionId, parentEmissionId: info.selectedNodes[0].parentEmissionId,
}; };
} else {
editTreeNode.value = {};
} }
}; };
@ -573,6 +593,15 @@
opMap.value.fuc && opMap.value.fuc({ ...formData.value }); opMap.value.fuc && opMap.value.fuc({ ...formData.value });
}); });
}; };
const doWnload = (url: any) => {
const a = document.createElement('a');
document.body.appendChild(a);
a.href = encodeURI(url);
//
// a.download = fileName.value;
//a
a.click();
};
const tableConfig = ref({ const tableConfig = ref({
title: '数据库', title: '数据库',
api: carbonEmissionFactorLibrary.getTableList, api: carbonEmissionFactorLibrary.getTableList,
@ -609,13 +638,26 @@
{ {
label: '导入', label: '导入',
type: 'primary', type: 'primary',
name: 'userImport', name: 'carbonEmissionFactorLibraryImport',
handle: () => {}, extra: {
api: carbonEmissionFactorLibrary.excel, //
title: '设备信息', // title
templateName: 'whiteListUser', // 使
indexName: '设备id', //
message: [
{ label: '1、若必填项未填写,则不能进行导入操作' },
{ label: `2、当重复时,则更新数据。` },
{ label: '3、数据将从模版的第五行进行导入。' },
{ label: '4、文件导入勿超过5MB。' },
],
},
}, },
{ {
label: '导出', label: '导出',
type: 'primary', type: 'primary',
name: 'userExports', handle: () => {
doWnload('/hx-ai-intelligent/asset/file/whiteListUser.xlsx');
},
}, },
{ {
label: '批量删除', label: '批量删除',
@ -687,6 +729,7 @@
{ {
title: '参考文献', title: '参考文献',
dataIndex: 'bibliography', dataIndex: 'bibliography',
ellipsis: true,
}, },
{ {
title: '引用数量', title: '引用数量',
@ -917,7 +960,7 @@
} else { } else {
canSelect.value = false; canSelect.value = false;
} }
fetch(carbonEmissionFactorLibrary.findOutermost).then((res) => { fetch(carbonEmissionFactorLibrary.findOutermost, { grp: 'MEASUREMENT_UNIT' }).then((res) => {
groupData.value = res.data; groupData.value = res.data;
}); });
addUnitTitle.value = '新增单位'; addUnitTitle.value = '新增单位';

556
hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/energyConsumption/index.vue

@ -27,7 +27,11 @@
</div> </div>
</template> </template>
</a-table> --> </a-table> -->
<ns-view-list-table v-bind="tableConfig" :model="data" ref="mainRef" :scroll="{ x: 1500,y:350 }"> <ns-view-list-table
v-bind="tableConfig"
:model="data"
ref="mainRef"
:scroll="{ x: 1500, y: 350 }">
<!-- <template #bodyCell="{ record, column }"> <!-- <template #bodyCell="{ record, column }">
<template v-if="column.dataIndex === 'enableRules'"> <template v-if="column.dataIndex === 'enableRules'">
<a-switch <a-switch
@ -40,7 +44,7 @@
</template> </template>
</template> --> </template> -->
</ns-view-list-table> </ns-view-list-table>
<!-- <a-pagination <!-- <a-pagination
:current="queryParams.pageNum" :current="queryParams.pageNum"
:total="total" :total="total"
:page-size="queryParams.pageSize" :page-size="queryParams.pageSize"
@ -61,8 +65,7 @@
:model="formState" :model="formState"
:rules="rules" :rules="rules"
:label-col="labelCol" :label-col="labelCol"
:wrapper-col="wrapperCol" :wrapper-col="wrapperCol">
>
<a-form-item ref="name" label="能源种类" name="energyType"> <a-form-item ref="name" label="能源种类" name="energyType">
<a-input v-model:value="formState.energyType" placeholder="请输入能源种类" /> <a-input v-model:value="formState.energyType" placeholder="请输入能源种类" />
</a-form-item> </a-form-item>
@ -73,8 +76,7 @@
<a-tree-select <a-tree-select
v-model:value="formState.collectionNode" v-model:value="formState.collectionNode"
:tree-line="true" :tree-line="true"
:tree-data="treeData" :tree-data="treeData">
>
</a-tree-select> </a-tree-select>
</a-form-item> </a-form-item>
<a-form-item label="计算碳排" name="isComputeCarbon"> <a-form-item label="计算碳排" name="isComputeCarbon">
@ -91,51 +93,149 @@
</a-select> </a-select>
</a-form-item> </a-form-item>
<a-row> <a-row>
<a-col :span="24" style="display:flex;justify-content: space-around;"> <a-col :span="24" style="display: flex; justify-content: space-around">
<a-form-item label="1月" name="janFlag" :label-col="switchLabelCol" :wrapper-col="switchWrapperCol"> <a-form-item
<a-switch v-model:checked="formState.janFlag" :checked-value="1" :unCheckedValue="0" /> label="1月"
name="janFlag"
:label-col="switchLabelCol"
:wrapper-col="switchWrapperCol">
<a-switch
v-model:checked="formState.janFlag"
:checked-value="1"
:unCheckedValue="0" />
</a-form-item> </a-form-item>
<a-form-item label="2月" name="febFlag" :label-col="switchLabelCol" :wrapper-col="switchWrapperCol"> <a-form-item
<a-switch v-model:checked="formState.febFlag" :checked-value="1" :unCheckedValue="0" /> label="2月"
name="febFlag"
:label-col="switchLabelCol"
:wrapper-col="switchWrapperCol">
<a-switch
v-model:checked="formState.febFlag"
:checked-value="1"
:unCheckedValue="0" />
</a-form-item> </a-form-item>
<a-form-item label="3月" name="marFlag" :label-col="switchLabelCol" :wrapper-col="switchWrapperCol"> <a-form-item
<a-switch v-model:checked="formState.marFlag" :checked-value="1" :unCheckedValue="0" /> label="3月"
name="marFlag"
:label-col="switchLabelCol"
:wrapper-col="switchWrapperCol">
<a-switch
v-model:checked="formState.marFlag"
:checked-value="1"
:unCheckedValue="0" />
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="24" style="display:flex;justify-content: space-around;"> <a-col :span="24" style="display: flex; justify-content: space-around">
<a-form-item label="4月" name="aprFlag" :label-col="switchLabelCol" :wrapper-col="switchWrapperCol"> <a-form-item
<a-switch v-model:checked="formState.aprFlag" :checked-value="1" :unCheckedValue="0" /> label="4月"
name="aprFlag"
:label-col="switchLabelCol"
:wrapper-col="switchWrapperCol">
<a-switch
v-model:checked="formState.aprFlag"
:checked-value="1"
:unCheckedValue="0" />
</a-form-item> </a-form-item>
<a-form-item label="5月" name="mayFlag" :label-col="switchLabelCol" :wrapper-col="switchWrapperCol"> <a-form-item
<a-switch v-model:checked="formState.mayFlag" :checked-value="1" :unCheckedValue="0" /> label="5月"
name="mayFlag"
:label-col="switchLabelCol"
:wrapper-col="switchWrapperCol">
<a-switch
v-model:checked="formState.mayFlag"
:checked-value="1"
:unCheckedValue="0" />
</a-form-item> </a-form-item>
<a-form-item label="6月" name="junFlag" :label-col="switchLabelCol" :wrapper-col="switchWrapperCol"> <a-form-item
<a-switch v-model:checked="formState.junFlag" :checked-value="1" :unCheckedValue="0" /> label="6月"
name="junFlag"
:label-col="switchLabelCol"
:wrapper-col="switchWrapperCol">
<a-switch
v-model:checked="formState.junFlag"
:checked-value="1"
:unCheckedValue="0" />
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="24" style="display:flex;justify-content: space-around;"> <a-col :span="24" style="display: flex; justify-content: space-around">
<a-form-item label="7月" name="julFlag" :label-col="switchLabelCol" :wrapper-col="switchWrapperCol"> <a-form-item
<a-switch v-model:checked="formState.julFlag" :checked-value="1" :unCheckedValue="0" /> label="7月"
name="julFlag"
:label-col="switchLabelCol"
:wrapper-col="switchWrapperCol">
<a-switch
v-model:checked="formState.julFlag"
:checked-value="1"
:unCheckedValue="0" />
</a-form-item> </a-form-item>
<a-form-item label="8月" name="augFlag" :label-col="switchLabelCol" :wrapper-col="switchWrapperCol"> <a-form-item
<a-switch v-model:checked="formState.augFlag" :checked-value="1" :unCheckedValue="0" /> label="8月"
name="augFlag"
:label-col="switchLabelCol"
:wrapper-col="switchWrapperCol">
<a-switch
v-model:checked="formState.augFlag"
:checked-value="1"
:unCheckedValue="0" />
</a-form-item> </a-form-item>
<a-form-item label="9月" name="sepFlag" :label-col="switchLabelCol" :wrapper-col="switchWrapperCol"> <a-form-item
<a-switch v-model:checked="formState.sepFlag" :checked-value="1" :unCheckedValue="0" /> label="9月"
name="sepFlag"
:label-col="switchLabelCol"
:wrapper-col="switchWrapperCol">
<a-switch
v-model:checked="formState.sepFlag"
:checked-value="1"
:unCheckedValue="0" />
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="24" style="display:flex;justify-content: space-around;"> <a-col :span="24" style="display: flex; justify-content: space-around">
<a-form-item label="10月" name="octFlag" :label-col="switchLabelCol" :wrapper-col="switchWrapperCol"> <a-form-item
<a-switch v-model:checked="formState.octFlag" :checked-value="1" :unCheckedValue="0" /> label="10月"
name="octFlag"
:label-col="switchLabelCol"
:wrapper-col="switchWrapperCol">
<a-switch
v-model:checked="formState.octFlag"
:checked-value="1"
:unCheckedValue="0" />
</a-form-item> </a-form-item>
<a-form-item label="11月" name="novFlag" :label-col="switchLabelCol" :wrapper-col="switchWrapperCol"> <a-form-item
<a-switch v-model:checked="formState.novFlag" :checked-value="1" :unCheckedValue="0" /> label="11月"
name="novFlag"
:label-col="switchLabelCol"
:wrapper-col="switchWrapperCol">
<a-switch
v-model:checked="formState.novFlag"
:checked-value="1"
:unCheckedValue="0" />
</a-form-item> </a-form-item>
<a-form-item label="12月" name="decFlag" :label-col="switchLabelCol" :wrapper-col="switchWrapperCol"> <a-form-item
<a-switch v-model:checked="formState.decFlag" :checked-value="1" :unCheckedValue="0" /> label="12月"
name="decFlag"
:label-col="switchLabelCol"
:wrapper-col="switchWrapperCol">
<a-switch
v-model:checked="formState.decFlag"
:checked-value="1"
:unCheckedValue="0" />
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row> </a-row>
<a-form-item ref="name" label="上传凭证">
<a-upload
:file-list="fileList"
name="file"
accept=".jpg,.jpeg,.png,.gif,.bmp,.pdf"
@remove="handleFileRemove"
:before-upload="beforeUpload"
@change="handleChange">
<a-button>
<upload-outlined></upload-outlined>
上传
</a-button>
</a-upload>
</a-form-item>
</a-form> </a-form>
<template #footer> <template #footer>
<a-button style="margin-right: 8px" @click="onClose">取消</a-button> <a-button style="margin-right: 8px" @click="onClose">取消</a-button>
@ -143,7 +243,7 @@
</template> </template>
</a-drawer> </a-drawer>
<!-- 上传凭证弹窗 --> <!-- 上传凭证弹窗 -->
<a-modal :visible="openUpload" title="凭证上传" @ok="handleOk" @cancel="closeOpenUpload"> <!-- <a-modal :visible="openUpload" title="凭证上传" @ok="handleOk" @cancel="closeOpenUpload">
<a-upload-dragger <a-upload-dragger
v-model:fileList="fileList" v-model:fileList="fileList"
name="file" name="file"
@ -161,19 +261,55 @@
<p>3.每次上传自动覆盖</p> <p>3.每次上传自动覆盖</p>
</p> </p>
</a-upload-dragger> </a-upload-dragger>
</a-modal> </a-modal> -->
<!-- 凭证下载 -->
<a-drawer
:visible="downLoadVisible"
title="凭证列表"
:width="500"
@close="onCloseDownLoad"
:footer-style="{ textAlign: 'right' }">
<div></div>
<a-table
:columns="downLoadColumns"
:data-source="downLoadData"
bordered
:rowKey="(record, index) => index"
:rowSelection="{
selectedRowKeys: selectedRowKeysSet,
onChange: onSelectionChangeSet,
}"
:pagination="false">
<template #bodyCell="{ column, text, record }">
<template v-if="column.key === 'action'">
<span>
<a @click="downLoad(record)">下载</a>
</span>
</template>
</template>
</a-table>
<template #footer>
<a-button style="margin-right: 8px" @click="onCloseDownLoad">取消</a-button>
<a-button type="primary" @click="onSubmitDownLoad">确定</a-button>
</template>
</a-drawer>
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, toRaw,defineExpose } from 'vue'; import { ref, toRaw, defineExpose } from 'vue';
import type { Rule } from 'ant-design-vue/es/form'; import type { Rule } from 'ant-design-vue/es/form';
import { Pagination,message,Modal } from 'ant-design-vue'; import { Pagination, message, Modal } from 'ant-design-vue';
import type { TreeSelectProps,UploadChangeParam } from 'ant-design-vue'; import { UploadOutlined } from '@ant-design/icons-vue';
import type { TreeSelectProps, UploadChangeParam, UploadProps } from 'ant-design-vue';
import { NsMessage } from '/nerv-lib/component'; import { NsMessage } from '/nerv-lib/component';
import dayjs, { Dayjs } from 'dayjs'; import dayjs, { Dayjs } from 'dayjs';
import { http } from '/nerv-lib/util/http'; import { http } from '/nerv-lib/util/http';
import { tableColumns } from '../config'; import { tableColumns } from '../config';
import { energyConsumption,carbonEmissionFactorLibrary } from '/@/api/carbonEmissionFactorLibrary'; import {
energyConsumption,
carbonEmissionFactorLibrary,
uploadPic,
} from '/@/api/carbonEmissionFactorLibrary';
import { group } from '/@/api/deviceManage'; import { group } from '/@/api/deviceManage';
defineOptions({ defineOptions({
energyType: 'EnergyConsumption', // name energyType: 'EnergyConsumption', // name
@ -184,17 +320,17 @@
const orgId = ref(''); const orgId = ref('');
const result = JSON.parse(sessionStorage.getItem('ORGID')!); const result = JSON.parse(sessionStorage.getItem('ORGID')!);
orgId.value = result; orgId.value = result;
const fetch = (api, params = { orgId } ) => { const fetch = (api, params = { orgId }) => {
return http.post(api, params); return http.post(api, params);
}; };
const selectYear = ref<Dayjs>(dayjs( new Date().getFullYear().toString())); const selectYear = ref<Dayjs>(dayjs(new Date().getFullYear().toString()));
const total = ref<number>() const total = ref<number>();
const queryParams = ref({ const queryParams = ref({
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
orgId: orgId.value, orgId: orgId.value,
year: selectYear.value.format('YYYY') year: selectYear.value.format('YYYY'),
}) });
const isRequired = ref(false); const isRequired = ref(false);
const visible = ref(false); const visible = ref(false);
const openUpload = ref<boolean>(false); const openUpload = ref<boolean>(false);
@ -225,26 +361,26 @@
const switchWrapperCol = { span: 14 }; const switchWrapperCol = { span: 14 };
const formState = ref({ const formState = ref({
orgId: orgId.value, orgId: orgId.value,
}) });
// form // form
const rules: Record<string, Rule[]> = { const rules: Record<string, Rule[]> = {
energyType: [{ required: true, message: '请输入能源种类', trigger: 'change' }], energyType: [{ required: true, message: '请输入能源种类', trigger: 'change' }],
isComputeCarbon: [{ required: true, message: '请选择是否计算碳排', trigger: 'change' }], isComputeCarbon: [{ required: true, message: '请选择是否计算碳排', trigger: 'change' }],
unit: [{ required: true, message: '请选择计量单位', trigger: 'change' }] unit: [{ required: true, message: '请选择计量单位', trigger: 'change' }],
}; };
// //
const emissionTypeDic = ref() const emissionTypeDic = ref();
// //
const measurementUnit = ref([]) const measurementUnit = ref([]);
// //
const treeData = ref<TreeSelectProps['treeData']>([]); const treeData = ref<TreeSelectProps['treeData']>([]);
// //
const changeYearData = () => { const changeYearData = () => {
queryParams.value.year = selectYear.value queryParams.value.year = selectYear.value;
getTableList() getTableList();
} };
const mainRef = ref(); const mainRef = ref();
const year = selectYear.value.format('YYYY') const year = selectYear.value.format('YYYY');
const tableConfig = ref({ const tableConfig = ref({
title: '能耗统计', title: '能耗统计',
api: energyConsumption.pageList, api: energyConsumption.pageList,
@ -255,8 +391,8 @@
name: 'userAdd', name: 'userAdd',
type: 'primary', type: 'primary',
handle: () => { handle: () => {
getDictList() getDictList();
visible.value = true visible.value = true;
}, },
}, },
{ {
@ -273,20 +409,24 @@
{ {
label: '模板下载', label: '模板下载',
type: 'primary', type: 'primary',
name: 'userExports',
}, },
// {
// label: '',
// type: 'primary',
// handle: () => {
// openUpload.value = true;
// },
// },
{ {
label: '上传凭证', label: '凭证下载',
type: 'primary', type: 'primary',
handle: () => { handle: () => {
openUpload.value = true; fetch(energyConsumption.voucherDownloadList, { bizType: 3 }).then((res) => {
downLoadData.value = res.data;
});
downLoadVisible.value = true;
}, },
}, },
{
label: '凭证下载',
type: 'primary',
name: 'userExports',
},
], ],
columns: [ columns: [
{ {
@ -370,25 +510,33 @@
label: '编辑', label: '编辑',
name: 'userEdit', name: 'userEdit',
handle: (record: any) => { handle: (record: any) => {
getDictList() getDictList();
visible.value = true visible.value = true;
fetch(energyConsumption.findById , {id : record.id }).then((res) => { fetch(energyConsumption.findById, { id: record.id }).then((res) => {
if(res.data.emissionType){ if (res.data.emissionType) {
res.data.emissionType = Number(res.data.emissionType) res.data.emissionType = Number(res.data.emissionType);
} }
if (res.data.unit) { if (res.data.unit) {
let selectDevice = ref([Number(res.data.unit)]); let selectDevice = ref([Number(res.data.unit)]);
findParentIds(measurementUnit.value, res.data.unit, selectDevice.value); findParentIds(measurementUnit.value, res.data.unit, selectDevice.value);
res.data.unit = selectDevice res.data.unit = selectDevice;
} }
formState.value = res.data formState.value = res.data;
emissionType.value = res.data.emissionType emissionType.value = res.data.emissionType;
if(formState.value.isComputeCarbon===0){ if (formState.value.isComputeCarbon === 0) {
isRequired.value = true isRequired.value = true;
}else{ } else {
isRequired.value = false isRequired.value = false;
} }
}); });
fetch(uploadPic.select, { bizId: record.id, bizType: 3 }).then((res) => {
fileList.value = res.data.map((item) => ({
uid: item.id.toString(), // 使id
name: item.fileName, //
status: 'done', //
url: item.filePath, // URLURL
}));
});
}, },
}, },
{ {
@ -437,27 +585,27 @@
} }
// //
const getTableList = () => { const getTableList = () => {
fetch(energyConsumption.pageList , queryParams.value).then((res) => { fetch(energyConsumption.pageList, queryParams.value).then((res) => {
data.value = res.data.records data.value = res.data.records;
}); });
}; };
// //
const onChange = (pageNumber: number,size: number) => { const onChange = (pageNumber: number, size: number) => {
queryParams.value.pageNum = pageNumber; queryParams.value.pageNum = pageNumber;
queryParams.value.pageSize = size; queryParams.value.pageSize = size;
mainRef.value?.nsTableRef.reload(); mainRef.value?.nsTableRef.reload();
}; };
// //
const emissionType = ref() const emissionType = ref();
const changeRadio = (e) => { const changeRadio = (e) => {
if(e.target.value === 0){ if (e.target.value === 0) {
isRequired.value = true isRequired.value = true;
if(emissionType.value){ if (emissionType.value) {
formState.value.emissionType = emissionType.value formState.value.emissionType = emissionType.value;
} }
}else{ } else {
isRequired.value = false isRequired.value = false;
formState.value.emissionType = '' formState.value.emissionType = '';
} }
}; };
// //
@ -466,84 +614,134 @@
.validate() .validate()
.then(() => { .then(() => {
console.log('values', formState, toRaw(formState)); console.log('values', formState, toRaw(formState));
formState.value.year = selectYear.value.format('YYYY') formState.value.year = selectYear.value.format('YYYY');
if(formState.value.unit){ if (formState.value.unit) {
formState.value.unit = formState.value.unit.join(',').split(',')[1] formState.value.unit = formState.value.unit.join(',').split(',')[1];
} }
if(formState.value.id){ if (formState.value.id) {
fetch(energyConsumption.update , formState.value).then((res) => { fetch(energyConsumption.update, formState.value).then((res) => {
visible.value = false if (fileList.value.length !== 0) {
formState.value = { const formData = ref(new FormData());
orgId: orgId.value, fileList.value.forEach((file) => {
} formData.value.append('files', file.originFileObj);
message.success('操作成功!'); });
mainRef.value?.nsTableRef.reload(); formData.value.append('bizType', 3);
}); formData.value.append('bizId', formState.value.id);
}else{ fetch(uploadPic.uploadfiles, formData.value)
fetch(energyConsumption.creat , formState.value).then((res) => { .then((res) => {
if(res.data === '新增数据已存在'){ message.success('操作成功!');
visible.value = false visible.value = false;
NsMessage.warning(res.data); formState.value = {
}else{ orgId: orgId.value,
visible.value = false };
mainRef.value?.nsTableRef.reload();
})
.catch((error) => {
console.log('error', error);
});
} else {
visible.value = false;
formState.value = { formState.value = {
orgId: orgId.value, orgId: orgId.value,
} };
message.success('操作成功!'); message.success('操作成功!');
mainRef.value?.nsTableRef.reload(); mainRef.value?.nsTableRef.reload();
} }
}); });
} else {
fetch(energyConsumption.creat, formState.value).then((res) => {
if (res.data === '新增数据已存在') {
visible.value = false;
NsMessage.warning(res.data);
} else {
if (fileList.value.length !== 0) {
const formData = ref(new FormData());
fileList.value.forEach((file) => {
formData.value.append('files', file.originFileObj);
});
formData.value.append('bizType', 3);
formData.value.append('bizId', res.data);
fetch(uploadPic.uploadfiles, formData.value)
.then((res) => {
message.success('操作成功!');
visible.value = false;
formState.value = {
orgId: orgId.value,
};
mainRef.value?.nsTableRef.reload();
})
.catch((error) => {
console.log('error', error);
});
} else {
visible.value = false;
formState.value = {
orgId: orgId.value,
};
message.success('操作成功!');
mainRef.value?.nsTableRef.reload();
}
}
});
} }
}) })
.catch(error => { .catch((error) => {
console.log('error', error); console.log('error', error);
}); });
}; };
// //
const getDictList = () => { const getDictList = () => {
// //
fetch(energyConsumption.getDicList , {grp: 'EMISSION_TYPE'}).then((res) => { fetch(energyConsumption.getDicList, { grp: 'EMISSION_TYPE' }).then((res) => {
emissionTypeDic.value = res.data emissionTypeDic.value = res.data;
}); });
// //
fetch(carbonEmissionFactorLibrary.dictionaryUnitManagement, { grp: 'MEASUREMENT_UNIT'}).then((res) => { fetch(carbonEmissionFactorLibrary.dictionaryUnitManagement, { grp: 'MEASUREMENT_UNIT' }).then(
measurementUnit.value = res.data (res) => {
measurementUnit.value = measurementUnit.value.map(item => ({ measurementUnit.value = res.data;
value: item.id, measurementUnit.value = measurementUnit.value.map((item) => ({
label: item.cnValue, value: item.id,
children: item.children ? item.children.map(child => ({ label: item.cnValue,
value: child.id, children: item.children
label: child.cnValue ? item.children.map((child) => ({
})) : [] value: child.id,
})); label: child.cnValue,
}); }))
: [],
}));
},
);
// //
fetch(group.queryDeviceGroupTree, { energyType: 'ELECTRICITY_USAGE',orgId: orgId.value }).then((res) => { fetch(group.queryDeviceGroupTree, { energyType: 'ELECTRICITY_USAGE', orgId: orgId.value }).then(
treeData.value = res.data (res) => {
treeData.value = treeData.value.map(item => ({ treeData.value = res.data;
value: item.id, treeData.value = treeData.value.map((item) => ({
label: item.pointName, value: item.id,
children: item.children ? item.children.map(child => ({ label: item.pointName,
value: child.id, children: item.children
label: child.pointName ? item.children.map((child) => ({
})) : [] value: child.id,
})); label: child.pointName,
}); }))
} : [],
}));
},
);
};
// //
const addNewData = () => { const addNewData = () => {
getDictList() getDictList();
visible.value = true visible.value = true;
} };
// //
const editData = (record) =>{ const editData = (record) => {
getDictList() getDictList();
visible.value = true visible.value = true;
fetch(energyConsumption.findById , {id : record.id }).then((res) => { fetch(energyConsumption.findById, { id: record.id }).then((res) => {
if(res.data.unitName){ if (res.data.unitName) {
res.data.unitName = res.data.unitName.split(',') res.data.unitName = res.data.unitName.split(',');
} }
formState.value = res.data formState.value = res.data;
}); });
}; };
// //
@ -555,7 +753,7 @@
okType: 'primary', okType: 'primary',
cancelText: '取消', cancelText: '取消',
onOk() { onOk() {
fetch(energyConsumption.del , {id : record.id }).then((res) => { fetch(energyConsumption.del, { id: record.id }).then((res) => {
message.success('操作成功!'); message.success('操作成功!');
mainRef.value?.nsTableRef.reload(); mainRef.value?.nsTableRef.reload();
}); });
@ -564,13 +762,13 @@
console.log('Cancel'); console.log('Cancel');
}, },
}); });
} };
// //
const onClose = () => { const onClose = () => {
visible.value = false; visible.value = false;
formState.value = { formState.value = {
orgId: orgId.value, orgId: orgId.value,
} };
formRef.value.resetFields(); formRef.value.resetFields();
}; };
// //
@ -583,25 +781,73 @@
openUpload.value = false; openUpload.value = false;
}; };
// //
const fileList = ref([]); const fileList = ref<UploadProps['fileList']>([]);
const beforeUpload: UploadProps['beforeUpload'] = (file) => {
return false;
};
const handleChange = (info: UploadChangeParam) => { const handleChange = (info: UploadChangeParam) => {
const status = info.file.status; fileList.value = [...info.fileList];
if (status !== 'uploading') { if (info.file.status !== 'uploading') {
console.log(info.file, info.fileList); console.log(info.file, info.fileList);
} }
if (status === 'done') { if (info.file.status === 'done') {
message.success(`${info.file.name} 文件上传成功`); message.success(`${info.file.name} 文件上传成功`);
} else if (status === 'error') { } else if (info.file.status === 'error') {
message.error(`${info.file.name} 文件上传失败`); message.error(`${info.file.name} 文件上传失败`);
} }
}; };
function handleDrop(e: DragEvent) { const handleFileRemove = (file) => {
console.log(e); const newFileList = [];
} fileList.value.forEach((item) => {
if (item.uid !== file.uid) {
newFileList.push(item);
}
});
fileList.value = newFileList;
};
// //
const closeOpenUpload = () =>{ const closeOpenUpload = () => {
openUpload.value = false; openUpload.value = false;
}; };
//
const downLoadVisible = ref(false);
const downLoadColumns = [
{
title: '序号',
customRender: (text: any) => {
return text.index + 1;
},
},
{
title: '能源类型',
dataIndex: 'bizName',
},
{
title: '文件名',
dataIndex: 'fileName',
ellipsis: true,
},
{
title: '操作',
key: 'action',
},
];
const downLoadData = ref([]);
const selectedRowKeysSet = ref([]);
const onSelectionChangeSet = (selectedKeys, selectedRows) => {
selectedRowKeysSet.value = selectedKeys;
};
const downLoad = (record) => {
const deleteId = ref(new FormData());
deleteId.value.append('id', record.id);
fetch(uploadPic.download, deleteId.value).then((res) => {
console.log(res);
});
};
const onSubmitDownLoad = () => {};
const onCloseDownLoad = () => {
downLoadVisible.value = false;
};
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
:deep(.ant-table-title) { :deep(.ant-table-title) {
@ -610,7 +856,7 @@
:deep(.ant-table-container) { :deep(.ant-table-container) {
padding: 0px 16px; padding: 0px 16px;
} }
.buttonGroup{ .buttonGroup {
margin-left: 1vw; margin-left: 1vw;
width: 30vw; width: 30vw;
display: flex; display: flex;

9
hx-ai-intelligent/src/view/carbonEmissionManage/carbonInventoryCheck/config.ts

@ -8,13 +8,14 @@ export const voucherColumns = [
}, },
{ {
title: '日期', title: '日期',
dataIndex: 'age', dataIndex: 'updateTime',
key: 'age', key: 'updateTime',
ellipsis: true,
}, },
{ {
title: '文件名称', title: '文件名称',
dataIndex: 'address', dataIndex: 'fileName',
key: 'address 1', key: 'fileName',
ellipsis: true, ellipsis: true,
}, },
]; ];

90
hx-ai-intelligent/src/view/carbonEmissionManage/carbonInventoryCheck/fillInPage/index.vue

@ -275,6 +275,7 @@
<a-tree-select <a-tree-select
v-model:value="editFormState.collectionNode" v-model:value="editFormState.collectionNode"
:tree-line="true" :tree-line="true"
@select="selectNode"
:tree-data="collectingNodes"> :tree-data="collectingNodes">
</a-tree-select> </a-tree-select>
</a-form-item> </a-form-item>
@ -320,8 +321,9 @@
<a-upload <a-upload
v-model:file-list="fileList" v-model:file-list="fileList"
name="file" name="file"
action="https://www.mocky.io/v2/5cc8019d300000980a055e76" accept=".jpg,.jpeg,.png,.gif,.bmp,.pdf"
:headers="headers" @remove="handleFileRemove"
:before-upload="beforeUpload"
@change="handleChange"> @change="handleChange">
<a-button> <a-button>
<upload-outlined></upload-outlined> <upload-outlined></upload-outlined>
@ -353,6 +355,7 @@
energyConsumption, energyConsumption,
carbonEmissionFactorLibrary, carbonEmissionFactorLibrary,
carbonInventoryCheck, carbonInventoryCheck,
uploadPic,
} from '/@/api/carbonEmissionFactorLibrary'; } from '/@/api/carbonEmissionFactorLibrary';
import { group } from '/@/api/deviceManage'; import { group } from '/@/api/deviceManage';
import { debug, log } from 'node:console'; import { debug, log } from 'node:console';
@ -844,6 +847,9 @@
// //
const openVoucher = ref(false); const openVoucher = ref(false);
const downLoadVoucher = () => { const downLoadVoucher = () => {
fetch(carbonInventoryCheck.voucherDownloadList, { bizType: 2 }).then((res) => {
voucherData.value = res.data
});
openVoucher.value = true; openVoucher.value = true;
}; };
const selectedRowKeys = ref([]); const selectedRowKeys = ref([]);
@ -851,29 +857,7 @@
selectedRowKeys.value = selectedKeys; selectedRowKeys.value = selectedKeys;
}; };
const voucherData = [ const voucherData = ref([]);
{
key: '1',
name: 'John Brown',
age: 32,
address: 'New York No. 1 Lake Park, New York No. 1 Lake Park',
tags: ['nice', 'developer'],
},
{
key: '2',
name: 'Jim Green',
age: 42,
address: 'London No. 2 Lake Park, London No. 2 Lake Park',
tags: ['loser'],
},
{
key: '3',
name: 'Joe Black',
age: 32,
address: 'Sidney No. 1 Lake Park, Sidney No. 1 Lake Park',
tags: ['cool', 'teacher'],
},
];
const onCloseVoucher = () => { const onCloseVoucher = () => {
openVoucher.value = false; openVoucher.value = false;
}; };
@ -909,6 +893,14 @@
editFormState.value.collectionNode = record.carbonSource; editFormState.value.collectionNode = record.carbonSource;
editFormState.value.factorId = record.factorId; editFormState.value.factorId = record.factorId;
selectedRowKeysEdit.value = [record.factorId]; selectedRowKeysEdit.value = [record.factorId];
fetch(uploadPic.select, { bizId: record.id, bizType: 2 }).then((res) => {
fileList.value = res.data.map((item) => ({
uid: item.id.toString(), // 使id
name: item.fileName, //
status: 'done', //
url: item.filePath, // URLURL
}));
});
editData.value = true; editData.value = true;
}; };
const getNewTable = () => { const getNewTable = () => {
@ -946,23 +938,35 @@
}, },
); );
}; };
const selectNode = (value) => {
debugger;
};
// //
const fileList = ref<UploadProps['fileList']>([]);
const beforeUpload: UploadProps['beforeUpload'] = (file) => {
return false;
};
const handleChange = (info: UploadChangeParam) => { const handleChange = (info: UploadChangeParam) => {
fileList.value = [...info.fileList];
if (info.file.status !== 'uploading') { if (info.file.status !== 'uploading') {
console.log(info.file, info.fileList); console.log(info.file, info.fileList);
} }
if (info.file.status === 'done') { if (info.file.status === 'done') {
message.success(`${info.file.name} file uploaded successfully`); message.success(`${info.file.name} 文件上传成功`);
} else if (info.file.status === 'error') { } else if (info.file.status === 'error') {
message.error(`${info.file.name} file upload failed.`); message.error(`${info.file.name} 文件上传失败`);
} }
}; };
const handleFileRemove = (file) => {
const fileList = ref([]); const newFileList = [];
const headers = { fileList.value.forEach((item) => {
authorization: 'authorization-text', if (item.uid !== file.uid) {
newFileList.push(item);
}
});
fileList.value = newFileList;
}; };
// // ;
const submitEditData = () => { const submitEditData = () => {
editFormRef.value editFormRef.value
.validate() .validate()
@ -978,8 +982,26 @@
editFormState.value.collectionNode = editFormState.value.collectionNode.value; editFormState.value.collectionNode = editFormState.value.collectionNode.value;
} }
fetch(carbonInventoryCheck.updateTable, editFormState.value).then((res) => { fetch(carbonInventoryCheck.updateTable, editFormState.value).then((res) => {
editData.value = false; if (fileList.value.length !== 0) {
getPFYTableList(getTableId.value); const formData = ref(new FormData());
fileList.value.forEach((file) => {
formData.value.append('files', file.originFileObj);
});
formData.value.append('bizType', 2);
formData.value.append('bizId', editFormState.value.id);
fetch(uploadPic.uploadfiles, formData.value)
.then((res) => {
message.success('操作成功!');
editData.value = false;
getPFYTableList(getTableId.value);
})
.catch((error) => {
console.log('error', error);
});
} else {
editData.value = false;
getPFYTableList(getTableId.value);
}
}); });
}) })
.catch((error) => { .catch((error) => {

13
hx-ai-intelligent/src/view/carbonEmissionManage/carbonInventoryCheck/index.vue

@ -5,7 +5,12 @@
</div> </div>
<!-- 填报页 --> <!-- 填报页 -->
<div v-if="fillInPage" style="height: 100%"> <div v-if="fillInPage" style="height: 100%">
<fillIn :reportId="reportId" :year="year" :startTime="startTime" :endTime="endTime" @change-data="updateData" /> <fillIn
:reportId="reportId"
:year="year"
:startTime="startTime"
:endTime="endTime"
@change-data="updateData" />
</div> </div>
<!-- 新增报告弹窗 --> <!-- 新增报告弹窗 -->
<a-drawer <a-drawer
@ -33,7 +38,7 @@
<a-form-item label="报告周期" name="reportPeriod"> <a-form-item label="报告周期" name="reportPeriod">
<a-select <a-select
v-model:value="formState.reportPeriod" v-model:value="formState.reportPeriod"
placeholder="请选择排放类型" placeholder="请选择报告周期"
@change="selectChange"> @change="selectChange">
<a-select-option value="1">年度</a-select-option> <a-select-option value="1">年度</a-select-option>
<a-select-option value="2">月度</a-select-option> <a-select-option value="2">月度</a-select-option>
@ -81,7 +86,9 @@
return year === Number(formState.value.reportYear) ? false : true; return year === Number(formState.value.reportYear) ? false : true;
} }
}; };
const selectChange = (value) => {}; const selectChange = (value) => {
formState.value.reportScope = '';
};
// form // form
const rules: Record<string, Rule[]> = { const rules: Record<string, Rule[]> = {
reportName: [{ required: true, message: '请输入报告名称', trigger: 'change' }], reportName: [{ required: true, message: '请输入报告名称', trigger: 'change' }],

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

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

Loading…
Cancel
Save