mirror of
https://github.com/hpd840321/craftlabs-authorization-sdk.git
synced 2026-06-09 10:00:30 +08:00
feat(m6): add BitAnswer ID mapping CRUD
This commit is contained in:
@@ -387,3 +387,17 @@ export function initiateContractChange(id, body) {
|
||||
export function completeContractChange(id) {
|
||||
return axios.post(`/api/v1/contracts/${id}/changes/complete`);
|
||||
}
|
||||
|
||||
// —— I12 M6 比特 ID 映射 ——————————————————————
|
||||
export function listIdMappings(params) {
|
||||
return axios.get('/api/v1/integration/id-mappings', { params });
|
||||
}
|
||||
export function createIdMapping(body) {
|
||||
return axios.post('/api/v1/integration/id-mappings', body);
|
||||
}
|
||||
export function updateIdMapping(id, body) {
|
||||
return axios.put(`/api/v1/integration/id-mappings/${id}`, body);
|
||||
}
|
||||
export function deleteIdMapping(id) {
|
||||
return axios.delete(`/api/v1/integration/id-mappings/${id}`);
|
||||
}
|
||||
|
||||
@@ -80,6 +80,12 @@ const routes = [
|
||||
component: () => import("../views/IntegrationProductLinesView.vue"),
|
||||
meta: { roles: ["SYS_ADMIN", "DEVELOPER", "OPS"], title: "产品线" },
|
||||
},
|
||||
{
|
||||
path: "integration/id-mappings",
|
||||
name: "integration-id-mappings",
|
||||
component: () => import("../views/IntegrationIdMappingView.vue"),
|
||||
meta: { roles: ["SYS_ADMIN", "DEVELOPER"], title: "ID 映射" },
|
||||
},
|
||||
{
|
||||
path: "callbacks/:id",
|
||||
name: "callback-inbox-detail",
|
||||
|
||||
@@ -0,0 +1,249 @@
|
||||
<template>
|
||||
<el-card shadow="never">
|
||||
<template #header>
|
||||
<div class="toolbar">
|
||||
<span class="title">ID 映射</span>
|
||||
<div class="actions">
|
||||
<el-select v-model="filterProductLineId" placeholder="产品线" clearable style="width:160px" @change="load">
|
||||
<el-option v-for="pl in productLines" :key="pl.id" :label="pl.name" :value="pl.id" />
|
||||
</el-select>
|
||||
<el-select v-model="filterEnvironmentId" placeholder="环境" clearable style="width:160px" @change="load">
|
||||
<el-option v-for="e in environments" :key="e.id" :label="e.name" :value="e.id" />
|
||||
</el-select>
|
||||
<el-button type="primary" :loading="loading" @click="load">查询</el-button>
|
||||
<el-button type="success" @click="openCreate">新建</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<el-table v-loading="loading" :data="rows" stripe style="width: 100%">
|
||||
<el-table-column prop="bitanswerProductId" label="比特产品 ID" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="bitanswerTemplateId" label="比特模板 ID" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="bitanswerBusinessId" label="比特业务 ID" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="featureKey" label="特性键" width="120" show-overflow-tooltip />
|
||||
<el-table-column prop="bitanswerFeatureId" label="比特特性 ID" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column label="产品线 ID" width="120">
|
||||
<template #default="{ row }">{{ row.productLineId ?? "—" }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="环境 ID" width="120">
|
||||
<template #default="{ row }">{{ row.environmentId ?? "—" }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="160" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button type="primary" link @click="openEdit(row)">编辑</el-button>
|
||||
<el-button type="danger" link @click="onDelete(row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<el-dialog v-model="dialogVisible" :title="dialogTitle" width="560px" destroy-on-close @closed="resetForm">
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="150px">
|
||||
<el-form-item label="产品线" prop="productLineId">
|
||||
<el-select v-model="form.productLineId" placeholder="请选择" style="width:100%">
|
||||
<el-option v-for="pl in productLines" :key="pl.id" :label="pl.name" :value="pl.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="环境" prop="environmentId">
|
||||
<el-select v-model="form.environmentId" placeholder="选填" clearable style="width:100%">
|
||||
<el-option v-for="e in environments" :key="e.id" :label="e.name" :value="e.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="比特产品 ID" prop="bitanswerProductId">
|
||||
<el-input v-model="form.bitanswerProductId" maxlength="128" placeholder="选填" />
|
||||
</el-form-item>
|
||||
<el-form-item label="比特模板 ID" prop="bitanswerTemplateId">
|
||||
<el-input v-model="form.bitanswerTemplateId" maxlength="128" placeholder="选填" />
|
||||
</el-form-item>
|
||||
<el-form-item label="比特业务 ID" prop="bitanswerBusinessId">
|
||||
<el-input v-model="form.bitanswerBusinessId" maxlength="128" placeholder="选填" />
|
||||
</el-form-item>
|
||||
<el-form-item label="特性键" prop="featureKey">
|
||||
<el-input v-model="form.featureKey" maxlength="64" placeholder="选填" />
|
||||
</el-form-item>
|
||||
<el-form-item label="比特特性 ID" prop="bitanswerFeatureId">
|
||||
<el-input v-model="form.bitanswerFeatureId" maxlength="128" placeholder="选填" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="dialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="saving" @click="submit">保存</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, computed, onMounted } from "vue";
|
||||
import { ElMessage, ElMessageBox } from "element-plus";
|
||||
import { useAuthStore } from "../stores/auth";
|
||||
import { listIdMappings, createIdMapping, updateIdMapping, deleteIdMapping, listProductLines, listIntegrationEnvironments } from "../api/platform";
|
||||
import { apiErrorMessage } from "../utils/apiErrorMessage";
|
||||
|
||||
const auth = useAuthStore();
|
||||
|
||||
const loading = ref(false);
|
||||
const saving = ref(false);
|
||||
const rows = ref([]);
|
||||
const productLines = ref([]);
|
||||
const environments = ref([]);
|
||||
const filterProductLineId = ref(null);
|
||||
const filterEnvironmentId = ref(null);
|
||||
|
||||
const dialogVisible = ref(false);
|
||||
const editingId = ref(null);
|
||||
const formRef = ref(null);
|
||||
const form = reactive({
|
||||
productLineId: null,
|
||||
environmentId: null,
|
||||
bitanswerProductId: "",
|
||||
bitanswerTemplateId: "",
|
||||
bitanswerBusinessId: "",
|
||||
featureKey: "",
|
||||
bitanswerFeatureId: "",
|
||||
});
|
||||
|
||||
const rules = {
|
||||
productLineId: [{ required: true, message: "请选择产品线", trigger: "change" }],
|
||||
};
|
||||
|
||||
const dialogTitle = computed(() => (editingId.value ? "编辑映射" : "新建映射"));
|
||||
|
||||
onMounted(async () => {
|
||||
auth.restoreAxiosAuth();
|
||||
await Promise.all([loadProductLines(), loadEnvironments(), load()]);
|
||||
});
|
||||
|
||||
async function loadProductLines() {
|
||||
try {
|
||||
const { data } = await listProductLines();
|
||||
const body = data && typeof data === "object" ? data : {};
|
||||
productLines.value = Array.isArray(body.content) ? body.content : [];
|
||||
} catch { productLines.value = []; }
|
||||
}
|
||||
|
||||
async function loadEnvironments() {
|
||||
try {
|
||||
const { data } = await listIntegrationEnvironments();
|
||||
const body = data && typeof data === "object" ? data : {};
|
||||
environments.value = Array.isArray(body.content) ? body.content : [];
|
||||
} catch { environments.value = []; }
|
||||
}
|
||||
|
||||
async function load() {
|
||||
loading.value = true;
|
||||
try {
|
||||
const { data } = await listIdMappings({
|
||||
productLineId: filterProductLineId.value || undefined,
|
||||
environmentId: filterEnvironmentId.value || undefined,
|
||||
});
|
||||
rows.value = Array.isArray(data) ? data : [];
|
||||
} catch (e) {
|
||||
ElMessage.error(apiErrorMessage(e, "加载 ID 映射失败"));
|
||||
rows.value = [];
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function openCreate() {
|
||||
editingId.value = null;
|
||||
resetForm();
|
||||
dialogVisible.value = true;
|
||||
}
|
||||
|
||||
function openEdit(row) {
|
||||
editingId.value = row.id;
|
||||
form.productLineId = row.productLineId ?? null;
|
||||
form.environmentId = row.environmentId ?? null;
|
||||
form.bitanswerProductId = row.bitanswerProductId ?? "";
|
||||
form.bitanswerTemplateId = row.bitanswerTemplateId ?? "";
|
||||
form.bitanswerBusinessId = row.bitanswerBusinessId ?? "";
|
||||
form.featureKey = row.featureKey ?? "";
|
||||
form.bitanswerFeatureId = row.bitanswerFeatureId ?? "";
|
||||
dialogVisible.value = true;
|
||||
}
|
||||
|
||||
function resetForm() {
|
||||
form.productLineId = null;
|
||||
form.environmentId = null;
|
||||
form.bitanswerProductId = "";
|
||||
form.bitanswerTemplateId = "";
|
||||
form.bitanswerBusinessId = "";
|
||||
form.featureKey = "";
|
||||
form.bitanswerFeatureId = "";
|
||||
formRef.value?.resetFields?.();
|
||||
}
|
||||
|
||||
async function submit() {
|
||||
const f = formRef.value;
|
||||
if (!f) return;
|
||||
try {
|
||||
await f.validate();
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
saving.value = true;
|
||||
const payload = {
|
||||
productLineId: form.productLineId,
|
||||
environmentId: form.environmentId || undefined,
|
||||
bitanswerProductId: form.bitanswerProductId?.trim() || undefined,
|
||||
bitanswerTemplateId: form.bitanswerTemplateId?.trim() || undefined,
|
||||
bitanswerBusinessId: form.bitanswerBusinessId?.trim() || undefined,
|
||||
featureKey: form.featureKey?.trim() || undefined,
|
||||
bitanswerFeatureId: form.bitanswerFeatureId?.trim() || undefined,
|
||||
};
|
||||
try {
|
||||
if (editingId.value != null) {
|
||||
await updateIdMapping(editingId.value, payload);
|
||||
ElMessage.success("已保存");
|
||||
} else {
|
||||
await createIdMapping(payload);
|
||||
ElMessage.success("已创建");
|
||||
}
|
||||
dialogVisible.value = false;
|
||||
await load();
|
||||
} catch (e) {
|
||||
ElMessage.error(apiErrorMessage(e, "保存失败"));
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function onDelete(row) {
|
||||
ElMessageBox.confirm(`确定删除 ID 映射(ID: ${row.id})吗?`, "提示", {
|
||||
type: "warning",
|
||||
confirmButtonText: "删除",
|
||||
cancelButtonText: "取消",
|
||||
})
|
||||
.then(async () => {
|
||||
try {
|
||||
await deleteIdMapping(row.id);
|
||||
ElMessage.success("已删除");
|
||||
await load();
|
||||
} catch (e) {
|
||||
ElMessage.error(apiErrorMessage(e, "删除失败"));
|
||||
}
|
||||
})
|
||||
.catch(() => {});
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.toolbar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
}
|
||||
.title {
|
||||
font-weight: 600;
|
||||
font-size: 16px;
|
||||
}
|
||||
.actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user