|
@ -55,12 +55,19 @@ |
|
|
<a-button type="primary" @click="addDetail">新增</a-button> |
|
|
<a-button type="primary" @click="addDetail">新增</a-button> |
|
|
<a-button type="primary" style="margin-left: 6px">导入</a-button> |
|
|
<a-button type="primary" style="margin-left: 6px">导入</a-button> |
|
|
<a-button type="primary" style="margin-left: 6px">导出</a-button> |
|
|
<a-button type="primary" style="margin-left: 6px">导出</a-button> |
|
|
<a-button type="primary" style="margin-left: 6px">批量删除</a-button> |
|
|
<a-button |
|
|
|
|
|
type="primary" |
|
|
|
|
|
style="margin-left: 6px" |
|
|
|
|
|
:disabled="selectedRowKeys.length === 0" |
|
|
|
|
|
@click="deleteMore" |
|
|
|
|
|
>批量删除</a-button |
|
|
|
|
|
> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
<a-table |
|
|
<a-table |
|
|
:columns="columns" |
|
|
:columns="columns" |
|
|
:data-source="data" |
|
|
:data-source="data" |
|
|
|
|
|
rowKey="id" |
|
|
@change="onChange" |
|
|
@change="onChange" |
|
|
:rowSelection="{ |
|
|
:rowSelection="{ |
|
|
selectedRowKeys: selectedRowKeys, |
|
|
selectedRowKeys: selectedRowKeys, |
|
@ -134,18 +141,19 @@ |
|
|
<a-form-item ref="name" label="交易数量" name="transactionQuantity"> |
|
|
<a-form-item ref="name" label="交易数量" name="transactionQuantity"> |
|
|
<a-input v-model:value="formState.transactionQuantity" placeholder="请输入交易数量" /> |
|
|
<a-input v-model:value="formState.transactionQuantity" placeholder="请输入交易数量" /> |
|
|
</a-form-item> |
|
|
</a-form-item> |
|
|
<a-form-item ref="name" label="发生金额" name="amountIncurredValue"> |
|
|
<a-form-item ref="name" label="发生金额" name="amountIncurred"> |
|
|
<a-input v-model:value="formState.amountIncurredValue" placeholder="请输入发生金额" /> |
|
|
<a-input v-model:value="formState.amountIncurred" placeholder="请输入发生金额" /> |
|
|
</a-form-item> |
|
|
</a-form-item> |
|
|
<a-form-item ref="name" label="交易对象" name="tradingPartner"> |
|
|
<a-form-item ref="name" label="交易对象" name="tradingPartner"> |
|
|
<a-input v-model:value="formState.tradingPartner" placeholder="请输入交易对象" /> |
|
|
<a-input v-model:value="formState.tradingPartner" placeholder="请输入交易对象" /> |
|
|
</a-form-item> |
|
|
</a-form-item> |
|
|
<a-form-item ref="name" label="交易凭证" name="tradingPartner"> |
|
|
<a-form-item ref="name" label="交易凭证"> |
|
|
<a-upload |
|
|
<a-upload |
|
|
v-model:file-list="fileList" |
|
|
:file-list="fileList" |
|
|
name="file" |
|
|
name="file" |
|
|
action="https://www.mocky.io/v2/5cc8019d300000980a055e76" |
|
|
accept=".jpg,.jpeg,.png,.gif,.bmp,.pdf" |
|
|
:headers="headers" |
|
|
@remove="handleFileRemove" |
|
|
|
|
|
:before-upload="beforeUpload" |
|
|
@change="handleChange"> |
|
|
@change="handleChange"> |
|
|
<a-button> |
|
|
<a-button> |
|
|
<upload-outlined></upload-outlined> |
|
|
<upload-outlined></upload-outlined> |
|
@ -164,10 +172,16 @@ |
|
|
<script lang="ts" setup> |
|
|
<script lang="ts" setup> |
|
|
import { ref, defineEmits, toRaw } from 'vue'; |
|
|
import { ref, defineEmits, toRaw } from 'vue'; |
|
|
import { http } from '/nerv-lib/util/http'; |
|
|
import { http } from '/nerv-lib/util/http'; |
|
|
|
|
|
import { NSAxios } from '/nerv-lib/util/http/axios'; |
|
|
import { UploadOutlined } from '@ant-design/icons-vue'; |
|
|
import { UploadOutlined } from '@ant-design/icons-vue'; |
|
|
import type { UploadChangeParam } from 'ant-design-vue'; |
|
|
import type { UploadChangeParam, UploadProps } from 'ant-design-vue'; |
|
|
import { Pagination, Modal, message } from 'ant-design-vue'; |
|
|
import { Pagination, Modal, message } from 'ant-design-vue'; |
|
|
import { carbonAssets, carbonEmissionFactorLibrary } from '/@/api/carbonEmissionFactorLibrary'; |
|
|
import { |
|
|
|
|
|
carbonAssets, |
|
|
|
|
|
carbonEmissionFactorLibrary, |
|
|
|
|
|
uploadPic, |
|
|
|
|
|
} from '/@/api/carbonEmissionFactorLibrary'; |
|
|
|
|
|
import { log } from 'console'; |
|
|
defineOptions({ |
|
|
defineOptions({ |
|
|
energyType: 'carbonAssets', // 与页面路由name一致缓存才可生效 |
|
|
energyType: 'carbonAssets', // 与页面路由name一致缓存才可生效 |
|
|
components: { |
|
|
components: { |
|
@ -207,6 +221,7 @@ |
|
|
const getDetailList = () => { |
|
|
const getDetailList = () => { |
|
|
fetch(carbonAssets.carbonDetailsList, queryParams.value).then((res) => { |
|
|
fetch(carbonAssets.carbonDetailsList, queryParams.value).then((res) => { |
|
|
data.value = res.data.records; |
|
|
data.value = res.data.records; |
|
|
|
|
|
total.value = res.data.total; |
|
|
}); |
|
|
}); |
|
|
}; |
|
|
}; |
|
|
getDetailList(); |
|
|
getDetailList(); |
|
@ -276,12 +291,20 @@ |
|
|
getDictList(); |
|
|
getDictList(); |
|
|
visible.value = true; |
|
|
visible.value = true; |
|
|
formState.value.id = record.id; |
|
|
formState.value.id = record.id; |
|
|
|
|
|
fetch(uploadPic.select, { bizId: record.id, bizTpye: 1 }).then((res) => { |
|
|
|
|
|
fileList.value = res.data; |
|
|
|
|
|
}); |
|
|
|
|
|
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(() => { |
|
|
setTimeout(() => { |
|
|
let selectDevice = ref([Number(record.transactionType)]); |
|
|
let selectDevice = ref([Number(formState.value.transactionType)]); |
|
|
findParentIds(options.value, record.transactionType, selectDevice.value); |
|
|
findParentIds(options.value, formState.value.transactionType, selectDevice.value); |
|
|
record.transactionType = selectDevice; |
|
|
formState.value.transactionType = selectDevice; |
|
|
formState.value.transactionType = record.transactionType; |
|
|
formState.value.transactionType = formState.value.transactionType; |
|
|
formState.value = record; |
|
|
|
|
|
}, 500); |
|
|
}, 500); |
|
|
}; |
|
|
}; |
|
|
// 定义一个递归函数来查找每一级的id 设备类型回显 层级方法 |
|
|
// 定义一个递归函数来查找每一级的id 设备类型回显 层级方法 |
|
@ -297,6 +320,7 @@ |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
const delData = (record) => { |
|
|
const delData = (record) => { |
|
|
|
|
|
const id = [record.id]; |
|
|
Modal.confirm({ |
|
|
Modal.confirm({ |
|
|
title: '警告', |
|
|
title: '警告', |
|
|
content: '确定要删除吗?', |
|
|
content: '确定要删除吗?', |
|
@ -304,7 +328,26 @@ |
|
|
okType: 'primary', |
|
|
okType: 'primary', |
|
|
cancelText: '取消', |
|
|
cancelText: '取消', |
|
|
onOk() { |
|
|
onOk() { |
|
|
fetch(carbonAssets.delete, { id: record.id }).then((res) => { |
|
|
fetch(carbonAssets.delete, { ids: id }).then((res) => { |
|
|
|
|
|
debugger; |
|
|
|
|
|
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('操作成功!'); |
|
|
message.success('操作成功!'); |
|
|
getDetailList(); |
|
|
getDetailList(); |
|
|
}); |
|
|
}); |
|
@ -353,6 +396,55 @@ |
|
|
visible.value = true; |
|
|
visible.value = true; |
|
|
getDictList(); |
|
|
getDictList(); |
|
|
}; |
|
|
}; |
|
|
|
|
|
// 上传附件 |
|
|
|
|
|
const fileList = ref<UploadProps['fileList']>([]); |
|
|
|
|
|
// const headers = { |
|
|
|
|
|
// authorization: 'authorization-text', |
|
|
|
|
|
// }; |
|
|
|
|
|
// const beforeUpload = (file: File) => { |
|
|
|
|
|
// return false; // 返回 true 表示允许上传 |
|
|
|
|
|
// }; |
|
|
|
|
|
const beforeUpload: UploadProps['beforeUpload'] = (file) => { |
|
|
|
|
|
// fileList.value = [...(fileList.value || []), 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 handleFileRemove = (file) => { |
|
|
|
|
|
const newFileList = []; |
|
|
|
|
|
fileList.value.forEach((item) => { |
|
|
|
|
|
if (item.uid !== file.uid) { |
|
|
|
|
|
newFileList.push(item); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
fileList.value = newFileList; |
|
|
|
|
|
}; |
|
|
|
|
|
const uploadQuery = ref({ |
|
|
|
|
|
bizTpye: 1, |
|
|
|
|
|
}); |
|
|
|
|
|
const config = { |
|
|
|
|
|
headers: { |
|
|
|
|
|
'Content-Type': 'multipart/form-data', |
|
|
|
|
|
}, |
|
|
|
|
|
}; |
|
|
|
|
|
function createHttp() { |
|
|
|
|
|
/** todo 临时去除超时时间 */ |
|
|
|
|
|
return new NSAxios({ |
|
|
|
|
|
headers: { 'Content-Type': 'application/json;charset=UTF-8' }, |
|
|
|
|
|
withCredentials: true, |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
const uploadHttp = createHttp(); |
|
|
|
|
|
const url = '/carbon-smart/api/common/file/uploadfiles'; // 请求api |
|
|
const onSubmit = () => { |
|
|
const onSubmit = () => { |
|
|
formRef.value |
|
|
formRef.value |
|
|
.validate() |
|
|
.validate() |
|
@ -361,10 +453,49 @@ |
|
|
if (formState.value.transactionType) { |
|
|
if (formState.value.transactionType) { |
|
|
formState.value.transactionType = formState.value.transactionType.join(',').split(',')[1]; |
|
|
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) => { |
|
|
fetch(carbonAssets.createOrUpdate, formState.value).then((res) => { |
|
|
message.success('操作成功!'); |
|
|
if (res.data.id && fileList.value.length !== 0) { |
|
|
visible.value = false; |
|
|
// uploadQuery.value.bizId = res.data.id; |
|
|
getDetailList(); |
|
|
const formData = ref(new FormData()); |
|
|
|
|
|
fileList.value.forEach(file => { |
|
|
|
|
|
console.log(file,'xxy'); |
|
|
|
|
|
|
|
|
|
|
|
formData.value.append('files[]', file); |
|
|
|
|
|
}); |
|
|
|
|
|
formData.value.append('bizTpye', 1); |
|
|
|
|
|
formData.value.append('bizId', res.data.id); |
|
|
|
|
|
// uploadQuery.value.files = formData.value; |
|
|
|
|
|
// uploadQuery.value.files = fileList.value; |
|
|
|
|
|
debugger; |
|
|
|
|
|
fetch(uploadPic.uploadfiles, formData.value) |
|
|
|
|
|
.then((res) => { |
|
|
|
|
|
message.success('操作成功!'); |
|
|
|
|
|
visible.value = false; |
|
|
|
|
|
getDetailList(); |
|
|
|
|
|
}) |
|
|
|
|
|
.catch((error) => { |
|
|
|
|
|
console.log('error', error); |
|
|
|
|
|
}); |
|
|
|
|
|
console.log(config,'xxy555'); |
|
|
|
|
|
|
|
|
|
|
|
// uploadHttp |
|
|
|
|
|
// .post(url, formData.value, config.headers) |
|
|
|
|
|
// .then((res) => { |
|
|
|
|
|
// console.log(res); |
|
|
|
|
|
|
|
|
|
|
|
// }) |
|
|
|
|
|
// .catch((res) => { |
|
|
|
|
|
// console.log(res); |
|
|
|
|
|
|
|
|
|
|
|
// }); |
|
|
|
|
|
} else { |
|
|
|
|
|
message.success('操作成功!'); |
|
|
|
|
|
visible.value = false; |
|
|
|
|
|
getDetailList(); |
|
|
|
|
|
} |
|
|
}); |
|
|
}); |
|
|
}) |
|
|
}) |
|
|
.catch((error) => { |
|
|
.catch((error) => { |
|
@ -377,13 +508,14 @@ |
|
|
transactionType: [{ required: true, message: '请选择交易类型', trigger: 'change' }], |
|
|
transactionType: [{ required: true, message: '请选择交易类型', trigger: 'change' }], |
|
|
transactionDate: [{ required: true, message: '请选择交易日期', trigger: 'change' }], |
|
|
transactionDate: [{ required: true, message: '请选择交易日期', trigger: 'change' }], |
|
|
transactionQuantity: [{ required: true, message: '请输入交易数量', trigger: 'change' }], |
|
|
transactionQuantity: [{ required: true, message: '请输入交易数量', trigger: 'change' }], |
|
|
amountIncurredValue: [{ required: true, message: '请输入发生金额', trigger: 'change' }], |
|
|
amountIncurred: [{ required: true, message: '请输入发生金额', trigger: 'change' }], |
|
|
tradingPartner: [{ required: true, message: '请输入交易对象', trigger: 'change' }], |
|
|
tradingPartner: [{ required: true, message: '请输入交易对象', trigger: 'change' }], |
|
|
}; |
|
|
}; |
|
|
// 关闭新增抽屉 |
|
|
// 关闭新增抽屉 |
|
|
const onClose = () => { |
|
|
const onClose = () => { |
|
|
visible.value = false; |
|
|
visible.value = false; |
|
|
formState.value = {}; |
|
|
formState.value = {}; |
|
|
|
|
|
fileList.value = []; |
|
|
formRef.value.resetFields(); |
|
|
formRef.value.resetFields(); |
|
|
}; |
|
|
}; |
|
|
// 统计表格 |
|
|
// 统计表格 |
|
|