refactor: clean up formatting and whitespace in chat-log.ts and EditMarkDialog.vue

This commit is contained in:
wxg0103 2025-07-12 09:50:20 +08:00
parent 4c9d024b67
commit a0e2403e77
2 changed files with 41 additions and 38 deletions

View File

@ -1,4 +1,4 @@
import { Result } from '@/request/Result' import {Result} from '@/request/Result'
import { import {
get, get,
post, post,
@ -10,14 +10,15 @@ import {
download, download,
exportFile, exportFile,
} from '@/request/index' } from '@/request/index'
import type { pageRequest } from '@/api/type/common' import type {pageRequest} from '@/api/type/common'
import type { ApplicationFormType } from '@/api/type/application' import type {ApplicationFormType} from '@/api/type/application'
import { type Ref } from 'vue' import {type Ref} from 'vue'
import useStore from '@/stores' import useStore from '@/stores'
const prefix: any = { _value: '/workspace/' }
const prefix: any = {_value: '/workspace/'}
Object.defineProperty(prefix, 'value', { Object.defineProperty(prefix, 'value', {
get: function () { get: function () {
const { user } = useStore() const {user} = useStore()
return this._value + user.getWorkspaceId() + '/application' return this._value + user.getWorkspaceId() + '/application'
}, },
}) })
@ -42,9 +43,9 @@ const postChatLogAddKnowledge: (
* @param * @param
* application_id * application_id
* param { * param {
"start_time": "string", "start_time": "string",
"end_time": "string", "end_time": "string",
} }
*/ */
const getChatLog: ( const getChatLog: (
application_id: String, application_id: String,
@ -73,7 +74,7 @@ const getChatRecordLog: (
) => Promise<Result<any>> = (application_id, chart_id, page, loading, order_asc) => { ) => Promise<Result<any>> = (application_id, chart_id, page, loading, order_asc) => {
return get( return get(
`${prefix.value}/${application_id}/chat/${chart_id}/chat_record/${page.current_page}/${page.page_size}`, `${prefix.value}/${application_id}/chat/${chart_id}/chat_record/${page.current_page}/${page.page_size}`,
{ order_asc: order_asc !== undefined ? order_asc : true }, {order_asc: order_asc !== undefined ? order_asc : true},
loading, loading,
) )
} }
@ -81,25 +82,21 @@ const getChatRecordLog: (
/** /**
* *
* @param * @param
* application_id, chart_id, chart_record_id, knowledge_id, document_id * application_id, chart_id, chart_record_id
*/ */
const getMarkChatRecord: ( const getMarkChatRecord: (
application_id: String, application_id: string,
chart_id: String, chart_id: string,
chart_record_id: String, chart_record_id: string,
knowledge_id: String,
document_id: String,
loading?: Ref<boolean>, loading?: Ref<boolean>,
) => Promise<Result<any>> = ( ) => Promise<Result<any>> = (
application_id, application_id,
chart_id, chart_id,
chart_record_id, chart_record_id,
knowledge_id,
document_id,
loading, loading,
) => { ) => {
return get( return get(
`${prefix.value}/${application_id}/chat/${chart_id}/chat_record/${chart_record_id}/knowledge/${knowledge_id}/document/${document_id}/improve`, `${prefix.value}/${application_id}/chat/${chart_id}/chat_record/${chart_record_id}/improve`,
undefined, undefined,
loading, loading,
) )
@ -110,10 +107,10 @@ const getMarkChatRecord: (
* @param * @param
* application_id, chart_id, chart_record_id, knowledge_id, document_id * application_id, chart_id, chart_record_id, knowledge_id, document_id
* data { * data {
"title": "string", "title": "string",
"content": "string", "content": "string",
"problem_text": "string" "problem_text": "string"
} }
*/ */
const putChatRecordLog: ( const putChatRecordLog: (
application_id: String, application_id: String,
@ -175,9 +172,9 @@ const delMarkChatRecord: (
* @param * @param
* application_id * application_id
* param { * param {
"start_time": "string", "start_time": "string",
"end_time": "string", "end_time": "string",
} }
*/ */
const postExportChatLog: ( const postExportChatLog: (
application_id: string, application_id: string,

View File

@ -12,12 +12,16 @@
<h4 :id="titleId" :class="titleClass">{{ $t('views.chatLog.editMark') }}</h4> <h4 :id="titleId" :class="titleClass">{{ $t('views.chatLog.editMark') }}</h4>
<div class="text-right"> <div class="text-right">
<el-button text @click="isEdit = true" v-if="!isEdit"> <el-button text @click="isEdit = true" v-if="!isEdit">
<el-icon><EditPen /></el-icon> <el-icon>
<EditPen/>
</el-icon>
</el-button> </el-button>
<el-button text style="margin-left: 4px" @click="deleteMark"> <el-button text style="margin-left: 4px" @click="deleteMark">
<el-icon><Delete /></el-icon> <el-icon>
<Delete/>
</el-icon>
</el-button> </el-button>
<el-divider direction="vertical" /> <el-divider direction="vertical"/>
</div> </div>
</div> </div>
</template> </template>
@ -60,17 +64,17 @@
</el-dialog> </el-dialog>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, watch, reactive } from 'vue' 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 chatLogApi from '@/api/application/chat-log' import chatLogApi from '@/api/application/chat-log'
import paragraphApi from '@/api/knowledge/paragraph' import paragraphApi from '@/api/knowledge/paragraph'
import { t } from '@/locales' import {t} from '@/locales'
import { MsgSuccess, MsgConfirm } from '@/utils/message' import {MsgSuccess, MsgConfirm} from '@/utils/message'
const route = useRoute() const route = useRoute()
const { const {
params: { id }, params: {id},
} = route as any } = route as any
const emit = defineEmits(['refresh']) const emit = defineEmits(['refresh'])
@ -86,7 +90,7 @@ const detail = ref<any>({})
const rules = reactive<FormRules>({ const rules = reactive<FormRules>({
content: [ content: [
{ required: true, message: t('views.chatLog.form.content.placeholder'), trigger: 'blur' }, {required: true, message: t('views.chatLog.form.content.placeholder'), trigger: 'blur'},
], ],
}) })
@ -116,8 +120,9 @@ function deleteMark() {
} }
function getMark(data: any) { function getMark(data: any) {
console.log(data)
chatLogApi chatLogApi
.getMarkChatRecord(id as string, data.chat_id, data.id, data.knowledge, data.document, loading) .getMarkChatRecord(id as string, data.chat_id, data.id, loading)
.then((res: any) => { .then((res: any) => {
if (res.data.length > 0) { if (res.data.length > 0) {
form.value = res.data[0] form.value = res.data[0]
@ -151,13 +156,14 @@ const submit = async (formEl: FormInstance) => {
}) })
} }
defineExpose({ open }) defineExpose({open})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.edit-mark-dialog { .edit-mark-dialog {
.el-dialog__header.show-close { .el-dialog__header.show-close {
padding-right: 15px; padding-right: 15px;
} }
.el-dialog__headerbtn { .el-dialog__headerbtn {
top: 13px; top: 13px;
} }