project-file-list.html 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>项目附件列表页面</title>
  5. <!--#include file="common/_header.html"-->
  6. <style>
  7. .table .center{
  8. text-align:center;
  9. }
  10. </style>
  11. </head>
  12. <body>
  13. <nav class="breadcrumb">
  14. <i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 列表
  15. <a class="btn btn-success radius r"
  16. style="line-height: 1.6em; margin-top: 3px"
  17. href="javascript:location.replace(location.href);" title="刷新">
  18. <i class="Hui-iconfont">&#xe68f;</i></a>
  19. </nav>
  20. <div class="page-container">
  21. <div class="text-c">
  22. <form>
  23. <input type="text" class="input-text" style="width: 250px" placeholder="输入项目名称" id="projectName" name="projectName">
  24. <button type="submit" class="btn btn-success" id="btnSearch"><i class="Hui-iconfont">&#xe665;</i> 查询</button>
  25. <button id="btnReset" type="reset" class="btn btn-default"><i class="Hui-iconfont">&#xe68f;</i> 重置</button>
  26. </form>
  27. </div>
  28. <div class="cl pd-5 bg-1 bk-gray" id="hid1" style="display: none;">
  29. <span class="l">
  30. <a href="javascript:batch_del();" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i>批量删除</a>
  31. </span>
  32. </div>
  33. <div class="mt-20">
  34. <table id="grid1" class="table table-border table-bordered table-bg">
  35. <thead>
  36. <tr class="text-c">
  37. <th width="25"><input id="checkAll" type="checkbox" value=""></th>
  38. <th width="90">所属项目</th>
  39. <th width="120">文件名称</th>
  40. <th width="80">缩略图</th>
  41. <th width="60">来源</th>
  42. <th width="80">上传时间</th>
  43. <th width="50">操作</th>
  44. </tr>
  45. </thead>
  46. <tbody>
  47. </tbody>
  48. </table>
  49. </div>
  50. </div>
  51. <!--_footer 作为公共模版分离出去-->
  52. <!--#include file="common/_footer.html"-->
  53. <!--/_footer 作为公共模版分离出去-->
  54. <!--请在下方写此页面业务相关的脚本-->
  55. <script type="text/javascript" src="lib/My97DatePicker/4.8/WdatePicker.js"></script>
  56. <script type="text/javascript" src="lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
  57. <script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
  58. <script id="rowTmpl" type="text/template">
  59. <a href="{{filePath}}{{fileAddress}}" download="{{fileName}}" target="_blank" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe600;</i>下载</a>
  60. <a href="javascript:item_del('{{id}}','{{name}}')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i>删除</a>
  61. </script>
  62. <script id="rowTmpl2" type="text/template">
  63. <a href="{{filePath}}{{fileAddress}}" download="{{fileName}}" target="_blank" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe600;</i>下载</a>
  64. </script>
  65. <script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
  66. <script type="text/javascript" src="scripts/global.js"></script>
  67. <script type="text/javascript">
  68. var path = global_backend_url;
  69. var filePath = file_upload_url;
  70. var projectId = getQueryString("id");
  71. var userStr;
  72. var json;
  73. var roleId;
  74. var allowEdit = false;
  75. $(document).ready(function(){
  76. /***角色权限****/
  77. userStr = sessionStorage.getItem("user");
  78. json = JSON.parse(userStr);
  79. for(var i=0;i<json.adminRoleList.length;i++){
  80. var role = json.adminRoleList[i];
  81. if(role.roleName=='XMF'){
  82. $("#hid1").hide();
  83. break;
  84. }
  85. else if(role.roleName == 'TZCJZX' || role.roleName=='SYSADMIN'){
  86. $("#hid1").show();
  87. allowEdit = true;
  88. break;
  89. }
  90. }
  91. $('#grid1').dataTable({
  92. ajax: {
  93. url: path + "/projectFile/list",
  94. type: 'post',
  95. dataFilter: function(responseText){
  96. var jsonData = JSON.parse(responseText);
  97. // 处理返回json
  98. if(jsonData.result){
  99. return JSON.stringify(jsonData.data);
  100. }
  101. else{
  102. processError(jsonData);
  103. return null;
  104. }
  105. },
  106. data: function(searchParams){
  107. // 查询json
  108. searchParams["projectId"] = projectId;
  109. searchParams["projectName"] = $("#projectName").val();
  110. }
  111. },
  112. serverSide: true,
  113. searching : false,
  114. ordering: false,
  115. columns: [
  116. {data:'fileId'},
  117. {data:'project.title'},
  118. {data:'fileName'},
  119. {data:'fileId'},
  120. {data:'fileSource'},
  121. {data:'createDate'},
  122. {"data":null}
  123. ],
  124. columnDefs: [
  125. {
  126. targets:0,
  127. sClass:'center',
  128. bSortable:false,
  129. render: function (data, type, row) {
  130. return '<input type="checkbox" name="checkItems" value="'+ data + '">';
  131. }
  132. },{
  133. targets:3,
  134. sClass:'center',
  135. bSortable:false,
  136. render: function (data, type, row) {
  137. //var url = filePath + row.fileAddress;
  138. var url = row.realAddress;
  139. if(row.fileType == "JPG" || row.fileType == "PNG" || row.fileType == "GIF"
  140. || row.fileType == "JPEG"){
  141. //return '<img src="' + url + '?x-oss-process=image/resize,m_lfit,h_70,w_50">';
  142. return '<img src="' + url + '" style="width:100px;" onclick=previewImg("' + url + '")>';
  143. }else{
  144. return '无预览';
  145. }
  146. }
  147. },{
  148. targets:4,
  149. sClass:'center',
  150. bSortable:false,
  151. render: function (data, type, row) {
  152. var str = ""
  153. if(row.fileSource == "project"){
  154. str = '联系函';
  155. }else{
  156. str = '现场图片';
  157. }
  158. return str;
  159. }
  160. },{
  161. targets:6,
  162. sClass:'center',
  163. bSortable:false,
  164. render: function (data, type, row) {
  165. var rowStr = "rowTmpl2";
  166. if(allowEdit){
  167. rowStr = "rowTmpl";
  168. }
  169. else{
  170. rowStr = "rowTmpl2";
  171. }
  172. return template(rowStr,{
  173. id: row.fileId,
  174. fileAddress: row.fileAddress,
  175. fileName: row.fileName,
  176. filePath : file_upload_url
  177. });
  178. }
  179. }
  180. ]
  181. });
  182. $("#checkAll").change(function(){
  183. var checked = $(this).is(':checked');
  184. $("input[name='checkItems']").each(function(){
  185. $(this).attr("checked",checked);
  186. });
  187. });
  188. $("#btnSearch").click(function(){
  189. event.preventDefault();
  190. var table = $('#grid1').DataTable();
  191. table.ajax.reload();
  192. });
  193. });
  194. function item_add(){
  195. layer_show("上传","project-file-detail.html",800,600);
  196. }
  197. function item_edit(id){
  198. layer_show("编辑","project-file-detail.html?id=" + id,800,600);
  199. }
  200. function item_del(id){
  201. layer.confirm("是否删除?",{
  202. btns:["是","否"]
  203. },function(){
  204. $.post(path + "/projectFile/delete/" + id,null,function(json){
  205. if(json.result){
  206. layer.msg("删除成功!",{icon:1,time:2000});
  207. reloadList();
  208. }
  209. else{
  210. layer.msg("删除失败!" + json.message);
  211. }
  212. });
  213. });
  214. }
  215. function reloadList(){
  216. $('#grid1').DataTable().ajax.reload(null,false);
  217. }
  218. function batch_del(){
  219. layer.confirm("是否删除选中项?",{
  220. btns:["是","否"]
  221. },function(){
  222. var arr = $("input[name='checkItems']:checked").map(function(){
  223. return $(this).val();
  224. }).get();
  225. $.post(path + "/projectFile/batchDelete",{
  226. ids:arr.join(",")
  227. },function(json){
  228. if(json.result){
  229. layer.msg("删除成功!",{icon:1,time:2000});
  230. reloadList();
  231. }
  232. else{
  233. layer.msg("删除失败!" + json.message);
  234. }
  235. });
  236. })
  237. }
  238. function previewImg(src) {
  239. var img = "<img src='" + src + "' />";
  240. layer.open({
  241. title:'查看图片',
  242. shadeClose:true,
  243. scrollbar :false,
  244. area: 'auto',
  245. maxWidth : '600px',
  246. maxHeight : '600px',
  247. content:img
  248. });
  249. }
  250. </script>
  251. </body>
  252. </html>