Ver código fonte

fix: 增加专家删除,无处方判断

刘秀芳 1 mês atrás
pai
commit
8a8928c8ac

+ 28 - 2
src/views/addFarm/index.vue

@@ -150,7 +150,7 @@
                         </template>
                     </div>
                     <div class="footer">
-                        <!-- <el-button class="btn" type="danger" plain @click="remove()">删除</el-button> -->
+                        <el-button class="button delete" type="danger" plain @click="remove()">删除</el-button>
                         <div class="button" @click="handleOk">{{ active === 0 ? "确定" : (isAdd ? "新增农事" : "下发农事") }}</div>
                     </div>
                 </chart-box>
@@ -194,7 +194,7 @@
 
 <script setup>
 import { onMounted, ref, reactive } from "vue";
-import { ElMessage } from "element-plus";
+import { ElMessage, ElMessageBox } from "element-plus";
 import fnHeader from "@/components/fnHeader.vue";
 import steps from "./components/steps.vue";
 import customTable from "./components/table.vue";
@@ -323,6 +323,27 @@ const goBack = () => {
     router.go(-1);
 };
 
+
+const remove = () => {
+    ElMessageBox.confirm("是否要删除这个农事?", "警告", {
+        confirmButtonText: "删除",
+        cancelButtonText: "取消",
+        type: "warning",
+    }).then(() => {
+        VE_API.farm.deleteFarmWork({ libId }).then(({ code }) => {
+            if (code === 0) {
+                ElMessage({
+                    type: "success",
+                    message: "删除成功!",
+                });
+                setTimeout(() => {
+                    router.go(-1);
+                }, 500);
+            }
+        });
+    });
+};
+
 //确定/下发农事
 const handleOk = () => {
     if (active.value) {
@@ -750,6 +771,11 @@ function updateTableData(pIndex, cIndex, tableData) {
                         color: #000;
                         margin-right: 12px;
                         cursor: pointer;
+                        &.delete {
+                            background: rgba(255, 148, 61, 0.1);
+                            color: #FF943D;
+                            border: 1px solid #FF943D;
+                        }
                     }
                 }
             }

+ 17 - 13
src/views/home/album/index.vue

@@ -153,17 +153,18 @@
                                                     <span
                                                         v-for="(
                                                             fertilizer, fertilizerI
-                                                        ) in card.pesticideFertilizerList"
+                                                        ) in card.prescriptionList"
                                                         :key="fertilizerI"
                                                     >
-                                                        {{ fertilizer.ratio ? fertilizer.ratio + "倍" : "" }}
-                                                        {{ fertilizer.name }}
-                                                        <span
-                                                            v-if="
-                                                                fertilizerI !== card.pesticideFertilizerList.length - 1
-                                                            "
-                                                        >
-                                                            +
+                                                        <span v-for="(pest, pestI) in fertilizer.pesticideFertilizerList" :key="'sub' + pestI">
+                                                            {{ pest.defaultName }}
+                                                            <span
+                                                                v-if="
+                                                                    (pestI !== fertilizer.pesticideFertilizerList.length - 1) || (fertilizerI !== card.prescriptionList.length - 1)
+                                                                "
+                                                            >
+                                                                +
+                                                            </span>
                                                         </span>
                                                     </span>
                                                 </div>
