Commit ff9b810ecd54e30fab3f16312f7ef352ddf63e58
Merge branch 'zwl-develop' into 'develop'
feat: 保存按钮新增loading功能 See merge request !18
Showing
4 changed files
with
86 additions
and
59 deletions
src/views/project/finance/financeProfit/ProductProfit/InnerData/FinanceEdit.vue
... | ... | @@ -148,6 +148,7 @@ |
148 | 148 | input1.value = ''; |
149 | 149 | } |
150 | 150 | }); |
151 | + const loading = ref(false); | |
151 | 152 | const [register, { setDrawerProps, closeDrawer }] = useDrawerInner((data) => { |
152 | 153 | // 方式1 |
153 | 154 | if (data.data?.lockFields) { |
... | ... | @@ -162,6 +163,7 @@ |
162 | 163 | input3.value = data.data?.productionDepartmentPredictUnitPrice?.toFixed(2); |
163 | 164 | resetFields(); |
164 | 165 | setDrawerProps({ confirmLoading: false }); |
166 | + loading.value = false; | |
165 | 167 | // setFieldsValue({ |
166 | 168 | // ...toRaw(data.data), |
167 | 169 | // }); |
... | ... | @@ -169,24 +171,28 @@ |
169 | 171 | }); |
170 | 172 | //完成编辑 |
171 | 173 | async function handleSubmit() { |
172 | - // const values = await validate(); | |
173 | - // const updatedValues = { | |
174 | - // ...values, | |
175 | - // id: update.value.data.id, | |
176 | - // bgUrl: update.value.data.bgUrl, | |
177 | - // }; | |
174 | + if (loading.value) return; | |
175 | + loading.value = true; | |
176 | + setDrawerProps({ confirmLoading: true }); | |
178 | 177 | if (!input1.value || !input2.value || !input3.value) { |
179 | 178 | error('选项不能为空'); |
179 | + loading.value = false; | |
180 | + setDrawerProps({ confirmLoading: false }); | |
180 | 181 | } else { |
181 | - await getPackageEdit({ | |
182 | - orderId: id.value, | |
183 | - productionDepartmentPredictPrice: input1.value, | |
184 | - productionActualPrice: input2.value, | |
185 | - orderCount: orderCount.value, | |
186 | - productionDepartmentPredictUnitPrice: input3.value, | |
187 | - }); | |
188 | - emit('success'); | |
189 | - closeDrawer(); | |
182 | + try { | |
183 | + await getPackageEdit({ | |
184 | + orderId: id.value, | |
185 | + productionDepartmentPredictPrice: input1.value, | |
186 | + productionActualPrice: input2.value, | |
187 | + orderCount: orderCount.value, | |
188 | + productionDepartmentPredictUnitPrice: input3.value, | |
189 | + }); | |
190 | + emit('success'); | |
191 | + } finally { | |
192 | + loading.value = false; | |
193 | + setDrawerProps({ confirmLoading: false }); | |
194 | + closeDrawer(); | |
195 | + } | |
190 | 196 | } |
191 | 197 | } |
192 | 198 | function handleShow(visible: boolean) { | ... | ... |
src/views/project/finance/financeProfit/ProductProfit/InnerProduce/FinanceEdit.vue
... | ... | @@ -202,24 +202,29 @@ |
202 | 202 | }); |
203 | 203 | update.value = data; |
204 | 204 | }); |
205 | + const loading = ref(false); | |
205 | 206 | //完成编辑 |
206 | 207 | async function handleSubmit() { |
207 | - // const values = await validate(); | |
208 | - // const updatedValues = { | |
209 | - // ...values, | |
210 | - // id: update.value.data.id, | |
211 | - // bgUrl: update.value.data.bgUrl, | |
212 | - // }; | |
213 | - if (!input3.value || !input4.value) { | |
208 | + if (loading.value) return; | |
209 | + loading.value = true; | |
210 | + setDrawerProps({ confirmLoading: true }); | |
211 | + if (!input1.value || !input2.value || !input3.value) { | |
214 | 212 | error('选项不能为空'); |
213 | + loading.value = false; | |
214 | + setDrawerProps({ confirmLoading: false }); | |
215 | 215 | } else { |
216 | - await getServiceEdit({ | |
217 | - projectNoPrefix: id.value, | |
218 | - projectInnerProfitInfoStartTime: input3.value, | |
219 | - projectInnerProfitInfoEndTime: input4.value, | |
220 | - }); | |
221 | - emit('success'); | |
222 | - closeDrawer(); | |
216 | + try { | |
217 | + await getServiceEdit({ | |
218 | + projectNoPrefix: id.value, | |
219 | + projectInnerProfitInfoStartTime: input3.value, | |
220 | + projectInnerProfitInfoEndTime: input4.value, | |
221 | + }); | |
222 | + emit('success'); | |
223 | + } finally { | |
224 | + loading.value = false; | |
225 | + setDrawerProps({ confirmLoading: false }); | |
226 | + closeDrawer(); | |
227 | + } | |
223 | 228 | } |
224 | 229 | } |
225 | 230 | function handleShow(visible: boolean) { | ... | ... |
src/views/project/finance/financeProfit/ServiceProfit/PackageProfit/FinanceEdit.vue
... | ... | @@ -128,6 +128,7 @@ |
128 | 128 | const input1 = ref(); |
129 | 129 | const input2 = ref(); |
130 | 130 | const id = ref(); |
131 | + const loading = ref(false); | |
131 | 132 | const [register, { setDrawerProps, closeDrawer }] = useDrawerInner((data) => { |
132 | 133 | // 方式1 |
133 | 134 | if (data.data.lockFields) { |
... | ... | @@ -146,29 +147,33 @@ |
146 | 147 | }); |
147 | 148 | //完成编辑 |
148 | 149 | async function handleSubmit() { |
149 | - // const values = await validate(); | |
150 | - // const updatedValues = { | |
151 | - // ...values, | |
152 | - // id: update.value.data.id, | |
153 | - // bgUrl: update.value.data.bgUrl, | |
154 | - // }; | |
150 | + if (loading.value) return; | |
151 | + loading.value = true; | |
152 | + setDrawerProps({ confirmLoading: true }); | |
155 | 153 | if (!input1.value) { |
156 | 154 | error('包装费用实际金额不能为空'); |
157 | - } else{ | |
158 | - if(!input2.value){ | |
159 | - await getPackageEdit({ | |
160 | - orderId: id.value, | |
161 | - packetActualRmbTotalPrice: input1.value, | |
162 | - }); | |
163 | - }else{ | |
164 | - await getPackageEdit({ | |
165 | - orderId: id.value, | |
166 | - packetActualRmbTotalPrice: input1.value, | |
167 | - orderScore: Number(input2.value), | |
168 | - }); | |
155 | + loading.value = false; | |
156 | + setDrawerProps({ confirmLoading: false }); | |
157 | + } else { | |
158 | + try { | |
159 | + if (!input2.value) { | |
160 | + await getPackageEdit({ | |
161 | + orderId: id.value, | |
162 | + packetActualRmbTotalPrice: input1.value, | |
163 | + }); | |
164 | + } else { | |
165 | + await getPackageEdit({ | |
166 | + orderId: id.value, | |
167 | + packetActualRmbTotalPrice: input1.value, | |
168 | + orderScore: Number(input2.value), | |
169 | + }); | |
170 | + } | |
171 | + emit('success'); | |
172 | + } finally { | |
173 | + loading.value = false; | |
174 | + setDrawerProps({ confirmLoading: false }); | |
175 | + closeDrawer(); | |
169 | 176 | } |
170 | - emit('success'); | |
171 | - closeDrawer(); | |
172 | 177 | } |
173 | 178 | } |
174 | 179 | </script> | ... | ... |
src/views/project/finance/financeProfit/ServiceProfit/ServiceProfit/FinanceEdit.vue
... | ... | @@ -219,8 +219,12 @@ |
219 | 219 | }); |
220 | 220 | update.value = data; |
221 | 221 | }); |
222 | + const loading = ref(false); | |
222 | 223 | //完成编辑 |
223 | 224 | async function handleSubmit() { |
225 | + if (loading.value) return; | |
226 | + loading.value = true; | |
227 | + setDrawerProps({ confirmLoading: true }); | |
224 | 228 | // const values = await validate(); |
225 | 229 | // const updatedValues = { |
226 | 230 | // ...values, |
... | ... | @@ -229,17 +233,24 @@ |
229 | 233 | // }; |
230 | 234 | if (!input1.value || !input2.value || !input3.value || !input4.value) { |
231 | 235 | error('选项不能为空'); |
236 | + loading.value = false; | |
237 | + setDrawerProps({ confirmLoading: false }); | |
232 | 238 | } else { |
233 | - await getServiceEdit({ | |
234 | - projectNoPrefix: id.value, | |
235 | - developmentCopyRmbTotalPrice: input1.value, | |
236 | - spainPaidRmbCommission: input2.value, | |
237 | - projectStartTime: input3.value, | |
238 | - projectEndTime: input4.value, | |
239 | - paidRmbCommission: input5.value, | |
240 | - }); | |
241 | - emit('success'); | |
242 | - closeDrawer(); | |
239 | + try { | |
240 | + await getServiceEdit({ | |
241 | + projectNoPrefix: id.value, | |
242 | + developmentCopyRmbTotalPrice: input1.value, | |
243 | + spainPaidRmbCommission: input2.value, | |
244 | + projectStartTime: input3.value, | |
245 | + projectEndTime: input4.value, | |
246 | + paidRmbCommission: input5.value, | |
247 | + }); | |
248 | + emit('success'); | |
249 | + } finally { | |
250 | + loading.value = false; | |
251 | + setDrawerProps({ confirmLoading: false }); | |
252 | + closeDrawer(); | |
253 | + } | |
243 | 254 | } |
244 | 255 | } |
245 | 256 | function handleShow(visible: boolean) { | ... | ... |