CateSizeAttr.js
4.42 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/**
* 创建供应商
*/
'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: "attributeId"},
{display: "尺码属性名", name: "attributeName"},
{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/sortattribute/ajax/index');
});
/**
* 验证
*/
var edit = new common.edit2(".modal-body");
/**
* 通用
* @type {{module: null, toast: Bll.toast}}
*/
var Bll = {
module: null,
attri: [],
dropDown: function () {
common.util.__ajax({
url: '/erpproduct/sortattribute/ajax/automatic',
data: {
"sortId": window.sortid ? window.sortid : ""
}
}, function (res) {
$("#attri-content").html(common.util.__template2($("#search-attri").html(), res));
new common.dropDown({el: "#choose-attri"});
Bll.attri = res.data;
}, true);
},
//弹框
toast: function (hint, module, url) {
if (module.__state == 'add') {
Bll.dropDown();
}
Bll.module = module;
var d = new common.dialog({
title: hint + "尺码",
content: common.util.__template2($("#template").html(), Bll.module),
width: '30%',
button: [
{
value: "保存",
callback: function () {
console.log("保存数据", Bll.module);
if (edit.validate()) {
common.util.__ajax({
url: url,
data: Bll.module
}, function (res) {
if (res.code == '200') {
g.reload();
d.close();
}
else {
common.util.__tip(res.message, "warning");
}
});
}
return false;
},
css: "btn-primary"
},
{
"value": "取消",
"css": "btn-info"
}
]
});
edit.init();
}
};
/**
* 监听输入框变化
*/
$(document).on("change", ".observe", function () {
var $this = $(this);
var name = $this.data("field");
Bll.module = common.util.__buildobj(name, '.', Bll.module, function (obj, name1) {
obj[name1] = $this.val();
});
});
/**
* 添加
*/
$(document).on("click", "#btn-add", function () {
var item = {
__state: "add",
name:"尺码属性",
sortName: window.sortname,
sortId: window.sortid,
attributeName: "",
attributeId: "",
orderBy: 0
};
Bll.toast("新增", item, '/erpproduct/sortsize/ajax/add');
});
/**
* 删除
*/
$(document).on("click", ".delbtn", function () {
var item = g.rows[$(this).data("index")];
common.dialog.confirm("温馨提示", "你确定要删除吗?", function () {
common.util.__ajax({
url: '/erpproduct/sortattribute/ajax/delete',
data: {sortId: item.sortId, attributeId: item.attributeId}
}, function () {
g.reload();
});
});
});
/**
* 下拉变化
*/
$(document).on("change", "#choose-attri", function () {
var attributeId = $(this).val();
Bll.module.attributeId = attributeId;
for (var i = 0; i < Bll.attri.length; i++) {
if (Bll.attri[i].id == attributeId) {
Bll.module.attributeName = Bll.attri[i].text;
}
}
});