|
|
|
@ -1,127 +1,156 @@
|
|
|
|
|
<template>
|
|
|
|
|
|
|
|
|
|
<div class="title-div">
|
|
|
|
|
<div class="title-span-div">
|
|
|
|
|
<div class="title-icon"></div>
|
|
|
|
|
<div class="title-span">创建算法</div>
|
|
|
|
|
<div class="title-span">{{props.modalType == 'insert'? '创建算法': '编辑算法'}}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="close-button" @click="emits('changeAddModal',false)"></div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="interval"></div>
|
|
|
|
|
<div class="modal-content">
|
|
|
|
|
<div class="left-content">
|
|
|
|
|
<div class="item-title">模型名称</div>
|
|
|
|
|
<a-input class="name-input" v-model:value="modelName" placeholder="请输入相关名称" />
|
|
|
|
|
<div class="item-title">模型描述</div>
|
|
|
|
|
<a-textarea class="item-desc" v-model:value="modelDescription" placeholder="请输入相关描述" :rows="4" />
|
|
|
|
|
<div class="item-title">模型封面</div>
|
|
|
|
|
<div class="item-image">
|
|
|
|
|
<div class="empty-image" @click="changeSelectImageModal(true)">
|
|
|
|
|
<div class="empty-image-content">
|
|
|
|
|
<div class="empty-image-icon"></div>
|
|
|
|
|
<div class="empty-image-span">请选择文件上传</div>
|
|
|
|
|
<a-spin tip="加载中..." :spinning="loading">
|
|
|
|
|
<div class="modal-content">
|
|
|
|
|
<div class="left-content">
|
|
|
|
|
<div class="item-title">模型名称</div>
|
|
|
|
|
<a-input class="name-input" v-model:value="name" placeholder="请输入相关名称" />
|
|
|
|
|
<div class="item-title">模型描述</div>
|
|
|
|
|
<a-textarea class="item-desc" v-model:value="describe" placeholder="请输入相关描述" :rows="4" />
|
|
|
|
|
<div class="item-title">模型封面</div>
|
|
|
|
|
<div class="item-image">
|
|
|
|
|
<img v-if="pic" class="show-image" :src="`${VITE_GLOB_API_URL}/${pic}`" @click="changeSelectImageModal(true)"/>
|
|
|
|
|
<div v-else class="empty-image" @click="changeSelectImageModal(true)">
|
|
|
|
|
<div class="empty-image-content">
|
|
|
|
|
<div class="empty-image-icon"></div>
|
|
|
|
|
<div class="empty-image-span">请选择文件上传</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="right-content">
|
|
|
|
|
<div class="item-title">模型类型</div>
|
|
|
|
|
<a-segmented class="item-type" v-model:value="modelType" :options="modelTypeOptions"></a-segmented>
|
|
|
|
|
<template v-if="modelType == '0'">
|
|
|
|
|
<div class="item-title">模型规模</div>
|
|
|
|
|
<a-segmented class="item-type" v-model:value="modelScale" :options="modelScaleOptions"></a-segmented>
|
|
|
|
|
<div class="item-title">模型文件</div>
|
|
|
|
|
<a-upload
|
|
|
|
|
v-model:file-list="modelFile"
|
|
|
|
|
accept=".zip"
|
|
|
|
|
:maxCount="1"
|
|
|
|
|
:custom-request="customRequest"
|
|
|
|
|
>
|
|
|
|
|
<a-button class="select-model-file-button" type="primary" :icon="h(PlusOutlined)">选择模型文件</a-button>
|
|
|
|
|
<!-- <template #itemRender="{ file, actions }">
|
|
|
|
|
<a-space>
|
|
|
|
|
<span>{{ file.name }}</span>
|
|
|
|
|
</a-space>
|
|
|
|
|
</template> -->
|
|
|
|
|
</a-upload>
|
|
|
|
|
<div class="upload-hint">(*请上传模型压缩文件,支持pt格式)</div>
|
|
|
|
|
<div class="item-title">模型标签</div>
|
|
|
|
|
<div class="item-label-div">
|
|
|
|
|
<div class="label-title-div">
|
|
|
|
|
<div class="label-title-span">请根据模型实际情况填写信息</div>
|
|
|
|
|
<div class="add-button" @click="addLabelRow">
|
|
|
|
|
<div class="button-icon"></div>
|
|
|
|
|
<div class="button-span">添加行</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="label-interval"></div>
|
|
|
|
|
<div class="label-table-title">
|
|
|
|
|
<div class="table-title-item" style="padding-left: 6px;">枚举值</div>
|
|
|
|
|
<div class="table-title-item">名称</div>
|
|
|
|
|
<div class="table-title-item">推荐置信度</div>
|
|
|
|
|
<div class="table-title-item" style="width: 55px;justify-content: center;">操作</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="label-table-content">
|
|
|
|
|
<div class="table-row" v-for="(item,index) in modelLabelList" :key="index">
|
|
|
|
|
<div class="table-item">
|
|
|
|
|
<a-input class="table-item-input" v-model:value="item.test"/>
|
|
|
|
|
<div class="right-content">
|
|
|
|
|
<div class="item-title">模型类型</div>
|
|
|
|
|
<a-segmented class="item-type" v-model:value="type" :options="modelTypeOptions"></a-segmented>
|
|
|
|
|
<template v-if="type == 0">
|
|
|
|
|
<div class="item-title">模型规模</div>
|
|
|
|
|
<a-segmented class="item-type" v-model:value="size" :options="modelScaleOptions"></a-segmented>
|
|
|
|
|
<div class="item-title">模型文件</div>
|
|
|
|
|
<a-upload
|
|
|
|
|
:file-list="modelFile"
|
|
|
|
|
accept=".zip,.pt"
|
|
|
|
|
:max-count="1"
|
|
|
|
|
:custom-request="customRequest"
|
|
|
|
|
>
|
|
|
|
|
<a-button class="select-model-file-button" type="primary" :icon="h(PlusOutlined)">选择模型文件</a-button>
|
|
|
|
|
</a-upload>
|
|
|
|
|
<div class="upload-hint">(*请上传模型压缩文件,支持pt格式)</div>
|
|
|
|
|
<div class="item-title">模型标签</div>
|
|
|
|
|
<div class="item-label-div">
|
|
|
|
|
<div class="label-title-div">
|
|
|
|
|
<div class="label-title-span">请根据模型实际情况填写信息</div>
|
|
|
|
|
<div class="add-button" @click="addLabelRow">
|
|
|
|
|
<div class="button-icon"></div>
|
|
|
|
|
<div class="button-span">添加行</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="table-item">
|
|
|
|
|
<a-input class="table-item-input" />
|
|
|
|
|
</div>
|
|
|
|
|
<div class="table-item">
|
|
|
|
|
<a-input class="table-item-input" />
|
|
|
|
|
</div>
|
|
|
|
|
<div class="table-item" style="width: 55px; justify-content: center">
|
|
|
|
|
<div class="del-table-row" @click="delLabelRow(index)"></div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="label-interval"></div>
|
|
|
|
|
<div class="label-table-title">
|
|
|
|
|
<div class="table-title-item" style="padding-left: 6px;">枚举值</div>
|
|
|
|
|
<div class="table-title-item">名称</div>
|
|
|
|
|
<div class="table-title-item">推荐置信度</div>
|
|
|
|
|
<div class="table-title-item" style="width: 55px;justify-content: center;">操作</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="label-table-content">
|
|
|
|
|
<div class="table-row" v-for="(item,index) in modelLabels" :key="index">
|
|
|
|
|
<div class="table-item">
|
|
|
|
|
<a-input class="table-item-input" v-model:value="item.enumValue"/>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="table-item">
|
|
|
|
|
<a-input class="table-item-input" v-model:value="item.name"/>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="table-item">
|
|
|
|
|
<a-input class="table-item-input" v-model:value="item.reliability"/>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="table-item" style="width: 55px; justify-content: center">
|
|
|
|
|
<div class="del-table-row" @click="delLabelRow(index)"></div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-else>
|
|
|
|
|
<div class="item-title">推流地址</div>
|
|
|
|
|
<a-input class="name-input" v-model:value="modelPushAddress" placeholder="请输入地址" />
|
|
|
|
|
<div class="item-title">拉流地址</div>
|
|
|
|
|
<a-input class="name-input" v-model:value="modelPullAddress" placeholder="请输入地址" />
|
|
|
|
|
<div class="item-title">服务地址</div>
|
|
|
|
|
<a-input class="name-input" v-model:value="modelServeAddress" placeholder="请输入地址" />
|
|
|
|
|
<div class="item-title">密钥</div>
|
|
|
|
|
<a-textarea class="item-key" v-model:value="modelKey" placeholder="请输入密钥" :rows="4" />
|
|
|
|
|
</template>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-else>
|
|
|
|
|
<div class="item-title">推流地址</div>
|
|
|
|
|
<a-input class="name-input" v-model:value="pushUrl" placeholder="请输入地址" />
|
|
|
|
|
<div class="item-title">拉流地址</div>
|
|
|
|
|
<a-input class="name-input" v-model:value="pullUrl" placeholder="请输入地址" />
|
|
|
|
|
<div class="item-title">服务地址</div>
|
|
|
|
|
<a-input class="name-input" v-model:value="serviceUrl" placeholder="请输入地址" />
|
|
|
|
|
<div class="item-title">密钥</div>
|
|
|
|
|
<a-textarea class="item-key" v-model:value="secretKey" placeholder="请输入密钥" :rows="4" />
|
|
|
|
|
</template>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="interval"></div>
|
|
|
|
|
<div class="footer">
|
|
|
|
|
<a-button class="cancel-button" @click="emits('changeAddModal',false)">取消</a-button>
|
|
|
|
|
<a-button class="save-button" type="primary">确定</a-button>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="interval"></div>
|
|
|
|
|
<div class="footer">
|
|
|
|
|
<a-button class="cancel-button" @click="emits('changeAddModal',false)">取消</a-button>
|
|
|
|
|
<a-button class="save-button" type="primary" @click="submit">确定</a-button>
|
|
|
|
|
</div>
|
|
|
|
|
</a-spin>
|
|
|
|
|
<a-modal v-model:open="selectImageModal" title="选择封面" width="1000px" :footer="null" :destroyOnClose="true">
|
|
|
|
|
<SelectImageModal @changeSelectImageModal="changeSelectImageModal"/>
|
|
|
|
|
<SelectImageModal @changeSelectImageModal="changeSelectImageModal" @getResultImage="getResultImage"/>
|
|
|
|
|
</a-modal>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { ref, h, defineEmits, defineProps } from "vue"
|
|
|
|
|
import { ref, h, defineEmits, defineProps, onMounted } from "vue"
|
|
|
|
|
import { uploadFile } from '@/api/formrender/index';
|
|
|
|
|
import { PlusOutlined, } from '@ant-design/icons-vue';
|
|
|
|
|
import SelectImageModal from "./SelectImageModal.vue";
|
|
|
|
|
const props = defineProps([''])
|
|
|
|
|
const emits = defineEmits(['changeAddModal'])
|
|
|
|
|
const modelName = ref('')
|
|
|
|
|
const modelDescription = ref('')
|
|
|
|
|
const modelType = ref('0')
|
|
|
|
|
const modelScale = ref('N')
|
|
|
|
|
const modelPullAddress = ref('')
|
|
|
|
|
const modelPushAddress = ref('')
|
|
|
|
|
const modelServeAddress = ref('')
|
|
|
|
|
const modelKey = ref('')
|
|
|
|
|
const modelFile = ref([])
|
|
|
|
|
const modelFilePath = ref()
|
|
|
|
|
const modelLabelList = ref([])
|
|
|
|
|
import { ModelLabelsType } from './utils'
|
|
|
|
|
import { getAppEnvConfig } from '@/utils/env';
|
|
|
|
|
import { AddAlgorithmsRepository, UpdateAlgorithmsRepository } from '@/api/demo/ailist'
|
|
|
|
|
import { message } from "ant-design-vue";
|
|
|
|
|
const { VITE_GLOB_API_URL } = getAppEnvConfig();
|
|
|
|
|
const props = defineProps(['modalType', 'algorithmInfo'])
|
|
|
|
|
const emits = defineEmits(['changeAddModal', 'query'])
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
if(props.modalType == 'update'){
|
|
|
|
|
id.value = props.algorithmInfo.id
|
|
|
|
|
name.value = props.algorithmInfo.name
|
|
|
|
|
describe.value = props.algorithmInfo.describe
|
|
|
|
|
pic.value = props.algorithmInfo.pic
|
|
|
|
|
type.value = props.algorithmInfo.type
|
|
|
|
|
size.value = props.algorithmInfo.size
|
|
|
|
|
pullUrl.value = props.algorithmInfo.pullUrl
|
|
|
|
|
pushUrl.value = props.algorithmInfo.pushUrl
|
|
|
|
|
serviceUrl.value = props.algorithmInfo.serviceUrl
|
|
|
|
|
secretKey.value = props.algorithmInfo.secretKey
|
|
|
|
|
path.value = props.algorithmInfo.path
|
|
|
|
|
modelLabels.value = props.algorithmInfo.modelLabels
|
|
|
|
|
modelFile.value?.push({
|
|
|
|
|
uid: '-1',
|
|
|
|
|
name: props.algorithmInfo.path,
|
|
|
|
|
status: 'done',
|
|
|
|
|
url: VITE_GLOB_API_URL + '/' + props.algorithmInfo.path,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
const id = ref('')
|
|
|
|
|
const name = ref('')
|
|
|
|
|
const describe = ref('')
|
|
|
|
|
const pic = ref('')
|
|
|
|
|
const type = ref(0)
|
|
|
|
|
const size = ref('N')
|
|
|
|
|
const pullUrl = ref('')
|
|
|
|
|
const pushUrl = ref('')
|
|
|
|
|
const serviceUrl = ref('')
|
|
|
|
|
const secretKey = ref('')
|
|
|
|
|
const modelFile = ref<any>([])
|
|
|
|
|
const path = ref()
|
|
|
|
|
const modelLabels = ref<ModelLabelsType[]>([])
|
|
|
|
|
const selectImageModal = ref(false)
|
|
|
|
|
const loading = ref(false)
|
|
|
|
|
const modelTypeOptions = ref([
|
|
|
|
|
{ label: '本地模型', value: '0' },
|
|
|
|
|
{ label: '远程模型', value: '1' }
|
|
|
|
|
{ label: '本地模型', value: 0 },
|
|
|
|
|
{ label: '远程模型', value: 1 }
|
|
|
|
|
])
|
|
|
|
|
const modelScaleOptions = ref([
|
|
|
|
|
{ label: 'N', value: 'N' },
|
|
|
|
@ -131,25 +160,72 @@ const modelScaleOptions = ref([
|
|
|
|
|
{ label: 'XI', value: 'XI' },
|
|
|
|
|
])
|
|
|
|
|
const customRequest = (file) => {
|
|
|
|
|
modelFile.value = []
|
|
|
|
|
const formData = new FormData()
|
|
|
|
|
formData.append('files', file.file)
|
|
|
|
|
uploadFile(formData).then(res => {
|
|
|
|
|
modelFilePath.value = res[0].filePath
|
|
|
|
|
// emits('update:shppath',res[0].filePath)
|
|
|
|
|
modelFile.value?.push({
|
|
|
|
|
uid: '-1',
|
|
|
|
|
name: res[0].filePath,
|
|
|
|
|
status: 'done',
|
|
|
|
|
url: VITE_GLOB_API_URL + '/' + res[0].filePath,
|
|
|
|
|
});
|
|
|
|
|
path.value = res[0].filePath
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
const addLabelRow = () => {
|
|
|
|
|
// TODO
|
|
|
|
|
modelLabelList.value.push({
|
|
|
|
|
test:''
|
|
|
|
|
modelLabels.value.push({
|
|
|
|
|
id: '',
|
|
|
|
|
name: '',
|
|
|
|
|
enumValue: '',
|
|
|
|
|
reliability: '',
|
|
|
|
|
pId: ''
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
const delLabelRow = (index) => {
|
|
|
|
|
modelLabelList.value.splice(index,1)
|
|
|
|
|
modelLabels.value.splice(index,1)
|
|
|
|
|
}
|
|
|
|
|
const changeSelectImageModal = (type: boolean) => {
|
|
|
|
|
selectImageModal.value = type
|
|
|
|
|
}
|
|
|
|
|
const getResultImage = (url: string) => {
|
|
|
|
|
pic.value = url
|
|
|
|
|
}
|
|
|
|
|
const submit = () => {
|
|
|
|
|
loading.value = true
|
|
|
|
|
let params = {
|
|
|
|
|
id: id.value,
|
|
|
|
|
name: name.value,
|
|
|
|
|
describe: describe.value,
|
|
|
|
|
pic: pic.value,
|
|
|
|
|
size: size.value,
|
|
|
|
|
type: type.value,
|
|
|
|
|
path: path.value,
|
|
|
|
|
pushUrl: pushUrl.value,
|
|
|
|
|
pullUrl: pullUrl.value,
|
|
|
|
|
serviceUrl: serviceUrl.value,
|
|
|
|
|
secretKey: secretKey.value,
|
|
|
|
|
modelLabels: modelLabels.value
|
|
|
|
|
}
|
|
|
|
|
console.log('params',params)
|
|
|
|
|
if(props.modalType == 'insert'){
|
|
|
|
|
AddAlgorithmsRepository(params).then(res => {
|
|
|
|
|
message.success('算法创建成功')
|
|
|
|
|
emits('query')
|
|
|
|
|
emits('changeAddModal',false)
|
|
|
|
|
}).finally(() => {
|
|
|
|
|
loading.value = false
|
|
|
|
|
})
|
|
|
|
|
}else{
|
|
|
|
|
UpdateAlgorithmsRepository(params).then(res => {
|
|
|
|
|
message.success('算法修改成功')
|
|
|
|
|
emits('query')
|
|
|
|
|
emits('changeAddModal',false)
|
|
|
|
|
}).finally(() => {
|
|
|
|
|
loading.value = false
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
@ -235,6 +311,11 @@ const changeSelectImageModal = (type: boolean) => {
|
|
|
|
|
background: #F5F5F5;
|
|
|
|
|
// box-shadow: 0px 10px 30px 0px rgba(0,0,6,0.15);
|
|
|
|
|
border: 2px dashed rgba(28,29,34,0.08);
|
|
|
|
|
.show-image{
|
|
|
|
|
width: 249px;
|
|
|
|
|
height: 151px;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
.empty-image{
|
|
|
|
|
position: absolute;
|
|
|
|
|
top: 50%;
|
|
|
|
|