Merge pull request 'feat : 台账导入' (#598) from dd into master
Reviewed-on: http://git.feashow.cn/clay/mosr-web/pulls/598
This commit is contained in:
@@ -160,6 +160,13 @@ export const searchUpdateLedgerData = (projectId) => {
|
||||
method: "get"
|
||||
});
|
||||
};
|
||||
//
|
||||
// export const searchUpdateLedgerData = (projectId) => {
|
||||
// return request({
|
||||
// url: '/workflow/mosr/expense/ledger/import',
|
||||
// method: "get"
|
||||
// });
|
||||
// };
|
||||
|
||||
export const exportExcel = (data) => {
|
||||
return axios.post(
|
||||
|
||||
@@ -432,7 +432,6 @@ onMounted(() => {
|
||||
// }
|
||||
})
|
||||
|
||||
console.log("propsprops", props.formData, props.type , props)
|
||||
if (props.formData.mode == 'view' && props.type == 'execute') {
|
||||
handleSearchImplementationFileList()
|
||||
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-col :span="8">
|
||||
<el-form-item prop="requirementName" label="征集名称" label-width="122">
|
||||
<span>{{basicData.requirementName}}</span>
|
||||
<span>{{ basicData.requirementName }}</span>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item prop="projectName" label="项目名称" label-width="130">
|
||||
<span>{{basicData.projectName}}</span>
|
||||
<span>{{ basicData.projectName }}</span>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<fvForm :schema="schema" @getInstance="(e)=>baseForm = e"></fvForm>
|
||||
<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>
|
||||
<el-empty description="暂无数据"/>
|
||||
</template>
|
||||
@@ -30,11 +36,12 @@
|
||||
import fvSelect from '@/fvcomponents/fvSelect/index.vue'
|
||||
import {toThousands} from '@/utils/changePrice.js'
|
||||
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 route = useRoute()
|
||||
const basicData=ref({})
|
||||
const basicData = ref({})
|
||||
const tableData = ref({})
|
||||
const formDataArray = ref([
|
||||
{
|
||||
@@ -78,7 +85,7 @@ const formDataArray = ref([
|
||||
colProps: {
|
||||
span: 6
|
||||
},
|
||||
component: ()=><span>{tableData.value.projectCompletionRate}%</span>
|
||||
component: () => <span>{tableData.value.projectCompletionRate}%</span>
|
||||
},
|
||||
{
|
||||
label: '已完成工作量',
|
||||
@@ -88,8 +95,9 @@ const formDataArray = ref([
|
||||
}
|
||||
}
|
||||
])
|
||||
const buttonShow = ref(false)
|
||||
const schema = computed(() => {
|
||||
return formDataArray.value
|
||||
return formDataArray.value
|
||||
})
|
||||
const baseForm = ref()
|
||||
const tableIns = ref()
|
||||
@@ -102,7 +110,7 @@ const searchConfig = reactive([
|
||||
prop: 'time',
|
||||
component: 'el-date-picker',
|
||||
props: {
|
||||
type:'month',
|
||||
type: 'month',
|
||||
placeholder: '请选择月份',
|
||||
clearable: true,
|
||||
format: 'YYYY-MM',
|
||||
@@ -218,12 +226,12 @@ const tableConfig = reactive({
|
||||
params: {
|
||||
projectId: route.query.id
|
||||
},
|
||||
btns: btns.value
|
||||
// btns: btns.value
|
||||
})
|
||||
// const exportIds=ref([])
|
||||
const selectionChange=(data)=>{
|
||||
console.log('data',data)
|
||||
console.log(' data.forEach(item=>item.id)', data.forEach(item=>item.id))
|
||||
// const exportIds=ref([])
|
||||
const selectionChange = (data) => {
|
||||
console.log('data', data)
|
||||
console.log(' data.forEach(item=>item.id)', data.forEach(item => item.id))
|
||||
}
|
||||
const handleUpdateTable = () => {
|
||||
router.push({
|
||||
@@ -236,17 +244,22 @@ const handleUpdateTable = () => {
|
||||
const getBaseInfo = async () => {
|
||||
try {
|
||||
const {code, data} = await getBaseInfoApi(route.query.id)
|
||||
basicData.value=data
|
||||
basicData.value = data
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
const init = async () => {
|
||||
buttonShow.value = false
|
||||
const {code, msg, data} = await searchUpdateLedgerData(route.query.id)
|
||||
if (code===1000) {
|
||||
if (code === 1000) {
|
||||
tableData.value = data
|
||||
if(!data.view){
|
||||
btns.value.push({name: '上传费用', key: 'add', color: '#DED0B2', auth: ''},{name: '表格更新', key: 'update', color: '#DED0B2', auth: ''},)
|
||||
}
|
||||
nextTick(() => {
|
||||
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)
|
||||
}
|
||||
// if (code !== 1000) {
|
||||
@@ -259,18 +272,8 @@ const init = async () => {
|
||||
}
|
||||
getBaseInfo()
|
||||
init()
|
||||
const headBtnClick = (key) => {
|
||||
switch (key) {
|
||||
case 'add':
|
||||
handleUploadFee()
|
||||
break;
|
||||
case 'update':
|
||||
handleUpdateTable()
|
||||
break;
|
||||
case 'export':
|
||||
exportExcelHandler()
|
||||
break;
|
||||
}
|
||||
const importTheExpenseLedger = () => {
|
||||
tableIns.value.refresh()
|
||||
}
|
||||
const handleUploadFee = () => {
|
||||
router.push({
|
||||
@@ -301,13 +304,13 @@ const search = (val) => {
|
||||
tableConfig.params = {...val, projectId: route.query.id}
|
||||
tableIns.value.refresh()
|
||||
}
|
||||
onActivated(()=>{
|
||||
onActivated(() => {
|
||||
init()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
:deep(.el-table--fit){
|
||||
min-height: 400px!important;
|
||||
:deep(.el-table--fit) {
|
||||
min-height: 400px !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user