fix(ui): 自定义工具表单 overflow-y-scroll→auto + 认证方式NONE翻译改为'无' + Captain文档爬虫/同步后端
This commit is contained in:
+35
-1
@@ -30,6 +30,7 @@ const formState = {
|
||||
const initialState = {
|
||||
name: '',
|
||||
url: '',
|
||||
content: '',
|
||||
documentType: 'url',
|
||||
pdfFile: null,
|
||||
};
|
||||
@@ -46,11 +47,18 @@ const validationRules = {
|
||||
pdfFile: {
|
||||
required: requiredIf(() => state.documentType === 'pdf'),
|
||||
},
|
||||
content: {
|
||||
required: requiredIf(() => state.documentType === 'content'),
|
||||
minLength: requiredIf(
|
||||
() => state.documentType === 'content' && minLength(10)
|
||||
),
|
||||
},
|
||||
};
|
||||
|
||||
const documentTypeOptions = [
|
||||
{ value: 'url', label: t('CAPTAIN.DOCUMENTS.FORM.TYPE.URL') },
|
||||
{ value: 'pdf', label: t('CAPTAIN.DOCUMENTS.FORM.TYPE.PDF') },
|
||||
{ value: 'content', label: t('CAPTAIN.DOCUMENTS.FORM.TYPE.CONTENT') },
|
||||
];
|
||||
|
||||
const v$ = useVuelidate(validationRules, state);
|
||||
@@ -58,6 +66,7 @@ const v$ = useVuelidate(validationRules, state);
|
||||
const isLoading = computed(() => formState.uiFlags.value.creatingItem);
|
||||
|
||||
const hasPdfFileError = computed(() => v$.value.pdfFile.$error);
|
||||
const hasContentError = computed(() => v$.value.content.$error);
|
||||
|
||||
const getErrorMessage = (field, errorKey) => {
|
||||
return v$.value[field].$error
|
||||
@@ -68,6 +77,7 @@ const getErrorMessage = (field, errorKey) => {
|
||||
const formErrors = computed(() => ({
|
||||
url: getErrorMessage('url', 'URL'),
|
||||
pdfFile: getErrorMessage('pdfFile', 'PDF_FILE'),
|
||||
content: getErrorMessage('content', 'CONTENT'),
|
||||
}));
|
||||
|
||||
const handleCancel = () => emit('cancel');
|
||||
@@ -107,13 +117,19 @@ const prepareDocumentDetails = () => {
|
||||
if (state.documentType === 'url') {
|
||||
formData.append('document[external_link]', state.url);
|
||||
formData.append('document[name]', state.name || state.url);
|
||||
} else {
|
||||
} else if (state.documentType === 'pdf') {
|
||||
formData.append('document[pdf_file]', state.pdfFile);
|
||||
formData.append(
|
||||
'document[name]',
|
||||
state.name || state.pdfFile.name.replace('.pdf', '')
|
||||
);
|
||||
// No need to send external_link for PDF - it's auto-generated in the backend
|
||||
} else if (state.documentType === 'content') {
|
||||
formData.append('document[content]', state.content);
|
||||
formData.append(
|
||||
'document[name]',
|
||||
state.name || t('CAPTAIN.DOCUMENTS.FORM.CONTENT.DEFAULT_NAME')
|
||||
);
|
||||
}
|
||||
|
||||
return formData;
|
||||
@@ -208,6 +224,24 @@ const handleSubmit = async () => {
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div v-if="state.documentType === 'content'" class="flex flex-col gap-1">
|
||||
<label class="text-sm font-medium text-n-slate-12">
|
||||
{{ t('CAPTAIN.DOCUMENTS.FORM.CONTENT.LABEL') }}
|
||||
</label>
|
||||
<textarea
|
||||
v-model="state.content"
|
||||
rows="8"
|
||||
:placeholder="t('CAPTAIN.DOCUMENTS.FORM.CONTENT.PLACEHOLDER')"
|
||||
class="w-full px-3 py-2 text-sm border rounded-lg resize-y bg-n-alpha-1 border-n-alpha-3 text-n-slate-12 focus:outline-none focus:border-n-blue-8"
|
||||
/>
|
||||
<p class="text-xs text-n-slate-11">
|
||||
{{ t('CAPTAIN.DOCUMENTS.FORM.CONTENT.HELP_TEXT') }}
|
||||
</p>
|
||||
<p v-if="formErrors.content" class="text-xs text-n-ruby-9">
|
||||
{{ formErrors.content }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<Input
|
||||
v-model="state.name"
|
||||
:label="t('CAPTAIN.DOCUMENTS.FORM.NAME.LABEL')"
|
||||
|
||||
Reference in New Issue
Block a user