| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327 |
- <template>
- <div class="agricultural-dynamics">
- <!-- 任务列表 -->
- <div class="task-list">
- <div v-for="(task, index) in taskList" :key="index" class="task-item">
- <div class="task-content" @click="handleTaskAction(task)">
- <div class="task-header">
- <div class="task-status-tag">待完成</div>
- <div class="task-title">{{ task.farmWorkName }}</div>
- </div>
- <div class="task-time" v-if="task.expectedExecuteDate">执行时间 {{ task.expectedExecuteDate }}</div>
- <div class="task-time deadline" v-else>截止时间 {{ task.executeDeadlineDate }}</div>
- </div>
- <div v-if="task.expectedExecuteDate" class="task-action" @click="showOfferPopup(task)">
- 上传照片
- </div>
- <div v-else class="task-action orange" @click="selectExecuteTime(task)">
- 确认执行时间
- </div>
- </div>
- </div>
- <div class="title">农情互动</div>
- <!-- 内容区域 -->
- <div class="agricultural-list">
- <div v-if="!unansweredList.length" class="empty-block">暂无数据</div>
- <template v-else>
- <div class="agricultural-item" v-for="(item, index) in unansweredList" :key="index">
- <!-- 头部区域 -->
- <div class="header-section">
- <div class="header-left">
- <div class="farm-name van-ellipsis">{{ item.farmName }}</div>
- <div class="tag-group">
- <div class="tag tag-blue">{{ item.typeName }}</div>
- <div class="tag" :class="{'tag-orange': item.userType === 2}">{{ item.userType === 1 ? '普通客户' : '托管客户' }}</div>
- </div>
- </div>
- <div class="remind-btn" @click="handleRemind(item)">提醒客户</div>
- </div>
- <!-- 警告通知块 -->
- <div
- class="warning-block"
- v-if="item.latestPhenologyProgressBroadcast"
- v-html="item.latestPhenologyProgressBroadcast?.content"
- ></div>
- <!-- 时间轴组件,只负责时间轴区域 -->
- <AgriculturalInteractionCard :item="item" @updateList="updateAllData" />
- </div>
- </template>
- </div>
- </div>
- <offer-popup ref="offerPopupRef"></offer-popup>
- <!-- 确认执行时间 -->
- <calendar
- teleport="#app"
- v-model:show="showCalendar"
- @confirm="onConfirmExecuteTime"
- :min-date="minDate"
- :max-date="maxDate"
- />
- </template>
- <script setup>
- import router from "@/router";
- import { ref, onMounted, onActivated } from "vue";
- import { Calendar } from "vant";
- import { ElMessage } from "element-plus";
- import offerPopup from "@/components/popup/offerPopup.vue";
- import AgriculturalInteractionCard from "@/components/pageComponents/AgriculturalInteractionCard.vue";
- import { formatDate } from "@/common/commonFun";
- // 任务列表数据
- const taskList = ref([]);
- const handleTaskAction = (item) => {
- router.push({
- path: "/completed_work",
- query: { miniJson: JSON.stringify({ id: item.id }) },
- });
- };
- const offerPopupRef = ref(null);
- const showOfferPopup = (item) => {
- offerPopupRef.value.openPopup(item);
- };
- const showCalendar = ref(false);
- const maxDate = ref();
- // 最小日期设置为今天,今天可以选择
- const minDate = new Date();
- const executeItem = ref(null);
- const selectExecuteTime = (item) => {
- executeItem.value = item;
- maxDate.value = new Date(item.executeDeadlineDate);
- showCalendar.value = true;
- };
- const onConfirmExecuteTime = (date) => {
- showCalendar.value = false;
- VE_API.z_farm_work_record
- .updateExpectedExecuteDate({ recordId: executeItem.value.id, expectedExecuteDate: formatDate(date) })
- .then((res) => {
- if (res.code === 0) {
- ElMessage.success("操作成功");
- getTaskList();
- }
- });
- };
- const handleRemind = (item) => {
- router.push(`/remind_customer?farmId=${item.farmId}`);
- };
- onActivated(() => {
- updateAllData();
- });
- const updateAllData = () => {
- getUnansweredFarms();
- getTaskList();
- };
- //农情互动的农场列表接口(分页)
- const getTaskList = async () => {
- const res = await VE_API.z_farm_work_record.getSimpleList({ role: 2, flowStatus: 4 });
- taskList.value = (res.data || []).slice(0, 2);
- };
- const unansweredList = ref([]);
- const getUnansweredFarms = async () => {
- const params = {
- page: 0,
- limit: 3,
- flowStatus: 5,
- };
- const res = await VE_API.home.listUnansweredFarms(params);
- unansweredList.value = (res.data || []).map((item) => ({
- ...item,
- timelineList: [],
- }));
- // 串行请求,一个完成后再请求下一个
- if (unansweredList.value.length) {
- for (let i = 0; i < unansweredList.value.length; i++) {
- await getFutureFarmWorkWarning(unansweredList.value[i]);
- }
- }
- };
- //查询未来农事预警
- const getFutureFarmWorkWarning = async (item) => {
- const res = await VE_API.home.listFutureFarmWorkWarning({ farmId: item.farmId });
- item.timelineList = res.data || [];
- };
- </script>
- <style scoped lang="scss">
- .agricultural-dynamics {
- padding: 0 10px;
- // 任务列表样式
- .task-list {
- .task-item {
- display: flex;
- align-items: center;
- justify-content: space-between;
- background-color: #ffffff;
- border-radius: 8px;
- padding: 12px;
- margin-top: 10px;
- position: relative;
- overflow: hidden;
- &::after {
- content: "";
- position: absolute;
- top: -10px;
- right: 0;
- width: 72px;
- height: 72px;
- pointer-events: none;
- background: url("@/assets/img/home/task-icon.png") no-repeat center center / 100% 100%;
- }
- .task-content {
- flex: 1;
- .task-header {
- display: flex;
- align-items: center;
- margin-bottom: 4px;
- gap: 8px;
- }
- .task-status-tag {
- background-color: rgba(33, 153, 248, 0.1);
- color: #2199f8;
- font-size: 12px;
- padding: 1px 6px;
- border-radius: 2px;
- }
- .task-title {
- font-size: 16px;
- font-weight: 500;
- color: #1d2129;
- }
- .task-time {
- font-size: 12px;
- color: rgba(78, 89, 105, 0.5);
- &.deadline {
- color: rgba(255, 85, 85, 0.7);
- }
- }
- }
- .task-action {
- flex: none;
- background-color: rgba(33, 153, 248, 0.1);
- color: #2199f8;
- border-radius: 25px;
- padding: 7px 14px;
- font-size: 12px;
- &.orange {
- color: #ff953d;
- background: rgba(255, 149, 61, 0.1);
- }
- }
- }
- }
- .title {
- font-size: 16px;
- font-weight: 500;
- color: #1d2129;
- margin-top: 10px;
- }
- .agricultural-list {
- .empty-block {
- display: flex;
- align-items: center;
- justify-content: center;
- height: 120px;
- color: #a0a0a0;
- font-size: 14px;
- background-color: #ffffff;
- border-radius: 8px;
- margin-top: 8px;
- }
- .agricultural-item {
- background-color: #ffffff;
- border-radius: 8px;
- padding: 8px 12px;
- margin-top: 8px;
- // 头部区域样式
- .header-section {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding-bottom: 5px;
- border-bottom: 0.5px solid rgba(0, 0, 0, 0.1);
- .header-left {
- display: flex;
- align-items: center;
- gap: 8px;
- width: calc(100% - 80px);
- .farm-name {
- font-size: 16px;
- font-weight: 500;
- color: #1d2129;
- max-width: calc(100% - 130px);
- }
- .tag-group {
- display: flex;
- gap: 4px;
- .tag {
- padding: 2px 8px;
- border-radius: 2px;
- font-size: 12px;
- color: #848282;
- background-color: rgba(148, 148, 148, 0.1);
- &.tag-blue {
- background-color: #e8f3ff;
- color: #2199f8;
- }
- &.tag-orange {
- background-color: rgba(255, 149, 61, 0.1);
- color: #ff953d;
- }
- }
- }
- }
- .remind-btn {
- background-color: #2199f8;
- color: #ffffff;
- border-radius: 25px;
- padding: 7px 12px;
- font-size: 12px;
- }
- }
- // 警告通知块样式
- .warning-block {
- background-color: rgba(33, 153, 248, 0.1);
- border-radius: 5px;
- padding: 5px;
- margin-top: 8px;
- font-size: 12px;
- color: #252525;
- ::v-deep {
- p {
- padding: 0;
- margin: 0;
- }
- }
- }
- }
- }
- }
- </style>
|