This commit is contained in:
2025-06-23 19:07:23 +08:00
parent 1ae5c75f5e
commit b98de4746d
5 changed files with 95 additions and 17 deletions

View File

@@ -1,17 +1,14 @@
<script setup>
import {computed} from 'vue';
import {computed, onMounted} from 'vue';
import messageIcon from "../static/icons/messageIcon.png";
import XActionsheet from "./XActionsheet.vue";
import OpenTypeFun from "./OpenTypeFun.js";
import {toPage} from "../utils/uils.js";
import {showToast, toPage} from "../utils/uils.js";
import {useSystemStore} from "../pinia/SystemStore/index.js";
import Api from "../api/index.js";
const itemList = computed(() => {
const item = [];
true ?
item.push({text: '标记未读', type: 0}) :
item.push({text: '标记已读', type: 1});
return item;
})
const SystemStore = useSystemStore();
const emits = defineEmits(['success']);
const {contextRow, type, data} = defineProps({
contextRow: {
type: String,
@@ -27,9 +24,46 @@ const {contextRow, type, data} = defineProps({
}
});
const selectActionsheet = (e) => {
console.log(e);
const itemList = computed(() => {
const list = type === 0 ? [
{text: '置顶', type: 1, hide: data.is_top === 1},
{text: '取消置顶', type: 0, hide: data.is_top === 0},
{text: '标记已读', type: 0, hide: data.is_read === 0},
{text: '标记未读', type: 1, hide: data.is_read === 1},
] : [
{text: '标记已读', type: 0, hide: data.is_read === 0},
{text: '标记未读', type: 1, hide: data.is_read === 1},
]
return list.filter(v => !v.hide);
})
const selectActionsheet = async (e) => {
if (type === 0) {
const {msg} = await Api.system.setExchangeTop({
id: data.id,
type: e.type,
});
showToast(msg);
emits('success');
} else {
const index = SystemStore.message.findIndex(v => v.id === data.id);
SystemStore.message[index].is_read = true;
}
}
const openOpenTypeFun = () => {
const index = SystemStore.message.findIndex(v => v.id === data.id);
SystemStore.message[index].is_read = true;
OpenTypeFun(data);
}
onMounted(() => {
if (type === 1) {
const now = SystemStore.message.find(v => v.id === data.id);
console.log(now);
if (!now) SystemStore.message.push({...data, is_read: false});
}
});
</script>
<template>
@@ -37,12 +71,17 @@ const selectActionsheet = (e) => {
@success="selectActionsheet"
:itemList="itemList">
<view
@click.stop="type === 0 ? toPage(`/pages/taskDetails/index?id=${data.task_id}&task_children_id=${data.task_children_id}&tab=3`) : OpenTypeFun(data)"
@click.stop="type === 0 ? toPage(`/pages/taskDetails/index?id=${data.task_id}&task_children_id=${data.task_children_id}&tab=3`) : openOpenTypeFun()"
class="!py-[30rpx] !px-[24rpx] bg-[#fff] rounded-[8rpx] !flex items-center gap-[20rpx] overflow-hidden relative !mb-[20rpx]">
<image class="!size-[72rpx] flex-shrink-0" mode="aspectFill" :src="messageIcon"></image>
<view class="relative">
<image class="!size-[72rpx] flex-shrink-0" mode="aspectFill" :src="messageIcon"></image>
<view v-if="type === 0 ? data.is_read===0 : !SystemStore.message.find(v => v.id===data.id).is_read"
class="size-[20rpx] bg-[#f00] absolute right-0 top-0 rounded-[50%]"></view>
</view>
<view class="flex-grow !flex flex-col gap-[12rpx]">
<view class="!flex justify-between items-center">
<view class="bh">{{ type === 0 ? '任务编号: DF12122' : data.title }}</view>
<view class="bh">{{ data.title }}</view>
<view class="time">2024-01-26 14:00</view>
</view>
<view :class="['context', contextRow]">