index2.html 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. {extend name='main'}
  2. {block name="button"}
  3. {if auth("contrast")}
  4. <button class="layui-btn layui-btn-sm " style="background-color: #DC2219 " onclick="getIds()" >去对比</button>
  5. {/if}
  6. {/block}
  7. {block name="content"}
  8. <div class="think-box-shadow">
  9. {include file='child_project/index_search'}
  10. <table class="layui-table margin-top-10">
  11. {notempty name='list'}
  12. <thead>
  13. <tr>
  14. <th class='list-table-check-td think-checkbox'>
  15. <label><input data-auto-none data-check-target='.list-check-box' type='checkbox'></label>
  16. </th>
  17. <th class='text-left nowrap'>项目名称</th>
  18. <th class='text-left nowrap'>主项目</th>
  19. <th class='text-left nowrap'>建筑分类</th>
  20. <th class='text-left nowrap'>创建时间</th>
  21. <th class='text-center nowrap'></th>
  22. </tr>
  23. </thead>
  24. {/notempty}
  25. <tbody>
  26. {foreach $list as $key=>$vo}
  27. <tr>
  28. <td class='list-table-check-td think-checkbox'>
  29. {if $vo.url neq ''} <label><input class="list-check-box" name="ids" value='{$vo.id}' type='checkbox'></label>{/if}
  30. </td>
  31. <td class='text-left nowrap'>{$vo.project_name|default=''}</td>
  32. <td class='text-left nowrap'>{$vo.main_project_name|default='-'}</td>
  33. <td class='text-left nowrap'>{$vo.category_name|default=''}</td>
  34. <td class='text-left nowrap'>{$vo.create_at|format_datetime}</td>
  35. <td class='text-left nowrap'>
  36. {if auth("admin/child_project/import")}
  37. <a class='layui-btn layui-btn-normal layui-btn-sm dr' id="dr" style="background-color:#DC2219;margin-right: 10px;width: 65px " onclick="changename('{$vo.id}')">
  38. {if $vo.url eq ''}待导入{else}重新导入{/if}
  39. </a>
  40. {/if}
  41. {if auth("admin/child_project/edit")}
  42. <a data-dbclick class="layui-btn layui-btn-sm" style="background-color: #FFB822" data-title="编辑" data-open='{:url("edit")}?id={$vo.id}'>编 辑</a>
  43. {/if}
  44. {if $vo.url neq '' && auth("admin/child_project/look")}
  45. <a data-dbclick class="layui-btn layui-btn-sm" style="background-color: #5AD729" data-title="查看" data-open='{:url("admin/child_project/look")}?id={$vo.id}'>查 看</a>
  46. {/if}
  47. {if $vo.url neq '' && auth("admin/child_project/down")}
  48. <a href="{$vo.url}" class="layui-btn layui-btn-sm" style="background-color:#29B2D7 " download data-title="下载" >下 载</a>
  49. {/if}
  50. {if auth("admin/child_project/remove")}
  51. <a class="layui-btn layui-btn-sm layui-btn-danger" style="background-color: #2944D7" data-confirm="确定要删除吗?" data-action="{:url('admin/child_project/remove')}" data-value="id#{$vo.id}" data-csrf="{:systoken('remove')}">删 除</a>
  52. {/if}
  53. </td>
  54. </tr>
  55. {/foreach}
  56. </tbody>
  57. </table>
  58. {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
  59. </div>
  60. <script>
  61. function getIds()
  62. {
  63. var id = document.getElementsByName('ids');
  64. var value = new Array();
  65. for (var i=0;i<id.length;i++){
  66. if (id[i].checked){
  67. value.push(id[i].value);
  68. }
  69. }
  70. if (value.length<1){
  71. layer.msg('请选择需要对比的数据');
  72. }else if (value.length<2){
  73. layer.msg('请选择至少两条数据');
  74. }else{
  75. $.form.href('{:url("admin/child_project/contrast")}?ids=' +value.toString());
  76. //window.location = '{:url("admin/main_project/contrast")}?ids=' +value.toString();
  77. }
  78. }
  79. var project_id = ''
  80. function changename(val){
  81. project_id = val
  82. }
  83. layui.use('upload', function(){
  84. var upload = layui.upload;
  85. //执行实例
  86. var uploadInst = upload.render({
  87. elem: '.dr' //绑定元素
  88. ,url: 'admin/api.plugs/upload'
  89. ,accept: 'file', //普通文件,
  90. before: function(obj){ //obj参数包含的信息,跟 choose回调完全一致,可参见上文。
  91. console.log(obj)
  92. // layer.load(); //上传loading
  93. }
  94. ,done: function(res){
  95. if (res.uploaded == true){
  96. var value = {path:res.key,project_id:project_id,url:res.url}
  97. $.ajax({
  98. url:"/admin/child_project/import",
  99. type:'get',
  100. data:value
  101. ,success:function(result){
  102. console.log(result.code);
  103. if (result.code==1){
  104. layer.msg('上传成功',{time:2000,end:function () {
  105. location.reload();
  106. // $.form.href('{:url("admin/child_project/index")}');
  107. }});
  108. }else {
  109. layer.msg('上传失败',{icon: 5});
  110. }
  111. }
  112. });
  113. }else {
  114. layer.msg('上传失败',{icon: 5});
  115. }
  116. // layer.closeAll('loading'); //关闭loading
  117. }
  118. ,error: function(){
  119. layer.msg('上传失败');
  120. }
  121. });
  122. });
  123. </script>
  124. {/block}