心衰系统,crf表单
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

109 lines
3.8 KiB

$(document).ready(function(){
$('.hminput ,.hmtextarea').on('change focusout keydown', function() {
this.setAttribute('value', this.value)
})
$('textarea').each(function(index,elm){
$(elm).text(elm.getAttribute('value') || '')
})
const initCRF = function() {
// const doc = window.document
const laydate = window.laydate
$('.hminput').each(function() {
const elm = this
const hmDataType = elm.getAttribute('data-hm_type')
// 时间控件
if (hmDataType === 'date' || hmDataType === 'datetime' || hmDataType === 'time') {
laydate.render({
elem: '#' + elm.id,
type: hmDataType,
done: function(value, date, endDate) {
elm.setAttribute('value', value)
}
})
}
})
$('.hmselect').on('click', function() {
this.setAttribute('value', this.value)
$(this).find(`option[value='${this.value}']`).attr("selected",'selected');
$(this).find(`option[value!='${this.value}']`).each((index, item) => {
if (item.value !== this.value) { item.removeAttribute('selected') }
})
// 把单位赋值给输入框的title
const id = $(this)[0].getAttribute('data-hm_id')
$(`input[data-hm_id='${id}']`).each((index, item) => {
item.setAttribute("title",this.value);
})
})
$('.DDDs').on('click', function() {
this.setAttribute('value', this.value)
$(this).find(`option[value='${this.value}']`).attr("selected",'selected');
$(this).find(`option[value!='${this.value}']`).each((index, item) => {
if (item.value !== this.value) { item.removeAttribute('selected') }
})
})
$('.hmcheckbox').on('change', function() {
$(this).attr('checked', this.checked)
})
$('.hmradio').on('change', function() {
const elm = this
$(elm).attr('checked', this.checked)
$(`input:radio[name='${this.name}']`).each((index, item) => {
if (item.value !== elm.value) { item.removeAttribute('checked') }
})
// 把单位赋值给输入框的title
const id = $(this)[0].getAttribute('data-hm_id')
$(`input:text[data-hm_id='${id}']`).each((index, item) => {
item.setAttribute("title",this.value);
// 给单位radio赋个标记unit
$(`input:radio[data-hm_id='${id}']`).each((index, item) => {
item.setAttribute("unit",'unit');
})
})
})
}
initCRF()
})
/** 对象数组,对象格式
const demo = {
both: null,
id: '4',
name: '眼压',
od: '20.3',
os: '16',
recId: '9379374',
time: '2013-04-15 13:27:14'
}
*/
function dataFill(itemList){
console.log(itemList)
itemList ? itemList.forEach(item => {
const eyeType=item.both ? '' : ''
// data-hm_bd_id--字典表/table/dict/getTableDictTreeForCRF--id
// 根据字典表id填充数据
// console.log(item.id);
// console.log( $(`[data-hm_bd_id='${item.id}']`));
$(`[data-hm_bd_id='${item.id}']`).each(function(index,elm){
// console.log(elm);
if(elm.getAttribute("data-hm_bd_eye_type") === 'od'){
$(elm).attr('value',item.od || '')
} else if(elm.getAttribute("data-hm_bd_eye_type")==='os'){
$(elm).attr('value',item.os || '')
} else {
$('textarea').each(function(index,elm){
$(elm).text(elm.getAttribute('value') || '')
$(elm).width(elm.getAttribute('value') ? (elm.getAttribute('value').length * 16) + 'px' : '450px')
})
$(elm).attr('value',item.value || '')
}
})
}): $('textarea').each(function(index,elm){
$(elm).width(elm.getAttribute('value') ? (elm.getAttribute('value').length * 16) + 'px' : '450px')
})
}