From d7eacafa3494e80125e011af4ebddc2e7e771f7d Mon Sep 17 00:00:00 2001 From: yziiy <15979918+mayday-yziiy@user.noreply.gitee.com> Date: Wed, 22 Oct 2025 10:33:35 +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/expression.ts | 61 +++++++++++ src/views/expression/form.vue | 135 +++++++++++++++++++++++ src/views/expression/hook.tsx | 189 +++++++++++++++++++++++++++++++++ src/views/expression/index.vue | 65 ++++++++++++ 4 files changed, 450 insertions(+) create mode 100644 src/api/modules/expression.ts create mode 100644 src/views/expression/form.vue create mode 100644 src/views/expression/hook.tsx create mode 100644 src/views/expression/index.vue diff --git a/src/api/modules/expression.ts b/src/api/modules/expression.ts new file mode 100644 index 0000000..c31908c --- /dev/null +++ b/src/api/modules/expression.ts @@ -0,0 +1,61 @@ +import { http } from "@/utils/http"; + +type Result = { + code: string; + data: any; +}; + +export const queryClassifyList = params => { + return http.request( + "get", + "/adminapi/RoomEmoji/emoji_type_list", + { params } + ); +}; + +// 分类新增 +// export const addClassifyData = data => { +// return http.request("post", "/adminapi/GiftLabel/add_label", { +// data +// }); +// } +// // 修改分类 +// export const editClassifyData = data => { +// return http.request("post", "/adminapi/GiftLabel/edit_label", { +// data +// }); +// } +// // 删除分类 +// export const removeClassifyData = data => { +// return http.request("post", "/adminapi/GiftLabel/del_label", { +// data +// }); +// }; +// 列表 +export const queryList = params => { + return http.request( + "get", + "/adminapi/RoomEmoji/emoji_list", + { params } + ); +}; + +// 新增 +export const addData = data => { + return http.request("post", "/adminapi/RoomEmoji/add_emoji", { + data + }); +} +// 编辑 +export const editData = data => { + return http.request("post", "/adminapi/RoomEmoji/edit_emoji", { + data + }); +} + +// 删除 +export const removeData = data => { + return http.request("post", "/adminapi/RoomEmoji/del_emoji", { + data + }); +}; \ No newline at end of file diff --git a/src/views/expression/form.vue b/src/views/expression/form.vue new file mode 100644 index 0000000..feb0768 --- /dev/null +++ b/src/views/expression/form.vue @@ -0,0 +1,135 @@ + + + diff --git a/src/views/expression/hook.tsx b/src/views/expression/hook.tsx new file mode 100644 index 0000000..ac2f923 --- /dev/null +++ b/src/views/expression/hook.tsx @@ -0,0 +1,189 @@ +import { ref, h } from "vue"; +import editForm from "./form.vue"; +import { message } from "@/utils/message"; +import { + queryList, + addData, + editData, + removeData +} from "@/api/modules/expression"; +import { addDialog } from "@/components/ReDialog"; + +export function useData() { + const formRef = ref(); + const loading = ref(true); + const tableList = ref([]); + const isShow = ref(false); + const searchForm = ref({ + id: "", + name: "" + }); + const searchLabel = ref([ + { label: "表情ID", prop: "id", type: "input" }, + { label: "表情名称", prop: "name", type: "input" } + ]); + const pagination = ref({ + total: 0, + pageSize: 10, + pageSizes: [10, 20, 50, 100], + currentPage: 1, + background: true + }); + const tableLabel = ref([ + { + label: "ID", + prop: "id" + }, + { + label: "表情名称", + prop: "gift_name" + }, + { + label: "图片", + prop: "base_image", + cellRenderer: ({ row }) => ( + + ) + }, + { + label: "状态", + prop: "is_can_buy", + cellRenderer: ({ row }) => ( + {row.is_can_buy === 1 ? '可购买' : '禁止购买'} + ) + }, + { + label: "修改时间", + prop: "createtime" + }, + { + label: "创建时间", + prop: "createtime" + }, + { + label: "操作", + fixed: "right", + width: 210, + slot: "operation" + } + ]); + const onSearch = async (formData) => { + loading.value = true; + searchForm.value = { ...formData } + const { data, code } = await queryList({ + ...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 handleDelete = async rowData => { + const { code } = await removeGiftData({ gid: rowData.gid }); + if (code) { + message(`您删除了礼物名称为【${rowData.gift_name}】的这条数据`, { + type: "success" + }); + onSearch(searchForm.value); + } + }; + // 新增 + const openDialog = async (title = "新增", rowData: any) => { + const { data, code } = await getGiftInfo({ gid: rowData.gid }) + addDialog({ + title: `${title}礼物`, + props: { + formInline: { + gift_name: rowData?.gift_name ?? "", + type: data?.type ?? "", + label: data?.label ?? "", + base_image: rowData?.base_image ?? "", + gift_price: rowData?.gift_price ?? "", + file_type: data?.file_type ?? "", + play_image: data?.play_image ?? "", + gift_type: data?.gift_type ?? "", + is_public_screen: rowData?.is_public_screen ?? "", + is_public_server: rowData?.is_public_server ?? "", + is_show: rowData?.is_show ?? "", + is_can_buy: rowData?.is_can_buy ?? "", + sort: rowData?.sort ?? "" + } + }, + width: "40%", + closeOnClickModal: false, + contentRenderer: () => h(editForm, { ref: formRef, formInline: null }), + beforeSure: (done, { options }) => { + const FormRef = formRef.value.getRef(); + const curData = options.props.formInline; + const saveData = async form => { + const { code, msg } = await addGiftData(form); + if (code) { + message("新增成功", { type: "success" }); + onSearch(searchForm.value); + done(); + } else { + message(msg, { type: "error" }); + } + }; + const updateData = async form => { + const { code, msg } = await editGiftData({ + ...form, + gid: rowData.gid + }); + if (code) { + message("修改成功", { type: "success" }); + onSearch(searchForm.value); + done(); + } else { + message(msg, { type: "error" }); + } + }; + FormRef.validate(valid => { + if (valid) { + console.log("curData", curData); + // 表单规则校验通过 + if (title === "新增") { + // 实际开发先调用新增接口,再进行下面操作 + saveData(curData); + } else { + // 实际开发先调用修改接口,再进行下面操作 + updateData(curData); + } + } + }); + } + }); + }; + return { + searchForm, + searchLabel, + onSearch, + isShow, + tableList, + tableLabel, + pagination, + handleSizeChange, + handleCurrentChange, + loading, + handleDelete, + openDialog + }; +} diff --git a/src/views/expression/index.vue b/src/views/expression/index.vue new file mode 100644 index 0000000..5b4df43 --- /dev/null +++ b/src/views/expression/index.vue @@ -0,0 +1,65 @@ + + + + +