Commit 7215508b0a6cf908f850ba4b672da2aa620953b2

Authored by
1 parent 45055645

feat: 保存按钮新增loading功能

src/views/project/finance/financeProfit/ProductProfit/InnerData/FinanceEdit.vue
@@ -148,6 +148,7 @@ @@ -148,6 +148,7 @@
148 input1.value = ''; 148 input1.value = '';
149 } 149 }
150 }); 150 });
  151 + const loading = ref(false);
151 const [register, { setDrawerProps, closeDrawer }] = useDrawerInner((data) => { 152 const [register, { setDrawerProps, closeDrawer }] = useDrawerInner((data) => {
152 // 方式1 153 // 方式1
153 if (data.data?.lockFields) { 154 if (data.data?.lockFields) {
@@ -162,6 +163,7 @@ @@ -162,6 +163,7 @@
162 input3.value = data.data?.productionDepartmentPredictUnitPrice?.toFixed(2); 163 input3.value = data.data?.productionDepartmentPredictUnitPrice?.toFixed(2);
163 resetFields(); 164 resetFields();
164 setDrawerProps({ confirmLoading: false }); 165 setDrawerProps({ confirmLoading: false });
  166 + loading.value = false;
165 // setFieldsValue({ 167 // setFieldsValue({
166 // ...toRaw(data.data), 168 // ...toRaw(data.data),
167 // }); 169 // });
@@ -169,24 +171,28 @@ @@ -169,24 +171,28 @@
169 }); 171 });
170 //完成编辑 172 //完成编辑
171 async function handleSubmit() { 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 if (!input1.value || !input2.value || !input3.value) { 177 if (!input1.value || !input2.value || !input3.value) {
179 error('选项不能为空'); 178 error('选项不能为空');
  179 + loading.value = false;
  180 + setDrawerProps({ confirmLoading: false });
180 } else { 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 function handleShow(visible: boolean) { 198 function handleShow(visible: boolean) {
src/views/project/finance/financeProfit/ProductProfit/InnerProduce/FinanceEdit.vue
@@ -202,24 +202,29 @@ @@ -202,24 +202,29 @@
202 }); 202 });
203 update.value = data; 203 update.value = data;
204 }); 204 });
  205 + const loading = ref(false);
205 //完成编辑 206 //完成编辑
206 async function handleSubmit() { 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 error('选项不能为空'); 212 error('选项不能为空');
  213 + loading.value = false;
  214 + setDrawerProps({ confirmLoading: false });
215 } else { 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 function handleShow(visible: boolean) { 230 function handleShow(visible: boolean) {
src/views/project/finance/financeProfit/ServiceProfit/PackageProfit/FinanceEdit.vue
@@ -128,6 +128,7 @@ @@ -128,6 +128,7 @@
128 const input1 = ref(); 128 const input1 = ref();
129 const input2 = ref(); 129 const input2 = ref();
130 const id = ref(); 130 const id = ref();
  131 + const loading = ref(false);
131 const [register, { setDrawerProps, closeDrawer }] = useDrawerInner((data) => { 132 const [register, { setDrawerProps, closeDrawer }] = useDrawerInner((data) => {
132 // 方式1 133 // 方式1
133 if (data.data.lockFields) { 134 if (data.data.lockFields) {
@@ -146,29 +147,33 @@ @@ -146,29 +147,33 @@
146 }); 147 });
147 //完成编辑 148 //完成编辑
148 async function handleSubmit() { 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 if (!input1.value) { 153 if (!input1.value) {
156 error('包装费用实际金额不能为空'); 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 </script> 179 </script>
src/views/project/finance/financeProfit/ServiceProfit/ServiceProfit/FinanceEdit.vue
@@ -219,8 +219,12 @@ @@ -219,8 +219,12 @@
219 }); 219 });
220 update.value = data; 220 update.value = data;
221 }); 221 });
  222 + const loading = ref(false);
222 //完成编辑 223 //完成编辑
223 async function handleSubmit() { 224 async function handleSubmit() {
  225 + if (loading.value) return;
  226 + loading.value = true;
  227 + setDrawerProps({ confirmLoading: true });
224 // const values = await validate(); 228 // const values = await validate();
225 // const updatedValues = { 229 // const updatedValues = {
226 // ...values, 230 // ...values,
@@ -229,17 +233,24 @@ @@ -229,17 +233,24 @@
229 // }; 233 // };
230 if (!input1.value || !input2.value || !input3.value || !input4.value) { 234 if (!input1.value || !input2.value || !input3.value || !input4.value) {
231 error('选项不能为空'); 235 error('选项不能为空');
  236 + loading.value = false;
  237 + setDrawerProps({ confirmLoading: false });
232 } else { 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 function handleShow(visible: boolean) { 256 function handleShow(visible: boolean) {