import { ref, h } from "vue"; import { message } from "@/utils/message"; import { queryHeadlinesList, deleteHeadlines, hideHeadlines } from "@/api/modules/room"; export function useData() { const loading = ref(true); const tableList = ref([]); const isShow = ref(false); const searchForm = ref({ user_id: "", stime: "", etime: "" }); const searchLabel = ref([ { label: "用户ID", prop: "user_id", type: "input" }, { label: "开始时间", prop: "stime", type: "date" }, { label: "结束时间", prop: "etime", type: "date" } ]); const pagination = ref({ total: 0, pageSize: 10, pageSizes: [10, 20, 50, 100, 500, 1000, 2000], currentPage: 1, background: true }); const tableLabel = ref([ { label: "订单ID", prop: "id" }, { label: "用户账号-昵称", prop: "user_name" }, // { // label: "房间ID-房间昵称", // prop: "user_nickname" // }, { label: "头条内容", prop: "content" }, // { // label: "查看数", // prop: "is_now" // }, { label: "支付金额", prop: "money" }, { label: "状态", prop: "status", }, { label: "创建时间", prop: "createtime" }, { label: "操作", fixed: "right", width: 210, slot: "operation" } ]); const onSearch = async (formData) => { loading.value = true; searchForm.value = { ...formData } const { data, code } = await queryHeadlinesList({ ...formData, page: pagination.value.currentPage, page_limit: pagination.value.pageSize }); if (code) { tableList.value = data.lists; pagination.value.total = data.count; pagination.value.currentPage = data.page; } loading.value = false; }; const handleSizeChange = (val: number) => { pagination.value.pageSize = val; onSearch(searchForm.value); }; const handleCurrentChange = (val: number) => { pagination.value.currentPage = val; onSearch(searchForm.value); }; const handleDetele = async rowData => { const { code } = await deleteHeadlines({ id: rowData.id }); if (code) { message(`您封禁了房间名称为【${rowData.room_name}】的这条数据`, { type: "success" }); onSearch(searchForm.value); } }; return { searchForm, searchLabel, onSearch, isShow, tableList, tableLabel, pagination, handleSizeChange, handleCurrentChange, loading, handleDetele }; }