类别和大类的select联动效果
parent
a1786e882d
commit
f75b91873a
|
@ -147,7 +147,7 @@ function bindOtherOtherChangeable() {
|
|||
});
|
||||
}
|
||||
|
||||
SELECT_DATA={
|
||||
SELECT_TYPE_CATEGORY_MAP_DATA={
|
||||
"1":[
|
||||
{
|
||||
"value":"1",
|
||||
|
@ -190,17 +190,37 @@ SELECT_DATA={
|
|||
]
|
||||
};
|
||||
|
||||
SELECT_CATEGORY_TYPE_MAP_DATA={
|
||||
"1":"1",
|
||||
"2":"1",
|
||||
"3":"1",
|
||||
"4":"2",
|
||||
"5":"3",
|
||||
"6":"3",
|
||||
"7":"3",
|
||||
"8":"4"
|
||||
};
|
||||
|
||||
/**
|
||||
* 大类类别联动效果
|
||||
*/
|
||||
function bindTypeSelectChange() {
|
||||
//大类变化联动类别
|
||||
$(".am-modal-prompt-input-cost-type").on('change',function () {
|
||||
var categorySelect = $(this).parent().parent().find(".am-modal-prompt-input-cost-category");
|
||||
var type = $(this).val();
|
||||
//删除后重新添加对应的类别
|
||||
categorySelect.empty();
|
||||
SELECT_DATA[type].forEach(function (d) {
|
||||
SELECT_TYPE_CATEGORY_MAP_DATA[type].forEach(function (d) {
|
||||
categorySelect.append("<option value='"+d.value+"'>"+d.name+"</option>");
|
||||
})
|
||||
});
|
||||
//类别变化联动大类
|
||||
$(".am-modal-prompt-input-cost-category").on('change',function () {
|
||||
var typeSelect = $(this).parent().parent().find(".am-modal-prompt-input-cost-type");
|
||||
var category = $(this).val();
|
||||
//设置他选中类别对应的大类
|
||||
typeSelect.val(SELECT_CATEGORY_TYPE_MAP_DATA[category]);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue