add.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  1. {extend name="common/base"/}
  2. {block name="style"}
  3. <style>
  4. .footer{
  5. width: 100%;
  6. height: 25px;
  7. text-align: center;
  8. position: fixed;
  9. bottom: 0;
  10. }
  11. .form-title{
  12. background-color: rgb(241, 241, 241);
  13. color: rgb(95, 95, 95);
  14. border-color: rgb(241, 241, 241);
  15. text-align: center;
  16. border-color: #e2e2e2;
  17. }
  18. .filelist{
  19. width: 100%;
  20. overflow: auto;
  21. justify-content:flex-start;
  22. align-content: space-between;
  23. /* flex-direction: column-reverse; */
  24. flex-wrap: wrap;
  25. display: flex;
  26. }
  27. .filelist li{
  28. padding: 0.5vw 0.7vw 0.5vw 0.7vw;
  29. white-space: nowrap;
  30. overflow: hidden;
  31. text-overflow: ellipsis;
  32. display: inline-block;
  33. border-right: 1px solid #e2e2e2;
  34. }
  35. .filelist p{
  36. margin: 3px 0 5px 0;
  37. width: 8vw;
  38. text-align: center;
  39. overflow: hidden;
  40. text-overflow: ellipsis;
  41. }
  42. .filelist img{
  43. width: 95px;
  44. height: 95px;
  45. }
  46. .form-title {
  47. background-color: rgb(241, 241, 241);
  48. color: rgb(95, 95, 95);
  49. border-color: rgb(241, 241, 241);
  50. font-weight: 600;
  51. }
  52. #tabniubi {
  53. width: 100%;
  54. margin: 10px 0;
  55. background-color: #fff;
  56. color: #5f5f5f;
  57. }
  58. #tabniubi th {
  59. padding: 9px 15px;
  60. min-height: 20px;
  61. height: 40px;
  62. line-height: 40px;
  63. text-align: center;
  64. /* font-size: 14px; */
  65. border-width: 1px;
  66. border-style: solid;
  67. border-color: #e2e2e2;
  68. font: 14px Helvetica Neue, Helvetica, PingFang SC, Tahoma, Arial, sans-serif;
  69. }
  70. #tabniubi tr:first-child {
  71. padding: 0;
  72. min-height: 0;
  73. line-height: 0;
  74. border-width: 0;
  75. border-style: none;
  76. border-color: #fff;
  77. font-size: 0;
  78. }
  79. #tabniubi tr:first-child th {
  80. padding: 0;
  81. min-height: 0;
  82. line-height: 0;
  83. border-width: 0;
  84. border-style: none;
  85. border-color: #fff;
  86. font-size: 0;
  87. }
  88. .forleft {
  89. text-align: left !important;
  90. }
  91. .xm-input{
  92. padding-left: 0 !important;
  93. }
  94. .xm-search{
  95. display: flex;
  96. justify-content: flex-end;
  97. }
  98. </style>
  99. {/block}
  100. <!-- 主体 -->
  101. {block name="body"}
  102. <form class="layui-form p-4">
  103. <h3 class="pb-3">新建造价项目</h3>
  104. <table id="tabniubi" cellpadding="1" cellspacing="1">
  105. <tr>
  106. <th style="width: 10%;height: 0;"></th>
  107. <th style="width: 10%;height: 0;"></th>
  108. <th style="width: 10%;height: 0;"></th>
  109. <th style="width: 10%;height: 0;"></th>
  110. <th style="width: 10%;height: 0;"></th>
  111. <th style="width: 10%;height: 0;"></th>
  112. <th style="width: 10%;height: 0;"></th>
  113. <th style="width: 10%;height: 0;"></th>
  114. <th style="width: 10%;height: 0;"></th>
  115. </tr>
  116. <tr border="1">
  117. <th class="form-title">项目名称 <font style="color: red !important;">*</font></th>
  118. <th colspan="2">
  119. <input type="text" name="project_name" lay-verify="required" lay-reqText="请完善项目名称" value="" autocomplete="off" placeholder="请输入项目名称" class="layui-input">
  120. </th>
  121. <th class="form-title">项目编号 <font style="color: red !important;">*</font></th>
  122. <th colspan="2">
  123. <input type="text" name="project_num" lay-verify="required" lay-reqText="请完善项目编号" value="" autocomplete="off" placeholder="请输入项目编号" class="layui-input">
  124. </th>
  125. <th class="form-title">项目周期 <font style="color: red !important;">*</font></th>
  126. <th id="date" colspan="2">
  127. <div class="layui-input-inline" style="width: 47%;display: inline-flex;">
  128. <input type="text" id="start_time" name="project_start_time" readonly lay-verify="required" lay-reqText="请选择开始时间" placeholder="请选择" class="layui-input" value="">
  129. </div>
  130. -
  131. <div class="layui-input-inline" style="width: 47%;display: inline-flex;">
  132. <input type="text" id="end_time" name="project_end_time" readonly lay-verify="required" lay-reqText="请选择结束时间" placeholder="请选择" class="layui-input" value="">
  133. </div>
  134. </th>
  135. </tr>
  136. <tr>
  137. <th class="form-title">工程类型 <font style="color: red !important;">*</font></th>
  138. <th colspan="2">
  139. <div>
  140. <select name="engineering_type1" lay-verify="required" lay-filter="aihao">
  141. <option value="0"></option>
  142. <option value="1">预算</option>
  143. <option value="2">结算</option>
  144. <option value="3">概算</option>
  145. <option value="4">决算</option>
  146. <option value="5">工程总承包(EPC)</option>
  147. </select>
  148. </div>
  149. </th>
  150. <th class="form-title" style="text-align: center;">——</th>
  151. <th colspan="2">
  152. <div>
  153. <select name="engineering_type2" lay-verify="required" lay-filter="aihao">
  154. <option value=""></option>
  155. <option value="1">审核</option>
  156. <option value="2">编制</option>
  157. </select>
  158. </div>
  159. </th>
  160. <th class="form-title">送审金额 <font style="color: red !important;">*</font></th>
  161. <th colspan="2">
  162. <input type="text" id="sent_review_amount" name="sent_review_amount" autocomplete="off" placeholder="请输入送审金额" class="layui-input">
  163. </th>
  164. </tr>
  165. <tr>
  166. <th class="form-title">评审单位 <font style="color: red !important;">*</font></th>
  167. <th colspan="2">
  168. <input type="text" name="review_unit_name" autocomplete="off" readonly value="" lay-verify="required" lay-reqText="请输入评审单位" placeholder="请输入评审单位" class="layui-input customer-picker">
  169. <input type="hidden" name="review_unit" value="">
  170. </th>
  171. <th class="form-title">审批人 <font style="color: red !important;">*</font></th>
  172. <th colspan="2">
  173. <select name="entrust_approver" lay-verify="required" lay-reqText="请选择审批人">
  174. <option value="">请选择审批人</option>
  175. {volist name="person" id="v"}
  176. <option value="{$v.id}">{$v.nickname}</option>
  177. {/volist}
  178. </select>
  179. </th>
  180. </tr>
  181. <tr>
  182. <th colspan="9" class="forleft">相关附件
  183. <button class="layui-btn layui-btn-xs layui-btn-danger" style="float: right;" type="button"
  184. id="uploadBtn">上传附件
  185. </button>
  186. </th>
  187. </tr>
  188. <tr>
  189. <th colspan="9" class="fujianimg" >
  190. <div id="filesBox2">
  191. <div class="filelist" id="filesBigBox">
  192. <ul id="filesBox">
  193. <div id="nofile" class="layui-data-none">暂无附件</div>
  194. </ul>
  195. </div>
  196. </div>
  197. </th>
  198. </tr>
  199. </table>
  200. <div class="pt-3">
  201. <input type="hidden" name="id" value="0"/>
  202. <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">保存</button>
  203. <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="save">提交</button>
  204. <button type="reset" class="layui-btn layui-btn-primary">重置</button>
  205. </div>
  206. </form>
  207. {/block}
  208. <!-- /主体 -->
  209. <!-- 脚本 -->
  210. {block name="script"}
  211. <script>
  212. var moduleInit = ['tool','oaTool'];
  213. function gouguInit() {
  214. var form = layui.form, tool = layui.tool, oaTool = layui.oaTool;
  215. var file_ids= [];
  216. //日期选择
  217. layui.laydate.render({
  218. elem: '#date',
  219. range: ['#start_time', '#end_time'],
  220. rangeLinked:true
  221. });
  222. let reviewtest;
  223. $('.customer-picker').on('click', function () {
  224. let that = $(this);
  225. let callback = function(data){
  226. console.log(data);
  227. $('[name="review_unit"]').val(data.id);
  228. $('[name="review_unit_name"]').val(data.title);
  229. $('[name="review_head_phone"]').val(data.mobile);
  230. $.ajax({
  231. url: '/admin/project.cost/getemployeelist',
  232. type: 'post',
  233. data: {"id": data.id},
  234. dataType: "json",
  235. async: false,
  236. success: function (msg) {
  237. reviewtest = msg
  238. let str ='<option value="0">无指定人选</option>';
  239. if(data.leader_id!==0){
  240. str = `<option value=${data.leader_id}>${data.nickname}</option>`;
  241. }
  242. for (let i of msg) {
  243. if(data.nickname === i.nickname){
  244. continue
  245. }
  246. //组装数据
  247. str += `<option value='${i.id}'>${i.nickname}</option>`;
  248. }
  249. console.log(msg)
  250. //jquery赋值方式
  251. $("#review_head").html(str);
  252. //重新渲染生效
  253. form.render();
  254. }
  255. });
  256. }
  257. oaTool.customerPicker(callback);
  258. });
  259. form.on('select(reviewselect)', function (data) {
  260. for (let i = 0; i < reviewtest.length; i++){
  261. if (reviewtest[i].id.toString() === data.value){
  262. $('[name="review_head_phone"]').val(reviewtest[i].mobile);
  263. }
  264. }
  265. return false;
  266. });
  267. let f = 1;
  268. //监听提交
  269. form.on('submit(webform)', function (data) {
  270. if(f){
  271. let callback = function (e) {
  272. layer.msg(e.msg);
  273. if (e.code == 0) {
  274. tool.sideClose(1000);
  275. f = 1
  276. }
  277. }
  278. //概算、决算、工程总承包(EPC)
  279. var engineering_type1 ='';
  280. if(data.field.engineering_type1==1){
  281. engineering_type1 ='预算';
  282. }else if(data.field.engineering_type1==2){
  283. engineering_type1 ='结算';
  284. }else if(data.field.engineering_type1==3){
  285. engineering_type1 ='概算';
  286. }else if(data.field.engineering_type1==4){
  287. engineering_type1 ='决算';
  288. }else if(data.field.engineering_type1==5){
  289. engineering_type1 ='工程总承包(EPC)';
  290. }
  291. var engineering_type2 = '';
  292. if(data.field.engineering_type2==1){
  293. engineering_type2 ='审核';
  294. }else if(data.field.engineering_type2==2) {
  295. engineering_type2 = '编制';
  296. }
  297. if(engineering_type1!==""&&engineering_type2!==""){
  298. data.field.engineering_type = engineering_type1 + "-" + engineering_type2;
  299. }
  300. data.field.file_ids = file_ids;
  301. // console.log("???");
  302. tool.post("/admin/project.cost/add", data.field, callback);
  303. }
  304. f = 0
  305. return false;
  306. });
  307. form.on('submit(save)', function (data) {
  308. if(f){
  309. let callback = function (e) {
  310. layer.msg(e.msg);
  311. if (e.code == 0) {
  312. tool.sideClose(1000);
  313. f = 1
  314. }
  315. }
  316. var engineering_type1 ='';
  317. if(data.field.engineering_type1==1){
  318. engineering_type1 ='预算';
  319. }else if(data.field.engineering_type1==2){
  320. engineering_type1 ='结算';
  321. }else if(data.field.engineering_type1==3){
  322. engineering_type1 ='概算';
  323. }else if(data.field.engineering_type1==4){
  324. engineering_type1 ='决算';
  325. }else if(data.field.engineering_type1==5){
  326. engineering_type1 ='工程总承包(EPC)';
  327. }
  328. var engineering_type2 = '';
  329. if(data.field.engineering_type2==1){
  330. engineering_type2 ='审核';
  331. }else if(data.field.engineering_type2==2) {
  332. engineering_type2 = '编制';
  333. }
  334. if(engineering_type1!==""&&engineering_type2!==""){
  335. data.field.engineering_type = engineering_type1 + "-" + engineering_type2;
  336. }
  337. data.field.file_ids = file_ids;
  338. // console.log("!!!");
  339. tool.post("/admin/project.cost/save", data.field, callback);
  340. }
  341. f = 0
  342. return false;
  343. });
  344. //上传文件数组
  345. function fileCard(item){
  346. var host = window.location.host;
  347. var li = '';
  348. if(item.length>0){
  349. for(var a=0;a<item.length;a++){
  350. let image = ['jpg','jpeg','png','gif'];
  351. let doc = ['doc','docx','xls','xlsx','ppt','pptx','txt','pdf','zip','rar','7z'];
  352. // let down = '<a href="'+item[a].filepath+'" target="_blank" class="layui-btn layui-btn-xs layui-btn-normal" download="'+item[a].name+'">下载</a>';
  353. let down ='<a href="' + item[a]['filepath'] + '" target="_blank" class="layui-btn layui-btn-xs layui-btn-normal" download="' + item[a]['name'] + '">预览</a>';
  354. // 判断元素是否在数组中
  355. let path='/static/home/images/icon/file.png';
  356. if (image.includes(item[a].fileext)) {
  357. path=item[a].filepath;
  358. down = '<span data-href="'+item[a].filepath+'" class="layui-btn layui-btn-xs layui-btn-normal file-view-img">预览</span>';
  359. } else if (doc.includes(item[a].fileext)){
  360. path='/static/home/images/icon/'+item[a].fileext+'.png';
  361. }
  362. if(item[a].fileext == 'pdf'){
  363. down = '<span data-href="'+item[a].filepath+'" class="layui-btn layui-btn-xs layui-btn-normal file-view-pdf">预览</span>';
  364. }
  365. 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+
  366. '" style="object-fit: contain;" class="file-item"><p title="'+item[a].name+'">'+item[a].name+
  367. '</p><div class="layui-btn-group">'+ down +
  368. '<span class="layui-btn layui-btn-xs layui-btn-danger file-del">删除</span></div></li>';
  369. }
  370. return li;
  371. }
  372. }
  373. $('#filesBox').on('click','.file-del',function(){
  374. let id = $(this).parent().parent().data('id');
  375. layer.confirm('确定要删除该文件吗?', { icon: 3, title: '提示' }, function () {
  376. layer.closeAll();
  377. var index = file_ids.indexOf(id);
  378. if (index > -1) {
  379. file_ids.splice(index, 1);
  380. }
  381. if(file_ids.length == 0){
  382. $("#filesBox").append('<div id="nofile" class="layui-data-none" >暂无附件</div>');
  383. }
  384. console.log(file_ids);
  385. $("#" + id).remove();
  386. });
  387. })
  388. oaTool.addFile({
  389. type: 1,
  390. isSave: true,
  391. ajaxSave: function (res) {
  392. let callback = function (e) {
  393. if (e.hasOwnProperty("msg")) {
  394. layer.msg(e.msg);
  395. }else{
  396. layer.msg('上传成功!')
  397. }
  398. $('#nofile').remove();
  399. $("#filesBox").append(fileCard(e));
  400. file_ids.push(e[0].id)
  401. }
  402. tool.post("/admin/project.api/add_file", {
  403. 'file_id': res.data.id,
  404. }, callback);
  405. }
  406. });
  407. }
  408. </script>
  409. {/block}
  410. <!-- /脚本 -->