feat : 台账导入
This commit is contained in:
@@ -160,6 +160,13 @@ export const searchUpdateLedgerData = (projectId) => {
|
|||||||
method: "get"
|
method: "get"
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
//
|
||||||
|
// export const searchUpdateLedgerData = (projectId) => {
|
||||||
|
// return request({
|
||||||
|
// url: '/workflow/mosr/expense/ledger/import',
|
||||||
|
// method: "get"
|
||||||
|
// });
|
||||||
|
// };
|
||||||
|
|
||||||
export const exportExcel = (data) => {
|
export const exportExcel = (data) => {
|
||||||
return axios.post(
|
return axios.post(
|
||||||
|
|||||||
@@ -432,7 +432,6 @@ onMounted(() => {
|
|||||||
// }
|
// }
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log("propsprops", props.formData, props.type , props)
|
|
||||||
if (props.formData.mode == 'view' && props.type == 'execute') {
|
if (props.formData.mode == 'view' && props.type == 'execute') {
|
||||||
handleSearchImplementationFileList()
|
handleSearchImplementationFileList()
|
||||||
getTagsOption()
|
getTagsOption()
|
||||||
|
|||||||
95
src/components/ImportExcel.vue
Normal file
95
src/components/ImportExcel.vue
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
<template>
|
||||||
|
<el-upload :action="uploadFileUrl"
|
||||||
|
:headers="headers"
|
||||||
|
:limit="maxSize"
|
||||||
|
with-credentials
|
||||||
|
:multiple="multiple"
|
||||||
|
:data="uploadParams"
|
||||||
|
:auto-upload="true"
|
||||||
|
:before-upload="beforeUpload"
|
||||||
|
:on-success="handleUploadSuccess"
|
||||||
|
:on-error="uploadError"
|
||||||
|
:before-remove="beforeRemove"
|
||||||
|
:on-remove="handleRemove"
|
||||||
|
>
|
||||||
|
<el-button color="#DED0B2" style="margin-left: 10px; margin-right: 10px;" :loading="loading" :disabled="disabled">导入</el-button>
|
||||||
|
</el-upload>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { ElMessageBox, ElNotification} from "element-plus";
|
||||||
|
import {getToken} from '@/utils/auth'
|
||||||
|
|
||||||
|
const baseURL = import.meta.env.VITE_BASE_URL
|
||||||
|
const uploadFileUrl = ref(baseURL + "/workflow/mosr/expense/ledger/import")
|
||||||
|
const headers = reactive({
|
||||||
|
authorization: getToken()
|
||||||
|
})
|
||||||
|
const loading = ref(false)
|
||||||
|
const uploadParams = ref({})
|
||||||
|
const props = defineProps({
|
||||||
|
value: {
|
||||||
|
type: Array,
|
||||||
|
default: () => {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
maxSize: {
|
||||||
|
type: Number,
|
||||||
|
default: 30
|
||||||
|
},
|
||||||
|
disabled: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
multiple: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const emit = defineEmits(["input", "getFile", "delete"])
|
||||||
|
const beforeRemove = (file) => {
|
||||||
|
return ElMessageBox.confirm(`确认删除名称为${file.name}的文件吗?`, '系统提示', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning'
|
||||||
|
}).then(() => true)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleRemove = (file) => {
|
||||||
|
emit("delete", file.response.data.id)
|
||||||
|
}
|
||||||
|
const beforeUpload = () => {
|
||||||
|
loading.value = true
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
const handleUploadSuccess = (res) => {
|
||||||
|
ElNotification({
|
||||||
|
title: '提示',
|
||||||
|
message: res.code === 1000 ? '上传成功' : '上传失败',
|
||||||
|
type: res.code === 1000 ? 'success' : 'error'
|
||||||
|
})
|
||||||
|
loading.value = false
|
||||||
|
emit("success")
|
||||||
|
}
|
||||||
|
const uploadError = (error) => {
|
||||||
|
loading.value = false
|
||||||
|
ElNotification({
|
||||||
|
title: '提示',
|
||||||
|
message: "上传失败,请稍后再试!",
|
||||||
|
type: 'error'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
defineExpose({
|
||||||
|
handleRemove
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
a {
|
||||||
|
font-size: 14px;
|
||||||
|
color: #2a99ff;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
@@ -5,19 +5,25 @@
|
|||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="8">
|
<el-col :span="8">
|
||||||
<el-form-item prop="requirementName" label="征集名称" label-width="122">
|
<el-form-item prop="requirementName" label="征集名称" label-width="122">
|
||||||
<span>{{basicData.requirementName}}</span>
|
<span>{{ basicData.requirementName }}</span>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="8">
|
<el-col :span="8">
|
||||||
<el-form-item prop="projectName" label="项目名称" label-width="130">
|
<el-form-item prop="projectName" label="项目名称" label-width="130">
|
||||||
<span>{{basicData.projectName}}</span>
|
<span>{{ basicData.projectName }}</span>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
</el-form>
|
</el-form>
|
||||||
<fvForm :schema="schema" @getInstance="(e)=>baseForm = e"></fvForm>
|
<fvForm :schema="schema" @getInstance="(e)=>baseForm = e"></fvForm>
|
||||||
<fvSearchForm :searchConfig="searchConfig" @search="search"></fvSearchForm>
|
<fvSearchForm :searchConfig="searchConfig" @search="search"></fvSearchForm>
|
||||||
<fvTable ref="tableIns" :tableConfig="tableConfig" @headBtnClick="headBtnClick" @selectionChange="selectionChange">
|
<div style="display: flex">
|
||||||
|
<el-button color="#DED0B2" @click="exportExcelHandler">导出</el-button>
|
||||||
|
<import-excel v-if="buttonShow" @success="importTheExpenseLedger"/>
|
||||||
|
<el-button color="#DED0B2" v-if="buttonShow" @click="handleUploadFee">上传费用</el-button>
|
||||||
|
<el-button color="#DED0B2" v-if="buttonShow" @click="handleUpdateTable">表格更新</el-button>
|
||||||
|
</div>
|
||||||
|
<fvTable ref="tableIns" :tableConfig="tableConfig" @selectionChange="selectionChange">
|
||||||
<template #empty>
|
<template #empty>
|
||||||
<el-empty description="暂无数据"/>
|
<el-empty description="暂无数据"/>
|
||||||
</template>
|
</template>
|
||||||
@@ -30,11 +36,12 @@
|
|||||||
import fvSelect from '@/fvcomponents/fvSelect/index.vue'
|
import fvSelect from '@/fvcomponents/fvSelect/index.vue'
|
||||||
import {toThousands} from '@/utils/changePrice.js'
|
import {toThousands} from '@/utils/changePrice.js'
|
||||||
import {getBaseInfoApi} from "@/components/steps/api";
|
import {getBaseInfoApi} from "@/components/steps/api";
|
||||||
import {searchUpdateLedgerData,exportExcel} from "@/api/project-manage";
|
import {searchUpdateLedgerData, exportExcel} from "@/api/project-manage";
|
||||||
|
// import ImportExcel from "../../../components/ImportExcel";
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const basicData=ref({})
|
const basicData = ref({})
|
||||||
const tableData = ref({})
|
const tableData = ref({})
|
||||||
const formDataArray = ref([
|
const formDataArray = ref([
|
||||||
{
|
{
|
||||||
@@ -78,7 +85,7 @@ const formDataArray = ref([
|
|||||||
colProps: {
|
colProps: {
|
||||||
span: 6
|
span: 6
|
||||||
},
|
},
|
||||||
component: ()=><span>{tableData.value.projectCompletionRate}%</span>
|
component: () => <span>{tableData.value.projectCompletionRate}%</span>
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '已完成工作量',
|
label: '已完成工作量',
|
||||||
@@ -88,8 +95,9 @@ const formDataArray = ref([
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
const buttonShow = ref(false)
|
||||||
const schema = computed(() => {
|
const schema = computed(() => {
|
||||||
return formDataArray.value
|
return formDataArray.value
|
||||||
})
|
})
|
||||||
const baseForm = ref()
|
const baseForm = ref()
|
||||||
const tableIns = ref()
|
const tableIns = ref()
|
||||||
@@ -102,7 +110,7 @@ const searchConfig = reactive([
|
|||||||
prop: 'time',
|
prop: 'time',
|
||||||
component: 'el-date-picker',
|
component: 'el-date-picker',
|
||||||
props: {
|
props: {
|
||||||
type:'month',
|
type: 'month',
|
||||||
placeholder: '请选择月份',
|
placeholder: '请选择月份',
|
||||||
clearable: true,
|
clearable: true,
|
||||||
format: 'YYYY-MM',
|
format: 'YYYY-MM',
|
||||||
@@ -218,12 +226,12 @@ const tableConfig = reactive({
|
|||||||
params: {
|
params: {
|
||||||
projectId: route.query.id
|
projectId: route.query.id
|
||||||
},
|
},
|
||||||
btns: btns.value
|
// btns: btns.value
|
||||||
})
|
})
|
||||||
// const exportIds=ref([])
|
// const exportIds=ref([])
|
||||||
const selectionChange=(data)=>{
|
const selectionChange = (data) => {
|
||||||
console.log('data',data)
|
console.log('data', data)
|
||||||
console.log(' data.forEach(item=>item.id)', data.forEach(item=>item.id))
|
console.log(' data.forEach(item=>item.id)', data.forEach(item => item.id))
|
||||||
}
|
}
|
||||||
const handleUpdateTable = () => {
|
const handleUpdateTable = () => {
|
||||||
router.push({
|
router.push({
|
||||||
@@ -236,17 +244,22 @@ const handleUpdateTable = () => {
|
|||||||
const getBaseInfo = async () => {
|
const getBaseInfo = async () => {
|
||||||
try {
|
try {
|
||||||
const {code, data} = await getBaseInfoApi(route.query.id)
|
const {code, data} = await getBaseInfoApi(route.query.id)
|
||||||
basicData.value=data
|
basicData.value = data
|
||||||
} catch {
|
} catch {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const init = async () => {
|
const init = async () => {
|
||||||
|
buttonShow.value = false
|
||||||
const {code, msg, data} = await searchUpdateLedgerData(route.query.id)
|
const {code, msg, data} = await searchUpdateLedgerData(route.query.id)
|
||||||
if (code===1000) {
|
if (code === 1000) {
|
||||||
tableData.value = data
|
tableData.value = data
|
||||||
if(!data.view){
|
nextTick(() => {
|
||||||
btns.value.push({name: '上传费用', key: 'add', color: '#DED0B2', auth: ''},{name: '表格更新', key: 'update', color: '#DED0B2', auth: ''},)
|
buttonShow.value = !data.view
|
||||||
}
|
})
|
||||||
|
// if (!data.view) {
|
||||||
|
// btns.value.push({name: '上传费用', key: 'add', color: '#DED0B2', auth: ''},
|
||||||
|
// {name: '表格更新', key: 'update', color: '#DED0B2', auth: ''})
|
||||||
|
// }
|
||||||
baseForm.value.setValues(data)
|
baseForm.value.setValues(data)
|
||||||
}
|
}
|
||||||
// if (code !== 1000) {
|
// if (code !== 1000) {
|
||||||
@@ -259,18 +272,8 @@ const init = async () => {
|
|||||||
}
|
}
|
||||||
getBaseInfo()
|
getBaseInfo()
|
||||||
init()
|
init()
|
||||||
const headBtnClick = (key) => {
|
const importTheExpenseLedger = () => {
|
||||||
switch (key) {
|
tableIns.value.refresh()
|
||||||
case 'add':
|
|
||||||
handleUploadFee()
|
|
||||||
break;
|
|
||||||
case 'update':
|
|
||||||
handleUpdateTable()
|
|
||||||
break;
|
|
||||||
case 'export':
|
|
||||||
exportExcelHandler()
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
const handleUploadFee = () => {
|
const handleUploadFee = () => {
|
||||||
router.push({
|
router.push({
|
||||||
@@ -301,13 +304,13 @@ const search = (val) => {
|
|||||||
tableConfig.params = {...val, projectId: route.query.id}
|
tableConfig.params = {...val, projectId: route.query.id}
|
||||||
tableIns.value.refresh()
|
tableIns.value.refresh()
|
||||||
}
|
}
|
||||||
onActivated(()=>{
|
onActivated(() => {
|
||||||
init()
|
init()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
:deep(.el-table--fit){
|
:deep(.el-table--fit) {
|
||||||
min-height: 400px!important;
|
min-height: 400px !important;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user