77 destroy-on-close
88 :close-on-click-modal =" false"
99 :close-on-press-escape =" false"
10+ @click.stop
1011 >
1112 <el-row v-loading =" loading" >
1213 <el-col :span =" 18" >
1314 <el-scrollbar height =" 500" wrap-class =" paragraph-scrollbar" >
1415 <div class =" p-24" style =" padding-bottom : 8px " >
1516 <div style =" position : absolute ; right : 20px ; top : 20px " >
16- <el-button text @click =" isEdit = true" v-if =" problemId && !isEdit" >
17+ <el-button text @click =" isEdit = true" v-if =" paragraphId && !isEdit" >
1718 <el-icon ><EditPen /></el-icon >
1819 </el-button >
1920 </div >
2021
2122 <ParagraphForm ref =" paragraphFormRef" :data =" detail" :isEdit =" isEdit" />
2223 </div >
2324 </el-scrollbar >
24- <div class =" text-right p-24 pt-0" v-if =" problemId && isEdit" >
25+ <div class =" text-right p-24 pt-0" v-if =" paragraphId && isEdit" >
2526 <el-button @click.prevent =" cancelEdit" > {{ $t('common.cancel') }} </el-button >
2627 <el-button type =" primary" :disabled =" loading" @click =" handleDebounceClick" >
2728 {{ $t('common.save') }}
3132 <el-col :span =" 6" class =" border-l" style =" width : 300px " >
3233 <!-- 关联问题 -->
3334 <ProblemComponent
34- :problemId = " problemId "
35+ :paragraphId = " paragraphId "
3536 :docId =" document_id"
3637 :knowledgeId =" dataset_id"
3738 ref =" ProblemRef"
3839 />
3940 </el-col >
4041 </el-row >
41- <template #footer v-if =" ! problemId " >
42+ <template #footer v-if =" ! paragraphId " >
4243 <span class =" dialog-footer" >
4344 <el-button @click.prevent =" dialogVisible = false" > {{ $t('common.cancel') }} </el-button >
4445 <el-button :disabled =" loading" type =" primary" @click =" handleDebounceClick" >
@@ -76,16 +77,17 @@ const paragraphFormRef = ref<any>()
7677const dialogVisible = ref <boolean >(false )
7778
7879const loading = ref (false )
79- const problemId = ref (' ' )
80+ const paragraphId = ref (' ' )
8081const detail = ref <any >({})
8182const isEdit = ref (false )
8283const document_id = ref (' ' )
8384const dataset_id = ref (' ' )
8485const cloneData = ref (null )
86+ const position = ref (null )
8587
8688watch (dialogVisible , (bool ) => {
8789 if (! bool ) {
88- problemId .value = ' '
90+ paragraphId .value = ' '
8991 detail .value = {}
9092 isEdit .value = false
9193 document_id .value = ' '
@@ -99,28 +101,31 @@ const cancelEdit = () => {
99101 detail .value = cloneDeep (cloneData .value )
100102}
101103
102- const open = (data : any ) => {
103- if (data ) {
104+ const open = (data : any , str : any ) => {
105+ if (data && ! str ) {
104106 detail .value .title = data .title
105107 detail .value .content = data .content
106108 cloneData .value = cloneDeep (detail .value )
107- problemId .value = data .id
109+ paragraphId .value = data .id
108110 document_id .value = data .document_id
109111 dataset_id .value = data .dataset_id || id
110112 } else {
111113 isEdit .value = true
114+ if (str === ' add' ) {
115+ position .value = data .position
116+ }
112117 }
113118 dialogVisible .value = true
114119}
115120const submitHandle = async () => {
116121 if (await paragraphFormRef .value ?.validate ()) {
117122 loading .value = true
118- if (problemId .value ) {
123+ if (paragraphId .value ) {
119124 paragraph
120125 .asyncPutParagraph (
121126 dataset_id .value ,
122127 documentId || document_id .value ,
123- problemId .value ,
128+ paragraphId .value ,
124129 paragraphFormRef .value ?.form ,
125130 loading ,
126131 )
@@ -132,10 +137,14 @@ const submitHandle = async () => {
132137 const obj =
133138 ProblemRef .value .problemList .length > 0
134139 ? {
140+ position: String (position .value ) ? position .value : null ,
135141 problem_list: ProblemRef .value .problemList ,
136142 ... paragraphFormRef .value ?.form ,
137143 }
138- : paragraphFormRef .value ?.form
144+ : {
145+ position: String (position .value ) ? position .value : null ,
146+ ... paragraphFormRef .value ?.form ,
147+ }
139148 paragraphApi .postParagraph (id , documentId , obj , loading ).then ((res ) => {
140149 dialogVisible .value = false
141150 emit (' refresh' )
0 commit comments