|
@@ -364,7 +364,7 @@
|
|
|
<div class="submit-btn" :class="{ 'center-btn': onlyPrice || defaultTagName === 0 }">
|
|
<div class="submit-btn" :class="{ 'center-btn': onlyPrice || defaultTagName === 0 }">
|
|
|
<!-- <div v-if="!onlyPrice" class="btn second" @click.prevent="cancelEdit">取消编辑</div> -->
|
|
<!-- <div v-if="!onlyPrice" class="btn second" @click.prevent="cancelEdit">取消编辑</div> -->
|
|
|
<div v-if="!onlyPrice && defaultTagName !== 0" class="btn second" @click.prevent="handleCancelAttention">取消关注</div>
|
|
<div v-if="!onlyPrice && defaultTagName !== 0" class="btn second" @click.prevent="handleCancelAttention">取消关注</div>
|
|
|
- <div class="btn" @click.prevent="submitForm(formRef)">保存</div>
|
|
|
|
|
|
|
+ <div class="btn" :style="{ opacity: isSaving ? 0.8 : 1 }" @click.prevent="submitForm(formRef)">{{ isSaving ? '保存中...' : '保存' }}</div>
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
@@ -577,6 +577,8 @@ const noPrice = ref(false);
|
|
|
const isDefault = ref(false);
|
|
const isDefault = ref(false);
|
|
|
// 是否在完善信息弹窗中
|
|
// 是否在完善信息弹窗中
|
|
|
const isDoingComplete = ref(false);
|
|
const isDoingComplete = ref(false);
|
|
|
|
|
+// 是否正在保存
|
|
|
|
|
+const isSaving = ref(false);
|
|
|
|
|
|
|
|
const showCompletePopup = ref(false);
|
|
const showCompletePopup = ref(false);
|
|
|
onActivated(() => {
|
|
onActivated(() => {
|
|
@@ -1231,31 +1233,39 @@ const validatePriceInfos = () => {
|
|
|
return true;
|
|
return true;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-const submit = () => {
|
|
|
|
|
- const data = {
|
|
|
|
|
- id: route.query.farmWorkId,
|
|
|
|
|
- ...dynamicValidateForm,
|
|
|
|
|
- serviceMuPrice: servicePricePerMu.value,
|
|
|
|
|
- prescription: dynamicValidateForm.prescription
|
|
|
|
|
- };
|
|
|
|
|
- VE_API.monitor.saveFarmWorkLib(data);
|
|
|
|
|
|
|
+const submit = async () => {
|
|
|
|
|
+ // 设置保存状态
|
|
|
|
|
+ isSaving.value = true;
|
|
|
|
|
|
|
|
- if (!onlyPrice.value) {
|
|
|
|
|
- handleSaveInteract();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 保存报价信息
|
|
|
|
|
- const priceList = {
|
|
|
|
|
- schemeId: detailData.value.schemeId,
|
|
|
|
|
- pesticideFertilizerInfos: dynamicValidateForm.prescription.pesticideFertilizerList.map(item => {
|
|
|
|
|
- return {
|
|
|
|
|
- pesticideFertilizerId: item.id,
|
|
|
|
|
- price: item.price,
|
|
|
|
|
- brand: item.brand,
|
|
|
|
|
- }
|
|
|
|
|
- }),
|
|
|
|
|
- }
|
|
|
|
|
- VE_API.farm.updateBatchByScheme(priceList).then(async (res) => {
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ const data = {
|
|
|
|
|
+ id: route.query.farmWorkId,
|
|
|
|
|
+ ...dynamicValidateForm,
|
|
|
|
|
+ serviceMuPrice: servicePricePerMu.value,
|
|
|
|
|
+ prescription: dynamicValidateForm.prescription
|
|
|
|
|
+ };
|
|
|
|
|
+ await VE_API.monitor.saveFarmWorkLib(data);
|
|
|
|
|
+
|
|
|
|
|
+ if (!onlyPrice.value) {
|
|
|
|
|
+ await handleSaveInteract();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 保存报价信息
|
|
|
|
|
+ const priceList = {
|
|
|
|
|
+ schemeId: detailData.value.schemeId,
|
|
|
|
|
+ pesticideFertilizerInfos: dynamicValidateForm.prescription.pesticideFertilizerList.map(item => {
|
|
|
|
|
+ return {
|
|
|
|
|
+ pesticideFertilizerId: item.id,
|
|
|
|
|
+ price: item.price,
|
|
|
|
|
+ brand: item.brand,
|
|
|
|
|
+ }
|
|
|
|
|
+ }),
|
|
|
|
|
+ }
|
|
|
|
|
+ const res = await VE_API.farm.updateBatchByScheme(priceList);
|
|
|
|
|
+
|
|
|
|
|
+ // 切换标记
|
|
|
|
|
+ await VE_API.container_farm_work_arrange.toggleFollow({ id: route.query.id, isFollow: tagName.value });
|
|
|
|
|
+
|
|
|
if (res.code === 0) {
|
|
if (res.code === 0) {
|
|
|
await getDetail();
|
|
await getDetail();
|
|
|
if (isDoingComplete.value) {
|
|
if (isDoingComplete.value) {
|
|
@@ -1298,11 +1308,13 @@ const submit = () => {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- }).catch(() => {
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- // 切换标记
|
|
|
|
|
- VE_API.container_farm_work_arrange.toggleFollow({ id: route.query.id, isFollow: tagName.value });
|
|
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error("保存失败:", error);
|
|
|
|
|
+ ElMessage.error("保存失败,请重试");
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ // 无论成功或失败,都要关闭保存状态
|
|
|
|
|
+ isSaving.value = false;
|
|
|
|
|
+ }
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const handleSaveInteractSuccess = () => {
|
|
const handleSaveInteractSuccess = () => {
|