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 {
|
export default {
|
||||||
getChatLog,
|
getChatLog,
|
||||||
delChatLog,
|
delChatLog,
|
||||||
getChatRecordLog,
|
getChatRecordLog,
|
||||||
putChatRecordLog
|
putChatRecordLog,
|
||||||
|
getMarkRecord
|
||||||
}
|
}
|
||||||
|
|||||||
@ -67,9 +67,10 @@ const delParagraph: (
|
|||||||
const postParagraph: (
|
const postParagraph: (
|
||||||
dataset_id: string,
|
dataset_id: string,
|
||||||
document_id: string,
|
document_id: string,
|
||||||
data: any
|
data: any,
|
||||||
) => Promise<Result<any>> = (dataset_id, document_id, data: any) => {
|
loading?: Ref<boolean>
|
||||||
return post(`${prefix}/${dataset_id}/document/${document_id}/paragraph`, data)
|
) => 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,
|
dataset_id: string,
|
||||||
document_id: string,
|
document_id: string,
|
||||||
paragraph_id: string,
|
paragraph_id: string,
|
||||||
data: any
|
data: any,
|
||||||
) => Promise<Result<any>> = (dataset_id, document_id, paragraph_id, data: any) => {
|
loading?: Ref<boolean>
|
||||||
return put(`${prefix}/${dataset_id}/document/${document_id}/paragraph/${paragraph_id}`, data)
|
) => 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>
|
||||||
|
|
||||||
<el-tooltip v-else effect="dark" content="修改标注" placement="top">
|
<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>
|
<AppIcon iconName="app-document-active" class="primary"></AppIcon>
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
@ -38,12 +38,14 @@
|
|||||||
<AppIcon iconName="app-oppose-color"></AppIcon>
|
<AppIcon iconName="app-oppose-color"></AppIcon>
|
||||||
</el-button>
|
</el-button>
|
||||||
<EditContentDialog ref="EditContentDialogRef" />
|
<EditContentDialog ref="EditContentDialogRef" />
|
||||||
|
<EditMarkDialog ref="EditMarkDialogRef" @refresh="refresh" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { reactive, ref, watch, onMounted } from 'vue'
|
import { reactive, ref, watch, onMounted } from 'vue'
|
||||||
import { copyClick } from '@/utils/clipboard'
|
import { copyClick } from '@/utils/clipboard'
|
||||||
import EditContentDialog from '@/views/log/component/EditContentDialog.vue'
|
import EditContentDialog from '@/views/log/component/EditContentDialog.vue'
|
||||||
|
import EditMarkDialog from '@/views/log/component/EditMarkDialog.vue'
|
||||||
import { datetimeFormat } from '@/utils/time'
|
import { datetimeFormat } from '@/utils/time'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@ -61,6 +63,7 @@ const props = defineProps({
|
|||||||
const emit = defineEmits(['update:data'])
|
const emit = defineEmits(['update:data'])
|
||||||
|
|
||||||
const EditContentDialogRef = ref()
|
const EditContentDialogRef = ref()
|
||||||
|
const EditMarkDialogRef = ref()
|
||||||
|
|
||||||
const buttonData = ref(props.data)
|
const buttonData = ref(props.data)
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
@ -69,8 +72,13 @@ function editContent(data: any) {
|
|||||||
EditContentDialogRef.value.open(data)
|
EditContentDialogRef.value.open(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
// function updateContent(data: any) {
|
function editMark(data: any) {
|
||||||
// emit('update:data', data)
|
EditMarkDialogRef.value.open(data)
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
function refresh() {
|
||||||
|
buttonData.value.improve_paragraph_id_list = []
|
||||||
|
emit('update:data', buttonData.value)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped></style>
|
<style lang="scss" scoped></style>
|
||||||
|
|||||||
@ -1,14 +1,40 @@
|
|||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import paragraphApi from '@/api/paragraph'
|
import paragraphApi from '@/api/paragraph'
|
||||||
|
import type { Ref } from 'vue'
|
||||||
|
|
||||||
const useParagraphStore = defineStore({
|
const useParagraphStore = defineStore({
|
||||||
id: 'paragraph',
|
id: 'paragraph',
|
||||||
state: () => ({}),
|
state: () => ({}),
|
||||||
actions: {
|
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) => {
|
return new Promise((resolve, reject) => {
|
||||||
paragraphApi
|
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) => {
|
.then((data) => {
|
||||||
resolve(data)
|
resolve(data)
|
||||||
})
|
})
|
||||||
|
|||||||
@ -254,6 +254,10 @@ h4 {
|
|||||||
word-break: break-all;
|
word-break: break-all;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.pre-line {
|
||||||
|
white-space: pre-line;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
内容部分 自适应高度
|
内容部分 自适应高度
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -72,7 +72,7 @@ const recordList = ref<chatType[]>([])
|
|||||||
|
|
||||||
const paginationConfig = reactive({
|
const paginationConfig = reactive({
|
||||||
current_page: 1,
|
current_page: 1,
|
||||||
page_size: 10,
|
page_size: 20,
|
||||||
total: 0
|
total: 0
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -1,10 +1,51 @@
|
|||||||
<template>
|
<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>
|
<template #footer>
|
||||||
<span class="dialog-footer">
|
<span class="dialog-footer" v-if="isEdit">
|
||||||
<el-button @click.prevent="dialogVisible = false"> 取消 </el-button>
|
<el-button @click.prevent="isEdit = false"> 取消 </el-button>
|
||||||
<el-button type="primary" @click="submitForm(formRef)" :loading="loading"> 保存 </el-button>
|
<el-button type="primary" @click="submit(formRef)" :loading="loading"> 保存 </el-button>
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
@ -14,117 +55,77 @@ import { ref, watch, reactive } from 'vue'
|
|||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
import type { FormInstance, FormRules } from 'element-plus'
|
import type { FormInstance, FormRules } from 'element-plus'
|
||||||
import logApi from '@/api/log'
|
import logApi from '@/api/log'
|
||||||
import type { CascaderProps } from 'element-plus'
|
|
||||||
import useStore from '@/stores'
|
import useStore from '@/stores'
|
||||||
|
import { MsgSuccess, MsgConfirm } from '@/utils/message'
|
||||||
const { application, document } = useStore()
|
const isEdit = ref(false)
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
chartId: {
|
|
||||||
type: String,
|
|
||||||
default: ''
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const {
|
const {
|
||||||
params: { id }
|
params: { id }
|
||||||
} = route as any
|
} = route as any
|
||||||
|
|
||||||
|
const { paragraph } = useStore()
|
||||||
|
|
||||||
|
const emit = defineEmits(['refresh'])
|
||||||
|
|
||||||
const formRef = ref()
|
const formRef = ref()
|
||||||
|
|
||||||
const dialogVisible = ref<boolean>(false)
|
const dialogVisible = ref<boolean>(false)
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
|
|
||||||
const form = ref<any>({
|
const form = ref<any>({})
|
||||||
chat_id: '',
|
|
||||||
record_id: '',
|
|
||||||
problem_text: '',
|
|
||||||
title: '',
|
|
||||||
content: '',
|
|
||||||
document: []
|
|
||||||
})
|
|
||||||
|
|
||||||
const rules = reactive<FormRules>({
|
const rules = reactive<FormRules>({
|
||||||
content: [{ required: true, message: '请输入内容', trigger: 'blur' }],
|
content: [{ required: true, message: '请输入内容', trigger: 'blur' }]
|
||||||
document: [{ type: 'array', required: true, message: '请选择文档', trigger: 'change' }]
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const datasetList = ref([])
|
|
||||||
|
|
||||||
watch(dialogVisible, (bool) => {
|
watch(dialogVisible, (bool) => {
|
||||||
if (!bool) {
|
if (!bool) {
|
||||||
form.value = {
|
form.value = {}
|
||||||
chat_id: '',
|
|
||||||
record_id: '',
|
|
||||||
problem_text: '',
|
|
||||||
title: '',
|
|
||||||
content: '',
|
|
||||||
document: []
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const LoadDocument: CascaderProps = {
|
function deleteParagraph() {
|
||||||
lazy: true,
|
paragraph
|
||||||
value: 'id',
|
.asyncDelParagraph(form.value.dataset, form.value.document, form.value.id, loading)
|
||||||
label: 'name',
|
.then(() => {
|
||||||
leaf: 'dataset_id',
|
emit('refresh')
|
||||||
lazyLoad(node, resolve: any) {
|
MsgSuccess('删除成功')
|
||||||
const { level, data } = node
|
dialogVisible.value = false
|
||||||
if (data?.id) {
|
})
|
||||||
getDocument(data?.id as string, resolve)
|
}
|
||||||
} else {
|
|
||||||
getDataset(resolve)
|
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) => {
|
const open = (data: any) => {
|
||||||
form.value.chat_id = data.chat
|
getMark(data)
|
||||||
form.value.record_id = data.id
|
|
||||||
form.value.problem_text = data.problem_text
|
|
||||||
form.value.content = data.answer_text
|
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
}
|
}
|
||||||
const submitForm = async (formEl: FormInstance | undefined) => {
|
const submit = async (formEl: FormInstance) => {
|
||||||
if (!formEl) return
|
if (!formEl) return
|
||||||
await formEl.validate((valid, fields) => {
|
await formEl.validate((valid, fields) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
const obj = {
|
paragraph
|
||||||
title: form.value.title,
|
.asyncPutParagraph(
|
||||||
content: form.value.content
|
form.value.dataset,
|
||||||
}
|
form.value.document,
|
||||||
logApi
|
form.value.id,
|
||||||
.putChatRecordLog(
|
{
|
||||||
id,
|
content: form.value.content
|
||||||
form.value.chat_id,
|
},
|
||||||
form.value.record_id,
|
|
||||||
form.value.document[0],
|
|
||||||
form.value.document[1],
|
|
||||||
obj,
|
|
||||||
loading
|
loading
|
||||||
)
|
)
|
||||||
.then((res: any) => {
|
.then((res) => {
|
||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
console.log('error submit!', fields)
|
console.log('error submit!')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -90,18 +90,13 @@ const open = (data: any) => {
|
|||||||
}
|
}
|
||||||
const submitHandle = async () => {
|
const submitHandle = async () => {
|
||||||
if (await paragraphFormRef.value?.validate()) {
|
if (await paragraphFormRef.value?.validate()) {
|
||||||
loading.value = true
|
|
||||||
if (problemId.value) {
|
if (problemId.value) {
|
||||||
paragraph
|
paragraph
|
||||||
.asyncPutParagraph(id, documentId, problemId.value, paragraphFormRef.value?.form)
|
.asyncPutParagraph(id, documentId, problemId.value, paragraphFormRef.value?.form, loading)
|
||||||
.then((res: any) => {
|
.then((res: any) => {
|
||||||
emit('refresh', res.data)
|
emit('refresh', res.data)
|
||||||
loading.value = false
|
|
||||||
isEdit.value = false
|
isEdit.value = false
|
||||||
})
|
})
|
||||||
.catch(() => {
|
|
||||||
loading.value = false
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
const obj =
|
const obj =
|
||||||
ProblemRef.value.problemList.length > 0
|
ProblemRef.value.problemList.length > 0
|
||||||
@ -110,16 +105,10 @@ const submitHandle = async () => {
|
|||||||
...paragraphFormRef.value?.form
|
...paragraphFormRef.value?.form
|
||||||
}
|
}
|
||||||
: paragraphFormRef.value?.form
|
: paragraphFormRef.value?.form
|
||||||
paragraphApi
|
paragraphApi.postParagraph(id, documentId, obj, loading).then((res) => {
|
||||||
.postParagraph(id, documentId, obj)
|
emit('refresh')
|
||||||
.then((res) => {
|
dialogVisible.value = false
|
||||||
emit('refresh')
|
})
|
||||||
loading.value = false
|
|
||||||
dialogVisible.value = false
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
loading.value = false
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -127,14 +127,7 @@ function changeState(bool: Boolean, row: any) {
|
|||||||
is_active: bool
|
is_active: bool
|
||||||
}
|
}
|
||||||
loading.value = true
|
loading.value = true
|
||||||
paragraph
|
paragraph.asyncPutParagraph(id, documentId, row.id, obj, loading).then((res) => {})
|
||||||
.asyncPutParagraph(id, documentId, row.id, obj)
|
|
||||||
.then((res) => {
|
|
||||||
loading.value = false
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
loading.value = false
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteParagraph(row: any) {
|
function deleteParagraph(row: any) {
|
||||||
@ -143,7 +136,7 @@ function deleteParagraph(row: any) {
|
|||||||
confirmButtonClass: 'danger'
|
confirmButtonClass: 'danger'
|
||||||
})
|
})
|
||||||
.then(() => {
|
.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)
|
const index = paragraphDetail.value.findIndex((v) => v.id === row.id)
|
||||||
paragraphDetail.value.splice(index, 1)
|
paragraphDetail.value.splice(index, 1)
|
||||||
MsgSuccess('删除成功')
|
MsgSuccess('删除成功')
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user