-
+
+
+
+
+
+
+
+
+
+
+
搜索
重置
@@ -71,7 +91,17 @@
维护中
-
+
+
+
+
+
+
+
+
+
+
+
维护中
+
+
+ {{ dict.label }}
+
+
+
+
+ {{ dict.label }}
+
+
@@ -137,6 +185,8 @@ import { listClassroom, getClassroom, addClassroom, updateClassroom, delClassroo
export default {
name: 'Classroom',
+ // 是否类字典(sys_yes_no),注入后可通过 dict.type.sys_yes_no 访问
+ dicts: ['sys_yes_no', 'train_yes_no'],
data() {
return {
// 遮罩层
@@ -164,7 +214,9 @@ export default {
roomName: null,
roomLocation: null,
capacity: null,
- roomStatus: null
+ roomStatus: null,
+ multimedia: null,
+ projector: null
},
// 表单参数
form: {},
@@ -191,10 +243,35 @@ export default {
}
}
},
+ computed: {
+ /*
+ * 是否(sys_yes_no)单选选项。
+ * 数据库 multimedia / projector 为数值型(1=是,0=否),
+ * 字典 dictValue 为 Y/N 字符串,此处统一转换为数值,保证回显与提交类型一致。
+ */
+ yesNoOptions() {
+ const list = (this.dict && this.dict.type && this.dict.type.train_yes_no) || []
+ return list.map(item => ({
+ label: item.label,
+ //value: this.toYesNoValue(item.value)
+ value: /^\d+$/.test(String(item.value)) ? Number(item.value) : item.value
+ }))
+ }
+ },
created() {
this.getList()
},
methods: {
+ /** 是否值归一化:Y->1,N->0,纯数字字符串转 Number */
+ toYesNoValue(value) {
+ if (value === null || value === undefined || value === '') {
+ return null
+ }
+ const text = String(value)
+ if (text === 'Y' || text === 'y') return 1
+ if (text === 'N' || text === 'n') return 0
+ return /^\d+$/.test(text) ? Number(text) : value
+ },
/** 查询教室信息列表 */
getList() {
this.loading = true
@@ -217,6 +294,8 @@ export default {
roomLocation: null,
capacity: 50,
roomStatus: 1,
+ multimedia: 0,
+ projector: 0,
remark: null
}
this.resetForm('form')
@@ -249,6 +328,10 @@ export default {
const classRoomId = row.classRoomId || this.ids
getClassroom(classRoomId).then(response => {
this.form = response.data
+ console.log("multimedia==="+this.form.multimedia);
+ // 归一化是否值,保证与单选选项(数值)类型一致,避免回显不选中
+ //this.$set(this.form, 'multimedia', /^\d+$/.test(String(this.form.multimedia)) ? Number(this.form.multimedia) : this.form.multimedia)
+ //this.$set(this.form, 'projector', /^\d+$/.test(String(this.form.projector)) ? Number(this.form.projector) : this.form.projector)
this.open = true
this.title = '修改教室信息'
})