feat:
This commit is contained in:
parent
8490aaf91d
commit
203ac725a4
@ -98,9 +98,28 @@ const putChatRecordLog: (
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取标注段落列表信息
|
||||
* @param 参数
|
||||
* application_id, chart_id, chart_record_id
|
||||
*/
|
||||
const getMarkRecord: (
|
||||
applicaiton_id: String,
|
||||
chart_id: String,
|
||||
chart_record_id: String,
|
||||
loading?: Ref<boolean>
|
||||
) => Promise<Result<any>> = (applicaiton_id, chart_id, chart_record_id, loading) => {
|
||||
return get(
|
||||
`${prefix}/${applicaiton_id}/chat/${chart_id}/chat_record/${chart_record_id}/improve`,
|
||||
undefined,
|
||||
loading
|
||||
)
|
||||
}
|
||||
|
||||
export default {
|
||||
getChatLog,
|
||||
delChatLog,
|
||||
getChatRecordLog,
|
||||
putChatRecordLog
|
||||
putChatRecordLog,
|
||||
getMarkRecord
|
||||
}
|
||||
|
||||
@ -67,9 +67,10 @@ const delParagraph: (
|
||||
const postParagraph: (
|
||||
dataset_id: string,
|
||||
document_id: string,
|
||||
data: any
|
||||
) => Promise<Result<any>> = (dataset_id, document_id, data: any) => {
|
||||
return post(`${prefix}/${dataset_id}/document/${document_id}/paragraph`, data)
|
||||
data: any,
|
||||
loading?: Ref<boolean>
|
||||
) => Promise<Result<any>> = (dataset_id, document_id, data, loading) => {
|
||||
return post(`${prefix}/${dataset_id}/document/${document_id}/paragraph`, data, undefined, loading)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -92,9 +93,15 @@ const putParagraph: (
|
||||
dataset_id: string,
|
||||
document_id: string,
|
||||
paragraph_id: string,
|
||||
data: any
|
||||
) => Promise<Result<any>> = (dataset_id, document_id, paragraph_id, data: any) => {
|
||||
return put(`${prefix}/${dataset_id}/document/${document_id}/paragraph/${paragraph_id}`, data)
|
||||
data: any,
|
||||
loading?: Ref<boolean>
|
||||
) => Promise<Result<any>> = (dataset_id, document_id, paragraph_id, data, loading) => {
|
||||
return put(
|
||||
`${prefix}/${dataset_id}/document/${document_id}/paragraph/${paragraph_id}`,
|
||||
data,
|
||||
undefined,
|
||||
loading
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
</el-tooltip>
|
||||
|
||||
<el-tooltip v-else effect="dark" content="修改标注" placement="top">
|
||||
<el-button text @click="editContent(data)">
|
||||
<el-button text @click="editMark(data)">
|
||||
<AppIcon iconName="app-document-active" class="primary"></AppIcon>
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
@ -38,12 +38,14 @@
|
||||
<AppIcon iconName="app-oppose-color"></AppIcon>
|
||||
</el-button>
|
||||
<EditContentDialog ref="EditContentDialogRef" />
|
||||
<EditMarkDialog ref="EditMarkDialogRef" @refresh="refresh" />
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref, watch, onMounted } from 'vue'
|
||||
import { copyClick } from '@/utils/clipboard'
|
||||
import EditContentDialog from '@/views/log/component/EditContentDialog.vue'
|
||||
import EditMarkDialog from '@/views/log/component/EditMarkDialog.vue'
|
||||
import { datetimeFormat } from '@/utils/time'
|
||||
|
||||
const props = defineProps({
|
||||
@ -61,6 +63,7 @@ const props = defineProps({
|
||||
const emit = defineEmits(['update:data'])
|
||||
|
||||
const EditContentDialogRef = ref()
|
||||
const EditMarkDialogRef = ref()
|
||||
|
||||
const buttonData = ref(props.data)
|
||||
const loading = ref(false)
|
||||
@ -69,8 +72,13 @@ function editContent(data: any) {
|
||||
EditContentDialogRef.value.open(data)
|
||||
}
|
||||
|
||||
// function updateContent(data: any) {
|
||||
// emit('update:data', data)
|
||||
// }
|
||||
function editMark(data: any) {
|
||||
EditMarkDialogRef.value.open(data)
|
||||
}
|
||||
|
||||
function refresh() {
|
||||
buttonData.value.improve_paragraph_id_list = []
|
||||
emit('update:data', buttonData.value)
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" scoped></style>
|
||||
|
||||
@ -1,14 +1,40 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import paragraphApi from '@/api/paragraph'
|
||||
import type { Ref } from 'vue'
|
||||
|
||||
const useParagraphStore = defineStore({
|
||||
id: 'paragraph',
|
||||
state: () => ({}),
|
||||
actions: {
|
||||
async asyncPutParagraph(datasetId: string, documentId: string, paragraphId: string, data: any) {
|
||||
async asyncPutParagraph(
|
||||
datasetId: string,
|
||||
documentId: string,
|
||||
paragraphId: string,
|
||||
data: any,
|
||||
loading?: Ref<boolean>
|
||||
) {
|
||||
return new Promise((resolve, reject) => {
|
||||
paragraphApi
|
||||
.putParagraph(datasetId, documentId, paragraphId, data)
|
||||
.putParagraph(datasetId, documentId, paragraphId, data, loading)
|
||||
.then((data) => {
|
||||
resolve(data)
|
||||
})
|
||||
.catch((error) => {
|
||||
reject(error)
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
async asyncDelParagraph(
|
||||
datasetId: string,
|
||||
documentId: string,
|
||||
paragraphId: string,
|
||||
data: any,
|
||||
loading?: Ref<boolean>
|
||||
) {
|
||||
return new Promise((resolve, reject) => {
|
||||
paragraphApi
|
||||
.delParagraph(datasetId, documentId, paragraphId, loading)
|
||||
.then((data) => {
|
||||
resolve(data)
|
||||
})
|
||||
|
||||
@ -254,6 +254,10 @@ h4 {
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.pre-line {
|
||||
white-space: pre-line;
|
||||
}
|
||||
|
||||
/*
|
||||
内容部分 自适应高度
|
||||
*/
|
||||
|
||||
@ -72,7 +72,7 @@ const recordList = ref<chatType[]>([])
|
||||
|
||||
const paginationConfig = reactive({
|
||||
current_page: 1,
|
||||
page_size: 10,
|
||||
page_size: 20,
|
||||
total: 0
|
||||
})
|
||||
|
||||
|
||||
@ -1,10 +1,51 @@
|
||||
<template>
|
||||
<el-dialog title="修改标注" v-model="dialogVisible" width="600">
|
||||
<el-dialog title="修改标注" v-model="dialogVisible" width="600" class="edit-mark-dialog">
|
||||
<template #header="{ titleId, titleClass }">
|
||||
<div class="flex-between">
|
||||
<h4 :id="titleId" :class="titleClass">修改标注</h4>
|
||||
<div class="text-right">
|
||||
<el-button text @click="isEdit = true" v-if="!isEdit">
|
||||
<el-icon><EditPen /></el-icon>
|
||||
</el-button>
|
||||
<el-button text style="margin-left: 4px" @click="deleteParagraph">
|
||||
<el-icon><Delete /></el-icon>
|
||||
</el-button>
|
||||
<el-divider direction="vertical" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<el-scrollbar>
|
||||
<div style="min-height: 250px; max-height: 350px" v-loading="loading">
|
||||
<el-form
|
||||
v-if="isEdit"
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
label-position="top"
|
||||
require-asterisk-position="right"
|
||||
:rules="rules"
|
||||
@submit.prevent
|
||||
>
|
||||
<el-form-item prop="content">
|
||||
<el-input
|
||||
v-model="form.content"
|
||||
placeholder="请输入分段内容"
|
||||
maxlength="1024"
|
||||
show-word-limit
|
||||
:rows="15"
|
||||
type="textarea"
|
||||
>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<span v-else class="pre-line">{{ form?.content }}</span>
|
||||
</div>
|
||||
</el-scrollbar>
|
||||
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click.prevent="dialogVisible = false"> 取消 </el-button>
|
||||
<el-button type="primary" @click="submitForm(formRef)" :loading="loading"> 保存 </el-button>
|
||||
<span class="dialog-footer" v-if="isEdit">
|
||||
<el-button @click.prevent="isEdit = false"> 取消 </el-button>
|
||||
<el-button type="primary" @click="submit(formRef)" :loading="loading"> 保存 </el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
@ -14,117 +55,77 @@ import { ref, watch, reactive } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import logApi from '@/api/log'
|
||||
import type { CascaderProps } from 'element-plus'
|
||||
import useStore from '@/stores'
|
||||
|
||||
const { application, document } = useStore()
|
||||
|
||||
const props = defineProps({
|
||||
chartId: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
})
|
||||
import { MsgSuccess, MsgConfirm } from '@/utils/message'
|
||||
const isEdit = ref(false)
|
||||
|
||||
const route = useRoute()
|
||||
const {
|
||||
params: { id }
|
||||
} = route as any
|
||||
|
||||
const { paragraph } = useStore()
|
||||
|
||||
const emit = defineEmits(['refresh'])
|
||||
|
||||
const formRef = ref()
|
||||
|
||||
const dialogVisible = ref<boolean>(false)
|
||||
const loading = ref(false)
|
||||
|
||||
const form = ref<any>({
|
||||
chat_id: '',
|
||||
record_id: '',
|
||||
problem_text: '',
|
||||
title: '',
|
||||
content: '',
|
||||
document: []
|
||||
})
|
||||
const form = ref<any>({})
|
||||
|
||||
const rules = reactive<FormRules>({
|
||||
content: [{ required: true, message: '请输入内容', trigger: 'blur' }],
|
||||
document: [{ type: 'array', required: true, message: '请选择文档', trigger: 'change' }]
|
||||
content: [{ required: true, message: '请输入内容', trigger: 'blur' }]
|
||||
})
|
||||
|
||||
const datasetList = ref([])
|
||||
|
||||
watch(dialogVisible, (bool) => {
|
||||
if (!bool) {
|
||||
form.value = {
|
||||
chat_id: '',
|
||||
record_id: '',
|
||||
problem_text: '',
|
||||
title: '',
|
||||
content: '',
|
||||
document: []
|
||||
}
|
||||
form.value = {}
|
||||
}
|
||||
})
|
||||
|
||||
const LoadDocument: CascaderProps = {
|
||||
lazy: true,
|
||||
value: 'id',
|
||||
label: 'name',
|
||||
leaf: 'dataset_id',
|
||||
lazyLoad(node, resolve: any) {
|
||||
const { level, data } = node
|
||||
if (data?.id) {
|
||||
getDocument(data?.id as string, resolve)
|
||||
} else {
|
||||
getDataset(resolve)
|
||||
function deleteParagraph() {
|
||||
paragraph
|
||||
.asyncDelParagraph(form.value.dataset, form.value.document, form.value.id, loading)
|
||||
.then(() => {
|
||||
emit('refresh')
|
||||
MsgSuccess('删除成功')
|
||||
dialogVisible.value = false
|
||||
})
|
||||
}
|
||||
|
||||
function getMark(data: any) {
|
||||
logApi.getMarkRecord(id as string, data.chat, data.id, loading).then((res: any) => {
|
||||
if (res.data.length > 0) {
|
||||
form.value = res.data[0]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getDocument(id: string, resolve: any) {
|
||||
document.asyncGetAllDocument(id, loading).then((res: any) => {
|
||||
datasetList.value = res.data
|
||||
resolve(datasetList.value)
|
||||
})
|
||||
}
|
||||
|
||||
function getDataset(resolve: any) {
|
||||
application.asyncGetApplicationDataset(id, loading).then((res: any) => {
|
||||
datasetList.value = res.data
|
||||
resolve(datasetList.value)
|
||||
})
|
||||
}
|
||||
|
||||
const open = (data: any) => {
|
||||
form.value.chat_id = data.chat
|
||||
form.value.record_id = data.id
|
||||
form.value.problem_text = data.problem_text
|
||||
form.value.content = data.answer_text
|
||||
getMark(data)
|
||||
dialogVisible.value = true
|
||||
}
|
||||
const submitForm = async (formEl: FormInstance | undefined) => {
|
||||
const submit = async (formEl: FormInstance) => {
|
||||
if (!formEl) return
|
||||
await formEl.validate((valid, fields) => {
|
||||
if (valid) {
|
||||
const obj = {
|
||||
title: form.value.title,
|
||||
content: form.value.content
|
||||
}
|
||||
logApi
|
||||
.putChatRecordLog(
|
||||
id,
|
||||
form.value.chat_id,
|
||||
form.value.record_id,
|
||||
form.value.document[0],
|
||||
form.value.document[1],
|
||||
obj,
|
||||
paragraph
|
||||
.asyncPutParagraph(
|
||||
form.value.dataset,
|
||||
form.value.document,
|
||||
form.value.id,
|
||||
{
|
||||
content: form.value.content
|
||||
},
|
||||
loading
|
||||
)
|
||||
.then((res: any) => {
|
||||
.then((res) => {
|
||||
dialogVisible.value = false
|
||||
})
|
||||
} else {
|
||||
console.log('error submit!', fields)
|
||||
console.log('error submit!')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@ -90,18 +90,13 @@ const open = (data: any) => {
|
||||
}
|
||||
const submitHandle = async () => {
|
||||
if (await paragraphFormRef.value?.validate()) {
|
||||
loading.value = true
|
||||
if (problemId.value) {
|
||||
paragraph
|
||||
.asyncPutParagraph(id, documentId, problemId.value, paragraphFormRef.value?.form)
|
||||
.asyncPutParagraph(id, documentId, problemId.value, paragraphFormRef.value?.form, loading)
|
||||
.then((res: any) => {
|
||||
emit('refresh', res.data)
|
||||
loading.value = false
|
||||
isEdit.value = false
|
||||
})
|
||||
.catch(() => {
|
||||
loading.value = false
|
||||
})
|
||||
} else {
|
||||
const obj =
|
||||
ProblemRef.value.problemList.length > 0
|
||||
@ -110,16 +105,10 @@ const submitHandle = async () => {
|
||||
...paragraphFormRef.value?.form
|
||||
}
|
||||
: paragraphFormRef.value?.form
|
||||
paragraphApi
|
||||
.postParagraph(id, documentId, obj)
|
||||
.then((res) => {
|
||||
emit('refresh')
|
||||
loading.value = false
|
||||
dialogVisible.value = false
|
||||
})
|
||||
.catch(() => {
|
||||
loading.value = false
|
||||
})
|
||||
paragraphApi.postParagraph(id, documentId, obj, loading).then((res) => {
|
||||
emit('refresh')
|
||||
dialogVisible.value = false
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -127,14 +127,7 @@ function changeState(bool: Boolean, row: any) {
|
||||
is_active: bool
|
||||
}
|
||||
loading.value = true
|
||||
paragraph
|
||||
.asyncPutParagraph(id, documentId, row.id, obj)
|
||||
.then((res) => {
|
||||
loading.value = false
|
||||
})
|
||||
.catch(() => {
|
||||
loading.value = false
|
||||
})
|
||||
paragraph.asyncPutParagraph(id, documentId, row.id, obj, loading).then((res) => {})
|
||||
}
|
||||
|
||||
function deleteParagraph(row: any) {
|
||||
@ -143,7 +136,7 @@ function deleteParagraph(row: any) {
|
||||
confirmButtonClass: 'danger'
|
||||
})
|
||||
.then(() => {
|
||||
paragraphApi.delParagraph(id, documentId, row.id, loading).then(() => {
|
||||
paragraph.asyncDelParagraph(id, documentId, row.id, loading).then(() => {
|
||||
const index = paragraphDetail.value.findIndex((v) => v.id === row.id)
|
||||
paragraphDetail.value.splice(index, 1)
|
||||
MsgSuccess('删除成功')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user