From 97667fc496196630d6bcf09385899d6cf3b995da Mon Sep 17 00:00:00 2001 From: fks-xuxinyue <2822784518@qq.com> Date: Thu, 18 Jul 2024 11:29:52 +0800 Subject: [PATCH] taskId:099 remark:"commit" --- .../src/api/carbonEmissionFactorLibrary.ts | 10 +- .../src/router/carbonEmissionManage.ts | 20 ++ .../carbonEmissionFactorLibrary/index.vue | 17 +- .../carbonEmissions/index copy.vue | 306 +++++++++++++++++++++ .../energyConsumption/index.vue | 203 ++++++++++++-- .../quickCalculation/index.vue | 110 +++++++- .../carbonInventoryCheck/config.ts | 283 +++++++++++++++++++ .../carbonInventoryCheck/index.vue | 115 ++++++++ .../carbonInventoryCheck/mock.ts | 45 +++ 9 files changed, 1065 insertions(+), 44 deletions(-) create mode 100644 hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/carbonEmissions/index copy.vue create mode 100644 hx-ai-intelligent/src/view/carbonEmissionManage/carbonInventoryCheck/config.ts create mode 100644 hx-ai-intelligent/src/view/carbonEmissionManage/carbonInventoryCheck/index.vue create mode 100644 hx-ai-intelligent/src/view/carbonEmissionManage/carbonInventoryCheck/mock.ts diff --git a/hx-ai-intelligent/src/api/carbonEmissionFactorLibrary.ts b/hx-ai-intelligent/src/api/carbonEmissionFactorLibrary.ts index 5d666ad..708c970 100644 --- a/hx-ai-intelligent/src/api/carbonEmissionFactorLibrary.ts +++ b/hx-ai-intelligent/src/api/carbonEmissionFactorLibrary.ts @@ -9,11 +9,11 @@ export enum carbonEmissionFactorLibrary { creat = '/carbon-smart/api/carbon/emission/type/creatOrUpdate', delTreeNode = '/carbon-smart/api/carbon/emission/type/del', // 单位管理 - dictionaryUnitManagement = '/carbon-smart/api/carbon/emission/factor/dictionaryUnitManagement', - findOutermost = '/carbon-smart/api/carbon/emission/factor/findOutermost', - createDictionary = '/carbon-smart/api/carbon/emission/factor/createDictionary', - updateDictionary = '/carbon-smart/api/carbon/emission/factor/updateDictionary', - delDictionary = '/carbon-smart/api/carbon/emission/factor/delDictionary', + dictionaryUnitManagement = '/carbon-smart/client/dict/dictionaryUnitManagement', + findOutermost = '/carbon-smart/client/dict/findOutermost', + createDictionary = '/carbon-smart/client/dict/createDictionary', + updateDictionary = '/carbon-smart/client/dict/updateDictionary', + delDictionary = '/carbon-smart/client/dict/delDictionary', } // 碳排管理-碳排统计接口 export enum energyConsumption { diff --git a/hx-ai-intelligent/src/router/carbonEmissionManage.ts b/hx-ai-intelligent/src/router/carbonEmissionManage.ts index 5ecc903..c945868 100644 --- a/hx-ai-intelligent/src/router/carbonEmissionManage.ts +++ b/hx-ai-intelligent/src/router/carbonEmissionManage.ts @@ -45,6 +45,26 @@ const equipment = { }, ], }, + { + path: 'carbonInventoryCheck', + name: 'CarbonInventoryCheck', + meta: { title: '碳盘查', hideChildren: true, icon: 'tanpaiguanli' }, + component: Base, + redirect: { name: 'CarbonInventoryCheckIndex' }, + children: [ + { + path: 'index', + name: 'CarbonInventoryCheckIndex', + // component: () => import('/nerv-lib/saas/view/menuManage/index.vue'), + component: () => import('/@/view/carbonEmissionManage/carbonInventoryCheck/index.vue'), + meta: { + title: '碳盘查', + keepAlive: true, + // backApi: [], + }, + }, + ], + }, ], }; export default equipment; diff --git a/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionFactorLibrary/index.vue b/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionFactorLibrary/index.vue index cf05dbf..3bb69b9 100644 --- a/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionFactorLibrary/index.vue +++ b/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionFactorLibrary/index.vue @@ -707,16 +707,17 @@ { field: 'emissionProcess', label: '排放环节', - component: 'NsSelect', + component: 'NsInput', componentProps: { - allowClear: true, + // allowClear: true, placeholder: '请选择排放环节', - options: [ - { - label: '消费环节', - value: 0, - } - ], + maxLength: 30, + // options: [ + // { + // label: '消费环节', + // value: 0, + // } + // ], }, }, { diff --git a/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/carbonEmissions/index copy.vue b/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/carbonEmissions/index copy.vue new file mode 100644 index 0000000..62c8b54 --- /dev/null +++ b/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/carbonEmissions/index copy.vue @@ -0,0 +1,306 @@ + + + + \ No newline at end of file diff --git a/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/energyConsumption/index.vue b/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/energyConsumption/index.vue index 78ff753..33312db 100644 --- a/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/energyConsumption/index.vue +++ b/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/energyConsumption/index.vue @@ -1,6 +1,6 @@ - - --> + + { + getDictList() + visible.value = true + }, + }, + { + label: '导入', + type: 'primary', + name: 'userImport', + handle: () => {}, + }, + { + label: '导出', + type: 'primary', + name: 'userExports', + }, + { + label: '模板下载', + type: 'primary', + name: 'userExports', + }, + { + label: '上传凭证', + type: 'primary', + handle: () => { + openUpload.value = true; + }, + }, + { + label: '凭证下载', + type: 'primary', + name: 'userExports', + }, + ], + columns: [ + { + title: '序号', + customRender: (text: any) => { + return text.index + 1; + }, + }, + { + title: '能源种类', + dataIndex: 'energyType', + }, + { + title: '计量单位', + className: 'unit', + dataIndex: 'unit', + }, + { + title: '全年', + dataIndex: 'yearly', + }, + { + title: '1月', + dataIndex: 'jan', + // customRender: ({ text, record }) => ({ + // children: text, + // attrs: { + // style: record.janFlag === 1 ? 'color: red' : 'color: blue' + // } + // }) + }, + { + title: '2月', + dataIndex: 'feb', + }, + { + title: '3月', + dataIndex: 'mar', + }, + { + title: '4月', + dataIndex: 'apr', + }, + { + title: '5月', + dataIndex: 'may', + }, + { + title: '6月', + dataIndex: 'jun', + }, + { + title: '7月', + dataIndex: 'jul', + }, + { + title: '8月', + dataIndex: 'aug', + }, + { + title: '9月', + dataIndex: 'sep', + }, + { + title: '10月', + dataIndex: 'oct', + }, + { + title: '11月', + dataIndex: 'nov', + }, + { + title: '12月', + dataIndex: 'dec', + }, + ], + columnActions: { + title: '操作', + actions: [ + { + label: '编辑', + name: 'userEdit', + handle: (record: any) => { + getDictList() + visible.value = true + fetch(energyConsumption.findById , {id : record.id }).then((res) => { + if(res.data.unit){ + res.data.unit = res.data.unit.split(',') + } + formState.value = res.data + }); + }, + }, + { + label: '删除', + name: 'userDelete', + dynamicParams: { id: 'id' }, + confirm: true, + isReload: true, + api: energyConsumption.del, + }, + ], + }, + + formConfig: { + schemas: [ + { + field: 'year', + label: '年份', + component: 'NsDatePicker', + componentProps: { + picker: 'year', + valueFormat: 'YYYY', + defaultValue: selectYear.value.format('YYYY'), + }, + }, + ], + params: {}, + }, + rowKey: 'id', + }); // 获取表格数据 const getTableList = () => { fetch(energyConsumption.pageList , queryParams.value).then((res) => { data.value = res.data.records - total.value = res.data.total }); }; - getTableList() // 分页器 const onChange = (pageNumber: number,size: number) => { queryParams.value.pageNum = pageNumber; queryParams.value.pageSize = size; - getTableList() + mainRef.value?.nsTableRef.reload(); }; // 计算碳排切换 const changeRadio = (e) => { @@ -263,23 +428,20 @@ if(formState.value.id){ fetch(energyConsumption.update , formState.value).then((res) => { visible.value = false + formState.value = {} message.success('操作成功!'); - getTableList() + mainRef.value?.nsTableRef.reload(); }); }else{ fetch(energyConsumption.creat , formState.value).then((res) => { if(res.data === '新增数据已存在'){ visible.value = false - queryParams.value = formState.value - queryParams.value.pageNum = 1, - queryParams.value.pageSize = 10, - queryParams.value.orgId = orgId.value, - queryParams.value.year = selectYear.value.format('YYYY') - getTableList() + NsMessage.warning(res.data); }else{ visible.value = false + formState.value = {} message.success('操作成功!'); - getTableList() + mainRef.value?.nsTableRef.reload(); } }); } @@ -298,10 +460,10 @@ fetch(carbonEmissionFactorLibrary.dictionaryUnitManagement, { grp: 'MEASUREMENT_UNIT'}).then((res) => { measurementUnit.value = res.data measurementUnit.value = measurementUnit.value.map(item => ({ - value: item.cnValue, + value: item.id, label: item.cnValue, children: item.children ? item.children.map(child => ({ - value: child.cnValue, + value: child.id, label: child.cnValue })) : [] })); @@ -310,10 +472,10 @@ fetch(group.queryDeviceGroupTree, { energyType: 'ELECTRICITY_USAGE',orgId: orgId.value }).then((res) => { treeData.value = res.data treeData.value = treeData.value.map(item => ({ - value: item.pointName, + value: item.id, label: item.pointName, children: item.children ? item.children.map(child => ({ - value: child.pointName, + value: child.id, label: child.pointName })) : [] })); @@ -346,7 +508,7 @@ onOk() { fetch(energyConsumption.del , {id : record.id }).then((res) => { message.success('操作成功!'); - getTableList() + mainRef.value?.nsTableRef.reload(); }); }, onCancel() { @@ -357,6 +519,7 @@ // 关闭新增抽屉 const onClose = () => { visible.value = false; + formState.value = {} formRef.value.resetFields(); }; // 点击上传凭证按钮 diff --git a/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/quickCalculation/index.vue b/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/quickCalculation/index.vue index c45e65d..6f1a5d3 100644 --- a/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/quickCalculation/index.vue +++ b/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/quickCalculation/index.vue @@ -39,7 +39,7 @@
- 新增
- + --> + { return http.post(api, params); }; + const mainRef = ref(); // 数结构 const x = 3; const y = 2; @@ -209,12 +211,13 @@ autoExpandParent.value = false; }; // 被选中的树节点 + const energyType = ref() const onSelect = (selectedKey: string[], info: any) => { selectedKeys.value = selectedKey; if(info.selected){ - queryParams.value.energyType = info.node.id + energyType.value = info.node.id statsId.value = info.node.id - getTableList() + mainRef.value?.nsTableRef.reload(); } }; @@ -239,10 +242,9 @@ const getTreeData = () => { fetch(quickCalculation.carbonQuickTree).then((res) => { gData.value = res.data - debugger - queryParams.value.energyType = gData.value[0].children[0].id + energyType.value = gData.value[0].children[0].id statsId.value = gData.value[0].children[0].id - getTableList() + mainRef.value?.nsTableRef.reload(); }); }; getTreeData() @@ -254,6 +256,90 @@ orgId: orgId.value }) const tableData = ref([]); + + const tableConfig = ref({ + title: '排放因子库', + api: quickCalculation.queryCarbonEmissionPage, + params: { + orgId, + energyType + }, + headerActions: [ + { + label: '新增', + name: 'userAdd', + type: 'primary', + handle: () => { + visible.value = true + getNewTable() + }, + }, + ], + columns: [ + { + title: '序号', + customRender: (text: any) => { + return text.index + 1; + }, + }, + { + title: '因子值', + dataIndex: 'emissionFactors', + }, + { + title: '计量单位', + className: 'carbonEmissionSuffix', + dataIndex: 'carbonEmissionSuffix', + }, + { + title: '更新时间', + className: 'updateTime', + dataIndex: 'updateTime', + }, + { + title: '启用时间', + className: 'startTime', + dataIndex: 'startTime', + }, + { + title: '结束时间', + className: 'endTime', + dataIndex: 'endTime', + }, + { + title: '数据来源', + className: 'dataSources', + dataIndex: 'dataSources', + }, + ], + columnActions: { + title: '操作', + actions: [ + { + label: '编辑', + name: 'userEdit', + handle: (record: any) => { + selectedRowKeys.value = [record.carbonId]; + formState.value.id = record.id + formState.value.emissionFactors = record.emissionFactors + formState.value.dateRange = [record.startTime, record.endTime]; + formState.value.carbonId = record.carbonId + visible.value = true + getNewTable() + }, + }, + { + label: '删除', + name: 'userDelete', + dynamicParams: { id: 'id' }, + confirm: true, + isReload: true, + api: quickCalculation.del, + }, + ], + }, + rowKey: 'id', + }); // 获取列表数据 const getTableList = () => { fetch(quickCalculation.queryCarbonEmissionPage,queryParams.value).then((res) => { @@ -265,7 +351,7 @@ const onChange = (pageNumber: number,size: number) => { queryParams.value.pageNum = pageNumber; queryParams.value.pageSize = size; - getTableList() + mainRef.value?.nsTableRef.reload(); }; // 新增/编辑 const formRef = ref(); @@ -321,14 +407,13 @@ formState.value.startTime = formState.value.dateRange[0] formState.value.endTime = formState.value.dateRange[1] console.log('values', formState, toRaw(formState)); - debugger if(formState.value.id){ fetch(quickCalculation.update,formState.value).then((res) => { visible.value = false selectedRowKeys.value = []; formState.value = {} formRef.value.resetFields(); - getTableList() + mainRef.value?.nsTableRef.reload(); }); }else{ fetch(quickCalculation.creat,formState.value).then((res) => { @@ -336,7 +421,7 @@ selectedRowKeys.value = []; formState.value = {} formRef.value.resetFields(); - getTableList() + mainRef.value?.nsTableRef.reload(); }); } }) @@ -408,6 +493,9 @@ ::v-deep .ant-table-container{ padding: 0px 16px; } + :deep(.ns-table-main) { + margin-top: unset !important; + } .top { overflow: auto; } diff --git a/hx-ai-intelligent/src/view/carbonEmissionManage/carbonInventoryCheck/config.ts b/hx-ai-intelligent/src/view/carbonEmissionManage/carbonInventoryCheck/config.ts new file mode 100644 index 0000000..6c3642a --- /dev/null +++ b/hx-ai-intelligent/src/view/carbonEmissionManage/carbonInventoryCheck/config.ts @@ -0,0 +1,283 @@ +import { ref } from 'vue'; +import { http } from '/nerv-lib/util'; +import { origanizemanage } from '/@/api/origanizemanage'; +import { carbonEmissionFactorLibrary } from '/@/api/carbonEmissionFactorLibrary'; +export const formConfig = (disabled) => { + return ref([ + { + field: 'fields', + component: 'NsChildForm', + componentProps: { + schemas: [ + { + label: '排放源', + field: 'emissionSources', + component: 'NsInput', + componentProps: { + placeholder: '请输入排放源', + maxLength: 20, + }, + rules: [ + { + required: true, + message: '请输入排放源', + }, + ], + }, + { + field: 'emissionType', + label: '排放分类', + component: 'NsCascader', + fieldMap: ['emissionType'], + componentProps: { + placeholder: '请选择排放分类', + api: carbonEmissionFactorLibrary.getCarbonFactorTree, + fieldNames: { label: 'emissionName', value: 'id' }, + showSearch: true, + }, + rules: [ + { + required: true, + message: '请选择排放分类', + }, + ], + }, + { + field: 'emissionGas', + label: '排放气体', + component: 'NsSelect', + componentProps: { + allowClear: true, + placeholder: '请选择排放气体', + options: [ + { + label: 'CO2', + value: 'CO2', + }, + { + label: 'CO2e', + value: 'CO2e', + }, + { + label: 'SF6', + value:'SF6', + }, + { + label: 'CH4', + value: 'CH4', + }, + { + label: 'PFCs', + value: 'PFCs', + }, + { + label: 'HFCs', + value: 'HFCs', + }, + ], + }, + rules: [ + { + required: true, + message: '请选择排放气体', + }, + ], + }, + // { + // field: 'emissionProcess', + // label: '排放环节', + // component: 'NsSelectApi', + // componentProps: { + // api: carbonEmissionFactorLibrary.getEmissionProcess, + // params: { + // emissionType: sessionStorage.getItem('checkedTreeNode'), + // }, + // resultField: 'data', + // labelField: 'emissionProcess', + // valueField: 'emissionProcess', + // immediate: true, + // autoSelectFirst: false, + // filterOption:false, + // showSearch:true, + // autoClearSearchValue:false + // }, + // }, + { + label: '排放环节', + field: 'emissionProcess', + component: 'NsInput', + componentProps: { + placeholder: '请输入排放环节', + maxLength: 20, + }, + rules: [ + { + required: true, + message: '请输入排放环节', + }, + ], + }, + { + label: '排放因子', + field: 'emissionFactors', + component: 'NsInputNumber', + componentProps: { + placeholder: '请输入排放因子值', + maxLength: 20, + }, + rules: [ + { + required: true, + message: '请输入排放因子值', + trigger: 'change', + }, + ], + }, + { + field: 'carbonEmissionPrefix', + label: '碳排前缀', + component: 'NsSelect', + componentProps: { + disabled: true, + allowClear: true, + defaultValue: 't', + placeholder: '请选择碳排前缀', + options: [ + { + label: 'g', + value: 'g', + }, + { + label: 'kg', + value: 'kg', + }, + { + label: 't', + value: 't', + }, + ], + }, + rules: [ + { + required: true, + message: '请选择碳排前缀', + }, + ], + }, + { + label: '碳排后缀', + field: 'carbonEmissionSuffix', + component: 'NsInput', + componentProps: { + placeholder: '请输入碳排后缀', + maxLength: 20, + }, + rules: [ + { + required: true, + message: '请输入碳排后缀', + }, + ], + }, + { + label: '已引用数', + field: 'numberOfReferences', + component: 'NsInput', + componentProps: { + defaultValue: 10, + disabled: true, + maxLength: 20, + }, + }, + { + label: '参考文献', + field: 'reference', + component: 'NsTextarea', + componentProps: { + placeholder: '请输入参考文献', + maxLength: 20, + }, + }, + ], + }, + }, + ]); +}; +const options = ref([]); + +const getUserPerList = (transform, params = {}) => { + return http.post(origanizemanage.queryUserPerList, { ...params }).then((res) => { + return res.data?.map((item) => { + item = { ...item, ...transform(item) }; + return item; + }); + }); +}; +export const formConfig2 = (casData: any) => { + return ref([ + { + field: 'information', + component: 'NsCascader', + componentProps: { + placeholder: '请选择', + displayRender: ({ labels, selectedOptions }: any) => { + console.log(labels, selectedOptions); + + casData.value = selectedOptions.map(({ label, value }) => { + return { label, value }; + }); + return labels.join('/'); + }, + loadData: (selectedOptions, options) => { + console.log(selectedOptions, options, 'selectedOptions, options'); + + const targetOption = selectedOptions[selectedOptions.length - 1]; + let transForm, params; + // load options lazily + if (!selectedOptions.length) { + transForm = (data) => { + data['label'] = data.orgName; + data['value'] = data.orgId; + data['isLeaf'] = false; + data['level'] = 1; + return data; + }; + getUserPerList(transForm).then((res) => { + options.value = [...res]; + }); + } + const id = targetOption?.value; + const level = targetOption?.level; + if (targetOption) { + targetOption.loading = true; + } + + if (level === 1) { + transForm = (data) => { + data['label'] = data.deptName; + data['value'] = data.deptId; + data['isLeaf'] = false; + data['level'] = 2; + return data; + }; + params = { orgId: id }; + } else if (level === 2) { + transForm = (data) => { + data['label'] = data.roleName; + data['value'] = data.roleId; + data['level'] = 3; + return data; + }; + params = { deptId: id }; + } + if (targetOption) { + getUserPerList(transForm, { ...params }).then((res) => { + targetOption.loading = false; + targetOption.children = [...res]; + }); + } + }, + }, + }, + ]); +}; diff --git a/hx-ai-intelligent/src/view/carbonEmissionManage/carbonInventoryCheck/index.vue b/hx-ai-intelligent/src/view/carbonEmissionManage/carbonInventoryCheck/index.vue new file mode 100644 index 0000000..d1a1a77 --- /dev/null +++ b/hx-ai-intelligent/src/view/carbonEmissionManage/carbonInventoryCheck/index.vue @@ -0,0 +1,115 @@ + + + + + \ No newline at end of file diff --git a/hx-ai-intelligent/src/view/carbonEmissionManage/carbonInventoryCheck/mock.ts b/hx-ai-intelligent/src/view/carbonEmissionManage/carbonInventoryCheck/mock.ts new file mode 100644 index 0000000..76ff687 --- /dev/null +++ b/hx-ai-intelligent/src/view/carbonEmissionManage/carbonInventoryCheck/mock.ts @@ -0,0 +1,45 @@ +import { ref } from 'vue'; +import { origanizemanage } from '/@/api/origanizemanage'; +import { http } from '/nerv-lib/saas'; + +export const mockData = ref([ + { + id: 3, + zhanghao: 'axb', + name: '张三', + sex: '男', + phone: '123456789', + email: '1234567889', + relation: '1', + role: '1', + status: '1', + }, +]); + +export const mockData2 = ref([ + { + information: '铁路局1/产品部1/产品总监1', + }, +]); + +export const treeData = ref([ + { + title: '铁路总局', + key: '0-0', + children: [ + { title: '济阳站', key: '0-0-0' }, + { title: '临沂站', key: '0-0-1' }, + ], + }, +]); + +export const treeData2 = [ + { + title: '全部', + key: '0-0', + children: [ + { title: '产品部', key: '0-0-0' }, + { title: '运维部', key: '0-0-1' }, + ], + }, +];