product.productMaterial.Index.js 2.69 KB
webpackJsonp([145],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {

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

	// 设置 物理类目 下拉框
	$('#max-sort-select').html(common.util.__template($('#max-sort-template').html()));
	// 取全局属性中的 物理类目列表
	var maxSortIds = window.ViewModel || {};

	var g = new common.grid({
	    el: '#basicTable',
	    parms: function() {
	        return {
	            maxSortId: common.util.__input('max-sort-select')
	        };
	    },
	    columns: [
	        {display: "ID", name: "id"},
	        {display: "分类", render: function(item) {
	            var sortName = '';
	            $.each(maxSortIds, function(_, sort) {
	                if(+item.maxSortId == +sort.id) {
	                    sortName = sort.sortName;
	                    return true;
	                }
	            });

	            return sortName;
	        }},
	        {display: "材质名称", name: "caption"},
	        {display: "英文名称", name: "encaption"},
	        {display: "图片", render: function(item) {
	            var htmlArr = [];
	            htmlArr.push('<div>');
	            htmlArr.push('<img src="' + item.imageUrl + '?imageView2/2/w/120/h/60">');
	            htmlArr.push('</div>');

	            return htmlArr.join('');
	        }},
	        {display: "洗涤说明", width: '50%', render: function(item) {
	            return "<p style='word-break:break-all;'>" + item.remark + "</p>";
	        }},
	        {display: "操作", render: function(item) {
	            var htmlArr = [];
	            htmlArr.push("<div>");
	            htmlArr.push('<a href="/goods/material/edit/' + item.id + '" class="btn btn-primary btn-xs">编辑</a>');
	            htmlArr.push('<a href="javascript:;" class="btn btn-danger del-btn btn-xs" data-id="' + item.id + '">删除</a>');
	            htmlArr.push('<a href="/goods/material/bindinfo/' + item.id + '" target="_blank" class="btn btn-info btn-xs">查看绑定</a>');
	            htmlArr.push('</div>');

	            return htmlArr.join('');
	        }}
	    ]
	});

	g.init('/product/material/list');

	// 筛选
	$(document).on('click', '#filter-btn', function() {
	    g.reload(1);
	});

	// 删除
	$(document).on('click', '.del-btn', function() {
	    var id = $(this).data('id');
	    common.dialog.confirm("温馨提示", "你确定要删除吗?", function() {
	        common.util.__ajax({
	            url: '/product/material/delete',
	            data: {
	                materialId: id
	            },
	            aysnc: false
	        }, function(res) {
	            if(res && res.code == 200) {
	                g.reload();
	            }
	        });
	    });
	});

/***/ }
]);