@@ -39,13 +39,13 @@ class="layui-icon"></i> 搜 索
3939
4040 <script type =" text/html" id =" toolbarFilter" >
4141 <div class =" layui-btn-container" >
42- {{-- <button class="layui-btn layui-btn-sm data-add-btn" lay-event="add "> 添加</ button>--}}
42+ <button class =" layui-btn layui-btn-sm data-add-btn" id = " file_upload " > < i class = " layui-icon " ></ i >上传附件</ button >
4343 </div >
4444 </script >
4545 <script type =" text/html" id =" currentTableBar" >
4646 @if ( check_admin_auth ($MODULE_NAME . ' show' ) )
4747 @ {{# if(d._src){ }}
48- <a target =" _blank" href =" @ {{ d._src }}" class =" layui-btn layui-btn-xs layui-btn-primary" >预览</a >
48+ <a target =" _blank" href =" @ {{ d._src }}" class =" layui-btn layui-btn-xs layui-btn-primary" >预览</a >
4949 @ {{# } }}
5050 @endif
5151 </script >
@@ -55,11 +55,12 @@ class="layui-icon"></i> 搜 索
5555
5656@section (' footer' )
5757 <script >
58- layui .use ([' form' , ' table' ,' laydate' ], function () {
58+ layui .use ([' form' , ' table' , ' laydate' , ' upload ' ], function () {
5959 var $ = layui .jquery ,
6060 form = layui .form ,
6161 table = layui .table ,
6262 layuimini = layui .layuimini ;
63+ upload = layui .upload ;
6364 laydate = layui .laydate ;
6465 form .render ();
6566
@@ -74,12 +75,15 @@ class="layui-icon"></i> 搜 索
7475 source_type: ' {{ request ()-> input (' source_type' )} }' ,
7576 },
7677 cols: [[
77- {field: ' name' ,title: ' 附件名称' ,sort: true },
78- {field: ' _src' ,title: ' 附件地址' ,},
79- {field: ' _w_h' ,title: ' 尺寸(长度px*宽度px)' ,width: 180 ,},
80- {field: ' _size' ,title: ' 大小' ,width: 100 ,},
81- {field: ' user_id' ,title: ' 记录人' ,width: 180 ,sort: true },
82- {field: ' created_at' ,title: ' 上传时间' ,width: 180 ,sort: true },
78+ {field: ' name' , title: ' 附件名称' , sort: true },
79+ {field: ' _src' , title: ' 附件地址' ,},
80+ {field: ' _w_h' , title: ' 尺寸(长度px*宽度px)' , width: 180 ,},
81+ {field: ' _size' , title: ' 大小' , width: 100 ,},
82+ {field: ' file_md5' , title: ' MD5' , hide: true ,},
83+ {field: ' file_sha1' , title: ' SHA1' , hide: true },
84+ {field: ' user_id' , title: ' 记录人' , width: 180 , sort: true },
85+ {field: ' status' , title: ' 状态' , width: 100 , sort: true },
86+ {field: ' created_at' , title: ' 上传时间' , width: 180 , sort: true },
8387 {title: ' 操作' , width: 100 , templet: ' #currentTableBar' , fixed: " right" , align: " center" }
8488 ]],
8589 limits: [10 , 15 , 20 , 25 , 50 , 100 ],
@@ -90,7 +94,7 @@ class="layui-icon"></i> 搜 索
9094 laydate .render ({
9195 elem: ' #created_at' ,
9296 trigger: ' click'
93- ,range: true
97+ , range: true
9498 });
9599 // 监听搜索操作
96100 form .on (' submit(data-search-btn)' , function (data ) {
@@ -115,7 +119,39 @@ class="layui-icon"></i> 搜 索
115119 table .on (' checkbox(currentTableFilter)' , function (obj ) {
116120 console .log (obj)
117121 });
122+ upload .render ({
123+ elem: ' #file_upload' // 绑定元素
124+ , url: ' {!! get_upload_url (route (' upload.file' ), $attachment ) ! !}' // 上传接口
125+ , accept: ' file'
126+ , done : function (res ) {
127+ // code=0代表上传成功
128+ if (res .code === 0 ) {
129+ top .layer .msg (res .message , {
130+ icon: 1 ,
131+ time: SUCCESS_TIME ,
132+ shade: 0.3
133+ });
134+ setTimeout (function () {
135+ $ (" .layui-form button[type='submit']" ).click ();
136+ }, SUCCESS_TIME )
118137
138+ } else {
139+ top .layer .msg (res .message , {
140+ icon: 2 ,
141+ time: FAIL_TIME ,
142+ shade: 0.3
143+ });
144+ }
145+ }
146+ , error : function () {
147+ // 请求异常回调
148+ top .layer .msg (' 上传接口异常' , {
149+ icon: 2 ,
150+ time: FAIL_TIME ,
151+ shade: 0.3
152+ });
153+ }
154+ });
119155 table .on (' toolbar(currentTableFilter)' , function (obj ) {
120156 console .log (obj);
121157 var data = form .val (" data-search-filter" );
0 commit comments