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