|
@@ -2,7 +2,7 @@
|
2
|
2
|
* @Author: ysh
|
3
|
3
|
* @Date: 2025-02-20 10:20:22
|
4
|
4
|
* @LastEditors: Please set LastEditors
|
5
|
|
- * @LastEditTime: 2025-02-27 10:49:10
|
|
5
|
+ * @LastEditTime: 2025-03-03 11:02:06
|
6
|
6
|
-->
|
7
|
7
|
<template>
|
8
|
8
|
<view class="form-container">
|
|
@@ -33,25 +33,42 @@
|
33
|
33
|
<uni-data-checkbox v-model="form.borrowUsage" :localdata="borrowUsageOptions"></uni-data-checkbox>
|
34
|
34
|
</uni-forms-item>
|
35
|
35
|
|
36
|
|
- <!-- 借款类型 -->
|
|
36
|
+ <!-- 借款事由 -->
|
37
|
37
|
<uni-forms-item label="借款事由" required class="form-item" name="applyReason" v-if="form.borrowUsage != 0">
|
38
|
38
|
<uv-textarea v-model="form.applyReason" placeholder="请输入借款事由"></uv-textarea>
|
39
|
39
|
</uni-forms-item>
|
40
|
40
|
|
41
|
41
|
<!-- 选择项目 -->
|
42
|
42
|
<uni-forms-item label="选择项目" required class="form-item" v-if="form.borrowUsage == 0" name="projectId">
|
43
|
|
- <u-button type="primary" @click="openProject = true" v-if="taskName == '借款申请'">选择项目</u-button>
|
|
43
|
+ <u-button type="primary" @click="openProject = true" v-if="taskName == '借款申请'">+ 选择项目</u-button>
|
44
|
44
|
<ProjectPicker :visible.sync="openProject" :selected.sync="selectedProject" @confirm="handleConfirm" />
|
45
|
45
|
<ProjectInfo :project="projectObj"></ProjectInfo>
|
46
|
46
|
</uni-forms-item>
|
47
|
47
|
|
48
|
48
|
<!-- 借款明细 -->
|
49
|
49
|
<uni-forms-item label="借款明细" required class="form-item">
|
50
|
|
- <BorrowDetail :borrowId="form.borrowId"></BorrowDetail>
|
|
50
|
+ <BorrowDetail :borrowId="form.borrowId" :taskName="taskName" @getApplyAmount="setApplyAmount"></BorrowDetail>
|
51
|
51
|
</uni-forms-item>
|
52
|
52
|
|
53
|
|
- </uni-forms>
|
|
53
|
+ <uni-forms-item label="申请金额" class="form-item">
|
|
54
|
+ <view>{{ (this.form.applyAmount).toFixed(2) }}</view>
|
|
55
|
+ <view style="color:#E74C3C" v-if="exceed && form.borrowUsage == '0'">
|
|
56
|
+ 超过预算金额:{{ getMoreAmount('0') }}</view>
|
|
57
|
+ </uni-forms-item>
|
54
|
58
|
|
|
59
|
+ <uni-forms-item label="最大借款金额" class="form-item">
|
|
60
|
+ {{ totalBudget.toFixed(2) }}
|
|
61
|
+ </uni-forms-item>
|
|
62
|
+ <uni-forms-item label="已申请借款" class="form-item">
|
|
63
|
+ {{ hasBorrow.toFixed(2) }}
|
|
64
|
+ </uni-forms-item>
|
|
65
|
+ <uni-forms-item label="可用借款" class="form-item">
|
|
66
|
+ {{ (totalBudget - hasBorrow).toFixed(2) }}
|
|
67
|
+ </uni-forms-item>
|
|
68
|
+ <view>
|
|
69
|
+ <u-button type="primary" size="normal" @click="submit">提交申请</u-button>
|
|
70
|
+ </view>
|
|
71
|
+ </uni-forms>
|
55
|
72
|
|
56
|
73
|
</view>
|
57
|
74
|
</template>
|
|
@@ -62,6 +79,7 @@ import ProjectInfo from '@/pages/components/ProjectInfo.vue';
|
62
|
79
|
import { parseTime } from "@/utils/common.js"
|
63
|
80
|
import { listBorrow, getBorrow, delBorrow, addBorrow, updateBorrow } from "@/api/oa/borrow/borrow";
|
64
|
81
|
import { listProject, getProject } from "@/api/oa/project/project";
|
|
82
|
+import { listBudget } from "@/api/oa/budget/budget";
|
65
|
83
|
import BorrowDetail from './borrowDetail.vue';
|
66
|
84
|
export default {
|
67
|
85
|
components: {
|
|
@@ -85,6 +103,7 @@ export default {
|
85
|
103
|
form: {
|
86
|
104
|
submitTime: '',
|
87
|
105
|
borrowUsage: '0',
|
|
106
|
+ applyAmount: 0,
|
88
|
107
|
},
|
89
|
108
|
rules: {},
|
90
|
109
|
borrowUsageOptions: [{
|
|
@@ -113,11 +132,14 @@ export default {
|
113
|
132
|
selectedProject: null, //选中的项目
|
114
|
133
|
projectObj: {}, //项目信息的项目
|
115
|
134
|
fromTotal: 0,
|
|
135
|
+ totalBudget: 0, //预结算额
|
|
136
|
+ exceed: false, //是否超预算
|
|
137
|
+ hasBorrow: 0, //已申请借款
|
116
|
138
|
}
|
117
|
139
|
},
|
118
|
140
|
methods: {
|
119
|
|
- initForm() {
|
120
|
|
- getBorrow(this.taskForm.formId).then(res => {
|
|
141
|
+ async initForm() {
|
|
142
|
+ getBorrow(this.taskForm.formId).then(async res => {
|
121
|
143
|
if (res.data) {
|
122
|
144
|
this.fromTotal = 1;
|
123
|
145
|
this.form = res.data;
|
|
@@ -129,6 +151,37 @@ export default {
|
129
|
151
|
this.projectObj = res.data;
|
130
|
152
|
}
|
131
|
153
|
})
|
|
154
|
+ let budgetData = await listBudget({ projectId: this.form.projectId })
|
|
155
|
+ if (budgetData.total == 1) {
|
|
156
|
+ let budget = budgetData.rows[0];
|
|
157
|
+ this.totalBudget = budget.settleExpense
|
|
158
|
+ } else if (budgetData.total == 0) {
|
|
159
|
+ this.totalBudget = 0
|
|
160
|
+ }
|
|
161
|
+ if (this.form.borrowUsage == '0') {
|
|
162
|
+ if ((this.totalBudget - this.form.applyAmount) < 0) {
|
|
163
|
+ this.exceed = true;
|
|
164
|
+ } else {
|
|
165
|
+ this.exceed = false;
|
|
166
|
+ }
|
|
167
|
+ } else {
|
|
168
|
+ this.exceed = false;
|
|
169
|
+ }
|
|
170
|
+ let borrow = await listBorrow({ projectId: this.form.projectId })
|
|
171
|
+ if (borrow.total != 0) {
|
|
172
|
+ let borrowList = borrow.rows;
|
|
173
|
+ let hasBorrow = 0;
|
|
174
|
+ borrowList = borrowList.filter(item => item.borrowId != this.taskForm.formId)
|
|
175
|
+ borrowList.forEach(element => {
|
|
176
|
+ if (element.managerAmount) {
|
|
177
|
+ hasBorrow = hasBorrow + element.managerAmount
|
|
178
|
+ }
|
|
179
|
+ if (!element.managerAmount && element.applyAmount) {
|
|
180
|
+ hasBorrow = hasBorrow + element.applyAmount
|
|
181
|
+ }
|
|
182
|
+ });
|
|
183
|
+ this.hasBorrow = hasBorrow
|
|
184
|
+ }
|
132
|
185
|
}
|
133
|
186
|
} else {
|
134
|
187
|
this.fromTotal = 0;
|
|
@@ -136,12 +189,35 @@ export default {
|
136
|
189
|
this.form.applyDate = parseTime(new Date(), "{y}-{m}-{d}");
|
137
|
190
|
}
|
138
|
191
|
})
|
|
192
|
+
|
|
193
|
+ },
|
|
194
|
+ // 计算超过预算的金额
|
|
195
|
+ getMoreAmount(type) {
|
|
196
|
+ let result;
|
|
197
|
+ if (type == '0') {
|
|
198
|
+ result = this.form.applyAmount - (this.totalBudget - this.hasBorrow);
|
|
199
|
+ } else {
|
|
200
|
+ result = this.form.managerAmount - (this.totalBudget - this.hasBorrow);
|
|
201
|
+ }
|
|
202
|
+ return result.toFixed(2)
|
|
203
|
+ },
|
|
204
|
+ setApplyAmount(val) {
|
|
205
|
+ console.log(val);
|
|
206
|
+ console.log(this.from);
|
|
207
|
+ this.form.applyAmount = val
|
139
|
208
|
},
|
140
|
209
|
handleConfirm(project) {
|
141
|
210
|
console.log('选中的项目:', project);
|
142
|
211
|
this.selectedProject = project;
|
143
|
212
|
this.projectObj = project;
|
144
|
213
|
},
|
|
214
|
+ submit() {
|
|
215
|
+ this.$refs.form.validate().then(res => {
|
|
216
|
+ console.log('表单数据信息:', res);
|
|
217
|
+ }).catch(err => {
|
|
218
|
+ console.log('表单错误信息:', err);
|
|
219
|
+ })
|
|
220
|
+ }
|
145
|
221
|
},
|
146
|
222
|
}
|
147
|
223
|
</script>
|