@@ -319,8 +320,10 @@ const toExpert = (expertName) =>{
 eventBus.off('garden:organId', getListData)
 eventBus.on('garden:organId', getListData)
 
-const areaIdVal = ref(null)
+const areaIdVal = ref(2)
+eventBus.off('area:id')
 eventBus.on('area:id', ({areaId,farmId}) => {
+    console.log('areaId', areaId);
     areaIdVal.value = areaId
     getFarmLog()
 })
@@ -356,9 +359,10 @@ onUnmounted(() => {
 const indicatorChartData = ref({})
 const getFarmLog = () => {
     VE_API.farm.fetchFarmLog({id: areaIdVal.value, farmId: farmId.value}).then(({data,code}) => {
-      if(code === 0){
-        indicatorChartData.value = data
-        eventBus.emit('chart:updateOption', indicatorChartData.value)
+        if(code === 0){
+            indicatorChartData.value = data
+            console.log('getFarmLog', data);
+            eventBus.emit('chart:updateOption', indicatorChartData.value)
       } else {
         indicatorChartData.value = {}
       }

+ 10 - 9
src/views/warningHome/components/album.vue

@@ -150,17 +150,18 @@
                                                     <span
                                                         v-for="(
                                                             fertilizer, fertilizerI
-                                                        ) in card.pesticideFertilizerList"
+                                                        ) in card.prescriptionList"
                                                         :key="fertilizerI"
                                                     >
-                                                        {{ fertilizer.ratio ? fertilizer.ratio + "倍" : "" }}
-                                                        {{ fertilizer.name }}
-                                                        <span
-                                                            v-if="
-                                                                fertilizerI !== card.pesticideFertilizerList.length - 1
-                                                            "
-                                                        >
-                                                            +
+                                                        <span v-for="(pest, pestI) in fertilizer.pesticideFertilizerList" :key="'sub' + pestI">
+                                                            {{ pest.defaultName }}
+                                                            <span
+                                                                v-if="
+                                                                    (pestI !== fertilizer.pesticideFertilizerList.length - 1) || (fertilizerI !== card.prescriptionList.length - 1)
+                                                                "
+                                                            >
+                                                                +
+                                                            </span>
                                                         </span>
                                                     </span>
                                                 </div>

+ 2 - 2
src/views/workDetail/components/prescriptionBox.vue

@@ -73,7 +73,7 @@
                 </div> -->
                 <!-- 显示简略信息 -->
                 <!-- v-if="prescriptioData?.orderStatus === 0 && ROLETYPE == '3'" -->
-                <!-- <div class="prescription-item">
+                <div class="prescription-item">
                     <div class="recipe-box">
                         <div class="recipe-title">
                             <div class="recipe-name">药物处方</div>
@@ -122,7 +122,7 @@
                             </div>
                         </div>
                     </div>
-                </div> -->
+                </div>
                 <div class="prescription-item" v-if="prescriptioData?.orderStatus === 0">
                     <div class="sub-title">
                         <div class="sub-line"></div>

+ 2 - 2
src/views/workDetail/components/serviceBox.vue

@@ -243,8 +243,8 @@ import { useStore } from "vuex";
 import { deepClone } from "@/common/commonFun";
 const store = useStore();
 
-// const ROLETYPE = store.state.app.curRole
-const ROLETYPE = '2'
+const ROLETYPE = store.state.app.curRole
+// const ROLETYPE = '2'
 
 const checkService = ref(true);
 const props = defineProps({

+ 19 - 3
src/views/workDetail/prescriptionBox.vue

@@ -79,7 +79,7 @@
                 <div class="desc">
                     {{ prescriptioData.expertPrescription || prescriptioData.weatherWarningMsg }}
                 </div>
-                <div class="prescription-item" v-if="progress === 0 && ROLETYPE == '3' && dynamicValidateForm.prescriptionList && dynamicValidateForm.prescriptionList.length && dynamicValidateForm.prescriptionList[0].pesticideFertilizerList.length">
+                <div class="prescription-item" v-if="progress === 0 && ROLETYPE == '3' && !allPesticideFertilizerListsEmpty">
                     <div class="usageMode-wrap">
                         <div class="box-item">
                             <div class="form-l">施用方式</div>
@@ -263,7 +263,7 @@
                         </div>
                     </el-form>
                 </div>
-                <div class="prescription-item" v-else v-show="prescriptioData.prescriptionList && prescriptioData.prescriptionList.length && prescriptioData.prescriptionList[0].pesticideFertilizerList.length">
+                <div class="prescription-item" v-else v-show="!allPesticideFertilizerListsEmpty">
                     <div class="sub-title">
                         <div class="sub-name">药物处方</div>
                     </div>
@@ -420,7 +420,7 @@
 <script setup>
 import eventBus from "@/api/eventBus";
 import chart from "./chart.vue";
-import { onActivated, onMounted, reactive, ref } from "vue";
+import { computed, onMounted, reactive, ref } from "vue";
 import { ElMessage, ElMessageBox } from "element-plus";
 import { useStore } from "vuex";
 import ExecuteBlueRegion from "./executeBlueRegion";
@@ -468,6 +468,22 @@ onMounted(() => {
     infoItem.value = props.prescriptioData;
 });
 
+const allPesticideFertilizerListsEmpty = computed(() => {
+    // prescriptioData.prescriptionList[0].pesticideFertilizerList
+    // 遍历 prescriptionList 数组
+    return props.prescriptioData.prescriptionList.every((item) => {
+        // 检查 pesticideFertilizerList 是否为空数组或每个对象都为空
+        return (
+            !item.pesticideFertilizerList.length ||
+            item.pesticideFertilizerList.every(
+                (subItem) =>
+                    // 假设每个子对象需要某种条件来判断是否为空,这里假设对象没有属性即为空
+                    Object.keys(subItem).length === 0
+            )
+        );
+    });
+});
+
 // 表单
 const formRef = ref();
 const dynamicValidateForm = reactive({