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

211 lines
7.7 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-06-17 21:34:59 +08:00
import Talk from "../Talk/index.vue";
2025-06-21 19:27:06 +08:00
import AddMaterial from "../../pages/merchant/components/AddMaterial.vue";
import AddComment from "../../pages/merchant/components/AddComment.vue";
import RejectTaskModal from "../../pages/manage/pages/manage-reward-mission/components/RejectTaskModal.vue";
2025-03-18 11:29:04 +08:00
2025-04-21 10:30:45 +08:00
const emits = defineEmits(['success']);
2025-06-21 19:27:06 +08:00
const selecdKey = ref([]);
2025-04-21 10:30:45 +08:00
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-06-21 19:27:06 +08:00
const getData = async (update) => {
Api.admin.getTaskChildrenInfo(id).then(({data}) => {
if (update) {
detail.content.forEach((v, index) => {
v.comment = data.content[index].comment;
});
} else {
Object.assign(detail, data);
}
});
}
2025-04-21 10:30:45 +08:00
watch(
() => visible.value,
(val) => {
2025-06-21 19:27:06 +08:00
if (val) getData();
2025-04-21 10:30:45 +08:00
},
{deep: true}
)
2025-03-18 11:29:04 +08:00
2025-04-21 10:30:45 +08:00
const passTaskChildren = async () => {
2025-06-21 19:27:06 +08:00
console.log(selecdKey.value);
const pro_list = [];
if (selecdKey.value.length === 0) {
pro_list.push(new Promise((reactive, reject) => {
Api.admin.passChildrenMaterial(detail.content[activeKey.value]).then((res) => {
reactive(res);
}).catch((err) => {
reject(err);
})
}));
}
selecdKey.value.forEach(v => {
pro_list.push(new Promise((reactive, reject) => {
Api.admin.passChildrenMaterial(v).then((res) => {
reactive(res);
}).catch((err) => {
reject(err);
})
}));
})
const res = await Promise.all(pro_list);
let flag = true;
for (const v of res) {
if (v.code !== 1) {
Message.warning(v.msg)
flag = false;
}
}
if (flag) {
Message.success(res[0].msg);
visible.value = false;
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>
2025-05-24 18:23:11 +08:00
<a-link v-if="!$slots.default" :hoverable="false" @click="visible=true">预览</a-link>
<div v-else @click="visible=true">
2025-05-09 14:57:18 +08:00
<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">
2025-06-21 19:27:06 +08:00
<a-form-item label="标题" v-if="item?.material_type?.title_limit > 0">
<a-input v-model:model-value="item.title" :disabled="detail.check_status !== 0"
:max-length="item.material_type.title_limit"></a-input>
2025-03-18 11:29:04 +08:00
</a-form-item>
2025-06-21 19:27:06 +08:00
<a-form-item label="正文" v-if="item?.material_type?.desc_limit > 0">
2025-03-18 11:29:04 +08:00
<a-textarea
2025-06-21 19:27:06 +08:00
v-model:model-value="item.content"
:max-length="item.material_type.desc_limit"
2025-03-18 11:29:04 +08:00
show-word-limit
2025-06-17 21:34:59 +08:00
:disabled="detail.check_status !== 0"
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>
2025-06-21 19:27:06 +08:00
<a-form-item label="话题" v-if="item?.material_type?.tags_limit > 0">
<Talk v-model:model-value="item.tags" :disabled="detail.check_status !== 0"
:limit="item?.material_type?.tags_limit"></Talk>
2025-03-18 11:29:04 +08:00
</a-form-item>
<a-form-item label="素材">
2025-06-21 19:27:06 +08:00
<div class="flex flex-wrap gap-[16px]">
2025-05-10 15:59:02 +08:00
<x-image
2025-06-21 19:27:06 +08:00
v-for="(v, index) in item.material"
@delete="item.material.splice(index, 1)"
2025-06-17 21:34:59 +08:00
:hide-delete="detail.check_status !== 0"
2025-05-10 15:59:02 +08:00
: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>
2025-06-21 19:27:06 +08:00
<add-material
v-if="detail.check_status === 0"
@success="val => item.material = val"
ref="AddMaterialRef"
:id="item.task_id"
:material="item">
<div
class="size-[60px] bg-[#F2F3F5] flex justify-center items-center flex-col rounded-[8px] cursor-pointer">
<icon-plus/>
<div>添加</div>
</div>
</add-material>
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-06-21 19:27:06 +08:00
<div class="flex-grow">
<div v-if="item.comment.length > 0" class="flex flex-col gap-[8px] w-full mb-[12px]">
<comment :data="item.comment" :hide-delete="detail.check_status !== 0"
@success="getData(true)"></comment>
</div>
<add-comment
v-if="detail.check_status === 0"
@success="getData(true)"
:material="{id: id}"
:item="item">
<a-button>
<icon-plus/>
<div>添加评论</div>
</a-button>
</add-comment>
2025-05-10 15:59:02 +08:00
</div>
2025-03-18 11:29:04 +08:00
</a-form-item>
</a-form>
</a-tab-pane>
</a-tabs>
<template #footer>
<div class="flex items-center gap-[8px]">
2025-06-21 19:27:06 +08:00
<a-checkbox-group v-model:model-value="selecdKey">
<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>
2025-06-21 19:27:06 +08:00
<RejectTaskModal
:api="Api.admin.refuseTaskChildren"
:id="detail.id"
@success="() => {
visible = false;
emits('success')
}">
<a-button>拒绝</a-button>
</RejectTaskModal>
2025-05-10 15:59:02 +08:00
</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>