|
|
@@ -1,7 +1,7 @@
|
|
|
<template>
|
|
|
<div class="new-farming-page">
|
|
|
<custom-header name="编辑方案"></custom-header>
|
|
|
- <div class="new-farming-content">
|
|
|
+ <div class="new-farming-content" v-loading="loading">
|
|
|
<el-form
|
|
|
ref="formRef"
|
|
|
style="max-width: 600px"
|
|
|
@@ -11,16 +11,16 @@
|
|
|
class="demo-dynamic"
|
|
|
>
|
|
|
<div class="farm-card" v-if="!isAdd">
|
|
|
- <div class="card-title">{{ detailData?.farmWorkName }}<span class="type-tag">标准农事</span></div>
|
|
|
+ <div class="card-title">{{ detailData?.farmWorkLib?.farmWorkName || detailData?.farmWorkLib?.name }}<span class="type-tag">标准农事</span></div>
|
|
|
<div class="info-content">
|
|
|
<el-form-item label-width="70px" class="form-item text-item" label="农事编号">
|
|
|
<div class="info-text">
|
|
|
- {{ detailData?.code }}
|
|
|
+ {{ detailData?.farmWorkLib?.code }}
|
|
|
</div>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label-width="70px" class="form-item" prop="conditionRate" label="触发条件">
|
|
|
+ <el-form-item label-width="70px" class="form-item" prop="condition" label="触发条件">
|
|
|
<div class="condition-wrap">
|
|
|
- {{ detailData?.condition }}
|
|
|
+ {{ detailData?.farmWorkLib?.condition }}
|
|
|
<!-- <el-select v-model="dynamicValidateForm.condition" placeholder="请选择触发条件" style="width: 58%">
|
|
|
<el-option v-for="(item, index) in farmWorkIndexNameList" :key="index" :value="item" :label="item" />
|
|
|
</el-select>
|
|
|
@@ -49,61 +49,7 @@
|
|
|
</el-form-item>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <template v-else>
|
|
|
- <div class="farm-card progress">
|
|
|
- <span class="progress-title">农事进度</span>
|
|
|
- <el-radio-group v-model="farmProgress">
|
|
|
- <el-radio :value="0">已做</el-radio>
|
|
|
- <el-radio :value="1">未做</el-radio>
|
|
|
- </el-radio-group>
|
|
|
- </div>
|
|
|
- <div class="farm-card" v-if="farmProgress === 0">
|
|
|
- <div class="card-title">基本信息</div>
|
|
|
- <div class="info-content">
|
|
|
- <el-form-item label-width="82px" class="form-item" prop="farmWorkName" label="农事名称">
|
|
|
- <el-select v-model="dynamicValidateForm.farmWorkName" placeholder="请选择农事名称" style="width: 100%">
|
|
|
- <el-option v-for="(item, index) in farmWorkNameList" :key="index" :value="item" :label="item" />
|
|
|
- </el-select>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label-width="82px" class="form-item" prop="name" label="农事目的">
|
|
|
- <el-input
|
|
|
- v-model="dynamicValidateForm.purpose"
|
|
|
- style="width: 100%"
|
|
|
- :rows="2"
|
|
|
- type="textarea"
|
|
|
- placeholder="请输入农事目的"
|
|
|
- />
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label-width="82px" class="form-item" prop="conditionRate" label="执行时间">
|
|
|
- <el-date-picker
|
|
|
- v-model="dynamicValidateForm.checkDay"
|
|
|
- value-format="YYYY-MM-DD"
|
|
|
- type="date"
|
|
|
- placeholder="请选择执行时间"
|
|
|
- style="width: 100%"
|
|
|
- />
|
|
|
- </el-form-item>
|
|
|
- <!-- <el-form-item label-width="82px" class="form-item" prop="conditionRate" label="触发条件">
|
|
|
- <div class="condition-wrap">
|
|
|
- <el-select v-model="dynamicValidateForm.condition" placeholder="请选择触发条件" style="width: 58%">
|
|
|
- <el-option v-for="(item, index) in farmWorkIndexNameList" :key="index" :value="item" :label="item" />
|
|
|
- </el-select>
|
|
|
- <span class="symbol"></span>
|
|
|
- <el-select v-model="dynamicValidateForm.conditionRate" placeholder="请选择" style="width: 38%">
|
|
|
- <el-option :value="0" label="0%" />
|
|
|
- <el-option :value="5" label="5%" />
|
|
|
- <el-option :value="10" label="10%" />
|
|
|
- <el-option :value="20" label="20%" />
|
|
|
- <el-option :value="40" label="40%" />
|
|
|
- <el-option :value="60" label="60%" />
|
|
|
- <el-option :value="80" label="80%" />
|
|
|
- </el-select>
|
|
|
- </div>
|
|
|
- </el-form-item> -->
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- <div class="farm-card prescription-content" v-if="farmProgress === 0">
|
|
|
+ <div class="farm-card prescription-content">
|
|
|
<div class="card-title pb-12">药物处方</div>
|
|
|
<el-form-item label-width="82px" class="form-item" prop="usageMode" label="施用方式">
|
|
|
<el-select v-model="dynamicValidateForm.usageMode" placeholder="请选择施用方式" style="width: 100%">
|
|
|
@@ -163,7 +109,7 @@
|
|
|
<el-option
|
|
|
v-for="item in pesticideFertilizersOptions"
|
|
|
:key="item.pesticideFertilizerCode"
|
|
|
- :label="item.defaultName"
|
|
|
+ :label="item.defaultName || item.name"
|
|
|
:value="item.pesticideFertilizerCode"
|
|
|
/>
|
|
|
</el-select>
|
|
|
@@ -284,60 +230,19 @@
|
|
|
</el-form-item>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div class="farm-card progress" v-else>
|
|
|
- <div class="situation-description">
|
|
|
- <div class="description-title">状况描述</div>
|
|
|
- <div class="description-content">
|
|
|
- <el-input
|
|
|
- v-model="situationDescription"
|
|
|
- type="textarea"
|
|
|
- :rows="3"
|
|
|
- placeholder="请输入目前农场状况"
|
|
|
- class="description-textarea"
|
|
|
- />
|
|
|
- <div class="upload-section">
|
|
|
- <el-button class="upload-btn" @click="handleUploadImage">
|
|
|
- <el-icon><Upload /></el-icon>
|
|
|
- 上传图片
|
|
|
- </el-button>
|
|
|
- <div class="upload-tip">上传图片,专家诊断更清晰</div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-
|
|
|
|
|
|
<div class="submit-btn" v-if="isEdit">
|
|
|
<div class="btn second" @click.prevent="cancelEdit">取消编辑</div>
|
|
|
<div class="btn" @click.prevent="submitForm(formRef)">保存方案</div>
|
|
|
</div>
|
|
|
- <div class="submit-btn" v-if="!isAdd && !isEdit">
|
|
|
- <div class="btn second" @click="handleIgnore">忽略</div>
|
|
|
- <div class="btn" @click.prevent="submitForm(formRef)">下发农事</div>
|
|
|
- </div>
|
|
|
- <div class="submit-btn" v-if="isAdd && farmProgress === 0">
|
|
|
- <div class="btn second">取消</div>
|
|
|
- <div class="btn" @click.prevent="submitForm(formRef)">确定新增</div>
|
|
|
- </div>
|
|
|
- <div v-if="isAdd && farmProgress === 1">
|
|
|
- <div class="expert-diagnosis-btn" @click="handleExpertDiagnosis">邀请专家诊断</div>
|
|
|
- </div>
|
|
|
</el-form>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
<popup v-model:show="showTaskPopup" round class="task-tips-popup">
|
|
|
- <template v-if="taskPopupType === 'warning'">
|
|
|
- <img class="create-farm-icon" src="@/assets/img/home/create-farm-icon.png" alt="" />
|
|
|
- <div class="create-farm-text">
|
|
|
- <div>您确认忽略 <span class="main-text">{{ detailData?.farmName }}</span> 的 <span class="main-text">{{ detailData?.farmWorkName }}</span> 农事吗</div>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- <template v-else>
|
|
|
- <img class="farm-check-icon" src="@/assets/img/home/right.png" alt="">
|
|
|
- <div class="create-farm-text success-text">方案已保存成功</div>
|
|
|
- </template>
|
|
|
- <div class="create-farm-btn" @click="handlePopupBtn">{{ taskPopupType === 'warning' ? '确认忽略' : '我知道了' }}</div>
|
|
|
+ <img class="farm-check-icon" src="@/assets/img/home/right.png" alt="">
|
|
|
+ <div class="create-farm-text success-text">方案已保存成功</div>
|
|
|
+ <div class="create-farm-btn" @click="handlePopupBtn">我知道了</div>
|
|
|
</popup>
|
|
|
</template>
|
|
|
|
|
|
@@ -348,9 +253,6 @@ import { ElMessage ,ElMessageBox} from "element-plus";
|
|
|
import customHeader from "@/components/customHeader.vue";
|
|
|
import { useStore } from "vuex";
|
|
|
import { Popup } from "vant";
|
|
|
-import farmSteps from "@/components/farmSteps.vue";
|
|
|
-import { base_img_url2 } from "@/api/config";
|
|
|
-import { formatArea } from "@/common/commonFun";
|
|
|
import dayjs from "dayjs";
|
|
|
const store = useStore();
|
|
|
const router = useRouter();
|
|
|
@@ -365,36 +267,36 @@ const actionType = ref([]);
|
|
|
const isAdd = ref(false)
|
|
|
|
|
|
const showTaskPopup = ref(false);
|
|
|
-const taskPopupType = ref('warning');
|
|
|
+const loading = ref(false);
|
|
|
|
|
|
const isEdit = ref(false)
|
|
|
isAdd.value = route.query.isAdd ? true : false
|
|
|
isEdit.value = route.query.isEdit ? true : false
|
|
|
onMounted(() => {
|
|
|
- const id = route.query.id;
|
|
|
- if (id) {
|
|
|
- getDetail(id);
|
|
|
- }
|
|
|
window.scrollTo(0, 0);
|
|
|
- getFarmWorkNameList();
|
|
|
- getFarmWorkIndexNameList();
|
|
|
- if (route.query.data) {
|
|
|
- actionType.value = JSON.parse(route.query.data);
|
|
|
- } else {
|
|
|
- actionType.value = ["生长异常"];
|
|
|
+ console.log('route.query', route.query);
|
|
|
+ const arrangeId = route.query.arrangeId;
|
|
|
+ if (arrangeId) {
|
|
|
+ getArrangeDetail(arrangeId);
|
|
|
}
|
|
|
- const planData = JSON.parse(route.query.planData);
|
|
|
- detailData.value = planData;
|
|
|
- console.log('planData', planData);
|
|
|
- dynamicValidateForm.farmWorkName = planData.name;
|
|
|
- dynamicValidateForm.executeDate = planData.executeDate;
|
|
|
- dynamicValidateForm.usageMode = planData.prescription.usageMode;
|
|
|
- planData.prescription.pesticideFertilizerList.forEach(item => {
|
|
|
- item.defaultName = item.name;
|
|
|
- item.pesticideFertilizerCode = item.code;
|
|
|
- });
|
|
|
- dynamicValidateForm.prescriptionList = [planData.prescription];
|
|
|
- console.log('dynamicValidateForm.prescriptionList', dynamicValidateForm.prescriptionList);
|
|
|
+
|
|
|
+ // if (route.query.data) {
|
|
|
+ // actionType.value = JSON.parse(route.query.data);
|
|
|
+ // } else {
|
|
|
+ // actionType.value = ["生长异常"];
|
|
|
+ // }
|
|
|
+ // const planData = JSON.parse(route.query.planData);
|
|
|
+ // detailData.value = planData;
|
|
|
+ // console.log('planData', planData);
|
|
|
+ // dynamicValidateForm.farmWorkName = planData.name;
|
|
|
+ // dynamicValidateForm.executeDate = planData.executeDate;
|
|
|
+ // dynamicValidateForm.usageMode = planData.prescription.usageMode;
|
|
|
+ // planData.prescription.pesticideFertilizerList.forEach(item => {
|
|
|
+ // item.defaultName = item.name;
|
|
|
+ // item.pesticideFertilizerCode = item.code;
|
|
|
+ // });
|
|
|
+ // dynamicValidateForm.prescriptionList = [planData.prescription];
|
|
|
+ // console.log('dynamicValidateForm.prescriptionList', dynamicValidateForm.prescriptionList);
|
|
|
// dynamicValidateForm.prescriptionList = actionType.value.map((name) => ({
|
|
|
// name,
|
|
|
// pesticideFertilizerList: [
|
|
|
@@ -411,36 +313,95 @@ onMounted(() => {
|
|
|
// }));
|
|
|
});
|
|
|
|
|
|
-const detailData = ref({});
|
|
|
-const getDetail = (id) => {
|
|
|
- VE_API.z_farm_work_record.getDetail({ id }).then(({ data }) => {
|
|
|
- const res = data[0];
|
|
|
- detailData.value = res;
|
|
|
- dynamicValidateForm.executeDate = res.executeDate;
|
|
|
- dynamicValidateForm.usageMode = res.usageMode;
|
|
|
-
|
|
|
- res.prescriptionList.forEach(item => {
|
|
|
- item.pesticideFertilizerList.forEach(pesticide => {
|
|
|
- pesticide.typeName = item.name;
|
|
|
+const getArrangeDetail = (arrangeId) => {
|
|
|
+ loading.value = true;
|
|
|
+ VE_API.container_farm_work_arrange.getComposite({ arrangeId }).then(({ data }) => {
|
|
|
+ detailData.value = data;
|
|
|
+
|
|
|
+ // 赋值表单数据
|
|
|
+ if (data.farmWorkLib) {
|
|
|
+ // 执行时间
|
|
|
+ if (data.farmWorkLib.executeDate) {
|
|
|
+ dynamicValidateForm.executeDate = data.farmWorkLib.executeDate;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 施用方式
|
|
|
+ if (data.prescription && data.prescription.usageMode) {
|
|
|
+ dynamicValidateForm.usageMode = data.prescription.usageMode;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 处理处方数据
|
|
|
+ if (data.prescription && data.prescription.pesticideFertilizerList) {
|
|
|
+ // 将 prescription 对象转换为 prescriptionList 数组格式
|
|
|
+ // 根据 typeName 分组,创建不同的处方项
|
|
|
+ const prescriptionMap = new Map();
|
|
|
+
|
|
|
+ data.prescription.pesticideFertilizerList.forEach((item, index) => {
|
|
|
+ const typeName = item.typeName || '其他';
|
|
|
+
|
|
|
+ if (!prescriptionMap.has(typeName)) {
|
|
|
+ prescriptionMap.set(typeName, {
|
|
|
+ name: typeName,
|
|
|
+ pesticideFertilizerList: []
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查找对应的药肥选项,获取完整信息
|
|
|
+ const pesticideOption = pesticideFertilizersOptions.value.find(
|
|
|
+ opt => opt.pesticideFertilizerCode === item.code || opt.code === item.code
|
|
|
+ );
|
|
|
+
|
|
|
+ // 映射字段到表单需要的格式
|
|
|
+ const prescriptionItem = {
|
|
|
+ key: Date.now() + index,
|
|
|
+ pesticideFertilizerCode: item.code,
|
|
|
+ pesticideFertilizerName: item.name,
|
|
|
+ pesticideFertilizerId: pesticideOption?.id || null, // 用于 handlePesticideFertilizerChange 函数
|
|
|
+ typeName: item.typeName || '',
|
|
|
+ ratio: item.ratio || '',
|
|
|
+ dosage: item.dosage || '',
|
|
|
+ ratio2: item.ratio2 || '', // 无人机方式的亩兑水量
|
|
|
+ dosage2: item.dosage2 || '', // 无人机方式的单亩用量
|
|
|
+ remark: item.remark || '',
|
|
|
+ unit: pesticideOption?.unit || 'kg',
|
|
|
+ defaultRatio: pesticideOption?.defaultRatio || item.ratio || '',
|
|
|
+ usageModeList: pesticideOption?.usageModeList || [],
|
|
|
+ defaultName: pesticideOption?.defaultName || pesticideOption?.name || item.name,
|
|
|
+ };
|
|
|
+
|
|
|
+ prescriptionMap.get(typeName).pesticideFertilizerList.push(prescriptionItem);
|
|
|
});
|
|
|
- });
|
|
|
-
|
|
|
- dynamicValidateForm.prescriptionList = res.prescriptionList;
|
|
|
+
|
|
|
+ // 转换为数组
|
|
|
+ dynamicValidateForm.prescriptionList = Array.from(prescriptionMap.values());
|
|
|
+
|
|
|
+ // 如果没有数据,至少保留一个空项
|
|
|
+ if (dynamicValidateForm.prescriptionList.length === 0) {
|
|
|
+ dynamicValidateForm.prescriptionList = [{
|
|
|
+ name: "",
|
|
|
+ pesticideFertilizerList: [{
|
|
|
+ key: Date.now(),
|
|
|
+ typeName: "",
|
|
|
+ muUsage: "",
|
|
|
+ muUsage2: "",
|
|
|
+ ratio: "",
|
|
|
+ ratio2: "",
|
|
|
+ remark: "",
|
|
|
+ }],
|
|
|
+ }];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }).finally(() => {
|
|
|
+ loading.value = false;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
-function handleIgnore() {
|
|
|
- taskPopupType.value = 'warning';
|
|
|
- showTaskPopup.value = true;
|
|
|
-}
|
|
|
+const detailData = ref({});
|
|
|
|
|
|
function handlePopupBtn() {
|
|
|
showTaskPopup.value = false;
|
|
|
- if (taskPopupType.value === 'warning') {
|
|
|
- // 确认忽略
|
|
|
- } else {
|
|
|
- router.back();
|
|
|
- }
|
|
|
+ router.back();
|
|
|
}
|
|
|
|
|
|
const resetForm = (formEl) => {
|
|
|
@@ -482,13 +443,11 @@ const clearData = () => {
|
|
|
serveArea.value = null;
|
|
|
regionId.value = null;
|
|
|
areaList.value = [];
|
|
|
- farmProgress.value = 0;
|
|
|
situationDescription.value = '';
|
|
|
checkedArea.value = false;
|
|
|
actionType.value = [];
|
|
|
gardenId.value = null;
|
|
|
showTaskPopup.value = false;
|
|
|
- taskPopupType.value = 'warning';
|
|
|
};
|
|
|
|
|
|
onDeactivated(() => {
|
|
|
@@ -592,62 +551,45 @@ VE_API.z_farm_work_order.pesticideFertilizersList().then(({ data }) => {
|
|
|
pesticideFertilizersOptions.value = data;
|
|
|
});
|
|
|
|
|
|
-const allUsageMode = ref(null);
|
|
|
const allUsageModeList = ["叶面施", "根部施", "人工农事"];
|
|
|
|
|
|
-// 农事名称列表
|
|
|
-const farmWorkIndexNameList = ref([
|
|
|
- "片区拔节率",
|
|
|
- "园区花蕾率",
|
|
|
- "单树花蕾率",
|
|
|
- "片区雄穗抽出率",
|
|
|
- "园区花量大率",
|
|
|
- "单树花量大率",
|
|
|
- "片区分蘖率",
|
|
|
- ]);
|
|
|
-function getFarmWorkIndexNameList() {
|
|
|
- farmWorkIndexNameList.value = [
|
|
|
- "片区拔节率",
|
|
|
- "园区花蕾率",
|
|
|
- "单树花蕾率",
|
|
|
- "片区雄穗抽出率",
|
|
|
- "园区花量大率",
|
|
|
- "单树花量大率",
|
|
|
- "片区分蘖率",
|
|
|
- ];
|
|
|
- // VE_API.farm.fetchFarmWorkIndexNameList().then(({data}) => {
|
|
|
- // farmWorkIndexNameList.value = data
|
|
|
- // })
|
|
|
-}
|
|
|
-// 触发指标列表
|
|
|
-const farmWorkNameList = ref([]);
|
|
|
-function getFarmWorkNameList() {
|
|
|
- // VE_API.farm.fetchFarmWorkNameList().then(({data}) => {
|
|
|
- // farmWorkNameList.value = data
|
|
|
- // })
|
|
|
-}
|
|
|
-
|
|
|
|
|
|
/**
|
|
|
- * 选择药肥的时候修改订单中药肥pesticideFertilizerId 以外其他数据
|
|
|
- * @param index
|
|
|
+ * 选择药肥的时候修改订单中药肥pesticideFertilizerCode 以外其他数据
|
|
|
+ * @param parentIndex 处方索引
|
|
|
+ * @param index 药物索引
|
|
|
*/
|
|
|
const handlePesticideFertilizerChange = (parentIndex, index) => {
|
|
|
- let obj = pesticideFertilizersOptions.value.filter(
|
|
|
- (item) =>
|
|
|
- dynamicValidateForm.prescriptionList[parentIndex].pesticideFertilizerList[index].pesticideFertilizerId ===
|
|
|
- item.id
|
|
|
- )[0];
|
|
|
+ const currentItem = dynamicValidateForm.prescriptionList[parentIndex].pesticideFertilizerList[index];
|
|
|
+ const pesticideFertilizerCode = currentItem.pesticideFertilizerCode;
|
|
|
+
|
|
|
+ // 根据 pesticideFertilizerCode 查找对应的药肥选项
|
|
|
+ const obj = pesticideFertilizersOptions.value.find(
|
|
|
+ (item) => item.pesticideFertilizerCode === pesticideFertilizerCode || item.code === pesticideFertilizerCode
|
|
|
+ );
|
|
|
+
|
|
|
+ if (!obj) {
|
|
|
+ ElMessage({
|
|
|
+ message: "未找到对应的药肥信息",
|
|
|
+ type: "warning",
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 更新当前项的数据,保留原有数据并更新新字段
|
|
|
dynamicValidateForm.prescriptionList[parentIndex].pesticideFertilizerList[index] = {
|
|
|
- ...dynamicValidateForm.prescriptionList[parentIndex].pesticideFertilizerList[index],
|
|
|
- typeName: obj.typeName,
|
|
|
- unit: obj.unit,
|
|
|
- defaultRatio: obj.defaultRatio,
|
|
|
- usageModeList: obj.usageModeList,
|
|
|
- ratio: obj.defaultRatio,
|
|
|
- defaultName: obj.defaultName,
|
|
|
- pesticideFertilizerName: obj.name,
|
|
|
- pesticideFertilizerCode: obj.pesticideFertilizerCode,
|
|
|
+ ...currentItem,
|
|
|
+ pesticideFertilizerId: obj.id || null,
|
|
|
+ typeName: obj.typeName || currentItem.typeName || '',
|
|
|
+ unit: obj.unit || currentItem.unit || 'kg',
|
|
|
+ defaultRatio: obj.defaultRatio || currentItem.defaultRatio || '',
|
|
|
+ usageModeList: obj.usageModeList || currentItem.usageModeList || [],
|
|
|
+ // 如果 ratio 为空,则使用默认值
|
|
|
+ ratio: currentItem.ratio || obj.defaultRatio || '',
|
|
|
+ ratio2: currentItem.ratio2 || obj.defaultDroneRatio || '',
|
|
|
+ defaultName: obj.defaultName || obj.name || currentItem.defaultName || '',
|
|
|
+ pesticideFertilizerName: obj.name || currentItem.pesticideFertilizerName || '',
|
|
|
+ pesticideFertilizerCode: obj.pesticideFertilizerCode || pesticideFertilizerCode,
|
|
|
};
|
|
|
};
|
|
|
|
|
|
@@ -682,9 +624,8 @@ const submitForm = (formEl) => {
|
|
|
// },
|
|
|
// });
|
|
|
|
|
|
- taskPopupType.value = 'success';
|
|
|
- showTaskPopup.value = true;
|
|
|
- // submit();
|
|
|
+ // showTaskPopup.value = true;
|
|
|
+ submit();
|
|
|
} else {
|
|
|
console.log("error submit!");
|
|
|
}
|
|
|
@@ -692,75 +633,49 @@ const submitForm = (formEl) => {
|
|
|
};
|
|
|
|
|
|
const submit = () => {
|
|
|
- // let executeBlueZones = null
|
|
|
- // if (!(curRole==1 && isAdd.value)) {
|
|
|
- // executeBlueZones = newFarmMap.getSelectedBlueRegion();
|
|
|
- // }
|
|
|
- // if (!executeBlueZones || !executeBlueZones.length) {
|
|
|
- // ElMessage({
|
|
|
- // message: "请选择执行区域",
|
|
|
- // type: "warning",
|
|
|
- // });
|
|
|
- // return false
|
|
|
- // }
|
|
|
-
|
|
|
- // 检查药物所有项是否都包含特定的字段
|
|
|
- // const hasRequiredFields = dynamicValidateForm.prescriptionList.every(item => {
|
|
|
- // return item.pesticideFertilizerList.every(domain => {
|
|
|
- // const hasPesticideFertilizerCode = 'pesticideFertilizerCode' in domain
|
|
|
- // const hasMuUsage = 'muUsage' in domain;
|
|
|
- // const hasRatio = 'ratio' in domain;
|
|
|
-
|
|
|
- // const isMuUsageValid = domain.muUsage !== '';
|
|
|
- // const isRatioValid = domain.ratio ? true : false;
|
|
|
-
|
|
|
- // return hasPesticideFertilizerCode && hasMuUsage && hasRatio && isMuUsageValid && isRatioValid
|
|
|
- // });
|
|
|
- // })
|
|
|
- // if (!hasRequiredFields) {
|
|
|
- // ElMessage({
|
|
|
- // message: "请完善药物信息",
|
|
|
- // type: "warning",
|
|
|
- // });
|
|
|
- // return false
|
|
|
- // }
|
|
|
-
|
|
|
- // const flattenedDomains = flattenDomains(dynamicValidateForm.prescription)
|
|
|
- const data = {
|
|
|
- id: route.query.id,
|
|
|
- ...dynamicValidateForm,
|
|
|
+ // 构造保存数据,格式与 getComposite 返回的一致
|
|
|
+ const saveData = {
|
|
|
+ arrange: {
|
|
|
+ ...detailData.value.arrange,
|
|
|
+ },
|
|
|
+ farmWorkLib: {
|
|
|
+ ...detailData.value.farmWorkLib,
|
|
|
+ // 更新执行时间
|
|
|
+ executeDate: dynamicValidateForm.executeDate || detailData.value.farmWorkLib?.executeDate,
|
|
|
+ },
|
|
|
+ prescription: {
|
|
|
+ id: detailData.value.prescription?.id || null,
|
|
|
+ usageMode: dynamicValidateForm.usageMode || detailData.value.prescription?.usageMode || '',
|
|
|
+ farmWorkLibCode: detailData.value.prescription?.farmWorkLibCode || detailData.value.farmWorkLib?.code || '',
|
|
|
+ expertId: detailData.value.prescription?.expertId || detailData.value.farmWorkLib?.expertId || '',
|
|
|
+ phenology: detailData.value.prescription?.phenology || '',
|
|
|
+ soil: detailData.value.prescription?.soil || '',
|
|
|
+ speed: detailData.value.prescription?.speed || null,
|
|
|
+ // 将 prescriptionList 扁平化为 pesticideFertilizerList
|
|
|
+ pesticideFertilizerList: dynamicValidateForm.prescriptionList.reduce((acc, prescriptionItem) => {
|
|
|
+ const items = prescriptionItem.pesticideFertilizerList.map(item => ({
|
|
|
+ code: item.pesticideFertilizerCode || item.code || '',
|
|
|
+ name: item.pesticideFertilizerName || item.name || '',
|
|
|
+ dosage: item.dosage || '',
|
|
|
+ ratio: item.ratio || '',
|
|
|
+ ratio2: item.ratio2 || '', // 无人机方式的亩兑水量
|
|
|
+ dosage2: item.dosage2 || '', // 无人机方式的单亩用量
|
|
|
+ muPrice: item.muPrice || null,
|
|
|
+ typeName: item.typeName || '',
|
|
|
+ remark: item.remark || '',
|
|
|
+ }));
|
|
|
+ return acc.concat(items);
|
|
|
+ }, []),
|
|
|
+ },
|
|
|
+ triggers: detailData.value.triggers || [],
|
|
|
};
|
|
|
- VE_API.z_farm_work_record.issueFarmWorkRecord(data).then((res) => {
|
|
|
- if (res.code === 0) {
|
|
|
- taskPopupType.value = 'success';
|
|
|
+console.log('saveData', saveData);
|
|
|
+ // 调用保存接口
|
|
|
+ VE_API.container_farm_work_arrange.saveComposite(saveData).then(({ code, message }) => {
|
|
|
+ if (code === 0) {
|
|
|
showTaskPopup.value = true;
|
|
|
}
|
|
|
- })
|
|
|
- // 新增农事
|
|
|
- // VE_API.farm.saveFarmWork(data).then(({ code }) => {
|
|
|
- // if (code === 0) {
|
|
|
- // ElMessage({
|
|
|
- // message: "保存成功",
|
|
|
- // type: "success",
|
|
|
- // });
|
|
|
- // setTimeout(() => {
|
|
|
- // // router.go(-1);
|
|
|
- // router.replace("/expert_album?reload=true");
|
|
|
- // }, 500);
|
|
|
- // }
|
|
|
- // });
|
|
|
- // const data = {
|
|
|
- // orderId: props.prescriptioData.orderId,
|
|
|
- // orderStatus: 1,
|
|
|
- // pesticideFertilizers: dynamicValidateForm.domains,
|
|
|
- // };
|
|
|
- // VE_API.order.confirm(data).then(({ code }) => {
|
|
|
- // if (code == 0) {
|
|
|
- // console.log('专家下发处方成功');
|
|
|
- // eventBus.emit('discover:submitForm')
|
|
|
- // window.location.reload()
|
|
|
- // }
|
|
|
- // });
|
|
|
+ });
|
|
|
};
|
|
|
|
|
|
const farmWorkTypeVal = computed(() => {
|
|
|
@@ -788,7 +703,6 @@ const serveArea = ref(null);
|
|
|
const areaList = ref([]);
|
|
|
const regionId = ref(null);
|
|
|
|
|
|
-const farmProgress = ref(0)
|
|
|
|
|
|
// 状况描述相关数据
|
|
|
const situationDescription = ref('')
|