baserule.parameterMake.Index.js 4.78 KB
webpackJsonp([14],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {

	var $ = __webpack_require__(1),
	    common = __webpack_require__(2);

	var GetRequestParams = function() { 
	    var url = location.search; //获取url中"?"符后的字串 
	    var theRequest = {}; 
	    if (url.indexOf("?") != -1) { 
	        var str = url.substr(1);
	        strs = str.split("&"); 
	        for(var i = 0; i < strs.length; i ++) {
	            var paramNameVal = strs[i].split("=");
	            theRequest[paramNameVal[0]] = decodeURIComponent(paramNameVal[1]);
	        } 
	    } 
	    return theRequest; 
	};

	var reqParams = GetRequestParams();

	var g = new common.grid({
	    el: "#basicTable",
	    usepagesize:true,
	    parms: function () {        
	        return {
	            standardId :reqParams.standardId,
	            standardName : reqParams.standardName
	        };
	    },
	    columns: [ {
	        display: 'ID',
	        name: 'id',
	    }, {
	        display: '参数值',
	        render: function(item) {
	            return item.parameterValue;
	        }
	    }, {
	        display: '所属参数',
	        render: function(item) {
	            return reqParams.standardName;
	        }
	    },{
	        display: '操作',
	        render: function(items) {
	            var HtmArr = [];
	            HtmArr.push('<a data-index="'+ items.__index+ '" href="JavaScript:;" class="btn btn-info btn-xs edit-class-btn">编辑</a>');
	            HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-danger btn-xs del-standardVal">删除</a>');
	            return HtmArr.join('');
	        }
	    }]
	});
	g.init("/erpproduct/standardVal/list");



	//删除
	$('tbody').on('click', '.del-standardVal', function() {
	    var item=g.rows[$(this).data("index")];
	    common.dialog.confirm("温馨提示", "你确定要删除吗?", function () {
	        common.util.__ajax({
	            url:'/erpproduct/standardVal/del',
	            data:{id:item.id}
	        },function(){
	            g.reload();
	        });
	    });
	});


	/**
	修改
	**/
	$(document).on('click', '.edit-class-btn', function () {
	    var item = g.rows[$(this).data("index")];   
	    
	    var standardVal = {
	        id: item.id,        
	        parameterValue: item.parameterValue    
	    };
	    common.dialog.confirm("修改参数",
	        common.util.__template2($("#edit-template").html(),standardVal)
	        , function () {
	            var flag=true;
	            var parameterValue = $('#parameterValue').val();
	            if (parameterValue === '' || $.trim(parameterValue) === '')
	            {
	                flag=false;
	                common.util.__tip("参数类别名称不能为空", "warning");
	            }
	            if(flag){
	                common.util.__ajax({
	                    url: '/erpproduct/standardVal/update',
	                    data: (function () {
	                        return {
	                            id: item.id,
	                            parameterValue: $("#parameterValue").val(),
	                            standardId: $("#standardId").val()
	                        };
	                    })()
	                }, function () {
	                    g.reload();
	                });
	            }else {
	                return false;
	            }
	        });
	});
	/**
	新增
	**/
	$(document).on('click', '#add-btn', function () {
	    var item = g.rows[$(this).data("index")];
	    

	    var standardVal = {                        
	                parameterValue: common.util.__input("parameterValue")    
	            };
	    common.dialog.confirm("新增参数类别",
	        common.util.__template2($("#edit-template").html(),standardVal), 
	        function () {
	            var flag=true;
	            var parameterValue = $('#parameterValue').val();
	            if (parameterValue === '' || $.trim(parameterValue) === '')
	            {
	                flag=false;
	                common.util.__tip("参数类别名称不能为空", "warning");
	            }
	            if(flag){
	                common.util.__ajax({
	                    url: '/erpproduct/standardVal/add',
	                    data: (function () {
	                        return {
	                            standardId: reqParams.standardId,
	                            parameterValue: $("#parameterValue").val()
	                        };
	                    })()
	                }, function () {
	                    g.reload();
	                });
	            }else {
	                return false;
	            }
	        });
	    new common.dropDown({
	        el: '#stortTypeId',
	        ajax: 'queryStortType',
	        hash: true,
	        params:function(){
	            return {standardId : reqParams.standardId};
	        }
	    });    
	});



/***/ }
]);