2024-05-16 09:41:16 +08:00
< template >
< a-modal
2024-05-22 10:45:52 +08:00
class = "publish_modal generalModel"
2024-05-16 09:41:16 +08:00
v - model : visible = "publish"
: footer = "null"
width = "50%"
: maskClosable = "false"
: centered = "true"
: closable = "false"
: mask = "publishMask"
: keyboard = "false"
: destroyOnClose = "true"
>
2024-05-22 10:45:52 +08:00
< div class = "generalModel_btn" >
< div class = "generalModel_closeIcon" @click.stop ="cancelDsign()" >
2024-05-16 09:41:16 +08:00
< i class = "fi fi-rr-cross-small" > < / i >
< / div >
< / div >
< div class = "publish_content" >
< div class = "modal_title_text" >
2024-06-21 10:30:09 +08:00
< div > { { $t ( 'Publish.Publish' ) } } < / div >
2024-05-16 09:41:16 +08:00
< div class = "modal_title_text_intro" > < / div >
< / div >
< div class = "publish_content_bottom" >
< div class = "publidh_left" >
< div class = "publidh_content_item" >
2024-06-21 10:30:09 +08:00
< div class = "publidh_content_item_title" > { { $t ( 'Publish.CoverPicture' ) } } < / div >
2024-05-16 09:41:16 +08:00
< div class = "publish_content_shrink publish_content_item" >
2024-05-16 17:14:22 +08:00
< img v-lazy = "selectDate.url" alt="" >
2024-05-16 09:41:16 +08:00
< / div >
< / div >
< / div >
< div class = "publidh_right" >
< div class = "publidh_right_name publidh_content_item" >
2024-06-21 10:30:09 +08:00
< div class = "publidh_content_item_title" > { { $t ( 'Publish.CollectionTitle' ) } } < / div >
2024-05-16 17:14:22 +08:00
< input type = "text" v-model = "subPublishDate.portfolioName" >
2024-05-16 09:41:16 +08:00
< / div >
< div class = "publidh_right_name publidh_content_item" >
2024-06-21 10:30:09 +08:00
< div class = "publidh_content_item_title" > { { $t ( 'Publish.Description' ) } } < / div >
2024-10-08 00:44:17 +08:00
< textarea @input ="textareaChange()" ref = "textarea" v-model = "subPublishDate.portfolioDes" > < / textarea >
< / div >
< div class = "publidh_content_item_tagList" >
< div v-for = "item,index in tagList" @click="pushTag(item,index)" >
2024-10-08 18:34:22 +08:00
< a-tag color = "purple" :title = "item.title" > { { item . tagName } } < / a-tag >
2024-10-08 00:44:17 +08:00
< / div >
2024-05-16 09:41:16 +08:00
< / div >
2024-06-17 09:39:01 +08:00
< div class = "publidh_right_detail publidh_content_item" >
2024-06-21 10:30:09 +08:00
< div class = "publidh_content_item_title" > { { $t ( 'Publish.Permissions' ) } } < / div >
2024-06-17 09:39:01 +08:00
< div >
2024-06-21 10:30:09 +08:00
< a-checkbox @change ="setPermissionsItem()" v -model :checked = "selectPermissions.isSecondaryCreation" > { { $t ( 'Publish.PermissionsItem1' ) } } < / a-checkbox >
2024-06-17 09:39:01 +08:00
< / div >
< / div >
2024-05-16 17:14:22 +08:00
< div class = "publidh_content_item publidh_right_zhuyi" >
2024-05-16 09:41:16 +08:00
< / div >
< div class = "publidh_right_btn" >
2024-06-21 10:30:09 +08:00
< div class = "started_btn" @click ="cancelDsign" > {{ $ t ( ' Publish.Close ' ) }} < / div >
2024-06-26 17:26:31 +08:00
< div class = "started_btn" @click ="setPublish" > {{ beenPublished = = 0 ? $ t ( ' Publish.Publish ' ) : $ t ( ' Publish.UpdatePublish ' ) }} < / div >
2024-05-16 09:41:16 +08:00
< / div >
< / div >
< / div >
2024-05-16 17:14:22 +08:00
< / div >
< div class = "mark_loading" v-show = "isShowMark" >
< a-spin size = "large" / >
2024-05-16 09:41:16 +08:00
< / div >
< / a-modal >
< / template >
< script lang = "ts" >
2024-07-08 09:42:21 +08:00
import { defineComponent , watch , createVNode , inject , ref , toRefs , computed , reactive , triggerRef , nextTick } from "vue" ;
2024-05-16 09:41:16 +08:00
// import { getCookie } from "@/tool/cookie";
2024-05-16 17:14:22 +08:00
import { Https } from "@/tool/https" ;
import { getCookie , setCookie } from "@/tool/cookie" ;
2024-05-16 09:41:16 +08:00
// import domTurnImg from '@/tool/domTurnImg'
import { ExclamationCircleOutlined } from '@ant-design/icons-vue' ;
import { Modal , message } from 'ant-design-vue' ;
2024-06-17 09:39:01 +08:00
import { downloadIamge , base64ToFile } from "@/tool/util" ;
2024-06-21 10:30:09 +08:00
import { useI18n } from 'vue-i18n' ;
2024-08-16 15:40:25 +08:00
import { useStore } from "vuex" ;
2024-05-16 09:41:16 +08:00
export default defineComponent ( {
2024-06-26 17:26:31 +08:00
setup ( prop , { emit } ) {
2024-06-21 10:30:09 +08:00
let { t } = useI18n ( )
2024-08-16 15:40:25 +08:00
const store = useStore ( ) ;
2024-05-16 09:41:16 +08:00
let publish : any = ref ( false ) ; //弹窗
let publishMask : any = ref ( false ) //弹窗遮罩
2024-07-08 09:42:21 +08:00
let setBeenPublished : any = inject ( 'setBeenPublished' )
2024-05-16 17:14:22 +08:00
let publishData : any = reactive ( {
2024-06-17 09:39:01 +08:00
publishName : '' ,
2024-05-16 09:41:16 +08:00
loadingShow : false ,
publishMarginTop : 0 ,
2024-07-08 09:42:21 +08:00
beenPublished : inject ( 'beenPublished' ) , //history回来时候表示是否已经发布0为没发布
2024-05-16 09:41:16 +08:00
publishList : [ ] ,
publishIndex : 0 , //当前图片索引
2024-05-16 17:14:22 +08:00
isShowMark : false ,
2024-06-17 09:39:01 +08:00
setPermissionsAll : true ,
2024-05-16 17:14:22 +08:00
selectDate : {
url : '' ,
} ,
subPublishDate : {
} ,
2024-06-17 09:39:01 +08:00
selectPermissions : {
isAllowComment : true ,
isDisplayArea : true ,
isSecondaryCreation : true ,
}
2024-05-16 09:41:16 +08:00
} )
2024-10-08 18:34:22 +08:00
let tagList = ref ( [ { tagId : 1 , tagName : '#RCAworkshop_2024 ' , title : 'The process is simple: use AiDA to post your design work on the "Gallery ", and the one with the most likes(at least 20 likes) will be invited to the AiDA Workshop offline event in Hong Kong on November 14th, to exchange ideas with the Royal College of Art (RCA), Jae Lim, co-founder of the renowned fashion brand BESFXXK, and outstanding designers! ' } ] )
2024-05-16 09:41:16 +08:00
// let textarea: any = ref(null)
// let setCopy = ()=>{
// textarea.value.select()
// document.execCommand("copy");
// }
2024-05-16 17:14:22 +08:00
let init = ( data : any ) => {
let userInfo : any = getCookie ( "userInfo" )
2024-06-17 09:39:01 +08:00
// console.log(data);
2024-05-16 09:41:16 +08:00
publish . value = true
2024-06-17 09:39:01 +08:00
publishData . selectDate . url = data . imgUrl
2024-05-16 17:14:22 +08:00
publishData . subPublishDate = {
2024-06-17 09:39:01 +08:00
userLikeGroupId : data . userlikeGroupId ,
// userLikeGroupId : data.id,
coverId : '' ,
// coverId : data.groupDetails[0].designOutfitId,
2024-05-16 17:14:22 +08:00
accountId : JSON . parse ( userInfo ) . userId ,
createDate : '' ,
idDeleted : '' ,
id : '' ,
portfolioDes : '' ,
2024-06-17 09:39:01 +08:00
portfolioName : '' ,
2024-05-16 17:14:22 +08:00
portfolioType : 'History' ,
status : '' ,
updateDate : '' ,
collectionId : '' ,
2024-10-08 18:34:22 +08:00
tagsDTO : [ ] ,
2024-06-17 09:39:01 +08:00
// isAllowLikes:true,
2024-05-16 17:14:22 +08:00
}
2024-05-16 09:41:16 +08:00
}
2024-05-16 17:14:22 +08:00
let setCover = ( item : any ) => {
publishData . subPublishDate . coverId = item . designOutfitId
publishData . selectDate . url = item . url
2024-10-08 00:44:17 +08:00
}
let extractHashtags = ( text : any ) => {
// const regex = /#\S+\s{2}/g;
const regex = /#\S+\s/g ;
// 使用match方法提取匹配的字符串
const matches = text . match ( regex ) ;
// 处理提取结果,去掉空格并返回
return matches ? matches . map ( ( match : any ) => match . trim ( ) ) : [ ] ;
}
let textareaChange = ( ) => {
2024-10-08 18:34:22 +08:00
let tagListArr = extractHashtags ( publishData . subPublishDate . portfolioDes )
let tagsDTO : any = [ ]
tagListArr . forEach ( ( item : any ) => {
const index = tagList . value . findIndex ( ( obj : any ) => obj . tagName === item ) ;
if ( index > - 1 ) {
let obj = {
tagName : tagList . value [ index ] ,
tagId : tagList . value [ index ] . tagId
}
tagsDTO . push ( tagList . value [ index ] )
} else {
tagsDTO . push ( { tagName : item } )
}
} ) ;
publishData . subPublishDate . tagsDTO = tagsDTO
2024-05-16 09:41:16 +08:00
}
2024-06-17 09:39:01 +08:00
let setPermissionsItem = ( ) => {
// publishData.selectPermissions.isAllowLikes &&
if ( publishData . selectPermissions . isAllowComment && publishData . selectPermissions . isDisplayArea && publishData . selectPermissions . isSecondaryCreation ) {
publishData . setPermissionsAll = true
} else {
publishData . setPermissionsAll = false
}
}
let setPermissions = ( ) => {
// publishData.selectPermissions.isAllowLikes = publishData.setPermissionsAll;
publishData . selectPermissions . isAllowComment = publishData . setPermissionsAll
publishData . selectPermissions . isDisplayArea = publishData . setPermissionsAll
publishData . selectPermissions . isSecondaryCreation = publishData . setPermissionsAll
}
2024-05-16 17:14:22 +08:00
let cleardata = ( ) => {
2024-05-16 09:41:16 +08:00
publish . value = false
2024-05-16 17:14:22 +08:00
publishData . isShowMark = false
publishData . subPublishDate = { }
2024-05-16 09:41:16 +08:00
}
let cancelDsign = ( ) => {
Modal . confirm ( {
2024-06-21 10:30:09 +08:00
title : t ( 'Publish.jsContent1' ) ,
2024-05-16 09:41:16 +08:00
icon : createVNode ( ExclamationCircleOutlined ) ,
okText : 'Yes' ,
cancelText : 'No' ,
mask : false ,
centered : true ,
onOk ( ) {
2024-05-16 17:14:22 +08:00
cleardata ( )
2024-05-16 09:41:16 +08:00
}
} ) ;
}
let setPublish = ( ) => {
2024-06-17 09:39:01 +08:00
if ( ! publishData . subPublishDate . portfolioName ) {
2024-06-21 10:30:09 +08:00
return message . info ( t ( 'Publish.jsContent2' ) )
2024-06-17 09:39:01 +08:00
}
// if(!publishData.subPublishDate.portfolioDes){
// return message.info('Please enter a description')
// }
2024-05-16 09:41:16 +08:00
Modal . confirm ( {
2024-06-21 10:30:09 +08:00
title : t ( 'Publish.jsContent3' ) ,
2024-05-16 09:41:16 +08:00
icon : createVNode ( ExclamationCircleOutlined ) ,
okText : 'Yes' ,
cancelText : 'No' ,
mask : false ,
centered : true ,
onOk ( ) {
2024-05-16 17:14:22 +08:00
subPublish ( )
2024-05-16 09:41:16 +08:00
}
} ) ;
}
2024-05-16 17:14:22 +08:00
let subPublish = ( ) => {
2024-06-17 09:39:01 +08:00
let param = new FormData ( ) ;
// let fill = dataURLtoFile(publishData.selectDate.url,'collection')
// let aa = new File([fill], 'collection' + ".jpg");
let file = base64ToFile ( publishData . selectDate . url , 'collection' )
param . append ( 'file' , file )
publishData . subPublishDate . openSource = publishData . selectPermissions . isSecondaryCreation ? 1 : 0
param . append ( 'data' , JSON . stringify ( publishData . subPublishDate ) )
2024-10-08 18:34:22 +08:00
param . append ( 'tagsDTO' , JSON . stringify ( publishData . subPublishDate . tagsDTO ) )
2024-06-17 09:39:01 +08:00
let config : any = { headers : { 'Content-Type' : 'multipart/form-data' , 'Accept' : '*/*' } }
// let data = publishData.subPublishDate
2024-05-16 17:14:22 +08:00
publishData . isShowMark = true
2024-06-17 09:39:01 +08:00
Https . axiosPost ( Https . httpUrls . publish , param , config )
2024-05-16 17:14:22 +08:00
. then ( ( rv ) => {
cleardata ( )
publishData . isShowMark = false
2024-06-26 17:26:31 +08:00
emit ( 'setPublish' )
2024-06-21 10:30:09 +08:00
message . success ( t ( 'Publish.jsContent4' ) )
2024-07-08 09:42:21 +08:00
setBeenPublished ( )
2024-05-16 17:14:22 +08:00
} )
. catch ( ( rv ) => {
publishData . isShowMark = false
} ) ;
}
2024-10-08 00:44:17 +08:00
let pushTag = ( tag : any , index : number ) => {
// let selectTag = tagList.value.splice(index,1)[0]
// selectTagList.value.push(selectTag)
// if(tag.tag == 'RCAworkshop_2024'){
// publishData.subPublishDate.portfolioDes = '#AiDA x RCA workshop '
// }
2024-10-08 18:34:22 +08:00
publishData . subPublishDate . portfolioDes = publishData . subPublishDate . portfolioDes + tag . tagName
2024-10-08 00:44:17 +08:00
textareaChange ( )
}
2024-05-16 09:41:16 +08:00
return {
publish ,
publishMask ,
2024-05-16 17:14:22 +08:00
... toRefs ( publishData ) ,
2024-10-08 00:44:17 +08:00
tagList ,
2024-05-16 09:41:16 +08:00
// textarea,
// setCopy,
init ,
2024-10-08 00:44:17 +08:00
textareaChange ,
2024-06-17 09:39:01 +08:00
setPermissionsItem ,
setPermissions ,
2024-05-16 09:41:16 +08:00
// download,
// setScaleImageIndex,
// LikeFile,
2024-05-16 17:14:22 +08:00
setCover ,
2024-05-16 09:41:16 +08:00
cancelDsign ,
setPublish ,
2024-10-08 00:44:17 +08:00
pushTag ,
2024-05-16 09:41:16 +08:00
} ;
} ,
data ( ) {
return {
// moodTemplateId: "", //模板id
} ;
} ,
mounted ( ) {
} ,
methods : {
} ,
} ) ;
< / script >
< style lang = "less" >
. publish _modal {
. publish _page {
overflow - y : auto ;
height : 100 % ;
& . publish _page : : - webkit - scrollbar { display : none ; }
}
. publish _content {
display : flex ;
flex - direction : column ;
height : 100 % ;
}
. publish _content _bottom {
-- border - color : # c4c4c4 ;
display : flex ;
justify - content : space - between ;
flex : 1 ;
2024-06-17 09:39:01 +08:00
height : calc ( 100 % - 10 rem ) ;
2024-10-08 00:44:17 +08:00
. publidh _content _item _tagList , . publidh _content _item _tag {
// height: 4rem;
border - radius : 1 rem ;
display : flex ;
align - items : center ;
flex - wrap : wrap ;
}
. publidh _content _item _tagList {
margin - top : 1 rem ;
. ant - tag {
cursor : pointer ;
margin - bottom : 8 px ;
}
}
2024-05-16 09:41:16 +08:00
. publidh _left , . publidh _right {
display : flex ;
flex - direction : column ;
}
. publidh _content _item {
margin - bottom : 2 rem ;
. publidh _content _item _title {
font - weight : 600 ;
font - size : 1.8 rem ;
margin - bottom : 1 rem ;
}
2024-10-08 00:44:17 +08:00
2024-05-16 09:41:16 +08:00
. publidh _content _item _intro {
font - size : 1.4 rem ;
}
input {
width : 100 % ;
border - radius : 1 rem ;
height : 4 rem ;
padding - left : 2 rem ;
font - size : 2 rem ;
border : .2 rem solid var ( -- border - color ) ;
}
textarea {
flex : 1 ;
margin - top : var ( -- padding ) ;
width : 100 % ! important ;
height : 10 rem ! important ;
border - radius : 1 rem ;
border : .2 rem solid var ( -- border - color ) ;
font - size : 1.8 rem ;
padding : 1 rem ;
color : # 575757 ;
outline : none ; /* 清除默认焦点样式 */
}
textarea : focus {
border : .2 rem solid var ( -- border - color ) ;
outline : none ; /* 清除默认焦点样式 */
}
}
. publidh _content _item : last - child {
margin - bottom : 0 ;
}
. publidh _left {
width : 45 % ;
2024-06-17 09:39:01 +08:00
. publidh _content _item {
height : 100 % ;
}
2024-05-16 09:41:16 +08:00
. publish _content _shrink {
width : 100 % ;
2024-06-17 09:39:01 +08:00
height : calc ( 100 % - 4 rem ) ;
2024-05-16 09:41:16 +08:00
img {
width : 100 % ;
object - fit : contain ;
2024-06-17 09:39:01 +08:00
// object-fit: cover;
// max-height: 30rem;
max - height : 100 % ;
2024-05-16 09:41:16 +08:00
}
}
. publidh _left _thubnai {
flex : 1 ;
. publidh _left _thubnail _list {
display : flex ;
overflow - x : auto ;
height : 24 rem ;
img {
2024-05-16 17:14:22 +08:00
cursor : pointer ;
2024-05-16 09:41:16 +08:00
height : 100 % ;
margin - right : 1 rem ;
}
img : last - child {
margin - right : 0 ;
}
}
}
}
. publidh _right {
width : 45 % ;
2024-05-16 17:14:22 +08:00
. publidh _right _zhuyi {
2024-05-16 09:41:16 +08:00
margin - top : auto ;
2024-05-16 17:14:22 +08:00
}
. publidh _right _btn {
2024-05-16 09:41:16 +08:00
display : flex ;
align - items : center ;
justify - content : flex - end ;
> div : nth - child ( 1 ) {
margin - right : auto ;
}
> div : nth - child ( 2 ) {
margin - right : 1 rem ;
}
}
2024-06-17 09:39:01 +08:00
. publidh _right _detail {
display : flex ;
flex - direction : column ;
label {
display : flex ;
}
}
2024-05-16 09:41:16 +08:00
}
}
}
< / style >