|
@@ -3,43 +3,141 @@
|
|
|
<div class="service-form">
|
|
<div class="service-form">
|
|
|
<div class="service-form-title">服务报价</div>
|
|
<div class="service-form-title">服务报价</div>
|
|
|
<el-form ref="formRef" :model="form" label-width="86px">
|
|
<el-form ref="formRef" :model="form" label-width="86px">
|
|
|
- <el-form-item label="人工服务" prop="manual" class="input-unit">
|
|
|
|
|
- <el-input v-if="isEdit" v-model.number="form.manual" placeholder="请输入数字">
|
|
|
|
|
|
|
+ <el-form-item label="人工服务" prop="manualServicePrice" class="input-unit">
|
|
|
|
|
+ <el-input v-if="isEdit" v-model.number="form.manualServicePrice" placeholder="请输入数字">
|
|
|
<template #append>元/亩</template>
|
|
<template #append>元/亩</template>
|
|
|
</el-input>
|
|
</el-input>
|
|
|
- <div v-else class="service-form-value">12<span class="unit">元/亩</span></div>
|
|
|
|
|
|
|
+ <div v-else class="service-form-value">
|
|
|
|
|
+ {{ form.manualServicePrice || "--" }}<span class="unit" v-if="form.manualServicePrice">元/亩</span>
|
|
|
|
|
+ </div>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
- <el-form-item label="无人机服务" prop="drone" class="input-unit">
|
|
|
|
|
- <el-input v-if="isEdit" v-model.number="form.drone" placeholder="请输入数字">
|
|
|
|
|
|
|
+ <el-form-item label="无人机服务" prop="uavServicePrice" class="input-unit">
|
|
|
|
|
+ <el-input v-if="isEdit" v-model.number="form.uavServicePrice" placeholder="请输入数字">
|
|
|
<template #append>元/亩</template>
|
|
<template #append>元/亩</template>
|
|
|
</el-input>
|
|
</el-input>
|
|
|
- <div v-else class="service-form-value">120<span class="unit">元/亩</span></div>
|
|
|
|
|
|
|
+ <div v-else class="service-form-value">
|
|
|
|
|
+ {{ form.uavServicePrice || "--" }}<span class="unit" v-if="form.uavServicePrice">元/亩</span>
|
|
|
|
|
+ </div>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
</el-form>
|
|
</el-form>
|
|
|
</div>
|
|
</div>
|
|
|
<div class="page-action" v-if="isEdit">
|
|
<div class="page-action" v-if="isEdit">
|
|
|
- <div class="btn-item cancel" @click="isEdit = false">取消</div>
|
|
|
|
|
|
|
+ <div class="btn-item cancel" @click="handleCancel">取消</div>
|
|
|
<div class="btn-right">
|
|
<div class="btn-right">
|
|
|
- <div class="btn-item primary" @click="isEdit = false">保存服务报价</div>
|
|
|
|
|
|
|
+ <div class="btn-item primary" @click="handleSave">保存服务报价</div>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
<div class="page-action" v-else>
|
|
<div class="page-action" v-else>
|
|
|
- <div class="btn-item primary center-btn" @click="isEdit = true">编辑服务报价</div>
|
|
|
|
|
|
|
+ <div class="btn-item primary center-btn" @click="handleEdit">编辑服务报价</div>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
|
-import { ref, reactive } from "vue";
|
|
|
|
|
|
|
+import { ref, reactive, onMounted, onActivated } from "vue";
|
|
|
|
|
+import { ElMessage } from "element-plus";
|
|
|
|
|
|
|
|
// 表单模型与选项
|
|
// 表单模型与选项
|
|
|
const formRef = ref();
|
|
const formRef = ref();
|
|
|
const form = reactive({
|
|
const form = reactive({
|
|
|
- manual: "",
|
|
|
|
|
- drone: "",
|
|
|
|
|
|
|
+ manualServicePrice: null,
|
|
|
|
|
+ uavServicePrice: null,
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
|
|
+// 保存原始值,用于取消编辑时恢复
|
|
|
|
|
+const originalForm = reactive({
|
|
|
|
|
+ manualServicePrice: null,
|
|
|
|
|
+ uavServicePrice: null,
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
const isEdit = ref(false);
|
|
const isEdit = ref(false);
|
|
|
|
|
+const loading = ref(false);
|
|
|
|
|
+
|
|
|
|
|
+// 获取服务报价
|
|
|
|
|
+const getServicePrice = () => {
|
|
|
|
|
+ loading.value = true;
|
|
|
|
|
+ VE_API.z_agricultural_store
|
|
|
|
|
+ .service_price()
|
|
|
|
|
+ .then((res) => {
|
|
|
|
|
+ if (res.code === 0 && res.data) {
|
|
|
|
|
+ form.manualServicePrice = res.data.manualServicePrice || null;
|
|
|
|
|
+ form.uavServicePrice = res.data.uavServicePrice || null;
|
|
|
|
|
+ // 保存原始值
|
|
|
|
|
+ originalForm.manualServicePrice = res.data.manualServicePrice || null;
|
|
|
|
|
+ originalForm.uavServicePrice = res.data.uavServicePrice || null;
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch((error) => {
|
|
|
|
|
+ console.error("获取服务报价失败:", error);
|
|
|
|
|
+ ElMessage.error("获取服务报价失败");
|
|
|
|
|
+ })
|
|
|
|
|
+ .finally(() => {
|
|
|
|
|
+ loading.value = false;
|
|
|
|
|
+ });
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+// 保存服务报价
|
|
|
|
|
+const handleSave = () => {
|
|
|
|
|
+ // 表单验证
|
|
|
|
|
+ if (form.manualServicePrice === null || form.manualServicePrice === "" || form.uavServicePrice === null || form.uavServicePrice === "") {
|
|
|
|
|
+ ElMessage.warning("请填写完整信息");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (form.manualServicePrice < 0 || form.uavServicePrice < 0) {
|
|
|
|
|
+ ElMessage.warning("价格不能为负数");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ loading.value = true;
|
|
|
|
|
+ VE_API.z_agricultural_store
|
|
|
|
|
+ .updatePrice({
|
|
|
|
|
+ manualServicePrice: form.manualServicePrice,
|
|
|
|
|
+ uavServicePrice: form.uavServicePrice,
|
|
|
|
|
+ })
|
|
|
|
|
+ .then((res) => {
|
|
|
|
|
+ if (res.code === 0) {
|
|
|
|
|
+ ElMessage.success("保存成功");
|
|
|
|
|
+ // 更新原始值
|
|
|
|
|
+ originalForm.manualServicePrice = form.manualServicePrice;
|
|
|
|
|
+ originalForm.uavServicePrice = form.uavServicePrice;
|
|
|
|
|
+ // 退出编辑模式
|
|
|
|
|
+ isEdit.value = false;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ ElMessage.error(res.message || "保存失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch((error) => {
|
|
|
|
|
+ console.error("保存失败:", error);
|
|
|
|
|
+ ElMessage.error("保存失败,请重试");
|
|
|
|
|
+ })
|
|
|
|
|
+ .finally(() => {
|
|
|
|
|
+ loading.value = false;
|
|
|
|
|
+ });
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+// 取消编辑
|
|
|
|
|
+const handleCancel = () => {
|
|
|
|
|
+ // 恢复原始值
|
|
|
|
|
+ form.manualServicePrice = originalForm.manualServicePrice;
|
|
|
|
|
+ form.uavServicePrice = originalForm.uavServicePrice;
|
|
|
|
|
+ // 退出编辑模式
|
|
|
|
|
+ isEdit.value = false;
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+// 进入编辑模式
|
|
|
|
|
+const handleEdit = () => {
|
|
|
|
|
+ isEdit.value = true;
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+onMounted(() => {
|
|
|
|
|
+ getServicePrice();
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
|
|
+onActivated(() => {
|
|
|
|
|
+ // 页面激活时重新获取数据
|
|
|
|
|
+ getServicePrice();
|
|
|
|
|
+});
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|