Commit 21f6a70c authored by tyyin lan's avatar tyyin lan

chore(智能表单): 出差表单功能完善

parent 3618fd7f
......@@ -163,6 +163,8 @@ common_module:
database_QA_executed_successfully: 'Database Q&A executed successfully'
input_parameter: 'Input parameter'
output_parameter: 'Output parameter'
submit_successfully: 'Submit successfully'
submit_failure: 'Submit failure'
dialogue_module:
continue_question_message: 'You can keep asking questions'
......
......@@ -162,6 +162,8 @@ common_module:
database_QA_executed_successfully: '数据库问答执行成功'
input_parameter: '输入参数'
output_parameter: '输出参数'
submit_successfully: '提交成功'
submit_failure: '提交失败'
dialogue_module:
continue_question_message: '你可以继续提问'
......
......@@ -162,6 +162,8 @@ common_module:
database_QA_executed_successfully: '數據庫問答執行成功'
input_parameter: '輸入參數'
output_parameter: '輸出參數'
submit_successfully: '提交成功'
submit_failure: '提交失敗'
dialogue_module:
continue_question_message: '你可以繼續提問'
......
<script setup lang="ts">
import { computed, inject, readonly, ref, toRaw, useTemplateRef, watch, watchEffect } from 'vue'
import type { MessageItemInterface } from '../../types'
import type { MessageItemInterface } from '../../../types'
import MarkdownRender from '@/components/markdown-render/markdown-render.vue'
import type { FormInst, FormRules, FormItemRule } from 'naive-ui'
import { useI18n } from 'vue-i18n'
import { useSystemLanguageStore } from '@/store/modules/system-language'
import MessageBubbleLoading from '../message-bubble-loading.vue'
import MessageBubbleLoading from '@/views/home/components/message-bubble-loading.vue'
import isEmail from 'validator/es/lib/isEmail'
import type { BusinessTripForm, ResponseBusinessTripForm } from './types'
import { businessTripFormParser, businessTripFormReturner } from '../../utils/smart-forms'
import type { BusinessTripFormInterface, ResponseBusinessTripFormInterface } from '../types/business-trip-form'
import {
businessTripFormParser,
businessTripFormReturner,
} from '@/views/home/components/smart-forms/utils/business-trip-form'
import { fetchBusinessTripFormSubmit } from '@/apis/smart-forms'
interface Props {
......@@ -70,7 +73,7 @@ const formRules = readonly<FormRules>({
},
})
const formModel = ref<BusinessTripForm>({
const formModel = ref<BusinessTripFormInterface>({
objective: 'CustomerVisits',
travelLocation: '',
departureTime: null,
......@@ -108,7 +111,7 @@ watch(
() => props.messageItem.smartFormInfo,
(smartFormInfo) => {
if (smartFormInfo && smartFormInfo.params) {
let config: Partial<ResponseBusinessTripForm> = {}
let config: Partial<ResponseBusinessTripFormInterface> = {}
try {
config = JSON.parse(smartFormInfo.params)
......@@ -151,7 +154,10 @@ function handleSubmitForm() {
fetchBusinessTripFormSubmit(businessTripFormReturner(toRaw(formModel.value)))
.then((res) => {
if (res.code !== 0) return ''
if (res.code !== 0) {
window.$message.error(t('common_module.submit_failure'))
return
}
updateSpecifyMessageItem(messageItemId, {
smartFormInfo: {
......@@ -159,6 +165,8 @@ function handleSubmitForm() {
isDisabled: true,
},
})
window.$message.success(t('common_module.submit_successfully'))
})
.finally(() => {
submitFormBtnLoading.value = false
......@@ -172,12 +180,7 @@ function handleSubmitForm() {
<div class="ml-[11px] overflow-hidden">
<div class="mb-[7px] text-[12px] text-[#999]">{{ messageAuthor }}</div>
<div
:class="{
'min-w-[420px]': !systemLanguageStore.isEnglishLanguage,
'min-w-[500px]': systemLanguageStore.isEnglishLanguage,
}"
>
<div>
<div
class="box-content min-h-[21px] min-w-[10px] max-w-full rounded-[10px] border border-[#9EA3FF] bg-[#777EF9] px-[15px] py-[14px] text-justify"
:class="{
......@@ -185,10 +188,7 @@ function handleSubmitForm() {
'!min-w-[80px]': messageItem.isAnswerLoading,
}"
>
<div
v-if="messageItem.isAnswerLoading && !messageItem.content"
class="flex h-[21px] items-center justify-center"
>
<div v-if="messageItem.isAnswerLoading" class="flex h-[21px] items-center justify-center">
<MessageBubbleLoading :active-color="currentBubbleTextColor" />
</div>
<template v-else>
......@@ -212,9 +212,12 @@ function handleSubmitForm() {
</div>
<div
v-if="!messageItem.isAnswerLoading"
class="mt-[10px] box-content min-h-[21px] min-w-[10px] max-w-full rounded-[10px] border border-[#9EA3FF] bg-[#777EF9] px-[15px] py-[14px] text-justify"
:class="{
'!bg-[#fff]': isAgentMessage,
'min-w-[420px]': !systemLanguageStore.isEnglishLanguage,
'min-w-[500px]': systemLanguageStore.isEnglishLanguage,
}"
>
<h2 class="font-600 text-[15px] text-[#0B7DFF]">{{ t('smart_forms_module.business_trip_form.title') }}</h2>
......
<script setup lang="ts">
import { readonly, ref } from 'vue'
import type { MessageItemInterface } from '../../types'
import type { MessageItemInterface } from '@/views/home/types'
import MarkdownRender from '@/components/markdown-render/markdown-render.vue'
import type { FormRules } from 'naive-ui'
import MessageBubbleLoading from '../message-bubble-loading.vue'
import MessageBubbleLoading from '@/views/home/components/message-bubble-loading.vue'
interface Props {
isAgentMessage: boolean
......
<script setup lang="ts">
import type { MessageItemInterface } from '../../types'
import BusinessTripForm from './business-trip-form.vue'
import BusinessTripForm from './components/business-trip-form.vue'
// import BusinessTripReimbursementForm from './business-trip-reimbursement-form.vue'
interface Props {
......
export interface ResponseBusinessTripForm {
export interface ResponseBusinessTripFormInterface {
purpose: string
place: string
departureDate: string
......@@ -11,7 +11,7 @@ export interface ResponseBusinessTripForm {
totalBudget: string
}
export interface BusinessTripForm {
export interface BusinessTripFormInterface {
objective: string
travelLocation: string
departureTime: number | null
......
import type { SmartFormTypes } from '../types'
import { ResponseBusinessTripForm, BusinessTripForm } from '@/views/home/components/smart-forms/types'
import type { SmartFormTypes } from '@/views/home/types'
import type {
ResponseBusinessTripFormInterface,
BusinessTripFormInterface,
} from '@/views/home/components/smart-forms/types/business-trip-form'
export function smartFormTypeConverter(type: 'travelForm'): SmartFormTypes {
switch (type) {
......@@ -8,7 +11,7 @@ export function smartFormTypeConverter(type: 'travelForm'): SmartFormTypes {
}
}
export function businessTripFormParser(resForm: Partial<ResponseBusinessTripForm>) {
export function businessTripFormParser(resForm: Partial<ResponseBusinessTripFormInterface>) {
return {
objective: resForm.purpose || 'CustomerVisits',
travelLocation: resForm.place || '',
......@@ -24,7 +27,7 @@ export function businessTripFormParser(resForm: Partial<ResponseBusinessTripForm
}
}
export function businessTripFormReturner(form: BusinessTripForm) {
export function businessTripFormReturner(form: BusinessTripFormInterface) {
return {
purpose: form.objective,
place: form.travelLocation,
......
......@@ -153,15 +153,6 @@ function messageListScrollToBottom() {
}
function onAddMessageItem(messageId: string, messageItem: MessageItemInterface) {
/* 重置智能表单项目 */
if (messageItem.smartFormInfo && messageItem.smartFormInfo.type) {
messageList.value.forEach((messageInfo) => {
if (messageInfo.smartFormInfo && messageInfo.smartFormInfo.type === messageItem.smartFormInfo?.type) {
messageInfo.smartFormInfo.isDisabled = true
}
})
}
messageList.value.set(messageId, messageItem)
}
......@@ -245,7 +236,16 @@ function onClearSessionReferenceFile() {
footerOperationRef.value && footerOperationRef.value.clearSessionReferenceFile()
}
function onSmartFormsStatusFreeze() {}
function onSmartFormsStatusFreezeCheck(messageItem: MessageItemInterface) {
/* 重置智能表单项目 */
if (messageItem.smartFormInfo && messageItem.smartFormInfo.type) {
messageList.value.forEach((item) => {
if (item.smartFormInfo && item.smartFormInfo.type === messageItem.smartFormInfo?.type) {
item.smartFormInfo.isDisabled = true
}
})
}
}
</script>
<template>
......@@ -283,7 +283,7 @@ function onSmartFormsStatusFreeze() {}
@delete-message-item="onDeleteMessageItem"
@create-new-session="onCreateNewSession"
@history-record-list-update="onHistoryRecordListUpdate"
@smart-forms-status-freeze="onSmartFormsStatusFreeze"
@smart-forms-status-freeze-check="onSmartFormsStatusFreezeCheck"
/>
</div>
......
......@@ -162,6 +162,8 @@ declare namespace I18n {
database_QA_executed_successfully: string
input_parameter: string
output_parameter: string
submit_successfully: string
submit_failure: string
dialogue_module: {
continue_question_message: string
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment