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) 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
} }

View File

@ -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'

View File

@ -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)
})
})
} }
} }
}) })

View File

@ -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()

View File

@ -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 = {