1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<template>
<div>
<a-row>
<a-col :span="24">
<div class="tb-title">
<span>项目经费 <strong>(单位:万元)</strong></span>
</div>
</a-col>
</a-row>
<a-row>
<a-col :span="6" class="bg-gray">
预算科目
</a-col>
<a-col :span="3" class="bg-gray">
总预算数
</a-col>
<a-col :span="5" class="bg-gray">
市卫健委科技经费
</a-col>
<a-col :span="5" class="bg-gray">
单位自筹经费
</a-col>
<a-col :span="5" class="bg-gray">
备注
</a-col>
</a-row>
<template v-for="(item, index) in budget">
<a-row :key="'budget' + index" v-if="item.type ==='count'">
<a-col :span="6">
{{item.budgetName}}
</a-col>
<a-col :span="3">
{{Count(item.source,'totalBudget',index)}}
</a-col>
<a-col :span="5">
{{Count(item.source,'govBudget',index)}}
</a-col>
<a-col :span="5">
{{Count(item.source,'unitBudget',index)}}
</a-col>
<a-col :span="5">
<a-input v-model="item.remark" :maxLength="100" style="width: 80%;" />
</a-col>
</a-row>
<a-row :key="'budget' + index" v-else>
<a-col :span="6">
{{item.budgetName}}
</a-col>
<a-col :span="3">
{{Count1(index, item.govBudget, item.unitBudget)}}
</a-col>
<a-col :span="5">
<a-input-number v-model="item.govBudget" :min="0" :step="0.01" style="width: 80%" :disabled="item.disabled === 'unitBudget'" />
</a-col>
<a-col :span="5">
<a-input-number v-model="item.unitBudget" :min="0" :step="0.01" style="width: 80%" :disabled="item.disabled === 'govBudget'" />
</a-col>
<a-col :span="5">
<a-input v-model="item.remark" :maxLength="100" style="width: 80%;" />
</a-col>
</a-row>
</template>
</div>
</template>
<script>
// 用法 <budget-edit :budget.sync="formData.budget" />
export default {
name: "BudgetEdit",
data() {
return {
// budget: this.value,
};
},
props: {
budget: {
type: Array,
default: () => {
return []
}
},
},
created() {
},
methods: {
// 计算经费合计数值
Count(source, type, index) {
if (!source || !source.length) {
return 0
}
let govBudget = 0, unitBudget = 0
source.forEach(i => {
govBudget = govBudget + this.budget[i].govBudget
unitBudget = unitBudget + this.budget[i].unitBudget
})
if (type === 'govBudget') {
this.budget[index].govBudget = govBudget.toFixed(2)
return govBudget.toFixed(2)
} else if (type === 'unitBudget') {
this.budget[index].unitBudget = unitBudget.toFixed(2)
return unitBudget.toFixed(2)
} else {
this.budget[index].totalBudget = (govBudget + unitBudget).toFixed(2)
return (govBudget + unitBudget).toFixed(2)
}
},
Count1(index, govBudget, unitBudget) {
this.budget[index].totalBudget = (govBudget + unitBudget).toFixed(2)
return (govBudget + unitBudget).toFixed(2)
}
},
};
</script>