diff --git a/src/views/modules/qc/IPQCResultEntry.vue b/src/views/modules/qc/IPQCResultEntry.vue index 53dc392..1395510 100644 --- a/src/views/modules/qc/IPQCResultEntry.vue +++ b/src/views/modules/qc/IPQCResultEntry.vue @@ -964,6 +964,105 @@ + +
+
检验单:{{ printOrder.inspectionNo }}
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + 序号 + 操作展现方式项目名称标准值 (MM)+Tol/-TolMINMAXMeasurement ResultsOKNOT OK
CAV
{{ n }}
+ + {{ index + 1 }} + + 选择 + + + {{ row.itemDesc }}{{ printNum(row.stdValue) }}{{ printNum(row.minValue) }}{{ printNum(row.maxValue) }}{{ row.measures[n - 1] }}{{ row.itemResult === 'Y' ? '✓' : '' }}{{ row.itemResult === 'N' ? '✓' : '' }}
+
+
+
+ 取消 + 确定 +
+
+ + + + + + + + 查询 + + + + + + + + + + + + + +
+ 取消 + 确定 +
+
+ @@ -1028,7 +1127,6 @@ getOperatorList } from '@/api/eam/eam.js' import {userFavoriteList, saveUserFavorite, removeUserFavorite} from '@/api/userFavorite.js' - import {qcPrint} from '@/api/qc/qcPrint.js' import qcFAIUploadFile from "./qc_FAI_upload_file" import comQcItemImageUploadFile from "./com_qc_itemImage_upload_file" import subDetailUpload from "./sub_detail_upload"; @@ -1055,6 +1153,17 @@ end = this.tableData.length } return this.tableData.slice(start,end) + }, + printItemFiltered () { + const key = this.printItemQuery || '' + return (this.printDetailList || []).filter(item => { + if (!key) return true + return String(item.itemDesc || '').toLowerCase().indexOf(key) >= 0 || String(item.itemNo || '').toLowerCase().indexOf(key) >= 0 + }) + }, + printItemPage () { + const start = (this.printItemPageNo - 1) * this.printItemLimit + return this.printItemFiltered.slice(start, start + this.printItemLimit) } }, watch: { @@ -2265,6 +2374,18 @@ resourceList: [], partList: [], IPQCSelections: [], + printDialogVisible: false, + printOrder: {}, + printRows: [], + printSeed: 1, + printDetailList: [], + printItemVisible: false, + printItemKey: '', + printItemQuery: '', + printItemPageNo: 1, + printItemLimit: 10, + printItemRow: null, + printCurrentRow: null, rules: { seqNoType: [ { @@ -2684,11 +2805,157 @@ this.$message.warning('请勾选要打印的检验单!') return } - const inspectionNos = this.$refs.qrCode.init(this.IPQCSelections.map(item => item.inspectionNo)) - for (let i = 0; i < inspectionNos.length; i++) { - this.IPQCSelections[i].qrCode = inspectionNos[i] + if (this.IPQCSelections.length !== 1) { + this.$message.warning('一次只能选择一个检验单!') + return + } + const order = this.IPQCSelections[0] + this.printOrder = order + this.printRows = [] + for (let i = 0; i < 6; i++) this.printRows.push(this.newPrintRow()) + this.printDetailList = [] + this.printDialogVisible = true + ipqcDetailSearch({ + site: order.site, + buNo: order.buNo, + inspectionNo: order.inspectionNo + }).then(({data}) => { + this.printDetailList = (data && data.code === 0 && data.rows) ? data.rows : [] + }) + }, + newPrintRow () { + this.printSeed += 1 + return { + uid: this.printSeed, + displayMode: '列转行', + itemNo: '', + itemDesc: '', + stdValue: '', + minValue: '', + maxValue: '', + itemResult: '', + subDetails: [], + measures: ['', '', '', '', '', '', '', '', '', ''] + } + }, + addPrintRow () { + this.printRows.push(this.newPrintRow()) + }, + deletePrintRow (index) { + this.printRows.splice(index, 1) + }, + printNum (value) { + return value == null || value === '' ? '' : value + }, + openPrintItemDialog (row) { + if (!this.printDetailList.length) { + this.$message.warning('当前检验单没有检验项目') + return + } + this.printCurrentRow = row + this.printItemRow = null + this.printItemKey = '' + this.printItemQuery = '' + this.printItemPageNo = 1 + this.printItemVisible = true + }, + searchPrintItems () { + this.printItemQuery = (this.printItemKey || '').trim().toLowerCase() + this.printItemPageNo = 1 + }, + confirmPrintItem (row) { + if (row && row.itemNo) this.printItemRow = row + const detail = this.printItemRow + const current = this.printCurrentRow + if (!detail || !current) return + this.$set(current, 'itemNo', detail.itemNo || '') + this.$set(current, 'itemDesc', detail.itemDesc || '') + this.$set(current, 'stdValue', detail.defaultValue != null ? detail.defaultValue : '') + this.$set(current, 'minValue', detail.minValue != null ? detail.minValue : '') + this.$set(current, 'maxValue', detail.maxValue != null ? detail.maxValue : '') + this.$set(current, 'itemResult', detail.itemResult || '') + this.printItemVisible = false + selectIPQCSubDetailedRecord({ + site: this.printOrder.site || '', + buNo: this.printOrder.buNo || '', + inspectionNo: this.printOrder.inspectionNo || '', + itemNo: current.itemNo + }).then(({data}) => { + const list = ((data && data.rows) || []).slice().sort((a, b) => (a.num || 0) - (b.num || 0)) + this.$set(current, 'subDetails', list) + this.rebuildPrintRow(current) + }) + }, + rebuildPrintRow (row) { + this.$set(row, 'measures', this.calcPrintMeasures(row.displayMode, row.subDetails || [])) + }, + calcPrintMeasures (mode, subDetails) { + const textOf = value => value == null ? '' : String(value).trim() + const rows = (subDetails || []).slice().sort((a, b) => (a.num || 0) - (b.num || 0)) + const raw = [] + if (mode === '行转列') { + const first = rows[0] || {} + const second = rows[1] || {} + ;[first.subDetailValue, first.subDetailValueB, first.subDetailValueC, first.subDetailValueD, first.subDetailValueE, + second.subDetailValue, second.subDetailValueB, second.subDetailValueC, second.subDetailValueD, second.subDetailValueE] + .forEach(value => raw.push(textOf(value))) + } else { + rows.forEach(item => raw.push(textOf(item.subDetailValue))) + if (raw.filter(value => value).length < 10) { + rows.forEach(item => raw.push(textOf(item.subDetailValueB))) + } } - qcPrint(this.IPQCSelections) + const out = raw.filter(value => value) + while (out.length < 10) out.push('') + return out.slice(0, 10) + }, + confirmPrintSheet () { + const sheet = this.$refs.ipqcPrintSheet + if (!sheet) return + const clone = sheet.cloneNode(true) + const hidden = { 2: true, 3: true } + Array.prototype.forEach.call(clone.querySelectorAll('.no-print'), function (el) { + if (el.parentNode) el.parentNode.removeChild(el) + }) + Array.prototype.forEach.call(clone.querySelectorAll('tr'), function (tr) { + let col = 1 + const cells = [] + Array.prototype.forEach.call(tr.children, function (el) { + if (el.tagName === 'TD') cells.push(el) + }) + cells.forEach(function (cell) { + const span = parseInt(cell.getAttribute('colspan') || '1', 10) + let hiddenCount = 0 + for (let c = col; c < col + span; c++) { + if (hidden[c]) hiddenCount++ + } + const drop = cell.classList.contains('col-op') || cell.classList.contains('col-mode') + if (drop) { + if (cell.parentNode) cell.parentNode.removeChild(cell) + } else if (span > 1 && hiddenCount > 0) { + cell.setAttribute('colspan', String(span - hiddenCount)) + } + col += span + }) + }) + Array.prototype.forEach.call(clone.querySelectorAll('col.col-op, col.col-mode'), function (col) { + if (col.parentNode) col.parentNode.removeChild(col) + }) + const style = ` + @page { size: A4 landscape; margin: 8mm; } + body { margin: 0; } + table { width: 100%; border-collapse: collapse; table-layout: fixed; } + td { border: 1px solid #000; text-align: center; vertical-align: middle; font-size: 10px; padding: 2px; word-break: break-all; } + .left { text-align: left; } + ` + const printWindow = window.open('', '_blank') + printWindow.document.write('IPQC检验' + clone.innerHTML + '') + printWindow.document.close() + printWindow.focus() + setTimeout(() => { + printWindow.print() + printWindow.close() + }, 300) }, // 数据采集 @@ -4570,4 +4837,52 @@ height: auto; line-height: 1.5; } +.ipqc-print-wrap .picked-no { + margin-bottom: 8px; + color: #606266; +} +.ipqc-print-sheet { + overflow: auto; + padding-left: 28px; +} +.ipqc-print-table { + width: 100%; + min-width: 1100px; + border-collapse: collapse; + table-layout: fixed; +} +.ipqc-print-table td { + border: 1px solid #000; + text-align: center; + vertical-align: middle; + font-size: 12px; + height: 28px; + padding: 2px 4px; +} +.ipqc-print-table .left { text-align: left; padding-left: 4px; } +.ipqc-print-table .th td { font-weight: 700; background: #f7f7f7; } +.p-seq { width: 42px; } +.p-op { width: 64px; } +.p-mode { width: 78px; } +.p-name { width: 120px; } +.p-std, .p-tol, .p-min, .p-max { width: 72px; } +.p-cav { width: 42px; } +.p-ok, .p-ng { width: 48px; } +.seq-cell { position: relative; } +.sign-btn { + position: absolute; + left: -22px; + top: 50%; + width: 18px; + height: 18px; + margin-top: -9px; + padding: 0; + border-radius: 2px; + background: #fff; + line-height: 16px; + cursor: pointer; +} +.sign-btn.minus { color: #f56c6c; border: 1px solid #f56c6c; } +.sign-btn.plus { color: #409eff; border: 1px solid #409eff; top: 14px; } +.mode-select { width: 72px; height: 22px; font-size: 12px; }