From c7397ad457ccfe46696b365b3a1229864b3f625c Mon Sep 17 00:00:00 2001 From: liweijie Date: Tue, 15 Sep 2026 17:15:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=93=E4=B8=9A=E4=BF=9D=E5=AD=98=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E9=94=99=E8=AF=AF=EF=BC=8C=E5=89=8D=E5=90=8E=E7=AB=AF?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=B1=BB=E5=9E=8B=E4=B8=8D=E4=B8=80=E8=87=B4?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/subjectMajor/major/index.vue | 32 ++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/frontend/src/views/subjectMajor/major/index.vue b/frontend/src/views/subjectMajor/major/index.vue index cb5546678..42409870d 100644 --- a/frontend/src/views/subjectMajor/major/index.vue +++ b/frontend/src/views/subjectMajor/major/index.vue @@ -248,9 +248,10 @@ + - - + + @@ -356,7 +357,7 @@ {{ viewForm.pxlx || '-' }} {{ viewForm.pxlx2 || '-' }} {{ viewForm.xylb || '-' }} - {{ viewForm.zgzy || '-' }} + {{ fmtBool(viewForm.zgzy) }} {{ viewForm.zdyfl || '-' }} {{ viewForm.jxgljgbh || '-' }} {{ viewForm.xkzyxxbsh || '-' }} @@ -537,6 +538,23 @@ export default { return (this.pageNum - 1) * this.pageSize + index + 1 }, + /** 宽松布尔归一:兼容后端 Boolean、数字 0/1、字符串 'true'/'false'/'1'/'0'/'是'/'否';无效值返回 null */ + normBool(val) { + if (val === null || val === undefined || val === '') return null + if (typeof val === 'boolean') return val + if (typeof val === 'number') return val !== 0 + const s = String(val).trim() + if (['是', 'true', '1', 'Y', 'y'].indexOf(s) >= 0) return true + if (['否', 'false', '0', 'N', 'n'].indexOf(s) >= 0) return false + return null + }, + + /** 布尔值展示为 是/否,空值显示 '-' */ + fmtBool(val) { + const b = this.normBool(val) + return b === null ? '-' : (b ? '是' : '否') + }, + /** 创建空表单 */ createEmptyForm() { return { @@ -678,7 +696,7 @@ export default { jclb: data.jclb, xtms: data.xtms, jsonzd: data.jsonzd, - zgzy: data.zgzy, + zgzy: this.normBool(data.zgzy), gfmc: data.gfmc, jxdgbh: data.jxdgbh, rpbh: data.rpbh, @@ -692,6 +710,12 @@ export default { if (!valid) return this.formSaving = true const payload = { ...this.form } + // 布尔字段统一归一为布尔值:后端实体 ty / zgzy 均为 Boolean,库列为 BIT(1) 且非空 + const zgzy = this.normBool(payload.zgzy) + payload.zgzy = zgzy === null ? false : zgzy + const ty = this.normBool(payload.ty) + payload.ty = ty === null ? false : ty + const request = this.isAdd ? addMajor(payload) : updateMajor(payload) request.then(() => { this.$message.success(this.isAdd ? '新增成功' : '修改成功')