增加二级密码
This commit is contained in:
36
src/components/passwordDiaglog/index.vue
Normal file
36
src/components/passwordDiaglog/index.vue
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { ref } from "vue";
|
||||||
|
const ruleFormRef = ref();
|
||||||
|
const formRules = ref({
|
||||||
|
password: [{ required: true, message: "请输入二级密码", trigger: "blur" }]
|
||||||
|
});
|
||||||
|
const props = defineProps(["formInline"]);
|
||||||
|
const newFormInline = ref(
|
||||||
|
props.formInline
|
||||||
|
? props.formInline
|
||||||
|
: {
|
||||||
|
password: ""
|
||||||
|
}
|
||||||
|
);
|
||||||
|
function getRef() {
|
||||||
|
return ruleFormRef.value;
|
||||||
|
}
|
||||||
|
defineExpose({ getRef });
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<el-form
|
||||||
|
ref="ruleFormRef"
|
||||||
|
:model="newFormInline"
|
||||||
|
:rules="formRules"
|
||||||
|
label-width="120px"
|
||||||
|
>
|
||||||
|
<el-form-item label="二级密码" prop="password">
|
||||||
|
<el-input
|
||||||
|
v-model="newFormInline.password"
|
||||||
|
placeholder="请输入密码"
|
||||||
|
show-password
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</template>
|
||||||
54
src/utils/passwordVerify.tsx
Normal file
54
src/utils/passwordVerify.tsx
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
import { h, ref } from "vue";
|
||||||
|
import { addDialog } from "@/components/ReDialog";
|
||||||
|
import passDialog from "@/components/passwordDiaglog/index.vue";
|
||||||
|
import { checkPassWord } from "@/api/modules/system";
|
||||||
|
import { message } from "@/utils/message";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 二级密码验证工具
|
||||||
|
* @param onSuccess 验证成功后的回调函数
|
||||||
|
* @param onError 验证失败后的回调函数(可选)
|
||||||
|
* @returns void
|
||||||
|
*/
|
||||||
|
export function verifyPassword(
|
||||||
|
onSuccess: () => void | Promise<void>,
|
||||||
|
onError?: (msg: string) => void
|
||||||
|
) {
|
||||||
|
const formRef = ref();
|
||||||
|
|
||||||
|
addDialog({
|
||||||
|
title: `输入二级密码`,
|
||||||
|
width: "40%",
|
||||||
|
props: {
|
||||||
|
formInline: {
|
||||||
|
password: ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
closeOnClickModal: false,
|
||||||
|
contentRenderer: () => h(passDialog, { ref: formRef, formInline: null }),
|
||||||
|
beforeSure: (done, { options }) => {
|
||||||
|
const FormRef = formRef.value.getRef();
|
||||||
|
const curData = options.props.formInline;
|
||||||
|
|
||||||
|
const verify = async form => {
|
||||||
|
const { code, msg } = await checkPassWord(form);
|
||||||
|
if (code) {
|
||||||
|
await onSuccess();
|
||||||
|
done();
|
||||||
|
} else {
|
||||||
|
if (onError) {
|
||||||
|
onError(msg);
|
||||||
|
} else {
|
||||||
|
message(msg, { type: "error" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
FormRef.validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
verify(curData);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -10,9 +10,10 @@ import {
|
|||||||
settingBlindBoxRule
|
settingBlindBoxRule
|
||||||
} from "@/api/modules/blindBox";
|
} from "@/api/modules/blindBox";
|
||||||
import editForm from "./form.vue";
|
import editForm from "./form.vue";
|
||||||
import settingRuleView from './settingRule.vue'
|
import settingRuleView from "./settingRule.vue";
|
||||||
import { addDialog } from "@/components/ReDialog";
|
import { addDialog } from "@/components/ReDialog";
|
||||||
import { message } from "@/utils/message";
|
import { message } from "@/utils/message";
|
||||||
|
import { verifyPassword } from "@/utils/passwordVerify";
|
||||||
export function useData() {
|
export function useData() {
|
||||||
const formRef = ref();
|
const formRef = ref();
|
||||||
const loading = ref(true);
|
const loading = ref(true);
|
||||||
@@ -27,22 +28,23 @@ export function useData() {
|
|||||||
});
|
});
|
||||||
const searchForm = ref({
|
const searchForm = ref({
|
||||||
gift_id: "",
|
gift_id: "",
|
||||||
gift_name: "",
|
gift_name: ""
|
||||||
});
|
});
|
||||||
const activeName = ref(0)
|
const activeName = ref(0);
|
||||||
const typeList = ref([])
|
const typeList = ref([]);
|
||||||
const statisticsList = ref([
|
const statisticsList = ref([
|
||||||
{ label: "每期总次数", prop: "total_count" },
|
{ label: "每期总次数", prop: "total_count" },
|
||||||
{ label: "每期总礼物价值(收入)", prop: "total_price" },
|
{ label: "每期总礼物价值(收入)", prop: "total_price" },
|
||||||
{
|
{
|
||||||
label: "每期总抽奖花费(支出)", prop: "total_cost"
|
label: "每期总抽奖花费(支出)",
|
||||||
|
prop: "total_cost"
|
||||||
},
|
},
|
||||||
{ label: "每期统计(收入/支出)", prop: "profit_loss_ratio", tip: "%" },
|
{ label: "每期统计(收入/支出)", prop: "profit_loss_ratio", tip: "%" },
|
||||||
{ label: "今日抽奖人数", prop: "today_count_user" },
|
{ label: "今日抽奖人数", prop: "today_count_user" },
|
||||||
{ label: "今日抽奖次数", prop: "today_total_count" },
|
{ label: "今日抽奖次数", prop: "today_total_count" },
|
||||||
{ label: "今日抽奖收入", prop: "today_total_price" },
|
{ label: "今日抽奖收入", prop: "today_total_price" }
|
||||||
])
|
]);
|
||||||
const statisticsData = ref({})
|
const statisticsData = ref({});
|
||||||
const searchLabel = ref([
|
const searchLabel = ref([
|
||||||
{ label: "礼物ID", prop: "gift_id", type: "input" },
|
{ label: "礼物ID", prop: "gift_id", type: "input" },
|
||||||
{ label: "礼物名称", prop: "gift_name", type: "input" }
|
{ label: "礼物名称", prop: "gift_name", type: "input" }
|
||||||
@@ -85,14 +87,18 @@ export function useData() {
|
|||||||
label: "公屏",
|
label: "公屏",
|
||||||
prop: "is_public_screen",
|
prop: "is_public_screen",
|
||||||
cellRenderer: ({ row }) => (
|
cellRenderer: ({ row }) => (
|
||||||
<el-tag type={row.is_public_screen === 1 ? 'success' : 'error'}>{row.is_public_screen === 1 ? '是' : '否'}</el-tag>
|
<el-tag type={row.is_public_screen === 1 ? "success" : "error"}>
|
||||||
|
{row.is_public_screen === 1 ? "是" : "否"}
|
||||||
|
</el-tag>
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "全服播报",
|
label: "全服播报",
|
||||||
prop: "is_public_server",
|
prop: "is_public_server",
|
||||||
cellRenderer: ({ row }) => (
|
cellRenderer: ({ row }) => (
|
||||||
<el-tag type={row.is_public_server === 1 ? 'success' : 'error'}>{row.is_public_server === 1 ? '是' : '否'}</el-tag>
|
<el-tag type={row.is_public_server === 1 ? "success" : "error"}>
|
||||||
|
{row.is_public_server === 1 ? "是" : "否"}
|
||||||
|
</el-tag>
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -106,23 +112,23 @@ export function useData() {
|
|||||||
slot: "operation"
|
slot: "operation"
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
const onSearch = async (formData) => {
|
const onSearch = async formData => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
searchForm.value = { ...formData }
|
searchForm.value = { ...formData };
|
||||||
const { data, code } = await queryBlindBoxList({
|
const { data, code } = await queryBlindBoxList({
|
||||||
...formData,
|
...formData,
|
||||||
gift_bag_id: activeName.value,
|
gift_bag_id: activeName.value,
|
||||||
page: pagination.value.currentPage,
|
page: pagination.value.currentPage,
|
||||||
page_limit: pagination.value.pageSize,
|
page_limit: pagination.value.pageSize
|
||||||
|
|
||||||
});
|
});
|
||||||
if (code) {
|
if (code) {
|
||||||
tableList.value = data.lists.map(ele => {
|
tableList.value = data.lists.map(ele => {
|
||||||
return {
|
return {
|
||||||
...ele, ...data.total
|
...ele,
|
||||||
}
|
...data.total
|
||||||
|
};
|
||||||
});
|
});
|
||||||
statisticsData.value = data.total_data
|
statisticsData.value = data.total_data;
|
||||||
pagination.value.total = data.count;
|
pagination.value.total = data.count;
|
||||||
pagination.value.currentPage = data.page;
|
pagination.value.currentPage = data.page;
|
||||||
}
|
}
|
||||||
@@ -137,49 +143,57 @@ export function useData() {
|
|||||||
onSearch(searchForm.value);
|
onSearch(searchForm.value);
|
||||||
};
|
};
|
||||||
const getType = async () => {
|
const getType = async () => {
|
||||||
const { code, data } = await queryBoxTypeList({ activities_id: 4 })
|
const { code, data } = await queryBoxTypeList({ activities_id: 4 });
|
||||||
// console.log(code, data)
|
// console.log(code, data)
|
||||||
typeList.value = code ? data.map(ele => {
|
typeList.value = code
|
||||||
return {
|
? data.map(ele => {
|
||||||
label: ele.name,
|
return {
|
||||||
value: ele.id
|
label: ele.name,
|
||||||
}
|
value: ele.id
|
||||||
}) : []
|
};
|
||||||
if (code) handleClick(data[0].id)
|
})
|
||||||
}
|
: [];
|
||||||
const handleClick = (id) => {
|
if (code) handleClick(data[0].id);
|
||||||
activeName.value = id
|
|
||||||
onSearch(searchForm.value);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
const resetSetting = async () => {
|
|
||||||
const { data, code } = await resetBlindBoxRule({
|
|
||||||
gift_bag_id: activeName.value
|
|
||||||
})
|
|
||||||
if (code) {
|
|
||||||
message(`重置成功`, {
|
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
handleClick(activeName.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
const handleDelete = async rowData => {
|
|
||||||
const { code } = await removeBlindBoxData({ id: rowData.id });
|
|
||||||
if (code) {
|
|
||||||
message(`您删除了这条数据`, {
|
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
onSearch(searchForm.value);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
const handleClick = id => {
|
||||||
|
activeName.value = id;
|
||||||
|
onSearch(searchForm.value);
|
||||||
|
};
|
||||||
|
// 重置规则
|
||||||
|
const resetSetting = async () => {
|
||||||
|
// 重置规则需要二级密码验证
|
||||||
|
verifyPassword(async () => {
|
||||||
|
const { code } = await resetBlindBoxRule({
|
||||||
|
gift_bag_id: activeName.value
|
||||||
|
});
|
||||||
|
if (code) {
|
||||||
|
message(`重置成功`, {
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
|
handleClick(activeName.value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
const handleDelete = async rowData => {
|
||||||
|
// 删除需要二级密码验证
|
||||||
|
verifyPassword(async () => {
|
||||||
|
const { code } = await removeBlindBoxData({ id: rowData.id });
|
||||||
|
if (code) {
|
||||||
|
message(`您删除了这条数据`, {
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
|
onSearch(searchForm.value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
// 新增/编辑盲盒礼物
|
||||||
const openDialog = async (title = "新增", rowData: any) => {
|
const openDialog = async (title = "新增", rowData: any) => {
|
||||||
addDialog({
|
addDialog({
|
||||||
title: `${title}盲盒礼物`,
|
title: `${title}盲盒礼物`,
|
||||||
props: {
|
props: {
|
||||||
formInline: {
|
formInline: {
|
||||||
gift_id: rowData?.gift_id ?? "",
|
gift_id: rowData?.gift_id ?? "",
|
||||||
quantity: rowData?.quantity ?? "",
|
quantity: rowData?.quantity ?? ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
width: "40%",
|
width: "40%",
|
||||||
@@ -188,51 +202,51 @@ export function useData() {
|
|||||||
beforeSure: (done, { options }) => {
|
beforeSure: (done, { options }) => {
|
||||||
const FormRef = formRef.value.getRef();
|
const FormRef = formRef.value.getRef();
|
||||||
const curData = options.props.formInline;
|
const curData = options.props.formInline;
|
||||||
const saveData = async form => {
|
|
||||||
const { code } = await addBlindBoxData({
|
FormRef.validate(async valid => {
|
||||||
...form,
|
if (!valid) return;
|
||||||
gift_bag_id: activeName.value,
|
|
||||||
});
|
if (title === "新增") {
|
||||||
if (code) {
|
// 新增操作 - 需要二级密码验证
|
||||||
message("新增成功", { type: "success" });
|
verifyPassword(async () => {
|
||||||
onSearch(searchForm.value);
|
const { code } = await addBlindBoxData({
|
||||||
done();
|
...curData,
|
||||||
|
gift_bag_id: activeName.value
|
||||||
|
});
|
||||||
|
if (code) {
|
||||||
|
message("新增成功", { type: "success" });
|
||||||
|
onSearch(searchForm.value);
|
||||||
|
done();
|
||||||
|
} else {
|
||||||
|
message("新增失败", { type: "error" });
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
message("新增失败", { type: "error" });
|
// 编辑操作 - 需要二级密码验证
|
||||||
}
|
verifyPassword(async () => {
|
||||||
};
|
const { code, msg } = await editBlindBoxData({
|
||||||
const updateData = async form => {
|
...curData,
|
||||||
const { code, msg } = await editBlindBoxData({
|
gift_bag_id: activeName.value,
|
||||||
...form,
|
id: rowData.id
|
||||||
gift_bag_id: activeName.value,
|
});
|
||||||
id: rowData.id
|
if (code) {
|
||||||
});
|
message("修改成功", { type: "success" });
|
||||||
if (code) {
|
onSearch(searchForm.value);
|
||||||
message("修改成功", { type: "success" });
|
done();
|
||||||
onSearch(searchForm.value);
|
} else {
|
||||||
done();
|
message(msg, { type: "error" });
|
||||||
} else {
|
}
|
||||||
message(msg, { type: "error" });
|
});
|
||||||
}
|
|
||||||
};
|
|
||||||
FormRef.validate(valid => {
|
|
||||||
if (valid) {
|
|
||||||
console.log("curData", curData);
|
|
||||||
// 表单规则校验通过
|
|
||||||
if (title === "新增") {
|
|
||||||
// 实际开发先调用新增接口,再进行下面操作
|
|
||||||
saveData(curData);
|
|
||||||
} else {
|
|
||||||
// 实际开发先调用修改接口,再进行下面操作
|
|
||||||
updateData(curData);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
// 设置盲盒规则
|
||||||
const setting = async () => {
|
const setting = async () => {
|
||||||
const { data, code } = await getBlindBoxRule({ gift_bag_id: activeName.value })
|
const { data, code } = await getBlindBoxRule({
|
||||||
|
gift_bag_id: activeName.value
|
||||||
|
});
|
||||||
addDialog({
|
addDialog({
|
||||||
title: `设置盲盒规则`,
|
title: `设置盲盒规则`,
|
||||||
props: {
|
props: {
|
||||||
@@ -242,29 +256,30 @@ export function useData() {
|
|||||||
},
|
},
|
||||||
width: "40%",
|
width: "40%",
|
||||||
closeOnClickModal: false,
|
closeOnClickModal: false,
|
||||||
contentRenderer: () => h(settingRuleView, { ref: formRef, formInline: null }),
|
contentRenderer: () =>
|
||||||
|
h(settingRuleView, { ref: formRef, formInline: null }),
|
||||||
beforeSure: (done, { options }) => {
|
beforeSure: (done, { options }) => {
|
||||||
const FormRef = formRef.value.getRef();
|
const FormRef = formRef.value.getRef();
|
||||||
const curData = options.props.formInline;
|
const curData = options.props.formInline;
|
||||||
const saveData = async form => {
|
|
||||||
const { code } = await settingBlindBoxRule({ ...form });
|
FormRef.validate(async valid => {
|
||||||
if (code) {
|
if (!valid) return;
|
||||||
message("设置成功", { type: "success" });
|
|
||||||
onSearch(searchForm.value);
|
// 设置规则需要二级密码验证
|
||||||
done();
|
verifyPassword(async () => {
|
||||||
} else {
|
const { code } = await settingBlindBoxRule({ ...curData });
|
||||||
message("设置失败", { type: "error" });
|
if (code) {
|
||||||
}
|
message("设置成功", { type: "success" });
|
||||||
};
|
onSearch(searchForm.value);
|
||||||
FormRef.validate(valid => {
|
done();
|
||||||
if (valid) {
|
} else {
|
||||||
// console.log("curData", curData);
|
message("设置失败", { type: "error" });
|
||||||
saveData(curData)
|
}
|
||||||
}
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
return {
|
return {
|
||||||
searchForm,
|
searchForm,
|
||||||
searchLabel,
|
searchLabel,
|
||||||
@@ -287,4 +302,4 @@ export function useData() {
|
|||||||
handleDelete,
|
handleDelete,
|
||||||
setting
|
setting
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import editForm from "./form.vue";
|
|||||||
import settingRuleView from "./settingRule.vue";
|
import settingRuleView from "./settingRule.vue";
|
||||||
import { addDialog } from "@/components/ReDialog";
|
import { addDialog } from "@/components/ReDialog";
|
||||||
import { message } from "@/utils/message";
|
import { message } from "@/utils/message";
|
||||||
|
import { verifyPassword } from "@/utils/passwordVerify";
|
||||||
export function useData() {
|
export function useData() {
|
||||||
const formRef = ref();
|
const formRef = ref();
|
||||||
const loading = ref(true);
|
const loading = ref(true);
|
||||||
@@ -162,17 +163,20 @@ export function useData() {
|
|||||||
activeName.value = id;
|
activeName.value = id;
|
||||||
onSearch(searchForm.value);
|
onSearch(searchForm.value);
|
||||||
};
|
};
|
||||||
//
|
// 重置数量
|
||||||
const resetSetting = async () => {
|
const resetSetting = async () => {
|
||||||
const { data, code } = await resetBlindBoxRule({
|
// 重置数量需要二级密码验证
|
||||||
gift_bag_id: activeName.value
|
verifyPassword(async () => {
|
||||||
});
|
const { code } = await resetBlindBoxRule({
|
||||||
if (code) {
|
gift_bag_id: activeName.value
|
||||||
message(`重置成功`, {
|
|
||||||
type: "success"
|
|
||||||
});
|
});
|
||||||
handleClick(activeName.value);
|
if (code) {
|
||||||
}
|
message(`重置成功`, {
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
|
handleClick(activeName.value);
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
const handleDelete = async rowData => {
|
const handleDelete = async rowData => {
|
||||||
const { code } = await removeBlindBoxData({ id: rowData.id });
|
const { code } = await removeBlindBoxData({ id: rowData.id });
|
||||||
@@ -183,6 +187,7 @@ export function useData() {
|
|||||||
onSearch(searchForm.value);
|
onSearch(searchForm.value);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
// 编辑盲盒礼物
|
||||||
const openDialog = async (title = "新增", rowData: any) => {
|
const openDialog = async (title = "新增", rowData: any) => {
|
||||||
addDialog({
|
addDialog({
|
||||||
title: `${title}盲盒礼物`,
|
title: `${title}盲盒礼物`,
|
||||||
@@ -200,49 +205,45 @@ export function useData() {
|
|||||||
beforeSure: (done, { options }) => {
|
beforeSure: (done, { options }) => {
|
||||||
const FormRef = formRef.value.getRef();
|
const FormRef = formRef.value.getRef();
|
||||||
const curData = options.props.formInline;
|
const curData = options.props.formInline;
|
||||||
const saveData = async form => {
|
|
||||||
const { code } = await addBlindBoxData({
|
FormRef.validate(async valid => {
|
||||||
...form,
|
if (!valid) return;
|
||||||
gift_bag_id: activeName.value
|
|
||||||
});
|
if (title === "新增") {
|
||||||
if (code) {
|
// 新增操作
|
||||||
message("新增成功", { type: "success" });
|
const { code } = await addBlindBoxData({
|
||||||
onSearch(searchForm.value);
|
...curData,
|
||||||
done();
|
gift_bag_id: activeName.value
|
||||||
} else {
|
});
|
||||||
message("新增失败", { type: "error" });
|
if (code) {
|
||||||
}
|
message("新增成功", { type: "success" });
|
||||||
};
|
onSearch(searchForm.value);
|
||||||
const updateData = async form => {
|
done();
|
||||||
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 {
|
} else {
|
||||||
// 实际开发先调用修改接口,再进行下面操作
|
message("新增失败", { type: "error" });
|
||||||
updateData(curData);
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// 编辑操作 - 需要二级密码验证
|
||||||
|
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 setting = async () => {
|
const setting = async () => {
|
||||||
const { data, code } = await getBlindBoxRule({
|
const { data, code } = await getBlindBoxRule({
|
||||||
gift_bag_id: activeName.value
|
gift_bag_id: activeName.value
|
||||||
@@ -261,21 +262,21 @@ export function useData() {
|
|||||||
beforeSure: (done, { options }) => {
|
beforeSure: (done, { options }) => {
|
||||||
const FormRef = formRef.value.getRef();
|
const FormRef = formRef.value.getRef();
|
||||||
const curData = options.props.formInline;
|
const curData = options.props.formInline;
|
||||||
const saveData = async form => {
|
|
||||||
const { code } = await settingBlindBoxRule({ ...form });
|
FormRef.validate(async valid => {
|
||||||
if (code) {
|
if (!valid) return;
|
||||||
message("设置成功", { type: "success" });
|
|
||||||
onSearch(searchForm.value);
|
// 设置规则需要二级密码验证
|
||||||
done();
|
verifyPassword(async () => {
|
||||||
} else {
|
const { code } = await settingBlindBoxRule({ ...curData });
|
||||||
message("设置失败", { type: "error" });
|
if (code) {
|
||||||
}
|
message("设置成功", { type: "success" });
|
||||||
};
|
onSearch(searchForm.value);
|
||||||
FormRef.validate(valid => {
|
done();
|
||||||
if (valid) {
|
} else {
|
||||||
// console.log("curData", curData);
|
message("设置失败", { type: "error" });
|
||||||
saveData(curData);
|
}
|
||||||
}
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ const {
|
|||||||
setting
|
setting
|
||||||
} = useData();
|
} = useData();
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getType()
|
getType();
|
||||||
});
|
});
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "boxList"
|
name: "boxList"
|
||||||
@@ -46,11 +46,10 @@ defineOptions({
|
|||||||
</div>
|
</div>
|
||||||
<SearchForm class="pb-2" :LabelList="searchLabel" :formData="searchForm" @handleSearch="onSearch" />
|
<SearchForm class="pb-2" :LabelList="searchLabel" :formData="searchForm" @handleSearch="onSearch" />
|
||||||
<div class="content-flex">
|
<div class="content-flex">
|
||||||
<div class="box" v-for="(ele, index) in statisticsList">
|
<div v-for="(ele, index) in statisticsList" class="box">
|
||||||
<el-statistic :precision="2" decimal-separator="." :value="statisticsData[ele.prop]" :suffix="ele.tip || ''"
|
<el-statistic :precision="2" decimal-separator="." :value="statisticsData[ele.prop]" :suffix="ele.tip || ''"
|
||||||
:title="ele.label"></el-statistic>
|
:title="ele.label" />
|
||||||
<span></span>
|
<span />
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div ref="contentRef" :class="['flex', deviceDetection() ? 'flex-wrap' : '']">
|
<div ref="contentRef" :class="['flex', deviceDetection() ? 'flex-wrap' : '']">
|
||||||
@@ -60,16 +59,11 @@ defineOptions({
|
|||||||
<el-button type="text" @click="openLotteryRecord">开奖记录</el-button>
|
<el-button type="text" @click="openLotteryRecord">开奖记录</el-button>
|
||||||
<el-popconfirm :title="`是否重置当前盲盒转盘的规则数量`" @confirm="resetSetting(row)">
|
<el-popconfirm :title="`是否重置当前盲盒转盘的规则数量`" @confirm="resetSetting(row)">
|
||||||
<template #reference>
|
<template #reference>
|
||||||
|
<el-button type="primary"> 重置数量 </el-button>
|
||||||
<el-button type="primary">
|
|
||||||
重置数量
|
|
||||||
</el-button>
|
|
||||||
</template>
|
</template>
|
||||||
</el-popconfirm>
|
</el-popconfirm>
|
||||||
|
|
||||||
<el-button type="primary" @click="setting(row)">
|
<el-button type="primary" @click="setting(row)"> 设置规则 </el-button>
|
||||||
设置规则
|
|
||||||
</el-button>
|
|
||||||
</template>
|
</template>
|
||||||
<template v-slot="{ size, dynamicColumns }">
|
<template v-slot="{ size, dynamicColumns }">
|
||||||
<pure-table ref="tableRef" align-whole="center" showOverflowTooltip table-layout="auto" default-expand-all
|
<pure-table ref="tableRef" align-whole="center" showOverflowTooltip table-layout="auto" default-expand-all
|
||||||
@@ -108,6 +102,6 @@ defineOptions({
|
|||||||
padding: 20px;
|
padding: 20px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { ref, h } from "vue";
|
import { ref, h } from "vue";
|
||||||
import editForm from "./form.vue";
|
import editForm from "./form.vue";
|
||||||
import { message } from "@/utils/message";
|
import { message } from "@/utils/message";
|
||||||
|
import { verifyPassword } from "@/utils/passwordVerify";
|
||||||
import {
|
import {
|
||||||
queryList,
|
queryList,
|
||||||
addDataProp,
|
addDataProp,
|
||||||
@@ -10,8 +11,8 @@ import {
|
|||||||
queryClassifyList
|
queryClassifyList
|
||||||
} from "@/api/modules/decorate";
|
} from "@/api/modules/decorate";
|
||||||
import { addDialog } from "@/components/ReDialog";
|
import { addDialog } from "@/components/ReDialog";
|
||||||
import priceList from './priceList.vue'
|
import priceList from "./priceList.vue";
|
||||||
import donateForm from './donateForm.vue'
|
import donateForm from "./donateForm.vue";
|
||||||
export function useData() {
|
export function useData() {
|
||||||
const formRef = ref();
|
const formRef = ref();
|
||||||
const loading = ref(true);
|
const loading = ref(true);
|
||||||
@@ -79,16 +80,19 @@ export function useData() {
|
|||||||
label: "是否显示",
|
label: "是否显示",
|
||||||
prop: "show_status",
|
prop: "show_status",
|
||||||
cellRenderer: ({ row }) => (
|
cellRenderer: ({ row }) => (
|
||||||
<el-tag type={row.show_status === 1 ? 'success' : 'info'}>{row.show_status === 1 ? '正常' : '隐藏'}</el-tag>
|
<el-tag type={row.show_status === 1 ? "success" : "info"}>
|
||||||
),
|
{row.show_status === 1 ? "正常" : "隐藏"}
|
||||||
|
</el-tag>
|
||||||
|
)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "是否可购买",
|
label: "是否可购买",
|
||||||
prop: "status_str",
|
prop: "status_str",
|
||||||
cellRenderer: ({ row }) => (
|
cellRenderer: ({ row }) => (
|
||||||
<el-tag type={row.is_buy === 1 ? 'success' : 'info'}>{row.is_buy
|
<el-tag type={row.is_buy === 1 ? "success" : "info"}>
|
||||||
=== 1 ? '是' : '否'}</el-tag>
|
{row.is_buy === 1 ? "是" : "否"}
|
||||||
),
|
</el-tag>
|
||||||
|
)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "创建时间",
|
label: "创建时间",
|
||||||
@@ -101,9 +105,9 @@ export function useData() {
|
|||||||
slot: "operation"
|
slot: "operation"
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
const onSearch = async (formData) => {
|
const onSearch = async formData => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
searchForm.value = { ...formData }
|
searchForm.value = { ...formData };
|
||||||
const { data, code } = await queryList({
|
const { data, code } = await queryList({
|
||||||
...formData,
|
...formData,
|
||||||
page: pagination.value.currentPage,
|
page: pagination.value.currentPage,
|
||||||
@@ -125,15 +129,18 @@ export function useData() {
|
|||||||
onSearch(searchForm.value);
|
onSearch(searchForm.value);
|
||||||
};
|
};
|
||||||
const handleDelete = async rowData => {
|
const handleDelete = async rowData => {
|
||||||
const { code } = await deleteDataProp({ id: rowData.id });
|
// 删除需要二级密码验证
|
||||||
if (code) {
|
verifyPassword(async () => {
|
||||||
message(`删除成功`, {
|
const { code } = await deleteDataProp({ id: rowData.id });
|
||||||
type: "success"
|
if (code) {
|
||||||
});
|
message(`删除成功`, {
|
||||||
onSearch(searchForm.value);
|
type: "success"
|
||||||
}
|
});
|
||||||
|
onSearch(searchForm.value);
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
// 新增
|
// 新增/编辑
|
||||||
const openDialog = (title = "新增", rowData: any) => {
|
const openDialog = (title = "新增", rowData: any) => {
|
||||||
addDialog({
|
addDialog({
|
||||||
title: `${title}`,
|
title: `${title}`,
|
||||||
@@ -157,37 +164,35 @@ export function useData() {
|
|||||||
beforeSure: (done, { options }) => {
|
beforeSure: (done, { options }) => {
|
||||||
const FormRef = formRef.value.getRef();
|
const FormRef = formRef.value.getRef();
|
||||||
const curData = options.props.formInline;
|
const curData = options.props.formInline;
|
||||||
const saveData = async form => {
|
|
||||||
const { code } = await addDataProp(form);
|
FormRef.validate(async valid => {
|
||||||
if (code) {
|
if (!valid) return;
|
||||||
message("新增成功", { type: "success" });
|
|
||||||
onSearch(searchForm.value);
|
if (title === "新增") {
|
||||||
done();
|
// 新增操作
|
||||||
} else {
|
const { code } = await addDataProp(curData);
|
||||||
message("新增失败", { type: "error" });
|
if (code) {
|
||||||
}
|
message("新增成功", { type: "success" });
|
||||||
};
|
onSearch(searchForm.value);
|
||||||
const editData = async form => {
|
done();
|
||||||
const { code } = await editDataProp({
|
|
||||||
...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);
|
|
||||||
} else {
|
} else {
|
||||||
editData(curData)
|
message("新增失败", { type: "error" });
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// 编辑操作 - 需要二级密码验证
|
||||||
|
verifyPassword(async () => {
|
||||||
|
const { code } = await editDataProp({
|
||||||
|
...curData,
|
||||||
|
id: rowData.id
|
||||||
|
});
|
||||||
|
if (code) {
|
||||||
|
message("修改成功", { type: "success" });
|
||||||
|
onSearch(searchForm.value);
|
||||||
|
done();
|
||||||
|
} else {
|
||||||
|
message("修改失败", { type: "error" });
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -202,10 +207,10 @@ export function useData() {
|
|||||||
width: "60%",
|
width: "60%",
|
||||||
closeOnClickModal: false,
|
closeOnClickModal: false,
|
||||||
hideFooter: true,
|
hideFooter: true,
|
||||||
contentRenderer: () => h(priceList, { ref: formRef, formInline: null }),
|
contentRenderer: () => h(priceList, { ref: formRef, formInline: null })
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
const sendGift = (rowData) => {
|
const sendGift = rowData => {
|
||||||
addDialog({
|
addDialog({
|
||||||
title: `赠送道具`,
|
title: `赠送道具`,
|
||||||
props: {
|
props: {
|
||||||
@@ -221,36 +226,39 @@ export function useData() {
|
|||||||
beforeSure: (done, { options }) => {
|
beforeSure: (done, { options }) => {
|
||||||
const FormRef = formRef.value.getRef();
|
const FormRef = formRef.value.getRef();
|
||||||
const curData = options.props.formInline;
|
const curData = options.props.formInline;
|
||||||
const saveData = async form => {
|
|
||||||
form.decorate_id = rowData.id
|
FormRef.validate(async valid => {
|
||||||
const { code, msg } = await giveDecorate(form);
|
if (!valid) return;
|
||||||
if (code) {
|
|
||||||
message("新增成功", { type: "success" });
|
// 赠送操作 - 需要二级密码验证
|
||||||
onSearch(searchForm.value);
|
verifyPassword(async () => {
|
||||||
done();
|
curData.decorate_id = rowData.id;
|
||||||
} else {
|
const { code, msg } = await giveDecorate(curData);
|
||||||
message(msg, { type: "error" });
|
if (code) {
|
||||||
}
|
message("赠送成功", { type: "success" });
|
||||||
};
|
onSearch(searchForm.value);
|
||||||
FormRef.validate(valid => {
|
done();
|
||||||
if (valid) {
|
} else {
|
||||||
saveData(curData);
|
message(msg, { type: "error" });
|
||||||
}
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
const getType = async () => {
|
const getType = async () => {
|
||||||
const { data, code } = await queryClassifyList();
|
const { data, code } = await queryClassifyList();
|
||||||
if (code) {
|
if (code) {
|
||||||
searchLabel.value[searchLabel.value.length - 1].optionList = data.map(ele => {
|
searchLabel.value[searchLabel.value.length - 1].optionList = data.map(
|
||||||
return {
|
ele => {
|
||||||
value: ele.id,
|
return {
|
||||||
label: ele.name
|
value: ele.id,
|
||||||
|
label: ele.name
|
||||||
|
};
|
||||||
}
|
}
|
||||||
})
|
);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
return {
|
return {
|
||||||
searchForm,
|
searchForm,
|
||||||
searchLabel,
|
searchLabel,
|
||||||
@@ -267,6 +275,5 @@ export function useData() {
|
|||||||
settingPrice,
|
settingPrice,
|
||||||
sendGift,
|
sendGift,
|
||||||
getType
|
getType
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,22 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted, h } from "vue";
|
import { ref, onMounted, h } from "vue";
|
||||||
import { message } from "@/utils/message";
|
import { message } from "@/utils/message";
|
||||||
import { queryPriceList, addPriceData, editPriceData, deletePriceData } from '@/api/modules/decorate';
|
import { verifyPassword } from "@/utils/passwordVerify";
|
||||||
|
import {
|
||||||
|
queryPriceList,
|
||||||
|
addPriceData,
|
||||||
|
editPriceData,
|
||||||
|
deletePriceData
|
||||||
|
} from "@/api/modules/decorate";
|
||||||
import { PureTableBar } from "@/components/RePureTableBar";
|
import { PureTableBar } from "@/components/RePureTableBar";
|
||||||
import { deviceDetection } from "@pureadmin/utils";
|
import { deviceDetection } from "@pureadmin/utils";
|
||||||
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
|
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
|
||||||
import AddFill from "@iconify-icons/ri/add-circle-line";
|
import AddFill from "@iconify-icons/ri/add-circle-line";
|
||||||
import { addDialog } from "@/components/ReDialog";
|
import { addDialog } from "@/components/ReDialog";
|
||||||
import donateForm from './priceForm.vue'
|
import donateForm from "./priceForm.vue";
|
||||||
const props = defineProps(["rowData"]);
|
const props = defineProps(["rowData"]);
|
||||||
const formRef = ref({})
|
const formRef = ref({});
|
||||||
const isShow = ref(false)
|
const isShow = ref(false);
|
||||||
const loading = ref(true);
|
const loading = ref(true);
|
||||||
const tableList = ref([]);
|
const tableList = ref([]);
|
||||||
const pagination = ref({
|
const pagination = ref({
|
||||||
@@ -46,20 +52,20 @@ const tableLabel = ref([
|
|||||||
width: 300,
|
width: 300,
|
||||||
slot: "operation"
|
slot: "operation"
|
||||||
}
|
}
|
||||||
])
|
]);
|
||||||
const getPriceList = async () => {
|
const getPriceList = async () => {
|
||||||
const { code, data } = await queryPriceList({
|
const { code, data } = await queryPriceList({
|
||||||
did: props.rowData.id,
|
did: props.rowData.id,
|
||||||
page: pagination.value.currentPage,
|
page: pagination.value.currentPage,
|
||||||
page_limit: pagination.value.pageSize
|
page_limit: pagination.value.pageSize
|
||||||
})
|
});
|
||||||
if (code) {
|
if (code) {
|
||||||
tableList.value = data.lists;
|
tableList.value = data.lists;
|
||||||
pagination.value.total = data.count;
|
pagination.value.total = data.count;
|
||||||
pagination.value.currentPage = data.page;
|
pagination.value.currentPage = data.page;
|
||||||
}
|
}
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
}
|
};
|
||||||
const handleSizeChange = (val: number) => {
|
const handleSizeChange = (val: number) => {
|
||||||
pagination.value.pageSize = val;
|
pagination.value.pageSize = val;
|
||||||
getPriceList();
|
getPriceList();
|
||||||
@@ -69,8 +75,8 @@ const handleCurrentChange = (val: number) => {
|
|||||||
getPriceList();
|
getPriceList();
|
||||||
};
|
};
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getPriceList()
|
getPriceList();
|
||||||
})
|
});
|
||||||
const openDialog = async (title, rowData) => {
|
const openDialog = async (title, rowData) => {
|
||||||
addDialog({
|
addDialog({
|
||||||
title: `${title}`,
|
title: `${title}`,
|
||||||
@@ -88,51 +94,53 @@ const openDialog = async (title, rowData) => {
|
|||||||
beforeSure: (done, { options }) => {
|
beforeSure: (done, { options }) => {
|
||||||
const FormRef = formRef.value.getRef();
|
const FormRef = formRef.value.getRef();
|
||||||
const curData = options.props.formInline;
|
const curData = options.props.formInline;
|
||||||
const saveData = async form => {
|
|
||||||
const { code,msg } = await addPriceData(form);
|
FormRef.validate(async valid => {
|
||||||
if (code) {
|
if (!valid) return;
|
||||||
message("新增成功", { type: "success" });
|
|
||||||
getPriceList();
|
if (title === "新增") {
|
||||||
done();
|
// 新增操作
|
||||||
} else {
|
const { code, msg } = await addPriceData(curData);
|
||||||
message(msg, { type: "error" });
|
if (code) {
|
||||||
}
|
message("新增成功", { type: "success" });
|
||||||
};
|
getPriceList();
|
||||||
const editData = async form => {
|
done();
|
||||||
const { code, msg } = await editPriceData({
|
|
||||||
...form,
|
|
||||||
id: rowData.id
|
|
||||||
});
|
|
||||||
if (code) {
|
|
||||||
message("修改成功", { type: "success" });
|
|
||||||
getPriceList();
|
|
||||||
done();
|
|
||||||
} else {
|
|
||||||
message(msg, { type: "error" });
|
|
||||||
}
|
|
||||||
};
|
|
||||||
FormRef.validate(valid => {
|
|
||||||
if (valid) {
|
|
||||||
if (title === "新增") {
|
|
||||||
saveData(curData);
|
|
||||||
} else {
|
} else {
|
||||||
editData(curData)
|
message(msg, { type: "error" });
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// 编辑操作 - 需要二级密码验证
|
||||||
|
verifyPassword(async () => {
|
||||||
|
const { code, msg } = await editPriceData({
|
||||||
|
...curData,
|
||||||
|
id: rowData.id
|
||||||
|
});
|
||||||
|
if (code) {
|
||||||
|
message("修改成功", { type: "success" });
|
||||||
|
getPriceList();
|
||||||
|
done();
|
||||||
|
} else {
|
||||||
|
message(msg, { type: "error" });
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
const handleDelete = async rowData => {
|
const handleDelete = async rowData => {
|
||||||
const { code, msg } = await deletePriceData({ id: rowData.id });
|
// 删除需要二级密码验证
|
||||||
if (code) {
|
verifyPassword(async () => {
|
||||||
message(`删除成功`, {
|
const { code, msg } = await deletePriceData({ id: rowData.id });
|
||||||
type: "success"
|
if (code) {
|
||||||
});
|
message(`删除成功`, {
|
||||||
getPriceList();
|
type: "success"
|
||||||
} else {
|
});
|
||||||
message(msg, { type: "error" });
|
getPriceList();
|
||||||
}
|
} else {
|
||||||
|
message(msg, { type: "error" });
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
// defineExpose({ getRef });
|
// defineExpose({ getRef });
|
||||||
</script>
|
</script>
|
||||||
@@ -143,7 +151,7 @@ const handleDelete = async rowData => {
|
|||||||
@refresh="getPriceList">
|
@refresh="getPriceList">
|
||||||
<template #buttons>
|
<template #buttons>
|
||||||
<!-- @click="openDialog('新增', {})" -->
|
<!-- @click="openDialog('新增', {})" -->
|
||||||
<el-button type="primary" @click="openDialog('新增', {})" :icon="useRenderIcon(AddFill)">
|
<el-button type="primary" :icon="useRenderIcon(AddFill)" @click="openDialog('新增', {})">
|
||||||
新增价格
|
新增价格
|
||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
@@ -154,7 +162,6 @@ const handleDelete = async rowData => {
|
|||||||
background: 'var(--el-fill-color-light)',
|
background: 'var(--el-fill-color-light)',
|
||||||
color: 'var(--el-text-color-primary)'
|
color: 'var(--el-text-color-primary)'
|
||||||
}" @page-current-change="handleCurrentChange" @page-size-change="handleSizeChange">
|
}" @page-current-change="handleCurrentChange" @page-size-change="handleSizeChange">
|
||||||
|
|
||||||
<template #operation="{ row }">
|
<template #operation="{ row }">
|
||||||
<!-- -->
|
<!-- -->
|
||||||
<!-- @confirm="handleDelete(row)" -->
|
<!-- @confirm="handleDelete(row)" -->
|
||||||
@@ -163,9 +170,7 @@ const handleDelete = async rowData => {
|
|||||||
</el-button>
|
</el-button>
|
||||||
<el-popconfirm :title="`是否删除这条数据`" @confirm="handleDelete(row)">
|
<el-popconfirm :title="`是否删除这条数据`" @confirm="handleDelete(row)">
|
||||||
<template #reference>
|
<template #reference>
|
||||||
<el-button link type="primary" :size="size">
|
<el-button link type="primary" :size="size"> 删除 </el-button>
|
||||||
删除
|
|
||||||
</el-button>
|
|
||||||
</template>
|
</template>
|
||||||
</el-popconfirm>
|
</el-popconfirm>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -98,6 +98,10 @@ export function useData() {
|
|||||||
</el-tag>
|
</el-tag>
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: "备注",
|
||||||
|
prop: "remarks"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: "生成时间",
|
label: "生成时间",
|
||||||
prop: "createtime"
|
prop: "createtime"
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { ref, h } from "vue";
|
import { ref, h } from "vue";
|
||||||
import editForm from "./form.vue";
|
import editForm from "./form.vue";
|
||||||
import { message } from "@/utils/message";
|
import { message } from "@/utils/message";
|
||||||
|
import { verifyPassword } from "@/utils/passwordVerify";
|
||||||
import {
|
import {
|
||||||
queryClassifyList,
|
queryClassifyList,
|
||||||
addClassifyData,
|
addClassifyData,
|
||||||
@@ -16,9 +17,7 @@ export function useData() {
|
|||||||
const searchForm = ref({
|
const searchForm = ref({
|
||||||
name: ""
|
name: ""
|
||||||
});
|
});
|
||||||
const searchLabel = ref([
|
const searchLabel = ref([{ label: "标签名称", prop: "name", type: "input" }]);
|
||||||
{ label: "标签名称", prop: "name", type: "input" }
|
|
||||||
]);
|
|
||||||
const pagination = ref({
|
const pagination = ref({
|
||||||
total: 0,
|
total: 0,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
@@ -55,9 +54,9 @@ export function useData() {
|
|||||||
slot: "operation"
|
slot: "operation"
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
const onSearch = async (formData) => {
|
const onSearch = async formData => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
searchForm.value = { ...formData }
|
searchForm.value = { ...formData };
|
||||||
const { data, code } = await queryClassifyList({
|
const { data, code } = await queryClassifyList({
|
||||||
...formData,
|
...formData,
|
||||||
page: pagination.value.currentPage,
|
page: pagination.value.currentPage,
|
||||||
@@ -78,16 +77,20 @@ export function useData() {
|
|||||||
pagination.value.currentPage = val;
|
pagination.value.currentPage = val;
|
||||||
onSearch(searchForm.value);
|
onSearch(searchForm.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDelete = async rowData => {
|
const handleDelete = async rowData => {
|
||||||
const { code } = await removeClassifyData({ id: rowData.id });
|
// 输入二级密码
|
||||||
if (code) {
|
verifyPassword(async () => {
|
||||||
message(`您删除了标签名称为${rowData.name}的这条数据`, {
|
const { code } = await removeClassifyData({ id: rowData.id });
|
||||||
type: "success"
|
if (code) {
|
||||||
});
|
message(`您删除了标签名称为${rowData.name}的这条数据`, {
|
||||||
onSearch(searchForm.value);
|
type: "success"
|
||||||
}
|
});
|
||||||
|
onSearch(searchForm.value);
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
// 新增
|
// 新增/编辑
|
||||||
const openDialog = (title = "新增", rowData: any) => {
|
const openDialog = (title = "新增", rowData: any) => {
|
||||||
addDialog({
|
addDialog({
|
||||||
title: `${title}礼物标签`,
|
title: `${title}礼物标签`,
|
||||||
@@ -104,40 +107,35 @@ export function useData() {
|
|||||||
beforeSure: (done, { options }) => {
|
beforeSure: (done, { options }) => {
|
||||||
const FormRef = formRef.value.getRef();
|
const FormRef = formRef.value.getRef();
|
||||||
const curData = options.props.formInline;
|
const curData = options.props.formInline;
|
||||||
const saveData = async form => {
|
|
||||||
const { code } = await addClassifyData(form);
|
FormRef.validate(async valid => {
|
||||||
if (code) {
|
if (!valid) return;
|
||||||
message("新增成功", { type: "success" });
|
|
||||||
onSearch(searchForm.value);
|
if (title === "新增") {
|
||||||
done();
|
// 新增操作
|
||||||
} else {
|
const { code } = await addClassifyData(curData);
|
||||||
message("新增失败", { type: "error" });
|
if (code) {
|
||||||
}
|
message("新增成功", { type: "success" });
|
||||||
};
|
onSearch(searchForm.value);
|
||||||
const updateData = async form => {
|
done();
|
||||||
const { code } = await editClassifyData({
|
|
||||||
...form,
|
|
||||||
id: rowData.id
|
|
||||||
});
|
|
||||||
if (code) {
|
|
||||||
message("修改成功", { type: "success" });
|
|
||||||
onSearch(searchForm.value);
|
|
||||||
done();
|
|
||||||
} else {
|
|
||||||
message("修改失败", { type: "error" });
|
|
||||||
}
|
|
||||||
};
|
|
||||||
FormRef.validate(valid => {
|
|
||||||
if (valid) {
|
|
||||||
console.log("curData", curData);
|
|
||||||
// 表单规则校验通过
|
|
||||||
if (title === "新增") {
|
|
||||||
// 实际开发先调用新增接口,再进行下面操作
|
|
||||||
saveData(curData);
|
|
||||||
} else {
|
} else {
|
||||||
// 实际开发先调用修改接口,再进行下面操作
|
message("新增失败", { type: "error" });
|
||||||
updateData(curData);
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// 修改操作 - 需要二级密码验证
|
||||||
|
verifyPassword(async () => {
|
||||||
|
const { code } = await editClassifyData({
|
||||||
|
...curData,
|
||||||
|
id: rowData.id
|
||||||
|
});
|
||||||
|
if (code) {
|
||||||
|
message("修改成功", { type: "success" });
|
||||||
|
onSearch(searchForm.value);
|
||||||
|
done(); // 关闭编辑对话框
|
||||||
|
} else {
|
||||||
|
message("修改失败", { type: "error" });
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { ref, h } from "vue";
|
import { ref, h } from "vue";
|
||||||
import editForm from "./form.vue";
|
import editForm from "./form.vue";
|
||||||
import { message } from "@/utils/message";
|
import { message } from "@/utils/message";
|
||||||
|
import { verifyPassword } from "@/utils/passwordVerify";
|
||||||
import { getGiftTypeOrLabel } from "@/api/modules/gift";
|
import { getGiftTypeOrLabel } from "@/api/modules/gift";
|
||||||
import {
|
import {
|
||||||
queryGiftList,
|
queryGiftList,
|
||||||
@@ -184,13 +185,16 @@ export function useData() {
|
|||||||
onSearch(searchForm.value);
|
onSearch(searchForm.value);
|
||||||
};
|
};
|
||||||
const handleDelete = async rowData => {
|
const handleDelete = async rowData => {
|
||||||
const { code } = await removeGiftData({ gid: rowData.gid });
|
// 输入二级密码
|
||||||
if (code) {
|
verifyPassword(async () => {
|
||||||
message(`您删除了礼物名称为【${rowData.gift_name}】的这条数据`, {
|
const { code } = await removeGiftData({ gid: rowData.gid });
|
||||||
type: "success"
|
if (code) {
|
||||||
});
|
message(`您删除了礼物名称为【${rowData.gift_name}】的这条数据`, {
|
||||||
onSearch(searchForm.value);
|
type: "success"
|
||||||
}
|
});
|
||||||
|
onSearch(searchForm.value);
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
// 新增
|
// 新增
|
||||||
const openDialog = async (title = "新增", rowData: any) => {
|
const openDialog = async (title = "新增", rowData: any) => {
|
||||||
@@ -231,18 +235,21 @@ export function useData() {
|
|||||||
message(msg, { type: "error" });
|
message(msg, { type: "error" });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const updateData = async form => {
|
const updateData = async (form, editDialogDone) => {
|
||||||
const { code, msg } = await editGiftData({
|
// 修改时需要二级密码验证
|
||||||
...form,
|
verifyPassword(async () => {
|
||||||
gid: rowData.gid
|
const { code, msg } = await editGiftData({
|
||||||
|
...form,
|
||||||
|
gid: rowData.gid
|
||||||
|
});
|
||||||
|
if (code) {
|
||||||
|
message("修改成功", { type: "success" });
|
||||||
|
onSearch(searchForm.value);
|
||||||
|
editDialogDone(); // 关闭编辑对话框
|
||||||
|
} else {
|
||||||
|
message(msg, { type: "error" });
|
||||||
|
}
|
||||||
});
|
});
|
||||||
if (code) {
|
|
||||||
message("修改成功", { type: "success" });
|
|
||||||
onSearch(searchForm.value);
|
|
||||||
done();
|
|
||||||
} else {
|
|
||||||
message(msg, { type: "error" });
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
FormRef.validate(valid => {
|
FormRef.validate(valid => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
@@ -253,7 +260,7 @@ export function useData() {
|
|||||||
saveData(curData);
|
saveData(curData);
|
||||||
} else {
|
} else {
|
||||||
// 实际开发先调用修改接口,再进行下面操作
|
// 实际开发先调用修改接口,再进行下面操作
|
||||||
updateData(curData);
|
updateData(curData, done);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -310,10 +310,10 @@ const exportExcal = async () => {
|
|||||||
<el-button size="small" type="primary" @click="exportExcal">导出当前数据</el-button>
|
<el-button size="small" type="primary" @click="exportExcal">导出当前数据</el-button>
|
||||||
</div>
|
</div>
|
||||||
幸运值流水总计:<span style="color: red">{{
|
幸运值流水总计:<span style="color: red">{{
|
||||||
PriceTotal.total_lucky_coin
|
PriceTotal.total_lucky_coin || 0
|
||||||
}}</span>
|
}}</span>
|
||||||
;流水总计:<span style="color: red">{{
|
;流水总计:<span style="color: red">{{
|
||||||
PriceTotal.total_price
|
PriceTotal.total_price || 0
|
||||||
}}</span>
|
}}</span>
|
||||||
金币
|
金币
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user