Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: excel安装--story=119830502 excel模版优化(closed #2499) #2500

Open
wants to merge 1 commit into
base: v2.4.8-dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions frontend/src/views/agent/components/parser-excel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ export default class ParserExcel extends Vue {
const workbook = XLSX.read(data, { type: 'binary' });
const sheets = Object.keys(workbook.Sheets);
const sheetData: any[] = XLSX.utils.sheet_to_json(workbook.Sheets[sheets[0]]);
sheetData.splice(0,2);
let sheetHead = XLSX.utils.sheet_to_csv(workbook.Sheets[sheets[0]]).split('\n');
sheetHead = sheetHead[0].split(',');

Expand Down Expand Up @@ -220,7 +221,7 @@ export default class ParserExcel extends Vue {
// .filter(item => !item.colOptional)
.map(item => item.prop);
const configHeaders = tableConfig.filter(item => !requiredColProps.includes(item.prop)).map(item => item.label);


const firstMissLabel = configHeaders.find(label => !sheetsHeaders.includes(this.$tc(label)));
if (firstMissLabel) { // 第一个未缺失的表头
Expand Down Expand Up @@ -253,16 +254,16 @@ export default class ParserExcel extends Vue {
tableConfig.forEach((header) => {
const key = this.$tc(header.label);
if (key === this.$tc('业务')) {
const data = MainStore.bkBizList.find(data => data.bk_biz_name === item[`${key}${this.$tc('可选')}`]);
const data = MainStore.bkBizList.find(data => data.bk_biz_name === item[`${key}`]);
info[header.prop] = data && !isEmpty(data.bk_biz_id) ? data.bk_biz_id : '';
} else if (key === this.$tc('管控区域')) {
const data = AgentStore.cloudList.find(data => data.bk_cloud_name === item[`${key}${this.$tc('可选')}`]);
const data = AgentStore.cloudList.find(data => data.bk_cloud_name === item[`${key}`]);
info[header.prop] = data && !isEmpty(data.bk_cloud_id) ? data.bk_cloud_id : '';
} else if (key === this.$tc('接入点')) {
const data = AgentStore.apList.find(data => data.name === item[`${key}${this.$tc('可选')}`]);
const data = AgentStore.apList.find(data => data.name === item[`${key}`]);
info[header.prop] = data && !isEmpty(data.id) ? data.id : -1;
} else if (key === this.$tc('寻址方式')) {
info[header.prop] = item[`${key}${this.$tc('可选')}`] === this.$tc('动态') ? 'dynamic' : 'static';
info[header.prop] = item[`${key}`] === this.$tc('动态') ? 'dynamic' : 'static';
} else if (key === this.$tc('认证方式')) { // 密钥 || 铁将军 需覆盖填写值
let val = '';
if (!isEmpty(item[key])) {
Expand Down Expand Up @@ -348,7 +349,8 @@ export default class ParserExcel extends Vue {
* 下载模板文件
*/
public handleDownload() {
const { url } = createExcel('bk_nodeman_info', headConfig);
// const { url } = createExcel('bk_nodeman_info', headConfig);
const url = `${window.location.origin}${window.PROJECT_CONFIG.SITE_URL}${AJAX_URL_PREFIX}api/excel/download`;
download('bk_nodeman_info.xlsx', url);
}
}
Expand Down
Loading