预算&指标填报

This commit is contained in:
2026-03-05 11:12:34 +08:00
parent babbe98c09
commit 2f3586e2f2
15 changed files with 537 additions and 371 deletions

View File

@@ -20,7 +20,7 @@
</el-form-item>
<el-form-item>
<el-button style="background-color: #0B58FF;" type="primary" @click="onSubmit">查询</el-button>
<!-- <el-button type="primary" plain size="medium">导入</el-button> -->
<el-button type="primary" plain size="medium" @click='importExcel'>导入</el-button>
</el-form-item>
</el-form>
</div>
@@ -64,6 +64,22 @@ font-style: normal;">指标详情</div>
></base-table>
</div>
</div>
<el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
<el-upload ref="upload" :limit="1" accept=".xlsx, .xls" action="#" :disabled="upload.isUploading"
:on-change="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag>
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处<em>点击上传</em></div>
<div class="el-upload__tip text-center" slot="tip">
<span>仅允许导入xlsxlsx格式文件</span>
</div>
<div class="el-upload__tip" slot="tip">
</div>
</el-upload>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitFileForm"> </el-button>
<el-button @click="upload.open = false"> </el-button>
</div>
</el-dialog>
</Container>
</div>
</template>
@@ -72,7 +88,8 @@ font-style: normal;">指标详情</div>
import Container from './container.vue'
import { getLevelStruc, getRealMonthPage, updateRealMonthData, getDictListData, } from '@/api/cockpit'
import inputArea from './inputArea.vue' // 导入输入组件
import {getAccessToken, getTenantId} from '@/utils/auth'
import axios from 'axios';
export default {
name: 'ProductionStatus',
components: {
@@ -85,7 +102,7 @@ export default {
data() {
return {
form: {
levelId: 1,
levelId: undefined,
pageNo: 1,
pageSize: 100,
month: undefined,
@@ -96,7 +113,17 @@ export default {
isDetail: false, // 编辑状态标识false=只读true=编辑
tableData: [], // 表格数据
levelLList: [], // 所属层级下拉数据
tableProps: [] // 表格列配置
tableProps: [], // 表格列配置
upload: {
// 是否显示弹出层
open: false,
// 弹出层标题
title: "指标填报导入",
// 是否禁用上传
isUploading: false,
fileList:[],
currentFile:null
}
}
},
watch: {
@@ -261,13 +288,16 @@ export default {
getData() {
// 1. 请求所属层级下拉数据
getLevelStruc().then((res) => {
console.log('所属层级数据:', res);
this.levelLList = res.data || [];
this.form.levelId = this.levelLList[0].id;
this.getDataPage()
}).catch(err => {
console.error('获取所属层级失败:', err);
this.levelLList = [];
});
this.$emit('updateLeft')
},
getDataPage() {
// 2. 请求表格分页数据
getRealMonthPage({
levelId: this.form.levelId,
@@ -288,6 +318,7 @@ export default {
console.error('获取表格数据失败:', err);
this.tableData = [];
});
},
// 查询按钮点击事件(可根据需求扩展逻辑)
@@ -295,8 +326,61 @@ export default {
// 清空原有表格数据,重新请求
this.tableData = [];
this.$nextTick(() => {
this.getData();
this.getDataPage();
});
},
// 导入
importExcel() {
this.upload.open = true
},
// 文件上传中处理
handleFileUploadProgress(file, fileList) {
console.log('文件上传中:',file, fileList)
this.upload.isUploading = true;
this.upload.fileList = fileList;
this.upload.currentFile = file.raw;
},
handleFileSuccess() {},
importTemplate() {},
// 提交上传文件
async submitFileForm() {
try {
if (!this.upload.currentFile) {
return this.$message.error('请先选择要上传的文件!')
}
const formData = new FormData()
formData.append('file', this.upload.currentFile) // 文件字段
formData.append('reportDate', this.form.endTime) // 时间维度字段
formData.append('levelId', this.form.levelId) // 层级维度字段
const response = await axios({
url: process.env.VUE_APP_BASE_API + '/admin-api/lb/index-real-month/actualIndicatorImport',
method: 'post',
data: formData,
headers: {
'Content-Type': 'multipart/form-data',
'Authorization': "Bearer " + getAccessToken(),
'tenant-id': getTenantId(),
},
timeout: 30000
})
// 4. 处理响应结果
if (response.data.code === 0) {
this.$message.success('文件上传成功!')
// 重置表单
this.upload.fileList = []
this.upload.currentFile = null
this.upload.open = false
this.upload.isUploading = false
this.$refs.upload.clearFiles();
this.getData()
} else {
this.$message.error(`上传失败:${response.data.msg || '未知错误'}`)
}
} catch (error) {
// 5. 异常处理
console.error('文件上传出错:', error)
this.$message.error('上传失败!')
}
}
}
}