Commit 86bf5900 by 朱哲铨

打印 大小位置无问题初版

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