index.js
2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/**
* 创建供应商
*/
'use strict';
var $ = require('jquery'),
common = require('../common/common');
var sortmenu = require('../common/sortmenu');
var g = new common.grid({
el: "#basicTable",
parms: function () {
return {
sortId: window.sortid ? window.sortid : "",
};
},
columns: [
//分类ID 分类名称 尺码ID 尺码名 排序 操作
{display: "分类ID", name: "sortId"},
{display: "分类名称", name: "sortName"},
{display: "尺码ID", name: "sizeId"},
{display: "尺码名", name: "sizeName"},
{display: "排序", name: "orderBy"},
{
display: "操作", name: 'id', render: function (item) {
// 子类目不能删除父类目所创建的属性
if (window.sortid == item.sortId)
return '<a data-index="' + item.__index + '" href="javascript:void(0)" class="btn btn-success btn-xs delbtn">删除</a>';
}
}
]
});
sortmenu.init(function () {
g.init('/erpproduct/sortsize/ajax/index');
});
var _model = JSON.parse($("#model").val());
$(document).on("click", "#btn-add", function () {
var _title = $(this).text();
common.dialog.confirm(_title, common.util.__template($("#template").html(), {
name: _model.name,
sortname: window.sortname
}), function () {
var data = {sortId: window.sortid, sizeId: $("#sizeId").val(), orderBy: $("#orderBy").val()};
if (!data.sortId) {
common.util.__tip("尺码不可为空", "warning");
return;
}
if (!~data.sizeId) {
common.util.__tip("尺码属性不可为空", "warning");
return;
}
if (!data.orderBy) {
common.util.__tip("排序不可为空", "warning");
return;
}
if (data.orderBy < 0) {
common.util.__tip("排序不可为负数", "warning");
return;
}
common.util.__ajax({
url: '/erpproduct/sortsize/ajax/add',
data: data
}, function () {
g.reload();
});
});
new common.dropDown({
el: "#sizeId",
ajax: "sortsize"
});
});
$(document).on("click", ".delbtn", function () {
var item = g.rows[$(this).data("index")];
common.dialog.confirm("温馨提示", "你确定要删除吗?", function () {
common.util.__ajax({
url: '/erpproduct/sortsize/ajax/delete',
data: {sortId: item.sortId, sizeId: item.sizeId}
}, function () {
g.reload();
});
});
});