1. Excel交互组件封装
Some checks failed
CI / Test (ubuntu-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Lint (ubuntu-latest) (push) Has been cancelled
CI / Lint (windows-latest) (push) Has been cancelled
CI / Check (ubuntu-latest) (push) Has been cancelled
CI / Check (windows-latest) (push) Has been cancelled
CI / CI OK (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
Deploy Website on push / Deploy Push Playground Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Docs Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Antd Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Element Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Naive Ftp (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
Lock Threads / action (push) Has been cancelled
Issue Close Require / close-issues (push) Has been cancelled
Close stale issues / stale (push) Has been cancelled
Some checks failed
CI / Test (ubuntu-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Lint (ubuntu-latest) (push) Has been cancelled
CI / Lint (windows-latest) (push) Has been cancelled
CI / Check (ubuntu-latest) (push) Has been cancelled
CI / Check (windows-latest) (push) Has been cancelled
CI / CI OK (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
Deploy Website on push / Deploy Push Playground Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Docs Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Antd Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Element Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Naive Ftp (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
Lock Threads / action (push) Has been cancelled
Issue Close Require / close-issues (push) Has been cancelled
Close stale issues / stale (push) Has been cancelled
This commit is contained in:
81
apps/web-antd/src/api/spreadsheet-formula.ts
Normal file
81
apps/web-antd/src/api/spreadsheet-formula.ts
Normal file
@@ -0,0 +1,81 @@
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
const prefix = 'spreadsheet-formula/';
|
||||
|
||||
export interface SpreadsheetFormulaRefSlot {
|
||||
slot: string;
|
||||
label: string;
|
||||
}
|
||||
|
||||
export interface SpreadsheetFormulaItem {
|
||||
id: number;
|
||||
code: string;
|
||||
name: string;
|
||||
description: string;
|
||||
expression_template: string;
|
||||
ref_slots: SpreadsheetFormulaRefSlot[];
|
||||
sort: number;
|
||||
status: number;
|
||||
created_at: number;
|
||||
updated_at: number;
|
||||
}
|
||||
|
||||
export async function listSpreadsheetFormula() {
|
||||
return requestClient.get<SpreadsheetFormulaItem[]>(`${prefix}list`);
|
||||
}
|
||||
|
||||
export async function createSpreadsheetFormula(data: {
|
||||
code: string;
|
||||
name: string;
|
||||
description?: string;
|
||||
expression_template: string;
|
||||
ref_slots: SpreadsheetFormulaRefSlot[];
|
||||
sort?: number;
|
||||
status?: boolean;
|
||||
}) {
|
||||
return requestClient.post<SpreadsheetFormulaItem>(`${prefix}create`, data);
|
||||
}
|
||||
|
||||
export async function updateSpreadsheetFormula(data: {
|
||||
id: number;
|
||||
code?: string;
|
||||
name?: string;
|
||||
description?: string;
|
||||
expression_template?: string;
|
||||
ref_slots?: SpreadsheetFormulaRefSlot[];
|
||||
sort?: number;
|
||||
status?: boolean;
|
||||
}) {
|
||||
return requestClient.post<SpreadsheetFormulaItem>(`${prefix}update`, data);
|
||||
}
|
||||
|
||||
export async function deleteSpreadsheetFormula(id: number) {
|
||||
return requestClient.post<boolean>(`${prefix}delete`, { id });
|
||||
}
|
||||
|
||||
/** Replace REF0/REF1 with Excel-style column letters + row 1 */
|
||||
export function buildFormulaFromTemplate(
|
||||
template: string,
|
||||
refColumns: number[],
|
||||
): string {
|
||||
let result = template;
|
||||
refColumns.forEach((colIndex, i) => {
|
||||
const letters = colIndexToLetters(colIndex);
|
||||
const re = new RegExp(`REF${i}`, 'g');
|
||||
result = result.replace(re, `${letters}1`);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
function colIndexToLetters(index: number): string {
|
||||
let n = index + 1;
|
||||
let result = '';
|
||||
while (n > 0) {
|
||||
n -= 1;
|
||||
result = String.fromCharCode(65 + (n % 26)) + result;
|
||||
n = Math.floor(n / 26);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export { colIndexToLetters };
|
||||
38
apps/web-antd/src/api/spreadsheet-history.ts
Normal file
38
apps/web-antd/src/api/spreadsheet-history.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
import type { SpreadsheetHistoryEntry } from '#/components/canvas-spreadsheet/types';
|
||||
|
||||
const prefix = 'spreadsheet-history/';
|
||||
|
||||
export async function saveSpreadsheetHistoryBatch(
|
||||
entries: SpreadsheetHistoryEntry[],
|
||||
) {
|
||||
return requestClient.post<{ saved_ids: string[] }>(`${prefix}save-batch`, {
|
||||
entries: entries.map((e) => ({
|
||||
client_entry_id: e.id,
|
||||
table_name: e.tableName,
|
||||
sheet_key: e.sheetKey,
|
||||
row_key: String(e.rowKey),
|
||||
field_id: e.fieldId,
|
||||
action: e.action,
|
||||
before_snapshot: e.beforeSnapshot,
|
||||
after_snapshot: e.afterSnapshot,
|
||||
created_at: e.createdAt,
|
||||
})),
|
||||
});
|
||||
}
|
||||
|
||||
export async function listSpreadsheetHistory(params: {
|
||||
table_name: string;
|
||||
sheet_key?: string;
|
||||
page?: number;
|
||||
pageSize?: number;
|
||||
}) {
|
||||
return requestClient.get<{ items: any[]; total: number }>(`${prefix}list`, {
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
export async function rollbackSpreadsheetHistory(id: number) {
|
||||
return requestClient.post<{ success: boolean }>(`${prefix}rollback`, { id });
|
||||
}
|
||||
55
apps/web-antd/src/api/spreadsheet-table-config.ts
Normal file
55
apps/web-antd/src/api/spreadsheet-table-config.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
import type { SpreadsheetConfigJson } from '#/views/business/warehouse-drug-management/admin/config/spreadsheetDefaults';
|
||||
|
||||
const prefix = 'spreadsheet-table-config/';
|
||||
|
||||
export interface SpreadsheetTableConfigItem {
|
||||
id: number;
|
||||
admin_id: number;
|
||||
table_name: string;
|
||||
sheet_key: string;
|
||||
name: string;
|
||||
is_default: number;
|
||||
config: SpreadsheetConfigJson;
|
||||
created_at: number;
|
||||
updated_at: number;
|
||||
}
|
||||
|
||||
export async function listSpreadsheetTableConfig(params: {
|
||||
table_name: string;
|
||||
sheet_key?: string;
|
||||
}) {
|
||||
return requestClient.get<SpreadsheetTableConfigItem[]>(`${prefix}list`, {
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
export async function getSpreadsheetTableConfigDetail(id: number) {
|
||||
return requestClient.get<SpreadsheetTableConfigItem>(`${prefix}detail`, {
|
||||
params: { id },
|
||||
});
|
||||
}
|
||||
|
||||
export async function createSpreadsheetTableConfig(data: {
|
||||
table_name: string;
|
||||
sheet_key?: string;
|
||||
name: string;
|
||||
is_default?: boolean;
|
||||
config: SpreadsheetConfigJson;
|
||||
}) {
|
||||
return requestClient.post<SpreadsheetTableConfigItem>(`${prefix}create`, data);
|
||||
}
|
||||
|
||||
export async function updateSpreadsheetTableConfig(data: {
|
||||
id: number;
|
||||
name?: string;
|
||||
is_default?: boolean;
|
||||
config?: SpreadsheetConfigJson;
|
||||
}) {
|
||||
return requestClient.post<SpreadsheetTableConfigItem>(`${prefix}update`, data);
|
||||
}
|
||||
|
||||
export async function deleteSpreadsheetTableConfig(id: number) {
|
||||
return requestClient.post<boolean>(`${prefix}delete`, { id });
|
||||
}
|
||||
Reference in New Issue
Block a user