Browse Source

修改测试问题

temp
fks-xuxinyue 3 months ago
parent
commit
c09ca418b3
  1. 1
      hx-ai-intelligent/src/view/carbonEmissionManage/carbonAssets/carbonAssetsDetail/index.vue
  2. 713
      hx-ai-intelligent/src/view/carbonEmissionManage/carbonAssets/carbonAssetsDetail/indexCopy.vue
  3. 261
      hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionFactorLibrary/index.vue
  4. 3
      hx-ai-intelligent/src/view/carbonEmissionManage/carbonInventoryCheck/config.ts
  5. 52
      hx-ai-intelligent/src/view/carbonEmissionManage/carbonInventoryCheck/fillInPage/index.vue
  6. 46
      hx-ai-intelligent/src/view/carbonEmissionManage/carbonPlanning/all/index.vue

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

@ -523,6 +523,7 @@
visible.value = false;
delIds.value = [];
getDetailList();
getTotalTable();
})
.catch((error) => {
console.log('error', error);

713
hx-ai-intelligent/src/view/carbonEmissionManage/carbonAssets/carbonAssetsDetail/indexCopy.vue

@ -0,0 +1,713 @@
<template>
<div class="search">
<a-card style="border-radius: 12px">
<div class="ns-form-title">
<div class="title">查询</div>
<div class="operation">
<a-button type="primary" @click="changeParentData"> 返回 </a-button>
</div>
</div>
<a-form layout="inline">
<a-form-item>
<a-select
v-model:value="queryParams.accountType"
style="width: 200px"
placeholder="请输入账户类型">
<a-select-option :value="1">全国账户</a-select-option>
<a-select-option :value="2">地方账户</a-select-option>
<a-select-option :value="3">CCER</a-select-option>
</a-select>
</a-form-item>
<a-form-item>
<a-cascader
v-model:value="queryParams.transactionType"
multiple
style="width: 200px"
:options="options"
placeholder="请选择交易类型"
suffix-icon="Shopping Around">
<template #tagRender="data">
<a-tag :key="data.value" color="blue">{{ data.label }}</a-tag>
</template>
</a-cascader>
</a-form-item>
<a-form-item>
<a-date-picker
style="width: 200px"
v-model:value="queryParams.year"
placeholder="请选择账期"
picker="year"
valueFormat="YYYY" />
</a-form-item>
<a-form-item>
<a-button type="primary" @click="searchTableList">查询</a-button>
<a-button html-type="submit" style="margin-left: 6px" @click="reset">重置</a-button>
</a-form-item>
</a-form>
</a-card>
</div>
<div style="display: flex; margin-top: 20px; height: calc(84% - 20px)">
<div class="detailTable">
<ns-view-list-table v-bind="tableConfig" :model="data" ref="mainRef" :scroll="{ x: 2000 }">
</ns-view-list-table>
</div>
<div class="total">
<div class="ns-form-title">
<div class="title">配额统计</div>
<div class="operation" style="display: flex; justify-content: space-around; width: 63%">
<a-button type="primary" @click="getTotalTable(1)">全国配额</a-button>
<a-button type="primary" @click="getTotalTable(2)">地方配额</a-button>
<a-button type="primary" @click="getTotalTable(3)">CCER配额</a-button>
</div>
</div>
<a-table :columns="totalColumns" :data-source="totalData" bordered :pagination="false">
<template #bodyCell="{ column, text }">
<template v-if="column.dataIndex === 'name'">
<a>{{ text }}</a>
</template>
</template>
</a-table>
</div>
</div>
<!-- 新增报告弹窗 -->
<a-drawer
:width="500"
:visible="visible"
:body-style="{ paddingBottom: '80px' }"
:footer-style="{ textAlign: 'right' }"
destroyOnClose
@close="onClose">
<div class="ns-form-title" style="display: flex">
<div class="title">{{ text }}</div>
</div>
<a-form
ref="formRef"
:model="formState"
:rules="rules"
:label-col="labelCol"
:wrapper-col="wrapperCol">
<a-form-item ref="name" label="账户类型" name="accountType">
<a-select v-model:value="formState.accountType" placeholder="请输入账户类型">
<a-select-option value="1">全国账户</a-select-option>
<a-select-option value="2">地方账户</a-select-option>
<a-select-option value="3">CCER</a-select-option>
</a-select>
</a-form-item>
<a-form-item ref="name" label="交易类型" name="transactionType">
<a-cascader
v-model:value="formState.transactionType"
:options="options"
placeholder="请选择交易类型" />
</a-form-item>
<a-form-item ref="name" label="交易日期" name="transactionDate">
<a-date-picker v-model:value="formState.transactionDate" valueFormat="YYYY-MM-DD" />
</a-form-item>
<a-form-item ref="name" label="交易数量" name="transactionQuantity">
<a-input v-model:value="formState.transactionQuantity" placeholder="请输入交易数量" />
</a-form-item>
<a-form-item ref="name" label="发生金额" name="amountIncurred">
<a-input v-model:value="formState.amountIncurred" placeholder="请输入发生金额" />
</a-form-item>
<a-form-item ref="name" label="交易对象" name="tradingPartner">
<a-input v-model:value="formState.tradingPartner" placeholder="请输入交易对象" />
</a-form-item>
<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>
<template #footer>
<a-button style="margin-right: 8px" @click="onClose">取消</a-button>
<a-button type="primary" @click="onSubmit">确定</a-button>
</template>
</a-drawer>
</template>
<script lang="ts" setup>
import { ref, defineEmits, toRaw } from 'vue';
import { http } from '/nerv-lib/util/http';
import { UploadOutlined } from '@ant-design/icons-vue';
import type { UploadChangeParam, UploadProps } from 'ant-design-vue';
import { Pagination, Modal, message } from 'ant-design-vue';
import {
carbonAssets,
carbonEmissionFactorLibrary,
uploadPic,
} from '/@/api/carbonEmissionFactorLibrary';
import { log } from 'console';
defineOptions({
energyType: 'carbonAssets', // name
components: {
'a-pagination': Pagination,
},
});
// id
const props = defineProps({
parentId: {
type: Number,
},
});
const orgId = ref('');
const result = JSON.parse(sessionStorage.getItem('ORGID')!);
orgId.value = result;
const fetch = (api, params = { orgId }, config) => {
return http.post(api, params, config);
};
//
const selectedRowKeys = ref([]);
const onSelectionChange = (selectedKeys, selectedRows) => {
selectedRowKeys.value = selectedKeys;
};
const total = ref<number>();
const thisYear = ref(new Date().getFullYear().toString());
const queryParams = ref({
pageNum: 1,
pageSize: 10,
orgId: orgId.value,
accountType: props.parentId,
year: thisYear.value,
});
const searchTableList = () => {
getDetailList();
};
//
const getDetailList = () => {
fetch(carbonAssets.carbonDetailsList, queryParams.value).then((res) => {
data.value = res.data.records;
total.value = res.data.total;
});
};
// getDetailList();
const columns = [
{
title: '序号',
customRender: (text: any) => {
return text.index + 1;
},
},
{
title: '资产类别',
dataIndex: 'accountType',
},
{
title: '交易方式',
dataIndex: 'transactionTypeName',
},
{
title: '交易日期',
dataIndex: 'transactionDate',
sorter: (a, b) => a.transactionDate - b.transactionDate,
},
{
title: '本期收入(tCO2)',
dataIndex: 'income',
sorter: (a, b) => a.income - b.income,
},
{
title: '本期支出(tCO2)',
dataIndex: 'expenditure',
sorter: (a, b) => a.expenditure - b.expenditure,
},
{
title: '发生金额(¥)',
dataIndex: 'amountIncurredValue',
},
{
title: '交易对象',
dataIndex: 'tradingPartner',
},
{
title: '更新人',
dataIndex: 'updateUser',
},
{
title: '更新时间',
dataIndex: 'updateTime',
},
{
title: '操作',
key: 'action',
width: 130,
},
];
const data = ref([]);
const reset = () => {
queryParams.value = {
pageNum: 1,
pageSize: 10,
orgId: orgId.value,
year: new Date().getFullYear(),
};
getDetailList();
};
const editData = (record) => {
getDictList();
text.value = '编辑';
visible.value = true;
formState.value.id = record.id;
fetch(uploadPic.select, { bizId: record.id, bizType: 1 }).then((res) => {
fileList.value = res.data.map((item) => ({
uid: item.id.toString(), // 使id
name: item.fileName, //
status: 'done', //
type: 'done',
url: item.filePath, // URLURL
}));
});
formState.value = JSON.parse(JSON.stringify(record));
if (formState.value.expenditure === 0) {
formState.value.transactionQuantity = formState.value.income;
} else {
formState.value.transactionQuantity = formState.value.expenditure;
}
setTimeout(() => {
let selectDevice = ref([Number(formState.value.transactionType)]);
findParentIds(options.value, formState.value.transactionType, selectDevice.value);
formState.value.transactionType = selectDevice;
formState.value.transactionType = formState.value.transactionType;
}, 500);
};
// id
function findParentIds(tree: any, targetId: number, result: any) {
for (let item of tree) {
if (item.children && item.children.length > 0) {
if (item.children.some((child: any) => child.value === targetId)) {
result.unshift(item.value); // id
findParentIds(tree, item.value, result); // id
break; // 退
}
}
}
}
const delData = (record) => {
const id = [record.id];
Modal.confirm({
title: '警告',
content: '确定要删除吗?',
okText: '确定',
okType: 'primary',
cancelText: '取消',
onOk() {
fetch(carbonAssets.delete, { ids: id }).then((res) => {
message.success('操作成功!');
getDetailList();
});
},
onCancel() {
console.log('Cancel');
},
});
};
const deleteMore = () => {
Modal.confirm({
title: '警告',
content: '确定要删除吗?',
okText: '确定',
okType: 'primary',
cancelText: '取消',
onOk() {
fetch(carbonAssets.delete, { ids: selectedRowKeys.value }).then((res) => {
message.success('操作成功!');
getDetailList();
});
},
onCancel() {
console.log('Cancel');
},
});
};
const mainRef = ref();
const tableConfig = ref({
title: '数据库',
api: carbonAssets.carbonDetailsList,
params: {
orgId,
},
headerActions: [
{
label: '新增',
name: 'userAdd',
type: 'primary',
handle: () => {
},
},
{
label: '导入',
type: 'primary',
name: 'carbonEmissionFactorLibraryImport',
extra: {
api: carbonEmissionFactorLibrary.import, //
params: {
orgId,
},
title: '排放源', // title
templateName: 'emissionSource', // 使
indexName: '设备id', //
message: [
{ label: '1、若必填项未填写,则不能进行导入操作' },
{ label: `2、当重复时,则更新数据。` },
{ label: '3、数据将从模版的第五行进行导入。' },
{ label: '4、文件导入勿超过5MB。' },
],
},
},
{
label: '导出',
type: 'primary',
handle: () => {
},
},
{
label: '批量删除',
type: 'primary',
name: 'userBatchDel',
dynamicDisabled: (data: any) => {
return data.list.length === 0;
},
confirm: true,
isReload: true,
isClearCheck: true,
api: carbonEmissionFactorLibrary.del,
dynamicParams: { ids: 'id[]' },
},
],
columns: [
{
title: '序号',
customRender: (text: any) => {
return text.index + 1;
},
},
{
title: '资产类别',
dataIndex: 'accountType',
},
{
title: '交易方式',
dataIndex: 'transactionTypeName',
},
{
title: '交易日期',
dataIndex: 'transactionDate',
sorter: (a, b) => a.transactionDate - b.transactionDate,
},
{
title: '本期收入(tCO2)',
dataIndex: 'income',
sorter: (a, b) => a.income - b.income,
},
{
title: '本期支出(tCO2)',
dataIndex: 'expenditure',
sorter: (a, b) => a.expenditure - b.expenditure,
},
{
title: '发生金额(¥)',
dataIndex: 'amountIncurredValue',
},
{
title: '交易对象',
dataIndex: 'tradingPartner',
},
{
title: '更新人',
dataIndex: 'updateUser',
},
{
title: '更新时间',
dataIndex: 'updateTime',
},
],
columnActions: {
title: '操作',
actions: [
{
label: '编辑',
name: 'userEdit',
handle: (record: any) => {},
},
{
label: '删除',
name: 'userDelete',
dynamicParams: { ids: 'id[]' },
confirm: true,
isReload: true,
api: carbonEmissionFactorLibrary.del,
},
],
},
rowKey: 'id',
});
//
const onChange = (pageNumber: number, size: number) => {
queryParams.value.pageNum = pageNumber;
queryParams.value.pageSize = size;
getDetailList();
};
//
const visible = ref(false);
const text = ref('新增');
const formState = ref({
orgId: orgId.value,
});
const formRef = ref();
const labelCol = { span: 5 };
const wrapperCol = { span: 19 };
const options = ref([]);
//
const getDictList = () => {
fetch(carbonEmissionFactorLibrary.dictionaryUnitManagement, { grp: 'TRANSACTION_TYPE' }).then(
(res) => {
options.value = res.data;
options.value = options.value.map((item) => ({
value: item.id,
label: item.cnValue,
children: item.children
? item.children.map((child) => ({
value: child.id,
label: child.cnValue,
}))
: [],
}));
},
);
};
getDictList();
//
const addDetail = () => {
text.value = '新增';
visible.value = true;
getDictList();
};
const importFileList = ref<UploadProps['fileList']>([]);
const importFile = (options: UploadRequestOption) => {
const { file, onSuccess, onError } = options;
const formData = ref(new FormData());
formData.value.append('file', file as any);
formData.value.append('orgId', orgId.value);
formData.value.append('year', queryParams.value.year);
fetch(carbonAssets.import, formData.value)
.then((res) => {
message.success('操作成功!');
getDetailList();
})
.catch((error) => {
console.log('error', error);
});
};
const exportFile = () => {
const exportQuery = ref({
orgId: orgId.value,
pageNum: 1,
pageSize: 999,
year: queryParams.value.year,
ids: selectedRowKeys.value,
});
const config = {
responseType: 'blob',
};
fetch(carbonAssets.export, exportQuery.value, config)
.then((res) => {
// URL blob
const url = window.URL.createObjectURL(new Blob([res]));
// <a>
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'carbonTradeDetails.xlsx'); //
document.body.appendChild(link);
link.click();
// URL
window.URL.revokeObjectURL(url);
selectedRowKeys.value = [];
})
.catch((error) => {
console.error('下载失败:', error);
});
};
//
const fileList = ref<UploadProps['fileList']>([]);
const beforeUpload: UploadProps['beforeUpload'] = (file) => {
return false;
};
const handleChange = (info: UploadChangeParam) => {
fileList.value = [...info.fileList];
if (info.file.status !== 'uploading') {
console.log(info.file, info.fileList);
}
if (info.file.status === 'done') {
message.success(`${info.file.name} 文件上传成功`);
} else if (info.file.status === 'error') {
message.error(`${info.file.name} 文件上传失败`);
}
};
const delIds = ref([]);
const handleFileRemove = (file) => {
delIds.value.push(file.uid);
const newFileList = [];
fileList.value.forEach((item) => {
if (item.uid !== file.uid) {
newFileList.push(item);
}
});
fileList.value = newFileList;
};
const onSubmit = () => {
formRef.value
.validate()
.then(() => {
console.log('values', formState, toRaw(formState));
if (formState.value.transactionType) {
formState.value.transactionType = formState.value.transactionType.join(',').split(',')[1];
}
if (formState.value.accountType.value) {
formState.value.accountType = formState.value.accountType.value;
}
fetch(carbonAssets.createOrUpdate, formState.value).then((res) => {
if (res.data.id && fileList.value.length !== 0) {
// uploadQuery.value.bizId = res.data.id;
const formData = ref(new FormData());
fileList.value.forEach((file) => {
if (file.type !== 'done') {
formData.value.append('files', file.originFileObj);
}
});
formData.value.append('bizType', 1);
formData.value.append('bizId', res.data.id);
delIds.value.forEach((item) => {
formData.value.append('deleteList', item);
});
fetch(uploadPic.uploadfiles, formData.value)
.then((res) => {
message.success('操作成功!');
visible.value = false;
delIds.value = [];
getDetailList();
getTotalTable();
})
.catch((error) => {
console.log('error', error);
});
} else {
message.success('操作成功!');
visible.value = false;
delIds.value = [];
getDetailList();
}
});
})
.catch((error) => {
console.log('error', error);
});
};
// form
const rules: Record<string, Rule[]> = {
accountType: [{ required: true, message: '请输入账户类型', trigger: 'change' }],
transactionType: [{ required: true, message: '请选择交易类型', trigger: 'change' }],
transactionDate: [{ required: true, message: '请选择交易日期', trigger: 'change' }],
transactionQuantity: [{ required: true, message: '请输入交易数量', trigger: 'change' }],
amountIncurred: [{ required: true, message: '请输入发生金额', trigger: 'change' }],
tradingPartner: [{ required: true, message: '请输入交易对象', trigger: 'change' }],
};
//
const onClose = () => {
visible.value = false;
delIds.value = [];
formState.value = {};
fileList.value = [];
formRef.value.resetFields();
};
//
const getTotalTable = (type) => {
if (type) {
queryParams.value.accountType = type;
}
fetch(carbonAssets.quotaStatistics, queryParams.value).then((res) => {
totalData.value = res.data;
});
};
getTotalTable();
const totalColumns = [
{
title: '统计类型',
dataIndex: 'statisticType',
},
{
title: '小计',
dataIndex: 'subtotal',
},
{
title: '合计',
dataIndex: 'amountTo',
},
];
const totalData = ref([]);
//
const emit = defineEmits(['change-data']);
const changeParentData = () => {
emit('change-data', true);
};
</script>
<style lang="less" scoped>
.ns-form-title {
font-weight: bold;
user-select: text;
padding-bottom: 10px;
display: flex;
justify-content: space-between;
}
.title {
text-align: left;
height: 32px;
line-height: 32px;
font-weight: bold;
user-select: text;
position: relative;
padding-left: 9px;
}
.title::before {
content: '';
position: absolute;
left: 0;
top: 50%;
transform: translateY(-50%);
height: 13px;
width: 3px;
border-radius: 1px;
background-color: #2778ff;
}
:deep(.ant-card-body) {
padding: 16px;
}
.search {
height: 16%;
}
.detailTable {
width: 65%;
margin-right: 20px;
height: 100%;
background: white;
border-radius: 12px;
padding: 16px;
}
.total {
width: calc(35% - 20px);
height: 100%;
background: white;
border-radius: 12px;
padding: 16px;
}
</style>

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

@ -22,7 +22,6 @@
v-if="gData && gData.length > 0"
class="draggable-tree"
style="padding: 0 16px !important"
draggable
checkable
block-node
:tree-data="gData"
@ -95,7 +94,11 @@
</div>
<!-- 新增树节点 -->
<ns-modal :visible="treeNodeAdd" :title="operationTree" @ok="handleOk" @cancel="handleCancel">
<ns-input v-model:value="addTreeNode" :maxlength="10" class="input" placeholder="请输入排放类型" />
<ns-input
v-model:value="addTreeNode"
:maxlength="10"
class="input"
placeholder="请输入排放类型" />
</ns-modal>
<!-- 新增数据库数据 -->
<a-drawer
@ -290,32 +293,38 @@
const x = 3;
const y = 2;
const z = 1;
const genData: TreeProps['treeData'] = [];
const genData: TreeProps['treeData'] = [
{
emissionName: '全部',
key: '0-0',
children: [],
},
];
const checkedTreeNodeKeys = ref<string[]>();
const generateData = (_level: number, _preKey?: string, _tns?: TreeProps['treeData']) => {
const preKey = _preKey || '0';
const tns = _tns || genData;
// const generateData = (_level: number, _preKey?: string, _tns?: TreeProps['treeData']) => {
// const preKey = _preKey || '0';
// const tns = _tns || genData;
const children = [];
for (let i = 0; i < x; i++) {
const key = `${preKey}-${i}`;
tns.push({ title: key, key });
if (i < y) {
children.push(key);
}
}
if (_level < 0) {
return tns;
}
const level = _level - 1;
children.forEach((key, index) => {
tns[index].children = [];
return generateData(level, key, tns[index].children);
});
};
generateData(z);
type TreeDataItem = TreeProps['treeData'][number];
// const children = [];
// for (let i = 0; i < x; i++) {
// const key = `${preKey}-${i}`;
// tns.push({ title: key, key });
// if (i < y) {
// children.push(key);
// }
// }
// if (_level < 0) {
// return tns;
// }
// const level = _level - 1;
// children.forEach((key, index) => {
// tns[index].children = [];
// return generateData(level, key, tns[index].children);
// });
// };
// generateData(z);
// type TreeDataItem = TreeProps['treeData'][number];
const gData = ref<TreeProps['treeData']>(genData);
const onDragEnter = (info: AntTreeNodeDragEnterEvent) => {
console.log(info);
@ -323,62 +332,62 @@
// expandedKeys.value = info.expandedKeys;
};
const onDrop = (info: AntTreeNodeDropEvent) => {
console.log(info);
const dropKey = info.node.key;
const dragKey = info.dragNode.key;
const dropPos = info.node.pos.split('-');
const dropPosition = info.dropPosition - Number(dropPos[dropPos.length - 1]);
const loop = (data: TreeProps['treeData'], key: string | number, callback: any) => {
data.forEach((item, index) => {
if (item.key === key) {
return callback(item, index, data);
}
if (item.children) {
return loop(item.children, key, callback);
}
});
};
const data = [...gData.value];
// const onDrop = (info: AntTreeNodeDropEvent) => {
// console.log(info);
// const dropKey = info.node.key;
// const dragKey = info.dragNode.key;
// const dropPos = info.node.pos.split('-');
// const dropPosition = info.dropPosition - Number(dropPos[dropPos.length - 1]);
// const loop = (data: TreeProps['treeData'], key: string | number, callback: any) => {
// data.forEach((item, index) => {
// if (item.key === key) {
// return callback(item, index, data);
// }
// if (item.children) {
// return loop(item.children, key, callback);
// }
// });
// };
// const data = [...gData.value];
// Find dragObject
let dragObj: TreeDataItem;
loop(data, dragKey, (item: TreeDataItem, index: number, arr: TreeProps['treeData']) => {
arr.splice(index, 1);
dragObj = item;
});
if (!info.dropToGap) {
// Drop on the content
loop(data, dropKey, (item: TreeDataItem) => {
item.children = item.children || [];
/// where to insert
item.children.unshift(dragObj);
});
} else if (
(info.node.children || []).length > 0 && // Has children
info.node.expanded && // Is expanded
dropPosition === 1 // On the bottom gap
) {
loop(data, dropKey, (item: TreeDataItem) => {
item.children = item.children || [];
// where to insert
item.children.unshift(dragObj);
});
} else {
let ar: TreeProps['treeData'] = [];
let i = 0;
loop(data, dropKey, (_item: TreeDataItem, index: number, arr: TreeProps['treeData']) => {
ar = arr;
i = index;
});
if (dropPosition === -1) {
ar.splice(i, 0, dragObj);
} else {
ar.splice(i + 1, 0, dragObj);
}
}
gData.value = data;
};
// // Find dragObject
// let dragObj: TreeDataItem;
// loop(data, dragKey, (item: TreeDataItem, index: number, arr: TreeProps['treeData']) => {
// arr.splice(index, 1);
// dragObj = item;
// });
// if (!info.dropToGap) {
// // Drop on the content
// loop(data, dropKey, (item: TreeDataItem) => {
// item.children = item.children || [];
// /// where to insert
// item.children.unshift(dragObj);
// });
// } else if (
// (info.node.children || []).length > 0 && // Has children
// info.node.expanded && // Is expanded
// dropPosition === 1 // On the bottom gap
// ) {
// loop(data, dropKey, (item: TreeDataItem) => {
// item.children = item.children || [];
// // where to insert
// item.children.unshift(dragObj);
// });
// } else {
// let ar: TreeProps['treeData'] = [];
// let i = 0;
// loop(data, dropKey, (_item: TreeDataItem, index: number, arr: TreeProps['treeData']) => {
// ar = arr;
// i = index;
// });
// if (dropPosition === -1) {
// ar.splice(i, 0, dragObj);
// } else {
// ar.splice(i + 1, 0, dragObj);
// }
// }
// gData.value = data;
// };
const dataList: TreeProps['treeData'] = [];
const generateList = (data: TreeProps['treeData']) => {
for (let i = 0; i < data.length; i++) {
@ -409,30 +418,30 @@
}
return parentKey;
};
const expandedKeys = ref<(string | number)[]>([]);
const expandedKeys = ref<(string | number)[]>(['0-0']);
const autoExpandParent = ref<boolean>(true);
const onExpand = (keys: string[]) => {
expandedKeys.value = keys;
autoExpandParent.value = false;
};
watch(selectTreeDataValue, (value) => {
const expanded = dataList
.map((item: TreeProps['treeData'][number]) => {
if (item.title.indexOf(value) > -1) {
return getParentKey(item.key, gData.value);
}
return null;
})
.filter((item, i, self) => item && self.indexOf(item) === i);
expandedKeys.value = expanded;
selectTreeDataValue.value = value;
autoExpandParent.value = true;
});
// watch(selectTreeDataValue, (value) => {
// const expanded = dataList
// .map((item: TreeProps['treeData'][number]) => {
// if (item.title.indexOf(value) > -1) {
// return getParentKey(item.key, gData.value);
// }
// return null;
// })
// .filter((item, i, self) => item && self.indexOf(item) === i);
// expandedKeys.value = expanded;
// selectTreeDataValue.value = value;
// autoExpandParent.value = true;
// });
//
const onSearchTreeData = (selectTreeDataValue: string) => {
console.log('use value', selectTreeDataValue);
console.log('or use this.value', value.value);
getClassificationTree.value.emissionName = selectTreeDataValue;
getOrgTree();
};
//
const checkedIds = ref([]);
@ -444,7 +453,7 @@
checkedIds.value.push(item.id);
});
sessionStorage.setItem('checkedTreeNode', checkedIds.value);
emissionList.value = checkedIds.value;
emissionList.value = [...onSelectKeys.value, ...checkedIds.value];
mainRef.value?.nsTableRef.reload();
};
//
@ -510,20 +519,25 @@
treeNodeAdd.value = false;
};
//
const getClassificationTree = ref({
orgId: orgId.value,
});
const getOrgTree = () => {
fetch(carbonEmissionFactorLibrary.getCarbonFactorTree, { orgId: orgId.value }).then((res) => {
gData.value = res.data;
//
// const selectedNodes = [];
// checkedTreeNodeKeys.value.forEach(key => {
// const [parentId, childId] = key.split('-').map(Number);
// if (parentId >= 0 && childId >= 0 && gData.value[parentId]?.children?.[childId]) {
// selectedNodes.push(gData.value[parentId]);
// }
// });
// id
// getDefaultIds(selectedNodes)
});
fetch(carbonEmissionFactorLibrary.getCarbonFactorTree, getClassificationTree.value).then(
(res) => {
gData.value[0].children = res.data;
//
// const selectedNodes = [];
// checkedTreeNodeKeys.value.forEach(key => {
// const [parentId, childId] = key.split('-').map(Number);
// if (parentId >= 0 && childId >= 0 && gData.value[parentId]?.children?.[childId]) {
// selectedNodes.push(gData.value[parentId]);
// }
// });
// id
// getDefaultIds(selectedNodes)
},
);
};
const defaultIds = ref([]);
const getDefaultIds = (selectedNodes) => {
@ -540,6 +554,7 @@
getOrgTree();
//
const editTreeNode = ref({});
const onSelectKeys = ref([]);
const onSelect = (selectedKeys: string[], info: any) => {
if (info.selected) {
// showOperation.value = true;
@ -550,8 +565,14 @@
sortNumber: info.selectedNodes[0].sortNumber,
parentEmissionId: info.selectedNodes[0].parentEmissionId,
};
onSelectKeys.value.push(info.selectedNodes[0].id);
emissionList.value = [...onSelectKeys.value, ...checkedIds.value];
mainRef.value?.nsTableRef.reload();
} else {
editTreeNode.value = {};
onSelectKeys.value = [];
emissionList.value = [...onSelectKeys.value, ...checkedIds.value];
mainRef.value?.nsTableRef.reload();
}
};
@ -851,17 +872,19 @@
{
field: 'emissionProcess',
label: '排放环节',
component: 'NsInput',
component: 'NsSelectApi',
componentProps: {
// allowClear: true,
placeholder: '请选择排放环节',
maxLength: 30,
// options: [
// {
// label: '',
// value: 0,
// }
// ],
api: carbonEmissionFactorLibrary.gasAndDatabase,
resultField: 'data',
params: {
orgId: orgId.value,
emissionList,
type: 'emissionProcess',
},
immediate: true,
labelField: 'label',
valueField: 'value',
},
},
{

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

@ -2,6 +2,7 @@
export const voucherColumns = [
{
title: '序号',
width: 80,
customRender: (text: any) => {
return text.index + 1;
},
@ -39,4 +40,4 @@ export const drawerColumns = [
className: 'dataSources',
dataIndex: 'dataSources',
},
];
];

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

@ -45,7 +45,9 @@
<a-input-search
v-model:value="searchValue"
style="margin-bottom: 8px"
placeholder="请输入关键词" />
placeholder="请输入关键词"
allowClear
@search="onSearchTreeData" />
</a-col>
</a-row>
</div>
@ -348,14 +350,14 @@
</a-row>
<a-row>
<a-col :span="24">
<a-form-item ref="name" label="因子值" name="factorId">
<ns-input v-model:value="editFormState.factorId" />
<a-form-item ref="name" label="因子值" name="emissionFactors">
<ns-input v-model:value="editFormState.emissionFactors" />
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item ref="name" label="关键字" name="emissionFactors">
<a-form-item ref="name" label="关键字" name="key">
<a-input-search
v-model:value="editFormState.emissionFactors"
v-model:value="editFormState.key"
@search="searchKey"
placeholder="请输入关键字" />
</a-form-item>
@ -564,13 +566,19 @@
getCarbonFlowDirection();
}
};
//
const onSearchTreeData = (searchValue: string) => {
getReportTreeQuery.value.cnValue = searchValue;
getReportTree();
};
//
const selectedIds = ref([]);
const getReportTreeQuery = ref({
reportId: props.reportId,
orgId: orgId.value,
});
const getReportTree = () => {
fetch(carbonInventoryCheck.getCategoryTree, {
reportId: props.reportId,
orgId: orgId.value,
}).then((res) => {
fetch(carbonInventoryCheck.getCategoryTree, getReportTreeQuery.value).then((res) => {
gData.value = res.data;
if (res.data.length > 0) {
categoryId.value = res.data[0].children[0].conId;
@ -712,6 +720,7 @@
year: props.year,
startTime: props.startTime,
endTime: props.endTime,
categoryId: categoryId.value,
});
//
const measurementUnit = ref([]);
@ -787,6 +796,10 @@
addTreeNodeVisible.value = false;
formState.value = {
orgId: orgId.value,
year: props.year,
startTime: props.startTime,
endTime: props.endTime,
categoryId: categoryId.value,
};
message.success('操作成功!');
getEmissionSourceTree();
@ -796,6 +809,10 @@
addTreeNodeVisible.value = false;
formState.value = {
orgId: orgId.value,
year: props.year,
startTime: props.startTime,
endTime: props.endTime,
categoryId: categoryId.value,
};
message.success('操作成功!');
changeSelectedKeys.value = true;
@ -919,6 +936,10 @@
addTreeNodeVisible.value = false;
formState.value = {
orgId: orgId.value,
year: props.year,
startTime: props.startTime,
endTime: props.endTime,
categoryId: categoryId.value,
};
formRef.value.resetFields();
};
@ -978,6 +999,7 @@
const selectedRowKeysEdit = ref([]);
const onSelectionChangeEdit = (selectedKeys, selectedRows) => {
selectedRowKeysEdit.value = selectedKeys;
editFormState.value.emissionFactors = selectedRows[0].emissionFactors;
editFormState.value.factorId = selectedKeys;
};
const queryParams = ref({
@ -997,12 +1019,14 @@
//
const options = await dict({ params: { dicKey: 'ENERGY_TYPE' } });
energyTypeOptions.value = options.data.data;
getNewTable();
editFormState.value.key = record.factorName;
searchKey();
editFormState.value.id = record.id;
editFormState.value.dataSources = record.dataSources;
editFormState.value.consumption = record.emissions;
editFormState.value.consumption = record.consumption;
editFormState.value.collectionNode = record.carbonSource;
editFormState.value.factorId = record.factorId;
editFormState.value.emissionFactors = record.emissionFactors;
selectedRowKeysEdit.value = [record.factorId];
fetch(uploadPic.select, { bizId: record.id, bizType: 2 }).then((res) => {
fileList.value = res.data.map((item) => ({
@ -1022,7 +1046,11 @@
});
};
const searchKey = () => {
queryData.value.emissionSources = editFormState.value.emissionFactors;
if (editFormState.value.key) {
queryData.value.emissionSources = editFormState.value.key;
} else {
queryData.value.emissionSources = '';
}
getNewTable();
};
//

46
hx-ai-intelligent/src/view/carbonEmissionManage/carbonPlanning/all/index.vue

@ -14,18 +14,23 @@
justify-content: space-between;
margin-bottom: 1%;
">
<a-date-picker
v-if="selectedTime"
valueFormat="YYYY"
v-model:value="selectYear"
@change="changeYear"
picker="year" />
<a-date-picker
v-else
valueFormat="YYYY-MM"
v-model:value="selectMonth"
@change="changeMonth"
picker="month" />
<div>
<a-button v-if="selectedTime" type="primary" @click="changeYear(-1)">上一年</a-button>
<a-date-picker
v-if="selectedTime"
valueFormat="YYYY"
format="YYYY"
v-model:value="selectYear"
@change="changeYear"
picker="year" />
<a-button v-if="selectedTime" type="primary" @click="changeYear(1)">下一年</a-button>
<a-date-picker
v-else
valueFormat="YYYY-MM"
v-model:value="selectMonth"
@change="changeMonth"
picker="month" />
</div>
<div class="operation">
<div class="month" :style="monthStyles" @click="changeToMonth">
<span :style="monthText">本月</span>
@ -95,8 +100,15 @@
selectedTime.value = false;
getTableData();
};
const changeYear = () => {
queryParams.value.year = selectYear.value;
const changeYear = (data) => {
if (data) {
const newYear = selectYear.value.year() + data;
selectYear.value = dayjs().year(newYear);
const queryYear = selectYear.value.format('YYYY');
queryParams.value.year = queryYear;
} else {
queryParams.value.year = selectYear.value;
}
getTableData();
};
const changeToYear = () => {
@ -331,6 +343,12 @@
border-radius: 4px;
border: 1px solid rgba(39, 120, 255, 1);
}
:deep(.ant-btn-primary) {
border-radius: unset !important;
border-color: #d7d7d7 !important;
background: #f2f2f2 !important;
color: black !important;
}
.month {
width: 50%;
display: flex;

Loading…
Cancel
Save