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.

92 lines
2.7 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 win = window
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)
}
})
}
})
$('.hmcheckbox').on('change', function() {
$(this).attr('checked', this.checked)
})
$('.hmradio').on('change', function() {
console.log(12333);
const elm = this
console.log($('.hmradio'));
$(elm).attr('checked', this.checked)
$(`input:radio[name='${this.name}']`).each((index, item) => {
if (item.id !== elm.id) { item.removeAttribute('checked') }
})
// 问卷调查计算总分
var score = 0
$('.hmradio').each((index,ele)=>{
if(ele.checked) {
score = score + parseInt(ele.value)
}
})
// console.log( score);
$('#score').attr('value',score +'分')
})
}
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')
})
}