--添加前端自动生成代码 按钮启用、作废、数据日志
This commit is contained in:
@ -99,6 +99,8 @@ export function buildApiCode(model: GeneratorConfig, _tableInfo: TableInfo[]): s
|
||||
const pascalMainTableName = upperFirst(camelCase(camelCaseMainTableName));
|
||||
const hasSetUserIdButton = hasButton(model.listConfig.buttonConfigs, 'batchSetUserId');
|
||||
const hasExportButton = hasButton(model.listConfig.buttonConfigs, 'export');
|
||||
const hasEnableButton = hasButton(model.listConfig.buttonConfigs, 'enable');
|
||||
const hasDataLogButton = hasButton(model.listConfig.buttonConfigs, 'datalog');
|
||||
|
||||
const code = `
|
||||
import { ${pascalMainTableName}PageModel, ${pascalMainTableName}PageParams, ${pascalMainTableName}PageResult } from './model/${pascalClassName}Model';
|
||||
@ -122,6 +124,19 @@ enum Api {
|
||||
Export = '/${model.outputConfig.outputValue}/${lowerFirstPascalClassName}/export',`
|
||||
: ''
|
||||
}
|
||||
${
|
||||
hasEnableButton
|
||||
? `
|
||||
Enable = '/${model.outputConfig.outputValue}/${lowerFirstPascalClassName}/enable',
|
||||
Disable= '/${model.outputConfig.outputValue}/${lowerFirstPascalClassName}/disable',`
|
||||
: ''
|
||||
}
|
||||
${
|
||||
hasDataLogButton
|
||||
? `
|
||||
DataLog = '/${model.outputConfig.outputValue}/${lowerFirstPascalClassName}/datalog',`
|
||||
: ''
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -199,6 +214,62 @@ export async function delete${pascalMainTableName}(ids: string[], mode: ErrorMes
|
||||
);
|
||||
}
|
||||
|
||||
${
|
||||
hasEnableButton
|
||||
? `
|
||||
/**
|
||||
* @description: 启用数据${pascalMainTableName}
|
||||
*/
|
||||
export async function enable${pascalMainTableName}(ids: string[], mode: ErrorMessageMode = 'modal') {
|
||||
return defHttp.post<boolean>(
|
||||
{
|
||||
url: Api.Enable,
|
||||
data: ids,
|
||||
},
|
||||
{
|
||||
errorMessageMode: mode,
|
||||
},
|
||||
);
|
||||
}
|
||||
/**
|
||||
* @description: 作废数据${pascalMainTableName}
|
||||
*/
|
||||
export async function disable${pascalMainTableName}(ids: string[], mode: ErrorMessageMode = 'modal') {
|
||||
return defHttp.post<boolean>(
|
||||
{
|
||||
url: Api.Disable,
|
||||
data: ids,
|
||||
},
|
||||
{
|
||||
errorMessageMode: mode,
|
||||
},
|
||||
);
|
||||
}
|
||||
`
|
||||
: ''
|
||||
}
|
||||
|
||||
${
|
||||
hasDataLogButton?
|
||||
`
|
||||
/**
|
||||
* @description: 获取数据日志${pascalMainTableName}
|
||||
*/
|
||||
export async function getDataLog${pascalMainTableName}(id: string, mode: ErrorMessageMode = 'modal') {
|
||||
return defHttp.post<boolean>(
|
||||
{
|
||||
url: Api.Datalog,
|
||||
data: id,
|
||||
},
|
||||
{
|
||||
errorMessageMode: mode,
|
||||
},
|
||||
);
|
||||
}
|
||||
`
|
||||
:''
|
||||
}
|
||||
|
||||
${
|
||||
hasSetUserIdButton
|
||||
? `
|
||||
@ -469,6 +540,8 @@ export function buildListCode(model: GeneratorConfig): string {
|
||||
const hasCopyDataButton = hasButton(buttonConfigs, 'copyData');
|
||||
const hasTemplatePrint = hasButton(buttonConfigs, PrintButton.CODE);
|
||||
const isSetDataAuth = model.outputConfig.isDataAuth;
|
||||
const hasEnableButton = hasButton(buttonConfigs, 'enable');
|
||||
const hasDataLogButton = hasButton(buttonConfigs, 'datalog');
|
||||
|
||||
//判断是否有用到数据源数据字典的组件
|
||||
const code = `
|
||||
@ -777,7 +850,7 @@ ${hasTemplatePrint ? ' reactive ' : ''}
|
||||
//所有按钮
|
||||
const buttons = ref(${JSON.stringify(model.listConfig.buttonConfigs.filter((x) => x.isUse))});
|
||||
//展示在列表内的按钮
|
||||
const actionButtons = ref<string[]>(['view', 'edit', 'copyData', 'delete', 'startwork','flowRecord']);
|
||||
const actionButtons = ref<string[]>(['view', 'edit','datalog', 'copyData', 'delete', 'startwork','flowRecord']);
|
||||
const buttonConfigs = computed(()=>{
|
||||
return filterButtonAuth(buttons.value);
|
||||
})
|
||||
@ -1108,6 +1181,66 @@ ${hasTemplatePrint ? ' reactive ' : ''}
|
||||
}`
|
||||
: ''
|
||||
}
|
||||
${
|
||||
hasEnableButton?`
|
||||
function handleEnable() {
|
||||
if (!selectedKeys.value.length) {
|
||||
notification.warning({
|
||||
message: 'Tip',
|
||||
description: t('请选择需要启用的数据'),
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
let ids = selectedKeys.value;
|
||||
Modal.confirm({
|
||||
title: '提示信息',
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
content: '是否确认启用?',
|
||||
okText: '确认',
|
||||
cancelText: '取消',
|
||||
onOk() {
|
||||
enable${pascalMainTableName}(ids).then((_) => {
|
||||
handleSuccess();
|
||||
notification.success({
|
||||
message: 'Tip',
|
||||
description: t('启用成功!'),
|
||||
});
|
||||
});
|
||||
},
|
||||
onCancel() {},
|
||||
});
|
||||
|
||||
}
|
||||
function handleDisable() {
|
||||
if (!selectedKeys.value.length) {
|
||||
notification.warning({
|
||||
message: 'Tip',
|
||||
description: t('请选择需要禁用的数据'),
|
||||
});
|
||||
return;
|
||||
}
|
||||
let ids = selectedKeys.value;
|
||||
Modal.confirm({
|
||||
title: '提示信息',
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
content: '是否确认禁用?',
|
||||
okText: '确认',
|
||||
cancelText: '取消',
|
||||
onOk() {
|
||||
disable${pascalMainTableName}(ids).then((_) => {
|
||||
handleSuccess();
|
||||
notification.success({
|
||||
message: 'Tip',
|
||||
description: t('禁用成功!'),
|
||||
});
|
||||
});
|
||||
},
|
||||
onCancel() {},
|
||||
});
|
||||
}
|
||||
`: ''
|
||||
}
|
||||
${
|
||||
hasBatchDeleteButton
|
||||
? `
|
||||
|
||||
Reference in New Issue
Block a user