All checks were successful
Build and Deploy Front / deploy (push) Successful in 5m34s
Co-authored-by: Cursor <cursoragent@cursor.com>
916 lines
27 KiB
Vue
916 lines
27 KiB
Vue
<template>
|
|
<div class="other-config-container">
|
|
<div class="other-config-page-card">
|
|
<div class="page-header">
|
|
<h2 class="page-title">{{ t('system.otherConfig.pageTitle') }}</h2>
|
|
<div class="page-header-actions">
|
|
<a-button type="primary" @click="handleAdd">{{ t('system.otherConfig.actions.add') }}</a-button>
|
|
<a-button @click="loadData">{{ t('system.otherConfig.actions.refresh') }}</a-button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card-grid">
|
|
<div v-for="item in list" :key="item.id" class="config-card-shell">
|
|
<a-card class="config-card-arco">
|
|
<template #title>
|
|
<div class="config-card-title">
|
|
<span class="config-card-icon" aria-hidden="true">
|
|
<icon-settings />
|
|
</span>
|
|
<span class="config-card-title-text">{{ item.configName || '-' }}</span>
|
|
</div>
|
|
</template>
|
|
<template #extra>
|
|
<div class="card-extra">
|
|
<a-space :size="4">
|
|
<a-tag v-if="platformTag(item.configCode)" size="small" color="arcoblue">
|
|
{{ platformTag(item.configCode) }}
|
|
</a-tag>
|
|
<a-tag size="small" :color="item.enabled ? 'green' : 'gray'">
|
|
{{ item.enabled ? t('system.otherConfig.status.enabled') : t('system.otherConfig.status.disabled') }}
|
|
</a-tag>
|
|
</a-space>
|
|
<div class="card-header-actions">
|
|
<a-tooltip :content="t('system.otherConfig.actions.edit')">
|
|
<a-button type="text" size="small" class="action-icon-btn" @click.stop="handleEdit(item)">
|
|
<template #icon><icon-edit /></template>
|
|
</a-button>
|
|
</a-tooltip>
|
|
<a-tooltip :content="t('system.otherConfig.actions.delete')">
|
|
<a-button
|
|
type="text"
|
|
size="small"
|
|
class="action-icon-btn action-icon-btn--danger"
|
|
@click.stop="handleDeleteConfirm(item)"
|
|
>
|
|
<template #icon><icon-delete /></template>
|
|
</a-button>
|
|
</a-tooltip>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
<div class="card-body">
|
|
<div class="card-body-scroll">
|
|
<div class="card-row">
|
|
<span class="label">{{ t('system.otherConfig.table.configCode') }}:</span>
|
|
<span class="value">{{ item.configCode || '-' }}</span>
|
|
</div>
|
|
<div class="card-row">
|
|
<span class="label">{{ cardFieldLabel(item.configCode, 'baseUrl') }}:</span>
|
|
<span class="value value-break">{{ item.baseUrl || '-' }}</span>
|
|
</div>
|
|
<div v-if="cardShowField(item.configCode, 'appKey')" class="card-row">
|
|
<span class="label">{{ cardFieldLabel(item.configCode, 'appKey') }}:</span>
|
|
<span class="value">{{ item.appKey || '-' }}</span>
|
|
</div>
|
|
<div v-if="cardShowField(item.configCode, 'appSecret')" class="card-row">
|
|
<span class="label">{{ cardFieldLabel(item.configCode, 'appSecret') }}:</span>
|
|
<span class="value">{{ item.appSecret || '-' }}</span>
|
|
</div>
|
|
<div class="card-row">
|
|
<span class="label">{{ t('system.otherConfig.table.timeoutSeconds') }}:</span>
|
|
<span class="value">{{ item.timeoutSeconds ?? '-' }}</span>
|
|
</div>
|
|
<div v-if="item.remark" class="card-row">
|
|
<span class="label">{{ cardFieldLabel(item.configCode, 'remark') }}:</span>
|
|
<span class="value value-break">{{ item.remark }}</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</a-card>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<a-modal
|
|
v-model:visible="modalVisible"
|
|
:title="isEdit ? t('system.otherConfig.modal.editTitle') : t('system.otherConfig.modal.addTitle')"
|
|
:confirm-loading="modalLoading"
|
|
width="640px"
|
|
:mask-closable="false"
|
|
unmount-on-close
|
|
@ok="handleModalOk"
|
|
>
|
|
<a-alert type="info" :show-icon="false" class="modal-form-tip">
|
|
{{ fieldHint || (isEdit ? t('system.otherConfig.modal.tipEdit') : t('system.otherConfig.modal.tip')) }}
|
|
</a-alert>
|
|
<a-form
|
|
ref="formRef"
|
|
:model="formState"
|
|
:rules="formRules"
|
|
layout="vertical"
|
|
class="other-config-form"
|
|
>
|
|
<div class="form-section-title">{{ t('system.otherConfig.section.basic') }}</div>
|
|
<a-row :gutter="16">
|
|
<a-col v-if="!isEdit" :span="24">
|
|
<a-form-item :label="t('system.otherConfig.form.preset')" field="preset">
|
|
<a-select
|
|
v-model="selectedPreset"
|
|
:options="presetOptions"
|
|
:placeholder="t('system.otherConfig.placeholder.preset')"
|
|
allow-search
|
|
@change="applyPreset"
|
|
/>
|
|
</a-form-item>
|
|
</a-col>
|
|
<a-col :span="12">
|
|
<a-form-item :label="t('system.otherConfig.form.configCode')" field="configCode">
|
|
<a-input
|
|
v-model="formState.configCode"
|
|
:placeholder="t('system.otherConfig.placeholder.configCode')"
|
|
:disabled="isEdit"
|
|
/>
|
|
</a-form-item>
|
|
</a-col>
|
|
<a-col :span="12">
|
|
<a-form-item :label="t('system.otherConfig.form.configName')" field="configName">
|
|
<a-input
|
|
v-model="formState.configName"
|
|
:placeholder="t('system.otherConfig.placeholder.input')"
|
|
/>
|
|
</a-form-item>
|
|
</a-col>
|
|
<a-col :span="12">
|
|
<a-form-item :label="t('system.otherConfig.form.enabled')" field="enabled">
|
|
<a-switch v-model="formState.enabled" />
|
|
</a-form-item>
|
|
</a-col>
|
|
</a-row>
|
|
|
|
<div class="form-section-title">{{ t('system.otherConfig.section.connection') }}</div>
|
|
<a-row :gutter="16">
|
|
<a-col :span="24">
|
|
<a-form-item :label="fieldLabels.baseUrl" field="baseUrl">
|
|
<a-input v-model="formState.baseUrl" :placeholder="fieldPlaceholders.baseUrl" />
|
|
</a-form-item>
|
|
</a-col>
|
|
<a-col v-if="showAppKey" :span="12">
|
|
<a-form-item :label="fieldLabels.appKey" field="appKey">
|
|
<a-input v-model="formState.appKey" :placeholder="fieldPlaceholders.appKey" />
|
|
</a-form-item>
|
|
</a-col>
|
|
<a-col v-if="showAppSecret" :span="12">
|
|
<a-form-item :label="fieldLabels.appSecret" field="appSecret">
|
|
<a-input-password
|
|
v-model="formState.appSecret"
|
|
:placeholder="isEdit ? t('system.otherConfig.placeholder.appSecretEdit') : fieldPlaceholders.appSecret"
|
|
allow-clear
|
|
/>
|
|
</a-form-item>
|
|
</a-col>
|
|
<a-col :span="12">
|
|
<a-form-item :label="t('system.otherConfig.form.timeoutSeconds')" field="timeoutSeconds">
|
|
<a-input-number
|
|
v-model="formState.timeoutSeconds"
|
|
:min="5"
|
|
:max="300"
|
|
:precision="0"
|
|
style="width: 100%"
|
|
/>
|
|
</a-form-item>
|
|
</a-col>
|
|
</a-row>
|
|
|
|
<template v-if="showRemark">
|
|
<div class="form-section-title">{{ t('system.otherConfig.section.more') }}</div>
|
|
<a-row :gutter="16">
|
|
<a-col :span="24">
|
|
<a-form-item :label="fieldLabels.remark" field="remark">
|
|
<a-textarea
|
|
v-model="formState.remark"
|
|
:placeholder="fieldPlaceholders.remark"
|
|
:auto-size="{ minRows: 2, maxRows: 4 }"
|
|
/>
|
|
</a-form-item>
|
|
</a-col>
|
|
</a-row>
|
|
</template>
|
|
</a-form>
|
|
</a-modal>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
|
import { Message, Modal } from '@arco-design/web-vue'
|
|
import { useI18n } from 'vue-i18n'
|
|
import {
|
|
API_CENTER_CONFIG_CODE,
|
|
PICKUP_OPEN_API_CONFIG_CODE,
|
|
PLATFORM_SHOP_CONFIG_CODES,
|
|
TRACK_SERVICE_CONFIG_CODE,
|
|
WECHAT_MP_CONFIG_CODE,
|
|
WECHAT_MP_FOLLOW_CONFIG_CODE,
|
|
createSystemOtherConfig,
|
|
deleteSystemOtherConfig,
|
|
getSystemOtherConfigDetail,
|
|
getSystemOtherConfigList,
|
|
updateSystemOtherConfig,
|
|
type SystemOtherConfigDto,
|
|
} from '@/api/system/otherConfig'
|
|
import { prodApiOrigin } from '@/utils/rewriteBrowserApiPath'
|
|
|
|
defineOptions({
|
|
name: 'SystemOtherConfig',
|
|
})
|
|
|
|
const { t } = useI18n()
|
|
|
|
function defaultSiteOrigin(): string {
|
|
if (typeof window !== 'undefined' && window.location?.origin) {
|
|
return window.location.origin.replace(/\/$/, '')
|
|
}
|
|
return 'https://test.ideship.com'
|
|
}
|
|
|
|
function defaultApiOrigin(): string {
|
|
return prodApiOrigin()
|
|
}
|
|
|
|
const list = ref<SystemOtherConfigDto[]>([])
|
|
const modalVisible = ref(false)
|
|
const modalLoading = ref(false)
|
|
const isEdit = ref(false)
|
|
const editingId = ref<number | string>()
|
|
const formRef = ref()
|
|
const selectedPreset = ref(TRACK_SERVICE_CONFIG_CODE)
|
|
|
|
type FieldMeta = {
|
|
baseUrl: string
|
|
appKey: string
|
|
appSecret: string
|
|
remark: string
|
|
hint?: string
|
|
showAppKey?: boolean
|
|
showAppSecret?: boolean
|
|
showRemark?: boolean
|
|
requireAppKey?: boolean
|
|
requireAppSecret?: boolean
|
|
requireBaseUrl?: boolean
|
|
requireRemark?: boolean
|
|
}
|
|
|
|
const PRESET_DEFS: Array<{
|
|
code: string
|
|
nameKey: string
|
|
defaults: Partial<typeof formState>
|
|
meta: FieldMeta
|
|
}> = [
|
|
{
|
|
code: TRACK_SERVICE_CONFIG_CODE,
|
|
nameKey: 'system.otherConfig.defaults.trackServiceName',
|
|
defaults: {
|
|
configCode: TRACK_SERVICE_CONFIG_CODE,
|
|
enabled: true,
|
|
baseUrl: `${defaultApiOrigin()}/track`,
|
|
timeoutSeconds: 30,
|
|
},
|
|
meta: {
|
|
baseUrl: 'system.otherConfig.form.baseUrl',
|
|
appKey: 'system.otherConfig.form.appKey',
|
|
appSecret: 'system.otherConfig.form.appSecret',
|
|
remark: 'system.otherConfig.form.remark',
|
|
requireBaseUrl: true,
|
|
requireAppKey: true,
|
|
requireAppSecret: true,
|
|
},
|
|
},
|
|
{
|
|
code: API_CENTER_CONFIG_CODE,
|
|
nameKey: 'system.otherConfig.defaults.apiCenterName',
|
|
defaults: {
|
|
configCode: API_CENTER_CONFIG_CODE,
|
|
enabled: true,
|
|
baseUrl: `${defaultApiOrigin()}/itfx`,
|
|
timeoutSeconds: 30,
|
|
},
|
|
meta: {
|
|
baseUrl: 'system.otherConfig.fields.apiCenter.baseUrl',
|
|
appKey: 'system.otherConfig.fields.apiCenter.appKey',
|
|
appSecret: 'system.otherConfig.fields.apiCenter.appSecret',
|
|
remark: 'system.otherConfig.form.remark',
|
|
hint: 'system.otherConfig.hint.apiCenter',
|
|
showRemark: false,
|
|
requireBaseUrl: true,
|
|
requireAppKey: true,
|
|
requireAppSecret: true,
|
|
},
|
|
},
|
|
{
|
|
code: PICKUP_OPEN_API_CONFIG_CODE,
|
|
nameKey: 'system.otherConfig.defaults.pickupOpenApiName',
|
|
defaults: {
|
|
configCode: PICKUP_OPEN_API_CONFIG_CODE,
|
|
enabled: true,
|
|
timeoutSeconds: 30,
|
|
},
|
|
meta: {
|
|
baseUrl: 'system.otherConfig.form.baseUrl',
|
|
appKey: 'system.otherConfig.form.appKey',
|
|
appSecret: 'system.otherConfig.form.appSecret',
|
|
remark: 'system.otherConfig.form.remark',
|
|
hint: 'system.otherConfig.hint.pickupOpenApi',
|
|
showAppSecret: false,
|
|
requireAppKey: true,
|
|
},
|
|
},
|
|
{
|
|
code: WECHAT_MP_CONFIG_CODE,
|
|
nameKey: 'system.otherConfig.defaults.wechatMpName',
|
|
defaults: {
|
|
configCode: WECHAT_MP_CONFIG_CODE,
|
|
enabled: true,
|
|
baseUrl: defaultSiteOrigin(),
|
|
timeoutSeconds: 30,
|
|
},
|
|
meta: {
|
|
baseUrl: 'system.otherConfig.fields.wechat.baseUrl',
|
|
appKey: 'system.otherConfig.fields.wechat.appKey',
|
|
appSecret: 'system.otherConfig.fields.wechat.appSecret',
|
|
remark: 'system.otherConfig.fields.wechat.remark',
|
|
hint: 'system.otherConfig.hint.wechat',
|
|
requireAppKey: true,
|
|
requireAppSecret: true,
|
|
requireRemark: true,
|
|
},
|
|
},
|
|
{
|
|
code: WECHAT_MP_FOLLOW_CONFIG_CODE,
|
|
nameKey: 'system.otherConfig.defaults.wechatMpFollowName',
|
|
defaults: {
|
|
configCode: WECHAT_MP_FOLLOW_CONFIG_CODE,
|
|
enabled: true,
|
|
timeoutSeconds: 10,
|
|
},
|
|
meta: {
|
|
baseUrl: 'system.otherConfig.fields.wechatFollow.baseUrl',
|
|
appKey: 'system.otherConfig.form.appKey',
|
|
appSecret: 'system.otherConfig.form.appSecret',
|
|
remark: 'system.otherConfig.form.remark',
|
|
hint: 'system.otherConfig.hint.wechatFollow',
|
|
showAppKey: false,
|
|
showAppSecret: false,
|
|
showRemark: false,
|
|
requireBaseUrl: true,
|
|
},
|
|
},
|
|
{
|
|
code: PLATFORM_SHOP_CONFIG_CODES.common,
|
|
nameKey: 'system.otherConfig.defaults.platformShopName',
|
|
defaults: {
|
|
configCode: PLATFORM_SHOP_CONFIG_CODES.common,
|
|
enabled: true,
|
|
baseUrl: 'http://localhost:5173',
|
|
timeoutSeconds: 30,
|
|
},
|
|
meta: {
|
|
baseUrl: 'system.otherConfig.fields.platformShop.baseUrl',
|
|
appKey: 'system.otherConfig.form.appKey',
|
|
appSecret: 'system.otherConfig.form.appSecret',
|
|
remark: 'system.otherConfig.fields.platformShop.remark',
|
|
hint: 'system.otherConfig.hint.platformShop',
|
|
showAppKey: false,
|
|
showAppSecret: false,
|
|
requireBaseUrl: true,
|
|
},
|
|
},
|
|
{
|
|
code: PLATFORM_SHOP_CONFIG_CODES.tiktok,
|
|
nameKey: 'system.otherConfig.defaults.platformShopTiktokName',
|
|
defaults: {
|
|
configCode: PLATFORM_SHOP_CONFIG_CODES.tiktok,
|
|
enabled: true,
|
|
baseUrl: 'https://auth.tiktok-shops.com',
|
|
remark: 'https://open-api.tiktokglobalshop.com',
|
|
timeoutSeconds: 30,
|
|
},
|
|
meta: {
|
|
baseUrl: 'system.otherConfig.fields.tiktok.baseUrl',
|
|
appKey: 'system.otherConfig.form.appKey',
|
|
appSecret: 'system.otherConfig.form.appSecret',
|
|
remark: 'system.otherConfig.fields.tiktok.remark',
|
|
requireBaseUrl: true,
|
|
requireAppKey: true,
|
|
requireAppSecret: true,
|
|
},
|
|
},
|
|
{
|
|
code: PLATFORM_SHOP_CONFIG_CODES.temu,
|
|
nameKey: 'system.otherConfig.defaults.platformShopTemuName',
|
|
defaults: {
|
|
configCode: PLATFORM_SHOP_CONFIG_CODES.temu,
|
|
enabled: true,
|
|
baseUrl: 'https://openapi-b-us.temu.com/openapi/router',
|
|
timeoutSeconds: 30,
|
|
},
|
|
meta: {
|
|
baseUrl: 'system.otherConfig.fields.temu.baseUrl',
|
|
appKey: 'system.otherConfig.form.appKey',
|
|
appSecret: 'system.otherConfig.form.appSecret',
|
|
remark: 'system.otherConfig.form.remark',
|
|
requireBaseUrl: true,
|
|
requireAppKey: true,
|
|
requireAppSecret: true,
|
|
},
|
|
},
|
|
{
|
|
code: PLATFORM_SHOP_CONFIG_CODES.shopee,
|
|
nameKey: 'system.otherConfig.defaults.platformShopShopeeName',
|
|
defaults: {
|
|
configCode: PLATFORM_SHOP_CONFIG_CODES.shopee,
|
|
enabled: true,
|
|
baseUrl: 'https://partner.shopeemobile.com',
|
|
remark: 'https://openplatform.shopee.cn',
|
|
timeoutSeconds: 30,
|
|
},
|
|
meta: {
|
|
baseUrl: 'system.otherConfig.fields.shopee.baseUrl',
|
|
appKey: 'system.otherConfig.fields.shopee.appKey',
|
|
appSecret: 'system.otherConfig.fields.shopee.appSecret',
|
|
remark: 'system.otherConfig.fields.shopee.remark',
|
|
requireBaseUrl: true,
|
|
requireAppKey: true,
|
|
requireAppSecret: true,
|
|
},
|
|
},
|
|
{
|
|
code: PLATFORM_SHOP_CONFIG_CODES.lazada,
|
|
nameKey: 'system.otherConfig.defaults.platformShopLazadaName',
|
|
defaults: {
|
|
configCode: PLATFORM_SHOP_CONFIG_CODES.lazada,
|
|
enabled: true,
|
|
baseUrl: 'https://auth.lazada.com/oauth/authorize',
|
|
remark: 'https://auth.lazada.com/rest',
|
|
timeoutSeconds: 30,
|
|
},
|
|
meta: {
|
|
baseUrl: 'system.otherConfig.fields.lazada.baseUrl',
|
|
appKey: 'system.otherConfig.form.appKey',
|
|
appSecret: 'system.otherConfig.form.appSecret',
|
|
remark: 'system.otherConfig.fields.lazada.remark',
|
|
requireBaseUrl: true,
|
|
requireAppKey: true,
|
|
requireAppSecret: true,
|
|
},
|
|
},
|
|
]
|
|
|
|
const formState = reactive({
|
|
configCode: TRACK_SERVICE_CONFIG_CODE,
|
|
configName: '',
|
|
enabled: false,
|
|
baseUrl: '',
|
|
appKey: '',
|
|
appSecret: '',
|
|
timeoutSeconds: 30,
|
|
remark: '',
|
|
})
|
|
|
|
const presetOptions = computed(() =>
|
|
PRESET_DEFS.map((p) => ({ label: `${t(p.nameKey)} (${p.code})`, value: p.code })),
|
|
)
|
|
|
|
const activeMeta = computed(() => resolveFieldMeta(formState.configCode))
|
|
|
|
const fieldLabels = computed(() => ({
|
|
baseUrl: t(activeMeta.value.baseUrl),
|
|
appKey: t(activeMeta.value.appKey),
|
|
appSecret: t(activeMeta.value.appSecret),
|
|
remark: t(activeMeta.value.remark),
|
|
}))
|
|
|
|
const fieldPlaceholders = computed(() => ({
|
|
baseUrl: t('system.otherConfig.placeholder.input'),
|
|
appKey: t('system.otherConfig.placeholder.input'),
|
|
appSecret: t('system.otherConfig.placeholder.input'),
|
|
remark: t('system.otherConfig.placeholder.input'),
|
|
}))
|
|
|
|
const showAppKey = computed(() => activeMeta.value.showAppKey !== false)
|
|
const showAppSecret = computed(() => activeMeta.value.showAppSecret !== false)
|
|
const showRemark = computed(() => activeMeta.value.showRemark !== false)
|
|
const fieldHint = computed(() => (activeMeta.value.hint ? t(activeMeta.value.hint) : ''))
|
|
|
|
function resolveFieldMeta(configCode?: string): FieldMeta {
|
|
const code = (configCode || '').trim().toLowerCase()
|
|
return (
|
|
PRESET_DEFS.find((p) => p.code === code)?.meta ?? {
|
|
baseUrl: 'system.otherConfig.form.baseUrl',
|
|
appKey: 'system.otherConfig.form.appKey',
|
|
appSecret: 'system.otherConfig.form.appSecret',
|
|
remark: 'system.otherConfig.form.remark',
|
|
requireBaseUrl: true,
|
|
requireAppKey: true,
|
|
requireAppSecret: true,
|
|
}
|
|
)
|
|
}
|
|
|
|
function cardFieldLabel(configCode: string | undefined, field: keyof Pick<FieldMeta, 'baseUrl' | 'appKey' | 'appSecret' | 'remark'>) {
|
|
return t(resolveFieldMeta(configCode)[field])
|
|
}
|
|
|
|
function cardShowField(configCode: string | undefined, field: 'appKey' | 'appSecret') {
|
|
const meta = resolveFieldMeta(configCode)
|
|
if (field === 'appKey') return meta.showAppKey !== false
|
|
return meta.showAppSecret !== false
|
|
}
|
|
|
|
function platformTag(configCode?: string) {
|
|
const code = (configCode || '').trim().toLowerCase()
|
|
if (code === PLATFORM_SHOP_CONFIG_CODES.common) return 'Shop'
|
|
if (code === PLATFORM_SHOP_CONFIG_CODES.tiktok) return 'TikTok'
|
|
if (code === PLATFORM_SHOP_CONFIG_CODES.temu) return 'Temu'
|
|
if (code === PLATFORM_SHOP_CONFIG_CODES.shopee) return 'Shopee'
|
|
if (code === PLATFORM_SHOP_CONFIG_CODES.lazada) return 'Lazada'
|
|
if (code === WECHAT_MP_CONFIG_CODE) return 'WeChat'
|
|
if (code === WECHAT_MP_FOLLOW_CONFIG_CODE) return 'WeChat'
|
|
if (code === TRACK_SERVICE_CONFIG_CODE) return 'Track'
|
|
if (code === API_CENTER_CONFIG_CODE) return 'API'
|
|
if (code === PICKUP_OPEN_API_CONFIG_CODE) return 'Pickup'
|
|
return ''
|
|
}
|
|
|
|
const formRules = computed(() => {
|
|
const meta = activeMeta.value
|
|
return {
|
|
configCode: [{ required: true, message: t('system.otherConfig.rule.configCodeRequired') }],
|
|
configName: [{ required: true, message: t('system.otherConfig.rule.configNameRequired') }],
|
|
baseUrl: meta.requireBaseUrl
|
|
? [{ required: true, message: t('system.otherConfig.rule.baseUrlRequired') }]
|
|
: [],
|
|
appKey: meta.requireAppKey && showAppKey.value
|
|
? [{ required: true, message: t('system.otherConfig.rule.appKeyRequired') }]
|
|
: [],
|
|
appSecret:
|
|
meta.requireAppSecret && showAppSecret.value && !isEdit.value
|
|
? [{ required: true, message: t('system.otherConfig.rule.appSecretRequired') }]
|
|
: [],
|
|
timeoutSeconds: [{ required: true, message: t('system.otherConfig.rule.timeoutSecondsRequired') }],
|
|
remark: meta.requireRemark
|
|
? [{ required: true, message: t('system.otherConfig.rule.remarkRequired') }]
|
|
: [],
|
|
}
|
|
})
|
|
|
|
function applyPreset(code: string) {
|
|
const preset = PRESET_DEFS.find((p) => p.code === code)
|
|
if (!preset) return
|
|
Object.assign(formState, {
|
|
configCode: preset.defaults.configCode || code,
|
|
configName: t(preset.nameKey),
|
|
enabled: preset.defaults.enabled ?? true,
|
|
baseUrl: preset.defaults.baseUrl || '',
|
|
appKey: preset.defaults.appKey || '',
|
|
appSecret: '',
|
|
timeoutSeconds: preset.defaults.timeoutSeconds ?? 30,
|
|
remark: preset.defaults.remark || '',
|
|
})
|
|
}
|
|
|
|
function handleAdd() {
|
|
isEdit.value = false
|
|
editingId.value = undefined
|
|
selectedPreset.value = TRACK_SERVICE_CONFIG_CODE
|
|
applyPreset(TRACK_SERVICE_CONFIG_CODE)
|
|
modalVisible.value = true
|
|
}
|
|
|
|
async function handleEdit(row: SystemOtherConfigDto) {
|
|
if (!row.id) return
|
|
isEdit.value = true
|
|
editingId.value = row.id
|
|
const detail = await getSystemOtherConfigDetail(row.id)
|
|
selectedPreset.value = detail.configCode || TRACK_SERVICE_CONFIG_CODE
|
|
Object.assign(formState, {
|
|
configCode: detail.configCode || '',
|
|
configName: detail.configName || '',
|
|
enabled: !!detail.enabled,
|
|
baseUrl: detail.baseUrl || '',
|
|
appKey: detail.appKey || '',
|
|
appSecret: detail.appSecret || '',
|
|
timeoutSeconds: detail.timeoutSeconds ?? 30,
|
|
remark: detail.remark || '',
|
|
})
|
|
modalVisible.value = true
|
|
}
|
|
|
|
function handleDeleteConfirm(row: SystemOtherConfigDto) {
|
|
Modal.confirm({
|
|
content: t('system.otherConfig.modal.deleteConfirmContentSingle', { configName: row.configName || '' }),
|
|
onOk: () => handleDelete(row.id),
|
|
})
|
|
}
|
|
|
|
async function handleDelete(id?: number | string) {
|
|
if (!id) return
|
|
await deleteSystemOtherConfig(id)
|
|
Message.success(t('system.otherConfig.message.deleteSuccess'))
|
|
loadData()
|
|
}
|
|
|
|
async function handleModalOk() {
|
|
try {
|
|
await formRef.value.validate()
|
|
modalLoading.value = true
|
|
const payload = {
|
|
configCode: formState.configCode.trim(),
|
|
configName: formState.configName.trim(),
|
|
enabled: formState.enabled,
|
|
baseUrl: formState.baseUrl.trim(),
|
|
appKey: formState.appKey.trim(),
|
|
appSecret: formState.appSecret?.trim() || undefined,
|
|
timeoutSeconds: Number(formState.timeoutSeconds),
|
|
remark: formState.remark?.trim() || undefined,
|
|
}
|
|
if (isEdit.value && editingId.value) {
|
|
await updateSystemOtherConfig({ id: editingId.value, ...payload })
|
|
Message.success(t('system.otherConfig.message.editSuccess'))
|
|
} else {
|
|
await createSystemOtherConfig(payload)
|
|
Message.success(t('system.otherConfig.message.addSuccess'))
|
|
}
|
|
modalVisible.value = false
|
|
loadData()
|
|
} finally {
|
|
modalLoading.value = false
|
|
}
|
|
}
|
|
|
|
async function loadData() {
|
|
const { items } = await getSystemOtherConfigList({ page: 1, pageSize: 100 })
|
|
list.value = items || []
|
|
}
|
|
|
|
watch(
|
|
() => formState.configCode,
|
|
(code) => {
|
|
if (!isEdit.value && code) selectedPreset.value = code
|
|
},
|
|
)
|
|
|
|
onMounted(() => {
|
|
loadData()
|
|
})
|
|
</script>
|
|
|
|
<style lang="less" scoped>
|
|
.other-config-container {
|
|
width: 100%;
|
|
box-sizing: border-box;
|
|
padding: 16px 16px 24px;
|
|
background-color: var(--app-page-bg);
|
|
flex: 1;
|
|
min-height: 0;
|
|
display: flex;
|
|
flex-direction: column;
|
|
overflow-x: hidden;
|
|
overflow-y: hidden;
|
|
}
|
|
|
|
.other-config-page-card {
|
|
background: transparent;
|
|
border-radius: 0;
|
|
padding: 0;
|
|
box-shadow: none;
|
|
box-sizing: border-box;
|
|
flex: 1;
|
|
min-height: 0;
|
|
display: flex;
|
|
flex-direction: column;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.page-header {
|
|
flex-shrink: 0;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
padding: 0 0 4px;
|
|
gap: 12px;
|
|
|
|
.page-title {
|
|
margin: 0;
|
|
font-size: 20px;
|
|
font-weight: 600;
|
|
color: var(--color-text-1);
|
|
}
|
|
}
|
|
|
|
.page-header-actions {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: var(--app-button-gap, 8px);
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.card-grid {
|
|
flex: 1;
|
|
min-height: 0;
|
|
overflow: auto;
|
|
padding: 12px 0 0;
|
|
box-sizing: border-box;
|
|
display: grid;
|
|
grid-template-columns: repeat(4, 1fr);
|
|
gap: 16px;
|
|
align-items: start;
|
|
}
|
|
|
|
@config-card-height: 380px;
|
|
|
|
.config-card-shell {
|
|
min-width: 0;
|
|
min-height: 0;
|
|
height: @config-card-height;
|
|
max-height: @config-card-height;
|
|
overflow: hidden;
|
|
box-sizing: border-box;
|
|
|
|
:deep(.arco-card) {
|
|
min-height: 0;
|
|
height: 100%;
|
|
max-height: 100%;
|
|
display: flex;
|
|
flex-direction: column;
|
|
box-sizing: border-box;
|
|
border: 1px solid var(--app-acrylic-border);
|
|
border-radius: 16px;
|
|
background: var(--app-acrylic-bg);
|
|
box-shadow: none;
|
|
backdrop-filter: var(--app-acrylic-blur);
|
|
-webkit-backdrop-filter: var(--app-acrylic-blur);
|
|
transition:
|
|
border-color 0.2s ease,
|
|
background 0.2s ease;
|
|
}
|
|
|
|
:deep(.arco-card:hover) {
|
|
border-color: var(--app-acrylic-border-strong);
|
|
background: var(--app-acrylic-hover-bg);
|
|
}
|
|
|
|
:deep(.arco-card-header) {
|
|
flex-shrink: 0;
|
|
height: auto;
|
|
padding: 16px 18px 12px;
|
|
border-bottom: 1px solid color-mix(in srgb, var(--app-acrylic-border) 70%, transparent);
|
|
background: transparent;
|
|
}
|
|
|
|
:deep(.arco-card-body) {
|
|
flex: 1;
|
|
display: flex;
|
|
flex-direction: column;
|
|
min-height: 0;
|
|
overflow: hidden;
|
|
padding: 12px 18px 16px;
|
|
background: transparent;
|
|
}
|
|
|
|
.config-card-title {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
min-width: 0;
|
|
}
|
|
|
|
.config-card-icon {
|
|
flex-shrink: 0;
|
|
display: inline-flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
width: 28px;
|
|
height: 28px;
|
|
border-radius: 10px;
|
|
border: 1px solid color-mix(in srgb, var(--app-acrylic-border) 80%, transparent);
|
|
background: rgba(var(--primary-6), 0.1);
|
|
color: rgb(var(--primary-6));
|
|
font-size: 16px;
|
|
}
|
|
|
|
.config-card-title-text {
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.card-extra {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
}
|
|
|
|
.card-header-actions {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 2px;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.action-icon-btn {
|
|
width: 32px;
|
|
height: 32px;
|
|
padding: 0;
|
|
font-size: 16px;
|
|
color: var(--color-text-3);
|
|
|
|
&:hover {
|
|
color: rgb(var(--primary-6));
|
|
}
|
|
}
|
|
|
|
.action-icon-btn--danger:hover {
|
|
color: rgb(var(--danger-6));
|
|
background: rgb(var(--danger-1));
|
|
}
|
|
}
|
|
|
|
.card-body {
|
|
display: flex;
|
|
flex-direction: column;
|
|
height: 100%;
|
|
min-height: 0;
|
|
}
|
|
|
|
.card-body-scroll {
|
|
flex: 1;
|
|
min-height: 0;
|
|
overflow: auto;
|
|
padding-right: 4px;
|
|
}
|
|
|
|
.card-row {
|
|
display: flex;
|
|
gap: 8px;
|
|
margin-bottom: 10px;
|
|
font-size: 13px;
|
|
line-height: 1.5;
|
|
|
|
.label {
|
|
flex-shrink: 0;
|
|
width: 88px;
|
|
color: var(--color-text-3);
|
|
}
|
|
|
|
.value {
|
|
flex: 1;
|
|
min-width: 0;
|
|
color: var(--color-text-1);
|
|
word-break: break-all;
|
|
}
|
|
|
|
.value-break {
|
|
word-break: break-all;
|
|
}
|
|
}
|
|
|
|
@media (max-width: 1600px) {
|
|
.card-grid {
|
|
grid-template-columns: repeat(3, 1fr);
|
|
}
|
|
}
|
|
|
|
@media (max-width: 1200px) {
|
|
.card-grid {
|
|
grid-template-columns: repeat(2, 1fr);
|
|
}
|
|
}
|
|
|
|
@media (max-width: 768px) {
|
|
.card-grid {
|
|
grid-template-columns: 1fr;
|
|
}
|
|
}
|
|
|
|
.modal-form-tip {
|
|
margin-bottom: 16px;
|
|
border-radius: 6px;
|
|
background: color-mix(in srgb, var(--app-primary-color) 8%, #fff);
|
|
border: 1px solid color-mix(in srgb, var(--app-primary-color) 18%, transparent);
|
|
color: var(--color-text-2);
|
|
font-size: 13px;
|
|
line-height: 1.5;
|
|
}
|
|
|
|
.form-section-title {
|
|
margin: 0 0 12px;
|
|
padding: 0 0 8px;
|
|
font-size: 13px;
|
|
font-weight: 600;
|
|
color: var(--color-text-2);
|
|
border-bottom: 1px solid var(--color-border-2);
|
|
|
|
~ .form-section-title {
|
|
margin-top: 8px;
|
|
}
|
|
}
|
|
|
|
.other-config-form {
|
|
:deep(.arco-form-item) {
|
|
margin-bottom: 16px;
|
|
}
|
|
}
|
|
</style>
|