2025-04-16 10:43:54 +08:00
< template >
2025-04-16 15:08:59 +08:00
< div class = "createCloud" ref = "createCloud" > < / div >
< a-modal
class = "createCloud_modal generalModel"
v - model : visible = "operationsModal"
: footer = "null"
: get - container = "() => $refs.createCloud"
width = "50%"
: height = "'77rem'"
: maskClosable = "false"
: centered = "true"
: closable = "false"
: mask = "true"
wrapClassName = "#app"
: keyboard = "false"
>
< div class = "generalModel_btn" >
< div class = "generalModel_closeIcon" @click.stop ="cancelDsign()" >
< svg width = "46" height = "46" viewBox = "0 0 46 46" fill = "none" xmlns = "http://www.w3.org/2000/svg" >
< circle cx = "23" cy = "23" r = "23" fill = "white" fill -opacity = " 0.3 " / >
2025-04-23 09:39:24 +08:00
< rect x = "32.5063" y = "12" width = "3" height = "29" rx = "1.5" transform = "rotate(45 32.5063 12)" fill = "#000" / >
< rect x = "34.6274" y = "32.5059" width = "3" height = "29" rx = "1.5" transform = "rotate(135 34.6274 32.5059)" fill = "#000" / >
2025-04-16 15:08:59 +08:00
< / svg >
< / div >
< / div >
< div class = "modal_title_text" >
2025-04-23 17:30:42 +08:00
< div > Create Cloud Generation Tasks < / div >
2025-04-16 15:08:59 +08:00
< / div >
< div class = "allUserPoeration_center admin_page" >
< div class = "admin_state_item" >
2025-04-23 17:30:42 +08:00
< span > Task type < span > * < / span > < / span >
2025-04-16 15:08:59 +08:00
< a-select
v - model : value = "buildType"
allowClear
2025-04-23 09:39:24 +08:00
style = "width: 200px"
2025-04-16 15:08:59 +08:00
placeholder = "Please select"
: options = "cloudList"
2025-04-23 09:39:24 +08:00
@ change = "changeBuildType"
2025-04-16 15:08:59 +08:00
> < / a-select >
< / div >
2025-04-23 17:30:42 +08:00
< div class = "admin_state_item" v-show = "buildType" >
< span > Quantity < span > * < / span > < / span >
2025-04-16 15:08:59 +08:00
< input
2025-04-23 09:39:24 +08:00
v - model = "numberOfImages"
placeholder = "Please enter number"
2025-04-16 15:08:59 +08:00
type = "text"
2025-04-23 09:39:24 +08:00
style = "width: 200px"
2025-04-23 17:30:42 +08:00
@ input = "changeNumberOfImages"
2025-04-16 15:08:59 +08:00
/ >
< / div >
2025-04-23 09:39:24 +08:00
<!-- toProductimg -- >
< div v-show = "buildType == 'toProductImage'" class="admin_state_item " >
< span > { { $t ( 'ProductImg.Similarity' ) } } < / span >
< div class = "sliderAndImput" style = "width: 200px" >
< a-slider class = "system_silder"
v - model : value = "similarity"
: tooltipVisible = "false"
: step = "5"
>
< / a-slider >
< input type = "number" readonly v-model = "similarity" >
< / div >
< / div >
< div v-show = "buildType == 'relight'" class="admin_state_item " >
< span > { { $t ( 'ProductImg.RelightDirection' ) } } < / span >
< a-select style = "width: 200px" v -model :value = "relightDirection" :options = "relightDirectionList" > < / a-select >
< / div >
< div v-show = "buildType == 'relight'" class="admin_state_item " >
< span > { { $t ( 'ProductImg.Highlight' ) } } < / span >
< div class = "sliderAndImput" style = "width: 200px" >
< a-slider class = "system_silder"
v - model : value = "brightenValue"
: tooltipVisible = "false"
: max = "3"
: min = "1"
: step = "0.1"
>
< / a-slider >
< input type = "number" readonly v-model = "brightenValue" >
< / div >
< / div >
< div v-show = "buildType == 'toProductImage' || buildType == 'relight'" class="admin_state_item" >
< span > Keyword < / span >
2025-04-16 15:08:59 +08:00
< input
2025-04-23 09:39:24 +08:00
v - model = "generateText"
: placeholder = "$t('Generate.inputContent1')"
2025-04-16 15:08:59 +08:00
type = "text"
2025-04-23 09:39:24 +08:00
style = "width: 200px"
2025-04-16 15:08:59 +08:00
/ >
< / div >
2025-04-23 09:39:24 +08:00
< div class = "selectImgList generalScroll" v-mousewheel v-show = "exhibitionImgList.length>0" >
< div v-for = "item in exhibitionImgList" class="item" >
< img :src = "item.designOutfitUrl||item.url" alt = "" >
< / div >
2025-04-16 15:08:59 +08:00
< / div >
2025-04-23 09:39:24 +08:00
<!-- < div class = "admin_state_item" style = "width: 100%;" >
< span style = "margin: 0;" > Generation time : 19 min < / span >
< / div > -- >
2025-04-23 17:30:42 +08:00
< div v-show = "buildType" class="admin_state_item" style="width: 100%;" >
2025-04-23 09:39:24 +08:00
< span style = "margin: 0;" > Cost credit : { { credits * numberOfImages } } < / span >
2025-04-16 15:08:59 +08:00
< / div >
< / div >
< div class = "allUserPoeration_btn admin_page" >
2025-04-23 17:30:42 +08:00
<!-- < div class = "admin_search_item" @click ="cancelDsign" >
2025-04-16 15:08:59 +08:00
Close
2025-04-23 17:30:42 +08:00
< / div > -- >
2025-04-16 15:08:59 +08:00
< div class = "admin_search_item" @click ="setOk" >
OK
< / div >
2025-04-16 10:43:54 +08:00
2025-04-16 15:08:59 +08:00
< / div >
< / a-modal >
< div class = "mark_loading" v-show = "loadingShow" >
< a-spin size = "large" / >
2025-04-16 10:43:54 +08:00
< / div >
< / template >
2025-04-16 15:08:59 +08:00
< script >
2025-04-23 09:39:24 +08:00
import { defineComponent , computed , reactive , watch , onMounted , nextTick , toRefs } from "vue" ;
2025-04-16 10:43:54 +08:00
import { Https } from "@/tool/https" ;
2025-04-16 15:08:59 +08:00
import { Modal , message } from "ant-design-vue" ;
import { ExclamationCircleOutlined } from "@ant-design/icons-vue" ;
import { formatTime , isEmail } from "@/tool/util" ;
import dayjs , { Dayjs } from 'dayjs' ;
2025-04-23 09:39:24 +08:00
import { useStore } from "vuex" ;
import { useI18n } from "vue-i18n" ;
import { getMinioUrl } from '@/tool/util'
2025-04-16 15:08:59 +08:00
const md5 = require ( "md5" ) ;
2025-04-16 10:43:54 +08:00
export default defineComponent ( {
2025-04-16 15:08:59 +08:00
components : {
} ,
2025-04-16 10:43:54 +08:00
props : {
2025-04-16 15:08:59 +08:00
cloudList : {
type : Array ,
default : [ ]
}
2025-04-16 10:43:54 +08:00
} ,
2025-04-23 09:39:24 +08:00
emits : [ 'getContentList' ] ,
2025-04-16 15:08:59 +08:00
setup ( props , { emit } ) {
2025-04-23 09:39:24 +08:00
const store = useStore ( ) ;
2025-04-16 15:08:59 +08:00
let operations = reactive ( {
operationsModal : false ,
loadingShow : false ,
2025-04-16 10:43:54 +08:00
} )
2025-04-16 15:08:59 +08:00
let operationsData = reactive ( {
buildType : '' ,
numberOfImages : '' ,
2025-04-23 09:39:24 +08:00
credits : 0 ,
exhibitionImgList : [ ] , //选择的图片
selectObject : computed ( ( ) => store . state . Workspace . probjects ) , //选择的项目
//toProduct
generateText : '' , //输入的内容
similarity : 30 ,
brightenValue : 1 , //亮度
relightDirection : 'Right Light' , //打光方向
relightDirectionList : [
{
value : 'Right Light' ,
label : useI18n ( ) . t ( 'ProductImg.RightLight' )
} , {
value : 'Left Light' ,
label : useI18n ( ) . t ( 'ProductImg.LeftLight' )
} , {
value : 'Top Light' ,
label : useI18n ( ) . t ( 'ProductImg.TopLight' )
} , {
value : 'Bottom Light' ,
label : useI18n ( ) . t ( 'ProductImg.BottomLight' )
}
]
2025-04-16 10:43:54 +08:00
} )
2025-04-16 15:08:59 +08:00
let init = ( ) => {
operations . operationsModal = true
2025-04-16 10:43:54 +08:00
}
2025-04-23 09:39:24 +08:00
const changeBuildType = ( ) => {
if ( operationsData . buildType == 'design' ) {
operationsData . exhibitionImgList = [ ]
} else if ( operationsData . buildType == 'toProductImage' ) {
operationsData . exhibitionImgList = store . state . UploadFilesModule . modularData . design . likeData
} else if ( operationsData . buildType == 'relight' ) {
operationsData . exhibitionImgList = store . state . UploadFilesModule . modularData . toProduct
} else if ( operationsData . buildType == 'poseTransfer' ) {
operationsData . exhibitionImgList = store . state . UploadFilesModule . modularData . toProduct
}
props . cloudList . forEach ( ( item ) => {
if ( item . value == operationsData . buildType ) {
operationsData . credits = item . consumption
}
} )
}
let getPorductImg = ( ) => {
let modularData = store . state . UploadFilesModule . modularData
let list = [ ]
if ( operationsData . buildType == 'toProductImage' || operationsData . buildType == 'relight' ) {
let productOrRelight = [ ]
if ( operationsData . buildType == 'toProductImage' ) productOrRelight = modularData . design . likeData
if ( operationsData . buildType == 'relight' ) productOrRelight = modularData . toProduct
productOrRelight . forEach ( ( item ) => {
if ( ! item . id ) return
let obj = {
"createTime" : "" ,
"elementId" : 0 ,
"elementType" : "" ,
"id" : 0 ,
"isLike" : 0 ,
"taskId" : "" ,
"toProductImageRecordId" : 0 ,
"url" : "" ,
}
obj . elementId = item . designOutfitId
obj . elementType = 'DesignOutfit'
if ( operationsData . buildType == 'relight' ) {
obj . elementId = item . id
obj . elementType = 'ToProductImage'
}
list . push ( obj )
} )
}
return list
}
const getImageStrength = ( ) => {
let imageStrength = operationsData . similarity == 100 ? 95 : operationsData . similarity
return imageStrength ;
} ;
const getPoseTransformData = ( ) => {
let list = [ ]
let toProduct = store . state . UploadFilesModule . modularData . toProduct
toProduct . forEach ( ( item ) => {
let obj = {
poseId : 1 ,
productImage : getMinioUrl ( item . url )
}
list . push ( obj )
} )
return list
}
2025-04-16 15:08:59 +08:00
let setAddData = ( ) => {
return {
2025-04-23 09:39:24 +08:00
"buildType" : operationsData . buildType ,
nums : operationsData . numberOfImages ,
projectId : operationsData . selectObject . id ,
//productimg
toProductImage : {
prompt : operationsData . generateText , //输入的内容
toProductImageVOList : getPorductImg ( ) , //选择的图片
projectId : operationsData . selectObject . id ,
direction : operationsData . relightDirection , //打光方向
brightenValue : operationsData . brightenValue ,
imageStrength : ( 100 - getImageStrength ( ) ) / 100 ,
} ,
//poseTransform
poseTransform : getPoseTransformData ( ) ,
private : operationsData . selectObject . id ,
ToProductImageDTO : operationsData . selectObject . id ,
2025-04-16 15:08:59 +08:00
}
2025-04-16 10:43:54 +08:00
}
2025-04-16 15:08:59 +08:00
let cancelDsign = ( ) => {
2025-04-23 09:39:24 +08:00
operationsData . buildType = ''
operationsData . numberOfImages = ''
2025-04-16 15:08:59 +08:00
operations . operationsModal = false
}
let setOk = ( ) => {
let data
data = setAddData ( )
2025-04-23 17:30:42 +08:00
if ( operationsData . buildType == 'toProductImage' ) {
if ( data . toProductImage . toProductImageVOList . length == 0 ) return message . warning ( "You need to go to the Design module and generate a design result first before you can use the 'To Product Image' cloud generation feature." )
} else if ( operationsData . buildType == 'relight' ) {
if ( data . toProductImage . toProductImageVOList . length == 0 ) return message . warning ( "You need to go to the 'To Product Image' module and generate a result first before you can use the 'Relight' cloud generation feature." )
2025-04-23 09:39:24 +08:00
} else if ( operationsData . buildType == 'poseTransfer' ) {
2025-04-23 17:30:42 +08:00
if ( data . poseTransform . length == 0 ) return message . warning ( "You must first generate results in the 'To Product Image' module before you can use the 'Transfer Pose' cloud generation feature." )
2025-04-23 09:39:24 +08:00
}
if ( ! data . buildType || ! data . nums ) return message . warning ( 'Please check the input box marked with *' )
operations . loadingShow = true
Https . axiosPost ( Https . httpUrls . designCloud , data ) . then (
2025-04-16 15:08:59 +08:00
( rv ) => {
if ( rv ) {
2025-04-23 09:39:24 +08:00
operations . loadingShow = false
2025-04-16 15:08:59 +08:00
cancelDsign ( )
2025-04-23 09:39:24 +08:00
emit ( 'getContentList' )
2025-04-16 15:08:59 +08:00
}
2025-04-23 09:39:24 +08:00
} ) . catch ( ( error ) => {
operations . loadingShow = false
2025-04-16 15:08:59 +08:00
} )
}
2025-04-23 17:30:42 +08:00
const changeNumberOfImages = ( ) => {
if ( operationsData . buildType == 'relight' || operationsData . buildType == 'poseTransfer' ) {
if ( operationsData . exhibitionImgList . length < Number ( operationsData . numberOfImages ) ) {
operationsData . numberOfImages = operationsData . exhibitionImgList . length
}
}
}
2025-04-16 15:08:59 +08:00
return {
... toRefs ( operations ) ,
... toRefs ( operationsData ) ,
cancelDsign ,
init ,
focus ,
blur ,
setOk ,
2025-04-23 09:39:24 +08:00
changeBuildType ,
2025-04-23 17:30:42 +08:00
changeNumberOfImages ,
2025-04-16 15:08:59 +08:00
} ;
} ,
data ( ) {
return {
} ;
} ,
mounted ( ) { } ,
methods : {
} ,
2025-04-23 09:39:24 +08:00
directives : {
mousewheel : {
mounted ( el ) {
el . addEventListener ( 'mouseenter' , ( e ) => {
if ( el . scrollWidth > el . clientWidth ) {
el . parentElement . style . overflowY = 'hidden' ;
}
} ) ;
// 鼠标移出事件
el . addEventListener ( 'mouseleave' , ( ) => {
el . parentElement . style . overflowY = 'auto' ;
} ) ;
el . addEventListener ( 'wheel' , ( e ) => {
let num = 0
if ( e . deltaY > 0 ) {
num = 25
} else {
num = - 25
}
el . scrollBy ( num , 0 ) ;
} , { passive : true } )
}
} ,
} ,
2025-04-16 15:08:59 +08:00
} ) ;
2025-04-16 10:43:54 +08:00
< / script >
< style lang = "less" scoped >
2025-04-23 09:39:24 +08:00
: deep ( . ant - modal - mask ) {
background : rgba ( 0 , 0 , 0 , 0.2 ) ;
}
2025-04-16 15:08:59 +08:00
: deep ( . createCloud _modal ) {
2025-04-23 09:39:24 +08:00
2025-04-16 15:08:59 +08:00
. ant - modal - body {
display : flex ;
flex - direction : column ;
}
}
< / style >
< style lang = "less" scoped >
. createCloud _modal {
. closeIcon {
z - index : 2 ;
}
. allUserPoeration _btn {
display : flex ;
flex - direction : row ;
height : auto ;
justify - content : flex - end ;
padding : 1 rem 0 ;
. admin _search _item {
margin - bottom : 0 ;
}
}
. allUserPoeration _center {
flex : 1 ;
overflow - y : auto ;
flex - direction : row ;
flex - wrap : wrap ;
align - content : flex - start ;
2025-04-23 09:39:24 +08:00
padding : 0 2 rem ;
> . selectImgList {
width : 100 % ;
display : flex ;
overflow - x : auto ;
align - items : center ;
flex - wrap : nowrap ;
height : 20 rem ;
margin : 2 rem 0 ;
> . item {
height : 100 % ;
margin - right : 1 rem ;
& : last - child {
margin - right : 0 ;
}
> img {
height : 100 % ;
}
}
//
}
2025-04-16 15:08:59 +08:00
> . admin _state _item {
width : auto ;
// width: 100%;
display : flex ;
flex - direction : column ;
align - items : flex - start ;
> span {
text - align : left ;
margin : 0 ;
margin - bottom : 1.5 rem ;
font - weight : 600 ;
}
: deep ( > . ant - select > . ant - select - selector ) {
border - radius : 1.6 rem ;
}
> input {
border - radius : 1.6 rem ;
}
2025-04-23 09:39:24 +08:00
> . sliderAndImput {
display : flex ;
align - items : center ;
flex : 1 ;
: deep ( > . ant - slider ) {
// border-radius: 1.6rem;
flex : 1 ;
}
> input {
border - radius : 1.6 rem ;
width : 4 rem ;
margin - left : 1 rem ;
height : 100 % ;
border - radius : 1 rem ;
}
}
2025-04-16 15:08:59 +08:00
}
2025-04-16 10:43:54 +08:00
}
2025-04-16 15:08:59 +08:00
}
2025-04-16 10:43:54 +08:00
< / style >