| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869 |
- <template>
- <div class="work-detail">
- <custom-header name="农事详情" :showClose="false" isGoBack @goback="handleBack" />
- <div class="work-detail-content">
- <!-- 顶部状态 -->
- <div class="content-status" :class="'status-' + detail?.flowStatus">
- <div class="status-l">
- <div class="status-title">{{ handleTagType(detail?.flowStatus) }}</div>
- <div class="status-sub" v-if="triggerDateText && detail?.flowStatus === 0">
- 执行时间已经过去 {{ daysDiff }} 天了
- </div>
- <div class="status-sub" v-if="detail?.flowStatus === 1">
- 距离执行时间还差 {{ daysDiff }} 天
- </div>
- <div class="status-sub" v-if="!detail?.flowStatus || detail?.flowStatus === 2">
- 预计触发时间 {{ detail?.activateTime ? formatDate(detail.activateTime) : "--" }}
- </div>
- </div>
- </div>
- <div class="work-wrap">
- <!-- 农事组信息 -->
- <div class="box-wrap group-info group-box">
- <div class="group-name">
- 该农事为 <span class="light-text">限时溯源农事</span> ,请在 <span class="light-text">3天内</span>
- 完成溯源认证上传,如果逾期未认证,该农事将不可溯源认证,且不计入飞鸟有味平台
- </div>
- </div>
- <!-- 每一段农事 -->
- <div v-for="(prescription, index) in stageList" :key="index" class="box-wrap stage-card">
- <div class="work-info">
- <div class="stage-header">
- <div class="stage-title">{{ detail.farmWorkName }}</div>
- </div>
- <div class="stage-info">
- <div class="form-item">
- <div class="item-name">农事目的</div>
- <div class="item-text">
- {{ detail.purpose || prescription.name || "--" }}
- </div>
- </div>
- <div class="form-item">
- <div class="item-name">农事时间</div>
- <div class="item-text">
- {{ detail.intervelTime ? `间隔 ${detail.intervelTime} 天后 执行` : "--" }}
- </div>
- </div>
- <div class="form-item">
- <div class="item-name">执行区域</div>
- <div class="item-text light-text area-text">
- 桂味种植区域
- <!-- <div class="area-btn" @click="handleViewArea">查看区域</div> -->
- <div class="area-btn area-btn-right" @click="toDraw">建议勾选<el-icon><ArrowRight /></el-icon></div>
- </div>
- </div>
- <div class="form-item">
- <div class="item-name">注意事项</div>
- <div class="item-text">
- {{ detail.remark || "--" }}
- </div>
- </div>
- <div class="form-item">
- <div class="item-name">药肥处方</div>
- </div>
- </div>
- <!-- 执行方式 -->
- <div class="stage-tabs">
- <div v-for="tab in executionTabs" :key="tab.value" class="tab-pill"
- :class="{ active: getStageExecutionMethod(index) === tab.value }"
- @click="changeExecutionMethod(index, tab.value)">
- {{ tab.label }}
- </div>
- </div>
- <!-- 药物处方表 -->
- <div class="prescription-wrap"
- v-if="prescription.pesticideList && prescription.pesticideList.length">
- <div class="prescription-table">
- <div class="table-header">
- <div class="col col-type">使用功效</div>
- <div class="col col-name">药肥名称</div>
- <div class="col col-ratio">药肥配比</div>
- </div>
- <div v-for="(item, i) in prescription.pesticideList" :key="i" class="table-row">
- <div class="col col-type">
- {{ item.typeName || "--" }}
- </div>
- <div class="col col-name">
- {{ item.name || item.pesticideFertilizerName || "--" }}
- </div>
- <div class="col col-ratio">
- {{ getPesticideParam(item, index)?.ratio || "--" }}倍
- </div>
- </div>
- </div>
- <div v-if="hasRemark(prescription, index)" class="prescription-remark">
- <span v-for="(item, idx) in [prescription.pesticideList[0]]" :key="idx">
- <template v-if="getParamRemark(item, index)">
- {{ getParamRemark(item, index) }}
- <br />
- </template>
- </span>
- </div>
- </div>
- </div>
- <!-- 农事凭证 -->
- <div class="work-info photo-box" v-if="prescription.cropAlbum && prescription.cropAlbum.length">
- <div class="photo-title">农事凭证</div>
- <div class="photo-sub-title" v-if="info?.appType === 1">来自于 某某某农资机构</div>
- <div class="photo-img-wrap">
- <photo-provider :photo-closable="true">
- <photo-consumer v-for="(src, index) in prescription.cropAlbum" intro="农事凭证" :key="index"
- :src="base_img_url2 + src.filename">
- <div class="photo-img">
- <img :src="base_img_url2 + src.filename" />
- </div>
- </photo-consumer>
- </photo-provider>
- </div>
- </div>
- </div>
- <!-- 底部按钮 -->
- <div class="fixed-btn-wrap center-btn" v-if="info?.appType === 2">
- <div class="fixed-btn" @click="handleConvert">
- 转发农事
- </div>
- </div>
- <div class="fixed-btn-wrap execute-action" v-if="info?.appType === 1 && detail?.flowStatus === 1">
- <div class="action-item second" @click="handleConvert">转发农事</div>
- <div class="action-item primary" @click="handleExecute">溯源认证</div>
- </div>
- </div>
- </div>
- <ExecutePopup ref="executePopupRef" />
- <upload-tips v-model:show="showUploadTipsPopup" />
- </div>
- <!-- 执行区域地图弹窗 -->
- <popup v-model:show="showMapPopup" closeable class="map-popup">
- <map-info :farmId="detail.farmId" />
- </popup>
- </template>
- <script setup>
- import wx from "weixin-js-sdk";
- import customHeader from "@/components/customHeader.vue";
- import { ref, computed, onMounted, onActivated } from "vue";
- import { useRouter } from "vue-router";
- import { formatDate } from "@/common/commonFun";
- import ExecutePopup from "./components/executePopup.vue";
- import { base_img_url2 } from "@/api/config";
- import UploadTips from "@/components/popup/uploadTips.vue";
- import { Popup } from "vant";
- import MapInfo from "./components/mapInfo.vue";
- import { useRoute } from "vue-router";
- const route = useRoute();
- const showUploadTipsPopup = ref(false);
- const router = useRouter();
- // const info = JSON.parse(localStorage.getItem("localUserInfo") || "{}");
- const info = { appType: 1 };
- /** 接口根级与 detail 合并后的详情(兼容旧 groupList / 新 pesticideList、prescriptionList) */
- const detail = ref({
- farmId: null,
- farmWorkLibId: null,
- farmWorkName: "",
- flowStatus: null,
- purpose: "",
- speciesId: null,
- speciesName: "",
- executeDate: null,
- intervelTime: null,
- remark: "",
- pesticideList: [],
- prescriptionList: [],
- groupList: [],
- confirmPicture: [],
- executeEvidence: [],
- expertName: "",
- expertPrescription: "",
- id: null,
- postId: null,
- post: null,
- expertNameFromFarmBasicInfo: "",
- rangeWkt: null,
- activateTime: null,
- });
- /** 凭证图片统一为 { filename } */
- const normalizeCropAlbum = (album) => {
- if (!album || !Array.isArray(album)) return [];
- return album
- .map((x) => {
- if (!x) return null;
- if (typeof x === "string") return { filename: x };
- if (x.filename) return x;
- return null;
- })
- .filter(Boolean);
- };
- /**
- * prescriptionList.pesticideFertilizerList → 与旧 groupList.pesticideList 一致(含 params 三行执行方式)
- */
- const mapFertilizerToPesticideItem = (f) => {
- if (!f || typeof f !== "object") return null;
- return {
- code: f.pesticideFertilizerCode || f.code,
- name: f.pesticideFertilizerName || f.defaultName || f.name || "",
- typeName: f.typeName || "",
- brand: f.brand || "",
- unit: f.unit,
- params: [
- {
- dosage:
- f.muUsage != null && f.muUsage !== ""
- ? String(f.muUsage)
- : "",
- executionMethod: 1,
- ratio:
- f.ratio != null && f.ratio !== "" ? String(f.ratio) : "",
- remark: f.remark || "",
- },
- {
- dosage:
- f.muUsage2 != null && f.muUsage2 !== ""
- ? String(f.muUsage2)
- : "",
- executionMethod: 2,
- ratio:
- f.ratio2 != null && f.ratio2 !== ""
- ? String(f.ratio2)
- : "",
- remark: "",
- },
- { dosage: "", executionMethod: 3, ratio: "", remark: "" },
- ],
- };
- };
- const maybeShowUploadTips = () => {
- if (detail.value?.flowStatus !== 1) return;
- const shown = localStorage.getItem('upload_tips');
- if (shown === "1") return;
- localStorage.setItem('upload_tips', "1");
- showUploadTipsPopup.value = true;
- };
- onMounted(() => {
- maybeShowUploadTips();
- });
- onActivated(() => {
- getDetail();
- });
- const getDetail = () => {
- const { farmWorkLibId, farmId } = route.query;
- VE_API.z_farm_work_record
- .getDetailById({ farmWorkLibId, farmId })
- .then(({ data }) => {
- const inner =
- data?.detail && typeof data.detail === "object"
- ? { ...data.detail }
- : {};
- detail.value = {
- ...inner,
- post: data?.post ?? null,
- expertNameFromFarmBasicInfo:
- data?.expertNameFromFarmBasicInfo ?? "",
- rangeWkt: data?.rangeWkt ?? null,
- activateTime: data?.activateTime ?? null,
- };
- });
- };
- // 计算距离执行时间的天数差
- const daysDiff = computed(() => {
- if (!detail.value?.executeDate) {
- return 0;
- }
- const executeDate = new Date(detail.value.executeDate);
- const today = new Date();
- // 将时间设置为 00:00:00,只比较日期
- executeDate.setHours(0, 0, 0, 0);
- today.setHours(0, 0, 0, 0);
- // 计算天数差(毫秒转天数)
- const diffTime = executeDate.getTime() - today.getTime();
- const diffDays = Math.floor(diffTime / (1000 * 60 * 60 * 24));
- return diffDays;
- });
- // 执行方式 Tab 配置
- const executionTabs = [
- { label: "植保机", value: 1 },
- { label: "人工手持", value: 2 },
- { label: "地面机械", value: 3 }
- ];
- // 每一段农事的当前执行方式(索引 -> 执行方式),默认 1:植保机
- const stageExecutionMethods = ref({});
- const executePopupRef = ref(null);
- const triggerDateText = computed(() => {
- if (!detail.value.executeDate) return "";
- const d = formatDate(detail.value.executeDate);
- return d.replace(/-/g, ".");
- });
- /**
- * 展示用「分段」列表:旧数据用 groupList;新接口用 detail.pesticideList 或 prescriptionList 推导
- */
- const stageList = computed(() => {
- const d = detail.value;
- if (!d) return [];
- if (Array.isArray(d.groupList) && d.groupList.length) {
- return d.groupList;
- }
- if (Array.isArray(d.pesticideList) && d.pesticideList.length) {
- return [
- {
- name: d.farmWorkName || "",
- pesticideList: d.pesticideList,
- cropAlbum: normalizeCropAlbum(
- d.confirmPicture?.length
- ? d.confirmPicture
- : d.executeEvidence
- ),
- },
- ];
- }
- if (Array.isArray(d.prescriptionList) && d.prescriptionList.length) {
- return d.prescriptionList.map((p) => ({
- name: p.name || "",
- pesticideList: (p.pesticideFertilizerList || [])
- .map(mapFertilizerToPesticideItem)
- .filter(Boolean),
- cropAlbum: normalizeCropAlbum(p.cropAlbum),
- }));
- }
- return [];
- });
- const hasRemark = (prescription, stageIndex) => {
- if (!prescription?.pesticideList || !Array.isArray(prescription.pesticideList)) return false;
- const currentMethod = getStageExecutionMethod(stageIndex);
- return prescription.pesticideList.some((item) => {
- if (!item.params || !Array.isArray(item.params)) return false;
- const p = item.params.find((param) => param.executionMethod === currentMethod);
- return !!(p && p.remark);
- });
- };
- const handleTagType = (tagType) => {
- if (tagType === 0) return "已过期";
- if (tagType === 1) return "待认证";
- if (tagType === 2) return "待触发";
- if (tagType === 3) return "已完成";
- return "待触发"
- }
- const handleExecute = () => {
- // wx.miniProgram.navigateTo({
- // url: `/pages/subPages/location_check/index?lng=113.264435&lat=23.129163`,
- // });
- executePopupRef.value.openPopup();
- };
- const showMapPopup = ref(false);
- const handleViewArea = () => {
- showMapPopup.value = true;
- }
- const toDraw = () => {
- router.push("/draw_region");
- }
- const handleBack = () => {
- router.back();
- };
- const handleConvert = () => {
- const query = {
- askInfo: { title: "农情互动", content: "是否分享该互动给好友" },
- shareText: '邀请您农情互动,精准匹配种植方案',
- targetUrl: `work_detail`,
- paramsPage: JSON.stringify({ id: detail.value.id }),
- imageUrl: 'https://birdseye-img.sysuimars.com/birdseye-look-mini/work_img.png',
- };
- wx.miniProgram.navigateTo({
- url: `/pages/subPages/share_page/index?pageParams=${JSON.stringify(query)}&type=sharePage`,
- });
- };
- // 获取当前段的执行方式
- const getStageExecutionMethod = (stageIndex) => {
- const val = stageExecutionMethods.value[stageIndex];
- return val || 1;
- };
- // 根据当前执行方式,获取对应的参数(配比、单亩用量、备注)
- const getPesticideParam = (item, stageIndex) => {
- if (!item?.params || !Array.isArray(item.params)) return null;
- const currentMethod = getStageExecutionMethod(stageIndex);
- return (
- item.params.find((param) => param.executionMethod === currentMethod) || null
- );
- };
- const getParamRemark = (item, stageIndex) => {
- const param = getPesticideParam(item, stageIndex);
- return param?.remark || item.remark || "";
- };
- const changeExecutionMethod = (stageIndex, value) => {
- stageExecutionMethods.value = {
- ...stageExecutionMethods.value,
- [stageIndex]: value
- };
- };
- </script>
- <style scoped lang="scss">
- .work-detail {
- height: 100vh;
- background: #f2f3f5;
- display: flex;
- flex-direction: column;
- .work-detail-content {
- flex: 1;
- overflow: auto;
- }
- }
- .content-status {
- position: relative;
- padding: 16px 12px 0 12px;
- color: #fff;
- z-index: 1;
- height: 100px;
- box-sizing: border-box;
- &::after {
- content: "";
- z-index: -1;
- position: absolute;
- left: 0;
- top: 0;
- height: 100px;
- background: #C7C7C7;
- // background: #FF953D;
- width: 100%;
- }
- &.status-0 {
- &::after {
- background: #FF4F4F;
- }
- }
- &.status-1 {
- &::after {
- background: #FF953D;
- }
- }
- &.status-2 {
- &::after {
- background: #C7C7C7;
- }
- }
- &.status-3 {
- padding-top: 30px;
- &::after {
- background: #2199F8;
- }
- }
- .status-l {
- .status-title {
- font-size: 22px;
- }
- .status-sub {
- font-size: 14px;
- }
- }
- }
- .work-wrap {
- position: relative;
- top: -16px;
- padding: 0 12px 12px;
- z-index: 2;
- margin-bottom: 60px;
- }
- .box-wrap {
- // background: #ffffff;
- // border-radius: 8px;
- // padding: 14px 10px 10px 10px;
- // box-shadow: 0 2px 8px rgba(15, 35, 52, 0.06);
- .work-info {
- background: #ffffff;
- border-radius: 8px;
- padding: 14px 10px 10px 10px;
- box-shadow: 0 2px 8px rgba(15, 35, 52, 0.06);
- }
- .photo-box {
- margin-top: 10px;
- padding: 11px 10px;
- font-size: 14px;
- .photo-title {
- color: #000;
- padding-bottom: 9px;
- }
- .photo-sub-title {
- padding-bottom: 9px;
- color: #767676;
- }
- }
- }
- .group-info {
- margin-bottom: 10px;
- background: #ffffff;
- border-radius: 8px;
- padding: 14px 10px 10px 10px;
- box-shadow: 0 2px 8px rgba(15, 35, 52, 0.06);
- &.group-box {
- padding: 10px;
- .group-name {
- font-size: 14px;
- color: #767676;
- .group-name-text {
- color: #000;
- }
- }
- }
- .group-name {
- font-size: 14px;
- color: rgba(0, 0, 0, 0.2);
- .group-name-text {
- color: #767676;
- }
- }
- .group-sub {
- margin-top: 6px;
- font-size: 12px;
- color: rgba(0, 0, 0, 0.45);
- line-height: 1.5;
- }
- }
- .stage-card+.stage-card {
- margin-top: 10px;
- }
- .stage-card {
- .stage-header {
- padding-bottom: 12px;
- display: flex;
- align-items: center;
- gap: 5px;
- .stage-title {
- font-size: 16px;
- color: #000;
- }
- .title-tag {
- width: fit-content;
- font-size: 12px;
- height: 26px;
- line-height: 26px;
- color: #2199F8;
- background: rgba(33, 153, 248, 0.1);
- border-radius: 20px;
- padding: 0 8px;
- }
- .tag-0 {
- color: #FF953D;
- background: rgba(255, 149, 61, 0.1);
- }
- }
- .stage-info {
- padding: 8px 0 2px;
- border-top: 1px solid #f5f5f5;
- }
- }
- .form-item {
- display: flex;
- font-size: 14px;
- color: #767676;
- margin-top: 4px;
- .area-btn {
- border: 1px solid rgba(0, 0, 0, 0.1);
- padding: 0 10px;
- color: #767676;
- }
- .area-btn-right {
- padding-right: 4px;
- display: inline-flex;
- align-items: center;
- gap: 4px;
- }
- .item-name {
- padding-right: 26px;
- color: rgba(0, 0, 0, 0.2);
- }
- .item-text {
- flex: 1;
- line-height: 21px;
- &.light-text {
- color: #2199F8;
- }
- }
- .area-text {
- display: inline-flex;
- align-items: center;
- gap: 10px;
- }
- }
- .light-text {
- color: #2199F8;
- }
- .stage-tabs {
- display: inline-flex;
- gap: 8px;
- margin-top: 8px;
- .tab-pill {
- padding: 0 8px;
- font-size: 14px;
- text-align: center;
- border-radius: 2px;
- height: 28px;
- line-height: 28px;
- color: #767676;
- background: rgba(171, 171, 171, 0.1);
- &.active {
- background: rgba(33, 153, 248, 0.1);
- color: #2199F8;
- }
- }
- }
- .prescription-wrap {
- margin-top: 10px;
- overflow: hidden;
- .prescription-title {
- padding: 8px 10px;
- font-size: 13px;
- font-weight: 500;
- border-bottom: 1px solid rgba(225, 225, 225, 0.6);
- }
- }
- .prescription-table {
- font-size: 12px;
- text-align: center;
- border-radius: 6px;
- border: 1px solid rgba(225, 225, 225, 0.6);
- .table-header {
- display: flex;
- background: rgba(171, 171, 171, 0.1);
- padding: 9px 6px;
- color: #767676;
- }
- .table-row {
- display: flex;
- padding: 12px 6px;
- border-bottom: 1px solid rgba(0, 0, 0, 0.08);
- color: rgba(0, 0, 0, 0.76);
- &:last-child {
- border-bottom: none;
- }
- }
- .col {
- display: flex;
- align-items: center;
- justify-content: center;
- padding: 0 2px;
- }
- .col-type {
- width: 56px;
- }
- .col-name {
- flex: 1;
- }
- .col-ratio {
- width: 64px;
- }
- .col-dose {
- width: 64px;
- }
- }
- .prescription-remark {
- margin-top: 8px;
- padding: 7px 10px;
- border-radius: 6px;
- color: #767676;
- background: rgba(171, 171, 171, 0.1);
- line-height: 21px;
- }
- .photo-img-wrap {
- display: flex;
- flex-wrap: wrap;
- gap: 10px;
- ::v-deep {
- .PhotoConsumer {
- width: 31%;
- height: 92px;
- }
- }
- .photo-img {
- width: 100%;
- height: 100%;
- position: relative;
- box-sizing: border-box;
- border: 2px solid transparent;
- border-radius: 8px;
- overflow: hidden;
- img {
- width: 100%;
- height: 100%;
- border-radius: 8px;
- object-fit: cover;
- }
- }
- }
- .execute-action {
- display: flex;
- align-items: center;
- // justify-content: center;
- justify-content: space-between;
- gap: 16px;
- .action-item {
- padding: 0 26px;
- height: 40px;
- line-height: 40px;
- border-radius: 26px;
- box-sizing: border-box;
- font-size: 14px;
- &.second {
- background: #ffffff;
- border: 0.5px solid rgba(153, 153, 153, 0.5);
- color: #999999;
- }
- &.primary {
- background: linear-gradient(180deg, #8ACBFF 0%, #2199F8 100%);
- color: #ffffff;
- }
- }
- }
- .fixed-btn-wrap {
- display: flex;
- // justify-content: center;
- justify-content: space-between;
- &.center-btn {
- justify-content: center;
- }
- position: fixed;
- bottom: 0px;
- left: 0;
- right: 0;
- background: #fff;
- padding: 10px 12px 16px 12px;
- box-sizing: border-box;
- // box-shadow: 0 -2px 8px rgba(15, 35, 52, 0.06);
- box-shadow: 2px 2px 4.5px 0px #00000066;
- .fixed-btn {
- min-width: 110px;
- height: 40px;
- line-height: 40px;
- text-align: center;
- border-radius: 20px;
- background: linear-gradient(180deg, #70bffe, #2199f8);
- color: #ffffff;
- font-size: 14px;
- }
- }
- .map-popup {
- width: 92%;
- // max-width: 420px;
- border-radius: 8px;
- padding: 12px;
- box-sizing: border-box;
- }
- </style>
|