feat: 应用管理

This commit is contained in:
wangdan-fit2cloud 2023-11-29 11:25:14 +08:00
parent a99cca7521
commit ab7c789e1b
5 changed files with 90 additions and 51 deletions

View File

@ -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)
}
/**
*
* @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 {
getAllAppilcation,
getApplication,
postApplication,
postChatOpen,
postChatMessage
postChatMessage,
delApplication,
getApplicationDetail
}

View File

@ -77,22 +77,9 @@
:disabled="loading"
/>
<div class="operate" v-loading="loading">
<el-button
text
class="sent-button"
: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 text class="sent-button" :disabled="isDisabledChart" @click="sendChatHandle">
<img v-show="isDisabledChart" src="@/assets/icon_send.svg" alt="" />
<img v-show="!isDisabledChart" src="@/assets/icon_send_colorful.svg" alt="" />
</el-button>
</div>
</div>
@ -100,7 +87,7 @@
</div>
</template>
<script setup lang="ts">
import { ref, nextTick, onUpdated } from 'vue'
import { ref, nextTick, onUpdated, computed } from 'vue'
import applicationApi from '@/api/application'
import { ChatManage, type chatType } from '@/api/type/application'
import { randomId } from '@/utils/utils'
@ -119,6 +106,10 @@ const inputValue = ref('')
const chartOpenId = ref('')
const chatList = ref<chatType[]>([])
const isDisabledChart = computed(
() => !(inputValue.value && props.data?.name && props.data?.model_id)
)
function quickProblemHandel(val: string) {
inputValue.value = val
}
@ -127,8 +118,9 @@ function sendChatHandle(event: any) {
if (!event.ctrlKey) {
// ctrl
event.preventDefault()
if (!isDisabledChart.value) {
chatMessage()
}
} else {
// ctrl+
inputValue.value += '\n'

View File

@ -16,6 +16,19 @@ const useApplicationStore = defineStore({
reject(error)
})
})
},
async asyncGetApplicationDetail(id: string) {
return new Promise((resolve, reject) => {
applicationApi
.getApplicationDetail(id)
.then((data) => {
resolve(data)
})
.catch((error) => {
reject(error)
})
})
}
}
})

View File

@ -139,9 +139,9 @@
</el-scrollbar>
</div>
<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">
创建
{{ id ? '保存' : '创建' }}
</el-button>
</div>
</el-col>
@ -171,7 +171,7 @@ import type { Provider } from '@/api/type/model'
import { realatedObject } from '@/utils/utils'
import { MsgSuccess } from '@/utils/message'
import useStore from '@/stores'
const { model, dataset } = useStore()
const { model, dataset, application } = useStore()
const router = useRouter()
const route = useRoute()
@ -241,6 +241,19 @@ function openDatasetDialog() {
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() {
loading.value = true
dataset
@ -281,6 +294,9 @@ function getProvider() {
}
onMounted(() => {
if (id) {
getDetail()
}
getProvider()
getModel()
getDataset()

View File

@ -71,7 +71,7 @@
<span>运行中</span>
<!-- <el-switch v-model="item.status" @change="changeState($event, item)" /> -->
</div>
<el-dropdown-item divided>删除</el-dropdown-item>
<el-dropdown-item divided @click="deleteApplication(item)">删除</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
@ -88,9 +88,8 @@
import { ref, onMounted, reactive } from 'vue'
import applicationApi from '@/api/application'
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 { numberFormat } from '@/utils/utils'
const router = useRouter()
const loading = ref(false)
@ -102,7 +101,6 @@ const pageConfig = reactive<pageRequest>({
})
const applicationList = ref<any[]>([])
const state = ref(false)
function loadDataset() {}
@ -111,29 +109,29 @@ function search() {
getList()
}
// function deleteDateset(row: any) {
// MsgConfirm(
// `${row.name} ?`,
// ` ${row.char_length} `,
// {
// confirmButtonText: '',
// confirmButtonClass: 'danger'
// }
// )
// .then(() => {
// loading.value = true
// datasetApi
// .delDateset(row.id)
// .then(() => {
// MsgSuccess('')
// getList()
// })
// .catch(() => {
// loading.value = false
// })
// })
// .catch(() => {})
// }
function deleteApplication(row: any) {
MsgConfirm(
`是否删除应用:${row.name} ?`,
`删除后该应用将不再提供服务,请谨慎操作。`,
{
confirmButtonText: '删除',
confirmButtonClass: 'danger'
}
)
.then(() => {
loading.value = true
applicationApi
.delApplication(row.id)
.then(() => {
MsgSuccess('删除成功')
getList()
})
.catch(() => {
loading.value = false
})
})
.catch(() => {})
}
// function changeState(bool: Boolean, row: any) {
// const obj = {