2024-07-18 11:29:52 +08:00
|
|
|
<template>
|
2024-07-18 15:14:25 +08:00
|
|
|
<!-- 首页 -->
|
|
|
|
<div v-if="isMainPage">
|
|
|
|
<ns-view-list-table v-bind="tableConfig" :model="data" ref="mainRef" />
|
|
|
|
</div>
|
|
|
|
<!-- 填报页 -->
|
2024-07-26 15:12:56 +08:00
|
|
|
<div v-if="fillInPage" style="height: 100%">
|
2024-08-08 15:13:32 +08:00
|
|
|
<fillIn
|
|
|
|
:reportId="reportId"
|
|
|
|
:year="year"
|
|
|
|
:startTime="startTime"
|
|
|
|
:endTime="endTime"
|
|
|
|
@change-data="updateData" />
|
2024-07-18 15:14:25 +08:00
|
|
|
</div>
|
|
|
|
<!-- 新增报告弹窗 -->
|
|
|
|
<a-drawer
|
|
|
|
:width="500"
|
|
|
|
:visible="visible"
|
|
|
|
:body-style="{ paddingBottom: '80px' }"
|
|
|
|
:footer-style="{ textAlign: 'right' }"
|
|
|
|
destroyOnClose
|
|
|
|
@close="onClose">
|
|
|
|
<a-form
|
|
|
|
ref="formRef"
|
|
|
|
:model="formState"
|
|
|
|
:rules="rules"
|
|
|
|
:label-col="labelCol"
|
2024-07-25 15:19:41 +08:00
|
|
|
:wrapper-col="wrapperCol">
|
2024-07-19 15:13:46 +08:00
|
|
|
<a-form-item ref="name" label="报告名称" name="reportName">
|
|
|
|
<a-input v-model:value="formState.reportName" placeholder="请输入报告名称" />
|
2024-07-18 15:14:25 +08:00
|
|
|
</a-form-item>
|
2024-07-19 15:13:46 +08:00
|
|
|
<a-form-item ref="name" label="报告年度" name="reportYear">
|
|
|
|
<a-date-picker v-model:value="formState.reportYear" picker="year" valueFormat="YYYY" />
|
2024-07-18 15:14:25 +08:00
|
|
|
</a-form-item>
|
2024-07-19 15:13:46 +08:00
|
|
|
<a-form-item ref="name" label="适用标准" name="genericStandard">
|
|
|
|
<a-input v-model:value="formState.genericStandard" placeholder="请输入适用标准" />
|
2024-07-18 15:14:25 +08:00
|
|
|
</a-form-item>
|
2024-07-19 15:13:46 +08:00
|
|
|
<a-form-item label="报告周期" name="reportPeriod">
|
2024-07-31 15:52:08 +08:00
|
|
|
<a-select
|
|
|
|
v-model:value="formState.reportPeriod"
|
2024-08-08 15:13:32 +08:00
|
|
|
placeholder="请选择报告周期"
|
2024-07-31 15:52:08 +08:00
|
|
|
@change="selectChange">
|
2024-07-19 15:13:46 +08:00
|
|
|
<a-select-option value="1">年度</a-select-option>
|
|
|
|
<a-select-option value="2">月度</a-select-option>
|
2024-07-18 15:14:25 +08:00
|
|
|
</a-select>
|
|
|
|
</a-form-item>
|
2024-07-19 15:13:46 +08:00
|
|
|
<a-form-item ref="name" label="报告范围" name="reportScope">
|
2024-07-25 15:19:41 +08:00
|
|
|
<a-range-picker
|
|
|
|
v-model:value="formState.reportScope"
|
|
|
|
picker="month"
|
2024-07-31 15:52:08 +08:00
|
|
|
:disabledDate="disabledDate"
|
2024-07-25 15:19:41 +08:00
|
|
|
valueFormat="YYYY-MM" />
|
2024-07-18 15:14:25 +08:00
|
|
|
</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>
|
2024-07-18 11:29:52 +08:00
|
|
|
</template>
|
|
|
|
|
2024-07-18 15:14:25 +08:00
|
|
|
<script lang="ts" setup>
|
2024-07-25 15:19:41 +08:00
|
|
|
import { ref, toRaw } from 'vue';
|
2024-07-18 11:29:52 +08:00
|
|
|
import { http } from '/nerv-lib/util/http';
|
2024-07-19 15:13:46 +08:00
|
|
|
import { carbonInventoryCheck } from '/@/api/carbonEmissionFactorLibrary';
|
|
|
|
import fillIn from './fillInPage/index.vue';
|
2024-07-18 11:29:52 +08:00
|
|
|
defineOptions({ name: 'CarbonInventoryCheck' });
|
|
|
|
const orgId = ref('');
|
|
|
|
const result = JSON.parse(sessionStorage.getItem('ORGID')!);
|
|
|
|
orgId.value = result;
|
|
|
|
const fetch = (api, params = { orgId }) => {
|
|
|
|
return http.post(api, params);
|
|
|
|
};
|
2024-07-18 15:14:25 +08:00
|
|
|
// 判断展示哪个页面
|
2024-07-24 15:17:34 +08:00
|
|
|
const isMainPage = ref(true);
|
|
|
|
const fillInPage = ref(false);
|
2024-07-18 15:14:25 +08:00
|
|
|
// 新增相关数据
|
|
|
|
const visible = ref(false);
|
2024-07-25 15:19:41 +08:00
|
|
|
const formState = ref({});
|
2024-07-18 15:14:25 +08:00
|
|
|
const formRef = ref();
|
|
|
|
const labelCol = { span: 5 };
|
|
|
|
const wrapperCol = { span: 19 };
|
2024-07-31 15:52:08 +08:00
|
|
|
const disabledDate = (current: moment.Moment | null) => {
|
|
|
|
if (formState.value.reportPeriod === '2') {
|
|
|
|
const year = current.year();
|
|
|
|
return year === Number(formState.value.reportYear) ? false : true;
|
|
|
|
}
|
|
|
|
};
|
2024-08-08 15:13:32 +08:00
|
|
|
const selectChange = (value) => {
|
|
|
|
formState.value.reportScope = '';
|
|
|
|
};
|
2024-07-18 15:14:25 +08:00
|
|
|
// 定义form表单的必填
|
|
|
|
const rules: Record<string, Rule[]> = {
|
2024-07-19 15:13:46 +08:00
|
|
|
reportName: [{ required: true, message: '请输入报告名称', trigger: 'change' }],
|
|
|
|
reportYear: [{ required: true, message: '请选择报告年度', trigger: 'change' }],
|
|
|
|
genericStandard: [{ required: true, message: '请输入适用标准', trigger: 'change' }],
|
|
|
|
reportPeriod: [{ required: true, message: '请选择排放类型', trigger: 'change' }],
|
|
|
|
reportScope: [{ required: true, message: '请选择报告范围', trigger: 'change' }],
|
2024-07-18 15:14:25 +08:00
|
|
|
};
|
|
|
|
// 关闭新增抽屉
|
|
|
|
const onClose = () => {
|
|
|
|
visible.value = false;
|
2024-07-25 15:19:41 +08:00
|
|
|
formState.value = {};
|
2024-07-18 15:14:25 +08:00
|
|
|
formRef.value.resetFields();
|
|
|
|
};
|
2024-07-19 15:13:46 +08:00
|
|
|
// 点击确定提交
|
|
|
|
const onSubmit = () => {
|
|
|
|
formRef.value
|
|
|
|
.validate()
|
|
|
|
.then(() => {
|
|
|
|
console.log('values', formState, toRaw(formState));
|
2024-07-25 15:19:41 +08:00
|
|
|
formState.value.enterpriseOrgId = orgId.value;
|
|
|
|
formState.value.startTime = formState.value.reportScope[0];
|
|
|
|
formState.value.endTime = formState.value.reportScope[1];
|
|
|
|
fetch(carbonInventoryCheck.createOrUpdate, formState.value).then((res) => {
|
|
|
|
visible.value = false;
|
2024-07-19 15:13:46 +08:00
|
|
|
mainRef.value?.nsTableRef.reload();
|
|
|
|
});
|
|
|
|
})
|
2024-07-25 15:19:41 +08:00
|
|
|
.catch((error) => {
|
2024-07-19 15:13:46 +08:00
|
|
|
console.log('error', error);
|
|
|
|
});
|
|
|
|
};
|
2024-07-18 15:14:25 +08:00
|
|
|
// 表格相关数据
|
2024-07-19 15:13:46 +08:00
|
|
|
const data = ref([]);
|
|
|
|
const mainRef = ref();
|
2024-07-24 15:17:34 +08:00
|
|
|
const reportId = ref();
|
2024-07-31 15:52:08 +08:00
|
|
|
const startTime = ref();
|
|
|
|
const endTime = ref();
|
2024-07-24 15:17:34 +08:00
|
|
|
const year = ref();
|
2024-07-18 11:29:52 +08:00
|
|
|
const tableConfig = ref({
|
|
|
|
title: '数据库',
|
2024-07-19 15:13:46 +08:00
|
|
|
api: carbonInventoryCheck.carbonInventoryList,
|
2024-07-18 11:29:52 +08:00
|
|
|
params: {
|
2024-07-25 15:19:41 +08:00
|
|
|
orgId,
|
2024-07-18 11:29:52 +08:00
|
|
|
},
|
|
|
|
headerActions: [
|
|
|
|
{
|
|
|
|
label: '新增',
|
|
|
|
name: 'userAdd',
|
|
|
|
type: 'primary',
|
|
|
|
handle: () => {
|
2024-07-25 15:19:41 +08:00
|
|
|
visible.value = true;
|
2024-07-18 11:29:52 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
title: '序号',
|
|
|
|
customRender: (text: any) => {
|
|
|
|
return text.index + 1;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '企业名称',
|
2024-07-19 15:13:46 +08:00
|
|
|
dataIndex: 'enterpriseName',
|
2024-07-18 11:29:52 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '报告名称',
|
2024-07-19 15:13:46 +08:00
|
|
|
dataIndex: 'reportName',
|
2024-07-18 11:29:52 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '报告年度',
|
2024-07-19 15:13:46 +08:00
|
|
|
dataIndex: 'reportYear',
|
2024-07-18 11:29:52 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '适用标准',
|
2024-07-19 15:13:46 +08:00
|
|
|
dataIndex: 'genericStandard',
|
2024-07-18 11:29:52 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '更新人',
|
2024-07-19 15:13:46 +08:00
|
|
|
dataIndex: 'updateUser',
|
2024-07-18 11:29:52 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '更新时间',
|
2024-07-19 15:13:46 +08:00
|
|
|
dataIndex: 'updateTime',
|
2024-07-18 11:29:52 +08:00
|
|
|
},
|
|
|
|
],
|
|
|
|
columnActions: {
|
|
|
|
title: '操作',
|
|
|
|
actions: [
|
|
|
|
{
|
|
|
|
label: '编辑',
|
|
|
|
name: 'userEdit',
|
|
|
|
handle: (record: any) => {
|
2024-07-25 15:19:41 +08:00
|
|
|
visible.value = true;
|
|
|
|
fetch(carbonInventoryCheck.findById, { id: record.id }).then((res) => {
|
|
|
|
formState.value = res.data;
|
|
|
|
formState.value.reportScope = [res.data.startTime, res.data.endTime];
|
2024-07-19 15:13:46 +08:00
|
|
|
});
|
2024-07-18 11:29:52 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: '填报',
|
|
|
|
name: 'fillIn',
|
|
|
|
handle: (record: any) => {
|
2024-07-25 15:19:41 +08:00
|
|
|
isMainPage.value = false;
|
|
|
|
fillInPage.value = true;
|
|
|
|
reportId.value = record.id;
|
|
|
|
year.value = record.reportYear;
|
2024-07-31 15:52:08 +08:00
|
|
|
startTime.value = record.startTime;
|
|
|
|
endTime.value = record.endTime;
|
2024-07-18 11:29:52 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: '下载',
|
|
|
|
name: 'download',
|
2024-07-25 15:19:41 +08:00
|
|
|
handle: (record: any) => {},
|
2024-07-18 11:29:52 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: '删除',
|
|
|
|
name: 'userDelete',
|
2024-07-19 15:13:46 +08:00
|
|
|
dynamicParams: { id: 'id' },
|
2024-07-18 11:29:52 +08:00
|
|
|
confirm: true,
|
|
|
|
isReload: true,
|
2024-07-19 15:13:46 +08:00
|
|
|
api: carbonInventoryCheck.delete,
|
2024-07-18 11:29:52 +08:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
formConfig: {
|
|
|
|
schemas: [
|
|
|
|
{
|
2024-07-19 15:13:46 +08:00
|
|
|
field: 'reportName',
|
2024-07-18 11:29:52 +08:00
|
|
|
label: '报告名称',
|
|
|
|
component: 'NsInput',
|
|
|
|
componentProps: {
|
|
|
|
placeholder: '请输入报告名称',
|
|
|
|
maxLength: 30,
|
|
|
|
},
|
|
|
|
},
|
2024-07-18 15:14:25 +08:00
|
|
|
{
|
2024-07-19 15:13:46 +08:00
|
|
|
field: 'reportYear',
|
|
|
|
label: '报告年度',
|
2024-07-18 15:14:25 +08:00
|
|
|
component: 'NsRangePicker',
|
2024-07-19 15:13:46 +08:00
|
|
|
fieldMap: ['startYear', 'endYear'],
|
2024-07-18 15:14:25 +08:00
|
|
|
componentProps: {
|
2024-07-19 15:13:46 +08:00
|
|
|
valueFormat: 'YYYY',
|
2024-07-18 15:14:25 +08:00
|
|
|
placeholder: ['报告年度', '报告年度'],
|
2024-07-25 15:19:41 +08:00
|
|
|
picker: 'year',
|
2024-07-18 15:14:25 +08:00
|
|
|
},
|
|
|
|
},
|
2024-07-18 11:29:52 +08:00
|
|
|
],
|
|
|
|
params: {},
|
|
|
|
},
|
|
|
|
rowKey: 'id',
|
|
|
|
});
|
2024-07-24 15:17:34 +08:00
|
|
|
// 填报页点击返回
|
2024-07-25 15:19:41 +08:00
|
|
|
const updateData = (newDataOne, newDataTwo) => {
|
|
|
|
isMainPage.value = newDataOne;
|
|
|
|
fillInPage.value = newDataTwo;
|
2024-07-24 15:17:34 +08:00
|
|
|
};
|
2024-07-18 11:29:52 +08:00
|
|
|
</script>
|
|
|
|
|
2024-07-25 15:19:41 +08:00
|
|
|
<style lang="less" scoped></style>
|