size-property.js 1.99 KB
/**
 * Created by wangqianjun on 16/2/3.
 */
'use strict';
var $ = require('jquery'),
    common = require('../common/common');

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-info add2"  data-index="' + item.__index + '">编辑</a>';
        }
        }
    ]
});

g.init($('#url').val());

$('#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();
            });
        });
});