index.html 5.8 KB

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