Files
aida_front/src/component/Detail/habit.vue
X1627315083 5b6844a9f0 2023-11-3-1
2023-11-03 11:16:42 +08:00

941 lines
24 KiB
Vue

<template>
<div class="habit">
<div v-show="openType.habit" class="habit_mask"></div>
<div class="habit_button" @click.stop="setOpenType('habit')" >
{{ $t('Habit.Workspace') }}
<i class="fi fi-bs-angle-down"></i>
</div>
<div class="habit_content" v-fade="openType.habit">
<div class="habit_title">
<h3>{{ $t('Habit.WorkspaceSetting') }}</h3>
<div class="habit_intro">{{ $t('Habit.settingWorkspace') }}</div>
</div>
<div class="habit_type" trigger="['click']" >
<a-dropdown placement="bottomRight" @click.stop="setOpenType('workspace')">
<a-button>
<UserOutlined />
{{workspaceItem.workSpaceName}}
<DownOutlined />
</a-button>
</a-dropdown>
<div class="habit_model_show habit_workspace_show" v-fade="openType.workspace">
<ul class="habit_model_list">
<li v-for="item,index in workspace.workspaceList">
<div @click.stop="setWorkspace(item.id)" v-show="!item.putName">{{ item.workSpaceName }}</div>
<input v-show="item.putName" type="text" v-model="workspaceItemName">
<i @click.stop="putName(index,'put')" v-show="!item.putName" class="fi fi-rr-edit"></i>
<i @click.stop="putName(index,'affirm')" v-show="item.putName" class="fi fi-br-check"></i>
<i @click.stop="putName(index,'delete')" class="fi fi-rr-trash"></i>
</li>
<li @click="newWorkspace" class="newWorkspace">
<input v-show="openType.addWorkspace" type="text" v-model="workspaceItemName">
<i @click.stop="putName(-1,'affirm')" v-show="openType.addWorkspace" class="fi fi-br-check"></i>
<div v-show="!openType.addWorkspace">+</div>
</li>
</ul>
</div>
</div>
<div class="habit_Overal_Single">
<a-dropdown @click.stop="setOpenType('sex')">
<a-button>
<UserOutlined />
{{ workspaceItem.sex }}
<DownOutlined />
</a-button>
</a-dropdown>
<div class="habit_model_show habit_sex_show" v-fade="openType.sex">
<ul class="habit_model_list">
<li v-for="item,index in sex">
<div @click.stop="setSex(item.value)">{{ item.label }}</div>
</li>
</ul>
</div>
</div>
<div class="habit_Overal_Single">
<div
class="habit_Overal_Single_text"
:class="{ active: !workspaceItem.overallSingle }"
>
{{ $t('Habit.Overall') }}
</div>
<a-switch @click="setOverallSingle" v-model:checked="workspaceItem.overallSingle" />
<div
class="habit_Overal_Single_text"
:class="{ active: workspaceItem.overallSingle }"
>
{{ $t('Habit.Single') }}
</div>
</div>
<div class="habit_habit_singleton" v-show="workspaceItem.overallSingle">
<a-dropdown @click.stop="setOpenType('singleton')">
<a-button>
<UserOutlined />
{{ workspaceItem.position }}
<DownOutlined />
</a-button>
</a-dropdown>
<div class="habit_model_show habit_singleton_show" v-fade="openType.singleton">
<ul class="habit_model_list">
<li v-for="item,index in singleTypeList">
<div @click.stop="setSingle(item.value)">{{ item.label }}</div>
</li>
</ul>
</div>
</div>
<div class="habit_System_Designer">
<a-slider id="system_silder"
v-model:value="workspaceItem.systemDesignerPercentage"
@afterChange="systemDesigner"
:tip-formatter="formatter"
>
</a-slider>
<div class="habit_System_Designer_text_max">
<div class="habit_System_Designer_text">{{ $t('Habit.System') }}</div>
<div class="habit_System_Designer_text">{{ $t('Habit.Designer') }}</div>
</div>
</div>
<div class="habit_model">
<a-dropdown placement="bottomRight"
trigger="['click']"
@click.stop="setOpenType('model')"
>
<a-button>
<UserOutlined />
{{ $t('Habit.Mannequin') }}
<DownOutlined />
</a-button>
</a-dropdown>
</div>
<div id="modelShow" class="habit_model_show" v-fade="openType.model">
<div class="habit_btn">
<div class="model_current">
<div class="model_text">{{ $t('Habit.Current') }}</div>
<div class="model_img">
<img :src="workspaceItem.mannequinUrl" alt="">
</div>
</div>
<div class="model_Designer">
<div class="model_text">
<div
class="habit_System_Seleves_text"
:class="{ active: !systemSeleves }"
>
{{ $t('Habit.System') }}
</div>
<a-switch :disabled="mannequins?.[0]==null?true:false" v-model:checked="systemSeleves" />
<div
class="habit_System_Seleves_text"
:class="{ active: systemSeleves }"
>
{{ $t('Habit.User') }}
</div>
</div>
<div class="model_img" v-show="systemSeleves" v-mousewheel>
<div class="model_img_item">
<div v-for="(item,index) in mannequins?.[0]?.modelList" :key="item.id">
<img :src="item?.presignedUrl" alt="" @click="setMannequins(item,'Library')">
</div>
</div>
</div>
<div class="model_img" v-show="!systemSeleves" v-mousewheel>
<div class="model_img_item">
<div v-for="(item,index) in mannequins?.[1]?.modelList" :key="item.id">
<img :src="item?.presignedUrl" alt="" @click="setMannequins(item,'System')">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script lang="ts">
import { useStore } from "vuex";
import { defineComponent, createVNode, ref,Ref} from "vue";
import { UserOutlined, DownOutlined } from "@ant-design/icons-vue";
import { Https } from "@/tool/https";
import type { MenuProps } from "ant-design-vue";
import { Modal,message,Upload} from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import { useI18n } from "vue-i18n";
export default defineComponent({
components: {
DownOutlined,
UserOutlined,
},
setup(){
let workspaceItem:any = ref({
id:1,
id_:1,
workSpaceName:"工作台1",
putName:false,
systemDesignerPercentage:30,
position:'',
sex:'',
overallSingle:false,
mannequinUrl:'',
mannequinType:'',
mannequinId:'',
})
let mannequins:any = ref([{},{}])
let systemSeleves= ref(false);
let openType = ref({
workspace:false,
singleton:false,
habit:false,
model:false,
addWorkspace:false,
sex:false
})
let workspace:any = ref({
});
let workspaceItemName = ref('')//设置单独name公共使用
let singleTypeList:any = ref([
])
let sex = ref([
])
const {t} = useI18n()
return{
systemSeleves,
mannequins,
openType,
workspace,
workspaceItem,
workspaceItemName,
singleTypeList,
sex,
t
}
},
watch:{
'openType.habit':{
handler(newVal:any,oldVal:any){
// this.store.state.Workspace.workspace
if(!newVal){
if(!this.workspaceItem.overallSingle){
this.workspaceItem.position = 'Overall'
}
let data = this.workspaceItem
delete data.isLastIndex
this.putWorkspace(data,'')
this.store.commit("setWorkspace", this.workspaceItem);
}
}
},
'workspaceItem.id_':{
handler(newVal:any,oldVal:any){
// this.store.state.Workspace.workspace
// if(!newVal){
// this.store.commit("setWorkspace", this.workspaceItem);
// }
this.workspace.workspaceList.forEach((v:any)=>{
if(v.id == this.workspaceItem.id_){
this.workspaceItem = v
this.workspaceItem.id_ = v.id
}
if(v.id == oldVal){
delete v.isLastIndex
this.putWorkspace(v,newVal)
// this.getDetail(newVal)
}
})
this.getMannequins()
}
},
workspaceItem:{
handler(newVal:any,oldVal:any){
this.store.commit("setWorkspace", this.workspaceItem);
}
}
},
data() {
return {
store: useStore(),
};
},
async mounted() {
this.getworkspace()
this.getSex()
},
directives:{
fade:{
mounted (el,binding) {
el.addEventListener('click',()=>{
})
},
updated (el,model){
if(model.value){
el.style.display="block"
setTimeout(() => {
el.classList.add("active")
}, 100);
}else{
el.classList.remove("active")
setTimeout(() => {
el.style.display="none"
}, 100);
}
}
},
mousewheel:{
mounted (el) {
el.addEventListener('wheel',(e:WheelEvent)=>{
let num = 0
if(e.deltaY > 0){
num = 25
}else{
num = -25
}
el.scrollBy(num, 0);
})
}
}
},
methods: {
getSex(){
Https.axiosGet(Https.httpUrls.workspaceenumValues,{params:{enumName:'Sex'}}).then((rv: any) => {
if (rv) {
let arr:any = []
rv.forEach((item:any) => {
let obj = {
value:item.name,
label:item.name,
}
arr.push(obj)
});
this.sex = arr
this.getPosition()
}
})
},
getPosition(){
let params
if(this.workspaceItem.sex == 'Female'){
params = 'FemalePosition'
}else{
params = 'MalePosition'
}
Https.axiosGet(Https.httpUrls.workspaceenumValues,{params:{enumName:params}}).then((rv: any) => {
if (rv) {
let arr:any = []
rv.forEach((item:any) => {
let obj = {
value:item.name,
label:item.name,
}
arr.push(obj)
});
this.singleTypeList = arr
if(this.workspaceItem.overallSingle){
this.workspaceItem.position = this.singleTypeList[0].label
}
}
})
},
getworkspace(){
// Https.axiosGet(Https.httpUrls.workspaceDetail,{params:{id:3}}).then((rv: any) => {
// if (rv) {
// console.log(rv,'workspace');
// }
// })
let data = {
page:1,
size:10,
}
Https.axiosPost(Https.httpUrls.workspaceList,data).then((rv: any) => {
if (rv) {
rv.page.content.forEach((v:any) => {
v.id_ = v.id
if(v.position == "Overall"){
v.overallSingle = false
}else{
v.overallSingle = true
}
v.putName = false
if(v.id == rv.id){
this.workspaceItem = v
this.setMannequinsSex()
}
});
this.workspace.id = rv.id
this.workspace.workspaceList = rv.page.content
}
})
},
getDetail(id:any){//
Https.axiosGet(Https.httpUrls.workspaceDetail,{params:{id:id}}).then((rv: any) => {
if (rv) {
this.getworkspace()
}
})
},
getMannequins(){//获取模特
Https.axiosGet(Https.httpUrls.getMannequins,{params:{sex:this.workspaceItem.sex}}).then((rv: any) => {
if (rv) {
// rv.forEach((item:any)=>{
// item.type ==
// })
if(rv[0].type == 'System'){
let a = rv[0]
rv[0] = rv[1]
rv[1] = a
}
this.mannequins = rv
if(this.mannequins?.[0]==null){
this.systemSeleves = false
}
}
})
},
putWorkspace(data:any,index:any){//修改workspace
Https.axiosPost(Https.httpUrls.workspacesaveOrUpdate,data).then((rv: any) => {
if (rv) {
if(index){
this.getDetail(index)
}else{
this.getworkspace()
}
}
})
},
deleteWorkspace(data:any){
Https.axiosDelete(Https.httpUrls.workspaceRemove,data).then((rv: any) => {
if (rv) {
this.getworkspace()
}
})
},
//
setOverallSingle(){
if(this.workspaceItem.overallSingle){
this.workspaceItem.position = this.singleTypeList[0].label
}else{
this.workspaceItem.position = 'Overall'
}
},
cancelDsign(index:any){
let _this = this
Modal.confirm({
title: _this.t('Habit.jsContent1'),
icon: createVNode(ExclamationCircleOutlined),
okText: 'Yes',
cancelText: 'No',
mask:false,
wrapClassName:'habit',
zIndex:999999999,
// centered:true,
onOk() {
let data = [{
id:_this.workspace.workspaceList[index].id,
}]
let id = _this.workspace.workspaceList[index].id
_this.deleteWorkspace(data)
}
});
},
//修改名字
putName(index:number,v:string){
this.workspace.workspaceList.forEach((v:any )=> {
v.putName = false
});
if(v == 'put'){
this.workspaceItemName = this.workspace.workspaceList[index].workSpaceName
this.workspace.workspaceList[index].putName = true
}else if (v == 'delete'){
this.cancelDsign(index)
// let data = [{
// id:this.workspace.workspaceList[index].id,
// }]
// let id = this.workspace.workspaceList[index].id
// this.deleteWorkspace(data)
}else{
if(this.workspaceItemName == ''){
message.warning(this.t('Habit.jsContent2'));
}else{
if(index == -1){
let data = {
workSpaceName:this.workspaceItemName,
}
this.putWorkspace(data,'')
this.openType.addWorkspace = false
}else{
let data:any
this.workspace.workspaceList.forEach((item:any)=>{
if(this.workspace.workspaceList[index].id == item.id){
data = item
}
})
data.workSpaceName = this.workspaceItemName
this.putWorkspace(data,'')
this.workspace.workspaceList[index].workSpaceName = this.workspaceItemName
this.workspace.workspaceList[index].putName = false
}
}
}
},
//设置系统设计占比
systemDesigner(num: number) {
this.workspaceItem.systemDesignerPercentage = num
},
formatter(value: number) {
return `${value}%`;
},
//根据id设置当前参数
setWorkspace(num:number){
this.openType.addWorkspace = false
this.workspace.workspaceList.forEach((v:any) => {
v.putName = false
});
this.workspaceItem.id_ = num
this.openType.workspace = false
},
//新建参数
newWorkspace(){
this.workspaceItemName = ''
this.openType.addWorkspace = true
},
setSex(v:any){
this.openType.sex = false
this.workspaceItem.sex = v
this.getMannequins()
this.setMannequinsSex()
this.getPosition()
},
//设置single & overall
setSingle(v:string){
this.openType.singleton = false
this.workspaceItem.position = v
},
setMannequins(item:any,str:string){//设置模特
// this.workspaceItem.mannequinId = item.id
// this.workspaceItem.mannequinType = str
// this.workspaceItem.mannequinUrl = item.presignedUrl
if(this.workspaceItem.sex == 'Female'){
this.workspaceItem.femalePresignedUrl = item.presignedUrl
this.workspaceItem.mannequinFemaleType = str
this.workspaceItem.mannequinFemaleId = item.id
}else if(this.workspaceItem.sex == 'Male'){
this.workspaceItem.malePresignedUrl = item.presignedUrl
this.workspaceItem.mannequinMaleType = str
this.workspaceItem.mannequinMaleId = item.id
}
this.workspaceItem.mannequinUrl = item.presignedUrl
this.workspaceItem.mannequinType = str
this.workspaceItem.mannequinId = item.id
},
setMannequinsSex(){
if(this.workspaceItem.sex == 'Female'){
this.workspaceItem.mannequinUrl = this.workspaceItem.femalePresignedUrl
this.workspaceItem.mannequinType = this.workspaceItem.mannequinFemaleType
this.workspaceItem.mannequinId = this.workspaceItem.mannequinFemaleId
}else if(this.workspaceItem.sex == 'Male'){
this.workspaceItem.mannequinUrl = this.workspaceItem.malePresignedUrl
this.workspaceItem.mannequinType = this.workspaceItem.mannequinMaleType
this.workspaceItem.mannequinId = this.workspaceItem.mannequinMaleId
}
},
setOpenType(v:string){
if(v == 'habit'){
this.openType.habit = !this.openType.habit
}else if(v == 'workspace'){
this.openType.singleton = false
this.openType.sex = false
// this.workspace.workspaceList.forEach((v:any) => {
// v.putName = false
// });
this.openType.workspace = !this.openType.workspace
}else if(v == 'model'){
this.openType.singleton = false
this.openType.workspace = false
this.openType.sex = false
this.openType.model = !this.openType.model
this.getMannequins()
}else if(v == 'singleton'){
this.openType.singleton = !this.openType.singleton
this.openType.workspace = false
this.openType.sex = false
}else if(v == 'sex'){
this.openType.sex = !this.openType.sex
this.openType.workspace = false
this.openType.singleton = false
}
let mask = document.getElementsByClassName("habit_mask")[0]
mask.addEventListener("click", this.documentClick,true);
},
documentClick(){
let mask = document.getElementsByClassName("habit_mask")[0]
mask.removeEventListener("click", this.documentClick);
this.openType.habit = false
this.openType.workspace = false
this.openType.model = false
this.openType.singleton = false
this.openType.sex = false
},
// //选择模特
// selectModels() {
// let modelsModal: any = this.$refs.modelsModal;
// modelsModal.init();
// },
// //确定选择模特
// sureSelectModel(event: any) {
// this.store.commit("setTemplateData", event);
// },
},
});
</script>
<style lang="less" scoped>
.habit {
position: relative;
.habit_button {
background-color: #fff;
border: solid 2px #000;
padding: 0px 2rem;
box-sizing: initial;
font-weight: 600;
height: 3.2rem;
line-height: 3.2rem;
padding: .4rem 1.5rem;
font-size: 1.2rem;
cursor: pointer;
position: relative;
.fi-bs-angle-down {
margin-left: 1rem;
display: inline-block;
transform: translateY(2px);
}
}
.habit_mask{
position: absolute;
top: -20px;
left: auto;
right: -30px;
bottom: 0;
// background: #000;
opacity: 0;
width: 100vw;
height: 100vh;
}
.habit_content {
border: solid 2px #000;
border-radius: 1rem;
padding: 2rem;
// zoom: .75;
font-size: 1.6rem;
transform-origin: top right;
position: absolute;
right: -.3rem;
top: 110%;
background: #fff;
// width: 25rem;
width: 30rem;
opacity: 0;
transition: all .3s;
transform: scale(0.75)translateY(10%);
display: none;
&.active{
opacity: 1;
transform: scale(0.75)translateY(0%);
}
.habit_title {
h3 {
font-size: 1.6rem;
font-weight: 600;
color: #000;
margin: 0;
}
.habit_intro {
font-size: 1.2rem;
color: rgba(0, 0, 0, 0.5);
font-weight: 500;
}
}
.habit_type {
margin-top: 1.5rem;
cursor: pointer;
position: relative;
.habit_workspace_show{
width: 100%;
z-index: 1;
transform: translateY(10%);
top: 4rem;
height: 14rem;
overflow-x: hidden;
cursor: auto;
&.active{
transform: translateY(0%);
}
}
}
.habit_Overal_Single {
display: flex;
align-items: center;
justify-content: center;
margin: 3rem 0;
position: relative;
.habit_Overal_Single_text {
font-weight: 600;
color: rgba(0, 0, 0, 0.5);
&.active {
color: rgba(0, 0, 0, 0.7);
font-weight: 900;
}
}
:deep(.ant-switch) {
margin: 0 1rem;
}
.habit_sex_show{
width: 100%;
z-index: 1;
transform: translateY(10%);
top: 4rem;
height: 14rem;
overflow-x: hidden;
cursor: auto;
&.active{
transform: translateY(0%);
}
}
}
.habit_habit_singleton {
margin-bottom: 3rem;
position: relative;
.habit_singleton_show{
width: 100%;
z-index: 1;
transform: translateY(10%);
top: 4rem;
height: 14rem;
overflow-x: hidden;
cursor: auto;
&.active{
transform: translateY(0%);
}
}
}
.habit_System_Designer {
margin-top: 8rem;
:deep(.ant-slider-track),
:deep(.ant-slider-rail) {
height: .6rem;
background-color: #e1e1e1;
border-radius: 0.5rem;
}
:deep(.ant-slider .ant-slider-handle:not(.ant-tooltip-open)),
:deep(.ant-slider-handle) {
background-color: #2d2e76 !important;
border: none !important;
}
:deep(.ant-slider-handle:hover) {
box-shadow: 0 0 0 5px rgba(45, 46, 118, 0.2);
}
.habit_System_Designer_text_max {
display: flex;
justify-content: space-between;
.habit_System_Designer_text {
}
}
}
.habit_model{
margin-top: 2rem;
}
.habit_model_show{
position: absolute;
background-color: #fff;
border: solid 2px #000;
border-radius: 1rem;
padding: 2rem;
bottom: -.5rem;
transform: translateY(110%);
right: -.2rem;
width: 40rem;
// width: 35rem;
opacity: 0;
transition: all .3s;
display: none;
&.active{
opacity: 1;
transform: translateY(100%);
}
.habit_btn{
display: flex;
justify-content: space-between;
.model_current{
margin-right: 3rem;
.model_text{
text-align: center;
}
}
}
.habit_model_list{
margin: 0;
li{
padding: .5rem 0;
display: flex;
input{
border: 0;
width: 80%;
background: rgba(0,0,0,0);
}
>div{
cursor: pointer;
width: 80%;
white-space: nowrap;
text-overflow:ellipsis;
overflow:hidden;
}
&.newWorkspace{
text-align: center;
justify-content: center;
div{
border-radius: 50%;
border: 1px solid #000;
display: inline-block;
width: 2rem;
height: 2rem;
line-height: 2rem;
text-align: center;
}
i{
flex: 1;
}
}
i{
cursor: pointer;
}
.fi-rr-trash{
margin-left: 1rem;
}
}
li:hover{
background: rgba(0, 0, 0, 0.1);
}
}
.model_Designer{
flex: 1;
overflow: hidden;
display: flex;
flex-direction: column;
.model_text{
display: flex;
justify-content: center;
:deep(.ant-switch) {
margin: 0 1rem;
}
.habit_System_Seleves_text {
font-weight: 600;
color: rgba(0, 0, 0, 0.5);
&.active {
color: rgba(0, 0, 0, 0.7);
font-weight: 900;
}
:deep(.ant-switch-checked) {
background-color: #000;
}
}
}
}
.model_img{
display: flex;
flex: 1;
align-items: center;
overflow-x: auto;
&.model_img::-webkit-scrollbar {
/* 竖轴的宽度 */
width: 1rem;
/* 横轴的高度 */
height: 1rem;
transition: all .3s;
}
/* 进度 */
&.model_img::-webkit-scrollbar-thumb {
border-radius: 1rem;
background: rgba(238, 238, 244, 0);
}
/* 轨道 */
&.model_img::-webkit-scrollbar-track {
border-radius: 1rem;
background: rgba(238, 238, 244, 0);
}
&.model_img:hover {
// overflow-x: scroll;
&.model_img::-webkit-scrollbar-thumb {
background: #543087;
}
/* 轨道 */
&.model_img::-webkit-scrollbar-track {
background: rgba(84, 48, 135,.2);
}
}
>div{
display: flex;
}
div{
width: auto;
margin-right: 1rem;
}
img{
width: 10rem;
cursor: pointer;
}
}
}
}
}
.habit :deep(.ant-dropdown-button) {
margin-right: 8px;
margin-bottom: 8px;
}
.habit :deep(.ant-btn) {
box-shadow: none !important;
color: rgba(0, 0, 0, 0.5);
box-shadow: none;
border: none;
background: #f6f6f6;
width: 100%;
font-weight: 600;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 1.4rem;
}
</style>
<style>
.ant-tooltip{
z-index: 1049 !important;
}
.habit :deep(.ant-tooltip .ant-tooltip-inner) ,:deep(.ant-tooltip-arrow-content){
background: #000 !important;
}
.habit_mod{
background-color: #000 !important;
/* top: 0 !important; */
/* left: 0 !important; */
}
.ant-tooltip .ant-tooltip-inner ,.ant-tooltip-arrow-content{
background: #000 !important;
}
</style>