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

2572 lines
82 KiB
Vue
Raw Normal View History

2024-02-23 14:32:33 +08:00
<template>
2024-02-29 17:16:51 +08:00
<a-modal
2024-03-26 15:45:32 +08:00
class="modal_component Export generalModelOperate"
2024-02-29 17:16:51 +08:00
v-model:visible="showUpgradePlan"
:footer="null"
width="78%"
:maskClosable="false"
:centered="true"
:closable="false"
:keyboard="false"
2024-08-19 10:36:46 +08:00
:destroyOnClose="true"
2024-02-29 17:16:51 +08:00
>
2024-03-26 15:45:32 +08:00
<div class="UpgradePlan_closeIcon generalModelOperate_closeIcon ">
2024-02-29 17:16:51 +08:00
<i class="fi fi-rr-cross-small" @click.stop="cancelDsign()"></i>
</div>
2024-03-26 15:45:32 +08:00
<div class="UpgradePlan_content generalModelOperate">
<div>{{ $t('exportModel.EditExport') }}</div>
2024-02-29 17:16:51 +08:00
</div>
<!-- <div>
2024-02-23 14:32:33 +08:00
<canvas ref="exportCanvas"></canvas>
</div> -->
2024-02-29 17:16:51 +08:00
<div class="exportCanvasBox">
<div class="exportCanvasBox_left">
2024-09-03 16:39:06 +08:00
<!-- <div class="exportCanvasBox_title">{{ $t('exportModel.CanvasSize') }}</div> -->
2024-03-22 12:01:11 +08:00
2024-03-26 15:45:32 +08:00
<!-- <label>
2024-03-22 12:01:11 +08:00
<div>Width:</div>
<input type="number" @input="setMaxInput('width', 500)" v-model="canvasWH.width"/>
2024-03-26 15:45:32 +08:00
</label> -->
2024-03-22 12:01:11 +08:00
<label>
2024-09-03 16:39:06 +08:00
<div>{{ $t('exportModel.Height') }}:</div>
2024-07-12 15:54:46 +08:00
<input type="number" @input="setMaxInput('height', 30000)" v-model="canvasWH.height" />
2024-03-22 12:01:11 +08:00
</label>
<div class="exportCanvasBox_title" @click.stop="setCloseNav('nav')">
2024-03-26 15:45:32 +08:00
{{ $t('exportModel.CanvasNav') }}
2024-02-29 17:16:51 +08:00
<div
:class="[
'icon',
'iconfont',
'icon-xiala',
closeNav.nav?'icon-rotate':''
2024-02-29 17:16:51 +08:00
]"
>
</div>
2024-09-03 16:39:06 +08:00
<div class="exportCanvasBox_imgbor exportCanvasBox_left_item" :class="{'closeNav':closeNav.nav}">
<div
class="exportCanvasBox_allItem"
v-for="(item,key) in allBoardData"
>
2024-03-26 15:45:32 +08:00
2024-09-03 16:39:06 +08:00
<div v-if="item[0] && key == 'disposeMoodboard'" class="exportCanvasBox_intro">Entirety Moodboard</div>
<div v-if="item[0] && key == 'printboardFiles'" class="exportCanvasBox_intro">Printboard</div>
<div v-if="item[0] && key == 'moodboardFiles'" class="exportCanvasBox_intro">Moodboard</div>
<div v-if="item[0] && key == 'colorBoards'" class="exportCanvasBox_intro">Color</div>
<div v-if="item[0] && key == 'sketchboardFiles'" class="exportCanvasBox_intro">Sketch</div>
<div v-if="item[0] && key == 'likeDesignCollectionList'" class="exportCanvasBox_intro">Selected Design</div>
<div v-if="item[0] && key == 'FinalizeImage'" class="exportCanvasBox_intro">Selected Product</div>
<div v-if="key == 'colorBoards'" class="exportCanvasBox_item_colorBor">
2024-09-11 16:36:08 +08:00
<div v-for="colorItem in item" class="exportCanvasBox_item_color" :class="{active:colorItem.upScaleChecked}" draggable="true" @dragstart="onDragstart(key,colorItem)" @click.stop="isMoible?setDragstart(key,colorItem):''">
2024-09-03 16:39:06 +08:00
<div class="color_content" v-if="colorItem.gradient" :style="{height:'10rem','background-image':colorItem?.gradient?`linear-gradient(${colorItem?.gradient.angle}deg,${setGradient(colorItem?.gradient)}`:'none'}"></div>
<div v-else>
<div class="exportCanvasBox_item_BGcolor" :style="{'background-color': 'rgb('+colorItem.rgbValue.r+','+colorItem.rgbValue.g+','+colorItem.rgbValue.b+')'}"></div>
<div>{{colorItem.tcx}}</div>
<div>{{colorItem.name}}</div>
</div>
</div>
2024-06-17 09:39:01 +08:00
</div>
2024-02-29 17:16:51 +08:00
2024-09-03 16:39:06 +08:00
<div
class="exportCanvasBox_item"
v-for="imgItem in item"
:class="[key == 'disposeMoodboard'?'exportCanvasBox_item_dispose':'',imgItem?.upScaleChecked?'active':'']"
draggable
@dragstart="onDragstart(key,imgItem)"
2024-09-11 16:36:08 +08:00
@click.stop="isMoible?setDragstart(key,imgItem):''"
2024-09-03 16:39:06 +08:00
>
<div class="exportCanvasBox_img">
<img :src="key == 'likeDesignCollectionList'?imgItem?.designOutfitUrl:imgItem?.imgUrl" alt="" />
</div>
2024-03-26 15:45:32 +08:00
</div>
2024-09-03 16:39:06 +08:00
</div>
</div>
</div>
2024-09-11 16:36:08 +08:00
<div class="exportCanvasBox_operation_bor_item exportCanvasBox_left_tool_item_column">
<label v-show="operation != 'move' && operation != 'eraser' && operation != 'texture'">
<div >{{ $t('exportModel.Color') }}</div>
<input type="color" @input="setPencilColor" v-model="canvasPencilColor">
</label>
<label v-show="operation != 'move'">
<div >{{ $t('exportModel.Size') }}:</div>
<input @change="setFontFamily" type="range" @input="setPencilWidth" min="3" max="50" v-model="canvasPencilWidth[operation]">
</label>
<label v-show="operation == 'pencil'">
<div >{{ $t('exportModel.Brushwork') }}:</div>
<a-select ref="select" class="label_select" size="small" v-model:value="brushworkValue"
style="flex: 1"
@change="brushworkChange"
>
<!-- v-model:value="brushwork" -->
<a-select-option class="label_select_item" v-for="item in brushList" :value="item.value">
<img :src="item.url" alt="">
</a-select-option>
</a-select>
</label>
<label v-show="operation == 'texture'" class="texture">
<div >{{ $t('exportModel.Texture') }}:</div>
<a-select ref="select" class="label_select" size="small" v-model:value="textureValue"
style="flex: 1"
@change="textureValueChange"
>
<!-- v-model:value="brushwork" -->
<a-select-option class="label_select_item" v-for="item in textureList" :value="item.value">
<img :src="item.url" alt="">
</a-select-option>
</a-select>
</label>
<label v-show="operation != 'pencil' && operation != 'eraser'&&operation != 'move'&&operation != 'text'&&operation != 'texture'&&operation != ''">
<div >{{ $t('exportModel.FillBack') }}:</div>
<div class="exportCanvasBox_left_tool_item leftAlign">
<i class="icon iconfont icon-tuceng1" @click="setOperationMode('fill')" :class="{active:operationMode == 'fill'}"></i>
<i class="icon iconfont icon-tuceng" @click="setOperationMode('border')" :class="{active:operationMode == 'border'}"></i>
</div>
</label>
<label v-show="operation === 'move'">
<div >{{ $t('exportModel.Layer') }}:</div>
<div class="exportCanvasBox_left_tool_item top">
<i class="icon iconfont icon-shangyiceng" @click="setLayerIndex('Front')"></i>
<i class="icon iconfont icon-shangyiceng2" @click="setLayerIndex('Forward')"></i>
<i class="icon iconfont icon-xiayiceng" @click="setLayerIndex('Backwards')"></i>
<i class="icon iconfont icon-shangyiceng1" @click="setLayerIndex('Back')"></i>
</div>
</label>
<!-- <label v-show="allSelectWidth > -1 && operation != 'move'">
<div >{{ $t('exportModel.Width') }}</div>
<input type="number" @input="setAllSelectWidth" v-model="allSelectWidth">
</label> -->
<label v-show="(operation == '' || operation == 'text' || textDataShow) && operation != 'move'">
<div>Font Family</div>
<a-select ref="select" class="label_select" size="small" v-model:value="fontFamily"
style="flex: 1"
@change="setFontFamily"
>
<!-- v-model:value="brushwork" -->
<a-select-option class="label_select_item" v-for="item in textFontFamilyList" :style="{'font-family':item.value}" :value="item.value">
{{item.name}}
</a-select-option>
</a-select>
</label>
<!-- <label v-show="operation != 'move' && operation != 'eraser' && operation != 'texture'">
<div >{{ $t('exportModel.Height') }}</div>
<input type="number" @input="setPencilColor" v-model="canvasPencilColor">
</label> -->
</div>
<!-- <div class="exportCanvasBox_title" @click.stop="setCloseNav('move')">
{{ $t('exportModel.More') }}
</div>
-->
</div>
<!-- <div @click="toSvg">12312312312</div> -->
<div class="exportCanvasBox_center_box exportCanvasBox_left">
<div class="exportCanvasBox_left_tool exportCanvasBox_title">
<div class="exportCanvasBox_left_tool_item">
<i class="icon iconfont icon-chehui" @click="historyState('')"></i>
<i class="icon iconfont icon-fanchehui" @click="historyState('reverse')"></i>
<i class="icon iconfont icon-bianji" @click="setOperation('pencil')" :class="{active:operation == 'pencil'}"></i>
2024-03-20 13:34:07 +08:00
<i class="icon iconfont icon-caizhi" @click="setOperation('texture')" :class="{active:operation == 'texture'}"></i>
<i class="icon iconfont icon-move" @click="setOperation('move')" :class="{active:operation == 'move'}"></i>
<i class="icon iconfont icon-xiangpi_huaban1" @click="setOperation('eraser')" :class="{active:operation == 'eraser'}"></i>
2024-09-11 16:36:08 +08:00
<!-- <i class="icon iconfont icon-xiala" :class="closeNav.tool?'icon-rotate':''" @click.stop="setCloseNav('tool')"></i> -->
<i class="icon iconfont icon-xian" @click="setOperation('fold')" :class="{active:operation == 'fold'}"></i>
2024-09-03 16:39:06 +08:00
<i class="icon iconfont icon-checkbox-full" @click="setOperation('rect')" :class="{active:operation == 'rect'}"></i>
<!-- <i class="icon iconfont icon-zhixian" @click="setOperation('line')" :class="{active:operation == 'line'}"></i> -->
<!-- <i class="icon iconfont icon-circle" @click="setOperation('circle')" :class="{active:operation == 'circle'}"></i> -->
<i class="icon iconfont icon-sanjiaoxing" @click="setOperation('triangle')" :class="{active:operation == 'triangle'}"></i>
<i class="icon iconfont icon-tx-fill-tuoyuanxing" @click="setOperation('ellipse')" :class="{active:operation == 'ellipse'}"></i>
<label class="uploadImage">
<i class="icon iconfont icon-shangchuantupian" ></i>
<input type="file" @change="uploadImage">
</label>
<i class="icon iconfont" @click="setOperation('text')" :class="{active:operation == 'text'}">T</i>
2024-06-20 10:36:45 +08:00
</div>
2024-09-11 16:36:08 +08:00
<!-- <div class="exportCanvasBox_left_tool exportCanvasBox_left_item" :class="{'closeNav' :closeNav.tool}">
<div class="exportCanvasBox_left_tool_item">
<i class="icon iconfont icon-xian" @click="setOperation('fold')" :class="{active:operation == 'fold'}"></i>
<i class="icon iconfont icon-checkbox-full" @click="setOperation('rect')" :class="{active:operation == 'rect'}"></i>
<i class="icon iconfont icon-sanjiaoxing" @click="setOperation('triangle')" :class="{active:operation == 'triangle'}"></i>
<i class="icon iconfont icon-tx-fill-tuoyuanxing" @click="setOperation('ellipse')" :class="{active:operation == 'ellipse'}"></i>
<label class="uploadImage">
<i class="icon iconfont icon-shangchuantupian" ></i>
<input type="file" @change="uploadImage">
2024-09-03 16:39:06 +08:00
</label>
2024-09-11 16:36:08 +08:00
<i class="icon iconfont" @click="setOperation('text')" :class="{active:operation == 'text'}">T</i>
2024-09-03 16:39:06 +08:00
</div>
2024-09-11 16:36:08 +08:00
</div> -->
</div>
2024-09-11 16:36:08 +08:00
<div class="exportCanvasBox_center">
<div class="editFrontBack_pencilbtn" v-show="!isShowMark" :style="pencilbtnStyle"></div>
2024-03-26 15:45:32 +08:00
</div>
2024-05-18 15:39:32 +08:00
</div>
2024-09-11 16:36:08 +08:00
<!-- <div v-if="isMoible" class="exportCanvasBox_scroll">
2024-05-18 15:39:32 +08:00
<div></div>
2024-09-11 16:36:08 +08:00
</div> -->
2024-09-03 16:39:06 +08:00
<div class="exportCanvasBox_bottom">
<div class="exportCanvasBox_left_btn Guide_1_38">
<div class="exportCanvasBox_left_credits" v-show="credits<1">
<div><span class="icon iconfont icon-zhuyi"></span>{{ $t('exportModel.insufficient') }}</div>
</div>
<!-- <div class="subitOkPreviewBtn" :class="{active:allBoardData.printboardFiles.length<=0}" :title="allBoardData.printboardFiles.length<=0?$t('exportModel.jsContent2'):''" @click="setHDExport">{{ $t('exportModel.HDExport') }}</div> -->
<div class="subitOkPreviewBtn" @click="setSubmit">{{ $t('exportModel.Save') }}</div>
<div class="subitOkPreviewBtn" @click="setShare">{{ $t('exportModel.Share') }}</div>
<div class="subitOkPreviewBtn" @click="setExport">{{ $t('exportModel.Export') }}</div>
</div>
</div>
2024-03-26 15:45:32 +08:00
<!-- <div class="exportCanvasBox_right">
2024-03-04 09:57:46 +08:00
<div class="exportCanvasBox_title">
High-definition Download
</div>
<div class="exportCanvasBox_right_definition">
<label>
2024-03-22 12:01:11 +08:00
<div>Scale:</div>
<input type="number" @input="setMaxInput('scale', 500)" v-model="scaleSR"/>
2024-03-04 09:57:46 +08:00
</label>
</div>
2024-03-26 15:45:32 +08:00
<div class="" @click="multiselect">all</div>
2024-03-08 16:51:24 +08:00
<div class="exportCanvasBox_right_credits" v-show="credits<1">
<div><span class="icon iconfont icon-zhuyi"></span>Your points balance is insufficient, if you need to use this feature, please click the top left corner to recharge</div>
</div>
2024-03-26 15:45:32 +08:00
</div> -->
2024-04-25 12:58:10 +08:00
<!-- <div @click="toSvg()">2312312312</div> -->
2024-02-29 17:16:51 +08:00
<div class="mark_loading" v-show="isShowMark">
<a-spin size="large" />
</div>
</div>
2024-03-26 15:45:32 +08:00
<a-modal
v-model:visible="showSRExport"
class="modal_component SRExport generalModelOperate"
width="48%"
:maskClosable="false"
:centered="true"
:closable="false"
:keyboard="false"
:footer="null"
:mask="false"
>
<div class="generalModelOperate_closeIcon">
<i class="fi fi-rr-cross-small" @click.stop="cancelSRExport()"></i>
</div>
<div class="modal_title_text">
<div class="modal_title_text_max">{{ $t('exportModel.SR') }}</div>
<div class="modal_title_text_intro">{{ $t('exportModel.requiresCredits',{data:(allExportSR.filter(item=> item.checked ).length*5)}) }}</div>
2024-03-26 15:45:32 +08:00
</div>
<div class="SRExport_operate">
2024-03-27 16:42:52 +08:00
<div class="SRExport_operate_box">
2024-03-26 15:45:32 +08:00
<div>{{ $t('exportModel.Scale') }}:</div>
2024-03-27 16:42:52 +08:00
<!-- <input type="number" @input="setMaxInput('scale', 500)" v-model="scaleSR"/> -->
2024-03-27 17:49:25 +08:00
<!-- <a-select ref="select" class="SRExport_operate_sclae" size="small" v-model:value="scaleSR"
2024-03-27 16:42:52 +08:00
style="flex: 1"
@change="setScaleSR"
>
<a-select-option class="label_select_item" v-for="item in scaleSRList" :value="item.value">
</a-select-option>
2024-03-27 17:49:25 +08:00
</a-select> -->
<div class="SRExport_operate_item_sclae" :class="{active:scaleSR==2}" @click="setScaleSR(2)">2</div>
<div class="SRExport_operate_item_sclae" :class="{active:scaleSR==4}" @click="setScaleSR(4)">4</div>
<!-- <div class="SRExport_operate_item_sclae" :class="{active:scaleSR==8}" @click="setScaleSR(8)">8</div> -->
2024-03-27 16:42:52 +08:00
</div>
2024-03-26 15:45:32 +08:00
<div :class="['check_all_block',allChecked ? 'check_all' : '']" @click="selectAllImg()">
<div class="check_block"><div class="check_block_body"></div></div>
<div>all</div>
</div>
</div>
<div class="SRExport_img">
2024-03-27 16:42:52 +08:00
<div class="SRExport_img_item_box" v-for="item in allExportSR" @click="selectImg(item)">
<input type="checkbox" v-model="item.checked">
<img class="SRExport_img_item" :src="item.imgUrl" alt="">
</div>
2024-03-26 15:45:32 +08:00
</div>
<div class="generalModelOperate_endBtn">
<div class="generalModelOperate_btn_cancel" @click="cancelSRExport">{{ $t('exportModel.Cancel') }}</div>
<div class="generalModelOperate_btn_ok" :class="[credits < (allExportSR.filter(item=> item.checked ).length*5)?'active':'']" @click="setExportSR">OK</div>
2024-03-26 15:45:32 +08:00
</div>
</a-modal>
<publish ref="publish" @setPublish="setSubmit"></publish>
2024-02-29 17:16:51 +08:00
</a-modal>
2024-02-23 14:32:33 +08:00
</template>
2024-02-27 15:15:38 +08:00
<script>
2024-07-08 09:42:21 +08:00
import {defineComponent, computed, h, ref, nextTick, inject, reactive, onMounted,
2024-02-29 17:16:51 +08:00
} from "vue";
2024-02-23 14:32:33 +08:00
import { Https } from "@/tool/https";
2024-03-22 12:01:11 +08:00
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
2024-02-23 14:32:33 +08:00
import scaleImage from "@/component/HomePage/scaleImage.vue";
import ExportNewCoolection from "@/component/HomePage/ExportNewCoolection.vue";
2024-02-27 15:15:38 +08:00
import { useStore } from "vuex";
2024-02-29 17:16:51 +08:00
import JSZip, { forEach } from "jszip";
2024-03-21 10:49:21 +08:00
// import fabric from 'fabric';
2024-02-29 17:16:51 +08:00
import { message, Modal } from "ant-design-vue";
2024-03-26 15:45:32 +08:00
import domTurnImg from '@/tool/domTurnImg'
2024-03-21 10:49:21 +08:00
import { openGuide,driverObj__ } from "@/tool/guide";
2024-02-29 17:16:51 +08:00
const FileSaver = require("file-saver");
2024-06-17 09:39:01 +08:00
import { exportSele,JSRectUpdata,JSchangeType,JScanvasMouseDown,JScanvasMouseMove,JScreateCheck,JSSetTexture,JSSetRemoveImage } from "@/tool/canvasDrawing";
2024-03-26 15:45:32 +08:00
import { useI18n } from "vue-i18n";
2024-06-17 09:39:01 +08:00
import {isMoible,calculateGradientCoordinate,base64ToFile} from '@/tool/util'
import publish from "@/component/WorksPage/publish.vue";
2024-04-25 17:16:34 +08:00
2024-02-23 14:32:33 +08:00
export default defineComponent({
2024-02-29 17:16:51 +08:00
components: {
scaleImage,
ExportNewCoolection,
2024-06-17 09:39:01 +08:00
publish,
2024-02-29 17:16:51 +08:00
},
props: ["msg", "sketchCatecoryList"],
2024-03-22 12:01:11 +08:00
setup(props,{emit}) {
2024-03-26 15:45:32 +08:00
const {t} = useI18n()
2024-08-16 15:40:25 +08:00
const store = useStore();
2024-03-21 10:49:21 +08:00
let driver__ = computed(()=>{
return store.state.Guide.guide
})
2024-02-27 15:15:38 +08:00
2024-02-29 17:16:51 +08:00
let showUpgradePlan = ref(false);
let canvas = reactive({});
// let canvasDom = ref()
let canvasWH = ref({
width: 400,
2024-05-18 15:39:32 +08:00
height: 100,
2024-02-29 17:16:51 +08:00
});
2024-09-11 16:36:08 +08:00
let pencilbtnStyle = ref({
background:'',
width:0+'px',
height:0+'px',
display:'none',
left:0+'px',
top:0+'px',
})
2024-06-17 09:39:01 +08:00
let publish = ref()
2024-03-26 15:45:32 +08:00
// canvasWH.value.width = [window.innerWidth/2.4]
// canvasWH.value.width = canvasWH.value.width.map(num => Math.round(num / 100) * 100)[0];
2024-03-08 16:51:24 +08:00
let credits = computed(() => {
return store.state.UserHabit.credits.value;
2024-02-29 17:16:51 +08:00
});
2024-03-08 16:51:24 +08:00
2024-02-29 17:16:51 +08:00
let allBoardData = computed(() => {
return store.state.UploadFilesModule.allBoardData;
});
let likeDesignCollectionList = computed(() => {
return store.state.HomeStoreModule.likeDesignCollectionList;
});
2024-06-17 09:39:01 +08:00
let isShowMark = ref(false);
2024-02-29 17:16:51 +08:00
// let allImage = Object.assign(allBoardData.value,{likeDesignCollectionList:likeDesignCollectionList.value})
let position = {
//设置每个图形位置的初始值
x: 0,
y: 0,
height: 0,
};
2024-03-04 09:57:46 +08:00
let sketchGrouping = 3; //sketch分组
let likeDesign = 4; //整体图分组
let disposeMoodboardShow = true;
let canvasState = ref()//存放canvas操作
let reverseCanvasState = ref([])//存放canvas操作
let normalCanvasState = ref([])//存放canvas操作
2024-03-04 09:57:46 +08:00
let isLoadCanvas = false//撤回或者反撤回false为撤回
2024-06-17 09:39:01 +08:00
let userlikeGroupId = 0
2024-09-03 16:39:06 +08:00
let imgWidth = {} //这是设置画布等宽
2024-08-19 10:36:46 +08:00
let submitCanvasContent = null
2024-06-17 09:39:01 +08:00
let init = (productData) => {
userlikeGroupId = productData.userlikeGroupId
2024-08-19 10:36:46 +08:00
clearTimeout(submitCanvasContent)
2024-05-18 15:39:32 +08:00
canvasWH.value.height = 100
normalCanvasState.value = []
reverseCanvasState.value = []
2024-02-29 17:16:51 +08:00
showUpgradePlan.value = true;
2024-03-27 16:42:52 +08:00
allBoardData.value.likeDesignCollectionList =
likeDesignCollectionList;
2024-06-17 09:39:01 +08:00
allBoardData.value[productData.key] = productData.imgList;
2024-02-29 17:16:51 +08:00
nextTick().then(async () => {
2024-07-03 17:32:06 +08:00
let exportCanvasBoxCanvas = document.querySelector('.Export .exportCanvasBox_center')
2024-03-26 15:45:32 +08:00
canvasWH.value.width = exportCanvasBoxCanvas.offsetWidth - 10
2024-09-11 16:36:08 +08:00
let canvasBox = document.querySelector(".Export .exportCanvasBox_center");
let oldCanvasDom = canvasBox.querySelector('.canvas-container')
let oldCanvasDom1 = canvasBox.querySelector('canvas')
var canvasDom = document.createElement("canvas");
document.addEventListener("keydown", setCanvasKeyDown);
document.addEventListener("keyup", clearCanvasKeyDown);
if(oldCanvasDom)oldCanvasDom.remove()
if(oldCanvasDom)loadingShow.value = false
if(oldCanvasDom1)oldCanvasDom1.remove()
2024-02-29 17:16:51 +08:00
canvasBox.appendChild(canvasDom);
canvas = new fabric.Canvas(canvasDom, {
backgroundColor: "rgba(255, 255, 255)",
width: canvasWH.value.width,
height: canvasWH.value.height,
isDrawingMode: false, // 开启绘图模式
});
2024-03-04 09:57:46 +08:00
canvasOnDrop()//开启鼠标到画布事件
2024-06-17 09:39:01 +08:00
if(!fabric.Object.prototype.controls.deleteControl){//设置元素删除
JSSetRemoveImage(deleteObject)
}else{
fabric.Object.prototype.controls.deleteControl.mouseUpHandler = deleteObject
}
// setRemoveImage()//设置元素删除
2024-03-04 09:57:46 +08:00
canvas.on("object:modified", ()=>{
updateCanvasState()
});
2024-03-20 13:34:07 +08:00
canvas.preserveObjectStacking = true;
//鼠标移动
2024-03-28 17:35:25 +08:00
// canvas.wrapperEl.onmouseover = setCanvasKeyDown;//document上添加按下和抬起事件
// canvas.wrapperEl.onmouseout = clearCanvasKeyDown;//document上添加按下和抬起事件
2024-09-11 16:36:08 +08:00
// canvas.on("mouse:over", event =>setCanvasKeyDown(event));//document上添加按下和抬起事件
// canvas.on("mouse:out", clearCanvasKeyDown);//document上添加按下和抬起事件
2024-03-28 17:35:25 +08:00
canvas.on("mouse:move", event =>setCanvasMove(event));
canvas.on("mouse:down", event=>setCanvasDown(event));
canvas.on("mouse:up", event=>setCanvasUp(event));
2024-05-21 10:55:06 +08:00
//双击
canvas.on("mouse:dblclick", event=>{
if(operation.value == 'fold'){
foldEnd('Enter')
}
});
// canvas.on('path:created', (event)=>{updateCanvasState()});
// canvas.on("selection:created", (event)=>{setZIndex(event)});
// canvas.on('object:removed', function() {
// });
// canvas.on("object:added", (obj)=>{
// obj.target.cornerSize = 10
// obj.target.transparentCorners = false
// });
initAligningGuidelines(canvas,true)
JSchangeType(canvas,'init')
2024-09-11 16:36:08 +08:00
pencilbtnStyle.value.background = '#fff'
fabric.Object.prototype.cornerSize = 10
fabric.Object.prototype.transparentCorners = false
2024-03-04 09:57:46 +08:00
// setCanvasOperation()//设置监听添加修改画布元素,用来做撤回功能
2024-02-29 17:16:51 +08:00
let arr = [
"disposeMoodboard",
"moodboardFiles",
"printboardFiles",
"colorBoards",
"sketchboardFiles",
"likeDesignCollectionList",
2024-06-17 09:39:01 +08:00
productData.key,
2024-02-29 17:16:51 +08:00
];
let oldKey = "";
let margin = 20; //每个图形边距
2024-03-20 13:34:07 +08:00
let maxHeight = 0
let sketchXy = {x:0,y:0}
2024-06-17 09:39:01 +08:00
let data = {
userLikeGroupId:userlikeGroupId
}
2024-09-03 16:39:06 +08:00
arr.forEach((item)=>{
if(item !== 'likeDesignCollectionList')imgWidth[item] = setImageWidth(item)
})
2024-06-17 09:39:01 +08:00
isShowMark.value = true
2024-08-19 10:36:46 +08:00
let oldExportCanvas
let localCanvas = localStorage.getItem('canvasContent')
let localUserlikeGroupId = localStorage.getItem('userlikeGroupId')
oldExportCanvas = await new Promise((resolve, reject) => {
if(localUserlikeGroupId == userlikeGroupId){
Modal.confirm({
title: useI18.t('exportModel.jsContent8'),
okText: 'Yes',
cancelText: 'No',
mask:false,
centered:true,
onOk() {
localCanvas = localCanvas?JSON.parse(localCanvas):null
resolve(localCanvas)
},
onCancel(){
resolve(null)
}
});
}else{
2024-06-17 09:39:01 +08:00
resolve(null)
2024-08-19 10:36:46 +08:00
}
2024-06-17 09:39:01 +08:00
})
2024-08-19 10:36:46 +08:00
if(!oldExportCanvas){
oldExportCanvas = await new Promise((resolve, reject) => {
Https.axiosPost(Https.httpUrls.exportSearch, data)
.then((rv) => {
resolve(rv)
})
.catch((rv) => {
resolve(null)
});
})
}
2024-02-29 17:16:51 +08:00
// arr.forEach((item,index)=>{
2024-06-17 09:39:01 +08:00
if(oldExportCanvas){
canvasWH.value.height = oldExportCanvas.canvasHeight
canvas.setHeight(canvasWH.value.height);
canvas.loadFromJSON(oldExportCanvas, () => {});
2024-06-20 10:36:45 +08:00
isShowMark.value = false
2024-06-17 09:39:01 +08:00
}else{
2024-07-03 11:39:01 +08:00
nextTick(async ()=>{
for (const item of arr) {
for (const key in allBoardData.value) {
if (item == key) {
//循环渲染顺序
let sketchGroupingItem = [];
if (
item == "moodboardFiles" &&
!disposeMoodboardShow
) {
continue;
}
for (const [allItemIndex, allItem,] of allBoardData.value[key].entries()) {
2024-08-13 09:36:13 +08:00
await new Promise(async (resolve, reject) => {
2024-07-03 11:39:01 +08:00
if(!allItem){
resolve()
2024-03-04 09:57:46 +08:00
}
2024-07-03 11:39:01 +08:00
maxHeight = position.y + position.height>maxHeight?position.y +position.height:maxHeight
if (key == "colorBoards") {
let rect = setGroup(allItem)
if (position.x + rect.width > canvasWH.value.width || oldKey != key) {
position.x = 0;
position.y = maxHeight;
}
let group = setCanvasColor(position.y,position.x,rect)
oldKey = key;
position.x += rect.width + margin;
position.height = group.height + margin;
resolve();
} else {
let itemCanvasImg = allItem.imgUrl;
if (key == "likeDesignCollectionList") {
2024-08-13 09:36:13 +08:00
2024-07-03 11:39:01 +08:00
itemCanvasImg =
allItem.designOutfitUrl;
2024-03-04 09:57:46 +08:00
}
2024-07-03 11:39:01 +08:00
fabric.Image.fromURL(itemCanvasImg,(img) => {
2024-09-03 16:39:06 +08:00
if(item == 'likeDesignCollectionList')imgWidth[item] = setImageWidth(key,img);
let scaleWH = imgWidth[item] / img.width; //计算放到画布上缩小倍率
2024-07-03 11:39:01 +08:00
if(key == "sketchboardFiles"){
if(allItemIndex == 0){
position.x = 0;
position.y = maxHeight;
}
}else{
if (position.x + img.width * scaleWH > canvasWH.value.width || oldKey != key) {
position.x = 0;
position.y = maxHeight;
}
2024-06-17 09:39:01 +08:00
}
2024-07-03 11:39:01 +08:00
setCanvasImage(img,key,position.x,position.y,allItem)//设置图片
position.height = img.height * scaleWH + margin;
if (key == "sketchboardFiles") {
if (sketchGroupingItem.length <3) {
sketchGroupingItem.push(JSON.parse(JSON.stringify(position)));
}
if (sketchGroupingItem.length >2) {
let sketchXyIndex = {
maxIndex: 0,
maxNum: 0,
minNum: 999999,
minIndex: 0,
};
sketchGroupingItem.forEach(
(sketchItem,sketchIndex) => {
if (sketchItem.y + sketchItem.height < sketchXyIndex.minNum) {
sketchXyIndex.minNum = sketchItem.y + sketchItem.height
sketchXyIndex.minIndex = sketchIndex;
}
if (sketchItem.y + sketchItem.height > sketchXyIndex.maxNum) {
sketchXyIndex.maxNum = sketchItem.y + sketchItem.height
sketchXyIndex.maxIndex = sketchIndex;
}
2024-06-17 09:39:01 +08:00
}
2024-07-03 11:39:01 +08:00
);
sketchGroupingItem[sketchXyIndex.minIndex].y = sketchXyIndex.minNum
// sketchGroupingItem[sketchXyIndex.maxIndex].y = sketchXyIndex.maxNum
if (allBoardData.value[key].length == allItemIndex + 1) {
maxHeight = sketchXyIndex.maxNum
} else {
position = sketchGroupingItem[sketchXyIndex.minIndex];
2024-03-20 13:34:07 +08:00
}
2024-03-04 09:57:46 +08:00
}
}
2024-07-03 11:39:01 +08:00
if(key == "sketchboardFiles" && sketchGroupingItem.length >2){
}else{
position.x += img.width * scaleWH + margin;
}
img.lock_rotation = true;
canvas.add(img);
oldKey = key;
// setTimeout(() => {
resolve()
// }, 1000);
},{ crossOrigin: "Anonymous" });
}
});
}
2024-06-17 09:39:01 +08:00
}
}
2024-07-03 11:39:01 +08:00
if(position.y+position.height>canvasWH.value.height){
canvasWH.value.height = Math.floor(position.y+position.height)
canvas.setHeight(canvasWH.value.height);
}
2024-06-17 09:39:01 +08:00
}
2024-07-03 11:39:01 +08:00
})
2024-06-20 10:36:45 +08:00
isShowMark.value = false
2024-06-17 09:39:01 +08:00
}
updateCanvasState('')//加载完成后记录一下
setOperation('move')
2024-08-19 10:36:46 +08:00
submitCanvasContent = setInterval(()=>{
let data = setCanvasContent(true)
if(data.objects.length == 0){
clearTimeout(submitCanvasContent)
return
}
data.canvasHeight = canvasWH.value.height
localStorage.setItem('canvasContent',JSON.stringify(data))
localStorage.setItem('userlikeGroupId',userlikeGroupId)
},3000)
2024-03-21 10:49:21 +08:00
if(driver__.value.driver){
driverObj__.moveNext()
}
2024-02-29 17:16:51 +08:00
});
2024-03-21 10:49:21 +08:00
2024-02-29 17:16:51 +08:00
};
2024-03-22 12:01:11 +08:00
let deleteObject = ()=> {
// var target = [transform.target];
2024-03-22 12:01:11 +08:00
if(!canvas.getActiveObjects()){
2024-03-20 13:34:07 +08:00
return
}
2024-03-22 12:01:11 +08:00
let target = canvas.getActiveObjects()
2024-03-04 09:57:46 +08:00
target.forEach((item)=>{
// var canvas = item.canvas;
// canvas.remove(item);
canvas.fxRemove(item, {
onComplete(){
canvas.discardActiveObject(); // 丢弃当前选中的对象
canvas.renderAll(); // 重新渲染 Canvas
}
})
canvas.FX_DURATION = 300
2024-03-04 09:57:46 +08:00
})
// canvas.requestRenderAll();
// canvas.discardActiveObject() // 丢弃当前活动的对象和触发事件。 如果fabric作为鼠标事件的结果调用该函数则将该事件作为参数传递给自定义事件的fire函数。 当作为一个方法使用时,参数没有任何应用。
// canvas.discardActiveObject(); // 丢弃当前选中的对象
// canvas.renderAll(); // 重新渲染 Canvas
updateCanvasState('remove')
2024-03-04 09:57:46 +08:00
}
2024-06-17 09:39:01 +08:00
2024-09-03 16:39:06 +08:00
let setImageWidth = (key,img)=>{
2024-03-04 09:57:46 +08:00
let imgWidth = canvasWH.value.width; //这是设置画布等宽
if (
disposeMoodboardShow &&
key == "disposeMoodboard" &&
allBoardData.value[key].length != 0 &&
allBoardData.value[key][0] != null
) {
//如果是mood 需要判断用户是否点击layout
disposeMoodboardShow = false;
}
2024-06-17 09:39:01 +08:00
if(key == 'upImgFiles'){
imgWidth = canvasWH.value.width / 4;
}
2024-03-04 09:57:46 +08:00
if (key == "printboardFiles") {
imgWidth = canvasWH.value.width / 8;
}
if (key == "sketchboardFiles"||key == 'moodboardFiles') {
imgWidth =
(canvasWH.value.width -
(sketchGrouping - 1) * 20) /
sketchGrouping;
}
2024-09-03 16:39:06 +08:00
if (key == "likeDesignCollectionList") {
2024-08-13 09:36:13 +08:00
if(img){
2024-09-03 16:39:06 +08:00
let imgObj = JSON.parse(JSON.stringify(img))
let height = imgObj.height
imgObj.height = canvasWH.value.width / 4 * 1.8
let heightScale = imgObj.height / height
imgWidth = imgObj.width * heightScale
2024-08-13 09:36:13 +08:00
}
// imgWidth =
// (canvasWH.value.width -
// (likeDesign - 1) * 20) /
// likeDesign;
2024-03-04 09:57:46 +08:00
}
return imgWidth
}
2024-06-01 10:02:21 +08:00
let setCanvasImage = (img,key,left,top,data)=>{
// data
let imgId = 0
2024-06-17 09:39:01 +08:00
let minioUrl = ''//表示收藏或者generate
2024-07-03 17:32:06 +08:00
let imgUrl = data.imgUrl
if (key == "likeDesignCollectionList") {
imgUrl = data.designOutfitUrl;
2024-09-03 16:39:06 +08:00
imgWidth[key] = setImageWidth(key,img);
2024-06-01 10:02:21 +08:00
}
2024-09-03 16:39:06 +08:00
2024-07-03 17:32:06 +08:00
let url = imgUrl.split('?')[0]
var match = url.match(/:(\d+)\/(.*)/);
minioUrl = match[2]
2024-06-01 10:02:21 +08:00
// let id =
2024-03-04 09:57:46 +08:00
let proportion = img.height / img.width; //计算图形宽高比例
2024-08-13 09:36:13 +08:00
// let imgWidth = setImageWidth(key)
2024-09-03 16:39:06 +08:00
let scaleWH = imgWidth[key] / img.width; //计算放到画布上缩小倍率
2024-03-04 09:57:46 +08:00
img.set({
2024-09-03 16:39:06 +08:00
// width: imgWidth[key]/img.width,
2024-03-04 09:57:46 +08:00
// height: canvasWH.value.height/img.height,
left,
top,
2024-06-17 09:39:01 +08:00
imgId,
minioUrl,
2024-03-04 09:57:46 +08:00
scaleX:
2024-09-03 16:39:06 +08:00
imgWidth[key] / img.width,
2024-03-04 09:57:46 +08:00
scaleY:(img.width * proportion * scaleWH) / img.height,
// cornerSize: 10, // 选中时角的大小为20
// transparentCorners: false, // 选中时角是被填充了。true 空心false 实心
2024-03-04 09:57:46 +08:00
lockRotation: true,
});
}
2024-08-26 10:06:08 +08:00
let setExportCanvas = async ()=>{
await calculateHeight()
canvas.setDimensions({ height: canvasWH.value.height });
2024-06-20 10:36:45 +08:00
canvas.renderAll();
return canvas.toDataURL({
2024-08-26 10:06:08 +08:00
format: "png", // 导出格式为 PNG
quality: 1, // 图片质量为 1最高质量
});
}
let calculateHeight = ()=>{
return new Promise((resolve, reject) =>{
var objects = canvas.getObjects();
var maxHeight = 0;
Modal.confirm({
title: useI18.t('exportModel.jsContent9'),
2024-08-26 10:06:08 +08:00
okText: 'Yes',
cancelText: 'No',
mask:false,
centered:true,
onOk() {
objects.forEach(function(obj) {
var objBottom = obj.top + obj.height*obj.scaleY;
if (objBottom > maxHeight) {
maxHeight = objBottom;
}
});
canvasWH.value.height = Math.round(maxHeight)+30
resolve(canvasWH.value.height)
},
onCancel(){
resolve(canvasWH.value.height)
}
});
})
2024-06-20 10:36:45 +08:00
}
//设置导出
let setExport = async () => {
initAligningGuidelines(canvas,false)
2024-08-26 10:06:08 +08:00
var imageDataURL = await setExportCanvas()
2024-02-29 17:16:51 +08:00
let a = document.createElement("a");
let img = [];
let index = 0;
img.push({
imgUrl: imageDataURL,
name: "collection.png",
});
let num = 0;
for (let key in allBoardData.value) {
if (key !== "colorBoards" && key !== "moodTemplateId") {
for (let item of allBoardData.value[key]) {
if (
key == "disposeMoodboard" &&
allBoardData.value[key][0] == undefined
) {
break;
}
2024-02-27 15:15:38 +08:00
2024-03-20 13:34:07 +08:00
let nameTail = item?.imgUrl?.split(".").pop().split("?").shift();
2024-02-29 17:16:51 +08:00
let data = {
imgUrl: item.imgUrl,
name: item?.resData?.name + index + "." + nameTail,
};
if (key == "likeDesignCollectionList") {
data.imgUrl = item.designOutfitUrl;
2024-07-08 09:42:21 +08:00
data.name = "result" + index + "." + data.imgUrl.split(".").pop().split("?").shift();
2024-06-17 09:39:01 +08:00
}
2024-06-24 16:45:20 +08:00
if (key == "FinalizeImage") {
2024-07-08 09:42:21 +08:00
data.imgUrl = item.url;
data.name = "Finalize" + index + "." + data.imgUrl.split(".").pop().split("?").shift();
2024-02-29 17:16:51 +08:00
}
img.push(data);
index++;
}
num++;
}
}
let dataList = [];
likeDesignCollectionList.value.forEach((item) => {
dataList.push(item.designItemId);
index++;
});
let mannequinList = [];
await Https.axiosPost(Https.httpUrls.designGetModel, dataList)
.then((rv) => {
mannequinList = rv;
})
.catch((rv) => {});
mannequinList.forEach((item) => {
let nameTail = item?.split(".").pop().split("?").shift();
let data = {
imgUrl: item,
name: "mannequin" + index + "." + nameTail,
};
img.push(data);
index++;
});
downImg(img);
};
let getImgArrayBuffer = (url) => {
return new Promise((resolve, reject) => {
//通过请求获取文件blob格式
let xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", url, true);
xmlhttp.responseType = "blob";
xmlhttp.onload = function () {
if (this.status == 200) {
resolve(this.response);
} else {
reject(this.status);
}
};
xmlhttp.send();
});
};
let downImg = (imagesParams) => {
let zip = new JSZip();
let cache = {};
let promises = [];
for (let item of imagesParams) {
const promise = getImgArrayBuffer(item.imgUrl).then((data) => {
// 下载文件, 并存成ArrayBuffer对象(blob)
zip.file(item.name, data, { binary: true }); // 逐个添加文件
cache[item.title] = data;
});
promises.push(promise);
}
Promise.all(promises)
.then(() => {
zip.generateAsync({ type: "blob" }).then((content) => {
// 生成二进制流
FileSaver.saveAs(content, "DesignFiles"); // 利用file-saver保存文件 自定义文件名
2024-06-17 09:39:01 +08:00
isShowMark.value = false;
2024-02-29 17:16:51 +08:00
});
2024-06-17 09:39:01 +08:00
setSubmit()//导出的时候保存
2024-05-20 14:45:43 +08:00
initAligningGuidelines(canvas,true)
2024-02-29 17:16:51 +08:00
})
.catch((res) => {
// message.warning(t('HomeView.jsContent3'));
2024-06-17 09:39:01 +08:00
isShowMark.value = false;
2024-05-20 14:45:43 +08:00
initAligningGuidelines(canvas,true)
2024-02-29 17:16:51 +08:00
});
};
//关闭画布
2024-03-27 13:31:51 +08:00
let useI18 = useI18n()
2024-02-29 17:16:51 +08:00
let cancelDsign = () => {
2024-03-26 15:45:32 +08:00
Modal.confirm({
2024-03-27 13:31:51 +08:00
title: useI18.t('exportModel.jsContent1'),
2024-03-26 15:45:32 +08:00
okText: 'Yes',
cancelText: 'No',
mask:false,
centered:true,
onOk() {
showUpgradePlan.value = false;
2024-07-12 15:54:46 +08:00
canvas.off("mouse:out", clearCanvasKeyDown);
2024-07-03 17:32:06 +08:00
canvas.dispose();
2024-03-26 15:45:32 +08:00
position = {
//设置每个图形位置的初始值
x: 0,
y: 0,
height: 0,
};
operation.value = 'move'
operation.value = 'fill'
},
// onCancel(){
2024-06-17 09:39:01 +08:00
// _this.isShowMark.value = false
2024-03-26 15:45:32 +08:00
// resolve(false)
// }
});
2024-02-29 17:16:51 +08:00
};
//设置画布宽高
let setMaxInput = (str, maxNum) => {
if (str == "width") {
// maxNum = window.innerWidth < 1100 ? 400 : maxNum;
maxNum = [window.innerWidth/2.4]
maxNum = maxNum.map(num => Math.round(num / 10) * 10)[0];
2024-03-04 09:57:46 +08:00
}else if(str == 'height'){
if(position.y+position.height>maxNum){
maxNum = Math.floor(position.y+position.height)
}
}
2024-02-29 17:16:51 +08:00
if (str == "width" && canvasWH.value.width >= maxNum) {
canvasWH.value.width = maxNum;
} else if (str == "height" && canvasWH.value.height >= maxNum) {
canvasWH.value.height = maxNum;
2024-03-22 12:01:11 +08:00
}else if(str == 'scale'){
scaleSR.value = scaleSR.value < 1 ? 1:scaleSR.value>4? 4:scaleSR.value
}
2024-02-29 17:16:51 +08:00
canvas.setHeight(canvasWH.value.height);
canvas.setWidth(canvasWH.value.width);
};
let closeNav = ref({
2024-09-03 16:39:06 +08:00
nav:false,
tool:false,
move:false,
})
let setCloseNav = (key)=>{
closeNav.value[key] = !closeNav.value[key]
2024-09-03 16:39:06 +08:00
// for (const iterator in closeNav.value) {
// if(key != iterator){
// closeNav.value[iterator] = false
// }
// }
2024-02-27 15:15:38 +08:00
}
2024-03-04 09:57:46 +08:00
function multiselect() {//获取整体宽高
2024-02-29 17:16:51 +08:00
canvas.discardActiveObject() // 丢弃当前活动的对象和触发事件。 如果fabric作为鼠标事件的结果调用该函数则将该事件作为参数传递给自定义事件的fire函数。 当作为一个方法使用时,参数没有任何应用。
const sel = new fabric.ActiveSelection(canvas.getObjects(), {
canvas
})
canvas.setActiveObject(sel)
canvas.requestRenderAll()
const activeObject = canvas.getActiveObject(); // 获取当前选中的整体对象
if (activeObject && activeObject.type === 'activeSelection') {
const totalWidth = activeObject.width * activeObject.scaleX;
const totalHeight = activeObject.height * activeObject.scaleY;
console.log('Total Width:', totalWidth);
console.log('Total Height:', totalHeight);
}
2024-02-27 15:15:38 +08:00
}
2024-03-04 09:57:46 +08:00
let currentType = ref({
type:'',
data:'',
})
let onDragstart = (type,imgItem)=>{
currentType.value.type = type
currentType.value.data = imgItem
2024-02-27 15:15:38 +08:00
}
2024-05-20 10:23:20 +08:00
let present = {}
let setDragstart = (type,imgItem)=>{
currentType.value.type = type
2024-06-17 09:39:01 +08:00
present.upScaleChecked = false
2024-05-20 10:23:20 +08:00
present = {}
2024-06-17 09:39:01 +08:00
if(imgItem.upScaleChecked){
2024-05-20 10:23:20 +08:00
}else{
2024-06-17 09:39:01 +08:00
imgItem.upScaleChecked = true
2024-05-20 10:23:20 +08:00
present = imgItem
}
currentType.value.data = imgItem
}
2024-02-29 17:16:51 +08:00
let canvasOnDrop = ()=>{
2024-03-04 09:57:46 +08:00
canvas.on('drop', (opt)=> {
let offset = {
left: canvas.getSelectionElement().getBoundingClientRect().left,
top: canvas.getSelectionElement().getBoundingClientRect().top
}
let point = {
x: opt.e.x - offset.left,
y: opt.e.y - offset.top,
}
let pointerVpt = canvas.restorePointerVpt(point)
switch (currentType.value.type) {
case 'colorBoards':
let rect = setGroup(currentType.value.data)
setCanvasColor(pointerVpt.y, pointerVpt.x,rect)
break
case 'moodboardFiles':
createImage(pointerVpt.y, pointerVpt.x,currentType.value.type)
break
default :
createImage(pointerVpt.y, pointerVpt.x,currentType.value.type)
break
}
// 创建完元素,把当前操作的元素类型设置回 null
2024-03-04 09:57:46 +08:00
currentType.value.type = null
currentType.value.data = null
2024-03-04 09:57:46 +08:00
})
}
let setGroup = (data)=>{
2024-06-17 09:39:01 +08:00
let rect
if(data.gradient){
let colorStops = []
data.gradient.gradientList.forEach(item=>{
let obj = {
offset:item.left.split('%')[0]/100,
color:`rgba(${item.rgba.r},${item.rgba.g},${item.rgba.b},${item.rgba.a})`
}
colorStops.push(obj)
})
let { x0, y0, x1, y1 } = calculateGradientCoordinate(100,120,data.gradient.angle)
let linear = new fabric.Gradient({
type: 'linear', // 线性渐变
// coords: { x1: 0, y1: 0, x2: 200, y2: 0 }, // 渐变方向
coords: { x1:x0, y1:y0, x2:x1, y2:y1 }, // 渐变方向
colorStops: colorStops,
})
var color = new fabric.Rect({
top:0,
left:0,
width: 110,
height: 130,
textAlign: "left",
fill: linear // 设置渐变填充
// fill: `rgb(${data.rgbValue.r},${data.rgbValue.g},${data.rgbValue.b})`,
});
var text = new fabric.Text('',{
left: 0,
top: 0,
fontSize: 0,
fontFamily: "Arial",
textAlign: "left",
fill: "black",
});
let text1 = new fabric.Text('',{
left: 0,
top: 0,
width: 20,
fontSize: 0,
fontFamily: "Arial",
textAlign: "left",
});
rect = {text,text1,color,width:110}
}else{
var text = new fabric.Text(data.tcx,{
left: 0,
top: 60,
fontSize: 14,
fontFamily: "Arial",
textAlign: "left",
fill: "black",
});
let text1 = new fabric.Text(data.name,{
left: 0,
top: 80,
width: 20,
fontSize: 14,
fontFamily: "Arial",
textAlign: "left",
});
let width = 110 > text1.width ? 110 : text1.width;
var color = new fabric.Rect({
width: width,
height: 60,
textAlign: "left",
fill: `rgb(${data.rgbValue.r},${data.rgbValue.g},${data.rgbValue.b})`,
});
rect = {text,text1,color,width}
}
2024-03-04 09:57:46 +08:00
return rect
}
let setCanvasColor = (top,left,rect)=>{
2024-06-17 09:39:01 +08:00
let group
group = new fabric.Group([rect.color,rect.text,rect.text1],{
2024-03-04 09:57:46 +08:00
left,
top,
width: rect.width,
fill: "rgb(255,255,255)",
stroke: "#212121",
strokeWidth: 1,
});
canvas.add(group);
return group
}
// 创建矩形
let createImage = async (top, left,key)=> {
2024-03-04 09:57:46 +08:00
let itemCanvasImg = currentType.value.data.imgUrl
2024-06-17 09:39:01 +08:00
let data = JSON.parse(JSON.stringify(currentType.value.data))
2024-03-04 09:57:46 +08:00
if(key == 'likeDesignCollectionList'){
itemCanvasImg = currentType.value.data.designOutfitUrl;
2024-02-27 15:15:38 +08:00
}
await new Promise((resolve,reject)=>{
fabric.Image.fromURL(itemCanvasImg,(img) => {
2024-06-17 09:39:01 +08:00
setCanvasImage(img,key,left,top,data)//设置图片
canvas.add(img);
resolve()
},{ crossOrigin: "Anonymous" });
})
updateCanvasState()
}
//设置画布监听修改添加事件,用来做撤回功能
let updateCanvasState = (str) =>{
const canvasAsJson = JSON.stringify(canvas.toJSON());
if(str == 'loadingCompleted'){
// reverseCanvasState.value.push(canvasAsJson);
}
2024-09-03 16:39:06 +08:00
normalCanvasState.value.push(canvasAsJson);
if (isLoadCanvas) {
reverseCanvasState.value = []
isLoadCanvas = false;
canvasState.value = canvasAsJson
}
2024-03-04 09:57:46 +08:00
}
//撤回
let historyState = (str)=> {
if(str == 'reverse' && reverseCanvasState.value.length > 0){//反撤回
let obj = reverseCanvasState.value.pop()
// canvasState.value = reverseCanvasState.value[reverseCanvasState.value.length-1]
canvasState.value = obj
normalCanvasState.value.push(obj);
}else if(str == '' && normalCanvasState.value.length > 1){
let obj = normalCanvasState.value.pop()
canvasState.value = normalCanvasState.value[normalCanvasState.value.length-1]
reverseCanvasState.value.push(obj);
isLoadCanvas = true;
}else{
return
}
canvas.loadFromJSON(canvasState.value, () => {});
}
//在画布进行画画
let operation = ref('move')
let operationMode = ref('fill')
2024-03-20 13:34:07 +08:00
let textureValue = ref(0)//材质信息
let textureValueChange = (value)=>{
textureValue.value = value
setTexture()
}
//铅笔颜色 大小
2024-03-15 09:21:17 +08:00
let brushworkValue = ref('PencilBrush')
let brushworkChange = (value)=>{
brushworkValue.value = value
setPencil()
}
// let brushwork = ref('')
2024-03-20 13:34:07 +08:00
// 监听键盘的 keydown 和 keyup 事件
let keyDown = []
2024-03-22 12:01:11 +08:00
let canvasKeyDown = (event) => {
2024-03-20 13:34:07 +08:00
if(keyDown.indexOf(event.key)>-1){
}else{
keyDown.push(event.code)
if(event.key === 'Enter' && operation.value == 'fold'){
foldEnd('Enter')
}else if(event.key === 'Delete'){
deleteObject()
}else if(keyDown.indexOf('ControlLeft') > -1 && keyDown.indexOf('KeyZ') > -1 && keyDown.indexOf('ShiftLeft') > -1){
historyState('reverse')
}else if(keyDown.indexOf('ControlLeft') > -1 && keyDown.indexOf('KeyZ') > -1){
historyState('')
}else if(keyDown.indexOf('ControlLeft') > -1 && keyDown.indexOf('KeyC') > -1){
copy()
}else if(keyDown.indexOf('ControlLeft') > -1 && keyDown.indexOf('KeyV') > -1){
paste()
}
}
2024-03-22 12:01:11 +08:00
}
let canvasKeyUp = (event) =>{
keyDown = keyDown.filter(function(item) {
return event.code !== item;
})
}
2024-03-28 17:35:25 +08:00
let setCanvasKeyDown = (event)=>{
// let e = event || window.event
// e.stopPropagation();
document.addEventListener('keydown',canvasKeyDown);
document.addEventListener('keyup', canvasKeyUp);
2024-03-22 12:01:11 +08:00
}
2024-03-28 17:35:25 +08:00
let clearCanvasKeyDown = (pointer)=>{
// var pointer = canvas.getPointer(pointer);
if(!pointer?.target){
document.removeEventListener('keydown',canvasKeyDown);
document.removeEventListener('keyup', canvasKeyUp);
}
// var x = pointer.x;
// var y = pointer.y;
2024-03-28 17:35:25 +08:00
// 检查是否鼠标离开了画布
// if (x < 0 || x > canvas.width || y < 0 || y > canvas.height) {
// // 执行你的操作
// }
// if(!x || !y){
// document.removeEventListener('keydown',canvasKeyDown);
// document.removeEventListener('keyup', canvasKeyUp);
// }
2024-03-22 12:01:11 +08:00
}
let canvasPencilColor = ref('#000000')//画笔颜色
2024-05-21 16:00:27 +08:00
// let canvasPencilWidth = ref(20)//画笔大小
let canvasPencilWidth = ref({
})
2024-06-20 10:36:45 +08:00
let fontFamily = ref({})
let textFontFamilyList = ref([])
let allSelectWidth = ref(-1)//多选或单选的宽度
let allSelect = ref([])//多选或单选的宽度
let setOperation = (str)=>{
operation.value = str
2024-03-15 09:21:17 +08:00
//折线图的时候切换其他形状或者笔触需要把未完成的折线图删掉
canvas.discardActiveObject();//取消所有选中边框
2024-03-15 09:21:17 +08:00
if(createPatterningIs){
canvas.remove(currentPatterning)
}
removeSetText()
initAligningGuidelines(canvas,false)
2024-03-15 09:21:17 +08:00
canvas.remove(polyLineBtn)
if(str == 'pencil'){
setPencil()
2024-09-11 16:36:08 +08:00
pencilbtnStyle.value.display = `block`
}else if(str == 'move'){
JSchangeType(canvas,'init')
initAligningGuidelines(canvas,true)
2024-06-20 10:36:45 +08:00
setMove()
2024-09-11 16:36:08 +08:00
pencilbtnStyle.value.display = `none`
2024-03-20 13:34:07 +08:00
}else if(str == 'texture'){
setTexture()
2024-09-11 16:36:08 +08:00
pencilbtnStyle.value.display = `block`
}else if(str == 'eraser'){
setEraser()
2024-09-11 16:36:08 +08:00
pencilbtnStyle.value.display = `block`
}else if(str == 'text'){
2024-04-25 17:16:34 +08:00
setMove()
setText()
JSchangeType(canvas,'init')
2024-09-11 16:36:08 +08:00
pencilbtnStyle.value.display = `none`
2024-06-20 10:36:45 +08:00
}else if(str){
2024-09-11 16:36:08 +08:00
pencilbtnStyle.value.display = `none`
2024-07-09 15:13:17 +08:00
canvas.forEachObject((obj) =>obj.selectable = false);
canvas.isDrawingMode = false
}
2024-09-11 16:36:08 +08:00
setPencilWidth()
}
let _setAllSelectTime = null
let setAllSelectWidth = ()=>{
clearTimeout(_setAllSelectTime)
allSelect.value.forEach((item)=>{
// item.width = allSelectWidth.value
item.scaleX = allSelectWidth.value/item.width
item.scaleY = item.scaleX
item.setCoords()
})
_setAllSelectTime = setTimeout(() => {
updateCanvasState('')//加载完成后记录一下
}, 1500);
}
2024-03-20 13:34:07 +08:00
let _clipboard = null // 复制到的内容
let copy = () => {//复制
var activeObject = canvas.getActiveObject();
if(!activeObject){
return
}
activeObject.clone(function(cloned) {
_clipboard = cloned;
})
}
let paste = () => {//粘贴
if(!_clipboard){
return
}
_clipboard.clone(clonedObj => {
canvas.discardActiveObject() // 取消选择
// 设置新内容的坐标位置
clonedObj.set({
left: clonedObj.left + 10,
top: clonedObj.top + 10,
evented: true
})
if (clonedObj.type === 'activeSelection') {
// 活动选择需要一个对画布的引用
clonedObj.canvas = canvas;
clonedObj.forEachObject(function(obj) {
canvas.add(obj)
})
clonedObj.setCoords()
} else {
canvas.add(clonedObj)
}
_clipboard.top += 10
_clipboard.left += 10
canvas.setActiveObject(clonedObj)
canvas.requestRenderAll()
})
updateCanvasState()
}
let textureList = ref([])
for (let index = 0; index < 20; index++) {
2024-03-21 10:49:21 +08:00
textureList.value.push({value:index,url:`/image/texture/texture${index}.webp`})
2024-03-20 13:34:07 +08:00
}
let setTexture = async ()=>{
canvas.isDrawingMode = true//开启绘画模式
let img = await JSSetTexture(textureList.value[textureValue.value].url)
let patternBrush = new fabric.PatternBrush(canvas)
patternBrush.source = img
2024-05-21 16:00:27 +08:00
patternBrush.width = canvasPencilWidth.value[operation.value]?canvasPencilWidth.value[operation.value]:20; // 设置画笔大小
2024-03-20 13:34:07 +08:00
canvas.freeDrawingBrush = patternBrush
}
let setOperationMode = (str) =>{
operationMode.value = str
}
2024-03-26 15:45:32 +08:00
let uploadImage = (event)=>{
let input = document.querySelector('.uploadImage input')
const file = event.target.files[0];
2024-05-21 10:55:06 +08:00
setOperation('move')
2024-03-26 15:45:32 +08:00
if (file) {
const reader = new FileReader();
reader.onload = (e) => {
2024-06-17 09:39:01 +08:00
let file = base64ToFile(e.target.result,'upload')
let formData = new FormData();
formData.append("file", file);
let config = {headers:{'Content-Type':'multipart/form-data','Accept':'*/*' }}
Https.axiosPost(Https.httpUrls.canvasElementUpload, formData,config).then((rv)=>{
2024-07-11 17:34:21 +08:00
rv.imgUrl = rv.minioUrl
2024-06-17 09:39:01 +08:00
fabric.Image.fromURL(rv.minioUrl,(img) => {
setCanvasImage(img,"upImgFiles",0,canvas.wrapperEl.parentNode.scrollTop,rv)
canvas.add(img);
},{ crossOrigin: "Anonymous" })
})
2024-03-26 15:45:32 +08:00
input.value = ''
};
reader.readAsDataURL(file);
}
}
2024-03-20 13:34:07 +08:00
let setLayerIndex = (str) =>{//设置优先级
var activeObject = canvas.getActiveObject();
switch (str) {
case 'Front':
canvas.bringToFront(activeObject)//顶层
break
case 'Back':
canvas.sendToBack(activeObject)//底层
break
case 'Forward':
canvas.bringForward(activeObject)
break
case 'Backwards':
canvas.sendBackwards(activeObject)
break
}
}
2024-03-15 09:21:17 +08:00
let hexToRgba=(hex, alpha)=> {
const r = parseInt(hex.slice(1, 3), 16);
const g = parseInt(hex.slice(3, 5), 16);
const b = parseInt(hex.slice(5, 7), 16);
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
}
let brushList = ref([
{
value:'PencilBrush',
2024-03-21 10:49:21 +08:00
url:'/image/brush/PencilBrush.jpg'
2024-03-15 09:21:17 +08:00
},{
value:'Marking',
2024-03-21 10:49:21 +08:00
url:'/image/brush/PencilBrush-2.jpg'
2024-03-15 09:21:17 +08:00
},{
value:'InkBrush',
2024-03-21 10:49:21 +08:00
url:'/image/brush/InkBrush.jpg'
2024-03-15 09:21:17 +08:00
},{
value:'CrayonBrush',
2024-03-21 10:49:21 +08:00
url:'/image/brush/CrayonBrush.jpg'
2024-03-15 09:21:17 +08:00
},{
value:'RibbonBrush',
2024-03-21 10:49:21 +08:00
url:'/image/brush/RibbonBrush.jpg'
2024-03-15 09:21:17 +08:00
},{
value:'MarkerBrush',
2024-03-21 10:49:21 +08:00
url:'/image/brush/MarkerBrush.jpg'
2024-03-15 09:21:17 +08:00
},{
value:'WritingBrush',
2024-03-21 10:49:21 +08:00
url:'/image/brush/WritingBrush.jpg'
2024-03-15 09:21:17 +08:00
},{
value:'LongfurBrush',
2024-03-21 10:49:21 +08:00
url:'/image/brush/LongfurBrush.jpg'
2024-03-15 09:21:17 +08:00
},{
value:'SpraypaintBrush',
2024-03-21 10:49:21 +08:00
url:'/image/brush/SpraypaintBrush.jpg'
2024-03-15 09:21:17 +08:00
},
])
let setPencil =()=>{
2024-03-15 09:21:17 +08:00
let pencil
canvas.isDrawingMode = true//开启绘画模式
2024-03-15 09:21:17 +08:00
if(brushworkValue.value == 'PencilBrush'){
pencil = new fabric.PencilBrush(canvas,{}); //普通笔
}else if(brushworkValue.value == 'Marking'){
pencil = new fabric.PencilBrush(canvas,); //记号笔
}else if(brushworkValue.value == 'InkBrush'){
pencil = new fabric.InkBrush(canvas,{}); //油画笔
}else if(brushworkValue.value=='CrayonBrush'){
pencil = new fabric.CrayonBrush(canvas,{}); //蜡笔
}else if(brushworkValue.value == 'RibbonBrush'){
pencil = new fabric.RibbonBrush(canvas,{width: 1,}); //色带
}else if(brushworkValue.value == 'MarkerBrush'){
pencil = new fabric.MarkerBrush(canvas,{}); //书写笔
2024-03-20 13:34:07 +08:00
// pencil = new fabric.PenBrush(canvas,{}); //书写笔
2024-03-15 09:21:17 +08:00
}else if(brushworkValue.value == 'WritingBrush'){
pencil = new fabric.WritingBrush(canvas,{}); //毛笔
}else if(brushworkValue.value == 'LongfurBrush'){
pencil = new fabric.LongfurBrush(canvas,{width: 1,}); //色带
}else if(brushworkValue.value == 'SpraypaintBrush'){
pencil = new fabric.SpraypaintBrush(canvas,{}); //长毛刷
}
canvas.freeDrawingBrush = pencil
2024-05-21 16:00:27 +08:00
canvas.freeDrawingBrush.width = canvasPencilWidth.value[operation.value]?canvasPencilWidth.value[operation.value]:20;
2024-09-11 16:36:08 +08:00
2024-03-15 09:21:17 +08:00
if(brushworkValue.value == 'RibbonBrush' || brushworkValue.value == 'LongfurBrush'){
canvas.freeDrawingBrush.width = 1;
}
if(brushworkValue.value == 'Marking'){
canvas.freeDrawingBrush.color = hexToRgba(canvasPencilColor.value,.5);
2024-03-20 13:34:07 +08:00
// }else if(brushworkValue.value == 'InkBrush'){
// canvas.freeDrawingBrush.color = hexToRgba(canvasPencilColor.value,.2);
2024-03-15 09:21:17 +08:00
}else{
canvas.freeDrawingBrush.color = hexToRgba(canvasPencilColor.value,1);
}
2024-09-11 16:36:08 +08:00
pencilbtnStyle.value.background = canvasPencilColor.value
canvas.freeDrawingBrush.isEraser = false
2024-03-15 09:21:17 +08:00
}
let setMove = () =>{
canvas.isDrawingMode = false
canvas.forEachObject((obj) =>obj.selectable = true);
}
let setEraser = ()=>{
canvas.isDrawingMode = true
let eraser = new fabric.EraserBrush(canvas)
canvas.freeDrawingBrush = eraser
2024-09-11 16:36:08 +08:00
pencilbtnStyle.value.background = '#fff'
canvas.requestRenderAll();
canvas.freeDrawingBrush.isEraser = true
2024-05-21 16:00:27 +08:00
canvas.freeDrawingBrush.width = canvasPencilWidth.value[operation.value]?canvasPencilWidth.value[operation.value]:20;
}
2024-06-20 10:36:45 +08:00
let createText = {}
let setTextFun = (e)=>{
if(operation.value != 'text'){
return
}
var clickedObject = e.target;
if (clickedObject instanceof fabric.Textbox) {
2024-06-20 10:36:45 +08:00
createText = clickedObject
}else{
var pointer = canvas.getPointer(e.pointer);
var x = pointer.x;
var y = pointer.y;
2024-06-20 10:36:45 +08:00
createText = new fabric.Textbox('', {
left: x,
top: y,
width: 150,
2024-05-21 16:00:27 +08:00
fontSize: canvasPencilWidth.value[operation.value]?canvasPencilWidth.value[operation.value]:20,
2024-06-20 10:36:45 +08:00
fontFamily:fontFamily.value,
fill:canvasPencilColor.value,
})
2024-06-20 10:36:45 +08:00
canvas.add(createText)
createText.enterEditing();
canvas.setActiveObject(createText).renderAll();
operation.value = ''
removeSetText()
}
}
let setText = ()=>{
2024-04-25 17:16:34 +08:00
canvas.on('mouse:down',setTextFun)
2024-06-20 10:36:45 +08:00
// if(isMoible()){
// canvas.on('mouse:down',setTextFun)
// }else{
// canvas.on('mouse:dblclick',setTextFun)
// }
}
let removeSetText = ()=>{
2024-04-25 17:16:34 +08:00
canvas.off('mouse:down',setTextFun)
2024-06-20 10:36:45 +08:00
// if(isMoible()){
// canvas.off('mouse:down',setTextFun)
// }else{
// canvas.off('mouse:dblclick',setTextFun)
// }
}
// let setTextStyle = (x,y)=>{
// var group = new fabric.Group([rect.color, rect.text, rect.text1],{
// left,
// top,
// width: rect.width,
// fill: "rgb(255,255,255)",
// stroke: "#212121",
// strokeWidth: 1,
// });
// canvas.add(group);
// }
let setTimeOut = {
color:null,
width:null,
}//给切换颜色设置防抖
let setPencilColor = ()=>{//切换颜色给铅笔设置颜色
clearTimeout(setTimeOut.color)
setTimeOut.color = setTimeout(()=>{
2024-07-09 15:13:17 +08:00
if(createText.set){
2024-06-20 10:36:45 +08:00
setFontFamily()
return
}
// brushIndicator.fill = canvasPencilColor.value;
2024-03-15 09:21:17 +08:00
if(canvas.freeDrawingBrush.isEraser){
}else{
2024-09-11 16:36:08 +08:00
pencilbtnStyle.value.background = canvasPencilColor.value
}
2024-03-15 09:21:17 +08:00
if(brushworkValue.value == 'Marking'){
canvas.freeDrawingBrush.color = hexToRgba(canvasPencilColor.value,.5);
}else if(brushworkValue.value == 'InkBrush'){
canvas.freeDrawingBrush.color = hexToRgba(canvasPencilColor.value,.2);
}else{
canvas.freeDrawingBrush.color = hexToRgba(canvasPencilColor.value,1);
}
2024-03-15 09:21:17 +08:00
},100)
}
let setPencilWidth = ()=>{//切换颜色给铅笔设置颜色
clearTimeout(setTimeOut.width)
2024-05-21 16:00:27 +08:00
canvasPencilWidth.value[operation.value] = Number(canvasPencilWidth.value[operation.value]?canvasPencilWidth.value[operation.value]:20)
setTimeOut.width = setTimeout(()=>{
2024-03-15 09:21:17 +08:00
if(brushworkValue.value == 'LongfurBrush' || brushworkValue.value == 'RibbonBrush'){
canvas.freeDrawingBrush.width = 1;
}else{
2024-05-21 16:00:27 +08:00
canvas.freeDrawingBrush.width = canvasPencilWidth.value[operation.value];
2024-03-15 09:21:17 +08:00
}
2024-09-11 16:36:08 +08:00
pencilbtnStyle.value.height = canvasPencilWidth.value[operation.value]+'px'
pencilbtnStyle.value.width = canvasPencilWidth.value[operation.value]+'px'
// setPencil()
},300)
}
let downPoint = null;//鼠标按下位置
let upPoint = null;//鼠标抬起位置
let currentPatterning = null//临时图形
let polyLineBtn = null
let createPatterningIs = false
let clearPatterning = () =>{
if(createPatterningIs){
canvas.remove(currentPatterning)
}
currentPatterning = null
canvas.remove(polyLineBtn)
updateCanvasState()
}
//设置再画布上移动
let setCanvasMove = (event)=>{
2024-05-21 10:55:06 +08:00
var pointer = canvas.getPointer(event.e);
if(canvas.isDrawingMode){
canvas.setCursor('none');
}else{
2024-09-11 16:36:08 +08:00
                if(createPatterningIs){
                    JScanvasMouseMove(operation.value,event,currentPatterning,downPoint,keyDown)
                }
            }
let canvasBox = document.querySelector(".Export .canvas-container");
const rect = canvasBox.getBoundingClientRect();
const parentRect = canvasBox.parentElement.getBoundingClientRect();
let parentX = rect.left - parentRect.left
let parentY = rect.top - parentRect.top
pencilbtnStyle.value.left = parentX + pointer.x+'px'
pencilbtnStyle.value.top = parentY + canvasBox.parentElement.scrollTop + pointer.y+'px'
canvas.requestRenderAll()
}
//设置再画布上按下
let setCanvasDown = (event)=>{
2024-05-20 10:23:20 +08:00
//设置移动端按下添加元素
2024-06-20 10:36:45 +08:00
2024-06-17 09:39:01 +08:00
if(isMoible && present.upScaleChecked){
present.upScaleChecked = false
2024-05-20 10:23:20 +08:00
present = {}
let pointerVpt = canvas.restorePointerVpt(event.pointer)
switch (currentType.value.type) {
case 'colorBoards':
let rect = setGroup(currentType.value.data)
setCanvasColor(pointerVpt.y, pointerVpt.x,rect)
break
case 'moodboardFiles':
createImage(pointerVpt.y, pointerVpt.x,currentType.value.type)
break
default :
createImage(pointerVpt.y, pointerVpt.x,currentType.value.type)
break
}
// 创建完元素,把当前操作的元素类型设置回 null
currentType.value.type = null
currentType.value.data = null
}
downPoint = event.absolutePointer
let arr = ['rect','line','circle','triangle','ellipse','fold']
if(arr.indexOf(operation.value) > -1){
JSchangeType(canvas,operation.value)
createPatterningIs = true
if(currentPatterning && operation.value == 'fold'){
canvas.skipTargetFind = false
currentPatterning.points.push({
x: downPoint.x,
y: downPoint.y
})
// currentPatterning = JScanvasMouseDown(operation.value,event,canvasPencilWidth.value,currentPatterning)
}else{
2024-05-21 16:00:27 +08:00
currentPatterning = JScanvasMouseDown(operation.value,event,canvasPencilWidth.value[operation.value]?canvasPencilWidth.value[operation.value]:20,currentPatterning)
2024-03-20 13:34:07 +08:00
canvas.add(currentPatterning)
canvas.bringToFront(currentPatterning);//设置优先级最高
if(operation.value == 'fold'){
polyLineBtn = JScreateCheck(event)
2024-03-20 13:34:07 +08:00
polyLineBtn.on('mousedown',foldEnd)
canvas.add(polyLineBtn)
}
}
}else{
2024-06-20 10:36:45 +08:00
var clickedObject = event.target;
if (clickedObject instanceof fabric.Textbox && operation.value != 'text') {
textDataShow.value = true
createText = clickedObject
setTextData(clickedObject)
}else{
textDataShow.value = false
createText = {}
}
createPatterningIs = false
}
}
2024-03-20 13:34:07 +08:00
let foldEnd = (key)=>{
canvas.skipTargetFind = true
let points = currentPatterning.points
if(key == 'Enter'){
}else{
points.pop()
}
points.pop()
canvas.remove(currentPatterning)
let polyline = new fabric.Polyline(points, {
fill: operationMode.value == 'fill'? canvasPencilColor.value : 'transparent',
stroke: canvasPencilColor.value,
2024-05-21 16:00:27 +08:00
strokeWidth:canvasPencilWidth.value[operation.value]?canvasPencilWidth.value[operation.value]:20,
2024-03-20 13:34:07 +08:00
selection:false,
})
canvas.add(polyline)
// currentPatterning.set({stroke: canvasPencilColor.value})
createPatterningIs = false
clearPatterning()//临时图形置为空并且添加撤回对象里面
2024-06-20 10:36:45 +08:00
setOperation('move')
2024-03-20 13:34:07 +08:00
}
//设置再画布上抬起
let setCanvasUp = (event)=>{
upPoint = event.absolutePointer
if(canvas.isDrawingMode){
2024-03-15 09:21:17 +08:00
setTimeout(() => {
2024-09-11 16:36:08 +08:00
// pencilbtnStyle.value.display = `none`
2024-03-15 09:21:17 +08:00
updateCanvasState()
}, 100);
}else{
// event.target && (event.target.bringToFront())//设置优先级
}
var selectedObjects = canvas.getActiveObjects();//获取多选选中的内容
if (selectedObjects.length >= 1) {
allSelect.value = selectedObjects
// allSelectWidth.value = 0
2024-04-15 16:09:33 +08:00
allSelectWidth.value = (selectedObjects[0].width * selectedObjects[0].scaleX).toFixed(0)
}else{
allSelectWidth.value = -1
}
if(createPatterningIs){
switch (operation.value) {
case 'line':
currentPatterning.set({stroke: canvasPencilColor.value})
break
case 'fold':
// currentPatterning.set({stroke: canvasPencilColor.value})
break
default :
if(operationMode.value == 'fill'){
currentPatterning.set({fill: canvasPencilColor.value})
}else if (operationMode.value == 'border'){
2024-05-21 16:00:27 +08:00
currentPatterning.set({fill: 'transparent',stroke: canvasPencilColor.value,strokeWidth: canvasPencilWidth.value[operation.value]?canvasPencilWidth.value[operation.value]:20})
}
if(JSON.stringify(downPoint) == JSON.stringify(upPoint)){
canvas.remove(currentPatterning)
}
break
}
if(operation.value == 'fold'){
canvas.forEachObject((obj) =>obj.selectable = false);
canvas.bringToFront(polyLineBtn);//设置优先级最高
2024-06-20 10:36:45 +08:00
}else if(operation.value){
createPatterningIs = false
clearPatterning()//临时图形置为空并且添加撤回对象里面
2024-07-09 15:13:17 +08:00
canvas.renderAll();
2024-06-20 10:36:45 +08:00
setOperation('move')
}
}
}
2024-03-15 17:23:25 +08:00
let setHDExport = async ()=>{//获取选中内容的位置信息
// if(allBoardData.value.printboardFiles.length <= 0){
// message.info('Your print is empty')
// return
// }
2024-04-23 11:56:52 +08:00
if(allBoardData.value.printboardFiles.length<=0){
2024-04-22 09:46:40 +08:00
return
}
2024-03-26 15:45:32 +08:00
if(credits.value < 30){
message.info( useI18.t('exportModel.jsContent3'))
2024-03-26 15:45:32 +08:00
// return
2024-03-22 12:01:11 +08:00
}
2024-03-26 15:45:32 +08:00
showSRExport.value = true
let arr = []
if(allBoardData.value.printboardFiles){
allBoardData.value.printboardFiles.forEach((item)=>{
arr.push({
imgUrl:item.imgUrl,
2024-03-27 16:42:52 +08:00
checked:false,
2024-03-26 15:45:32 +08:00
})
})
}
allExportSR.value = arr
2024-03-28 13:44:05 +08:00
allChecked.value = false
2024-03-26 15:45:32 +08:00
//多选导出转高清暂时不用
// let {url,imageType} = await exportSele(canvas,'jpeg')
// if(!imageType){
// message.info('Please select the region of SR')
// return
// }
// let img = new Image
// img.src = url
// let imgStyle = {
// 'width': '80%',
// 'max-height': '30rem',
// 'object-fit': 'contain',
// 'position': 'relative',
// 'left': '50%',
// 'transform': 'translateX(-50%)',
// }
// let imgElement = createVNode('img',{src:url,style:imgStyle})
// img.onload = ()=>{
// Modal.confirm({
// title: 'SR needs 300 points, whether to continue',
// icon: false,
// okText: 'Yes',
// cancelText: 'No',
// content: imgElement,
// mask:false,
// centered:true,
// onOk() {
// if(img.width*scaleSR.value>4069 || img.height*scaleSR.value>4069){
// message.info('Your selected area and SR magnification are more than 4096 pixels,Please re-select.')
// return
// }
// let data = {
// images: url,
// scale: scaleSR.value,
// uniqueId: "",
// imageType:imageType,
// }
// Https.axiosPost(Https.httpUrls.prepareForSR, data).then((rv) => {
// console.log(rv);
// store.dispatch('getCredits')
// emit('setTask')
// });
// },
// // onCancel(){
2024-06-17 09:39:01 +08:00
// // _this.isShowMark.value = false
2024-03-26 15:45:32 +08:00
// // resolve(false)
// // }
// });
// }
}
let allExportSR = ref([])
let scaleSR = ref(2);
2024-03-27 17:49:25 +08:00
2024-03-27 16:42:52 +08:00
let setScaleSR = (value)=>{
scaleSR.value = value
}
2024-03-26 15:45:32 +08:00
let showSRExport = ref(false)
let cancelSRExport = ()=>{
allExportSR.value = []
showSRExport.value = false
}
let allChecked = ref(false)
let selectImg = (item)=>{
item.checked = !item.checked
let arr = allExportSR.value.filter((item)=>item.checked)
if(arr.length == allExportSR.value.length){
allChecked.value = true
}else{
allChecked.value = false
}
}
let selectAllImg = ()=>{
allChecked.value = !allChecked.value
allExportSR.value.forEach((item)=>{
item.checked = allChecked.value
})
}
let setExportSR = ()=>{
let arr = []
let data = []
// if(allExportSR.value.filter(item=> item.checked ).length <= 0){
// message.info('Your print is empty')
// return
// }
2024-03-26 15:45:32 +08:00
if(credits < (allExportSR.value.filter(item=> item.checked ).length*30)){
message.info(useI18.t('exportModel.jsContent4'))
2024-03-26 15:45:32 +08:00
return
}
let allPromise = allExportSR.value.map(async (item,index)=>{
if(item.checked){
return await new Promise((resolve,reject)=>{
let obj = {}
2024-03-26 15:45:32 +08:00
obj = {
images:item.imgUrl,
2024-03-22 12:01:11 +08:00
scale: scaleSR.value,
uniqueId: "",
}
2024-03-26 15:45:32 +08:00
data.push(obj)
let img = new Image
img.onload = ()=>{
2024-04-15 16:09:33 +08:00
if(img.width*scaleSR.value>2048 || img.height*scaleSR.value>2048){
2024-03-26 15:45:32 +08:00
arr.push(index)
}
2024-06-17 09:39:01 +08:00
img.remove()
resolve(img)
2024-03-26 15:45:32 +08:00
}
img.src = item.imgUrl
})
}else{
return
}
2024-03-26 15:45:32 +08:00
})
Promise.all(allPromise)
.then(promiseArr => {
if(arr.length > 0){
arr.forEach((item,index)=>arr[index]+=1)
let str = arr.join(',')
message.info(useI18.t('exportModel.jsContent5',{str:str}))
return
}
let aa = promiseArr.filter(item=> item == undefined)
if(aa.length == promiseArr.length){
message.info(useI18.t('exportModel.jsContent6'))
}else{
Https.axiosPost(Https.httpUrls.prepareForSR, data).then((rv) => {
emit('setTask',rv)
cancelSRExport()
});
}
})
.catch(error => {
2024-03-26 15:45:32 +08:00
});
2024-02-27 15:15:38 +08:00
}
2024-06-17 09:39:01 +08:00
2024-04-25 12:58:10 +08:00
let toSvg = ()=>{
// console.log(canvas.toSvg());
2024-04-25 17:16:34 +08:00
}
2024-08-26 10:06:08 +08:00
let setShare = async ()=>{
2024-06-17 09:39:01 +08:00
initAligningGuidelines(canvas,false)
let publishModal = publish.value
publishModal.publishMask = true
2024-08-26 10:06:08 +08:00
var imageDataURL = await setExportCanvas()
2024-06-17 09:39:01 +08:00
let data = {
"imgUrl":imageDataURL,
userlikeGroupId:userlikeGroupId,
}
publishModal.init(data)
}
let setSubmit = ()=>{
2024-08-19 10:36:46 +08:00
let data = setCanvasContent(false)
2024-06-17 09:39:01 +08:00
data.canvasHeight = canvasWH.value.height
let blob = new Blob([JSON.stringify(data)], { type: "application/json" });
let formData = new FormData();
formData.append("file", blob, "data.json");
formData.append('userLikeGroupId', userlikeGroupId);
let config = {headers:{'Content-Type':'multipart/form-data','Accept':'*/*' }}
Https.axiosPost(Https.httpUrls.exportSave, formData,config).then((rv)=>{
2024-06-21 10:30:09 +08:00
message.success(t('exportModel.jsContent7'))
2024-06-17 09:39:01 +08:00
})
}
2024-08-19 10:36:46 +08:00
let setCanvasContent = (isSaveImg)=>{
2024-06-17 09:39:01 +08:00
var json = canvas.toJSON(['imgId','minioUrl']);
// console.log(JSON.stringify(json));
2024-08-19 10:36:46 +08:00
if(!isSaveImg){
json.objects.forEach(item=>{
if(item.type == 'image'){
delete item.src
}
})
}
2024-06-17 09:39:01 +08:00
return json
}
2024-06-20 10:36:45 +08:00
let textDataShow = ref(false)
let setTextData = (obj)=>{
fontFamily.value = obj.fontFamily
canvasPencilWidth.value['text'] = obj.fontSize
canvasPencilColor.value = obj.fill
}
let setFontFamily = ()=>{
2024-07-12 15:54:46 +08:00
if(createText.set){
2024-06-20 10:36:45 +08:00
createText.set({
fontFamily:fontFamily.value,
fontSize:canvasPencilWidth.value[operation.value]?canvasPencilWidth.value[operation.value]:20,
fill:canvasPencilColor.value,
})
canvas.renderAll();
}
}
onMounted(() => {
let arr = [
{ value: 'Arial', name: 'select font' },
{ value: 'EN_slogan_art1', name: 'select font' },
{ value: 'EN_slogan_art2', name: 'select font' },
{ value: 'EN_slogan_art3', name: 'select font' },
{ value: 'EN_slogan_art4', name: 'select font' },
{ value: 'EN_slogan_art5', name: 'select font' },
{ value: 'EN_slogan_art6', name: 'select font' },
{ value: 'EN_slogan_art7', name: 'select font' },
{ value: '微软雅黑', name: '请选择字体' },
{ value: 'CN_slogan_art1', name: '请选择字体' },
{ value: 'CN_slogan_art2', name: '请选择字体' },
{ value: 'CN_slogan_art3', name: '请选择字体' },
{ value: 'CN_slogan_art4', name: '请选择字体' },
{ value: '华文行楷', name: '请选择字体' },
{ value: '隶书', name: '请选择字体' },
]
textFontFamilyList.value = arr
fontFamily.value = arr[0].value
2024-08-19 10:36:46 +08:00
2024-06-20 10:36:45 +08:00
});
2024-02-23 14:32:33 +08:00
return {
2024-04-25 17:16:34 +08:00
toSvg,
2024-03-26 15:45:32 +08:00
t,
2024-04-25 12:58:10 +08:00
toSvg,
2024-03-15 09:21:17 +08:00
showUpgradePlan,//当前弹窗是否打开
canvasWH,//画布初始宽高
2024-09-11 16:36:08 +08:00
pencilbtnStyle,//笔触按钮
2024-06-17 09:39:01 +08:00
publish,//发布作品广场
2024-03-15 09:21:17 +08:00
credits,//积分 用来判断HD导出积分是否够用
init,//首页点击导出后初始化
setExport,//导出所有内容
cancelDsign,//关闭画布
setMaxInput,//设置画布宽高
isShowMark,//加载遮罩
allBoardData,//选择画布所有内容
closeNav,//导航展开或者收起来状态
setCloseNav,//给图片导航或者工具收起来或者展开
multiselect,//获取整体高度
onDragstart,//拖拽函数
2024-05-20 10:23:20 +08:00
setDragstart,//的移动端拖拽改为按下
2024-03-15 09:21:17 +08:00
historyState,//执行撤回或者反撤回
operation,//设置当前鼠标状态绘画或者矩形或者移动
operationMode,//设置矩形是边框还是填充
setOperation,//设置当前鼠标状态绘画或者矩形或者移动方法
setOperationMode,//设置矩形是边框还是填充方法
2024-03-26 15:45:32 +08:00
uploadImage,//上传图帕
2024-03-20 13:34:07 +08:00
setLayerIndex,//设置选中元素的层级
2024-03-15 09:21:17 +08:00
brushList,//笔触列表
2024-03-20 13:34:07 +08:00
textureList,//材质列表
2024-03-15 09:21:17 +08:00
canvasPencilColor,//input选择颜色
canvasPencilWidth,//input选择宽度
setAllSelectWidth,//多选设置宽度
allSelectWidth,//多选设置宽度的值
2024-03-15 09:21:17 +08:00
setPencilColor,//切换颜色执行函数 给当前矩形或者笔触设置颜色
setPencilWidth,//切换宽度执行函数 给当前矩形或者笔触设置宽度
setHDExport,//高清导出选择的图片
brushworkChange,//切换笔触的回调
2024-03-20 13:34:07 +08:00
textureValueChange,//切换材质信息
2024-03-15 09:21:17 +08:00
brushworkValue,//当前笔触
2024-03-20 13:34:07 +08:00
textureValue,//当前材质
2024-03-22 12:01:11 +08:00
scaleSR,
2024-03-27 16:42:52 +08:00
setScaleSR,
2024-03-26 15:45:32 +08:00
//SR页面
showSRExport,
allExportSR,
cancelSRExport,//关闭高清导出
allChecked,//全选
selectAllImg,//控制全选
selectImg,//选中单个图片
setExportSR,//设置SR导出
2024-06-17 09:39:01 +08:00
setShare,
setSubmit,
2024-06-20 10:36:45 +08:00
textFontFamilyList,
fontFamily,
textDataShow,
setFontFamily,
2024-02-23 14:32:33 +08:00
};
},
data(prop) {
2024-05-18 15:39:32 +08:00
return {
isMoible:isMoible()
};
2024-02-23 14:32:33 +08:00
},
2024-06-17 09:39:01 +08:00
computed: {
setGradient(){
return (gradient)=>{
let gradientStr = ''
gradient.gradientList.sort((a, b) => {
let aArr = a.left.split('%')[0]
let bArr = b.left.split('%')[0]
return aArr - bArr;
});
gradient.gradientList.forEach((item,index)=>{
let str = ','
if(gradient.gradientList.length == index+1)str = ''
gradientStr += `rgba(${item.rgba.r},${item.rgba.g},${item.rgba.b},${item.rgba.a}) ${item.left}${str}`
})
return `${gradientStr}`
}
}
},
2024-02-29 17:16:51 +08:00
watch: {
2024-09-11 16:36:08 +08:00
// 'canvasWH.height':{
// handler(newVal,oldVal){
// if(!this.isMoible){
// return
// }
// return
// let canvasBox = document.querySelector('.exportCanvasBox .exportCanvasBox_center')
// let scrollBox = document.querySelector('.exportCanvasBox_scroll div')
// canvasBox.scroll({
// top: 0, // 纵向滚动距离
// left: 0, // 横向滚动距离
// });
// scrollBox.style.marginTop = 0+'px'
// let height = canvasBox.offsetHeight / (newVal / canvasBox.offsetHeight )
// scrollBox.style.height = height +'px'
// let scale = (newVal - canvasBox.offsetHeight) / (canvasBox.offsetHeight - height)
2024-05-18 15:39:32 +08:00
2024-09-11 16:36:08 +08:00
// let mousedown = (event)=>{//按下
// let position = {
// y:event.touches[0].screenY,
// top : scrollBox.style.marginTop?scrollBox.style.marginTop.split('px')[0]*1:0
// }
// // let top =
// let scrollMousemove = (e)=>{
// let height = scrollBox.style.height.split('px')[0]*1
// let offsetTop = position.top+e.touches[0].screenY - position.y
// offsetTop = offsetTop <= 0? 0 : offsetTop
// offsetTop = height+offsetTop >= canvasBox.offsetHeight? canvasBox.offsetHeight - height : offsetTop
// scrollBox.style.marginTop = offsetTop+'px'
// canvasBox.scroll({
// top: offsetTop*scale, // 纵向滚动距离
// left: 0, // 横向滚动距离
// });
// }
// let mouseup = ()=>{//抬起
// window.removeEventListener('touchmove',scrollMousemove)
// scrollBox.removeEventListener('touchend',mouseup)
// }
// window.addEventListener('touchmove',scrollMousemove)
// scrollBox.addEventListener('touchend',mouseup)
// }
// scrollBox.removeEventListener('touchstart',mousedown)
// scrollBox.addEventListener('touchstart',mousedown)
2024-05-18 15:39:32 +08:00
2024-09-11 16:36:08 +08:00
// }
// },
2024-02-23 14:32:33 +08:00
},
2024-05-18 15:39:32 +08:00
mounted() {},
2024-03-04 09:57:46 +08:00
methods: {
},
2024-02-23 14:32:33 +08:00
});
</script>
<style lang="less" scoped>
2024-03-26 15:45:32 +08:00
2024-02-23 14:32:33 +08:00
.Export {
2024-02-29 17:16:51 +08:00
flex: 1;
2024-02-23 14:32:33 +08:00
// height: 30rem;
// overflow-x: hidden;
2024-09-03 16:39:06 +08:00
.icon{
transition: all .3s;
}
.icon-rotate{
transform: rotate(-180deg);
}
2024-02-29 17:16:51 +08:00
.exportCanvasBox {
flex: 1;
overflow-x: hidden;
display: flex;
margin-top: 2rem;
justify-content: space-between;
2024-09-03 16:39:06 +08:00
flex-direction: column;
2024-02-29 17:16:51 +08:00
.exportCanvasBox_title {
margin-bottom: .5rem;
font-size: 1.8rem;
2024-09-11 16:36:08 +08:00
// font-weight: 600;
2024-03-08 16:51:24 +08:00
// margin-top: 2rem;
padding-top: 2rem;
2024-02-29 17:16:51 +08:00
display: flex;
2024-03-08 16:54:04 +08:00
top: -1rem;
2024-02-29 17:16:51 +08:00
justify-content: space-between;
cursor: pointer;
position: sticky;
background: #f9fafb;
z-index: 2;
2024-09-03 16:39:06 +08:00
align-items: flex-start;
2024-09-11 16:36:08 +08:00
margin: 0 2rem;
2024-09-03 16:39:06 +08:00
2024-02-29 17:16:51 +08:00
}
.exportCanvasBox_intro{
margin-bottom: 1rem;
font-size: 1.6rem;
font-weight: 600;
width: 100%;
2024-02-27 15:15:38 +08:00
}
2024-02-29 17:16:51 +08:00
.exportCanvasBox_right,
.exportCanvasBox_left {
2024-09-03 16:39:06 +08:00
width: 100%;
height: auto;
2024-09-11 16:36:08 +08:00
.exportCanvasBox_left_tool{
margin: 0;
}
2024-03-04 09:57:46 +08:00
label {
2024-02-29 17:16:51 +08:00
display: flex;
2024-03-04 09:57:46 +08:00
align-items: center;
2024-09-11 16:36:08 +08:00
width: 23%;
2024-02-29 17:16:51 +08:00
div {
2024-09-11 16:36:08 +08:00
width: auto;
margin-right: 2rem;
white-space: nowrap;
2024-02-29 17:16:51 +08:00
}
2024-06-20 10:36:45 +08:00
input,select {
2024-03-15 09:21:17 +08:00
// width: 10em;
flex: 1;
overflow: hidden;
2024-06-20 10:36:45 +08:00
height: 4.5rem;
2024-02-29 17:16:51 +08:00
}
2024-06-20 10:36:45 +08:00
2024-03-15 09:21:17 +08:00
.label_select{
img{
width: 100%;
2024-03-15 17:23:25 +08:00
max-height: 100%;
object-fit: contain;
2024-03-15 09:21:17 +08:00
}
}
2024-02-29 17:16:51 +08:00
}
2024-03-20 13:34:07 +08:00
.texture{
.label_select{
img{
max-height: none;
}
}
}
.exportCanvasBox_left_item.closeNav{
// max-height: 1000rem;
2024-09-03 16:39:06 +08:00
// height: auto;
display: block;
2024-03-04 09:57:46 +08:00
}
}
.exportCanvasBox_left::-webkit-scrollbar,
.exportCanvasBox_right::-webkit-scrollbar{display: none;}
.exportCanvasBox_left {
2024-03-26 15:45:32 +08:00
padding-right: 1rem;
margin-right: 2rem;
2024-09-03 16:39:06 +08:00
// height: 7rem;
display: flex;
flex-wrap: wrap;
align-items: flex-start;
position: relative;
2024-09-11 16:36:08 +08:00
flex-direction: row;
2024-09-03 16:39:06 +08:00
>label{
width: 20%;
2024-03-26 15:45:32 +08:00
}
.exportCanvasBox_title {
2024-09-11 16:36:08 +08:00
// margin: 0 4rem;
2024-09-03 16:39:06 +08:00
position: relative;
2024-09-11 16:36:08 +08:00
.exportCanvasBox_left_tool_item{
display: flex;
flex-direction: column;
}
}
.exportCanvasBox_left_item{
2024-02-29 17:16:51 +08:00
overflow: hidden;
transition: all .3s;
// max-height: 0;
2024-03-04 09:57:46 +08:00
transform: translate3d(0, 0, 0);
2024-09-03 16:39:06 +08:00
position: absolute;
}
.exportCanvasBox_left_item,.exportCanvasBox_imgbor,.exportCanvasBox_operation_bor{
background: #fff;
height: auto;
max-height: 30rem;
border: 1px solid;
display: none;
top: 7rem;
position: absolute;
}
2024-09-11 16:36:08 +08:00
2024-09-03 16:39:06 +08:00
.exportCanvasBox_imgbor {
// height: auto;
2024-09-03 16:39:06 +08:00
width: 20rem;
overflow-y: auto;
padding: 1rem;
&.exportCanvasBox_imgbor::-webkit-scrollbar{display: none;}
2024-02-29 17:16:51 +08:00
.exportCanvasBox_allItem {
display: flex;
flex-wrap: wrap;
2024-09-03 16:39:06 +08:00
justify-content: space-between;
2024-02-29 17:16:51 +08:00
.exportCanvasBox_item {
text-align: center;
2024-03-26 15:45:32 +08:00
.exportCanvasBox_img{
position: relative;
2024-02-29 17:16:51 +08:00
margin-bottom: 2rem;
2024-03-26 15:45:32 +08:00
img {
max-width: 7rem;
max-height: 7rem;
object-fit: contain;
}
.exportCanvasBox_img_SR{
position: absolute;
bottom: 0;
height: 2rem;
background: rgba(0, 0, 0, 0.3);
color: #fff;
width: 100%;
text-align: center;
font-weight: 600;
cursor: pointer;
}
}
2024-02-29 17:16:51 +08:00
}
2024-09-03 16:39:06 +08:00
.exportCanvasBox_item_colorBor{
width: 100%;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
2024-02-29 17:16:51 +08:00
.exportCanvasBox_item_color{
width: 8rem;
margin-bottom: 2rem;
.exportCanvasBox_item_BGcolor{
height: 5rem;
}
2024-03-04 09:57:46 +08:00
div{
// -webkit-user-select:none; /* Safari */
// -moz-user-select:none; /* Firefox */
// -ms-user-select:none; /* IE10+/Edge */
// user-select:none; /* Standard syntax */
}
2024-02-29 17:16:51 +08:00
}
.exportCanvasBox_item_dispose{
img{
max-width: 100%;
max-height: 100%;
}
}
2024-05-20 10:23:20 +08:00
.active{
opacity: .5;
transform: scale(.9);
}
2024-02-29 17:16:51 +08:00
}
}
2024-09-11 16:36:08 +08:00
.exportCanvasBox_operation_bor_item{
flex: 1;
margin-left: 8rem;
display: flex;
label{
margin-right: 2rem;
2024-09-03 16:39:06 +08:00
}
2024-09-11 16:36:08 +08:00
}
.exportCanvasBox_left_tool_item{
display: flex;
flex: 1;
flex-wrap: wrap;
justify-content: space-between;
align-items: center;
flex-direction: row;
flex-wrap: nowrap;
&.leftAlign{
justify-content: flex-start;
}
&.leftAlign{
justify-content: flex-start;
}
i{
font-size: 2.5rem;
cursor: pointer;
width: 4rem;
height: 4rem;
display: flex;
2024-09-03 16:39:06 +08:00
align-items: center;
2024-09-11 16:36:08 +08:00
justify-content: center;
flex-shrink: 0;
&.active{
border: 1px solid;
border-radius: .4rem;
}
2024-09-11 16:36:08 +08:00
}
.uploadImage{
width: 4rem;
height: 4rem;
input{
height: 0;
width: 0;
border: none;
2024-03-08 16:51:24 +08:00
}
2024-03-04 09:57:46 +08:00
}
2024-09-11 16:36:08 +08:00
2024-03-04 09:57:46 +08:00
}
2024-03-26 15:45:32 +08:00
}
2024-09-03 16:39:06 +08:00
.exportCanvasBox_bottom{
width: 100%;
flex-shrink: 0;
background: #f9fafb;
z-index: 2;
padding-top: 2rem;
.exportCanvasBox_left_credits{
margin-right: auto
}
.exportCanvasBox_left_btn{
display: flex;
justify-content: flex-end;
flex-wrap: wrap;
align-items: flex-start;
.subitOkPreviewBtn{
position: initial;
transform: none;
margin-bottom: 0rem;
width: auto;
text-align: center;
&.active{
opacity: .7;
cursor: not-allowed;
}
}
.subitOkPreviewBtn:nth-child(2n){
margin: 0 1rem;
}
}
}
2024-09-11 16:36:08 +08:00
.exportCanvasBox_center_box{
display: flex;
overflow: hidden;
}
2024-02-29 17:16:51 +08:00
.exportCanvasBox_center {
2024-03-26 15:45:32 +08:00
flex: 1;
2024-02-29 17:16:51 +08:00
height: 100%;
2024-09-11 16:36:08 +08:00
overflow-y: auto;
2024-02-29 17:16:51 +08:00
overflow-x: hidden;
2024-09-11 16:36:08 +08:00
position: relative;
.editFrontBack_pencilbtn{
position: absolute;
z-index: 1;
border-radius: 50%;
border: 1px solid #000;
pointer-events: none;
transform: translate(-50%,-50%);
}
&.exportCanvasBox_center::-webkit-scrollbar-button:single-button{
}
&.exportCanvasBox_center::-webkit-scrollbar {
/* 竖轴的宽度 */
width: 2rem;
/* 横轴的高度 */
height: 1rem;
transition: all .3s;
}
/* 进度 */
&.exportCanvasBox_center::-webkit-scrollbar-thumb {
border-radius: 1rem;
background: #543087;
}
/* 轨道 */
&.exportCanvasBox_center::-webkit-scrollbar-track {
border-radius: 1rem;
background: rgba(84, 48, 135,.2);
// background: rgba(238, 238, 244, 0);
}
2024-02-29 17:16:51 +08:00
}
2024-05-18 15:39:32 +08:00
.exportCanvasBox_scroll{
height: 100%;
width: 2rem;
background: #d6cfe3;
border-radius: 1rem;
div{
background: #543087;
border-radius: 1rem;
width: 100%;
height: 30rem;
}
}
2024-02-29 17:16:51 +08:00
.export_new_collection_review {
position: initial;
margin: 10rem auto;
margin-bottom: 0;
}
}
2024-02-23 14:32:33 +08:00
}
</style>
<style lang="less">
2024-02-29 17:16:51 +08:00
.Export {
.ant-modal-content {
.ant-modal-body {
height: calc(65rem * 1.2);
}
}
2024-03-26 15:45:32 +08:00
2024-03-15 09:21:17 +08:00
}
.label_select_item{
img{
width: 100%;
2024-03-15 17:23:25 +08:00
max-height: 100%;
object-fit: contain;
2024-03-15 09:21:17 +08:00
}
2024-02-23 14:32:33 +08:00
}
2024-03-26 15:45:32 +08:00
</style>
<style lang="less">
.SRExport{
.ant-modal-body{
height: calc(35rem* 1.2);
}
.SRExport_img{
margin-bottom: 2rem;
flex: 1;
overflow-x: hidden;
2024-03-27 16:42:52 +08:00
display: flex;
flex-wrap: wrap;
min-height: 12rem;
.SRExport_img_item_box{
position: relative;
margin-right: 2rem;
margin-bottom: 2rem;
input{
position: absolute;
top: .5rem;
right: .5rem;
2024-03-27 16:42:52 +08:00
z-index: 2;
height: 2rem;
width: 2rem;
2024-03-27 16:42:52 +08:00
}
}
2024-03-26 15:45:32 +08:00
img{
width: 10rem;
max-height: 10rem;
object-fit: contain;
text-align: center;
cursor: pointer;
&.active{
transform: scale(.8);
opacity: .6;
}
}
}
.check_all_block{
display: flex;
align-items: center;
font-size: 1.6rem;
color: #64686D;
cursor: pointer;
justify-content: flex-end;
&.check_all{
color: #1A1A1A;
.check_block{
.check_block_body{
opacity: 1;
}
}
}
.check_block{
width: 2.4rem;
height: 2.4rem;
background: #EBECF4;
border: 0.1rem solid #64686D;
padding: 0.3rem;
margin-right: 0.7rem;
.check_block_body{
width: 100%;
opacity: 0;
height: 100%;
background: #343579;
}
}
}
.SRExport_operate{
display: flex;
align-items: center;
justify-content: space-between;
2024-03-27 16:42:52 +08:00
.SRExport_operate_box {
2024-03-26 15:45:32 +08:00
display: flex;
align-items: center;
margin-bottom: 1rem;
width: 100%;
2024-03-27 16:42:52 +08:00
>div {
width: 5rem;
2024-03-26 15:45:32 +08:00
}
2024-03-27 17:49:25 +08:00
.SRExport_operate_item_sclae{
width: 4rem;
height: 3rem;
border: .2rem solid rgba(0, 0, 0, 0.3);
display: flex;
align-items: center;
justify-content: center;
margin-right: 1rem;
cursor: pointer;
border-radius: .4rem;
font-weight: 600;
&.active{
border-color: rgba(152, 139, 247);
color: rgba(152, 139, 247);
}
}
2024-03-27 16:42:52 +08:00
.SRExport_operate_sclae{
max-width: 15rem;
2024-03-27 17:49:25 +08:00
2024-03-26 15:45:32 +08:00
}
2024-03-27 16:42:52 +08:00
// input {
// // width: 10em;
// overflow: hidden;
// }
// label{
// display: flex;
// align-items: center;
// margin-right: 2rem;
// span{
// margin-right: 1rem;
// }
// }
2024-03-26 15:45:32 +08:00
}
}
.generalModelOperate_endBtn{
.generalModelOperate_btn_ok{
&.active{
opacity: .6;
cursor: no-drop;
}
}
}
}
2024-02-23 14:32:33 +08:00
</style>