feat(external-api): 接口类型改为下拉「天豹云WMS」,选中自动带出基础地址

- 接口类型从只读文案改成下拉,选项为「天豹云WMS」(值仍为 qimen,服务端照旧固定写入)
- 选中后自动填基础地址 https://qimen.wms.gztbyc.com/openapi,不用手填;
  已手工改过的地址不会被覆盖
- 新增配置时默认就是天豹云WMS + 对应基础地址
- 列表「接口类型」列按类型显示中文;导出同口径(qimen → 天豹云WMS)
- contract / api 注释同步改成「天豹云WMS(类奇门JSON接口)」

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
liufumingren 2026-11-07 08:25:57 +08:00
parent 2b60136443
commit 6b320a94b2
4 changed files with 51 additions and 15 deletions

View File

@ -806,7 +806,7 @@ module.exports = {
principal_id: { type: 'integer', description: '所属主体ID' },
warehouse_id: { type: 'integer', description: '所属仓库ID' },
name: { type: 'string', description: '接口配置名称' },
type: { type: 'string', description: '接口类型,当前系统仅支持 qimen(类奇门JSON接口),由服务端固定写入' },
type: { type: 'string', description: '接口类型:qimen=**天豹云WMS**(类奇门JSON接口),当前仅支持这一种,服务端固定写入' },
base_url: { type: 'string', description: '接口基础地址' },
app_key: { type: 'string', description: '应用Key' },
app_secret: { type: 'string', description: '应用密钥(建议加密存储)' },
@ -860,7 +860,7 @@ module.exports = {
principal_id: { type: 'integer', required: true, description: '所属主体ID,由请求拦截器注入' },
warehouse_id: { type: 'integer', required: true, description: '所属仓库ID' },
name: { type: 'string', required: true, description: '接口配置名称' },
type: { type: 'string', description: '接口类型,可不传;当前系统仅支持 qimen(类奇门JSON接口),服务端固定写入' },
type: { type: 'string', description: '接口类型:qimen=**天豹云WMS**(类奇门JSON接口),可不传;服务端固定写入' },
base_url: { type: 'string', description: '接口基础地址' },
app_key: { type: 'string', description: '应用Key' },
app_secret: { type: 'string', description: '应用密钥' },

View File

@ -629,7 +629,7 @@ const WAREHOUSE_API_COLUMNS = [
{ key: 'warehouse_id', header: '仓库ID' },
{ key: 'warehouse_name', header: '仓库名称', expr: '(SELECT w.name FROM warehouses w WHERE w.id = t.warehouse_id)' },
{ key: 'name', header: '配置名称' },
{ key: 'type', header: '接口类型' },
{ key: 'type', header: '接口类型', format: labels({ qimen: '天豹云WMS' }) },
{ key: 'base_url', header: '接口地址' },
{ key: 'app_key', header: 'app_key' },
{ key: 'status', header: '状态', format: labels(ENABLE_MAP) },

View File

@ -6,7 +6,7 @@ export interface WarehouseApiItem {
principal_id: number
warehouse_id: number
name: string
/** 接口类型:固定 qimen(类奇门JSON接口),当前系统仅支持这一种 */
/** 接口类型:qimen = 天豹云WMS(类奇门JSON接口),当前系统仅支持这一种 */
type: string | null
base_url: string | null
app_key: string | null
@ -25,7 +25,7 @@ export interface WarehouseApiItem {
export interface WarehouseApiPayload {
warehouse_id: number
name: string
/** 接口类型,固定传 qimen(类奇门JSON接口),服务端亦会固定写入 */
/** 接口类型:qimen = 天豹云WMS(类奇门JSON接口),服务端亦会固定写入 */
type?: string | null
base_url?: string | null
app_key?: string | null

View File

@ -61,11 +61,23 @@ function warehouseTypeLabel(type?: string | null) {
}
/**
* 仓库接口的接口类型:当前系统只对接「类奇门JSON接口」这一种
* 取值与后端 API_TYPE_QIMEN 保持一致,由服务端固定写入,前端不接受选择
* 仓库接口的接口类型:系统当前只对接「天豹云WMS」(类奇门JSON接口)
* 下拉选择后自动带出基础地址,不需要手工填写
*/
const API_TYPE_QIMEN = 'qimen'
const API_TYPE_LABEL = '类奇门JSON接口'
const API_TYPE_OPTIONS = [
{ label: '天豹云WMS', value: 'qimen', base_url: 'https://qimen.wms.gztbyc.com/openapi' },
]
const API_TYPE_QIMEN = API_TYPE_OPTIONS[0].value
const API_TYPE_DEFAULT_BASE_URL = API_TYPE_OPTIONS[0].base_url
/**
* 接口类型编码 → 展示名
* @param {string} [type] 接口类型编码
* @return {string} 展示名
*/
function apiTypeLabel(type?: string | null) {
return API_TYPE_OPTIONS.find(item => item.value === type)?.label || API_TYPE_OPTIONS[0].label
}
/* -------------------- 仓库列表 -------------------- */
const query = reactive({
@ -448,6 +460,8 @@ const apiFormRef = ref<FormInstance>()
const apiEditId = ref<number | null>(null)
const apiForm = reactive({
name: '',
/** 接口类型(天豹云WMS = qimen);切换类型自动带出基础地址 */
type: API_TYPE_QIMEN,
base_url: '',
app_key: '',
app_secret: '',
@ -456,6 +470,18 @@ const apiForm = reactive({
status: 1,
remark: '',
})
/**
* 切换接口类型:自动带出该类型的默认基础地址(用户已手工改过的不覆盖)
* @return {void}
*/
function onApiTypeChange() {
const preset = API_TYPE_OPTIONS.find(item => item.value === apiForm.type)
if (!preset) return
const current = String(apiForm.base_url || '').trim()
const isPresetOfOthers = API_TYPE_OPTIONS.some(item => item.base_url === current)
if (!current || isPresetOfOthers) apiForm.base_url = preset.base_url
}
const apiRules: FormRules = {
name: [{ required: true, message: '请输入配置名称', trigger: 'blur' }],
}
@ -499,7 +525,9 @@ function collectConfigFieldValues(): Record<string, unknown> {
async function openApiCreate() {
apiEditId.value = null
apiForm.name = ''
apiForm.base_url = ''
// 默认就用天豹云WMS,基础地址随类型带出,用户不用手填
apiForm.type = API_TYPE_QIMEN
apiForm.base_url = API_TYPE_DEFAULT_BASE_URL
apiForm.app_key = ''
apiForm.app_secret = ''
apiForm.callback_url = ''
@ -517,7 +545,8 @@ async function openApiCreate() {
async function openApiEdit(row: WarehouseApiItem) {
apiEditId.value = row.id
apiForm.name = row.name
apiForm.base_url = row.base_url || ''
apiForm.type = row.type || API_TYPE_QIMEN
apiForm.base_url = row.base_url || API_TYPE_DEFAULT_BASE_URL
apiForm.app_key = row.app_key || ''
apiForm.app_secret = row.app_secret || ''
apiForm.callback_url = row.callback_url || ''
@ -542,7 +571,7 @@ async function submitApiForm() {
const payload = {
warehouse_id: currentWarehouse.value!.id,
name: apiForm.name,
type: API_TYPE_QIMEN,
type: apiForm.type || API_TYPE_QIMEN,
base_url: apiForm.base_url,
app_key: apiForm.app_key,
app_secret: apiForm.app_secret,
@ -1091,7 +1120,7 @@ onMounted(async () => {
<DataTable :loading="configLoading" :data="configList" height="100%">
<el-table-column prop="name" label="配置名称" min-width="140" />
<el-table-column label="接口类型" width="150">
<template #default>{{ API_TYPE_LABEL }}</template>
<template #default="{ row }">{{ apiTypeLabel(row.type) }}</template>
</el-table-column>
<el-table-column prop="base_url" label="基础地址" min-width="220" show-overflow-tooltip />
<el-table-column prop="app_key" label="应用Key" min-width="140" show-overflow-tooltip />
@ -1432,10 +1461,17 @@ onMounted(async () => {
<el-input v-model="apiForm.name" placeholder="如 出库推送接口" />
</el-form-item>
<el-form-item label="接口类型">
<span class="hint">{{ API_TYPE_LABEL }}(当前系统仅支持这一种,由系统固定)</span>
<el-select v-model="apiForm.type" style="width: 100%" @change="onApiTypeChange">
<el-option
v-for="opt in API_TYPE_OPTIONS"
:key="opt.value"
:label="opt.label"
:value="opt.value"
/>
</el-select>
</el-form-item>
<el-form-item label="基础地址" prop="base_url">
<el-input v-model="apiForm.base_url" placeholder="如 https://wms.example.com" />
<el-input v-model="apiForm.base_url" placeholder="选择接口类型后自动带出,可修改" />
</el-form-item>
<el-form-item label="应用Key" prop="app_key">
<el-input v-model="apiForm.app_key" placeholder="选填" />