Files
xl-root/src/components/PreviewTaskModal/PreviewTaskModal.vue

137 lines
4.8 KiB
Vue
Raw Normal View History

2025-03-18 11:29:04 +08:00
<script setup>
2025-05-10 15:59:02 +08:00
import XImage from "../../components/XImage/Index.vue";
2025-04-21 10:30:45 +08:00
import {reactive, ref, watch} from 'vue';
2025-05-09 14:57:18 +08:00
import Api from "../../api/index.ts";
2025-04-21 10:30:45 +08:00
import {Message} from "@arco-design/web-vue";
2025-05-10 15:59:02 +08:00
import Comment from "../Comment/index.vue";
2025-03-18 11:29:04 +08:00
2025-04-21 10:30:45 +08:00
const emits = defineEmits(['success']);
const {id} = defineProps({
id: {
type: Number,
default: 0,
}
});
2025-03-18 11:29:04 +08:00
const visible = ref(false);
2025-04-21 10:30:45 +08:00
const detail = reactive({});
2025-05-10 15:59:02 +08:00
const activeKey = ref(0);
2025-03-18 11:29:04 +08:00
2025-04-21 10:30:45 +08:00
watch(
() => visible.value,
(val) => {
if (val) Api.admin.getTaskChildrenInfo(id).then(({data}) => {
Object.assign(detail, data);
console.log('我看看我看看', data);
});
},
{deep: true}
)
2025-03-18 11:29:04 +08:00
2025-04-21 10:30:45 +08:00
const passTaskChildren = async () => {
const {code, msg} = await Api.admin.passTaskChildren(id);
if (code === 1) Message.success(msg);
2025-05-10 15:59:02 +08:00
visible.value = false;
2025-04-21 10:30:45 +08:00
emits('success');
2025-03-18 11:29:04 +08:00
}
2025-04-21 10:30:45 +08:00
const refuseTaskChildren = async () => {
const {code, msg} = await Api.admin.refuseTaskChildren(id);
if (code === 1) Message.success(msg);
2025-05-10 15:59:02 +08:00
visible.value = false;
2025-04-21 10:30:45 +08:00
emits('success');
2025-03-18 11:29:04 +08:00
}
</script>
<template>
<a-link :hoverable="false" @click="visible=true">预览</a-link>
2025-05-09 14:57:18 +08:00
<div @click="visible=true">
<slot></slot>
</div>
2025-03-18 11:29:04 +08:00
<a-modal
title-align="start"
title="预览"
v-model:visible="visible">
2025-04-21 10:30:45 +08:00
<a-tabs v-model:active-key="activeKey" type="rounded" v-if="detail.id !== undefined && detail.id !== null">
<a-tab-pane v-for="(item, index) in detail.content" :title="`素材${index+1}`" :key="index">
2025-03-18 11:29:04 +08:00
<a-form
layout="vertical">
<a-form-item label="标题">
2025-04-21 10:30:45 +08:00
<a-input :model-value="item.title"></a-input>
2025-03-18 11:29:04 +08:00
</a-form-item>
<a-form-item label="正文">
<a-textarea
auto-size
:max-length="1000"
show-word-limit
2025-04-21 10:30:45 +08:00
:model-value="item.content">
2025-03-18 11:29:04 +08:00
</a-textarea>
</a-form-item>
<a-form-item label="话题">
2025-05-10 15:59:02 +08:00
<div v-if="item.tags_arr.length > 0" id="tag-list"
class="w-full bg-[var(--color-neutral-2)] p-[4px]">
2025-04-21 10:30:45 +08:00
<a-tag v-for="v in item.tags_arr">#{{ v }}</a-tag>
2025-03-18 11:29:04 +08:00
</div>
2025-05-10 15:59:02 +08:00
<div v-else>
暂无话题
</div>
2025-03-18 11:29:04 +08:00
</a-form-item>
<a-form-item label="素材">
2025-05-10 15:59:02 +08:00
<div v-if="item.materia_arr.length > 0" class="flex flex-wrap gap-[16px]">
<x-image
v-for="(v, index) in item.materia_arr"
:hide-delete="true"
:key="index"
2025-04-21 10:30:45 +08:00
width="60px"
height="60px"
:src="v">
2025-05-10 15:59:02 +08:00
</x-image>
</div>
<div v-else>
暂无话题
2025-04-21 10:30:45 +08:00
</div>
2025-03-18 11:29:04 +08:00
</a-form-item>
<a-form-item label="评论区内容">
2025-05-10 15:59:02 +08:00
<div v-if="item.comment.length > 0" class="flex flex-col gap-[8px] w-full">
<comment :data="item.comment" :hide-delete="true"></comment>
</div>
<div v-else>
暂无评论区内容
2025-03-18 11:29:04 +08:00
</div>
</a-form-item>
</a-form>
</a-tab-pane>
</a-tabs>
<template #footer>
<div class="flex items-center gap-[8px]">
2025-05-10 15:59:02 +08:00
<!-- <a-checkbox-group>-->
<!-- <template v-for="(item, index) in detail.content" :key="item">-->
<!-- <a-checkbox v-show="activeKey === index" :value="item">选中</a-checkbox>-->
<!-- </template>-->
<!-- </a-checkbox-group>-->
2025-03-18 11:29:04 +08:00
2025-05-10 15:59:02 +08:00
<template v-if="detail.check_status === 0">
<a-button @click="passTaskChildren" type="primary" class="ml-auto">通过
</a-button>
<a-button @click="refuseTaskChildren">拒绝</a-button>
</template>
<a-button v-else @click="visible=false" class="ml-auto">关闭</a-button>
2025-03-18 11:29:04 +08:00
</div>
</template>
</a-modal>
</template>
<style lang="scss" scoped>
#tag-list {
:deep(.arco-tag) {
color: #000;
background-color: #fff;
border: 1px solid rgb(229, 230, 235);
box-sizing: border-box;
}
}
</style>