Edit.js
4.51 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
'use strict';
var $ = require('jquery'),
common = require('../../../common/common'),
rejectPromotions=require('./partials/edit_reject');
var baseInfoEdit=require('./partials/edit_baseinfo');
var date_util=require('./partials/_date_util');
var operationEdit=require('./partials/edit_operation');
/*
* 获取业务数据
*/
window.PromotionInfo=window.ViewModel.data;
console.log(window.PromotionInfo);
var ENUM = {
status: {
'0': '已下架',
'1': '已上架',
'2': '待审核',
'3': '上架驳回',
'4': '通过',
'5': '再上架待审核',
'6': '再上架驳回',
'7': '再上架通过',
'8': '待上架',
'9': '下架驳回',
'10':'下架待审核'
},
tab: {
'1': 0,
'2': 0,
'3': 0,
'4': 0,
'5': 0
},
tabName:[
{en:"baseinfo",cn:"基本信息"},
{en:"condition",cn:"促销条件"},
{en:"operation",cn:"促销操作"},
{en:"limit",cn:"促销限制"},
{en:"reject",cn:"互斥促销"},
{en:"display",cn:"促销显示"},]
};
var fixDateTime=function(){
if(PromotionInfo.startTime&&PromotionInfo.startTime>0){
PromotionInfo.startTimeStr=date_util.getDateStr(PromotionInfo.startTime);
}
if(PromotionInfo.endTime&&PromotionInfo.endTime>0){
PromotionInfo.endTimeStr=date_util.getDateStr(PromotionInfo.endTime);
}
}
//修复日期格式,只修改一次即可
fixDateTime();
var str2Json=function(){
if(PromotionInfo.promotionParams){
if(PromotionInfo.promotionParams && PromotionInfo.promotionParams.actionParam){
PromotionInfo.promotionParams.actionParam=JSON.parse(PromotionInfo.promotionParams.actionParam);
}
if(PromotionInfo.promotionParams.conditionParam){
PromotionInfo.promotionParams.conditionParam=JSON.parse(PromotionInfo.promotionParams.conditionParam);
}
if(PromotionInfo.promotionParams.rejectParam){
PromotionInfo.promotionParams.rejectParam=JSON.parse(PromotionInfo.promotionParams.rejectParam);
}
}
}
str2Json();
//加载显示tab页内容
var loadTabHtml=function(columnname){
var default_html="<a href='#'>bad error</a>";
if (columnname === ENUM.tabName[0].en) {//baseinfo
var html_baseinfo=common.util.__template2($("#fm_baseInfo").html(), PromotionInfo);
$("#tab_body").html(html_baseinfo);
baseInfoEdit.load({promotionId : PromotionInfo.id});
}else if(columnname === ENUM.tabName[1].en) {//condition
var html_condition = $("#fm_condition").html()||default_html;
$("#tab_body").html(html_condition);
} else if(columnname === ENUM.tabName[2].en) {//operation
var html_operation = $("#fm_operation").html()||default_html;
$("#tab_body").html(html_operation);
var operationData={
promotionType : PromotionInfo.promotionParams.promotionType,
actionParam : PromotionInfo.promotionParams.actionParam,
promotionId : PromotionInfo.id
};
operationEdit.load(operationData);
}else if(columnname === ENUM.tabName[3].en) {//limit
var html_limit = $("#fm_limit").html()||default_html;
$("#tab_body").html(html_limit);
}else if(columnname === ENUM.tabName[4].en) {//reject
// 加载促销列表
var html_promotions=$("#fm_reject").html();
$("#tab_body").html(html_promotions);
rejectPromotions.init();
}else if(columnname === ENUM.tabName[5].en) {//display
var html_display = $("#fm_display").html()||default_html;
$("#tab_body").html(html_display);
}
}
//tab 页组件
var t = new common.tab2({
el: "#basicTab",
active: 0,
click: function () {
var columnname = t.options.columns[t.options.active].name;
loadTabHtml(columnname);
},
columns: [{
name: ENUM.tabName[0].en,
value: '8',
display: ENUM.tabName[0].cn
}, {
name: ENUM.tabName[1].en,
value: '1',
display: ENUM.tabName[1].cn
}, {
name: ENUM.tabName[2].en,
value: '1',
display: ENUM.tabName[2].cn
}, {
name: ENUM.tabName[3].en,
value: '1',
display: ENUM.tabName[3].cn
}, {
name: ENUM.tabName[4].en,
value: '0',
display: ENUM.tabName[4].cn
},{
name: ENUM.tabName[5].en,
value: 'all',
display: ENUM.tabName[5].cn
}]
}).init(ENUM.tab);
//默认加载
loadTabHtml(t.options.columns[t.options.active].name);