|
@ -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 |
|
@ -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="id" |
|
|
|
|
|
: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,34 @@ |
|
|
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', // 设置默认状态为已完成 |
|
|
|
|
|
type: 'done', |
|
|
|
|
|
url: item.filePath, // 文件的URL,这里假设用示例的URL格式 |
|
|
|
|
|
})); |
|
|
|
|
|
}); |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
@ -437,27 +586,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 +615,144 @@ |
|
|
.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) { |
|
|
|
|
|
fetch(energyConsumption.update, formState.value).then((res) => { |
|
|
|
|
|
if (fileList.value.length !== 0) { |
|
|
|
|
|
const formData = ref(new FormData()); |
|
|
|
|
|
fileList.value.forEach((file) => { |
|
|
|
|
|
if (file.type !== 'done') { |
|
|
|
|
|
formData.value.append('files', file.originFileObj); |
|
|
} |
|
|
} |
|
|
if(formState.value.id){ |
|
|
}); |
|
|
fetch(energyConsumption.update , formState.value).then((res) => { |
|
|
formData.value.append('bizType', 3); |
|
|
visible.value = false |
|
|
formData.value.append('bizId', formState.value.id); |
|
|
|
|
|
delIds.value.forEach((item) => { |
|
|
|
|
|
formData.value.append('deleteList', item); |
|
|
|
|
|
}); |
|
|
|
|
|
fetch(uploadPic.uploadfiles, formData.value) |
|
|
|
|
|
.then((res) => { |
|
|
|
|
|
message.success('操作成功!'); |
|
|
|
|
|
visible.value = false; |
|
|
|
|
|
delIds.value = []; |
|
|
formState.value = { |
|
|
formState.value = { |
|
|
orgId: orgId.value, |
|
|
orgId: orgId.value, |
|
|
} |
|
|
}; |
|
|
|
|
|
mainRef.value?.nsTableRef.reload(); |
|
|
|
|
|
}) |
|
|
|
|
|
.catch((error) => { |
|
|
|
|
|
console.log('error', error); |
|
|
|
|
|
}); |
|
|
|
|
|
} else { |
|
|
|
|
|
visible.value = false; |
|
|
|
|
|
delIds.value = []; |
|
|
|
|
|
formState.value = { |
|
|
|
|
|
orgId: orgId.value, |
|
|
|
|
|
}; |
|
|
message.success('操作成功!'); |
|
|
message.success('操作成功!'); |
|
|
mainRef.value?.nsTableRef.reload(); |
|
|
mainRef.value?.nsTableRef.reload(); |
|
|
|
|
|
} |
|
|
}); |
|
|
}); |
|
|
}else{ |
|
|
} else { |
|
|
fetch(energyConsumption.creat , formState.value).then((res) => { |
|
|
fetch(energyConsumption.creat, formState.value).then((res) => { |
|
|
if(res.data === '新增数据已存在'){ |
|
|
if (res.data === '新增数据已存在') { |
|
|
visible.value = false |
|
|
visible.value = false; |
|
|
|
|
|
delIds.value = []; |
|
|
NsMessage.warning(res.data); |
|
|
NsMessage.warning(res.data); |
|
|
}else{ |
|
|
} else { |
|
|
visible.value = false |
|
|
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; |
|
|
|
|
|
delIds.value = []; |
|
|
formState.value = { |
|
|
formState.value = { |
|
|
orgId: orgId.value, |
|
|
orgId: orgId.value, |
|
|
} |
|
|
}; |
|
|
|
|
|
mainRef.value?.nsTableRef.reload(); |
|
|
|
|
|
}) |
|
|
|
|
|
.catch((error) => { |
|
|
|
|
|
console.log('error', error); |
|
|
|
|
|
}); |
|
|
|
|
|
} else { |
|
|
|
|
|
visible.value = false; |
|
|
|
|
|
delIds.value = []; |
|
|
|
|
|
formState.value = { |
|
|
|
|
|
orgId: orgId.value, |
|
|
|
|
|
}; |
|
|
message.success('操作成功!'); |
|
|
message.success('操作成功!'); |
|
|
mainRef.value?.nsTableRef.reload(); |
|
|
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; |
|
|
|
|
|
measurementUnit.value = measurementUnit.value.map((item) => ({ |
|
|
value: item.id, |
|
|
value: item.id, |
|
|
label: item.cnValue, |
|
|
label: item.cnValue, |
|
|
children: item.children ? item.children.map(child => ({ |
|
|
children: item.children |
|
|
|
|
|
? item.children.map((child) => ({ |
|
|
value: child.id, |
|
|
value: child.id, |
|
|
label: child.cnValue |
|
|
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; |
|
|
|
|
|
treeData.value = treeData.value.map((item) => ({ |
|
|
value: item.id, |
|
|
value: item.id, |
|
|
label: item.pointName, |
|
|
label: item.pointName, |
|
|
children: item.children ? item.children.map(child => ({ |
|
|
children: item.children |
|
|
|
|
|
? item.children.map((child) => ({ |
|
|
value: child.id, |
|
|
value: child.id, |
|
|
label: child.pointName |
|
|
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 +764,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 +773,14 @@ |
|
|
console.log('Cancel'); |
|
|
console.log('Cancel'); |
|
|
}, |
|
|
}, |
|
|
}); |
|
|
}); |
|
|
} |
|
|
}; |
|
|
// 关闭新增抽屉 |
|
|
// 关闭新增抽屉 |
|
|
const onClose = () => { |
|
|
const onClose = () => { |
|
|
visible.value = false; |
|
|
visible.value = false; |
|
|
|
|
|
delIds.value = []; |
|
|
formState.value = { |
|
|
formState.value = { |
|
|
orgId: orgId.value, |
|
|
orgId: orgId.value, |
|
|
} |
|
|
}; |
|
|
formRef.value.resetFields(); |
|
|
formRef.value.resetFields(); |
|
|
}; |
|
|
}; |
|
|
// 点击上传凭证按钮 |
|
|
// 点击上传凭证按钮 |
|
@ -583,25 +793,113 @@ |
|
|
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 delIds = ref([]); |
|
|
console.log(e); |
|
|
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 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) => { |
|
|
|
|
|
// 创建一个 URL 对象,指向图片数据的 blob |
|
|
|
|
|
const url = window.URL.createObjectURL(new Blob([res.data])); |
|
|
|
|
|
// 创建一个 <a> 标签,用于触发下载 |
|
|
|
|
|
const link = document.createElement('a'); |
|
|
|
|
|
link.href = url; |
|
|
|
|
|
link.setAttribute('download', record.fileName); // 设置下载的文件名 |
|
|
|
|
|
document.body.appendChild(link); |
|
|
|
|
|
link.click(); |
|
|
|
|
|
|
|
|
|
|
|
// 清理 URL 对象 |
|
|
|
|
|
window.URL.revokeObjectURL(url); |
|
|
|
|
|
}) |
|
|
|
|
|
.catch((error) => { |
|
|
|
|
|
console.error('下载图片失败:', error); |
|
|
|
|
|
}); |
|
|
|
|
|
}; |
|
|
|
|
|
const onSubmitDownLoad = () => { |
|
|
|
|
|
const deleteIds = ref(new FormData()); |
|
|
|
|
|
selectedRowKeysSet.value.forEach((item) => { |
|
|
|
|
|
deleteIds.value.append('ids', item); |
|
|
|
|
|
}); |
|
|
|
|
|
fetch(uploadPic.downloadZip, deleteIds.value) |
|
|
|
|
|
.then((res) => { |
|
|
|
|
|
// 创建一个 URL 对象,指向图片数据的 blob |
|
|
|
|
|
const url = window.URL.createObjectURL(new Blob([res.data])); |
|
|
|
|
|
// 创建一个 <a> 标签,用于触发下载 |
|
|
|
|
|
const link = document.createElement('a'); |
|
|
|
|
|
link.href = url; |
|
|
|
|
|
debugger |
|
|
|
|
|
link.setAttribute('download', ''); // 设置下载的文件名 |
|
|
|
|
|
document.body.appendChild(link); |
|
|
|
|
|
link.click(); |
|
|
|
|
|
|
|
|
|
|
|
// 清理 URL 对象 |
|
|
|
|
|
window.URL.revokeObjectURL(url); |
|
|
|
|
|
}) |
|
|
|
|
|
.catch((error) => { |
|
|
|
|
|
console.error('下载图片失败:', error); |
|
|
|
|
|
}); |
|
|
|
|
|
}; |
|
|
|
|
|
const onCloseDownLoad = () => { |
|
|
|
|
|
selectedRowKeysSet.value = [] |
|
|
|
|
|
downLoadVisible.value = false; |
|
|
|
|
|
}; |
|
|
</script> |
|
|
</script> |
|
|
<style scoped lang="less"> |
|
|
<style scoped lang="less"> |
|
|
:deep(.ant-table-title) { |
|
|
:deep(.ant-table-title) { |
|
@ -610,7 +908,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; |
|
|