|
|
|
@ -158,14 +158,15 @@ layui.define(['form'], function (exports) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 设置只读
|
|
|
|
|
if (this.readonly) { |
|
|
|
|
this.setReadonly(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 设置组件已读 |
|
|
|
|
*/ |
|
|
|
|
setReadonly() { |
|
|
|
|
if (this.readonly) { |
|
|
|
|
// 设置延迟执行,确保在所有组件渲染完成后再设置只读,否则被layui的render方法执行后会将该只读设置重写覆盖而导致失效
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
// 先添加用于覆盖layui样式的内部样式到head中
|
|
|
|
@ -202,7 +203,6 @@ layui.define(['form'], function (exports) { |
|
|
|
|
} |
|
|
|
|
}, 150); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取渲染目标元素 |
|
|
|
@ -386,6 +386,15 @@ layui.define(['form'], function (exports) { |
|
|
|
|
console.error('组件未定义:' + id); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
setReadonly: function (id) { |
|
|
|
|
if (id) { |
|
|
|
|
_cache.get(id).setReadonly(); |
|
|
|
|
} else { |
|
|
|
|
for (const dict of _cache.values()) { |
|
|
|
|
dict.setReadonly(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
/** |
|
|
|
|
* 获取字典项的描述 |
|
|
|
|
* @param type 字典类型 |
|
|
|
|