From c09ca418b38f71250f4dea61f57c136e7523701a Mon Sep 17 00:00:00 2001 From: fks-xuxinyue <2822784518@qq.com> Date: Wed, 21 Aug 2024 15:26:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B5=8B=E8=AF=95=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../carbonAssets/carbonAssetsDetail/index.vue | 1 + .../carbonAssets/carbonAssetsDetail/indexCopy.vue | 713 +++++++++++++++++++++ .../carbonEmissionFactorLibrary/index.vue | 261 ++++---- .../carbonInventoryCheck/config.ts | 3 +- .../carbonInventoryCheck/fillInPage/index.vue | 52 +- .../carbonPlanning/all/index.vue | 46 +- 6 files changed, 930 insertions(+), 146 deletions(-) create mode 100644 hx-ai-intelligent/src/view/carbonEmissionManage/carbonAssets/carbonAssetsDetail/indexCopy.vue diff --git a/hx-ai-intelligent/src/view/carbonEmissionManage/carbonAssets/carbonAssetsDetail/index.vue b/hx-ai-intelligent/src/view/carbonEmissionManage/carbonAssets/carbonAssetsDetail/index.vue index 6f3f04f..05bbc92 100644 --- a/hx-ai-intelligent/src/view/carbonEmissionManage/carbonAssets/carbonAssetsDetail/index.vue +++ b/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); diff --git a/hx-ai-intelligent/src/view/carbonEmissionManage/carbonAssets/carbonAssetsDetail/indexCopy.vue b/hx-ai-intelligent/src/view/carbonEmissionManage/carbonAssets/carbonAssetsDetail/indexCopy.vue new file mode 100644 index 0000000..fd85219 --- /dev/null +++ b/hx-ai-intelligent/src/view/carbonEmissionManage/carbonAssets/carbonAssetsDetail/indexCopy.vue @@ -0,0 +1,713 @@ + + + + + diff --git a/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionFactorLibrary/index.vue b/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionFactorLibrary/index.vue index 30247a0..e09c09b 100644 --- a/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionFactorLibrary/index.vue +++ b/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 @@ - + (); - 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(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(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', }, }, { diff --git a/hx-ai-intelligent/src/view/carbonEmissionManage/carbonInventoryCheck/config.ts b/hx-ai-intelligent/src/view/carbonEmissionManage/carbonInventoryCheck/config.ts index 3574b58..c076d88 100644 --- a/hx-ai-intelligent/src/view/carbonEmissionManage/carbonInventoryCheck/config.ts +++ b/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', }, -]; \ No newline at end of file +]; diff --git a/hx-ai-intelligent/src/view/carbonEmissionManage/carbonInventoryCheck/fillInPage/index.vue b/hx-ai-intelligent/src/view/carbonEmissionManage/carbonInventoryCheck/fillInPage/index.vue index a3a5e09..5bea682 100644 --- a/hx-ai-intelligent/src/view/carbonEmissionManage/carbonInventoryCheck/fillInPage/index.vue +++ b/hx-ai-intelligent/src/view/carbonEmissionManage/carbonInventoryCheck/fillInPage/index.vue @@ -45,7 +45,9 @@ + placeholder="请输入关键词" + allowClear + @search="onSearchTreeData" /> @@ -348,14 +350,14 @@ - - + + - + @@ -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(); }; // 数据来源选择框改变 diff --git a/hx-ai-intelligent/src/view/carbonEmissionManage/carbonPlanning/all/index.vue b/hx-ai-intelligent/src/view/carbonEmissionManage/carbonPlanning/all/index.vue index fb37166..f6c6df3 100644 --- a/hx-ai-intelligent/src/view/carbonEmissionManage/carbonPlanning/all/index.vue +++ b/hx-ai-intelligent/src/view/carbonEmissionManage/carbonPlanning/all/index.vue @@ -14,18 +14,23 @@ justify-content: space-between; margin-bottom: 1%; "> - - +
+ 上一年 + + 下一年 + +
本月 @@ -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;