add.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. {extend name="common/base"/}
  2. {block name="style"}
  3. <style>
  4. .footer{
  5. display: none;
  6. }
  7. #fileBox li{
  8. display: flex;
  9. flex-wrap: wrap;
  10. flex-direction: column;
  11. }
  12. .layui-table th{
  13. text-align: center !important;
  14. font-weight: 500;
  15. }
  16. .layui-anim dd{
  17. text-align: left;
  18. }
  19. .layui-th-gray{
  20. background-color: rgb(241, 241, 241);
  21. }
  22. .layui-table th{
  23. border-color: #e2e2e2
  24. }
  25. .fujian p{
  26. margin: 3px 0 5px 0;
  27. width: 11vw;
  28. overflow: hidden;
  29. text-overflow: ellipsis;
  30. text-align: center;
  31. }
  32. .fujian{
  33. width: auto;
  34. overflow: auto;
  35. justify-content:flex-start;
  36. align-content: space-between;
  37. flex-direction: column-reverse;
  38. flex-wrap: wrap;
  39. display: flex;
  40. }
  41. .fujian li{
  42. padding: 0.5vw 0.8vw 0.5vw 0.8vw;
  43. white-space: nowrap;
  44. overflow: hidden;
  45. text-overflow: ellipsis;
  46. display: inline-block;
  47. border-right: 1px solid #e2e2e2;
  48. float: left;
  49. }
  50. .layui-btn-group{
  51. display: flex;
  52. justify-content: center;
  53. }
  54. </style>
  55. {/block}
  56. {block name="body"}
  57. <form class="layui-form p-4">
  58. <h3 class="pb-3">新建报告</h3>
  59. <table class="layui-table layui-table-form">
  60. <tr>
  61. <th class="layui-th-gray-2" style="background-color: rgb(241, 241, 241);">报告名称 <font style="color: red !important;">*</font></th>
  62. <th colspan="5">
  63. <input type="text" name="title" lay-verify="required" lay-reqText="请输入报告名称"
  64. placeholder="请输入报告名称" class="layui-input" value="">
  65. </th>
  66. <th class="layui-th-gray">报告类型 <font style="color: red !important;">*</font></th>
  67. <th colspan="2">
  68. <select id="projectId" name="type" lay-verify="required">
  69. <option value="">请选择报告类型</option>
  70. <option value="0">初审报告</option>
  71. <option value="1">对数报告</option>
  72. <option value="2">审定报告</option>
  73. </select>
  74. </th>
  75. </tr>
  76. <tr>
  77. <th class="layui-th-gray" style="vertical-align:top;">报告内容 <font style="color: red !important;">*</font></th>
  78. <th colspan="8">
  79. <textarea name="content" placeholder="请输入内容" class="layui-textarea" id="container_content"
  80. style="border:0;padding:0"></textarea>
  81. </th>
  82. </tr>
  83. <tr>
  84. <th class="layui-th-gray">一级审核人 <font style="color: red !important;">*</font></th>
  85. <th colspan="2">
  86. <select name="first" lay-verify="required" lay-reqText="请选择审批人">
  87. <option value="">请选择审核人</option>
  88. {volist name='people' id='vo'}
  89. <option value="{$vo.id}">{$vo.nickname}</option>
  90. {/volist}
  91. </select>
  92. </th>
  93. <th class="layui-th-gray">二级审核人</th>
  94. <th colspan="2">
  95. <select name="second">
  96. <option value="">请选择审核人,可空</option>
  97. {volist name='people' id='vo'}
  98. <option value="{$vo.id}">{$vo.nickname}</option>
  99. {/volist}
  100. </select>
  101. </th>
  102. <th class="layui-th-gray">三级审核人</th>
  103. <th colspan="2">
  104. <select name="third">
  105. <option value="">请选择审核人,可空</option>
  106. {volist name='people' id='vo'}
  107. <option value="{$vo.id}">{$vo.nickname}</option>
  108. {/volist}
  109. </select>
  110. </th>
  111. </tr>
  112. <tr>
  113. <th class="layui-th-gray">四级审核人</th>
  114. <th colspan="2">
  115. <select name="fourth" lay-reqText="请选择审批人">
  116. <option value="">请选择审核人</option>
  117. {volist name='people' id='vo'}
  118. <option value="{$vo.id}">{$vo.nickname}</option>
  119. {/volist}
  120. </select>
  121. </th>
  122. <th class="layui-th-gray">五级级审核人</th>
  123. <th colspan="2">
  124. <select name="fifth">
  125. <option value="">请选择审核人,可空</option>
  126. {volist name='people' id='vo'}
  127. <option value="{$vo.id}">{$vo.nickname}</option>
  128. {/volist}
  129. </select>
  130. </th>
  131. </tr>
  132. </table>
  133. <div class="pt-3">
  134. <input type="hidden" name="id" value=""/>
  135. <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
  136. <button type="reset" class="layui-btn layui-btn-primary">重置</button>
  137. </div>
  138. </form>
  139. <div class="layui-card border-y">
  140. <div class="layui-card-header" style="height:45px;border: 1px solid #e2e2e2;">
  141. <div class="layui-row">
  142. <div class="layui-col-md6">
  143. <strong>项目附件</strong>
  144. </div>
  145. <div class="layui-col-md6" style="text-align:right">
  146. <button type="button" class="layui-btn layui-btn-danger layui-btn-sm" id="uploadBtn">上传附件</button>
  147. </div>
  148. </div>
  149. </div>
  150. <div class="layui-row p-2 fujian" id="fileBox">
  151. <div class="layui-data-none">暂无附件</div>
  152. </div>
  153. </div>
  154. {/block}
  155. <!-- /主体 -->
  156. <!-- 脚本 -->
  157. {block name="script"}
  158. <script>
  159. const moduleInit = ['tool', 'tagpicker', 'tinymce', 'oaTool','employeepicker'];
  160. function gouguInit() {
  161. var form = layui.form, tool = layui.tool, oaTool = layui.oaTool,employeepicker = layui.employeepicker;
  162. var file_id = null;
  163. //编辑器初始化
  164. var editor = layui.tinymce;
  165. var edit = editor.render({
  166. selector: "#container_content",
  167. height: 500
  168. });
  169. let a = 1;
  170. //监听提交
  171. form.on('submit(webform)', function (data) {
  172. data.field.content = tinyMCE.editors['container_content'].getContent();
  173. if (data.field.content == '') {
  174. layer.msg('请先完善文章内容');
  175. return false;
  176. }
  177. if(a){
  178. let callback = function (e) {
  179. parent.layui.reportTable.reload();
  180. layer.msg(e.msg);
  181. if (e.code == 0) {
  182. tool.tabRefresh(71);
  183. tool.sideClose(1000);
  184. } a = 1
  185. }
  186. data.field.file = file_id;
  187. data.field.project_id = '{$project_id}';
  188. // console.log(data.field)
  189. tool.post("/admin/project.report/add_company", data.field, callback);
  190. }
  191. a = 0
  192. return false;
  193. });
  194. function fileCard(item){
  195. var host = window.location.host;
  196. var li = '';
  197. if(item.length>0){
  198. for(var a=0;a<item.length;a++){
  199. let image = ['jpg','jpeg','png','gif'];
  200. let doc = ['doc','docx','xls','xlsx','ppt','pptx','txt','pdf','zip','rar','7z'];
  201. // let down = '<a href="'+item[a].filepath+'" target="_blank" class="layui-btn layui-btn-xs layui-btn-normal" download="'+item[a].name+'">下载</a>';
  202. let down ='<a href="' + item[a]['filepath'] + '" target="_blank" class="layui-btn layui-btn-xs layui-btn-normal" download="' + item[a]['name'] + '">预览</a>';
  203. // 判断元素是否在数组中
  204. let path='/static/home/images/icon/file.png';
  205. if (image.includes(item[a].fileext)) {
  206. path=item[a].filepath;
  207. down = '<span data-href="'+item[a].filepath+'" class="layui-btn layui-btn-xs layui-btn-normal file-view-img">预览</span>';
  208. } else if (doc.includes(item[a].fileext)){
  209. path='/static/home/images/icon/'+item[a].fileext+'.png';
  210. }
  211. if(item[a].fileext == 'pdf'){
  212. down = '<span data-href="'+item[a].filepath+'" class="layui-btn layui-btn-xs layui-btn-normal file-view-pdf">预览</span>';
  213. }
  214. li += '<li id="'+item[a].id+'" data-id="'+item[a].id+'" data-title="'+item[a].name+'" data-ext="'+item[a].fileext+'"><img src="'+path+'" alt="'+item[a].filename+
  215. '" style="object-fit: contain;" class="file-item"><p title="'+item[a].name+'">'+item[a].name+
  216. '</p><div class="layui-btn-group">'+ down +
  217. '<span class="layui-btn layui-btn-xs layui-btn-danger file-del">删除</span></div></li>';
  218. }
  219. return li;
  220. }
  221. }
  222. var emptyCard = ' <div class="layui-data-none">暂无附件</div>'
  223. $('#fileBox').on('click','.file-del',function(){
  224. layer.confirm('确定要删除该文件吗?', { icon: 3, title: '提示' }, function (index) {
  225. layer.closeAll();
  226. file_id = null;
  227. $('#' + file_id).remove();
  228. $("#fileBox").html(emptyCard);
  229. let callback = function (e) {
  230. layer.closeAll();
  231. file_id = null;
  232. layer.msg(e.msg);
  233. $('#' + file_id).remove();
  234. $("#fileBox").html(emptyCard);
  235. }
  236. // tool.delete("/admin/project.report/delete_file", {id:file_id}, callback);
  237. });
  238. })
  239. oaTool.addFile({
  240. type: 1,
  241. isSave: true,
  242. ajaxDelete: function (file_id) {
  243. let callback = function (e) {
  244. layer.msg(e.msg);
  245. var emptyCard = ' <div class="layui-data-none">暂无附件</div>'
  246. file_id = null;
  247. if (e.code == 0) {
  248. $('#fileItem' + file_id).remove();
  249. $("#fileBox").html(emptyCard);
  250. }
  251. }
  252. tool.delete("/admin/project.report/delete_file", {id: file_id}, callback);
  253. },
  254. ajaxSave: function (res) {
  255. let callback = function (e) {
  256. layer.msg('上传成功');
  257. $("#fileBox").html(fileCard(e));
  258. file_id = res.data.id
  259. }
  260. tool.post("/admin/project.report/add_file_company", {
  261. 'file': res.data.id,
  262. }, callback);
  263. }
  264. });
  265. }
  266. </script>
  267. {/block}