Commit 9841c5c0 authored by 罗林杰's avatar 罗林杰

完成B1,B2两种类型

parent 07fc2ad6
......@@ -5,7 +5,6 @@
v-loading="loading"
:data="tableData"
style="width: 100%"
:span-method="arraySpanMethod"
>
<el-table-column
v-for="(item, index) in tableHeader"
......@@ -20,20 +19,12 @@
{{ scope.row[index] }}
</div>
<el-input
v-else-if="index !== tableHeader.length - 1"
v-else
v-model="scope.row[index]"
:class="{ 'custom-input': dataVerify(scope.row,scope.row[index],scope.column,scope.$index) }"
style="background-color: transparent;"
@input="handleInput(scope.row,scope.row[index],scope.column,scope.$index)"
/>
<div
v-else
:class="{ 'custom-span': verifyResult(scope.row, scope.row[index], scope.column, scope.$index) === 'NG' }"
>
{{
verifyResult(scope.row, scope.row[index], scope.column, scope.$index) === null ? '' : verifyResult(scope.row, scope.row[index], scope.column, scope.$index)
}}
</div>
</template>
</el-table-column>
</el-table>
......@@ -128,6 +119,8 @@ export default {
// { label: 'R', prop: '15' },
// { label: '结果', prop: '16' }
],
maxTable: [],
minTable: [],
// 列表备注数据
tableRemarks: []
}
......@@ -222,71 +215,54 @@ export default {
methods: {
verifyResult(rowData, columnData, column, index) {
if (this.localVerifyResultFlag[index] === true) {
// 校验整行数据,只要有一个数据不符合条件 就将结果改为NO
const keys = Object.keys(rowData).map(Number)
// 过滤出第4个及其以后的键(索引从0开始,所以"3"是第4个)
const startIndex = 3
const endIndex = keys.length - 3 // 最后 2 个数据之前的结束索引
const filteredKeys = keys.slice(startIndex, endIndex)
// 根据过滤后的键名数组提取对应的值,并生成数组
const result = filteredKeys.map(key => rowData[key])
// 遍历result
let allInRange = 'OK' // 假设所有值都在范围内
for (let i = 0; i < result.length; i++) {
// 获取当前行,如果第一个列的值为'Cpk',则进行校验
if (rowData[0] === 'Cpk') {
// 校验表格数据
const upperBound = this.tableRemarks[index][1] // 上限
const lowerBound = this.tableRemarks[index][0]// 下限
if (upperBound === undefined && lowerBound !== '') {
// remarks只填了一个值
if (result[i] !== lowerBound) {
allInRange = 'NG'
}
} else if (upperBound === undefined && lowerBound === '') {
// remarks没填值
allInRange = 'OK'
// 检查 columnData 是否为数字
if (isNaN(Number(columnData))) {
allInRange = 'NG' // 如果 columnData 不是数字,直接返回 true
} else {
// remarks填了范围
// 如果 columnData 不是数字,直接返回 true
if (isNaN(Number(result[i]))) {
allInRange = 'NG'
} else {
if (Number(result[i]) < Number(lowerBound) || Number(result[i]) > Number(upperBound)) {
if (upperBound !== '' && upperBound !== '') {
if (Number(columnData) < Number(lowerBound) || Number(columnData) > Number(upperBound)) {
// 不在范围之间
allInRange = 'NG'
} else {
allInRange = 'OK'
}
}
}
}
// 新增时 判断表格中是否有数据 只有有数据的时候,才改变最后一列的值
if (this.updateFlag === false) {
if (Object.keys(rowData).length - 1 > this.fixedColumnCount) {
this.$set(rowData, Object.keys(rowData).length - 1, allInRange)
}
} else {
// 修改时 不跟新增写一样的 是因为这样可以避免无限循环
// 判断是否是最后一行 如果是最后一行 value返回的是输入的值
if (rowData[0] === this.tableData[this.tableData.length - 1][0]) {
const params = {
rowData: rowData,
value: rowData[rowData.length - 1]
// 如果当前行第一个值为'n='开头的字符串
if (rowData[0].startsWith('n=')) {
const fourthRowData = this.tableData[3][column.property] // 第4行的数据
const fifthRowData = this.tableData[4][column.property] // 第5行的数据
// 确保 fourthRowData 和 fifthRowData 是有效的数值
if (!isNaN(Number(fourthRowData)) && !isNaN(Number(fifthRowData))) {
if (Number(columnData) < Number(fourthRowData) && Number(columnData) > Number(fifthRowData)) {
// 当前列的数据不在第四行和第五行指定的范围内
allInRange = 'OK'
} else {
allInRange = 'NG'
}
this.$emit('updateTableData', params)
} else {
const params = {
rowData: rowData,
value: allInRange
}
this.$emit('updateTableData', params)
// 如果 columnData 不是数字,直接返回 true
allInRange = 'OK'
}
}
return allInRange
const params = {
rowData: rowData,
value: allInRange
}
this.$emit('updateTableData', params)
} else if (this.localVerifyResultFlag[index] === false) {
// 当为修改时 并且不需要校验的时候 直接返回数据的结果
if (this.updateFlag === true) {
return rowData[rowData.length - 1]
}
return 'OK'
} else {
return null
}
},
// 处理输入事件 一旦输入 就把当前行改为需要校验结果列的行
......@@ -299,74 +275,23 @@ export default {
// 校验结果列
this.verifyResult(rowData, columnData, column, index)
},
// 合并最后一行到倒数第四行第二列的单元格
arraySpanMethod({ row, column, rowIndex, columnIndex }) {
// 计算表格中的总行数
const totalRows = this.tableData.length
// 检查是否是倒数第四行的第二列
if (rowIndex === totalRows - 4 && columnIndex === 1) {
// 返回合并的行数和列数,这里我们只关心合并行数
return {
rowspan: 4, // 合并两行
colspan: 1 // 不合并列
}
}
// 如果是最后一行,则不渲染它在指定的列上(因为已经被合并了)
if (rowIndex === totalRows - 1 && columnIndex === 1) {
return {
rowspan: 0,
colspan: 0
}
}
// 如果是倒数二行,则不渲染它在指定的列上(因为已经被合并了)
if (rowIndex === totalRows - 2 && columnIndex === 1) {
return {
rowspan: 0,
colspan: 0
}
}
// 如果是倒数三行,则不渲染它在指定的列上(因为已经被合并了)
if (rowIndex === totalRows - 3 && columnIndex === 1) {
return {
rowspan: 0,
colspan: 0
}
}
// 默认返回值,表示不做合并
return {
rowspan: 1,
colspan: 1
}
},
// 初始化时 整个表格的数据校验
dataVerify(rowData, columnData, column, index) {
// 判断该列是否需要校验,R列和结果列不需要校验
if (column.label === 'MAX' || column.label === 'MIN' || column.label === '结果') {
// 判断该列是否需要校验
if (column.label === '毛刺' || column.label === 'ITEM') {
return false
}
// 数据为空
if (columnData === '' || columnData === null || columnData === undefined) {
return false
}
// 校验表格数据
const upperBound = this.tableRemarks[index][1] // 上限
const lowerBound = this.tableRemarks[index][0]// 下限
if (upperBound === undefined && lowerBound !== '') {
// 只填了一个值 直接判断当前输入的值是否与这一个值相等即可 相等返回OK 不等返回NG
if (columnData === lowerBound) {
// 等于 返回false
return false
} else {
// 不等 返回true
return true
}
} else if (lowerBound === '') {
// lowerBound为''证明没填remarks 不需要校验
return false
} else {
// 判断校验结果
this.verifyResult(rowData, columnData, column, index)
// 获取当前行,如果第一个列的值为'Cpk',则进行校验
if (rowData[0] === 'Cpk') {
// 校验表格数据
const upperBound = this.tableRemarks[index][1] // 上限
const lowerBound = this.tableRemarks[index][0]// 下限
// 检查 columnData 是否为数字
if (isNaN(Number(columnData))) {
return true // 如果 columnData 不是数字,直接返回 true
......@@ -381,11 +306,28 @@ export default {
}
}
}
// 如果当前行第一个值为'n='开头的字符串
if (rowData[0].startsWith('n=')) {
const fourthRowData = this.tableData[3][column.property] // 第4行的数据
const fifthRowData = this.tableData[4][column.property] // 第5行的数据
// 确保 fourthRowData 和 fifthRowData 是有效的数值
if (!isNaN(Number(fourthRowData)) && !isNaN(Number(fifthRowData))) {
if (Number(columnData) < Number(fourthRowData) && Number(columnData) > Number(fifthRowData)) {
// 当前列的数据不在第四行和第五行指定的范围内
return false
} else {
return true
}
} else {
return false // 或者可以根据需求决定是否返回 true
}
}
},
// 获取OCR模版配置
getDictOcrTemplate1() {
this.loading = true
getDict('ocr_template2').then(res => {
getDict('ocr_template3').then(res => {
if (res.code === 200) {
const templateData = res.data
// 遍历templateData
......
......@@ -5,7 +5,6 @@
v-loading="loading"
:data="tableData"
style="width: 100%"
:span-method="arraySpanMethod"
>
<el-table-column
v-for="(item, index) in tableHeader"
......@@ -20,20 +19,12 @@
{{ scope.row[index] }}
</div>
<el-input
v-else-if="index !== tableHeader.length - 1"
v-else
v-model="scope.row[index]"
:class="{ 'custom-input': dataVerify(scope.row,scope.row[index],scope.column,scope.$index) }"
style="background-color: transparent;"
@input="handleInput(scope.row,scope.row[index],scope.column,scope.$index)"
/>
<div
v-else
:class="{ 'custom-span': verifyResult(scope.row, scope.row[index], scope.column, scope.$index) === 'NG' }"
>
{{
verifyResult(scope.row, scope.row[index], scope.column, scope.$index) === null ? '' : verifyResult(scope.row, scope.row[index], scope.column, scope.$index)
}}
</div>
</template>
</el-table-column>
</el-table>
......@@ -128,6 +119,8 @@ export default {
// { label: 'R', prop: '15' },
// { label: '结果', prop: '16' }
],
maxTable: [],
minTable: [],
// 列表备注数据
tableRemarks: []
}
......@@ -222,71 +215,54 @@ export default {
methods: {
verifyResult(rowData, columnData, column, index) {
if (this.localVerifyResultFlag[index] === true) {
// 校验整行数据,只要有一个数据不符合条件 就将结果改为NO
const keys = Object.keys(rowData).map(Number)
// 过滤出第4个及其以后的键(索引从0开始,所以"3"是第4个)
const startIndex = 3
const endIndex = keys.length - 3 // 最后 2 个数据之前的结束索引
const filteredKeys = keys.slice(startIndex, endIndex)
// 根据过滤后的键名数组提取对应的值,并生成数组
const result = filteredKeys.map(key => rowData[key])
// 遍历result
let allInRange = 'OK' // 假设所有值都在范围内
for (let i = 0; i < result.length; i++) {
// 获取当前行,如果第一个列的值为'Cpk',则进行校验
if (rowData[0] === 'Cpk') {
// 校验表格数据
const upperBound = this.tableRemarks[index][1] // 上限
const lowerBound = this.tableRemarks[index][0]// 下限
if (upperBound === undefined && lowerBound !== '') {
// remarks只填了一个值
if (result[i] !== lowerBound) {
allInRange = 'NG'
}
} else if (upperBound === undefined && lowerBound === '') {
// remarks没填值
allInRange = 'OK'
// 检查 columnData 是否为数字
if (isNaN(Number(columnData))) {
allInRange = 'NG' // 如果 columnData 不是数字,直接返回 true
} else {
// remarks填了范围
// 如果 columnData 不是数字,直接返回 true
if (isNaN(Number(result[i]))) {
allInRange = 'NG'
} else {
if (Number(result[i]) < Number(lowerBound) || Number(result[i]) > Number(upperBound)) {
if (upperBound !== '' && upperBound !== '') {
if (Number(columnData) < Number(lowerBound) || Number(columnData) > Number(upperBound)) {
// 不在范围之间
allInRange = 'NG'
} else {
allInRange = 'OK'
}
}
}
}
// 新增时 判断表格中是否有数据 只有有数据的时候,才改变最后一列的值
if (this.updateFlag === false) {
if (Object.keys(rowData).length - 1 > this.fixedColumnCount) {
this.$set(rowData, Object.keys(rowData).length - 1, allInRange)
}
} else {
// 修改时 不跟新增写一样的 是因为这样可以避免无限循环
// 判断是否是最后一行 如果是最后一行 value返回的是输入的值
if (rowData[0] === this.tableData[this.tableData.length - 1][0]) {
const params = {
rowData: rowData,
value: rowData[rowData.length - 1]
// 如果当前行第一个值为'n='开头的字符串
if (rowData[0].startsWith('n=')) {
const fourthRowData = this.tableData[3][column.property] // 第4行的数据
const fifthRowData = this.tableData[4][column.property] // 第5行的数据
// 确保 fourthRowData 和 fifthRowData 是有效的数值
if (!isNaN(Number(fourthRowData)) && !isNaN(Number(fifthRowData))) {
if (Number(columnData) < Number(fourthRowData) && Number(columnData) > Number(fifthRowData)) {
// 当前列的数据不在第四行和第五行指定的范围内
allInRange = 'OK'
} else {
allInRange = 'NG'
}
this.$emit('updateTableData', params)
} else {
const params = {
rowData: rowData,
value: allInRange
}
this.$emit('updateTableData', params)
// 如果 columnData 不是数字,直接返回 true
allInRange = 'OK'
}
}
return allInRange
const params = {
rowData: rowData,
value: allInRange
}
this.$emit('updateTableData', params)
} else if (this.localVerifyResultFlag[index] === false) {
// 当为修改时 并且不需要校验的时候 直接返回数据的结果
if (this.updateFlag === true) {
return rowData[rowData.length - 1]
}
return 'OK'
} else {
return null
}
},
// 处理输入事件 一旦输入 就把当前行改为需要校验结果列的行
......@@ -299,74 +275,23 @@ export default {
// 校验结果列
this.verifyResult(rowData, columnData, column, index)
},
// 合并最后一行到倒数第四行第二列的单元格
arraySpanMethod({ row, column, rowIndex, columnIndex }) {
// 计算表格中的总行数
const totalRows = this.tableData.length
// 检查是否是倒数第四行的第二列
if (rowIndex === totalRows - 4 && columnIndex === 1) {
// 返回合并的行数和列数,这里我们只关心合并行数
return {
rowspan: 4, // 合并两行
colspan: 1 // 不合并列
}
}
// 如果是最后一行,则不渲染它在指定的列上(因为已经被合并了)
if (rowIndex === totalRows - 1 && columnIndex === 1) {
return {
rowspan: 0,
colspan: 0
}
}
// 如果是倒数二行,则不渲染它在指定的列上(因为已经被合并了)
if (rowIndex === totalRows - 2 && columnIndex === 1) {
return {
rowspan: 0,
colspan: 0
}
}
// 如果是倒数三行,则不渲染它在指定的列上(因为已经被合并了)
if (rowIndex === totalRows - 3 && columnIndex === 1) {
return {
rowspan: 0,
colspan: 0
}
}
// 默认返回值,表示不做合并
return {
rowspan: 1,
colspan: 1
}
},
// 初始化时 整个表格的数据校验
dataVerify(rowData, columnData, column, index) {
// 判断该列是否需要校验,R列和结果列不需要校验
if (column.label === 'MAX' || column.label === 'MIN' || column.label === '结果') {
// 判断该列是否需要校验
if (column.label === '毛刺' || column.label === 'ITEM') {
return false
}
// 数据为空
if (columnData === '' || columnData === null || columnData === undefined) {
return false
}
// 校验表格数据
const upperBound = this.tableRemarks[index][1] // 上限
const lowerBound = this.tableRemarks[index][0]// 下限
if (upperBound === undefined && lowerBound !== '') {
// 只填了一个值 直接判断当前输入的值是否与这一个值相等即可 相等返回OK 不等返回NG
if (columnData === lowerBound) {
// 等于 返回false
return false
} else {
// 不等 返回true
return true
}
} else if (lowerBound === '') {
// lowerBound为''证明没填remarks 不需要校验
return false
} else {
// 判断校验结果
this.verifyResult(rowData, columnData, column, index)
// 获取当前行,如果第一个列的值为'Cpk',则进行校验
if (rowData[0] === 'Cpk') {
// 校验表格数据
const upperBound = this.tableRemarks[index][1] // 上限
const lowerBound = this.tableRemarks[index][0]// 下限
// 检查 columnData 是否为数字
if (isNaN(Number(columnData))) {
return true // 如果 columnData 不是数字,直接返回 true
......@@ -381,11 +306,28 @@ export default {
}
}
}
// 如果当前行第一个值为'n='开头的字符串
if (rowData[0].startsWith('n=')) {
const fourthRowData = this.tableData[3][column.property] // 第4行的数据
const fifthRowData = this.tableData[4][column.property] // 第5行的数据
// 确保 fourthRowData 和 fifthRowData 是有效的数值
if (!isNaN(Number(fourthRowData)) && !isNaN(Number(fifthRowData))) {
if (Number(columnData) < Number(fourthRowData) && Number(columnData) > Number(fifthRowData)) {
// 当前列的数据不在第四行和第五行指定的范围内
return false
} else {
return true
}
} else {
return false // 或者可以根据需求决定是否返回 true
}
}
},
// 获取OCR模版配置
getDictOcrTemplate1() {
this.loading = true
getDict('ocr_template2').then(res => {
getDict('ocr_template4').then(res => {
if (res.code === 200) {
const templateData = res.data
// 遍历templateData
......
......@@ -759,15 +759,6 @@ export default {
getOcrData(params).then(res => {
this.ocrArray = res.data.resultList
this.lot = res.data.lot
// 遍历this.ocrArray 将最后一项全部改为OK for循环
for (let i = 0; i < this.ocrArray.length; i++) {
if (this.ocrArray[i].length > 0) {
if (i !== this.ocrArray.length - 1) {
// 不是最后一行数据
this.ocrArray[i][this.ocrArray[i].length - 1] = 'OK'// 修改最后一个元素
}
}
}
this.dialogLoading = false
})
},
......
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