user-release-of-goods.js
12.4 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
define(function( require, exports, module ) {
require( 'region' );
require( 'dragsort' );
require( 'jqueryUI' );
require( 'fancybox' );
var _SalesData = require( 'SalesData' ),
_Jselect = require( 'jselect'),
_Controller = require('categorySelect');
$(function(){
var methods = {
updateunm : function(view){
var mun = 0;
$("#"+view+" .available").each(function(){
var value = $(this).val();
console.log(value);
if(value && !isNaN(value)){
mun += parseInt($(this).val());
}
});
return mun;
},
updateunit : function(){
var unit = $("#unit").find("option:selected").length > 0 ? $("#unit").find("option:selected").text() : $("#unit").text();
this.unit = unit;
$(".t-unit").html(unit);
},
unit : "斤"
};
region.start();
$(".certification .certification-img").fancybox({
padding : 0
});
$("#add-certification .add-mbox").click(function(){
$.fancybox.close();
});
$(".my-list p").click(function(){
$(this).next().slideToggle();
});
$(".release-stairs").draggable();
//初始化
methods.updateunit();
//业务逻辑区
//添加报价区间
var priceTable = $("#purchases tbody");
$(".addbtn").click(function(){
var pkey = '<tr>'
+'<td>购买:'
+ '<input type="text" '
+ 'min="1" maxlength="6" '
+ 'dilimethod="checkQuotationStockNum" '
+ 'name="qujianNum'+ $("#purchases tbody tr").length+'" required="true" '
+ 'digits="true" class="count">'
+ '<span ng-bind="name">' + methods.unit + '</span>以上</td> '
+ '<td> '
+ '<input type="text" '
+ 'range="0.01,999999.99" '
+ 'maxlength="9" '
+ 'dilimethod="checkQuotationPrice" '
+ 'name="qujianPrice'+ $("#purchases tbody tr").length+'" money="true" '
+ 'required="true" class="price">元/'
+ '<span ng-bind="name">' + methods.unit + '</span>'
+ '<span class="delete a-link">删除</span> '
+'</td>'+'</tr>' ;
if($("#purchases tbody tr").length < 3){
priceTable.append(pkey);
}
if ($("#purchases tbody tr").length ==3) {
$(".addbtn").parent().parent().hide();
}
});
$("#purchases .delete").live("click", function(){
if($("#purchases tbody tr").length > 1){
$(".addbtn").parent().parent().show();
$(this).parent().parent().remove();
}
});
//设置商品属性选择
var sales1 = new _SalesData({
'rootView':'#saleAttr',
'showView':'#describe',
'radioNmae':'#unit'
}) ;
sales1.event("change", function(){
methods.updateunit();
});
sales1.eachData();
var sales2 = new _SalesData({
'rootView':'#saleAttr',
'showView':'#interval',
'radioNmae':'#unit',
res : [
{"class": "stockNum", "digits": "true", "maxlength": "6", "required": "true", "dilipattern": "/^[0-9]+$/,可售量有误!", "value": "", "name": ""}
]
});
sales2.event("change", function(){
methods.updateunit();
});
sales2.eachData();
//修改页区间设置
var sales3 = new _SalesData({
'rootView': '#saleAttr',
'showView': '#interval1',
'radioNmae': '#unit',
res: [
{"class": "stockNum", "digits": "true", "maxlength": "6", "required": "true", "dilipattern": "/^[0-9]+$/,可售量有误!", "value": "", "name": ""}
]
});
sales3.event("change", function () {
methods.updateunit();
});
sales3.eachData();
if($('input[name="quotationType"]:checked').val()==1){
$(".interval-view").hide();
$(".specifications-view").show();
//sales1.changeData();
}else{
$(".interval-view").show();
$(".specifications-view").hide();
//sales2.changeData();
}
//报价方式
$("input[name='quotationType']").change(function(){
if($(this).val() == "2"){
$(".interval-view").show();
$(".specifications-view").hide();
if($(this.hasClass("update"))) {
sales3.changeData();
}else {
sales2.changeData();
}
}else{
$(".interval-view").hide();
$(".specifications-view").show();
sales1.changeData();
}
});
//楼梯
$(".icon-stairs-colse").click(function(){
$(".release-stairs").hide();
});
////拖动
//$("#user-list").dragsort({ dragSelector: "span", dragBetween: true, dragEnd: function(){
//
//}});
//楼层跳转
$(".release-stairs li").click(function(){
var view = $(".form-box").eq($(this).index());
var $body = (window.opera) ? (document.compatMode == "CSS1Compat" ? $('html') : $('body')) : $('html,body');
var distance = view.offset().top;
$body.stop().animate({scrollTop: distance}, 800);
});
$(".release-stairs .top").click(function(){
var $body = (window.opera) ? (document.compatMode == "CSS1Compat" ? $('html') : $('body')) : $('html,body');
$body.stop().animate({scrollTop: 0}, 800);
});
$(".certification-img").hover(function(){
if($(this).find("img").attr("src") == ""){
$(this).next().hide();
}else{
$(this).next().show();
}
});
$(".available").live("change", function(){
var getnum = 0;
if($('input[name="quotationType"]:checked').val() == "1"){
getnum = methods.updateunm("describe");
}else{
getnum = methods.updateunm("interval");
}
$(".sell-num").html(getnum+""+methods.unit);
});
//自动生成标题
$( "#auto-title" ).click(function(){
var countycity2= $("select[name='producingId2']").val();
var countycity2Value= $("select[name='producingId2']").find("option:selected").text();//选中文本值
var countycity3Value= $("select[name='producingId3']").find("option:selected").text();//选中文本值
var producingValue=$("input[name='producingId']").val();
if (producingValue == "") {
alert("请选择产地!");
return false;
}
if (parseInt(producingValue) == -10) {
alert("产地还需选择下一级!");
return false;
}
if(producingValue>-20){
if(countycity2Value=='北京'||countycity2Value=='天津'||countycity2Value=='重庆'||countycity2Value=='上海'||countycity2Value=='澳门'||countycity2Value=='香港'){
productArea=countycity2Value;
}else{
if(countycity3Value=='请选择'){
productArea=countycity2Value;
}else{
productArea=countycity2Value+countycity3Value;
}
}
}else{
productArea= $("input[name='producingId']").attr("data-cate-txt");
}
var cateName = $("#autoCname").val();
//var pickUpId=[];
//var pickUpNames=[];
//$("input[name='deliId']:checked").each(function(){
// pickUpId.push($(this).val()) ;
// var text = $(this).attr("attr");
// //text=text.replaceAll(" ","");
// pickUpNames.push(text);
//});
//if(pickUpId.length==0){
// alert("需填写完成分类、产地时才能自动生成标题!");
// return false;
//}
//var pickUpName = pickUpNames[0]
//if(pickUpNames.length>1){
// pickUpName+="等";
//}
//苹果 产地四川省成都市 提货点成都聚合等
var pName = cateName+" 产地"+productArea;
$("#title").val(pName);
$("#title").blur();
});
/* 模拟下拉列表 */
var conf = {
url: "/titan/category/nextSubCategroy?parentId={cid}", root: "#subCategory", name: "subCategory",sid:"-1"
};
new _Controller(conf);
$( '.sea-select' ).each( function(){
new _Jselect( this , {
searchBar:true
});
});
//新增子分类
$( '#c-nav-add' ).click(function(){
var scId = $(".subCategoryVal").val();
if(scId=="" || scId==undefined){
alert("请选择最后一级分类!");
return false;
}
var mcId = $("#mainCid").val();
if(scId==mcId){
alert("该分类已存在主分类上了!");
return false;
}
var areadyScIdObj = $("#scId-"+scId);
if(undefined != areadyScIdObj && areadyScIdObj.length >= 1){
alert("该分类已经添加了!");
return false;
}
var htmlScId = "scId-"+scId;
var textSubClase = $(".subCategoryVal").attr("val");
var _html = $('<div class="c-nav-box subcid" id="'+htmlScId+'" scid="'+ scId+'"><div id="" class="pack_jselect " ><div style="background: #f5f5f5;border: 1px #ccc;"><span>'+textSubClase+'</span></div></div><span class="submitBtn grayBtn c-nav-rmove">删除</span></div>');
$( _html ).insertBefore( $( "#subCates" ) );
new _Jselect( $( _html ).find( '.sea-select' )[0] , {
searchBar:true
});
});
//删除子分类
$(".c-nav-rmove").live("click", function () {
$(this).parent().remove();
}) ;
//有效期,上架模式自定义
$( '.c-info' ).click(function(){
if( $(this).hasClass("defind")){
if($(this).attr("name")=="indate") {
$("#defindIndate").val($(this).val());
}
$( '#'+$( this ).attr('cdata')).show();
}else{
$('#' + $(this).attr('cdata')).find("input").removeAttr("value","");
$( '#'+$( this ).attr('cdata') ).hide();
}
});
//有效期自定义自动赋值
$("#indateInput").live("keyup", function () {
$("#defindIndate").val($(this).val());
}) ;
////产地选择切换
//$("#sameCity").click(function(){
// if($(this).find("input").first().attr("checked")){
// $("#localityId").attr("value",$("#producingId").val());
// $("#home").hide();
// }else{
// $("#localityId").attr("value","");
// $("#home").show();
// }
//})
});
});