修改商店
This commit is contained in:
parent
9ad05f8aef
commit
15fbfa95de
@ -85,11 +85,11 @@ export async function getGroupActivityList() {
|
||||
}
|
||||
|
||||
export async function sendPropsGiveUser(data: Record<string, any>) {
|
||||
return requestClient.post<string | null>('/props/give/send', data);
|
||||
return requestClient.post<null | string>('/props/give/send', data);
|
||||
}
|
||||
|
||||
export async function sendPropsTicketGiveUser(data: Record<string, any>) {
|
||||
return requestClient.post<string | null>('/props/give/grant-coupon', data);
|
||||
return requestClient.post<null | string>('/props/give/grant-coupon', data);
|
||||
}
|
||||
|
||||
export async function pagePropsStore(params: Record<string, any>) {
|
||||
@ -101,6 +101,17 @@ export async function pagePropsStore(params: Record<string, any>) {
|
||||
);
|
||||
}
|
||||
|
||||
export async function mapPropsStoreBySourceIds(data: Record<string, any>) {
|
||||
return requestClient.post<Record<string, Record<string, any>>>(
|
||||
'/go/props/store/source-map',
|
||||
data,
|
||||
);
|
||||
}
|
||||
|
||||
export async function addOrUpdatePropsStore(data: Record<string, any>) {
|
||||
return requestClient.post('/go/props/store/add-or-update', data);
|
||||
}
|
||||
|
||||
export async function addOrUpdatePropsStoreLegacy(data: Record<string, any>) {
|
||||
return requestClient.post('/props/store/add-or-update', data);
|
||||
}
|
||||
|
||||
@ -1,28 +1,28 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed, reactive, ref, watch } from 'vue';
|
||||
|
||||
import {
|
||||
addOrUpdatePropsStore,
|
||||
listSysOriginTypeList,
|
||||
} from '#/api/legacy/props';
|
||||
|
||||
import {
|
||||
Form,
|
||||
FormItem,
|
||||
Input,
|
||||
message,
|
||||
Modal,
|
||||
Select,
|
||||
Switch,
|
||||
message,
|
||||
} from 'antdv-next';
|
||||
|
||||
import RewardIcon from './reward-icon.vue';
|
||||
import {
|
||||
addOrUpdatePropsStoreLegacy,
|
||||
listSysOriginTypeList,
|
||||
} from '#/api/legacy/props';
|
||||
|
||||
import {
|
||||
NOBLE_VIP_OPTIONS,
|
||||
PROPS_CURRENCY_TYPES,
|
||||
PROPS_STORE_TYPES,
|
||||
PROPS_VALID_DAYS,
|
||||
} from '../shared';
|
||||
import RewardIcon from './reward-icon.vue';
|
||||
|
||||
const props = defineProps<{
|
||||
open: boolean;
|
||||
@ -42,14 +42,15 @@ const sourceOptionsMap = reactive<
|
||||
Record<string, { list: Array<Record<string, any>>; loaded: boolean; loading: boolean }>
|
||||
>({});
|
||||
|
||||
const mainSource = ref<Record<string, any> | null>(null);
|
||||
const rideSource = ref<Record<string, any> | null>(null);
|
||||
const avatarSource = ref<Record<string, any> | null>(null);
|
||||
const dataCardSource = ref<Record<string, any> | null>(null);
|
||||
const chatBubbleSource = ref<Record<string, any> | null>(null);
|
||||
const mainSource = ref<null | Record<string, any>>(null);
|
||||
const rideSource = ref<null | Record<string, any>>(null);
|
||||
const avatarSource = ref<null | Record<string, any>>(null);
|
||||
const dataCardSource = ref<null | Record<string, any>>(null);
|
||||
const chatBubbleSource = ref<null | Record<string, any>>(null);
|
||||
|
||||
const form = reactive<Record<string, any>>({
|
||||
currencyTypes: '',
|
||||
del: false,
|
||||
discount: 0,
|
||||
id: '',
|
||||
label: '',
|
||||
@ -161,6 +162,7 @@ watch(
|
||||
const propsAbility = record.propsAbility || {};
|
||||
const nobleVipAbility = propsAbility.nobleVipAbility || {};
|
||||
form.currencyTypes = commodity.currencyTypes || '';
|
||||
form.del = commodity.del ?? false;
|
||||
form.discount = commodity.discount || 0;
|
||||
form.id = commodity.id || '';
|
||||
form.label = commodity.label || '';
|
||||
@ -203,7 +205,7 @@ watch(
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
function updateSelectedSource(type: string, id: string | number) {
|
||||
function updateSelectedSource(type: string, id: number | string) {
|
||||
const item = sourceOptionsMap[type]?.list.find(
|
||||
(option) => String(option.id) === String(id),
|
||||
);
|
||||
@ -295,7 +297,7 @@ async function handleSubmit() {
|
||||
}
|
||||
saving.value = true;
|
||||
try {
|
||||
await addOrUpdatePropsStore({
|
||||
await addOrUpdatePropsStoreLegacy({
|
||||
...form,
|
||||
currencyTypes: form.tmpCurrencyTypes.join(','),
|
||||
discount: Number(form.discount) >= 0 && Number(form.discount) <= 1 ? Number(form.discount) : 1,
|
||||
@ -324,9 +326,11 @@ async function handleSubmit() {
|
||||
<Form layout="vertical">
|
||||
<div class="form-grid">
|
||||
<FormItem label="归属系统">
|
||||
<SysOriginSelect v-model:value="form.sysOrigin" disabled
|
||||
<SysOriginSelect
|
||||
v-model:value="form.sysOrigin"
|
||||
disabled
|
||||
:options="sysOriginOptions"
|
||||
></SysOriginSelect>
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem label="道具类型">
|
||||
<Select
|
||||
@ -339,7 +343,8 @@ async function handleSubmit() {
|
||||
</div>
|
||||
|
||||
<FormItem label="道具资源">
|
||||
<Select option-label-prop="label"
|
||||
<Select
|
||||
option-label-prop="label"
|
||||
v-model:value="form.sourceId"
|
||||
:loading="sourceOptionsMap[form.propsType]?.loading"
|
||||
:options="getSourceSelectOptions(form.propsType)"
|
||||
@ -429,7 +434,8 @@ async function handleSubmit() {
|
||||
<div class="ability-grid">
|
||||
<div class="ability-item">
|
||||
<div class="ability-item__label">车辆</div>
|
||||
<Select option-label-prop="label"
|
||||
<Select
|
||||
option-label-prop="label"
|
||||
v-model:value="form.propsAbility.carId"
|
||||
:loading="sourceOptionsMap.RIDE?.loading"
|
||||
:options="getSourceSelectOptions('RIDE')"
|
||||
@ -447,7 +453,8 @@ async function handleSubmit() {
|
||||
|
||||
<div class="ability-item">
|
||||
<div class="ability-item__label">头像框</div>
|
||||
<Select option-label-prop="label"
|
||||
<Select
|
||||
option-label-prop="label"
|
||||
v-model:value="form.propsAbility.avatarFrameId"
|
||||
:loading="sourceOptionsMap.AVATAR_FRAME?.loading"
|
||||
:options="getSourceSelectOptions('AVATAR_FRAME')"
|
||||
@ -465,7 +472,8 @@ async function handleSubmit() {
|
||||
|
||||
<div class="ability-item">
|
||||
<div class="ability-item__label">资料卡</div>
|
||||
<Select option-label-prop="label"
|
||||
<Select
|
||||
option-label-prop="label"
|
||||
v-model:value="form.propsAbility.dataCardId"
|
||||
:loading="sourceOptionsMap.DATA_CARD?.loading"
|
||||
:options="getSourceSelectOptions('DATA_CARD')"
|
||||
@ -483,7 +491,8 @@ async function handleSubmit() {
|
||||
|
||||
<div class="ability-item">
|
||||
<div class="ability-item__label">聊天气泡</div>
|
||||
<Select option-label-prop="label"
|
||||
<Select
|
||||
option-label-prop="label"
|
||||
v-model:value="form.propsAbility.chatBubbleId"
|
||||
:loading="sourceOptionsMap.CHAT_BUBBLE?.loading"
|
||||
:options="getSourceSelectOptions('CHAT_BUBBLE')"
|
||||
|
||||
@ -34,6 +34,7 @@ import {
|
||||
|
||||
import {
|
||||
addOrUpdatePropsStore,
|
||||
mapPropsStoreBySourceIds,
|
||||
offShelfPropsSource,
|
||||
pagePropsSource,
|
||||
updatePropsSource,
|
||||
@ -258,7 +259,8 @@ async function loadData(reset = false) {
|
||||
loading.value = true;
|
||||
try {
|
||||
const result = await pagePropsSource({ ...query });
|
||||
list.value = result.records || [];
|
||||
const records = result.records || [];
|
||||
list.value = await attachStoreCommodities(records);
|
||||
total.value = result.total || 0;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
@ -266,6 +268,27 @@ async function loadData(reset = false) {
|
||||
}
|
||||
}
|
||||
|
||||
async function attachStoreCommodities(records: Array<Record<string, any>>) {
|
||||
const sourceIds = [
|
||||
...new Set(
|
||||
records
|
||||
.map((record) => String(record.id || '').trim())
|
||||
.filter(Boolean),
|
||||
),
|
||||
];
|
||||
if (sourceIds.length === 0) {
|
||||
return records;
|
||||
}
|
||||
const commodityMap = await mapPropsStoreBySourceIds({
|
||||
sourceIds,
|
||||
sysOrigin: query.sysOrigin,
|
||||
});
|
||||
return records.map((record) => ({
|
||||
...record,
|
||||
storeCommodity: commodityMap[String(record.id)] || null,
|
||||
}));
|
||||
}
|
||||
|
||||
function updateTableScrollY() {
|
||||
const area = tableAreaRef.value;
|
||||
if (!area) {
|
||||
@ -423,6 +446,7 @@ function buildStoreShelfPayload(record: Record<string, any>, checked: boolean) {
|
||||
return {
|
||||
...commodity,
|
||||
currencyTypes: commodity.currencyTypes || DEFAULT_STORE_CURRENCY_TYPES,
|
||||
del: commodity.del ?? false,
|
||||
discount: commodity.discount ?? 0,
|
||||
label: commodity.label || '',
|
||||
propsType: commodity.propsType || record.type,
|
||||
@ -442,9 +466,6 @@ async function handleStoreShelfStatusChange(record: Record<string, any>, checked
|
||||
try {
|
||||
await addOrUpdatePropsStore(nextCommodity);
|
||||
message.success('道具商店状态已更新');
|
||||
if (!commodity) {
|
||||
await loadData();
|
||||
}
|
||||
} catch (error) {
|
||||
if (commodity) {
|
||||
commodity.shelfStatus = previous;
|
||||
|
||||
@ -1,35 +1,31 @@
|
||||
<script lang="ts" setup>
|
||||
import {
|
||||
computed,
|
||||
reactive,
|
||||
ref } from 'vue';
|
||||
import { computed, reactive, ref } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
import { useAccessStore } from '@vben/stores';
|
||||
|
||||
import {
|
||||
addOrUpdatePropsStore,
|
||||
pagePropsStore,
|
||||
} from '#/api/legacy/props';
|
||||
import SysOriginLabel from '#/components/sys-origin-label.vue';
|
||||
import InlineFilterField from '#/views/_shared/inline-filter-field.vue';
|
||||
import InlineFilterToolbar from '#/views/_shared/inline-filter-toolbar.vue';
|
||||
import { formatDate,
|
||||
getAllowedSysOrigins } from '#/views/system/shared';
|
||||
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
Input,
|
||||
message,
|
||||
Pagination,
|
||||
Select,
|
||||
Space,
|
||||
Switch,
|
||||
Table,
|
||||
Tag,
|
||||
message
|
||||
} from 'antdv-next';
|
||||
|
||||
import {
|
||||
addOrUpdatePropsStore,
|
||||
pagePropsStore,
|
||||
} from '#/api/legacy/props';
|
||||
import SysOriginLabel from '#/components/sys-origin-label.vue';
|
||||
import InlineFilterField from '#/views/_shared/inline-filter-field.vue';
|
||||
import InlineFilterToolbar from '#/views/_shared/inline-filter-toolbar.vue';
|
||||
import { formatDate, getAllowedSysOrigins } from '#/views/system/shared';
|
||||
|
||||
import RewardIcon from './components/reward-icon.vue';
|
||||
import StoreEditModal from './components/store-edit-modal.vue';
|
||||
import {
|
||||
@ -50,7 +46,7 @@ const loading = ref(false);
|
||||
const total = ref(0);
|
||||
const list = ref<Array<Record<string, any>>>([]);
|
||||
const formOpen = ref(false);
|
||||
const activeRow = ref<Record<string, any> | null>(null);
|
||||
const activeRow = ref<null | Record<string, any>>(null);
|
||||
|
||||
const query = reactive({
|
||||
cursor: 1,
|
||||
@ -145,34 +141,34 @@ loadData(true);
|
||||
@change="loadData(true)"
|
||||
|
||||
:options="sysOriginOptions"
|
||||
></SysOriginSelect>
|
||||
/>
|
||||
</InlineFilterField>
|
||||
<InlineFilterField label="道具类型">
|
||||
<Select option-label-prop="label"
|
||||
<Select
|
||||
option-label-prop="label"
|
||||
v-model:value="query.propsType"
|
||||
style="width: 140px"
|
||||
@change="loadData(true)"
|
||||
|
||||
:options="PROPS_STORE_TYPES.map((item) => ({ label: `${item.name}`, value: item.value as any }))"
|
||||
/>
|
||||
</InlineFilterField>
|
||||
<InlineFilterField label="状态">
|
||||
<Select option-label-prop="label"
|
||||
<Select
|
||||
option-label-prop="label"
|
||||
v-model:value="query.shelfStatus"
|
||||
allow-clear
|
||||
style="width: 120px"
|
||||
@change="loadData(true)"
|
||||
|
||||
:options="PROPS_SHELF_STATUS_OPTIONS.map((item) => ({ label: `${item.name}`, value: item.value as any }))"
|
||||
/>
|
||||
</InlineFilterField>
|
||||
<InlineFilterField label="付费类型" :label-width="72">
|
||||
<Select option-label-prop="label"
|
||||
<Select
|
||||
option-label-prop="label"
|
||||
v-model:value="query.currencyTypes"
|
||||
allow-clear
|
||||
style="width: 120px"
|
||||
@change="loadData(true)"
|
||||
|
||||
:options="PROPS_CURRENCY_TYPES.map((item) => ({ label: `${item.name}`, value: item.value as any }))"
|
||||
/>
|
||||
</InlineFilterField>
|
||||
@ -262,7 +258,7 @@ loadData(true);
|
||||
:total="total"
|
||||
show-size-changer
|
||||
@change="handlePageChange"
|
||||
@showSizeChange="handlePageChange"
|
||||
@show-size-change="handlePageChange"
|
||||
/>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user