提交 | 用户 | 时间
|
1ac2bc
|
1 |
/** |
懒 |
2 |
* 详情对话框 |
|
3 |
*/ |
|
4 |
var EgFormInfoDlg = { |
|
5 |
data: { |
|
6 |
title: "", |
|
7 |
singleTime: "", |
|
8 |
beginTime: "", |
|
9 |
endTime: "", |
|
10 |
multiSelect: "", |
|
11 |
pictureOne: "", |
|
12 |
number: "", |
|
13 |
singleSelectOne: "", |
|
14 |
singleSelectTwo: "", |
|
15 |
pictureTwo: "", |
|
16 |
longText: "" |
|
17 |
} |
|
18 |
}; |
|
19 |
|
|
20 |
layui.use(['form', 'admin', 'ax', 'upload', 'laydate', 'selectPlus'], function () { |
|
21 |
var $ = layui.jquery; |
|
22 |
var $ax = layui.ax; |
|
23 |
var form = layui.form; |
|
24 |
var admin = layui.admin; |
|
25 |
var upload = layui.upload; |
|
26 |
var laydate = layui.laydate; |
|
27 |
var selectPlus = layui.selectPlus; |
|
28 |
|
|
29 |
//初始化时间选择器 |
|
30 |
laydate.render({ |
|
31 |
elem: '#singleTime' |
|
32 |
, type: 'datetime' |
|
33 |
}); |
|
34 |
laydate.render({ |
|
35 |
elem: '#betweenTime' |
|
36 |
, range: true //或 range: '~' 来自定义分割字符 |
|
37 |
}); |
|
38 |
|
|
39 |
//初始化多选 |
|
40 |
var test = selectPlus.render({ |
|
41 |
el: '#multiSelect', |
|
42 |
data: [{ |
|
43 |
"id": 1, |
|
44 |
"name": "spring" |
|
45 |
}, { |
|
46 |
"id": 2, |
|
47 |
"name": "shiro" |
|
48 |
}, { |
|
49 |
"id": 3, |
|
50 |
"name": "mybatis-puls" |
|
51 |
}, { |
|
52 |
"id": 4, |
|
53 |
"name": "beetl" |
|
54 |
}], |
|
55 |
valueName: "name", |
|
56 |
values: ['abc'], |
|
57 |
valueSeparator: " --- " |
|
58 |
}); |
|
59 |
selectPlus.on('selectPlus(multiSelect)', function (obj) { |
|
60 |
console.log(obj.checked); //当前是否选中状态 |
|
61 |
console.log(obj.values); //选中的数据 |
|
62 |
console.log(obj.checkedData); //选中的相关数据 |
|
63 |
console.log(obj.isAll); //是否是全选 |
|
64 |
console.log(obj.ele); //点击的DOM |
|
65 |
$("#multiSelectHidden").val(obj.values); |
|
66 |
}); |
|
67 |
|
|
68 |
//上传文件 |
|
69 |
upload.render({ |
|
70 |
elem: '#fileBtn' |
|
71 |
, url: Feng.ctxPath + '/system/upload' |
|
72 |
, accept: 'file' |
|
73 |
, before: function (obj) { |
|
74 |
obj.preview(function (index, file, result) { |
|
75 |
$("#fileNameTip").html(file.name); |
|
76 |
}); |
|
77 |
} |
|
78 |
, done: function (res) { |
|
79 |
$("#fileInputHidden").val(res.data.fileId); |
|
80 |
Feng.success(res.message); |
|
81 |
} |
|
82 |
, error: function () { |
|
83 |
Feng.error("上传图片失败!"); |
|
84 |
} |
|
85 |
}); |
|
86 |
|
|
87 |
//普通图片上传 |
|
88 |
upload.render({ |
|
89 |
elem: '#picBtn' |
|
90 |
, url: Feng.ctxPath + '/system/upload' |
|
91 |
, before: function (obj) { |
|
92 |
obj.preview(function (index, file, result) { |
|
93 |
$('#img1').attr('src', result); |
|
94 |
}); |
|
95 |
} |
|
96 |
, done: function (res) { |
|
97 |
$("#pictureInputHidden").val(res.data.fileId); |
|
98 |
Feng.success(res.message); |
|
99 |
} |
|
100 |
, error: function () { |
|
101 |
Feng.error("上传图片失败!"); |
|
102 |
} |
|
103 |
}); |
|
104 |
|
|
105 |
//表单提交事件 |
|
106 |
form.on('submit(btnSubmit)', function (data) { |
|
107 |
var ajax = new $ax(Feng.ctxPath + "/egForm/addItem", function (data) { |
|
108 |
Feng.success("添加成功!"); |
|
109 |
|
|
110 |
//传给上个页面,刷新table用 |
|
111 |
admin.putTempData('formOk', true); |
|
112 |
|
|
113 |
//关掉对话框 |
|
114 |
admin.closeThisDialog(); |
|
115 |
}, function (data) { |
|
116 |
Feng.error("添加失败!" + data.responseJSON.message) |
|
117 |
}); |
|
118 |
ajax.set(data.field); |
|
119 |
ajax.start(); |
|
120 |
}); |
|
121 |
|
|
122 |
//返回按钮 |
|
123 |
$("#backupPage").click(function () { |
|
124 |
window.location.href = Feng.ctxPath + "/egForm"; |
|
125 |
}); |
|
126 |
|
|
127 |
}); |