|  | @@ -0,0 +1,39 @@
 | 
	
		
			
				|  |  | +const rptShowLevel = (function (){
 | 
	
		
			
				|  |  | +    const ratio = [{value: '2', title: '项'}, {value: '3', title: '目'}, {value: '4', title: '节'}, {value: '5', title: '细目'}, {value: 'leafXmj', title: '最底层项目节'}, {value: 'last', title: '最底层'}];
 | 
	
		
			
				|  |  | +    const info = {
 | 
	
		
			
				|  |  | +        show_level: { title: '请选择显示层级', ratioValue: ['2', '3', '4', '5', 'last'] },
 | 
	
		
			
				|  |  | +    };
 | 
	
		
			
				|  |  | +    const data = {};
 | 
	
		
			
				|  |  | +    let curType = '';
 | 
	
		
			
				|  |  | +    const initList = function () {
 | 
	
		
			
				|  |  | +        const ratioHtml = [];
 | 
	
		
			
				|  |  | +        const ratioValue = info[curType].ratioValue;
 | 
	
		
			
				|  |  | +        for (const r of ratio) {
 | 
	
		
			
				|  |  | +            if (ratioValue.indexOf(r.value) >= 0) {
 | 
	
		
			
				|  |  | +                ratioHtml.push(`<div class="form-check form-check-inline"><input class="form-check-input" type="radio" value="${r.value}" id="ratio_${r.value}" name="show-level"><label class="form-check-label" for="radio_${r.value}" name="show-level">${r.title}</label></div>`);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        $('#ssl-list').html(ratioHtml.join(''));
 | 
	
		
			
				|  |  | +        $(`#ratio_${data[curType]}`)[0].checked = true;
 | 
	
		
			
				|  |  | +    };
 | 
	
		
			
				|  |  | +    const show = async function (type) {
 | 
	
		
			
				|  |  | +        curType = type;
 | 
	
		
			
				|  |  | +        document.getElementById('ssl-title').innerText = info[type].title;
 | 
	
		
			
				|  |  | +        if (!data[type]) {
 | 
	
		
			
				|  |  | +            const result = await postDataAsync(`/tender/${window.location.pathname.split('/')[2]}/load`, { filter: curType });
 | 
	
		
			
				|  |  | +            data[curType] = result[curType];
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        initList();
 | 
	
		
			
				|  |  | +        $('#select-show-level').modal('show');
 | 
	
		
			
				|  |  | +    };
 | 
	
		
			
				|  |  | +    const update = async function () {
 | 
	
		
			
				|  |  | +        const updateData = {};
 | 
	
		
			
				|  |  | +        updateData[curType] = $('[name=show-level]:checked').val();
 | 
	
		
			
				|  |  | +        if (updateData[curType].length > 0) {
 | 
	
		
			
				|  |  | +            await postData(`/tender/${window.location.pathname.split('/')[2]}/saveRela`, updateData);
 | 
	
		
			
				|  |  | +            data[curType] = updateData[curType];
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        $('#select-show-level').modal('hide');
 | 
	
		
			
				|  |  | +    };
 | 
	
		
			
				|  |  | +    return { show, update }
 | 
	
		
			
				|  |  | +})();
 |