Commit ea8dac77 by lichengming

修改了样品分拨打印标签按钮

parent f03b5af1
<template>
<div>
<Modal v-model="showBackModal" :mask-closable="false" class="zIndex-1100">
<p slot="header">{{modalTitle}}</p>
<div>
<Form ref="formObj" :model="formObj" :rules="ruleValidate" :label-width="90">
<Form-item label="打印份数" prop="number">
<InputNumber :min="1" :step="1" v-model.number="formObj.number"
name="number"
style="width:100%" placeholder="请输入打印份数">
</InputNumber>
</Form-item>
</Form>
</div>
<div slot="footer" class="btn-width">
<Button @click="_cancel" style="margin-left: 8px">取消</Button>
<Button @click="_ok" type="primary">确定</Button>
</div>
</Modal>
</div>
</template>
<script>
/**
* 制备标签打印数量
*/
export default {
components: {},
data() {
return {
currentComponent: '',
modalTitle: '打印份数',
showBackModal: false,
formObj: {
number: 1
},
ruleValidate: {
number: [
{
required: true,
message: '打印份数不能为空',
trigger: 'blur',
type: 'number'
}
]
},
printerVal: '',
selectData: [],
companyId: ''
}
},
methods: {
// 打开界面
_open() {
this.showBackModal = true
this.formObj.number = 1
},
_cancel() {
this.showBackModal = false
},
// 打开界面
_ok() {
this.$refs.formObj.validate(valid => {
if (valid) {
this.$emit('on-result-change', this.formObj.number)
this.showBackModal = false
} else {
this.$Message.error('表单验证失败!')
}
})
}
}
}
</script>
......@@ -73,18 +73,26 @@
</Row>
</div>
<!--选择领样人-->
<downloadPlugin ref="downloadPlugin"></downloadPlugin>
<SelectPrinter ref="selectPrint" @on-result-change="_printResult"></SelectPrinter>
<PrintNum ref="printNum" @on-result-change="_printNumResult"></PrintNum>
</div>
</template>
<script>
import { soilAptitude, soilEntrust } from '../../../../api'
import { soilAptitude, soilEntrust, soilStatistics } from '../../../../api'
import SelectPrinter from '../../sample-preparation/SelectPrinter'
import { getLodop } from '../../../../plugins/clodop/LodopFuncs'
import downloadPlugin from '../../../../plugins/download/downloadPlugin'
import PrintNum from './PrintNum'
let LODOP
export default {
components: {},
components: { PrintNum, SelectPrinter, downloadPlugin },
data() {
return {
btn: [
{ type: 'primary', id: '', name: '发放' },
{ type: 'primary', id: '', name: '发放到高级试验' }
{ type: 'primary', id: '', name: '发放到高级试验' },
{ type: 'primary', id: '', name: '打印标签' }
],
selectIds: [],
getPage: {},
......@@ -295,8 +303,15 @@ export default {
case '接收':
this._sampleReceive()
break
// case '打印标签':
// this._selectPrinter('print-label')
// break
case '打印标签':
this._selectPrinter('print-label')
if (this.selectData.length > 0) {
this.$refs.selectPrint._open()
} else {
this.$Message.warning('请至少选择一条数据')
}
break
case '自定义打印':
if (this.selectData.length === 0) {
......@@ -311,6 +326,117 @@ export default {
}
})
},
_pluginDownload() {
this.$refs.downloadPlugin._open()
},
_printResult(data) {
console.log(data)
if (data) {
console.log('data.printerVal')
this.printerVal = data.printerVal
this.$refs.printNum._open()
// this._getLabelInfo()
}
},
_printNumResult(data) {
this.printNum = data
this._getLabelInfo()
},
_getLabelInfo: async function() {
console.log('this._getLabelInfo')
const result = await soilStatistics._getLabel(
this.$serializeForm(this.formObj)
)
if (result) {
for (let i = 0; i < result.records.length; i++) {
if (result.records[i].type.display === '打印前处理标签') {
this.labelCode = result.records[i].code
}
}
console.log(result)
}
this._printMessage()
},
_printMessage: function() {
LODOP = getLodop()
if (LODOP === 'undefined' || LODOP === undefined) {
this._pluginDownload()
return false
}
if (LODOP.GET_PRINTER_COUNT() === 0) {
this.$Messager.warning('系统未关联打印机,请确认....')
return false
}
const data = this.selectData
for (let i = 0; i < data.length; i++) {
for (let j = 0; j < this.printNum; j++) {
this._printLabelOk(data[i])
}
}
},
_printLabelOk(row) {
LODOP.PRINT_INITA('') // 必须在设置打印机之前
// 返回的标签代码
// eslint-disable-next-line no-eval
eval(this._replaceCodes(row))
// 设置打印机
LODOP.SET_PRINTER_INDEX(this.printerVal)
// 打开设计模式
// LODOP.PRINT_DESIGN()
LODOP.PRINT()
},
_replaceCodes(row) {
// /g表示全局替换
let result = this.labelCode
result = result.replace(
/\$sampleCode\$/g,
undefined !== row.sampleCode ? row.sampleCode : ''
)
result = result.replace(
/\$sampleDepth\$/g,
undefined !== row.sampleDepth ? row.sampleDepth : ''
)
result = result.replace(
/\$receiver\$/g,
undefined !== row.receiver ? row.receiver : ''
)
result = result.replace(
/\$receiveTime\$/g,
undefined !== row.receiveTime ? this._formatDate(row.receiveTime) : ''
)
result = result.replace(
/\$entrustCode\$/g,
undefined !== row.entrustCode ? row.entrustCode : ''
)
// 检测项目
result = result.replace(
/\$experimentNames\$/g,
undefined !== row.experimentNames ? row.experimentNames : ''
)
// 二维码地址
result = result.replace(
/\$qrCode\$/g,
undefined !== row.qrCode ? row.qrCode : ''
)
return result
},
_formatDate(time) {
const date = new Date(time)
const YY = date.getFullYear() + '-'
const MM =
(date.getMonth() + 1 < 10
? '0' + (date.getMonth() + 1)
: date.getMonth() + 1) + '-'
const DD = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
const hh =
(date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':'
const mm =
(date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) +
':'
const ss =
date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
return YY + MM + DD + ' ' + hh + mm + ss
},
// 扫码发放
_oneKeySend() {
if (this.selectIds.length === 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