Files
aida_front/src/component/HomePage/Material.vue

650 lines
19 KiB
Vue
Raw Normal View History

2023-01-06 16:00:15 +08:00
<template>
2023-08-05 12:52:56 +08:00
<div class="my_material_modal">
<!-- <a-modal class="my_material_modal"
2023-01-06 16:00:15 +08:00
v-model:visible="myMaterialModalShow"
:footer="null"
width="80%"
:maskClosable="false"
:centered="true"
2023-08-05 12:52:56 +08:00
> -->
2023-01-06 16:00:15 +08:00
<div class="my_material_header">
<div class="my_material_header_right">
<div class="content_search_block">
2023-11-09 10:16:18 +08:00
<input class="search_input" :placeholder="$t('Material.inputContent1')" v-model="searchPictureName" @keydown.enter="getLibraryList('')">
<div class="search_icon_block" @click.stop="getLibraryList('')"><span class="icon iconfont icon-sousuo"></span></div>
2023-01-06 16:00:15 +08:00
</div>
</div>
</div>
<div class="my_material_content">
2023-09-12 10:11:27 +08:00
2023-01-06 16:00:15 +08:00
<div class="material_content_body scroll_style">
2023-09-12 10:11:27 +08:00
<div v-for="item,index in imgList" :key="item" class="content_img_item" :class="[ item?.checked ? 'active':'' , selectCode == 'Moodboard' ? 'moodb':'' ]" >
2023-11-08 09:31:40 +08:00
<img :src="item?.imgUrl" @click.stop="selectImgItem(item)">
2023-09-12 10:11:27 +08:00
<div v-if="selectCode == 'Sketchboard'" class="operate_file_block">
<div class="select_img_type">
<div
class="select_category"
@click.stop="showFileCategory(item)"
>
2023-11-23 14:05:35 +08:00
{{ item?.categoryValue }}
2023-09-12 10:11:27 +08:00
<div
:class="[
'icon',
'iconfont',
'icon-xiala',
2023-10-11 17:34:14 +08:00
item?.categoryShow
2023-09-12 10:11:27 +08:00
? 'icon_rotate'
: '',
]"
></div>
</div>
<div
class="category_list"
2023-10-11 17:34:14 +08:00
v-show="item?.categoryShow"
2023-09-12 10:11:27 +08:00
>
<div
:class="[
'category_item',
2023-11-23 14:05:35 +08:00
item?.category == cate.name
2023-09-12 10:11:27 +08:00
? 'select_category_item'
: '',
]"
v-for="(
cate, index
) in disignTypeList"
:key="index"
@click.stop="selectFileCategory(item, cate)"
>
2023-11-23 14:05:35 +08:00
{{ cate.value }}
2023-08-23 17:50:09 +08:00
</div>
</div>
2023-09-12 10:11:27 +08:00
</div>
2023-01-06 16:00:15 +08:00
</div>
2023-10-12 17:09:05 +08:00
<div v-if="selectCode == 'Sketchboard' || selectCode == 'Printboard'" class="pin_block">
2023-10-30 17:26:36 +08:00
<a-checkbox v-model:checked="item.pin">{{ $t('Material.PIN') }}</a-checkbox>
2023-10-12 17:09:05 +08:00
</div>
2023-09-12 10:11:27 +08:00
</div>
2023-12-19 16:36:48 +08:00
<div v-show="total > imgList?.length && total != 0" class="material_content_list_loding" v-observe>
2023-09-25 10:09:00 +08:00
<img src="@/assets/images/homePage/loading.gif" alt="">
</div>
2023-01-06 16:00:15 +08:00
</div>
<div class="no_data_block loading_block" v-show="isShowLoading">
<a-spin size="large"></a-spin>
</div>
2023-08-05 12:52:56 +08:00
2023-01-06 16:00:15 +08:00
</div>
2023-08-05 12:52:56 +08:00
<!-- </a-modal> -->
2023-01-06 16:00:15 +08:00
</div>
</template>
<script lang="ts">
2023-10-11 17:34:14 +08:00
import { defineComponent, computed, ref} from 'vue'
2023-01-06 16:00:15 +08:00
import { Https } from "@/tool/https";
import { message } from 'ant-design-vue';
2023-08-05 12:52:56 +08:00
import { useStore } from "vuex";
import GO from '@/tool/GO';
2023-10-31 16:04:40 +08:00
import { useI18n } from 'vue-i18n';
2023-08-05 12:52:56 +08:00
2023-01-06 16:00:15 +08:00
export default defineComponent({
2023-10-20 17:21:45 +08:00
props: ["msg",'disignTypeList'],
2023-08-21 10:55:39 +08:00
setup(prop) {
2023-01-06 16:00:15 +08:00
let myMaterialModalShow = ref(false)
2023-11-08 09:31:40 +08:00
let imgList:any = ref([])
2023-01-06 16:00:15 +08:00
let isShowLoading:any = ref(false)
let selectCode:any = ref('')
let currentPage:any = ref(1)
let searchPictureName = ref('')
2023-12-19 16:36:48 +08:00
let isOldSearchPictureName = ref('')
2023-09-25 10:09:00 +08:00
let pageSize = ref(12)
2023-01-06 16:00:15 +08:00
let total = ref(0)
let searcMaterialhName:any = ref('') //搜索名字
let designType:any = ref(null)
2023-10-20 17:21:45 +08:00
// let disignTypeList:any = ref([
2023-10-11 17:34:14 +08:00
2023-10-20 17:21:45 +08:00
// ])
2023-10-11 17:34:14 +08:00
let workspace:any = ref({})
2023-10-31 16:04:40 +08:00
let {t} = useI18n()
2023-01-06 16:00:15 +08:00
return{
myMaterialModalShow,
imgList,
isShowLoading,
selectCode,
currentPage,
searchPictureName,
2023-12-19 16:36:48 +08:00
isOldSearchPictureName,
2023-01-06 16:00:15 +08:00
pageSize,
total,
searcMaterialhName,
designType,
2023-10-20 17:21:45 +08:00
// disignTypeList,
2023-10-31 16:04:40 +08:00
workspace,
t
2023-01-06 16:00:15 +08:00
}
},
2023-08-21 10:55:39 +08:00
data (prop) {
return {
type_ : {
type1:'material',
type2:prop.msg
2023-10-11 17:34:14 +08:00
},
store: useStore(),
2023-08-21 10:55:39 +08:00
}
},
2023-10-11 17:34:14 +08:00
directives:{
observe:{
mounted (el,binding) {
2023-10-12 17:09:05 +08:00
// console.log(binding.instance);
const ob = new IntersectionObserver(callback,{
root:null,
threshold:[0.1]
2023-10-11 17:34:14 +08:00
})
2023-10-12 17:09:05 +08:00
ob.observe(el)
// this.currentPage = 1
// this.pageSize = 12
let this_:any = binding.instance
function callback(entries:any, observer:any) {
entries.forEach((entry:any) => {
if (entry.isIntersecting) {
2023-11-09 10:16:18 +08:00
this_.getLibraryList('di')
2023-10-12 17:09:05 +08:00
} else {
}
});
}
2023-10-11 17:34:14 +08:00
},
},
},
2023-08-23 17:50:09 +08:00
computed: {
getSketchLabel(value:any) {
return (value: any) => {
let lable = "";
for (let item of this.disignTypeList) {
if (item.value === value) {
lable = item.label;
break;
}
}
return lable;
};
},
2023-10-11 17:34:14 +08:00
sketchboardList(){
return this.store.state.UploadFilesModule.sketchMaterialFiles
},
moodboardList(){
return this.store.state.UploadFilesModule.moodboardMaterialFiles
},
printboardList(){
return this.store.state.UploadFilesModule.printMaterialFiles
},
2023-08-23 17:50:09 +08:00
},
2023-10-11 17:34:14 +08:00
mounted () {
2023-10-13 17:06:44 +08:00
2023-10-12 17:09:05 +08:00
// let loding = document.getElementsByClassName("material_content_list_loding")[0]
// let bodyLoding = document.getElementsByClassName("material_content_body")[0]
// const ob = new IntersectionObserver(callback,{
// root:null,
// threshold:[0.1]
// })
// ob.observe(loding)
// console.log(loding);
// // this.currentPage = 1
// // this.pageSize = 12
// // let this_ = this
// function callback(entries:any, observer:any) {
// entries.forEach((entry:any) => {
// if (entry.isIntersecting) {
// console.log(111);
2023-11-09 10:16:18 +08:00
// // this_.getLibraryList('')
2023-10-12 17:09:05 +08:00
// } else {
// }
// });
// }
2023-10-11 17:34:14 +08:00
},
watch:{
sketchboardList:{
handler(newVal:any,oldVal:any){
// this.store.state.Workspace.workspace
oldVal.forEach((item:any) => {
if(newVal.findIndex((newValItem:any) =>newValItem.id == item.id) == -1){
this.imgList.forEach((i:any)=>{
if(i.id == item.id){
i.checked = false
}
})
}
});
},
},
moodboardList:{
handler(newVal:any,oldVal:any){
// this.store.state.Workspace.workspace
oldVal.forEach((item:any) => {
if(newVal.findIndex((newValItem:any) =>newValItem.id == item.id) == -1){
this.imgList.forEach((i:any)=>{
if(i.id == item.id){
i.checked = false
}
})
}
});
}
},
printboardList:{
handler(newVal:any,oldVal:any){
// this.store.state.Workspace.workspace
oldVal.forEach((item:any) => {
if(newVal.findIndex((newValItem:any) =>newValItem.id == item.id) == -1){
this.imgList.forEach((i:any)=>{
if(i.id == item.id){
i.checked = false
}
})
}
});
}
},
},
2023-01-06 16:00:15 +08:00
methods:{
init(code:any){
this.selectCode = code
2023-08-05 12:52:56 +08:00
// this.myMaterialModalShow = true
2023-11-09 10:16:18 +08:00
this.getLibraryList('')
2023-09-25 10:09:00 +08:00
2023-01-06 16:00:15 +08:00
},
selectImgItem(imgData:any){
2023-08-21 10:55:39 +08:00
imgData.type_ = this.type_
2023-09-12 10:11:27 +08:00
imgData.resData = JSON.parse(JSON.stringify(imgData))
2023-10-11 17:34:14 +08:00
this.imgList.forEach((v:any)=>{
v.categoryShow = false
})
2023-12-11 11:02:48 +08:00
let maxImg = 8
if(this.selectCode == 'Sketchboard'){
maxImg = 20
}
imgData.jsContent1 = this.t('uploadFile.jsContent1',{maxImg:maxImg})
2023-08-05 12:52:56 +08:00
this.store.commit("addGenerateMaterialFils", imgData);
2023-01-06 16:00:15 +08:00
},
//选择所有的图片
2023-12-20 17:03:42 +08:00
async getLibraryList(str:any){
let workspace = JSON.parse(JSON.stringify(this.store.state.Workspace.workspace))
if(this.searchPictureName != this.isOldSearchPictureName || this.workspace?.sex != workspace.sex){
this.imgList = []
this.currentPage = 1
}else{
}
2023-11-09 10:16:18 +08:00
if(str == 'di'){
this.currentPage = this.imgList?.[0]?.id != undefined?this.imgList?.length / this.pageSize+1:1
}
2023-01-06 16:00:15 +08:00
let data = {
level1Type:this.selectCode,
2023-08-05 12:52:56 +08:00
// level2Type:this.designType,
2023-10-12 17:09:05 +08:00
modelSex:workspace?.sex,
2023-11-09 10:16:18 +08:00
page: this.currentPage,
2023-11-08 09:31:40 +08:00
// page:this.currentPage,
2023-01-06 16:00:15 +08:00
pictureName:this.searchPictureName,
2023-11-08 09:31:40 +08:00
size:this.pageSize,
// size:this.imgList?.length + this.pageSize,
2023-01-06 16:00:15 +08:00
}
this.isShowLoading = true
2023-12-20 17:03:42 +08:00
await Https.axiosPost(Https.httpUrls.queryLibraryPage,data).then(
2023-01-06 16:00:15 +08:00
(rv: any) => {
2023-12-19 16:36:48 +08:00
this.total = rv.total
2023-08-05 12:52:56 +08:00
let aa:any = []
2023-09-25 10:09:00 +08:00
rv.content.forEach((item:any,index:any) => {
2023-10-11 17:34:14 +08:00
let arr
2023-08-23 17:50:09 +08:00
if(this.type_.type2 == 'Sketchboard'){
2023-10-11 17:34:14 +08:00
arr = this.store.state.UploadFilesModule.sketchMaterialFiles
2023-11-23 15:31:40 +08:00
item.categoryValue = item.level2TypeEnum.value;
2023-10-11 17:34:14 +08:00
item.category = item.level2Type;
2023-08-23 17:50:09 +08:00
item.categoryShow = false;
2023-10-11 17:34:14 +08:00
}else if(this.type_.type2 == 'Moodboard'){
arr = this.store.state.UploadFilesModule.moodboardMaterialFiles
}else if(this.type_.type2 == 'Printboard'){
arr = this.store.state.UploadFilesModule.printMaterialFiles
2023-08-23 17:50:09 +08:00
}
2023-09-25 10:09:00 +08:00
item.imgUrl = item.url
2023-10-11 17:34:14 +08:00
// aa.push(item)
if(!item.id_){
item.id_ = GO.id++
arr.forEach((v:any)=>{
if(item.id == v.id){
item.id_ = v.id_?v.id_:GO.id++
item.checked = true
2023-11-20 09:47:10 +08:00
item.pin = v.pin
2023-10-11 17:34:14 +08:00
}
})
}else{
}
2023-09-25 10:09:00 +08:00
aa.push(item)
2023-08-05 12:52:56 +08:00
});
2023-12-20 17:03:42 +08:00
2023-12-19 16:36:48 +08:00
this.isOldSearchPictureName = this.searchPictureName
if((aa[aa.length-1].id == this.imgList[this.imgList.length-1]?.id) && aa?.[aa.length-1]?.id){
2023-11-09 10:16:18 +08:00
}else{
this.imgList.push(...aa)
}
2023-12-20 17:03:42 +08:00
this.workspace = workspace
2023-11-09 10:16:18 +08:00
// this.imgList = aa
2023-01-06 16:00:15 +08:00
this.isShowLoading = false
}
).catch((res)=>{
this.isShowLoading = false
});
2023-08-23 17:50:09 +08:00
},
showFileCategory(file: any) {
file.categoryShow = true;
document.addEventListener("click", this.hiddenFileCategory);
},
selectFileCategory(file: any, cate: any) {
2023-11-23 14:05:35 +08:00
file.categoryValue = cate.value;
file.category = cate.name;
2023-08-23 17:50:09 +08:00
for (let item of (this.imgList as any)) {
item.categoryShow = false;
}
2023-10-11 17:34:14 +08:00
this.setSketchLibrary(file)
2023-08-23 17:50:09 +08:00
},
hiddenFileCategory() {
for (let item of (this.imgList as any)) {
item.categoryShow = false;
}
document.removeEventListener("click", this.hiddenFileCategory);
},
2023-10-11 17:34:14 +08:00
setSketchLibrary(item:any){
let data = {
2024-01-05 14:12:03 +08:00
libraryId:[item.id],
2023-10-11 17:34:14 +08:00
level2Type:item.category,
}
Https.axiosPost(Https.httpUrls.setSketchLibrary,data).then(
(rv: any) => {
}
).catch((res)=>{
});
},
2023-01-06 16:00:15 +08:00
}
})
</script>
<style lang="less">
.my_material_modal{
height: calc(30rem*1.2);
2023-08-05 12:52:56 +08:00
overflow-x: hidden;
border-right: 1px solid #e5e5e5;
2023-09-12 10:11:27 +08:00
flex: 1;
border-radius: 0;
2023-08-05 12:52:56 +08:00
&.my_material_modal::-webkit-scrollbar{display: none;}
2023-01-06 16:00:15 +08:00
.ant-modal-close{
width: calc(3.6rem*1.2);
height: calc(3.6rem*1.2);
2023-01-06 16:00:15 +08:00
position: absolute;
top: calc(-1.8rem*1.2);
right: calc(-1.8rem*1.2);
2023-01-06 16:00:15 +08:00
}
.ant-modal-header{
display: none;
}
.ant-modal-body{
background: #F2F3FB;
height: 80vh;
min-height: calc(72rem*1.2);
2023-01-06 16:00:15 +08:00
overflow-y: hidden;
padding: 0;
}
.my_material_header{
2023-08-05 12:52:56 +08:00
display: flex;
justify-content: flex-end;
2023-01-06 16:00:15 +08:00
align-items: center;
width: 100%;
2023-08-05 12:52:56 +08:00
height: auto;
padding: 0;
padding-top: calc(2.5rem*1.2);
padding-bottom: calc(2rem*1.2);
2023-08-05 12:52:56 +08:00
background-color: #fff;
position: sticky;
top: 0;
2023-09-12 10:11:27 +08:00
z-index: 2;
2023-01-06 16:00:15 +08:00
.my_material_header_right{
display: flex;
justify-content: space-between;
align-items: center;
.content_search_block{
margin-right: calc(5rem*1.2);
2023-01-06 16:00:15 +08:00
display: flex;
.search_input{
width: calc(15rem*1.2);
padding-left: calc(1.5rem*1.2);
// height: 4rem*1.2);
// line-height: 3.8rem*1.2);
2023-08-05 12:52:56 +08:00
// background: #FFFFFF;
border:calc( 0.1rem*1.2) solid #F1F1F1;
// font-size: 1.6rem*1.2);
font-size: calc(1.2rem*1.2);
2023-01-06 16:00:15 +08:00
font-weight: 400;
height: calc(3rem*1.2);
2023-01-06 16:00:15 +08:00
&::placeholder {
color: #C2C2C2;
}
}
.search_icon_block{
width: calc(5rem*1.2);
height: calc(3rem*1.2);
line-height: calc(3rem*1.2);
2023-01-06 16:00:15 +08:00
text-align: center;
background: #343579;
cursor: pointer;
.icon-sousuo{
font-size: calc(2rem*1.2);
2023-01-06 16:00:15 +08:00
color: #FFFFFF;
}
}
}
.icon_close{
color: rgba(174, 178, 183, 1);
font-size: calc(2.4rem*1.2);
2023-01-06 16:00:15 +08:00
cursor: pointer;
}
}
}
.my_material_content{
// padding: 0 3rem*1.2) 3.5rem*1.2) 3rem*1.2);
2023-08-05 12:52:56 +08:00
padding: 0;
// height: calc(100% - 6.6rem*1.2));
2023-09-12 10:11:27 +08:00
height: auto;
2023-01-06 16:00:15 +08:00
position: relative;
.material_content_top{
padding: calc(1.3rem*1.2) 0 calc(2.1rem*1.2);
height: calc(7rem*1.2);
2023-01-06 16:00:15 +08:00
display: flex;
justify-content: space-between;
align-items: center;
box-sizing: border-box;
.material_content_top_title{
font-size: calc(2rem*1.2);
2023-01-06 16:00:15 +08:00
color: #030303;
}
.material_content_top_right{
display: flex;
align-items: center;
.select_block{
background: #FFFFFF;
color: #1A1A1A !important;
margin-right: calc(2.3rem*1.2);
2023-01-06 16:00:15 +08:00
.icon-xiala{
color: #1A1A1A !important;
}
}
.check_all_block{
display: flex;
align-items: center;
font-size: calc(1.6rem*1.2);
2023-01-06 16:00:15 +08:00
color: #64686D;
cursor: pointer;
&.check_all{
color: #1A1A1A;
}
.check_block{
width: calc(2.4rem*1.2);
height: calc(2.4rem*1.2);
2023-01-06 16:00:15 +08:00
background: #EBECF4;
border: calc(0.1rem*1.2) solid #64686D;
padding: calc(0.3rem*1.2);
margin-right:calc( 0.7rem*1.2);
2023-01-06 16:00:15 +08:00
.check_block_body{
width: 100%;
height: 100%;
background: #343579;
}
}
}
}
}
.material_content_body{
width: 100%;
// height: calc(100% - 19rem*1.2));
2023-08-05 12:52:56 +08:00
height: 100%;
2023-01-06 16:00:15 +08:00
overflow-y: auto;
position: relative;
height: calc(30rem*1.2);
2023-09-25 10:09:00 +08:00
&.material_content_body::-webkit-scrollbar{display: none;}
2023-01-06 16:00:15 +08:00
.content_img_item{
margin: 0 calc(2rem*1.2) calc(5rem*1.2) 0;
2023-09-12 10:11:27 +08:00
display: inline-block;
width: calc(10rem*1.2);
height: calc(10rem*1.2);
2023-09-12 10:11:27 +08:00
border: 1px solid #f5f5f5;
position: relative;
cursor: pointer;
2023-08-05 12:52:56 +08:00
padding: 0;
2023-09-12 10:11:27 +08:00
img{
object-fit: cover;
width: 100%;
height: 100%;
}
&.moodb{
margin: 0 calc(2rem*1.2) calc(2rem*1.2) 0;
2023-09-12 10:11:27 +08:00
}
.pin_block{
.ant-checkbox-wrapper{
height:calc(2.2rem*1.2);
align-items: center;
span{
font-size: calc(1.4rem*1.2);
line-height: calc(2.3rem*1.2);
}
.ant-checkbox-inner{
width:calc( 1.6rem*1.2);
height: calc(1.6rem*1.2);
}
.ant-checkbox-inner::after{
width: calc(.571428571rem*1.2);
height: calc(.914285714rem*1.2);
}
}
}
2023-08-23 17:50:09 +08:00
&.active{
2023-09-12 10:11:27 +08:00
opacity: 0.5;
// border: 2px solid;
border-radius: calc(1rem*1.2);
2023-09-12 10:11:27 +08:00
transform: scale(0.9);
img {
}
2023-08-23 17:50:09 +08:00
.pin_block{
2023-09-12 10:11:27 +08:00
pointer-events:none;
2023-08-23 17:50:09 +08:00
}
2023-09-12 10:11:27 +08:00
.operate_file_block{
pointer-events:none;
2023-08-05 12:52:56 +08:00
}
2023-09-12 10:11:27 +08:00
}
2023-01-06 16:00:15 +08:00
.content_img_name{
width: calc(16.5rem*1.2);
height: calc(3.5rem*1.2);
line-height: calc(3.5rem*1.2);
2023-01-06 16:00:15 +08:00
white-space: nowrap;
text-align: center;
overflow: hidden;
text-overflow: ellipsis;
font-size: calc(1.4rem*1.2);
2023-01-06 16:00:15 +08:00
color: #030303;
}
}
2023-09-25 10:09:00 +08:00
.material_content_list_loding{
text-align: center;
img{
height: calc(10rem*1.2);
2023-09-25 10:09:00 +08:00
}
}
2023-01-06 16:00:15 +08:00
}
.no_data_block{
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
position: absolute;
left: 0;
top: 0;
z-index: 99;
&.loading_block{
background: rgba(0,0,0,0.2);
}
}
.material_confirm{
width: calc(9.8rem*1.2);
height: calc(3.6rem*1.2);
line-height: calc(3.6rem*1.2);
font-size: calc(1.4rem*1.2);
2023-01-06 16:00:15 +08:00
text-align: center;
margin: 0 auto;
color: #FFFFFF;
background: #343579;
cursor: pointer;
margin-top: calc(2rem*1.2);
2023-01-06 16:00:15 +08:00
}
.table_pagination{
position: absolute;
bottom: calc(3.5rem*1.2);
2023-01-06 16:00:15 +08:00
left: 0;
width: 100%;
text-align: center;
margin-top: calc(5rem*1.2);
2023-01-06 16:00:15 +08:00
}
}
}
</style>