baserule.SizeAttribute.js 2.18 KB
webpackJsonp([10],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {

	/**
	 * Created by wangqianjun on 16/2/3.
	 */
	'use strict';
	var $ = __webpack_require__(1),
	    common = __webpack_require__(2);

	var g = new common.grid({
	    el: '#size-property',
	    columns: [
	        {display: "编号", name: "id"},
	        {display: "属性名", name: "attributeName"},
	        {
	            display: "操作", name: "", render: function (item) {
	            return '<a class="btn btn-xs btn-info add2"  data-index="' + item.__index + '">编辑</a>';
	        }
	        }
	    ]
	});

	g.init("/erpproduct/sizeattribute/propertyList");

	$('#size-property').on('click', '.add2', function () {

	    var item = g.rows[$(this).data("index")];
	    common.dialog.confirm("修改尺码属性",
	        common.util.__template($("#template").html(), {id: item.id, input: item.attributeName})
	        , function () {
	            common.util.__ajax({
	                url: '/erpproduct/sizeattribute/propertyModify',
	                data: (function () {
	                    var input = $('#input').val();
	                    if (input === '' || $.trim(input) === '') return "尺码名不能为空";
	                    return {
	                        id: item.id,
	                        attributeName: $("#input").val()
	                    };
	                })()

	            }, function () {
	                g.reload();
	            });
	        });
	});

	// 添加&编辑 尺码属性
	$('#add').on('click', function () {

	    common.dialog.confirm("添加尺码属性",
	        common.util.__template($("#template").html(), {id: "", input: ""})
	        , function () {
	            common.util.__ajax({
	                url: '/erpproduct/sizeattribute/propertyAdd',
	                data: (function () {
	                        var input = $('#input').val();
	                        if (input === '' || $.trim(input) === '') return "尺码名不能为空";
	                        return {
	                            attributeName: input
	                    };
	                })()
	            }, function () {
	                g.reload();
	            });
	        });
	});







/***/ }
]);