Commit 86bf5900 by 朱哲铨

打印 大小位置无问题初版

parent df3a587f
...@@ -13,6 +13,7 @@ export default { ...@@ -13,6 +13,7 @@ export default {
printSettingList: [], printSettingList: [],
printSettingVal: 0, printSettingVal: 0,
description: '', description: '',
printSettingSelectLabel: 'default',
printer: '', printer: '',
settingName: '', settingName: '',
printInkList: [ printInkList: [
...@@ -34,6 +35,7 @@ export default { ...@@ -34,6 +35,7 @@ export default {
showPopover: false, showPopover: false,
printSetting: { printSetting: {
printer: '', printer: '',
xy: '',
byInk: 2, byInk: 2,
byInkVolume: 1, byInkVolume: 1,
byDoublePrint: 3, byDoublePrint: 3,
...@@ -73,6 +75,21 @@ export default { ...@@ -73,6 +75,21 @@ export default {
}, },
mounted() { mounted() {
this.$dataStore.set('default-print-setting', this.printSetting) this.$dataStore.set('default-print-setting', this.printSetting)
let select = this.$dataStore.get('print-setting-select')
if (select) {
this.printSettingSelectLabel = select
let index = this.printSettingList.findIndex(el => el.label === select)
if (index >= 0) {
this.printSettingVal = index
this.printSetting = JSON.parse(JSON.stringify(this.printSettingList[index].value))
} else {
this.printSettingVal = 0
this.printSetting = JSON.parse(JSON.stringify(this.printSettingList[0].value))
}
} else {
this.printSettingVal = 0
this.printSetting = JSON.parse(JSON.stringify(this.printSettingList[0].value))
}
}, },
computed: { computed: {
inkNum() { inkNum() {
...@@ -120,7 +137,7 @@ export default { ...@@ -120,7 +137,7 @@ export default {
getPrintSettingList() { getPrintSettingList() {
let arr = [] let arr = []
for (let k in this.$dataStore.store) { for (let k in this.$dataStore.store) {
if (k.includes('print-setting')) { if (k.includes('-print-setting')) {
arr.push({ arr.push({
label: k.replace('-print-setting', ''), label: k.replace('-print-setting', ''),
value: this.$dataStore.get(k) value: this.$dataStore.get(k)
...@@ -130,7 +147,8 @@ export default { ...@@ -130,7 +147,8 @@ export default {
this.printSettingList = arr this.printSettingList = arr
}, },
printSettingChange(v) { printSettingChange(v) {
let label = this.printSettingList[v].label
this.$dataStore.set('print-setting-select', label)
this.printSetting = JSON.parse(JSON.stringify(this.printSettingList[v].value)) this.printSetting = JSON.parse(JSON.stringify(this.printSettingList[v].value))
}, },
saveSetting() { saveSetting() {
...@@ -150,17 +168,32 @@ export default { ...@@ -150,17 +168,32 @@ export default {
this.settingName = '' this.settingName = ''
}, },
singleStr(str) { singleStr(str) {
// 不足四位前面用0补齐 if (Number(str) >= 0) {
str = str.toString().replace('.', '') str = str.toString().replace('.', '')
if (str.length >= 4) { if (str.length >= 4) {
str = str.slice(0, 5) str = str.slice(0, 5)
} else if (str.length === 3) { } else if (str.length === 3) {
str = '0' + str str = '0' + str
} else if (str.length === 2) { } else if (str.length === 2) {
str = '00' + str str = '00' + str
} else if (str.length === 1) { } else if (str.length === 1) {
str = '000' + str str = '000' + str
}
} else {
str = str.toString().replace('.', '').replace('-', '')
if (str.length >= 4) {
str = str.slice(0, 5)
} else if (str.length === 3) {
str = '0' + str
} else if (str.length === 2) {
str = '00' + str
} else if (str.length === 1) {
str = '000' + str
}
str = '-' + str
} }
// 不足四位前面用0补齐
console.log(str) console.log(str)
return str return str
}, },
...@@ -169,10 +202,10 @@ export default { ...@@ -169,10 +202,10 @@ export default {
console.log(this.imgList[0]) console.log(this.imgList[0])
let {x, y, r, w, h} = this.imgList[0] let {x, y, r, w, h} = this.imgList[0]
let x_mm = Number(x * 0.84) let x_mm = Number((x * 0.84183).toFixed(1))
let w_mm = Number(w * 0.84).toFixed(1) let w_mm = Number((w * 0.84183).toFixed(1))
let h_mm = Number(h * 0.84).toFixed(1) let h_mm = Number((h * 0.84183).toFixed(1))
let y_mm = Number(y * 0.84) let y_mm = Number((y * 0.84183).toFixed(1))
console.log(x_mm, y_mm) console.log(x_mm, y_mm)
r = Number(r).toFixed(0) r = Number(r).toFixed(0)
...@@ -180,23 +213,16 @@ export default { ...@@ -180,23 +213,16 @@ export default {
let position = '' // 位置 let position = '' // 位置
let size = '' // 图像大小 let size = '' // 图像大小
if (Number(x_mm) < 0 || Number(y_mm) < 0) { if (Number(x_mm) < 0 || Number(y_mm) < 0) {
if(Number(x_mm)>=0){ position = `"${this.singleStr(Number(x_mm).toFixed(1))},${this.singleStr(Number(y_mm).toFixed(1))}"`
x_mm = this.singleStr(Number(x_mm).toFixed(1))
y_mm = Number(y_mm).toFixed(0)
}else{
y_mm = this.singleStr(Number(y_mm).toFixed(1))
x_mm = Number(x_mm).toFixed(0)
}
position = `"${x_mm},${y_mm}"`
} else { } else {
position = `${this.singleStr(x_mm.toFixed(1))}${this.singleStr(y_mm.toFixed(1))}` position = `${this.singleStr(x_mm.toFixed(1))}${this.singleStr(y_mm.toFixed(1))}`
} }
size = `${this.singleStr(w_mm)}${this.singleStr(h_mm)}` size = `${this.singleStr(Number(w_mm).toFixed(1))}${this.singleStr(Number(h_mm).toFixed(1))}`
const bigNum = '0031131' // 图像放大倍数 -R const bigNum = '0031131' // 图像放大倍数 -R
const whitePrint = [1, 2].includes(this.printSetting.byInk) ? 1 : 0 // 白色打印 const whitePrint = [1, 2].includes(this.printSetting.byInk) ? 1 : 0 // 白色打印
let cmd = `GTXproCMD.exe print -X "${`Profile\\${imgFileName.replace('.png', '')}.xml`}" -I "${'Input\\' + imgFileName}" -A "Output\\${imgFileName.replace('.png', '')}.arxp" -S ${size} -L ${position} -D ${r} -W ${whitePrint}` let cmd = `GTXproCMD.exe print -X "${`Profile\\${imgFileName.replace('.png', '')}.xml`}" -I "${'Input\\' + imgFileName}" -A "Output\\${imgFileName.replace('.png', '')}.arxp" -S ${size} -L ${position} -D ${r} -W ${whitePrint}`
let print_cmd = `GTXproCMD.exe send -A "Output\\${imgFileName.replace('.png', '')}.arxp" -P "${this.printer}` let print_cmd = `GTXproCMD.exe send -A "Output\\${imgFileName.replace('.png', '')}.arxp" -P "${this.printer}`
...@@ -222,13 +248,7 @@ export default { ...@@ -222,13 +248,7 @@ export default {
} }
}) })
}, },
mouseenter(e, f) {
console.log(e, f)
this.description = this.fieldDescription[f] || ''
},
mouseleave() {
this.description = ''
},
setDetailShow() { setDetailShow() {
this.detailShow = !this.detailShow this.detailShow = !this.detailShow
} }
...@@ -757,7 +777,7 @@ export default { ...@@ -757,7 +777,7 @@ export default {
</style> </style>
<style> <style>
.my-popper{ .my-popper {
background: rgba(0, 0, 0, 0.5) !important; background: rgba(0, 0, 0, 0.5) !important;
} }
</style> </style>
\ No newline at end of file
...@@ -5,6 +5,7 @@ export default { ...@@ -5,6 +5,7 @@ export default {
drawerShow: false, drawerShow: false,
form: { form: {
x: 0, x: 0,
rate: 0,
sx: 0, sx: 0,
sh: 0, sh: 0,
sw: 0, sw: 0,
...@@ -16,6 +17,7 @@ export default { ...@@ -16,6 +17,7 @@ export default {
} }
} }
}, },
props: { props: {
visible: { visible: {
type: Boolean, type: Boolean,
...@@ -38,15 +40,17 @@ export default { ...@@ -38,15 +40,17 @@ export default {
item: { item: {
handler() { handler() {
if (this.item) { if (this.item) {
// let x_mm = Number((this.item.x * 0.84).toFixed(2).replace('.00', '')) console.log(this.item.x,this.item.y,this.item.h)
// let w_mm = Number((this.item.w * 0.84).toFixed(2).replace('.00', '')) let x_mm = Number((this.item.x * 0.84183).toFixed(2))
// let h_mm = Number((this.item.h * 0.84).toFixed(2).replace('.00', '')) let w_mm = Number((this.item.w * 0.84183).toFixed(2))
// let y_mm = Number((this.item.y * 0.84).toFixed(2).replace('.00', '')) let h_mm = Number((this.item.h * 0.84183).toFixed(2))
let y_mm = Number((this.item.y * 0.84183).toFixed(2))
// return // return
this.form.x = this.item.x this.form.x = x_mm
this.form.y = this.item.y this.form.rate = this.item.rate
this.form.w = this.item.w this.form.y = y_mm
this.form.h = this.item.h this.form.w = w_mm
this.form.h = h_mm
// this.form.sx = x_mm // this.form.sx = x_mm
// this.form.sy = y_mm // this.form.sy = y_mm
// this.form.sh = h_mm // this.form.sh = h_mm
...@@ -59,19 +63,44 @@ export default { ...@@ -59,19 +63,44 @@ export default {
} }
}, },
methods: { methods: {
formChange() { formChange(t) {
this.$emit('change', this.form) if (t && t === 'w') {
this.form.h = this.form.w * this.form.rate
}
if (t && t === 'h') {
this.form.w = this.form.h * this.form.rate
}
let f = JSON.parse(JSON.stringify(this.form))
f.x = Number((f.x / 0.84183).toFixed(2))
f.y = Number((f.y / 0.84183).toFixed(2))
f.w = Number((f.w / 0.84183).toFixed(2))
f.h = Number((f.h / 0.84183).toFixed(2))
this.$emit('change', f)
}, },
addValue(f) { addValue(f) {
if (!this.form[f]) this.$set(this.form, f, 0) if (!this.form[f]) this.$set(this.form, f, 0)
let nw = Number(this.form[f]) + 1 let nw = Number(this.form[f]) + 1
this.$set(this.form, f, nw) this.$set(this.form, f, nw)
if (f && f === 'w') {
this.form.h = this.form.w * this.form.rate
}
if (f && f === 'h') {
this.form.w = this.form.h * this.form.rate
}
this.formChange() this.formChange()
}, },
reduceValue(f) { reduceValue(f) {
if (!this.form[f]) this.$set(this.form, f, 0) if (!this.form[f]) this.$set(this.form, f, 0)
let nw = Number(this.form[f]) - 1 let nw = Number(this.form[f]) - 1
this.$set(this.form, f, nw) this.$set(this.form, f, nw)
if (f && f === 'w') {
this.form.h = this.form.w * this.form.rate
}
if (f && f === 'h') {
this.form.w = this.form.h * this.form.rate
}
this.formChange() this.formChange()
}, },
} }
...@@ -111,7 +140,7 @@ export default { ...@@ -111,7 +140,7 @@ export default {
<el-col :span="12"> <el-col :span="12">
<el-form-item label="w:"> <el-form-item label="w:">
<div class="form-content"> <div class="form-content">
<el-input @blur="formChange" v-model="form.w"></el-input> <el-input @blur="formChange('w')" v-model="form.w"></el-input>
<div class="set-value"> <div class="set-value">
<i @click="addValue('w')" class="el-icon-arrow-up"></i> <i @click="addValue('w')" class="el-icon-arrow-up"></i>
<i @click="reduceValue('w')" class="el-icon-arrow-down"></i> <i @click="reduceValue('w')" class="el-icon-arrow-down"></i>
...@@ -122,7 +151,7 @@ export default { ...@@ -122,7 +151,7 @@ export default {
<el-col :span="12"> <el-col :span="12">
<el-form-item label="h:"> <el-form-item label="h:">
<div class="form-content"> <div class="form-content">
<el-input @blur="formChange" v-model="form.h"></el-input> <el-input @blur="formChange('h')" v-model="form.h"></el-input>
<div class="set-value"> <div class="set-value">
<i @click="addValue('h')" class="el-icon-arrow-up"></i> <i @click="addValue('h')" class="el-icon-arrow-up"></i>
<i @click="reduceValue('h')" class="el-icon-arrow-down"></i> <i @click="reduceValue('h')" class="el-icon-arrow-down"></i>
......
...@@ -108,7 +108,7 @@ export default { ...@@ -108,7 +108,7 @@ export default {
this.getBackFile([it]) this.getBackFile([it])
}, },
ev(type) { ev(type) {
if(this.selectIndex===-1) this.selectIndex = 0 if (this.selectIndex === -1) this.selectIndex = 0
if (!this.imgList[this.selectIndex]) return if (!this.imgList[this.selectIndex]) return
let w = document.getElementById('line').clientWidth / 2 let w = document.getElementById('line').clientWidth / 2
...@@ -136,7 +136,7 @@ export default { ...@@ -136,7 +136,7 @@ export default {
} }
}, },
formChange(form) { formChange(form) {
if(this.selectIndex===-1) this.selectIndex = 0 if (this.selectIndex === -1) this.selectIndex = 0
if (!this.imgList[this.selectIndex]) return if (!this.imgList[this.selectIndex]) return
let f = JSON.parse(JSON.stringify(form)) let f = JSON.parse(JSON.stringify(form))
let x_mm = f.x let x_mm = f.x
...@@ -162,7 +162,7 @@ export default { ...@@ -162,7 +162,7 @@ export default {
}, },
dragStop(left, top) { dragStop(left, top) {
if(this.selectIndex===-1) this.selectIndex = 0 if (this.selectIndex === -1) this.selectIndex = 0
if (!this.imgList[this.selectIndex]) return if (!this.imgList[this.selectIndex]) return
this.$set(this.imgList[this.selectIndex], 'x', left) this.$set(this.imgList[this.selectIndex], 'x', left)
this.$set(this.imgList[this.selectIndex], 'y', top) this.$set(this.imgList[this.selectIndex], 'y', top)
...@@ -174,9 +174,7 @@ export default { ...@@ -174,9 +174,7 @@ export default {
this.$store.commit('changeActionList', this.actionList) this.$store.commit('changeActionList', this.actionList)
}, },
resizeStop(x, y, w, h) { resizeStop(x, y, w, h) {
if (this.selectIndex === -1) this.selectIndex = 0
if(this.selectIndex===-1) this.selectIndex = 0
if (!this.imgList[this.selectIndex]) return if (!this.imgList[this.selectIndex]) return
this.$set(this.imgList[this.selectIndex], 'w', w) this.$set(this.imgList[this.selectIndex], 'w', w)
this.$set(this.imgList[this.selectIndex], 'h', h) this.$set(this.imgList[this.selectIndex], 'h', h)
...@@ -192,10 +190,13 @@ export default { ...@@ -192,10 +190,13 @@ export default {
this.$store.commit('changeActionList', this.actionList) this.$store.commit('changeActionList', this.actionList)
}, },
resizing(x, y, w, h) { resizing(x, y, w, h) {
if (this.selectIndex === -1) this.selectIndex = 0
if (!this.imgList[this.selectIndex]) return
this.$set(this.imgList[this.selectIndex], 'w', w)
this.$set(this.imgList[this.selectIndex], 'h', h)
}, },
rotating(angle) { rotating(angle) {
if(this.selectIndex===-1) this.selectIndex = 0 if (this.selectIndex === -1) this.selectIndex = 0
if (!this.imgList[this.selectIndex]) return if (!this.imgList[this.selectIndex]) return
this.$set(this.imgList[this.selectIndex], 'r', angle) this.$set(this.imgList[this.selectIndex], 'r', angle)
}, },
...@@ -243,6 +244,7 @@ export default { ...@@ -243,6 +244,7 @@ export default {
that.imgList.push({ that.imgList.push({
url: files[i].url, url: files[i].url,
fileName: files[i].fileName, fileName: files[i].fileName,
rate,
w: 100, w: 100,
zIndex: that.imgList.length, zIndex: that.imgList.length,
x: w - 75, x: w - 75,
...@@ -265,6 +267,7 @@ export default { ...@@ -265,6 +267,7 @@ export default {
that.imgList.push({ that.imgList.push({
url: file.url, url: file.url,
w: 100, w: 100,
rate,
fileName: file.fileName, fileName: file.fileName,
zIndex: that.imgList.length, zIndex: that.imgList.length,
x: w - 75, x: w - 75,
...@@ -292,7 +295,12 @@ export default { ...@@ -292,7 +295,12 @@ export default {
e.stopPropagation(); e.stopPropagation();
//阻止浏览器默认打开文件的操作 //阻止浏览器默认打开文件的操作
e.preventDefault(); e.preventDefault();
console.log(e)
const files = e.dataTransfer.files; const files = e.dataTransfer.files;
if (files.length === 0) return
if (files[0].type !== 'image/png') {
return that.$message.warning('只能上传png格式文件')
}
let formData = new FormData() let formData = new FormData()
console.log(files) console.log(files)
formData.append('file', files[0]) formData.append('file', files[0])
......
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