|
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
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
|
onLoadSuccess: onLoadSuccess,
onReorderRow: onReorderRow,
columns: [{
title: "序号",
width: "5%",
formatter: function (value, row, index) {
// 编号隐藏域
var columnIdHtml = $.common.sprintf("<input type='hidden' name='columns[%s].columnId' value='%s'>", index, row.columnId);
// 排序隐藏域
var sortHtml = $.common.sprintf("<input type='hidden' name='columns[%s].sort' value='%s' id='columns_sort_%s'>", index, row.sort, row.columnId);
return columnIdHtml + sortHtml + $.table.serialNumber(index);
},
cellStyle: function(value, row, index) {
return { css: { "cursor": "move" } };
}
},
{
field: 'columnName',
title: '字段列名',
width: "10%",
class: "nodrag",
cellStyle: function(value, row, index) {
return { css: { "cursor": "default" } };
}
},
{
field: 'columnComment',
title: '字段描述',
width: "10%",
formatter: function (value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' name='columns[%s].columnComment' value='%s'>", index, $.common.nullToStr(value));
return html;
}
},
{
field: 'columnType',
title: '物理类型',
width: "10%",
class: "nodrag",
cellStyle: function(value, row, index) {
return { css: { "cursor": "default" } };
}
},
{
field: 'javaType',
title: 'Java类型',
width: "10%",
formatter: function (value, row, index) {
var data = [{ index: index, javaType: value }];
return $("#javaTypeTpl").tmpl(data).html();
}
},
{
field: 'javaField',
title: 'Java属性',
width: "10%",
formatter: function (value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' name='columns[%s].javaField' value='%s' required>", index, value);
return html;
}
},
{
field: 'isInsert',
title: '插入',
width: "5%",
formatter: function (value, row, index) {
var isCheck = value == 1 ? 'checked' : '';
var html = $.common.sprintf("<label class='check-box'><input type='checkbox' name='columns[%s].isInsert' value='1' %s></label>", index, isCheck);
return html;
}
},
{
field: 'isEdit',
title: '编辑',
width: "5%",
formatter: function (value, row, index) {
var isCheck = value == 1 ? 'checked' : '';
var html = $.common.sprintf("<label class='check-box'><input type='checkbox' name='columns[%s].isEdit' value='1' %s></label>", index, isCheck);
return html;
}
},
{
field: 'isList',
title: '列表',
width: "5%",
formatter: function (value, row, index) {
var isCheck = value == 1 ? 'checked' : '';
var html = $.common.sprintf("<label class='check-box'><input type='checkbox' name='columns[%s].isList' value='1' %s></label>", index, isCheck);
return html;
}
},
{
field: 'isQuery',
title: '查询',
width: "5%",
formatter: function (value, row, index) {
var isCheck = value == 1 ? 'checked' : '';
var html = $.common.sprintf("<label class='check-box'><input type='checkbox' name='columns[%s].isQuery' value='1' %s></label>", index, isCheck);
return html;
}
},
{
field: 'queryType',
title: '查询方式',
width: "10%",
formatter: function (value, row, index) {
var data = [{ index: index, queryType: value }];
return $("#queryTypeTpl").tmpl(data).html();
}
},
{
field: 'isRequired',
title: '必填',
width: "5%",
formatter: function (value, row, index) {
var isCheck = value == 1 ? 'checked' : '';
var html = $.common.sprintf("<label class='check-box'><input type='checkbox' name='columns[%s].isRequired' value='1' %s></label>", index, isCheck);
return html;
}
},
{
field: 'htmlType',
title: '显示类型',
width: "12%",
formatter: function (value, row, index) {
var data = [{ index: index, htmlType: value }];
return $("#htmlTypeTpl").tmpl(data).html();
}
},
{
field: 'dictType',
title: '字典类型',
width: "13%",
formatter: function (value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' name='columns[%s].dictType' value='%s' id='columns_dict_%s'>", index, value, row.columnId);
return "<div class='input-group'>" + html + "<span class='input-group-addon input-sm' onclick='selectDictTree(" + row.columnId + ", this)'><i class='fa fa-search'></i></span></div>";
},
cellStyle: function(value, row, index) {
return { css: { "cursor": "default" } };
}
}]
};
$.table.init(options);
});
// 当所有数据被加载时触发处理函数
function onLoadSuccess(data){
$.fn.select2.defaults.set( "theme", "bootstrap" );
$("select.form-control").each(function () {
$(this).select2().on("change", function () {
$(this).valid();
})
})
$(".check-box").each(function() {
$(this).iCheck({
checkboxClass: 'icheckbox-blue'
})
})
}
// 当拖拽结束后处理函数
function onReorderRow(data) {
for (var i = 0; i < data.length; i++) {
$("#columns_sort_" + data[i].columnId).val(i+1);
}
}
$(function() {
var tplCategory = $("#tplCategory option:selected").val();
tplCategoryVisible(tplCategory);
});
$('#tplCategory').on('select2:select', function (event) {
var tplCategory = $(event.target).val();
tplCategoryVisible(tplCategory);
});
function tplCategoryVisible(tplCategory) {
if("crud" == tplCategory){
$("#treeCode").select2("val", [""]);
$("#treeParentCode").select2("val", [""]);
$("#treeName").select2("val", [""]);
$("#otherInfo").addClass("hidden");
$("#subInfo").addClass("hidden");
} else if("tree" == tplCategory){
$("#otherInfo").removeClass("hidden");
$("#treeCode").attr("required", "true");
$("#treeParentCode").attr("required", "true");
$("#treeName").attr("required", "true");
$("#subInfo").addClass("hidden");
} else if("sub" == tplCategory){
$("#subInfo").removeClass("hidden");
$("#treeCode").select2("val", [""]);
$("#treeParentCode").select2("val", [""]);
$("#treeName").select2("val", [""]);
$("#otherInfo").addClass("hidden");
}
}
// 选择字典处理函数
function selectDictTree(columnId, obj) {
var dictType = $.common.nullToStr($(obj).parent().find("input").val());
var url = ctx + "system/dict/selectDictTree/" + columnId + "/" + dictType;
var options = {
title: '选择字典类型',
width: "380",
url: url,
callBack: doSubmit
};
$.modal.openOptions(options);
}
function doSubmit(index, layero){
var body = layer.getChildFrame('body', index);
var columnId = body.find('#columnId').val();
var dictType = body.find('#dictType').val();
layer.close(index);
$("#columns_dict_" + columnId).val(dictType);
}
|