From 2b609b9e03d66714935bb48e85a710e2c48a8e79 Mon Sep 17 00:00:00 2001 From: yziiy <15979918+mayday-yziiy@user.noreply.gitee.com> Date: Fri, 23 Jan 2026 14:05:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/modules/system.ts | 4 +++ src/views/system/Tasks/hook.tsx | 63 +++++++++++++++++++++------------ 2 files changed, 44 insertions(+), 23 deletions(-) diff --git a/src/api/modules/system.ts b/src/api/modules/system.ts index 5054768..9822248 100644 --- a/src/api/modules/system.ts +++ b/src/api/modules/system.ts @@ -138,6 +138,10 @@ export const upadteTaskData = data => { data }); }; +// 获取任务类型列表 +export const getTaskTypeList = () => { + return http.request("get", "/adminapi/Tasks/task_type_list"); +}; // 二级密码校验 export const checkPassWord = data => { diff --git a/src/views/system/Tasks/hook.tsx b/src/views/system/Tasks/hook.tsx index a1a2119..63f7f80 100644 --- a/src/views/system/Tasks/hook.tsx +++ b/src/views/system/Tasks/hook.tsx @@ -1,13 +1,14 @@ -import { ref, h } from "vue"; +import { ref, h, onMounted } from "vue"; import editForm from "./form.vue"; import { message } from "@/utils/message"; import { ElMessageBox } from "element-plus"; import { queryTaskList, editTaskData, - upadteTaskData + upadteTaskData, + getTaskTypeList } from "@/api/modules/system"; -import detailView from './Reward/index.vue' +import detailView from "./Reward/index.vue"; import { addDialog } from "@/components/ReDialog"; export function useData() { const formRef = ref(); @@ -20,12 +21,10 @@ export function useData() { }); const searchLabel = ref([ { - label: "任务类型", prop: "task_type", type: "select", - optionList: [ - { label: "每日任务", value: 1 }, - { label: "每日特殊任务", value: 2 }, - { label: "平台常规任务", value: 3 } - ] + label: "任务类型", + prop: "task_type", + type: "select", + optionList: [] } ]); const pagination = ref({ @@ -60,8 +59,8 @@ export function useData() { active-text="激活" inactive-text="未激活" active-color="#13ce66" - inactive-color="#ff4949"> - + inactive-color="#ff4949" + > ) }, { @@ -71,10 +70,11 @@ export function useData() { slot: "operation" } ]); - const onChange = async (row) => { + const onChange = async row => { if (!loading.value) { ElMessageBox.confirm( - `确认要${row.is_active === 2 ? "未激活" : "激活" + `确认要${ + row.is_active === 2 ? "未激活" : "激活" }吗?`, "系统提示", { @@ -86,7 +86,10 @@ export function useData() { } ) .then(async () => { - const { data, code } = await upadteTaskData({ task_id: row.task_id, is_active: row.is_active }) + const { data, code } = await upadteTaskData({ + task_id: row.task_id, + is_active: row.is_active + }); if (code) { message(`已${row.status === 2 ? "未激活" : "激活"}`, { type: "success" @@ -97,11 +100,10 @@ export function useData() { row.status == 2 ? (row.status = 1) : (row.status = 2); }); } - - } - const onSearch = async (formData) => { + }; + const onSearch = async formData => { loading.value = true; - searchForm.value = { ...formData } + searchForm.value = { ...formData }; const { data, code } = await queryTaskList({ ...formData, page: pagination.value.currentPage, @@ -109,14 +111,14 @@ export function useData() { }); if (code) { tableList.value = data.lists.map(ele => { - ele.is_active === 0 ? 2 : 1 - return ele + ele.is_active === 0 ? 2 : 1; + return ele; }); pagination.value.total = data.count; pagination.value.currentPage = data.page; Object.keys(data.task_type).forEach(ele => { - typeList.value.push({ id: +ele, value: data.task_type[ele] }) - }) + typeList.value.push({ id: +ele, value: data.task_type[ele] }); + }); } loading.value = false; }; @@ -140,7 +142,7 @@ export function useData() { closeOnClickModal: false, contentRenderer: () => h(detailView) }); - } + }; // 新增 const openDialog = (title = "新增", rowData: any) => { addDialog({ @@ -179,6 +181,21 @@ export function useData() { } }); }; + // 获取任务类型列表 + const fetchTaskTypeList = async () => { + const { data, code } = await getTaskTypeList(); + if (code) { + const options = Object.keys(data).map(key => ({ + label: data[key], + value: parseInt(key) + })); + searchLabel.value[0].optionList = options; + } + }; + // 初始化时获取任务类型列表 + onMounted(() => { + fetchTaskTypeList(); + }); return { searchForm, searchLabel,