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 }}(当前系统仅支持这一种,由系统固定) + + + - +