{
+ return authStore.organizationalLevelNum >= 3
+})
+
+// 计算本单位和下属单位的上报数之和
+const totalReportedAmount = computed(() => {
+ if (consumptionReports.value.length === 0) {
+ return distribution.value?.actualCompletion || 0
+ }
+ return consumptionReports.value.reduce((sum, report) => sum + report.reportedAmount, 0)
+})
+
+// 根据用户级别动态生成验证规则
+const formRules = computed(() => {
+ const baseRules: FormRules = {
+ actualCompletion: [
+ { required: true, message: '请输入本次上报数量', trigger: 'blur' },
+ {
+ type: 'number',
+ min: 0.01,
+ message: '数量必须大于0',
+ trigger: 'blur'
+ }
+ ]
+ }
+
+ // 只有师团/团级才需要验证不超过剩余配额
+ if (!isBattalionOrBelow.value) {
+ baseRules.actualCompletion.push({
validator: (_rule, value, callback) => {
const remaining = (distribution.value?.unitQuota || 0) - (distribution.value?.actualCompletion || 0)
if (value > remaining) {
@@ -221,9 +247,11 @@ const rules: FormRules = {
}
},
trigger: 'blur'
- }
- ]
-}
+ })
+ }
+
+ return baseRules
+})
function formatDate(dateStr: string): string {
return new Date(dateStr).toLocaleString('zh-CN')
@@ -268,8 +296,13 @@ async function handleSubmit() {
const newTotal = (distribution.value?.actualCompletion || 0) + form.actualCompletion
+ // 营部及以下级别的确认信息不显示总数
+ const confirmMessage = isBattalionOrBelow.value
+ ? `本次上报数量:${form.actualCompletion} ${allocation.value?.unit}\n\n确认提交吗?`
+ : `本次上报数量:${form.actualCompletion} ${allocation.value?.unit}\n上报后总数:${newTotal} ${allocation.value?.unit}\n\n确认提交吗?`
+
await ElMessageBox.confirm(
- `本次上报数量:${form.actualCompletion} ${allocation.value?.unit}\n上报后总数:${newTotal} ${allocation.value?.unit}\n\n确认提交吗?`,
+ confirmMessage,
'确认上报',
{
type: 'warning',