feat: 应用管理
This commit is contained in:
parent
a99cca7521
commit
ab7c789e1b
@ -72,14 +72,34 @@ const postChatMessage: (chat_id: string, message: string) => Promise<any> = (cha
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
const postApplication: ( data: ApplicationFormType, loading?: Ref<boolean> ) => Promise<Result<any>> = (data, loading) => {
|
const postApplication: (
|
||||||
|
data: ApplicationFormType,
|
||||||
|
loading?: Ref<boolean>
|
||||||
|
) => Promise<Result<any>> = (data, loading) => {
|
||||||
return post(`${prefix}`, data, undefined, loading)
|
return post(`${prefix}`, data, undefined, loading)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除应用
|
||||||
|
* @param 参数 applicaiton_id
|
||||||
|
*/
|
||||||
|
const delApplication: (applicaiton_id: String) => Promise<Result<boolean>> = (applicaiton_id) => {
|
||||||
|
return del(`${prefix}/${applicaiton_id}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应用详情
|
||||||
|
* @param 参数 applicaiton_id
|
||||||
|
*/
|
||||||
|
const getApplicationDetail: (applicaiton_id: string) => Promise<Result<any>> = (applicaiton_id) => {
|
||||||
|
return get(`${prefix}/${applicaiton_id}`)
|
||||||
|
}
|
||||||
export default {
|
export default {
|
||||||
getAllAppilcation,
|
getAllAppilcation,
|
||||||
getApplication,
|
getApplication,
|
||||||
postApplication,
|
postApplication,
|
||||||
postChatOpen,
|
postChatOpen,
|
||||||
postChatMessage
|
postChatMessage,
|
||||||
|
delApplication,
|
||||||
|
getApplicationDetail
|
||||||
}
|
}
|
||||||
|
|||||||
@ -77,22 +77,9 @@
|
|||||||
:disabled="loading"
|
:disabled="loading"
|
||||||
/>
|
/>
|
||||||
<div class="operate" v-loading="loading">
|
<div class="operate" v-loading="loading">
|
||||||
<el-button
|
<el-button text class="sent-button" :disabled="isDisabledChart" @click="sendChatHandle">
|
||||||
text
|
<img v-show="isDisabledChart" src="@/assets/icon_send.svg" alt="" />
|
||||||
class="sent-button"
|
<img v-show="!isDisabledChart" src="@/assets/icon_send_colorful.svg" alt="" />
|
||||||
:disabled="!(inputValue && data?.name && data?.model_id)"
|
|
||||||
@click="sendChatHandle"
|
|
||||||
>
|
|
||||||
<img
|
|
||||||
v-show="!(inputValue && data?.name && data?.model_id)"
|
|
||||||
src="@/assets/icon_send.svg"
|
|
||||||
alt=""
|
|
||||||
/>
|
|
||||||
<img
|
|
||||||
v-show="inputValue && data?.name && data?.model_id"
|
|
||||||
src="@/assets/icon_send_colorful.svg"
|
|
||||||
alt=""
|
|
||||||
/>
|
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -100,7 +87,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, nextTick, onUpdated } from 'vue'
|
import { ref, nextTick, onUpdated, computed } from 'vue'
|
||||||
import applicationApi from '@/api/application'
|
import applicationApi from '@/api/application'
|
||||||
import { ChatManage, type chatType } from '@/api/type/application'
|
import { ChatManage, type chatType } from '@/api/type/application'
|
||||||
import { randomId } from '@/utils/utils'
|
import { randomId } from '@/utils/utils'
|
||||||
@ -119,6 +106,10 @@ const inputValue = ref('')
|
|||||||
const chartOpenId = ref('')
|
const chartOpenId = ref('')
|
||||||
const chatList = ref<chatType[]>([])
|
const chatList = ref<chatType[]>([])
|
||||||
|
|
||||||
|
const isDisabledChart = computed(
|
||||||
|
() => !(inputValue.value && props.data?.name && props.data?.model_id)
|
||||||
|
)
|
||||||
|
|
||||||
function quickProblemHandel(val: string) {
|
function quickProblemHandel(val: string) {
|
||||||
inputValue.value = val
|
inputValue.value = val
|
||||||
}
|
}
|
||||||
@ -127,8 +118,9 @@ function sendChatHandle(event: any) {
|
|||||||
if (!event.ctrlKey) {
|
if (!event.ctrlKey) {
|
||||||
// 如果没有按下组合键ctrl,则会阻止默认事件
|
// 如果没有按下组合键ctrl,则会阻止默认事件
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
if (!isDisabledChart.value) {
|
||||||
chatMessage()
|
chatMessage()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// 如果同时按下ctrl+回车键,则会换行
|
// 如果同时按下ctrl+回车键,则会换行
|
||||||
inputValue.value += '\n'
|
inputValue.value += '\n'
|
||||||
|
|||||||
@ -16,6 +16,19 @@ const useApplicationStore = defineStore({
|
|||||||
reject(error)
|
reject(error)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
async asyncGetApplicationDetail(id: string) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
applicationApi
|
||||||
|
.getApplicationDetail(id)
|
||||||
|
.then((data) => {
|
||||||
|
resolve(data)
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
reject(error)
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@ -139,9 +139,9 @@
|
|||||||
</el-scrollbar>
|
</el-scrollbar>
|
||||||
</div>
|
</div>
|
||||||
<div class="text-right border-t p-16">
|
<div class="text-right border-t p-16">
|
||||||
<el-button @click="router.push({ path: `/application` })"> 取消 </el-button>
|
<el-button v-if="!id" @click="router.push({ path: `/application` })"> 取消 </el-button>
|
||||||
<el-button type="primary" @click="submit(applicationFormRef)" :disabled="loading">
|
<el-button type="primary" @click="submit(applicationFormRef)" :disabled="loading">
|
||||||
创建
|
{{ id ? '保存' : '创建' }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
</el-col>
|
</el-col>
|
||||||
@ -171,7 +171,7 @@ import type { Provider } from '@/api/type/model'
|
|||||||
import { realatedObject } from '@/utils/utils'
|
import { realatedObject } from '@/utils/utils'
|
||||||
import { MsgSuccess } from '@/utils/message'
|
import { MsgSuccess } from '@/utils/message'
|
||||||
import useStore from '@/stores'
|
import useStore from '@/stores'
|
||||||
const { model, dataset } = useStore()
|
const { model, dataset, application } = useStore()
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
@ -241,6 +241,19 @@ function openDatasetDialog() {
|
|||||||
AddDatasetDialogRef.value.open(applicationForm.dataset_id_list)
|
AddDatasetDialogRef.value.open(applicationForm.dataset_id_list)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getDetail() {
|
||||||
|
loading.value = true
|
||||||
|
application
|
||||||
|
.asyncGetApplicationDetail(id)
|
||||||
|
.then((res) => {
|
||||||
|
// detail.value = res.data
|
||||||
|
loading.value = false
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
loading.value = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function getDataset() {
|
function getDataset() {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
dataset
|
dataset
|
||||||
@ -281,6 +294,9 @@ function getProvider() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
if (id) {
|
||||||
|
getDetail()
|
||||||
|
}
|
||||||
getProvider()
|
getProvider()
|
||||||
getModel()
|
getModel()
|
||||||
getDataset()
|
getDataset()
|
||||||
|
|||||||
@ -71,7 +71,7 @@
|
|||||||
<span>运行中</span>
|
<span>运行中</span>
|
||||||
<!-- <el-switch v-model="item.status" @change="changeState($event, item)" /> -->
|
<!-- <el-switch v-model="item.status" @change="changeState($event, item)" /> -->
|
||||||
</div>
|
</div>
|
||||||
<el-dropdown-item divided>删除</el-dropdown-item>
|
<el-dropdown-item divided @click="deleteApplication(item)">删除</el-dropdown-item>
|
||||||
</el-dropdown-menu>
|
</el-dropdown-menu>
|
||||||
</template>
|
</template>
|
||||||
</el-dropdown>
|
</el-dropdown>
|
||||||
@ -88,9 +88,8 @@
|
|||||||
import { ref, onMounted, reactive } from 'vue'
|
import { ref, onMounted, reactive } from 'vue'
|
||||||
import applicationApi from '@/api/application'
|
import applicationApi from '@/api/application'
|
||||||
import type { pageRequest } from '@/api/type/common'
|
import type { pageRequest } from '@/api/type/common'
|
||||||
// import { MsgSuccess, MsgConfirm } from '@/utils/message'
|
import { MsgSuccess, MsgConfirm } from '@/utils/message'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
// import { numberFormat } from '@/utils/utils'
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
@ -102,7 +101,6 @@ const pageConfig = reactive<pageRequest>({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const applicationList = ref<any[]>([])
|
const applicationList = ref<any[]>([])
|
||||||
const state = ref(false)
|
|
||||||
|
|
||||||
function loadDataset() {}
|
function loadDataset() {}
|
||||||
|
|
||||||
@ -111,29 +109,29 @@ function search() {
|
|||||||
getList()
|
getList()
|
||||||
}
|
}
|
||||||
|
|
||||||
// function deleteDateset(row: any) {
|
function deleteApplication(row: any) {
|
||||||
// MsgConfirm(
|
MsgConfirm(
|
||||||
// `是否删除数据集:${row.name} ?`,
|
`是否删除应用:${row.name} ?`,
|
||||||
// `此数据集关联 ${row.char_length} 个应用,删除后无法恢复,请谨慎操作。`,
|
`删除后该应用将不再提供服务,请谨慎操作。`,
|
||||||
// {
|
{
|
||||||
// confirmButtonText: '删除',
|
confirmButtonText: '删除',
|
||||||
// confirmButtonClass: 'danger'
|
confirmButtonClass: 'danger'
|
||||||
// }
|
}
|
||||||
// )
|
)
|
||||||
// .then(() => {
|
.then(() => {
|
||||||
// loading.value = true
|
loading.value = true
|
||||||
// datasetApi
|
applicationApi
|
||||||
// .delDateset(row.id)
|
.delApplication(row.id)
|
||||||
// .then(() => {
|
.then(() => {
|
||||||
// MsgSuccess('删除成功')
|
MsgSuccess('删除成功')
|
||||||
// getList()
|
getList()
|
||||||
// })
|
})
|
||||||
// .catch(() => {
|
.catch(() => {
|
||||||
// loading.value = false
|
loading.value = false
|
||||||
// })
|
})
|
||||||
// })
|
})
|
||||||
// .catch(() => {})
|
.catch(() => {})
|
||||||
// }
|
}
|
||||||
|
|
||||||
// function changeState(bool: Boolean, row: any) {
|
// function changeState(bool: Boolean, row: any) {
|
||||||
// const obj = {
|
// const obj = {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user