list_myproject.html 27 KB

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