|
|
@@ -10,11 +10,9 @@
|
|
|
<img class="header-icon" src="@/assets/img/home/file-icon.png" alt="" />
|
|
|
</div>
|
|
|
<div class="question-section-wrapper">
|
|
|
- <!-- <span class="question-text">{{ questPopupData.quest }}</span> -->
|
|
|
- <span class="question-text">请问 <span style="color: #2199f8;">水稻园</span> 的水稻是否进入分蘖期?</span>
|
|
|
+ <div class="question-text">请问 <span style="color: #2199f8;">{{ farmName }}</span> {{ questPopupData.quest }}</div>
|
|
|
<div class="img">
|
|
|
- <!-- <img :src="questPopupData.backgroundImage" alt="" /> -->
|
|
|
- <img src="@/assets/img/home/sd.png" alt="" />
|
|
|
+ <img :src="questPopupData.backgroundImage" alt="" />
|
|
|
</div>
|
|
|
<div class="options-section">
|
|
|
<span class="options-label">您可以选择</span>
|
|
|
@@ -47,27 +45,21 @@
|
|
|
<div class="no-popup-btn" @click="noShow = false">我知道了</div>
|
|
|
</Popup>
|
|
|
<!-- 农事信息弹窗 -->
|
|
|
- <detail-dialog ref="detailDialogRef" :show-success-only="true"></detail-dialog>
|
|
|
+ <detail-dialog ref="detailDialogRef" showSuccessOnly @triggerFarmWork="triggerFarmWork"></detail-dialog>
|
|
|
<!-- 新增:激活上传弹窗 -->
|
|
|
- <active-upload-popup @handleUploadSuccess="handleUploadSuccess"></active-upload-popup>
|
|
|
+ <active-upload-popup ref="activeUploadPopupRef" @handleUploadSuccess="handleUploadSuccess"></active-upload-popup>
|
|
|
</template>
|
|
|
<script setup>
|
|
|
import { Popup } from "vant";
|
|
|
-import { ref,watch } from "vue";
|
|
|
+import { ref,onActivated } from "vue";
|
|
|
import wx from "weixin-js-sdk";
|
|
|
import activeUploadPopup from "@/components/popup/activeUploadPopup.vue";
|
|
|
import detailDialog from "@/components/detailDialog.vue";
|
|
|
import eventBus from "@/api/eventBus";
|
|
|
import { useRouter } from "vue-router";
|
|
|
+import { ElMessage } from "element-plus";
|
|
|
const router = useRouter();
|
|
|
|
|
|
-const props = defineProps({
|
|
|
- farmId: {
|
|
|
- type: [Number, String],
|
|
|
- default: null,
|
|
|
- }
|
|
|
-});
|
|
|
-
|
|
|
const show = ref(false);
|
|
|
const noShow = ref(false);
|
|
|
const dropdownGardenItem = ref({
|
|
|
@@ -79,37 +71,57 @@ const dropdownGardenItem = ref({
|
|
|
name: "荔博园",
|
|
|
});
|
|
|
const toUpload = () => {
|
|
|
- wx.miniProgram.navigateTo({
|
|
|
- url: `/pages/subPages/carmera/index?gardenData=${JSON.stringify(dropdownGardenItem.value)}`,
|
|
|
- });
|
|
|
+ if(curRole == 0){
|
|
|
+ wx.miniProgram.navigateTo({
|
|
|
+ url: `/pages/subPages/carmera/index?gardenData=${JSON.stringify(dropdownGardenItem.value)}`,
|
|
|
+ });
|
|
|
+ }else{
|
|
|
+ ElMessage.warning("该功能正在升级中,敬请期待");
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
function toPage() {
|
|
|
- router.push("/expert_list");
|
|
|
+ const expertId = sessionStorage.getItem('expertId');
|
|
|
+ if(expertId){
|
|
|
+ router.push(`/chat_frame?userId=${expertId}`);
|
|
|
+ }else{
|
|
|
+ ElMessage.warning("专家信息不存在,请联系管理员");
|
|
|
+ }
|
|
|
}
|
|
|
const detailDialogRef = ref(null);
|
|
|
|
|
|
const curRole = localStorage.getItem("SET_USER_CUR_ROLE");
|
|
|
|
|
|
-watch(() => props.farmId, (newVal) => {
|
|
|
- if (newVal) {
|
|
|
+const farmName = ref('');
|
|
|
+const farmIdVal = ref(null);
|
|
|
+
|
|
|
+onActivated(() => {
|
|
|
+ if(curRole == 0){
|
|
|
+ if(localStorage.getItem('selectedFarmId')){
|
|
|
+ farmIdVal.value = localStorage.getItem('selectedFarmId');
|
|
|
+ fetchQuestPopup();
|
|
|
+ }
|
|
|
+ }else{
|
|
|
fetchQuestPopup();
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+
|
|
|
const questPopupData = ref({});
|
|
|
const bottomAnswerOptions = ref([]);
|
|
|
+//弹出问卷接口
|
|
|
const fetchQuestPopup = () => {
|
|
|
- VE_API.home
|
|
|
- .fetchQuestPopup({ farmId: props.farmId })
|
|
|
- .then(({ data }) => {
|
|
|
- if (Array.isArray(data) && data.length > 0) {
|
|
|
- show.value = true;
|
|
|
- questPopupData.value = data[0];
|
|
|
- bottomAnswerOptions.value = transformAnswerOptions(questPopupData.value?.answerOptions);
|
|
|
- }
|
|
|
- })
|
|
|
- .catch(() => {});
|
|
|
+ const api = curRole == 0 ? VE_API.home.fetchQuestPopup({ farmId: farmIdVal.value }) : VE_API.home.popupByAgriculturalUserFarms();
|
|
|
+ api.then(({ data }) => {
|
|
|
+ if (Array.isArray(data) && data.length > 0) {
|
|
|
+ show.value = true;
|
|
|
+ farmName.value = data[0].farm?.name;
|
|
|
+ farmIdVal.value = data[0].farm?.id;
|
|
|
+ questPopupData.value = data[0];
|
|
|
+ bottomAnswerOptions.value = transformAnswerOptions(questPopupData.value?.answerOptions);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(() => {});
|
|
|
};
|
|
|
|
|
|
function transformAnswerOptions(raw) {
|
|
|
@@ -157,8 +169,9 @@ function onBottomOptionClick(opt) {
|
|
|
optValue.value = opt.value;
|
|
|
if (opt.value == 1) {
|
|
|
eventBus.emit("activeUpload:show", {
|
|
|
- gardenIdVal: props.farmId,
|
|
|
- problemTitleVal: "请选择您出现白点的时间",
|
|
|
+ gardenIdVal: farmIdVal.value,
|
|
|
+ arrangeIdVal: questPopupData.value.arrangeId,
|
|
|
+ problemTitleVal: `请选择您出现${questPopupData.value.phenologyName}的时间`,
|
|
|
typeVal: "question",
|
|
|
});
|
|
|
} else {
|
|
|
@@ -169,7 +182,7 @@ function onBottomOptionClick(opt) {
|
|
|
function saveQuestPopup() {
|
|
|
const agriDate = getTodayStr();
|
|
|
const params = {
|
|
|
- farmId: props.farmId,
|
|
|
+ farmId: farmIdVal.value,
|
|
|
phenologyId: questPopupData.value.phenologyId,
|
|
|
indicatorId: questPopupData.value.indicatorId,
|
|
|
answerValue: optValue.value,
|
|
|
@@ -194,10 +207,17 @@ function getTodayStr() {
|
|
|
return `${y}-${m}-${day}`;
|
|
|
}
|
|
|
const images = ref([]);
|
|
|
+const currentParams = ref({});
|
|
|
function handleUploadSuccess(params) {
|
|
|
- images.value = params.images;
|
|
|
+ currentParams.value = params;
|
|
|
+ images.value = params.imagePaths;
|
|
|
+ detailDialogRef.value.showDialog(questPopupData.value.farmWorkLibId, "转发");
|
|
|
+}
|
|
|
+
|
|
|
+const activeUploadPopupRef = ref(null);
|
|
|
+function triggerFarmWork() {
|
|
|
+ activeUploadPopupRef.value.triggerFarmWork(currentParams.value);
|
|
|
saveQuestPopup();
|
|
|
- detailDialogRef.value.showDialog("2220003", curRole == 0 ? "咨询专家" : "转发");
|
|
|
}
|
|
|
</script>
|
|
|
<style lang="scss" scoped>
|