修复区域飘屏
This commit is contained in:
parent
0ddf3bd3bd
commit
8043571cec
@ -10,6 +10,7 @@ import {
|
||||
startRegionBroadcastWorker,
|
||||
stopRegionBroadcastWorker,
|
||||
} from '#/api/legacy/region-broadcast';
|
||||
import { regionConfigTable } from '#/api/legacy/system';
|
||||
import { getAllowedSysOrigins } from '#/views/system/shared';
|
||||
|
||||
import SystemRegionSelect from './components/system-region-select.vue';
|
||||
@ -69,6 +70,7 @@ const form = reactive<Record<string, any>>({
|
||||
const sending = ref(false);
|
||||
const workerLoading = ref(false);
|
||||
const resultText = ref('');
|
||||
const regionList = ref<Array<Record<string, any>>>([]);
|
||||
const workerStatus = ref<Record<string, any>>({});
|
||||
const workerForm = reactive<Record<string, any>>({
|
||||
betAmounts: '100,200,500,1000',
|
||||
@ -103,11 +105,20 @@ watch(
|
||||
form.regionCode = '';
|
||||
workerForm.regionCodes = [];
|
||||
if (value) {
|
||||
void loadRegionList();
|
||||
void refreshWorkerStatus();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
async function loadRegionList() {
|
||||
if (!form.sysOrigin) {
|
||||
regionList.value = [];
|
||||
return;
|
||||
}
|
||||
regionList.value = (await regionConfigTable({ sysOrigin: form.sysOrigin })) || [];
|
||||
}
|
||||
|
||||
function handleRegionChange(_value: any, item: Record<string, any> | null) {
|
||||
form.regionCode = item?.regionCode || item?.code || String(item?.id || '');
|
||||
}
|
||||
@ -199,11 +210,25 @@ function buildWorkerPayload() {
|
||||
maxDelaySeconds: Number(workerForm.maxDelaySeconds || 0),
|
||||
minDelaySeconds: Number(workerForm.minDelaySeconds || 0),
|
||||
multiples: parseFloatList(workerForm.multiples),
|
||||
regionCodes: workerForm.regionCodes || [],
|
||||
regionCodes: normalizeWorkerRegionCodes(workerForm.regionCodes || []),
|
||||
sysOrigin: form.sysOrigin,
|
||||
};
|
||||
}
|
||||
|
||||
function normalizeWorkerRegionCodes(values: any[]) {
|
||||
return values
|
||||
.map((value) => {
|
||||
const raw = String(value || '').trim();
|
||||
const item = regionList.value.find((region) =>
|
||||
[region.id, region.regionCode, region.code, region.regionName]
|
||||
.filter((current) => current !== undefined && current !== null)
|
||||
.some((current) => String(current).trim() === raw),
|
||||
);
|
||||
return String(item?.regionCode || item?.code || item?.regionName || raw).trim();
|
||||
})
|
||||
.filter(Boolean);
|
||||
}
|
||||
|
||||
async function refreshWorkerStatus() {
|
||||
workerLoading.value = true;
|
||||
try {
|
||||
@ -214,6 +239,7 @@ async function refreshWorkerStatus() {
|
||||
}
|
||||
|
||||
async function handleStartWorker() {
|
||||
await loadRegionList();
|
||||
const payload = buildWorkerPayload();
|
||||
if (!payload.sysOrigin) {
|
||||
message.warning('请选择系统来源');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user