| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589 |
- <template>
- <div class="document p-16-24">
- <h2 class="mb-16">{{ $t('common.fileUpload.document') }}</h2>
- <el-card style="--el-card-padding: 0">
- <div class="main-calc-height">
- <div class="p-24">
- <div class="flex-between">
- <div>
- <template v-if="!isShared">
- <el-button
- v-if="knowledgeDetail?.type === 0 && permissionPrecise.doc_create(id)"
- type="primary"
- @click="
- router.push({
- path: `/knowledge/document/upload/${folderId}/${type}`,
- query: { id: id },
- })
- "
- >{{ $t('views.document.uploadDocument') }}
- </el-button>
- <el-button
- v-if="knowledgeDetail?.type === 1 && permissionPrecise.doc_create(id)"
- type="primary"
- @click="importDoc"
- >{{ $t('views.document.importDocument') }}
- </el-button>
- <el-button
- v-if="knowledgeDetail?.type === 2 && permissionPrecise.doc_create(id)"
- type="primary"
- @click="
- router.push({
- path: `/knowledge/import/lark/${folderId}`,
- query: {
- id: id,
- folder_token: knowledgeDetail?.meta.folder_token,
- },
- })
- "
- >{{ $t('views.document.importDocument') }}
- </el-button>
- <el-button
- v-if="knowledgeDetail?.type === 4 && permissionPrecise.doc_create(id)"
- type="primary"
- @click="toImportWorkflow"
- >{{ $t('views.document.importDocument') }}
- </el-button>
- <el-button
- v-if="knowledgeDetail?.type === 5 && permissionPrecise.doc_create(id)"
- type="primary"
- @click="
- router.push({
- path: `/knowledge/document/upload/${folderId}/${type}`,
- query: { id: id },
- })
- "
- >{{ $t('views.document.uploadDocument') }}
- </el-button>
- <el-button
- v-if="knowledgeDetail?.type === 5"
- @click="openSyncToSampleCenter"
- :disabled="multipleSelection.length === 0"
- >推送到样本中心
- </el-button>
- <el-button
- @click="batchRefresh"
- :disabled="multipleSelection.length === 0"
- v-if="permissionPrecise.doc_vector(id)"
- >{{ $t('views.knowledge.setting.vectorization') }}
- </el-button>
- <el-button
- @click="openGenerateDialog()"
- :disabled="multipleSelection.length === 0"
- v-if="permissionPrecise.doc_generate(id)"
- >{{ $t('views.document.generateQuestion.title') }}
- </el-button>
- <el-button
- @click="openBatchEditDocument"
- :disabled="multipleSelection.length === 0"
- v-if="permissionPrecise.doc_edit(id)"
- >
- {{ $t('common.setting') }}
- </el-button>
- <el-dropdown v-if="MoreFilledPermission0(id)">
- <el-button class="ml-12 mr-12">
- <AppIcon iconName="app-more"></AppIcon>
- </el-button>
- <template #dropdown>
- <el-dropdown-menu>
- <el-dropdown-item
- @click="openknowledgeDialog()"
- :disabled="multipleSelection.length === 0"
- v-if="permissionPrecise.doc_migrate(id)"
- >
- {{ $t('views.document.setting.migration') }}
- </el-dropdown-item>
- <el-dropdown-item
- @click="openAddTagDialog()"
- :disabled="multipleSelection.length === 0"
- v-if="permissionPrecise.doc_tag(id)"
- >{{ $t('views.document.tag.addTag') }}
- </el-dropdown-item>
- <el-dropdown-item
- divided
- @click="syncMulDocument"
- :disabled="multipleSelection.length === 0"
- v-if="knowledgeDetail?.type === 1 && permissionPrecise.doc_sync(id)"
- >{{ $t('views.document.syncDocument') }}
- </el-dropdown-item>
- <el-dropdown-item
- divided
- @click="syncLarkMulDocument"
- :disabled="multipleSelection.length === 0"
- v-if="knowledgeDetail?.type === 2 && permissionPrecise.doc_sync(id)"
- >{{ $t('views.document.syncDocument') }}
- </el-dropdown-item>
- <el-dropdown-item
- @click="exportMulDocument"
- :disabled="multipleSelection.length === 0"
- v-if="permissionPrecise.doc_export(id)"
- >
- {{ $t('views.document.setting.export') }} Excel
- </el-dropdown-item>
- <el-dropdown-item
- @click="exportMulDocumentZip"
- :disabled="multipleSelection.length === 0"
- v-if="permissionPrecise.doc_export(id)"
- >
- {{ $t('views.document.setting.export') }} Zip
- </el-dropdown-item>
- <el-dropdown-item
- divided
- @click="deleteMulDocument"
- :disabled="multipleSelection.length === 0"
- v-if="permissionPrecise.doc_delete(id)"
- >{{ $t('common.delete') }}
- </el-dropdown-item>
- </el-dropdown-menu>
- </template>
- </el-dropdown>
- </template>
- </div>
- <div class="flex">
- <div class="flex-between complex-search">
- <el-select
- class="complex-search__left"
- v-model="search_type"
- style="width: 120px"
- @change="search_type_change"
- >
- <el-option :label="$t('common.name')" value="name" />
- </el-select>
- <el-input
- v-if="search_type === 'name'"
- v-model="search_form.name"
- @change="refresh"
- :placeholder="$t('common.searchBar.placeholder')"
- style="width: 220px"
- clearable
- />
- </div>
- <el-tooltip
- effect="dark"
- :content="$t('common.ExecutionRecord.title')"
- placement="top"
- v-if="knowledgeDetail?.type === 4 && permissionPrecise.doc_create(id)"
- >
- <el-button @click="openListAction" class="ml-12">
- <AppIcon iconName="app-execution-record" class="color-secondary"></AppIcon>
- </el-button>
- </el-tooltip>
- <el-button @click="openTagDrawer" class="ml-12" v-if="permissionPrecise.tag_read(id)">
- {{ $t('views.document.tag.label') }}
- </el-button>
- </div>
- </div>
- <app-table
- ref="multipleTableRef"
- class="mt-16 document-table"
- :data="documentData"
- :pagination-config="paginationConfig"
- :quick-create="
- knowledgeDetail?.type === 0 && permissionPrecise.doc_create(id) && !isShared
- "
- @sizeChange="handleSizeChange"
- @changePage="getList"
- @cell-mouse-enter="cellMouseEnter"
- @cell-mouse-leave="cellMouseLeave"
- @creatQuick="creatQuickHandle"
- @row-click="rowClickHandle"
- @selection-change="handleSelectionChange"
- @sort-change="handleSortChange"
- v-loading="loading"
- :row-key="(row: any) => row.id"
- :storeKey="storeKey"
- @cell-click="cellClickHandle"
- >
- <el-table-column
- type="selection"
- width="55"
- :reserve-selection="true"
- v-if="!isShared"
- />
- <el-table-column prop="name" :label="$t('views.document.table.name')" min-width="280">
- <template #default="{ row }">
- <ReadWrite
- v-if="!isShared"
- @change="editName($event, row.id)"
- :data="row.name"
- :showEditIcon="row.id === currentMouseId"
- />
- <span v-else>{{ row.name }}</span>
- </template>
- </el-table-column>
- <el-table-column
- prop="status"
- :label="$t('views.document.fileStatus.label')"
- width="120"
- >
- <template #header>
- <div>
- <span>{{ $t('views.document.fileStatus.label') }}</span>
- <el-dropdown trigger="click" @command="dropdownHandle">
- <el-button
- style="margin-top: 1px"
- link
- :type="filterMethod['status'] ? 'primary' : ''"
- >
- <el-icon>
- <Filter />
- </el-icon>
- </el-button>
- <template #dropdown>
- <el-dropdown-menu style="width: 100px">
- <el-dropdown-item
- :class="filterMethod['status'] ? '' : 'is-active'"
- :command="beforeCommand('status', '')"
- class="justify-center"
- >{{ $t('common.status.all') }}
- </el-dropdown-item>
- <el-dropdown-item
- :class="filterMethod['status'] === State.SUCCESS ? 'is-active' : ''"
- class="justify-center"
- :command="beforeCommand('status', State.SUCCESS)"
- >{{ $t('common.status.success') }}
- </el-dropdown-item>
- <el-dropdown-item
- :class="filterMethod['status'] === State.FAILURE ? 'is-active' : ''"
- class="justify-center"
- :command="beforeCommand('status', State.FAILURE)"
- >{{ $t('common.status.fail') }}
- </el-dropdown-item>
- <el-dropdown-item
- :class="
- filterMethod['status'] === State.STARTED &&
- filterMethod['task_type'] == TaskType.EMBEDDING
- ? 'is-active'
- : ''
- "
- class="justify-center"
- :command="beforeCommand('status', State.STARTED, TaskType.EMBEDDING)"
- >{{ $t('views.document.fileStatus.EMBEDDING') }}
- </el-dropdown-item>
- <el-dropdown-item
- :class="filterMethod['status'] === State.PENDING ? 'is-active' : ''"
- class="justify-center"
- :command="beforeCommand('status', State.PENDING)"
- >{{ $t('views.document.fileStatus.PENDING') }}
- </el-dropdown-item>
- <el-dropdown-item
- :class="
- filterMethod['status'] === State.STARTED &&
- filterMethod['task_type'] === TaskType.GENERATE_PROBLEM
- ? 'is-active'
- : ''
- "
- class="justify-center"
- :command="
- beforeCommand('status', State.STARTED, TaskType.GENERATE_PROBLEM)
- "
- >{{ $t('views.document.fileStatus.GENERATE') }}
- </el-dropdown-item>
- </el-dropdown-menu>
- </template>
- </el-dropdown>
- </div>
- </template>
- <template #default="{ row }">
- <StatusValue :status="row.status" :status-meta="row.status_meta"></StatusValue>
- </template>
- </el-table-column>
- <el-table-column
- prop="char_length"
- :label="$t('views.document.table.char_length')"
- align="right"
- min-width="120"
- sortable
- >
- <template #default="{ row }">
- {{ numberFormat(row.char_length) }}
- </template>
- </el-table-column>
- <el-table-column
- prop="paragraph_count"
- :label="$t('views.document.table.paragraph')"
- align="right"
- min-width="120"
- sortable
- />
- <el-table-column width="110">
- <template #header>
- <div>
- <span>{{ $t('views.document.enableStatus.label') }}</span>
- <el-dropdown trigger="click" @command="dropdownHandle">
- <el-button
- style="margin-top: 1px"
- link
- :type="filterMethod['is_active'] ? 'primary' : ''"
- >
- <el-icon>
- <Filter />
- </el-icon>
- </el-button>
- <template #dropdown>
- <el-dropdown-menu style="width: 100px">
- <el-dropdown-item
- :class="filterMethod['is_active'] === '' ? 'is-active' : ''"
- :command="beforeCommand('is_active', '')"
- class="justify-center"
- >{{ $t('common.status.all') }}
- </el-dropdown-item>
- <el-dropdown-item
- :class="filterMethod['is_active'] === true ? 'is-active' : ''"
- class="justify-center"
- :command="beforeCommand('is_active', true)"
- >{{ $t('common.status.enabled') }}
- </el-dropdown-item>
- <el-dropdown-item
- :class="filterMethod['is_active'] === false ? 'is-active' : ''"
- class="justify-center"
- :command="beforeCommand('is_active', false)"
- >{{ $t('common.status.disabled') }}
- </el-dropdown-item>
- </el-dropdown-menu>
- </template>
- </el-dropdown>
- </div>
- </template>
- <template #default="{ row }">
- <div v-if="row.is_active" class="flex align-center">
- <el-icon class="color-success mr-8" style="font-size: 16px">
- <SuccessFilled />
- </el-icon>
- <span class="color-text-primary">
- {{ $t('common.status.enabled') }}
- </span>
- </div>
- <div v-else class="flex align-center">
- <AppIcon iconName="app-disabled" class="color-secondary mr-8"></AppIcon>
- <span class="color-text-primary">
- {{ $t('common.status.disabled') }}
- </span>
- </div>
- </template>
- </el-table-column>
- <el-table-column width="150" prop="tag">
- <template #header>
- <div>
- <span>{{ $t('dynamicsForm.tag.label') }}</span>
- <el-dropdown trigger="click" @visible-change="handleTagVisibleChange">
- <el-button
- style="margin-top: 1px"
- link
- :type="filterMethod['tags']?.length > 0 ? 'primary' : ''"
- >
- <el-icon>
- <Filter />
- </el-icon>
- </el-button>
- <template #dropdown>
- <div>
- <el-cascader-panel
- v-model="tagFilterValue"
- :options="tagFilterOptions"
- :props="{
- multiple: true,
- checkStrictly: true,
- emitPath: false,
- showPrefix: false,
- }"
- @change="(val: any) => dropdownHandle({ attr: 'tags', command: val })"
- />
- </div>
- </template>
- </el-dropdown>
- </div>
- </template>
- <template #default="{ row }">
- <el-popover
- trigger="hover"
- placement="bottom-start"
- :disabled="!row.tag_count"
- :popper-style="{ width: 'auto', maxWidth: '300px' }"
- >
- <div
- v-for="tag in row.tags"
- :key="tag.id"
- class="flex align-center lighter color-text-primary mt-4 mb-4"
- >
- <span class="color-secondary ellipsis-1" style="width: 40%" :title="tag.key">{{
- tag.key
- }}</span>
- <span class="ml-4 ellipsis-1" :title="tag.value"> {{ tag.value }}</span>
- </div>
- <template #reference>
- <el-tag v-if="row.tag_count" type="info" effect="plain" class="never mr-4">
- <div class="flex align-center color-text-primary">
- <AppIcon iconName="app-tag"></AppIcon>
- <span class="ml-4">{{ row.tag_count }}</span>
- </div>
- </el-tag>
- </template>
- </el-popover>
- <el-button
- class="button-new-tag"
- size="small"
- :disabled="!permissionPrecise.doc_tag(id)"
- @click.stop="openAddTagDialog(row.id)"
- >
- <AppIcon iconName="app-add-outlined" class="mr-4"></AppIcon>
- {{ $t('views.document.tag.key') }}
- </el-button>
- </template>
- </el-table-column>
- <el-table-column width="165">
- <template #header>
- <div>
- <span>{{ $t('views.document.form.hit_handling_method.label') }}</span>
- <el-dropdown trigger="click" @command="dropdownHandle">
- <el-button
- style="margin-top: 1px"
- link
- :type="filterMethod['hit_handling_method'] ? 'primary' : ''"
- >
- <el-icon>
- <Filter />
- </el-icon>
- </el-button>
- <template #dropdown>
- <el-dropdown-menu style="width: 150px">
- <el-dropdown-item
- :class="filterMethod['hit_handling_method'] ? '' : 'is-active'"
- :command="beforeCommand('hit_handling_method', '')"
- class="justify-center"
- >{{ $t('common.status.all') }}
- </el-dropdown-item>
- <template v-for="(value, key) of hitHandlingMethod" :key="key">
- <el-dropdown-item
- :class="filterMethod['hit_handling_method'] === key ? 'is-active' : ''"
- class="justify-center"
- :command="beforeCommand('hit_handling_method', key)"
- >{{ $t(value) }}
- </el-dropdown-item>
- </template>
- </el-dropdown-menu>
- </template>
- </el-dropdown>
- </div>
- </template>
- <template #default="{ row }">
- {{
- $t(hitHandlingMethod[row.hit_handling_method as keyof typeof hitHandlingMethod])
- }}
- </template>
- </el-table-column>
- <el-table-column
- prop="create_time"
- :label="$t('common.createTime')"
- width="175"
- sortable
- >
- <template #default="{ row }">
- {{ datetimeFormat(row.create_time) }}
- </template>
- </el-table-column>
- <el-table-column
- prop="update_time"
- :label="$t('views.document.table.updateTime')"
- width="175"
- sortable
- >
- <template #default="{ row }">
- {{ datetimeFormat(row.update_time) }}
- </template>
- </el-table-column>
- <el-table-column
- :label="$t('common.operation')"
- align="left"
- width="160"
- fixed="right"
- v-if="!isShared"
- >
- <template #default="{ row }">
- <span @click.stop>
- <el-switch
- :loading="loading"
- size="small"
- v-model="row.is_active"
- :before-change="() => changeState(row)"
- v-if="permissionPrecise.doc_edit(id)"
- />
- </span>
- <el-divider direction="vertical" />
- <template v-if="knowledgeDetail?.type === 0 || knowledgeDetail?.type === 4">
- <el-tooltip
- effect="dark"
- :content="$t('views.document.setting.cancelVectorization')"
- placement="top"
- v-if="
- ([State.STARTED, State.PENDING] as Array<string>).includes(
- getTaskState(row.status, TaskType.EMBEDDING),
- )
- "
- >
- <span class="mr-4">
- <el-button
- type="primary"
- text
- @click.stop="cancelTask(row, TaskType.EMBEDDING)"
- v-if="permissionPrecise.doc_vector(id)"
- >
- <el-icon><Close /></el-icon>
- </el-button>
- </span>
- </el-tooltip>
- <el-tooltip
- effect="dark"
- :content="$t('views.knowledge.setting.vectorization')"
- placement="top"
- v-else
- >
- <span class="mr-4" v-if="permissionPrecise.doc_vector(id)">
- <el-button type="primary" text @click.stop="refreshDocument(row)">
- <AppIcon iconName="app-document-refresh" style="font-size: 16px"></AppIcon>
- </el-button>
- </span>
- </el-tooltip>
- <el-tooltip
- effect="dark"
- :content="$t('common.setting')"
- placement="top"
- v-if="permissionPrecise.doc_edit(id)"
- >
- <span class="mr-4">
- <el-button type="primary" text @click.stop="settingDoc(row)">
- <AppIcon iconName="app-setting"></AppIcon>
- </el-button>
- </span>
- </el-tooltip>
- <span @click.stop>
- <el-dropdown trigger="click" v-if="MoreFilledPermission1(id)">
- <el-button text type="primary">
- <AppIcon iconName="app-more"></AppIcon>
- </el-button>
- <template #dropdown>
- <el-dropdown-menu>
- <el-dropdown-item
- v-if="
- ([State.STARTED, State.PENDING] as Array<string>).includes(
- getTaskState(row.status, TaskType.GENERATE_PROBLEM),
- ) && permissionPrecise.doc_generate(id)
- "
- @click="cancelTask(row, TaskType.GENERATE_PROBLEM)"
- >
- <el-icon class="color-secondary"><Close /></el-icon>
- {{ $t('views.document.setting.cancelGenerateQuestion') }}
- </el-dropdown-item>
- <el-dropdown-item
- @click="openGenerateDialog(row)"
- v-else-if="permissionPrecise.doc_generate(id)"
- >
- <AppIcon
- iconName="app-generate-question"
- class="color-secondary"
- ></AppIcon>
- {{ $t('views.document.generateQuestion.title') }}
- </el-dropdown-item>
- <el-dropdown-item
- @click="openTagSettingDrawer(row)"
- v-if="permissionPrecise.doc_tag(id)"
- >
- <AppIcon iconName="app-tag" class="color-secondary"></AppIcon>
- {{ $t('views.document.tag.setting') }}
- </el-dropdown-item>
- <el-dropdown-item
- @click="openknowledgeDialog(row)"
- v-if="permissionPrecise.doc_migrate(id)"
- >
- <AppIcon iconName="app-migrate" class="color-secondary"></AppIcon>
- {{ $t('views.document.setting.migration') }}
- </el-dropdown-item>
- <el-dropdown-item
- @click="exportDocument(row)"
- v-if="permissionPrecise.doc_export(id)"
- >
- <AppIcon iconName="app-export" class="color-secondary"></AppIcon>
- {{ $t('views.document.setting.export') }} Excel
- </el-dropdown-item>
- <el-dropdown-item
- @click="exportDocumentZip(row)"
- v-if="permissionPrecise.doc_export(id)"
- >
- <AppIcon iconName="app-export" class="color-secondary"></AppIcon>
- {{ $t('views.document.setting.export') }} Zip
- </el-dropdown-item>
- <el-dropdown-item
- @click.stop="downloadDocument(row)"
- v-if="permissionPrecise.doc_download(id)"
- >
- <AppIcon iconName="app-download" class="color-secondary" />
- {{ $t('views.document.setting.download') }}
- </el-dropdown-item>
- <el-upload
- v-if="permissionPrecise.doc_replace(id)"
- ref="elUploadRef"
- :file-list="[]"
- action="#"
- :auto-upload="false"
- :show-file-list="false"
- :on-change="(file: any, fileList: any) => replaceDocument(file, row)"
- >
- <el-dropdown-item>
- <AppIcon iconName="app-upload" class="color-secondary" />
- {{ $t('views.document.setting.replace') }}
- </el-dropdown-item>
- </el-upload>
- <el-dropdown-item
- @click.stop="deleteDocument(row)"
- v-if="permissionPrecise.doc_delete(id)"
- >
- <AppIcon iconName="app-delete" class="color-secondary"></AppIcon>
- {{ $t('common.delete') }}</el-dropdown-item
- >
- </el-dropdown-menu>
- </template>
- </el-dropdown>
- </span>
- </template>
- <template v-if="knowledgeDetail?.type === 1 || knowledgeDetail?.type === 2">
- <el-tooltip
- effect="dark"
- :content="$t('views.document.setting.cancelVectorization')"
- placement="top"
- v-if="
- ([State.STARTED, State.PENDING] as Array<string>).includes(
- getTaskState(row.status, TaskType.EMBEDDING),
- ) && permissionPrecise.doc_vector(id)
- "
- >
- <span class="mr-4">
- <el-button
- type="primary"
- text
- @click.stop="cancelTask(row, TaskType.EMBEDDING)"
- >
- <el-icon><Close /></el-icon>
- </el-button>
- </span>
- </el-tooltip>
- <el-tooltip
- effect="dark"
- :content="$t('views.knowledge.setting.vectorization')"
- placement="top"
- v-if="permissionPrecise.vector(id)"
- >
- <span class="mr-4">
- <el-button type="primary" text @click.stop="refreshDocument(row)">
- <AppIcon iconName="app-document-refresh" style="font-size: 16px"></AppIcon>
- </el-button>
- </span>
- </el-tooltip>
- <el-tooltip
- effect="dark"
- :content="$t('common.setting')"
- placement="top"
- v-if="permissionPrecise.doc_edit(id)"
- >
- <span class="mr-4">
- <el-button type="primary" text @click.stop="settingDoc(row)">
- <AppIcon iconName="app-setting"></AppIcon>
- </el-button>
- </span>
- </el-tooltip>
- <span @click.stop>
- <el-dropdown trigger="click" v-if="MoreFilledPermission2(id)">
- <el-button text type="primary">
- <AppIcon iconName="app-more"></AppIcon>
- </el-button>
- <template #dropdown>
- <el-dropdown-menu>
- <el-dropdown-item
- @click="syncDocument(row)"
- v-if="permissionPrecise.sync(id)"
- >
- <AppIcon iconName="app-sync" class="color-secondary"></AppIcon>
- {{ $t('views.knowledge.setting.sync') }}</el-dropdown-item
- >
- <el-dropdown-item
- @click="openTagSettingDrawer(row)"
- v-if="permissionPrecise.doc_tag(id)"
- >
- <AppIcon iconName="app-tag" class="color-secondary"></AppIcon>
- {{ $t('views.document.tag.setting') }}
- </el-dropdown-item>
- <el-dropdown-item
- v-if="
- permissionPrecise.doc_generate(id) &&
- ([State.STARTED, State.PENDING] as Array<string>).includes(
- getTaskState(row.status, TaskType.GENERATE_PROBLEM),
- )
- "
- @click="cancelTask(row, TaskType.GENERATE_PROBLEM)"
- >
- <el-icon class="color-secondary"><Close /></el-icon>
- {{ $t('views.document.setting.cancelGenerateQuestion') }}
- </el-dropdown-item>
- <el-dropdown-item
- @click="openGenerateDialog(row)"
- v-else-if="permissionPrecise.doc_generate(id)"
- >
- <AppIcon
- iconName="app-generate-question"
- class="color-secondary"
- ></AppIcon>
- {{ $t('views.document.generateQuestion.title') }}
- </el-dropdown-item>
- <el-dropdown-item
- @click="openknowledgeDialog(row)"
- v-if="permissionPrecise.doc_migrate(id)"
- >
- <AppIcon iconName="app-migrate" class="color-secondary"></AppIcon>
- {{ $t('views.document.setting.migration') }}
- </el-dropdown-item>
- <el-dropdown-item
- @click="exportDocument(row)"
- v-if="permissionPrecise.doc_export(id)"
- >
- <AppIcon iconName="app-export" class="color-secondary"></AppIcon>
- {{ $t('views.document.setting.export') }} Excel
- </el-dropdown-item>
- <el-dropdown-item
- @click="exportDocumentZip(row)"
- v-if="permissionPrecise.doc_export(id)"
- >
- <AppIcon iconName="app-export" class="color-secondary"></AppIcon>
- {{ $t('views.document.setting.export') }} Zip
- </el-dropdown-item>
- <el-dropdown-item
- @click.stop="deleteDocument(row)"
- v-if="permissionPrecise.doc_delete(id)"
- >
- <AppIcon iconName="app-delete" class="color-secondary"></AppIcon>
- {{ $t('common.delete') }}
- </el-dropdown-item>
- </el-dropdown-menu>
- </template>
- </el-dropdown>
- </span>
- </template>
- </template>
- </el-table-column>
- </app-table>
- </div>
- </div>
- </el-card>
- <div class="mul-operation w-full flex" v-if="multipleSelection.length !== 0">
- <el-button
- :disabled="multipleSelection.length === 0"
- @click="cancelTaskHandle(1)"
- v-if="permissionPrecise.doc_vector(id)"
- >
- {{ $t('views.document.setting.cancelVectorization') }}
- </el-button>
- <el-button
- :disabled="multipleSelection.length === 0"
- @click="cancelTaskHandle(2)"
- v-if="permissionPrecise.doc_generate(id)"
- >
- {{ $t('views.document.setting.cancelGenerate') }}
- </el-button>
- <el-text type="info" class="secondary ml-24">
- {{ $t('common.selected') }} {{ multipleSelection.length }}
- {{ $t('views.document.items') }}
- </el-text>
- <el-button class="ml-16" type="primary" link @click="clearSelection">
- {{ $t('common.clear') }}
- </el-button>
- </div>
- <EmbeddingContentDialog ref="embeddingContentDialogRef"></EmbeddingContentDialog>
- <ImportDocumentDialog ref="ImportDocumentDialogRef" :title="title" @refresh="refresh" />
- <!-- 选择知识库 -->
- <SelectKnowledgeDialog
- ref="selectKnowledgeDialogRef"
- @refresh="refreshMigrate"
- :workspaceId="knowledgeDetail?.workspace_id"
- />
- <GenerateRelatedDialog ref="GenerateRelatedDialogRef" @refresh="getList" :apiType="apiType" />
- <TagDrawer ref="tagDrawerRef" @tag-changed="onTagChanged" />
- <TagSettingDrawer
- ref="tagSettingDrawerRef"
- @refresh="
- () => {
- onTagChanged()
- getList()
- }
- "
- />
- <AddTagDialog ref="addTagDialogRef" @addTags="addTags" :apiType="apiType" />
- <!-- 执行详情 -->
- <ExecutionRecord ref="ListActionRef"></ExecutionRecord>
- <!-- 推送到样本中心 -->
- <SyncToSampleCenterDialog ref="syncToSampleCenterDialogRef" />
- </div>
- </template>
- <script setup lang="ts">
- import { ref, onMounted, onBeforeUnmount, computed, reactive } from 'vue'
- import { useRouter, useRoute, onBeforeRouteLeave, onBeforeRouteUpdate } from 'vue-router'
- import type { ElTable } from 'element-plus'
- import ImportDocumentDialog from './component/ImportDocumentDialog.vue'
- import SelectKnowledgeDialog from './component/SelectKnowledgeDialog.vue'
- import { numberFormat } from '@/utils/common'
- import { datetimeFormat } from '@/utils/time'
- import { hitHandlingMethod } from '@/enums/document'
- import { MsgSuccess, MsgConfirm, MsgError, MsgAlert } from '@/utils/message'
- import useStore from '@/stores'
- import StatusValue from '@/views/document/component/Status.vue'
- import GenerateRelatedDialog from '@/components/generate-related-dialog/index.vue'
- import EmbeddingContentDialog from '@/views/document/component/EmbeddingContentDialog.vue'
- import { TaskType, State } from '@/utils/status'
- import { t } from '@/locales'
- import permissionMap from '@/permission'
- import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
- import TagDrawer from './tag/TagDrawer.vue'
- import TagSettingDrawer from './tag/TagSettingDrawer.vue'
- import AddTagDialog from '@/views/document/tag/MulAddTagDialog.vue'
- import ExecutionRecord from '@/views/knowledge-workflow/component/execution-record/ExecutionRecordDrawer.vue'
- import SyncToSampleCenterDialog from '@/views/document/component/SyncToSampleCenterDialog.vue'
- const route = useRoute()
- const router = useRouter()
- const {
- params: { id, folderId, type }, // id为knowledgeID
- } = route as any
- const { common } = useStore()
- const storeKey = 'documents'
- onBeforeRouteUpdate(() => {
- common.savePage(storeKey, null)
- common.saveCondition(storeKey, null)
- })
- onBeforeRouteLeave((to: any) => {
- if (to.name !== 'ParagraphIndex') {
- common.savePage(storeKey, null)
- common.saveCondition(storeKey, null)
- } else {
- common.saveCondition(storeKey, {
- search_type: search_type.value,
- search_form: search_form.value,
- filterMethod: filterMethod.value,
- })
- }
- })
- const isShared = computed(() => {
- return folderId === 'share'
- })
- const apiType = computed(() => {
- if (route.path.includes('shared')) {
- return 'systemShare'
- } else if (route.path.includes('resource-management')) {
- return 'systemManage'
- } else if (route.path.includes('share/')) {
- return 'workspaceShare'
- } else {
- return 'workspace'
- }
- })
- const permissionPrecise = computed(() => {
- return permissionMap['knowledge'][apiType.value]
- })
- const MoreFilledPermission0 = (id: string) => {
- return (
- permissionPrecise.value.doc_migrate(id) ||
- (knowledgeDetail?.value.type === 1 && permissionPrecise.value.doc_sync(id)) ||
- (knowledgeDetail?.value.type === 2 && permissionPrecise.value.doc_sync(id)) ||
- permissionPrecise.value.doc_delete(id) ||
- permissionPrecise.value.doc_tag(id)
- )
- }
- const MoreFilledPermission1 = (id: string) => {
- return (
- permissionPrecise.value.doc_generate(id) ||
- permissionPrecise.value.doc_migrate(id) ||
- permissionPrecise.value.doc_export(id) ||
- permissionPrecise.value.doc_download(id) ||
- permissionPrecise.value.doc_delete(id) ||
- permissionPrecise.value.doc_tag(id) ||
- permissionPrecise.value.doc_replace(id)
- )
- }
- const MoreFilledPermission2 = (id: string) => {
- return (
- permissionPrecise.value.sync(id) ||
- permissionPrecise.value.doc_generate(id) ||
- permissionPrecise.value.doc_migrate(id) ||
- permissionPrecise.value.doc_export(id) ||
- permissionPrecise.value.doc_delete(id)
- )
- }
- const getTaskState = (status: string, taskType: number) => {
- const statusList = status.split('').reverse()
- return taskType - 1 > statusList.length + 1 ? 'n' : statusList[taskType - 1]
- }
- const search_type = ref('name')
- const search_form = ref<any>({
- name: '',
- tag: '',
- })
- const beforePagination = computed(() => common.paginationConfig[storeKey])
- const beforeSearch = computed(() => common.search[storeKey])
- const embeddingContentDialogRef = ref<InstanceType<typeof EmbeddingContentDialog>>()
- const ListActionRef = ref<InstanceType<typeof ExecutionRecord>>()
- const loading = ref(false)
- let interval: any
- const filterMethod = ref<any>({})
- const orderBy = ref<string>('')
- const documentData = ref<any[]>([])
- const currentMouseId = ref(null)
- const knowledgeDetail = ref<any>({})
- const paginationConfig = ref({
- current_page: 1,
- page_size: 10,
- total: 0,
- })
- const ImportDocumentDialogRef = ref()
- const multipleTableRef = ref<InstanceType<typeof ElTable>>()
- const multipleSelection = ref<any[]>([])
- const title = ref('')
- const selectKnowledgeDialogRef = ref()
- const openListAction = () => {
- ListActionRef.value?.open(id)
- }
- const toImportWorkflow = () => {
- if (knowledgeDetail.value.is_publish) {
- router.push({
- path: `/knowledge/import/workflow/${folderId}`,
- query: {
- id: id,
- },
- })
- } else {
- MsgConfirm(t('common.tip'), t('views.document.tip.toImportDocConfirm'), {
- cancelButtonText: t('common.close'),
- showConfirmButton: false,
- type: 'warning',
- })
- .then(() => {})
- .catch(() => {})
- }
- }
- const exportDocument = (document: any) => {
- loadSharedApi({ type: 'document', systemType: apiType.value })
- .exportDocument(document.name, document.knowledge_id, document.id, loading)
- .then(() => {
- MsgSuccess(t('common.exportSuccess'))
- })
- }
- const exportDocumentZip = (document: any) => {
- loadSharedApi({ type: 'document', systemType: apiType.value })
- .exportDocumentZip(document.name, document.knowledge_id, document.id, loading)
- .then(() => {
- MsgSuccess(t('common.exportSuccess'))
- })
- }
- function cancelTaskHandle(val: any) {
- const arr: string[] = []
- multipleSelection.value.map((v) => {
- if (v) {
- arr.push(v.id)
- }
- })
- const obj = {
- id_list: arr,
- type: val,
- }
- loadSharedApi({ type: 'document', systemType: apiType.value })
- .putBatchCancelTask(id, obj, loading)
- .then(() => {
- MsgSuccess(t('views.document.tip.cancelSuccess'))
- multipleTableRef.value?.clearSelection()
- })
- }
- function clearSelection() {
- multipleTableRef.value?.clearSelection()
- }
- function openknowledgeDialog(row?: any) {
- const arr: string[] = []
- if (row) {
- arr.push(row.id)
- } else {
- multipleSelection.value.map((v) => {
- if (v) {
- arr.push(v.id)
- }
- })
- }
- selectKnowledgeDialogRef.value.open(arr)
- }
- function dropdownHandle(obj: any) {
- filterMethod.value[obj.attr] = obj.command
- if (obj.attr == 'status') {
- filterMethod.value['task_type'] = obj.task_type
- }
- getList()
- }
- function beforeCommand(attr: string, val: any, task_type?: number) {
- return {
- attr: attr,
- command: val,
- task_type,
- }
- }
- const cancelTask = (row: any, task_type: number) => {
- loadSharedApi({ type: 'document', systemType: apiType.value })
- .putCancelTask(id, row.id, { type: task_type })
- .then(() => {
- MsgSuccess(t('views.document.tip.sendMessage'))
- })
- }
- function importDoc() {
- title.value = t('views.document.importDocument')
- ImportDocumentDialogRef.value.open()
- }
- function settingDoc(row: any) {
- title.value = t('common.setting')
- ImportDocumentDialogRef.value.open(row)
- }
- const handleSelectionChange = (val: any[]) => {
- multipleSelection.value = val
- }
- function openBatchEditDocument() {
- title.value = t('common.setting')
- const arr: string[] = multipleSelection.value.map((v) => v.id)
- ImportDocumentDialogRef.value.open(null, arr)
- }
- /**
- * 初始化轮询
- */
- const initInterval = () => {
- interval = setInterval(() => {
- getList(true)
- }, 6000)
- }
- /**
- * 关闭轮询
- */
- const closeInterval = () => {
- if (interval) {
- clearInterval(interval)
- }
- }
- function syncDocument(row: any) {
- if (+row.type === 1) {
- syncWebDocument(row)
- } else {
- syncLarkDocument(row)
- }
- }
- function syncLarkDocument(row: any) {
- MsgConfirm(t('views.document.sync.confirmTitle'), t('views.document.sync.confirmMessage1'), {
- confirmButtonText: t('views.document.sync.label'),
- confirmButtonClass: 'danger',
- })
- .then(() => {
- loadSharedApi({ type: 'document', systemType: apiType.value })
- .putLarkDocumentSync(id, row.id)
- .then(() => {
- getList()
- })
- })
- .catch(() => {})
- }
- function syncWebDocument(row: any) {
- if (row.meta?.source_url) {
- MsgConfirm(t('views.document.sync.confirmTitle'), t('views.document.sync.confirmMessage1'), {
- confirmButtonText: t('views.document.sync.label'),
- confirmButtonClass: 'danger',
- })
- .then(() => {
- loadSharedApi({ type: 'document', systemType: apiType.value })
- .putDocumentSync(row.knowledge_id, row.id)
- .then(() => {
- getList()
- })
- })
- .catch(() => {})
- } else {
- MsgConfirm(t('common.tip'), t('views.document.sync.confirmMessage2'), {
- confirmButtonText: t('common.confirm'),
- type: 'warning',
- })
- .then(() => {})
- .catch(() => {})
- }
- }
- function refreshDocument(row: any) {
- const embeddingDocument = (stateList: Array<string>) => {
- return loadSharedApi({ type: 'document', systemType: apiType.value })
- .putDocumentRefresh(row.knowledge_id, row.id, stateList)
- .then(() => {
- getList()
- })
- }
- embeddingContentDialogRef.value?.open(embeddingDocument)
- }
- function rowClickHandle(row: any, column: any) {
- console.log(column)
- if (column && (column.type === 'selection' || column.property === 'tag')) {
- return
- }
- router.push({
- path: `/paragraph/${id}/${row.id}`,
- query: { from: apiType.value, isShared: isShared.value ? 'true' : 'false' },
- })
- }
- /*
- 快速创建空白文档
- */
- function creatQuickHandle(val: string) {
- loading.value = true
- const obj = [{ name: val }]
- loadSharedApi({ type: 'document', systemType: apiType.value })
- .putMulDocument(id, obj)
- .then(() => {
- getList()
- MsgSuccess(t('common.createSuccess'))
- })
- .catch(() => {
- loading.value = false
- })
- }
- function syncMulDocument() {
- const arr: string[] = []
- multipleSelection.value.map((v) => {
- if (v) {
- arr.push(v.id)
- }
- })
- MsgConfirm(t('views.document.sync.confirmTitle'), t('views.document.sync.confirmMessage1'), {
- confirmButtonText: t('views.document.sync.label'),
- confirmButtonClass: 'danger',
- })
- .then(() => {
- loadSharedApi({ type: 'document', systemType: apiType.value })
- .putMulSyncDocument(id, arr, loading)
- .then(() => {
- MsgSuccess(t('views.document.sync.successMessage'))
- getList()
- })
- })
- .catch(() => {})
- }
- function syncLarkMulDocument() {
- const arr: string[] = []
- multipleSelection.value.map((v) => {
- if (v) {
- arr.push(v.id)
- }
- })
- loadSharedApi({ type: 'document', systemType: apiType.value })
- .putMulLarkSyncDocument(id, arr, loading)
- .then(() => {
- MsgSuccess(t('views.document.sync.successMessage'))
- getList()
- })
- }
- function exportMulDocument() {
- const arr: string[] = []
- multipleSelection.value.map((v) => {
- if (v) {
- arr.push(v.id)
- }
- })
- loadSharedApi({ type: 'document', systemType: apiType.value })
- .exportMulDocument(knowledgeDetail.value.name, id, arr, loading)
- .then(() => {
- MsgSuccess(t('common.exportSuccess'))
- })
- }
- function exportMulDocumentZip() {
- const arr: string[] = []
- multipleSelection.value.map((v) => {
- if (v) {
- arr.push(v.id)
- }
- })
- loadSharedApi({ type: 'document', systemType: apiType.value })
- .exportMulDocumentZip(knowledgeDetail.value.name, id, arr, loading)
- .then(() => {
- MsgSuccess(t('common.exportSuccess'))
- })
- }
- function deleteMulDocument() {
- MsgConfirm(
- `${t('views.document.delete.confirmTitle1')} ${multipleSelection.value.length} ${t('views.document.delete.confirmTitle2')}`,
- t('views.document.delete.confirmMessage'),
- {
- confirmButtonText: t('common.confirm'),
- confirmButtonClass: 'danger',
- },
- )
- .then(() => {
- const arr: string[] = []
- multipleSelection.value.map((v) => {
- if (v) {
- arr.push(v.id)
- }
- })
- loadSharedApi({ type: 'document', systemType: apiType.value })
- .delMulDocument(id, arr, loading)
- .then(() => {
- MsgSuccess(t('views.document.delete.successMessage'))
- multipleTableRef.value?.clearSelection()
- getList()
- })
- })
- .catch(() => {})
- }
- // 推送到样本中心
- const syncToSampleCenterDialogRef = ref()
- function openSyncToSampleCenter() {
- syncToSampleCenterDialogRef.value?.open(knowledgeDetail.value, multipleSelection.value)
- }
- function batchRefresh() {
- const arr: string[] = multipleSelection.value.map((v) => v.id)
- const embeddingBatchDocument = (stateList: Array<string>) => {
- loadSharedApi({ type: 'document', systemType: apiType.value })
- .putBatchRefresh(id, arr, stateList, loading)
- .then(() => {
- MsgSuccess(t('views.document.tip.vectorizationSuccess'))
- multipleTableRef.value?.clearSelection()
- })
- }
- embeddingContentDialogRef.value?.open(embeddingBatchDocument)
- }
- function downloadDocument(row: any) {
- loadSharedApi({ type: 'document', systemType: apiType.value })
- .getDownloadSourceFile(id, row.id, row.name)
- .then(() => {
- getList()
- })
- }
- const elUploadRef = ref()
- function replaceDocument(file: any, row: any) {
- const formData = new FormData()
- formData.append('file', file.raw, file.name)
- elUploadRef.value.clearFiles()
- loadSharedApi({ type: 'document', systemType: apiType.value })
- .postReplaceSourceFile(id, row.id, formData, loading)
- .then(() => {
- MsgSuccess(t('views.document.tip.replaceSuccess'))
- getList()
- })
- .catch((e: any) => {})
- }
- function deleteDocument(row: any) {
- MsgConfirm(
- `${t('views.document.delete.confirmTitle3')} ${row.name} ?`,
- `${t('views.document.delete.confirmMessage1')} ${row.paragraph_count} ${t('views.document.delete.confirmMessage2')}`,
- {
- confirmButtonText: t('common.confirm'),
- confirmButtonClass: 'danger',
- },
- )
- .then(() => {
- loadSharedApi({ type: 'document', systemType: apiType.value })
- .delDocument(id, row.id, loading)
- .then(() => {
- MsgSuccess(t('common.deleteSuccess'))
- getList()
- })
- })
- .catch(() => {})
- }
- /*
- 更新名称或状态
- */
- function updateData(documentId: string, data: any, msg: string) {
- loadSharedApi({ type: 'document', systemType: apiType.value })
- .putDocument(id, documentId, data, loading)
- .then((res: any) => {
- const index = documentData.value.findIndex((v) => v.id === documentId)
- documentData.value.splice(index, 1, res.data)
- MsgSuccess(msg)
- return true
- })
- .catch(() => {
- return false
- })
- }
- async function changeState(row: any) {
- const obj = {
- is_active: !row.is_active,
- }
- const str = !row.is_active ? t('common.status.enableSuccess') : t('common.status.disableSuccess')
- await updateData(row.id, obj, str)
- }
- function editName(val: string, id: string) {
- if (val) {
- const obj = {
- name: val,
- }
- updateData(id, obj, t('common.modifySuccess'))
- } else {
- MsgError(t('views.document.tip.nameMessage'))
- }
- }
- function cellMouseEnter(row: any, column: any) {
- if (column && column.property === 'name') {
- currentMouseId.value = row.id
- }
- }
- function cellMouseLeave() {
- currentMouseId.value = null
- }
- function handleSizeChange() {
- paginationConfig.value.current_page = 1
- getList()
- }
- function handleSortChange({ prop, order }: { prop: string; order: string }) {
- orderBy.value = order === 'ascending' ? prop : `-${prop}`
- getList()
- }
- function getList(bool?: boolean) {
- const param = {
- ...filterMethod.value,
- order_by: orderBy.value,
- folder_id: folderId,
- }
- if (search_form.value[search_type.value]) {
- param[search_type.value] = search_form.value[search_type.value]
- }
- loadSharedApi({ type: 'document', isShared: isShared.value, systemType: apiType.value })
- .getDocumentPage(id as string, paginationConfig.value, param, bool ? undefined : loading)
- .then((res: any) => {
- documentData.value = res.data.records
- paginationConfig.value.total = res.data.total
- })
- }
- const search_type_change = () => {
- search_form.value = { name: '', tag: '' }
- }
- function getDetail() {
- loadSharedApi({ type: 'knowledge', isShared: isShared.value, systemType: apiType.value })
- .getKnowledgeDetail(id, loading)
- .then((res: any) => {
- knowledgeDetail.value = res.data
- })
- }
- function refreshMigrate() {
- multipleTableRef.value?.clearSelection()
- getList()
- }
- function refresh() {
- paginationConfig.value.current_page = 1
- getList()
- }
- const GenerateRelatedDialogRef = ref()
- function openGenerateDialog(row?: any) {
- const arr: string[] = []
- if (row) {
- arr.push(row.id)
- } else {
- multipleSelection.value.map((v) => {
- if (v) {
- arr.push(v.id)
- }
- })
- }
- GenerateRelatedDialogRef.value.open(arr, 'document')
- }
- function cellClickHandle(row: any, column: any, cell: any, event: any) {
- if (column.property === 'tag' && permissionPrecise.value.doc_tag(id)) {
- event.stopPropagation()
- openTagSettingDrawer(row)
- }
- }
- const tagFilterValue = ref<string[]>([])
- const tagFilterDirty = ref(false)
- const tagFilterOptions = ref<any[]>([])
- const tagFilterLoaded = ref(false)
- const tagFilterLoading = ref(false)
- function buildTagCascaderOptions(tags: any[]) {
- const options = tags.map((group: any) => ({
- label: group.key,
- value: group.key,
- children: (group.values || []).map((item: any) => ({
- label: item.value,
- value: item.id, // 叶子节点 tag.id
- })),
- }))
- options.push({
- label: t('views.document.tag.noTag'),
- value: 'NO_TAG',
- children: [],
- })
- return options
- }
- async function ensureTagFilterOptions(needRefresh = false) {
- // 非刷新 && 已加载 && 非脏数据
- if (!needRefresh && tagFilterLoaded.value && !tagFilterDirty.value) return
- try {
- tagFilterLoading.value = true
- const params = {}
- const res: any = await loadSharedApi({
- type: 'knowledge',
- systemType: apiType.value,
- isShared: isShared.value,
- }).getTags(id, params, tagFilterLoading)
- tagFilterOptions.value = buildTagCascaderOptions(res?.data || [])
- tagFilterLoaded.value = true
- tagFilterDirty.value = false
- } finally {
- tagFilterLoading.value = false
- }
- }
- async function handleTagVisibleChange(visible: boolean) {
- if (!visible) return
- await ensureTagFilterOptions()
- }
- function onTagChanged() {
- tagFilterDirty.value = true
- }
- const tagDrawerRef = ref()
- function openTagDrawer() {
- tagDrawerRef.value.open()
- }
- const tagSettingDrawerRef = ref()
- function openTagSettingDrawer(doc: any) {
- tagSettingDrawerRef.value.open(doc)
- }
- const addTagDialogRef = ref()
- function openAddTagDialog(rowId?: string) {
- addTagDialogRef.value?.open(rowId)
- }
- function addTags(tags: any, rowId?: string) {
- const arr: string[] = multipleSelection.value.length
- ? multipleSelection.value.map((v) => v.id)
- : [rowId]
- loadSharedApi({ type: 'document', systemType: apiType.value })
- .postMulDocumentTags(id, { tag_ids: tags, document_ids: arr }, loading)
- .then(() => {
- addTagDialogRef.value?.close()
- getList()
- clearSelection()
- })
- }
- onMounted(() => {
- getDetail()
- if (beforePagination.value) {
- paginationConfig.value = beforePagination.value
- }
- if (beforeSearch.value) {
- filterMethod.value = beforeSearch.value['filterMethod']
- search_type.value = beforeSearch.value['search_type']
- search_form.value = beforeSearch.value['search_form']
- }
- getList()
- // 初始化定时任务
- initInterval()
- if (route.query.imported === 'true') {
- MsgAlert(t('common.tip'), t('common.knowledgeImportTip')).then(() => {
- router.replace({ query: {} })
- })
- }
- })
- onBeforeUnmount(() => {
- // 清除定时任务
- closeInterval()
- })
- </script>
- <style lang="scss" scoped>
- .document {
- .mul-operation {
- right: 24px;
- width: calc(100% - var(--sidebar-width) - 48px);
- }
- .document-table {
- :deep(.el-table__row) {
- cursor: pointer;
- }
- }
- }
- </style>
|