datalist.html 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  1. {extend name="common/base"/}
  2. <!-- 主体 -->
  3. {block name="body"}
  4. <div class="p-3">
  5. <div class="gg-form-bar border-t border-x">
  6. <form id="taskForm" class="layui-form" lay-filter="barsearchform">
  7. <div class="layui-input-inline" style="width:100px;">
  8. <select name="project_status" lay-filter="status">
  9. <option value="">项目状态</option>
  10. <option value="1">立项中</option>
  11. <option value="2">审批中</option>
  12. <option value="3">待接收</option>
  13. <option value="4">分配中</option>
  14. <option value="5">作业中</option>
  15. <option value="6">归档中</option>
  16. <option value="7">退审中</option>
  17. <option value="8">已归档</option>
  18. <option value="9">已退审</option>
  19. </select>
  20. </div>
  21. <div class="layui-input-inline" style="width:100px;">
  22. <select id="province" lay-filter="province" name="province">
  23. <option value="">省</option>
  24. </select>
  25. </div>
  26. <div class="layui-input-inline" style="width:100px;">
  27. <select id="city" lay-filter="city" name="city">
  28. <option value="">市</option>
  29. </select>
  30. </div>
  31. <div class="layui-input-inline" style="width:100px;">
  32. <select id="area" lay-filter="area" name="area">
  33. <option value="">县</option>
  34. </select>
  35. </div>
  36. <div id="time_date" class="layui-input-inline" style="margin: 0;">
  37. <div class="layui-input-inline" style="width:150px;">
  38. <input type="text" id="start_time" name="project_start_time" readonly placeholder="起始日期"
  39. class="layui-input" value="">
  40. </div>
  41. <div class="layui-input-inline">-</div>
  42. <div class="layui-input-inline" style="width:150px;">
  43. <input type="text" id="end_time" name="project_end_time" readonly placeholder="截止日期"
  44. class="layui-input" value="">
  45. </div>
  46. </div>
  47. <div class="layui-input-inline" style="width:200px;">
  48. <input type="text" name="sent_review_unit_name" placeholder="送审单位" class="layui-input"
  49. autocomplete="off"/>
  50. </div>
  51. <div class="layui-input-inline" style="width:200px;">
  52. <input type="text" name="review_unit_name" placeholder="评审机构" class="layui-input"
  53. autocomplete="off"/>
  54. </div>
  55. <div class="layui-input-inline" style="width:200px;">
  56. <input type="text" name="keyword" placeholder="项目名称关键字" class="layui-input" autocomplete="off"/>
  57. </div>
  58. <div class="layui-input-inline" style="width:150px;">
  59. <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform"><i
  60. class="layui-icon layui-icon-search mr-1"></i>搜索
  61. </button>
  62. <button class="layui-btn layui-btn-reset" lay-submit="" lay-filter="reset1">清空</button>
  63. </div>
  64. </form>
  65. </div>
  66. <table class="layui-hide" id="cost_project" lay-filter="cost_project"></table>
  67. </div>
  68. <script type="text/html" id="toolbarDemo">
  69. <div class="layui-btn-container">
  70. <span class="layui-btn layui-btn-sm" lay-event="add" data-title="添加造价项目">+ 添加造价项目</span>
  71. </div>
  72. </script>
  73. <script type="text/html" id="barDemo">
  74. </script>
  75. {/block}
  76. <!-- /主体 -->
  77. <!-- 脚本 -->
  78. {block name="script"}
  79. <script>
  80. const moduleInit = ['tool', 'oaTool'];
  81. const field = {:json_encode($field)};
  82. function gouguInit() {
  83. var table = layui.table, tool = layui.tool, form = layui.form, oaTool = layui.oaTool;
  84. var allcount;
  85. layui.laydate.render({
  86. elem: '#time_date',
  87. range: ['#start_time', '#end_time'],
  88. rangeLinked: true
  89. });
  90. layui.pageTable = table.render({
  91. elem: '#cost_project',
  92. id: "demo",
  93. title: '造价项目列表',
  94. toolbar: '#toolbarDemo',
  95. url: '/admin/project.cost/datalist',
  96. page: true,
  97. limit: 20,
  98. cellMinWidth: 100,
  99. parseData: function (res) { // 数据解析回调函数
  100. // 在这里可以获取数据总数
  101. allcount = res.count;
  102. return {
  103. code: res.code, // 数据状态码
  104. msg: res.msg, // 状态信息
  105. count: res.count, // 数据总数
  106. data: res.data // 当前页数据
  107. };
  108. },
  109. cols: [
  110. [
  111. {
  112. fixed: 'left', field: 'id', title: '编号', align: 'center', width: 80,
  113. templet: function (d) {
  114. return allcount - (d.LAY_NUM - 1);
  115. }
  116. },
  117. {
  118. fixed: 'left',
  119. field: 'project_status',
  120. title: '项目状态',
  121. align: 'center',
  122. width: 100,
  123. hide: field.project_status,
  124. templet: function (item) {
  125. var html = '';
  126. if (item.project_status === 1) {
  127. html = '<span class="layui-badge layui-bg-orange" style="background-color: #ffb800 !important">立项中</span> ';
  128. } else if (item.project_status === 2) {
  129. html = '<span class="layui-badge layui-bg-blue" style="background-color: #b30095 !important">审批中</span> ';
  130. } else if (item.project_status === -1) {
  131. html = '<span class="layui-badge layui-bg-red" style="background-color: #5825aa !important">待修改</span> ';
  132. } else if (item.project_status === 3) {
  133. html = '<span class="layui-badge layui-bg-green" style="background-color: #d37000 !important">待接收</span> ';
  134. } else if (item.project_status === 4) {
  135. html = '<span class="layui-badge" style="background-color: #005fa8 !important">分配中</span> ';
  136. } else if (item.project_status === 5) {
  137. html = '<span class="layui-badge layui-bg-blue" style="background-color: #1e9fff !important">作业中</span> ';
  138. } else if (item.project_status === 6) {
  139. html = '<span class="layui-badge" style="background-color: #007244 !important">归档中</span> ';
  140. } else if (item.project_status === 7) {
  141. html = '<span class="layui-badge" style="background-color: #881f1f !important">退审中</span> ';
  142. } else if (item.project_status === 8) {
  143. html = '<span class="layui-badge" style="background-color: #16b777 !important">已归档</span> ';
  144. } else if (item.project_status === 9) {
  145. html = '<span class="layui-badge" style="background-color: #d81e06 !important">已退审</span> ';
  146. }
  147. return html;
  148. }
  149. },
  150. {
  151. fixed: 'left',
  152. field: 'report_status',
  153. title: '报告状态',
  154. align: 'center',
  155. width: 100,
  156. hide: false,
  157. templet: function (item) {
  158. var html;
  159. if (item.report_status === 0) {
  160. html = '<span>初稿中</span> ';
  161. } else if (item.report_status === 1) {
  162. html = '<span>对数中</span> ';
  163. } else if (item.report_status === 2) {
  164. html = '<span>审定中</span> ';
  165. } else if (item.report_status === 3) {
  166. html = '<span>已审定</span> ';
  167. }else {
  168. html = '<span >未知</span> ';
  169. }
  170. return html;
  171. }
  172. },
  173. {
  174. fixed: 'left',
  175. field: 'project_name',
  176. title: '项目名称',
  177. align: 'center',
  178. width: 400,
  179. hide: field.project_name,
  180. templet: function (d) {
  181. var html = "";
  182. if (d.red) {
  183. //判断是否有新消息,有就有new
  184. html = '<a class="side-a" lay-event="read" lay-event="read">' + d.project_name + ' <span class="layui-badge-dot hongdian"></span></a>';
  185. } else {
  186. html = '<a class="side-a" lay-event="read" lay-event="read">' + d.project_name + '</a>';
  187. }
  188. return '<div style="text-align:left;">' + html + '</div>'
  189. }
  190. },
  191. {
  192. field: 'project_num', title: '项目编号', align: 'center', width: 150, hide: field.project_num,
  193. templet: function (d) {
  194. return '<div style="text-align:left">' + d.project_num + '</div>'
  195. }
  196. },
  197. {
  198. field: 'project_time', title: '项目周期', align: 'center', width: 250, hide: field.project_time,
  199. templet: function (item) {
  200. let outcome = Math.round(new Date().getTime() / 1000).toString();
  201. var advent_time = item.project_end_time - outcome
  202. var time = getDuration(advent_time);
  203. var timestr = "<span style='color: green'>" + "剩余" + time + "</span>";
  204. if (advent_time < 0) {
  205. advent_time = -advent_time;
  206. time = getDuration(advent_time);
  207. timestr = "<span style='color: red'>" + "逾期" + time + "</span>";
  208. }
  209. var html;
  210. if (item.project_status == 8 || item.project_status == 9 ){
  211. html =
  212. "<div>" +
  213. layui.util.toDateString(item.project_start_time * 1000, 'yyyy-MM-dd') +
  214. "至" +
  215. layui.util.toDateString(item.project_end_time * 1000, 'yyyy-MM-dd') +
  216. "</div>";
  217. }else{
  218. html =
  219. "<div>" +
  220. layui.util.toDateString(item.project_start_time * 1000, 'yyyy-MM-dd') +
  221. "至" +
  222. layui.util.toDateString(item.project_end_time * 1000, 'yyyy-MM-dd') +
  223. "&nbsp;&nbsp;" + timestr +
  224. "</div>";
  225. }
  226. function getDuration(second) {
  227. var duration
  228. var days = Math.floor(second / 86400);
  229. var hours = Math.floor((second % 86400) / 3600);
  230. if (days > 0) duration = days + "天";
  231. else if (hours > 0) duration = "不足一天";
  232. else if (hours == 0) duration = "不足一天";
  233. return duration;
  234. }
  235. return html;
  236. }
  237. },
  238. {
  239. field: 'review_unit_name',
  240. title: '评审机构',
  241. align: 'center',
  242. width: 150,
  243. hide: field.review_unit
  244. },
  245. {
  246. field: 'review_head_name',
  247. title: '评审机构负责人',
  248. align: 'center',
  249. width: 150,
  250. hide: field.review_head
  251. },
  252. {
  253. field: 'review_head_phone',
  254. title: '评审机构负责人电话',
  255. align: 'center',
  256. width: 150,
  257. hide: field.review_head_phone,
  258. },
  259. {
  260. field: 'sent_review_unit_name',
  261. title: '送审单位',
  262. align: 'center',
  263. width: 150,
  264. hide: field.sent_review_unit
  265. },
  266. {
  267. field: 'sent_review_head_name',
  268. title: '送审单位负责人',
  269. align: 'center',
  270. width: 150,
  271. hide: field.sent_review_head
  272. },
  273. {
  274. field: 'sent_review_phone',
  275. title: '送审单位负责人电话',
  276. align: 'center',
  277. width: 150,
  278. hide: field.sent_review_phone
  279. },
  280. {
  281. field: 'construction_unit',
  282. title: '施工单位',
  283. align: 'center',
  284. width: 150,
  285. hide: field.construction_unit
  286. },
  287. {
  288. field: 'construction_head',
  289. title: '施工单位负责人',
  290. align: 'center',
  291. width: 150,
  292. hide: field.construction_head
  293. },
  294. {
  295. field: 'construction_phone',
  296. title: '施工单位负责人电话',
  297. align: 'center',
  298. width: 150,
  299. hide: field.construction_phone
  300. },
  301. {field: 'project_scale', title: '项目规模', align: 'center', width: 150, hide: field.project_scale},
  302. {
  303. field: 'engineering_category',
  304. title: '工程类别',
  305. align: 'center',
  306. width: 150,
  307. hide: field.engineering_category
  308. },
  309. {
  310. field: 'engineering_type',
  311. title: '项目类型',
  312. align: 'center',
  313. width: 150,
  314. hide: field.engineering_type
  315. },
  316. {
  317. field: 'project_region',
  318. title: '项目区域',
  319. align: 'center',
  320. width: 150,
  321. hide: field.project_region
  322. },
  323. {field: 'fiscal_nature', title: '财政性质', align: 'center', width: 150, hide: field.fiscal_nature},
  324. {
  325. field: 'sent_review_cost',
  326. title: '送审服务费',
  327. align: 'center',
  328. width: 100,
  329. hide: field.sent_review_cost
  330. },
  331. {
  332. field: 'sent_review_approver_amount',
  333. title: '送审单位承担审核费',
  334. align: 'center',
  335. width: 150,
  336. hide: field.sent_review_approver_amount
  337. },
  338. {
  339. field: 'construction_approver_amount',
  340. title: '施工单位负责核减超5%评审费部分',
  341. align: 'center',
  342. width: 230,
  343. hide: field.construction_approver_amount
  344. },
  345. {
  346. field: 'sent_review_amount',
  347. title: '送审金额',
  348. align: 'center',
  349. width: 150,
  350. hide: field.sent_review_amount
  351. },
  352. {
  353. field: 'authorize_amount',
  354. title: '审定金额',
  355. align: 'center',
  356. width: 150,
  357. hide: field.authorize_amount
  358. },
  359. {
  360. field: 'review_add_amount',
  361. title: '审增额',
  362. align: 'center',
  363. width: 150,
  364. hide: field.review_add_reduce_amount
  365. },
  366. {
  367. field: 'review_reduce_amount',
  368. title: '审减额',
  369. align: 'center',
  370. width: 150,
  371. hide: field.review_add_reduce_amount
  372. },
  373. {
  374. field: 'review_add_reduce_rate',
  375. title: '审增减率',
  376. align: 'center',
  377. width: 150,
  378. hide: field.review_add_reduce_rate
  379. },
  380. {
  381. field: 'report_time',
  382. title: '报告时间',
  383. align: 'center',
  384. width: 150,
  385. hide: field.report_time,
  386. templet: function (d) {
  387. if (d.report_time) {
  388. return layui.util.toDateString(d.report_time * 1000, "yyyy-MM-dd")
  389. } else {
  390. return "";
  391. }
  392. }
  393. },
  394. {
  395. field: 'charge_standard',
  396. title: '收费标准',
  397. align: 'center',
  398. width: 150,
  399. hide: field.charge_standard
  400. },
  401. {
  402. field: 'operate_head_name',
  403. title: '作业负责人',
  404. align: 'center',
  405. width: 150,
  406. hide: field.operate_name
  407. },
  408. {
  409. field: 'operate_team_names',
  410. title: '作业成员',
  411. align: 'center',
  412. width: 300,
  413. hide: field.operate_team_names
  414. },
  415. {
  416. field: 'creator',
  417. title: '创建人',
  418. align: 'center',
  419. width: 150,
  420. },
  421. {
  422. field: 'create_time',
  423. title: '项目创建日期',
  424. align: 'center',
  425. width: 180,
  426. hide: field.create_time,
  427. },
  428. {
  429. field: 'project_dead_time',
  430. title: '项目归档日期',
  431. align: 'center',
  432. width: 120,
  433. hide: field.project_dead_time,
  434. templet: function (d) {
  435. if (d.project_dead_time) {
  436. return layui.util.toDateString(d.project_dead_time * 1000, "yyyy-MM-dd")
  437. } else {
  438. return "";
  439. }
  440. }
  441. },
  442. {
  443. fixed: 'right', field: 'right', title: '操作', width: 136, align: 'center',
  444. templet: function (a) {
  445. var h = '';
  446. // 1全部-可查看可编辑,2全部-可查看,0与我有关
  447. if (a.self_id == 1) {
  448. if (a.project_status == 1) {
  449. h = '<div class="layui-btn-group"><a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a><a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a></div>'
  450. } else {
  451. h = '<div class="layui-btn-group"><a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a></div>'
  452. }
  453. } else if (a.self_id == 2) {
  454. h = '<div class="layui-btn-group"><a class="layui-btn layui-btn-xs layui-bg-blue" lay-event="read">查看</a></div>'
  455. } else if (a.self_id == 0 || a.self_id == 3) {
  456. if (a.project_status == 1) {
  457. h = '<div class="layui-btn-group"><a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a><a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a></div>'
  458. } else {
  459. h = '<div class="layui-btn-group"><a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a></div>'
  460. }
  461. }
  462. return h;
  463. }
  464. }
  465. ]
  466. ]
  467. });
  468. //监听表头工具栏事件
  469. table.on('toolbar(cost_project)', function (obj) {
  470. if (obj.event === 'add') {
  471. tool.side("/admin/project.cost/add");
  472. return false;
  473. }
  474. });
  475. //监听表格行工具事件
  476. table.on('tool(cost_project)', function (obj) {
  477. var data = obj.data;
  478. if (obj.event === 'read') {
  479. tool.side('/admin/project.cost/read?id=' + obj.data.id);
  480. } else if (obj.event === 'edit') {
  481. if (obj.data.project_status < 6) {
  482. tool.side('/admin/project.cost/edit?id=' + obj.data.id);
  483. } else {
  484. layer.msg("已归档/已退审")
  485. }
  486. } else if (obj.event === 'del') {
  487. layer.confirm('确定要删除该记录吗?', {
  488. icon: 3,
  489. title: '提示'
  490. }, function (index) {
  491. if (data.project_status == 1) {
  492. let callback = function (e) {
  493. layer.msg(e.msg);
  494. if (e.code == 0) {
  495. obj.del();
  496. }
  497. }
  498. tool.delete("/admin/project.cost/del", {id: data.id}, callback);
  499. layer.close(index);
  500. } else {
  501. layer.msg("已审核,无法删除");
  502. }
  503. });
  504. }
  505. return false;
  506. });
  507. //监听搜索提交
  508. form.on('submit(webform)', function (data) {
  509. // console.log(data.field)
  510. layui.pageTable.reload({where: data.field});
  511. return false;
  512. });
  513. form.on('submit(reset1)', function () {
  514. $(".layui-form").reset();
  515. layui.pageTable.reload();
  516. return false;
  517. });
  518. layui.use(['form', 'jquery'], function () {
  519. var form = layui.form;
  520. const $ = layui.jquery;
  521. let adress;
  522. $.ajax({
  523. type: "get", //使用get方式
  524. url: "/static/assets/layui/adress.json", //json文件相对于这个HTML的路径
  525. dataType: "json",
  526. async: false,
  527. success: function (data) {
  528. //这个data就是json数据
  529. adress = data
  530. var province = Object.keys(adress)
  531. var proStrs = '<option value="">省</option>';
  532. for (var i = 0; i < province.length; i++) {
  533. proStrs += '<option value="' + province[i] + '">' + province[i] + '</option>';
  534. }
  535. $("#province").html(proStrs);
  536. layui.form.render("select")
  537. },
  538. error: function () {
  539. layer.alert("地址请求失败!! ");
  540. }
  541. });
  542. function getFirstAttr(obj) {
  543. for (var k in obj) return k;
  544. }
  545. function selectOption(selectedProvince, selectedCity = '', selectedArea = '') {
  546. var proStr = '<option value="">省</option>', cityStr = '<option value="">市</option>',
  547. areaStr = '<option value="">县</option>';
  548. var pro = adress[selectedProvince], ci = adress[selectedProvince][selectedCity];
  549. for (var province in adress) {
  550. if (province == selectedProvince) proStr += '<option value="' + province + '" selected>' + province + '</option>';
  551. else proStr += '<option value="' + province + '">' + province + '</option>';
  552. }
  553. $("#province").html(proStr);
  554. for (var city in pro) {
  555. if (city == selectedCity) cityStr += '<option value="' + city + '" selected>' + city + '</option>';
  556. else cityStr += '<option value="' + city + '">' + city + '</option>';
  557. }
  558. $("#city").html(cityStr);
  559. for (var area in ci) {
  560. if (area == "remove") {
  561. continue;
  562. }
  563. if (ci[area] == selectedArea) areaStr += '<option value="' + ci[area] + '" selected>' + ci[area] + '</option>';
  564. else areaStr += '<option value="' + ci[area] + '">' + ci[area] + '</option>';
  565. }
  566. $("#area").html(areaStr);
  567. form.render();
  568. }
  569. /*selectOption(1,2, 3);*/
  570. form.on('select(province)', function (data) {
  571. let thisProvince = data.value;
  572. let thisCity = getFirstAttr(adress[thisProvince]);
  573. selectOption(data.value);
  574. });
  575. form.on('select(city)', function (data) {
  576. selectOption($("#province").val(), data.value, getFirstAttr(data.value));
  577. });
  578. window.hongdianselect = function () {
  579. let num = $(document).find('.hongdian').length
  580. console.log(num, '我是数量')
  581. if (num === 0) {
  582. parent.showhongdian()
  583. console.log('2执行了')
  584. }
  585. }
  586. })
  587. }
  588. </script>
  589. <!--<script src="/static/assets/layui/adress.json"></script>-->
  590. {/block}
  591. <!-- /脚本 -->