|
|
|
|
@ -18,7 +18,7 @@ |
|
|
|
|
</el-button> |
|
|
|
|
</template> |
|
|
|
|
</avue-form> |
|
|
|
|
<el-table v-show="isRead && !isDetail" :data="tableData"> |
|
|
|
|
<el-table v-show="isRead && !isDetail" :data="tableData" :row-class-name="tableRowClassName"> |
|
|
|
|
<el-table-column type="index" width="50" label="序号" /> |
|
|
|
|
<el-table-column |
|
|
|
|
v-for="item in tableColumn" |
|
|
|
|
@ -43,31 +43,18 @@ import { |
|
|
|
|
reportBsEfficiencyTask, |
|
|
|
|
subReportBsEfficiencyTask, |
|
|
|
|
} from '@/api/performanceManagement/dataReporting'; |
|
|
|
|
|
|
|
|
|
export default { |
|
|
|
|
props: { |
|
|
|
|
title: { |
|
|
|
|
type: String, |
|
|
|
|
default: '', |
|
|
|
|
}, |
|
|
|
|
showReport: { |
|
|
|
|
type: Boolean, |
|
|
|
|
default: false, |
|
|
|
|
}, |
|
|
|
|
isDetail: { |
|
|
|
|
type: Boolean, |
|
|
|
|
default: false, |
|
|
|
|
}, |
|
|
|
|
row: { |
|
|
|
|
type: Object, |
|
|
|
|
default: null, |
|
|
|
|
}, |
|
|
|
|
title: { type: String, default: '' }, |
|
|
|
|
showReport: { type: Boolean, default: false }, |
|
|
|
|
isDetail: { type: Boolean, default: false }, |
|
|
|
|
row: { type: Object, default: null }, |
|
|
|
|
}, |
|
|
|
|
data() { |
|
|
|
|
return { |
|
|
|
|
openShow: false, |
|
|
|
|
excelForm: { |
|
|
|
|
excelFile: [], |
|
|
|
|
}, |
|
|
|
|
excelForm: { excelFile: [] }, |
|
|
|
|
excelOption: { |
|
|
|
|
submitBtn: false, |
|
|
|
|
emptyBtn: false, |
|
|
|
|
@ -81,63 +68,58 @@ export default { |
|
|
|
|
fileSize: 50000, |
|
|
|
|
propsHttp: { |
|
|
|
|
res: 'data', |
|
|
|
|
attachId: 'attachId', // 关键:指定附件ID字段 |
|
|
|
|
}, |
|
|
|
|
dataType: 'object', |
|
|
|
|
accept: '.xls,.xlsx', |
|
|
|
|
tip: '请上传 .xls,.xlsx 标准格式文件,文件最大5M', |
|
|
|
|
action: '/api/blade-resource/oss/endpoint/put-file-attach', |
|
|
|
|
rules: [ |
|
|
|
|
{ |
|
|
|
|
required: true, |
|
|
|
|
message: '请上传文件', |
|
|
|
|
trigger: 'blur', |
|
|
|
|
}, |
|
|
|
|
], |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
label: '', |
|
|
|
|
prop: 'readExcel', |
|
|
|
|
formslot: true, |
|
|
|
|
span: 12, |
|
|
|
|
rules: [{ required: true, message: '请上传文件', trigger: 'blur' }], |
|
|
|
|
}, |
|
|
|
|
{ label: '', prop: 'readExcel', formslot: true, span: 12 }, |
|
|
|
|
], |
|
|
|
|
}, |
|
|
|
|
tableData: [], |
|
|
|
|
isRead: false, |
|
|
|
|
tableColumn: [ |
|
|
|
|
{ label: '员工工号', prop: 'cardNo' }, |
|
|
|
|
{ label: '姓名', prop: 'name' }, |
|
|
|
|
], |
|
|
|
|
tableColumn: [], |
|
|
|
|
attachId: null, |
|
|
|
|
formData: null, |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
created() { |
|
|
|
|
this.openShow = this.showReport; |
|
|
|
|
watch: { |
|
|
|
|
showReport: { |
|
|
|
|
handler(val) { |
|
|
|
|
this.openShow = val; |
|
|
|
|
}, |
|
|
|
|
immediate: true, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
tableRowClassName({ row }) { |
|
|
|
|
if (row.isSysUser == '0' || row.isSysUser == 0) { |
|
|
|
|
return 'warning-row'; |
|
|
|
|
} |
|
|
|
|
return ''; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
closeDialog(val) { |
|
|
|
|
this.openShow = false; |
|
|
|
|
// 清空数据 |
|
|
|
|
this.excelForm = { excelFile: [] }; |
|
|
|
|
this.attachId = null; |
|
|
|
|
this.tableData = []; |
|
|
|
|
this.isRead = false; |
|
|
|
|
this.$emit('closeDialog', val); |
|
|
|
|
}, |
|
|
|
|
// 上传前(不用改,保留) |
|
|
|
|
|
|
|
|
|
uploadBefore(file, done, loading, column) { |
|
|
|
|
this.formData = file; |
|
|
|
|
done(); // 必须执行,允许上传 |
|
|
|
|
done(file); |
|
|
|
|
}, |
|
|
|
|
// 上传后(修复版) |
|
|
|
|
uploadAfter(file, done, loading, column) { |
|
|
|
|
console.log('上传成功返回:', file); |
|
|
|
|
// 正确获取 attachId |
|
|
|
|
this.attachId = file.attachId || file.data?.attachId; |
|
|
|
|
uploadAfter(res, done, loading, column) { |
|
|
|
|
// 处理action接口返回的文件信息 |
|
|
|
|
this.attachId = res.attachId; |
|
|
|
|
done(); |
|
|
|
|
}, |
|
|
|
|
// 读取Excel(关键修复) |
|
|
|
|
|
|
|
|
|
readExcel() { |
|
|
|
|
if (!this.attachId) { |
|
|
|
|
this.$message.warning('请先上传文件'); |
|
|
|
|
@ -151,52 +133,75 @@ export default { |
|
|
|
|
this.isRead = true; |
|
|
|
|
this.$message.success('文件读取成功'); |
|
|
|
|
} else { |
|
|
|
|
this.$message.error('文件读取失败'); |
|
|
|
|
this.$message.error(res.data.msg || '读取失败'); |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
.catch(() => { |
|
|
|
|
.catch(error => { |
|
|
|
|
console.error('读取文件失败:', error); |
|
|
|
|
this.$message.error('文件读取接口异常'); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
// 提交表单 |
|
|
|
|
submitForm() { |
|
|
|
|
if (!this.attachId) { |
|
|
|
|
this.$message.error('请先上传文件'); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
let params = {}; |
|
|
|
|
if (!this.isDetail) { |
|
|
|
|
params = { |
|
|
|
|
// 1. 判断状态 |
|
|
|
|
const hasPending = this.row.subTasks?.some(t => t.status === 1); |
|
|
|
|
const hasError = this.tableData.some(item => item.isSysUser == 0); |
|
|
|
|
// 2. 提示语(优先级:未完成 > 错误 > 正常) |
|
|
|
|
let msg = '确认提交绩效数据?'; |
|
|
|
|
if (hasPending && hasError) { |
|
|
|
|
msg = '本月有未完成绩效任务,数据可能存在错误,确认提交绩效数据?'; |
|
|
|
|
} else if (hasError) { |
|
|
|
|
msg = '数据可能存在错误,确认提交绩效数据?'; |
|
|
|
|
} else if (hasPending) { |
|
|
|
|
msg = '本月有未完成绩效任务,确认提交绩效数据?'; |
|
|
|
|
} else { |
|
|
|
|
msg = '确认提交绩效数据?'; |
|
|
|
|
} |
|
|
|
|
this.$confirm(msg, '', { |
|
|
|
|
confirmButtonText: '确定', |
|
|
|
|
cancelButtonText: '取消', |
|
|
|
|
type: 'warning', |
|
|
|
|
}) |
|
|
|
|
.then(() => { |
|
|
|
|
const params = { |
|
|
|
|
id: this.row.id, |
|
|
|
|
attachId: this.attachId, |
|
|
|
|
table: { |
|
|
|
|
}; |
|
|
|
|
if (!this.isDetail) { |
|
|
|
|
params.table = { |
|
|
|
|
tableData: this.tableData, |
|
|
|
|
tableColumn: this.tableColumn, |
|
|
|
|
}, |
|
|
|
|
}; |
|
|
|
|
reportBsEfficiencyTask(params).then(res => { |
|
|
|
|
if (res.data.code === 200) { |
|
|
|
|
this.$message.success('提交成功'); |
|
|
|
|
this.closeDialog(true); |
|
|
|
|
} else { |
|
|
|
|
this.$message.error('提交失败'); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
params = { |
|
|
|
|
id: this.row.id, |
|
|
|
|
attachId: this.attachId, |
|
|
|
|
}; |
|
|
|
|
subReportBsEfficiencyTask(params).then(res => { |
|
|
|
|
const api = this.isDetail ? subReportBsEfficiencyTask : reportBsEfficiencyTask; |
|
|
|
|
|
|
|
|
|
api(params) |
|
|
|
|
.then(res => { |
|
|
|
|
if (res.data.code === 200) { |
|
|
|
|
this.$message.success('提交成功'); |
|
|
|
|
this.closeDialog(true); |
|
|
|
|
} else { |
|
|
|
|
this.$message.error('提交失败'); |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
.catch(error => { |
|
|
|
|
console.error('提交失败:', error); |
|
|
|
|
this.$message.error('提交失败,请检查网络或稍后重试'); |
|
|
|
|
}); |
|
|
|
|
}) |
|
|
|
|
.catch(() => { |
|
|
|
|
// 取消提交 |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}; |
|
|
|
|
</script> |
|
|
|
|
<style> |
|
|
|
|
/* 高亮样式 权重提升 确保生效 */ |
|
|
|
|
.warning-row { |
|
|
|
|
background: #fff800 !important; |
|
|
|
|
} |
|
|
|
|
</style> |