|
@@ -26,16 +26,25 @@
|
|
|
<el-radio :label="3">重打时跳过,不打印</el-radio>
|
|
|
</el-radio-group>
|
|
|
</div>
|
|
|
- <div>号段范围:<el-input v-model="labelRange" style="width: 180px" readonly></el-input></div>
|
|
|
+ <div>
|
|
|
+ <span :style="{ color: textColor }">号段范围:</span>
|
|
|
+ <el-select v-model="labelTableName" style="width: 200px" @change="handleLabelRangeChange">
|
|
|
+ <el-option v-for="item in labelRanges" :key="item.tableName" :label="item.labelRange" :value="item.tableName">
|
|
|
+ <span v-html="analyzeFinishStatus(item.finishFlag)"></span>
|
|
|
+ <el-divider direction="vertical"></el-divider>
|
|
|
+ <span>{{ item.labelRange }}</span>
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </div>
|
|
|
<div>
|
|
|
起始标签:
|
|
|
- <el-input v-model="startLabel" placeholder="请输入起始标签号" style="width: 180px" clearable></el-input>
|
|
|
+ <el-input v-model="startLabel" placeholder="请输入起始标签号" style="width: 200px" clearable></el-input>
|
|
|
</div>
|
|
|
<div>
|
|
|
打印数量:
|
|
|
- <el-input-number v-model="printCount" :min="1" :max="100" type="number" placeholder="请输入打印数量" style="width: 180px" clearable></el-input-number>
|
|
|
+ <el-input-number v-model="printCount" :min="1" :max="100" type="number" placeholder="请输入打印数量" style="width: 200px" clearable></el-input-number>
|
|
|
</div>
|
|
|
- <div>打印操作:<el-button type="primary" style="width: 180px" @click="begnPrint">开始打印</el-button></div>
|
|
|
+ <div>打印操作:<el-button type="primary" style="width: 200px" @click="begnPrint">开始打印</el-button></div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</el-main>
|
|
@@ -43,7 +52,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup name="MixLabelPrinter">
|
|
|
-import { selectMaxLabelRange, selectLabelPrinter, printLabel, reprintLabel } from '@/api/mix-label-printer/index'
|
|
|
+import { selectLabelRanges, selectBeginLabel, selectLabelPrinter, printLabel, reprintLabel, allPrinted } from '@/api/mix-label-printer/index'
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
|
import { qrcanvas } from 'qrcanvas'
|
|
|
import store from '@/store'
|
|
@@ -54,61 +63,89 @@ const leftBoxStyle = {
|
|
|
height: windowSize.h - 25 + 'px',
|
|
|
}
|
|
|
|
|
|
-const labelRange = $ref(null)
|
|
|
+const labelRanges = $ref([])
|
|
|
+const labelTableName = $ref(null)
|
|
|
+const currentLabelRange = $ref({})
|
|
|
const startLabel = $ref(null)
|
|
|
const printCount = $ref(1)
|
|
|
-const excutable = $ref(false)
|
|
|
const reprintWarning = $ref(1)
|
|
|
const printedLabels = $ref([])
|
|
|
+const textColor = computed(() => {
|
|
|
+ return currentLabelRange.finishFlag === 0 ? 'green' : 'red'
|
|
|
+})
|
|
|
+
|
|
|
+const analyzeFinishStatus = (val) => {
|
|
|
+ return val === 0 ? '<span style="font-size:12px;color:green">未打完</span>' : '<span style="font-size:12px;color:red">已打完</span>'
|
|
|
+}
|
|
|
+
|
|
|
+const handleLabelRangeChange = (val) => {
|
|
|
+ selectBeginLabel(val).then((begin) => {
|
|
|
+ startLabel = begin
|
|
|
+ })
|
|
|
+ labelRanges.forEach((item) => {
|
|
|
+ if (item.tableName === labelTableName) {
|
|
|
+ currentLabelRange = item
|
|
|
+ return
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
const begnPrint = async () => {
|
|
|
- if (!startLabel.startsWith('01180')) {
|
|
|
- ElMessageBox.alert('请输入正确的起始标签!', '提示', {
|
|
|
+ if (!startLabel || startLabel.length < currentLabelRange.sliceIndex) {
|
|
|
+ ElMessage({
|
|
|
+ message: '请输入正确的起始标签!',
|
|
|
type: 'error',
|
|
|
- confirmButtonText: '确定',
|
|
|
- }).then(() => {})
|
|
|
+ duration: 2500,
|
|
|
+ showClose: true,
|
|
|
+ })
|
|
|
return
|
|
|
}
|
|
|
printedLabels = []
|
|
|
- excutable = true
|
|
|
for (let i = 0; i < printCount; i++) {
|
|
|
- if (excutable) {
|
|
|
- const labelIndex = Number(startLabel.substring(5, startLabel.length)) + i
|
|
|
- if (labelIndex > 76000) {
|
|
|
- ElMessage({
|
|
|
- message: '打印完成。',
|
|
|
- type: 'success',
|
|
|
- duration: 2500,
|
|
|
- showClose: true,
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- const label = '01180' + labelIndex
|
|
|
- await executePrint(label)
|
|
|
- .then((res) => {
|
|
|
- console.log('printed:', res.label)
|
|
|
- })
|
|
|
- .catch((e) => {
|
|
|
- console.log('canceled: ' + e)
|
|
|
- })
|
|
|
+ const labelIndex = Number(startLabel.substring(currentLabelRange.sliceIndex, startLabel.length)) + i
|
|
|
+ if (labelIndex > currentLabelRange.endNumber) {
|
|
|
+ ElMessage({
|
|
|
+ message: '打印完成',
|
|
|
+ type: 'success',
|
|
|
+ duration: 2500,
|
|
|
+ showClose: true,
|
|
|
+ })
|
|
|
+ return
|
|
|
}
|
|
|
+ const label = currentLabelRange.prefix + labelIndex
|
|
|
+ await executePrint(label)
|
|
|
+ .then((res) => {
|
|
|
+ console.log('printed: ' + res.label)
|
|
|
+ })
|
|
|
+ .catch((e) => {
|
|
|
+ console.log('canceled: ' + e)
|
|
|
+ })
|
|
|
}
|
|
|
- selectMaxLabelRange().then((origin) => {
|
|
|
- if (origin.advise) {
|
|
|
- startLabel = origin.advise
|
|
|
+
|
|
|
+ selectBeginLabel(labelTableName).then((begin) => {
|
|
|
+ if (begin) {
|
|
|
+ startLabel = begin
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
-
|
|
|
const executePrint = (label) => {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
- selectLabelPrinter(label).then((origin) => {
|
|
|
+ selectLabelPrinter(labelTableName, label).then((origin) => {
|
|
|
if (origin.status === 0) {
|
|
|
- printLabel(label).then((firstPrint) => {
|
|
|
+ printLabel(labelTableName, label).then((firstPrint) => {
|
|
|
printedLabels.push(firstPrint)
|
|
|
setTimeout(() => {
|
|
|
drawQrcoce(firstPrint.label)
|
|
|
lodopPrint(firstPrint.label)
|
|
|
- resolve(firstPrint)
|
|
|
+ console.log(label, currentLabelRange.maxLabel)
|
|
|
+ if (label === currentLabelRange.maxLabel) {
|
|
|
+ allPrinted(labelTableName).then((msg) => {
|
|
|
+ console.log(msg)
|
|
|
+ resolve(firstPrint)
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ resolve(firstPrint)
|
|
|
+ }
|
|
|
}, 100)
|
|
|
})
|
|
|
} else {
|
|
@@ -135,6 +172,7 @@ const executePrint = (label) => {
|
|
|
}
|
|
|
|
|
|
const executeReprint = (origin, resolve) => {
|
|
|
+ origin.tableName = labelTableName
|
|
|
reprintLabel(origin).then((reprint) => {
|
|
|
let found = false
|
|
|
printedLabels.forEach((ele) => {
|
|
@@ -165,25 +203,33 @@ const drawQrcoce = (label) => {
|
|
|
}
|
|
|
|
|
|
const lodopPrint = (label) => {
|
|
|
- const LODOP = getLodop()
|
|
|
- LODOP.PRINT_INIT('labels')
|
|
|
- LODOP.SET_PRINT_PAGESIZE(1, '50mm', '30mm', 'CreateCustomPage')
|
|
|
- LODOP.SET_PRINT_STYLE('Bold', 1)
|
|
|
- LODOP.ADD_PRINT_TEXT('8mm', '3mm', '32mm', '5mm', '泰和医院20人混采')
|
|
|
- LODOP.ADD_PRINT_BARCODE('14mm', '3mm', '32mm', '10mm', '128Auto', label)
|
|
|
- LODOP.ADD_PRINT_BARCODE('10mm', '35mm', '17mm', '17mm', 'QRCode', label)
|
|
|
- // LODOP.ADD_PRINT_TEXT('10mm', '2mm', '30mm', '5mm', '泰和医院20人混采')
|
|
|
- // LODOP.ADD_PRINT_TEXT('14mm', '2mm', '30mm', '5mm', label)
|
|
|
- // LODOP.ADD_PRINT_TEXT('19mm', '2mm', '30mm', '5mm', label)
|
|
|
- // LODOP.ADD_PRINT_BARCODE('7mm', '29mm', '19mm', '19mm', 'QRCode', label)
|
|
|
- LODOP.PRINT()
|
|
|
+ // const LODOP = getLodop()
|
|
|
+ // LODOP.PRINT_INIT('labels')
|
|
|
+ // LODOP.SET_PRINT_PAGESIZE(1, '50mm', '30mm', 'CreateCustomPage')
|
|
|
+ // LODOP.SET_PRINT_STYLE('Bold', 1)
|
|
|
+ // LODOP.ADD_PRINT_TEXT('8mm', '3mm', '32mm', '5mm', '泰和医院20人混采')
|
|
|
+ // LODOP.ADD_PRINT_BARCODE('14mm', '3mm', '32mm', '10mm', '128Auto', label)
|
|
|
+ // LODOP.ADD_PRINT_BARCODE('10mm', '35mm', '17mm', '17mm', 'QRCode', label)
|
|
|
+ // LODOP.PRINT()
|
|
|
}
|
|
|
|
|
|
onMounted(() => {
|
|
|
initLodop()
|
|
|
- selectMaxLabelRange().then((origin) => {
|
|
|
- labelRange = origin.range
|
|
|
- startLabel = origin.advise
|
|
|
+ selectLabelRanges().then((ranges) => {
|
|
|
+ labelRanges = ranges
|
|
|
+ if (ranges && ranges.length > 0) {
|
|
|
+ for (let index = 0; index < ranges.length; index++) {
|
|
|
+ const item = ranges[index]
|
|
|
+ if (item.finishFlag === 0) {
|
|
|
+ currentLabelRange = item
|
|
|
+ labelTableName = item.tableName
|
|
|
+ selectBeginLabel(item.tableName).then((begin) => {
|
|
|
+ startLabel = begin
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
})
|
|
|
})
|
|
|
</script>
|