This commit is contained in:
yziiy
2026-01-23 14:05:07 +08:00
parent aa5328d784
commit 2b609b9e03
2 changed files with 44 additions and 23 deletions

View File

@@ -138,6 +138,10 @@ export const upadteTaskData = data => {
data data
}); });
}; };
// 获取任务类型列表
export const getTaskTypeList = () => {
return http.request<Result>("get", "/adminapi/Tasks/task_type_list");
};
// 二级密码校验 // 二级密码校验
export const checkPassWord = data => { export const checkPassWord = data => {

View File

@@ -1,13 +1,14 @@
import { ref, h } from "vue"; import { ref, h, onMounted } from "vue";
import editForm from "./form.vue"; import editForm from "./form.vue";
import { message } from "@/utils/message"; import { message } from "@/utils/message";
import { ElMessageBox } from "element-plus"; import { ElMessageBox } from "element-plus";
import { import {
queryTaskList, queryTaskList,
editTaskData, editTaskData,
upadteTaskData upadteTaskData,
getTaskTypeList
} from "@/api/modules/system"; } from "@/api/modules/system";
import detailView from './Reward/index.vue' import detailView from "./Reward/index.vue";
import { addDialog } from "@/components/ReDialog"; import { addDialog } from "@/components/ReDialog";
export function useData() { export function useData() {
const formRef = ref(); const formRef = ref();
@@ -20,12 +21,10 @@ export function useData() {
}); });
const searchLabel = ref([ const searchLabel = ref([
{ {
label: "任务类型", prop: "task_type", type: "select", label: "任务类型",
optionList: [ prop: "task_type",
{ label: "每日任务", value: 1 }, type: "select",
{ label: "每日特殊任务", value: 2 }, optionList: []
{ label: "平台常规任务", value: 3 }
]
} }
]); ]);
const pagination = ref({ const pagination = ref({
@@ -60,8 +59,8 @@ export function useData() {
active-text="激活" active-text="激活"
inactive-text="未激活" inactive-text="未激活"
active-color="#13ce66" active-color="#13ce66"
inactive-color="#ff4949"> inactive-color="#ff4949"
</el-switch> ></el-switch>
) )
}, },
{ {
@@ -71,10 +70,11 @@ export function useData() {
slot: "operation" slot: "operation"
} }
]); ]);
const onChange = async (row) => { const onChange = async row => {
if (!loading.value) { if (!loading.value) {
ElMessageBox.confirm( ElMessageBox.confirm(
`确认要<strong>${row.is_active === 2 ? "未激活" : "激活" `确认要<strong>${
row.is_active === 2 ? "未激活" : "激活"
}</strong><strong style='color:var(--el-color-primary)'></strong>吗?`, }</strong><strong style='color:var(--el-color-primary)'></strong>吗?`,
"系统提示", "系统提示",
{ {
@@ -86,7 +86,10 @@ export function useData() {
} }
) )
.then(async () => { .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) { if (code) {
message(`${row.status === 2 ? "未激活" : "激活"}`, { message(`${row.status === 2 ? "未激活" : "激活"}`, {
type: "success" type: "success"
@@ -97,11 +100,10 @@ export function useData() {
row.status == 2 ? (row.status = 1) : (row.status = 2); row.status == 2 ? (row.status = 1) : (row.status = 2);
}); });
} }
};
} const onSearch = async formData => {
const onSearch = async (formData) => {
loading.value = true; loading.value = true;
searchForm.value = { ...formData } searchForm.value = { ...formData };
const { data, code } = await queryTaskList({ const { data, code } = await queryTaskList({
...formData, ...formData,
page: pagination.value.currentPage, page: pagination.value.currentPage,
@@ -109,14 +111,14 @@ export function useData() {
}); });
if (code) { if (code) {
tableList.value = data.lists.map(ele => { tableList.value = data.lists.map(ele => {
ele.is_active === 0 ? 2 : 1 ele.is_active === 0 ? 2 : 1;
return ele return ele;
}); });
pagination.value.total = data.count; pagination.value.total = data.count;
pagination.value.currentPage = data.page; pagination.value.currentPage = data.page;
Object.keys(data.task_type).forEach(ele => { 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; loading.value = false;
}; };
@@ -140,7 +142,7 @@ export function useData() {
closeOnClickModal: false, closeOnClickModal: false,
contentRenderer: () => h(detailView) contentRenderer: () => h(detailView)
}); });
} };
// 新增 // 新增
const openDialog = (title = "新增", rowData: any) => { const openDialog = (title = "新增", rowData: any) => {
addDialog({ 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 { return {
searchForm, searchForm,
searchLabel, searchLabel,