{`${$t('drop_file_here')} / ${$t('click_to_upload')}`}
>
),
beforeSure: async (_done, {}) => {
const { type, file } = data;
if (!type || !file) {
message('填写必填项', { type: 'warning', duration: 3666 });
return;
}
i18nStore.updateI18nByFile({ type, file: file[0].raw });
done();
await onSearch();
},
});
};
/* 行内容添加 打开添加弹窗 */
export const onAdd = () => {
addDialog({
title: $t('addMultilingual'),
width: '30%',
props: { formInline: { keyName: '', translation: '', typeName: '' } },
draggable: true,
fullscreenIcon: true,
closeOnClickModal: false,
contentRenderer: () => h(I18nDialog, { ref: formRef }),
footerButtons: [
{
label: $t('cancel'),
text: true,
bg: true,
btnClick: ({ dialog: { options, index } }) => {
closeDialog(options, index);
},
},
{
label: $t('buttons.pureConfirm'),
type: 'primary',
text: true,
bg: true,
btnClick: ({ dialog: { options, index } }) => {
const form = options.props.formInline as FormProps;
formRef.value.ruleFormRef.validate(async (valid: any) => {
if (!valid) return;
const result = await i18nStore.addI18n(form);
if (!result) return;
closeDialog(options, index);
await onSearch();
});
},
},
{
label: $t('continue_adding'),
type: 'success',
text: true,
bg: true,
btnClick: ({ dialog: { options } }) => {
const form = options.props.formInline as FormProps;
formRef.value.ruleFormRef.validate(async (valid: any) => {
if (!valid) return;
const result = await i18nStore.addI18n(form);
if (!result) return;
await onSearch();
});
},
},
],
});
};
/* 当表格修改时 */
export const onUpdate = (row: any) => {
const id = row.id;
addDialog({
title: $t('update_multilingual'),
width: '30%',
props: { formInline: { keyName: row.keyName, translation: row.translation, typeName: row.typeName } },
draggable: true,
fullscreenIcon: true,
closeOnClickModal: false,
contentRenderer: () => h(I18nDialog, { ref: formRef }),
beforeSure: (done, { options }) => {
const form = options.props.formInline as FormProps;
formRef.value.ruleFormRef.validate(async (valid: any) => {
if (!valid) return;
const result = await i18nStore.updateI18n({ ...form, id });
if (!result) return;
done();
await onSearch();
});
},
});
};
/* 批量彻底删除行 */
export const onDelete = async (row: any) => {
const isConfirm = await messageBox({
message: $t('confirmDelete'),
title: $t('delete_warning'),
showMessage: false,
confirmMessage: $t('delete_success'),
cancelMessage: $t('confirmDelete'),
});
if (isConfirm) {
await i18nStore.deleteI18n([row.id]);
await onSearch();
}
};
/* 批量删除 */
export const onDeleteBatch = async () => {
const isConfirm = await messageBox({
message: $t('confirmDelete'),
title: $t('delete_warning'),
showMessage: false,
confirmMessage: $t('delete_success'),
cancelMessage: $t('confirmDelete'),
});
if (isConfirm) {
await i18nStore.deleteI18n(deleteIds.value);
await onSearch();
}
};