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.
131 lines
6.6 KiB
131 lines
6.6 KiB
//全局input框绑定
|
|
$(document).off('keyup', '#columnProperty .layui-input').on('keyup', '#columnProperty .layui-input', function () {
|
|
var _key = $(this).attr("name");
|
|
var _value = $(this).val();
|
|
var _json = options.selectItem;
|
|
switch (_key) {
|
|
case 'label':
|
|
case 'width':
|
|
case 'interval':
|
|
case 'iconPickerLimit':
|
|
case 'iconPickerCellWidth':
|
|
case 'buttonVlaue':
|
|
case 'placeholder':
|
|
case 'rateLength':
|
|
case 'height':
|
|
case 'iconPickerLimit':
|
|
_json[_key] = _value;
|
|
that.components[_json.tag].update(_json, that);
|
|
break;
|
|
case 'defaultValue':
|
|
if (_json.tag === 'slider') {
|
|
var resultNumber = that.replaceNumber(_value);
|
|
_json[_key] = resultNumber;
|
|
$(this).val(resultNumber);
|
|
slider.render({
|
|
elem: '#' + _json.tag + _json.id,
|
|
value: _json.defaultValue, //初始值
|
|
min: _json.minValue,
|
|
max: _json.maxValue,
|
|
step: _json.stepValue,
|
|
disabled: _json.disabled
|
|
});
|
|
} else if (_json.tag == 'numberInput') {
|
|
var resultNumber = that.replaceNumber(_value);
|
|
_json[_key] = resultNumber;
|
|
$(this).val(resultNumber);
|
|
that.components[_json.tag].update(_json, that);//局部更新
|
|
} else {
|
|
_json[_key] = _value;
|
|
that.components[_json.tag].update(_json, that);
|
|
}
|
|
break;
|
|
case 'minValue':
|
|
case 'maxValue':
|
|
case 'stepValue':
|
|
var resultNumber = that.replaceNumber(_value);
|
|
_json[_key] = resultNumber;
|
|
$(this).val(resultNumber);
|
|
if (_json.tag === 'slider') {
|
|
slider.render({
|
|
elem: '#' + _json.tag + _json.id,
|
|
value: _json.defaultValue, //初始值
|
|
min: _json.minValue,
|
|
max: _json.maxValue,
|
|
step: _json.stepValue,
|
|
disabled: _json.disabled
|
|
});
|
|
} else if (_json.tag == 'numberInput') {
|
|
that.components[_json.tag].update(_json, that);//局部更新
|
|
}
|
|
break;
|
|
case 'carousel-text':
|
|
case 'carousel-value':
|
|
var _options = [];
|
|
$('#columnProperty .select-options').each(function () {
|
|
_options.push({
|
|
text: $(this).find('input[name=carousel-text]').val(),
|
|
value: $(this).find('input[name=carousel-value]').val(),
|
|
checked: $(this).find('input[name=carousel]').hasAttribute("checked")
|
|
});
|
|
});
|
|
_json.options = JSON.parse(JSON.stringify(_options));
|
|
that.components[_json.tag].update(_json, that);//局部更新
|
|
break;
|
|
case 'select-text':
|
|
case 'select-value':
|
|
case 'radio-text':
|
|
case 'radio-value':
|
|
case 'checkbox-text':
|
|
case 'checkbox-value':
|
|
//找到 id=key 下的 option值
|
|
var _index = parseInt($(this).parent().parent().attr("data-index"));
|
|
if (_key === 'select-text' || _key === 'radio-text' || _key === 'checkbox-text') {
|
|
_json.options[_index].text = $(this).val();
|
|
} else {
|
|
_json.options[_index].value = $(this).val();
|
|
}
|
|
that.components[_json.tag].update(_json, that);//局部更新
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
});
|
|
|
|
|
|
|
|
form.on('radio', function (data) {
|
|
var _json = options.selectItem;
|
|
alert(_json.tag);
|
|
switch (_json.tag) {
|
|
case 'radio':
|
|
var _index = parseInt($("#" + _json.id + " .layui-input-block div.layui-form-radio").index(data.othis[0]));
|
|
if ($(data.othis[0]).parent().parent().parent().attr("id") === 'radio') {
|
|
_index = parseInt($(data.othis[0]).parent().parent().attr("data-index"));
|
|
}
|
|
for (var i = 0; i < _json.options.length; i++) {
|
|
if (i === _index) {
|
|
_json.options[i].checked = true;
|
|
continue;
|
|
}
|
|
_json.options[i].checked = false;
|
|
}
|
|
that.components[_json.tag].update(_json, that);
|
|
break;
|
|
case 'select':
|
|
case 'carousel':
|
|
var _index = parseInt(data.elem.closest('.layui-form-item').dataset.index);
|
|
for (var i = 0; i < _json.options.length; i++) {
|
|
if (i === _index) {
|
|
_json.options[i].checked = true;
|
|
_json.startIndex = i;
|
|
continue;
|
|
}
|
|
_json.options[i].checked = false;
|
|
}
|
|
that.components[_json.tag].update(_json, that);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}); |