Steps_wev8.js
9.91 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
if(typeof(MEC_NS) == 'undefined'){
MEC_NS = {};
}
MEC_NS.Steps = function(type, id, mecJson){
this.type = type;
if(!id){
id = new UUID().toString();
}
this.id = id;
if(!mecJson){
mecJson = this.getDefaultMecJson();
}
this.mecJson = mecJson;
}
/*获取id。 必需的方法*/
MEC_NS.Steps.prototype.getID = function(){
return this.id;
};
/*获取设计的html, 页面上怎么显示控件完全依赖于此方法。 必需的方法*/
MEC_NS.Steps.prototype.getDesignHtml = function(){
return getDesignHtml(this);
};
/*获取构建属性编辑窗体的html,添加和单击控件后会调用此方法,由此方法去构建属性编辑窗体。 必需的方法*/
MEC_NS.Steps.prototype.getAttrDlgHtml = function(){
var theId = this.id;
var htm = '<div id="MAD'+theId+'" style="height: inherit;">';
htm += '<div class="title">'+SystemEnv.getHtmlNoteName(4650)+'<div class=\"add-before add-step\">'+SystemEnv.getHtmlNoteName(3518)+'</div></div>';//基本信息
htm += '<div class="form-group">';
htm += '<table class="table" id="MADSteps_table_'+theId+'" style="margin-top: 0px;margin-bottom:8px;">'; //名称 描述 条件
htm += '<thead>';
htm += '<tr>';
htm += '<td style="width:20px;"></td>';
htm += '<td style="width:90px;">'+SystemEnv.getHtmlNoteName(4141)+'</td>';//名称
htm += '<td style="width:*;">'+SystemEnv.getHtmlNoteName(4325)+'</td>'; //描述
htm += '<td style="width:*;">'+SystemEnv.getHtmlNoteName(6040)+'</td>';//条件
htm += '<td style="width:24px;"></td>';
htm += '</tr>';
htm += '</thead>';
htm += '<tbody></tbody>';
htm += '</table>';
htm += '<div class="tip-control tip-steps-control" style="margin-bottom: 8px;">'+SystemEnv.getHtmlNoteName(4159)+'</div>'; //单击右上角的添加按钮以添加内容
htm += '<div class="row">'
htm += '<span class="col-2 span-control">'+SystemEnv.getHtmlNoteName(4552)+'</span>'; //插件样式:
htm += '<div class="col-8 pd-7">';
htm += '<div class="multi-checkbox">';
htm += '<span class="cbboxEntry">';
htm += '<input type="checkbox" name="direction" value="vertical"/>';
htm += '<span class="cbboxLabel">'+SystemEnv.getHtmlNoteName(5051)+'</span>'; //纵向排列
htm += '</span>';
htm += '<span class="cbboxEntry">';
htm += '<input type="checkbox" name="direction" value="horizontal"/>';
htm += '<span class="cbboxLabel">'+SystemEnv.getHtmlNoteName(5052)+'</span>'; //横向排列
htm += '</span>';
htm += '</div>';
htm += '</div>';
htm += '</div>';//end row
htm += '<div class="tip-control tip-condition-control" style="margin-top: 20px;display:block;">';
htm += SystemEnv.getHtmlNoteName(6046) + '<br>'; //条件格式支持使用数据集和参数,格式支持JavaScript表达式,如:
htm += '1、'+SystemEnv.getHtmlNoteName(6047)+'{data.status} == 1<br>'; //1、单个条件用数据集,如:
htm += '2、'+SystemEnv.getHtmlNoteName(6048)+'{status} == 1<br>'; //2、单个条件用参数,如:{status} == 1
htm += '3、'+SystemEnv.getHtmlNoteName(6049)+'{data.status} == 1 && {status} == 1<br>';//3、多个条件同时满足,如:
htm += '4、'+SystemEnv.getHtmlNoteName(6050)+'{data.status} == 1 || {status} == 1<br>';//4、多个条件满足任意一个,如:
htm += '5、'+SystemEnv.getHtmlNoteName(6051); //支持直接用true、false来判断条件是否满足
htm += '</div>';
htm+='<div class="bottom">';
htm += '<div class="save-btn">'+SystemEnv.getHtmlNoteName(3451)+'</div>'; //确定
htm += '</div>';
htm += '</div>';//end form-group
htm += '</div>';//end MADSteps
htm += '<div class="MAD_Alert">'+SystemEnv.getHtmlNoteName(4115)+'</div>'; //已生成到布局
return htm;
};
/*构建属性编辑窗体完成后调用此方法,主要用于一些必须要使用js对页面进行后置操作时,无需要此方法可至空。 不必需的方法,有此方法系统自动调用*/
MEC_NS.Steps.prototype.afterAttrDlgBuild = function(){
var that = this,
theId = this.id,
$attrContainer = this.$attrContainer = $("#MAD_" + theId);
this.bindAttrDlgHtmlEvent();
var steps = this.mecJson["steps"] || [];
if(steps.length == 0){
$attrContainer.find(".tip-steps-control").show();
}else{
steps.forEach(function(step) {
that.addStepToPage(step);
});
}
var direction = this.mecJson["direction"];
var $direction = $attrContainer.find("input[type='checkbox'][name='direction'][value='" + direction + "']");
if($direction.length > 0){
$direction.checked();
}
$("#MAD_"+theId).checkbox({
onClick: function(){
that.autoUpdate();
}
});
$("#MADSteps_table_"+theId+" > tbody").sortable({
revert: false,
axis: "y",
items: "tr",
handle: ".bemove",
update: function(){
that.autoUpdate();
}
});
};
/*获取JSON*/
MEC_NS.Steps.prototype.getMecJson = function(){
var theId = this.id;
this.mecJson["id"] = theId;
this.mecJson["mectype"] = this.type;
var $attrContainer = $("#MAD_"+theId);
if($attrContainer.length > 0){
var $direction = $attrContainer.find("input[type='checkbox'][name='direction']:checked");
if($direction.length > 0){
this.mecJson["direction"] = $direction.val();
}
var steps = [];
$("#MADSteps_table_"+theId+" > tbody > tr").each(function(i){
var $row = $(this);
steps.push({
title: MLanguage.getValue($row.find("input[name='title']")),
desc: MLanguage.getValue($row.find("input[name='desc']")),
condition: encodeURIComponent($row.find("input[name='condition']").val())
});
});
this.mecJson["steps"] = steps;
}
return this.mecJson;
};
MEC_NS.Steps.prototype.getDefaultMecJson = function(){
return {
direction: 'vertical',
steps: [
{
title: SystemEnv.getHtmlNoteName(5251), // 开始
desc: SystemEnv.getHtmlNoteName(6045), // 描述信息
condition: "true"
},
{
title: SystemEnv.getHtmlNoteName(4900), // 进行中
desc: SystemEnv.getHtmlNoteName(6045), // 描述信息
condition: "true"
},
{
title: SystemEnv.getHtmlNoteName(4831), // 完成
desc: SystemEnv.getHtmlNoteName(6045), // 描述信息
condition: "false"
}
]
}
};
$.extend(MEC_NS.Steps.prototype, {
autoUpdate: function(){
var mecHandler = MECHandlerPool.getHandler(this.id);
//避免导入插件到低版本时报错
mecHandler && mecHandler.autobind && mecHandler.autobind.update();
},
bindAttrDlgHtmlEvent: function(){
var that = this, theId = this.id, $attrContainer = this.$attrContainer;
//添加行事件
$attrContainer.find(".add-step").on("click", function(){
that.addStepToPage({
title: "",
desc: "",
condition: ""
});
that.autoUpdate();
});
//删除行事件
var $tbody = $("#MADSteps_table_"+theId+" > tbody");
$tbody.on("click", ".del-after2", function(e){
$(this).closest("tr").remove();
if($tbody.children("tr").length == 0){
$(".tip-steps-control", $attrContainer).show();
}
that.autoUpdate();
});
},
addStepToPage: function(step){
var that = this,
theId = this.id,
$attrContainer = this.$attrContainer;
$attrContainer.find(".tip-steps-control").hide();
var title = step["title"], desc = step["desc"], condition = decodeURIComponent(step["condition"]);
var html = '<tr>'
+ '<td class="bemove" width="20px"></td>'
+ '<td width="90px">'
+'<input type="text" name="title" data-autobind placeholder="'+SystemEnv.getHtmlNoteName(4141)+'" class="form-control" '+MLanguage.ATTR+'/>'
+ '</td>'
+ '<td width="*">'
+'<input type="text" name="desc" data-autobind placeholder="'+SystemEnv.getHtmlNoteName(4325)+'" class="form-control" '+MLanguage.ATTR+'/>'
+ '</td>'
+ '<td width="*">'
+'<input type="text" name="condition" data-autobind placeholder="'+SystemEnv.getHtmlNoteName(6044)+'" class="form-control"/>' //如{status}==1
+ '</td>'
+ '<td width="24px">'
+ '<div class="del-after2"></div>'
+ '</td>'
+ '</tr>';
var $row = $(html);
var $tbody = $("#MADSteps_table_"+theId+" > tbody");
$tbody.append($row);
MLanguage.setValue($row.find("input[name='title']"), title);
MLanguage.setValue($row.find("input[name='desc']"), desc);
$row.find("input[name='condition']").val(condition);
$row.MLanguage();
}
});