Commit 34c277f4 by zhuzhequan

添加铺满功能

parent 5cfdd1a6
...@@ -323,7 +323,10 @@ export default { ...@@ -323,7 +323,10 @@ export default {
this.detail = findByPodProductionNo.data; this.detail = findByPodProductionNo.data;
// console.log("detail111111", findByPodProductionNo); // console.log("detail111111", findByPodProductionNo);
let imageResList = []; let imageResList = [];
let designImagesCanvasJsonList = this.detail.drParam; let designImagesCanvasJsonList = this.detail.drParam
this.detail.adjustable = true
this.detail.mssWidth = 400
this.detail.mssHeight = 450
if (designImagesCanvasJsonList) { if (designImagesCanvasJsonList) {
designImagesCanvasJsonList = JSON.parse(designImagesCanvasJsonList); designImagesCanvasJsonList = JSON.parse(designImagesCanvasJsonList);
let imageList = await this.canvasToImage(designImagesCanvasJsonList); let imageList = await this.canvasToImage(designImagesCanvasJsonList);
......
...@@ -240,6 +240,15 @@ export default { ...@@ -240,6 +240,15 @@ export default {
:span="24" :span="24"
style="display: flex;justify-content: space-between;padding:0 30px;" style="display: flex;justify-content: space-between;padding:0 30px;"
> >
<el-tooltip content="铺满">
<el-button @click="$emit('ev', 'cover')" class="btn">
<img
style="width: 13px;height: 13px"
src="@/static/icon/pm.png"
alt=""
/>
</el-button>
</el-tooltip>
<el-tooltip content="居中"> <el-tooltip content="居中">
<el-button @click="$emit('ev', 'center')" class="btn"> <el-button @click="$emit('ev', 'center')" class="btn">
<img <img
......
<script> <script>
import VueDragResizeRotate from "@minogin/vue-drag-resize-rotate"; import VueDragResizeRotate from "@minogin/vue-drag-resize-rotate";
import PicScrollbarBox from "../../../components/PicScrollbarBox.vue"; import PicScrollbarBox from "../../../components/PicScrollbarBox.vue";
const { ipcRenderer } = require("electron"); const { ipcRenderer } = require("electron");
// import { fabric } from "fabric"; // import { fabric } from "fabric";
...@@ -15,6 +16,7 @@ const uuid = require("uuid"); ...@@ -15,6 +16,7 @@ const uuid = require("uuid");
import { startLoading, endLoading } from "@/utils/axios.js"; import { startLoading, endLoading } from "@/utils/axios.js";
import { mapState } from "vuex"; import { mapState } from "vuex";
const img = require("../../../assets/bg_tshirt_shadow.png"); const img = require("../../../assets/bg_tshirt_shadow.png");
export default { export default {
...@@ -22,7 +24,7 @@ export default { ...@@ -22,7 +24,7 @@ export default {
PrintDialog, PrintDialog,
VueDragResizeRotate, VueDragResizeRotate,
ImgSetting, ImgSetting,
PicScrollbarBox, PicScrollbarBox
}, },
props: { factoryType: { type: String, default: "CN" } }, props: { factoryType: { type: String, default: "CN" } },
destroyed() { destroyed() {
...@@ -64,7 +66,7 @@ export default { ...@@ -64,7 +66,7 @@ export default {
return { return {
w: this.grid[this.systemSetting.gridValue].w, w: this.grid[this.systemSetting.gridValue].w,
v: this.grid[this.systemSetting.gridValue].value, v: this.grid[this.systemSetting.gridValue].value,
h: this.grid[this.systemSetting.gridValue].h, h: this.grid[this.systemSetting.gridValue].h
}; };
}, },
gridSpacing() { gridSpacing() {
...@@ -74,7 +76,7 @@ export default { ...@@ -74,7 +76,7 @@ export default {
if (unit === "mm") { if (unit === "mm") {
return { return {
w: gridSpacing + "px", w: gridSpacing + "px",
h: gridSpacing + "px", h: gridSpacing + "px"
}; };
} else if (unit === "inch") { } else if (unit === "inch") {
let w = this.grid[this.systemSetting.gridValue].w; let w = this.grid[this.systemSetting.gridValue].w;
...@@ -84,7 +86,7 @@ export default { ...@@ -84,7 +86,7 @@ export default {
return { return {
// w: gridSpacing * ((w - row + 1) / row) + "px", // w: gridSpacing * ((w - row + 1) / row) + "px",
w: gridSpacing * (w / row) + "px", w: gridSpacing * (w / row) + "px",
h: gridSpacing * (h / col) + "px", h: gridSpacing * (h / col) + "px"
}; };
} }
return { w: "480px", h: "540px" }; return { w: "480px", h: "540px" };
...@@ -96,7 +98,7 @@ export default { ...@@ -96,7 +98,7 @@ export default {
if (unit === "mm") { if (unit === "mm") {
return { return {
w: gridSpacing + "px", w: gridSpacing + "px",
h: gridSpacing + "px", h: gridSpacing + "px"
}; };
} else if (unit === "inch") { } else if (unit === "inch") {
let w = 480; let w = 480;
...@@ -105,7 +107,7 @@ export default { ...@@ -105,7 +107,7 @@ export default {
let h = 540; let h = 540;
return { return {
w: gridSpacing * (w / row) + "px", w: gridSpacing * (w / row) + "px",
h: gridSpacing * (h / col) + "px", h: gridSpacing * (h / col) + "px"
}; };
} }
return { w: "480px", h: "540px" }; return { w: "480px", h: "540px" };
...@@ -138,8 +140,8 @@ export default { ...@@ -138,8 +140,8 @@ export default {
"WHproportion", "WHproportion",
"grid", "grid",
"windowWH", "windowWH",
"countryList", "countryList"
]), ])
}, },
data() { data() {
return { return {
...@@ -157,7 +159,7 @@ export default { ...@@ -157,7 +159,7 @@ export default {
"hsva(120, 40, 94, 0.5)", "hsva(120, 40, 94, 0.5)",
"hsl(181, 100%, 37%)", "hsl(181, 100%, 37%)",
"hsla(209, 100%, 56%, 0.73)", "hsla(209, 100%, 56%, 0.73)",
"#c7158577", "#c7158577"
], ],
actionList: [], actionList: [],
checkList: [], checkList: [],
...@@ -192,7 +194,7 @@ export default { ...@@ -192,7 +194,7 @@ export default {
col: 7, col: 7,
oldImgStyle: "", oldImgStyle: "",
drrDom: null, drrDom: null,
imgDom: null, imgDom: null
}; };
}, },
watch: { watch: {
...@@ -220,7 +222,7 @@ export default { ...@@ -220,7 +222,7 @@ export default {
this.$store.commit("changeImgList", this.imgList); this.$store.commit("changeImgList", this.imgList);
}, },
deep: true, deep: true,
immediate: true, immediate: true
}, },
selectIndex() { selectIndex() {
if (this.selectIndex >= 0) { if (this.selectIndex >= 0) {
...@@ -264,7 +266,7 @@ export default { ...@@ -264,7 +266,7 @@ export default {
this.imgDom = ""; this.imgDom = "";
} }
}, },
immediate: true, immediate: true
}, },
systemSetting: { systemSetting: {
handler() { handler() {
...@@ -272,8 +274,8 @@ export default { ...@@ -272,8 +274,8 @@ export default {
this.$refs.imgSetting?.getCurrentItem(this.imgList[this.selectIndex]); this.$refs.imgSetting?.getCurrentItem(this.imgList[this.selectIndex]);
} }
}, },
deep: true, deep: true
}, }
}, },
methods: { methods: {
// 重构为可手动触发的方法 // 重构为可手动触发的方法
...@@ -297,8 +299,8 @@ export default { ...@@ -297,8 +299,8 @@ export default {
formData.append("file", files[i]); formData.append("file", files[i]);
let { data } = await that.$api.post("/uploadImage", formData, { let { data } = await that.$api.post("/uploadImage", formData, {
headers: { headers: {
"Content-Type": "application/x-www-form-urlencoded", "Content-Type": "application/x-www-form-urlencoded"
}, }
}); });
that.selectImgIndex = 0; that.selectImgIndex = 0;
that.addFile(data, () => { that.addFile(data, () => {
...@@ -430,7 +432,7 @@ export default { ...@@ -430,7 +432,7 @@ export default {
) { ) {
size = { size = {
width: this.detail.mssWidth, width: this.detail.mssWidth,
height: this.detail.mssHeight, height: this.detail.mssHeight
}; };
} }
this.getBackFile({ files: [it], size }, () => { this.getBackFile({ files: [it], size }, () => {
...@@ -460,6 +462,26 @@ export default { ...@@ -460,6 +462,26 @@ export default {
} }
switch (type) { switch (type) {
case "cover":
if (this.imgList[this.selectIndex].w > this.imgList[this.selectIndex].h) {
// 宽度铺满,高度自适应
let r = Number(this.gridWH.w) / this.imgList[this.selectIndex].w
this.$set(this.imgList[this.selectIndex], "w", Number(this.gridWH.w));
this.$set(this.imgList[this.selectIndex], "h", this.imgList[this.selectIndex].h * r);
}else if(this.imgList[this.selectIndex].w < this.imgList[this.selectIndex].h) {
// // 高度铺满,宽度自适应
let r = Number(this.gridWH.h) / this.imgList[this.selectIndex].h
this.$set(this.imgList[this.selectIndex], "h", Number(this.gridWH.h));
this.$set(this.imgList[this.selectIndex], "w", this.imgList[this.selectIndex].w * r);
}else{
let r = Number(this.gridWH.w) / this.imgList[this.selectIndex].w
this.$set(this.imgList[this.selectIndex], "w", Number(this.gridWH.w));
this.$set(this.imgList[this.selectIndex], "h", this.imgList[this.selectIndex].h * r);
}
this.$set(this.imgList[this.selectIndex], "x", Number(w));
this.$set(this.imgList[this.selectIndex], "y", Number(h));
this.imgHistoryList.push(JSON.parse(JSON.stringify(this.imgList)));
break;
case "center": case "center":
this.$set(this.imgList[this.selectIndex], "x", Number(w)); this.$set(this.imgList[this.selectIndex], "x", Number(w));
this.$set(this.imgList[this.selectIndex], "y", Number(h)); this.$set(this.imgList[this.selectIndex], "y", Number(h));
...@@ -535,7 +557,8 @@ export default { ...@@ -535,7 +557,8 @@ export default {
} }
this.getCutArea(); this.getCutArea();
}, },
resizing() {}, resizing() {
},
rotating(data, item) { rotating(data, item) {
this.$set(item, "r", data.angle); this.$set(item, "r", data.angle);
this.imgHistoryList.push(JSON.parse(JSON.stringify(this.imgList))); this.imgHistoryList.push(JSON.parse(JSON.stringify(this.imgList)));
...@@ -657,7 +680,7 @@ export default { ...@@ -657,7 +680,7 @@ export default {
x, x,
y, y,
h: height_px, h: height_px,
r: 0, r: 0
}); });
that.selectIndex = that.imgList.length - 1; that.selectIndex = that.imgList.length - 1;
that.showImgSetting = true; that.showImgSetting = true;
...@@ -691,7 +714,7 @@ export default { ...@@ -691,7 +714,7 @@ export default {
x: w, x: w,
y: (bw * (2 / 3) * rate) / 2, y: (bw * (2 / 3) * rate) / 2,
h: bw * (2 / 3) * rate, h: bw * (2 / 3) * rate,
r: 0, r: 0
}); });
console.log(570, that.imgList); console.log(570, that.imgList);
that.selectIndex = that.imgList.length - 1; that.selectIndex = that.imgList.length - 1;
...@@ -717,7 +740,7 @@ export default { ...@@ -717,7 +740,7 @@ export default {
image.onload = function() { image.onload = function() {
resolve({ resolve({
width: image.width, width: image.width,
height: image.height, height: image.height
}); });
}; };
image.onerror = function() { image.onerror = function() {
...@@ -796,14 +819,14 @@ export default { ...@@ -796,14 +819,14 @@ export default {
const outputPath = path.join(outputDir, outputFileName); const outputPath = path.join(outputDir, outputFileName);
const params = { const params = {
inputPath: el.productionFile, inputPath: el.productionFile,
outputPath: outputPath, outputPath: outputPath
}; };
const res = await this.$api.post("/processImage", params); const res = await this.$api.post("/processImage", params);
fs.unlinkSync(el.productionFile); fs.unlinkSync(el.productionFile);
return { return {
fileName: outputFileName, fileName: outputFileName,
productionFile: res.msg[0]?.outputPath, productionFile: res.msg[0]?.outputPath,
designId: el.designId, designId: el.designId
}; };
} catch (error) { } catch (error) {
console.error(`处理失败: ${el.productionFile}`, error); console.error(`处理失败: ${el.productionFile}`, error);
...@@ -865,7 +888,7 @@ export default { ...@@ -865,7 +888,7 @@ export default {
let res = await this.$api.post("/downloadBySubOrderNumber", { let res = await this.$api.post("/downloadBySubOrderNumber", {
ids: [this.detail.id], ids: [this.detail.id],
device: this.$store.state.desktopDevice, device: this.$store.state.desktopDevice,
type: this.factoryType, type: this.factoryType
}); });
if (res.data.length === 0) return this.$message.warning("未找到素材图!"); if (res.data.length === 0) return this.$message.warning("未找到素材图!");
let imgList = []; let imgList = [];
...@@ -992,7 +1015,7 @@ export default { ...@@ -992,7 +1015,7 @@ export default {
} catch (error) { } catch (error) {
console.log(error); console.log(error);
} }
}, }
}, },
mounted() { mounted() {
this.imgHeight = window.screen.height + "px"; this.imgHeight = window.screen.height + "px";
...@@ -1068,7 +1091,7 @@ export default { ...@@ -1068,7 +1091,7 @@ export default {
beforeDestroy() { beforeDestroy() {
// 销毁组件时移除事件监听器 // 销毁组件时移除事件监听器
document.removeEventListener("click", this.handleClick); document.removeEventListener("click", this.handleClick);
}, }
}; };
</script> </script>
...@@ -1110,7 +1133,8 @@ export default { ...@@ -1110,7 +1133,8 @@ export default {
v-if="selectImgList.length" v-if="selectImgList.length"
style="margin: 5px;" style="margin: 5px;"
@click="downloadImg" @click="downloadImg"
>下载原素材</el-button >下载原素材
</el-button
> >
<el-button <el-button
type="primary" type="primary"
...@@ -1118,7 +1142,8 @@ export default { ...@@ -1118,7 +1142,8 @@ export default {
v-if="selectImgList.length" v-if="selectImgList.length"
style="margin: 5px;" style="margin: 5px;"
@click="cutImgFn" @click="cutImgFn"
>裁切</el-button >裁切
</el-button
> >
</div> </div>
</template> </template>
...@@ -1490,6 +1515,7 @@ export default { ...@@ -1490,6 +1515,7 @@ export default {
font-size: 24px; font-size: 24px;
left: 25%; left: 25%;
} }
.page-main { .page-main {
display: flex; display: flex;
flex: 1; flex: 1;
...@@ -1571,6 +1597,7 @@ export default { ...@@ -1571,6 +1597,7 @@ export default {
position: absolute; position: absolute;
z-index: 2; z-index: 2;
left: 5%; left: 5%;
img { img {
pointer-events: none; pointer-events: none;
width: auto; width: auto;
...@@ -1600,9 +1627,11 @@ export default { ...@@ -1600,9 +1627,11 @@ export default {
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
.element { .element {
// position: relative; // position: relative;
} }
// #imgBox { // #imgBox {
// img { // img {
// transition: clip-path 0.1s ease-in; // transition: clip-path 0.1s ease-in;
...@@ -1656,11 +1685,13 @@ img { ...@@ -1656,11 +1685,13 @@ img {
box-sizing: border-box; box-sizing: border-box;
border-color: #409eff !important; border-color: #409eff !important;
} }
.showImg { .showImg {
max-height: 194px !important; max-height: 194px !important;
text-align: center; text-align: center;
width: auto !important; width: auto !important;
} }
.img-item { .img-item {
// height: 150px; // height: 150px;
width: 180px; width: 180px;
...@@ -1675,10 +1706,12 @@ img { ...@@ -1675,10 +1706,12 @@ img {
margin-right: 5px; margin-right: 5px;
box-sizing: border-box; box-sizing: border-box;
img { img {
width: 100%; width: 100%;
height: auto; height: auto;
} }
span { span {
font-size: 14px; font-size: 14px;
// margin: 5px 0; // margin: 5px 0;
...@@ -1708,6 +1741,7 @@ img { ...@@ -1708,6 +1741,7 @@ img {
height: 100%; height: 100%;
// border-top: 1px solid #ececec; // border-top: 1px solid #ececec;
margin-bottom: 25px; margin-bottom: 25px;
::v-deep .el-checkbox { ::v-deep .el-checkbox {
height: 100%; height: 100%;
width: 100%; width: 100%;
...@@ -1721,6 +1755,7 @@ img { ...@@ -1721,6 +1755,7 @@ img {
top: 5px; top: 5px;
left: 5px; left: 5px;
} }
.el-checkbox__label { .el-checkbox__label {
width: 100%; width: 100%;
padding: 0; padding: 0;
...@@ -1755,54 +1790,66 @@ img { ...@@ -1755,54 +1790,66 @@ img {
.handle-rot::after { .handle-rot::after {
display: none; display: none;
} }
.information-content { .information-content {
border: 1px solid #ececec; border: 1px solid #ececec;
border-top: none; border-top: none;
width: 100%; width: 100%;
.main { .main {
margin: 5px; margin: 5px;
border: 1px solid #ececec; border: 1px solid #ececec;
height: 100%; height: 100%;
.effectPic { .effectPic {
.img { .img {
width: 100%; width: 100%;
} }
} }
} }
.pic-title { .pic-title {
text-align: center; text-align: center;
} }
} }
.product-information { .product-information {
border: 1px solid #ececec; border: 1px solid #ececec;
border-top: none; border-top: none;
.title { .title {
padding: 5px 10px; padding: 5px 10px;
} }
.div-content { .div-content {
padding: 0 10px; padding: 0 10px;
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
.div-item { .div-item {
display: flex; display: flex;
flex: 50%; flex: 50%;
font-size: 12px; font-size: 12px;
margin-bottom: 5px; margin-bottom: 5px;
.item-label { .item-label {
flex: 1; flex: 1;
text-align: right; text-align: right;
} }
.item-value { .item-value {
flex: 36%; flex: 36%;
} }
} }
} }
} }
.title { .title {
padding: 5px 10px; padding: 5px 10px;
font-size: 20px; font-size: 20px;
font-weight: 700; font-weight: 700;
} }
.border-row { .border-row {
border-top: 1px solid #ececec; border-top: 1px solid #ececec;
// border-bottom: 1px solid #ececec; // border-bottom: 1px solid #ececec;
...@@ -1811,36 +1858,44 @@ img { ...@@ -1811,36 +1858,44 @@ img {
height: 100%; height: 100%;
// align-items: center; // align-items: center;
} }
.full-width { .full-width {
width: 100%; width: 100%;
} }
.text-center { .text-center {
text-align: center; text-align: center;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
} }
.border-col { .border-col {
border-left: 1px solid #ececec; border-left: 1px solid #ececec;
border-right: 1px solid #ececec; border-right: 1px solid #ececec;
} }
.boxShaow { .boxShaow {
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2), 0 0 15px rgba(0, 0, 0, 0.14), box-shadow: 0 0 10px rgba(0, 0, 0, 0.2), 0 0 15px rgba(0, 0, 0, 0.14),
0 0 20px rgba(0, 0, 0, 0.12); 0 0 20px rgba(0, 0, 0, 0.12);
position: relative; position: relative;
.left-bg-color { .left-bg-color {
position: absolute; position: absolute;
left: -57px; left: -57px;
} }
} }
.vieWsucaitu { .vieWsucaitu {
.active::before { .active::before {
display: none; display: none;
} }
//::v-deep .drr:hover:before { //::v-deep .drr:hover:before {
// outline: none; // outline: none;
//} //}
} }
// ::v-deep.el-table thead { // ::v-deep.el-table thead {
// color: black; // color: black;
// } // }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment