list_deptproject.html 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  1. <!DOCTYPE html>
  2. <html lang="en" xmlns:th="http://www.thymeleaf.org">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  6. <title>项目任务书</title>
  7. <link rel="stylesheet" th:href="@{/lib/layui/css/layui.css}" media="all">
  8. <link rel="stylesheet" th:href="@{/css/public.css}" media="all">
  9. <link rel="stylesheet" th:href="@{/lib/font-awesome-4.7.0/css/font-awesome.min.css}" media="all">
  10. </head>
  11. <body>
  12. <div class="layuimini-container">
  13. <div class="layuimini-main">
  14. <fieldset class="table-search-fieldset">
  15. <legend>搜索信息(<b>收起-展开</b>)</legend>
  16. <div id="search-div" style="margin: 5px 10px -10px 0px">
  17. <form class="layui-form" action="" lay-filter="search-form">
  18. <div class="layui-form-item">
  19. <div class="layui-inline">
  20. <label class="layui-form-label" style="width: 60px">中文名称</label>
  21. <div class="layui-input-inline" style="width: 250px">
  22. <input type="text" name="zwmc" autocomplete="off" class="layui-input">
  23. </div>
  24. </div>
  25. <div class="layui-inline">
  26. <label class="layui-form-label" style="width: 60px">ERP编号</label>
  27. <div class="layui-input-inline" style="width: 150px">
  28. <input type="text" name="erpbh" autocomplete="off" class="layui-input">
  29. </div>
  30. </div>
  31. <div class="layui-inline">
  32. <label class="layui-form-label" style="width: 60px">项目类型</label>
  33. <div class="layui-input-inline" style="width: 150px">
  34. <select name="xmlx" id="xmlx" lay-filter="status">
  35. <option value="">全部</option>
  36. <option th:each="item:${xmlxList}" th:text="${item.name}"
  37. th:value="${item.code}"></option>
  38. </select>
  39. </div>
  40. </div>
  41. <div class="layui-inline">
  42. <label class="layui-form-label" style="width: 60px">审批状态</label>
  43. <div class="layui-input-inline" style="width: 150px">
  44. <select name="spzt" lay-filter="status">
  45. <option value="">全部</option>
  46. <option th:each="item:${dictList}" th:text="${item.name}"
  47. th:value="${item.name}"></option>
  48. </select>
  49. </div>
  50. </div>
  51. <div class="layui-inline" style="margin-left: 0px">
  52. <button type="submit" class="layui-btn" lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
  53. <button type="submit" class="layui-btn layui-btn-primary" lay-submit lay-filter="data-reset-btn"><i class="layui-icon layui-icon-refresh"></i> 重 置 </button>
  54. </div>
  55. </div>
  56. </form>
  57. </div>
  58. </fieldset>
  59. <script type="text/html" id="toolbarDemo">
  60. <div class="layui-btn-container">
  61. <button class="layui-btn layui-btn-sm data-add-btn" lay-event="add">
  62. <i class="layui-icon layui-icon-addition" style="font-size: 10px;"></i>新增
  63. </button>
  64. <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="edit">
  65. <i class="layui-icon layui-icon-edit" style="font-size: 10px;"></i>编辑
  66. </button>
  67. <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="view">
  68. <i class="layui-icon layui-icon-file" style="font-size: 10px;"></i>查看
  69. </button>
  70. <button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="delete">
  71. <i class="layui-icon layui-icon-delete" style="font-size: 10px;"></i>删除
  72. </button>
  73. <button class="layui-btn layui-btn-sm data-add-btn" lay-event="tjApprove">
  74. <i class="layui-icon layui-icon-ok" style="font-size: 10px;"></i>提交审批
  75. </button>
  76. <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="spOption">
  77. <i class="layui-icon layui-icon-edit" style="font-size: 10px;"></i>审核
  78. </button>
  79. <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="spList">
  80. <i class="layui-icon layui-icon-list" style="font-size: 10px;"></i>审批列表
  81. </button>
  82. <button class="layui-btn layui-btn-sm" lay-event="downloadWord">
  83. <i class="layui-icon layui-icon-export" style="font-size: 10px;"></i>导出
  84. </button>
  85. <!-- <button class="layui-btn layui-btn-sm" lay-event="exportExcel">-->
  86. <!-- <i class="layui-icon layui-icon-export" style="font-size: 10px;"></i>导出列表-->
  87. <!-- </button>-->
  88. </div>
  89. </script>
  90. <input type="hidden" id="userId" name="userId" class="layui-input" th:value="${userId}">
  91. <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
  92. <!-- <script type="text/html" id="currentTableBar">-->
  93. <!-- <a class="layui-btn layui-btn-xs layui-btn-warm data-count-view" lay-event="view">-->
  94. <!-- <i class="layui-icon layui-icon-set" style="font-size: 10px;"></i>查看-->
  95. <!-- </a>-->
  96. <!-- <a class="layui-btn layui-btn-xs data-count-update" lay-event="update">-->
  97. <!-- <i class="layui-icon layui-icon-edit" style="font-size: 10px;"></i>编辑-->
  98. <!-- </a>-->
  99. <!-- <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="delFlag">-->
  100. <!-- <i class="layui-icon layui-icon-delete" style="font-size: 10px;"></i>删除-->
  101. <!-- </a>-->
  102. <!-- </script>-->
  103. </div>
  104. </div>
  105. <script th:src="@{/lib/jquery-3.4.1/jquery-3.4.1.min.js}" charset="utf-8"></script>
  106. <script th:src="@{/lib/layui/layui.js}" charset="utf-8"></script>
  107. <script th:src="@{/lib/coco-message/coco-message.js}" charset="utf-8"></script>
  108. <script th:src="@{/js/lay-config.js}" charset="utf-8"></script>
  109. <script th:src="@{/lib/xm-select-v1.2.2/xm-select.js}" charset="utf-8"></script>
  110. <script th:inline="javascript" type="text/javascript">
  111. AjaxUtil.ctx = /*[[@{/}]]*/'';
  112. var updateflag = 0;
  113. var xmApproval = {};
  114. layui.use(['form', 'table'], function () {
  115. var form = layui.form,
  116. table = layui.table;
  117. var userId = $("#userId").val();
  118. var currTable = table.render({
  119. elem: '#currentTableId',
  120. url: AjaxUtil.ctx + 'prjProject/list_deptproject',
  121. method: 'post',
  122. toolbar: '#toolbarDemo',
  123. defaultToolbar: ['filter', 'exports', 'print'],
  124. cols: [
  125. [
  126. {type: "checkbox", fixed: 'left'},
  127. {type: 'numbers', align: 'center'},
  128. {field: 'zwmc', width: '26%', title: '中文名称'},
  129. {field: 'spzt', width: '10%',title: '审批状态', sort: true},
  130. {field: 'erpbh', width: '10%', title: 'ERP编号'},
  131. {field: 'xmlxmc', width: '15%', title: '项目类型'},
  132. {field: 'qs', width: '8%', title: '起始', align: 'center'},
  133. {field: 'wc', width: '8%', title: '完成', align: 'center'},
  134. {field: 'cjrxm', width: '7%', title: '创建人', align: 'center'},
  135. {field: 'cjrq', width: '8%', title: '创建时间', align: 'center'}
  136. // {title: '操作', toolbar: '#currentTableBar', align: 'center', fixed: 'right'}
  137. ]
  138. ],
  139. autoSort: false,
  140. limits: [10, 15, 20, 25, 50, 100],
  141. limit: 10,
  142. page: true,
  143. skin: 'grid',
  144. parseData: function(res){ //res 即为原始返回的数据
  145. return {
  146. "code": res.code, //解析接口状态
  147. "msg": res.message, //解析提示文本
  148. "count": res.data.total, //解析数据长度
  149. "data": res.data.rows //解析数据列表
  150. };
  151. },
  152. done: function(res, curr, count) { // done为数据渲染完的回调
  153. // 测试打印出后端返回的权限列表
  154. // let permissionSet = [[${permissionSet}]];
  155. // console.log(JSON.stringify(permissionSet));
  156. }
  157. });
  158. // 监听搜索操作
  159. form.on('submit(data-search-btn)', function (data) {
  160. // 执行搜索重载
  161. currTable.reload({
  162. page: {
  163. curr: 1 // 页码从1开始
  164. },
  165. where: form.val("search-form")
  166. });
  167. return false;
  168. });
  169. // 监听重置操作
  170. form.on('submit(data-reset-btn)', function (data) {
  171. form.val("search-form", {
  172. "zwmc": '',
  173. "erpbh": '',
  174. "xmlx": '',
  175. "spzt": ''
  176. });
  177. // 执行搜索重载
  178. currTable.reload({
  179. page: {
  180. curr: 1
  181. },
  182. where: form.val("search-form")
  183. });
  184. return false;
  185. });
  186. // 监听排序事件
  187. table.on('sort(currentTableFilter)', function(obj){ //注:sort 是工具条事件名,test 是 table 原始容器的属性 lay-filter="对应的值"
  188. // console.log(obj.field); //当前排序的字段名
  189. // console.log(obj.type); //当前排序类型:desc(降序)、asc(升序)、null(空对象,默认排序)
  190. // console.log(this); //当前排序的 th 对象
  191. //尽管我们的 table 自带排序功能,但并没有请求服务端。
  192. //有些时候,你可能需要根据当前排序的字段,重新向服务端发送请求,从而实现服务端排序,如:
  193. currTable.reload({
  194. initSort: obj, //记录初始排序,如果不设的话,将无法标记表头的排序状态。
  195. where: { //请求参数(注意:这里面的参数可任意定义,并非下面固定的格式)
  196. sortName: toLine(obj.field), //排序字段
  197. sortOrder: toLine(obj.type) //排序方式
  198. }
  199. });
  200. });
  201. // 监听行工具事件
  202. table.on('toolbar(currentTableFilter)', function (obj) {
  203. if (obj.event === 'add') { // 监听添加操作
  204. layer.open({
  205. title: '新建项目任务书',
  206. type: 2,
  207. shade: 0.3,
  208. maxmin: true,
  209. area: ['1090px', layerheight + 'px'],
  210. content: AjaxUtil.ctx + 'prjProject/forAdd',
  211. end: function (index) {
  212. // 重载表格
  213. if(updateflag == 1)
  214. currTable.reload();
  215. updateflag =0;
  216. }
  217. });
  218. // layer.full(index);
  219. }
  220. else if (obj.event == 'edit') {
  221. var projects = table.cache["currentTableId"];
  222. if(projects.length == 0)
  223. return;
  224. var checkStatus = table.checkStatus('currentTableId')
  225. , data = checkStatus.data;
  226. if (data == null || data.length === 0) {
  227. Message.warning("请选择要编辑的任务书!", 1500);
  228. } else if (data.length > 1) {
  229. Message.warning("请选择一条记录进行编辑操作!", 1500);
  230. } else if (data[0].spzt == "审批结束") {
  231. Message.warning("该任务书已审批结束,不能修改!", 1500);
  232. } else if (data[0].spzt != null && data[0].spzt.indexOf("未提交") < 0) {
  233. Message.warning("该任务书审批中,不能修改!", 1500);
  234. } else if (data[0].cjr != userId) {
  235. Message.error("您不是该任务书的创建人!", 1500);
  236. } else {
  237. console.log("修改项目任务书");
  238. layer.open({
  239. title: '修改项目任务书',
  240. type: 2,
  241. shade: 0.3,
  242. maxmin: true,
  243. shadeClose: true,
  244. area: ['1090px', layerheight + 'px'],
  245. content: AjaxUtil.ctx + 'prjProject/forUpdate/' + data[0].id,
  246. end: function (index) {
  247. if(updateflag == 1)
  248. currTable.reload();
  249. updateflag =0;
  250. }
  251. });
  252. // layer.full(index);
  253. }
  254. }
  255. else if (obj.event == 'view') {
  256. var projects = table.cache["currentTableId"];
  257. if(projects.length == 0)
  258. return;
  259. var checkStatus = table.checkStatus('currentTableId')
  260. , data = checkStatus.data;
  261. if (data == null || data.length === 0) {
  262. Message.warning("请选择要查看的任务书!", 1500);
  263. } else if (data.length > 1) {
  264. Message.warning("请选择一条记录进行查看!", 1500);
  265. } else {
  266. layer.open({
  267. title: '查看项目任务书',
  268. type: 2,
  269. shade: 0.3,
  270. maxmin: true,
  271. shadeClose: true,
  272. area: ['1090px', layerheight + 'px'],
  273. content: AjaxUtil.ctx + 'prjProject/forView/' + data[0].id,
  274. end: function (index) {
  275. layer.close(index);
  276. }
  277. });
  278. // layer.full(index);
  279. }
  280. }
  281. else if (obj.event === 'delete') { // 监听删除操作
  282. var projects = table.cache["currentTableId"];
  283. if(projects.length == 0)
  284. return;
  285. var checkStatus = table.checkStatus('currentTableId')
  286. , data = checkStatus.data;
  287. if (data == null || data.length === 0) {
  288. Message.warning("请选择要删除的任务书!", 1000);
  289. return;
  290. } else {
  291. for (let item of data) {
  292. if(item.cjr != userId) {
  293. Message.error("存在您不是创建人的任务书,不能直接删除!", 2000);
  294. return;
  295. }
  296. if(item.spzt != "未提交") {
  297. if(item.spzt == "审批结束")
  298. Message.warning("存在已审批结束的可研报告,不能直接删除!", 2000);
  299. else if (data[0].spzt != null)
  300. Message.warning("存在审批中的可研报告,不能直接删除!", 2000);
  301. return;
  302. }
  303. }
  304. }
  305. layer.confirm('确定批量删除项目任务书吗?', function (index) {
  306. layer.close(index);
  307. AjaxUtil.post({
  308. url: AjaxUtil.ctx + "prjProject/batchDelete",
  309. contentType: "application/json",
  310. data: JSON.stringify(data),
  311. success: function (res) {
  312. if (res.code === 0) {
  313. Message.success(1500, res.message, function () {
  314. // 重载表格
  315. currTable.reload();
  316. });
  317. } else {
  318. Message.error(res.message, 1000);
  319. }
  320. },
  321. error: function (error) {
  322. }
  323. });
  324. });
  325. }
  326. else if (obj.event === 'exportExcel') {
  327. var projects = table.cache["currentTableId"];
  328. if (projects.length == 0)
  329. return;
  330. let a = document.createElement('a');
  331. a.href = AjaxUtil.ctx + 'prjProject/exportExcel';
  332. a.click();
  333. a.parentNode.removeChild(a);
  334. }
  335. else if (obj.event === 'tjApprove') {
  336. var projects = table.cache["currentTableId"];
  337. if (projects.length == 0)
  338. return;
  339. var checkStatus = table.checkStatus('currentTableId')
  340. , data = checkStatus.data;
  341. if (data == null || data.length === 0) {
  342. Message.warning("请选择要提交审批的任务书!", 1500);
  343. } else if (data.length > 1) {
  344. Message.warning("请选择一条记录进行提交!", 1500);
  345. } else if (data[0].spzt == "审批结束") {
  346. Message.warning("该任务书已审批结束!", 1500);
  347. } else if (data[0].spzt != null && data[0].spzt.indexOf("未提交") < 0) {
  348. Message.warning("该任务书正在审批中……", 1500);
  349. } else if (data[0].cjr != userId) {
  350. Message.error("您不是该任务书的创建人!", 1500);
  351. } else {
  352. xmApproval = {
  353. "xmid": data[0].id,
  354. "xm": data[0].zwmc,
  355. "zt": data[0].spzt
  356. };
  357. if(data[0].spzt == null) {
  358. xmApproval.zt = "未提交";
  359. data[0].spzt = "未提交";
  360. }
  361. var content = AjaxUtil.ctx + 'prjProject/forApproveAdd';
  362. if (data[0].spzt != "未提交")
  363. // content = AjaxUtil.ctx + 'prjProject/forApproveUpdate/' + data[0].id + '?spzt=' + data[0].spzt;
  364. content = AjaxUtil.ctx + 'prjProject/forApproveUpdate/' + data[0].id + '/' + data[0].ysje + '?spzt=' + data[0].spzt;
  365. layer.open({
  366. title: '提交审批',
  367. type: 2,
  368. shade: 0.3,
  369. maxmin: true,
  370. shadeClose: true,
  371. area: ['1025px', layerheight + 'px'],
  372. content: content,
  373. end: function (index) {
  374. if (updateflag == 1)
  375. currTable.reload();
  376. updateflag = 0;
  377. }
  378. });
  379. }
  380. }
  381. else if (obj.event === 'spOption') {
  382. var projects = table.cache["currentTableId"];
  383. if (projects.length == 0)
  384. return;
  385. var checkStatus = table.checkStatus('currentTableId')
  386. , data = checkStatus.data;
  387. if (data == null || data.length === 0) {
  388. Message.warning("请选择要审批的任务书!", 1500);
  389. } else if (data.length > 1) {
  390. Message.warning("请选择一条记录进行审批!", 1500);
  391. } else if (data[0].spzt == null || data[0].spzt.indexOf("未提交") >= 0) {
  392. Message.warning("该任务书尚未提交审批!", 1500);
  393. } else if (data[0].spzt == "审批结束") {
  394. Message.warning("该任务书已审批结束!", 1500);
  395. } else {
  396. xmApproval = {
  397. "xmid": data[0].id,
  398. "xm": data[0].zwmc,
  399. "ysje": data[0].ysje
  400. };
  401. layer.open({
  402. title: '审批意见',
  403. type: 2,
  404. shade: 0.3,
  405. maxmin: true,
  406. shadeClose: true,
  407. area: ['1025px', layerheight + 'px'],
  408. content: AjaxUtil.ctx + 'prjProject/forApproveUpdate/' + data[0].id + '/' + data[0].ysje + '?spzt=' + data[0].spzt,
  409. end: function (index) {
  410. if (updateflag == 1)
  411. currTable.reload();
  412. updateflag = 0;
  413. }
  414. });
  415. }
  416. }
  417. else if (obj.event === 'spList') {
  418. var projects = table.cache["currentTableId"];
  419. if (projects.length == 0)
  420. return;
  421. var checkStatus = table.checkStatus('currentTableId')
  422. , data = checkStatus.data;
  423. if (data == null || data.length === 0) {
  424. Message.warning("请选择要查看审批列表的任务书!", 1500);
  425. } else if (data.length > 1) {
  426. Message.warning("请选择一条记录进行查看!", 1500);
  427. } else if (data[0].spzt == null || data[0].spzt == "未提交") {
  428. Message.warning("该任务书尚未提交审批!", 1500);
  429. } else {
  430. xmApproval = {
  431. "xmid": data[0].id,
  432. "xm": data[0].zwmc
  433. };
  434. var index = layer.open({
  435. title: '审批列表',
  436. type: 2,
  437. shade: 0.3,
  438. maxmin: true,
  439. shadeClose: true,
  440. area: ['1300px', layerheight + 'px'],
  441. content: AjaxUtil.ctx + 'prjProject/forApproveList',
  442. end: function () {
  443. layer.close(index);
  444. }
  445. });
  446. }
  447. }
  448. else if (obj.event === 'downloadWord') { // 监听查看操作
  449. var projects = table.cache["currentTableId"];
  450. if (projects.length == 0)
  451. return;
  452. var checkStatus = table.checkStatus('currentTableId')
  453. , data = checkStatus.data;
  454. if (data == null || data.length === 0) {
  455. Message.warning("请选择要导出的任务书!", 1500);
  456. } else if (data.length > 1) {
  457. Message.warning("请选择一条记录进行导出!", 1500)
  458. } else {
  459. layer.confirm('是否确定导出任务书——'+data[0].zwmc+'?', {
  460. btn: ['导出', '取消']
  461. }, function(index, layero){
  462. window.location.href=AjaxUtil.ctx + "prjProject/exportWord/" + data[0].id;
  463. layer.close(index);
  464. }, function(index){
  465. });
  466. }
  467. }
  468. });
  469. //双击
  470. table.on('rowDouble(currentTableFilter)', function (obj) {
  471. var data = obj.data;
  472. layer.open({
  473. title: '查看项目任务书',
  474. type: 2,
  475. shade: 0.3,
  476. maxmin: true,
  477. shadeClose: true,
  478. area: ['1090px', layerheight + 'px'],
  479. content: AjaxUtil.ctx + 'prjProject/forView/' + data.id,
  480. end: function (index) {
  481. layer.close(index);
  482. }
  483. });
  484. // layer.full(index);
  485. });
  486. });
  487. function setUpdateFlag() {
  488. updateflag = 1;
  489. }
  490. function getXmApproval() {
  491. return xmApproval;
  492. }
  493. </script>
  494. </body>
  495. </html>