diff --git a/src/views/Activities/RechargeList/hook.tsx b/src/views/Activities/RechargeList/hook.tsx index e04da7c..305833b 100644 --- a/src/views/Activities/RechargeList/hook.tsx +++ b/src/views/Activities/RechargeList/hook.tsx @@ -1,8 +1,9 @@ import { ref, h } from "vue"; import editForm from "./form.vue"; import { message } from "@/utils/message"; +import { verifyPassword } from "@/utils/passwordVerify"; import recordList from "./record.vue"; -import giftPackView from '../giftPack/index.vue'; +import giftPackView from "../giftPack/index.vue"; import { queryFirstCharge, addChargeTypeData, @@ -80,13 +81,16 @@ export function useData() { onSearch(); }; const handleDelete = async rowData => { - const { code } = await deteleChargeTypeData({ id: rowData.id }); - if (code) { - message(`您删除了名称为${rowData.name}的这条数据`, { - type: "success" - }); - onSearch(); - } + // 删除需要二级密码验证 + verifyPassword(async () => { + const { code } = await deteleChargeTypeData({ id: rowData.id }); + if (code) { + message(`您删除了名称为${rowData.name}的这条数据`, { + type: "success" + }); + onSearch(); + } + }); }; const DistributionRecord = () => { addDialog({ @@ -94,10 +98,10 @@ export function useData() { width: "60%", closeOnClickModal: false, hideFooter: true, - contentRenderer: () => h(recordList, { ref: formRef, formInline: null }), + contentRenderer: () => h(recordList, { ref: formRef, formInline: null }) }); }; - // 新增 + // 新增/编辑首充分类 const openDialog = (title = "新增", rowData: any) => { addDialog({ title: `${title}首充分类`, @@ -117,40 +121,37 @@ export function useData() { beforeSure: (done, { options }) => { const FormRef = formRef.value.getRef(); const curData = options.props.formInline; - const saveData = async form => { - const { code } = await addChargeTypeData(form); - if (code) { - message("新增成功", { type: "success" }); - onSearch(); - done(); + + FormRef.validate(async valid => { + if (!valid) return; + + if (title === "新增") { + // 增加首充类型 - 需要二级密码验证 + verifyPassword(async () => { + const { code } = await addChargeTypeData(curData); + if (code) { + message("新增成功", { type: "success" }); + onSearch(); + done(); + } else { + message("新增失败", { type: "error" }); + } + }); } else { - message("新增失败", { type: "error" }); - } - }; - const updateData = async form => { - const { code } = await editChargeTypeData({ - ...form, - id: rowData.id - }); - if (code) { - message("修改成功", { type: "success" }); - onSearch(); - done(); - } else { - message("修改失败", { type: "error" }); - } - }; - FormRef.validate(valid => { - if (valid) { - console.log("curData", curData); - // 表单规则校验通过 - if (title === "新增") { - // 实际开发先调用新增接口,再进行下面操作 - saveData(curData); - } else { - // 实际开发先调用修改接口,再进行下面操作 - updateData(curData); - } + // 编辑操作 - 需要二级密码验证 + verifyPassword(async () => { + const { code } = await editChargeTypeData({ + ...curData, + id: rowData.id + }); + if (code) { + message("修改成功", { type: "success" }); + onSearch(); + done(); + } else { + message("修改失败", { type: "error" }); + } + }); } }); } @@ -166,9 +167,9 @@ export function useData() { props: { rowData }, - contentRenderer: () => h(giftPackView, { ref: formRef, formInline: null }), + contentRenderer: () => h(giftPackView, { ref: formRef, formInline: null }) }); - } + }; return { onSearch, isShow, diff --git a/src/views/Activities/giftPack/hook.tsx b/src/views/Activities/giftPack/hook.tsx index 60ed859..b1f4bdc 100644 --- a/src/views/Activities/giftPack/hook.tsx +++ b/src/views/Activities/giftPack/hook.tsx @@ -1,6 +1,7 @@ import { ref, h, nextTick } from "vue"; import editForm from "./form.vue"; import { message } from "@/utils/message"; +import { verifyPassword } from "@/utils/passwordVerify"; import { queryGiftPack, addGiftPackData, @@ -10,7 +11,7 @@ import { import { addDialog } from "@/components/ReDialog"; export function useData() { const formRef = ref(); - const propRowData = ref(null) + const propRowData = ref(null); const loading = ref(true); const tableList = ref([]); const isShow = ref(false); @@ -66,8 +67,8 @@ export function useData() { slot: "operation" } ]); - const onSearch = async (rowData) => { - propRowData.value = { ...rowData } + const onSearch = async rowData => { + propRowData.value = { ...rowData }; loading.value = true; const { data, code } = await queryGiftPack({ gift_bag_id: propRowData.value.id, @@ -78,7 +79,7 @@ export function useData() { tableList.value = data.lists.map(ele => { return { ...ele - } + }; }); pagination.value.total = data.count; pagination.value.currentPage = data.page; @@ -93,7 +94,7 @@ export function useData() { pagination.value.currentPage = val; onSearch(propRowData.value); }; - // 新增 + // 新增/编辑礼物 const openDialog = (title = "新增", rowData: any) => { addDialog({ title: `${title}礼物`, @@ -102,8 +103,7 @@ export function useData() { type: rowData?.type ?? "", num: rowData?.num ?? "", gift_id: rowData?.gift_id ?? "", - gift_bag_id: propRowData.value.id ?? "", - + gift_bag_id: propRowData.value.id ?? "" } }, width: "40%", @@ -112,53 +112,51 @@ export function useData() { beforeSure: (done, { options }) => { const FormRef = formRef.value.getRef(); const curData = options.props.formInline; - const saveData = async form => { - const { code } = await addGiftPackData(form); - if (code) { - message("新增成功", { type: "success" }); - onSearch(propRowData.value); - done(); - } else { - message("新增失败", { type: "error" }); - } - }; - const updateData = async form => { - const { code } = await editGiftPackData({ - ...form, - id: rowData.id - }); - if (code) { - message("修改成功", { type: "success" }); - onSearch(propRowData.value); - done(); - } else { - message("修改失败", { type: "error" }); - } - }; - FormRef.validate(valid => { - if (valid) { - console.log("curData", curData); - // 表单规则校验通过 - if (title === "新增") { - // 实际开发先调用新增接口,再进行下面操作 - saveData(curData); + + FormRef.validate(async valid => { + if (!valid) return; + + if (title === "新增") { + // 新增操作 + const { code } = await addGiftPackData(curData); + if (code) { + message("新增成功", { type: "success" }); + onSearch(propRowData.value); + done(); } else { - // 实际开发先调用修改接口,再进行下面操作 - updateData(curData); + message("新增失败", { type: "error" }); } + } else { + // 编辑操作 - 需要二级密码验证 + verifyPassword(async () => { + const { code } = await editGiftPackData({ + ...curData, + id: rowData.id + }); + if (code) { + message("修改成功", { type: "success" }); + onSearch(propRowData.value); + done(); + } else { + message("修改失败", { type: "error" }); + } + }); } }); } }); }; const handleDelete = async rowData => { - const { code } = await deteleGiftPackData({ id: rowData.id }); - if (code) { - message(`您删除了名称为${rowData.name}的这条数据`, { - type: "success" - }); - onSearch(propRowData.value); - } + // 删除需要二级密码验证 + verifyPassword(async () => { + const { code } = await deteleGiftPackData({ id: rowData.id }); + if (code) { + message(`您删除了名称为${rowData.name}的这条数据`, { + type: "success" + }); + onSearch(propRowData.value); + } + }); }; return { onSearch, diff --git a/src/views/Activities/goodGift/giftPack/hook.tsx b/src/views/Activities/goodGift/giftPack/hook.tsx index d203a04..254f838 100644 --- a/src/views/Activities/goodGift/giftPack/hook.tsx +++ b/src/views/Activities/goodGift/giftPack/hook.tsx @@ -1,6 +1,7 @@ -import { ref, h, nextTick } from "vue"; +import { ref, h } from "vue"; import editForm from "./form.vue"; import { message } from "@/utils/message"; +import { verifyPassword } from "@/utils/passwordVerify"; import { queryGiftPack, addGiftPackData, @@ -10,7 +11,7 @@ import { import { addDialog } from "@/components/ReDialog"; export function useData() { const formRef = ref(); - const propRowData = ref(null) + const propRowData = ref(null); const loading = ref(true); const tableList = ref([]); const isShow = ref(false); @@ -66,8 +67,8 @@ export function useData() { slot: "operation" } ]); - const onSearch = async (rowData) => { - propRowData.value = { ...rowData } + const onSearch = async rowData => { + propRowData.value = { ...rowData }; loading.value = true; const { data, code } = await queryGiftPack({ gift_bag_id: propRowData.value.id, @@ -78,7 +79,7 @@ export function useData() { tableList.value = data.lists.map(ele => { return { ...ele - } + }; }); pagination.value.total = data.count; pagination.value.currentPage = data.page; @@ -93,7 +94,7 @@ export function useData() { pagination.value.currentPage = val; onSearch(propRowData.value); }; - // 新增 + // 新增/编辑礼物 const openDialog = (title = "新增", rowData: any) => { addDialog({ title: `${title}礼物`, @@ -102,8 +103,7 @@ export function useData() { type: rowData?.type ?? "", num: rowData?.num ?? "", gift_id: rowData?.gift_id ?? "", - gift_bag_id: propRowData.value.id, - + gift_bag_id: propRowData.value.id } }, width: "40%", @@ -112,53 +112,51 @@ export function useData() { beforeSure: (done, { options }) => { const FormRef = formRef.value.getRef(); const curData = options.props.formInline; - const saveData = async form => { - const { code } = await addGiftPackData(form); - if (code) { - message("新增成功", { type: "success" }); - onSearch(propRowData.value); - done(); - } else { - message("新增失败", { type: "error" }); - } - }; - const updateData = async form => { - const { code } = await editGiftPackData({ - ...form, - id: rowData.id - }); - if (code) { - message("修改成功", { type: "success" }); - onSearch(propRowData.value); - done(); - } else { - message("修改失败", { type: "error" }); - } - }; - FormRef.validate(valid => { - if (valid) { - console.log("curData", curData); - // 表单规则校验通过 - if (title === "新增") { - // 实际开发先调用新增接口,再进行下面操作 - saveData(curData); + + FormRef.validate(async valid => { + if (!valid) return; + + if (title === "新增") { + // 新增操作 + const { code } = await addGiftPackData(curData); + if (code) { + message("新增成功", { type: "success" }); + onSearch(propRowData.value); + done(); } else { - // 实际开发先调用修改接口,再进行下面操作 - updateData(curData); + message("新增失败", { type: "error" }); } + } else { + // 编辑操作 - 需要二级密码验证 + verifyPassword(async () => { + const { code } = await editGiftPackData({ + ...curData, + id: rowData.id + }); + if (code) { + message("修改成功", { type: "success" }); + onSearch(propRowData.value); + done(); + } else { + message("修改失败", { type: "error" }); + } + }); } }); } }); }; const handleDelete = async rowData => { - const { code } = await deteleGiftPackData({ id: rowData.id }); - if (code) { - message(`您删除了名称为${rowData.name}的这条数据`, { - type: "success" - }); - onSearch(propRowData.value); - } + // 删除需要二级密码验证 + verifyPassword(async () => { + const { code } = await deteleGiftPackData({ id: rowData.id }); + if (code) { + message(`您删除了名称为${rowData.name}的这条数据`, { + type: "success" + }); + onSearch(propRowData.value); + } + }); }; return { onSearch, diff --git a/src/views/Activities/goodGift/hook.tsx b/src/views/Activities/goodGift/hook.tsx index 4303ad6..6412378 100644 --- a/src/views/Activities/goodGift/hook.tsx +++ b/src/views/Activities/goodGift/hook.tsx @@ -1,12 +1,10 @@ import { ref, h, nextTick } from "vue"; import editForm from "./form.vue"; import { message } from "@/utils/message"; -import recordList from "./record.vue" -import giftPackView from './giftPack/index.vue'; -import { - getGoodGiftInfo, - setGoodGiftConfig -} from "@/api/modules/activities"; +import { verifyPassword } from "@/utils/passwordVerify"; +import recordList from "./record.vue"; +import giftPackView from "./giftPack/index.vue"; +import { getGoodGiftInfo, setGoodGiftConfig } from "@/api/modules/activities"; import { addDialog } from "@/components/ReDialog"; export function useData() { const formRef = ref(); @@ -37,8 +35,10 @@ export function useData() { label: "状态", prop: "status", cellRenderer: ({ row }) => ( - {row.status === 1 ? '正常' : '隐藏'} - ), + + {row.status === 1 ? "正常" : "隐藏"} + + ) }, { label: "介绍内容", @@ -58,6 +58,7 @@ export function useData() { }, { label: "操作", + width: 220, fixed: "right", slot: "operation" } @@ -84,9 +85,9 @@ export function useData() { onSearch(); }; const setConfig = async () => { - let rowData = {} - const { data, code } = await getGoodGiftInfo({}) - rowData = code ? data : null + let rowData = {}; + const { data, code } = await getGoodGiftInfo({}); + rowData = code ? data : null; nextTick(() => { addDialog({ title: `设置配置`, @@ -99,7 +100,7 @@ export function useData() { money: rowData?.money ?? "", money_str: rowData?.money_str ?? "", diamond: rowData?.diamond ?? "", - activity_end_time: rowData?.activity_end_time ?? "", + activity_end_time: rowData?.activity_end_time ?? "" } }, width: "40%", @@ -108,26 +109,25 @@ export function useData() { beforeSure: (done, { options }) => { const FormRef = formRef.value.getRef(); const curData = options.props.formInline; - const saveData = async form => { - const { code } = await setGoodGiftConfig(form); - if (code) { - message("新增成功", { type: "success" }); - onSearch(); - done(); - } else { - message("新增失败", { type: "error" }); - } - }; - FormRef.validate(valid => { - if (valid) { - // console.log("curData", curData); - saveData(curData); - } + + FormRef.validate(async valid => { + if (!valid) return; + + // 设置配置需要二级密码验证 + verifyPassword(async () => { + const { code } = await setGoodGiftConfig(curData); + if (code) { + message("设置成功", { type: "success" }); + onSearch(); + done(); + } else { + message("设置失败", { type: "error" }); + } + }); }); } }); - }) - + }); }; const DistributionRecord = () => { addDialog({ @@ -135,10 +135,10 @@ export function useData() { width: "60%", closeOnClickModal: false, hideFooter: true, - contentRenderer: () => h(recordList, { ref: formRef, formInline: null }), + contentRenderer: () => h(recordList, { ref: formRef, formInline: null }) }); }; - const openGiftPark = (rowData) => { + const openGiftPark = rowData => { addDialog({ title: `礼包列表`, width: "60%", @@ -147,9 +147,9 @@ export function useData() { props: { rowData }, - contentRenderer: () => h(giftPackView, { ref: formRef, formInline: null }), + contentRenderer: () => h(giftPackView, { ref: formRef, formInline: null }) }); - } + }; return { onSearch, isShow, diff --git a/src/views/Activities/newcomer/hook.tsx b/src/views/Activities/newcomer/hook.tsx index 3cda29b..014e8bb 100644 --- a/src/views/Activities/newcomer/hook.tsx +++ b/src/views/Activities/newcomer/hook.tsx @@ -1,8 +1,9 @@ import { ref, h } from "vue"; import editForm from "./form.vue"; import { message } from "@/utils/message"; +import { verifyPassword } from "@/utils/passwordVerify"; import recordList from "./record.vue"; -import giftPackView from '../giftPack/index.vue'; +import giftPackView from "../giftPack/index.vue"; import { queryFirstCharge, addChargeTypeData, @@ -95,10 +96,10 @@ export function useData() { width: "60%", closeOnClickModal: false, hideFooter: true, - contentRenderer: () => h(recordList, { ref: formRef, formInline: null }), + contentRenderer: () => h(recordList, { ref: formRef, formInline: null }) }); }; - // 新增 + // 新增/编辑新人礼包 const openDialog = (title = "新增", rowData: any) => { addDialog({ title: `${title}首充分类`, @@ -118,41 +119,39 @@ export function useData() { beforeSure: (done, { options }) => { const FormRef = formRef.value.getRef(); const curData = options.props.formInline; - const saveData = async form => { - const { code } = await addChargeTypeData({ ...form, activities_id: 7 }); - if (code) { - message("新增成功", { type: "success" }); - onSearch(); - done(); - } else { - message("新增失败", { type: "error" }); - } - }; - const updateData = async form => { - const { code } = await editChargeTypeData({ - ...form, - id: rowData.id, - activities_id: 7 - }); - if (code) { - message("修改成功", { type: "success" }); - onSearch(); - done(); - } else { - message("修改失败", { type: "error" }); - } - }; - FormRef.validate(valid => { - if (valid) { - console.log("curData", curData); - // 表单规则校验通过 - if (title === "新增") { - // 实际开发先调用新增接口,再进行下面操作 - saveData(curData); + + FormRef.validate(async valid => { + if (!valid) return; + + if (title === "新增") { + // 新增操作 + const { code } = await addChargeTypeData({ + ...curData, + activities_id: 7 + }); + if (code) { + message("新增成功", { type: "success" }); + onSearch(); + done(); } else { - // 实际开发先调用修改接口,再进行下面操作 - updateData(curData); + message("新增失败", { type: "error" }); } + } else { + // 编辑操作 - 需要二级密码验证 + verifyPassword(async () => { + const { code } = await editChargeTypeData({ + ...curData, + id: rowData.id, + activities_id: 7 + }); + if (code) { + message("修改成功", { type: "success" }); + onSearch(); + done(); + } else { + message("修改失败", { type: "error" }); + } + }); } }); } @@ -168,9 +167,9 @@ export function useData() { props: { rowData }, - contentRenderer: () => h(giftPackView, { ref: formRef, formInline: null }), + contentRenderer: () => h(giftPackView, { ref: formRef, formInline: null }) }); - } + }; return { onSearch, isShow, diff --git a/src/views/Nobility/nobilityList/List/hook.tsx b/src/views/Nobility/nobilityList/List/hook.tsx index 844bc6e..0ef1629 100644 --- a/src/views/Nobility/nobilityList/List/hook.tsx +++ b/src/views/Nobility/nobilityList/List/hook.tsx @@ -1,6 +1,7 @@ import { ref, h } from "vue"; import editForm from "./form.vue"; import { message } from "@/utils/message"; +import { verifyPassword } from "@/utils/passwordVerify"; import { queryDecList, deleteDecData, @@ -44,7 +45,7 @@ export function useData() { preview-src-list={Array.of(row.decorate_image)} class="w-[24px] h-[24px] rounded-full align-middle" /> - ), + ) }, { label: "时长(天数)", @@ -59,12 +60,11 @@ export function useData() { ]); const onSearch = async () => { loading.value = true; - const { data, code } = await queryDecList - ({ - lid: detailData.value.lid, - page: pagination.value.currentPage, - page_limit: pagination.value.pageSize - }); + const { data, code } = await queryDecList({ + lid: detailData.value.lid, + page: pagination.value.currentPage, + page_limit: pagination.value.pageSize + }); if (code) { tableList.value = data.lists; pagination.value.total = data.count; @@ -81,13 +81,15 @@ export function useData() { onSearch(); }; const handleDelete = async rowData => { - const { code } = await deleteDecData({ id: rowData.id }); - if (code) { - message(`您删除了名称为${rowData.decorate_name}的这条数据`, { - type: "success" - }); - onSearch(); - } + verifyPassword(async () => { + const { code } = await deleteDecData({ id: rowData.id }); + if (code) { + message(`您删除了名称为${rowData.decorate_name}的这条数据`, { + type: "success" + }); + onSearch(); + } + }); }; // 新增 const openDialog = (title = "新增", rowData: any) => { @@ -105,23 +107,20 @@ export function useData() { beforeSure: (done, { options }) => { const FormRef = formRef.value.getRef(); const curData = options.props.formInline; - const saveData = async form => { - const { code, msg } = await addDecData({ - lid: detailData.value.lid, - dpid: form.dpid - }); - if (code) { - message("新增成功", { type: "success" }); - onSearch(); - done(); - } else { - message(msg, { type: "error" }); - } - }; - FormRef.validate(valid => { + + FormRef.validate(async valid => { if (valid) { - console.log("curData", curData); - saveData(curData); + verifyPassword(async () => { + const { code } = await addDecData({ + lid: detailData.value.lid, + dpid: curData.dpid + }); + if (code) { + message("新增成功", { type: "success" }); + onSearch(); + done(); + } + }); } }); } diff --git a/src/views/Nobility/nobilityList/hook.tsx b/src/views/Nobility/nobilityList/hook.tsx index 1e043d6..cff7739 100644 --- a/src/views/Nobility/nobilityList/hook.tsx +++ b/src/views/Nobility/nobilityList/hook.tsx @@ -1,7 +1,8 @@ import { ref, h } from "vue"; import editForm from "./form.vue"; -import attireList from './List/index.vue' +import attireList from "./List/index.vue"; import { message } from "@/utils/message"; +import { verifyPassword } from "@/utils/passwordVerify"; import { queryList, addNobilityData, @@ -41,7 +42,7 @@ export function useData() { preview-src-list={Array.of(row.image)} class="w-[24px] h-[24px] rounded-full align-middle" /> - ), + ) }, { label: "购买价格", @@ -92,13 +93,15 @@ export function useData() { onSearch(); }; const handleDelete = async rowData => { - const { code } = await deleteRobotData({ lid: rowData.lid }); - if (code) { - message(`您删除了名称为${rowData.name}的这条数据`, { - type: "success" - }); - onSearch(); - } + verifyPassword(async () => { + const { code } = await deleteRobotData({ lid: rowData.lid }); + if (code) { + message(`您删除了名称为${rowData.name}的这条数据`, { + type: "success" + }); + onSearch(); + } + }); }; const openList = (title = "爵位装扮", rowData: any) => { addDialog({ @@ -111,7 +114,7 @@ export function useData() { closeOnClickModal: false, contentRenderer: () => h(attireList) }); - } + }; // 新增 const openDialog = (title = "新增", rowData: any) => { addDialog({ @@ -127,10 +130,10 @@ export function useData() { renew_coin: rowData?.renew_coin ?? "", day: rowData?.day ?? "", nick_name_color: rowData?.nick_name_color ?? "", - power_ids: rowData?.power_ids ?? '', - nick_name_color_name: rowData?.nick_name_color_name ?? '', - play_image: rowData?.play_image ?? '', - enter_image: rowData?.enter_image ?? '', + power_ids: rowData?.power_ids ?? "", + nick_name_color_name: rowData?.nick_name_color_name ?? "", + play_image: rowData?.play_image ?? "", + enter_image: rowData?.enter_image ?? "" } }, width: "40%", @@ -139,39 +142,30 @@ export function useData() { beforeSure: (done, { options }) => { const FormRef = formRef.value.getRef(); const curData = options.props.formInline; - const saveData = async form => { - const { code, msg } = await addNobilityData(form); - if (code) { - message("新增成功", { type: "success" }); - onSearch(); - done(); - } else { - message(msg, { type: "error" }); - } - }; - const updateData = async form => { - const { code, msg } = await editNobilityData({ - ...form, - lid: rowData.lid - }); - if (code) { - message("修改成功", { type: "success" }); - onSearch(); - done(); - } else { - message(msg, { type: "error" }); - } - }; - FormRef.validate(valid => { + + FormRef.validate(async valid => { if (valid) { - console.log("curData", curData); - // 表单规则校验通过 if (title === "新增") { - // 实际开发先调用新增接口,再进行下面操作 - saveData(curData); + // 新增操作,不需要二级密码 + const { code } = await addNobilityData(curData); + if (code) { + message("新增成功", { type: "success" }); + onSearch(); + done(); + } } else { - // 实际开发先调用修改接口,再进行下面操作 - updateData(curData); + // 编辑操作,需要二级密码验证 + verifyPassword(async () => { + const { code } = await editNobilityData({ + ...curData, + lid: rowData.lid + }); + if (code) { + message("修改成功", { type: "success" }); + onSearch(); + done(); + } + }); } } }); diff --git a/src/views/dailyTasksBox/ActivitiesList/hook.tsx b/src/views/dailyTasksBox/ActivitiesList/hook.tsx index 39aec99..51ca067 100644 --- a/src/views/dailyTasksBox/ActivitiesList/hook.tsx +++ b/src/views/dailyTasksBox/ActivitiesList/hook.tsx @@ -1,7 +1,5 @@ import { ref, h } from "vue"; -import { - queryBoxTypeList -} from "@/api/modules/blindBox"; +import { queryBoxTypeList } from "@/api/modules/blindBox"; import { queryList, addActivitiesBox, @@ -11,9 +9,10 @@ import { setConfig } from "@/api/modules/activities"; import editForm from "./form.vue"; -import settingRuleView from './settingRule.vue' +import settingRuleView from "./settingRule.vue"; import { addDialog } from "@/components/ReDialog"; import { message } from "@/utils/message"; +import { verifyPassword } from "@/utils/passwordVerify"; export function useData() { const formRef = ref(); const loading = ref(true); @@ -29,8 +28,8 @@ export function useData() { const searchForm = ref({ user_id: "" }); - const activeName = ref(0) - const typeList = ref([]) + const activeName = ref(0); + const typeList = ref([]); const statisticsList = ref([ { label: "抽奖人数总计", prop: "total_count" }, { label: "抽奖价格总计", prop: "total_price" }, @@ -40,8 +39,8 @@ export function useData() { // { label: "高级礼盒收入总计", prop: "" }, { label: "今日抽奖价格", prop: "today_total_price" }, { label: "今日抽奖次数", prop: "today_total_count" } - ]) - const statisticsData = ref({}) + ]); + const statisticsData = ref({}); const searchLabel = ref([ { label: "用户ID", prop: "user_id", type: "input" } ]); @@ -98,23 +97,23 @@ export function useData() { slot: "operation" } ]); - const onSearch = async (formData) => { + const onSearch = async formData => { loading.value = true; - searchForm.value = { ...formData } + searchForm.value = { ...formData }; const { data, code } = await queryList({ ...formData, gift_bag_id: activeName.value, page: pagination.value.currentPage, - page_limit: pagination.value.pageSize, - + page_limit: pagination.value.pageSize }); if (code) { tableList.value = data.lists.map(ele => { return { - ...ele, ...data.total - } + ...ele, + ...data.total + }; }); - statisticsData.value = data.total_data + statisticsData.value = data.total_data; pagination.value.total = data.count; pagination.value.currentPage = data.page; } @@ -129,20 +128,22 @@ export function useData() { onSearch(searchForm.value); }; const getType = async () => { - const { code, data } = await queryBoxTypeList({ activities_id: 2 }) - typeList.value = code ? data.map(ele => { - return { - label: ele.name, - value: ele.id - } - }) : [] - if (code) handleClick(data[0].id) - } - const handleClick = (id) => { - activeName.value = id + const { code, data } = await queryBoxTypeList({ activities_id: 2 }); + typeList.value = code + ? data.map(ele => { + return { + label: ele.name, + value: ele.id + }; + }) + : []; + if (code) handleClick(data[0].id); + }; + const handleClick = id => { + activeName.value = id; onSearch(searchForm.value); - } - // + }; + // const resetSetting = async () => { // const { data, code } = await deletectivitiesBox({ // gift_bag_id: activeName.value @@ -153,16 +154,18 @@ export function useData() { // }); // handleClick(activeName.value); // } - - } + }; const handleDelete = async rowData => { - const { code } = await deletectivitiesBox({ id: rowData.id }); - if (code) { - message(`您删除了这条数据`, { - type: "success" - }); - onSearch(searchForm.value); - } + // 删除需要二级密码验证 + verifyPassword(async () => { + const { code } = await deletectivitiesBox({ id: rowData.id }); + if (code) { + message(`您删除了这条数据`, { + type: "success" + }); + onSearch(searchForm.value); + } + }); }; const openDialog = async (title = "新增", rowData: any) => { addDialog({ @@ -172,7 +175,7 @@ export function useData() { type: rowData?.gift_type ?? "", num: rowData?.quantity ?? "", gift_id: rowData?.gift_id ?? "", - gift_bag_id: rowData?.gift_bag_id ?? "", + gift_bag_id: rowData?.gift_bag_id ?? "" } }, width: "40%", @@ -181,51 +184,48 @@ export function useData() { beforeSure: (done, { options }) => { const FormRef = formRef.value.getRef(); const curData = options.props.formInline; - const saveData = async form => { - const { code } = await addActivitiesBox({ - ...form, - gift_bag_id: activeName.value, - }); - if (code) { - message("新增成功", { type: "success" }); - onSearch(searchForm.value); - done(); - } else { - message("新增失败", { type: "error" }); - } - }; - const updateData = async form => { - const { code, msg } = await editActivitiesBox({ - ...form, - gift_bag_id: activeName.value, - id: rowData.id - }); - 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); + + FormRef.validate(async valid => { + if (!valid) return; + + if (title === "新增") { + // 新增操作 + const { code } = await addActivitiesBox({ + ...curData, + gift_bag_id: activeName.value + }); + if (code) { + message("新增成功", { type: "success" }); + onSearch(searchForm.value); + done(); } else { - // 实际开发先调用修改接口,再进行下面操作 - updateData(curData); + message("新增失败", { type: "error" }); } + } else { + // 编辑操作 - 需要二级密码验证 + verifyPassword(async () => { + const { code, msg } = await editActivitiesBox({ + ...curData, + gift_bag_id: activeName.value, + id: rowData.id + }); + if (code) { + message("修改成功", { type: "success" }); + onSearch(searchForm.value); + done(); + } else { + message(msg, { type: "error" }); + } + }); } }); } }); }; const setting = async () => { - const { data, code } = await getActivitiesBoxInfo({ gift_bag_id: activeName.value }) + const { data, code } = await getActivitiesBoxInfo({ + gift_bag_id: activeName.value + }); addDialog({ title: `设置礼盒规则`, props: { @@ -235,30 +235,31 @@ export function useData() { }, width: "40%", closeOnClickModal: false, - contentRenderer: () => h(settingRuleView, { ref: formRef, formInline: null }), + contentRenderer: () => + h(settingRuleView, { ref: formRef, formInline: null }), beforeSure: (done, { options }) => { const FormRef = formRef.value.getRef(); const curData = options.props.formInline; - const saveData = async form => { - const { code } = await setConfig({ ...form }); - if (code) { - message("设置成功", { type: "success" }); - onSearch(searchForm.value); - done(); - } else { - message("设置失败", { type: "error" }); - } - }; - FormRef.validate(valid => { - if (valid) { - // console.log(curData) - curData.gift_bag_id = activeName.value - saveData(curData) - } + + FormRef.validate(async valid => { + if (!valid) return; + + // 设置规则需要二级密码验证 + verifyPassword(async () => { + curData.gift_bag_id = activeName.value; + const { code } = await setConfig({ ...curData }); + if (code) { + message("设置成功", { type: "success" }); + onSearch(searchForm.value); + done(); + } else { + message("设置失败", { type: "error" }); + } + }); }); } }); - } + }; return { searchForm, searchLabel, @@ -281,4 +282,4 @@ export function useData() { handleDelete, setting }; -} \ No newline at end of file +} diff --git a/src/views/paradise/paradiseList/hook.tsx b/src/views/paradise/paradiseList/hook.tsx index 262d15a..05de27e 100644 --- a/src/views/paradise/paradiseList/hook.tsx +++ b/src/views/paradise/paradiseList/hook.tsx @@ -9,9 +9,10 @@ import { settingXunLeRule } from "@/api/modules/blindBox"; import editForm from "./form.vue"; -import settingRuleView from './settingRule.vue' +import settingRuleView from "./settingRule.vue"; import { addDialog } from "@/components/ReDialog"; import { message } from "@/utils/message"; +import { verifyPassword } from "@/utils/passwordVerify"; export function useData() { const formRef = ref(); const loading = ref(true); @@ -26,19 +27,20 @@ export function useData() { }); const searchForm = ref({ gift_id: "", - gift_name: "", + gift_name: "" }); - const activeName = ref(13) - const typeList = ref([]) + const activeName = ref(13); + const typeList = ref([]); const statisticsList = ref([ { label: "每期总次数", prop: "total_count" }, { label: "每期总礼物价值(收入)", prop: "total_price" }, { - label: "每期总抽奖花费(支出)", prop: "total_cost" + label: "每期总抽奖花费(支出)", + prop: "total_cost" }, { label: "每期统计(收入/支出)", prop: "profit_loss_ratio", tip: "%" } - ]) - const statisticsData = ref({}) + ]); + const statisticsData = ref({}); const searchLabel = ref([ { label: "礼物ID", prop: "gift_id", type: "input" }, { label: "礼物名称", prop: "gift_name", type: "input" } @@ -85,21 +87,27 @@ export function useData() { label: "公屏", prop: "is_public_screen", cellRenderer: ({ row }) => ( - {row.is_public_screen === 1 ? '显示' : '隐藏'} + + {row.is_public_screen === 1 ? "显示" : "隐藏"} + ) }, { label: "全服显示", prop: "is_public_server", cellRenderer: ({ row }) => ( - {row.is_public_server === 1 ? '显示' : '隐藏'} + + {row.is_public_server === 1 ? "显示" : "隐藏"} + ) }, { label: "榜单显示", prop: "is_world_show", cellRenderer: ({ row }) => ( - {row.is_world_show === 1 ? '显示' : '隐藏'} + + {row.is_world_show === 1 ? "显示" : "隐藏"} + ) }, { @@ -113,23 +121,23 @@ export function useData() { slot: "operation" } ]); - const onSearch = async (formData) => { + const onSearch = async formData => { loading.value = true; - searchForm.value = { ...formData } + searchForm.value = { ...formData }; const { data, code } = await queryBlindBoxList({ ...formData, gift_bag_id: activeName.value, page: pagination.value.currentPage, - page_limit: pagination.value.pageSize, - + page_limit: pagination.value.pageSize }); if (code) { tableList.value = data.lists.map(ele => { return { - ...ele, ...data.total - } + ...ele, + ...data.total + }; }); - statisticsData.value = data.total_data + statisticsData.value = data.total_data; pagination.value.total = data.count; pagination.value.currentPage = data.page; } @@ -144,25 +152,30 @@ export function useData() { onSearch(searchForm.value); }; const resetSetting = async () => { - const { data, code } = await resetBlindBoxRule({ - gift_bag_id: activeName.value - }) - if (code) { - message(`重置成功`, { - type: "success" + // 重置数量需要二级密码验证 + verifyPassword(async () => { + const { code } = await resetBlindBoxRule({ + gift_bag_id: activeName.value }); - onSearch(searchForm.value); - } - - } + if (code) { + message(`重置成功`, { + type: "success" + }); + onSearch(searchForm.value); + } + }); + }; const handleDelete = async rowData => { - const { code } = await removeBlindBoxData({ id: rowData.id }); - if (code) { - message(`您删除了这条数据`, { - type: "success" - }); - onSearch(searchForm.value); - } + // 删除需要二级密码验证 + verifyPassword(async () => { + const { code } = await removeBlindBoxData({ id: rowData.id }); + if (code) { + message(`您删除了这条数据`, { + type: "success" + }); + onSearch(searchForm.value); + } + }); }; const openDialog = async (title = "新增", rowData: any) => { addDialog({ @@ -172,7 +185,7 @@ export function useData() { gift_id: rowData?.gift_id ?? "", quantity: rowData?.quantity ?? 1, weight: rowData?.weight ?? 1, - is_world_show: rowData?.is_world_show ?? 1, + is_world_show: rowData?.is_world_show ?? 1 } }, width: "40%", @@ -181,54 +194,51 @@ export function useData() { beforeSure: (done, { options }) => { const FormRef = formRef.value.getRef(); const curData = options.props.formInline; - const saveData = async form => { - const { code } = await addBlindBoxData({ - ...form, - gift_bag_id: activeName.value, - }); - if (code) { - message("新增成功", { type: "success" }); - onSearch(searchForm.value); - done(); + + FormRef.validate(async valid => { + if (!valid) return; + + if (title === "新增") { + // 添加操作 - 需要二级密码验证 + verifyPassword(async () => { + const { code } = await addBlindBoxData({ + ...curData, + gift_bag_id: activeName.value + }); + if (code) { + message("新增成功", { type: "success" }); + onSearch(searchForm.value); + done(); + } else { + message("新增失败", { type: "error" }); + } + }); } else { - message("新增失败", { type: "error" }); - } - }; - const updateData = async form => { - const { code, msg } = await editBlindBoxData({ - ...form, - gift_bag_id: activeName.value, - id: rowData.id - }); - 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); - } + // 编辑操作 - 需要二级密码验证 + verifyPassword(async () => { + const { code, msg } = await editBlindBoxData({ + ...curData, + gift_bag_id: activeName.value, + id: rowData.id + }); + if (code) { + message("修改成功", { type: "success" }); + onSearch(searchForm.value); + done(); + } else { + message(msg, { type: "error" }); + } + }); } }); } }); }; - const addGiftData = async () => { - - } + const addGiftData = async () => {}; const setting = async () => { - const { data, code } = await getXunLeRule({ gift_bag_id: activeName.value }) + const { data, code } = await getXunLeRule({ + gift_bag_id: activeName.value + }); addDialog({ title: `设置巡乐会规则`, props: { @@ -239,7 +249,8 @@ export function useData() { start_num: data.open_condition.start_num, selected_gift_id: +data.locking_condition.selected_gift_id, locking_gift_id: +data.locking_condition.locking_gift_id, - give_homeowner_gift_id: +data.locking_condition.give_homeowner_gift_id, + give_homeowner_gift_id: + +data.locking_condition.give_homeowner_gift_id, end_time: data.locking_time.end_time, tow_no_locking_time: data.locking_time.tow_no_locking_time, next_time: data.locking_time.next_time, @@ -248,29 +259,30 @@ export function useData() { }, width: "60%", closeOnClickModal: false, - contentRenderer: () => h(settingRuleView, { ref: formRef, formInline: null }), + contentRenderer: () => + h(settingRuleView, { ref: formRef, formInline: null }), beforeSure: (done, { options }) => { const FormRef = formRef.value.getRef(); const curData = options.props.formInline; - const saveData = async form => { - const { code } = await settingXunLeRule({ ...form }); - if (code) { - message("设置成功", { type: "success" }); - onSearch(searchForm.value); - done(); - } else { - message("设置失败", { type: "error" }); - } - }; - FormRef.validate(valid => { - if (valid) { - // console.log("curData", curData); - saveData(curData) - } + + FormRef.validate(async valid => { + if (!valid) return; + + // 设置规则需要二级密码验证 + verifyPassword(async () => { + const { code } = await settingXunLeRule({ ...curData }); + if (code) { + message("设置成功", { type: "success" }); + onSearch(searchForm.value); + done(); + } else { + message("设置失败", { type: "error" }); + } + }); }); } }); - } + }; return { searchForm, searchLabel, @@ -292,4 +304,4 @@ export function useData() { addGiftData, setting }; -} \ No newline at end of file +} diff --git a/src/views/union/unionList/hook.tsx b/src/views/union/unionList/hook.tsx index 8bb0be8..8ed5f30 100644 --- a/src/views/union/unionList/hook.tsx +++ b/src/views/union/unionList/hook.tsx @@ -3,8 +3,9 @@ import editForm from "./form.vue"; import { ElMessageBox } from "element-plus"; import memberListView from "./memberList.vue"; import roomListView from "./roomList.vue"; -import mergeFormView from './mergeForm.vue' +import mergeFormView from "./mergeForm.vue"; import { message } from "@/utils/message"; +import { verifyPassword } from "@/utils/passwordVerify"; import { queryUnionList, addUnionData, @@ -71,7 +72,7 @@ export function useData() { preview-src-list={Array.of(row.guild_logo)} class="w-[24px] h-[24px] align-middle" /> - ), + ) }, { label: "今日流水", @@ -85,15 +86,17 @@ export function useData() { label: "公会状态", prop: "status_str", cellRenderer: ({ row }) => ( - {row.status_str} - ), + + {row.status_str} + + ) }, { label: "显示状态", prop: "is_show", cellRenderer: ({ row }) => ( -
{row.status_str === '正常' ? row.is_show_str : '-'}
- ), +
{row.status_str === "正常" ? row.is_show_str : "-"}
+ ) }, { label: "创建时间", @@ -106,9 +109,9 @@ export function useData() { slot: "operation" } ]); - const onSearch = async (formData) => { + const onSearch = async formData => { loading.value = true; - searchForm.value = { ...formData } + searchForm.value = { ...formData }; const { data, code } = await queryUnionList({ ...formData, page: pagination.value.currentPage, @@ -130,16 +133,20 @@ export function useData() { pagination.value.currentPage = val; onSearch(searchForm.value); }; + // 解散工会 const handleDelete = async rowData => { - const { code } = await dissolveUnionData({ id: rowData.id }); - if (code === "0") { - message(`您删除了公会名称为【${rowData.guild_name}】的这条数据`, { - type: "success" - }); - onSearch(searchForm.value); - } + // 解散需要二级密码验证 + verifyPassword(async () => { + const { code } = await dissolveUnionData({ id: rowData.id }); + if (code === "0") { + message(`您删除了公会名称为【${rowData.guild_name}】的这条数据`, { + type: "success" + }); + onSearch(searchForm.value); + } + }); }; - // 新增 + // 新增/编辑工会 const openDialog = (title = "新增", rowData: any) => { addDialog({ title: `${title}工会`, @@ -161,46 +168,42 @@ export function useData() { beforeSure: (done, { options }) => { const FormRef = formRef.value.getRef(); const curData = options.props.formInline; - const saveData = async form => { - const { code, msg } = await addUnionData(form); - if (code) { - message("新增成功", { type: "success" }); - onSearch(searchForm.value); - done(); - } else { - message(msg, { type: "error" }); - } - }; - const updateData = async form => { - const { code } = await editUnionData({ - ...form, - id: rowData.id - }); - if (code) { - message("修改成功", { type: "success" }); - onSearch(searchForm.value); - done(); - } else { - message("修改失败", { type: "error" }); - } - }; - FormRef.validate(valid => { - if (valid) { - // 表单规则校验通过 - if (title === "新增") { - // 实际开发先调用新增接口,再进行下面操作 - saveData(curData); + + FormRef.validate(async valid => { + if (!valid) return; + + if (title === "新增") { + // 新增操作 + const { code, msg } = await addUnionData(curData); + if (code) { + message("新增成功", { type: "success" }); + onSearch(searchForm.value); + done(); } else { - // 实际开发先调用修改接口,再进行下面操作 - updateData(curData); + message(msg, { type: "error" }); } + } else { + // 编辑操作 - 需要二级密码验证 + verifyPassword(async () => { + const { code } = await editUnionData({ + ...curData, + id: rowData.id + }); + if (code) { + message("修改成功", { type: "success" }); + onSearch(searchForm.value); + done(); + } else { + message("修改失败", { type: "error" }); + } + }); } }); } }); }; // 查看成员 roomListView memberListView - const viewMember = (rowData) => { + const viewMember = rowData => { addDialog({ title: `查看成员列表`, props: { @@ -209,13 +212,13 @@ export function useData() { width: "60%", closeOnClickModal: false, contentRenderer: () => h(memberListView), - beforeSure: (done) => { - done() + beforeSure: done => { + done(); } }); - } + }; // 查看房间列表 - const viewRoomList = (rowData) => { + const viewRoomList = rowData => { addDialog({ title: `查看房间列表`, props: { @@ -224,11 +227,11 @@ export function useData() { width: "60%", closeOnClickModal: false, contentRenderer: () => h(roomListView), - beforeSure: (done) => { - done() + beforeSure: done => { + done(); } }); - } + }; // 合并公会 const mergeData = async () => { addDialog({ @@ -236,50 +239,54 @@ export function useData() { props: { formInline: { guild_id: "", - merge_guild_id: "", + merge_guild_id: "" } }, width: "40%", closeOnClickModal: false, - contentRenderer: () => h(mergeFormView, { ref: formRef, formInline: null }), + contentRenderer: () => + h(mergeFormView, { ref: formRef, formInline: null }), beforeSure: (done, { options }) => { const FormRef = formRef.value.getRef(); const curData = options.props.formInline; - FormRef.validate(valid => { - if (valid) { - ElMessageBox.confirm( - `此操作不可更改,是否继续?`, - "提示", - { - type: "warning" - } - ) + + FormRef.validate(async valid => { + if (!valid) return; + + // 合并公会需要二级密码验证 + verifyPassword(async () => { + ElMessageBox.confirm(`此操作不可更改,是否继续?`, "提示", { + type: "warning" + }) .then(async () => { - const { code, msg } = await guildUnionData(curData) + const { code, msg } = await guildUnionData(curData); if (code) { message("操作成功", { type: "success" }); onSearch(searchForm.value); - done() + done(); } else { message(msg, { type: "error" }); } }) - .catch(() => { }); - } + .catch(() => {}); + }); }); } }); - } - // 更改工会状态 隐藏 显示 - const changeShowStatus = async (rowData) => { - const { data, code, msg } = await changeStatus({ id: rowData.id }) - if (code) { - message("操作成功", { type: "success" }); - onSearch(searchForm.value); - } else { - message(msg, { type: "error" }); - } - } + }; + // 更改工会状态 隐藏/显示 + const changeShowStatus = async rowData => { + // 更改状态需要二级密码验证 + verifyPassword(async () => { + const { code, msg } = await changeStatus({ id: rowData.id }); + if (code) { + message("操作成功", { type: "success" }); + onSearch(searchForm.value); + } else { + message(msg, { type: "error" }); + } + }); + }; return { searchForm, searchLabel, diff --git a/src/views/union/unionList/memberList.vue b/src/views/union/unionList/memberList.vue index b213d9c..c5e76b2 100644 --- a/src/views/union/unionList/memberList.vue +++ b/src/views/union/unionList/memberList.vue @@ -2,13 +2,11 @@ import SearchForm from "@/components/SearchForm/index.vue"; import { ref, onMounted } from "vue"; import { message } from "@/utils/message"; -import { - queryUnionMemberList, - kickUnionMember -} from "@/api/modules/union"; +import { verifyPassword } from "@/utils/passwordVerify"; +import { queryUnionMemberList, kickUnionMember } from "@/api/modules/union"; const props = defineProps(["rowData"]); -const loading = ref(false) -const tableList = ref([]) +const loading = ref(false); +const tableList = ref([]); const searchForm = ref({ user_id: "", search_stime: "", @@ -56,20 +54,26 @@ const dynamicColumns = ref([ width: 300, slot: "operation" } -]) -const kickMember = async (rowData) => { - const { code, msg } = await kickUnionMember({ user_id: rowData.user_id, guild_id: props.rowData.id }); - if (code) { - message(`您已踢出昵称为【${rowData.nickname}】的用户`, { - type: "success" +]); +const kickMember = async rowData => { + // 踢出成员需要二级密码验证 + verifyPassword(async () => { + const { code, msg } = await kickUnionMember({ + user_id: rowData.user_id, + guild_id: props.rowData.id }); - onSearch(searchForm.value); - } else { - message(msg, { - type: "error" - }); - } -} + if (code) { + message(`您已踢出昵称为【${rowData.nickname}】的用户`, { + type: "success" + }); + onSearch(searchForm.value); + } else { + message(msg, { + type: "error" + }); + } + }); +}; const handleSizeChange = (val: number) => { pagination.value.pageSize = val; onSearch(searchForm.value); @@ -78,9 +82,9 @@ const handleCurrentChange = (val: number) => { pagination.value.currentPage = val; onSearch(searchForm.value); }; -const onSearch = async (formData) => { +const onSearch = async formData => { loading.value = true; - searchForm.value = { ...formData } + searchForm.value = { ...formData }; const { data, code } = await queryUnionMemberList({ ...formData, guild_id: props.rowData.id, @@ -93,10 +97,10 @@ const onSearch = async (formData) => { pagination.value.currentPage = data.page; } loading.value = false; -} +}; onMounted(() => { - onSearch(searchForm.value) -}) + onSearch(searchForm.value); +});