From 6b320a94b26c790599fc935b22c803002c3cb4d0 Mon Sep 17 00:00:00 2001 From: liufumingren Date: Sat, 7 Nov 2026 08:25:57 +0800 Subject: [PATCH] =?UTF-8?q?feat(external-api):=20=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E6=94=B9=E4=B8=BA=E4=B8=8B=E6=8B=89=E3=80=8C?= =?UTF-8?q?=E5=A4=A9=E8=B1=B9=E4=BA=91WMS=E3=80=8D=EF=BC=8C=E9=80=89?= =?UTF-8?q?=E4=B8=AD=E8=87=AA=E5=8A=A8=E5=B8=A6=E5=87=BA=E5=9F=BA=E7=A1=80?= =?UTF-8?q?=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 接口类型从只读文案改成下拉,选项为「天豹云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> --- backend/app/contract/index.js | 4 +- backend/app/utils/exportDefs.js | 2 +- frontend/src/api/warehouseApi.ts | 4 +- frontend/src/views/ExternalApi/Index.vue | 56 +++++++++++++++++++----- 4 files changed, 51 insertions(+), 15 deletions(-) diff --git a/backend/app/contract/index.js b/backend/app/contract/index.js index 74acd27..b244889 100644 --- a/backend/app/contract/index.js +++ b/backend/app/contract/index.js @@ -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: '应用密钥' }, diff --git a/backend/app/utils/exportDefs.js b/backend/app/utils/exportDefs.js index 7af22af..9aba442 100644 --- a/backend/app/utils/exportDefs.js +++ b/backend/app/utils/exportDefs.js @@ -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) }, diff --git a/frontend/src/api/warehouseApi.ts b/frontend/src/api/warehouseApi.ts index aeec691..4c37be5 100644 --- a/frontend/src/api/warehouseApi.ts +++ b/frontend/src/api/warehouseApi.ts @@ -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 diff --git a/frontend/src/views/ExternalApi/Index.vue b/frontend/src/views/ExternalApi/Index.vue index be7d520..dbd175e 100644 --- a/frontend/src/views/ExternalApi/Index.vue +++ b/frontend/src/views/ExternalApi/Index.vue @@ -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() const apiEditId = ref(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 { 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 () => { - + @@ -1432,10 +1461,17 @@ onMounted(async () => { - {{ API_TYPE_LABEL }}(当前系统仅支持这一种,由系统固定) + + + - +