diff --git a/src/views/modules/qc/IQCResultEntry.vue b/src/views/modules/qc/IQCResultEntry.vue
index a9d4d0f..fa90018 100644
--- a/src/views/modules/qc/IQCResultEntry.vue
+++ b/src/views/modules/qc/IQCResultEntry.vue
@@ -371,8 +371,8 @@
min-width="60"
label="实测值">
-
-
+
+
-
+
-
+
@@ -410,8 +410,8 @@
-
-
+
+
-
-
+
+
@@ -461,7 +461,7 @@
:label = "i.sitename"
:value = "i.buDesc">
{{ i.sitename }}
-
+
{{ i.buDesc }}
@@ -729,7 +729,7 @@
min-width="100"
label="设备">
-
+
{
+ this.getDataList()
+ })
+ }
+ },
+ immediate: false // 不立即执行,由 created 处理首次加载
+ },
detailData: {
deep: true,
handler: function (newV, oldV) {
@@ -1790,6 +1809,8 @@
disposalRemark: '',
inspectionResult: '',
inspectorNo: '',
+ inspectorDate: '',
+ submitDate: '',
inspectionRemark: '',
submitFlag: '',
supplierNo: '',
@@ -2000,28 +2021,7 @@
this.height = window.innerHeight - 250
})
},
- // 🔑 监听路由参数变化,处理组件复用的情况
- watch: {
- '$route.query.inspectionNo': {
- handler (newVal) {
- if (newVal) {
- if (!this.searchData.site) {
- this.searchData.site = this.$store.state.user.site
- }
- if (!this.searchData.userName) {
- this.searchData.userName = this.$store.state.user.name
- }
- this.searchData.inspectionNo = newVal
- // 自动执行查询
- this.$nextTick(() => {
- this.getDataList()
- })
- }
- },
- immediate: false // 不立即执行,由 created 处理首次加载
- }
- },
created () {
// 按钮控制
@@ -2844,6 +2844,8 @@
this.detailData.disposalRemark = row.disposalRemark
this.detailData.inspectionResult = row.inspectionResult
this.detailData.inspectorNo = row.inspectorNo
+ this.detailData.inspectorDate = row.inspectorDate
+ this.detailData.submitDate = row.submitDate
this.detailData.inspectionRemark = row.inspectionRemark
this.detailData.umId = row.umId
this.detailData.rollCount = row.rollCount
@@ -2885,10 +2887,12 @@
iqcDetailSearch(this.detailData).then(({data}) => {
if (data && data.code === 0) {
const rows = Array.isArray(data.rows) ? data.rows : []
- this.detailList = rows.map(item => ({
- ...item,
- itemResult: item.itemResult == null ? '' : item.itemResult
- }))
+ // 业务规则:
+ // 1) 仅当单据状态=待检验 且 所有明细实测值都为空 时,才允许默认回填标准值;
+ // 2) 只要任意一行已有实测值,就视为“已录入过”,本次整单不再自动回填;
+ // 3) 回填时按检测值类型区分字段:数值型写 numberValue,文本型写 textValue。
+ const shouldAutoFillMeasuredValue = this.shouldAutoFillMeasuredValueByInspectionRows(rows)
+ this.detailList = rows.map(item => this.buildDetailRowWithDefaultMeasuredValue(item, shouldAutoFillMeasuredValue))
this.refreshUnqualifiedQty()
} else {
this.detailList = []
@@ -2897,6 +2901,108 @@
})
},
+ /**
+ * @description 判断当前检验单是否满足“整单默认标准值回填”条件
+ * 生效条件(必须同时满足):
+ * 1) 单据状态为“待检验”;
+ * 2) 明细存在至少1行;
+ * 3) 所有明细行的实测值都为空(数值型看 numberValue,文本型看 textValue)。
+ * @param rows 明细行列表
+ * @returns true=允许整单回填,false=不回填
+ */
+ shouldAutoFillMeasuredValueByInspectionRows (rows) {
+ const inspectionState = String(this.detailData.state || '').trim()
+ if (inspectionState !== '待检验') {
+ return false
+ }
+ // 业务兜底:
+ // 只要该单据已经执行过“应用/保存”并产生了主记录时间戳,
+ // 即使当前实测值为空,也应尊重用户已保存的空值输入,禁止再次默认回填标准值。
+ if (this.hasInspectionPersistedByApplyOrSave()) {
+ return false
+ }
+ if (!Array.isArray(rows) || rows.length === 0) {
+ return false
+ }
+ return rows.every(item => {
+ if (item && item.valueTypeDb === 'N') {
+ return this.isInspectionMeasuredValueEmpty(item.numberValue)
+ }
+ return this.isInspectionMeasuredValueEmpty(item ? item.textValue : null)
+ })
+ },
+
+ /**
+ * @description 判断当前检验单是否已经发生过“应用/保存”落库行为
+ * 判定规则:
+ * 1) 主记录 inspectorDate 非空,说明检验录入动作已落库;
+ * 2) 主记录 submitDate 非空,说明保存/提交流程已写入时间戳;
+ * 3) 以上任一成立,即视为“用户已处理过该单据”,后续禁止默认回填标准值。
+ * @returns true=已处理过(不允许回填),false=未处理过(可继续按待检验全空规则判断)
+ */
+ hasInspectionPersistedByApplyOrSave () {
+ return !this.isInspectionMeasuredValueEmpty(this.detailData.inspectorDate) ||
+ !this.isInspectionMeasuredValueEmpty(this.detailData.submitDate)
+ },
+
+ /**
+ * @description 构建检验明细行并按“待检验默认标准值”规则初始化实测值
+ * 处理逻辑:
+ * 1) 统一补齐 itemResult 空值,避免后续判定出现 null;
+ * 2) 仅在“整单允许回填”场景触发默认回填;
+ * 3) 实测值已有内容时不覆盖,确保用户历史录入不被改写;
+ * 4) defaultValue 为空时不回填,避免写入无意义空串。
+ * @param item 后端返回的单条检验项目
+ * @param shouldAutoFillMeasuredValue 是否允许整单回填
+ * @returns 处理后的前端展示行对象
+ */
+ buildDetailRowWithDefaultMeasuredValue (item, shouldAutoFillMeasuredValue) {
+ const row = {
+ ...item,
+ itemResult: item.itemResult == null ? '' : item.itemResult
+ }
+
+ // 只有整单满足“待检验且全部实测值为空”时才做默认值回填
+ if (!shouldAutoFillMeasuredValue) {
+ return row
+ }
+
+ // 标准值为空时直接返回,不进行回填
+ if (this.isInspectionMeasuredValueEmpty(row.defaultValue)) {
+ return row
+ }
+
+ // 数值型项目:实测值(numberValue)为空时,默认取标准值(defaultValue)
+ if (row.valueTypeDb === 'N') {
+ if (this.isInspectionMeasuredValueEmpty(row.numberValue)) {
+ row.numberValue = row.defaultValue
+ }
+ return row
+ }
+
+ // 文本型项目:实测值(textValue)为空时,默认取标准值(defaultValue)
+ if (this.isInspectionMeasuredValueEmpty(row.textValue)) {
+ row.textValue = String(row.defaultValue)
+ }
+ return row
+ },
+
+ /**
+ * @description 判断检验值是否为空(统一空值判定,避免0被误判为空)
+ * 判定规则:
+ * 1) null / undefined 视为空;
+ * 2) 字符串去空格后为空视为空;
+ * 3) 数值 0 视为有效值,不为空。
+ * @param value 待判定值
+ * @returns true=空,false=非空
+ */
+ isInspectionMeasuredValueEmpty (value) {
+ if (value === null || value === undefined) {
+ return true
+ }
+ return String(value).trim() === ''
+ },
+
// 子明细记录信息查询
subDetailModal (row) {
this.subDetailLoading = true