This commit is contained in:
2025-03-09 21:44:39 +08:00
parent b600f7f5af
commit b400a1e0bc
11 changed files with 248 additions and 106 deletions

View File

@@ -6,7 +6,7 @@
</div>
<!-- 上传弹窗 -->
<el-dialog
<el-dialog
title="薪资计算"
:visible.sync="uploadVisible"
width="30%"
@@ -23,7 +23,7 @@
:disabled="isUploading">
</el-date-picker>
</el-form-item>
<el-form-item label="薪资文件" required>
<el-upload
class="upload-demo"
@@ -38,15 +38,16 @@
</el-upload>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="uploadVisible = false" :disabled="isUploading">取消</el-button>
<el-button @click="handleUpload" :disabled="fileList.length === 0">确认上传</el-button>
<el-button
type="primary"
<el-button
type="primary"
@click="handleSubmit"
:loading="isUploading"
:disabled="!filePath">
:disabled="isUploading"
>
{{ isUploading ? '计算中...' : '开始计算' }}
</el-button>
</span>
@@ -87,7 +88,7 @@
</template>
</el-table-column>
</el-table>
<div class="summary">
<span>合计人数{{currentResult.length}} </span>
<span class="total-amount">总金额¥ {{totalAmount}}</span>
@@ -98,7 +99,7 @@
</template>
<script>
import { calculateSalary, uploadOssFile } from '@/api/oa/salary'
import {calculateSalary, listStaff, uploadOssFile} from '@/api/oa/salary'
export default {
data() {
@@ -112,6 +113,12 @@ export default {
currentMonth: '',
historyData: [],
filePath: '',
query:{
pageSize:10,
pageNum:1,
payTime:"2025-03-01"
},
StaffSalaryList:[]
}
},
computed: {
@@ -122,46 +129,55 @@ export default {
return this.currentResult.reduce((sum, item) => sum + item.total, 0)
}
},
created() {
this.getStaffList()
},
methods: {
getStaffList(){
listStaff(this.query).then(res => {
this.StaffSalaryList = res.rows
console.log(this.StaffSalaryList)
})
},
showUploadDialog() {
this.uploadVisible = true
},
handleFileChange(file, fileList) {
// 限制单个文件上传
this.fileList = [fileList[fileList.length - 1]]
},
async handleSubmit() {
try {
this.isUploading = true
// 第一步:上传文件
// const formData = new FormData()
// formData.append('file', this.fileList[0].raw)
// const { data } = await uploadOssFile(formData)
// const filePath = '/data' + data.url.split('/data')[1];
// console.log('上传成功,文件路径:', filePath, this.month)
// 第二步:提交计算
const { result } = await calculateSalary({
filePath: this.filePath,
monthStr: this.month
})
this.currentResult = result.details
this.currentMonth = this.month
this.showCurrentResult = true
// 更新历史记录
this.historyData.unshift({
calcMonth: this.month,
calcTime: new Date().toLocaleString(),
totalAmount: this.totalAmount
})
this.$message.success('计算完成')
this.uploadVisible = false
} catch (error) {
@@ -170,12 +186,12 @@ export default {
this.isUploading = false
}
},
// 上传文件
async handleUpload() {
const formData = new FormData()
formData.append('file', this.fileList[0].raw)
const { data } = await uploadOssFile(formData)
const filePath = '/data' + data.url.split('/data')[1];
@@ -187,7 +203,7 @@ export default {
this.fileList = []
this.month = ''
},
showDetail(row) {
// 查看历史详情逻辑
console.log('查看详情', row)
@@ -243,4 +259,4 @@ export default {
.upload-demo {
text-align: center;
}
</style>
</style>