mirror of
https://github.com/hpd840321/craftlabs-authorization-sdk.git
synced 2026-06-09 10:00:30 +08:00
feat(m4): add SN batch import with text area dialog
This commit is contained in:
@@ -207,6 +207,10 @@ export function patchLicenseSnStatus(id, body) {
|
||||
return axios.patch(`/api/v1/license-sns/${id}/status`, body);
|
||||
}
|
||||
|
||||
export function batchImportLicenseSns(body) {
|
||||
return axios.post('/api/v1/license-sns/batch-import', body);
|
||||
}
|
||||
|
||||
/* —— I5 Callback Inbox & M6 integration read APIs (paths per docs/engineering/iterations/I5_I6_DESIGN.md A.3) —— */
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
/>
|
||||
<el-button type="primary" :loading="loading" @click="load">查询</el-button>
|
||||
<el-button type="success" @click="goNew">新建许可 SN</el-button>
|
||||
<el-button @click="batchDialogVisible = true">批量导入</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -63,6 +64,25 @@
|
||||
@size-change="onSizeChange"
|
||||
/>
|
||||
</div>
|
||||
<el-dialog v-model="batchDialogVisible" title="批量导入 SN" width="520px">
|
||||
<el-form label-width="120px">
|
||||
<el-form-item label="SN 编码">
|
||||
<el-input v-model="batchSnText" type="textarea" :rows="8" placeholder="每行一个 SN 编码" />
|
||||
</el-form-item>
|
||||
<el-form-item label="项目">
|
||||
<el-select v-model="batchProjectId" clearable filterable placeholder="选填" style="width:100%">
|
||||
<el-option v-for="p in projectOptions" :key="p.id" :label="p.name || String(p.id)" :value="p.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="激活备注">
|
||||
<el-input v-model="batchRemark" maxlength="512" placeholder="选填" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="batchDialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="batchImporting" @click="handleBatchImport">导入</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
@@ -71,7 +91,7 @@ import { ref, onMounted } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { useAuthStore } from "../stores/auth";
|
||||
import { listLicenseSns, listProjects } from "../api/platform";
|
||||
import { listLicenseSns, listProjects, batchImportLicenseSns } from "../api/platform";
|
||||
import { apiErrorMessage } from "../utils/apiErrorMessage";
|
||||
|
||||
const auth = useAuthStore();
|
||||
@@ -87,6 +107,11 @@ const filterProjectId = ref(undefined);
|
||||
const projectOptions = ref([]);
|
||||
/** @type {import('vue').Ref<Map<string | number, string>>} */
|
||||
const projectMap = ref(new Map());
|
||||
const batchDialogVisible = ref(false);
|
||||
const batchSnText = ref('');
|
||||
const batchProjectId = ref(undefined);
|
||||
const batchRemark = ref('');
|
||||
const batchImporting = ref(false);
|
||||
|
||||
onMounted(async () => {
|
||||
auth.restoreAxiosAuth();
|
||||
@@ -178,6 +203,27 @@ function goNew() {
|
||||
function goDetail(id) {
|
||||
router.push({ name: "license-sn-detail", params: { id: String(id) } });
|
||||
}
|
||||
|
||||
async function handleBatchImport() {
|
||||
const codes = batchSnText.value.split('\n').map(s => s.trim()).filter(Boolean)
|
||||
if (codes.length === 0) { ElMessage.warning('请输入 SN 编码'); return }
|
||||
batchImporting.value = true
|
||||
try {
|
||||
const { data } = await batchImportLicenseSns({
|
||||
snCodes: codes,
|
||||
projectId: batchProjectId.value || undefined,
|
||||
activationRemark: batchRemark.value || undefined,
|
||||
})
|
||||
ElMessage.success(`导入完成:成功 ${data.success} 条,失败 ${data.failed} 条`)
|
||||
batchDialogVisible.value = false
|
||||
batchSnText.value = ''
|
||||
load()
|
||||
} catch (e) {
|
||||
ElMessage.error(apiErrorMessage(e, '批量导入失败'))
|
||||
} finally {
|
||||
batchImporting.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
Reference in New Issue
Block a user